maplibre-gl 6.1.0 → 6.3.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 +694 -406
- package/dist/maplibre-gl-dev.mjs.map +1 -1
- package/dist/maplibre-gl-shared-dev.mjs +971 -882
- 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 +35 -59
- 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 +238 -65
- package/dist/maplibre-gl.mjs +44 -44
- package/dist/maplibre-gl.mjs.map +1 -1
- package/package.json +13 -26
- 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_index.bench.ts +21 -0
- package/src/data/feature_position_map.test.ts +1 -1
- package/src/data/segment.test.ts +16 -16
- package/src/geo/bounds.test.ts +4 -4
- package/src/geo/edge_insets.test.ts +1 -1
- package/src/geo/lng_lat.test.ts +7 -7
- package/src/geo/lng_lat_bounds.test.ts +5 -5
- package/src/geo/mercator_coordinate.test.ts +2 -2
- package/src/geo/projection/camera_helper.ts +5 -0
- package/src/geo/projection/globe_transform.test.ts +25 -0
- package/src/geo/projection/globe_transform.ts +7 -3
- package/src/geo/projection/mercator_camera_helper.ts +1 -1
- package/src/geo/projection/mercator_transform.test.ts +1 -1
- package/src/geo/projection/mercator_transform.ts +21 -5
- package/src/geo/projection/mercator_utils.test.ts +8 -8
- package/src/geo/projection/vertical_perspective_camera_helper.ts +60 -31
- package/src/geo/projection/vertical_perspective_transform.ts +7 -1
- package/src/geo/transform_interface.ts +13 -1
- package/src/index.test.ts +7 -12
- package/src/index.ts +7 -2
- package/src/render/glyph_manager.test.ts +6 -22
- package/src/render/image_atlas.test.ts +72 -0
- package/src/render/image_atlas.ts +17 -2
- package/src/render/image_manager.test.ts +46 -0
- package/src/render/image_manager.ts +9 -2
- package/src/render/painter.test.ts +2 -0
- package/src/render/painter.ts +8 -17
- 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/render/update_pattern_positions_in_program.test.ts +1 -1
- package/src/shaders/glsl/_prelude.vertex.glsl +2 -3
- package/src/shaders/glsl/_prelude.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/circle.vertex.glsl +4 -4
- package/src/shaders/glsl/circle.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/fill_extrusion.vertex.glsl +3 -3
- package/src/shaders/glsl/fill_extrusion.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/fill_extrusion_pattern.vertex.glsl +5 -5
- package/src/shaders/glsl/fill_extrusion_pattern.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/heatmap.vertex.glsl +4 -4
- package/src/shaders/glsl/heatmap.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/line.vertex.glsl +7 -7
- package/src/shaders/glsl/line.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/line_gradient.vertex.glsl +6 -6
- package/src/shaders/glsl/line_gradient.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/line_gradient_sdf.vertex.glsl +7 -7
- package/src/shaders/glsl/line_gradient_sdf.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/line_pattern.vertex.glsl +7 -7
- package/src/shaders/glsl/line_pattern.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/line_sdf.vertex.glsl +7 -7
- package/src/shaders/glsl/line_sdf.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/raster.fragment.glsl +4 -4
- package/src/shaders/glsl/raster.fragment.glsl.g.ts +1 -1
- package/src/shaders/glsl/raster.vertex.glsl +11 -6
- package/src/shaders/glsl/raster.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/symbol_icon.vertex.glsl +5 -5
- package/src/shaders/glsl/symbol_icon.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/symbol_sdf.vertex.glsl +5 -5
- package/src/shaders/glsl/symbol_sdf.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/symbol_text_and_icon.vertex.glsl +6 -6
- package/src/shaders/glsl/symbol_text_and_icon.vertex.glsl.g.ts +1 -1
- package/src/source/canvas_source.test.ts +32 -1
- package/src/source/canvas_source.ts +2 -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 +97 -5
- package/src/source/geojson_worker_source.ts +22 -39
- package/src/source/image_source.test.ts +205 -10
- package/src/source/image_source.ts +118 -4
- package/src/source/raster_dem_tile_source.test.ts +2 -2
- package/src/source/raster_dem_tile_worker_source.test.ts +1 -1
- 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 +101 -7
- package/src/source/vector_tile_worker_source.ts +18 -27
- package/src/source/video_source.test.ts +12 -8
- package/src/source/worker.test.ts +1 -1
- package/src/source/worker_tile.bench.ts +10 -0
- package/src/source/worker_tile.test.ts +4 -2
- package/src/source/worker_tile.ts +0 -3
- package/src/style/create_style_layer.bench.ts +15 -0
- package/src/style/load_glyph_range.test.ts +8 -8
- package/src/style/load_sprite.test.ts +1 -1
- package/src/style/properties.bench.ts +81 -0
- package/src/style/style.test.ts +47 -44
- package/src/style/style_image.ts +67 -9
- 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.bench.ts +65 -0
- package/src/style/style_layer.test.ts +4 -51
- package/src/style/style_layer.ts +2 -2
- package/src/style/validate_style.bench.ts +11 -0
- package/src/style/validate_style.test.ts +2 -2
- package/src/symbol/anchor.test.ts +2 -2
- package/src/symbol/collision_index.bench.ts +116 -0
- package/src/symbol/collision_index.test.ts +1 -1
- package/src/symbol/cross_tile_symbol_index.bench.ts +49 -0
- package/src/symbol/grid_index.test.ts +1 -1
- package/src/symbol/shaping.test.ts +2 -1
- package/src/symbol/symbol_layout.bench.ts +30 -0
- package/src/tile/terrain_tile_manager.test.ts +2 -2
- package/src/tile/tile_id.test.ts +6 -6
- package/src/tile/tile_manager.test.ts +85 -72
- package/src/tile/tile_manager.ts +2 -2
- package/src/tile/tile_manager_in_view_tiles.test.ts +2 -2
- package/src/ui/camera.test.ts +137 -134
- package/src/ui/control/fullscreen_control.test.ts +10 -10
- package/src/ui/control/geolocate_control.test.ts +9 -34
- package/src/ui/control/globe_control.test.ts +6 -6
- package/src/ui/events.ts +1 -1
- package/src/ui/handler/dblclick_zoom.test.ts +2 -2
- package/src/ui/handler/scroll_zoom.test.ts +52 -0
- package/src/ui/handler/two_fingers_touch.test.ts +3 -3
- package/src/ui/handler_manager.test.ts +250 -10
- package/src/ui/handler_manager.ts +79 -16
- package/src/ui/hash.test.ts +1 -0
- package/src/ui/map.ts +45 -21
- 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_cross_window.test.ts +2 -2
- package/src/ui/map_tests/map_events.test.ts +8 -8
- package/src/ui/map_tests/map_global_state.test.ts +3 -3
- package/src/ui/map_tests/map_images.test.ts +32 -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 +18 -9
- package/src/ui/map_tests/map_terrain.test.ts +20 -0
- package/src/ui/map_tests/map_webgl.test.ts +29 -0
- package/src/ui/map_tests/map_zoom.test.ts +15 -15
- package/src/ui/marker.test.ts +33 -55
- package/src/ui/popup.test.ts +17 -17
- 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 +37 -29
- package/src/util/evented.ts +69 -43
- 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/null_gl.ts +10 -0
- package/src/util/test/util.ts +3 -1
- 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 +28 -14
- package/src/util/verticalize_punctuation.test.ts +4 -4
- package/src/util/web_worker_transfer.test.ts +10 -10
- package/src/webgl/context.ts +20 -0
- 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_raster.ts +11 -6
- package/src/webgl/draw/draw_symbol.test.ts +16 -16
- package/src/webgl/program/raster_program.ts +11 -0
- package/src/webgl/program.ts +31 -14
- package/src/webgl/render_to_texture.test.ts +5 -5
- package/src/webgl/state.test.ts +1 -1
- package/src/webgl/texture.test.ts +19 -4
- package/src/webgl/texture.ts +3 -0
- package/src/webgl/vertex_buffer.test.ts +18 -3
- package/src/webgl/vertex_buffer.ts +24 -13
- package/build/rolldown_plugins.ts +0 -18
|
@@ -1,6 +1,6 @@
|
|
|
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.3.0/LICENSE.txt
|
|
4
4
|
*/
|
|
5
5
|
//#region \0rolldown/runtime.js
|
|
6
6
|
var __create = Object.create;
|
|
@@ -20,7 +20,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
20
20
|
}
|
|
21
21
|
return to;
|
|
22
22
|
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
24
24
|
value: mod,
|
|
25
25
|
enumerable: true
|
|
26
26
|
}) : target, mod));
|
|
@@ -380,13 +380,13 @@ function isOffscreenCanvasDistorted() {
|
|
|
380
380
|
const size = 5;
|
|
381
381
|
const context = new OffscreenCanvas(size, size).getContext("2d", { willReadFrequently: true });
|
|
382
382
|
if (context) {
|
|
383
|
-
for (let i = 0; i <
|
|
383
|
+
for (let i = 0; i < 25; i++) {
|
|
384
384
|
const base = i * 4;
|
|
385
385
|
context.fillStyle = `rgb(${base},${base + 1},${base + 2})`;
|
|
386
386
|
context.fillRect(i % size, Math.floor(i / size), 1, 1);
|
|
387
387
|
}
|
|
388
388
|
const data = context.getImageData(0, 0, size, size).data;
|
|
389
|
-
for (let i = 0; i <
|
|
389
|
+
for (let i = 0; i < 100; i++) if (i % 4 !== 3 && data[i] !== i) {
|
|
390
390
|
offscreenCanvasDistorted = true;
|
|
391
391
|
break;
|
|
392
392
|
}
|
|
@@ -436,6 +436,15 @@ function invert$5(out, a) {
|
|
|
436
436
|
return out;
|
|
437
437
|
}
|
|
438
438
|
/**
|
|
439
|
+
* Calculates the determinant of a mat2
|
|
440
|
+
*
|
|
441
|
+
* @param {ReadonlyMat2} a the source matrix
|
|
442
|
+
* @returns {Number} determinant of a
|
|
443
|
+
*/
|
|
444
|
+
function determinant$3(a) {
|
|
445
|
+
return a[0] * a[3] - a[2] * a[1];
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
439
448
|
* Rotates a mat2 by the given angle
|
|
440
449
|
*
|
|
441
450
|
* @param {mat2} out the receiving matrix
|
|
@@ -1778,6 +1787,18 @@ function create() {
|
|
|
1778
1787
|
return out;
|
|
1779
1788
|
}
|
|
1780
1789
|
/**
|
|
1790
|
+
* Creates a new vec2 initialized with values from an existing vector
|
|
1791
|
+
*
|
|
1792
|
+
* @param {ReadonlyVec2} a vector to clone
|
|
1793
|
+
* @returns {vec2} a new 2D vector
|
|
1794
|
+
*/
|
|
1795
|
+
function clone$1(a) {
|
|
1796
|
+
var out = new ARRAY_TYPE(2);
|
|
1797
|
+
out[0] = a[0];
|
|
1798
|
+
out[1] = a[1];
|
|
1799
|
+
return out;
|
|
1800
|
+
}
|
|
1801
|
+
/**
|
|
1781
1802
|
* Creates a new vec2 initialized with the given values
|
|
1782
1803
|
*
|
|
1783
1804
|
* @param {Number} x X component
|
|
@@ -1791,6 +1812,32 @@ function fromValues(x, y) {
|
|
|
1791
1812
|
return out;
|
|
1792
1813
|
}
|
|
1793
1814
|
/**
|
|
1815
|
+
* Adds two vec2's
|
|
1816
|
+
*
|
|
1817
|
+
* @param {vec2} out the receiving vector
|
|
1818
|
+
* @param {ReadonlyVec2} a the first operand
|
|
1819
|
+
* @param {ReadonlyVec2} b the second operand
|
|
1820
|
+
* @returns {vec2} out
|
|
1821
|
+
*/
|
|
1822
|
+
function add(out, a, b) {
|
|
1823
|
+
out[0] = a[0] + b[0];
|
|
1824
|
+
out[1] = a[1] + b[1];
|
|
1825
|
+
return out;
|
|
1826
|
+
}
|
|
1827
|
+
/**
|
|
1828
|
+
* Subtracts vector b from vector a
|
|
1829
|
+
*
|
|
1830
|
+
* @param {vec2} out the receiving vector
|
|
1831
|
+
* @param {ReadonlyVec2} a the first operand
|
|
1832
|
+
* @param {ReadonlyVec2} b the second operand
|
|
1833
|
+
* @returns {vec2} out
|
|
1834
|
+
*/
|
|
1835
|
+
function subtract(out, a, b) {
|
|
1836
|
+
out[0] = a[0] - b[0];
|
|
1837
|
+
out[1] = a[1] - b[1];
|
|
1838
|
+
return out;
|
|
1839
|
+
}
|
|
1840
|
+
/**
|
|
1794
1841
|
* Scales a vec2 by a scalar number
|
|
1795
1842
|
*
|
|
1796
1843
|
* @param {vec2} out the receiving vector
|
|
@@ -1804,6 +1851,20 @@ function scale(out, a, b) {
|
|
|
1804
1851
|
return out;
|
|
1805
1852
|
}
|
|
1806
1853
|
/**
|
|
1854
|
+
* Adds two vec2's after scaling the second operand by a scalar value
|
|
1855
|
+
*
|
|
1856
|
+
* @param {vec2} out the receiving vector
|
|
1857
|
+
* @param {ReadonlyVec2} a the first operand
|
|
1858
|
+
* @param {ReadonlyVec2} b the second operand
|
|
1859
|
+
* @param {Number} scale the amount to scale b by before adding
|
|
1860
|
+
* @returns {vec2} out
|
|
1861
|
+
*/
|
|
1862
|
+
function scaleAndAdd(out, a, b, scale) {
|
|
1863
|
+
out[0] = a[0] + b[0] * scale;
|
|
1864
|
+
out[1] = a[1] + b[1] * scale;
|
|
1865
|
+
return out;
|
|
1866
|
+
}
|
|
1867
|
+
/**
|
|
1807
1868
|
* Calculates the length of a vec2
|
|
1808
1869
|
*
|
|
1809
1870
|
* @param {ReadonlyVec2} a vector to calculate length of
|
|
@@ -1824,6 +1885,21 @@ function squaredLength(a) {
|
|
|
1824
1885
|
return x * x + y * y;
|
|
1825
1886
|
}
|
|
1826
1887
|
/**
|
|
1888
|
+
* Normalize a vec2
|
|
1889
|
+
*
|
|
1890
|
+
* @param {vec2} out the receiving vector
|
|
1891
|
+
* @param {ReadonlyVec2} a vector to normalize
|
|
1892
|
+
* @returns {vec2} out
|
|
1893
|
+
*/
|
|
1894
|
+
function normalize(out, a) {
|
|
1895
|
+
var x = a[0], y = a[1];
|
|
1896
|
+
var len = x * x + y * y;
|
|
1897
|
+
if (len > 0) len = 1 / Math.sqrt(len);
|
|
1898
|
+
out[0] = a[0] * len;
|
|
1899
|
+
out[1] = a[1] * len;
|
|
1900
|
+
return out;
|
|
1901
|
+
}
|
|
1902
|
+
/**
|
|
1827
1903
|
* Calculates the dot product of two vec2's
|
|
1828
1904
|
*
|
|
1829
1905
|
* @param {ReadonlyVec2} a the first operand
|
|
@@ -1834,23 +1910,30 @@ function dot$1(a, b) {
|
|
|
1834
1910
|
return a[0] * b[0] + a[1] * b[1];
|
|
1835
1911
|
}
|
|
1836
1912
|
/**
|
|
1837
|
-
*
|
|
1838
|
-
*
|
|
1839
|
-
*
|
|
1840
|
-
*
|
|
1841
|
-
* @param {
|
|
1842
|
-
* @param {ReadonlyVec2} a the vector to transform
|
|
1843
|
-
* @param {ReadonlyMat4} m matrix to transform with
|
|
1913
|
+
* Rotate a 2D vector
|
|
1914
|
+
* @param {vec2} out The receiving vec2
|
|
1915
|
+
* @param {ReadonlyVec2} a The vec2 point to rotate
|
|
1916
|
+
* @param {ReadonlyVec2} b The origin of the rotation
|
|
1917
|
+
* @param {Number} rad The angle of rotation in radians
|
|
1844
1918
|
* @returns {vec2} out
|
|
1845
1919
|
*/
|
|
1846
|
-
function
|
|
1847
|
-
var
|
|
1848
|
-
|
|
1849
|
-
out[
|
|
1850
|
-
out[1] = m[1] * x + m[5] * y + m[13];
|
|
1920
|
+
function rotate(out, a, b, rad) {
|
|
1921
|
+
var p0 = a[0] - b[0], p1 = a[1] - b[1], sinC = Math.sin(rad), cosC = Math.cos(rad);
|
|
1922
|
+
out[0] = p0 * cosC - p1 * sinC + b[0];
|
|
1923
|
+
out[1] = p0 * sinC + p1 * cosC + b[1];
|
|
1851
1924
|
return out;
|
|
1852
1925
|
}
|
|
1853
1926
|
/**
|
|
1927
|
+
* Get the smallest angle between two 2D vectors
|
|
1928
|
+
* @param {ReadonlyVec2} a The first operand
|
|
1929
|
+
* @param {ReadonlyVec2} b The second operand
|
|
1930
|
+
* @returns {Number} The angle in radians
|
|
1931
|
+
*/
|
|
1932
|
+
function angle(a, b) {
|
|
1933
|
+
var ax = a[0], ay = a[1], bx = b[0], by = b[1];
|
|
1934
|
+
return Math.abs(Math.atan2(ay * bx - ax * by, ax * bx + ay * by));
|
|
1935
|
+
}
|
|
1936
|
+
/**
|
|
1854
1937
|
* Set the components of a vec2 to zero
|
|
1855
1938
|
*
|
|
1856
1939
|
* @param {vec2} out the receiving vector
|
|
@@ -1862,6 +1945,11 @@ function zero(out) {
|
|
|
1862
1945
|
return out;
|
|
1863
1946
|
}
|
|
1864
1947
|
/**
|
|
1948
|
+
* Alias for {@link vec2.subtract}
|
|
1949
|
+
* @function
|
|
1950
|
+
*/
|
|
1951
|
+
var sub = subtract;
|
|
1952
|
+
/**
|
|
1865
1953
|
* Alias for {@link vec2.squaredLength}
|
|
1866
1954
|
* @function
|
|
1867
1955
|
*/
|
|
@@ -3088,23 +3176,23 @@ var Evented = class {
|
|
|
3088
3176
|
return this;
|
|
3089
3177
|
}
|
|
3090
3178
|
fire(event, properties) {
|
|
3091
|
-
|
|
3092
|
-
const type =
|
|
3179
|
+
const firedEvent = typeof event === "string" ? new Event(event, properties || {}) : event;
|
|
3180
|
+
const type = firedEvent.type;
|
|
3093
3181
|
if (this.listens(type)) {
|
|
3094
|
-
|
|
3095
|
-
const listeners = this._listeners?.[type]
|
|
3096
|
-
for (const listener of listeners) listener.call(this,
|
|
3097
|
-
const oneTimeListeners = this._oneTimeListeners?.[type]
|
|
3182
|
+
firedEvent.target = this;
|
|
3183
|
+
const listeners = this._listeners?.[type]?.slice() ?? [];
|
|
3184
|
+
for (const listener of listeners) listener.call(this, firedEvent);
|
|
3185
|
+
const oneTimeListeners = this._oneTimeListeners?.[type]?.slice() ?? [];
|
|
3098
3186
|
for (const listener of oneTimeListeners) {
|
|
3099
3187
|
_removeEventListener(type, listener, this._oneTimeListeners);
|
|
3100
|
-
listener.call(this,
|
|
3188
|
+
listener.call(this, firedEvent);
|
|
3101
3189
|
}
|
|
3102
3190
|
const parent = this._eventedParent;
|
|
3103
3191
|
if (parent) {
|
|
3104
|
-
extend(
|
|
3105
|
-
parent.fire(
|
|
3192
|
+
extend(firedEvent, typeof this._eventedParentData === "function" ? this._eventedParentData() : this._eventedParentData);
|
|
3193
|
+
parent.fire(firedEvent);
|
|
3106
3194
|
}
|
|
3107
|
-
} else if (
|
|
3195
|
+
} else if (firedEvent instanceof ErrorEvent) console.error(firedEvent.error);
|
|
3108
3196
|
return this;
|
|
3109
3197
|
}
|
|
3110
3198
|
/**
|
|
@@ -3114,7 +3202,7 @@ var Evented = class {
|
|
|
3114
3202
|
* @returns `true` if there is at least one registered listener for specified event type, `false` otherwise
|
|
3115
3203
|
*/
|
|
3116
3204
|
listens(type) {
|
|
3117
|
-
return this._listeners?.[type]?.length
|
|
3205
|
+
return Boolean(this._listeners?.[type]?.length || this._oneTimeListeners?.[type]?.length || this._eventedParent?.listens(type));
|
|
3118
3206
|
}
|
|
3119
3207
|
/**
|
|
3120
3208
|
* Bubble all events fired by this instance of Evented to this parent instance of Evented.
|
|
@@ -7510,14 +7598,12 @@ var Padding = class Padding {
|
|
|
7510
7598
|
input[1]
|
|
7511
7599
|
];
|
|
7512
7600
|
break;
|
|
7513
|
-
case 3:
|
|
7514
|
-
input
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
];
|
|
7520
|
-
break;
|
|
7601
|
+
case 3: input = [
|
|
7602
|
+
input[0],
|
|
7603
|
+
input[1],
|
|
7604
|
+
input[2],
|
|
7605
|
+
input[1]
|
|
7606
|
+
];
|
|
7521
7607
|
}
|
|
7522
7608
|
return new Padding(input);
|
|
7523
7609
|
}
|
|
@@ -9513,8 +9599,7 @@ function calculateSignedArea(ring) {
|
|
|
9513
9599
|
return sum;
|
|
9514
9600
|
}
|
|
9515
9601
|
const RE = 6378.137;
|
|
9516
|
-
const
|
|
9517
|
-
const E2 = FE * (2 - FE);
|
|
9602
|
+
const E2 = .0066943799901413165;
|
|
9518
9603
|
const RAD = Math.PI / 180;
|
|
9519
9604
|
var CheapRuler = class {
|
|
9520
9605
|
constructor(lat) {
|
|
@@ -9523,7 +9608,7 @@ var CheapRuler = class {
|
|
|
9523
9608
|
const w2 = 1 / (1 - E2 * (1 - coslat * coslat));
|
|
9524
9609
|
const w = Math.sqrt(w2);
|
|
9525
9610
|
this.kx = m * w * coslat;
|
|
9526
|
-
this.ky = m * w * w2 *
|
|
9611
|
+
this.ky = m * w * w2 * .9933056200098587;
|
|
9527
9612
|
}
|
|
9528
9613
|
/**
|
|
9529
9614
|
* Given two points of the form [longitude, latitude], returns the distance.
|
|
@@ -9860,9 +9945,7 @@ function pointToGeometryDistance(ctx, geometries) {
|
|
|
9860
9945
|
case "LineString":
|
|
9861
9946
|
dist = Math.min(dist, pointSetToPointSetDistance(pointPosition, false, geometry.coordinates, true, ruler, dist));
|
|
9862
9947
|
break;
|
|
9863
|
-
case "Polygon":
|
|
9864
|
-
dist = Math.min(dist, pointsToPolygonDistance(pointPosition, false, geometry.coordinates, ruler, dist));
|
|
9865
|
-
break;
|
|
9948
|
+
case "Polygon": dist = Math.min(dist, pointsToPolygonDistance(pointPosition, false, geometry.coordinates, ruler, dist));
|
|
9866
9949
|
}
|
|
9867
9950
|
if (dist === 0) return dist;
|
|
9868
9951
|
}
|
|
@@ -9882,9 +9965,7 @@ function lineStringToGeometryDistance(ctx, geometries) {
|
|
|
9882
9965
|
case "LineString":
|
|
9883
9966
|
dist = Math.min(dist, pointSetToPointSetDistance(linePositions, true, geometry.coordinates, true, ruler, dist));
|
|
9884
9967
|
break;
|
|
9885
|
-
case "Polygon":
|
|
9886
|
-
dist = Math.min(dist, pointsToPolygonDistance(linePositions, true, geometry.coordinates, ruler, dist));
|
|
9887
|
-
break;
|
|
9968
|
+
case "Polygon": dist = Math.min(dist, pointsToPolygonDistance(linePositions, true, geometry.coordinates, ruler, dist));
|
|
9888
9969
|
}
|
|
9889
9970
|
if (dist === 0) return dist;
|
|
9890
9971
|
}
|
|
@@ -9908,9 +9989,7 @@ function polygonToGeometryDistance(ctx, geometries) {
|
|
|
9908
9989
|
case "LineString":
|
|
9909
9990
|
dist = Math.min(dist, pointsToPolygonDistance(geometry.coordinates, true, polygon, ruler, dist));
|
|
9910
9991
|
break;
|
|
9911
|
-
case "Polygon":
|
|
9912
|
-
dist = Math.min(dist, polygonToPolygonDistance(polygon, geometry.coordinates, ruler, dist));
|
|
9913
|
-
break;
|
|
9992
|
+
case "Polygon": dist = Math.min(dist, polygonToPolygonDistance(polygon, geometry.coordinates, ruler, dist));
|
|
9914
9993
|
}
|
|
9915
9994
|
if (dist === 0) return dist;
|
|
9916
9995
|
}
|
|
@@ -11227,12 +11306,10 @@ function findMixedLegacyFilter(filter, path = []) {
|
|
|
11227
11306
|
if (diagnostic) return diagnostic;
|
|
11228
11307
|
break;
|
|
11229
11308
|
}
|
|
11230
|
-
case "case":
|
|
11231
|
-
|
|
11232
|
-
|
|
11233
|
-
|
|
11234
|
-
}
|
|
11235
|
-
break;
|
|
11309
|
+
case "case": for (let i = 1; i < filter.length - 1; i += 2) {
|
|
11310
|
+
const diagnostic = checkChild(i, path, filter);
|
|
11311
|
+
if (diagnostic) return diagnostic;
|
|
11312
|
+
}
|
|
11236
11313
|
}
|
|
11237
11314
|
return null;
|
|
11238
11315
|
}
|
|
@@ -11336,148 +11413,6 @@ function convertHasOp$1(property) {
|
|
|
11336
11413
|
function convertNegation(filter) {
|
|
11337
11414
|
return ["!", filter];
|
|
11338
11415
|
}
|
|
11339
|
-
function convertFilter(filter, expectedTypes = {}) {
|
|
11340
|
-
if (isExpressionFilter(filter)) return filter;
|
|
11341
|
-
if (!filter) return true;
|
|
11342
|
-
const legacyFilter = filter;
|
|
11343
|
-
const legacyOp = legacyFilter[0];
|
|
11344
|
-
if (filter.length <= 1) return legacyOp !== "any";
|
|
11345
|
-
switch (legacyOp) {
|
|
11346
|
-
case "==":
|
|
11347
|
-
case "!=":
|
|
11348
|
-
case "<":
|
|
11349
|
-
case ">":
|
|
11350
|
-
case "<=":
|
|
11351
|
-
case ">=": {
|
|
11352
|
-
const [, property, value] = filter;
|
|
11353
|
-
return convertComparisonOp(property, value, legacyOp, expectedTypes);
|
|
11354
|
-
}
|
|
11355
|
-
case "any": {
|
|
11356
|
-
const [, ...conditions] = legacyFilter;
|
|
11357
|
-
return ["any", ...conditions.map((f) => {
|
|
11358
|
-
const types = {};
|
|
11359
|
-
const child = convertFilter(f, types);
|
|
11360
|
-
const typechecks = runtimeTypeChecks(types);
|
|
11361
|
-
return typechecks === true ? child : [
|
|
11362
|
-
"case",
|
|
11363
|
-
typechecks,
|
|
11364
|
-
child,
|
|
11365
|
-
false
|
|
11366
|
-
];
|
|
11367
|
-
})];
|
|
11368
|
-
}
|
|
11369
|
-
case "all": {
|
|
11370
|
-
const [, ...conditions] = legacyFilter;
|
|
11371
|
-
const children = conditions.map((f) => convertFilter(f, expectedTypes));
|
|
11372
|
-
return children.length > 1 ? ["all", ...children] : children[0];
|
|
11373
|
-
}
|
|
11374
|
-
case "none": {
|
|
11375
|
-
const [, ...conditions] = legacyFilter;
|
|
11376
|
-
return ["!", convertFilter(["any", ...conditions], {})];
|
|
11377
|
-
}
|
|
11378
|
-
case "in": {
|
|
11379
|
-
const [, property, ...values] = legacyFilter;
|
|
11380
|
-
return convertInOp(property, values);
|
|
11381
|
-
}
|
|
11382
|
-
case "!in": {
|
|
11383
|
-
const [, property, ...values] = legacyFilter;
|
|
11384
|
-
return convertInOp(property, values, true);
|
|
11385
|
-
}
|
|
11386
|
-
case "has": return convertHasOp(legacyFilter[1]);
|
|
11387
|
-
case "!has": return ["!", convertHasOp(legacyFilter[1])];
|
|
11388
|
-
default: return true;
|
|
11389
|
-
}
|
|
11390
|
-
}
|
|
11391
|
-
function runtimeTypeChecks(expectedTypes) {
|
|
11392
|
-
const conditions = [];
|
|
11393
|
-
for (const property in expectedTypes) {
|
|
11394
|
-
const get = property === "$id" ? ["id"] : ["get", property];
|
|
11395
|
-
conditions.push([
|
|
11396
|
-
"==",
|
|
11397
|
-
["typeof", get],
|
|
11398
|
-
expectedTypes[property]
|
|
11399
|
-
]);
|
|
11400
|
-
}
|
|
11401
|
-
if (conditions.length === 0) return true;
|
|
11402
|
-
if (conditions.length === 1) return conditions[0];
|
|
11403
|
-
return ["all", ...conditions];
|
|
11404
|
-
}
|
|
11405
|
-
function convertComparisonOp(property, value, op, expectedTypes) {
|
|
11406
|
-
let get;
|
|
11407
|
-
if (property === "$type") return [
|
|
11408
|
-
op,
|
|
11409
|
-
["geometry-type"],
|
|
11410
|
-
value
|
|
11411
|
-
];
|
|
11412
|
-
else if (property === "$id") get = ["id"];
|
|
11413
|
-
else get = ["get", property];
|
|
11414
|
-
if (expectedTypes && value !== null) expectedTypes[property] = typeof value;
|
|
11415
|
-
if (op === "==" && property !== "$id" && value === null) return [
|
|
11416
|
-
"all",
|
|
11417
|
-
["has", property],
|
|
11418
|
-
[
|
|
11419
|
-
"==",
|
|
11420
|
-
get,
|
|
11421
|
-
null
|
|
11422
|
-
]
|
|
11423
|
-
];
|
|
11424
|
-
else if (op === "!=" && property !== "$id" && value === null) return [
|
|
11425
|
-
"any",
|
|
11426
|
-
["!", ["has", property]],
|
|
11427
|
-
[
|
|
11428
|
-
"!=",
|
|
11429
|
-
get,
|
|
11430
|
-
null
|
|
11431
|
-
]
|
|
11432
|
-
];
|
|
11433
|
-
return [
|
|
11434
|
-
op,
|
|
11435
|
-
get,
|
|
11436
|
-
value
|
|
11437
|
-
];
|
|
11438
|
-
}
|
|
11439
|
-
function convertInOp(property, values, negate = false) {
|
|
11440
|
-
if (values.length === 0) return negate;
|
|
11441
|
-
let get;
|
|
11442
|
-
if (property === "$type") get = ["geometry-type"];
|
|
11443
|
-
else if (property === "$id") get = ["id"];
|
|
11444
|
-
else get = ["get", property];
|
|
11445
|
-
let uniformTypes = true;
|
|
11446
|
-
const type = typeof values[0];
|
|
11447
|
-
for (const value of values) if (typeof value !== type) {
|
|
11448
|
-
uniformTypes = false;
|
|
11449
|
-
break;
|
|
11450
|
-
}
|
|
11451
|
-
if (uniformTypes && (type === "string" || type === "number")) {
|
|
11452
|
-
const uniqueValues = values.sort().filter((v, i) => i === 0 || values[i - 1] !== v);
|
|
11453
|
-
return [
|
|
11454
|
-
"match",
|
|
11455
|
-
get,
|
|
11456
|
-
uniqueValues,
|
|
11457
|
-
!negate,
|
|
11458
|
-
negate
|
|
11459
|
-
];
|
|
11460
|
-
}
|
|
11461
|
-
if (negate) return ["all", ...values.map((v) => [
|
|
11462
|
-
"!=",
|
|
11463
|
-
get,
|
|
11464
|
-
v
|
|
11465
|
-
])];
|
|
11466
|
-
else return ["any", ...values.map((v) => [
|
|
11467
|
-
"==",
|
|
11468
|
-
get,
|
|
11469
|
-
v
|
|
11470
|
-
])];
|
|
11471
|
-
}
|
|
11472
|
-
function convertHasOp(property) {
|
|
11473
|
-
if (property === "$type") return true;
|
|
11474
|
-
else if (property === "$id") return [
|
|
11475
|
-
"!=",
|
|
11476
|
-
["id"],
|
|
11477
|
-
null
|
|
11478
|
-
];
|
|
11479
|
-
else return ["has", property];
|
|
11480
|
-
}
|
|
11481
11416
|
function stringify$1(obj) {
|
|
11482
11417
|
const type = typeof obj;
|
|
11483
11418
|
if (type === "number" || type === "boolean" || type === "string" || obj === void 0 || obj === null) return JSON.stringify(obj);
|
|
@@ -11881,7 +11816,6 @@ function validateNonExpressionFilter(options) {
|
|
|
11881
11816
|
type = getType(value[1]);
|
|
11882
11817
|
if (value.length !== 2) errors.push(new ValidationError(key, value, `filter array for "${value[0]}" operator must have 2 elements`));
|
|
11883
11818
|
else if (type !== "string") errors.push(new ValidationError(`${key}[1]`, value[1], `string expected, ${type} found`));
|
|
11884
|
-
break;
|
|
11885
11819
|
}
|
|
11886
11820
|
return errors;
|
|
11887
11821
|
}
|
|
@@ -12597,10 +12531,6 @@ function wrapCleanErrors(inner) {
|
|
|
12597
12531
|
return sortErrors(inner.apply(this, args));
|
|
12598
12532
|
};
|
|
12599
12533
|
}
|
|
12600
|
-
function resolveConstant(style, value) {
|
|
12601
|
-
if (typeof value === "string" && value[0] === "@") return resolveConstant(style, style.constants[value]);
|
|
12602
|
-
else return value;
|
|
12603
|
-
}
|
|
12604
12534
|
const visibilitySpec = {
|
|
12605
12535
|
type: "enum",
|
|
12606
12536
|
"property-type": "data-constant",
|
|
@@ -15180,7 +15110,6 @@ var RasterBoundsArray = class extends StructArrayLayout4i8 {};
|
|
|
15180
15110
|
var CircleLayoutArray = class extends StructArrayLayout2i4 {};
|
|
15181
15111
|
var FillLayoutArray = class extends StructArrayLayout2i4 {};
|
|
15182
15112
|
var FillExtrusionLayoutArray = class extends StructArrayLayout2i4i12 {};
|
|
15183
|
-
(class extends StructArrayLayout2i4 {});
|
|
15184
15113
|
var LineLayoutArray = class extends StructArrayLayout2i4ub8 {};
|
|
15185
15114
|
var LineExtLayoutArray = class extends StructArrayLayout2f8 {};
|
|
15186
15115
|
var PatternLayoutArray = class extends StructArrayLayout10ui20 {};
|
|
@@ -15750,8 +15679,10 @@ var SourceExpressionBinder = class {
|
|
|
15750
15679
|
}
|
|
15751
15680
|
}
|
|
15752
15681
|
upload(context) {
|
|
15753
|
-
if (this.paintVertexArray?.arrayBuffer.byteLength)
|
|
15754
|
-
|
|
15682
|
+
if (this.paintVertexArray?.arrayBuffer.byteLength) {
|
|
15683
|
+
if (this.paintVertexBuffer?.buffer) this.paintVertexBuffer.updateData(this.paintVertexArray);
|
|
15684
|
+
else this.paintVertexBuffer = context.createVertexBuffer(this.paintVertexArray, this.paintVertexAttributes, this.expression.isStateDependent);
|
|
15685
|
+
}
|
|
15755
15686
|
}
|
|
15756
15687
|
destroy() {
|
|
15757
15688
|
if (this.paintVertexBuffer) this.paintVertexBuffer.destroy();
|
|
@@ -15796,8 +15727,10 @@ var CompositeExpressionBinder = class {
|
|
|
15796
15727
|
}
|
|
15797
15728
|
}
|
|
15798
15729
|
upload(context) {
|
|
15799
|
-
if (this.paintVertexArray?.arrayBuffer.byteLength)
|
|
15800
|
-
|
|
15730
|
+
if (this.paintVertexArray?.arrayBuffer.byteLength) {
|
|
15731
|
+
if (this.paintVertexBuffer?.buffer) this.paintVertexBuffer.updateData(this.paintVertexArray);
|
|
15732
|
+
else this.paintVertexBuffer = context.createVertexBuffer(this.paintVertexArray, this.paintVertexAttributes, this.expression.isStateDependent);
|
|
15733
|
+
}
|
|
15801
15734
|
}
|
|
15802
15735
|
destroy() {
|
|
15803
15736
|
if (this.paintVertexBuffer) this.paintVertexBuffer.destroy();
|
|
@@ -16911,6 +16844,8 @@ var Texture = class {
|
|
|
16911
16844
|
gl.deleteTexture(this.texture);
|
|
16912
16845
|
this.texture = gl.createTexture();
|
|
16913
16846
|
this._ownedHandle = this.texture;
|
|
16847
|
+
this.filter = void 0;
|
|
16848
|
+
this.wrap = void 0;
|
|
16914
16849
|
}
|
|
16915
16850
|
gl.bindTexture(gl.TEXTURE_2D, this.texture);
|
|
16916
16851
|
context.pixelStoreUnpackFlipY.set(false);
|
|
@@ -17056,7 +16991,6 @@ var DEMData = class DEMData {
|
|
|
17056
16991
|
this.greenFactor = 25.6;
|
|
17057
16992
|
this.blueFactor = .1;
|
|
17058
16993
|
this.baseShift = 1e4;
|
|
17059
|
-
break;
|
|
17060
16994
|
}
|
|
17061
16995
|
for (let x = 0; x < dim; x++) {
|
|
17062
16996
|
this.data[this._idx(-1, x)] = this.data[this._idx(0, x)];
|
|
@@ -17129,17 +17063,13 @@ var DEMData = class DEMData {
|
|
|
17129
17063
|
case -1:
|
|
17130
17064
|
xMin = xMax - 1;
|
|
17131
17065
|
break;
|
|
17132
|
-
case 1:
|
|
17133
|
-
xMax = xMin + 1;
|
|
17134
|
-
break;
|
|
17066
|
+
case 1: xMax = xMin + 1;
|
|
17135
17067
|
}
|
|
17136
17068
|
switch (dy) {
|
|
17137
17069
|
case -1:
|
|
17138
17070
|
yMin = yMax - 1;
|
|
17139
17071
|
break;
|
|
17140
|
-
case 1:
|
|
17141
|
-
yMax = yMin + 1;
|
|
17142
|
-
break;
|
|
17072
|
+
case 1: yMax = yMin + 1;
|
|
17143
17073
|
}
|
|
17144
17074
|
const ox = -dx * this.dim;
|
|
17145
17075
|
const oy = -dy * this.dim;
|
|
@@ -18135,7 +18065,7 @@ var Subdivider = class {
|
|
|
18135
18065
|
for (let i = 0; i < flattened.length; i += 2) {
|
|
18136
18066
|
const vy = flattened[i + 1];
|
|
18137
18067
|
if (vy === -32768) flattened[i + 1] = -32767;
|
|
18138
|
-
if (vy === 32767) flattened[i + 1] =
|
|
18068
|
+
if (vy === 32767) flattened[i + 1] = 32766;
|
|
18139
18069
|
}
|
|
18140
18070
|
}
|
|
18141
18071
|
/**
|
|
@@ -18365,8 +18295,10 @@ function subdivideVertexLine(linePoints, granularity, isRing = false) {
|
|
|
18365
18295
|
const first = linePoints[0];
|
|
18366
18296
|
const last = linePoints[linePoints.length - 1];
|
|
18367
18297
|
const addLastToFirstSegment = isRing && (first.x !== last.x || first.y !== last.y);
|
|
18368
|
-
if (granularity < 2)
|
|
18369
|
-
|
|
18298
|
+
if (granularity < 2) {
|
|
18299
|
+
if (addLastToFirstSegment) return [...linePoints, linePoints[0]];
|
|
18300
|
+
else return [...linePoints];
|
|
18301
|
+
}
|
|
18370
18302
|
const cellSize = Math.floor(EXTENT$1 / granularity);
|
|
18371
18303
|
const finalLineVertices = [];
|
|
18372
18304
|
finalLineVertices.push(new Point(linePoints[0].x, linePoints[0].y));
|
|
@@ -19108,69 +19040,473 @@ var VectorTile = class {
|
|
|
19108
19040
|
}
|
|
19109
19041
|
};
|
|
19110
19042
|
//#endregion
|
|
19111
|
-
//#region src/
|
|
19112
|
-
const
|
|
19113
|
-
|
|
19114
|
-
|
|
19115
|
-
|
|
19116
|
-
|
|
19117
|
-
|
|
19118
|
-
|
|
19119
|
-
|
|
19120
|
-
|
|
19121
|
-
|
|
19122
|
-
|
|
19123
|
-
|
|
19124
|
-
|
|
19125
|
-
|
|
19126
|
-
|
|
19127
|
-
|
|
19128
|
-
|
|
19129
|
-
|
|
19130
|
-
|
|
19131
|
-
|
|
19132
|
-
|
|
19133
|
-
|
|
19134
|
-
|
|
19135
|
-
|
|
19136
|
-
|
|
19137
|
-
|
|
19138
|
-
|
|
19139
|
-
|
|
19140
|
-
|
|
19141
|
-
|
|
19142
|
-
|
|
19143
|
-
index,
|
|
19144
|
-
geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature),
|
|
19145
|
-
properties: feature.properties,
|
|
19146
|
-
type: feature.type,
|
|
19147
|
-
patterns: {}
|
|
19148
|
-
};
|
|
19149
|
-
if (this.hasDependencies) this.features.push(addPatternDependencies("fill-extrusion", this.layers, bucketFeature, { zoom: this.zoom }, options));
|
|
19150
|
-
else this.addFeature(bucketFeature, bucketFeature.geometry, index, canonical, {}, options.subdivisionGranularity);
|
|
19151
|
-
options.featureIndex.insert(feature, bucketFeature.geometry, index, sourceLayerIndex, this.index, true);
|
|
19152
|
-
}
|
|
19153
|
-
}
|
|
19154
|
-
addFeatures(options, canonical, imagePositions) {
|
|
19155
|
-
for (const feature of this.features) {
|
|
19156
|
-
const { geometry } = feature;
|
|
19157
|
-
this.addFeature(feature, geometry, feature.index, canonical, imagePositions, options.subdivisionGranularity);
|
|
19158
|
-
}
|
|
19159
|
-
}
|
|
19160
|
-
update(states, vtLayer, imagePositions) {
|
|
19161
|
-
if (!this.stateDependentLayers.length) return;
|
|
19162
|
-
this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, { imagePositions });
|
|
19043
|
+
//#region src/geo/lng_lat.ts
|
|
19044
|
+
const earthRadius = 6371008.8;
|
|
19045
|
+
/**
|
|
19046
|
+
* A `LngLat` object represents a given longitude and latitude coordinate, measured in degrees.
|
|
19047
|
+
* These coordinates are based on the [WGS84 (EPSG:4326) standard](https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84).
|
|
19048
|
+
*
|
|
19049
|
+
* MapLibre GL JS uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match the
|
|
19050
|
+
* [GeoJSON specification](https://tools.ietf.org/html/rfc7946).
|
|
19051
|
+
*
|
|
19052
|
+
* Note that any MapLibre GL JS method that accepts a `LngLat` object as an argument or option
|
|
19053
|
+
* can also accept an `Array` of two numbers and will perform an implicit conversion.
|
|
19054
|
+
* This flexible type is documented as {@link LngLatLike}.
|
|
19055
|
+
*
|
|
19056
|
+
* @group Geography and Geometry
|
|
19057
|
+
*
|
|
19058
|
+
* @example
|
|
19059
|
+
* ```ts
|
|
19060
|
+
* let ll = new LngLat(-123.9749, 40.7736);
|
|
19061
|
+
* ll.lng; // = -123.9749
|
|
19062
|
+
* ```
|
|
19063
|
+
* @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/get-coordinates-of-the-mouse-pointer/)
|
|
19064
|
+
*/
|
|
19065
|
+
var LngLat = class LngLat {
|
|
19066
|
+
/**
|
|
19067
|
+
* @param lng - Longitude, measured in degrees.
|
|
19068
|
+
* @param lat - Latitude, measured in degrees.
|
|
19069
|
+
*/
|
|
19070
|
+
constructor(lng, lat) {
|
|
19071
|
+
if (isNaN(lng) || isNaN(lat)) throw new Error(`Invalid LngLat object: (${lng}, ${lat})`);
|
|
19072
|
+
this.lng = +lng;
|
|
19073
|
+
this.lat = +lat;
|
|
19074
|
+
if (this.lat > 90 || this.lat < -90) throw new Error("Invalid LngLat latitude value: must be between -90 and 90");
|
|
19163
19075
|
}
|
|
19164
|
-
|
|
19165
|
-
|
|
19076
|
+
/**
|
|
19077
|
+
* Returns a new `LngLat` object whose longitude is wrapped to the range (-180, 180).
|
|
19078
|
+
*
|
|
19079
|
+
* @returns The wrapped `LngLat` object.
|
|
19080
|
+
* @example
|
|
19081
|
+
* ```ts
|
|
19082
|
+
* let ll = new LngLat(286.0251, 40.7736);
|
|
19083
|
+
* let wrapped = ll.wrap();
|
|
19084
|
+
* wrapped.lng; // = -73.9749
|
|
19085
|
+
* ```
|
|
19086
|
+
*/
|
|
19087
|
+
wrap() {
|
|
19088
|
+
return new LngLat(wrap$1(this.lng, -180, 180), this.lat);
|
|
19166
19089
|
}
|
|
19167
|
-
|
|
19168
|
-
|
|
19090
|
+
/**
|
|
19091
|
+
* Returns the coordinates represented as an array of two numbers.
|
|
19092
|
+
*
|
|
19093
|
+
* @returns The coordinates represented as an array of longitude and latitude.
|
|
19094
|
+
* @example
|
|
19095
|
+
* ```ts
|
|
19096
|
+
* let ll = new LngLat(-73.9749, 40.7736);
|
|
19097
|
+
* ll.toArray(); // = [-73.9749, 40.7736]
|
|
19098
|
+
* ```
|
|
19099
|
+
*/
|
|
19100
|
+
toArray() {
|
|
19101
|
+
return [this.lng, this.lat];
|
|
19169
19102
|
}
|
|
19170
|
-
|
|
19171
|
-
|
|
19172
|
-
|
|
19173
|
-
|
|
19103
|
+
/**
|
|
19104
|
+
* Returns the coordinates represent as a string.
|
|
19105
|
+
*
|
|
19106
|
+
* @returns The coordinates represented as a string of the format `'LngLat(lng, lat)'`.
|
|
19107
|
+
* @example
|
|
19108
|
+
* ```ts
|
|
19109
|
+
* let ll = new LngLat(-73.9749, 40.7736);
|
|
19110
|
+
* ll.toString(); // = "LngLat(-73.9749, 40.7736)"
|
|
19111
|
+
* ```
|
|
19112
|
+
*/
|
|
19113
|
+
toString() {
|
|
19114
|
+
return `LngLat(${this.lng}, ${this.lat})`;
|
|
19115
|
+
}
|
|
19116
|
+
/**
|
|
19117
|
+
* Returns the approximate distance between a pair of coordinates in meters
|
|
19118
|
+
* Uses the Haversine Formula (from R.W. Sinnott, "Virtues of the Haversine", Sky and Telescope, vol. 68, no. 2, 1984, p. 159)
|
|
19119
|
+
*
|
|
19120
|
+
* @param lngLat - coordinates to compute the distance to
|
|
19121
|
+
* @returns Distance in meters between the two coordinates.
|
|
19122
|
+
* @example
|
|
19123
|
+
* ```ts
|
|
19124
|
+
* let new_york = new LngLat(-74.0060, 40.7128);
|
|
19125
|
+
* let los_angeles = new LngLat(-118.2437, 34.0522);
|
|
19126
|
+
* new_york.distanceTo(los_angeles); // = 3935751.690893987, "true distance" using a non-spherical approximation is ~3966km
|
|
19127
|
+
* ```
|
|
19128
|
+
*/
|
|
19129
|
+
distanceTo(lngLat) {
|
|
19130
|
+
const rad = Math.PI / 180;
|
|
19131
|
+
const lat1 = this.lat * rad;
|
|
19132
|
+
const lat2 = lngLat.lat * rad;
|
|
19133
|
+
const a = Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos((lngLat.lng - this.lng) * rad);
|
|
19134
|
+
return earthRadius * Math.acos(Math.min(a, 1));
|
|
19135
|
+
}
|
|
19136
|
+
/**
|
|
19137
|
+
* Converts an array of two numbers or an object with `lng` and `lat` or `lon` and `lat` properties
|
|
19138
|
+
* to a `LngLat` object.
|
|
19139
|
+
*
|
|
19140
|
+
* If a `LngLat` object is passed in, the function returns it unchanged.
|
|
19141
|
+
*
|
|
19142
|
+
* @param input - An array of two numbers or object to convert, or a `LngLat` object to return.
|
|
19143
|
+
* @returns A new `LngLat` object, if a conversion occurred, or the original `LngLat` object.
|
|
19144
|
+
* @example
|
|
19145
|
+
* ```ts
|
|
19146
|
+
* let arr = [-73.9749, 40.7736];
|
|
19147
|
+
* let ll = LngLat.convert(arr);
|
|
19148
|
+
* ll; // = LngLat {lng: -73.9749, lat: 40.7736}
|
|
19149
|
+
* ```
|
|
19150
|
+
*/
|
|
19151
|
+
static convert(input) {
|
|
19152
|
+
if (input instanceof LngLat) return input;
|
|
19153
|
+
if (Array.isArray(input) && (input.length === 2 || input.length === 3)) return new LngLat(Number(input[0]), Number(input[1]));
|
|
19154
|
+
if (!Array.isArray(input) && typeof input === "object" && input !== null) return new LngLat(Number("lng" in input ? input.lng : input.lon), Number(input.lat));
|
|
19155
|
+
throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]");
|
|
19156
|
+
}
|
|
19157
|
+
};
|
|
19158
|
+
//#endregion
|
|
19159
|
+
//#region src/geo/mercator_coordinate.ts
|
|
19160
|
+
const earthCircumference = 2 * Math.PI * earthRadius;
|
|
19161
|
+
function circumferenceAtLatitude(latitude) {
|
|
19162
|
+
return earthCircumference * Math.cos(latitude * Math.PI / 180);
|
|
19163
|
+
}
|
|
19164
|
+
function mercatorXfromLng(lng) {
|
|
19165
|
+
return (180 + lng) / 360;
|
|
19166
|
+
}
|
|
19167
|
+
function mercatorYfromLat(lat) {
|
|
19168
|
+
return (180 - 180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360))) / 360;
|
|
19169
|
+
}
|
|
19170
|
+
function mercatorZfromAltitude(altitude, lat) {
|
|
19171
|
+
return altitude / circumferenceAtLatitude(lat);
|
|
19172
|
+
}
|
|
19173
|
+
function lngFromMercatorX(x) {
|
|
19174
|
+
return x * 360 - 180;
|
|
19175
|
+
}
|
|
19176
|
+
function latFromMercatorY(y) {
|
|
19177
|
+
const y2 = 180 - y * 360;
|
|
19178
|
+
return 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
|
|
19179
|
+
}
|
|
19180
|
+
function altitudeFromMercatorZ(z, y) {
|
|
19181
|
+
return z * circumferenceAtLatitude(latFromMercatorY(y));
|
|
19182
|
+
}
|
|
19183
|
+
/**
|
|
19184
|
+
* Determine the Mercator scale factor for a given latitude, see
|
|
19185
|
+
* https://en.wikipedia.org/wiki/Mercator_projection#Scale_factor
|
|
19186
|
+
*
|
|
19187
|
+
* At the equator the scale factor will be 1, which increases at higher latitudes.
|
|
19188
|
+
*
|
|
19189
|
+
* @param lat - Latitude
|
|
19190
|
+
* @returns scale factor
|
|
19191
|
+
*/
|
|
19192
|
+
function mercatorScale(lat) {
|
|
19193
|
+
return 1 / Math.cos(lat * Math.PI / 180);
|
|
19194
|
+
}
|
|
19195
|
+
/**
|
|
19196
|
+
* A `MercatorCoordinate` object represents a projected three dimensional position.
|
|
19197
|
+
*
|
|
19198
|
+
* `MercatorCoordinate` uses the web mercator projection ([EPSG:3857](https://epsg.io/3857)) with slightly different units:
|
|
19199
|
+
*
|
|
19200
|
+
* - the size of 1 unit is the width of the projected world instead of the "mercator meter"
|
|
19201
|
+
* - the origin of the coordinate space is at the north-west corner instead of the middle
|
|
19202
|
+
*
|
|
19203
|
+
* For example, `MercatorCoordinate(0, 0, 0)` is the north-west corner of the mercator world and
|
|
19204
|
+
* `MercatorCoordinate(1, 1, 0)` is the south-east corner. If you are familiar with
|
|
19205
|
+
* [vector tiles](https://github.com/mapbox/vector-tile-spec) it may be helpful to think
|
|
19206
|
+
* of the coordinate space as the `0/0/0` tile with an extent of `1`.
|
|
19207
|
+
*
|
|
19208
|
+
* The `z` dimension of `MercatorCoordinate` is conformal. A cube in the mercator coordinate space would be rendered as a cube.
|
|
19209
|
+
*
|
|
19210
|
+
* @group Geography and Geometry
|
|
19211
|
+
*
|
|
19212
|
+
* @example
|
|
19213
|
+
* ```ts
|
|
19214
|
+
* let nullIsland = new MercatorCoordinate(0.5, 0.5, 0);
|
|
19215
|
+
* ```
|
|
19216
|
+
* @see [Add a custom style layer](https://maplibre.org/maplibre-gl-js/docs/examples/add-a-custom-style-layer/)
|
|
19217
|
+
* @see [Add a 3D model using three.js](https://maplibre.org/maplibre-gl-js/docs/examples/add-a-3d-model-using-threejs/)
|
|
19218
|
+
* @see [Add a simple custom layer on a globe](https://maplibre.org/maplibre-gl-js/docs/examples/add-a-simple-custom-layer-on-a-globe/)
|
|
19219
|
+
*/
|
|
19220
|
+
var MercatorCoordinate = class MercatorCoordinate {
|
|
19221
|
+
/**
|
|
19222
|
+
* @param x - The x component of the position.
|
|
19223
|
+
* @param y - The y component of the position.
|
|
19224
|
+
* @param z - The z component of the position.
|
|
19225
|
+
*/
|
|
19226
|
+
constructor(x, y, z = 0) {
|
|
19227
|
+
this.x = +x;
|
|
19228
|
+
this.y = +y;
|
|
19229
|
+
this.z = +z;
|
|
19230
|
+
}
|
|
19231
|
+
/**
|
|
19232
|
+
* Project a `LngLat` to a `MercatorCoordinate`.
|
|
19233
|
+
*
|
|
19234
|
+
* @param lngLatLike - The location to project.
|
|
19235
|
+
* @param altitude - The altitude in meters of the position.
|
|
19236
|
+
* @returns The projected mercator coordinate.
|
|
19237
|
+
* @example
|
|
19238
|
+
* ```ts
|
|
19239
|
+
* let coord = MercatorCoordinate.fromLngLat({ lng: 0, lat: 0}, 0);
|
|
19240
|
+
* coord; // MercatorCoordinate(0.5, 0.5, 0)
|
|
19241
|
+
* ```
|
|
19242
|
+
*/
|
|
19243
|
+
static fromLngLat(lngLatLike, altitude = 0) {
|
|
19244
|
+
const lngLat = LngLat.convert(lngLatLike);
|
|
19245
|
+
return new MercatorCoordinate(mercatorXfromLng(lngLat.lng), mercatorYfromLat(lngLat.lat), mercatorZfromAltitude(altitude, lngLat.lat));
|
|
19246
|
+
}
|
|
19247
|
+
/**
|
|
19248
|
+
* Returns the `LngLat` for the coordinate.
|
|
19249
|
+
*
|
|
19250
|
+
* @returns The `LngLat` object.
|
|
19251
|
+
* @example
|
|
19252
|
+
* ```ts
|
|
19253
|
+
* let coord = new MercatorCoordinate(0.5, 0.5, 0);
|
|
19254
|
+
* let lngLat = coord.toLngLat(); // LngLat(0, 0)
|
|
19255
|
+
* ```
|
|
19256
|
+
*/
|
|
19257
|
+
toLngLat() {
|
|
19258
|
+
return new LngLat(lngFromMercatorX(this.x), latFromMercatorY(this.y));
|
|
19259
|
+
}
|
|
19260
|
+
/**
|
|
19261
|
+
* Returns the altitude in meters of the coordinate.
|
|
19262
|
+
*
|
|
19263
|
+
* @returns The altitude in meters.
|
|
19264
|
+
* @example
|
|
19265
|
+
* ```ts
|
|
19266
|
+
* let coord = new MercatorCoordinate(0, 0, 0.02);
|
|
19267
|
+
* coord.toAltitude(); // 6914.281956295339
|
|
19268
|
+
* ```
|
|
19269
|
+
*/
|
|
19270
|
+
toAltitude() {
|
|
19271
|
+
return altitudeFromMercatorZ(this.z, this.y);
|
|
19272
|
+
}
|
|
19273
|
+
/**
|
|
19274
|
+
* Returns the distance of 1 meter in `MercatorCoordinate` units at this latitude.
|
|
19275
|
+
*
|
|
19276
|
+
* For coordinates in real world units using meters, this naturally provides the scale
|
|
19277
|
+
* to transform into `MercatorCoordinate`s.
|
|
19278
|
+
*
|
|
19279
|
+
* @returns Distance of 1 meter in `MercatorCoordinate` units.
|
|
19280
|
+
*/
|
|
19281
|
+
meterInMercatorCoordinateUnits() {
|
|
19282
|
+
return 1 / earthCircumference * mercatorScale(latFromMercatorY(this.y));
|
|
19283
|
+
}
|
|
19284
|
+
};
|
|
19285
|
+
//#endregion
|
|
19286
|
+
//#region src/geo/projection/mercator_utils.ts
|
|
19287
|
+
const maxMercatorHorizonAngle = 89.25;
|
|
19288
|
+
/**
|
|
19289
|
+
* Returns mercator coordinates in range 0..1 for given coordinates inside a specified tile.
|
|
19290
|
+
* @param inTileX - X coordinate in tile units - range [0..EXTENT].
|
|
19291
|
+
* @param inTileY - Y coordinate in tile units - range [0..EXTENT].
|
|
19292
|
+
* @param canonicalTileID - Tile canonical ID - mercator X, Y and zoom.
|
|
19293
|
+
* @returns Mercator coordinates of the specified point in range [0..1].
|
|
19294
|
+
*/
|
|
19295
|
+
function tileCoordinatesToMercatorCoordinates(inTileX, inTileY, canonicalTileID) {
|
|
19296
|
+
const scale = 1 / (1 << canonicalTileID.z);
|
|
19297
|
+
return new MercatorCoordinate(inTileX / EXTENT$1 * scale + canonicalTileID.x * scale, inTileY / EXTENT$1 * scale + canonicalTileID.y * scale);
|
|
19298
|
+
}
|
|
19299
|
+
/**
|
|
19300
|
+
* Returns LngLat for given in-tile coordinates and tile ID.
|
|
19301
|
+
* @param inTileX - X coordinate in tile units - range [0..EXTENT].
|
|
19302
|
+
* @param inTileY - Y coordinate in tile units - range [0..EXTENT].
|
|
19303
|
+
* @param canonicalTileID - Tile canonical ID - mercator X, Y and zoom.
|
|
19304
|
+
*/
|
|
19305
|
+
function tileCoordinatesToLocation(inTileX, inTileY, canonicalTileID) {
|
|
19306
|
+
return tileCoordinatesToMercatorCoordinates(inTileX, inTileY, canonicalTileID).toLngLat();
|
|
19307
|
+
}
|
|
19308
|
+
/**
|
|
19309
|
+
* Convert from LngLat to world coordinates (Mercator coordinates scaled by world size).
|
|
19310
|
+
* @param worldSize - Mercator world size computed from zoom level and tile size.
|
|
19311
|
+
* @param lnglat - The location to convert.
|
|
19312
|
+
* @returns Point
|
|
19313
|
+
*/
|
|
19314
|
+
function projectToWorldCoordinates(worldSize, lnglat) {
|
|
19315
|
+
const lat = clamp$2(lnglat.lat, -85.051129, MAX_VALID_LATITUDE);
|
|
19316
|
+
return new Point(mercatorXfromLng(lnglat.lng) * worldSize, mercatorYfromLat(lat) * worldSize);
|
|
19317
|
+
}
|
|
19318
|
+
/**
|
|
19319
|
+
* Convert from world coordinates (mercator coordinates scaled by world size) to LngLat.
|
|
19320
|
+
* @param worldSize - Mercator world size computed from zoom level and tile size.
|
|
19321
|
+
* @param point - World coordinate.
|
|
19322
|
+
* @returns LngLat
|
|
19323
|
+
*/
|
|
19324
|
+
function unprojectFromWorldCoordinates(worldSize, point) {
|
|
19325
|
+
return new MercatorCoordinate(point.x / worldSize, point.y / worldSize).toLngLat();
|
|
19326
|
+
}
|
|
19327
|
+
/**
|
|
19328
|
+
* Calculate pixel height of the visible horizon in relation to map-center (e.g. height/2),
|
|
19329
|
+
* multiplied by a static factor to simulate the earth-radius.
|
|
19330
|
+
* The calculated value is the horizontal line from the camera-height to sea-level.
|
|
19331
|
+
* @returns Horizon above center in pixels.
|
|
19332
|
+
*/
|
|
19333
|
+
function getMercatorHorizon(transform) {
|
|
19334
|
+
return transform.cameraToCenterDistance * Math.min(Math.tan(degreesToRadians(90 - transform.pitch)) * .85, Math.tan(degreesToRadians(maxMercatorHorizonAngle - transform.pitch)));
|
|
19335
|
+
}
|
|
19336
|
+
function calculateTileMatrix(unwrappedTileID, worldSize) {
|
|
19337
|
+
const canonical = unwrappedTileID.canonical;
|
|
19338
|
+
const scale = worldSize / zoomScale(canonical.z);
|
|
19339
|
+
const unwrappedX = canonical.x + Math.pow(2, canonical.z) * unwrappedTileID.wrap;
|
|
19340
|
+
const worldMatrix = /* @__PURE__ */ new Float64Array(16);
|
|
19341
|
+
identity$2(worldMatrix);
|
|
19342
|
+
translate$2(worldMatrix, worldMatrix, [
|
|
19343
|
+
unwrappedX * scale,
|
|
19344
|
+
canonical.y * scale,
|
|
19345
|
+
0
|
|
19346
|
+
]);
|
|
19347
|
+
scale$5(worldMatrix, worldMatrix, [
|
|
19348
|
+
scale / EXTENT$1,
|
|
19349
|
+
scale / EXTENT$1,
|
|
19350
|
+
1
|
|
19351
|
+
]);
|
|
19352
|
+
return worldMatrix;
|
|
19353
|
+
}
|
|
19354
|
+
function cameraMercatorCoordinateFromCenterAndRotation(center, elevation, pitch, bearing, distance) {
|
|
19355
|
+
const centerMercator = MercatorCoordinate.fromLngLat(center, elevation);
|
|
19356
|
+
const dMercator = distance * mercatorZfromAltitude(1, center.lat);
|
|
19357
|
+
const { x, y, z } = cameraDirectionFromPitchBearing(pitch, bearing);
|
|
19358
|
+
const dxMercator = dMercator * -x;
|
|
19359
|
+
const dyMercator = dMercator * -y;
|
|
19360
|
+
const dzMercator = dMercator * -z;
|
|
19361
|
+
return new MercatorCoordinate(centerMercator.x + dxMercator, centerMercator.y + dyMercator, centerMercator.z + dzMercator);
|
|
19362
|
+
}
|
|
19363
|
+
function cameraDirectionFromPitchBearing(pitch, bearing) {
|
|
19364
|
+
const pitchRadians = degreesToRadians(pitch);
|
|
19365
|
+
const bearingRadians = degreesToRadians(bearing);
|
|
19366
|
+
const z = Math.cos(-pitchRadians);
|
|
19367
|
+
const h = Math.sin(pitchRadians);
|
|
19368
|
+
return {
|
|
19369
|
+
x: h * Math.sin(bearingRadians),
|
|
19370
|
+
y: -h * Math.cos(bearingRadians),
|
|
19371
|
+
z
|
|
19372
|
+
};
|
|
19373
|
+
}
|
|
19374
|
+
//#endregion
|
|
19375
|
+
//#region src/data/bucket/round_polygon_corners.ts
|
|
19376
|
+
/**
|
|
19377
|
+
* Rounds polygon corners by calculating arc points at each corner vertex.
|
|
19378
|
+
* @param polygon - Collection of polygon rings (outer ring and hole rings)
|
|
19379
|
+
* @param distanceInMeters - Desired corner rounding distance in meters
|
|
19380
|
+
* @param canonical - Canonical tile ID used for meter to tile unit conversion
|
|
19381
|
+
*/
|
|
19382
|
+
function roundPolygonCorners(polygon, distanceInMeters, canonical) {
|
|
19383
|
+
if (distanceInMeters <= 0 || !polygon || polygon.length === 0) return polygon;
|
|
19384
|
+
const distanceInTileUnits = getTileUnitsForMeters(distanceInMeters, canonical);
|
|
19385
|
+
return polygon.map((ring) => roundRing(ring, distanceInTileUnits));
|
|
19386
|
+
}
|
|
19387
|
+
function getTileUnitsForMeters(distanceInMeters, canonical) {
|
|
19388
|
+
const centerLocation = tileCoordinatesToLocation(EXTENT$1 / 2, EXTENT$1 / 2, canonical);
|
|
19389
|
+
const meterInMercator = MercatorCoordinate.fromLngLat(centerLocation).meterInMercatorCoordinateUnits();
|
|
19390
|
+
const tileUnitsPerMercator = (1 << canonical.z) * EXTENT$1;
|
|
19391
|
+
return distanceInMeters * meterInMercator * tileUnitsPerMercator;
|
|
19392
|
+
}
|
|
19393
|
+
function roundRing(ring, distanceInTileUnits) {
|
|
19394
|
+
if (!ring || ring.length < 3) return ring;
|
|
19395
|
+
const isClosed = ring[0].x === ring[ring.length - 1].x && ring[0].y === ring[ring.length - 1].y;
|
|
19396
|
+
const vertexCount = isClosed ? ring.length - 1 : ring.length;
|
|
19397
|
+
if (vertexCount < 3) return ring;
|
|
19398
|
+
const vertices = ring.map((p) => fromValues(p.x, p.y));
|
|
19399
|
+
const newRing = [];
|
|
19400
|
+
for (let i = 0; i < vertexCount; i++) {
|
|
19401
|
+
const prev = vertices[(i - 1 + vertexCount) % vertexCount];
|
|
19402
|
+
const current = vertices[i];
|
|
19403
|
+
const next = vertices[(i + 1) % vertexCount];
|
|
19404
|
+
appendRoundCorner(newRing, prev, current, next, distanceInTileUnits);
|
|
19405
|
+
}
|
|
19406
|
+
if (isClosed && newRing.length > 0) newRing.push(clone$1(newRing[0]));
|
|
19407
|
+
return newRing.map((p) => new Point(p[0], p[1]));
|
|
19408
|
+
}
|
|
19409
|
+
function appendRoundCorner(newRing, prev, current, next, distanceInTileUnits) {
|
|
19410
|
+
const ua = sub(create(), prev, current);
|
|
19411
|
+
const ub = sub(create(), next, current);
|
|
19412
|
+
const lenA = length(ua);
|
|
19413
|
+
const lenB = length(ub);
|
|
19414
|
+
if (lenA < 1e-6 || lenB < 1e-6) {
|
|
19415
|
+
newRing.push(clone$1(current));
|
|
19416
|
+
return;
|
|
19417
|
+
}
|
|
19418
|
+
scale(ua, ua, 1 / lenA);
|
|
19419
|
+
scale(ub, ub, 1 / lenB);
|
|
19420
|
+
const dot = dot$1(ua, ub);
|
|
19421
|
+
if (Math.abs(dot) > Math.cos(5 * Math.PI / 180)) {
|
|
19422
|
+
newRing.push(clone$1(current));
|
|
19423
|
+
return;
|
|
19424
|
+
}
|
|
19425
|
+
const maxEdgeLenPercent = .2;
|
|
19426
|
+
const r = Math.min(distanceInTileUnits, lenA * maxEdgeLenPercent, lenB * maxEdgeLenPercent);
|
|
19427
|
+
const tangentA = scaleAndAdd(create(), current, ua, r);
|
|
19428
|
+
const tangentB = scaleAndAdd(create(), current, ub, r);
|
|
19429
|
+
const bisector = add(create(), ua, ub);
|
|
19430
|
+
normalize(bisector, bisector);
|
|
19431
|
+
const cosHalfTheta = Math.sqrt((1 + dot) / 2);
|
|
19432
|
+
const center = scaleAndAdd(create(), current, bisector, r / cosHalfTheta);
|
|
19433
|
+
const radiusA = sub(create(), tangentA, center);
|
|
19434
|
+
const radiusB = sub(create(), tangentB, center);
|
|
19435
|
+
const sweepAngle = angle(radiusA, radiusB);
|
|
19436
|
+
const direction = Math.sign(radiusA[0] * radiusB[1] - radiusA[1] * radiusB[0]);
|
|
19437
|
+
const numSegments = Math.max(2, Math.ceil(sweepAngle / (Math.PI / 6) - 1e-6));
|
|
19438
|
+
for (let s = 0; s <= numSegments; s++) {
|
|
19439
|
+
const angle = direction * sweepAngle * (s / numSegments);
|
|
19440
|
+
newRing.push(rotate(create(), tangentA, center, angle));
|
|
19441
|
+
}
|
|
19442
|
+
}
|
|
19443
|
+
//#endregion
|
|
19444
|
+
//#region src/data/bucket/fill_extrusion_bucket.ts
|
|
19445
|
+
const EARCUT_MAX_RINGS = 500;
|
|
19446
|
+
const FACTOR = Math.pow(2, 13);
|
|
19447
|
+
function addVertex$1(vertexArray, x, y, nx, ny, nz, t, e) {
|
|
19448
|
+
vertexArray.emplaceBack(x, y, Math.floor(nx * FACTOR) * 2 + t, ny * FACTOR * 2, nz * FACTOR * 2, Math.round(e));
|
|
19449
|
+
}
|
|
19450
|
+
var FillExtrusionBucket = class {
|
|
19451
|
+
constructor(options) {
|
|
19452
|
+
this.zoom = options.zoom;
|
|
19453
|
+
this.overscaling = options.overscaling;
|
|
19454
|
+
this.layers = options.layers;
|
|
19455
|
+
this.layerIds = this.layers.map((layer) => layer.id);
|
|
19456
|
+
this.index = options.index;
|
|
19457
|
+
this.hasDependencies = false;
|
|
19458
|
+
this.layoutVertexArray = new FillExtrusionLayoutArray();
|
|
19459
|
+
this.centroidVertexArray = new PosArray();
|
|
19460
|
+
this.indexArray = new TriangleIndexArray();
|
|
19461
|
+
this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom);
|
|
19462
|
+
this.segments = new SegmentVector();
|
|
19463
|
+
this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);
|
|
19464
|
+
}
|
|
19465
|
+
populate(features, options, canonical) {
|
|
19466
|
+
this.features = [];
|
|
19467
|
+
this.hasDependencies = hasPattern("fill-extrusion", this.layers, options);
|
|
19468
|
+
const globalProperties = new EvaluationParameters(this.zoom);
|
|
19469
|
+
const layer = this.layers[0];
|
|
19470
|
+
const roundedCornerDistance = layer.layout.get("fill-extrusion-rounded-corner-distance");
|
|
19471
|
+
const needGeometry = layer._featureFilter.needGeometry;
|
|
19472
|
+
for (const { feature, id, index, sourceLayerIndex } of features) {
|
|
19473
|
+
const evaluationFeature = toEvaluationFeature(feature, needGeometry);
|
|
19474
|
+
if (!layer._featureFilter.filter(globalProperties, evaluationFeature, canonical)) continue;
|
|
19475
|
+
const rawGeometry = needGeometry ? evaluationFeature.geometry : loadGeometry(feature);
|
|
19476
|
+
const bucketFeature = {
|
|
19477
|
+
id,
|
|
19478
|
+
sourceLayerIndex,
|
|
19479
|
+
index,
|
|
19480
|
+
geometry: roundedCornerDistance > 0 ? roundPolygonCorners(rawGeometry, roundedCornerDistance, canonical) : rawGeometry,
|
|
19481
|
+
properties: feature.properties,
|
|
19482
|
+
type: feature.type,
|
|
19483
|
+
patterns: {}
|
|
19484
|
+
};
|
|
19485
|
+
if (this.hasDependencies) this.features.push(addPatternDependencies("fill-extrusion", this.layers, bucketFeature, { zoom: this.zoom }, options));
|
|
19486
|
+
else this.addFeature(bucketFeature, bucketFeature.geometry, index, canonical, {}, options.subdivisionGranularity);
|
|
19487
|
+
options.featureIndex.insert(feature, bucketFeature.geometry, index, sourceLayerIndex, this.index, true);
|
|
19488
|
+
}
|
|
19489
|
+
}
|
|
19490
|
+
addFeatures(options, canonical, imagePositions) {
|
|
19491
|
+
for (const feature of this.features) {
|
|
19492
|
+
const { geometry } = feature;
|
|
19493
|
+
this.addFeature(feature, geometry, feature.index, canonical, imagePositions, options.subdivisionGranularity);
|
|
19494
|
+
}
|
|
19495
|
+
}
|
|
19496
|
+
update(states, vtLayer, imagePositions) {
|
|
19497
|
+
if (!this.stateDependentLayers.length) return;
|
|
19498
|
+
this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, { imagePositions });
|
|
19499
|
+
}
|
|
19500
|
+
isEmpty() {
|
|
19501
|
+
return this.layoutVertexArray.length === 0 && this.centroidVertexArray.length === 0;
|
|
19502
|
+
}
|
|
19503
|
+
uploadPending() {
|
|
19504
|
+
return !this.uploaded || this.programConfigurations.needsUpload;
|
|
19505
|
+
}
|
|
19506
|
+
upload(context) {
|
|
19507
|
+
if (!this.uploaded) {
|
|
19508
|
+
this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, members$2);
|
|
19509
|
+
this.centroidVertexBuffer = context.createVertexBuffer(this.centroidVertexArray, centroidAttributes.members, true);
|
|
19174
19510
|
this.indexBuffer = context.createIndexBuffer(this.indexArray);
|
|
19175
19511
|
}
|
|
19176
19512
|
this.programConfigurations.upload(context);
|
|
@@ -19185,7 +19521,10 @@ var FillExtrusionBucket = class {
|
|
|
19185
19521
|
this.centroidVertexBuffer.destroy();
|
|
19186
19522
|
}
|
|
19187
19523
|
addFeature(feature, geometry, index, canonical, imagePositions, subdivisionGranularity) {
|
|
19188
|
-
|
|
19524
|
+
const layer = this.layers[0];
|
|
19525
|
+
const roundedCornerDistance = layer.layout ? layer.layout.get("fill-extrusion-rounded-corner-distance") : 0;
|
|
19526
|
+
const processedGeometry = roundedCornerDistance > 0 ? roundPolygonCorners(geometry, roundedCornerDistance, canonical) : geometry;
|
|
19527
|
+
for (const polygon of classifyRings$1(processedGeometry, EARCUT_MAX_RINGS)) {
|
|
19189
19528
|
const centroid = {
|
|
19190
19529
|
x: 0,
|
|
19191
19530
|
y: 0,
|
|
@@ -19538,9 +19877,7 @@ function createFeature(id, type, geom, tags) {
|
|
|
19538
19877
|
case "MultiLineString":
|
|
19539
19878
|
for (const line of data.geom) calcLineBBox(feature, line.points);
|
|
19540
19879
|
break;
|
|
19541
|
-
case "MultiPolygon":
|
|
19542
|
-
for (const polygon of data.geom) calcLineBBox(feature, polygon[0].points);
|
|
19543
|
-
break;
|
|
19880
|
+
case "MultiPolygon": for (const polygon of data.geom) calcLineBBox(feature, polygon[0].points);
|
|
19544
19881
|
}
|
|
19545
19882
|
return feature;
|
|
19546
19883
|
}
|
|
@@ -20201,7 +20538,7 @@ var KDBush = class KDBush {
|
|
|
20201
20538
|
this.coords = new ArrayType(data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2);
|
|
20202
20539
|
this._pos = 0;
|
|
20203
20540
|
this._finished = false;
|
|
20204
|
-
new Uint8Array(data, 0, 2).set([219,
|
|
20541
|
+
new Uint8Array(data, 0, 2).set([219, 16 + arrayTypeIndex]);
|
|
20205
20542
|
new Uint16Array(data, 2, 1)[0] = nodeSize;
|
|
20206
20543
|
new Uint32Array(data, 4, 1)[0] = numItems;
|
|
20207
20544
|
}
|
|
@@ -21364,9 +21701,8 @@ const EXTRUDE_SCALE = 63;
|
|
|
21364
21701
|
const COS_HALF_SHARP_CORNER = Math.cos(75 / 2 * (Math.PI / 180));
|
|
21365
21702
|
const SHARP_CORNER_OFFSET = 15;
|
|
21366
21703
|
const DEG_PER_TRIANGLE = 20;
|
|
21367
|
-
const LINE_DISTANCE_BUFFER_BITS = 15;
|
|
21368
21704
|
const LINE_DISTANCE_SCALE = 1 / 2;
|
|
21369
|
-
const MAX_LINE_DISTANCE = Math.pow(2,
|
|
21705
|
+
const MAX_LINE_DISTANCE = Math.pow(2, 14) / LINE_DISTANCE_SCALE;
|
|
21370
21706
|
/**
|
|
21371
21707
|
* @internal
|
|
21372
21708
|
* Line bucket class
|
|
@@ -22336,8 +22672,10 @@ function getGlyphAdvance(codePoint, section, glyphMap, imagePositions, spacing,
|
|
|
22336
22672
|
}
|
|
22337
22673
|
function calculateBadness(lineWidth, targetWidth, penalty, isLastBreak) {
|
|
22338
22674
|
const raggedness = Math.pow(lineWidth - targetWidth, 2);
|
|
22339
|
-
if (isLastBreak)
|
|
22340
|
-
|
|
22675
|
+
if (isLastBreak) {
|
|
22676
|
+
if (lineWidth < targetWidth) return raggedness / 2;
|
|
22677
|
+
else return raggedness * 2;
|
|
22678
|
+
}
|
|
22341
22679
|
return raggedness + Math.abs(penalty) * penalty;
|
|
22342
22680
|
}
|
|
22343
22681
|
function calculatePenalty(codePoint, nextCodePoint, penalizableIdeographicBreak) {
|
|
@@ -22528,7 +22866,7 @@ var TaggedString = class TaggedString {
|
|
|
22528
22866
|
};
|
|
22529
22867
|
//#endregion
|
|
22530
22868
|
//#region node_modules/pbf/index.js
|
|
22531
|
-
const SHIFT_LEFT_32 =
|
|
22869
|
+
const SHIFT_LEFT_32 = 4294967296;
|
|
22532
22870
|
const SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;
|
|
22533
22871
|
const TEXT_DECODER_MIN_LENGTH$1 = 12;
|
|
22534
22872
|
const utf8TextDecoder$1 = typeof TextDecoder === "undefined" ? null : new TextDecoder("utf-8");
|
|
@@ -23263,25 +23601,27 @@ function readUtf8$1(buf, pos, end) {
|
|
|
23263
23601
|
function writeUtf8(buf, str, pos) {
|
|
23264
23602
|
for (let i = 0, c, lead; i < str.length; i++) {
|
|
23265
23603
|
c = str.charCodeAt(i);
|
|
23266
|
-
if (c > 55295 && c < 57344)
|
|
23267
|
-
|
|
23268
|
-
|
|
23269
|
-
|
|
23270
|
-
|
|
23271
|
-
|
|
23272
|
-
|
|
23273
|
-
|
|
23274
|
-
|
|
23275
|
-
|
|
23276
|
-
|
|
23277
|
-
|
|
23278
|
-
|
|
23279
|
-
|
|
23280
|
-
|
|
23281
|
-
|
|
23282
|
-
|
|
23283
|
-
|
|
23284
|
-
|
|
23604
|
+
if (c > 55295 && c < 57344) {
|
|
23605
|
+
if (lead) {
|
|
23606
|
+
if (c < 56320) {
|
|
23607
|
+
buf[pos++] = 239;
|
|
23608
|
+
buf[pos++] = 191;
|
|
23609
|
+
buf[pos++] = 189;
|
|
23610
|
+
lead = c;
|
|
23611
|
+
continue;
|
|
23612
|
+
} else {
|
|
23613
|
+
c = lead - 55296 << 10 | c - 56320 | 65536;
|
|
23614
|
+
lead = null;
|
|
23615
|
+
}
|
|
23616
|
+
} else {
|
|
23617
|
+
if (c > 56319 || i + 1 === str.length) {
|
|
23618
|
+
buf[pos++] = 239;
|
|
23619
|
+
buf[pos++] = 191;
|
|
23620
|
+
buf[pos++] = 189;
|
|
23621
|
+
} else lead = c;
|
|
23622
|
+
continue;
|
|
23623
|
+
}
|
|
23624
|
+
} else if (lead) {
|
|
23285
23625
|
buf[pos++] = 239;
|
|
23286
23626
|
buf[pos++] = 191;
|
|
23287
23627
|
buf[pos++] = 189;
|
|
@@ -23303,9 +23643,6 @@ function writeUtf8(buf, str, pos) {
|
|
|
23303
23643
|
}
|
|
23304
23644
|
return pos;
|
|
23305
23645
|
}
|
|
23306
|
-
//#endregion
|
|
23307
|
-
//#region src/style/parse_glyph_pbf.ts
|
|
23308
|
-
const border$1 = 3;
|
|
23309
23646
|
function readFontstacks(tag, glyphs, pbf) {
|
|
23310
23647
|
if (tag === 1) pbf.readMessage(readFontstack, glyphs);
|
|
23311
23648
|
}
|
|
@@ -23315,8 +23652,8 @@ function readFontstack(tag, glyphs, pbf) {
|
|
|
23315
23652
|
glyphs.push({
|
|
23316
23653
|
id,
|
|
23317
23654
|
bitmap: new AlphaImage({
|
|
23318
|
-
width: width +
|
|
23319
|
-
height: height +
|
|
23655
|
+
width: width + 6,
|
|
23656
|
+
height: height + 6
|
|
23320
23657
|
}, bitmap),
|
|
23321
23658
|
metrics: {
|
|
23322
23659
|
width,
|
|
@@ -23340,15 +23677,15 @@ function readGlyph(tag, glyph, pbf) {
|
|
|
23340
23677
|
function parseGlyphPbf(data) {
|
|
23341
23678
|
return new PbfReader(data).readFields(readFontstacks, []);
|
|
23342
23679
|
}
|
|
23680
|
+
function isStyleImageWebGLData(data) {
|
|
23681
|
+
return typeof data?.renderWithWebGL === "function";
|
|
23682
|
+
}
|
|
23343
23683
|
function renderStyleImage(image) {
|
|
23344
23684
|
const { userImage } = image;
|
|
23345
|
-
if (userImage?.render)
|
|
23346
|
-
|
|
23347
|
-
|
|
23348
|
-
|
|
23349
|
-
}
|
|
23350
|
-
}
|
|
23351
|
-
return false;
|
|
23685
|
+
if (!userImage?.render) return false;
|
|
23686
|
+
if (!userImage.render()) return false;
|
|
23687
|
+
if (!isStyleImageWebGLData(userImage.data)) image.data.replace(new Uint8Array(userImage.data.buffer));
|
|
23688
|
+
return true;
|
|
23352
23689
|
}
|
|
23353
23690
|
//#endregion
|
|
23354
23691
|
//#region node_modules/potpack/index.js
|
|
@@ -23425,13 +23762,14 @@ function potpack(boxes) {
|
|
|
23425
23762
|
};
|
|
23426
23763
|
}
|
|
23427
23764
|
var ImagePosition = class {
|
|
23428
|
-
constructor(paddedRect, { pixelRatio, version, stretchX, stretchY, content, textFitWidth, textFitHeight }) {
|
|
23765
|
+
constructor(paddedRect, { pixelRatio, version, isWebGLImage = false, stretchX, stretchY, content, textFitWidth, textFitHeight }) {
|
|
23429
23766
|
this.paddedRect = paddedRect;
|
|
23430
23767
|
this.pixelRatio = pixelRatio;
|
|
23431
23768
|
this.stretchX = stretchX;
|
|
23432
23769
|
this.stretchY = stretchY;
|
|
23433
23770
|
this.content = content;
|
|
23434
23771
|
this.version = version;
|
|
23772
|
+
this.needsFirstWebGLRender = isWebGLImage;
|
|
23435
23773
|
this.textFitWidth = textFitWidth;
|
|
23436
23774
|
this.textFitHeight = textFitHeight;
|
|
23437
23775
|
}
|
|
@@ -23465,6 +23803,7 @@ var ImageAtlas = class {
|
|
|
23465
23803
|
});
|
|
23466
23804
|
for (const id in icons) {
|
|
23467
23805
|
const src = icons[id];
|
|
23806
|
+
if (src.isWebGLImage) continue;
|
|
23468
23807
|
const bin = iconPositions[id].paddedRect;
|
|
23469
23808
|
RGBAImage.copy(src.data, image, {
|
|
23470
23809
|
x: 0,
|
|
@@ -23553,13 +23892,29 @@ var ImageAtlas = class {
|
|
|
23553
23892
|
}
|
|
23554
23893
|
patchUpdatedImage(position, image, texture) {
|
|
23555
23894
|
if (!position || !image) return;
|
|
23556
|
-
if (position.version === image.version) return;
|
|
23895
|
+
if (!position.needsFirstWebGLRender && position.version === image.version) return;
|
|
23896
|
+
position.needsFirstWebGLRender = false;
|
|
23557
23897
|
position.version = image.version;
|
|
23558
23898
|
const [x, y] = position.tl;
|
|
23559
|
-
|
|
23899
|
+
const data = image.userImage?.data;
|
|
23900
|
+
if (!isStyleImageWebGLData(data)) {
|
|
23901
|
+
texture.update(image.data, void 0, {
|
|
23902
|
+
x,
|
|
23903
|
+
y
|
|
23904
|
+
});
|
|
23905
|
+
return;
|
|
23906
|
+
}
|
|
23907
|
+
const { width, height } = image.data;
|
|
23908
|
+
texture.context.setCustomLayerDefaults();
|
|
23909
|
+
data.renderWithWebGL({
|
|
23910
|
+
gl: texture.context.gl,
|
|
23911
|
+
texture: texture.texture,
|
|
23560
23912
|
x,
|
|
23561
|
-
y
|
|
23913
|
+
y,
|
|
23914
|
+
width,
|
|
23915
|
+
height
|
|
23562
23916
|
});
|
|
23917
|
+
texture.context.setDirty();
|
|
23563
23918
|
}
|
|
23564
23919
|
};
|
|
23565
23920
|
register("ImagePosition", ImagePosition);
|
|
@@ -23647,9 +24002,7 @@ function getAnchorAlignment(anchor) {
|
|
|
23647
24002
|
break;
|
|
23648
24003
|
case "left":
|
|
23649
24004
|
case "top-left":
|
|
23650
|
-
case "bottom-left":
|
|
23651
|
-
horizontalAlign = 0;
|
|
23652
|
-
break;
|
|
24005
|
+
case "bottom-left": horizontalAlign = 0;
|
|
23653
24006
|
}
|
|
23654
24007
|
switch (anchor) {
|
|
23655
24008
|
case "bottom":
|
|
@@ -23659,9 +24012,7 @@ function getAnchorAlignment(anchor) {
|
|
|
23659
24012
|
break;
|
|
23660
24013
|
case "top":
|
|
23661
24014
|
case "top-right":
|
|
23662
|
-
case "top-left":
|
|
23663
|
-
verticalAlign = 0;
|
|
23664
|
-
break;
|
|
24015
|
+
case "top-left": verticalAlign = 0;
|
|
23665
24016
|
}
|
|
23666
24017
|
return {
|
|
23667
24018
|
horizontalAlign,
|
|
@@ -24640,10 +24991,14 @@ var SymbolStyleLayer = class SymbolStyleLayer extends StyleLayer {
|
|
|
24640
24991
|
}
|
|
24641
24992
|
recalculate(parameters, availableImages) {
|
|
24642
24993
|
super.recalculate(parameters, availableImages);
|
|
24643
|
-
if (this.layout.get("icon-rotation-alignment") === "auto")
|
|
24644
|
-
|
|
24645
|
-
|
|
24646
|
-
|
|
24994
|
+
if (this.layout.get("icon-rotation-alignment") === "auto") {
|
|
24995
|
+
if (this.layout.get("symbol-placement") !== "point") this.layout._values["icon-rotation-alignment"] = "map";
|
|
24996
|
+
else this.layout._values["icon-rotation-alignment"] = "viewport";
|
|
24997
|
+
}
|
|
24998
|
+
if (this.layout.get("text-rotation-alignment") === "auto") {
|
|
24999
|
+
if (this.layout.get("symbol-placement") !== "point") this.layout._values["text-rotation-alignment"] = "map";
|
|
25000
|
+
else this.layout._values["text-rotation-alignment"] = "viewport";
|
|
25001
|
+
}
|
|
24647
25002
|
if (this.layout.get("text-pitch-alignment") === "auto") this.layout._values["text-pitch-alignment"] = this.layout.get("text-rotation-alignment") === "map" ? "map" : "viewport";
|
|
24648
25003
|
if (this.layout.get("icon-pitch-alignment") === "auto") this.layout._values["icon-pitch-alignment"] = this.layout.get("icon-rotation-alignment");
|
|
24649
25004
|
if (this.layout.get("symbol-placement") === "point") {
|
|
@@ -24720,501 +25075,258 @@ function getIconPadding(layout, feature, canonical, pixelRatio = 1) {
|
|
|
24720
25075
|
values[2] * pixelRatio,
|
|
24721
25076
|
values[3] * pixelRatio
|
|
24722
25077
|
];
|
|
24723
|
-
}
|
|
24724
|
-
//#endregion
|
|
24725
|
-
//#region src/style/style_layer/background_style_layer_properties.g.ts
|
|
24726
|
-
let paint;
|
|
24727
|
-
const getPaint = () => paint = paint || new Properties({
|
|
24728
|
-
"background-color": new DataConstantProperty(latest["paint_background"]["background-color"], "background-color"),
|
|
24729
|
-
"background-pattern": new CrossFadedProperty(latest["paint_background"]["background-pattern"], "background-pattern"),
|
|
24730
|
-
"background-opacity": new DataConstantProperty(latest["paint_background"]["background-opacity"], "background-opacity")
|
|
24731
|
-
});
|
|
24732
|
-
var background_style_layer_properties_g_default = { get paint() {
|
|
24733
|
-
return getPaint();
|
|
24734
|
-
} };
|
|
24735
|
-
//#endregion
|
|
24736
|
-
//#region src/style/style_layer/background_style_layer.ts
|
|
24737
|
-
const isBackgroundStyleLayer = (layer) => layer.type === "background";
|
|
24738
|
-
var BackgroundStyleLayer = class extends StyleLayer {
|
|
24739
|
-
constructor(layer, globalState) {
|
|
24740
|
-
super(layer, background_style_layer_properties_g_default, globalState);
|
|
24741
|
-
}
|
|
24742
|
-
};
|
|
24743
|
-
//#endregion
|
|
24744
|
-
//#region src/style/style_layer/custom_style_layer.ts
|
|
24745
|
-
function validateCustomStyleLayer(layerObject) {
|
|
24746
|
-
const errors = [];
|
|
24747
|
-
const id = layerObject.id;
|
|
24748
|
-
if (id === void 0) errors.push(new ValidationError(`layers.${id}`, null, "missing required property \"id\""));
|
|
24749
|
-
if (layerObject.render === void 0) errors.push(new ValidationError(`layers.${id}`, null, "missing required method \"render\""));
|
|
24750
|
-
if (layerObject.renderingMode && layerObject.renderingMode !== "2d" && layerObject.renderingMode !== "3d") errors.push(new ValidationError(`layers.${id}`, null, "property \"renderingMode\" must be either \"2d\" or \"3d\""));
|
|
24751
|
-
return errors;
|
|
24752
|
-
}
|
|
24753
|
-
const isCustomStyleLayer = (layer) => layer.type === "custom";
|
|
24754
|
-
var CustomStyleLayer = class extends StyleLayer {
|
|
24755
|
-
constructor(implementation, globalState) {
|
|
24756
|
-
super(implementation, {}, globalState);
|
|
24757
|
-
this.onAdd = (map) => {
|
|
24758
|
-
if (this.implementation.onAdd) this.implementation.onAdd(map, map.painter.context.gl);
|
|
24759
|
-
};
|
|
24760
|
-
this.onRemove = (map) => {
|
|
24761
|
-
if (this.implementation.onRemove) this.implementation.onRemove(map, map.painter.context.gl);
|
|
24762
|
-
};
|
|
24763
|
-
this.implementation = implementation;
|
|
24764
|
-
}
|
|
24765
|
-
is3D() {
|
|
24766
|
-
return this.implementation.renderingMode === "3d";
|
|
24767
|
-
}
|
|
24768
|
-
hasOffscreenPass() {
|
|
24769
|
-
return this.implementation.prerender !== void 0;
|
|
24770
|
-
}
|
|
24771
|
-
recalculate() {}
|
|
24772
|
-
updateTransitions() {}
|
|
24773
|
-
hasTransition() {
|
|
24774
|
-
return false;
|
|
24775
|
-
}
|
|
24776
|
-
serialize() {
|
|
24777
|
-
throw new Error("Custom layers cannot be serialized");
|
|
24778
|
-
}
|
|
24779
|
-
};
|
|
24780
|
-
//#endregion
|
|
24781
|
-
//#region src/style/create_style_layer.ts
|
|
24782
|
-
function createStyleLayer(layer, globalState) {
|
|
24783
|
-
if (layer.type === "custom") return new CustomStyleLayer(layer, globalState);
|
|
24784
|
-
switch (layer.type) {
|
|
24785
|
-
case "background": return new BackgroundStyleLayer(layer, globalState);
|
|
24786
|
-
case "circle": return new CircleStyleLayer(layer, globalState);
|
|
24787
|
-
case "color-relief": return new ColorReliefStyleLayer(layer, globalState);
|
|
24788
|
-
case "fill": return new FillStyleLayer(layer, globalState);
|
|
24789
|
-
case "fill-extrusion": return new FillExtrusionStyleLayer(layer, globalState);
|
|
24790
|
-
case "heatmap": return new HeatmapStyleLayer(layer, globalState);
|
|
24791
|
-
case "hillshade": return new HillshadeStyleLayer(layer, globalState);
|
|
24792
|
-
case "line": return new LineStyleLayer(layer, globalState);
|
|
24793
|
-
case "raster": return new RasterStyleLayer(layer, globalState);
|
|
24794
|
-
case "symbol": return new SymbolStyleLayer(layer, globalState);
|
|
24795
|
-
}
|
|
24796
|
-
}
|
|
24797
|
-
//#endregion
|
|
24798
|
-
//#region src/util/throttled_invoker.ts
|
|
24799
|
-
/**
|
|
24800
|
-
* Invokes the wrapped function in a non-blocking way when trigger() is called.
|
|
24801
|
-
* Invocation requests are ignored until the function was actually invoked.
|
|
24802
|
-
*/
|
|
24803
|
-
var ThrottledInvoker = class {
|
|
24804
|
-
constructor(methodToThrottle) {
|
|
24805
|
-
this._methodToThrottle = methodToThrottle;
|
|
24806
|
-
this._triggered = false;
|
|
24807
|
-
this._channel = new MessageChannel();
|
|
24808
|
-
this._channel.port2.onmessage = () => {
|
|
24809
|
-
this._triggered = false;
|
|
24810
|
-
this._methodToThrottle();
|
|
24811
|
-
};
|
|
24812
|
-
}
|
|
24813
|
-
trigger() {
|
|
24814
|
-
if (this._triggered) return;
|
|
24815
|
-
this._triggered = true;
|
|
24816
|
-
this._channel?.port1.postMessage(true);
|
|
24817
|
-
}
|
|
24818
|
-
remove() {
|
|
24819
|
-
delete this._channel;
|
|
24820
|
-
this._methodToThrottle = () => {};
|
|
24821
|
-
}
|
|
24822
|
-
};
|
|
24823
|
-
//#endregion
|
|
24824
|
-
//#region src/util/actor.ts
|
|
24825
|
-
const addEventDefaultOptions = { once: true };
|
|
24826
|
-
/**
|
|
24827
|
-
* An implementation of the [Actor design pattern](https://en.wikipedia.org/wiki/Actor_model)
|
|
24828
|
-
* that maintains the relationship between asynchronous tasks and the objects
|
|
24829
|
-
* that spin them off - in this case, tasks like parsing parts of styles,
|
|
24830
|
-
* owned by the styles
|
|
24831
|
-
*/
|
|
24832
|
-
var Actor = class {
|
|
24833
|
-
/**
|
|
24834
|
-
* @param target - The target
|
|
24835
|
-
* @param mapId - A unique identifier for the Map instance using this Actor.
|
|
24836
|
-
*/
|
|
24837
|
-
constructor(target, mapId) {
|
|
24838
|
-
this.target = target;
|
|
24839
|
-
this.mapId = mapId;
|
|
24840
|
-
this.resolveRejects = {};
|
|
24841
|
-
this.tasks = {};
|
|
24842
|
-
this.taskQueue = [];
|
|
24843
|
-
this.abortControllers = {};
|
|
24844
|
-
this.messageHandlers = {};
|
|
24845
|
-
this.invoker = new ThrottledInvoker(() => this.process());
|
|
24846
|
-
this.subscription = subscribe(this.target, "message", (message) => this.receive(message), false);
|
|
24847
|
-
this.globalScope = isWorker(self) ? target : window;
|
|
24848
|
-
}
|
|
24849
|
-
registerMessageHandler(type, handler) {
|
|
24850
|
-
this.messageHandlers[type] = handler;
|
|
24851
|
-
}
|
|
24852
|
-
unregisterMessageHandler(type) {
|
|
24853
|
-
delete this.messageHandlers[type];
|
|
24854
|
-
}
|
|
24855
|
-
/**
|
|
24856
|
-
* Sends a message from a main-thread map to a Worker or from a Worker back to
|
|
24857
|
-
* a main-thread map instance.
|
|
24858
|
-
* @param message - the message to send
|
|
24859
|
-
* @param abortController - an optional AbortController to abort the request
|
|
24860
|
-
* @returns a promise that will be resolved with the response data
|
|
24861
|
-
*/
|
|
24862
|
-
sendAsync(message, abortController) {
|
|
24863
|
-
return new Promise((resolve, reject) => {
|
|
24864
|
-
const id = Math.round(Math.random() * 0xde0b6b3a7640000).toString(36).substring(0, 10);
|
|
24865
|
-
const subscription = abortController ? subscribe(abortController.signal, "abort", () => {
|
|
24866
|
-
subscription?.unsubscribe();
|
|
24867
|
-
delete this.resolveRejects[id];
|
|
24868
|
-
const cancelMessage = {
|
|
24869
|
-
id,
|
|
24870
|
-
type: "<cancel>",
|
|
24871
|
-
origin: location.origin,
|
|
24872
|
-
targetMapId: message.targetMapId,
|
|
24873
|
-
sourceMapId: this.mapId
|
|
24874
|
-
};
|
|
24875
|
-
this.target.postMessage(cancelMessage);
|
|
24876
|
-
reject(new AbortError(abortController.signal.reason));
|
|
24877
|
-
}, addEventDefaultOptions) : null;
|
|
24878
|
-
this.resolveRejects[id] = {
|
|
24879
|
-
resolve: (value) => {
|
|
24880
|
-
subscription?.unsubscribe();
|
|
24881
|
-
resolve(value);
|
|
24882
|
-
},
|
|
24883
|
-
reject: (reason) => {
|
|
24884
|
-
subscription?.unsubscribe();
|
|
24885
|
-
reject(reason);
|
|
24886
|
-
}
|
|
24887
|
-
};
|
|
24888
|
-
const buffers = [];
|
|
24889
|
-
const messageToPost = {
|
|
24890
|
-
...message,
|
|
24891
|
-
id,
|
|
24892
|
-
sourceMapId: this.mapId,
|
|
24893
|
-
origin: location.origin,
|
|
24894
|
-
data: serialize(message.data, buffers)
|
|
24895
|
-
};
|
|
24896
|
-
this.target.postMessage(messageToPost, { transfer: buffers });
|
|
24897
|
-
});
|
|
24898
|
-
}
|
|
24899
|
-
receive(message) {
|
|
24900
|
-
const data = message.data;
|
|
24901
|
-
const id = data.id;
|
|
24902
|
-
const SPECIAL_ORIGINS = [
|
|
24903
|
-
"file://",
|
|
24904
|
-
"resource://android",
|
|
24905
|
-
"null"
|
|
24906
|
-
];
|
|
24907
|
-
const origins = [data.origin, location.origin];
|
|
24908
|
-
const isSameOrigin = data.origin === location.origin;
|
|
24909
|
-
const hasSpecialOrigin = origins.some((origin) => SPECIAL_ORIGINS.includes(origin));
|
|
24910
|
-
if (!isSameOrigin && !hasSpecialOrigin) return;
|
|
24911
|
-
if (data.targetMapId && this.mapId !== data.targetMapId) return;
|
|
24912
|
-
if (data.type === "<cancel>") {
|
|
24913
|
-
delete this.tasks[id];
|
|
24914
|
-
const abortController = this.abortControllers[id];
|
|
24915
|
-
delete this.abortControllers[id];
|
|
24916
|
-
if (abortController) abortController.abort();
|
|
24917
|
-
return;
|
|
24918
|
-
}
|
|
24919
|
-
if (isWorker(self) || data.mustQueue) {
|
|
24920
|
-
this.tasks[id] = data;
|
|
24921
|
-
this.taskQueue.push(id);
|
|
24922
|
-
this.invoker.trigger();
|
|
24923
|
-
return;
|
|
24924
|
-
}
|
|
24925
|
-
this.processTask(id, data);
|
|
24926
|
-
}
|
|
24927
|
-
process() {
|
|
24928
|
-
if (this.taskQueue.length === 0) return;
|
|
24929
|
-
const id = this.taskQueue.shift();
|
|
24930
|
-
const task = this.tasks[id];
|
|
24931
|
-
delete this.tasks[id];
|
|
24932
|
-
if (this.taskQueue.length > 0) this.invoker.trigger();
|
|
24933
|
-
if (!task) return;
|
|
24934
|
-
this.processTask(id, task);
|
|
24935
|
-
}
|
|
24936
|
-
async processTask(id, task) {
|
|
24937
|
-
if (task.type === "<response>") {
|
|
24938
|
-
const resolveReject = this.resolveRejects[id];
|
|
24939
|
-
delete this.resolveRejects[id];
|
|
24940
|
-
if (!resolveReject) return;
|
|
24941
|
-
if (task.error) resolveReject.reject(ensureError(deserialize(task.error)));
|
|
24942
|
-
else resolveReject.resolve(deserialize(task.data));
|
|
24943
|
-
return;
|
|
24944
|
-
}
|
|
24945
|
-
if (!this.messageHandlers[task.type]) {
|
|
24946
|
-
this.completeTask(id, null, null);
|
|
24947
|
-
return;
|
|
24948
|
-
}
|
|
24949
|
-
const params = deserialize(task.data);
|
|
24950
|
-
const abortController = new AbortController();
|
|
24951
|
-
this.abortControllers[id] = abortController;
|
|
24952
|
-
try {
|
|
24953
|
-
const data = await this.messageHandlers[task.type](task.sourceMapId, params, abortController);
|
|
24954
|
-
this.completeTask(id, null, data);
|
|
24955
|
-
} catch (err) {
|
|
24956
|
-
this.completeTask(id, ensureError(err));
|
|
24957
|
-
}
|
|
24958
|
-
}
|
|
24959
|
-
completeTask(id, err, data) {
|
|
24960
|
-
const buffers = [];
|
|
24961
|
-
delete this.abortControllers[id];
|
|
24962
|
-
const responseMessage = {
|
|
24963
|
-
id,
|
|
24964
|
-
type: "<response>",
|
|
24965
|
-
sourceMapId: this.mapId,
|
|
24966
|
-
origin: location.origin,
|
|
24967
|
-
error: err ? serialize(err) : null,
|
|
24968
|
-
data: serialize(data, buffers)
|
|
24969
|
-
};
|
|
24970
|
-
this.target.postMessage(responseMessage, { transfer: buffers });
|
|
24971
|
-
}
|
|
24972
|
-
remove() {
|
|
24973
|
-
this.invoker.remove();
|
|
24974
|
-
this.subscription.unsubscribe();
|
|
25078
|
+
}
|
|
25079
|
+
//#endregion
|
|
25080
|
+
//#region src/style/style_layer/background_style_layer_properties.g.ts
|
|
25081
|
+
let paint;
|
|
25082
|
+
const getPaint = () => paint = paint || new Properties({
|
|
25083
|
+
"background-color": new DataConstantProperty(latest["paint_background"]["background-color"], "background-color"),
|
|
25084
|
+
"background-pattern": new CrossFadedProperty(latest["paint_background"]["background-pattern"], "background-pattern"),
|
|
25085
|
+
"background-opacity": new DataConstantProperty(latest["paint_background"]["background-opacity"], "background-opacity")
|
|
25086
|
+
});
|
|
25087
|
+
var background_style_layer_properties_g_default = { get paint() {
|
|
25088
|
+
return getPaint();
|
|
25089
|
+
} };
|
|
25090
|
+
//#endregion
|
|
25091
|
+
//#region src/style/style_layer/background_style_layer.ts
|
|
25092
|
+
const isBackgroundStyleLayer = (layer) => layer.type === "background";
|
|
25093
|
+
var BackgroundStyleLayer = class extends StyleLayer {
|
|
25094
|
+
constructor(layer, globalState) {
|
|
25095
|
+
super(layer, background_style_layer_properties_g_default, globalState);
|
|
24975
25096
|
}
|
|
24976
25097
|
};
|
|
24977
25098
|
//#endregion
|
|
24978
|
-
//#region src/
|
|
24979
|
-
|
|
24980
|
-
|
|
24981
|
-
|
|
24982
|
-
|
|
24983
|
-
|
|
24984
|
-
|
|
24985
|
-
|
|
24986
|
-
|
|
24987
|
-
|
|
24988
|
-
|
|
24989
|
-
|
|
24990
|
-
|
|
24991
|
-
|
|
24992
|
-
|
|
24993
|
-
|
|
24994
|
-
|
|
24995
|
-
|
|
24996
|
-
|
|
24997
|
-
|
|
24998
|
-
* @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/get-coordinates-of-the-mouse-pointer/)
|
|
24999
|
-
*/
|
|
25000
|
-
var LngLat = class LngLat {
|
|
25001
|
-
/**
|
|
25002
|
-
* @param lng - Longitude, measured in degrees.
|
|
25003
|
-
* @param lat - Latitude, measured in degrees.
|
|
25004
|
-
*/
|
|
25005
|
-
constructor(lng, lat) {
|
|
25006
|
-
if (isNaN(lng) || isNaN(lat)) throw new Error(`Invalid LngLat object: (${lng}, ${lat})`);
|
|
25007
|
-
this.lng = +lng;
|
|
25008
|
-
this.lat = +lat;
|
|
25009
|
-
if (this.lat > 90 || this.lat < -90) throw new Error("Invalid LngLat latitude value: must be between -90 and 90");
|
|
25010
|
-
}
|
|
25011
|
-
/**
|
|
25012
|
-
* Returns a new `LngLat` object whose longitude is wrapped to the range (-180, 180).
|
|
25013
|
-
*
|
|
25014
|
-
* @returns The wrapped `LngLat` object.
|
|
25015
|
-
* @example
|
|
25016
|
-
* ```ts
|
|
25017
|
-
* let ll = new LngLat(286.0251, 40.7736);
|
|
25018
|
-
* let wrapped = ll.wrap();
|
|
25019
|
-
* wrapped.lng; // = -73.9749
|
|
25020
|
-
* ```
|
|
25021
|
-
*/
|
|
25022
|
-
wrap() {
|
|
25023
|
-
return new LngLat(wrap$1(this.lng, -180, 180), this.lat);
|
|
25099
|
+
//#region src/style/style_layer/custom_style_layer.ts
|
|
25100
|
+
function validateCustomStyleLayer(layerObject) {
|
|
25101
|
+
const errors = [];
|
|
25102
|
+
const id = layerObject.id;
|
|
25103
|
+
if (id === void 0) errors.push(new ValidationError(`layers.${id}`, null, "missing required property \"id\""));
|
|
25104
|
+
if (layerObject.render === void 0) errors.push(new ValidationError(`layers.${id}`, null, "missing required method \"render\""));
|
|
25105
|
+
if (layerObject.renderingMode && layerObject.renderingMode !== "2d" && layerObject.renderingMode !== "3d") errors.push(new ValidationError(`layers.${id}`, null, "property \"renderingMode\" must be either \"2d\" or \"3d\""));
|
|
25106
|
+
return errors;
|
|
25107
|
+
}
|
|
25108
|
+
const isCustomStyleLayer = (layer) => layer.type === "custom";
|
|
25109
|
+
var CustomStyleLayer = class extends StyleLayer {
|
|
25110
|
+
constructor(implementation, globalState) {
|
|
25111
|
+
super(implementation, {}, globalState);
|
|
25112
|
+
this.onAdd = (map) => {
|
|
25113
|
+
if (this.implementation.onAdd) this.implementation.onAdd(map, map.painter.context.gl);
|
|
25114
|
+
};
|
|
25115
|
+
this.onRemove = (map) => {
|
|
25116
|
+
if (this.implementation.onRemove) this.implementation.onRemove(map, map.painter.context.gl);
|
|
25117
|
+
};
|
|
25118
|
+
this.implementation = implementation;
|
|
25024
25119
|
}
|
|
25025
|
-
|
|
25026
|
-
|
|
25027
|
-
*
|
|
25028
|
-
* @returns The coordinates represented as an array of longitude and latitude.
|
|
25029
|
-
* @example
|
|
25030
|
-
* ```ts
|
|
25031
|
-
* let ll = new LngLat(-73.9749, 40.7736);
|
|
25032
|
-
* ll.toArray(); // = [-73.9749, 40.7736]
|
|
25033
|
-
* ```
|
|
25034
|
-
*/
|
|
25035
|
-
toArray() {
|
|
25036
|
-
return [this.lng, this.lat];
|
|
25120
|
+
is3D() {
|
|
25121
|
+
return this.implementation.renderingMode === "3d";
|
|
25037
25122
|
}
|
|
25038
|
-
|
|
25039
|
-
|
|
25040
|
-
*
|
|
25041
|
-
* @returns The coordinates represented as a string of the format `'LngLat(lng, lat)'`.
|
|
25042
|
-
* @example
|
|
25043
|
-
* ```ts
|
|
25044
|
-
* let ll = new LngLat(-73.9749, 40.7736);
|
|
25045
|
-
* ll.toString(); // = "LngLat(-73.9749, 40.7736)"
|
|
25046
|
-
* ```
|
|
25047
|
-
*/
|
|
25048
|
-
toString() {
|
|
25049
|
-
return `LngLat(${this.lng}, ${this.lat})`;
|
|
25123
|
+
hasOffscreenPass() {
|
|
25124
|
+
return this.implementation.prerender !== void 0;
|
|
25050
25125
|
}
|
|
25051
|
-
|
|
25052
|
-
|
|
25053
|
-
|
|
25054
|
-
|
|
25055
|
-
* @param lngLat - coordinates to compute the distance to
|
|
25056
|
-
* @returns Distance in meters between the two coordinates.
|
|
25057
|
-
* @example
|
|
25058
|
-
* ```ts
|
|
25059
|
-
* let new_york = new LngLat(-74.0060, 40.7128);
|
|
25060
|
-
* let los_angeles = new LngLat(-118.2437, 34.0522);
|
|
25061
|
-
* new_york.distanceTo(los_angeles); // = 3935751.690893987, "true distance" using a non-spherical approximation is ~3966km
|
|
25062
|
-
* ```
|
|
25063
|
-
*/
|
|
25064
|
-
distanceTo(lngLat) {
|
|
25065
|
-
const rad = Math.PI / 180;
|
|
25066
|
-
const lat1 = this.lat * rad;
|
|
25067
|
-
const lat2 = lngLat.lat * rad;
|
|
25068
|
-
const a = Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos((lngLat.lng - this.lng) * rad);
|
|
25069
|
-
return earthRadius * Math.acos(Math.min(a, 1));
|
|
25126
|
+
recalculate() {}
|
|
25127
|
+
updateTransitions() {}
|
|
25128
|
+
hasTransition() {
|
|
25129
|
+
return false;
|
|
25070
25130
|
}
|
|
25071
|
-
|
|
25072
|
-
|
|
25073
|
-
* to a `LngLat` object.
|
|
25074
|
-
*
|
|
25075
|
-
* If a `LngLat` object is passed in, the function returns it unchanged.
|
|
25076
|
-
*
|
|
25077
|
-
* @param input - An array of two numbers or object to convert, or a `LngLat` object to return.
|
|
25078
|
-
* @returns A new `LngLat` object, if a conversion occurred, or the original `LngLat` object.
|
|
25079
|
-
* @example
|
|
25080
|
-
* ```ts
|
|
25081
|
-
* let arr = [-73.9749, 40.7736];
|
|
25082
|
-
* let ll = LngLat.convert(arr);
|
|
25083
|
-
* ll; // = LngLat {lng: -73.9749, lat: 40.7736}
|
|
25084
|
-
* ```
|
|
25085
|
-
*/
|
|
25086
|
-
static convert(input) {
|
|
25087
|
-
if (input instanceof LngLat) return input;
|
|
25088
|
-
if (Array.isArray(input) && (input.length === 2 || input.length === 3)) return new LngLat(Number(input[0]), Number(input[1]));
|
|
25089
|
-
if (!Array.isArray(input) && typeof input === "object" && input !== null) return new LngLat(Number("lng" in input ? input.lng : input.lon), Number(input.lat));
|
|
25090
|
-
throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]");
|
|
25131
|
+
serialize() {
|
|
25132
|
+
throw new Error("Custom layers cannot be serialized");
|
|
25091
25133
|
}
|
|
25092
25134
|
};
|
|
25093
25135
|
//#endregion
|
|
25094
|
-
//#region src/
|
|
25095
|
-
|
|
25096
|
-
|
|
25097
|
-
|
|
25098
|
-
|
|
25099
|
-
|
|
25100
|
-
|
|
25101
|
-
|
|
25102
|
-
|
|
25103
|
-
|
|
25104
|
-
|
|
25105
|
-
|
|
25106
|
-
|
|
25107
|
-
|
|
25108
|
-
|
|
25109
|
-
return x * 360 - 180;
|
|
25110
|
-
}
|
|
25111
|
-
function latFromMercatorY(y) {
|
|
25112
|
-
const y2 = 180 - y * 360;
|
|
25113
|
-
return 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
|
|
25114
|
-
}
|
|
25115
|
-
function altitudeFromMercatorZ(z, y) {
|
|
25116
|
-
return z * circumferenceAtLatitude(latFromMercatorY(y));
|
|
25136
|
+
//#region src/style/create_style_layer.ts
|
|
25137
|
+
function createStyleLayer(layer, globalState) {
|
|
25138
|
+
if (layer.type === "custom") return new CustomStyleLayer(layer, globalState);
|
|
25139
|
+
switch (layer.type) {
|
|
25140
|
+
case "background": return new BackgroundStyleLayer(layer, globalState);
|
|
25141
|
+
case "circle": return new CircleStyleLayer(layer, globalState);
|
|
25142
|
+
case "color-relief": return new ColorReliefStyleLayer(layer, globalState);
|
|
25143
|
+
case "fill": return new FillStyleLayer(layer, globalState);
|
|
25144
|
+
case "fill-extrusion": return new FillExtrusionStyleLayer(layer, globalState);
|
|
25145
|
+
case "heatmap": return new HeatmapStyleLayer(layer, globalState);
|
|
25146
|
+
case "hillshade": return new HillshadeStyleLayer(layer, globalState);
|
|
25147
|
+
case "line": return new LineStyleLayer(layer, globalState);
|
|
25148
|
+
case "raster": return new RasterStyleLayer(layer, globalState);
|
|
25149
|
+
case "symbol": return new SymbolStyleLayer(layer, globalState);
|
|
25150
|
+
}
|
|
25117
25151
|
}
|
|
25152
|
+
//#endregion
|
|
25153
|
+
//#region src/util/throttled_invoker.ts
|
|
25118
25154
|
/**
|
|
25119
|
-
*
|
|
25120
|
-
*
|
|
25121
|
-
*
|
|
25122
|
-
* At the equator the scale factor will be 1, which increases at higher latitudes.
|
|
25123
|
-
*
|
|
25124
|
-
* @param lat - Latitude
|
|
25125
|
-
* @returns scale factor
|
|
25155
|
+
* Invokes the wrapped function in a non-blocking way when trigger() is called.
|
|
25156
|
+
* Invocation requests are ignored until the function was actually invoked.
|
|
25126
25157
|
*/
|
|
25127
|
-
|
|
25128
|
-
|
|
25129
|
-
|
|
25130
|
-
|
|
25131
|
-
|
|
25132
|
-
|
|
25133
|
-
|
|
25134
|
-
|
|
25135
|
-
|
|
25136
|
-
|
|
25137
|
-
|
|
25138
|
-
|
|
25139
|
-
|
|
25140
|
-
|
|
25141
|
-
|
|
25142
|
-
|
|
25143
|
-
|
|
25144
|
-
|
|
25145
|
-
|
|
25146
|
-
|
|
25147
|
-
|
|
25148
|
-
|
|
25149
|
-
|
|
25150
|
-
|
|
25151
|
-
*
|
|
25152
|
-
*
|
|
25153
|
-
*
|
|
25158
|
+
var ThrottledInvoker = class {
|
|
25159
|
+
constructor(methodToThrottle) {
|
|
25160
|
+
this._methodToThrottle = methodToThrottle;
|
|
25161
|
+
this._triggered = false;
|
|
25162
|
+
this._channel = new MessageChannel();
|
|
25163
|
+
this._channel.port2.onmessage = () => {
|
|
25164
|
+
this._triggered = false;
|
|
25165
|
+
this._methodToThrottle();
|
|
25166
|
+
};
|
|
25167
|
+
}
|
|
25168
|
+
trigger() {
|
|
25169
|
+
if (this._triggered) return;
|
|
25170
|
+
this._triggered = true;
|
|
25171
|
+
this._channel?.port1.postMessage(true);
|
|
25172
|
+
}
|
|
25173
|
+
remove() {
|
|
25174
|
+
delete this._channel;
|
|
25175
|
+
this._methodToThrottle = () => {};
|
|
25176
|
+
}
|
|
25177
|
+
};
|
|
25178
|
+
//#endregion
|
|
25179
|
+
//#region src/util/actor.ts
|
|
25180
|
+
const addEventDefaultOptions = { once: true };
|
|
25181
|
+
/**
|
|
25182
|
+
* An implementation of the [Actor design pattern](https://en.wikipedia.org/wiki/Actor_model)
|
|
25183
|
+
* that maintains the relationship between asynchronous tasks and the objects
|
|
25184
|
+
* that spin them off - in this case, tasks like parsing parts of styles,
|
|
25185
|
+
* owned by the styles
|
|
25154
25186
|
*/
|
|
25155
|
-
var
|
|
25187
|
+
var Actor = class {
|
|
25156
25188
|
/**
|
|
25157
|
-
* @param
|
|
25158
|
-
* @param
|
|
25159
|
-
* @param z - The z component of the position.
|
|
25189
|
+
* @param target - The target
|
|
25190
|
+
* @param mapId - A unique identifier for the Map instance using this Actor.
|
|
25160
25191
|
*/
|
|
25161
|
-
constructor(
|
|
25162
|
-
this.
|
|
25163
|
-
this.
|
|
25164
|
-
this.
|
|
25192
|
+
constructor(target, mapId) {
|
|
25193
|
+
this.target = target;
|
|
25194
|
+
this.mapId = mapId;
|
|
25195
|
+
this.resolveRejects = {};
|
|
25196
|
+
this.tasks = {};
|
|
25197
|
+
this.taskQueue = [];
|
|
25198
|
+
this.abortControllers = {};
|
|
25199
|
+
this.messageHandlers = {};
|
|
25200
|
+
this.invoker = new ThrottledInvoker(() => this.process());
|
|
25201
|
+
this.subscription = subscribe(this.target, "message", (message) => this.receive(message), false);
|
|
25202
|
+
this.globalScope = isWorker(self) ? target : window;
|
|
25165
25203
|
}
|
|
25166
|
-
|
|
25167
|
-
|
|
25168
|
-
*
|
|
25169
|
-
* @param lngLatLike - The location to project.
|
|
25170
|
-
* @param altitude - The altitude in meters of the position.
|
|
25171
|
-
* @returns The projected mercator coordinate.
|
|
25172
|
-
* @example
|
|
25173
|
-
* ```ts
|
|
25174
|
-
* let coord = MercatorCoordinate.fromLngLat({ lng: 0, lat: 0}, 0);
|
|
25175
|
-
* coord; // MercatorCoordinate(0.5, 0.5, 0)
|
|
25176
|
-
* ```
|
|
25177
|
-
*/
|
|
25178
|
-
static fromLngLat(lngLatLike, altitude = 0) {
|
|
25179
|
-
const lngLat = LngLat.convert(lngLatLike);
|
|
25180
|
-
return new MercatorCoordinate(mercatorXfromLng(lngLat.lng), mercatorYfromLat(lngLat.lat), mercatorZfromAltitude(altitude, lngLat.lat));
|
|
25204
|
+
registerMessageHandler(type, handler) {
|
|
25205
|
+
this.messageHandlers[type] = handler;
|
|
25181
25206
|
}
|
|
25182
|
-
|
|
25183
|
-
|
|
25184
|
-
*
|
|
25185
|
-
* @returns The `LngLat` object.
|
|
25186
|
-
* @example
|
|
25187
|
-
* ```ts
|
|
25188
|
-
* let coord = new MercatorCoordinate(0.5, 0.5, 0);
|
|
25189
|
-
* let lngLat = coord.toLngLat(); // LngLat(0, 0)
|
|
25190
|
-
* ```
|
|
25191
|
-
*/
|
|
25192
|
-
toLngLat() {
|
|
25193
|
-
return new LngLat(lngFromMercatorX(this.x), latFromMercatorY(this.y));
|
|
25207
|
+
unregisterMessageHandler(type) {
|
|
25208
|
+
delete this.messageHandlers[type];
|
|
25194
25209
|
}
|
|
25195
25210
|
/**
|
|
25196
|
-
*
|
|
25197
|
-
*
|
|
25198
|
-
* @
|
|
25199
|
-
* @
|
|
25200
|
-
*
|
|
25201
|
-
* let coord = new MercatorCoordinate(0, 0, 0.02);
|
|
25202
|
-
* coord.toAltitude(); // 6914.281956295339
|
|
25203
|
-
* ```
|
|
25211
|
+
* Sends a message from a main-thread map to a Worker or from a Worker back to
|
|
25212
|
+
* a main-thread map instance.
|
|
25213
|
+
* @param message - the message to send
|
|
25214
|
+
* @param abortController - an optional AbortController to abort the request
|
|
25215
|
+
* @returns a promise that will be resolved with the response data
|
|
25204
25216
|
*/
|
|
25205
|
-
|
|
25206
|
-
return
|
|
25217
|
+
sendAsync(message, abortController) {
|
|
25218
|
+
return new Promise((resolve, reject) => {
|
|
25219
|
+
const id = Math.round(Math.random() * 0xde0b6b3a7640000).toString(36).substring(0, 10);
|
|
25220
|
+
const subscription = abortController ? subscribe(abortController.signal, "abort", () => {
|
|
25221
|
+
subscription?.unsubscribe();
|
|
25222
|
+
delete this.resolveRejects[id];
|
|
25223
|
+
const cancelMessage = {
|
|
25224
|
+
id,
|
|
25225
|
+
type: "<cancel>",
|
|
25226
|
+
origin: location.origin,
|
|
25227
|
+
targetMapId: message.targetMapId,
|
|
25228
|
+
sourceMapId: this.mapId
|
|
25229
|
+
};
|
|
25230
|
+
this.target.postMessage(cancelMessage);
|
|
25231
|
+
reject(new AbortError(abortController.signal.reason));
|
|
25232
|
+
}, addEventDefaultOptions) : null;
|
|
25233
|
+
this.resolveRejects[id] = {
|
|
25234
|
+
resolve: (value) => {
|
|
25235
|
+
subscription?.unsubscribe();
|
|
25236
|
+
resolve(value);
|
|
25237
|
+
},
|
|
25238
|
+
reject: (reason) => {
|
|
25239
|
+
subscription?.unsubscribe();
|
|
25240
|
+
reject(reason);
|
|
25241
|
+
}
|
|
25242
|
+
};
|
|
25243
|
+
const buffers = [];
|
|
25244
|
+
const messageToPost = {
|
|
25245
|
+
...message,
|
|
25246
|
+
id,
|
|
25247
|
+
sourceMapId: this.mapId,
|
|
25248
|
+
origin: location.origin,
|
|
25249
|
+
data: serialize(message.data, buffers)
|
|
25250
|
+
};
|
|
25251
|
+
this.target.postMessage(messageToPost, { transfer: buffers });
|
|
25252
|
+
});
|
|
25207
25253
|
}
|
|
25208
|
-
|
|
25209
|
-
|
|
25210
|
-
|
|
25211
|
-
|
|
25212
|
-
|
|
25213
|
-
|
|
25214
|
-
|
|
25215
|
-
|
|
25216
|
-
|
|
25217
|
-
|
|
25254
|
+
receive(message) {
|
|
25255
|
+
const data = message.data;
|
|
25256
|
+
const id = data.id;
|
|
25257
|
+
const SPECIAL_ORIGINS = [
|
|
25258
|
+
"file://",
|
|
25259
|
+
"resource://android",
|
|
25260
|
+
"null"
|
|
25261
|
+
];
|
|
25262
|
+
const origins = [data.origin, location.origin];
|
|
25263
|
+
const isSameOrigin = data.origin === location.origin;
|
|
25264
|
+
const hasSpecialOrigin = origins.some((origin) => SPECIAL_ORIGINS.includes(origin));
|
|
25265
|
+
if (!isSameOrigin && !hasSpecialOrigin) return;
|
|
25266
|
+
if (data.targetMapId && this.mapId !== data.targetMapId) return;
|
|
25267
|
+
if (data.type === "<cancel>") {
|
|
25268
|
+
delete this.tasks[id];
|
|
25269
|
+
const abortController = this.abortControllers[id];
|
|
25270
|
+
delete this.abortControllers[id];
|
|
25271
|
+
if (abortController) abortController.abort();
|
|
25272
|
+
return;
|
|
25273
|
+
}
|
|
25274
|
+
if (isWorker(self) || data.mustQueue) {
|
|
25275
|
+
this.tasks[id] = data;
|
|
25276
|
+
this.taskQueue.push(id);
|
|
25277
|
+
this.invoker.trigger();
|
|
25278
|
+
return;
|
|
25279
|
+
}
|
|
25280
|
+
this.processTask(id, data);
|
|
25281
|
+
}
|
|
25282
|
+
process() {
|
|
25283
|
+
if (this.taskQueue.length === 0) return;
|
|
25284
|
+
const id = this.taskQueue.shift();
|
|
25285
|
+
const task = this.tasks[id];
|
|
25286
|
+
delete this.tasks[id];
|
|
25287
|
+
if (this.taskQueue.length > 0) this.invoker.trigger();
|
|
25288
|
+
if (!task) return;
|
|
25289
|
+
this.processTask(id, task);
|
|
25290
|
+
}
|
|
25291
|
+
async processTask(id, task) {
|
|
25292
|
+
if (task.type === "<response>") {
|
|
25293
|
+
const resolveReject = this.resolveRejects[id];
|
|
25294
|
+
delete this.resolveRejects[id];
|
|
25295
|
+
if (!resolveReject) return;
|
|
25296
|
+
if (task.error) resolveReject.reject(ensureError(deserialize(task.error)));
|
|
25297
|
+
else resolveReject.resolve(deserialize(task.data));
|
|
25298
|
+
return;
|
|
25299
|
+
}
|
|
25300
|
+
if (!this.messageHandlers[task.type]) {
|
|
25301
|
+
this.completeTask(id, null, null);
|
|
25302
|
+
return;
|
|
25303
|
+
}
|
|
25304
|
+
const params = deserialize(task.data);
|
|
25305
|
+
const abortController = new AbortController();
|
|
25306
|
+
this.abortControllers[id] = abortController;
|
|
25307
|
+
try {
|
|
25308
|
+
const data = await this.messageHandlers[task.type](task.sourceMapId, params, abortController);
|
|
25309
|
+
this.completeTask(id, null, data);
|
|
25310
|
+
} catch (err) {
|
|
25311
|
+
this.completeTask(id, ensureError(err));
|
|
25312
|
+
}
|
|
25313
|
+
}
|
|
25314
|
+
completeTask(id, err, data) {
|
|
25315
|
+
const buffers = [];
|
|
25316
|
+
delete this.abortControllers[id];
|
|
25317
|
+
const responseMessage = {
|
|
25318
|
+
id,
|
|
25319
|
+
type: "<response>",
|
|
25320
|
+
sourceMapId: this.mapId,
|
|
25321
|
+
origin: location.origin,
|
|
25322
|
+
error: err ? serialize(err) : null,
|
|
25323
|
+
data: serialize(data, buffers)
|
|
25324
|
+
};
|
|
25325
|
+
this.target.postMessage(responseMessage, { transfer: buffers });
|
|
25326
|
+
}
|
|
25327
|
+
remove() {
|
|
25328
|
+
this.invoker.remove();
|
|
25329
|
+
this.subscription.unsubscribe();
|
|
25218
25330
|
}
|
|
25219
25331
|
};
|
|
25220
25332
|
//#endregion
|
|
@@ -27070,9 +27182,7 @@ function unpackBlock256(inValues, inPos, out, outPos, bitWidth) {
|
|
|
27070
27182
|
case 16:
|
|
27071
27183
|
fastUnpack256_16(inValues, inPos, out, outPos);
|
|
27072
27184
|
break;
|
|
27073
|
-
default:
|
|
27074
|
-
fastUnpack256_Generic(inValues, inPos, out, outPos, bitWidth);
|
|
27075
|
-
break;
|
|
27185
|
+
default: fastUnpack256_Generic(inValues, inPos, out, outPos, bitWidth);
|
|
27076
27186
|
}
|
|
27077
27187
|
return inPos + (bitWidth << 3) | 0;
|
|
27078
27188
|
}
|
|
@@ -27190,9 +27300,7 @@ function decodePageBlocks(inValues, pageStart, inPos, packedEnd, out, outPos, bl
|
|
|
27190
27300
|
for (let i = 0; i < 256; i = i + 1 | 0) out[blockOutPos + i | 0] = inValues[tmpInPos + i | 0] | 0;
|
|
27191
27301
|
tmpInPos = tmpInPos + 256 | 0;
|
|
27192
27302
|
break;
|
|
27193
|
-
default:
|
|
27194
|
-
tmpInPos = unpackBlock256(inValues, tmpInPos, out, blockOutPos, bitWidth);
|
|
27195
|
-
break;
|
|
27303
|
+
default: tmpInPos = unpackBlock256(inValues, tmpInPos, out, blockOutPos, bitWidth);
|
|
27196
27304
|
}
|
|
27197
27305
|
if (exceptionCount > 0) bytePosIn = applyBlockExceptions(out, blockOutPos, bitWidth, exceptionCount, byteContainer, byteContainerLen, bytePosIn, workspace, run);
|
|
27198
27306
|
}
|
|
@@ -27327,7 +27435,6 @@ function fastUnpack32(inValues, inPos, out, outPos, bitWidth) {
|
|
|
27327
27435
|
case 32:
|
|
27328
27436
|
for (let i = 0; i < 32; i = i + 1 | 0) out[outPos + i | 0] = inValues[inPos + i | 0] | 0;
|
|
27329
27437
|
return;
|
|
27330
|
-
default: break;
|
|
27331
27438
|
}
|
|
27332
27439
|
const valueMask = MASKS[bitWidth] >>> 0;
|
|
27333
27440
|
let inputWordIndex = inPos;
|
|
@@ -28028,9 +28135,7 @@ function decodeStreamMetadataInternal(tile, offset) {
|
|
|
28028
28135
|
case PhysicalStreamType.OFFSET:
|
|
28029
28136
|
logicalStreamType = { offsetType: OFFSET_TYPE_BY_ID[stream_type & 15] };
|
|
28030
28137
|
break;
|
|
28031
|
-
case PhysicalStreamType.LENGTH:
|
|
28032
|
-
logicalStreamType = { lengthType: LENGTH_TYPE_BY_ID[stream_type & 15] };
|
|
28033
|
-
break;
|
|
28138
|
+
case PhysicalStreamType.LENGTH: logicalStreamType = { lengthType: LENGTH_TYPE_BY_ID[stream_type & 15] };
|
|
28034
28139
|
}
|
|
28035
28140
|
offset.increment();
|
|
28036
28141
|
const encodings_header = tile[offset.get()];
|
|
@@ -28571,7 +28676,8 @@ function convertGeometryVector(geometryVector) {
|
|
|
28571
28676
|
lineStrings[j] = getLineStringOrRing(vertexBuffer, vertexBufferOffset, numVertices, false);
|
|
28572
28677
|
vertexBufferOffset += numVertices * 2;
|
|
28573
28678
|
} else {
|
|
28574
|
-
|
|
28679
|
+
const vertices = decodeDictionaryEncodedLineStringOrRing(geometryVector.vertexBufferType, vertexBuffer, vertexOffsets, vertexOffsetsOffset, numVertices, false, mortonSettings);
|
|
28680
|
+
lineStrings[j] = vertices;
|
|
28575
28681
|
vertexOffsetsOffset += numVertices;
|
|
28576
28682
|
}
|
|
28577
28683
|
}
|
|
@@ -28808,30 +28914,28 @@ var GpuVector = class {
|
|
|
28808
28914
|
if (geometryOffsets) geometryOffsetsCounter++;
|
|
28809
28915
|
}
|
|
28810
28916
|
break;
|
|
28811
|
-
case GEOMETRY_TYPE.MULTIPOLYGON:
|
|
28812
|
-
|
|
28813
|
-
|
|
28814
|
-
|
|
28815
|
-
|
|
28816
|
-
|
|
28817
|
-
|
|
28818
|
-
|
|
28819
|
-
|
|
28820
|
-
|
|
28821
|
-
|
|
28822
|
-
|
|
28823
|
-
|
|
28824
|
-
|
|
28825
|
-
|
|
28826
|
-
ring.push(new Point(x, y));
|
|
28827
|
-
}
|
|
28828
|
-
if (ring.length > 0) ring.push(ring[0]);
|
|
28829
|
-
allRings.push(ring);
|
|
28917
|
+
case GEOMETRY_TYPE.MULTIPOLYGON: {
|
|
28918
|
+
const numPolygons = geometryOffsets[geometryOffsetsCounter] - geometryOffsets[geometryOffsetsCounter - 1];
|
|
28919
|
+
geometryOffsetsCounter++;
|
|
28920
|
+
const allRings = [];
|
|
28921
|
+
for (let p = 0; p < numPolygons; p++) {
|
|
28922
|
+
const numRings = partOffsets[partOffsetCounter] - partOffsets[partOffsetCounter - 1];
|
|
28923
|
+
partOffsetCounter++;
|
|
28924
|
+
for (let j = 0; j < numRings; j++) {
|
|
28925
|
+
const numVertices = ringOffsets[ringOffsetsCounter] - ringOffsets[ringOffsetsCounter - 1];
|
|
28926
|
+
ringOffsetsCounter++;
|
|
28927
|
+
const ring = [];
|
|
28928
|
+
for (let k = 0; k < numVertices; k++) {
|
|
28929
|
+
const x = this._vertexBuffer[vertexBufferOffset++];
|
|
28930
|
+
const y = this._vertexBuffer[vertexBufferOffset++];
|
|
28931
|
+
ring.push(new Point(x, y));
|
|
28830
28932
|
}
|
|
28933
|
+
if (ring.length > 0) ring.push(ring[0]);
|
|
28934
|
+
allRings.push(ring);
|
|
28831
28935
|
}
|
|
28832
|
-
geometries[i] = allRings;
|
|
28833
28936
|
}
|
|
28834
|
-
|
|
28937
|
+
geometries[i] = allRings;
|
|
28938
|
+
}
|
|
28835
28939
|
}
|
|
28836
28940
|
return geometries;
|
|
28837
28941
|
}
|
|
@@ -28917,22 +29021,18 @@ function decodeGeometryColumn(tile, numStreams, offset, numFeatures, scalingData
|
|
|
28917
29021
|
case OffsetType.VERTEX:
|
|
28918
29022
|
vertexOffsets = decodeUnsignedInt32Stream(tile, offset, geometryStreamMetadata);
|
|
28919
29023
|
break;
|
|
28920
|
-
case OffsetType.INDEX:
|
|
28921
|
-
indexBuffer = decodeUnsignedInt32Stream(tile, offset, geometryStreamMetadata);
|
|
28922
|
-
break;
|
|
28923
|
-
}
|
|
28924
|
-
break;
|
|
28925
|
-
case PhysicalStreamType.DATA:
|
|
28926
|
-
if (DictionaryType.VERTEX === geometryStreamMetadata.logicalStreamType.dictionaryType) vertexBuffer = decodeSignedInt32Stream(tile, offset, geometryStreamMetadata, scalingData);
|
|
28927
|
-
else {
|
|
28928
|
-
const mortonMetadata = geometryStreamMetadata;
|
|
28929
|
-
mortonSettings = {
|
|
28930
|
-
numBits: mortonMetadata.numBits,
|
|
28931
|
-
coordinateShift: mortonMetadata.coordinateShift
|
|
28932
|
-
};
|
|
28933
|
-
vertexBuffer = decodeUnsignedInt32Stream(tile, offset, geometryStreamMetadata, scalingData);
|
|
29024
|
+
case OffsetType.INDEX: indexBuffer = decodeUnsignedInt32Stream(tile, offset, geometryStreamMetadata);
|
|
28934
29025
|
}
|
|
28935
29026
|
break;
|
|
29027
|
+
case PhysicalStreamType.DATA: if (DictionaryType.VERTEX === geometryStreamMetadata.logicalStreamType.dictionaryType) vertexBuffer = decodeSignedInt32Stream(tile, offset, geometryStreamMetadata, scalingData);
|
|
29028
|
+
else {
|
|
29029
|
+
const mortonMetadata = geometryStreamMetadata;
|
|
29030
|
+
mortonSettings = {
|
|
29031
|
+
numBits: mortonMetadata.numBits,
|
|
29032
|
+
coordinateShift: mortonMetadata.coordinateShift
|
|
29033
|
+
};
|
|
29034
|
+
vertexBuffer = decodeUnsignedInt32Stream(tile, offset, geometryStreamMetadata, scalingData);
|
|
29035
|
+
}
|
|
28936
29036
|
}
|
|
28937
29037
|
}
|
|
28938
29038
|
if (indexBuffer) {
|
|
@@ -28980,22 +29080,18 @@ function decodeGeometryColumn(tile, numStreams, offset, numFeatures, scalingData
|
|
|
28980
29080
|
case OffsetType.VERTEX:
|
|
28981
29081
|
vertexOffsets = decodeUnsignedInt32Stream(tile, offset, geometryStreamMetadata);
|
|
28982
29082
|
break;
|
|
28983
|
-
case OffsetType.INDEX:
|
|
28984
|
-
indexBuffer = decodeUnsignedInt32Stream(tile, offset, geometryStreamMetadata);
|
|
28985
|
-
break;
|
|
28986
|
-
}
|
|
28987
|
-
break;
|
|
28988
|
-
case PhysicalStreamType.DATA:
|
|
28989
|
-
if (DictionaryType.VERTEX === geometryStreamMetadata.logicalStreamType.dictionaryType) vertexBuffer = decodeSignedInt32Stream(tile, offset, geometryStreamMetadata, scalingData);
|
|
28990
|
-
else {
|
|
28991
|
-
const mortonMetadata = geometryStreamMetadata;
|
|
28992
|
-
mortonSettings = {
|
|
28993
|
-
numBits: mortonMetadata.numBits,
|
|
28994
|
-
coordinateShift: mortonMetadata.coordinateShift
|
|
28995
|
-
};
|
|
28996
|
-
vertexBuffer = decodeUnsignedInt32Stream(tile, offset, geometryStreamMetadata, scalingData);
|
|
29083
|
+
case OffsetType.INDEX: indexBuffer = decodeUnsignedInt32Stream(tile, offset, geometryStreamMetadata);
|
|
28997
29084
|
}
|
|
28998
29085
|
break;
|
|
29086
|
+
case PhysicalStreamType.DATA: if (DictionaryType.VERTEX === geometryStreamMetadata.logicalStreamType.dictionaryType) vertexBuffer = decodeSignedInt32Stream(tile, offset, geometryStreamMetadata, scalingData);
|
|
29087
|
+
else {
|
|
29088
|
+
const mortonMetadata = geometryStreamMetadata;
|
|
29089
|
+
mortonSettings = {
|
|
29090
|
+
numBits: mortonMetadata.numBits,
|
|
29091
|
+
coordinateShift: mortonMetadata.coordinateShift
|
|
29092
|
+
};
|
|
29093
|
+
vertexBuffer = decodeUnsignedInt32Stream(tile, offset, geometryStreamMetadata, scalingData);
|
|
29094
|
+
}
|
|
28999
29095
|
}
|
|
29000
29096
|
}
|
|
29001
29097
|
let geometryOffsets;
|
|
@@ -29387,7 +29483,6 @@ function decodeSharedDictionary(data, offset, column, propertyColumnNames) {
|
|
|
29387
29483
|
dictionaryStreamDecoded = true;
|
|
29388
29484
|
} else symbolTableBuffer = data.subarray(offset.get(), offset.get() + streamMetadata.byteLength);
|
|
29389
29485
|
offset.add(streamMetadata.byteLength);
|
|
29390
|
-
break;
|
|
29391
29486
|
}
|
|
29392
29487
|
}
|
|
29393
29488
|
const childFields = column.complexType.children;
|
|
@@ -29825,8 +29920,10 @@ function decodeTile(tile, geometryScaling, idWithinMaxSafeInteger = true) {
|
|
|
29825
29920
|
const numStreams = hasStreamCount(columnMetadata) ? decodeVarintInt32(tile, offset, 1)[0] : 1;
|
|
29826
29921
|
if (numStreams === 0) continue;
|
|
29827
29922
|
const propertyVector = decodePropertyColumn(tile, offset, columnMetadata, numStreams, numFeatures, void 0);
|
|
29828
|
-
if (propertyVector)
|
|
29829
|
-
|
|
29923
|
+
if (propertyVector) {
|
|
29924
|
+
if (Array.isArray(propertyVector)) for (const property of propertyVector) propertyVectors.push(property);
|
|
29925
|
+
else propertyVectors.push(propertyVector);
|
|
29926
|
+
}
|
|
29830
29927
|
}
|
|
29831
29928
|
}
|
|
29832
29929
|
const featureTable = new FeatureTable(featureTableMetadata.name, geometryVector, idVector, propertyVectors, extent);
|
|
@@ -30526,8 +30623,8 @@ function getIconQuads(shapedIcon, iconRotate, isSDFIcon, hasIconTextFit) {
|
|
|
30526
30623
|
const quads = [];
|
|
30527
30624
|
const image = shapedIcon.image;
|
|
30528
30625
|
const pixelRatio = image.pixelRatio;
|
|
30529
|
-
const imageWidth = image.paddedRect.w - 2
|
|
30530
|
-
const imageHeight = image.paddedRect.h - 2
|
|
30626
|
+
const imageWidth = image.paddedRect.w - 2;
|
|
30627
|
+
const imageHeight = image.paddedRect.h - 2;
|
|
30531
30628
|
let icon = {
|
|
30532
30629
|
x1: shapedIcon.left,
|
|
30533
30630
|
y1: shapedIcon.top,
|
|
@@ -30726,7 +30823,7 @@ function getGlyphQuads(anchor, shaping, textOffset, layer, alongLine, feature, i
|
|
|
30726
30823
|
if (rotateVerticalGlyph) {
|
|
30727
30824
|
const center = new Point(-halfAdvance, halfAdvance - -17);
|
|
30728
30825
|
const verticalRotation = -Math.PI / 2;
|
|
30729
|
-
const xHalfWidthOffsetCorrection =
|
|
30826
|
+
const xHalfWidthOffsetCorrection = 12 - halfAdvance;
|
|
30730
30827
|
const yImageOffsetCorrection = positionedGlyph.imageName ? xHalfWidthOffsetCorrection : 0;
|
|
30731
30828
|
const halfWidthOffsetCorrection = new Point(22 - xHalfWidthOffsetCorrection, -yImageOffsetCorrection);
|
|
30732
30829
|
const verticalOffsetCorrection = new Point(...verticalizedLabelOffset);
|
|
@@ -30995,9 +31092,7 @@ function evaluateVariableOffset(anchor, offset) {
|
|
|
30995
31092
|
case "bottom":
|
|
30996
31093
|
y = -radialOffset + baselineOffset;
|
|
30997
31094
|
break;
|
|
30998
|
-
case "top":
|
|
30999
|
-
y = radialOffset - baselineOffset;
|
|
31000
|
-
break;
|
|
31095
|
+
case "top": y = radialOffset - baselineOffset;
|
|
31001
31096
|
}
|
|
31002
31097
|
switch (anchor) {
|
|
31003
31098
|
case "top-right":
|
|
@@ -31011,9 +31106,7 @@ function evaluateVariableOffset(anchor, offset) {
|
|
|
31011
31106
|
case "left":
|
|
31012
31107
|
x = radialOffset;
|
|
31013
31108
|
break;
|
|
31014
|
-
case "right":
|
|
31015
|
-
x = -radialOffset;
|
|
31016
|
-
break;
|
|
31109
|
+
case "right": x = -radialOffset;
|
|
31017
31110
|
}
|
|
31018
31111
|
return [x, y];
|
|
31019
31112
|
}
|
|
@@ -31029,9 +31122,7 @@ function evaluateVariableOffset(anchor, offset) {
|
|
|
31029
31122
|
break;
|
|
31030
31123
|
case "bottom-right":
|
|
31031
31124
|
case "bottom-left":
|
|
31032
|
-
case "bottom":
|
|
31033
|
-
y = -offsetY + baselineOffset;
|
|
31034
|
-
break;
|
|
31125
|
+
case "bottom": y = -offsetY + baselineOffset;
|
|
31035
31126
|
}
|
|
31036
31127
|
switch (anchor) {
|
|
31037
31128
|
case "top-right":
|
|
@@ -31041,9 +31132,7 @@ function evaluateVariableOffset(anchor, offset) {
|
|
|
31041
31132
|
break;
|
|
31042
31133
|
case "top-left":
|
|
31043
31134
|
case "bottom-left":
|
|
31044
|
-
case "left":
|
|
31045
|
-
x = offsetX;
|
|
31046
|
-
break;
|
|
31135
|
+
case "left": x = offsetX;
|
|
31047
31136
|
}
|
|
31048
31137
|
return [x, y];
|
|
31049
31138
|
}
|
|
@@ -31359,6 +31448,6 @@ function anchorIsTooClose(bucket, text, repeatDistance, anchor) {
|
|
|
31359
31448
|
return false;
|
|
31360
31449
|
}
|
|
31361
31450
|
//#endregion
|
|
31362
|
-
export {
|
|
31451
|
+
export { projectToWorldCoordinates as $, defaultEasing as $n, add$4 as $r, Transitionable as $t, getOverlapMode as A, rotateZ$3 as Ai, makeRequest as An, rollPitchBearingEqual as Ar, Uniform1f as At, parseGlyphPbf as B, offscreenCanvasSupported as Bi, MAX_VALID_LATITUDE as Bn, zoomScale as Br, CollisionBoxArray as Bt, createStyleLayer as C, identity$2 as Ci, Evented as Cn, parseCacheControl as Cr, isHeatmapStyleLayer as Ct, isSymbolStyleLayer as D, perspective as Di, getJSON as Dn, rayPlaneIntersection as Dr, isCircleStyleLayer as Dt, isBackgroundStyleLayer as E, ortho as Ei, getArrayBuffer as En, radiansToDegrees as Er, RGBAImage as Et, ImageAtlas as F, create$8 as Fi, config as Fn, threePlaneIntersection as Fr, UniformColor as Ft, GeoJSONVT as G, clamp$2 as Gn, scale as Gr, QuadTriangleArray as Gt, collisionCircleLayout as H, arrayBufferToImage as Hn, EXTENT$1 as Hr, LineStripIndexArray as Ht, ImagePosition as I, determinant$3 as Ii, AbortError as In, translatePosition as Ir, UniformColorArray as It, calculateTileMatrix as J, createIdentityMat4f64 as Jn, fromEuler as Jr, createLayout as Jt, isFillExtrusionStyleLayer as K, clone as Kn, sqrLen as Kr, RasterBoundsArray as Kt, potpack as L, invert$5 as Li, isAbortError as Ln, uniqueId as Lr, UniformFloatArray as Lt, evaluateSizeForZoom as M, translate$2 as Mi, addProtocol as Mn, scaleZoom as Mr, Uniform2f as Mt, WritingMode as N, create$6 as Ni, getProtocol as Nn, sphericalToCartesian as Nr, Uniform3f as Nt, SymbolBucket as O, rotateX$3 as Oi, getReferrer as On, readImageUsingVideoFrame as Or, polygonIntersectsPolygon as Ot, getAnchorAlignment as P, fromRotation$2 as Pi, removeProtocol as Pn, subscribe as Pr, Uniform4f as Pt, maxMercatorHorizonAngle as Q, deepEqual$1 as Qn, transformMat4$1 as Qr, TRANSITION_SUFFIX as Qt, isStyleImageWebGLData as R, rotate$4 as Ri, throwIfAborted as Rn, warnOnce as Rr, UniformMatrix4f as Rt, Actor as S, fromScaling as Si, Event as Sn, nextPowerOfTwo as Sr, HEATMAP_FULL_RENDER_FBO_KEY as St, validateCustomStyleLayer as T, multiply$5 as Ti, GLOBAL_DISPATCHER_ID as Tn, pointPlaneSignedDistance as Tr, AlphaImage as Tt, isLineStyleLayer as U, arrayBufferToImageBitmap as Un, create as Ur, Pos3dArray as Ut, PbfReader as V, Point as Vi, angleToRotateBetweenVectors2D as Vn, pixelsToTileUnits as Vr, CollisionCircleLayoutArray as Vt, LineBucket as W, bezier as Wn, length as Wr, PosArray as Wt, cameraMercatorCoordinateFromCenterAndRotation as X, createVec3f64 as Xn, mul$3 as Xr, DataConstantProperty as Xt, cameraDirectionFromPitchBearing as Y, createMat4f64 as Yn, slerp as Yr, isRasterStyleLayer as Yt, getMercatorHorizon as Z, createVec4f64 as Zn, scale$3 as Zr, Properties as Zt, OverscaledTileID as _, clone$6 as _i, featureFilter as _n, isTouchableOrPointableType as _r, SubdivisionGranularitySetting as _t, clipLine as a, negate$2 as ai, SPEC_SOURCE_TYPES as an, extend as ar, lngFromMercatorX as at, compareTileId as b, equals$6 as bi, latest as bn, mapObject as br, Texture as bt, FeatureIndex as c, rotateY$2 as ci, validateStyle as cn, getAABB as cr, mercatorZfromAltitude as ct, DictionaryCoder as d, scaleAndAdd$2 as di, ProjectionDefinition as dn, getImageData as dr, VectorTile as dt, clone$5 as ei, EvaluationParameters as en, degreesToRadians as er, tileCoordinatesToMercatorCoordinates as et, GEOJSON_TILE_LAYER_NAME as f, sub$2 as fi, ValidationError as fn, getRollPitchBearing as fr, isFillStyleLayer as ft, CanonicalTileID as g, zero$2 as gi, emptyStyle as gn, isTouchableEvent as gr, SubdivisionGranularityExpression as gt, Bounds as h, transformQuat$1 as hi, diff as hn, isSafari as hr, SOUTH_POLE_Y as ht, clipGeometry as i, length$4 as ii, register as in, evaluateZoomSnap as ir, latFromMercatorY as it, evaluateSizeForFeature as j, scale$5 as ji, sameOrigin as jn, rollPitchBearingToQuat as jr, Uniform1i as jt, addDynamicAttributes as k, rotateY$3 as ki, getVideo as kn, remapSaturate as kr, toEvaluationFeature as kt, MLTVectorTile as l, rotateZ$2 as li, validateStyleAndEmit as ln, getAngleDelta as lr, LngLat as lt, fromVectorTileJs as m, transformMat4$2 as mi, derefLayers as mn, isPointableEvent as mr, NORTH_POLE_Y as mt, performSymbolLayout as n, dot$5 as ni, codePointUsesLocalIdeographFontFamily as nn, distanceOfAnglesRadians as nr, MercatorCoordinate as nt, BoundedLRUCache as o, normalize$4 as oi, emitValidationErrors as on, filterObject as or, mercatorXfromLng as ot, GeoJSONWrapper as p, transformMat3$1 as pi, createExpression as pn, isImageBitmap as pr, FillBucket as pt, FillExtrusionBucket as q, createIdentityMat4f32 as qn, zero as qr, TriangleIndexArray as qt, TextAnchorEnum as r, len$4 as ri, ZoomHistory as rn, ensureError as rr, altitudeFromMercatorZ as rt, TileCache as s, rotateX$2 as si, validateAndEmit as sn, findLineIntersection as sr, mercatorYfromLat as st, getAnchorJustification as t, cross$2 as ti, rtlWorkerPlugin as tn, differenceOfAnglesDegrees as tr, unprojectFromWorldCoordinates as tt, GeoJSONFeature as u, scale$4 as ui, Color as un, getEdgeTiles as ur, earthRadius as ut, UnwrappedTileID as v, copy$5 as vi, groupByLayout as vn, isWorker as vr, isColorReliefStyleLayer as vt, isCustomStyleLayer as w, invert$2 as wi, AJAXError as wn, pick as wr, renderColorRamp as wt, isInBoundsForZoomLngLat as x, exactEquals$5 as xi, ErrorEvent as xn, mod as xr, isHillshadeStyleLayer as xt, calculateTileKey as y, create$5 as yi, interpolateFactory as yn, lerp as yr, DEMData as yt, renderStyleImage as z, isOffscreenCanvasDistorted as zi, JSON_PREFIX as zn, wrap$1 as zr, SegmentVector as zt };
|
|
31363
31452
|
|
|
31364
31453
|
//# sourceMappingURL=maplibre-gl-shared-dev.mjs.map
|