@edugis-org/webmapx 0.1.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.
Files changed (84) hide show
  1. package/README.md +149 -0
  2. package/dist-lib/WMTS-DCN4zX0-.js +1169 -0
  3. package/dist-lib/alert-GeHlqlN8.js +310 -0
  4. package/dist-lib/assets/epsg-lookup.worker-J7TVnHDq.js +1 -0
  5. package/dist-lib/assets/shapefile.worker-kQfZj6G2.js +4 -0
  6. package/dist-lib/attribution-format-B4f05_u0.js +62 -0
  7. package/dist-lib/button-DFdGkRPQ.js +741 -0
  8. package/dist-lib/cesium-adapter-BHXNytkU.js +1488 -0
  9. package/dist-lib/checkbox-QoR4S8tV.js +284 -0
  10. package/dist-lib/chunk-HEgqtunE.js +20 -0
  11. package/dist-lib/chunk.36O46B5H-B6ZL7Sm1.js +77 -0
  12. package/dist-lib/chunk.3RPBFEDE-BFO1fHVm.js +138 -0
  13. package/dist-lib/chunk.5JY5FUCG-DTXsslmx.js +1090 -0
  14. package/dist-lib/chunk.6CTB5ZDJ-DjZrBd6Y.js +99 -0
  15. package/dist-lib/chunk.AJ3ENQ5C-Ci7Gm2b6.js +175 -0
  16. package/dist-lib/chunk.LD4M4QGE-CiCfhE8r.js +8 -0
  17. package/dist-lib/chunk.NYIIDP5N-BikXIStD.js +99 -0
  18. package/dist-lib/chunk.RWUUFNUL-DFztA4uV.js +43 -0
  19. package/dist-lib/chunk.SI4ACBFK-CLb9VfMG.js +61 -0
  20. package/dist-lib/chunk.YHLNUJ7P-D-kanrCf.js +503 -0
  21. package/dist-lib/core-CMAlSR68.js +22 -0
  22. package/dist-lib/decorate-CWgUV1hU.js +1139 -0
  23. package/dist-lib/decorators-B35AgiCU.js +351 -0
  24. package/dist-lib/deferred-query-service-BJDcngw6.js +386 -0
  25. package/dist-lib/dist-Dm6b7XCs.js +12318 -0
  26. package/dist-lib/dist-Ha9LQCut.js +244 -0
  27. package/dist-lib/dist-c1PlDAd1.js +2359 -0
  28. package/dist-lib/dist-kKlmcBXq.js +50 -0
  29. package/dist-lib/divider-CPm675yY.js +41 -0
  30. package/dist-lib/dropped-config-C_GyVa8o.js +17 -0
  31. package/dist-lib/dropped-layer-builder-DAaYgUPk.js +396 -0
  32. package/dist-lib/epsg-definitions-BZLZWa8Q.js +668 -0
  33. package/dist-lib/esm-CTuscnN5.js +46 -0
  34. package/dist-lib/file-sniff-Dhxj3KTF.js +251 -0
  35. package/dist-lib/geo-calculations-DbFJAUoI.js +30 -0
  36. package/dist-lib/icon-CEOgWlro.js +9 -0
  37. package/dist-lib/icon-button-Da_nBTy3.js +408 -0
  38. package/dist-lib/input-CeGntPlT.js +590 -0
  39. package/dist-lib/layer-discovery-afWzu5hY.js +2825 -0
  40. package/dist-lib/leaflet-adapter-D9djjrKv.js +1227 -0
  41. package/dist-lib/lib-CdHVicAE.js +4074 -0
  42. package/dist-lib/map-layer-registry-2cmkiRDK.js +62 -0
  43. package/dist-lib/maplibre-adapter-TFc3e0G9.js +1190 -0
  44. package/dist-lib/maplibre-expression-evaluator-DCWUcpwf.js +7233 -0
  45. package/dist-lib/marker-utils-DztWXeop.js +12 -0
  46. package/dist-lib/ol-tilegrid-9VtyxaLG.js +64 -0
  47. package/dist-lib/openlayers-adapter-DVW1KCRv.js +13307 -0
  48. package/dist-lib/option-CBxl1mZP.js +1106 -0
  49. package/dist-lib/papaparse.min-B7v3c0D7.js +501 -0
  50. package/dist-lib/rbush-C8k41T4z.js +254 -0
  51. package/dist-lib/shapefile-SawVY6xg.js +207 -0
  52. package/dist-lib/spinner-DysxdNG9.js +6 -0
  53. package/dist-lib/src-CL94RDe3.js +111 -0
  54. package/dist-lib/throttle-BeneRNYK.js +16 -0
  55. package/dist-lib/toast-Cm28o9U6.js +15 -0
  56. package/dist-lib/togeojson.es-DAgiTBvg.js +579 -0
  57. package/dist-lib/tooltip-Cucn1SiD.js +197 -0
  58. package/dist-lib/webmapx-3d-tool-D4CTD2gB.js +176 -0
  59. package/dist-lib/webmapx-base-tool-Dm9NAWLD.js +75 -0
  60. package/dist-lib/webmapx-config-edit-tool-DCTyxqTk.js +389 -0
  61. package/dist-lib/webmapx-coordinates-tool-jeWohup9.js +648 -0
  62. package/dist-lib/webmapx-core-bundle-BDImi1RE.js +8203 -0
  63. package/dist-lib/webmapx-draw-tool-DooAV8cF.js +4336 -0
  64. package/dist-lib/webmapx-geolocation-tool-Rw3-Iad1.js +788 -0
  65. package/dist-lib/webmapx-import-layer-tool-DRYviHd5.js +250 -0
  66. package/dist-lib/webmapx-info-tool-BJA157cy.js +412 -0
  67. package/dist-lib/webmapx-language-osmvector-M5y_lwOg.js +489 -0
  68. package/dist-lib/webmapx-measure-tool-BXhMJFC6.js +590 -0
  69. package/dist-lib/webmapx-modal-tool-eF6Naluv.js +84 -0
  70. package/dist-lib/webmapx-plugin-tool-D2Hghf9n.js +45 -0
  71. package/dist-lib/webmapx-print-tool-ob1bOsR5.js +348 -0
  72. package/dist-lib/webmapx-search-tool-Cv8BrYvY.js +437 -0
  73. package/dist-lib/webmapx-settings-DDEJ8aoV.js +479 -0
  74. package/dist-lib/webmapx-truearea-tool-CMB4Orm-.js +615 -0
  75. package/dist-lib/webmapx-view-mode-tool-CUpLNjOj.js +106 -0
  76. package/dist-lib/webmapx.css +2 -0
  77. package/dist-lib/webmapx.js +1321 -0
  78. package/dist-lib/wms-feature-info-C0RVMEQC.js +145 -0
  79. package/dist-lib/wms-url-builder-DIJLQ1v2.js +54 -0
  80. package/dist-lib/zip.js-DVhmtjxZ.js +3615 -0
  81. package/package.json +107 -0
  82. package/public/data/country-epsg-codes.json +297 -0
  83. package/public/data/world-countries-simplified.topojson +1 -0
  84. package/src/locales/en/core.json +20 -0
