@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,590 @@
1
+ import { t as e } from "./decorate-CWgUV1hU.js";
2
+ import { a as t, i as n, o as r } from "./decorators-B35AgiCU.js";
3
+ import "./icon-CEOgWlro.js";
4
+ import "./button-DFdGkRPQ.js";
5
+ import { i, n as a, r as o, t as s } from "./geo-calculations-DbFJAUoI.js";
6
+ import { t as c } from "./throttle-BeneRNYK.js";
7
+ import { t as l } from "./webmapx-modal-tool-eF6Naluv.js";
8
+ import { css as u, html as d, nothing as f } from "lit";
9
+ //#region src/components/webmapx-measure-tool.ts
10
+ var p = "webmapx-measure-static-source", m = "webmapx-measure-points", h = "webmapx-measure-lines", g = "webmapx-measure-polygon", _ = "webmapx-measure-segment-labels", v = "webmapx-measure-rubberband-source", y = "webmapx-measure-rubberband-layer", b = class extends l {
11
+ constructor(...e) {
12
+ super(...e), this.toolId = "measure", this.closeThreshold = 10, this.finishThreshold = 10, this.points = [], this.segments = [], this.totalDistanceCm = 0, this.cursorPosition = null, this.isClosed = !1, this.areaM2 = 0, this.finished = !1, this.touchMQ = window.matchMedia("(pointer: coarse)"), this.isTouchDevice = this.touchMQ.matches, this.onTouchMQChange = (e) => {
13
+ this.isTouchDevice = e.matches;
14
+ }, this.layersCreated = !1, this.throttledUpdateVisualization = c(() => {
15
+ this.doUpdateRubberbandVisualization();
16
+ }, 50), this.unsubClick = null, this.unsubDblClick = null, this.unsubPointerMove = null, this.unsubContextMenu = null, this.keydownHandler = null;
17
+ }
18
+ get isFinished() {
19
+ return this.finished || this.isClosed;
20
+ }
21
+ static {
22
+ this.styles = u`
23
+ :host {
24
+ display: block;
25
+ pointer-events: auto;
26
+ }
27
+
28
+ :host(:not([active])) .measure-content {
29
+ display: none;
30
+ }
31
+
32
+ .measure-container {
33
+ display: flex;
34
+ flex-direction: column;
35
+ gap: 0.5rem;
36
+ padding: var(--webmapx-tool-padding, 0);
37
+ font-size: var(--font-size-small, 0.875rem);
38
+ }
39
+
40
+ .segment-list {
41
+ /* max-height is removed to allow the panel to grow */
42
+ }
43
+
44
+ .segment {
45
+ display: flex;
46
+ justify-content: space-between;
47
+ padding: 0.25rem 0;
48
+ border-bottom: 1px solid var(--color-border-light, #eee);
49
+ }
50
+
51
+ .segment:last-child {
52
+ border-bottom: none;
53
+ }
54
+
55
+ .segment-label {
56
+ color: var(--color-text-secondary, #666);
57
+ }
58
+
59
+ .segment-value {
60
+ font-weight: 600;
61
+ font-variant-numeric: tabular-nums;
62
+ }
63
+
64
+ .total-row {
65
+ display: flex;
66
+ justify-content: space-between;
67
+ padding-top: 0.5rem;
68
+ border-top: 2px solid var(--color-border, #ccc);
69
+ font-weight: 600;
70
+ }
71
+
72
+ .area-row {
73
+ display: flex;
74
+ justify-content: space-between;
75
+ padding-top: 0.25rem;
76
+ color: var(--color-primary, #0f62fe);
77
+ font-weight: 600;
78
+ }
79
+
80
+ .instructions {
81
+ color: var(--color-text-secondary, #666);
82
+ font-size: 0.75rem;
83
+ font-style: italic;
84
+ margin: 0;
85
+ }
86
+
87
+ .actions {
88
+ display: flex;
89
+ gap: 0.5rem;
90
+ margin-top: 0.5rem;
91
+ }
92
+ `;
93
+ }
94
+ onMapAttached(e) {
95
+ super.onMapAttached(e), this.setupMapEventListeners(e), this.loadConfigDefaults();
96
+ }
97
+ onMapDetached() {
98
+ this.cleanupEventListeners(), this.cleanupMapLayers(), super.onMapDetached();
99
+ }
100
+ connectedCallback() {
101
+ super.connectedCallback(), this.touchMQ.addEventListener("change", this.onTouchMQChange);
102
+ }
103
+ disconnectedCallback() {
104
+ this.touchMQ.removeEventListener("change", this.onTouchMQChange), this.cleanupEventListeners(), super.disconnectedCallback();
105
+ }
106
+ async updated(e) {
107
+ e.has("segments") && (await this.updateComplete, this.dispatchEvent(new CustomEvent("webmapx-content-updated", {
108
+ bubbles: !0,
109
+ composed: !0
110
+ })));
111
+ }
112
+ loadConfigDefaults() {
113
+ let e = this.toolsConfig?.measure;
114
+ e && (this.closeThreshold = e.closeThreshold ?? 10, this.finishThreshold = e.finishThreshold ?? 10);
115
+ }
116
+ setupMapEventListeners(e) {
117
+ this.unsubClick = e.events.on("click", this.handleClick.bind(this)), this.unsubDblClick = e.events.on("dblclick", this.handleDblClick.bind(this)), this.unsubPointerMove = e.events.on("pointer-move", this.handlePointerMove.bind(this)), this.unsubContextMenu = e.events.on("contextmenu", this.handleContextMenu.bind(this)), this.keydownHandler = this.handleKeydown.bind(this), document.addEventListener("keydown", this.keydownHandler);
118
+ }
119
+ cleanupEventListeners() {
120
+ this.unsubClick?.(), this.unsubDblClick?.(), this.unsubPointerMove?.(), this.unsubContextMenu?.(), this.keydownHandler &&= (document.removeEventListener("keydown", this.keydownHandler), null);
121
+ }
122
+ createMeasureLayers() {
123
+ this.layersCreated ||= (this.dispatchEvent(new CustomEvent("webmapx-add-source", {
124
+ detail: {
125
+ id: p,
126
+ config: {
127
+ type: "geojson",
128
+ data: this.buildStaticGeoJSON()
129
+ }
130
+ },
131
+ bubbles: !0,
132
+ composed: !0
133
+ })), this.dispatchEvent(new CustomEvent("webmapx-add-source", {
134
+ detail: {
135
+ id: v,
136
+ config: {
137
+ type: "geojson",
138
+ data: this.buildRubberbandGeoJSON()
139
+ }
140
+ },
141
+ bubbles: !0,
142
+ composed: !0
143
+ })), this.dispatchEvent(new CustomEvent("webmapx-add-layer", {
144
+ detail: {
145
+ id: g,
146
+ type: "fill",
147
+ source: p,
148
+ metadata: {
149
+ hideFromLegend: !0,
150
+ label: "Measure polygon"
151
+ },
152
+ filter: [
153
+ "==",
154
+ ["geometry-type"],
155
+ "Polygon"
156
+ ],
157
+ paint: {
158
+ "fill-color": "#0f62fe",
159
+ "fill-opacity": .1
160
+ }
161
+ },
162
+ bubbles: !0,
163
+ composed: !0
164
+ })), this.dispatchEvent(new CustomEvent("webmapx-add-layer", {
165
+ detail: {
166
+ id: h,
167
+ type: "line",
168
+ source: p,
169
+ metadata: {
170
+ hideFromLegend: !0,
171
+ label: "Measure lines"
172
+ },
173
+ filter: [
174
+ "==",
175
+ ["get", "type"],
176
+ "line"
177
+ ],
178
+ paint: {
179
+ "line-color": "#0f62fe",
180
+ "line-width": 2
181
+ }
182
+ },
183
+ bubbles: !0,
184
+ composed: !0
185
+ })), this.dispatchEvent(new CustomEvent("webmapx-add-layer", {
186
+ detail: {
187
+ id: y,
188
+ type: "line",
189
+ source: v,
190
+ metadata: {
191
+ hideFromLegend: !0,
192
+ label: "Measure rubberband"
193
+ },
194
+ paint: {
195
+ "line-color": "#0f62fe",
196
+ "line-width": 2,
197
+ "line-dasharray": [4, 4]
198
+ }
199
+ },
200
+ bubbles: !0,
201
+ composed: !0
202
+ })), this.dispatchEvent(new CustomEvent("webmapx-add-layer", {
203
+ detail: {
204
+ id: _,
205
+ type: "symbol",
206
+ source: p,
207
+ metadata: {
208
+ isToolLayer: !0,
209
+ hideFromLegend: !0,
210
+ label: "Measure segment labels"
211
+ },
212
+ filter: [
213
+ "==",
214
+ ["get", "type"],
215
+ "segment-label"
216
+ ],
217
+ layout: {
218
+ "text-field": ["get", "label"],
219
+ "text-font": ["Noto Sans Regular"],
220
+ "text-size": 12,
221
+ "text-anchor": "center",
222
+ "text-allow-overlap": !0,
223
+ "text-ignore-placement": !0
224
+ },
225
+ paint: {
226
+ "text-color": "#0f62fe",
227
+ "text-halo-color": "#fff",
228
+ "text-halo-width": 1.5
229
+ }
230
+ },
231
+ bubbles: !0,
232
+ composed: !0
233
+ })), this.dispatchEvent(new CustomEvent("webmapx-add-layer", {
234
+ detail: {
235
+ id: m,
236
+ type: "circle",
237
+ source: p,
238
+ metadata: {
239
+ isToolLayer: !0,
240
+ hideFromLegend: !0,
241
+ label: "Measure points"
242
+ },
243
+ filter: [
244
+ "==",
245
+ ["get", "type"],
246
+ "point"
247
+ ],
248
+ paint: {
249
+ "circle-radius": 5,
250
+ "circle-color": "#fff",
251
+ "circle-opacity": 1,
252
+ "circle-stroke-color": "#0f62fe",
253
+ "circle-stroke-width": 2
254
+ }
255
+ },
256
+ bubbles: !0,
257
+ composed: !0
258
+ })), !0);
259
+ }
260
+ cleanupMapLayers() {
261
+ this.removeMeasureLayers();
262
+ }
263
+ removeMeasureLayers() {
264
+ this.layersCreated &&= (this.dispatchEvent(new CustomEvent("webmapx-remove-layer", {
265
+ detail: m,
266
+ bubbles: !0,
267
+ composed: !0
268
+ })), this.dispatchEvent(new CustomEvent("webmapx-remove-layer", {
269
+ detail: _,
270
+ bubbles: !0,
271
+ composed: !0
272
+ })), this.dispatchEvent(new CustomEvent("webmapx-remove-layer", {
273
+ detail: h,
274
+ bubbles: !0,
275
+ composed: !0
276
+ })), this.dispatchEvent(new CustomEvent("webmapx-remove-layer", {
277
+ detail: g,
278
+ bubbles: !0,
279
+ composed: !0
280
+ })), this.dispatchEvent(new CustomEvent("webmapx-remove-layer", {
281
+ detail: y,
282
+ bubbles: !0,
283
+ composed: !0
284
+ })), this.dispatchEvent(new CustomEvent("webmapx-remove-source", {
285
+ detail: p,
286
+ bubbles: !0,
287
+ composed: !0
288
+ })), this.dispatchEvent(new CustomEvent("webmapx-remove-source", {
289
+ detail: v,
290
+ bubbles: !0,
291
+ composed: !0
292
+ })), !1);
293
+ }
294
+ updateMapVisualization() {
295
+ this.doUpdateStaticVisualization();
296
+ }
297
+ doUpdateStaticVisualization() {
298
+ if (!this.layersCreated) return;
299
+ let e = this.buildStaticGeoJSON();
300
+ this.dispatchEvent(new CustomEvent("webmapx-set-source-data", {
301
+ detail: {
302
+ id: p,
303
+ data: e
304
+ },
305
+ bubbles: !0,
306
+ composed: !0
307
+ }));
308
+ }
309
+ doUpdateRubberbandVisualization() {
310
+ if (!this.layersCreated) return;
311
+ let e = this.buildRubberbandGeoJSON();
312
+ this.dispatchEvent(new CustomEvent("webmapx-set-source-data", {
313
+ detail: {
314
+ id: v,
315
+ data: e
316
+ },
317
+ bubbles: !0,
318
+ composed: !0
319
+ }));
320
+ }
321
+ buildStaticGeoJSON() {
322
+ let e = [];
323
+ if (this.points.forEach((t, n) => {
324
+ e.push({
325
+ type: "Feature",
326
+ properties: {
327
+ index: n,
328
+ type: "point",
329
+ isFirst: n === 0,
330
+ isLast: n === this.points.length - 1
331
+ },
332
+ geometry: {
333
+ type: "Point",
334
+ coordinates: t
335
+ }
336
+ });
337
+ }), this.points.length >= 2) {
338
+ let t = this.buildLineCoordinates(this.points, this.isClosed);
339
+ e.push({
340
+ type: "Feature",
341
+ properties: { type: "line" },
342
+ geometry: {
343
+ type: "LineString",
344
+ coordinates: t
345
+ }
346
+ });
347
+ }
348
+ if (this.segments.forEach((t, n) => {
349
+ e.push({
350
+ type: "Feature",
351
+ properties: {
352
+ type: "segment-label",
353
+ label: String(n + 1)
354
+ },
355
+ geometry: {
356
+ type: "Point",
357
+ coordinates: [(t.from[0] + t.to[0]) / 2, (t.from[1] + t.to[1]) / 2]
358
+ }
359
+ });
360
+ }), this.isClosed && this.points.length >= 3) {
361
+ let t = this.buildLineCoordinates(this.points, !0);
362
+ e.push({
363
+ type: "Feature",
364
+ properties: { type: "polygon" },
365
+ geometry: {
366
+ type: "Polygon",
367
+ coordinates: [t]
368
+ }
369
+ });
370
+ }
371
+ return {
372
+ type: "FeatureCollection",
373
+ features: e
374
+ };
375
+ }
376
+ buildRubberbandGeoJSON() {
377
+ let e = [];
378
+ if (!this.isClosed && this.points.length > 0 && this.cursorPosition && this.active) {
379
+ let t = this.buildSegmentCoordinates(this.points[this.points.length - 1], this.cursorPosition);
380
+ e.push({
381
+ type: "Feature",
382
+ properties: { type: "rubberband" },
383
+ geometry: {
384
+ type: "LineString",
385
+ coordinates: t
386
+ }
387
+ });
388
+ }
389
+ return {
390
+ type: "FeatureCollection",
391
+ features: e
392
+ };
393
+ }
394
+ handleClick(e) {
395
+ if (!this.active) return;
396
+ let t = e.coords, n = e.pixel;
397
+ if (this.isFinished) {
398
+ if (this.isTouchDevice) return;
399
+ this.clearMeasurement(), this.addPoint(t);
400
+ return;
401
+ }
402
+ if (this.points.length >= 3 && this.isWithinThreshold(n, this.points[0], this.closeThreshold)) {
403
+ this.closePolygon();
404
+ return;
405
+ }
406
+ if (this.points.length >= 1) {
407
+ let e = this.points[this.points.length - 1];
408
+ if (this.isWithinThreshold(n, e, this.finishThreshold)) {
409
+ this.finishMeasurement();
410
+ return;
411
+ }
412
+ }
413
+ this.addPoint(t);
414
+ }
415
+ handleDblClick(e) {
416
+ !this.active || this.isFinished || this.finishMeasurement();
417
+ }
418
+ handlePointerMove(e) {
419
+ !this.active || this.isFinished || this.points.length !== 0 && (this.cursorPosition = e.coords, this.throttledUpdateVisualization());
420
+ }
421
+ handleContextMenu(e) {
422
+ !this.active || this.isFinished || this.finishMeasurement();
423
+ }
424
+ handleKeydown(e) {
425
+ !this.active || this.isFinished || e.key === "Escape" && this.finishMeasurement();
426
+ }
427
+ isWithinThreshold(e, t, n) {
428
+ let r = this.adapter?.project(t);
429
+ if (!r) return !1;
430
+ let i = e[0] - r[0], a = e[1] - r[1];
431
+ return Math.sqrt(i * i + a * a) <= n;
432
+ }
433
+ buildSegmentCoordinates(e, t) {
434
+ let n = Math.abs(t[1] - e[1]), r = Math.abs(this.normalizeLongitudeDeltaDegrees(t[0] - e[0]));
435
+ if (!(n > 1 || r > 1)) return [e, t];
436
+ let i = this.computeAngularDistanceRad(e, t);
437
+ if (i === 0) return [e];
438
+ let a = i * 180 / Math.PI, o = Math.max(1, Math.ceil(a)), s = [];
439
+ for (let n = 0; n <= o; n++) {
440
+ let r = n / o;
441
+ s.push(this.interpolateGreatCirclePoint(e, t, r, i));
442
+ }
443
+ return s;
444
+ }
445
+ buildLineCoordinates(e, t) {
446
+ if (e.length < 2) return e;
447
+ let n = t ? [...e, e[0]] : e, r = [];
448
+ for (let e = 1; e < n.length; e++) {
449
+ let t = this.buildSegmentCoordinates(n[e - 1], n[e]);
450
+ r.length === 0 ? r.push(...t) : r.push(...t.slice(1));
451
+ }
452
+ return r;
453
+ }
454
+ computeAngularDistanceRad(e, t) {
455
+ let n = this.toRadians(e[1]), r = this.toRadians(t[1]), i = r - n, a = this.normalizeLongitudeDeltaRadians(this.toRadians(t[0] - e[0])), o = Math.sin(i / 2) ** 2 + Math.cos(n) * Math.cos(r) * Math.sin(a / 2) ** 2;
456
+ return 2 * Math.atan2(Math.sqrt(o), Math.sqrt(1 - o));
457
+ }
458
+ interpolateGreatCirclePoint(e, t, n, r) {
459
+ let i = this.toRadians(e[1]), a = this.toRadians(e[0]), o = this.toRadians(t[1]), s = this.toRadians(t[0]), c = Math.sin(r);
460
+ if (c === 0) return e;
461
+ let l = Math.sin((1 - n) * r) / c, u = Math.sin(n * r) / c, d = l * Math.cos(i) * Math.cos(a) + u * Math.cos(o) * Math.cos(s), f = l * Math.cos(i) * Math.sin(a) + u * Math.cos(o) * Math.sin(s), p = l * Math.sin(i) + u * Math.sin(o), m = Math.atan2(p, Math.sqrt(d * d + f * f)), h = Math.atan2(f, d);
462
+ return [this.toDegrees(h), this.toDegrees(m)];
463
+ }
464
+ toRadians(e) {
465
+ return e * Math.PI / 180;
466
+ }
467
+ toDegrees(e) {
468
+ return e * 180 / Math.PI;
469
+ }
470
+ normalizeLongitudeDeltaDegrees(e) {
471
+ return (e + 540) % 360 - 180;
472
+ }
473
+ normalizeLongitudeDeltaRadians(e) {
474
+ return (e + 3 * Math.PI) % (2 * Math.PI) - Math.PI;
475
+ }
476
+ addPoint(e) {
477
+ let t = [...this.points, e];
478
+ if (t.length >= 2) {
479
+ let e = t[t.length - 2], n = t[t.length - 1], r = i(e, n), a = {
480
+ from: e,
481
+ to: n,
482
+ distanceCm: r
483
+ };
484
+ this.segments = [...this.segments, a], this.totalDistanceCm += r;
485
+ }
486
+ this.points = t, this.updateMapVisualization();
487
+ }
488
+ closePolygon() {
489
+ if (this.points.length < 3) return;
490
+ let e = this.points[this.points.length - 1], t = this.points[0], n = i(e, t), r = {
491
+ from: e,
492
+ to: t,
493
+ distanceCm: n
494
+ };
495
+ this.segments = [...this.segments, r], this.totalDistanceCm += n, this.areaM2 = o(this.points), this.isClosed = !0, this.cursorPosition = null, this.updateMapVisualization(), this.doUpdateRubberbandVisualization();
496
+ }
497
+ finishMeasurement() {
498
+ this.finished = !0, this.cursorPosition = null, this.doUpdateRubberbandVisualization();
499
+ }
500
+ clearMeasurement() {
501
+ this.points = [], this.segments = [], this.totalDistanceCm = 0, this.cursorPosition = null, this.isClosed = !1, this.finished = !1, this.areaM2 = 0, this.doUpdateStaticVisualization(), this.doUpdateRubberbandVisualization();
502
+ }
503
+ onActivate() {
504
+ this.clearMeasurement(), this.layersCreated || this.createMeasureLayers(), this.dispatchEvent(new CustomEvent("webmapx-suppress-busy-for-source", {
505
+ detail: v,
506
+ bubbles: !0,
507
+ composed: !0
508
+ })), this.dispatchEvent(new CustomEvent("webmapx-suppress-busy-for-source", {
509
+ detail: p,
510
+ bubbles: !0,
511
+ composed: !0
512
+ })), this.dispatchEvent(new CustomEvent("webmapx-measure-activate", {
513
+ bubbles: !0,
514
+ composed: !0
515
+ }));
516
+ }
517
+ onDeactivate() {
518
+ this.clearMeasurement(), this.removeMeasureLayers(), this.dispatchEvent(new CustomEvent("webmapx-unsuppress-busy-for-source", {
519
+ detail: v,
520
+ bubbles: !0,
521
+ composed: !0
522
+ })), this.dispatchEvent(new CustomEvent("webmapx-unsuppress-busy-for-source", {
523
+ detail: p,
524
+ bubbles: !0,
525
+ composed: !0
526
+ })), this.dispatchEvent(new CustomEvent("webmapx-measure-deactivate", {
527
+ bubbles: !0,
528
+ composed: !0
529
+ }));
530
+ }
531
+ renderSegments() {
532
+ return this.segments.length === 0 ? f : d`
533
+ <div class="segment-list">
534
+ ${this.segments.map((e, t) => d`
535
+ <div class="segment">
536
+ <span class="segment-label">Segment ${t + 1}</span>
537
+ <span class="segment-value">${a(e.distanceCm)}</span>
538
+ </div>
539
+ `)}
540
+ </div>
541
+ `;
542
+ }
543
+ renderTotal() {
544
+ return this.segments.length === 0 ? f : d`
545
+ <div class="total-row">
546
+ <span>Total</span>
547
+ <span>${a(this.totalDistanceCm)}</span>
548
+ </div>
549
+ `;
550
+ }
551
+ renderArea() {
552
+ return !this.isClosed || this.areaM2 === 0 ? f : d`
553
+ <div class="area-row">
554
+ <span>Area</span>
555
+ <span>${s(this.areaM2)}</span>
556
+ </div>
557
+ `;
558
+ }
559
+ renderInstructions() {
560
+ return this.isFinished ? this.isTouchDevice ? d`<p class="instructions">Measurement finished. Tap Clear to start a new measurement.</p>` : d`<p class="instructions">Measurement finished. Click Clear, or click the map to start a new measurement.</p>` : this.points.length === 0 ? d`<p class="instructions">Click on the map to start measuring.</p>` : this.points.length < 3 ? d`<p class="instructions">Click to add points. Double-click, right-click or ESC to finish.</p>` : d`<p class="instructions">Click near first point to close polygon, or double-click/right-click/ESC to finish.</p>`;
561
+ }
562
+ render() {
563
+ return d`
564
+ <div class="tool-content measure-container">
565
+ <div class="measure-content">
566
+ ${this.renderInstructions()}
567
+ ${this.renderSegments()}
568
+ ${this.renderTotal()}
569
+ ${this.renderArea()}
570
+
571
+ <div class="actions">
572
+ <sl-button size="small" @click=${this.clearMeasurement}>
573
+ <sl-icon name="trash" slot="prefix"></sl-icon>
574
+ Clear
575
+ </sl-button>
576
+ </div>
577
+ </div>
578
+ </div>
579
+ `;
580
+ }
581
+ };
582
+ e([t({
583
+ type: Number,
584
+ attribute: "close-threshold"
585
+ })], b.prototype, "closeThreshold", void 0), e([t({
586
+ type: Number,
587
+ attribute: "finish-threshold"
588
+ })], b.prototype, "finishThreshold", void 0), e([n()], b.prototype, "points", void 0), e([n()], b.prototype, "segments", void 0), e([n()], b.prototype, "totalDistanceCm", void 0), e([n()], b.prototype, "cursorPosition", void 0), e([n()], b.prototype, "isClosed", void 0), e([n()], b.prototype, "areaM2", void 0), e([n()], b.prototype, "finished", void 0), e([n()], b.prototype, "isTouchDevice", void 0), b = e([r("webmapx-measure-tool")], b);
589
+ //#endregion
590
+ export { b as WebmapxMeasureTool };
@@ -0,0 +1,84 @@
1
+ import { r as e, t } from "./decorate-CWgUV1hU.js";
2
+ import { t as n } from "./webmapx-base-tool-Dm9NAWLD.js";
3
+ import { a as r } from "./decorators-B35AgiCU.js";
4
+ //#region src/components/webmapx-modal-tool.ts
5
+ var i = class extends n {
6
+ constructor(...e) {
7
+ super(...e), this.isModal = !0, this._active = !1, this.registerWithToolManager = !0, this.portalContainer = null, this.toolManager = null;
8
+ }
9
+ get active() {
10
+ return this._active;
11
+ }
12
+ set active(e) {
13
+ let t = this._active;
14
+ e !== t && (this._active = e, e ? this.onActivate() : this.onDeactivate(), this.requestUpdate("active", t));
15
+ }
16
+ onMapAttached(t) {
17
+ super.onMapAttached(t);
18
+ let n = e(this);
19
+ this.registerWithToolManager && n?.toolManager && (this.toolManager = n.toolManager, this.toolManager.register(this));
20
+ }
21
+ onMapDetached() {
22
+ this.toolManager &&= (this.toolManager.unregister(this.toolId), null), super.onMapDetached();
23
+ }
24
+ onStateChanged(e) {}
25
+ updated(e) {
26
+ super.updated(e), (e.has("renderTarget") || e.has("active")) && this.updatePortal();
27
+ }
28
+ activate() {
29
+ if (!this._active) {
30
+ if (this.registerWithToolManager && this.toolManager && this.toolManager.activeToolId !== this.toolId) {
31
+ this.toolManager.activate(this.toolId);
32
+ return;
33
+ }
34
+ this.active = !0;
35
+ }
36
+ }
37
+ deactivate() {
38
+ if (this._active) {
39
+ if (this.registerWithToolManager && this.toolManager && this.toolManager.activeToolId === this.toolId) {
40
+ this.toolManager.deactivate(this.toolId);
41
+ return;
42
+ }
43
+ this.active = !1;
44
+ }
45
+ }
46
+ toggle() {
47
+ this.registerWithToolManager && this.toolManager ? this.toolManager.toggle(this.toolId) : this._active ? this.deactivate() : this.activate();
48
+ }
49
+ onActivate() {}
50
+ onDeactivate() {}
51
+ updatePortal() {
52
+ if (!this.renderTarget) {
53
+ this.restoreContent();
54
+ return;
55
+ }
56
+ let e = document.querySelector(this.renderTarget);
57
+ if (!e) {
58
+ console.warn(`[${this.toolId}] Render target "${this.renderTarget}" not found`);
59
+ return;
60
+ }
61
+ if (this.active) {
62
+ let t = this.shadowRoot?.querySelector(".tool-content");
63
+ t && (e.innerHTML = "", e.appendChild(t), this.portalContainer = e);
64
+ } else this.portalContainer && (this.portalContainer.innerHTML = "");
65
+ }
66
+ restoreContent() {
67
+ if (this.portalContainer) {
68
+ let e = this.portalContainer.querySelector(".tool-content");
69
+ e && this.shadowRoot && this.shadowRoot.appendChild(e), this.portalContainer.innerHTML = "", this.portalContainer = null;
70
+ }
71
+ }
72
+ };
73
+ t([r({ type: String })], i.prototype, "label", void 0), t([r({ attribute: !1 })], i.prototype, "icon", void 0), t([r({
74
+ type: Boolean,
75
+ reflect: !0
76
+ })], i.prototype, "active", null), t([r({
77
+ type: String,
78
+ attribute: "render-target"
79
+ })], i.prototype, "renderTarget", void 0), t([r({
80
+ type: Boolean,
81
+ attribute: "register-with-toolmanager"
82
+ })], i.prototype, "registerWithToolManager", void 0);
83
+ //#endregion
84
+ export { i as t };