maplibre-gl 6.1.0 → 6.2.0
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/build/readme.md +0 -2
- package/dist/maplibre-gl-dev.mjs +179 -190
- package/dist/maplibre-gl-dev.mjs.map +1 -1
- package/dist/maplibre-gl-shared-dev.mjs +869 -825
- 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 +14 -12
- package/dist/maplibre-gl-worker-dev.mjs.map +1 -1
- package/dist/maplibre-gl-worker.mjs +2 -2
- package/dist/maplibre-gl-worker.mjs.map +1 -1
- package/dist/maplibre-gl.css +1 -1
- package/dist/maplibre-gl.d.ts +24 -6
- package/dist/maplibre-gl.mjs +13 -13
- package/dist/maplibre-gl.mjs.map +1 -1
- package/package.json +10 -13
- package/src/data/bucket/fill_extrusion_bucket.test.ts +22 -0
- package/src/data/bucket/fill_extrusion_bucket.ts +16 -4
- package/src/data/bucket/round_polygon_corners.test.ts +159 -0
- package/src/data/bucket/round_polygon_corners.ts +121 -0
- package/src/data/bucket/symbol_bucket.test.ts +1 -1
- package/src/data/dem_data.test.ts +23 -23
- package/src/data/feature_position_map.test.ts +1 -1
- package/src/data/segment.test.ts +14 -14
- package/src/geo/bounds.test.ts +4 -4
- package/src/geo/lng_lat_bounds.test.ts +1 -1
- package/src/geo/projection/mercator_transform.test.ts +1 -1
- package/src/geo/projection/mercator_utils.test.ts +8 -8
- package/src/index.test.ts +7 -12
- package/src/render/glyph_manager.test.ts +6 -22
- package/src/render/painter.test.ts +2 -0
- package/src/render/painter.ts +7 -5
- package/src/render/subdivision.test.ts +22 -22
- package/src/render/terrain.test.ts +68 -34
- package/src/render/terrain.ts +69 -26
- package/src/source/canvas_source.test.ts +1 -1
- package/src/source/geojson_source.test.ts +5 -4
- package/src/source/geojson_source_diff.test.ts +2 -2
- package/src/source/geojson_worker_source.test.ts +9 -5
- package/src/source/image_source.test.ts +0 -3
- package/src/source/raster_dem_tile_source.test.ts +2 -2
- package/src/source/raster_tile_source.test.ts +15 -9
- package/src/source/rtl_text_plugin_main_thread.test.ts +14 -14
- package/src/source/source.test.ts +8 -8
- package/src/source/vector_tile_source.test.ts +1 -1
- package/src/source/vector_tile_worker_source.test.ts +7 -5
- package/src/source/worker.test.ts +1 -1
- package/src/source/worker_tile.test.ts +4 -2
- package/src/style/load_glyph_range.test.ts +8 -8
- package/src/style/load_sprite.test.ts +1 -1
- package/src/style/style.test.ts +36 -34
- package/src/style/style_layer/color_relief_style_layer.test.ts +1 -1
- package/src/style/style_layer/fill_extrusion_style_layer.ts +6 -3
- package/src/style/style_layer/raster_style_layer.test.ts +2 -2
- package/src/style/style_layer.test.ts +3 -50
- package/src/symbol/collision_index.test.ts +1 -1
- package/src/symbol/grid_index.test.ts +1 -1
- package/src/tile/terrain_tile_manager.test.ts +2 -2
- package/src/tile/tile_id.test.ts +5 -5
- package/src/tile/tile_manager.test.ts +85 -72
- package/src/tile/tile_manager_in_view_tiles.test.ts +2 -2
- package/src/ui/camera.test.ts +137 -134
- package/src/ui/control/geolocate_control.test.ts +6 -29
- package/src/ui/handler/dblclick_zoom.test.ts +2 -2
- package/src/ui/handler/scroll_zoom.test.ts +2 -0
- package/src/ui/handler_manager.test.ts +7 -7
- package/src/ui/hash.test.ts +1 -0
- package/src/ui/map.ts +28 -18
- package/src/ui/map_tests/map_basic.test.ts +11 -23
- package/src/ui/map_tests/map_calculate_camera_options.test.ts +6 -6
- package/src/ui/map_tests/map_events.test.ts +5 -5
- package/src/ui/map_tests/map_global_state.test.ts +3 -3
- package/src/ui/map_tests/map_images.test.ts +3 -3
- package/src/ui/map_tests/map_is_moving.test.ts +1 -1
- package/src/ui/map_tests/map_is_rotating.test.ts +1 -1
- package/src/ui/map_tests/map_layer.test.ts +2 -1
- package/src/ui/map_tests/map_options.test.ts +1 -5
- package/src/ui/map_tests/map_pitch.test.ts +6 -6
- package/src/ui/map_tests/map_refresh_tiles.test.ts +2 -2
- package/src/ui/map_tests/map_render.test.ts +1 -1
- package/src/ui/map_tests/map_set_lod_params.test.ts +1 -1
- package/src/ui/map_tests/map_style.test.ts +9 -1
- package/src/ui/map_tests/map_terrain.test.ts +20 -0
- package/src/ui/map_tests/map_zoom.test.ts +15 -15
- package/src/ui/marker.test.ts +7 -13
- package/src/ui/popup.test.ts +3 -3
- package/src/util/actor.test.ts +6 -6
- package/src/util/ajax.test.ts +27 -39
- package/src/util/browser.test.ts +7 -9
- package/src/util/create_tile_mesh.test.ts +2 -2
- package/src/util/dispatcher.test.ts +1 -1
- package/src/util/evented.test.ts +4 -1
- package/src/util/fast_maths.test.ts +4 -4
- package/src/util/image_request.test.ts +6 -4
- package/src/util/struct_array.test.ts +2 -2
- package/src/util/task_queue.test.ts +1 -1
- package/src/util/test/util.ts +1 -0
- package/src/util/time_control.test.ts +2 -2
- package/src/util/transferable_grid_index.test.ts +1 -1
- package/src/util/util.test.ts +27 -13
- package/src/util/verticalize_punctuation.test.ts +4 -4
- package/src/util/web_worker_transfer.test.ts +5 -5
- package/src/webgl/draw/draw_custom.test.ts +13 -13
- package/src/webgl/draw/draw_debug.test.ts +1 -1
- package/src/webgl/draw/draw_fill.test.ts +12 -12
- package/src/webgl/draw/draw_symbol.test.ts +16 -16
- package/src/webgl/program.ts +2 -0
- package/src/webgl/render_to_texture.test.ts +5 -5
- package/src/webgl/state.test.ts +1 -1
- package/src/webgl/texture.test.ts +3 -3
- package/src/webgl/vertex_buffer.test.ts +1 -1
- package/build/rolldown_plugins.ts +0 -18
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.
|
|
3
|
+
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.2.0/LICENSE.txt
|
|
4
4
|
*/
|
|
5
|
-
import { $n as
|
|
5
|
+
import { $ as tileCoordinatesToMercatorCoordinates, $n as degreesToRadians, $r as clone, $t as EvaluationParameters, A as getOverlapMode, Ai as scale, An as sameOrigin, Ar as rollPitchBearingToQuat, At as Uniform1i, Bn as angleToRotateBetweenVectors2D, Br as pixelsToTileUnits, Bt as CollisionCircleLayoutArray, C as createStyleLayer, Ci as invert$1, Cn as AJAXError, Cr as pick, Ct as renderColorRamp, D as isSymbolStyleLayer, Di as rotateX, Dn as getReferrer, Dr as readImageUsingVideoFrame, Dt as polygonIntersectsPolygon, E as isBackgroundStyleLayer, Ei as perspective, En as getJSON, Er as rayPlaneIntersection, Et as isCircleStyleLayer, Fi as invert, Fn as AbortError, Fr as translatePosition, Ft as UniformColorArray, G as isFillExtrusionStyleLayer, Gn as clone$2, Gr as sqrLen, Gt as RasterBoundsArray, H as isLineStyleLayer, Hn as arrayBufferToImageBitmap, Hr as create$3, Ht as Pos3dArray, I as ImagePosition, Ii as rotate, In as isAbortError, Ir as uniqueId, It as UniformFloatArray, J as cameraDirectionFromPitchBearing, Jn as createMat4f64, Jr as slerp, Jt as isRasterStyleLayer, Kn as createIdentityMat4f32, Kr as zero, Kt as TriangleIndexArray, L as potpack, Li as isOffscreenCanvasDistorted, Ln as throwIfAborted, Lr as warnOnce, Lt as UniformMatrix4f, M as evaluateSizeForZoom, Mi as create$4, Mn as getProtocol, Mr as sphericalToCartesian, Mt as Uniform3f, Ni as fromRotation, Nn as removeProtocol, Nr as subscribe, Nt as Uniform4f, O as SymbolBucket, Oi as rotateY$1, On as getVideo, Or as remapSaturate, Ot as toEvaluationFeature, P as getAnchorAlignment, Pi as create$2, Pn as config, Pr as threePlaneIntersection, Pt as UniformColor, Q as projectToWorldCoordinates, Qn as defaultEasing, Qr as add, Qt as Transitionable, R as renderStyleImage, Ri as offscreenCanvasSupported, Rr as wrap, Rt as SegmentVector, S as Actor, Si as identity, Sn as Evented, Sr as parseCacheControl, St as isHeatmapStyleLayer, T as validateCustomStyleLayer, Ti as ortho, Tn as getArrayBuffer, Tr as radiansToDegrees, Tt as RGBAImage, Un as bezier, Ur as length, Ut as PosArray, V as collisionCircleLayout, Vn as arrayBufferToImage, Vr as EXTENT, Vt as LineStripIndexArray, Wn as clamp, Wr as scale$1, Wt as QuadTriangleArray, X as getMercatorHorizon, Xn as createVec4f64, Xr as scale$3, Xt as Properties, Y as cameraMercatorCoordinateFromCenterAndRotation, Yn as createVec3f64, Yr as mul, Yt as DataConstantProperty, Z as maxMercatorHorizonAngle, Zn as deepEqual, Zr as transformMat4, Zt as TRANSITION_SUFFIX, _ as OverscaledTileID, _i as copy, _r as isWorker, _t as isColorReliefStyleLayer, a as clipLine, ai as normalize, an as emitValidationErrors, ar as filterObject, at as mercatorXfromLng, b as compareTileId, bi as exactEquals, bn as ErrorEvent, br as mod, bt as isHillshadeStyleLayer, ci as rotateZ$1, cn as validateStyleAndEmit, cr as getAngleDelta, ct as LngLat, di as sub, dn as ValidationError, dr as getRollPitchBearing, dt as isFillStyleLayer, ei as cross, er as differenceOfAnglesDegrees, et as unprojectFromWorldCoordinates, f as GEOJSON_TILE_LAYER_NAME, fi as transformMat3, fr as isImageBitmap, g as CanonicalTileID, gi as clone$1, gn as featureFilter, gr as isTouchableOrPointableType, gt as SubdivisionGranularitySetting, h as Bounds, hi as zero$1, hn as emptyStyle, hr as isTouchableEvent, ht as SubdivisionGranularityExpression, ii as negate, in as SPEC_SOURCE_TYPES, ir as extend, it as lngFromMercatorX, j as evaluateSizeForFeature, ji as translate, jn as addProtocol, jr as scaleZoom, jt as Uniform2f, k as addDynamicAttributes, ki as rotateZ, kn as makeRequest, kr as rollPitchBearingEqual, kt as Uniform1f, li as scale$2, ln as Color, lr as getEdgeTiles, lt as earthRadius, mi as transformQuat, mn as diff, mr as isSafari, mt as SOUTH_POLE_Y, ni as len, nn as ZoomHistory, nr as ensureError, nt as altitudeFromMercatorZ, oi as rotateX$1, on as validateAndEmit, or as findLineIntersection, ot as mercatorYfromLat, pi as transformMat4$1, pn as derefLayers, pr as isPointableEvent, pt as NORTH_POLE_Y, q as calculateTileMatrix, qn as createIdentityMat4f64, qr as fromEuler, qt as createLayout, r as TextAnchorEnum, ri as length$1, rr as evaluateZoomSnap, rt as latFromMercatorY, s as TileCache, si as rotateY, sn as validateStyle, sr as getAABB, st as mercatorZfromAltitude, t as getAnchorJustification, ti as dot, tn as codePointUsesLocalIdeographFontFamily, tr as distanceOfAnglesRadians, tt as MercatorCoordinate, u as GeoJSONFeature, ui as scaleAndAdd, un as ProjectionDefinition, v as UnwrappedTileID, vi as create$1, vn as interpolateFactory, vr as lerp, w as isCustomStyleLayer, wi as multiply, wn as GLOBAL_DISPATCHER_ID, wr as pointPlaneSignedDistance, wt as AlphaImage, x as isInBoundsForZoomLngLat, xi as fromScaling, xn as Event, xr as nextPowerOfTwo, xt as HEATMAP_FULL_RENDER_FBO_KEY, y as calculateTileKey, yi as equals, yn as latest, yr as mapObject, yt as Texture, z as parseGlyphPbf, zi as Point, zn as MAX_VALID_LATITUDE, zr as zoomScale, zt as CollisionBoxArray } from "./maplibre-gl-shared-dev.mjs";
|
|
6
6
|
//#region package.json
|
|
7
|
-
var version$2 = "6.
|
|
7
|
+
var version$2 = "6.2.0";
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region src/util/browser.ts
|
|
10
10
|
let linkEl;
|
|
@@ -709,7 +709,8 @@ async function loadSprite(originalSprite, requestManager, pixelRatio, abortContr
|
|
|
709
709
|
const jsonsMap = {};
|
|
710
710
|
const imagesMap = {};
|
|
711
711
|
for (const { id, url } of spriteArray) {
|
|
712
|
-
|
|
712
|
+
const jsonRequestParameters = await requestManager.transformRequest(normalizeSpriteURL(url, format, ".json"), "SpriteJSON");
|
|
713
|
+
jsonsMap[id] = getJSON(jsonRequestParameters, abortController);
|
|
713
714
|
const imageRequestParameters = await requestManager.transformRequest(normalizeSpriteURL(url, format, ".png"), "SpriteImage");
|
|
714
715
|
imagesMap[id] = ImageRequest.getImage(imageRequestParameters, abortController);
|
|
715
716
|
}
|
|
@@ -940,8 +941,8 @@ var ImageManager = class extends Evented {
|
|
|
940
941
|
if (pattern && pattern.position.version === image.version) return pattern.position;
|
|
941
942
|
if (!pattern) {
|
|
942
943
|
const bin = {
|
|
943
|
-
w: image.data.width +
|
|
944
|
-
h: image.data.height +
|
|
944
|
+
w: image.data.width + 2,
|
|
945
|
+
h: image.data.height + 2,
|
|
945
946
|
x: 0,
|
|
946
947
|
y: 0
|
|
947
948
|
};
|
|
@@ -1061,7 +1062,8 @@ var ImageManager = class extends Evented {
|
|
|
1061
1062
|
async function loadGlyphRange(fontstack, range, urlTemplate, requestManager) {
|
|
1062
1063
|
const begin = range * 256;
|
|
1063
1064
|
const end = begin + 255;
|
|
1064
|
-
const
|
|
1065
|
+
const request = await requestManager.transformRequest(urlTemplate.replace("{fontstack}", fontstack).replace("{range}", `${begin}-${end}`), "Glyphs");
|
|
1066
|
+
const response = await getArrayBuffer(request, new AbortController());
|
|
1065
1067
|
if (!response?.data) throw new Error(`Could not load glyph range. range: ${range}, ${begin}-${end}`);
|
|
1066
1068
|
const glyphs = {};
|
|
1067
1069
|
for (const glyph of parseGlyphPbf(response.data)) glyphs[glyph.id] = glyph;
|
|
@@ -1280,7 +1282,9 @@ var GlyphManager = class GlyphManager {
|
|
|
1280
1282
|
}
|
|
1281
1283
|
_warnOnMissingGlyphRange(glyph, range, id, err) {
|
|
1282
1284
|
const begin = range * 256;
|
|
1283
|
-
|
|
1285
|
+
const end = begin + 255;
|
|
1286
|
+
const codePoint = id.toString(16).padStart(4, "0").toUpperCase();
|
|
1287
|
+
warnOnce(`Unable to load glyph range ${range}, ${begin}-${end}. Rendering codepoint U+${codePoint} locally instead. ${err}`);
|
|
1284
1288
|
}
|
|
1285
1289
|
/**
|
|
1286
1290
|
* Returns whether the given codepoint should be rendered locally.
|
|
@@ -1315,8 +1319,8 @@ var GlyphManager = class GlyphManager {
|
|
|
1315
1319
|
return {
|
|
1316
1320
|
id,
|
|
1317
1321
|
bitmap: new AlphaImage({
|
|
1318
|
-
width: char.width ||
|
|
1319
|
-
height: char.height ||
|
|
1322
|
+
width: char.width || 60,
|
|
1323
|
+
height: char.height || 60
|
|
1320
1324
|
}, char.data),
|
|
1321
1325
|
metrics: {
|
|
1322
1326
|
width: isControl ? 0 : char.glyphWidth / textureScale || 24,
|
|
@@ -1332,7 +1336,7 @@ var GlyphManager = class GlyphManager {
|
|
|
1332
1336
|
const fontFamilies = stack ? stack.split(",") : [];
|
|
1333
1337
|
fontFamilies.push(defaultGenericFontFamily);
|
|
1334
1338
|
const fontFamily = fontFamilies.map((fontName) => /[-\w]+/.test(fontName) ? fontName : `'${CSS.escape(fontName)}'`).join(",");
|
|
1335
|
-
const fontSize =
|
|
1339
|
+
const fontSize = 48;
|
|
1336
1340
|
const fontWeight = this._fontWeight(fontFamilies[0]);
|
|
1337
1341
|
const fontStyle = this._fontStyle(fontFamilies[0]);
|
|
1338
1342
|
if (typeof document !== "undefined" && document.fonts?.load) try {
|
|
@@ -1342,8 +1346,8 @@ var GlyphManager = class GlyphManager {
|
|
|
1342
1346
|
}
|
|
1343
1347
|
return new GlyphManager.TinySDF({
|
|
1344
1348
|
fontSize,
|
|
1345
|
-
buffer:
|
|
1346
|
-
radius:
|
|
1349
|
+
buffer: 6,
|
|
1350
|
+
radius: 16,
|
|
1347
1351
|
cutoff: .25,
|
|
1348
1352
|
fontFamily,
|
|
1349
1353
|
fontWeight,
|
|
@@ -3185,9 +3189,7 @@ function getGeoJSONBounds(data) {
|
|
|
3185
3189
|
case "Feature":
|
|
3186
3190
|
coordinates = getCoordinatesFromGeometry(data.geometry);
|
|
3187
3191
|
break;
|
|
3188
|
-
default:
|
|
3189
|
-
coordinates = getCoordinatesFromGeometry(data);
|
|
3190
|
-
break;
|
|
3192
|
+
default: coordinates = getCoordinatesFromGeometry(data);
|
|
3191
3193
|
}
|
|
3192
3194
|
if (coordinates.length === 0) return bounds;
|
|
3193
3195
|
for (const coordinate of coordinates) {
|
|
@@ -3902,9 +3904,11 @@ var ImageSource = class extends Evented {
|
|
|
3902
3904
|
const maxTileY = Math.floor(maxY * tilesAtZoom);
|
|
3903
3905
|
const minTileXWrapped = (minTileX % tilesAtZoom + tilesAtZoom) % tilesAtZoom;
|
|
3904
3906
|
const maxTileXWrapped = maxTileX % tilesAtZoom;
|
|
3907
|
+
const minWrap = Math.floor(minTileX / tilesAtZoom);
|
|
3908
|
+
const maxWrap = Math.floor(maxTileX / tilesAtZoom);
|
|
3905
3909
|
ranges[z] = {
|
|
3906
|
-
minWrap
|
|
3907
|
-
maxWrap
|
|
3910
|
+
minWrap,
|
|
3911
|
+
maxWrap,
|
|
3908
3912
|
minTileXWrapped,
|
|
3909
3913
|
maxTileXWrapped,
|
|
3910
3914
|
minTileY,
|
|
@@ -4564,7 +4568,8 @@ var Tile = class {
|
|
|
4564
4568
|
const evaluationFeature = toEvaluationFeature(feature, true);
|
|
4565
4569
|
if (!filter.filter(new EvaluationParameters(this.tileID.overscaledZ), evaluationFeature, this.tileID.canonical)) continue;
|
|
4566
4570
|
} else if (!filter.filter(new EvaluationParameters(this.tileID.overscaledZ), feature)) continue;
|
|
4567
|
-
const
|
|
4571
|
+
const id = featureIndex.getId(feature, sourceLayer);
|
|
4572
|
+
const geojsonFeature = new GeoJSONFeature(feature, z, x, y, id);
|
|
4568
4573
|
geojsonFeature.tile = coord;
|
|
4569
4574
|
result.push(geojsonFeature);
|
|
4570
4575
|
}
|
|
@@ -4755,86 +4760,6 @@ var SourceFeatureState = class {
|
|
|
4755
4760
|
}
|
|
4756
4761
|
};
|
|
4757
4762
|
//#endregion
|
|
4758
|
-
//#region src/geo/projection/mercator_utils.ts
|
|
4759
|
-
const maxMercatorHorizonAngle = 89.25;
|
|
4760
|
-
/**
|
|
4761
|
-
* Returns mercator coordinates in range 0..1 for given coordinates inside a specified tile.
|
|
4762
|
-
* @param inTileX - X coordinate in tile units - range [0..EXTENT].
|
|
4763
|
-
* @param inTileY - Y coordinate in tile units - range [0..EXTENT].
|
|
4764
|
-
* @param canonicalTileID - Tile canonical ID - mercator X, Y and zoom.
|
|
4765
|
-
* @returns Mercator coordinates of the specified point in range [0..1].
|
|
4766
|
-
*/
|
|
4767
|
-
function tileCoordinatesToMercatorCoordinates(inTileX, inTileY, canonicalTileID) {
|
|
4768
|
-
const scale = 1 / (1 << canonicalTileID.z);
|
|
4769
|
-
return new MercatorCoordinate(inTileX / EXTENT * scale + canonicalTileID.x * scale, inTileY / EXTENT * scale + canonicalTileID.y * scale);
|
|
4770
|
-
}
|
|
4771
|
-
/**
|
|
4772
|
-
* Convert from LngLat to world coordinates (Mercator coordinates scaled by world size).
|
|
4773
|
-
* @param worldSize - Mercator world size computed from zoom level and tile size.
|
|
4774
|
-
* @param lnglat - The location to convert.
|
|
4775
|
-
* @returns Point
|
|
4776
|
-
*/
|
|
4777
|
-
function projectToWorldCoordinates(worldSize, lnglat) {
|
|
4778
|
-
const lat = clamp(lnglat.lat, -MAX_VALID_LATITUDE, MAX_VALID_LATITUDE);
|
|
4779
|
-
return new Point(mercatorXfromLng(lnglat.lng) * worldSize, mercatorYfromLat(lat) * worldSize);
|
|
4780
|
-
}
|
|
4781
|
-
/**
|
|
4782
|
-
* Convert from world coordinates (mercator coordinates scaled by world size) to LngLat.
|
|
4783
|
-
* @param worldSize - Mercator world size computed from zoom level and tile size.
|
|
4784
|
-
* @param point - World coordinate.
|
|
4785
|
-
* @returns LngLat
|
|
4786
|
-
*/
|
|
4787
|
-
function unprojectFromWorldCoordinates(worldSize, point) {
|
|
4788
|
-
return new MercatorCoordinate(point.x / worldSize, point.y / worldSize).toLngLat();
|
|
4789
|
-
}
|
|
4790
|
-
/**
|
|
4791
|
-
* Calculate pixel height of the visible horizon in relation to map-center (e.g. height/2),
|
|
4792
|
-
* multiplied by a static factor to simulate the earth-radius.
|
|
4793
|
-
* The calculated value is the horizontal line from the camera-height to sea-level.
|
|
4794
|
-
* @returns Horizon above center in pixels.
|
|
4795
|
-
*/
|
|
4796
|
-
function getMercatorHorizon(transform) {
|
|
4797
|
-
return transform.cameraToCenterDistance * Math.min(Math.tan(degreesToRadians(90 - transform.pitch)) * .85, Math.tan(degreesToRadians(maxMercatorHorizonAngle - transform.pitch)));
|
|
4798
|
-
}
|
|
4799
|
-
function calculateTileMatrix(unwrappedTileID, worldSize) {
|
|
4800
|
-
const canonical = unwrappedTileID.canonical;
|
|
4801
|
-
const scale$5 = worldSize / zoomScale(canonical.z);
|
|
4802
|
-
const unwrappedX = canonical.x + Math.pow(2, canonical.z) * unwrappedTileID.wrap;
|
|
4803
|
-
const worldMatrix = /* @__PURE__ */ new Float64Array(16);
|
|
4804
|
-
identity(worldMatrix);
|
|
4805
|
-
translate(worldMatrix, worldMatrix, [
|
|
4806
|
-
unwrappedX * scale$5,
|
|
4807
|
-
canonical.y * scale$5,
|
|
4808
|
-
0
|
|
4809
|
-
]);
|
|
4810
|
-
scale(worldMatrix, worldMatrix, [
|
|
4811
|
-
scale$5 / EXTENT,
|
|
4812
|
-
scale$5 / EXTENT,
|
|
4813
|
-
1
|
|
4814
|
-
]);
|
|
4815
|
-
return worldMatrix;
|
|
4816
|
-
}
|
|
4817
|
-
function cameraMercatorCoordinateFromCenterAndRotation(center, elevation, pitch, bearing, distance) {
|
|
4818
|
-
const centerMercator = MercatorCoordinate.fromLngLat(center, elevation);
|
|
4819
|
-
const dMercator = distance * mercatorZfromAltitude(1, center.lat);
|
|
4820
|
-
const { x, y, z } = cameraDirectionFromPitchBearing(pitch, bearing);
|
|
4821
|
-
const dxMercator = dMercator * -x;
|
|
4822
|
-
const dyMercator = dMercator * -y;
|
|
4823
|
-
const dzMercator = dMercator * -z;
|
|
4824
|
-
return new MercatorCoordinate(centerMercator.x + dxMercator, centerMercator.y + dyMercator, centerMercator.z + dzMercator);
|
|
4825
|
-
}
|
|
4826
|
-
function cameraDirectionFromPitchBearing(pitch, bearing) {
|
|
4827
|
-
const pitchRadians = degreesToRadians(pitch);
|
|
4828
|
-
const bearingRadians = degreesToRadians(bearing);
|
|
4829
|
-
const z = Math.cos(-pitchRadians);
|
|
4830
|
-
const h = Math.sin(pitchRadians);
|
|
4831
|
-
return {
|
|
4832
|
-
x: h * Math.sin(bearingRadians),
|
|
4833
|
-
y: -h * Math.cos(bearingRadians),
|
|
4834
|
-
z
|
|
4835
|
-
};
|
|
4836
|
-
}
|
|
4837
|
-
//#endregion
|
|
4838
4763
|
//#region src/geo/projection/covering_tiles.ts
|
|
4839
4764
|
/**
|
|
4840
4765
|
* A simple/heuristic function that returns whether the tile is visible under the current transform.
|
|
@@ -6912,12 +6837,13 @@ var CollisionIndex = class {
|
|
|
6912
6837
|
const featureKey = feature.key;
|
|
6913
6838
|
if (seenFeatures[featureKey.bucketInstanceId] === void 0) seenFeatures[featureKey.bucketInstanceId] = {};
|
|
6914
6839
|
if (seenFeatures[featureKey.bucketInstanceId][featureKey.featureIndex]) continue;
|
|
6915
|
-
|
|
6840
|
+
const bbox = [
|
|
6916
6841
|
new Point(feature.x1, feature.y1),
|
|
6917
6842
|
new Point(feature.x2, feature.y1),
|
|
6918
6843
|
new Point(feature.x2, feature.y2),
|
|
6919
6844
|
new Point(feature.x1, feature.y2)
|
|
6920
|
-
]
|
|
6845
|
+
];
|
|
6846
|
+
if (!polygonIntersectsPolygon(query, bbox)) continue;
|
|
6921
6847
|
seenFeatures[featureKey.bucketInstanceId][featureKey.featureIndex] = true;
|
|
6922
6848
|
if (result[featureKey.bucketInstanceId] === void 0) result[featureKey.bucketInstanceId] = [];
|
|
6923
6849
|
result[featureKey.bucketInstanceId].push(featureKey.featureIndex);
|
|
@@ -7040,7 +6966,8 @@ var CollisionIndex = class {
|
|
|
7040
6966
|
distanceMultiplier = Math.pow(2, -zoomFraction);
|
|
7041
6967
|
distanceMultiplier *= this.transform.getPitchedTextCorrection(translatedAnchorX, translatedAnchorY, unwrappedTileID);
|
|
7042
6968
|
if (!shift) {
|
|
7043
|
-
const
|
|
6969
|
+
const distanceRatio = projectedPoint.signedDistanceFromCamera / this.transform.cameraToCenterDistance;
|
|
6970
|
+
const perspectiveRatio = clamp(.5 + .5 * distanceRatio, 0, 4);
|
|
7044
6971
|
distanceMultiplier *= perspectiveRatio;
|
|
7045
6972
|
}
|
|
7046
6973
|
}
|
|
@@ -7898,7 +7825,7 @@ var KDBush = class KDBush {
|
|
|
7898
7825
|
this.coords = new ArrayType(data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2);
|
|
7899
7826
|
this._pos = 0;
|
|
7900
7827
|
this._finished = false;
|
|
7901
|
-
new Uint8Array(data, 0, 2).set([219,
|
|
7828
|
+
new Uint8Array(data, 0, 2).set([219, 16 + arrayTypeIndex]);
|
|
7902
7829
|
new Uint16Array(data, 2, 1)[0] = nodeSize;
|
|
7903
7830
|
new Uint32Array(data, 4, 1)[0] = numItems;
|
|
7904
7831
|
}
|
|
@@ -8575,7 +8502,9 @@ var EdgeInsets = class EdgeInsets {
|
|
|
8575
8502
|
* @returns the point
|
|
8576
8503
|
*/
|
|
8577
8504
|
getCenter(width, height) {
|
|
8578
|
-
|
|
8505
|
+
const x = clamp((this.left + width - this.right) / 2, 0, width);
|
|
8506
|
+
const y = clamp((this.top + height - this.bottom) / 2, 0, height);
|
|
8507
|
+
return new Point(x, y);
|
|
8579
8508
|
}
|
|
8580
8509
|
equals(other) {
|
|
8581
8510
|
return this.top === other.top && this.bottom === other.bottom && this.left === other.left && this.right === other.right;
|
|
@@ -9247,7 +9176,8 @@ var MercatorCoveringTilesDetailsProvider = class {
|
|
|
9247
9176
|
]);
|
|
9248
9177
|
}
|
|
9249
9178
|
allowVariableZoom(transform, options) {
|
|
9250
|
-
const
|
|
9179
|
+
const zfov = transform.fov * (Math.abs(Math.cos(transform.rollInRadians)) * transform.height + Math.abs(Math.sin(transform.rollInRadians)) * transform.width) / transform.height;
|
|
9180
|
+
const maxConstantZoomPitch = clamp(78.5 - zfov / 2, 0, 60);
|
|
9251
9181
|
return !!options.terrain || transform.pitch > maxConstantZoomPitch;
|
|
9252
9182
|
}
|
|
9253
9183
|
allowWorldCopies() {
|
|
@@ -9381,7 +9311,9 @@ var Frustum = class Frustum {
|
|
|
9381
9311
|
const frustumCoords = clipSpaceCorners.map((v) => unprojectClipSpacePoint(v, invProj, worldSize, scale));
|
|
9382
9312
|
if (horizonPlane) adjustFarPlaneByHorizonPlane(frustumCoords, frustumPlanePointIndices[0], horizonPlane, flippedNearFar);
|
|
9383
9313
|
const frustumPlanes = frustumPlanePointIndices.map((p) => {
|
|
9384
|
-
const
|
|
9314
|
+
const a = sub([], frustumCoords[p[0]], frustumCoords[p[1]]);
|
|
9315
|
+
const b = sub([], frustumCoords[p[2]], frustumCoords[p[1]]);
|
|
9316
|
+
const n = normalize([], cross([], a, b));
|
|
9385
9317
|
const d = -dot(n, frustumCoords[p[1]]);
|
|
9386
9318
|
return n.concat(d);
|
|
9387
9319
|
});
|
|
@@ -9475,12 +9407,15 @@ function getNormalizedNearPlane(frustumCoords, nearPlanePointsIndices) {
|
|
|
9475
9407
|
* Returns the ideal distance between the frustum's near and far plane so that the far plane only lies as far as the horizon.
|
|
9476
9408
|
*/
|
|
9477
9409
|
function getIdealNearFarPlaneDistance(horizonPlane, nearPlaneNormalized) {
|
|
9478
|
-
const
|
|
9410
|
+
const horizonPlaneLen = len(horizonPlane);
|
|
9411
|
+
const normalizedHorizonPlane = scale$3([], horizonPlane, 1 / horizonPlaneLen);
|
|
9479
9412
|
const projectedViewDirection = sub([], nearPlaneNormalized, scale$2([], normalizedHorizonPlane, dot(nearPlaneNormalized, normalizedHorizonPlane)));
|
|
9480
9413
|
const projectedViewLength = len(projectedViewDirection);
|
|
9481
9414
|
if (projectedViewLength > 0) {
|
|
9482
9415
|
const horizonCircleRadius = Math.sqrt(1 - normalizedHorizonPlane[3] * normalizedHorizonPlane[3]);
|
|
9483
|
-
|
|
9416
|
+
const horizonCircleCenter = scale$2([], normalizedHorizonPlane, -normalizedHorizonPlane[3]);
|
|
9417
|
+
const pointFurthestOnHorizonCircle = add([], horizonCircleCenter, scale$2([], projectedViewDirection, horizonCircleRadius / projectedViewLength));
|
|
9418
|
+
return pointPlaneSignedDistance(nearPlaneNormalized, pointFurthestOnHorizonCircle);
|
|
9484
9419
|
} else return null;
|
|
9485
9420
|
}
|
|
9486
9421
|
//#endregion
|
|
@@ -9687,7 +9622,7 @@ var MercatorTransform = class MercatorTransform {
|
|
|
9687
9622
|
zoom
|
|
9688
9623
|
};
|
|
9689
9624
|
let lngRange = this._helper._lngRange;
|
|
9690
|
-
if (!this._helper._renderWorldCopies && lngRange === null) lngRange = [-179.9999999999,
|
|
9625
|
+
if (!this._helper._renderWorldCopies && lngRange === null) lngRange = [-179.9999999999, 180 - 1e-10];
|
|
9691
9626
|
const worldSize = this.tileSize * zoomScale(result.zoom);
|
|
9692
9627
|
let minY = 0;
|
|
9693
9628
|
let maxY = worldSize;
|
|
@@ -9712,7 +9647,8 @@ var MercatorTransform = class MercatorTransform {
|
|
|
9712
9647
|
let modifiedX, modifiedY;
|
|
9713
9648
|
const scale = Math.max(scaleX || 0, scaleY || 0);
|
|
9714
9649
|
if (scale) {
|
|
9715
|
-
|
|
9650
|
+
const newPoint = new Point(scaleX ? (maxX + minX) / 2 : originalX, scaleY ? (maxY + minY) / 2 : originalY);
|
|
9651
|
+
result.center = unprojectFromWorldCoordinates(worldSize, newPoint).wrap();
|
|
9716
9652
|
result.zoom += scaleZoom(scale);
|
|
9717
9653
|
return result;
|
|
9718
9654
|
}
|
|
@@ -9729,7 +9665,10 @@ var MercatorTransform = class MercatorTransform {
|
|
|
9729
9665
|
if (wrappedX - w2 < minX) modifiedX = minX + w2;
|
|
9730
9666
|
if (wrappedX + w2 > maxX) modifiedX = maxX - w2;
|
|
9731
9667
|
}
|
|
9732
|
-
if (modifiedX !== void 0 || modifiedY !== void 0)
|
|
9668
|
+
if (modifiedX !== void 0 || modifiedY !== void 0) {
|
|
9669
|
+
const newPoint = new Point(modifiedX ?? originalX, modifiedY ?? originalY);
|
|
9670
|
+
result.center = unprojectFromWorldCoordinates(worldSize, newPoint).wrap();
|
|
9671
|
+
}
|
|
9733
9672
|
return result;
|
|
9734
9673
|
};
|
|
9735
9674
|
this.applyConstrain = (lngLat, zoom) => {
|
|
@@ -10223,7 +10162,9 @@ function cameraForBoxAndBearing(options, padding, bounds, bearing, tr) {
|
|
|
10223
10162
|
}
|
|
10224
10163
|
const zoom = Math.min(scaleZoom(tr.scale * Math.min(scaleX, scaleY)), options.maxZoom);
|
|
10225
10164
|
const offset = Point.convert(options.offset);
|
|
10226
|
-
const
|
|
10165
|
+
const paddingOffsetX = (padding.left - padding.right) / 2;
|
|
10166
|
+
const paddingOffsetY = (padding.top - padding.bottom) / 2;
|
|
10167
|
+
const rotatedPaddingOffset = new Point(paddingOffsetX, paddingOffsetY).rotate(degreesToRadians(bearing));
|
|
10227
10168
|
const offsetAtFinalZoom = offset.add(rotatedPaddingOffset).mult(tr.scale / zoomScale(zoom));
|
|
10228
10169
|
return {
|
|
10229
10170
|
center: unprojectFromWorldCoordinates(tr.worldSize, nwWorld.add(seWorld).div(2).sub(offsetAtFinalZoom)),
|
|
@@ -10599,7 +10540,9 @@ function getGlobeCircumferencePixels(transform) {
|
|
|
10599
10540
|
return 2 * Math.PI * radius;
|
|
10600
10541
|
}
|
|
10601
10542
|
function globeDistanceOfLocationsPixels(transform, a, b) {
|
|
10602
|
-
const
|
|
10543
|
+
const vecA = angularCoordinatesToSurfaceVector(a);
|
|
10544
|
+
const vecB = angularCoordinatesToSurfaceVector(b);
|
|
10545
|
+
const dot$2 = dot(vecA, vecB);
|
|
10603
10546
|
const radians = Math.acos(dot$2);
|
|
10604
10547
|
const circumference = getGlobeCircumferencePixels(transform);
|
|
10605
10548
|
return radians / (2 * Math.PI) * circumference;
|
|
@@ -10665,7 +10608,8 @@ function sphereSurfacePointToCoordinates(surface) {
|
|
|
10665
10608
|
const projX = surface[0] / lengthXZ;
|
|
10666
10609
|
const projZ = surface[2] / lengthXZ;
|
|
10667
10610
|
const acosZ = Math.acos(projZ);
|
|
10668
|
-
|
|
10611
|
+
const lngDegrees = (projX > 0 ? acosZ : -acosZ) / Math.PI * 180;
|
|
10612
|
+
return new LngLat(wrap(lngDegrees, -180, 180), latDegrees);
|
|
10669
10613
|
} else return new LngLat(0, latDegrees);
|
|
10670
10614
|
}
|
|
10671
10615
|
/**
|
|
@@ -10711,7 +10655,8 @@ function planetScaleAtLatitude(latitudeDegrees) {
|
|
|
10711
10655
|
*/
|
|
10712
10656
|
function getZoomAdjustment(oldLat, newLat) {
|
|
10713
10657
|
const oldCircumference = planetScaleAtLatitude(oldLat);
|
|
10714
|
-
|
|
10658
|
+
const newCircumference = planetScaleAtLatitude(newLat);
|
|
10659
|
+
return scaleZoom(newCircumference / oldCircumference);
|
|
10715
10660
|
}
|
|
10716
10661
|
function getDegreesPerPixel(worldSize, lat) {
|
|
10717
10662
|
return 360 / getGlobeCircumferencePixels({
|
|
@@ -10759,8 +10704,12 @@ function interpolateLngLatForGlobe(start, deltaLng, deltaLat, t) {
|
|
|
10759
10704
|
const valueStart = integrateSecX(samplePointStart);
|
|
10760
10705
|
const valueEnd = integrateSecX(samplePointEnd);
|
|
10761
10706
|
const newT = (valueT - valueStart) / (valueEnd - valueStart);
|
|
10762
|
-
|
|
10763
|
-
|
|
10707
|
+
const interpolatedLng = start.lng + deltaLng * newT;
|
|
10708
|
+
return new LngLat(interpolatedLng, interpolatedLat);
|
|
10709
|
+
} else {
|
|
10710
|
+
const interpolatedLng = start.lng + deltaLng * t;
|
|
10711
|
+
return new LngLat(interpolatedLng, interpolatedLat);
|
|
10712
|
+
}
|
|
10764
10713
|
}
|
|
10765
10714
|
//#endregion
|
|
10766
10715
|
//#region src/util/primitives/bounding_volume_cache.ts
|
|
@@ -11026,9 +10975,8 @@ var GlobeCoveringTilesDetailsProvider = class {
|
|
|
11026
10975
|
const tileMercatorSize = 1 / scale;
|
|
11027
10976
|
const tileCornerX = tileID.x / scale;
|
|
11028
10977
|
const tileCornerY = tileID.y / scale;
|
|
11029
|
-
const
|
|
11030
|
-
|
|
11031
|
-
let smallestDistance = 2 * worldSize;
|
|
10978
|
+
const halfWorld = .5;
|
|
10979
|
+
let smallestDistance = 2;
|
|
11032
10980
|
smallestDistance = Math.min(smallestDistance, distanceToTileWrapX(pointX, pointY, tileCornerX, tileCornerY, tileMercatorSize));
|
|
11033
10981
|
smallestDistance = Math.min(smallestDistance, distanceToTileWrapX(pointX, pointY, tileCornerX + halfWorld, -tileCornerY - tileMercatorSize, tileMercatorSize));
|
|
11034
10982
|
smallestDistance = Math.min(smallestDistance, distanceToTileWrapX(pointX, pointY, tileCornerX + halfWorld, 2 - tileCornerY - tileMercatorSize, tileMercatorSize));
|
|
@@ -11781,7 +11729,10 @@ var VerticalPerspectiveTransform = class VerticalPerspectiveTransform {
|
|
|
11781
11729
|
}
|
|
11782
11730
|
locationToScreenPoint(lnglat, terrain) {
|
|
11783
11731
|
const pos = angularCoordinatesToSurfaceVector(lnglat);
|
|
11784
|
-
if (terrain)
|
|
11732
|
+
if (terrain) {
|
|
11733
|
+
const elevation = terrain.getElevationForLngLatZoom(lnglat, this._helper._tileZoom);
|
|
11734
|
+
scale$2(pos, pos, 1 + elevation / earthRadius);
|
|
11735
|
+
}
|
|
11785
11736
|
return this._projectSurfacePointToScreen(pos);
|
|
11786
11737
|
}
|
|
11787
11738
|
/**
|
|
@@ -12222,7 +12173,9 @@ var GlobeTransform = class GlobeTransform {
|
|
|
12222
12173
|
return lerp(this._mercatorTransform.getCircleRadiusCorrection(), this._verticalPerspectiveTransform.getCircleRadiusCorrection(), this._globeness);
|
|
12223
12174
|
}
|
|
12224
12175
|
getPitchedTextCorrection(textAnchorX, textAnchorY, tileID) {
|
|
12225
|
-
|
|
12176
|
+
const mercatorCorrection = this._mercatorTransform.getPitchedTextCorrection(textAnchorX, textAnchorY, tileID);
|
|
12177
|
+
const verticalCorrection = this._verticalPerspectiveTransform.getPitchedTextCorrection(textAnchorX, textAnchorY, tileID);
|
|
12178
|
+
return lerp(mercatorCorrection, verticalCorrection, this._globeness);
|
|
12226
12179
|
}
|
|
12227
12180
|
projectTileCoordinates(x, y, unwrappedTileID, getElevation) {
|
|
12228
12181
|
return this.currentTransform.projectTileCoordinates(x, y, unwrappedTileID, getElevation);
|
|
@@ -12535,7 +12488,8 @@ var VerticalPerspectiveCameraHelper = class VerticalPerspectiveCameraHelper {
|
|
|
12535
12488
|
const requestedMinZoom = typeof options.minZoom === "number" ? +options.minZoom : tr.minZoom;
|
|
12536
12489
|
const normalizedEffectiveMinZoom = Math.max(requestedMinZoom, tr.minZoom) + getZoomAdjustment(targetCenter.lat, 0);
|
|
12537
12490
|
const minZoomPreConstrain = Math.min(normalizedEffectiveMinZoom, normalizedStartZoom, normalizedTargetZoom) + getZoomAdjustment(0, targetCenter.lat);
|
|
12538
|
-
const
|
|
12491
|
+
const normalizedMinZoom = tr.applyConstrain(targetCenter, minZoomPreConstrain).zoom + getZoomAdjustment(targetCenter.lat, 0);
|
|
12492
|
+
const scaleOfMinZoom = zoomScale(normalizedMinZoom - normalizedStartZoom);
|
|
12539
12493
|
const deltaLng = differenceOfAnglesDegrees(startCenter.lng, targetCenter.lng);
|
|
12540
12494
|
const deltaLat = differenceOfAnglesDegrees(startCenter.lat, targetCenter.lat);
|
|
12541
12495
|
const easeFunc = (k, scale, centerFactor, _pointAtOffset) => {
|
|
@@ -13159,9 +13113,7 @@ var Style = class extends Evented {
|
|
|
13159
13113
|
case "setTransition":
|
|
13160
13114
|
operations.push(() => {});
|
|
13161
13115
|
break;
|
|
13162
|
-
default:
|
|
13163
|
-
unimplemented.push(op.command);
|
|
13164
|
-
break;
|
|
13116
|
+
default: unimplemented.push(op.command);
|
|
13165
13117
|
}
|
|
13166
13118
|
return {
|
|
13167
13119
|
operations,
|
|
@@ -14161,6 +14113,7 @@ var Program = class {
|
|
|
14161
14113
|
for (const name in this.attributes) {
|
|
14162
14114
|
const actual = gl.getAttribLocation(this.program, name);
|
|
14163
14115
|
if (actual >= 0) this.attributes[name] = actual;
|
|
14116
|
+
else delete this.attributes[name];
|
|
14164
14117
|
}
|
|
14165
14118
|
if (!gl.getProgramParameter(this.program, gl.LINK_STATUS)) throw new Error(`Program failed to link: ${gl.getProgramInfoLog(this.program)}`);
|
|
14166
14119
|
gl.deleteShader(vertexShader);
|
|
@@ -14203,9 +14156,7 @@ var Program = class {
|
|
|
14203
14156
|
case gl.TRIANGLES:
|
|
14204
14157
|
primitiveSize = 3;
|
|
14205
14158
|
break;
|
|
14206
|
-
case gl.LINE_STRIP:
|
|
14207
|
-
primitiveSize = 1;
|
|
14208
|
-
break;
|
|
14159
|
+
case gl.LINE_STRIP: primitiveSize = 1;
|
|
14209
14160
|
}
|
|
14210
14161
|
for (const segment of segments.get()) {
|
|
14211
14162
|
segment.vaos ||= {};
|
|
@@ -14472,9 +14423,7 @@ const hillshadeUniformValues = (painter, tile, layer) => {
|
|
|
14472
14423
|
case "multidirectional":
|
|
14473
14424
|
method = 3;
|
|
14474
14425
|
break;
|
|
14475
|
-
default:
|
|
14476
|
-
method = 0;
|
|
14477
|
-
break;
|
|
14426
|
+
default: method = 0;
|
|
14478
14427
|
}
|
|
14479
14428
|
const illumination = layer.getIlluminationProperties();
|
|
14480
14429
|
for (let i = 0; i < illumination.directionRadians.length; i++) if (layer.paint.get("hillshade-illumination-anchor") === "viewport") illumination.directionRadians[i] += painter.transform.bearingInRadians;
|
|
@@ -16167,7 +16116,9 @@ function drawCircles(painter, tileManager, layer, coords, renderOptions) {
|
|
|
16167
16116
|
const tile = tileManager.getTile(coord);
|
|
16168
16117
|
const bucket = tile.getBucket(layer);
|
|
16169
16118
|
if (!bucket) continue;
|
|
16170
|
-
const
|
|
16119
|
+
const styleTranslate = layer.paint.get("circle-translate");
|
|
16120
|
+
const styleTranslateAnchor = layer.paint.get("circle-translate-anchor");
|
|
16121
|
+
const translateForUniforms = translatePosition(transform, tile, styleTranslate, styleTranslateAnchor);
|
|
16171
16122
|
const programConfiguration = bucket.programConfigurations.get(layer.id);
|
|
16172
16123
|
const program = painter.useProgram("circle", programConfiguration);
|
|
16173
16124
|
const layoutVertexBuffer = bucket.layoutVertexBuffer;
|
|
@@ -16447,7 +16398,8 @@ function updateGradientTexture(painter, tileManager, context, gl, layer, bucket,
|
|
|
16447
16398
|
if (layer.stepInterpolant) {
|
|
16448
16399
|
const sourceMaxZoom = tileManager.getSource().maxzoom;
|
|
16449
16400
|
const potentialOverzoom = coord.canonical.z === sourceMaxZoom ? Math.ceil(1 << painter.transform.maxZoom - coord.canonical.z) : 1;
|
|
16450
|
-
|
|
16401
|
+
const maxTextureCoverage = bucket.maxLineLength / EXTENT * 1024 * potentialOverzoom;
|
|
16402
|
+
textureResolution = clamp(nextPowerOfTwo(maxTextureCoverage), 256, context.maxTextureSize);
|
|
16451
16403
|
}
|
|
16452
16404
|
layerGradient.gradient = renderColorRamp({
|
|
16453
16405
|
expression: layer.gradientExpression(),
|
|
@@ -17040,7 +16992,8 @@ function getCrossFadeValues(tile, parentTile, fadeDuration) {
|
|
|
17040
16992
|
* Simple fade-in values for tile without a parent (i.e. edge tiles)
|
|
17041
16993
|
*/
|
|
17042
16994
|
function getSelfFadeValues(tile, fadeDuration) {
|
|
17043
|
-
const
|
|
16995
|
+
const timeSinceTile = (now() - tile.timeAdded) / fadeDuration;
|
|
16996
|
+
const tileOpacity = clamp(timeSinceTile, 0, 1);
|
|
17044
16997
|
return {
|
|
17045
16998
|
tileOpacity,
|
|
17046
16999
|
fadeMix: {
|
|
@@ -17600,7 +17553,7 @@ var Painter = class Painter {
|
|
|
17600
17553
|
context.setDepthMode(DepthMode.disabled);
|
|
17601
17554
|
const stencilRefs = {};
|
|
17602
17555
|
for (const tileID of tileIDs) stencilRefs[tileID.key] = this.nextStencilID++;
|
|
17603
|
-
this._renderTileMasks(stencilRefs, tileIDs, renderToTexture, true);
|
|
17556
|
+
if (this.style.projection.useSubdivision) this._renderTileMasks(stencilRefs, tileIDs, renderToTexture, true);
|
|
17604
17557
|
this._renderTileMasks(stencilRefs, tileIDs, renderToTexture, false);
|
|
17605
17558
|
this._tileClippingMaskIDs = stencilRefs;
|
|
17606
17559
|
}
|
|
@@ -18152,7 +18105,7 @@ var Hash = class {
|
|
|
18152
18105
|
location = location.replace("&&", "&");
|
|
18153
18106
|
window.history.replaceState(window.history.state, null, location);
|
|
18154
18107
|
};
|
|
18155
|
-
this._updateHash = throttle(this._updateHashUnthrottled,
|
|
18108
|
+
this._updateHash = throttle(this._updateHashUnthrottled, 3e4 / 100);
|
|
18156
18109
|
this._hashName = hashName && encodeURIComponent(hashName);
|
|
18157
18110
|
}
|
|
18158
18111
|
/**
|
|
@@ -19631,7 +19584,8 @@ var ScrollZoomHandler = class {
|
|
|
19631
19584
|
const t = (now() - currentEase.start) / currentEase.duration;
|
|
19632
19585
|
const speed = currentEase.easing(t + .01) - currentEase.easing(t);
|
|
19633
19586
|
const x = .27 / Math.sqrt(speed * speed + 1e-4) * .01;
|
|
19634
|
-
|
|
19587
|
+
const y = Math.sqrt(.0729 - x * x);
|
|
19588
|
+
easing = bezier(x, y, .25, 1);
|
|
19635
19589
|
}
|
|
19636
19590
|
this._prevEase = {
|
|
19637
19591
|
start: now(),
|
|
@@ -21775,7 +21729,8 @@ var Terrain = class {
|
|
|
21775
21729
|
this._terrainSkirtLength = terrainSkirtLength;
|
|
21776
21730
|
this.qualityFactor = 2;
|
|
21777
21731
|
this.meshSize = 128;
|
|
21778
|
-
this._demMatrixCache =
|
|
21732
|
+
this._demMatrixCache = /* @__PURE__ */ new Map();
|
|
21733
|
+
this._elevationSamplerCache = /* @__PURE__ */ new Map();
|
|
21779
21734
|
this.coordsIndex = [];
|
|
21780
21735
|
this._coordsTextureSize = 1024;
|
|
21781
21736
|
}
|
|
@@ -21821,12 +21776,8 @@ var Terrain = class {
|
|
|
21821
21776
|
getDEMElevation(tileID, x, y, extent = EXTENT) {
|
|
21822
21777
|
const normalized = tileID.normalizeCoordinates(x, y, extent);
|
|
21823
21778
|
if (!normalized) return 0;
|
|
21824
|
-
const
|
|
21825
|
-
|
|
21826
|
-
if (!dem) return 0;
|
|
21827
|
-
const pos = transformMat4$2([], [normalized.x / extent * EXTENT, normalized.y / extent * EXTENT], terrain.u_terrain_matrix);
|
|
21828
|
-
const coord = [pos[0] * dem.dim, pos[1] * dem.dim];
|
|
21829
|
-
return dem.sampleBilinear(coord[0], coord[1]);
|
|
21779
|
+
const sampler = this._getElevationSampler(normalized.tileID);
|
|
21780
|
+
return sampler ? sampler(normalized.x, normalized.y, extent) : 0;
|
|
21830
21781
|
}
|
|
21831
21782
|
/**
|
|
21832
21783
|
* Get the elevation for given {@link LngLat} in respect of exaggeration.
|
|
@@ -21868,6 +21819,55 @@ var Terrain = class {
|
|
|
21868
21819
|
return this.getDEMElevation(tileID, x, y, extent) * this.exaggeration;
|
|
21869
21820
|
}
|
|
21870
21821
|
/**
|
|
21822
|
+
* Clear CPU elevation samplers that may retain a previously selected DEM tile.
|
|
21823
|
+
* @internal
|
|
21824
|
+
*/
|
|
21825
|
+
resetElevationCache() {
|
|
21826
|
+
this._elevationSamplerCache.clear();
|
|
21827
|
+
}
|
|
21828
|
+
_getElevationSampler(tileID) {
|
|
21829
|
+
const key = tileID.key;
|
|
21830
|
+
const cachedSampler = this._elevationSamplerCache.get(key);
|
|
21831
|
+
if (cachedSampler) return cachedSampler;
|
|
21832
|
+
const sourceTile = this.tileManager.getSourceTile(tileID, true);
|
|
21833
|
+
const dem = sourceTile?.dem;
|
|
21834
|
+
if (!sourceTile || !dem) return null;
|
|
21835
|
+
const matrix = this._getDEMTileMatrix(tileID, sourceTile);
|
|
21836
|
+
const demPixelScaleX = matrix[0] * dem.dim;
|
|
21837
|
+
const demPixelScaleY = matrix[5] * dem.dim;
|
|
21838
|
+
const demPixelOffsetX = matrix[12] * dem.dim;
|
|
21839
|
+
const demPixelOffsetY = matrix[13] * dem.dim;
|
|
21840
|
+
const sampler = (x, y, extent) => {
|
|
21841
|
+
const extentScale = extent === 8192 ? 1 : EXTENT / extent;
|
|
21842
|
+
return dem.sampleBilinear(x * extentScale * demPixelScaleX + demPixelOffsetX, y * extentScale * demPixelScaleY + demPixelOffsetY);
|
|
21843
|
+
};
|
|
21844
|
+
this._elevationSamplerCache.set(key, sampler);
|
|
21845
|
+
return sampler;
|
|
21846
|
+
}
|
|
21847
|
+
_getDEMTileMatrix(tileID, sourceTile) {
|
|
21848
|
+
const matrixKey = `${sourceTile.tileID.key}/${tileID.key}`;
|
|
21849
|
+
const cachedMatrix = this._demMatrixCache.get(matrixKey);
|
|
21850
|
+
if (cachedMatrix) return cachedMatrix;
|
|
21851
|
+
const maxzoom = this.tileManager.getSource().maxzoom;
|
|
21852
|
+
let dz = tileID.canonical.z - sourceTile.tileID.canonical.z;
|
|
21853
|
+
if (tileID.overscaledZ > tileID.canonical.z) if (tileID.canonical.z >= maxzoom) dz = tileID.canonical.z - maxzoom;
|
|
21854
|
+
else warnOnce("cannot calculate elevation if elevation maxzoom > source.maxzoom");
|
|
21855
|
+
const dx = tileID.canonical.x - (tileID.canonical.x >> dz << dz);
|
|
21856
|
+
const dy = tileID.canonical.y - (tileID.canonical.y >> dz << dz);
|
|
21857
|
+
const demMatrix = fromScaling(/* @__PURE__ */ new Float64Array(16), [
|
|
21858
|
+
1 / (EXTENT << dz),
|
|
21859
|
+
1 / (EXTENT << dz),
|
|
21860
|
+
0
|
|
21861
|
+
]);
|
|
21862
|
+
translate(demMatrix, demMatrix, [
|
|
21863
|
+
dx * EXTENT,
|
|
21864
|
+
dy * EXTENT,
|
|
21865
|
+
0
|
|
21866
|
+
]);
|
|
21867
|
+
this._demMatrixCache.set(matrixKey, demMatrix);
|
|
21868
|
+
return demMatrix;
|
|
21869
|
+
}
|
|
21870
|
+
/**
|
|
21871
21871
|
* returns a Terrain Object for a tile. Unless the tile corresponds to data (e.g. tile is loading), return a flat dem object
|
|
21872
21872
|
* @param tileID - the tile to get the terrain for
|
|
21873
21873
|
* @returns the terrain data to use in the program
|
|
@@ -21902,34 +21902,12 @@ var Terrain = class {
|
|
|
21902
21902
|
sourceTile.demTexture.bind(context.gl.NEAREST, context.gl.CLAMP_TO_EDGE);
|
|
21903
21903
|
sourceTile.needsTerrainPrepare = false;
|
|
21904
21904
|
}
|
|
21905
|
-
const
|
|
21906
|
-
if (matrixKey && !this._demMatrixCache[matrixKey]) {
|
|
21907
|
-
const maxzoom = this.tileManager.getSource().maxzoom;
|
|
21908
|
-
let dz = tileID.canonical.z - sourceTile.tileID.canonical.z;
|
|
21909
|
-
if (tileID.overscaledZ > tileID.canonical.z) if (tileID.canonical.z >= maxzoom) dz = tileID.canonical.z - maxzoom;
|
|
21910
|
-
else warnOnce("cannot calculate elevation if elevation maxzoom > source.maxzoom");
|
|
21911
|
-
const dx = tileID.canonical.x - (tileID.canonical.x >> dz << dz);
|
|
21912
|
-
const dy = tileID.canonical.y - (tileID.canonical.y >> dz << dz);
|
|
21913
|
-
const demMatrix = fromScaling(/* @__PURE__ */ new Float64Array(16), [
|
|
21914
|
-
1 / (EXTENT << dz),
|
|
21915
|
-
1 / (EXTENT << dz),
|
|
21916
|
-
0
|
|
21917
|
-
]);
|
|
21918
|
-
translate(demMatrix, demMatrix, [
|
|
21919
|
-
dx * EXTENT,
|
|
21920
|
-
dy * EXTENT,
|
|
21921
|
-
0
|
|
21922
|
-
]);
|
|
21923
|
-
this._demMatrixCache[matrixKey] = {
|
|
21924
|
-
matrix: demMatrix,
|
|
21925
|
-
coord: tileID
|
|
21926
|
-
};
|
|
21927
|
-
}
|
|
21905
|
+
const terrainMatrix = sourceTile ? this._getDEMTileMatrix(tileID, sourceTile) : this._emptyDemMatrix;
|
|
21928
21906
|
return {
|
|
21929
21907
|
"u_depth": 2,
|
|
21930
21908
|
"u_terrain": 3,
|
|
21931
21909
|
"u_terrain_dim": sourceTile?.dem?.dim || 1,
|
|
21932
|
-
"u_terrain_matrix":
|
|
21910
|
+
"u_terrain_matrix": terrainMatrix,
|
|
21933
21911
|
"u_terrain_unpack": sourceTile?.dem?.getUnpackVector() || this._emptyDemUnpack,
|
|
21934
21912
|
"u_terrain_exaggeration": this.exaggeration,
|
|
21935
21913
|
texture: (sourceTile?.demTexture || this._emptyDemTexture).texture,
|
|
@@ -21997,10 +21975,11 @@ var Terrain = class {
|
|
|
21997
21975
|
data[i + 2] = x >> 8 << 4 | y >> 8;
|
|
21998
21976
|
data[i + 3] = 0;
|
|
21999
21977
|
}
|
|
22000
|
-
const
|
|
21978
|
+
const image = new RGBAImage({
|
|
22001
21979
|
width: this._coordsTextureSize,
|
|
22002
21980
|
height: this._coordsTextureSize
|
|
22003
|
-
}, new Uint8Array(data.buffer))
|
|
21981
|
+
}, new Uint8Array(data.buffer));
|
|
21982
|
+
const texture = new Texture(context, image, context.gl.RGBA, { premultiply: false });
|
|
22004
21983
|
texture.bind(context.gl.NEAREST, context.gl.CLAMP_TO_EDGE);
|
|
22005
21984
|
this._coordsTexture = texture;
|
|
22006
21985
|
return texture;
|
|
@@ -22041,7 +22020,7 @@ var Terrain = class {
|
|
|
22041
22020
|
context.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer);
|
|
22042
22021
|
gl.readPixels(p.x, this.painter.height / devicePixelRatio - p.y - 1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, rgba);
|
|
22043
22022
|
context.bindFramebuffer.set(null);
|
|
22044
|
-
return (rgba[0] /
|
|
22023
|
+
return (rgba[0] / 16777216 + rgba[1] / 65536 + rgba[2] / 256 + rgba[3]) / 256;
|
|
22045
22024
|
}
|
|
22046
22025
|
/**
|
|
22047
22026
|
* create a regular mesh which will be used by all terrain-tiles
|
|
@@ -22108,8 +22087,9 @@ var Terrain = class {
|
|
|
22108
22087
|
const worldSize = (1 << zoom) * EXTENT;
|
|
22109
22088
|
const mercatorX = mercatorCoordinate.x * worldSize;
|
|
22110
22089
|
const mercatorY = mercatorCoordinate.y * worldSize;
|
|
22090
|
+
const tileX = Math.floor(mercatorX / EXTENT), tileY = Math.floor(mercatorY / EXTENT);
|
|
22111
22091
|
return {
|
|
22112
|
-
tileID: new OverscaledTileID(zoom, 0, zoom,
|
|
22092
|
+
tileID: new OverscaledTileID(zoom, 0, zoom, tileX, tileY),
|
|
22113
22093
|
mercatorX,
|
|
22114
22094
|
mercatorY
|
|
22115
22095
|
};
|
|
@@ -24297,22 +24277,30 @@ var Map$1 = class extends Evented {
|
|
|
24297
24277
|
this._camera.terrain = this.terrain;
|
|
24298
24278
|
this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center, this._camera.transform.tileZoom));
|
|
24299
24279
|
this._camera.transform.setElevation(this.terrain.getElevationForLngLatZoom(this._camera.transform.center, this._camera.transform.tileZoom));
|
|
24300
|
-
this._terrainDataCallback = (e) =>
|
|
24301
|
-
if (e.dataType === "style") this.terrain.tileManager.releaseAllRTT();
|
|
24302
|
-
else if (e.dataType === "source" && e.tile) {
|
|
24303
|
-
if (e.sourceId === options.source && !this._camera.elevationFreeze) {
|
|
24304
|
-
this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center, this._camera.transform.tileZoom));
|
|
24305
|
-
if (this.getCenterClampedToGround()) this._camera.transform.setElevation(this.terrain.getElevationForLngLatZoom(this._camera.transform.center, this._camera.transform.tileZoom));
|
|
24306
|
-
}
|
|
24307
|
-
if (e.source?.type === "image") this.terrain.tileManager.releaseAllRTT();
|
|
24308
|
-
else this.terrain.tileManager.releaseRTT(e.tile.tileID);
|
|
24309
|
-
}
|
|
24310
|
-
};
|
|
24280
|
+
this._terrainDataCallback = (e) => this._handleTerrainDataEvent(e, options.source);
|
|
24311
24281
|
this.style.on("data", this._terrainDataCallback);
|
|
24312
24282
|
}
|
|
24313
24283
|
this.fire(new MapTerrainEvent({ terrain: options }));
|
|
24314
24284
|
return this;
|
|
24315
24285
|
}
|
|
24286
|
+
_handleTerrainDataEvent(event, terrainSourceId) {
|
|
24287
|
+
if (event.dataType === "style") {
|
|
24288
|
+
this.terrain.tileManager.releaseAllRTT();
|
|
24289
|
+
return;
|
|
24290
|
+
}
|
|
24291
|
+
const isTerrainSourceEvent = event.sourceId === terrainSourceId;
|
|
24292
|
+
if (isTerrainSourceEvent) this.terrain.resetElevationCache();
|
|
24293
|
+
if (isTerrainSourceEvent && event.tile && !this._camera.elevationFreeze) {
|
|
24294
|
+
this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center, this._camera.transform.tileZoom));
|
|
24295
|
+
if (this.getCenterClampedToGround()) this._camera.transform.setElevation(this.terrain.getElevationForLngLatZoom(this._camera.transform.center, this._camera.transform.tileZoom));
|
|
24296
|
+
}
|
|
24297
|
+
if (!event.tile) return;
|
|
24298
|
+
if (event.source?.type === "image") {
|
|
24299
|
+
this.terrain.tileManager.releaseAllRTT();
|
|
24300
|
+
return;
|
|
24301
|
+
}
|
|
24302
|
+
this.terrain.tileManager.releaseRTT(event.tile.tileID);
|
|
24303
|
+
}
|
|
24316
24304
|
/**
|
|
24317
24305
|
* Get the terrain-options if terrain is loaded
|
|
24318
24306
|
* @returns the TerrainSpecification passed to setTerrain
|
|
@@ -25406,6 +25394,7 @@ var Map$1 = class extends Evented {
|
|
|
25406
25394
|
}
|
|
25407
25395
|
if (this.terrain) {
|
|
25408
25396
|
this.terrain.tileManager.update(this._camera.transform, this.terrain);
|
|
25397
|
+
this.terrain.resetElevationCache();
|
|
25409
25398
|
this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center, this._camera.transform.tileZoom));
|
|
25410
25399
|
if (!this._camera.elevationFreeze && this.getCenterClampedToGround()) this._camera.transform.setElevation(this.terrain.getElevationForLngLatZoom(this._camera.transform.center, this._camera.transform.tileZoom));
|
|
25411
25400
|
} else {
|
|
@@ -26304,7 +26293,6 @@ var Marker = class extends Evented {
|
|
|
26304
26293
|
}
|
|
26305
26294
|
if (popup) {
|
|
26306
26295
|
if (!("offset" in popup.options)) {
|
|
26307
|
-
const markerHeight = 41 - 5.8 / 2;
|
|
26308
26296
|
const markerRadius = 13.5;
|
|
26309
26297
|
const linearOffset = Math.abs(markerRadius) / Math.SQRT2;
|
|
26310
26298
|
popup.options.offset = this._defaultMarker ? {
|
|
@@ -26312,10 +26300,10 @@ var Marker = class extends Evented {
|
|
|
26312
26300
|
"top-left": [0, 0],
|
|
26313
26301
|
"top-right": [0, 0],
|
|
26314
26302
|
"bottom": [0, -38.1],
|
|
26315
|
-
"bottom-left": [linearOffset, (
|
|
26316
|
-
"bottom-right": [-linearOffset, (
|
|
26317
|
-
"left": [markerRadius,
|
|
26318
|
-
"right": [-13.5,
|
|
26303
|
+
"bottom-left": [linearOffset, (24.6 + linearOffset) * -1],
|
|
26304
|
+
"bottom-right": [-linearOffset, (24.6 + linearOffset) * -1],
|
|
26305
|
+
"left": [markerRadius, -24.6],
|
|
26306
|
+
"right": [-13.5, -24.6]
|
|
26319
26307
|
} : this._offset;
|
|
26320
26308
|
}
|
|
26321
26309
|
this._popup = popup;
|
|
@@ -26841,7 +26829,8 @@ var GeolocateControl = class extends Evented {
|
|
|
26841
26829
|
this._updateCamera = (position) => {
|
|
26842
26830
|
const center = new LngLat(position.coords.longitude, position.coords.latitude);
|
|
26843
26831
|
const radius = position.coords.accuracy;
|
|
26844
|
-
const
|
|
26832
|
+
const bearing = this._map.getBearing();
|
|
26833
|
+
const options = extend({ bearing }, this.options.fitBoundsOptions);
|
|
26845
26834
|
const newBounds = LngLatBounds.fromLngLat(center, radius);
|
|
26846
26835
|
this._map.fitBounds(newBounds, options, { geolocateSource: true });
|
|
26847
26836
|
};
|