maplibre-gl 6.0.0-17 → 6.0.0-19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/maplibre-gl-dev.mjs +325 -26
- package/dist/maplibre-gl-dev.mjs.map +1 -1
- package/dist/maplibre-gl-shared-dev.mjs +719 -542
- package/dist/maplibre-gl-shared-dev.mjs.map +1 -1
- package/dist/maplibre-gl-shared.mjs +2 -2
- package/dist/maplibre-gl-shared.mjs.map +1 -1
- package/dist/maplibre-gl-worker-dev.mjs +2 -2
- package/dist/maplibre-gl-worker.mjs +2 -2
- package/dist/maplibre-gl-worker.mjs.map +1 -1
- package/dist/maplibre-gl.d.ts +6 -0
- package/dist/maplibre-gl.mjs +13 -13
- package/dist/maplibre-gl.mjs.map +1 -1
- package/package.json +15 -16
- package/src/data/dem_data.test.ts +25 -1
- package/src/data/dem_data.ts +45 -4
- package/src/render/painter.test.ts +51 -0
- package/src/render/painter.ts +8 -2
- package/src/render/subdivision.test.ts +48 -47
- package/src/render/terrain.test.ts +1 -3
- package/src/render/terrain.ts +2 -13
- package/src/source/geojson_source.test.ts +64 -0
- package/src/source/geojson_source.ts +14 -5
- package/src/source/vector_tile_source.test.ts +26 -0
- package/src/source/vector_tile_source.ts +1 -1
- package/src/style/style.test.ts +115 -0
- package/src/style/style.ts +10 -3
- package/src/tile/terrain_tile_manager.ts +1 -1
- package/src/tile/tile_id.ts +29 -1
- package/src/ui/map_tests/map_images.test.ts +57 -1
- package/src/util/actor.test.ts +11 -26
- package/src/util/actor.ts +4 -1
- package/src/webgl/draw/draw_background.ts +1 -1
- package/src/webgl/draw/draw_color_relief.ts +1 -1
- package/src/webgl/draw/draw_fill.ts +1 -1
- package/src/webgl/draw/draw_hillshade.ts +1 -1
- package/src/webgl/draw/draw_line.ts +1 -2
- package/src/webgl/draw/draw_raster.ts +1 -1
package/dist/maplibre-gl-dev.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MapLibre GL JS
|
|
3
|
-
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.0.0-
|
|
3
|
+
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.0.0-19/LICENSE.txt
|
|
4
4
|
*/
|
|
5
|
-
import { $n as
|
|
5
|
+
import { $n as findLineIntersection, $r as rotateX$1, $t as validateStyle, A as earthRadius, Ai as isOffscreenCanvasDistorted, Ar as warnOnce, At as SegmentVector, B as evaluateSizeForFeature, Bn as createMat4f64, Br as zero, Bt as isRasterStyleLayer, C as altitudeFromMercatorZ, Ci as scale, Cn as addProtocol, Cr as rollPitchBearingToQuat, Ct as Uniform2f, D as mercatorYfromLat, Di as create$2, Dn as AbortError, Dr as threePlaneIntersection, Dt as UniformColorArray, E as mercatorXfromLng, Ei as fromRotation, En as config, Er as subscribe, Et as UniformColor, F as isBackgroundStyleLayer, Fn as bezier, Fr as create$3, Ft as PosArray, G as ImagePosition, Gn as degreesToRadians, Gr as transformMat4, Gt as EvaluationParameters, Hn as createVec4f64, Hr as slerp, Ht as Properties, I as isSymbolStyleLayer, In as clamp, Ir as length, It as QuadTriangleArray, J as parseGlyphPbf, Jn as easeCubicInOut, Jr as cross, Jt as ZoomHistory, K as potpack, Kn as differenceOfAnglesDegrees, Kr as add, L as SymbolBucket, Ln as clone$2, Lr as scale$1, Lt as RasterBoundsArray, M as createStyleLayer, Mi as Point, Mn as angleToRotateBetweenVectors2D, Mr as zoomScale, Mt as CollisionCircleLayoutArray, N as isCustomStyleLayer, Nn as arrayBufferToImage, Nr as pixelsToTileUnits, Nt as LineStripIndexArray, O as mercatorZfromAltitude, Oi as invert, On as isAbortError, Or as translatePosition, Ot as UniformFloatArray, P as validateCustomStyleLayer, Pn as arrayBufferToImageBitmap, Pr as EXTENT, Pt as Pos3dArray, Qn as filterObject, Qr as normalize, Qt as validateSky, R as addDynamicAttributes, Rn as createIdentityMat4f32, Rr as sqrLen, Rt as TriangleIndexArray, S as MercatorCoordinate, Si as rotateZ, Sn as sameOrigin, Sr as rollPitchBearingEqual, St as Uniform1i, T as lngFromMercatorX, Ti as create$4, Tn as removeProtocol, Tr as sphericalToCartesian, Tt as Uniform4f, U as getAnchorAlignment, Un as deepEqual, Ur as mul, Ut as TRANSITION_SUFFIX, V as evaluateSizeForZoom, Vn as createVec3f64, Vr as fromEuler, Vt as DataConstantProperty, Wn as defaultEasing, Wr as scale$3, Wt as Transitionable, X as collisionCircleLayout, Xn as evaluateZoomSnap, Xr as len, Xt as emitValidationErrors$1, Yn as ensureError, Yr as dot, Z as isLineStyleLayer, Zn as extend, Zr as length$1, Zt as validateLight, _ as OverscaledTileID, _i as multiply, _n as getArrayBuffer, _r as pointPlaneSignedDistance, _t as RGBAImage, a as clipLine, ai as transformMat3, an as diff, ar as isImageBitmap, at as NORTH_POLE_Y, b as compareTileId, bi as rotateX, bn as getVideo, br as readImageUsingVideoFrame, bt as toEvaluationFeature, ci as zero$1, cr as isTouchableEvent, ct as SubdivisionGranularitySetting, di as create$1, dn as v8, dr as lerp, dt as Texture, ei as rotateY, en as Color, er as getAABB, et as isFillExtrusionStyleLayer, f as GEOJSON_TILE_LAYER_NAME, fi as equals, fn as ErrorEvent, fr as mapObject, ft as isHillshadeStyleLayer, g as CanonicalTileID, gi as invert$1, gn as GLOBAL_DISPATCHER_ID, gr as pick, gt as AlphaImage, h as Bounds, hi as identity, hn as AJAXError, hr as parseCacheControl, ht as renderColorRamp, ii as sub, in as derefLayers, ir as getRollPitchBearing, j as Actor, ji as offscreenCanvasSupported, jn as MAX_VALID_LATITUDE, jr as wrap, jt as CollisionBoxArray, k as LngLat, ki as rotate, kn as throwIfAborted, kr as uniqueId, kt as UniformMatrix4f, li as clone$1, ln as interpolateFactory, lr as isTouchableOrPointableType, lt as isColorReliefStyleLayer, mi as fromScaling, mn as Evented, mr as nextPowerOfTwo, mt as isHeatmapStyleLayer, ni as scale$2, nn as ValidationError, nr as getEdgeTiles, oi as transformMat4$1, on as emptyStyle, or as isPointableEvent, ot as SOUTH_POLE_Y, pi as exactEquals, pn as Event, pr as mod, pt as HEATMAP_FULL_RENDER_FBO_KEY, q as renderStyleImage, qn as distanceOfAnglesRadians, qr as clone, qt as codePointUsesLocalIdeographFontFamily, r as TextAnchorEnum, ri as scaleAndAdd, rt as isFillStyleLayer, s as TileCache, si as transformQuat, sn as featureFilter, sr as isSafari, st as SubdivisionGranularityExpression, t as getAnchorJustification, ti as rotateZ$1, tn as ProjectionDefinition, tr as getAngleDelta, u as GeoJSONFeature, ui as copy, un as latest_default, ur as isWorker, v as UnwrappedTileID, vi as ortho, vn as getJSON, vr as radiansToDegrees, vt as isCircleStyleLayer, w as latFromMercatorY, wi as translate, wn as getProtocol, wr as scaleZoom, wt as Uniform3f, x as isInBoundsForZoomLngLat, xi as rotateY$1, xn as makeRequest, xr as remapSaturate, xt as Uniform1f, y as calculateTileKey, yi as perspective, yn as getReferrer, yr as rayPlaneIntersection, yt as polygonIntersectsPolygon, z as getOverlapMode, zn as createIdentityMat4f64, zr as transformMat4$2, zt as createLayout } from "./maplibre-gl-shared-dev.mjs";
|
|
6
6
|
//#region package.json
|
|
7
|
-
var version$2 = "6.0.0-
|
|
7
|
+
var version$2 = "6.0.0-19";
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region src/util/browser.ts
|
|
10
10
|
let linkEl;
|
|
@@ -2577,7 +2577,7 @@ var VectorTileSource = class extends Evented {
|
|
|
2577
2577
|
return result;
|
|
2578
2578
|
} catch (err) {
|
|
2579
2579
|
delete tile.abortController;
|
|
2580
|
-
if (tile.aborted) return;
|
|
2580
|
+
if (tile.aborted || isAbortError(err)) return;
|
|
2581
2581
|
if (err && err.status !== 404) throw err;
|
|
2582
2582
|
this._afterTileLoadWorkerResponse(tile, null);
|
|
2583
2583
|
}
|
|
@@ -3595,13 +3595,19 @@ var GeoJSONSource = class extends Evented {
|
|
|
3595
3595
|
subdivisionGranularity: this.map.style.projection.subdivisionGranularity
|
|
3596
3596
|
};
|
|
3597
3597
|
tile.abortController = new AbortController();
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3598
|
+
try {
|
|
3599
|
+
const data = await (await this.actorPromise).sendAsync({
|
|
3600
|
+
type: message,
|
|
3601
|
+
data: params
|
|
3602
|
+
}, tile.abortController);
|
|
3603
|
+
delete tile.abortController;
|
|
3604
|
+
tile.unloadVectorData();
|
|
3605
|
+
if (!tile.aborted) tile.loadVectorData(data, this.map.painter, message === "RT");
|
|
3606
|
+
} catch (err) {
|
|
3607
|
+
delete tile.abortController;
|
|
3608
|
+
if (tile.aborted || isAbortError(err)) return;
|
|
3609
|
+
throw err;
|
|
3610
|
+
}
|
|
3605
3611
|
}
|
|
3606
3612
|
async abortTile(tile) {
|
|
3607
3613
|
if (tile.abortController) {
|
|
@@ -7736,6 +7742,291 @@ var PauseablePlacement = class {
|
|
|
7736
7742
|
}
|
|
7737
7743
|
};
|
|
7738
7744
|
//#endregion
|
|
7745
|
+
//#region node_modules/kdbush/index.js
|
|
7746
|
+
const ARRAY_TYPES = [
|
|
7747
|
+
Int8Array,
|
|
7748
|
+
Uint8Array,
|
|
7749
|
+
Uint8ClampedArray,
|
|
7750
|
+
Int16Array,
|
|
7751
|
+
Uint16Array,
|
|
7752
|
+
Int32Array,
|
|
7753
|
+
Uint32Array,
|
|
7754
|
+
Float32Array,
|
|
7755
|
+
Float64Array
|
|
7756
|
+
];
|
|
7757
|
+
/** @typedef {Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor} TypedArrayConstructor */
|
|
7758
|
+
/** @typedef {Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array} TypedArray */
|
|
7759
|
+
const VERSION = 1;
|
|
7760
|
+
const HEADER_SIZE = 8;
|
|
7761
|
+
const STACK = /* @__PURE__ */ new Uint32Array(96);
|
|
7762
|
+
var KDBush = class KDBush {
|
|
7763
|
+
/**
|
|
7764
|
+
* Creates an index from raw `ArrayBuffer` data.
|
|
7765
|
+
* @param {ArrayBufferLike} data
|
|
7766
|
+
*/
|
|
7767
|
+
static from(data) {
|
|
7768
|
+
if (!data || data.byteLength === void 0 || data.buffer) throw new Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");
|
|
7769
|
+
const [magic, versionAndType] = new Uint8Array(data, 0, 2);
|
|
7770
|
+
if (magic !== 219) throw new Error("Data does not appear to be in a KDBush format.");
|
|
7771
|
+
const version = versionAndType >> 4;
|
|
7772
|
+
if (version !== VERSION) throw new Error(`Got v${version} data when expected v${VERSION}.`);
|
|
7773
|
+
const ArrayType = ARRAY_TYPES[versionAndType & 15];
|
|
7774
|
+
if (!ArrayType) throw new Error("Unrecognized array type.");
|
|
7775
|
+
const [nodeSize] = new Uint16Array(data, 2, 1);
|
|
7776
|
+
const [numItems] = new Uint32Array(data, 4, 1);
|
|
7777
|
+
return new KDBush(numItems, nodeSize, ArrayType, void 0, data);
|
|
7778
|
+
}
|
|
7779
|
+
/**
|
|
7780
|
+
* Creates an index that will hold a given number of items.
|
|
7781
|
+
* @param {number} numItems
|
|
7782
|
+
* @param {number} [nodeSize=64] Size of the KD-tree node (64 by default).
|
|
7783
|
+
* @param {TypedArrayConstructor} [ArrayType=Float64Array] The array type used for coordinates storage (`Float64Array` by default).
|
|
7784
|
+
* @param {ArrayBufferConstructor | SharedArrayBufferConstructor} [ArrayBufferType=ArrayBuffer] The array buffer type used for storage (`ArrayBuffer` by default).
|
|
7785
|
+
* @param {ArrayBufferLike} [data] (For internal use only)
|
|
7786
|
+
*/
|
|
7787
|
+
constructor(numItems, nodeSize = 64, ArrayType = Float64Array, ArrayBufferType = ArrayBuffer, data) {
|
|
7788
|
+
if (isNaN(numItems) || numItems < 0) throw new Error(`Unexpected numItems value: ${numItems}.`);
|
|
7789
|
+
this.numItems = +numItems;
|
|
7790
|
+
this.nodeSize = Math.min(Math.max(+nodeSize, 2), 65535);
|
|
7791
|
+
this.ArrayType = ArrayType;
|
|
7792
|
+
this.IndexArrayType = numItems < 65536 ? Uint16Array : Uint32Array;
|
|
7793
|
+
const arrayTypeIndex = ARRAY_TYPES.indexOf(this.ArrayType);
|
|
7794
|
+
const coordsByteSize = numItems * 2 * this.ArrayType.BYTES_PER_ELEMENT;
|
|
7795
|
+
const idsByteSize = numItems * this.IndexArrayType.BYTES_PER_ELEMENT;
|
|
7796
|
+
const padCoords = (8 - idsByteSize % 8) % 8;
|
|
7797
|
+
if (arrayTypeIndex < 0) throw new Error(`Unexpected typed array class: ${ArrayType}.`);
|
|
7798
|
+
if (data) {
|
|
7799
|
+
this.data = data;
|
|
7800
|
+
this.ids = new this.IndexArrayType(data, HEADER_SIZE, numItems);
|
|
7801
|
+
this.coords = new ArrayType(data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2);
|
|
7802
|
+
this._pos = numItems * 2;
|
|
7803
|
+
this._finished = true;
|
|
7804
|
+
} else {
|
|
7805
|
+
const data = this.data = new ArrayBufferType(HEADER_SIZE + coordsByteSize + idsByteSize + padCoords);
|
|
7806
|
+
this.ids = new this.IndexArrayType(data, HEADER_SIZE, numItems);
|
|
7807
|
+
this.coords = new ArrayType(data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2);
|
|
7808
|
+
this._pos = 0;
|
|
7809
|
+
this._finished = false;
|
|
7810
|
+
new Uint8Array(data, 0, 2).set([219, (VERSION << 4) + arrayTypeIndex]);
|
|
7811
|
+
new Uint16Array(data, 2, 1)[0] = nodeSize;
|
|
7812
|
+
new Uint32Array(data, 4, 1)[0] = numItems;
|
|
7813
|
+
}
|
|
7814
|
+
}
|
|
7815
|
+
/**
|
|
7816
|
+
* Add a point to the index.
|
|
7817
|
+
* @param {number} x
|
|
7818
|
+
* @param {number} y
|
|
7819
|
+
* @returns {number} An incremental index associated with the added item (starting from `0`).
|
|
7820
|
+
*/
|
|
7821
|
+
add(x, y) {
|
|
7822
|
+
const index = this._pos >> 1;
|
|
7823
|
+
this.ids[index] = index;
|
|
7824
|
+
this.coords[this._pos++] = x;
|
|
7825
|
+
this.coords[this._pos++] = y;
|
|
7826
|
+
return index;
|
|
7827
|
+
}
|
|
7828
|
+
/**
|
|
7829
|
+
* Perform indexing of the added points.
|
|
7830
|
+
*/
|
|
7831
|
+
finish() {
|
|
7832
|
+
const numAdded = this._pos >> 1;
|
|
7833
|
+
if (numAdded !== this.numItems) throw new Error(`Added ${numAdded} items when expected ${this.numItems}.`);
|
|
7834
|
+
sort(this.ids, this.coords, this.nodeSize, 0, this.numItems - 1, 0);
|
|
7835
|
+
this._finished = true;
|
|
7836
|
+
return this;
|
|
7837
|
+
}
|
|
7838
|
+
/**
|
|
7839
|
+
* Search the index for items within a given bounding box.
|
|
7840
|
+
* @param {number} minX
|
|
7841
|
+
* @param {number} minY
|
|
7842
|
+
* @param {number} maxX
|
|
7843
|
+
* @param {number} maxY
|
|
7844
|
+
* @returns {number[]} An array of indices correponding to the found items.
|
|
7845
|
+
*/
|
|
7846
|
+
range(minX, minY, maxX, maxY) {
|
|
7847
|
+
if (!this._finished) throw new Error("Data not yet indexed - call index.finish().");
|
|
7848
|
+
const { ids, coords, nodeSize } = this;
|
|
7849
|
+
STACK[0] = 0;
|
|
7850
|
+
STACK[1] = ids.length - 1;
|
|
7851
|
+
STACK[2] = 0;
|
|
7852
|
+
let sp = 3;
|
|
7853
|
+
const result = [];
|
|
7854
|
+
while (sp > 0) {
|
|
7855
|
+
const axis = STACK[--sp];
|
|
7856
|
+
const right = STACK[--sp];
|
|
7857
|
+
const left = STACK[--sp];
|
|
7858
|
+
if (right - left <= nodeSize) {
|
|
7859
|
+
for (let i = left; i <= right; i++) {
|
|
7860
|
+
const x = coords[2 * i];
|
|
7861
|
+
const y = coords[2 * i + 1];
|
|
7862
|
+
if (x >= minX && x <= maxX && y >= minY && y <= maxY) result.push(ids[i]);
|
|
7863
|
+
}
|
|
7864
|
+
continue;
|
|
7865
|
+
}
|
|
7866
|
+
const m = left + right >> 1;
|
|
7867
|
+
const x = coords[2 * m];
|
|
7868
|
+
const y = coords[2 * m + 1];
|
|
7869
|
+
if (x >= minX && x <= maxX && y >= minY && y <= maxY) result.push(ids[m]);
|
|
7870
|
+
if (axis === 0 ? minX <= x : minY <= y) {
|
|
7871
|
+
STACK[sp++] = left;
|
|
7872
|
+
STACK[sp++] = m - 1;
|
|
7873
|
+
STACK[sp++] = 1 - axis;
|
|
7874
|
+
}
|
|
7875
|
+
if (axis === 0 ? maxX >= x : maxY >= y) {
|
|
7876
|
+
STACK[sp++] = m + 1;
|
|
7877
|
+
STACK[sp++] = right;
|
|
7878
|
+
STACK[sp++] = 1 - axis;
|
|
7879
|
+
}
|
|
7880
|
+
}
|
|
7881
|
+
return result;
|
|
7882
|
+
}
|
|
7883
|
+
/**
|
|
7884
|
+
* Search the index for items within a given radius.
|
|
7885
|
+
* @param {number} qx
|
|
7886
|
+
* @param {number} qy
|
|
7887
|
+
* @param {number} r Query radius.
|
|
7888
|
+
* @returns {number[]} An array of indices correponding to the found items.
|
|
7889
|
+
*/
|
|
7890
|
+
within(qx, qy, r) {
|
|
7891
|
+
const result = [];
|
|
7892
|
+
this.withinInto(qx, qy, r, result);
|
|
7893
|
+
return result;
|
|
7894
|
+
}
|
|
7895
|
+
/**
|
|
7896
|
+
* Search the index for items within a given radius, writing matching ids into `out`
|
|
7897
|
+
* via indexed assignment (`out[i] = id`). Accepts any indexed-writable container —
|
|
7898
|
+
* a typed array sized to the expected upper bound (allocation-free, fast) or a plain
|
|
7899
|
+
* `Array` (which will grow as needed). Returns the number of matches written.
|
|
7900
|
+
* @param {number} qx
|
|
7901
|
+
* @param {number} qy
|
|
7902
|
+
* @param {number} r Query radius.
|
|
7903
|
+
* @param {number[] | TypedArray} out Container to write matching ids into.
|
|
7904
|
+
* @returns {number} The number of matches written to `out`.
|
|
7905
|
+
*/
|
|
7906
|
+
withinInto(qx, qy, r, out) {
|
|
7907
|
+
if (!this._finished) throw new Error("Data not yet indexed - call index.finish().");
|
|
7908
|
+
const { ids, coords, nodeSize } = this;
|
|
7909
|
+
STACK[0] = 0;
|
|
7910
|
+
STACK[1] = ids.length - 1;
|
|
7911
|
+
STACK[2] = 0;
|
|
7912
|
+
let sp = 3;
|
|
7913
|
+
let count = 0;
|
|
7914
|
+
const r2 = r * r;
|
|
7915
|
+
while (sp > 0) {
|
|
7916
|
+
const axis = STACK[--sp];
|
|
7917
|
+
const right = STACK[--sp];
|
|
7918
|
+
const left = STACK[--sp];
|
|
7919
|
+
if (right - left <= nodeSize) {
|
|
7920
|
+
for (let i = left; i <= right; i++) if (sqDist(coords[2 * i], coords[2 * i + 1], qx, qy) <= r2) out[count++] = ids[i];
|
|
7921
|
+
continue;
|
|
7922
|
+
}
|
|
7923
|
+
const m = left + right >> 1;
|
|
7924
|
+
const x = coords[2 * m];
|
|
7925
|
+
const y = coords[2 * m + 1];
|
|
7926
|
+
if (sqDist(x, y, qx, qy) <= r2) out[count++] = ids[m];
|
|
7927
|
+
if (axis === 0 ? qx - r <= x : qy - r <= y) {
|
|
7928
|
+
STACK[sp++] = left;
|
|
7929
|
+
STACK[sp++] = m - 1;
|
|
7930
|
+
STACK[sp++] = 1 - axis;
|
|
7931
|
+
}
|
|
7932
|
+
if (axis === 0 ? qx + r >= x : qy + r >= y) {
|
|
7933
|
+
STACK[sp++] = m + 1;
|
|
7934
|
+
STACK[sp++] = right;
|
|
7935
|
+
STACK[sp++] = 1 - axis;
|
|
7936
|
+
}
|
|
7937
|
+
}
|
|
7938
|
+
return count;
|
|
7939
|
+
}
|
|
7940
|
+
};
|
|
7941
|
+
/**
|
|
7942
|
+
* @param {Uint16Array | Uint32Array} ids
|
|
7943
|
+
* @param {TypedArray} coords
|
|
7944
|
+
* @param {number} nodeSize
|
|
7945
|
+
* @param {number} left
|
|
7946
|
+
* @param {number} right
|
|
7947
|
+
* @param {number} axis
|
|
7948
|
+
*/
|
|
7949
|
+
function sort(ids, coords, nodeSize, left, right, axis) {
|
|
7950
|
+
if (right - left <= nodeSize) return;
|
|
7951
|
+
const m = left + right >> 1;
|
|
7952
|
+
select(ids, coords, m, left, right, axis);
|
|
7953
|
+
sort(ids, coords, nodeSize, left, m - 1, 1 - axis);
|
|
7954
|
+
sort(ids, coords, nodeSize, m + 1, right, 1 - axis);
|
|
7955
|
+
}
|
|
7956
|
+
/**
|
|
7957
|
+
* Custom Floyd-Rivest selection algorithm: sort ids and coords so that
|
|
7958
|
+
* [left..k-1] items are smaller than k-th item (on either x or y axis)
|
|
7959
|
+
* @param {Uint16Array | Uint32Array} ids
|
|
7960
|
+
* @param {TypedArray} coords
|
|
7961
|
+
* @param {number} k
|
|
7962
|
+
* @param {number} left
|
|
7963
|
+
* @param {number} right
|
|
7964
|
+
* @param {number} axis
|
|
7965
|
+
*/
|
|
7966
|
+
function select(ids, coords, k, left, right, axis) {
|
|
7967
|
+
while (right > left) {
|
|
7968
|
+
if (right - left > 600) {
|
|
7969
|
+
const n = right - left + 1;
|
|
7970
|
+
const m = k - left + 1;
|
|
7971
|
+
const z = Math.log(n);
|
|
7972
|
+
const s = .5 * Math.exp(2 * z / 3);
|
|
7973
|
+
const sd = .5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);
|
|
7974
|
+
select(ids, coords, k, Math.max(left, Math.floor(k - m * s / n + sd)), Math.min(right, Math.floor(k + (n - m) * s / n + sd)), axis);
|
|
7975
|
+
}
|
|
7976
|
+
const t = coords[2 * k + axis];
|
|
7977
|
+
let i = left;
|
|
7978
|
+
let j = right;
|
|
7979
|
+
swapItem(ids, coords, left, k);
|
|
7980
|
+
if (coords[2 * right + axis] > t) swapItem(ids, coords, left, right);
|
|
7981
|
+
while (i < j) {
|
|
7982
|
+
swapItem(ids, coords, i, j);
|
|
7983
|
+
i++;
|
|
7984
|
+
j--;
|
|
7985
|
+
while (coords[2 * i + axis] < t) i++;
|
|
7986
|
+
while (coords[2 * j + axis] > t) j--;
|
|
7987
|
+
}
|
|
7988
|
+
if (coords[2 * left + axis] === t) swapItem(ids, coords, left, j);
|
|
7989
|
+
else {
|
|
7990
|
+
j++;
|
|
7991
|
+
swapItem(ids, coords, j, right);
|
|
7992
|
+
}
|
|
7993
|
+
if (j <= k) left = j + 1;
|
|
7994
|
+
if (k <= j) right = j - 1;
|
|
7995
|
+
}
|
|
7996
|
+
}
|
|
7997
|
+
/**
|
|
7998
|
+
* @param {Uint16Array | Uint32Array} ids
|
|
7999
|
+
* @param {TypedArray} coords
|
|
8000
|
+
* @param {number} i
|
|
8001
|
+
* @param {number} j
|
|
8002
|
+
*/
|
|
8003
|
+
function swapItem(ids, coords, i, j) {
|
|
8004
|
+
swap(ids, i, j);
|
|
8005
|
+
swap(coords, 2 * i, 2 * j);
|
|
8006
|
+
swap(coords, 2 * i + 1, 2 * j + 1);
|
|
8007
|
+
}
|
|
8008
|
+
/**
|
|
8009
|
+
* @param {TypedArray} arr
|
|
8010
|
+
* @param {number} i
|
|
8011
|
+
* @param {number} j
|
|
8012
|
+
*/
|
|
8013
|
+
function swap(arr, i, j) {
|
|
8014
|
+
const tmp = arr[i];
|
|
8015
|
+
arr[i] = arr[j];
|
|
8016
|
+
arr[j] = tmp;
|
|
8017
|
+
}
|
|
8018
|
+
/**
|
|
8019
|
+
* @param {number} ax
|
|
8020
|
+
* @param {number} ay
|
|
8021
|
+
* @param {number} bx
|
|
8022
|
+
* @param {number} by
|
|
8023
|
+
*/
|
|
8024
|
+
function sqDist(ax, ay, bx, by) {
|
|
8025
|
+
const dx = ax - bx;
|
|
8026
|
+
const dy = ay - by;
|
|
8027
|
+
return dx * dx + dy * dy;
|
|
8028
|
+
}
|
|
8029
|
+
//#endregion
|
|
7739
8030
|
//#region src/symbol/cross_tile_symbol_index.ts
|
|
7740
8031
|
const roundingFactor = 512 / EXTENT / 2;
|
|
7741
8032
|
var TileLayerIndex = class {
|
|
@@ -12704,6 +12995,7 @@ var Style = class extends Evented {
|
|
|
12704
12995
|
this.tileManagers = {};
|
|
12705
12996
|
this.zoomHistory = new ZoomHistory();
|
|
12706
12997
|
this._availableImages = [];
|
|
12998
|
+
this._imagesListDirty = false;
|
|
12707
12999
|
this._globalState = {};
|
|
12708
13000
|
this._serializedLayers = {};
|
|
12709
13001
|
this.stylesheet = null;
|
|
@@ -12882,8 +13174,8 @@ var Style = class extends Evented {
|
|
|
12882
13174
|
}
|
|
12883
13175
|
this._spritesImagesIds = {};
|
|
12884
13176
|
this._availableImages = this.imageManager.listImages();
|
|
13177
|
+
this._imagesListDirty = true;
|
|
12885
13178
|
this._changed = true;
|
|
12886
|
-
this.dispatcher.broadcast("SI", this._availableImages);
|
|
12887
13179
|
this.fire(new MapStyleDataEvent("data"));
|
|
12888
13180
|
}
|
|
12889
13181
|
_validateLayer(layer) {
|
|
@@ -12952,6 +13244,10 @@ var Style = class extends Evented {
|
|
|
12952
13244
|
if (!this._loaded) return;
|
|
12953
13245
|
const changed = this._changed;
|
|
12954
13246
|
if (changed) {
|
|
13247
|
+
if (this._imagesListDirty) {
|
|
13248
|
+
this.dispatcher.broadcast("SI", this._availableImages);
|
|
13249
|
+
this._imagesListDirty = false;
|
|
13250
|
+
}
|
|
12955
13251
|
const updatedIds = Object.keys(this._updatedLayers);
|
|
12956
13252
|
const removedIds = Object.keys(this._removedLayers);
|
|
12957
13253
|
if (updatedIds.length || removedIds.length) this._updateWorkerLayers(updatedIds, removedIds);
|
|
@@ -13140,8 +13436,8 @@ var Style = class extends Evented {
|
|
|
13140
13436
|
_afterImageUpdated(id) {
|
|
13141
13437
|
this._availableImages = this.imageManager.listImages();
|
|
13142
13438
|
this._changedImages[id] = true;
|
|
13439
|
+
this._imagesListDirty = true;
|
|
13143
13440
|
this._changed = true;
|
|
13144
|
-
this.dispatcher.broadcast("SI", this._availableImages);
|
|
13145
13441
|
this.fire(new MapStyleDataEvent("data"));
|
|
13146
13442
|
}
|
|
13147
13443
|
listImages() {
|
|
@@ -13823,8 +14119,8 @@ var Style = class extends Evented {
|
|
|
13823
14119
|
this.stylesheet.sprite = internalSpriteRepresentation.length > 0 ? internalSpriteRepresentation : void 0;
|
|
13824
14120
|
delete this._spritesImagesIds[id];
|
|
13825
14121
|
this._availableImages = this.imageManager.listImages();
|
|
14122
|
+
this._imagesListDirty = true;
|
|
13826
14123
|
this._changed = true;
|
|
13827
|
-
this.dispatcher.broadcast("SI", this._availableImages);
|
|
13828
14124
|
this.fire(new MapStyleDataEvent("data"));
|
|
13829
14125
|
}
|
|
13830
14126
|
/**
|
|
@@ -16411,7 +16707,7 @@ function drawLineTiles(painter, tileManager, layer, coords, renderOptions, useTe
|
|
|
16411
16707
|
const prevProgram = painter.context.program.get();
|
|
16412
16708
|
const program = painter.useProgram(programId, programConfiguration);
|
|
16413
16709
|
const programChanged = firstTile || program.program !== prevProgram;
|
|
16414
|
-
const terrainData = useTerrain ? painter.
|
|
16710
|
+
const terrainData = useTerrain ? painter.getTerrainDataForTile(coord, isRenderingToTexture) : null;
|
|
16415
16711
|
const constantPattern = patternProperty.constantOr(null);
|
|
16416
16712
|
const constantDasharray = dasharrayProperty?.constantOr(null);
|
|
16417
16713
|
if (constantPattern && tile.imageAtlas) {
|
|
@@ -16549,7 +16845,7 @@ function drawFillTiles(painter, tileManager, layer, coords, depthMode, colorMode
|
|
|
16549
16845
|
if (!bucket) continue;
|
|
16550
16846
|
const programConfiguration = bucket.programConfigurations.get(layer.id);
|
|
16551
16847
|
const program = painter.useProgram(programName, programConfiguration);
|
|
16552
|
-
const terrainData = painter.
|
|
16848
|
+
const terrainData = painter.getTerrainDataForTile(coord, isRenderingToTexture);
|
|
16553
16849
|
if (image) {
|
|
16554
16850
|
painter.context.activeTexture.set(gl.TEXTURE0);
|
|
16555
16851
|
tile.imageAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);
|
|
@@ -16666,7 +16962,7 @@ function renderHillshade(painter, tileManager, layer, coords, stencilModes, dept
|
|
|
16666
16962
|
const fbo = tile.fbo;
|
|
16667
16963
|
if (!fbo) continue;
|
|
16668
16964
|
const mesh = projection.getMeshFromTileID(context, coord.canonical, useBorder, true, "raster");
|
|
16669
|
-
const terrainData = painter.
|
|
16965
|
+
const terrainData = painter.getTerrainDataForTile(coord, isRenderingToTexture);
|
|
16670
16966
|
context.activeTexture.set(gl.TEXTURE0);
|
|
16671
16967
|
gl.bindTexture(gl.TEXTURE_2D, fbo.colorAttachment.get());
|
|
16672
16968
|
const projectionData = transform.getProjectionData({
|
|
@@ -16782,7 +17078,7 @@ function renderColorRelief(painter, tileManager, layer, coords, stencilModes, de
|
|
|
16782
17078
|
tile.demTexture.bind(textureFilter, gl.CLAMP_TO_EDGE);
|
|
16783
17079
|
}
|
|
16784
17080
|
const mesh = projection.getMeshFromTileID(context, coord.canonical, useBorder, true, "raster");
|
|
16785
|
-
const terrainData = painter.
|
|
17081
|
+
const terrainData = painter.getTerrainDataForTile(coord, isRenderingToTexture);
|
|
16786
17082
|
const projectionData = transform.getProjectionData({
|
|
16787
17083
|
overscaledTileID: coord,
|
|
16788
17084
|
aligned: align,
|
|
@@ -16843,7 +17139,7 @@ function drawTiles(painter, tileManager, layer, coords, stencilModes, useBorder,
|
|
|
16843
17139
|
parentTile.texture.bind(textureFilter, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST);
|
|
16844
17140
|
} else tile.texture.bind(textureFilter, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST);
|
|
16845
17141
|
if (tile.texture.useMipmap && context.extTextureFilterAnisotropic && painter.transform.pitch > painter.options.anisotropicFilterPitch) gl.texParameterf(gl.TEXTURE_2D, context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT, context.extTextureFilterAnisotropicMax);
|
|
16846
|
-
const terrainData = painter.
|
|
17142
|
+
const terrainData = painter.getTerrainDataForTile(coord, isRenderingToTexture);
|
|
16847
17143
|
const projectionData = transform.getProjectionData({
|
|
16848
17144
|
overscaledTileID: coord,
|
|
16849
17145
|
aligned: align,
|
|
@@ -16965,7 +17261,7 @@ function drawBackground(painter, tileManager, layer, coords, renderOptions) {
|
|
|
16965
17261
|
tileID,
|
|
16966
17262
|
tileSize
|
|
16967
17263
|
}, crossfade) : backgroundUniformValues(opacity, color);
|
|
16968
|
-
const terrainData = painter.
|
|
17264
|
+
const terrainData = painter.getTerrainDataForTile(tileID, isRenderingToTexture);
|
|
16969
17265
|
const mesh = projection.getMeshFromTileID(context, tileID.canonical, false, true, "raster");
|
|
16970
17266
|
program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.backCCW, uniformValues, terrainData, projectionData, layer.id, mesh.vertexBuffer, mesh.indexBuffer, mesh.segments);
|
|
16971
17267
|
}
|
|
@@ -17489,7 +17785,7 @@ var Painter = class Painter {
|
|
|
17489
17785
|
const program = this.useProgram("clippingMask");
|
|
17490
17786
|
for (const tileID of tileIDs) {
|
|
17491
17787
|
const stencilRef = tileStencilRefs[tileID.key];
|
|
17492
|
-
const terrainData = this.
|
|
17788
|
+
const terrainData = this.getTerrainDataForTile(tileID, renderToTexture);
|
|
17493
17789
|
const mesh = projection.getMeshFromTileID(this.context, tileID.canonical, useBorders, true, "stencil");
|
|
17494
17790
|
const projectionData = transform.getProjectionData({
|
|
17495
17791
|
overscaledTileID: tileID,
|
|
@@ -17502,6 +17798,10 @@ var Painter = class Painter {
|
|
|
17502
17798
|
}, stencilRef, 255, gl.KEEP, gl.KEEP, gl.REPLACE), ColorMode.disabled, renderToTexture ? CullFaceMode.disabled : CullFaceMode.backCCW, null, terrainData, projectionData, "$clipping", mesh.vertexBuffer, mesh.indexBuffer, mesh.segments);
|
|
17503
17799
|
}
|
|
17504
17800
|
}
|
|
17801
|
+
getTerrainDataForTile(tileID, isRenderingToTexture) {
|
|
17802
|
+
if (isRenderingToTexture && this.style.projection?.name === "mercator") return null;
|
|
17803
|
+
return this.style.map.terrain?.getTerrainData(tileID) || null;
|
|
17804
|
+
}
|
|
17505
17805
|
/**
|
|
17506
17806
|
* Fills the depth buffer with the geometry of all supplied tiles.
|
|
17507
17807
|
* Does not change the color buffer or the stencil buffer.
|
|
@@ -17733,7 +18033,7 @@ var Painter = class Painter {
|
|
|
17733
18033
|
doUpdate ||= this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime);
|
|
17734
18034
|
if (!doUpdate) return;
|
|
17735
18035
|
copy(prevMatrix, currMatrix);
|
|
17736
|
-
this.terrainFacilitator.renderTime =
|
|
18036
|
+
this.terrainFacilitator.renderTime = now();
|
|
17737
18037
|
this.terrainFacilitator.depthDirty = false;
|
|
17738
18038
|
this.terrainFacilitator.coordsDirty = true;
|
|
17739
18039
|
this.drawFunctions.terrainDepth(this, this.style.map.terrain);
|
|
@@ -22052,7 +22352,7 @@ var TerrainTileManager = class extends Evented {
|
|
|
22052
22352
|
* @param time - the time
|
|
22053
22353
|
* @returns true if any tiles came into view at or after the specified time
|
|
22054
22354
|
*/
|
|
22055
|
-
anyTilesAfterTime(time =
|
|
22355
|
+
anyTilesAfterTime(time = now()) {
|
|
22056
22356
|
return this._lastTilesetChange >= time;
|
|
22057
22357
|
}
|
|
22058
22358
|
/**
|
|
@@ -22163,8 +22463,7 @@ var Terrain = class {
|
|
|
22163
22463
|
if (!dem) return 0;
|
|
22164
22464
|
const pos = transformMat4$2([], [normalized.x / extent * EXTENT, normalized.y / extent * EXTENT], terrain.u_terrain_matrix);
|
|
22165
22465
|
const coord = [pos[0] * dem.dim, pos[1] * dem.dim];
|
|
22166
|
-
|
|
22167
|
-
return dem.get(cx, cy) * (1 - tx) * (1 - ty) + dem.get(cx + 1, cy) * tx * (1 - ty) + dem.get(cx, cy + 1) * (1 - tx) * ty + dem.get(cx + 1, cy + 1) * tx * ty;
|
|
22466
|
+
return dem.sampleBilinear(coord[0], coord[1]);
|
|
22168
22467
|
}
|
|
22169
22468
|
/**
|
|
22170
22469
|
* Get the elevation for given {@link LngLat} in respect of exaggeration.
|
|
@@ -22234,7 +22533,7 @@ var Terrain = class {
|
|
|
22234
22533
|
const sourceTile = this.tileManager.getSourceTile(tileID, true);
|
|
22235
22534
|
if (sourceTile?.dem && (!sourceTile.demTexture || sourceTile.needsTerrainPrepare)) {
|
|
22236
22535
|
const context = this.painter.context;
|
|
22237
|
-
sourceTile.demTexture
|
|
22536
|
+
sourceTile.demTexture ||= this.painter.getTileTexture(sourceTile.dem.stride);
|
|
22238
22537
|
if (sourceTile.demTexture) sourceTile.demTexture.update(sourceTile.dem.getPixels(), { premultiply: false });
|
|
22239
22538
|
else sourceTile.demTexture = new Texture(context, sourceTile.dem.getPixels(), context.gl.RGBA, { premultiply: false });
|
|
22240
22539
|
sourceTile.demTexture.bind(context.gl.NEAREST, context.gl.CLAMP_TO_EDGE);
|