ts-maps 0.2.7 → 0.3.1

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.
Files changed (225) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +202 -141
  3. package/dist/core-map/assets/embedded-icons.d.ts +8 -0
  4. package/dist/core-map/control/AttributionControl.d.ts +12 -0
  5. package/dist/core-map/control/Control.d.ts +14 -0
  6. package/dist/core-map/control/LayersControl.d.ts +38 -0
  7. package/dist/core-map/control/ScaleControl.d.ts +14 -0
  8. package/dist/core-map/control/ZoomControl.d.ts +14 -0
  9. package/dist/core-map/control/index.d.ts +5 -0
  10. package/dist/core-map/core/Browser.d.ts +24 -0
  11. package/dist/core-map/core/Class.d.ts +12 -0
  12. package/dist/core-map/core/Events.d.ts +31 -0
  13. package/dist/core-map/core/Handler.d.ts +12 -0
  14. package/dist/core-map/core/Util.d.ts +24 -0
  15. package/dist/core-map/core/index.d.ts +7 -0
  16. package/dist/core-map/dom/Animation.d.ts +50 -0
  17. package/dist/core-map/dom/DomEvent.DoubleTap.d.ts +6 -0
  18. package/dist/core-map/dom/DomEvent.PointerEvents.d.ts +4 -0
  19. package/dist/core-map/dom/DomEvent.d.ts +15 -0
  20. package/dist/core-map/dom/DomUtil.d.ts +22 -0
  21. package/dist/core-map/dom/Draggable.d.ts +26 -0
  22. package/dist/core-map/dom/PosAnimation.d.ts +19 -0
  23. package/dist/core-map/dom/easing.d.ts +41 -0
  24. package/dist/core-map/dom/index.d.ts +8 -0
  25. package/dist/core-map/geo/LatLng.d.ts +18 -0
  26. package/dist/core-map/geo/LatLngBounds.d.ts +27 -0
  27. package/dist/core-map/geo/TerrainSource.d.ts +35 -0
  28. package/dist/core-map/geo/crs/CRS.d.ts +23 -0
  29. package/dist/core-map/geo/crs/EPSG3395.d.ts +7 -0
  30. package/dist/core-map/geo/crs/EPSG3857.d.ts +10 -0
  31. package/dist/core-map/geo/crs/EPSG4326.d.ts +7 -0
  32. package/dist/core-map/geo/crs/EarthCRS.d.ts +7 -0
  33. package/dist/core-map/geo/crs/SimpleCRS.d.ts +11 -0
  34. package/dist/core-map/geo/crs/index.d.ts +6 -0
  35. package/dist/core-map/geo/elevation.d.ts +23 -0
  36. package/dist/core-map/geo/index.d.ts +13 -0
  37. package/dist/core-map/geo/index.js +1204 -0
  38. package/dist/core-map/geo/projection/Projection.Globe.d.ts +30 -0
  39. package/dist/core-map/geo/projection/Projection.LonLat.d.ts +11 -0
  40. package/dist/core-map/geo/projection/Projection.Mercator.d.ts +6 -0
  41. package/dist/core-map/geo/projection/Projection.SphericalMercator.d.ts +6 -0
  42. package/dist/core-map/geo/projection/index.d.ts +5 -0
  43. package/dist/core-map/geo/terrainMesh.d.ts +21 -0
  44. package/dist/core-map/geometry/Bounds.d.ts +23 -0
  45. package/dist/core-map/geometry/LineUtil.d.ts +13 -0
  46. package/dist/core-map/geometry/Point.d.ts +35 -0
  47. package/dist/core-map/geometry/PolyUtil.d.ts +6 -0
  48. package/dist/core-map/geometry/RTree.d.ts +35 -0
  49. package/dist/core-map/geometry/Transformation.d.ts +12 -0
  50. package/dist/core-map/geometry/earcut.d.ts +17 -0
  51. package/dist/core-map/geometry/index.d.ts +10 -0
  52. package/dist/core-map/geometry/index.js +1586 -0
  53. package/dist/core-map/index.d.ts +59 -0
  54. package/dist/core-map/layer/BlanketOverlay.d.ts +24 -0
  55. package/dist/core-map/layer/DivOverlay.d.ts +40 -0
  56. package/dist/core-map/layer/FeatureGroup.d.ts +11 -0
  57. package/dist/core-map/layer/GeoJSON.d.ts +17 -0
  58. package/dist/core-map/layer/GeoJSONClusterSource.d.ts +54 -0
  59. package/dist/core-map/layer/HeatmapLayer.d.ts +40 -0
  60. package/dist/core-map/layer/ImageOverlay.d.ts +27 -0
  61. package/dist/core-map/layer/Layer.d.ts +27 -0
  62. package/dist/core-map/layer/LayerGroup.d.ts +16 -0
  63. package/dist/core-map/layer/Popup.d.ts +38 -0
  64. package/dist/core-map/layer/SVGOverlay.d.ts +4 -0
  65. package/dist/core-map/layer/Tooltip.d.ts +15 -0
  66. package/dist/core-map/layer/VideoOverlay.d.ts +4 -0
  67. package/dist/core-map/layer/index.d.ts +18 -0
  68. package/dist/core-map/layer/marker/DefaultIcon.d.ts +7 -0
  69. package/dist/core-map/layer/marker/DivIcon.d.ts +5 -0
  70. package/dist/core-map/layer/marker/Icon.d.ts +10 -0
  71. package/dist/core-map/layer/marker/Marker.Drag.d.ts +17 -0
  72. package/dist/core-map/layer/marker/Marker.d.ts +37 -0
  73. package/dist/core-map/layer/marker/index.d.ts +5 -0
  74. package/dist/core-map/layer/tile/GridLayer.d.ts +88 -0
  75. package/dist/core-map/layer/tile/RasterDEMLayer.d.ts +46 -0
  76. package/dist/core-map/layer/tile/TileLayer.d.ts +22 -0
  77. package/dist/core-map/layer/tile/VectorTileMapLayer.d.ts +145 -0
  78. package/dist/core-map/layer/tile/WMSTileLayer.d.ts +12 -0
  79. package/dist/core-map/layer/tile/index.d.ts +15 -0
  80. package/dist/core-map/layer/tile/urlTemplate.d.ts +17 -0
  81. package/dist/core-map/layer/vector/Canvas.d.ts +52 -0
  82. package/dist/core-map/layer/vector/Circle.d.ts +7 -0
  83. package/dist/core-map/layer/vector/CircleMarker.d.ts +22 -0
  84. package/dist/core-map/layer/vector/Path.d.ts +20 -0
  85. package/dist/core-map/layer/vector/Polygon.d.ts +13 -0
  86. package/dist/core-map/layer/vector/Polyline.d.ts +30 -0
  87. package/dist/core-map/layer/vector/Rectangle.d.ts +6 -0
  88. package/dist/core-map/layer/vector/Renderer.d.ts +12 -0
  89. package/dist/core-map/layer/vector/Renderer.getRenderer.d.ts +1 -0
  90. package/dist/core-map/layer/vector/SVG.d.ts +21 -0
  91. package/dist/core-map/layer/vector/index.d.ts +10 -0
  92. package/dist/core-map/map/Map.d.ts +352 -0
  93. package/dist/core-map/map/Style.d.ts +29 -0
  94. package/dist/core-map/map/handler/BoxZoomHandler.d.ts +23 -0
  95. package/dist/core-map/map/handler/DoubleClickZoomHandler.d.ts +6 -0
  96. package/dist/core-map/map/handler/DragHandler.d.ts +27 -0
  97. package/dist/core-map/map/handler/KeyboardHandler.d.ts +18 -0
  98. package/dist/core-map/map/handler/PinchZoomHandler.d.ts +20 -0
  99. package/dist/core-map/map/handler/ScrollWheelZoomHandler.d.ts +12 -0
  100. package/dist/core-map/map/handler/TapHoldHandler.d.ts +15 -0
  101. package/dist/core-map/map/handler/TwoFingerPitchHandler.d.ts +21 -0
  102. package/dist/core-map/map/handler/TwoFingerRotateHandler.d.ts +17 -0
  103. package/dist/core-map/map/index.d.ts +11 -0
  104. package/dist/core-map/mvt/VectorTile.d.ts +9 -0
  105. package/dist/core-map/mvt/VectorTileFeature.d.ts +59 -0
  106. package/dist/core-map/mvt/VectorTileLayer.d.ts +13 -0
  107. package/dist/core-map/proto/Pbf.d.ts +84 -0
  108. package/dist/core-map/renderer/webgl/GLContext.d.ts +22 -0
  109. package/dist/core-map/renderer/webgl/WebGLTileRenderer.d.ts +86 -0
  110. package/dist/core-map/renderer/webgl/index.d.ts +9 -0
  111. package/dist/core-map/renderer/webgl/mat4.d.ts +14 -0
  112. package/dist/core-map/services/index.d.ts +26 -0
  113. package/dist/core-map/services/index.js +1230 -0
  114. package/dist/core-map/services/providers/Google.d.ts +16 -0
  115. package/dist/core-map/services/providers/Mapbox.d.ts +26 -0
  116. package/dist/core-map/services/providers/Maptiler.d.ts +11 -0
  117. package/dist/core-map/services/providers/Nominatim.d.ts +11 -0
  118. package/dist/core-map/services/providers/OSRM.d.ts +20 -0
  119. package/dist/core-map/services/providers/Photon.d.ts +10 -0
  120. package/dist/core-map/services/providers/Valhalla.d.ts +20 -0
  121. package/dist/core-map/services/types.d.ts +84 -0
  122. package/dist/core-map/storage/TileCache.d.ts +40 -0
  123. package/dist/core-map/storage/cachedFetch.d.ts +13 -0
  124. package/dist/core-map/storage/defaultCache.d.ts +3 -0
  125. package/dist/core-map/storage/index.d.ts +13 -0
  126. package/dist/core-map/storage/index.js +283 -0
  127. package/dist/core-map/storage/offlineRegion.d.ts +26 -0
  128. package/dist/core-map/style-spec/diff.d.ts +17 -0
  129. package/dist/core-map/style-spec/expressions/Color.d.ts +16 -0
  130. package/dist/core-map/style-spec/expressions/compile.d.ts +4 -0
  131. package/dist/core-map/style-spec/expressions/errors.d.ts +8 -0
  132. package/dist/core-map/style-spec/expressions/index.d.ts +16 -0
  133. package/dist/core-map/style-spec/expressions/legacyFilter.d.ts +6 -0
  134. package/dist/core-map/style-spec/expressions/operators/conversion.d.ts +1 -0
  135. package/dist/core-map/style-spec/expressions/operators/interpolate.d.ts +14 -0
  136. package/dist/core-map/style-spec/expressions/operators/logical.d.ts +1 -0
  137. package/dist/core-map/style-spec/expressions/operators/lookup.d.ts +1 -0
  138. package/dist/core-map/style-spec/expressions/operators/math.d.ts +1 -0
  139. package/dist/core-map/style-spec/expressions/operators/string.d.ts +1 -0
  140. package/dist/core-map/style-spec/expressions/registry.d.ts +29 -0
  141. package/dist/core-map/style-spec/expressions/types.d.ts +48 -0
  142. package/dist/core-map/style-spec/expressions/validate.d.ts +13 -0
  143. package/dist/core-map/style-spec/index.d.ts +68 -0
  144. package/dist/core-map/style-spec/index.js +2529 -0
  145. package/dist/core-map/style-spec/schema.d.ts +381 -0
  146. package/dist/core-map/style-spec/types.d.ts +375 -0
  147. package/dist/core-map/style-spec/validate.d.ts +14 -0
  148. package/dist/core-map/symbols/CollisionIndex.d.ts +21 -0
  149. package/dist/core-map/symbols/GlyphAtlas.d.ts +38 -0
  150. package/dist/core-map/symbols/IconAtlas.d.ts +18 -0
  151. package/dist/core-map/symbols/index.d.ts +6 -0
  152. package/dist/core-map/symbols/index.js +501 -0
  153. package/dist/index.d.ts +2 -4
  154. package/dist/index.js +18413 -1857
  155. package/package.json +50 -58
  156. package/src/core-map/ts-maps.css +725 -0
  157. package/dist/components/base.d.ts +0 -17
  158. package/dist/components/concerns/interactable.d.ts +0 -1
  159. package/dist/components/line.d.ts +0 -29
  160. package/dist/components/marker.d.ts +0 -50
  161. package/dist/components/region.d.ts +0 -46
  162. package/dist/components/tooltip.d.ts +0 -22
  163. package/dist/core/apply-transform.d.ts +0 -7
  164. package/dist/core/coords-to-point.d.ts +0 -12
  165. package/dist/core/create-lines.d.ts +0 -2
  166. package/dist/core/create-markers.d.ts +0 -2
  167. package/dist/core/create-regions.d.ts +0 -2
  168. package/dist/core/create-series.d.ts +0 -3
  169. package/dist/core/get-inset-for-point.d.ts +0 -13
  170. package/dist/core/get-marker-position.d.ts +0 -6
  171. package/dist/core/index.d.ts +0 -1
  172. package/dist/core/reposition-labels.d.ts +0 -2
  173. package/dist/core/reposition-lines.d.ts +0 -2
  174. package/dist/core/reposition-markers.d.ts +0 -2
  175. package/dist/core/resize.d.ts +0 -3
  176. package/dist/core/set-focus.d.ts +0 -2
  177. package/dist/core/set-scale.d.ts +0 -2
  178. package/dist/core/setup-container-events.d.ts +0 -2
  179. package/dist/core/setup-container-touch-events.d.ts +0 -2
  180. package/dist/core/setup-element-events.d.ts +0 -2
  181. package/dist/core/setup-zoom-buttons.d.ts +0 -2
  182. package/dist/core/update-size.d.ts +0 -2
  183. package/dist/data-visualization.d.ts +0 -17
  184. package/dist/defaults/events.d.ts +0 -1
  185. package/dist/defaults/options.d.ts +0 -1
  186. package/dist/event-handler.d.ts +0 -1
  187. package/dist/legend.d.ts +0 -17
  188. package/dist/map.d.ts +0 -81
  189. package/dist/maps/brasil.d.ts +0 -2
  190. package/dist/maps/brasil.js +0 -7
  191. package/dist/maps/canada.d.ts +0 -2
  192. package/dist/maps/canada.js +0 -7
  193. package/dist/maps/iraq.d.ts +0 -2
  194. package/dist/maps/iraq.js +0 -84
  195. package/dist/maps/italy.d.ts +0 -2
  196. package/dist/maps/italy.js +0 -7
  197. package/dist/maps/russia.d.ts +0 -2
  198. package/dist/maps/russia.js +0 -366
  199. package/dist/maps/spain.d.ts +0 -2
  200. package/dist/maps/spain.js +0 -7
  201. package/dist/maps/us-aea-en.d.ts +0 -2
  202. package/dist/maps/us-aea-en.js +0 -7
  203. package/dist/maps/us-lcc-en.d.ts +0 -2
  204. package/dist/maps/us-lcc-en.js +0 -7
  205. package/dist/maps/us-merc-en.d.ts +0 -2
  206. package/dist/maps/us-merc-en.js +0 -7
  207. package/dist/maps/us-mill-en.d.ts +0 -2
  208. package/dist/maps/us-mill-en.js +0 -7
  209. package/dist/maps/world-merc.d.ts +0 -2
  210. package/dist/maps/world-merc.js +0 -7
  211. package/dist/maps/world.d.ts +0 -2
  212. package/dist/maps/world.js +0 -7
  213. package/dist/projection.d.ts +0 -1
  214. package/dist/scales/ordinal-scale.d.ts +0 -12
  215. package/dist/series.d.ts +0 -14
  216. package/dist/svg/base-element.d.ts +0 -19
  217. package/dist/svg/canvas-element.d.ts +0 -21
  218. package/dist/svg/image-element.d.ts +0 -12
  219. package/dist/svg/shape-element.d.ts +0 -19
  220. package/dist/svg/text-element.d.ts +0 -7
  221. package/dist/types.d.ts +0 -418
  222. package/dist/util/deep-merge.d.ts +0 -2
  223. package/dist/util/index.d.ts +0 -18
  224. package/dist/utils.d.ts +0 -87
  225. package/dist/vector-map.d.ts +0 -5