@@ -0,0 +1,1488 @@
1
+ import { t as e } from "./throttle-BeneRNYK.js";
2
+ import { t } from "./wms-feature-info-C0RVMEQC.js";
3
+ import { a as n, i as r, n as i, o as a, r as o, t as s } from "./deferred-query-service-BJDcngw6.js";
4
+ import { i as c, n as l, t as u } from "./maplibre-expression-evaluator-DCWUcpwf.js";
5
+ import { t as d } from "./marker-utils-DztWXeop.js";
6
+ //#region src/map/cesium-services/MapCoreService.ts
7
+ function f() {
8
+ return globalThis.Cesium;
9
+ }
10
+ function p(e) {
11
+ return Math.max(10, 2e7 / 2 ** Math.max(0, e));
12
+ }
13
+ function m(e) {
14
+ return !isFinite(e) || e <= 0 ? 0 : Math.log2(2e7 / e);
15
+ }
16
+ var h = 6378137, g = 512;
17
+ function _(e) {
18
+ return Math.max(-85.05112878, Math.min(85.05112878, e));
19
+ }
20
+ function v(e, t) {
21
+ let n = _(t) * Math.PI / 180;
22
+ return 2 * Math.PI * h * Math.cos(n) / (g * 2 ** e);
23
+ }
24
+ function y(e) {
25
+ return typeof e == "number" && isFinite(e) && e > 0 ? Math.max(.05, Math.min(4, e * .005)) : .05;
26
+ }
27
+ function b(e) {
28
+ return typeof e == "number" && isFinite(e) ? Math.max(.05, Math.min(16, 2 ** (10 - e))) : 1;
29
+ }
30
+ function x(e, t, n, r = 48) {
31
+ let i = t * Math.PI / 180, a = n / h * (180 / Math.PI), o = a / Math.max(1e-6, Math.cos(i)), s = [];
32
+ for (let n = 0; n <= r; n += 1) {
33
+ let i = n / r * Math.PI * 2, c = e + o * Math.cos(i), l = t + a * Math.sin(i);
34
+ s.push([c, l]);
35
+ }
36
+ return s;
37
+ }
38
+ var S = class {
39
+ constructor(t, n) {
40
+ this.store = t, this.eventBus = n, this.viewer = null, this.readyCbs = [], this.sources = /* @__PURE__ */ new Map(), this.sourceState = /* @__PURE__ */ new Map(), this.minPitch = 0, this.maxPitch = 85, this.isClamping = !1, this.lastCenter = [0, 0], this.lastStyledZoom = null, this.dispatchViewportStateThrottled = e(() => this.dispatchViewportState(), 100), this.runtimeLayerOrder = [], this.layerOrderRegistry = null, this.layerZStepMeters = .5, this.basePolylinePositions = /* @__PURE__ */ new WeakMap(), this.terrainEnabled = !1, this.arcgisTerrainProvider = null, this.boundKeydown = null;
41
+ }
42
+ initialize(e, t) {
43
+ let n = f();
44
+ if (!n) throw Error("[Cesium] window.Cesium not found. Load CesiumJS before using the cesium adapter.");
45
+ let r = t?.center ?? [0, 0], i = t?.zoom ?? 1, a = this.resolveContainer(e);
46
+ this.minZoom = t?.minZoom, this.maxZoom = t?.maxZoom, this.minPitch = typeof t?.minPitch == "number" ? Math.max(0, Math.min(85, t.minPitch)) : 0, this.maxPitch = typeof t?.maxPitch == "number" ? Math.max(0, Math.min(85, t.maxPitch)) : 85, this.minPitch > this.maxPitch && (this.minPitch = this.maxPitch);
47
+ let o = document.createElement("div");
48
+ o.style.display = "none", this.viewer = new n.Viewer(a, {
49
+ animation: !1,
50
+ baseLayerPicker: !1,
51
+ fullscreenButton: !1,
52
+ geocoder: !1,
53
+ homeButton: !1,
54
+ infoBox: !1,
55
+ navigationHelpButton: !1,
56
+ sceneModePicker: !1,
57
+ selectionIndicator: !1,
58
+ timeline: !1,
59
+ vrButton: !1,
60
+ scene3DOnly: !0,
61
+ baseLayer: !1,
62
+ terrainProvider: new n.EllipsoidTerrainProvider(),
63
+ creditContainer: o
64
+ }), navigator.maxTouchPoints > 0 && (this.viewer.scene.highDynamicRange = !1, this.viewer.scene.skyAtmosphere.show = !1, this.viewer.scene.globe.showGroundAtmosphere = !1);
65
+ let s = this.clampZoom(i);
66
+ this.setCameraView(r, s, !1), this.applyZoomDistanceLimits(r[1]), this.attachEvents(), this.store.dispatch({
67
+ mapLoaded: !0,
68
+ mapBusy: !1,
69
+ mapCenter: r,
70
+ zoomLevel: i
71
+ }, "MAP"), this.flushReady();
72
+ }
73
+ setTerrainEnabled(e, t) {
74
+ let n = f();
75
+ if (!n || !this.viewer) return !1;
76
+ if (this.terrainEnabled = e, !e) return this.viewer.terrainProvider = new n.EllipsoidTerrainProvider(), !0;
77
+ if (this.arcgisTerrainProvider) return this.viewer.terrainProvider = this.arcgisTerrainProvider, !0;
78
+ let r = t ?? "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer";
79
+ return Promise.resolve(n.ArcGISTiledElevationTerrainProvider.fromUrl(r)).then((e) => {
80
+ this.arcgisTerrainProvider = e, this.terrainEnabled && this.viewer && (this.viewer.terrainProvider = e);
81
+ }).catch((e) => console.error("[Cesium] failed to load terrain provider", e)), !0;
82
+ }
83
+ isTerrainEnabled() {
84
+ return this.viewer ? this.terrainEnabled : null;
85
+ }
86
+ getViewportState() {
87
+ if (!this.viewer) return {
88
+ center: this.lastCenter,
89
+ zoom: 1,
90
+ bearing: 0,
91
+ pitch: 0
92
+ };
93
+ let e = f();
94
+ if (!e) return {
95
+ center: this.lastCenter,
96
+ zoom: 1,
97
+ bearing: 0,
98
+ pitch: 0
99
+ };
100
+ let t = this.viewer.camera, n = this.computeViewportCenter() ?? this.lastCenter;
101
+ this.lastCenter = n;
102
+ let r = t.positionCartographic?.height ?? e.Ellipsoid.WGS84.cartesianToCartographic(t.positionWC).height;
103
+ return {
104
+ center: n,
105
+ zoom: this.cameraHeightMetersToZoom(r, n[1]),
106
+ bearing: t.heading * 180 / Math.PI,
107
+ pitch: e.Math.toDegrees(t.pitch + Math.PI / 2)
108
+ };
109
+ }
110
+ setViewport(e, t) {
111
+ if (!this.viewer || !f()) return;
112
+ let n = this.clampZoom(t);
113
+ this.lastCenter = e, this.setCameraView(e, n, !0), this.applyZoomDistanceLimits(e[1]);
114
+ }
115
+ setZoom(e) {
116
+ let t = this.getViewportState(), n = this.clampZoom(e);
117
+ if (t.zoom === n && n !== e) {
118
+ this.dispatchViewportState();
119
+ return;
120
+ }
121
+ this.setViewport(t.center, e);
122
+ }
123
+ getZoom() {
124
+ return this.getViewportState().zoom;
125
+ }
126
+ getNavigationCapabilities() {
127
+ return {
128
+ bearing: !0,
129
+ pitch: !0
130
+ };
131
+ }
132
+ getBearing() {
133
+ return this.getViewportState().bearing;
134
+ }
135
+ setBearing(e) {
136
+ if (!this.viewer || !f()) return;
137
+ let t = this.computeViewportCenter();
138
+ if (!t) return;
139
+ let n = this.getPitch();
140
+ this.applyHeadingPitch(t, e, n);
141
+ }
142
+ getPitch() {
143
+ let e = f();
144
+ return !e || !this.viewer ? 0 : e.Math.toDegrees(this.viewer.camera.pitch + Math.PI / 2);
145
+ }
146
+ setPitch(e) {
147
+ if (!this.viewer || !f()) return;
148
+ let t = this.computeViewportCenter();
149
+ if (!t) return;
150
+ let n = this.getBearing(), r = Math.max(this.minPitch, Math.min(this.maxPitch, e));
151
+ this.applyHeadingPitch(t, n, r);
152
+ }
153
+ resetNorth() {
154
+ this.setBearing(0);
155
+ }
156
+ resetNorthPitch() {
157
+ this.viewer && (this.setBearing(0), this.setPitch(0));
158
+ }
159
+ setProjection(e) {
160
+ return !1;
161
+ }
162
+ getProjection() {
163
+ return null;
164
+ }
165
+ applyHeadingPitch(e, t, n) {
166
+ if (!this.viewer) return;
167
+ let r = f();
168
+ if (!r) return;
169
+ let i = this.viewer.camera, a = r.Cartesian3.fromDegrees(e[0], e[1]), o = Math.max(1, r.Cartesian3.distance(i.positionWC, a)), s = r.Math.toRadians(t), c = r.Math.toRadians(-90 + n);
170
+ i.lookAt(a, new r.HeadingPitchRange(s, c, o)), i.lookAtTransform(r.Matrix4.IDENTITY);
171
+ }
172
+ addLayer(e, t) {
173
+ let n = e, r = n?.source;
174
+ if (!r) return !1;
175
+ let i = this.sourceState.get(r);
176
+ if (!i) return !1;
177
+ let a = typeof n?.id == "string" ? n.id : null;
178
+ a && (this.insertRuntimeLayer(a, t), this.layerOrderRegistry?.registerInlineLayer(a, t), i.layers = i.layers.filter((e) => e?.spec?.id !== a));
179
+ let o = {
180
+ spec: n,
181
+ dataSource: null
182
+ };
183
+ return this.insertLayerByOptions(i.layers, o, t) || i.layers.push(o), this.refreshSourceLayerData(r), !0;
184
+ }
185
+ removeLayer(e) {
186
+ let t = e;
187
+ typeof t == "string" && (this.removeRuntimeLayer(t), this.layerOrderRegistry?.unregisterInlineLayer(t));
188
+ for (let [e, n] of this.sourceState.entries()) {
189
+ let e = n.layers.length, r = n.layers.filter((e) => e.spec?.id === t);
190
+ if (n.layers = n.layers.filter((e) => e.spec?.id !== t), n.layers.length !== e) {
191
+ for (let e of r) this.removeLayerDataSource(e);
192
+ return;
193
+ }
194
+ }
195
+ }
196
+ addSource(e, t) {
197
+ if (!this.viewer || !f() || this.sources.has(e) || t?.type !== "geojson" || !t.data) return;
198
+ this.sourceState.set(e, {
199
+ data: t.data,
200
+ layers: [],
201
+ updateToken: 0
202
+ });
203
+ let n = (t) => {
204
+ let n = this.sourceState.get(e);
205
+ n && (n.data = t, this.refreshSourceLayerData(e));
206
+ }, r = {
207
+ id: e,
208
+ setData: n
209
+ };
210
+ this.sources.set(e, r), n(t.data);
211
+ }
212
+ removeSource(e) {
213
+ let t = this.sourceState.get(e);
214
+ if (t?.layers?.length) for (let e of t.layers) {
215
+ let t = typeof e.spec?.id == "string" ? e.spec.id : null;
216
+ t && this.removeRuntimeLayer(t), this.removeLayerDataSource(e);
217
+ }
218
+ this.sourceState.delete(e), this.sources.delete(e);
219
+ }
220
+ getSource(e) {
221
+ return this.sources.get(e);
222
+ }
223
+ suppressBusySignalForSource(e) {}
224
+ unsuppressBusySignalForSource(e) {}
225
+ project(e) {
226
+ let t = f();
227
+ if (!t || !this.viewer) return [0, 0];
228
+ let n = t.Cartesian3.fromDegrees(e[0], e[1]), r = t.SceneTransforms.worldToWindowCoordinates(this.viewer.scene, n);
229
+ return r ? [r.x, r.y] : [0, 0];
230
+ }
231
+ unproject(e) {
232
+ let t = f();
233
+ if (!t || !this.viewer) return null;
234
+ this.viewer.scene.canvas;
235
+ let n = new t.Cartesian2(e[0], e[1]), r = this.viewer.camera.pickEllipsoid(n, t.Ellipsoid.WGS84);
236
+ if (!r) return null;
237
+ let i = t.Ellipsoid.WGS84.cartesianToCartographic(r);
238
+ return [i.longitude * 180 / Math.PI, i.latitude * 180 / Math.PI];
239
+ }
240
+ fitBounds(e) {
241
+ let t = f();
242
+ if (!(!t || !this.viewer)) try {
243
+ let n = e[0], r = e[1], i = e[2], a = e[3], o = t.Rectangle.fromDegrees(n, r, i, a);
244
+ this.viewer.camera.flyTo({
245
+ destination: o,
246
+ duration: .7
247
+ });
248
+ } catch {
249
+ let n = (e[0] + e[2]) / 2, r = (e[1] + e[3]) / 2, i = this.zoomToCameraHeightMeters(this.getViewportState().zoom, r);
250
+ this.viewer.camera.flyTo({
251
+ destination: t.Cartesian3.fromDegrees(n, r, i),
252
+ duration: .7
253
+ });
254
+ }
255
+ }
256
+ setCursor(e) {
257
+ if (!this.viewer) return;
258
+ let t = this.viewer.canvas;
259
+ t.style.cursor = e;
260
+ }
261
+ setPanEnabled(e) {
262
+ if (!this.viewer) return;
263
+ let t = this.viewer.scene.screenSpaceCameraController;
264
+ t.enableTranslate = e, t.enableRotate = e, t.enableTilt = e, t.enableZoom = e;
265
+ }
266
+ setTouchCaptureEnabled(e) {}
267
+ setDoubleClickZoomEnabled(e) {}
268
+ setLayerVisibility(e, t) {
269
+ for (let n of this.sourceState.values()) for (let r of n.layers) r.spec?.id === e && r.dataSource && (r.dataSource.show = t);
270
+ }
271
+ getSourceData(e) {
272
+ return this.sourceState.get(e)?.data ?? null;
273
+ }
274
+ onMapReady(e) {
275
+ if (this.viewer) {
276
+ e(this.viewer);
277
+ return;
278
+ }
279
+ this.readyCbs.push(e);
280
+ }
281
+ flushReady() {
282
+ this.viewer && this.readyCbs.splice(0).forEach((e) => e(this.viewer));
283
+ }
284
+ attachEvents() {
285
+ if (!this.viewer || !this.eventBus) return;
286
+ let e = f();
287
+ if (!e) return;
288
+ let t = new e.ScreenSpaceEventHandler(this.viewer.scene.canvas), n = (t) => {
289
+ let n = this.viewer.camera.pickEllipsoid(t, e.Ellipsoid.WGS84);
290
+ if (!n) return null;
291
+ let r = e.Ellipsoid.WGS84.cartesianToCartographic(n);
292
+ return [r.longitude * 180 / Math.PI, r.latitude * 180 / Math.PI];
293
+ };
294
+ t.setInputAction((e) => {
295
+ let t = n(e.endPosition);
296
+ if (!t) return;
297
+ let r = [e.endPosition.x, e.endPosition.y];
298
+ this.eventBus?.emit({
299
+ type: "pointer-move",
300
+ coords: t,
301
+ pixel: r,
302
+ resolution: null,
303
+ originalEvent: e
304
+ }), this.store.dispatch({
305
+ pointerCoordinates: t,
306
+ pointerResolution: null
307
+ }, "MAP");
308
+ }, e.ScreenSpaceEventType.MOUSE_MOVE), t.setInputAction((e) => {
309
+ let t = n(e.position);
310
+ if (!t) return;
311
+ let r = [e.position.x, e.position.y];
312
+ this.eventBus?.emit({
313
+ type: "click",
314
+ coords: t,
315
+ pixel: r,
316
+ resolution: null,
317
+ originalEvent: e
318
+ }), this.store.dispatch({
319
+ lastClickedCoordinates: t,
320
+ pointerCoordinates: t,
321
+ lastClickedResolution: null,
322
+ pointerResolution: null
323
+ }, "MAP");
324
+ }, e.ScreenSpaceEventType.LEFT_CLICK), t.setInputAction((e) => {
325
+ let t = n(e.position);
326
+ if (!t) return;
327
+ let r = [e.position.x, e.position.y];
328
+ this.eventBus?.emit({
329
+ type: "pointer-down",
330
+ coords: t,
331
+ pixel: r,
332
+ button: 0,
333
+ originalEvent: e
334
+ });
335
+ }, e.ScreenSpaceEventType.LEFT_DOWN), t.setInputAction((e) => {
336
+ let t = n(e.position);
337
+ if (!t) return;
338
+ let r = [e.position.x, e.position.y];
339
+ this.eventBus?.emit({
340
+ type: "pointer-up",
341
+ coords: t,
342
+ pixel: r,
343
+ button: 0,
344
+ originalEvent: e
345
+ });
346
+ }, e.ScreenSpaceEventType.LEFT_UP), this.viewer.scene.canvas.addEventListener("contextmenu", (e) => {
347
+ e.preventDefault();
348
+ let t = this.viewer.scene.canvas.getBoundingClientRect(), r = {
349
+ x: e.clientX - t.left,
350
+ y: e.clientY - t.top
351
+ }, i = n(r);
352
+ if (!i) return;
353
+ let a = [r.x, r.y];
354
+ this.eventBus?.emit({
355
+ type: "contextmenu",
356
+ coords: i,
357
+ pixel: a,
358
+ originalEvent: e
359
+ });
360
+ }), this.viewer.camera.moveEnd.addEventListener(() => {
361
+ this.dispatchViewportState();
362
+ }), this.viewer.camera.changed.addEventListener(() => {
363
+ this.dispatchViewportStateThrottled();
364
+ });
365
+ let r = this.viewer.scene.canvas;
366
+ r && (r.tabIndex = -1), this.boundKeydown = (e) => {
367
+ let t = document.activeElement, n = t?.tagName?.toLowerCase() ?? "";
368
+ if (!(n === "input" || n === "textarea" || n === "select") && !(t && t !== document.body && t !== document.documentElement && t !== this.viewer?.scene?.canvas)) {
369
+ if (e.key === "+" || e.key === "=") {
370
+ e.preventDefault(), this.setZoom(this.getZoom() + 1);
371
+ return;
372
+ }
373
+ if (e.key === "-") {
374
+ e.preventDefault(), this.setZoom(this.getZoom() - 1);
375
+ return;
376
+ }
377
+ if (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "ArrowUp" || e.key === "ArrowDown") {
378
+ if (!this.viewer) return;
379
+ e.preventDefault(), f();
380
+ let t = this.viewer.scene.canvas, n = v(this.getZoom(), (this.computeViewportCenter() ?? this.lastCenter)[1]) * t.clientWidth * .15, r = this.viewer.camera;
381
+ e.key === "ArrowLeft" && r.moveLeft(n), e.key === "ArrowRight" && r.moveRight(n), e.key === "ArrowUp" && r.moveUp(n), e.key === "ArrowDown" && r.moveDown(n), this.dispatchViewportState();
382
+ }
383
+ }
384
+ }, document.addEventListener("keydown", this.boundKeydown);
385
+ }
386
+ resolveContainer(e) {
387
+ let t = document.getElementById(e);
388
+ if (!t) throw Error(`[Cesium] Container #${e} not found.`);
389
+ if (t.tagName.toLowerCase() === "webmapx-map") {
390
+ let e = t.querySelector("[slot=\"map-view\"]");
391
+ if (e) return e;
392
+ }
393
+ return t;
394
+ }
395
+ computeViewportCenter() {
396
+ let e = f();
397
+ if (!e || !this.viewer) return null;
398
+ let t = this.viewer.scene.canvas, n = new e.Cartesian2(t.clientWidth / 2, t.clientHeight / 2), r = this.viewer.camera.pickEllipsoid(n, e.Ellipsoid.WGS84);
399
+ if (!r) return null;
400
+ let i = e.Ellipsoid.WGS84.cartesianToCartographic(r);
401
+ return [i.longitude * 180 / Math.PI, i.latitude * 180 / Math.PI];
402
+ }
403
+ computeViewportBounds() {
404
+ let e = f();
405
+ if (!e || !this.viewer) return null;
406
+ let t = this.viewer.scene.canvas, n = [
407
+ new e.Cartesian2(0, t.clientHeight),
408
+ new e.Cartesian2(t.clientWidth, t.clientHeight),
409
+ new e.Cartesian2(t.clientWidth, 0),
410
+ new e.Cartesian2(0, 0)
411
+ ], r = [];
412
+ for (let t of n) {
413
+ let n = this.viewer.camera.pickEllipsoid(t, e.Ellipsoid.WGS84);
414
+ if (!n) continue;
415
+ let i = e.Ellipsoid.WGS84.cartesianToCartographic(n);
416
+ r.push([i.longitude * 180 / Math.PI, i.latitude * 180 / Math.PI]);
417
+ }
418
+ return r.length === 0 ? null : (r.length > 0 && (r[0][0] !== r[r.length - 1][0] || r[0][1] !== r[r.length - 1][1]) && r.push(r[0]), {
419
+ type: "Feature",
420
+ properties: {},
421
+ geometry: {
422
+ type: "Polygon",
423
+ coordinates: [r]
424
+ }
425
+ });
426
+ }
427
+ zoomToCameraHeightMeters(e, t) {
428
+ if (!f() || !this.viewer) return p(e);
429
+ let n = v(e, t), r = this.viewer.scene.canvas, i = Math.max(1, r.clientHeight || r.height || 1), a = this.viewer.camera.frustum, o = a && "fovy" in a ? a.fovy : Math.PI / 3;
430
+ return Math.max(10, n * i / (2 * Math.tan(o / 2)));
431
+ }
432
+ cameraHeightMetersToZoom(e, t) {
433
+ if (!f() || !this.viewer) return m(e);
434
+ let n = this.viewer.scene.canvas, r = Math.max(1, n.clientHeight || n.height || 1), i = this.viewer.camera.frustum, a = i && "fovy" in i ? i.fovy : Math.PI / 3, o = e * 2 * Math.tan(a / 2) / r, s = _(t) * Math.PI / 180, c = 2 * Math.PI * h, l = g * o;
435
+ return !isFinite(l) || l <= 0 ? 0 : Math.log2(c * Math.cos(s) / l);
436
+ }
437
+ clampZoom(e) {
438
+ let t = e;
439
+ return this.minZoom !== void 0 && (t = Math.max(t, this.minZoom)), this.maxZoom !== void 0 && (t = Math.min(t, this.maxZoom)), t;
440
+ }
441
+ applyZoomDistanceLimits(e) {
442
+ if (!this.viewer) return;
443
+ let t = this.viewer.scene?.screenSpaceCameraController;
444
+ t && (this.maxZoom !== void 0 && (t.minimumZoomDistance = this.zoomToCameraHeightMeters(this.maxZoom, e)), this.minZoom !== void 0 && (t.maximumZoomDistance = this.zoomToCameraHeightMeters(this.minZoom, e)));
445
+ }
446
+ setCameraView(e, t, n) {
447
+ if (!this.viewer) return;
448
+ let r = f();
449
+ if (!r) return;
450
+ let i = this.viewer.camera, a = i.heading, o = i.pitch, s = r.Cartesian3.fromDegrees(e[0], e[1]), c = this.zoomToCameraHeightMeters(t, e[1]), l = Math.max(1, c / Math.max(.01, Math.abs(Math.sin(o)))), u = () => {
451
+ i.lookAt(s, new r.HeadingPitchRange(a, o, l)), i.lookAtTransform(r.Matrix4.IDENTITY);
452
+ };
453
+ n ? i.flyTo({
454
+ destination: s,
455
+ orientation: {
456
+ heading: a,
457
+ pitch: o,
458
+ roll: i.roll
459
+ },
460
+ duration: .1,
461
+ complete: u
462
+ }) : u();
463
+ }
464
+ dispatchViewportState() {
465
+ this.isClamping &&= !1;
466
+ let e = this.getViewportState(), t = this.clampZoom(e.zoom);
467
+ if (t !== e.zoom) {
468
+ this.isClamping = !0, this.setCameraView(e.center, t, !1), this.applyZoomDistanceLimits(e.center[1]);
469
+ return;
470
+ }
471
+ this.applyZoomDistanceLimits(e.center[1]), this.lastCenter = e.center;
472
+ let n = this.computeViewportBounds();
473
+ this.store.dispatch({
474
+ zoomLevel: e.zoom,
475
+ mapCenter: e.center,
476
+ mapViewportBounds: n
477
+ }, "MAP"), (this.lastStyledZoom === null || Math.abs(this.lastStyledZoom - e.zoom) > 1e-4) && (this.lastStyledZoom = e.zoom, this.applyAllSourceStyles());
478
+ let r = n ? n.geometry.coordinates[0][0] : e.center, i = n ? n.geometry.coordinates[0][2] : e.center;
479
+ this.eventBus?.emit({
480
+ type: "view-change-end",
481
+ center: e.center,
482
+ zoom: e.zoom,
483
+ bearing: e.bearing,
484
+ pitch: e.pitch,
485
+ bounds: {
486
+ sw: r,
487
+ ne: i
488
+ }
489
+ }), this.eventBus?.emit({
490
+ type: "zoom-end",
491
+ zoom: e.zoom
492
+ });
493
+ }
494
+ applyAllSourceStyles() {
495
+ for (let e of this.sourceState.keys()) this.applySourceStyles(e);
496
+ }
497
+ applySourceStyles(e) {
498
+ if (!f() || !this.viewer) return;
499
+ let t = this.sourceState.get(e);
500
+ if (t) for (let e of t.layers) this.applyLayerStyle(e);
501
+ }
502
+ applyLayerStyle(e) {
503
+ let t = f();
504
+ if (!t || !this.viewer || !e.dataSource) return;
505
+ let n = e.spec, r = n?.paint ?? {}, i = this.store.getState().zoomLevel ?? 2, a = this.isLayerVisibleAtZoom(n, i), o = b(i), s = this.getLayerZOffset(n, o), c = e.dataSource.entities?.values ?? [];
506
+ for (let e of c) {
507
+ let c = this.getEntityGeometryType(e), d = a && this.entityMatchesLayer(e, n, c);
508
+ if (e.polygon && (e.polygon.show = d && n?.type === "fill"), e.polyline && n?.type !== "line" && (e.polyline.show = !1), e.billboard && (e.billboard.show = !1), e.point && (e.point.show = !1), e.ellipse && (e.ellipse.show = d && n?.type === "circle"), d) {
509
+ if (n?.type === "fill" && e.polygon) {
510
+ let n = {
511
+ properties: this.getEntityProperties(e),
512
+ geometry: { type: "Polygon" }
513
+ }, a = u(r["fill-color"] ?? "#3388ff", n, i, "#3388ff"), o = l(r["fill-opacity"] ?? .2, n, i, .2);
514
+ e.polygon.material = t.Color.fromCssColorString(a).withAlpha(o), e.polygon.outline = !1, e.polygon.height = s;
515
+ }
516
+ if (n?.type === "line") {
517
+ if (!e.polyline && e.polygon) {
518
+ let n = e.polygon.hierarchy?.getValue?.(t.JulianDate.now()) ?? e.polygon.hierarchy, r = n?.positions ?? n;
519
+ Array.isArray(r) && r.length > 0 && (e.polyline = new t.PolylineGraphics(), e.polyline.positions = [...r, r[0]]);
520
+ }
521
+ if (e.polyline) {
522
+ e.polyline.show = !0;
523
+ let n = {
524
+ properties: this.getEntityProperties(e),
525
+ geometry: { type: "LineString" }
526
+ }, a = u(r["line-color"] ?? "#3388ff", n, i, "#3388ff"), o = l(r["line-width"] ?? 2, n, i, 2);
527
+ e.polyline.material = t.Color.fromCssColorString(a).withAlpha(1), e.polyline.width = o;
528
+ let c = r["line-dasharray"];
529
+ Array.isArray(c) && c.length >= 2 && t.PolylineDashMaterialProperty && (e.polyline.material = new t.PolylineDashMaterialProperty({
530
+ color: t.Color.fromCssColorString(a).withAlpha(1),
531
+ dashLength: c[0] + c[1]
532
+ })), this.applyPolylineHeightOffset(e, s);
533
+ }
534
+ }
535
+ if (n?.type === "circle" && (e.position || e.point || e.billboard || e.ellipse)) {
536
+ n?.metadata;
537
+ let a = r["circle-color"] ?? "#3388ff", c = r["circle-opacity"] ?? 1, l = r["circle-radius"] ?? 6, u = r["circle-stroke-color"] ?? "#3388ff", d = r["circle-stroke-width"] ?? 1, f = t.JulianDate.now(), p = e.position?.getValue?.(f) ?? e.position;
538
+ if (!p) continue;
539
+ let m = t.Ellipsoid.WGS84.cartesianToCartographic(p), h = m.latitude * 180 / Math.PI, g = v(i, h), _ = Math.max(1, Number(l) * g), b = s + y(_) * o;
540
+ e.ellipse ||= new t.EllipseGraphics(), e.ellipse.show = !0, e.ellipse.semiMajorAxis = _, e.ellipse.semiMinorAxis = _, e.ellipse.material = t.Color.fromCssColorString(String(a)).withAlpha(Number(c)), e.ellipse.outline = !0, e.ellipse.outlineColor = t.Color.fromCssColorString(String(u)).withAlpha(1), e.ellipse.outlineWidth = Number(d);
541
+ let S = x(t.Math.toDegrees(m.longitude), h, _, 64), C = b + Math.max(1, _ * .01), w = S.map(([e, n]) => t.Cartesian3.fromDegrees(e, n, C));
542
+ e.polyline ||= new t.PolylineGraphics(), e.polyline.show = !0, e.polyline.positions = w, e.polyline.width = Math.max(1, Number(d)), e.polyline.material = t.Color.fromCssColorString(String(u)).withAlpha(1), "clampToGround" in e.polyline && (e.polyline.clampToGround = !1), t.HeightReference?.CLAMP_TO_GROUND && (e.ellipse.heightReference = t.HeightReference.NONE), e.ellipse.height = b, e.billboard = void 0, e.point = void 0;
543
+ }
544
+ }
545
+ }
546
+ }
547
+ isLayerVisibleAtZoom(e, t) {
548
+ let n = this.toNumericZoom(e?.minzoom ?? e?.minZoom), r = this.toNumericZoom(e?.maxzoom ?? e?.maxZoom);
549
+ return !(n !== void 0 && t < n || r !== void 0 && t >= r);
550
+ }
551
+ toNumericZoom(e) {
552
+ return typeof e == "number" && isFinite(e) ? e : void 0;
553
+ }
554
+ getLayerZOffset(e, t = 1) {
555
+ let n = typeof e?.id == "string" ? e.id : null;
556
+ if (!n) return 0;
557
+ let r = this.runtimeLayerOrder.indexOf(n);
558
+ return r < 0 ? 0 : (r + 1) * this.layerZStepMeters * t;
559
+ }
560
+ removeRuntimeLayer(e) {
561
+ this.runtimeLayerOrder = this.runtimeLayerOrder.filter((t) => t !== e);
562
+ }
563
+ insertRuntimeLayer(e, t) {
564
+ this.removeRuntimeLayer(e), this.insertByOptions(this.runtimeLayerOrder, e, t) || this.runtimeLayerOrder.push(e);
565
+ }
566
+ insertLayerByOptions(e, t, n) {
567
+ if (!(typeof t.spec?.id == "string" && t.spec.id)) return !1;
568
+ let r = n?.beforeLayerId;
569
+ if (typeof r == "string") {
570
+ let n = e.findIndex((e) => e.spec?.id === r);
571
+ if (n >= 0) return e.splice(n, 0, t), !0;
572
+ }
573
+ let i = n?.afterLayerId;
574
+ if (typeof i == "string") {
575
+ let n = e.findIndex((e) => e.spec?.id === i);
576
+ if (n >= 0) return e.splice(n + 1, 0, t), !0;
577
+ }
578
+ return !1;
579
+ }
580
+ insertByOptions(e, t, n) {
581
+ let r = n?.beforeLayerId;
582
+ if (typeof r == "string") {
583
+ let n = e.indexOf(r);
584
+ if (n >= 0) return e.splice(n, 0, t), !0;
585
+ }
586
+ let i = n?.afterLayerId;
587
+ if (typeof i == "string") {
588
+ let n = e.indexOf(i);
589
+ if (n >= 0) return e.splice(n + 1, 0, t), !0;
590
+ }
591
+ return !1;
592
+ }
593
+ applyPolylineHeightOffset(e, t) {
594
+ let n = f();
595
+ if (!n || !e?.polyline) return;
596
+ let r = n.JulianDate.now(), i = e.polyline, a = i.positions?.getValue?.(r) ?? i.positions;
597
+ if (!Array.isArray(a) || a.length === 0) return;
598
+ let o = this.basePolylinePositions.get(e);
599
+ if (o || (o = [...a], this.basePolylinePositions.set(e, o)), !(typeof t == "number" && isFinite(t) && t > 0)) {
600
+ i.positions = o;
601
+ return;
602
+ }
603
+ i.positions = o.map((e) => {
604
+ let r = n.Ellipsoid.WGS84.cartesianToCartographic(e), i = (r.height ?? 0) + t;
605
+ return n.Cartesian3.fromRadians(r.longitude, r.latitude, i);
606
+ });
607
+ }
608
+ refreshSourceLayerData(e) {
609
+ if (!f() || !this.viewer) return;
610
+ let t = this.sourceState.get(e);
611
+ if (!t || !t.data) return;
612
+ let n = ++t.updateToken;
613
+ for (let r of t.layers) this.loadLayerDataSource(e, r, n);
614
+ }
615
+ async loadLayerDataSource(e, t, n) {
616
+ let r = f();
617
+ if (!r || !this.viewer) return;
618
+ let i = this.sourceState.get(e);
619
+ if (!i?.data) return;
620
+ let a = await r.GeoJsonDataSource.load(i.data, { clampToGround: !1 }), o = this.sourceState.get(e), s = o?.layers.includes(t) ?? !1;
621
+ if (!o || o.updateToken !== n || !s) return;
622
+ let c = t.dataSource;
623
+ this.removeLayerDataSource({ dataSource: c }), t.dataSource = a, this.viewer.dataSources.add(a), this.applyLayerStyle(t), setTimeout(() => this.reapplyDataSourceOrder(), 0);
624
+ }
625
+ reapplyDataSourceOrder() {
626
+ if (this.viewer) {
627
+ for (let e of this.runtimeLayerOrder) for (let t of this.sourceState.values()) for (let n of t.layers) if (n.spec?.id === e && n.dataSource) try {
628
+ this.viewer.dataSources.raiseToTop(n.dataSource);
629
+ } catch {}
630
+ }
631
+ }
632
+ removeLayerDataSource(e) {
633
+ if (!e.dataSource || !this.viewer) return;
634
+ let t = e.dataSource, n = this.viewer;
635
+ setTimeout(() => {
636
+ try {
637
+ n.dataSources.remove(t, !0);
638
+ } catch {}
639
+ }, 0);
640
+ }
641
+ getEntityProperties(e) {
642
+ let t = e?.properties;
643
+ if (!t) return {};
644
+ let n = t.propertyNames ?? Object.keys(t), r = {};
645
+ for (let e of n) {
646
+ let n = t[e];
647
+ r[e] = typeof n?.getValue == "function" ? n.getValue(void 0) : n;
648
+ }
649
+ return r;
650
+ }
651
+ getEntityGeometryType(e) {
652
+ return e.position || e.point || e.billboard || e.ellipse ? "Point" : e.polygon ? "Polygon" : e.polyline ? "LineString" : null;
653
+ }
654
+ entityMatchesLayer(e, t, n) {
655
+ let r = t?.type === "fill" ? "Polygon" : t?.type === "line" ? "LineString" : t?.type === "circle" ? "Point" : null;
656
+ return !r || n === r || t?.type === "line" && n === "Polygon" ? this.matchesFilter(e, t?.filter) : !1;
657
+ }
658
+ matchesFilter(e, t) {
659
+ if (!Array.isArray(t) || t.length < 3) return !0;
660
+ let [n, r, i] = t;
661
+ return n === "==" ? this.resolveFilterOperand(e, r) === i : !0;
662
+ }
663
+ resolveFilterOperand(e, t) {
664
+ let n = f()?.JulianDate?.now?.();
665
+ if (t === "$type" || Array.isArray(t) && t[0] === "geometry-type") return this.getEntityGeometryType(e);
666
+ if (Array.isArray(t) && t[0] === "get" && typeof t[1] == "string") {
667
+ let r = e?.properties?.[t[1]];
668
+ return r ? typeof r.getValue == "function" ? r.getValue(n) : r : void 0;
669
+ }
670
+ return t;
671
+ }
672
+ setLayerOrderRegistry(e) {
673
+ this.layerOrderRegistry = e;
674
+ }
675
+ clampImageryProviderMaxLevel(e, t) {
676
+ if (!e || typeof t != "number" || !isFinite(t)) return;
677
+ if (typeof e.requestImage == "function") {
678
+ let n = e.requestImage.bind(e);
679
+ e.requestImage = (e, r, i, ...a) => n(e, r, Math.min(i, t), ...a);
680
+ }
681
+ let n = e.tilingScheme, r = (e) => e ? (r) => e.call(n, Math.min(r, t)) : void 0;
682
+ if (n) {
683
+ if (typeof n.getNumberOfXTilesAtLevel == "function") {
684
+ let e = n.getNumberOfXTilesAtLevel;
685
+ n.getNumberOfXTilesAtLevel = r(e);
686
+ }
687
+ if (typeof n.getNumberOfYTilesAtLevel == "function") {
688
+ let e = n.getNumberOfYTilesAtLevel;
689
+ n.getNumberOfYTilesAtLevel = r(e);
690
+ }
691
+ }
692
+ }
693
+ }, C = class {
694
+ toggleTool() {}
695
+ setBufferRadius(e) {}
696
+ };
697
+ //#endregion
698
+ //#region src/map/cesium-services/MapFactoryService.ts
699
+ function w() {
700
+ return globalThis.Cesium;
701
+ }
702
+ function T(e) {
703
+ return typeof ShadowRoot < "u" && e instanceof ShadowRoot;
704
+ }
705
+ function E(e) {
706
+ return Math.max(10, 2e7 / 2 ** Math.max(0, e));
707
+ }
708
+ function D(e) {
709
+ return !isFinite(e) || e <= 0 ? 0 : Math.log2(2e7 / e);
710
+ }
711
+ var O = 6378137, k = 512;
712
+ function A(e) {
713
+ return Math.max(-85.05112878, Math.min(85.05112878, e));
714
+ }
715
+ function j(e, t) {
716
+ let n = A(t) * Math.PI / 180;
717
+ return 2 * Math.PI * O * Math.cos(n) / (k * 2 ** e);
718
+ }
719
+ function M(e, t, n) {
720
+ let r = e.scene.canvas, i = Math.max(1, r.clientHeight || r.height || 1), a = e.camera.frustum, o = a && "fovy" in a ? a.fovy : Math.PI / 3, s = j(t, n);
721
+ return Math.max(10, s * i / (2 * Math.tan(o / 2)));
722
+ }
723
+ var ee = class {
724
+ constructor(e, t, n) {
725
+ this.id = e, this.getDataSource = t, this.setDataFn = n;
726
+ }
727
+ setData(e) {
728
+ this.setDataFn(e);
729
+ }
730
+ }, N = class {
731
+ constructor(e, t, n) {
732
+ this.id = e, this.sourceId = t, this.destroyFn = n;
733
+ }
734
+ getSource() {
735
+ return {
736
+ id: this.sourceId,
737
+ setData: () => {}
738
+ };
739
+ }
740
+ remove() {
741
+ this.destroyFn();
742
+ }
743
+ }, P = class {
744
+ constructor(e) {
745
+ this.viewer = e, this.sources = /* @__PURE__ */ new Map(), this.sourceState = /* @__PURE__ */ new Map(), this.layers = /* @__PURE__ */ new Map();
746
+ }
747
+ setViewport(e, t, n, r) {
748
+ let i = w();
749
+ if (!i) return;
750
+ let a = M(this.viewer, t, e[1]);
751
+ this.viewer.camera.setView({ destination: i.Cartesian3.fromDegrees(e[0], e[1], a) });
752
+ }
753
+ createSource(e, t) {
754
+ if (this.sources.has(e)) return this.sources.get(e);
755
+ let n = w();
756
+ if (!n) return {
757
+ id: e,
758
+ setData: () => {}
759
+ };
760
+ this.sourceState.set(e, {
761
+ dataSource: null,
762
+ layerSpecs: []
763
+ });
764
+ let r = (t) => {
765
+ let r = this.sourceState.get(e);
766
+ if (!r) return;
767
+ let i = r.dataSource;
768
+ n.GeoJsonDataSource.load(t, { clampToGround: !1 }).then((t) => {
769
+ i && this.viewer.dataSources.remove(i, !0), r.dataSource = t, this.viewer.dataSources.add(t), this.applyLayerStyles(e);
770
+ });
771
+ };
772
+ r(t);
773
+ let i = new ee(e, () => this.sourceState.get(e)?.dataSource ?? null, r);
774
+ return this.sources.set(e, i), i;
775
+ }
776
+ getSource(e) {
777
+ return this.sources.get(e) ?? null;
778
+ }
779
+ createLayer(e) {
780
+ if (this.layers.has(e.id)) return this.layers.get(e.id);
781
+ let t = this.sourceState.get(e.sourceId);
782
+ t && (t.layerSpecs = [...t.layerSpecs, e], this.applyLayerStyles(e.sourceId));
783
+ let n = new N(e.id, e.sourceId, () => {
784
+ let t = this.sourceState.get(e.sourceId);
785
+ t && (t.layerSpecs = t.layerSpecs.filter((t) => t.id !== e.id), this.applyLayerStyles(e.sourceId)), this.layers.delete(e.id);
786
+ });
787
+ return this.layers.set(e.id, n), n;
788
+ }
789
+ getLayer(e) {
790
+ return this.layers.get(e) ?? null;
791
+ }
792
+ onReady(e) {
793
+ queueMicrotask(e);
794
+ }
795
+ destroy() {
796
+ try {
797
+ this.viewer?.destroy?.();
798
+ } catch {}
799
+ this.sources.clear(), this.sourceState.clear(), this.layers.clear();
800
+ }
801
+ applyLayerStyles(e) {
802
+ let t = w();
803
+ if (!t) return;
804
+ let n = this.sourceState.get(e), r = n?.dataSource;
805
+ if (!n || !r) return;
806
+ let i = n.layerSpecs.filter((e) => e.type === "fill"), a = n.layerSpecs.filter((e) => e.type === "line"), o = i[i.length - 1], s = a[a.length - 1], c = o?.paint?.["fill-color"] ?? "#3388ff", l = o?.paint?.["fill-opacity"] ?? .2, u = s?.paint?.["line-color"] ?? "#3388ff", d = s?.paint?.["line-width"] ?? 2, f = r.entities?.values ?? [];
807
+ for (let e of f) e.polygon && (e.polygon.material = t.Color.fromCssColorString(c).withAlpha(l), e.polygon.outline = !0, e.polygon.outlineColor = t.Color.fromCssColorString(u).withAlpha(1)), e.polyline && (e.polyline.material = t.Color.fromCssColorString(u).withAlpha(1), e.polyline.width = d);
808
+ }
809
+ }, F = class {
810
+ applyInsetContainerFixes(e) {
811
+ e.classList.contains("inset-map") && (e.style.transform = "none", e.style.top = "0", e.style.left = "0", e.style.width = "100%", e.style.height = "100%");
812
+ }
813
+ ensureCesiumShadowStyles(e) {
814
+ let t = e.getRootNode();
815
+ if (!T(t)) return;
816
+ let n = "webmapx-cesium-shadow-styles";
817
+ if (t.querySelector(`#${n}`)) return;
818
+ let r = document.createElement("style");
819
+ r.id = n, r.textContent = "\n .cesium-viewer,\n .cesium-viewer-cesiumWidgetContainer,\n .cesium-widget,\n .cesium-widget canvas {\n width: 100%;\n height: 100%;\n display: block;\n }\n .cesium-widget canvas {\n outline: none;\n }\n .cesium-viewer,\n .cesium-viewer-cesiumWidgetContainer,\n .cesium-widget {\n position: absolute;\n inset: 0;\n }\n /* Keep credits from consuming layout inside shadow DOM insets. */\n .cesium-widget-credits,\n .cesium-credit-logoContainer,\n .cesium-credit-textContainer {\n display: none !important;\n }\n ", t.appendChild(r);
820
+ }
821
+ createMap(e, t) {
822
+ let n = w();
823
+ if (!n) throw Error("[Cesium] window.Cesium not found. Load CesiumJS before using the cesium adapter.");
824
+ this.applyInsetContainerFixes(e), this.ensureCesiumShadowStyles(e);
825
+ let r = t?.center ?? [0, 0], i = t?.zoom ?? 1, a = (Array.isArray(t?.tileUrls) && t.tileUrls.length > 0 ? t.tileUrls[0] : t?.tileUrl) ?? "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", o = new n.UrlTemplateImageryProvider({
826
+ url: a,
827
+ ...a.includes("{s}") ? { subdomains: [
828
+ "a",
829
+ "b",
830
+ "c"
831
+ ] } : {},
832
+ credit: t?.tileAttribution ?? "&copy; OpenStreetMap contributors"
833
+ }), s = document.createElement("div");
834
+ s.style.display = "none";
835
+ let c = new n.Viewer(e, {
836
+ animation: !1,
837
+ baseLayerPicker: !1,
838
+ fullscreenButton: !1,
839
+ geocoder: !1,
840
+ homeButton: !1,
841
+ infoBox: !1,
842
+ navigationHelpButton: !1,
843
+ sceneModePicker: !1,
844
+ selectionIndicator: !1,
845
+ timeline: !1,
846
+ vrButton: !1,
847
+ scene3DOnly: !0,
848
+ baseLayer: new n.ImageryLayer(o),
849
+ terrainProvider: new n.EllipsoidTerrainProvider(),
850
+ creditContainer: s
851
+ }), l = () => {
852
+ try {
853
+ c.resize?.(), c.scene?.requestRender?.();
854
+ } catch {}
855
+ };
856
+ l();
857
+ let u = new ResizeObserver(l);
858
+ u.observe(e);
859
+ let d = c.destroy?.bind(c);
860
+ if (c.destroy = () => (u.disconnect(), d?.()), t?.interactive === !1) {
861
+ let e = c.scene?.screenSpaceCameraController;
862
+ e && (e.enableRotate = !1, e.enableTranslate = !1, e.enableZoom = !1, e.enableTilt = !1, e.enableLook = !1);
863
+ }
864
+ let f = M(c, i, r[1]);
865
+ return c.camera.setView({ destination: n.Cartesian3.fromDegrees(r[0], r[1], f) }), c._webmapx = {
866
+ project: (e) => {
867
+ let t = n.Cartesian3.fromDegrees(e[0], e[1]), r = n.SceneTransforms.worldToWindowCoordinates(c.scene, t);
868
+ return r ? [r.x, r.y] : [0, 0];
869
+ },
870
+ heightMetersToZoom: D,
871
+ zoomToHeightMeters: E
872
+ }, new P(c);
873
+ }
874
+ };
875
+ //#endregion
876
+ //#region src/map/cesium-services/MapLayerService.ts
877
+ function I() {
878
+ return globalThis.Cesium;
879
+ }
880
+ var L = 6378137, R = 512;
881
+ function z(e) {
882
+ return Math.max(-85.05112878, Math.min(85.05112878, e));
883
+ }
884
+ function B(e, t) {
885
+ let n = z(t) * Math.PI / 180;
886
+ return 2 * Math.PI * L * Math.cos(n) / (R * 2 ** e);
887
+ }
888
+ function V(e, t, n, r = 48) {
889
+ let i = t * Math.PI / 180, a = n / L * (180 / Math.PI), o = a / Math.max(1e-6, Math.cos(i)), s = [];
890
+ for (let n = 0; n <= r; n += 1) {
891
+ let i = n / r * Math.PI * 2, c = e + o * Math.cos(i), l = t + a * Math.sin(i);
892
+ s.push([c, l]);
893
+ }
894
+ return s;
895
+ }
896
+ function H(e) {
897
+ let t = e.minzoom ?? e.minZoom;
898
+ return typeof t == "number" && isFinite(t) ? t : void 0;
899
+ }
900
+ function U(e) {
901
+ let t = e.maxzoom ?? e.maxZoom;
902
+ return typeof t == "number" && isFinite(t) ? t : void 0;
903
+ }
904
+ function W(e) {
905
+ if (!(typeof e != "number" || !isFinite(e))) return Math.max(0, Math.floor(e));
906
+ }
907
+ function G(e) {
908
+ try {
909
+ let t = new URL(e, window.location.origin), n = t.searchParams.get("layers") ?? "";
910
+ return t.search = "", {
911
+ baseUrl: t.toString(),
912
+ layers: n
913
+ };
914
+ } catch {
915
+ let [t, n] = e.split("?", 2);
916
+ return {
917
+ baseUrl: t,
918
+ layers: new URLSearchParams(n ?? "").get("layers") ?? ""
919
+ };
920
+ }
921
+ }
922
+ var K = class {
923
+ constructor(t, n) {
924
+ this.viewer = t, this.store = n, this.handles = /* @__PURE__ */ new Map(), this.lastZoomLevel = null, this.unsubscribeStore = null, this.busyOps = 0, this.logicalOrder = [], this.applyGeoJsonStylesThrottled = e(() => this.applyAllGeoJsonStyles(), 100), this.viewer?.scene?.globe?.tileLoadProgressEvent?.addEventListener?.((e) => {
925
+ e > 0 ? this.store.dispatch({ mapBusy: !0 }, "MAP") : this.busyOps === 0 && this.store.dispatch({ mapBusy: !1 }, "MAP");
926
+ }), this.unsubscribeStore = this.store.subscribe((e) => {
927
+ e.zoomLevel != null && e.zoomLevel !== this.lastZoomLevel && (this.lastZoomLevel = e.zoomLevel, this.applyGeoJsonStylesThrottled(), this.applyImageryVisibility(e.zoomLevel));
928
+ });
929
+ }
930
+ beginBusyOperation() {
931
+ this.busyOps += 1, this.busyOps === 1 && this.store.dispatch({ mapBusy: !0 }, "MAP");
932
+ }
933
+ endBusyOperation() {
934
+ if (this.busyOps <= 0) {
935
+ this.busyOps = 0;
936
+ return;
937
+ }
938
+ --this.busyOps, this.busyOps === 0 && this.store.dispatch({ mapBusy: !1 }, "MAP");
939
+ }
940
+ resolveInsertIndex(e) {
941
+ if (e?.beforeLayerId) {
942
+ let t = this.logicalOrder.indexOf(e.beforeLayerId);
943
+ if (t >= 0) return t;
944
+ }
945
+ if (e?.afterLayerId) {
946
+ let t = this.logicalOrder.indexOf(e.afterLayerId);
947
+ if (t >= 0) return t + 1;
948
+ }
949
+ }
950
+ upsertLogicalOrder(e, t) {
951
+ let n = this.resolveInsertIndex(t);
952
+ if (this.logicalOrder = this.logicalOrder.filter((t) => t !== e), typeof n != "number" || !Number.isFinite(n)) {
953
+ this.logicalOrder.push(e);
954
+ return;
955
+ }
956
+ let r = Math.max(0, Math.min(n, this.logicalOrder.length));
957
+ this.logicalOrder.splice(r, 0, e);
958
+ }
959
+ reapplyImageryOrder() {
960
+ let e = [];
961
+ for (let t of this.logicalOrder) for (let [n, r] of this.handles.entries()) n.startsWith(`${t}::`) && r.kind === "imagery" && e.push(r.imageryLayer);
962
+ for (let t = 0; t < e.length; t += 1) {
963
+ let n = e[t];
964
+ if (this.viewer.imageryLayers.indexOf(n) !== t) {
965
+ try {
966
+ this.viewer.imageryLayers.remove(n, !1);
967
+ } catch {}
968
+ this.viewer.imageryLayers.add(n, t);
969
+ }
970
+ }
971
+ }
972
+ async addImagerySource(e, t, n, r) {
973
+ let i = I();
974
+ if (!i) return !1;
975
+ let a = `${e}::${t}`;
976
+ if (this.handles.has(a)) return !0;
977
+ if (n.type !== "raster") return !1;
978
+ let o = Array.isArray(n.url) ? n.url[0] : n.url;
979
+ if (n.service === "xyz") {
980
+ if (o.startsWith("warpedmap://")) return console.warn("[CESIUM LAYER SERVICE] warpedmap:// (Allmaps) is not supported in Cesium."), !1;
981
+ let t = W(H(n)), s = W(U(n)), c = o.includes("{bbox-epsg-3857}"), l = new i.UrlTemplateImageryProvider({
982
+ url: c ? o.replace("{bbox-epsg-3857}", "{westProjected},{southProjected},{eastProjected},{northProjected}") : o,
983
+ ...c ? { tilingScheme: new i.WebMercatorTilingScheme() } : {},
984
+ credit: n.attribution ?? "",
985
+ minimumLevel: t,
986
+ maximumLevel: s
987
+ });
988
+ this.enforceMaxLevel(l, s);
989
+ let u = new i.ImageryLayer(l);
990
+ return this.viewer.imageryLayers.add(u), this.handles.set(a, {
991
+ kind: "imagery",
992
+ imageryLayer: u,
993
+ maxLevel: s
994
+ }), this.upsertLogicalOrder(e, r), this.reapplyImageryOrder(), this.applyImageryVisibility(this.store.getState().zoomLevel ?? 0), !0;
995
+ }
996
+ if (n.service === "wms") {
997
+ let t = n, { baseUrl: s, layers: c } = G(o), l = W(H(t)), u = W(U(t)), d = new i.WebMapServiceImageryProvider({
998
+ url: s,
999
+ layers: t.layers ?? c,
1000
+ parameters: {
1001
+ transparent: t.transparent ?? !0,
1002
+ format: t.format ?? "image/png",
1003
+ styles: t.styles ?? "",
1004
+ version: t.version ?? "1.1.1"
1005
+ },
1006
+ minimumLevel: l,
1007
+ maximumLevel: u,
1008
+ credit: t.attribution ?? ""
1009
+ });
1010
+ this.enforceMaxLevel(d, u);
1011
+ let f = new i.ImageryLayer(d);
1012
+ return this.viewer.imageryLayers.add(f), this.handles.set(a, {
1013
+ kind: "imagery",
1014
+ imageryLayer: f,
1015
+ maxLevel: u
1016
+ }), this.upsertLogicalOrder(e, r), this.reapplyImageryOrder(), this.applyImageryVisibility(this.store.getState().zoomLevel ?? 0), !0;
1017
+ }
1018
+ return !1;
1019
+ }
1020
+ async addGeoJSONSource(e, t, n, r, i) {
1021
+ let a = I();
1022
+ if (!a) return !1;
1023
+ let o = `${e}::${t}`;
1024
+ if (this.handles.has(o)) return !0;
1025
+ this.beginBusyOperation();
1026
+ try {
1027
+ let s = n.data, c = typeof s == "string" ? await (await fetch(s)).json() : s;
1028
+ if (r.length > 0 && r.every((e) => e.type === "fill") && this.isGlobeSpanningFillData(c, r)) return console.warn(`[CESIUM] Skipping layer "${e}": fill polygon too large for Cesium renderer`), !1;
1029
+ let l = await a.GeoJsonDataSource.load(c, { clampToGround: !1 });
1030
+ return await this.viewer.dataSources.add(l), this.applyGeoJsonStyles(l, r), this.handles.set(o, {
1031
+ kind: "geojson",
1032
+ dataSource: l,
1033
+ sourceId: t,
1034
+ subLayers: r,
1035
+ data: c,
1036
+ updateToken: 0
1037
+ }), this.upsertLogicalOrder(e, i), !0;
1038
+ } catch (t) {
1039
+ return console.warn(`[CESIUM] Failed to load GeoJSON layer "${e}":`, t), !1;
1040
+ } finally {
1041
+ this.endBusyOperation();
1042
+ }
1043
+ }
1044
+ isGlobeSpanningFillData(e, t) {
1045
+ let n = t.find((e) => e.type === "fill")?.paint ?? {};
1046
+ if (!("fill-color" in n || "fill-opacity" in n)) return !1;
1047
+ for (let t of e.features ?? []) {
1048
+ let e = t.geometry;
1049
+ if (!e || e.type !== "Polygon" && e.type !== "MultiPolygon") continue;
1050
+ let n = e.type === "Polygon" ? [e.coordinates[0]] : e.coordinates.map((e) => e[0]);
1051
+ for (let e of n) {
1052
+ let t = e.map((e) => e[0]), n = e.map((e) => e[1]), r = Math.max(...t) - Math.min(...t), i = Math.max(...n) - Math.min(...n);
1053
+ if (r > 90 || i > 60) return !0;
1054
+ }
1055
+ }
1056
+ return !1;
1057
+ }
1058
+ async addLayer(e, t) {
1059
+ if (!I()) return !1;
1060
+ let i = e.id;
1061
+ if (e.type === "allmaps") return console.warn("[CESIUM LAYER SERVICE] Allmaps is not supported in Cesium."), !1;
1062
+ if (e.type === "style") {
1063
+ let n = r(e);
1064
+ return n ? this.addCompositeLayer(n, t) : !1;
1065
+ }
1066
+ let a = e;
1067
+ if (!a.source) return !1;
1068
+ let o = e.sources?.[a.source], s = o ? n(a.source, o) : null;
1069
+ if (!s) return !1;
1070
+ let c = !1;
1071
+ return s.type === "raster" ? c = await this.addImagerySource(i, s.id, s, t) : s.type === "geojson" && (c = await this.addGeoJSONSource(i, s.id, s, [a], t)), c;
1072
+ }
1073
+ async addCompositeLayer(e, t) {
1074
+ let n = e.styleId, r = new Set(e.subLayers.map((e) => e.source).filter(Boolean)), i = !1;
1075
+ for (let a of r) {
1076
+ let r = o(e, a)?.config ?? null;
1077
+ r && (r.type === "raster" ? await this.addImagerySource(n, r.id, r, t) && (i = !0) : r.type === "geojson" && await this.addGeoJSONSource(n, r.id, r, e.subLayers, t) && (i = !0));
1078
+ }
1079
+ return i;
1080
+ }
1081
+ updateLayerStyle(e, t, n) {
1082
+ let r = !1;
1083
+ for (let [i, a] of this.handles.entries()) {
1084
+ if (a.kind !== "geojson" || !i.startsWith(`${e}::`)) continue;
1085
+ let o = a.subLayers.findIndex((e) => e.id === t);
1086
+ if (o < 0) continue;
1087
+ let s = a.subLayers[o];
1088
+ a.subLayers[o] = {
1089
+ ...s,
1090
+ paint: {
1091
+ ...s.paint ?? {},
1092
+ ...n
1093
+ }
1094
+ }, this.applyGeoJsonStyles(a.dataSource, a.subLayers), r = !0;
1095
+ }
1096
+ return r;
1097
+ }
1098
+ moveLayer(e, t) {
1099
+ let n = t ?? null;
1100
+ if (n && !this.logicalOrder.includes(n)) {
1101
+ let e = Object.keys(this.store.getState().mapLayers ?? {}), t = e.indexOf(n);
1102
+ n = t === -1 ? null : e.slice(t + 1).find((e) => this.logicalOrder.includes(e)) ?? null;
1103
+ }
1104
+ this.upsertLogicalOrder(e, n ? { beforeLayerId: n } : void 0), this.reapplyImageryOrder();
1105
+ }
1106
+ removeLayer(e) {
1107
+ let t = Array.from(this.handles.keys()).filter((t) => t.startsWith(`${e}::`));
1108
+ for (let e of t) {
1109
+ let t = this.handles.get(e);
1110
+ if (t) {
1111
+ if (t.kind === "imagery") try {
1112
+ this.viewer.imageryLayers.remove(t.imageryLayer, !0);
1113
+ } catch {}
1114
+ else if (t.kind === "geojson") try {
1115
+ this.viewer.dataSources.remove(t.dataSource, !0);
1116
+ } catch {}
1117
+ this.handles.delete(e);
1118
+ }
1119
+ }
1120
+ this.logicalOrder = this.logicalOrder.filter((t) => t !== e), this.reapplyImageryOrder();
1121
+ }
1122
+ getVisibleLayers() {
1123
+ let e = /* @__PURE__ */ new Set();
1124
+ for (let t of this.handles.keys()) e.add(t.split("::")[0]);
1125
+ return Array.from(e);
1126
+ }
1127
+ isLayerVisible(e) {
1128
+ for (let t of this.handles.keys()) if (t.startsWith(`${e}::`)) return !0;
1129
+ return !1;
1130
+ }
1131
+ setLayerVisibility(e, t) {
1132
+ for (let [n, r] of this.handles.entries()) n.startsWith(`${e}::`) && (r.kind === "imagery" ? r.imageryLayer.show = t : r.kind === "geojson" && (r.dataSource.show = t));
1133
+ }
1134
+ setLayerOpacity(e, t) {
1135
+ for (let [n, r] of this.handles.entries()) n.startsWith(`${e}::`) && r.kind === "imagery" && (r.imageryLayer.alpha = t);
1136
+ }
1137
+ getSourceData(e) {
1138
+ for (let t of this.handles.values()) if (!(t.kind !== "geojson" || t.sourceId !== e)) return t.data;
1139
+ return null;
1140
+ }
1141
+ setSourceData(e, t) {
1142
+ let n = !1;
1143
+ for (let [r, i] of this.handles.entries()) i.kind !== "geojson" || i.sourceId !== e || (i.data = t, i.updateToken += 1, this.replaceGeoJsonDataSource(r, i, i.updateToken), n = !0);
1144
+ return n;
1145
+ }
1146
+ async replaceGeoJsonDataSource(e, t, n) {
1147
+ let r = I();
1148
+ if (r) {
1149
+ this.beginBusyOperation();
1150
+ try {
1151
+ let i = await r.GeoJsonDataSource.load(t.data, { clampToGround: !1 }), a = this.handles.get(e);
1152
+ if (a?.kind !== "geojson" || a.updateToken !== n) return;
1153
+ let o = a.dataSource;
1154
+ a.dataSource = i, await this.viewer.dataSources.add(i), this.applyGeoJsonStyles(i, a.subLayers);
1155
+ try {
1156
+ this.viewer.dataSources.remove(o, !0);
1157
+ } catch {}
1158
+ } finally {
1159
+ this.endBusyOperation();
1160
+ }
1161
+ }
1162
+ }
1163
+ getVisibleWMSLayers() {
1164
+ return [];
1165
+ }
1166
+ registerInlineLayer(e, t) {
1167
+ this.upsertLogicalOrder(e, t);
1168
+ }
1169
+ unregisterInlineLayer(e) {
1170
+ this.logicalOrder = this.logicalOrder.filter((t) => t !== e);
1171
+ }
1172
+ getLogicalLayerForEntity(e) {
1173
+ for (let [t, n] of this.handles.entries()) if (n.kind === "geojson" && n.dataSource?.entities?.contains?.(e)) return t.split("::")[0];
1174
+ return null;
1175
+ }
1176
+ getEntityProperties(e) {
1177
+ let t = {}, n = e?.properties?.propertyNames ?? [];
1178
+ for (let r of n) t[r] = this.getEntityProperty(e, r);
1179
+ return t;
1180
+ }
1181
+ enforceMaxLevel(e, t) {
1182
+ if (typeof t != "number" || !isFinite(t) || typeof e.requestImage != "function") return;
1183
+ let n = e.requestImage.bind(e);
1184
+ if (e.requestImage = (e, r, i, ...a) => n(e, r, Math.min(i, t), ...a), e.tilingScheme && typeof e.tilingScheme.getNumberOfXTilesAtLevel == "function") {
1185
+ let n = e.tilingScheme.getNumberOfXTilesAtLevel.bind(e.tilingScheme);
1186
+ e.tilingScheme.getNumberOfXTilesAtLevel = (e) => n(Math.min(e, t));
1187
+ }
1188
+ if (e.tilingScheme && typeof e.tilingScheme.getNumberOfYTilesAtLevel == "function") {
1189
+ let n = e.tilingScheme.getNumberOfYTilesAtLevel.bind(e.tilingScheme);
1190
+ e.tilingScheme.getNumberOfYTilesAtLevel = (e) => n(Math.min(e, t));
1191
+ }
1192
+ }
1193
+ applyImageryVisibility(e) {
1194
+ for (let e of this.handles.values()) e.kind === "imagery" && e.imageryLayer?.show === !1 && (e.imageryLayer.show = !0);
1195
+ }
1196
+ getEntityProperty(e, t) {
1197
+ let n = I()?.JulianDate?.now?.(), r = e?.properties?.[t];
1198
+ if (r?.getValue && n) return r.getValue(n);
1199
+ if (r && typeof r == "object" && "valueOf" in r) try {
1200
+ return r.valueOf();
1201
+ } catch {
1202
+ return r;
1203
+ }
1204
+ return r;
1205
+ }
1206
+ entityToFeature(e) {
1207
+ let t = I()?.JulianDate?.now?.(), n = {};
1208
+ if (e?.properties) {
1209
+ let r = e.properties.propertyNames ?? Object.keys(e.properties);
1210
+ for (let i of r) {
1211
+ let r = e.properties[i];
1212
+ n[i] = r?.getValue?.(t) ?? r;
1213
+ }
1214
+ }
1215
+ let r = "Point";
1216
+ return e?.polygon ? r = "Polygon" : e?.polyline && (r = "LineString"), {
1217
+ properties: n,
1218
+ geometry: { type: r }
1219
+ };
1220
+ }
1221
+ matchesStyleFilter(e, t) {
1222
+ return t ? c(t, this.entityToFeature(e)) : !0;
1223
+ }
1224
+ resolveNumber(e, t, n) {
1225
+ let r = this.store.getState().zoomLevel ?? 0;
1226
+ return l(t, this.entityToFeature(e), r, n);
1227
+ }
1228
+ resolveColor(e, t, n) {
1229
+ let r = this.store.getState().zoomLevel ?? 0;
1230
+ return u(t, this.entityToFeature(e), r, n);
1231
+ }
1232
+ applyGeoJsonStyles(e, t) {
1233
+ let n = I();
1234
+ if (!n) return;
1235
+ let r = t.find((e) => e.type === "circle"), i = t.find((e) => e.type === "line"), a = t.find((e) => e.type === "fill"), o = r?.paint ?? {}, s = i?.paint ?? {}, c = a?.paint ?? {}, d = this.store.getState().zoomLevel ?? 0, f = { properties: {} }, p = u(s["line-color"], f, d, "#3388ff"), m = l(s["line-width"], f, d, 2), h = u(c["fill-color"], f, d, "#3388ff"), g = l(c["fill-opacity"], f, d, .2), _ = e.entities?.values ?? [];
1236
+ for (let e of _) {
1237
+ let t = this.matchesStyleFilter(e, r?.filter), s = this.matchesStyleFilter(e, i?.filter), c = this.matchesStyleFilter(e, a?.filter), l = !!(e.position || e.point || e.billboard || e.ellipse);
1238
+ if (r && l && !t && (e.point = void 0, e.billboard = void 0, e.ellipse = void 0, !s && !c)) {
1239
+ e.show = !1;
1240
+ continue;
1241
+ }
1242
+ if (r && l && t && (e.show = !0), r && t && l) {
1243
+ let t = this.store.getState().zoomLevel ?? 2, r = n.JulianDate.now(), i = e.position?.getValue?.(r) ?? e.position;
1244
+ if (i) {
1245
+ let r = this.resolveNumber(e, o["circle-radius"], 6), a = this.resolveColor(e, o["circle-color"], "#FF5722"), s = this.resolveNumber(e, o["circle-opacity"], 1), c = this.resolveColor(e, o["circle-stroke-color"], p), l = this.resolveNumber(e, o["circle-stroke-width"], 1), u = n.Ellipsoid.WGS84.cartesianToCartographic(i), d = u.latitude * 180 / Math.PI, f = B(t, d), m = Math.max(1, r * f);
1246
+ e.ellipse ||= new n.EllipseGraphics(), e.ellipse.semiMajorAxis = m, e.ellipse.semiMinorAxis = m, e.ellipse.material = n.Color.fromCssColorString(a).withAlpha(s), e.ellipse.outline = !1, e.ellipse.height = 0;
1247
+ let h = V(n.Math.toDegrees(u.longitude), d, m, 64).map(([e, t]) => n.Cartesian3.fromDegrees(e, t, 0));
1248
+ e.polyline ||= new n.PolylineGraphics(), e.polyline.positions = h, e.polyline.width = Math.max(1, l), e.polyline.material = n.Color.fromCssColorString(c).withAlpha(1), "clampToGround" in e.polyline && (e.polyline.clampToGround = !0), n.HeightReference?.CLAMP_TO_GROUND && (e.ellipse.heightReference = n.HeightReference.CLAMP_TO_GROUND), e.billboard = void 0, e.point = void 0;
1249
+ }
1250
+ }
1251
+ e.polyline && i && s && (e.polyline.material = n.Color.fromCssColorString(p).withAlpha(1), e.polyline.width = m), e.polygon && a && c && (e.polygon.material = n.Color.fromCssColorString(h).withAlpha(g), e.polygon.outline = !0, e.polygon.outlineColor = n.Color.fromCssColorString(p).withAlpha(1));
1252
+ }
1253
+ }
1254
+ applyAllGeoJsonStyles() {
1255
+ for (let e of this.handles.values()) e.kind === "geojson" && this.applyGeoJsonStyles(e.dataSource, e.subLayers);
1256
+ }
1257
+ };
1258
+ //#endregion
1259
+ //#region src/map/cesium-services/MapQueryService.ts
1260
+ function q() {
1261
+ return globalThis.Cesium;
1262
+ }
1263
+ var J = class {
1264
+ constructor(e, t) {
1265
+ this.viewer = e, this.layerService = t;
1266
+ }
1267
+ async queryFeatures(e, n = {}) {
1268
+ let { pixel: r } = e, i = q();
1269
+ if (!i || !this.viewer?.scene) return [];
1270
+ let a = [], o = n.layerIds?.length ? new Set(n.layerIds) : null, s = this.viewer.scene, c = new i.Cartesian2(r[0], r[1]), l = s.drillPick(c) ?? [];
1271
+ for (let e of l) {
1272
+ let t = e?.id;
1273
+ if (!t) continue;
1274
+ let n = this.layerService.getLogicalLayerForEntity(t);
1275
+ if (!n || o && !o.has(n)) continue;
1276
+ let r = this.layerService.getEntityProperties(t);
1277
+ a.push({
1278
+ layerId: n,
1279
+ properties: r,
1280
+ source: "vector"
1281
+ });
1282
+ }
1283
+ if (n.includeWMS) {
1284
+ let e = s.canvas, n = e.clientWidth, c = e.clientHeight, l = this.getCameraBounds(i);
1285
+ if (l) {
1286
+ let e = this.layerService.getVisibleWMSLayers(), i = await Promise.all(e.filter((e) => !o || o.has(e.layerId)).map((e) => t({
1287
+ sourceConfig: e.sourceConfig,
1288
+ layerId: e.layerId,
1289
+ layerTitle: e.layerTitle,
1290
+ bounds: l,
1291
+ containerWidth: n,
1292
+ containerHeight: c,
1293
+ pixelX: r[0],
1294
+ pixelY: r[1]
1295
+ })));
1296
+ for (let e of i) a.push(...e);
1297
+ }
1298
+ }
1299
+ return a;
1300
+ }
1301
+ getCameraBounds(e) {
1302
+ try {
1303
+ let t = this.viewer.camera.computeViewRectangle(this.viewer.scene.globe.ellipsoid);
1304
+ return t ? {
1305
+ west: e.Math.toDegrees(t.west),
1306
+ south: e.Math.toDegrees(t.south),
1307
+ east: e.Math.toDegrees(t.east),
1308
+ north: e.Math.toDegrees(t.north)
1309
+ } : null;
1310
+ } catch {
1311
+ return null;
1312
+ }
1313
+ }
1314
+ };
1315
+ //#endregion
1316
+ //#region src/map/cesium-services/MapMarkerService.ts
1317
+ function Y() {
1318
+ return globalThis.Cesium;
1319
+ }
1320
+ var X = class {
1321
+ constructor(e) {
1322
+ this.viewer = e, this.entities = /* @__PURE__ */ new Map();
1323
+ }
1324
+ add(e, t, n = {}) {
1325
+ this.remove(e);
1326
+ let r = Y();
1327
+ if (!r || !this.viewer) return;
1328
+ let i = n.color ?? "#e63946", a = this.viewer.entities.add({
1329
+ position: r.Cartesian3.fromDegrees(t[0], t[1]),
1330
+ billboard: {
1331
+ image: d(i),
1332
+ width: 24,
1333
+ height: 36,
1334
+ verticalOrigin: r.VerticalOrigin.BOTTOM,
1335
+ horizontalOrigin: r.HorizontalOrigin.CENTER,
1336
+ disableDepthTestDistance: Infinity
1337
+ }
1338
+ });
1339
+ this.entities.set(e, a);
1340
+ }
1341
+ move(e, t) {
1342
+ let n = Y(), r = this.entities.get(e);
1343
+ r && n && (r.position = n.Cartesian3.fromDegrees(t[0], t[1]));
1344
+ }
1345
+ remove(e) {
1346
+ let t = this.entities.get(e);
1347
+ t && (this.viewer?.entities.remove(t), this.entities.delete(e));
1348
+ }
1349
+ }, Z = null;
1350
+ function Q(e) {
1351
+ let t = "/".endsWith("/") ? "/" : "//";
1352
+ return new URL(e.replace(/^\//, ""), new URL(t, window.location.href)).toString();
1353
+ }
1354
+ async function te() {
1355
+ if (!globalThis.Cesium) return Z || (Z = new Promise((e, t) => {
1356
+ let n = document.querySelector("script[data-webmapx-cesium]");
1357
+ if (n && globalThis.Cesium) {
1358
+ e();
1359
+ return;
1360
+ }
1361
+ let r = "webmapx-cesium-widgets-css";
1362
+ if (!document.getElementById(r)) {
1363
+ let e = document.createElement("link");
1364
+ e.id = r, e.rel = "stylesheet", e.href = Q("cesium/Widgets/widgets.css"), document.head.appendChild(e);
1365
+ }
1366
+ globalThis.CESIUM_BASE_URL = Q("cesium/");
1367
+ let i = n ?? document.createElement("script");
1368
+ i.setAttribute("data-webmapx-cesium", "true"), i.src = Q("cesium/Cesium.js"), i.async = !0, i.onload = () => {
1369
+ globalThis.Cesium ? e() : t(/* @__PURE__ */ Error("[Cesium] Script loaded but window.Cesium is still undefined."));
1370
+ }, i.onerror = () => {
1371
+ t(/* @__PURE__ */ Error(`[Cesium] Failed to load ${i.src}. Ensure Cesium assets are hosted under /cesium/.`));
1372
+ }, n || document.head.appendChild(i);
1373
+ }), Z);
1374
+ }
1375
+ var $ = class extends a {
1376
+ get engineVersion() {
1377
+ return globalThis.Cesium?.VERSION ?? "";
1378
+ }
1379
+ constructor() {
1380
+ super(), this.engineId = "cesium", this.markerService = null, this.core = new S(this.store, this.events), this.toolService = new C(), this.logicalLayerExecutor = new i(), this.queryExecutor = new s(), this.queryService = this.queryExecutor, this.mapFactory = new F(), this.core.onMapReady?.((e) => {
1381
+ let t = new K(e, this.store);
1382
+ this.logicalLayerExecutor.bind(t), this.core.setLayerOrderRegistry(t), this.queryExecutor.bind(new J(e, t)), this.markerService = new X(e);
1383
+ });
1384
+ }
1385
+ initialize(e, t) {
1386
+ this.core.initialize(e, t);
1387
+ }
1388
+ getViewportState() {
1389
+ return this.core.getViewportState();
1390
+ }
1391
+ setViewport(e, t) {
1392
+ this.core.setViewport(e, t);
1393
+ }
1394
+ getZoom() {
1395
+ return this.core.getZoom();
1396
+ }
1397
+ setZoom(e) {
1398
+ this.core.setZoom(e);
1399
+ }
1400
+ getBearing() {
1401
+ return this.core.getBearing();
1402
+ }
1403
+ setBearing(e) {
1404
+ this.core.setBearing(e);
1405
+ }
1406
+ getPitch() {
1407
+ return this.core.getPitch();
1408
+ }
1409
+ setPitch(e) {
1410
+ this.core.setPitch(e);
1411
+ }
1412
+ setTerrainEnabled(e, t) {
1413
+ return this.core.setTerrainEnabled(e, t);
1414
+ }
1415
+ isTerrainEnabled() {
1416
+ return this.core.isTerrainEnabled();
1417
+ }
1418
+ resetNorth() {
1419
+ this.core.resetNorth();
1420
+ }
1421
+ resetNorthPitch() {
1422
+ this.core.resetNorthPitch();
1423
+ }
1424
+ fitBounds(e) {
1425
+ this.core.fitBounds(e);
1426
+ }
1427
+ setProjection(e) {
1428
+ return !1;
1429
+ }
1430
+ getProjection() {
1431
+ return null;
1432
+ }
1433
+ setCursor(e) {
1434
+ this.core.setCursor(e);
1435
+ }
1436
+ setPanEnabled(e) {
1437
+ this.core.setPanEnabled(e);
1438
+ }
1439
+ setTouchCaptureEnabled(e) {}
1440
+ setDoubleClickZoomEnabled(e) {}
1441
+ setLayerVisibility(e, t) {
1442
+ this.logicalLayerExecutor.setLayerVisibility(e, t);
1443
+ }
1444
+ setLayerOpacity(e, t) {
1445
+ this.logicalLayerExecutor.setLayerOpacity(e, t);
1446
+ }
1447
+ getSourceData(e) {
1448
+ return this.core.getSourceData(e) ?? this.logicalLayerExecutor.getSourceData(e);
1449
+ }
1450
+ project(e) {
1451
+ return this.core.project(e);
1452
+ }
1453
+ unproject(e) {
1454
+ return this.core.unproject(e);
1455
+ }
1456
+ getNavigationCapabilities() {
1457
+ return this.core.getNavigationCapabilities();
1458
+ }
1459
+ async engineAddLayer(e, t) {
1460
+ return await this.logicalLayerExecutor.addLayer(e, t) ? !0 : this.core.addLayer(e, t);
1461
+ }
1462
+ removeLogicalLayer(e) {
1463
+ this.removeLayer(e);
1464
+ }
1465
+ engineAddSource(e, t) {
1466
+ this.core.addSource(e, t);
1467
+ }
1468
+ engineRemoveLayer(e) {
1469
+ this.logicalLayerExecutor.removeLayer(e), this.core.removeLayer(e);
1470
+ }
1471
+ engineRemoveSource(e) {
1472
+ this.core.removeSource(e);
1473
+ }
1474
+ getCore() {
1475
+ return this.core;
1476
+ }
1477
+ getLogicalLayerExecutor() {
1478
+ return this.logicalLayerExecutor;
1479
+ }
1480
+ getMarkerService() {
1481
+ return this.markerService;
1482
+ }
1483
+ };
1484
+ async function ne() {
1485
+ return await te(), new $();
1486
+ }
1487
+ //#endregion
1488
+ export { $ as CesiumAdapter, ne as createCesiumAdapter };