@@ -0,0 +1,1204 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ function __accessProp(key) {
6
+ return this[key];
7
+ }
8
+ var __toCommonJS = (from) => {
9
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
10
+ if (entry)
11
+ return entry;
12
+ entry = __defProp({}, "__esModule", { value: true });
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (var key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(entry, key))
16
+ __defProp(entry, key, {
17
+ get: __accessProp.bind(from, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ __moduleCache.set(from, entry);
22
+ return entry;
23
+ };
24
+ var __moduleCache;
25
+ var __returnValue = (v) => v;
26
+ function __exportSetter(name, newValue) {
27
+ this[name] = __returnValue.bind(null, newValue);
28
+ }
29
+ var __export = (target, all) => {
30
+ for (var name in all)
31
+ __defProp(target, name, {
32
+ get: all[name],
33
+ enumerable: true,
34
+ configurable: true,
35
+ set: __exportSetter.bind(all, name)
36
+ });
37
+ };
38
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
39
+
40
+ // src/core-map/core/Util.ts
41
+ var exports_Util = {};
42
+ __export(exports_Util, {
43
+ wrapNum: () => wrapNum,
44
+ throttle: () => throttle,
45
+ template: () => template,
46
+ stamp: () => stamp,
47
+ splitWords: () => splitWords,
48
+ setOptions: () => setOptions,
49
+ setLastId: () => setLastId,
50
+ noop: () => noop,
51
+ lastId: () => lastId,
52
+ formatNum: () => formatNum,
53
+ falseFn: () => falseFn
54
+ });
55
+ function stamp(obj) {
56
+ if (!("_tsmap_id" in obj)) {
57
+ obj._tsmap_id = ++lastId;
58
+ }
59
+ return obj._tsmap_id;
60
+ }
61
+ function setLastId(id) {
62
+ lastId = id;
63
+ }
64
+ function throttle(fn, time, context) {
65
+ let lock = false;
66
+ let queuedArgs = false;
67
+ function later() {
68
+ lock = false;
69
+ if (queuedArgs) {
70
+ wrapperFn.apply(context, queuedArgs);
71
+ queuedArgs = false;
72
+ }
73
+ }
74
+ function wrapperFn(...args) {
75
+ if (lock) {
76
+ queuedArgs = args;
77
+ } else {
78
+ fn.apply(context, args);
79
+ setTimeout(later, time);
80
+ lock = true;
81
+ }
82
+ }
83
+ return wrapperFn;
84
+ }
85
+ function wrapNum(x, range, includeMax) {
86
+ const max = range[1];
87
+ const min = range[0];
88
+ const d = max - min;
89
+ return x === max && includeMax ? x : ((x - min) % d + d) % d + min;
90
+ }
91
+ function falseFn(..._args) {
92
+ return false;
93
+ }
94
+ function formatNum(num, precision) {
95
+ if (precision === false)
96
+ return num;
97
+ const pow = 10 ** (precision === undefined ? 6 : precision);
98
+ return Math.round(num * pow) / pow;
99
+ }
100
+ function splitWords(str) {
101
+ return str.trim().split(/\s+/);
102
+ }
103
+ function setOptions(obj, options) {
104
+ if (!Object.hasOwn(obj, "options")) {
105
+ obj.options = obj.options ? Object.create(obj.options) : {};
106
+ }
107
+ if (options) {
108
+ for (const i in options) {
109
+ if (Object.hasOwn(options, i)) {
110
+ obj.options[i] = options[i];
111
+ }
112
+ }
113
+ }
114
+ return obj.options;
115
+ }
116
+ function template(str, data) {
117
+ return str.replace(templateRe, (match, key) => {
118
+ const k = key.trim();
119
+ let value = data[k];
120
+ if (value === undefined)
121
+ throw new Error(`No value provided for variable ${match}`);
122
+ else if (typeof value === "function")
123
+ value = value(data);
124
+ return value;
125
+ });
126
+ }
127
+ function noop() {}
128
+ var lastId = 0, templateRe;
129
+ var init_Util = __esm(() => {
130
+ templateRe = /\{([^{}]+)\}/g;
131
+ });
132
+
133
+ // src/core-map/geometry/Point.ts
134
+ class Point {
135
+ x;
136
+ y;
137
+ constructor(x, y, round) {
138
+ const valid = Point.validate(x, y);
139
+ if (!valid) {
140
+ throw new Error(`Invalid Point object: (${x}, ${y})`);
141
+ }
142
+ let _x;
143
+ let _y;
144
+ if (x instanceof Point) {
145
+ return x;
146
+ } else if (Array.isArray(x)) {
147
+ _x = x[0];
148
+ _y = x[1];
149
+ } else if (typeof x === "object" && x !== null && "x" in x && "y" in x) {
150
+ _x = x.x;
151
+ _y = x.y;
152
+ } else {
153
+ _x = x;
154
+ _y = y;
155
+ }
156
+ this.x = round ? Math.round(_x) : _x;
157
+ this.y = round ? Math.round(_y) : _y;
158
+ }
159
+ static validate(x, y) {
160
+ if (x instanceof Point || Array.isArray(x))
161
+ return true;
162
+ if (x && typeof x === "object" && "x" in x && "y" in x)
163
+ return true;
164
+ if ((x || x === 0) && (y || y === 0))
165
+ return true;
166
+ return false;
167
+ }
168
+ clone() {
169
+ const p = new Point(0, 0);
170
+ p.x = this.x;
171
+ p.y = this.y;
172
+ return p;
173
+ }
174
+ add(point) {
175
+ return this.clone()._add(new Point(point));
176
+ }
177
+ _add(point) {
178
+ this.x += point.x;
179
+ this.y += point.y;
180
+ return this;
181
+ }
182
+ subtract(point) {
183
+ return this.clone()._subtract(new Point(point));
184
+ }
185
+ _subtract(point) {
186
+ this.x -= point.x;
187
+ this.y -= point.y;
188
+ return this;
189
+ }
190
+ divideBy(num) {
191
+ return this.clone()._divideBy(num);
192
+ }
193
+ _divideBy(num) {
194
+ this.x /= num;
195
+ this.y /= num;
196
+ return this;
197
+ }
198
+ multiplyBy(num) {
199
+ return this.clone()._multiplyBy(num);
200
+ }
201
+ _multiplyBy(num) {
202
+ this.x *= num;
203
+ this.y *= num;
204
+ return this;
205
+ }
206
+ scaleBy(point) {
207
+ return new Point(this.x * point.x, this.y * point.y);
208
+ }
209
+ unscaleBy(point) {
210
+ return new Point(this.x / point.x, this.y / point.y);
211
+ }
212
+ round() {
213
+ return this.clone()._round();
214
+ }
215
+ _round() {
216
+ this.x = Math.round(this.x);
217
+ this.y = Math.round(this.y);
218
+ return this;
219
+ }
220
+ floor() {
221
+ return this.clone()._floor();
222
+ }
223
+ _floor() {
224
+ this.x = Math.floor(this.x);
225
+ this.y = Math.floor(this.y);
226
+ return this;
227
+ }
228
+ ceil() {
229
+ return this.clone()._ceil();
230
+ }
231
+ _ceil() {
232
+ this.x = Math.ceil(this.x);
233
+ this.y = Math.ceil(this.y);
234
+ return this;
235
+ }
236
+ trunc() {
237
+ return this.clone()._trunc();
238
+ }
239
+ _trunc() {
240
+ this.x = Math.trunc(this.x);
241
+ this.y = Math.trunc(this.y);
242
+ return this;
243
+ }
244
+ distanceTo(point) {
245
+ const p = new Point(point);
246
+ const x = p.x - this.x;
247
+ const y = p.y - this.y;
248
+ return Math.sqrt(x * x + y * y);
249
+ }
250
+ equals(point) {
251
+ const p = new Point(point);
252
+ return p.x === this.x && p.y === this.y;
253
+ }
254
+ contains(point) {
255
+ const p = new Point(point);
256
+ return Math.abs(p.x) <= Math.abs(this.x) && Math.abs(p.y) <= Math.abs(this.y);
257
+ }
258
+ toString() {
259
+ return `Point(${formatNum(this.x)}, ${formatNum(this.y)})`;
260
+ }
261
+ }
262
+ function toPoint(x, y, round) {
263
+ if (x instanceof Point)
264
+ return x;
265
+ if (Array.isArray(x))
266
+ return new Point(x[0], x[1]);
267
+ if (x === undefined || x === null)
268
+ return x;
269
+ if (typeof x === "object" && "x" in x && "y" in x)
270
+ return new Point(x.x, x.y);
271
+ return new Point(x, y, round);
272
+ }
273
+ var init_Point = __esm(() => {
274
+ init_Util();
275
+ });
276
+
277
+ // src/core-map/geometry/Bounds.ts
278
+ class Bounds {
279
+ min;
280
+ max;
281
+ constructor(a, b) {
282
+ if (!a)
283
+ return;
284
+ if (a instanceof Bounds) {
285
+ return a;
286
+ }
287
+ const points = b ? [a, b] : a;
288
+ for (const point of points) {
289
+ this.extend(point);
290
+ }
291
+ }
292
+ extend(obj) {
293
+ let min2;
294
+ let max2;
295
+ if (!obj)
296
+ return this;
297
+ if (obj instanceof Point || Array.isArray(obj) && typeof obj[0] === "number" || obj && "x" in obj) {
298
+ min2 = max2 = toPoint(obj);
299
+ } else {
300
+ const b = new Bounds(obj);
301
+ min2 = b.min;
302
+ max2 = b.max;
303
+ if (!min2 || !max2)
304
+ return this;
305
+ }
306
+ if (!this.min && !this.max) {
307
+ this.min = min2.clone();
308
+ this.max = max2.clone();
309
+ } else {
310
+ this.min.x = Math.min(min2.x, this.min.x);
311
+ this.max.x = Math.max(max2.x, this.max.x);
312
+ this.min.y = Math.min(min2.y, this.min.y);
313
+ this.max.y = Math.max(max2.y, this.max.y);
314
+ }
315
+ return this;
316
+ }
317
+ getCenter(round) {
318
+ return new Point((this.min.x + this.max.x) / 2, (this.min.y + this.max.y) / 2, round);
319
+ }
320
+ getBottomLeft() {
321
+ return new Point(this.min.x, this.max.y);
322
+ }
323
+ getTopRight() {
324
+ return new Point(this.max.x, this.min.y);
325
+ }
326
+ getTopLeft() {
327
+ return this.min;
328
+ }
329
+ getBottomRight() {
330
+ return this.max;
331
+ }
332
+ getSize() {
333
+ return this.max.subtract(this.min);
334
+ }
335
+ contains(obj) {
336
+ let min, max;
337
+ let target = obj;
338
+ if (Array.isArray(target) && typeof target[0] === "number" || target instanceof Point) {
339
+ target = toPoint(target);
340
+ } else {
341
+ target = new Bounds(target);
342
+ }
343
+ if (target instanceof Bounds) {
344
+ min = target.min;
345
+ max = target.max;
346
+ } else {
347
+ min = max = target;
348
+ }
349
+ return min.x >= this.min.x && max.x <= this.max.x && min.y >= this.min.y && max.y <= this.max.y;
350
+ }
351
+ intersects(bounds) {
352
+ const b = new Bounds(bounds);
353
+ const min = this.min;
354
+ const max = this.max;
355
+ const min2 = b.min;
356
+ const max2 = b.max;
357
+ const xIntersects = max2.x >= min.x && min2.x <= max.x;
358
+ const yIntersects = max2.y >= min.y && min2.y <= max.y;
359
+ return xIntersects && yIntersects;
360
+ }
361
+ overlaps(bounds) {
362
+ const b = new Bounds(bounds);
363
+ const min = this.min;
364
+ const max = this.max;
365
+ const min2 = b.min;
366
+ const max2 = b.max;
367
+ const xOverlaps = max2.x > min.x && min2.x < max.x;
368
+ const yOverlaps = max2.y > min.y && min2.y < max.y;
369
+ return xOverlaps && yOverlaps;
370
+ }
371
+ isValid() {
372
+ return !!(this.min && this.max);
373
+ }
374
+ pad(bufferRatio) {
375
+ const min = this.min;
376
+ const max = this.max;
377
+ const heightBuffer = Math.abs(min.x - max.x) * bufferRatio;
378
+ const widthBuffer = Math.abs(min.y - max.y) * bufferRatio;
379
+ return new Bounds(new Point(min.x - heightBuffer, min.y - widthBuffer), new Point(max.x + heightBuffer, max.y + widthBuffer));
380
+ }
381
+ equals(bounds) {
382
+ if (!bounds)
383
+ return false;
384
+ const b = new Bounds(bounds);
385
+ return this.min.equals(b.getTopLeft()) && this.max.equals(b.getBottomRight());
386
+ }
387
+ }
388
+ function toBounds(a, b) {
389
+ if (!a || a instanceof Bounds)
390
+ return a;
391
+ return new Bounds(a, b);
392
+ }
393
+ var init_Bounds = __esm(() => {
394
+ init_Point();
395
+ });
396
+
397
+ // src/core-map/geo/LatLngBounds.ts
398
+ class LatLngBounds {
399
+ _southWest;
400
+ _northEast;
401
+ constructor(corner1, corner2) {
402
+ if (!corner1)
403
+ return;
404
+ if (corner1 instanceof LatLngBounds) {
405
+ return corner1;
406
+ }
407
+ const latlngs = corner2 ? [corner1, corner2] : corner1;
408
+ for (const latlng of latlngs)
409
+ this.extend(latlng);
410
+ }
411
+ extend(obj) {
412
+ const sw = this._southWest;
413
+ const ne = this._northEast;
414
+ let sw2, ne2;
415
+ if (obj instanceof LatLng) {
416
+ sw2 = obj;
417
+ ne2 = obj;
418
+ } else if (obj instanceof LatLngBounds) {
419
+ sw2 = obj._southWest;
420
+ ne2 = obj._northEast;
421
+ if (!sw2 || !ne2)
422
+ return this;
423
+ } else {
424
+ if (!obj)
425
+ return this;
426
+ if (LatLng.validate(obj))
427
+ return this.extend(new LatLng(obj));
428
+ return this.extend(new LatLngBounds(obj));
429
+ }
430
+ if (!sw && !ne) {
431
+ this._southWest = new LatLng(sw2.lat, sw2.lng);
432
+ this._northEast = new LatLng(ne2.lat, ne2.lng);
433
+ } else {
434
+ sw.lat = Math.min(sw2.lat, sw.lat);
435
+ sw.lng = Math.min(sw2.lng, sw.lng);
436
+ ne.lat = Math.max(ne2.lat, ne.lat);
437
+ ne.lng = Math.max(ne2.lng, ne.lng);
438
+ }
439
+ return this;
440
+ }
441
+ pad(bufferRatio) {
442
+ const sw = this._southWest;
443
+ const ne = this._northEast;
444
+ const heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio;
445
+ const widthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio;
446
+ return new LatLngBounds(new LatLng(sw.lat - heightBuffer, sw.lng - widthBuffer), new LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer));
447
+ }
448
+ getCenter() {
449
+ return new LatLng((this._southWest.lat + this._northEast.lat) / 2, (this._southWest.lng + this._northEast.lng) / 2);
450
+ }
451
+ getSouthWest() {
452
+ return this._southWest;
453
+ }
454
+ getNorthEast() {
455
+ return this._northEast;
456
+ }
457
+ getNorthWest() {
458
+ return new LatLng(this.getNorth(), this.getWest());
459
+ }
460
+ getSouthEast() {
461
+ return new LatLng(this.getSouth(), this.getEast());
462
+ }
463
+ getWest() {
464
+ return this._southWest.lng;
465
+ }
466
+ getSouth() {
467
+ return this._southWest.lat;
468
+ }
469
+ getEast() {
470
+ return this._northEast.lng;
471
+ }
472
+ getNorth() {
473
+ return this._northEast.lat;
474
+ }
475
+ contains(obj) {
476
+ let target = obj;
477
+ if (LatLng.validate(target))
478
+ target = new LatLng(target);
479
+ else
480
+ target = new LatLngBounds(target);
481
+ const sw = this._southWest;
482
+ const ne = this._northEast;
483
+ let sw2, ne2;
484
+ if (target instanceof LatLngBounds) {
485
+ sw2 = target.getSouthWest();
486
+ ne2 = target.getNorthEast();
487
+ } else {
488
+ sw2 = ne2 = target;
489
+ }
490
+ return sw2.lat >= sw.lat && ne2.lat <= ne.lat && sw2.lng >= sw.lng && ne2.lng <= ne.lng;
491
+ }
492
+ intersects(bounds) {
493
+ const b = new LatLngBounds(bounds);
494
+ const sw = this._southWest;
495
+ const ne = this._northEast;
496
+ const sw2 = b.getSouthWest();
497
+ const ne2 = b.getNorthEast();
498
+ const latIntersects = ne2.lat >= sw.lat && sw2.lat <= ne.lat;
499
+ const lngIntersects = ne2.lng >= sw.lng && sw2.lng <= ne.lng;
500
+ return latIntersects && lngIntersects;
501
+ }
502
+ overlaps(bounds) {
503
+ const b = new LatLngBounds(bounds);
504
+ const sw = this._southWest;
505
+ const ne = this._northEast;
506
+ const sw2 = b.getSouthWest();
507
+ const ne2 = b.getNorthEast();
508
+ const latOverlaps = ne2.lat > sw.lat && sw2.lat < ne.lat;
509
+ const lngOverlaps = ne2.lng > sw.lng && sw2.lng < ne.lng;
510
+ return latOverlaps && lngOverlaps;
511
+ }
512
+ toBBoxString() {
513
+ return [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()].join(",");
514
+ }
515
+ equals(bounds, maxMargin) {
516
+ if (!bounds)
517
+ return false;
518
+ const b = new LatLngBounds(bounds);
519
+ return this._southWest.equals(b.getSouthWest(), maxMargin) && this._northEast.equals(b.getNorthEast(), maxMargin);
520
+ }
521
+ isValid() {
522
+ return !!(this._southWest && this._northEast);
523
+ }
524
+ }
525
+ function toLatLngBounds(a, b) {
526
+ if (a instanceof LatLngBounds)
527
+ return a;
528
+ return new LatLngBounds(a, b);
529
+ }
530
+ var init_LatLngBounds = __esm(() => {
531
+ init_LatLng();
532
+ });
533
+
534
+ // src/core-map/geo/crs/CRS.ts
535
+ class CRS {
536
+ static projection = undefined;
537
+ static transformation = undefined;
538
+ static code;
539
+ static wrapLng;
540
+ static wrapLat;
541
+ static infinite = false;
542
+ static latLngToPoint(latlng, zoom) {
543
+ const projectedPoint = this.projection.project(latlng);
544
+ const scale = this.scale(zoom);
545
+ return this.transformation._transform(projectedPoint, scale);
546
+ }
547
+ static pointToLatLng(point, zoom) {
548
+ const scale = this.scale(zoom);
549
+ const untransformedPoint = this.transformation.untransform(point, scale);
550
+ return this.projection.unproject(untransformedPoint);
551
+ }
552
+ static project(latlng) {
553
+ return this.projection.project(latlng);
554
+ }
555
+ static unproject(point) {
556
+ return this.projection.unproject(point);
557
+ }
558
+ static scale(zoom) {
559
+ return 256 * 2 ** zoom;
560
+ }
561
+ static zoom(scale) {
562
+ return Math.log(scale / 256) / Math.LN2;
563
+ }
564
+ static getProjectedBounds(zoom) {
565
+ if (this.infinite)
566
+ return null;
567
+ const b = this.projection.bounds;
568
+ const s = this.scale(zoom);
569
+ const min = this.transformation.transform(b.min, s);
570
+ const max = this.transformation.transform(b.max, s);
571
+ return new Bounds(min, max);
572
+ }
573
+ static distance(_a, _b) {
574
+ return 0;
575
+ }
576
+ static wrapLatLng(latlng) {
577
+ const ll = new LatLng(latlng);
578
+ const lng = this.wrapLng ? wrapNum(ll.lng, this.wrapLng, true) : ll.lng;
579
+ const lat = this.wrapLat ? wrapNum(ll.lat, this.wrapLat, true) : ll.lat;
580
+ const alt = ll.alt;
581
+ return new LatLng(lat, lng, alt);
582
+ }
583
+ static wrapLatLngBounds(bounds) {
584
+ const b = new LatLngBounds(bounds);
585
+ const center = b.getCenter();
586
+ const newCenter = this.wrapLatLng(center);
587
+ const latShift = center.lat - newCenter.lat;
588
+ const lngShift = center.lng - newCenter.lng;
589
+ if (latShift === 0 && lngShift === 0)
590
+ return b;
591
+ const sw = b.getSouthWest();
592
+ const ne = b.getNorthEast();
593
+ const newSw = new LatLng(sw.lat - latShift, sw.lng - lngShift);
594
+ const newNe = new LatLng(ne.lat - latShift, ne.lng - lngShift);
595
+ return new LatLngBounds(newSw, newNe);
596
+ }
597
+ }
598
+ var init_CRS = __esm(() => {
599
+ init_Util();
600
+ init_Bounds();
601
+ init_LatLng();
602
+ init_LatLngBounds();
603
+ });
604
+
605
+ // src/core-map/geo/crs/EarthCRS.ts
606
+ var EarthCRS;
607
+ var init_EarthCRS = __esm(() => {
608
+ init_CRS();
609
+ EarthCRS = class EarthCRS extends CRS {
610
+ static wrapLng = [-180, 180];
611
+ static R = 6371000;
612
+ static distance(latlng1, latlng2) {
613
+ const rad = Math.PI / 180;
614
+ const lat1 = latlng1.lat * rad;
615
+ const lat2 = latlng2.lat * rad;
616
+ const sinDLat = Math.sin((latlng2.lat - latlng1.lat) * rad / 2);
617
+ const sinDLon = Math.sin((latlng2.lng - latlng1.lng) * rad / 2);
618
+ const a = sinDLat * sinDLat + Math.cos(lat1) * Math.cos(lat2) * sinDLon * sinDLon;
619
+ const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
620
+ return this.R * c;
621
+ }
622
+ };
623
+ });
624
+
625
+ // src/core-map/geo/LatLng.ts
626
+ class LatLng {
627
+ lat;
628
+ lng;
629
+ alt;
630
+ constructor(lat, lng, alt) {
631
+ const valid = LatLng.validate(lat, lng, alt);
632
+ if (!valid)
633
+ throw new Error(`Invalid LatLng object: (${lat}, ${lng})`);
634
+ let _lat, _lng, _alt;
635
+ if (lat instanceof LatLng) {
636
+ return lat;
637
+ } else if (Array.isArray(lat) && typeof lat[0] !== "object") {
638
+ if (lat.length === 3) {
639
+ _lat = lat[0];
640
+ _lng = lat[1];
641
+ _alt = lat[2];
642
+ } else {
643
+ _lat = lat[0];
644
+ _lng = lat[1];
645
+ }
646
+ } else if (typeof lat === "object" && lat !== null && "lat" in lat) {
647
+ const o = lat;
648
+ _lat = o.lat;
649
+ _lng = "lng" in o ? o.lng : o.lon;
650
+ _alt = o.alt;
651
+ } else {
652
+ _lat = lat;
653
+ _lng = lng;
654
+ _alt = alt;
655
+ }
656
+ this.lat = +_lat;
657
+ this.lng = +_lng;
658
+ if (_alt !== undefined)
659
+ this.alt = +_alt;
660
+ }
661
+ static validate(lat, lng, _alt) {
662
+ if (lat instanceof LatLng || typeof lat === "object" && lat !== null && "lat" in lat)
663
+ return true;
664
+ if (lat && Array.isArray(lat) && typeof lat[0] !== "object") {
665
+ if (lat.length === 3 || lat.length === 2)
666
+ return true;
667
+ return false;
668
+ }
669
+ if ((lat || lat === 0) && (lng || lng === 0))
670
+ return true;
671
+ return false;
672
+ }
673
+ equals(obj, maxMargin) {
674
+ if (!obj)
675
+ return false;
676
+ const other = new LatLng(obj);
677
+ const margin = Math.max(Math.abs(this.lat - other.lat), Math.abs(this.lng - other.lng));
678
+ return margin <= (maxMargin ?? 0.000000001);
679
+ }
680
+ toString(precision) {
681
+ return `LatLng(${formatNum(this.lat, precision)}, ${formatNum(this.lng, precision)})`;
682
+ }
683
+ distanceTo(other) {
684
+ return EarthCRS.distance(this, new LatLng(other));
685
+ }
686
+ wrap() {
687
+ return EarthCRS.wrapLatLng(this);
688
+ }
689
+ toBounds(sizeInMeters) {
690
+ const latAccuracy = 180 * sizeInMeters / 40075017;
691
+ const lngAccuracy = latAccuracy / Math.cos(Math.PI / 180 * this.lat);
692
+ return new LatLngBounds([this.lat - latAccuracy, this.lng - lngAccuracy], [this.lat + latAccuracy, this.lng + lngAccuracy]);
693
+ }
694
+ clone() {
695
+ const latlng = new LatLng(0, 0);
696
+ latlng.lat = this.lat;
697
+ latlng.lng = this.lng;
698
+ latlng.alt = this.alt;
699
+ return latlng;
700
+ }
701
+ }
702
+ function toLatLng(a, b, c) {
703
+ if (a instanceof LatLng)
704
+ return a;
705
+ if (a === null || a === undefined)
706
+ return a;
707
+ return new LatLng(a, b, c);
708
+ }
709
+ var init_LatLng = __esm(() => {
710
+ init_Util();
711
+ init_EarthCRS();
712
+ init_LatLngBounds();
713
+ });
714
+
715
+ // src/core-map/geo/elevation.ts
716
+ function decodeMapboxRGB(r, g, b) {
717
+ return -1e4 + (r * 65536 + g * 256 + b) * 0.1;
718
+ }
719
+ function decodeTerrariumRGB(r, g, b) {
720
+ return r * 256 + g + b / 256 - 32768;
721
+ }
722
+ function getElevationDecoder(encoding) {
723
+ return encoding === "terrarium" ? decodeTerrariumRGB : decodeMapboxRGB;
724
+ }
725
+ function decodeElevationGrid(pixels, encoding = "mapbox") {
726
+ const n = pixels.length / 4 | 0;
727
+ const elev = new Float32Array(n);
728
+ const decode = getElevationDecoder(encoding);
729
+ for (let i = 0, p = 0;i < n; i++, p += 4)
730
+ elev[i] = decode(pixels[p], pixels[p + 1], pixels[p + 2]);
731
+ return elev;
732
+ }
733
+ function sampleElevationBilinear(elev, size, u, v) {
734
+ const cu = clamp(u, 0, size - 1);
735
+ const cv = clamp(v, 0, size - 1);
736
+ const x0 = Math.floor(cu);
737
+ const y0 = Math.floor(cv);
738
+ const x1 = Math.min(size - 1, x0 + 1);
739
+ const y1 = Math.min(size - 1, y0 + 1);
740
+ const fx = cu - x0;
741
+ const fy = cv - y0;
742
+ const e00 = elev[y0 * size + x0];
743
+ const e10 = elev[y0 * size + x1];
744
+ const e01 = elev[y1 * size + x0];
745
+ const e11 = elev[y1 * size + x1];
746
+ const a = e00 * (1 - fx) + e10 * fx;
747
+ const b = e01 * (1 - fx) + e11 * fx;
748
+ return a * (1 - fy) + b * fy;
749
+ }
750
+ function clamp(v, lo, hi) {
751
+ return v < lo ? lo : v > hi ? hi : v;
752
+ }
753
+
754
+ // src/core-map/geo/terrainMesh.ts
755
+ function buildTerrainMesh(opts) {
756
+ const demSize = opts.demSize;
757
+ if (demSize < 2)
758
+ throw new RangeError("demSize must be >= 2");
759
+ if (opts.elevation.length < demSize * demSize)
760
+ throw new RangeError(`elevation array is too small for demSize=${demSize}`);
761
+ const tileSize = opts.tileSize ?? demSize;
762
+ const resolution = Math.max(1, Math.floor(opts.resolution ?? 32));
763
+ const exaggeration = opts.exaggeration ?? 1;
764
+ const upm = opts.unitsPerMeter ?? 1;
765
+ const verticesPerSide = resolution + 1;
766
+ const vertexCount = verticesPerSide * verticesPerSide;
767
+ const positions = new Float32Array(vertexCount * 6);
768
+ const step = tileSize / resolution;
769
+ const demStep = (demSize - 1) / resolution;
770
+ for (let j = 0;j < verticesPerSide; j++) {
771
+ const y = j * step;
772
+ const dv = j * demStep;
773
+ for (let i = 0;i < verticesPerSide; i++) {
774
+ const x = i * step;
775
+ const du = i * demStep;
776
+ const metres = sampleElevationBilinear(opts.elevation, demSize, du, dv);
777
+ const z = metres * exaggeration * upm;
778
+ const vi = (j * verticesPerSide + i) * 6;
779
+ positions[vi] = x;
780
+ positions[vi + 1] = y;
781
+ positions[vi + 2] = z;
782
+ positions[vi + 3] = 0;
783
+ positions[vi + 4] = 0;
784
+ positions[vi + 5] = 1;
785
+ }
786
+ }
787
+ for (let j = 0;j < verticesPerSide; j++) {
788
+ for (let i = 0;i < verticesPerSide; i++) {
789
+ const im = Math.max(0, i - 1);
790
+ const ip = Math.min(verticesPerSide - 1, i + 1);
791
+ const jm = Math.max(0, j - 1);
792
+ const jp = Math.min(verticesPerSide - 1, j + 1);
793
+ const zL = positions[(j * verticesPerSide + im) * 6 + 2];
794
+ const zR = positions[(j * verticesPerSide + ip) * 6 + 2];
795
+ const zU = positions[(jm * verticesPerSide + i) * 6 + 2];
796
+ const zD = positions[(jp * verticesPerSide + i) * 6 + 2];
797
+ const dx = (ip - im) * step || 1;
798
+ const dy = (jp - jm) * step || 1;
799
+ const nx = -(zR - zL) / dx;
800
+ const ny = -(zD - zU) / dy;
801
+ const nz = 1;
802
+ const len = Math.hypot(nx, ny, nz) || 1;
803
+ const base = (j * verticesPerSide + i) * 6;
804
+ positions[base + 3] = nx / len;
805
+ positions[base + 4] = ny / len;
806
+ positions[base + 5] = nz / len;
807
+ }
808
+ }
809
+ const indices = new Uint32Array(resolution * resolution * 6);
810
+ let idx = 0;
811
+ for (let j = 0;j < resolution; j++) {
812
+ for (let i = 0;i < resolution; i++) {
813
+ const a = j * verticesPerSide + i;
814
+ const b = a + 1;
815
+ const c = a + verticesPerSide;
816
+ const d = c + 1;
817
+ indices[idx++] = a;
818
+ indices[idx++] = c;
819
+ indices[idx++] = b;
820
+ indices[idx++] = b;
821
+ indices[idx++] = c;
822
+ indices[idx++] = d;
823
+ }
824
+ }
825
+ return {
826
+ positions,
827
+ indices,
828
+ vertexCount,
829
+ indexCount: indices.length,
830
+ resolution
831
+ };
832
+ }
833
+ var init_terrainMesh = () => {};
834
+
835
+ // src/core-map/geo/TerrainSource.ts
836
+ class TerrainSource {
837
+ constructor(opts) {
838
+ this._tiles = new Map;
839
+ this._opts = {
840
+ demSize: opts?.demSize ?? 256,
841
+ encoding: opts?.encoding ?? "mapbox",
842
+ meshResolution: opts?.meshResolution ?? 32,
843
+ exaggeration: opts?.exaggeration ?? 1
844
+ };
845
+ }
846
+ get demSize() {
847
+ return this._opts.demSize;
848
+ }
849
+ get encoding() {
850
+ return this._opts.encoding;
851
+ }
852
+ get meshResolution() {
853
+ return this._opts.meshResolution;
854
+ }
855
+ get exaggeration() {
856
+ return this._opts.exaggeration;
857
+ }
858
+ setExaggeration(v) {
859
+ if (!Number.isFinite(v))
860
+ throw new RangeError("exaggeration must be a finite number");
861
+ this._opts.exaggeration = v;
862
+ }
863
+ addTilePixels(coord, pixels) {
864
+ const expected = this._opts.demSize * this._opts.demSize * 4;
865
+ if (pixels.length < expected)
866
+ throw new RangeError(`pixel buffer too small: got ${pixels.length}, need ${expected}`);
867
+ this._tiles.set(key(coord), decodeElevationGrid(pixels, this._opts.encoding));
868
+ }
869
+ addTileElevation(coord, elevation) {
870
+ const expected = this._opts.demSize * this._opts.demSize;
871
+ if (elevation.length < expected)
872
+ throw new RangeError(`elevation grid too small: got ${elevation.length}, need ${expected}`);
873
+ this._tiles.set(key(coord), elevation);
874
+ }
875
+ hasTile(coord) {
876
+ return this._tiles.has(key(coord));
877
+ }
878
+ getTile(coord) {
879
+ return this._tiles.get(key(coord));
880
+ }
881
+ deleteTile(coord) {
882
+ this._tiles.delete(key(coord));
883
+ }
884
+ clear() {
885
+ this._tiles.clear();
886
+ }
887
+ size() {
888
+ return this._tiles.size;
889
+ }
890
+ queryElevation(lng, lat, preferredZoom) {
891
+ const latC = clamp2(lat, -85.05112878, 85.05112878);
892
+ const startZ = Math.max(0, Math.floor(preferredZoom));
893
+ for (let z = startZ;z >= 0; z--) {
894
+ const tx = lngToTileX(lng, z);
895
+ const ty = latToTileY(latC, z);
896
+ const tile = this._tiles.get(key({ z, x: tx, y: ty }));
897
+ if (!tile)
898
+ continue;
899
+ const pxX = lngToPixel(lng, z) - tx * this._opts.demSize;
900
+ const pxY = latToPixel(latC, z) - ty * this._opts.demSize;
901
+ return sampleElevationBilinear(tile, this._opts.demSize, pxX, pxY);
902
+ }
903
+ return null;
904
+ }
905
+ }
906
+ function key(c) {
907
+ return `${c.z}/${c.x}/${c.y}`;
908
+ }
909
+ function clamp2(v, lo, hi) {
910
+ return v < lo ? lo : v > hi ? hi : v;
911
+ }
912
+ function lngToTileX(lng, z) {
913
+ return Math.floor((lng + 180) / 360 * 2 ** z);
914
+ }
915
+ function latToTileY(lat, z) {
916
+ const rad = lat * Math.PI / 180;
917
+ return Math.floor((1 - Math.log(Math.tan(rad) + 1 / Math.cos(rad)) / Math.PI) / 2 * 2 ** z);
918
+ }
919
+ function lngToPixel(lng, z) {
920
+ return (lng + 180) / 360 * 2 ** z * 256;
921
+ }
922
+ function latToPixel(lat, z) {
923
+ const rad = lat * Math.PI / 180;
924
+ return (1 - Math.log(Math.tan(rad) + 1 / Math.cos(rad)) / Math.PI) / 2 * 2 ** z * 256;
925
+ }
926
+ var init_TerrainSource = () => {};
927
+
928
+ // src/core-map/geo/projection/Projection.SphericalMercator.ts
929
+ var earthRadius = 6378137, SphericalMercator;
930
+ var init_Projection_SphericalMercator = __esm(() => {
931
+ init_Bounds();
932
+ init_Point();
933
+ init_LatLng();
934
+ SphericalMercator = {
935
+ R: earthRadius,
936
+ MAX_LATITUDE: 85.0511287798,
937
+ project(latlng) {
938
+ const ll = new LatLng(latlng);
939
+ const d = Math.PI / 180;
940
+ const max = this.MAX_LATITUDE;
941
+ const lat = Math.max(Math.min(max, ll.lat), -max);
942
+ const sin = Math.sin(lat * d);
943
+ return new Point(this.R * ll.lng * d, this.R * Math.log((1 + sin) / (1 - sin)) / 2);
944
+ },
945
+ unproject(point) {
946
+ const p = new Point(point);
947
+ const d = 180 / Math.PI;
948
+ return new LatLng((2 * Math.atan(Math.exp(p.y / this.R)) - Math.PI / 2) * d, p.x * d / this.R);
949
+ },
950
+ bounds: (() => {
951
+ const d = earthRadius * Math.PI;
952
+ return new Bounds([-d, -d], [d, d]);
953
+ })()
954
+ };
955
+ });
956
+
957
+ // src/core-map/geometry/Transformation.ts
958
+ class Transformation {
959
+ _a;
960
+ _b;
961
+ _c;
962
+ _d;
963
+ constructor(a, b, c, d) {
964
+ if (Array.isArray(a)) {
965
+ this._a = a[0];
966
+ this._b = a[1];
967
+ this._c = a[2];
968
+ this._d = a[3];
969
+ return;
970
+ }
971
+ this._a = a;
972
+ this._b = b;
973
+ this._c = c;
974
+ this._d = d;
975
+ }
976
+ transform(point, scale) {
977
+ return this._transform(point.clone(), scale);
978
+ }
979
+ _transform(point, scale) {
980
+ scale ||= 1;
981
+ point.x = scale * (this._a * point.x + this._b);
982
+ point.y = scale * (this._c * point.y + this._d);
983
+ return point;
984
+ }
985
+ untransform(point, scale) {
986
+ scale ||= 1;
987
+ return new Point((point.x / scale - this._b) / this._a, (point.y / scale - this._d) / this._c);
988
+ }
989
+ }
990
+ function toTransformation(a, b, c, d) {
991
+ return new Transformation(a, b, c, d);
992
+ }
993
+ var init_Transformation = __esm(() => {
994
+ init_Point();
995
+ });
996
+
997
+ // src/core-map/geo/crs/EPSG3857.ts
998
+ var EPSG3857, EPSG900913;
999
+ var init_EPSG3857 = __esm(() => {
1000
+ init_Transformation();
1001
+ init_Projection_SphericalMercator();
1002
+ init_EarthCRS();
1003
+ EPSG3857 = class EPSG3857 extends EarthCRS {
1004
+ static code = "EPSG:3857";
1005
+ static projection = SphericalMercator;
1006
+ static transformation = (() => {
1007
+ const scale = 0.5 / (Math.PI * SphericalMercator.R);
1008
+ return new Transformation(scale, 0.5, -scale, 0.5);
1009
+ })();
1010
+ };
1011
+ EPSG900913 = class EPSG900913 extends EPSG3857 {
1012
+ static code = "EPSG:900913";
1013
+ };
1014
+ });
1015
+
1016
+ // src/core-map/geo/index.ts
1017
+ init_LatLng();
1018
+ init_LatLngBounds();
1019
+ init_terrainMesh();
1020
+ init_TerrainSource();
1021
+
1022
+ // src/core-map/geo/projection/index.ts
1023
+ var exports_projection = {};
1024
+ __export(exports_projection, {
1025
+ SphericalMercator: () => SphericalMercator,
1026
+ Mercator: () => Mercator,
1027
+ LonLat: () => LonLat,
1028
+ Globe: () => Globe
1029
+ });
1030
+
1031
+ // src/core-map/geo/projection/Projection.Globe.ts
1032
+ init_LatLng();
1033
+ init_Projection_SphericalMercator();
1034
+ var earthRadius2 = SphericalMercator.R;
1035
+ function latLngToUnitSphere(latlng) {
1036
+ const ll = new LatLng(latlng);
1037
+ const phi = ll.lat * Math.PI / 180;
1038
+ const lambda = ll.lng * Math.PI / 180;
1039
+ const cosPhi = Math.cos(phi);
1040
+ return {
1041
+ x: cosPhi * Math.sin(lambda),
1042
+ y: Math.sin(phi),
1043
+ z: cosPhi * Math.cos(lambda)
1044
+ };
1045
+ }
1046
+ function unitSphereToLatLng(v) {
1047
+ const r = Math.hypot(v.x, v.y, v.z) || 1;
1048
+ const phi = Math.asin(Math.max(-1, Math.min(1, v.y / r)));
1049
+ const lambda = Math.atan2(v.x, v.z);
1050
+ return new LatLng(phi * 180 / Math.PI, lambda * 180 / Math.PI);
1051
+ }
1052
+ function globeMix(zoom, start, end) {
1053
+ if (zoom <= start)
1054
+ return 1;
1055
+ if (zoom >= end)
1056
+ return 0;
1057
+ const t = (zoom - start) / (end - start);
1058
+ return 1 - t * t * (3 - 2 * t);
1059
+ }
1060
+ var Globe = {
1061
+ R: earthRadius2,
1062
+ GLOBE_START_ZOOM: 5.5,
1063
+ GLOBE_END_ZOOM: 6,
1064
+ project(latlng) {
1065
+ return SphericalMercator.project(latlng);
1066
+ },
1067
+ unproject(point) {
1068
+ return SphericalMercator.unproject(point);
1069
+ },
1070
+ bounds: SphericalMercator.bounds,
1071
+ toSphere: latLngToUnitSphere,
1072
+ fromSphere: unitSphereToLatLng,
1073
+ globeToMercatorMix(zoom) {
1074
+ return globeMix(zoom, this.GLOBE_START_ZOOM, this.GLOBE_END_ZOOM);
1075
+ }
1076
+ };
1077
+ // src/core-map/geo/projection/Projection.LonLat.ts
1078
+ init_Bounds();
1079
+ init_Point();
1080
+ init_LatLng();
1081
+ var LonLat = {
1082
+ project(latlng) {
1083
+ const ll = new LatLng(latlng);
1084
+ return new Point(ll.lng, ll.lat);
1085
+ },
1086
+ unproject(point) {
1087
+ const p = new Point(point);
1088
+ return new LatLng(p.y, p.x);
1089
+ },
1090
+ bounds: new Bounds([-180, -90], [180, 90])
1091
+ };
1092
+ // src/core-map/geo/projection/Projection.Mercator.ts
1093
+ init_Bounds();
1094
+ init_Point();
1095
+ init_LatLng();
1096
+ var earthRadius3 = 6378137;
1097
+ var Mercator = {
1098
+ R: earthRadius3,
1099
+ R_MINOR: 6356752.314245179,
1100
+ bounds: new Bounds([-20037508.34279, -15496570.73972], [20037508.34279, 18764656.23138]),
1101
+ project(latlng) {
1102
+ const ll = new LatLng(latlng);
1103
+ const d = Math.PI / 180;
1104
+ const r = this.R;
1105
+ const tmp = this.R_MINOR / r;
1106
+ const e = Math.sqrt(1 - tmp * tmp);
1107
+ let y = ll.lat * d;
1108
+ const con = e * Math.sin(y);
1109
+ const ts = Math.tan(Math.PI / 4 - y / 2) / ((1 - con) / (1 + con)) ** (e / 2);
1110
+ y = -r * Math.log(Math.max(ts, 0.0000000001));
1111
+ return new Point(ll.lng * d * r, y);
1112
+ },
1113
+ unproject(point) {
1114
+ const p = new Point(point);
1115
+ const d = 180 / Math.PI;
1116
+ const r = this.R;
1117
+ const tmp = this.R_MINOR / r;
1118
+ const e = Math.sqrt(1 - tmp * tmp);
1119
+ const ts = Math.exp(-p.y / r);
1120
+ let phi = Math.PI / 2 - 2 * Math.atan(ts);
1121
+ let dphi = 0.1;
1122
+ for (let i = 0;i < 15 && Math.abs(dphi) > 0.0000001; i++) {
1123
+ let con = e * Math.sin(phi);
1124
+ con = ((1 - con) / (1 + con)) ** (e / 2);
1125
+ dphi = Math.PI / 2 - 2 * Math.atan(ts * con) - phi;
1126
+ phi += dphi;
1127
+ }
1128
+ return new LatLng(phi * d, p.x * d / r);
1129
+ }
1130
+ };
1131
+
1132
+ // src/core-map/geo/projection/index.ts
1133
+ init_Projection_SphericalMercator();
1134
+
1135
+ // src/core-map/geo/crs/index.ts
1136
+ init_CRS();
1137
+ init_EarthCRS();
1138
+
1139
+ // src/core-map/geo/crs/EPSG3395.ts
1140
+ init_Transformation();
1141
+ init_EarthCRS();
1142
+
1143
+ class EPSG3395 extends EarthCRS {
1144
+ static code = "EPSG:3395";
1145
+ static projection = Mercator;
1146
+ static transformation = (() => {
1147
+ const scale = 0.5 / (Math.PI * Mercator.R);
1148
+ return new Transformation(scale, 0.5, -scale, 0.5);
1149
+ })();
1150
+ }
1151
+
1152
+ // src/core-map/geo/crs/index.ts
1153
+ init_EPSG3857();
1154
+
1155
+ // src/core-map/geo/crs/EPSG4326.ts
1156
+ init_Transformation();
1157
+ init_EarthCRS();
1158
+
1159
+ class EPSG4326 extends EarthCRS {
1160
+ static code = "EPSG:4326";
1161
+ static projection = LonLat;
1162
+ static transformation = new Transformation(1 / 180, 1, -1 / 180, 0.5);
1163
+ }
1164
+ // src/core-map/geo/crs/SimpleCRS.ts
1165
+ init_Transformation();
1166
+ init_CRS();
1167
+
1168
+ class SimpleCRS extends CRS {
1169
+ static projection = LonLat;
1170
+ static transformation = new Transformation(1, 0, -1, 0);
1171
+ static infinite = true;
1172
+ static scale(zoom) {
1173
+ return 2 ** zoom;
1174
+ }
1175
+ static zoom(scale) {
1176
+ return Math.log(scale) / Math.LN2;
1177
+ }
1178
+ static distance(latlng1, latlng2) {
1179
+ const dx = latlng2.lng - latlng1.lng;
1180
+ const dy = latlng2.lat - latlng1.lat;
1181
+ return Math.sqrt(dx * dx + dy * dy);
1182
+ }
1183
+ }
1184
+ export {
1185
+ toLatLngBounds,
1186
+ toLatLng,
1187
+ sampleElevationBilinear,
1188
+ getElevationDecoder,
1189
+ decodeTerrariumRGB,
1190
+ decodeMapboxRGB,
1191
+ decodeElevationGrid,
1192
+ buildTerrainMesh,
1193
+ TerrainSource,
1194
+ SimpleCRS,
1195
+ exports_projection as Projection,
1196
+ LatLngBounds,
1197
+ LatLng,
1198
+ EarthCRS,
1199
+ EPSG900913,
1200
+ EPSG4326,
1201
+ EPSG3857,
1202
+ EPSG3395,
1203
+ CRS
1204
+ };