@element-editor/adapter-maplibre 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +19 -2
- package/README.md +2 -2
- package/dist/adapter-maplibre.css +1 -1
- package/dist/basemaps.cjs +1 -1
- package/dist/basemaps.es.js +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.es.js +687 -687
- package/dist/{style-873tzaoH.cjs → style-Cd_oPEXW.cjs} +1 -1
- package/dist/{style-mSgM9UsZ.js → style-DVShZtJT.js} +1 -1
- package/package.json +9 -5
package/dist/index.es.js
CHANGED
|
@@ -3,11 +3,11 @@ import { jsx as X, jsxs as fe, Fragment as lt } from "react/jsx-runtime";
|
|
|
3
3
|
import { useContext as pt, createContext as Nt, useEffect as K, useState as le, useRef as $, useCallback as ve, useMemo as Bt, memo as ao, useLayoutEffect as uo, forwardRef as In, useImperativeHandle as fo } from "react";
|
|
4
4
|
import { canProcessShape as _t, warnOnce as Rn, DEFAULT_FEATURE_COLOR_ON_DARK as go, createClickRepeatGuard as yo, routingError as po, CLICK_TOOL_MODES as ho, CLICK_SLOP_PX as mo, makeCircleCoords as vo, makeRectCoords as xo, isMultiGeometry as ht, getPartCount as wo, getPartGeometry as At, placeBox as Fn, commitTopoMove as on, vertexEditPatch as So, commitTopoInsert as wt, commitTopoDelete as rn, rdp as bo, withXY as Ve, setPartGeometry as Lo, insertedPosition as sn, transformUpdates as Eo, getMercatorLatCorrectionRatio as Te, unproject as Ot, project as me, offsetGeometry as $t, applyVisualTransform as Po, toRadians as Ke, mapPositions as _n, vertexEditNotice as Co, fitPadding as jt, addPickedFeature as Mo, OSM_PICK_OVERLAY_COLORS as at, unionPieces as ko, tileCandidateResult as Io, OSM_PICK_MIN_ZOOM as Ro, overpassRadiusForZoom as Fo, tileCandidates as _o, normalizeFitBoundsTarget as Ao, visibleCenterOffset as cn, loadErrorCode as ln } from "@element-editor/core/internal";
|
|
5
5
|
import { useAccentPalette as To, useDataStore as he, useUIStore as W, useElementEditorConfig as ke, useGeoStore as Le, useEmit as Ue, useIsEventForEditor as zt, featureLabel as Do, ContextMenu as Ko, VertexSelectionBar as No, FeatureMapContextMenu as Bo, useAccentStyle as Oo, useTheme as An, runGeometryWorkerOperation as $o, MapControllerProvider as jo, EventProvider as zo, useAdapterControls as Ho, useKeyboardShortcuts as Vo, useApplyAccentToRoot as Xo, useReportThemeFromRoot as Yo, preloadEditorPanelsWhenIdle as Go, useSetMapController as Wo, BasemapPicker as Uo } from "@element-editor/ui";
|
|
6
|
-
import { ActiveDrawingToolbar as
|
|
6
|
+
import { ActiveDrawingToolbar as fi, EditingToolbar as gi, ElementEditorUIProvider as yi, FloatingToolbar as pi, GeoStoreProvider as hi, MapControllerProvider as mi, StoreContext as vi, useDataStore as xi, useGeoStore as wi, useKeyboardShortcuts as Si, useMapController as bi, useSetMapController as Li, useUIStore as Ei } from "@element-editor/ui";
|
|
7
7
|
import { useOptionalEmit as Tn, useRouting as Zo, applyRootTokens as qo, useContextMenu as Jo } from "@element-editor/ui/internal";
|
|
8
8
|
import { readAccentPalette as Dn, DEFAULT_FEATURE_COLOR as Kn, fetchRoute as an, getGeometryBBox as Nn, formatLength as mt, formatArea as Ht, fetchOverpassFeatures as Qo, overpassErrorMessage as er, OverpassError as tr, readStorage as nr, writeStorage as or, ElementEditorError as Tt } from "@element-editor/core";
|
|
9
|
-
import { ElementEditorError as
|
|
10
|
-
import De from "maplibre-gl";
|
|
9
|
+
import { ElementEditorError as Ci } from "@element-editor/core";
|
|
10
|
+
import * as De from "maplibre-gl";
|
|
11
11
|
import { Crosshair as rr, Trash as sr } from "@phosphor-icons/react";
|
|
12
12
|
import { createPortal as Ze } from "react-dom";
|
|
13
13
|
import { transformRotate as ir } from "@turf/transform-rotate";
|
|
@@ -227,60 +227,60 @@ function Lr(e) {
|
|
|
227
227
|
}
|
|
228
228
|
const Be = ["elm-features-fill", "elm-features-line", Xt, "elm-features-point"];
|
|
229
229
|
function Er({ map: e }) {
|
|
230
|
-
const t = he((
|
|
230
|
+
const t = he((_) => _.features), n = he((_) => _.groups), o = he((_) => _.selectedIds), r = W((_) => _.editingMode), s = W((_) => _.geometryPreview !== null), i = W((_) => _.bufferCreateNew), l = yr(), u = ke().featureColor, c = vt(), [v, d] = le(() => un(e));
|
|
231
231
|
K(() => {
|
|
232
|
-
const
|
|
233
|
-
return
|
|
234
|
-
e.off("styledata",
|
|
232
|
+
const _ = () => d(un(e));
|
|
233
|
+
return _(), e.on("styledata", _), () => {
|
|
234
|
+
e.off("styledata", _);
|
|
235
235
|
};
|
|
236
236
|
}, [e, c]);
|
|
237
237
|
const g = v ? wr : Hn, w = qe(e, g);
|
|
238
238
|
K(() => {
|
|
239
239
|
Ne(e, g, w);
|
|
240
240
|
}, [c]);
|
|
241
|
-
const
|
|
241
|
+
const C = Tn(), T = $(!1);
|
|
242
242
|
K(() => {
|
|
243
|
-
T.current || e.getGlyphs() || (T.current = !0,
|
|
243
|
+
T.current || e.getGlyphs() || (T.current = !0, C == null || C({
|
|
244
244
|
type: "error",
|
|
245
245
|
code: "unsupported",
|
|
246
246
|
source: "basemap",
|
|
247
247
|
quiet: !0,
|
|
248
248
|
message: 'The map style has no glyphs, so text features are not shown. Use a style whose glyphs serve "Noto Sans Regular".'
|
|
249
249
|
}));
|
|
250
|
-
}, [e, c,
|
|
251
|
-
const
|
|
250
|
+
}, [e, c, C]);
|
|
251
|
+
const k = s && (r === "simplify-shape" || r === "smooth-shape" || r === "buffer-shape" && !i) ? o : null;
|
|
252
252
|
K(() => {
|
|
253
|
-
const
|
|
254
|
-
if (!
|
|
255
|
-
const D = new Set(n.filter((
|
|
253
|
+
const _ = e.getSource(ge);
|
|
254
|
+
if (!_) return;
|
|
255
|
+
const D = new Set(n.filter((M) => M.hidden).map((M) => M.id)), q = k ? new Set(k) : null, p = t.filter((M) => !(M.hidden || M.groupId && D.has(M.groupId) || q != null && q.has(M.id) && _t(M.geometry.type))), f = [];
|
|
256
256
|
let b = !0;
|
|
257
|
-
for (const
|
|
258
|
-
const { _validation:
|
|
259
|
-
if (
|
|
260
|
-
|
|
261
|
-
for (const m of
|
|
257
|
+
for (const M of p) {
|
|
258
|
+
const { _validation: A, ...E } = M, a = l == null ? void 0 : l(M), x = {}, y = (a == null ? void 0 : a.color) ?? u;
|
|
259
|
+
if (y !== void 0 && (x._color = y), a && (a.fillColor !== void 0 && (x._fillColor = a.fillColor), a.opacity !== void 0 && (x._opacity = a.opacity), a.fillOpacity !== void 0 && (x._fillOpacity = a.fillOpacity), a.weight !== void 0 && (x._weight = a.weight)), M.geometry.type === "GeometryCollection") {
|
|
260
|
+
M.geometry.geometries.length > 1 && (b = !1);
|
|
261
|
+
for (const m of M.geometry.geometries)
|
|
262
262
|
f.push({
|
|
263
|
-
...
|
|
263
|
+
...E,
|
|
264
264
|
geometry: m,
|
|
265
|
-
properties: { ...
|
|
265
|
+
properties: { ...E.properties, ...x, id: M.id }
|
|
266
266
|
});
|
|
267
267
|
} else
|
|
268
268
|
f.push({
|
|
269
|
-
...
|
|
270
|
-
properties: { ...
|
|
269
|
+
...E,
|
|
270
|
+
properties: { ...E.properties, ...x, id: M.id }
|
|
271
271
|
});
|
|
272
272
|
}
|
|
273
|
-
|
|
274
|
-
}, [t, n, e,
|
|
275
|
-
const N = $(/* @__PURE__ */ new Set()),
|
|
273
|
+
_.setData({ type: "FeatureCollection", features: f }), fr(e, f, b);
|
|
274
|
+
}, [t, n, e, k, l, u, c]);
|
|
275
|
+
const N = $(/* @__PURE__ */ new Set()), P = $(c);
|
|
276
276
|
return K(() => {
|
|
277
277
|
if (!e.getSource(ge)) return;
|
|
278
|
-
|
|
279
|
-
const
|
|
280
|
-
for (const q of
|
|
278
|
+
P.current !== c && (P.current = c, N.current = /* @__PURE__ */ new Set());
|
|
279
|
+
const _ = N.current, D = new Set(o);
|
|
280
|
+
for (const q of _)
|
|
281
281
|
D.has(q) || e.setFeatureState({ source: ge, id: q }, { selected: !1 });
|
|
282
282
|
for (const q of D)
|
|
283
|
-
|
|
283
|
+
_.has(q) || e.setFeatureState({ source: ge, id: q }, { selected: !0 });
|
|
284
284
|
N.current = D;
|
|
285
285
|
}, [o, e, c]), null;
|
|
286
286
|
}
|
|
@@ -289,76 +289,76 @@ function bt(e, t, n) {
|
|
|
289
289
|
}
|
|
290
290
|
function Vn(e, t, n, o, r = 15, s = /* @__PURE__ */ new Set()) {
|
|
291
291
|
const i = n.project([e, t]), l = i.x, u = i.y;
|
|
292
|
-
let c = 1 / 0, v = null, d = null, g = 1 / 0, w = 0,
|
|
293
|
-
const
|
|
294
|
-
let N = 1 / 0,
|
|
295
|
-
for (const [b,
|
|
296
|
-
const
|
|
297
|
-
|
|
292
|
+
let c = 1 / 0, v = null, d = null, g = 1 / 0, w = 0, C = 0, T = !1, F = null;
|
|
293
|
+
const k = r + 1;
|
|
294
|
+
let N = 1 / 0, P = -1 / 0, _ = 1 / 0, D = -1 / 0;
|
|
295
|
+
for (const [b, M] of [[l - k, u - k], [l + k, u - k], [l - k, u + k], [l + k, u + k]]) {
|
|
296
|
+
const A = n.unproject([b, M]);
|
|
297
|
+
A.lng < N && (N = A.lng), A.lng > P && (P = A.lng), A.lat < _ && (_ = A.lat), A.lat > D && (D = A.lat);
|
|
298
298
|
}
|
|
299
299
|
let q = "";
|
|
300
|
-
function
|
|
300
|
+
function p(b, M = !0) {
|
|
301
301
|
if (!b || b.length === 0) return;
|
|
302
|
-
let
|
|
302
|
+
let A = -1, E = 0, a = 0;
|
|
303
303
|
for (let x = 0; x < b.length; x++) {
|
|
304
|
-
const
|
|
305
|
-
if (!(
|
|
306
|
-
if (
|
|
307
|
-
const
|
|
308
|
-
|
|
304
|
+
const y = b[x];
|
|
305
|
+
if (!(y[0] < N || y[0] > P || y[1] < _ || y[1] > D)) {
|
|
306
|
+
if (A !== x) {
|
|
307
|
+
const R = n.project(y);
|
|
308
|
+
E = R.x, a = R.y, A = x;
|
|
309
309
|
}
|
|
310
|
-
const m = Math.hypot(l -
|
|
311
|
-
m < c && (c = m, v =
|
|
310
|
+
const m = Math.hypot(l - E, u - a);
|
|
311
|
+
m < c && (c = m, v = y, d = q);
|
|
312
312
|
}
|
|
313
|
-
if (
|
|
313
|
+
if (M && x < b.length - 1) {
|
|
314
314
|
const m = b[x + 1];
|
|
315
|
-
if (
|
|
316
|
-
if (
|
|
317
|
-
const
|
|
318
|
-
|
|
315
|
+
if (y[0] < N && m[0] < N || y[0] > P && m[0] > P || y[1] < _ && m[1] < _ || y[1] > D && m[1] > D) continue;
|
|
316
|
+
if (A !== x) {
|
|
317
|
+
const I = n.project(y);
|
|
318
|
+
E = I.x, a = I.y;
|
|
319
319
|
}
|
|
320
|
-
const
|
|
321
|
-
|
|
322
|
-
const B = (
|
|
323
|
-
let V =
|
|
320
|
+
const R = E, S = a, L = n.project(m);
|
|
321
|
+
A = x + 1, E = L.x, a = L.y;
|
|
322
|
+
const B = (R - L.x) ** 2 + (S - L.y) ** 2;
|
|
323
|
+
let V = R, j = S;
|
|
324
324
|
if (B !== 0) {
|
|
325
|
-
let
|
|
326
|
-
|
|
325
|
+
let I = ((l - R) * (L.x - R) + (u - S) * (L.y - S)) / B;
|
|
326
|
+
I = Math.max(0, Math.min(1, I)), V = R + I * (L.x - R), j = S + I * (L.y - S);
|
|
327
327
|
}
|
|
328
328
|
const h = Math.hypot(l - V, u - j);
|
|
329
|
-
h < g && (g = h, w = V,
|
|
329
|
+
h < g && (g = h, w = V, C = j, T = !0, F = q);
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
333
|
function f(b) {
|
|
334
334
|
switch (b.type) {
|
|
335
335
|
case "Point":
|
|
336
|
-
|
|
336
|
+
p([b.coordinates]);
|
|
337
337
|
break;
|
|
338
338
|
case "MultiPoint":
|
|
339
|
-
|
|
339
|
+
p(b.coordinates, !1);
|
|
340
340
|
break;
|
|
341
341
|
case "LineString":
|
|
342
|
-
|
|
342
|
+
p(b.coordinates);
|
|
343
343
|
break;
|
|
344
344
|
case "Polygon":
|
|
345
345
|
case "MultiLineString":
|
|
346
|
-
for (const
|
|
346
|
+
for (const M of b.coordinates) p(M);
|
|
347
347
|
break;
|
|
348
348
|
case "MultiPolygon":
|
|
349
|
-
for (const
|
|
350
|
-
for (const
|
|
349
|
+
for (const M of b.coordinates)
|
|
350
|
+
for (const A of M) p(A);
|
|
351
351
|
break;
|
|
352
352
|
case "GeometryCollection":
|
|
353
|
-
for (const
|
|
353
|
+
for (const M of b.geometries) f(M);
|
|
354
354
|
break;
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
357
|
for (const b of o)
|
|
358
358
|
if (!s.has(b.id)) {
|
|
359
359
|
if (b.bbox) {
|
|
360
|
-
const [
|
|
361
|
-
if (
|
|
360
|
+
const [M, A, E, a] = b.bbox;
|
|
361
|
+
if (E < N || M > P || a < _ || A > D) continue;
|
|
362
362
|
}
|
|
363
363
|
q = b.id, f(b.geometry);
|
|
364
364
|
}
|
|
@@ -369,11 +369,11 @@ function Vn(e, t, n, o, r = 15, s = /* @__PURE__ */ new Set()) {
|
|
|
369
369
|
featureId: d ?? void 0
|
|
370
370
|
};
|
|
371
371
|
if (g <= r && T) {
|
|
372
|
-
const b = n.unproject([w,
|
|
372
|
+
const b = n.unproject([w, C]);
|
|
373
373
|
return {
|
|
374
374
|
lnglat: [b.lng, b.lat],
|
|
375
375
|
isVertex: !1,
|
|
376
|
-
featureId:
|
|
376
|
+
featureId: F ?? void 0
|
|
377
377
|
};
|
|
378
378
|
}
|
|
379
379
|
return null;
|
|
@@ -381,8 +381,8 @@ function Vn(e, t, n, o, r = 15, s = /* @__PURE__ */ new Set()) {
|
|
|
381
381
|
function Dt(e, t, n, o = 15) {
|
|
382
382
|
const r = e.project(t), s = e.project(n), i = s.x - r.x, l = s.y - r.y, u = Math.hypot(i, l);
|
|
383
383
|
if (u < 1) return n;
|
|
384
|
-
const c = Math.atan2(l, i), v = o * Math.PI / 180, d = Math.round(c / v) * v, g = r.x + u * Math.cos(d), w = r.y + u * Math.sin(d),
|
|
385
|
-
return [
|
|
384
|
+
const c = Math.atan2(l, i), v = o * Math.PI / 180, d = Math.round(c / v) * v, g = r.x + u * Math.cos(d), w = r.y + u * Math.sin(d), C = e.unproject([g, w]);
|
|
385
|
+
return [C.lng, C.lat];
|
|
386
386
|
}
|
|
387
387
|
let Kt = !1;
|
|
388
388
|
function Pr() {
|
|
@@ -411,242 +411,242 @@ const Ge = (e) => e !== "none" ? "crosshair" : "", Ir = 3, yn = 5;
|
|
|
411
411
|
function Rr({ map: e, routingApiKey: t }) {
|
|
412
412
|
const { uiStore: n, dataStore: o } = Le(), r = Zo(t), s = ke().network.fetch, i = $(null);
|
|
413
413
|
i.current = r === !1 ? null : { ...r, fetch: s };
|
|
414
|
-
const l = Ue(), u = zt(), c = W((
|
|
414
|
+
const l = Ue(), u = zt(), c = W((p) => p.editingMode), v = W((p) => p.cancelDrawing), d = W((p) => p.routeWaypoints), g = $(d);
|
|
415
415
|
K(() => {
|
|
416
416
|
g.current = d;
|
|
417
417
|
}, [d]);
|
|
418
|
-
const w = $(null),
|
|
419
|
-
async (
|
|
420
|
-
if (!(
|
|
418
|
+
const w = $(null), C = $(null), T = $(null), F = $(!1), k = $(!1), N = $(!1), P = $(null), _ = $(yo()).current, D = $(!1), q = ve(
|
|
419
|
+
async (p) => {
|
|
420
|
+
if (!(p.length < 2)) {
|
|
421
421
|
n.getState().setRoutePreview(null, !0);
|
|
422
422
|
try {
|
|
423
423
|
if (!i.current) throw new Error("routing is off");
|
|
424
|
-
const f = await an(
|
|
424
|
+
const f = await an(p, i.current);
|
|
425
425
|
g.current.length >= 2 && n.getState().setRoutePreview(f, !1);
|
|
426
426
|
} catch (f) {
|
|
427
427
|
const b = po(f);
|
|
428
|
-
l({ type: "error", code: b.code, source: "routing", message: b.message, error: b }), n.getState().setRoutePreview(
|
|
428
|
+
l({ type: "error", code: b.code, source: "routing", message: b.message, error: b }), n.getState().setRoutePreview(p, !1);
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
431
|
},
|
|
432
432
|
[n, l]
|
|
433
433
|
);
|
|
434
434
|
return K(() => {
|
|
435
|
-
const
|
|
435
|
+
const p = e.getCanvas();
|
|
436
436
|
function f() {
|
|
437
|
-
D.current || (D.current = !0, e.dragPan.enable(),
|
|
437
|
+
D.current || (D.current = !0, e.dragPan.enable(), p.style.cursor = "grab");
|
|
438
438
|
}
|
|
439
439
|
function b() {
|
|
440
440
|
if (!D.current) return;
|
|
441
441
|
D.current = !1;
|
|
442
|
-
const
|
|
443
|
-
|
|
442
|
+
const y = n.getState().editingMode;
|
|
443
|
+
p.style.cursor = Ge(y), (y === "draw-rect" || y === "draw-circle" || y === "draw-freehand") && e.dragPan.disable();
|
|
444
444
|
}
|
|
445
|
-
const
|
|
446
|
-
if (
|
|
447
|
-
if (
|
|
448
|
-
const m =
|
|
445
|
+
const M = (y) => {
|
|
446
|
+
if (y.key === "Shift" && (k.current = !0), !!u(y)) {
|
|
447
|
+
if (y.code === "Space") {
|
|
448
|
+
const m = y.target;
|
|
449
449
|
if (m && (m.tagName === "INPUT" || m.tagName === "TEXTAREA" || m.isContentEditable)) return;
|
|
450
|
-
|
|
450
|
+
y.preventDefault(), n.getState().editingMode !== "none" && f();
|
|
451
451
|
return;
|
|
452
452
|
}
|
|
453
|
-
if (
|
|
454
|
-
const { selectedMeasurementId: m, setSelectedMeasurementId:
|
|
453
|
+
if (y.key === "Escape") {
|
|
454
|
+
const { selectedMeasurementId: m, setSelectedMeasurementId: R } = n.getState();
|
|
455
455
|
if (m) {
|
|
456
|
-
|
|
456
|
+
R(null);
|
|
457
457
|
return;
|
|
458
458
|
}
|
|
459
459
|
v();
|
|
460
460
|
return;
|
|
461
461
|
}
|
|
462
|
-
if (
|
|
462
|
+
if (y.key === "Enter") {
|
|
463
463
|
const m = n.getState();
|
|
464
464
|
if (m.editingMode === "measure") {
|
|
465
465
|
m.completeMeasure();
|
|
466
466
|
return;
|
|
467
467
|
}
|
|
468
468
|
}
|
|
469
|
-
if (
|
|
469
|
+
if (y.key === "Backspace" || y.key === "Delete") {
|
|
470
470
|
const m = n.getState();
|
|
471
471
|
if (m.selectedMeasurementId) {
|
|
472
472
|
m.removeMeasurement(m.selectedMeasurementId);
|
|
473
473
|
return;
|
|
474
474
|
}
|
|
475
|
-
const
|
|
476
|
-
if (
|
|
475
|
+
const R = m.editingMode;
|
|
476
|
+
if (R === "measure") {
|
|
477
477
|
m.removeLastMeasurePoint();
|
|
478
478
|
return;
|
|
479
479
|
}
|
|
480
|
-
if (
|
|
480
|
+
if (R === "draw-line" || R === "slice-shape") {
|
|
481
481
|
m.removeLastLineVertex();
|
|
482
482
|
return;
|
|
483
483
|
}
|
|
484
|
-
if (
|
|
484
|
+
if (R === "draw-polygon" || R === "cut-hole") {
|
|
485
485
|
m.removeLastPolygonVertex();
|
|
486
486
|
return;
|
|
487
487
|
}
|
|
488
|
-
if (
|
|
488
|
+
if (R === "draw-route") {
|
|
489
489
|
m.removeLastRouteWaypoint();
|
|
490
490
|
return;
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
|
-
},
|
|
495
|
-
if (
|
|
494
|
+
}, A = (y) => {
|
|
495
|
+
if (y.code === "Space") {
|
|
496
496
|
b();
|
|
497
497
|
return;
|
|
498
498
|
}
|
|
499
|
-
|
|
500
|
-
},
|
|
501
|
-
|
|
499
|
+
y.key === "Shift" && (k.current = !1);
|
|
500
|
+
}, E = () => b(), a = () => {
|
|
501
|
+
p.style.cursor = "grabbing";
|
|
502
502
|
}, x = () => {
|
|
503
|
-
|
|
503
|
+
p.style.cursor = D.current ? "grab" : Ge(n.getState().editingMode);
|
|
504
504
|
};
|
|
505
|
-
return window.addEventListener("keydown",
|
|
506
|
-
window.removeEventListener("keydown",
|
|
505
|
+
return window.addEventListener("keydown", M), window.addEventListener("keyup", A), window.addEventListener("blur", E), e.on("dragstart", a), e.on("dragend", x), () => {
|
|
506
|
+
window.removeEventListener("keydown", M), window.removeEventListener("keyup", A), window.removeEventListener("blur", E), e.off("dragstart", a), e.off("dragend", x);
|
|
507
507
|
};
|
|
508
508
|
}, [v, n, e, u]), K(() => {
|
|
509
509
|
e.getCanvas().style.cursor = Ge(c);
|
|
510
510
|
}, [c, e]), K(() => {
|
|
511
|
-
c === "draw-freehand" ? e.dragPan.disable() : (e.dragPan.enable(),
|
|
511
|
+
c === "draw-freehand" ? e.dragPan.disable() : (e.dragPan.enable(), F.current = !1);
|
|
512
512
|
}, [c, e]), K(() => (c !== "none" ? e.doubleClickZoom.disable() : e.doubleClickZoom.enable(), () => {
|
|
513
513
|
e.doubleClickZoom.enable();
|
|
514
514
|
}), [c, e]), K(() => {
|
|
515
|
-
var
|
|
515
|
+
var A;
|
|
516
516
|
if (!ho.includes(c)) return;
|
|
517
|
-
const
|
|
518
|
-
for (const
|
|
519
|
-
return () =>
|
|
520
|
-
|
|
517
|
+
const p = e, f = (A = p.handlers ?? p._handlerManager) == null ? void 0 : A._handlersById, b = [f == null ? void 0 : f.mapEvent, f == null ? void 0 : f.mousePan].filter((E) => typeof (E == null ? void 0 : E._clickTolerance) == "number"), M = b.map((E) => E._clickTolerance);
|
|
518
|
+
for (const E of b) E._clickTolerance = mo;
|
|
519
|
+
return () => b.forEach((E, a) => {
|
|
520
|
+
E._clickTolerance = M[a];
|
|
521
521
|
});
|
|
522
522
|
}, [c, e]), K(() => (c !== "none" ? e.boxZoom.disable() : e.boxZoom.enable(), () => {
|
|
523
523
|
e.boxZoom.enable();
|
|
524
524
|
}), [c, e]), K(() => () => {
|
|
525
|
-
|
|
525
|
+
C.current && clearTimeout(C.current), T.current && T.current.abort();
|
|
526
526
|
}, []), K(() => {
|
|
527
|
-
const
|
|
528
|
-
if (!
|
|
527
|
+
const p = (a) => a.metaKey || a.ctrlKey || a.altKey, f = (a) => {
|
|
528
|
+
if (!p(a.originalEvent) && !D.current) {
|
|
529
529
|
if (c === "draw-freehand") {
|
|
530
|
-
|
|
530
|
+
F.current = !0, n.getState().clearFreehandPoints(), n.getState().addFreehandPoint([a.lngLat.lng, a.lngLat.lat]);
|
|
531
531
|
return;
|
|
532
532
|
}
|
|
533
533
|
if (c === "draw-rect") {
|
|
534
534
|
e.dragPan.disable(), o.getState().selectedIds.length > 0 && o.setState({ selectedIds: [] });
|
|
535
535
|
const x = n.getState().snappedCoord ?? [a.lngLat.lng, a.lngLat.lat];
|
|
536
|
-
n.getState().setRectCorner(x), N.current = !0,
|
|
536
|
+
n.getState().setRectCorner(x), N.current = !0, P.current = { x: a.point.x, y: a.point.y };
|
|
537
537
|
return;
|
|
538
538
|
}
|
|
539
539
|
if (c === "draw-circle") {
|
|
540
540
|
e.dragPan.disable(), o.getState().selectedIds.length > 0 && o.setState({ selectedIds: [] });
|
|
541
541
|
const x = n.getState().snappedCoord ?? [a.lngLat.lng, a.lngLat.lat];
|
|
542
|
-
n.getState().setCircleCenter(x), N.current = !0,
|
|
542
|
+
n.getState().setCircleCenter(x), N.current = !0, P.current = { x: a.point.x, y: a.point.y };
|
|
543
543
|
return;
|
|
544
544
|
}
|
|
545
545
|
}
|
|
546
546
|
}, b = (a) => {
|
|
547
|
-
if (c === "draw-freehand" &&
|
|
548
|
-
|
|
549
|
-
const
|
|
547
|
+
if (c === "draw-freehand" && F.current) {
|
|
548
|
+
F.current = !1;
|
|
549
|
+
const R = e.getZoom(), S = 156543.03392 * Math.cos(a.lngLat.lat * Math.PI / 180) / Math.pow(2, R), L = Ir * S / 111320;
|
|
550
550
|
n.getState().commitFreehand(L), Lt();
|
|
551
551
|
return;
|
|
552
552
|
}
|
|
553
553
|
if (!N.current) return;
|
|
554
554
|
N.current = !1, e.dragPan.enable();
|
|
555
|
-
const x =
|
|
556
|
-
|
|
555
|
+
const x = P.current, y = x ? Math.hypot(a.point.x - x.x, a.point.y - x.y) : 0;
|
|
556
|
+
P.current = null;
|
|
557
557
|
const m = n.getState();
|
|
558
558
|
if (c === "draw-rect") {
|
|
559
|
-
const
|
|
560
|
-
if (!
|
|
561
|
-
if (
|
|
559
|
+
const R = m.rectCorner;
|
|
560
|
+
if (!R) return;
|
|
561
|
+
if (y < yn) {
|
|
562
562
|
n.setState({ rectCorner: null });
|
|
563
563
|
return;
|
|
564
564
|
}
|
|
565
|
-
const S = m.snappedCoord ?? [a.lngLat.lng, a.lngLat.lat], L =
|
|
566
|
-
m.commitRect(
|
|
565
|
+
const S = m.snappedCoord ?? [a.lngLat.lng, a.lngLat.lat], L = k.current || a.originalEvent.shiftKey;
|
|
566
|
+
m.commitRect(R, S, {}, L), Lt();
|
|
567
567
|
return;
|
|
568
568
|
}
|
|
569
569
|
if (c === "draw-circle") {
|
|
570
|
-
const
|
|
571
|
-
if (!
|
|
570
|
+
const R = m.circleCenter;
|
|
571
|
+
if (!R) return;
|
|
572
572
|
let S;
|
|
573
|
-
if (
|
|
573
|
+
if (y < yn) {
|
|
574
574
|
const V = e.unproject([a.point.x + 25, a.point.y]);
|
|
575
575
|
S = [V.lng, V.lat];
|
|
576
576
|
} else
|
|
577
577
|
S = m.snappedCoord ?? [a.lngLat.lng, a.lngLat.lat];
|
|
578
|
-
const L = S[0] -
|
|
579
|
-
Math.hypot(L, B) >= 1e-6 && (m.commitCircle(
|
|
578
|
+
const L = S[0] - R[0], B = S[1] - R[1];
|
|
579
|
+
Math.hypot(L, B) >= 1e-6 && (m.commitCircle(R, S, {}), Lt());
|
|
580
580
|
return;
|
|
581
581
|
}
|
|
582
|
-
},
|
|
582
|
+
}, M = (a) => {
|
|
583
583
|
const x = n.getState();
|
|
584
|
-
if (c === "draw-freehand" &&
|
|
584
|
+
if (c === "draw-freehand" && F.current) {
|
|
585
585
|
x.addFreehandPoint([a.lngLat.lng, a.lngLat.lat]);
|
|
586
586
|
return;
|
|
587
587
|
}
|
|
588
588
|
if (c === "draw-route" && g.current.length > 0) {
|
|
589
|
-
const
|
|
590
|
-
x.setRouteCursorPos(
|
|
589
|
+
const y = [a.lngLat.lng, a.lngLat.lat];
|
|
590
|
+
x.setRouteCursorPos(y), x.setRouteCursorPreview(null), C.current && clearTimeout(C.current), T.current && T.current.abort();
|
|
591
591
|
const m = g.current[g.current.length - 1];
|
|
592
|
-
|
|
593
|
-
const
|
|
594
|
-
T.current =
|
|
592
|
+
C.current = setTimeout(async () => {
|
|
593
|
+
const R = new AbortController();
|
|
594
|
+
T.current = R;
|
|
595
595
|
try {
|
|
596
596
|
if (!i.current) return;
|
|
597
|
-
const S = await an([m,
|
|
598
|
-
|
|
597
|
+
const S = await an([m, y], { ...i.current, signal: R.signal });
|
|
598
|
+
R.signal.aborted || n.getState().setRouteCursorPreview(S);
|
|
599
599
|
} catch {
|
|
600
600
|
}
|
|
601
601
|
}, 400);
|
|
602
602
|
}
|
|
603
603
|
if ((c === "draw-polygon" || c === "cut-hole") && x.polygonInProgress.length >= 3) {
|
|
604
|
-
const
|
|
605
|
-
e.getCanvas().style.cursor =
|
|
604
|
+
const y = x.polygonInProgress[0], m = e.project(y), R = Math.hypot(a.point.x - m.x, a.point.y - m.y);
|
|
605
|
+
e.getCanvas().style.cursor = R <= 48 ? "pointer" : "crosshair";
|
|
606
606
|
}
|
|
607
|
-
},
|
|
608
|
-
const x =
|
|
609
|
-
if (
|
|
610
|
-
const
|
|
607
|
+
}, A = (a) => {
|
|
608
|
+
const x = _.click(a.originalEvent);
|
|
609
|
+
if (p(a.originalEvent) || kr() || D.current || Gn()) return;
|
|
610
|
+
const y = n.getState();
|
|
611
611
|
if (c === "measure") {
|
|
612
612
|
if (x || Cr()) return;
|
|
613
|
-
|
|
614
|
-
const S =
|
|
615
|
-
|
|
613
|
+
y.selectedMeasurementId && y.setSelectedMeasurementId(null);
|
|
614
|
+
const S = y.snappedCoord ?? [a.lngLat.lng, a.lngLat.lat];
|
|
615
|
+
y.addMeasurePoint(S);
|
|
616
616
|
return;
|
|
617
617
|
}
|
|
618
618
|
["place-point", "draw-line", "draw-polygon", "draw-route", "draw-circle", "draw-rect"].includes(c) && o.getState().selectedIds.length > 0 && o.setState({ selectedIds: [] });
|
|
619
|
-
const
|
|
619
|
+
const R = y.snappedCoord ?? [a.lngLat.lng, a.lngLat.lat];
|
|
620
620
|
if (c === "place-point") {
|
|
621
621
|
if (x) return;
|
|
622
|
-
|
|
622
|
+
y.commitPoint(R);
|
|
623
623
|
return;
|
|
624
624
|
}
|
|
625
625
|
if (c === "draw-line" || c === "draw-polygon" || c === "draw-route" || c === "cut-hole" || c === "slice-shape") {
|
|
626
|
-
let S =
|
|
627
|
-
if (
|
|
628
|
-
const L = c === "draw-line" || c === "slice-shape" ?
|
|
626
|
+
let S = R;
|
|
627
|
+
if (k.current || a.originalEvent.shiftKey) {
|
|
628
|
+
const L = c === "draw-line" || c === "slice-shape" ? y.lineInProgress : y.polygonInProgress;
|
|
629
629
|
L.length >= 1 && (S = Dt(e, L[L.length - 1], S));
|
|
630
630
|
}
|
|
631
|
-
if ((c === "draw-polygon" || c === "cut-hole") &&
|
|
632
|
-
const L =
|
|
631
|
+
if ((c === "draw-polygon" || c === "cut-hole") && y.polygonInProgress.length >= 2) {
|
|
632
|
+
const L = y.polygonInProgress[0], B = e.project(L);
|
|
633
633
|
if (Math.hypot(a.point.x - B.x, a.point.y - B.y) <= 48) {
|
|
634
|
-
c === "draw-polygon" ?
|
|
634
|
+
c === "draw-polygon" ? y.commitPolygon({}) : y.commitCutHole();
|
|
635
635
|
return;
|
|
636
636
|
}
|
|
637
637
|
}
|
|
638
638
|
if (x) return;
|
|
639
|
-
if (c === "draw-line" || c === "slice-shape")
|
|
640
|
-
else if (c === "draw-polygon" || c === "cut-hole")
|
|
639
|
+
if (c === "draw-line" || c === "slice-shape") y.addLineVertex(S);
|
|
640
|
+
else if (c === "draw-polygon" || c === "cut-hole") y.addPolygonVertex(S);
|
|
641
641
|
else if (c === "draw-route") {
|
|
642
|
-
w.current = { waypoints: [...g.current], preview:
|
|
642
|
+
w.current = { waypoints: [...g.current], preview: y.routePreview }, C.current && (clearTimeout(C.current), C.current = null), T.current && (T.current.abort(), T.current = null), y.setRouteCursorPos(null), y.setRouteCursorPreview(null), y.addRouteWaypoint(S);
|
|
643
643
|
const L = [...g.current, S];
|
|
644
644
|
q(L);
|
|
645
645
|
}
|
|
646
646
|
return;
|
|
647
647
|
}
|
|
648
|
-
},
|
|
649
|
-
if (!
|
|
648
|
+
}, E = () => {
|
|
649
|
+
if (!_.isDouble()) return;
|
|
650
650
|
const a = n.getState();
|
|
651
651
|
if (c === "measure") {
|
|
652
652
|
a.completeMeasure();
|
|
@@ -658,8 +658,8 @@ function Rr({ map: e, routingApiKey: t }) {
|
|
|
658
658
|
routeLoading: !1
|
|
659
659
|
}), w.current = null), a.commitRoute());
|
|
660
660
|
};
|
|
661
|
-
return e.on("mousedown", f), e.on("mouseup", b), e.on("mousemove",
|
|
662
|
-
e.off("mousedown", f), e.off("mouseup", b), e.off("mousemove",
|
|
661
|
+
return e.on("mousedown", f), e.on("mouseup", b), e.on("mousemove", M), e.on("click", A), e.on("dblclick", E), () => {
|
|
662
|
+
e.off("mousedown", f), e.off("mouseup", b), e.off("mousemove", M), e.off("click", A), e.off("dblclick", E);
|
|
663
663
|
};
|
|
664
664
|
}, [c, e, q, n, o]), null;
|
|
665
665
|
}
|
|
@@ -751,9 +751,9 @@ function Ar({ map: e }) {
|
|
|
751
751
|
if (g.length === 0) return Fe(e, []);
|
|
752
752
|
let w = v ?? g[g.length - 1];
|
|
753
753
|
l.current && g.length >= 1 && (w = Dt(e, g[g.length - 1], w));
|
|
754
|
-
const
|
|
755
|
-
d.push({ type: "Feature", properties: {}, geometry: { type: "LineString", coordinates:
|
|
756
|
-
d.push({ type: "Feature", properties: { _isFirst:
|
|
754
|
+
const C = [...g, w];
|
|
755
|
+
d.push({ type: "Feature", properties: {}, geometry: { type: "LineString", coordinates: C } }), g.forEach((T, F) => {
|
|
756
|
+
d.push({ type: "Feature", properties: { _isFirst: F === 0 }, geometry: { type: "Point", coordinates: T } });
|
|
757
757
|
});
|
|
758
758
|
}
|
|
759
759
|
if (c.editingMode === "draw-polygon" || c.editingMode === "cut-hole") {
|
|
@@ -761,31 +761,31 @@ function Ar({ map: e }) {
|
|
|
761
761
|
if (g.length === 0) return Fe(e, []);
|
|
762
762
|
let w = v ?? g[g.length - 1];
|
|
763
763
|
l.current && g.length >= 1 && (w = Dt(e, g[g.length - 1], w));
|
|
764
|
-
const
|
|
765
|
-
g.length >= 2 ? d.push({ type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [
|
|
766
|
-
d.push({ type: "Feature", properties: { _isFirst:
|
|
764
|
+
const C = [...g, w, g[0]];
|
|
765
|
+
g.length >= 2 ? d.push({ type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [C] } }) : d.push({ type: "Feature", properties: {}, geometry: { type: "LineString", coordinates: C } }), g.forEach((T, F) => {
|
|
766
|
+
d.push({ type: "Feature", properties: { _isFirst: F === 0 }, geometry: { type: "Point", coordinates: T } });
|
|
767
767
|
});
|
|
768
768
|
}
|
|
769
769
|
if (c.editingMode === "draw-circle") {
|
|
770
770
|
const g = c.circleCenter;
|
|
771
771
|
if (!g) return Fe(e, []);
|
|
772
|
-
const w = v ?? g,
|
|
773
|
-
d.push({ type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [
|
|
772
|
+
const w = v ?? g, C = vo(g, w, s.current, 64);
|
|
773
|
+
d.push({ type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [C] } }), d.push({ type: "Feature", properties: { _isFirst: !0 }, geometry: { type: "Point", coordinates: g } }), d.push({ type: "Feature", properties: {}, geometry: { type: "Point", coordinates: w } });
|
|
774
774
|
}
|
|
775
775
|
if (c.editingMode === "draw-rect") {
|
|
776
776
|
const g = c.rectCorner;
|
|
777
777
|
if (!g) return Fe(e, []);
|
|
778
|
-
const
|
|
779
|
-
d.push({ type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [
|
|
778
|
+
const C = xo(g, v ?? g, s.current, l.current);
|
|
779
|
+
d.push({ type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [C] } });
|
|
780
780
|
}
|
|
781
781
|
if (c.editingMode === "draw-route") {
|
|
782
782
|
const g = c.routeWaypoints;
|
|
783
783
|
if (g.length === 0) return Fe(e, []);
|
|
784
784
|
const w = c.routePreview ?? g;
|
|
785
785
|
w.length >= 2 && d.push({ type: "Feature", properties: {}, geometry: { type: "LineString", coordinates: w } });
|
|
786
|
-
const
|
|
787
|
-
|
|
788
|
-
d.push({ type: "Feature", properties: { _isFirst:
|
|
786
|
+
const C = c.routeCursorPreview ?? (v ? [g[g.length - 1], v] : null);
|
|
787
|
+
C && C.length >= 2 && d.push({ type: "Feature", properties: {}, geometry: { type: "LineString", coordinates: C } }), g.forEach((T, F) => {
|
|
788
|
+
d.push({ type: "Feature", properties: { _isFirst: F === 0 }, geometry: { type: "Point", coordinates: T } });
|
|
789
789
|
});
|
|
790
790
|
}
|
|
791
791
|
if (c.editingMode === "draw-freehand") {
|
|
@@ -888,23 +888,23 @@ function Un({ map: e, coords: t, onSave: n, onClose: o }) {
|
|
|
888
888
|
}), d = $(null);
|
|
889
889
|
K(() => {
|
|
890
890
|
const w = () => {
|
|
891
|
-
const
|
|
892
|
-
v({ x:
|
|
891
|
+
const C = e.project(t);
|
|
892
|
+
v({ x: C.x, y: C.y });
|
|
893
893
|
};
|
|
894
894
|
return e.on("move", w), e.on("zoom", w), e.on("resize", w), () => {
|
|
895
895
|
e.off("move", w), e.off("zoom", w), e.off("resize", w);
|
|
896
896
|
};
|
|
897
897
|
}, [e, t]), K(() => {
|
|
898
|
-
var w,
|
|
899
|
-
(w = d.current) == null || w.focus(), (
|
|
898
|
+
var w, C;
|
|
899
|
+
(w = d.current) == null || w.focus(), (C = d.current) == null || C.select();
|
|
900
900
|
}, []);
|
|
901
901
|
function g() {
|
|
902
|
-
const w = parseFloat(s),
|
|
903
|
-
if (isNaN(w) || isNaN(
|
|
902
|
+
const w = parseFloat(s), C = parseFloat(l);
|
|
903
|
+
if (isNaN(w) || isNaN(C)) {
|
|
904
904
|
r({ type: "warning", message: "Invalid coordinates" });
|
|
905
905
|
return;
|
|
906
906
|
}
|
|
907
|
-
n([w,
|
|
907
|
+
n([w, C]), r({ type: "success", message: "Coordinate updated" }), o();
|
|
908
908
|
}
|
|
909
909
|
return Ze(
|
|
910
910
|
/* @__PURE__ */ X(
|
|
@@ -1140,46 +1140,46 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
|
|
|
1140
1140
|
K(() => {
|
|
1141
1141
|
g.current = v;
|
|
1142
1142
|
}, [v]);
|
|
1143
|
-
const w = $(/* @__PURE__ */ new Map()), [
|
|
1143
|
+
const w = $(/* @__PURE__ */ new Map()), [C, T] = le(null), F = ve(() => T(null), []), [k, N] = le(null);
|
|
1144
1144
|
K(() => {
|
|
1145
1145
|
d(/* @__PURE__ */ new Set()), T(null), N(null);
|
|
1146
1146
|
}, [t.id, u]);
|
|
1147
|
-
const
|
|
1147
|
+
const P = $(n);
|
|
1148
1148
|
K(() => {
|
|
1149
|
-
n !==
|
|
1150
|
-
const
|
|
1151
|
-
for (const O of n)
|
|
1149
|
+
n !== P.current && (P.current = n, !(!n || n.length === 0) && d((h) => {
|
|
1150
|
+
const I = new Set(h);
|
|
1151
|
+
for (const O of n) I.add(`0:${O}`);
|
|
1152
1152
|
for (const O of n) {
|
|
1153
1153
|
const z = w.current.get(`0:${O}`);
|
|
1154
1154
|
z && Ct(z, !0);
|
|
1155
1155
|
}
|
|
1156
|
-
return
|
|
1156
|
+
return I;
|
|
1157
1157
|
}));
|
|
1158
1158
|
}, [n]);
|
|
1159
|
-
function
|
|
1159
|
+
function _(h) {
|
|
1160
1160
|
Vt(e, /* @__PURE__ */ new Map([[t.id, h]]));
|
|
1161
1161
|
}
|
|
1162
1162
|
function D(h) {
|
|
1163
|
-
const
|
|
1164
|
-
o.getState().updateFeature(t.id, So(t,
|
|
1163
|
+
const I = nt(t.geometry, u, h);
|
|
1164
|
+
o.getState().updateFeature(t.id, So(t, I));
|
|
1165
1165
|
}
|
|
1166
1166
|
const q = $(!1);
|
|
1167
1167
|
K(() => {
|
|
1168
|
-
const h = (
|
|
1169
|
-
q.current =
|
|
1168
|
+
const h = (I) => {
|
|
1169
|
+
q.current = I.metaKey || I.ctrlKey;
|
|
1170
1170
|
};
|
|
1171
1171
|
return window.addEventListener("keydown", h), window.addEventListener("keyup", h), () => {
|
|
1172
1172
|
window.removeEventListener("keydown", h), window.removeEventListener("keyup", h);
|
|
1173
1173
|
};
|
|
1174
1174
|
}, []);
|
|
1175
|
-
function
|
|
1176
|
-
Br(), c.current.forEach((z) => z.remove()), c.current = [], w.current = /* @__PURE__ */ new Map(), f.current = [], b.current = null,
|
|
1175
|
+
function p() {
|
|
1176
|
+
Br(), c.current.forEach((z) => z.remove()), c.current = [], w.current = /* @__PURE__ */ new Map(), f.current = [], b.current = null, M.current = !1;
|
|
1177
1177
|
const h = Oe(t.geometry, u);
|
|
1178
1178
|
if (!h) return;
|
|
1179
|
-
const
|
|
1180
|
-
|
|
1179
|
+
const I = ot(h), O = g.current;
|
|
1180
|
+
E.current = !1, I.forEach((z, G) => {
|
|
1181
1181
|
const H = h.type === "Polygon" ? z.slice(0, -1) : z, te = Sn(e, H, (Z) => O.has(`${G}:${Z}`));
|
|
1182
|
-
te.capped && (
|
|
1182
|
+
te.capped && (E.current = !0);
|
|
1183
1183
|
for (const Z of te.indices) {
|
|
1184
1184
|
const ne = H[Z], se = `${G}:${Z}`, ie = xn(O.has(se));
|
|
1185
1185
|
w.current.set(se, ie);
|
|
@@ -1197,13 +1197,13 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
|
|
|
1197
1197
|
return Q && Ct(Q, oe.has(se)), oe;
|
|
1198
1198
|
}) : (d(/* @__PURE__ */ new Set([se])), w.current.forEach((ee, oe) => Ct(ee, oe === se)));
|
|
1199
1199
|
}), re.on("dragstart", () => {
|
|
1200
|
-
J = !0,
|
|
1200
|
+
J = !0, M.current = !0, o.getState().takeSnapshot(), document.querySelectorAll(".elm-midpoint-marker").forEach((Y) => {
|
|
1201
1201
|
Y.style.display = "none";
|
|
1202
1202
|
}), Ce(!0);
|
|
1203
1203
|
});
|
|
1204
1204
|
const ce = [ne[0], ne[1]], U = ze(() => {
|
|
1205
1205
|
const Y = re.getLngLat(), ee = [Y.lng, Y.lat], oe = Mt(h, G, Z, ee);
|
|
1206
|
-
|
|
1206
|
+
_(nt(t.geometry, u, oe));
|
|
1207
1207
|
});
|
|
1208
1208
|
re.on("drag", () => U.schedule()), re.on("dragend", () => {
|
|
1209
1209
|
U.cancel();
|
|
@@ -1217,7 +1217,7 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
|
|
|
1217
1217
|
ee
|
|
1218
1218
|
));
|
|
1219
1219
|
}
|
|
1220
|
-
Ce(!1),
|
|
1220
|
+
Ce(!1), M.current = !1, setTimeout(() => {
|
|
1221
1221
|
J = !1;
|
|
1222
1222
|
}, 50);
|
|
1223
1223
|
}), ie.addEventListener("contextmenu", (Y) => {
|
|
@@ -1228,18 +1228,18 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
|
|
|
1228
1228
|
const Z = h.type === "Polygon" ? H.length : H.length - 1, ne = [];
|
|
1229
1229
|
for (let ie = 0; ie < Z; ie++) ne.push(Or(H[ie], H[(ie + 1) % H.length]));
|
|
1230
1230
|
const se = Sn(e, ne, () => !1);
|
|
1231
|
-
se.capped && (
|
|
1231
|
+
se.capped && (E.current = !0);
|
|
1232
1232
|
for (const ie of se.indices) {
|
|
1233
1233
|
const re = H[ie], J = H[(ie + 1) % H.length], ce = ne[ie], U = xn(!1, !0);
|
|
1234
1234
|
U.style.display = "none", f.current.push({ el: U, a: re, b: J });
|
|
1235
1235
|
const Y = new De.Marker({ element: U, draggable: !0 }).setLngLat(ce).addTo(e);
|
|
1236
1236
|
let ee = !1;
|
|
1237
1237
|
Y.on("dragstart", () => {
|
|
1238
|
-
ee = !0,
|
|
1238
|
+
ee = !0, M.current = !0, o.getState().takeSnapshot(), Ce(!0);
|
|
1239
1239
|
});
|
|
1240
1240
|
const oe = ze(() => {
|
|
1241
1241
|
const Q = Y.getLngLat(), de = [Q.lng, Q.lat], ue = He(h, G, ie + 1, de);
|
|
1242
|
-
|
|
1242
|
+
_(nt(t.geometry, u, ue));
|
|
1243
1243
|
});
|
|
1244
1244
|
Y.on("drag", () => oe.schedule()), Y.on("dragend", () => {
|
|
1245
1245
|
oe.cancel();
|
|
@@ -1256,7 +1256,7 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
|
|
|
1256
1256
|
}
|
|
1257
1257
|
setTimeout(() => {
|
|
1258
1258
|
ee = !1;
|
|
1259
|
-
}, 50), Ce(!1),
|
|
1259
|
+
}, 50), Ce(!1), M.current = !1;
|
|
1260
1260
|
}), U.addEventListener("click", (Q) => {
|
|
1261
1261
|
if (Q.stopPropagation(), ee) {
|
|
1262
1262
|
ee = !1;
|
|
@@ -1279,14 +1279,14 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
|
|
|
1279
1279
|
}
|
|
1280
1280
|
});
|
|
1281
1281
|
}
|
|
1282
|
-
const f = $([]), b = $(null),
|
|
1282
|
+
const f = $([]), b = $(null), M = $(!1);
|
|
1283
1283
|
K(() => {
|
|
1284
1284
|
const h = (z) => {
|
|
1285
1285
|
if (z === b.current) return;
|
|
1286
1286
|
const G = f.current;
|
|
1287
1287
|
b.current !== null && G[b.current] && (G[b.current].el.style.display = "none"), z !== null && (G[z].el.style.display = "flex"), b.current = z;
|
|
1288
|
-
},
|
|
1289
|
-
if (
|
|
1288
|
+
}, I = (z) => {
|
|
1289
|
+
if (M.current) return;
|
|
1290
1290
|
const { x: G, y: H } = z.point;
|
|
1291
1291
|
let te = -1, Z = 1 / 0;
|
|
1292
1292
|
f.current.forEach(({ a: se, b: ie }, re) => {
|
|
@@ -1297,18 +1297,18 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
|
|
|
1297
1297
|
h(te >= 0 && Z <= ne * ne ? te : null);
|
|
1298
1298
|
}, O = (z) => {
|
|
1299
1299
|
const G = z.originalEvent.relatedTarget;
|
|
1300
|
-
!
|
|
1300
|
+
!M.current && !(G instanceof Node && e.getContainer().contains(G)) && h(null);
|
|
1301
1301
|
};
|
|
1302
|
-
return e.on("mousemove",
|
|
1303
|
-
e.off("mousemove",
|
|
1302
|
+
return e.on("mousemove", I), e.on("mouseout", O), () => {
|
|
1303
|
+
e.off("mousemove", I), e.off("mouseout", O);
|
|
1304
1304
|
};
|
|
1305
1305
|
}, [e]);
|
|
1306
|
-
const
|
|
1306
|
+
const A = $(() => {
|
|
1307
1307
|
});
|
|
1308
|
-
|
|
1308
|
+
A.current = (h) => {
|
|
1309
1309
|
var ee, oe;
|
|
1310
|
-
const
|
|
1311
|
-
if (
|
|
1310
|
+
const I = h.originalEvent;
|
|
1311
|
+
if (M.current || I.button !== 0 || I.shiftKey || (oe = (ee = I.target) == null ? void 0 : ee.closest) != null && oe.call(ee, ".maplibregl-marker")) return;
|
|
1312
1312
|
const O = Oe(t.geometry, u);
|
|
1313
1313
|
if (!O || O.type !== "Polygon" && O.type !== "LineString") return;
|
|
1314
1314
|
const z = O.type === "Polygon";
|
|
@@ -1327,11 +1327,11 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
|
|
|
1327
1327
|
const ie = h.point;
|
|
1328
1328
|
let re = [h.lngLat.lng, h.lngLat.lat], J = !1;
|
|
1329
1329
|
const ce = ze(() => {
|
|
1330
|
-
|
|
1330
|
+
_(nt(t.geometry, u, He(O, te, Z + 1, re)));
|
|
1331
1331
|
}), U = (Q) => {
|
|
1332
1332
|
if (!J) {
|
|
1333
1333
|
if (Math.hypot(Q.point.x - ie.x, Q.point.y - ie.y) < 3) return;
|
|
1334
|
-
J = !0,
|
|
1334
|
+
J = !0, M.current = !0, o.getState().takeSnapshot(), document.querySelectorAll(".elm-midpoint-marker").forEach((ue) => {
|
|
1335
1335
|
ue.style.display = "none";
|
|
1336
1336
|
}), b.current = null, Ce(!0);
|
|
1337
1337
|
}
|
|
@@ -1348,53 +1348,53 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
|
|
|
1348
1348
|
const Q = o.getState();
|
|
1349
1349
|
Q.updateFeatures(wt(Q.features, t.id, ne, se, re));
|
|
1350
1350
|
}
|
|
1351
|
-
Ce(!1),
|
|
1351
|
+
Ce(!1), M.current = !1;
|
|
1352
1352
|
}
|
|
1353
1353
|
};
|
|
1354
1354
|
e.on("mousemove", U), window.addEventListener("mouseup", Y);
|
|
1355
1355
|
}, K(() => {
|
|
1356
|
-
const h = (
|
|
1356
|
+
const h = (I) => A.current(I);
|
|
1357
1357
|
return e.on("mousedown", h), () => {
|
|
1358
1358
|
e.off("mousedown", h);
|
|
1359
1359
|
};
|
|
1360
1360
|
}, [e]);
|
|
1361
|
-
const
|
|
1362
|
-
a.current =
|
|
1361
|
+
const E = $(!1), a = $(p);
|
|
1362
|
+
a.current = p, K(() => {
|
|
1363
1363
|
const h = () => {
|
|
1364
|
-
|
|
1364
|
+
E.current && a.current();
|
|
1365
1365
|
};
|
|
1366
1366
|
return e.on("moveend", h), () => {
|
|
1367
1367
|
e.off("moveend", h);
|
|
1368
1368
|
};
|
|
1369
|
-
}, [e]), K(() => (
|
|
1369
|
+
}, [e]), K(() => (p(), () => {
|
|
1370
1370
|
c.current.forEach((h) => h.remove()), c.current = [], w.current = /* @__PURE__ */ new Map();
|
|
1371
1371
|
}), [t, e, l, u]);
|
|
1372
|
-
function x(h,
|
|
1372
|
+
function x(h, I) {
|
|
1373
1373
|
const O = Oe(t.geometry, u);
|
|
1374
1374
|
if (!O) return;
|
|
1375
|
-
const z = jr(O, h,
|
|
1375
|
+
const z = jr(O, h, I);
|
|
1376
1376
|
if (!z) {
|
|
1377
1377
|
s({ type: "warning", message: `Cannot delete: ${O.type === "Polygon" ? "an area needs at least 3" : O.type === "LineString" ? "a line needs at least 2" : "at least 1"} points` });
|
|
1378
1378
|
return;
|
|
1379
1379
|
}
|
|
1380
|
-
const G = ot(O)[h][
|
|
1380
|
+
const G = ot(O)[h][I];
|
|
1381
1381
|
if (o.getState().takeSnapshot(), D(z), d(/* @__PURE__ */ new Set()), O.type === "Polygon" && r.getState().topoEditEnabled) {
|
|
1382
1382
|
const H = o.getState();
|
|
1383
1383
|
H.updateFeatures(rn(H.features, t.id, [G]));
|
|
1384
1384
|
}
|
|
1385
1385
|
}
|
|
1386
|
-
function
|
|
1386
|
+
function y() {
|
|
1387
1387
|
const h = g.current;
|
|
1388
1388
|
if (h.size === 0) return;
|
|
1389
|
-
const
|
|
1390
|
-
if (!
|
|
1389
|
+
const I = Oe(t.geometry, u);
|
|
1390
|
+
if (!I) return;
|
|
1391
1391
|
const O = /* @__PURE__ */ new Map();
|
|
1392
1392
|
for (const z of h) {
|
|
1393
1393
|
const [G, H] = z.split(":"), te = Number(G), Z = Number(H), ne = O.get(te) ?? [];
|
|
1394
1394
|
ne.push(Z), O.set(te, ne);
|
|
1395
1395
|
}
|
|
1396
|
-
if (
|
|
1397
|
-
const z =
|
|
1396
|
+
if (I.type === "LineString") {
|
|
1397
|
+
const z = I.coordinates, G = new Set(O.get(0) ?? []), H = z.filter((te, Z) => !G.has(Z));
|
|
1398
1398
|
if (H.length < 2) {
|
|
1399
1399
|
s({ type: "warning", message: "Cannot delete: a line needs at least 2 points" });
|
|
1400
1400
|
return;
|
|
@@ -1402,8 +1402,8 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
|
|
|
1402
1402
|
o.getState().takeSnapshot(), D({ type: "LineString", coordinates: H }), d(/* @__PURE__ */ new Set());
|
|
1403
1403
|
return;
|
|
1404
1404
|
}
|
|
1405
|
-
if (
|
|
1406
|
-
const z =
|
|
1405
|
+
if (I.type === "MultiPoint") {
|
|
1406
|
+
const z = I.coordinates, G = new Set(O.get(0) ?? []), H = z.filter((te, Z) => !G.has(Z));
|
|
1407
1407
|
if (H.length < 1) {
|
|
1408
1408
|
s({ type: "warning", message: "Cannot delete: at least 1 point required" });
|
|
1409
1409
|
return;
|
|
@@ -1411,8 +1411,8 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
|
|
|
1411
1411
|
o.getState().takeSnapshot(), D({ type: "MultiPoint", coordinates: H }), d(/* @__PURE__ */ new Set());
|
|
1412
1412
|
return;
|
|
1413
1413
|
}
|
|
1414
|
-
if (
|
|
1415
|
-
const z =
|
|
1414
|
+
if (I.type === "Polygon") {
|
|
1415
|
+
const z = I.coordinates, G = [];
|
|
1416
1416
|
for (let H = 0; H < z.length; H++) {
|
|
1417
1417
|
const te = z[H], Z = te.slice(0, -1), ne = new Set(O.get(H) ?? []);
|
|
1418
1418
|
if (ne.size === 0) {
|
|
@@ -1440,16 +1440,16 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
|
|
|
1440
1440
|
}
|
|
1441
1441
|
const h = Oe(t.geometry, u);
|
|
1442
1442
|
if (!h || h.type !== "LineString" && h.type !== "Polygon") return;
|
|
1443
|
-
const
|
|
1443
|
+
const I = /* @__PURE__ */ new Map();
|
|
1444
1444
|
for (const U of g.current) {
|
|
1445
|
-
const [Y, ee] = U.split(":"), oe = Number(Y), Q = Number(ee), de =
|
|
1446
|
-
de.push(Q),
|
|
1445
|
+
const [Y, ee] = U.split(":"), oe = Number(Y), Q = Number(ee), de = I.get(oe) ?? [];
|
|
1446
|
+
de.push(Q), I.set(oe, de);
|
|
1447
1447
|
}
|
|
1448
|
-
if (
|
|
1448
|
+
if (I.size !== 1) {
|
|
1449
1449
|
s({ type: "warning", message: "Selection must stay within one ring/line to simplify" });
|
|
1450
1450
|
return;
|
|
1451
1451
|
}
|
|
1452
|
-
const [O, z] = Array.from(
|
|
1452
|
+
const [O, z] = Array.from(I.entries())[0], G = z.sort((U, Y) => U - Y), H = G[0], te = G[G.length - 1], Z = h.type === "Polygon", ne = Z ? h.coordinates[O].slice(0, -1) : h.coordinates, se = ne.slice(H, te + 1), ie = bo(se, 1e-5), re = se.length - ie.length;
|
|
1453
1453
|
if (re === 0) {
|
|
1454
1454
|
s({ type: "warning", message: "Nothing to remove: no selected point sits on a straight line" });
|
|
1455
1455
|
return;
|
|
@@ -1470,57 +1470,57 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
|
|
|
1470
1470
|
}
|
|
1471
1471
|
K(() => {
|
|
1472
1472
|
if (v.size === 0) return;
|
|
1473
|
-
function h(
|
|
1474
|
-
if (
|
|
1475
|
-
const O =
|
|
1476
|
-
O && (O.tagName === "INPUT" || O.tagName === "TEXTAREA" || O.isContentEditable) || i(
|
|
1473
|
+
function h(I) {
|
|
1474
|
+
if (I.key !== "Delete" && I.key !== "Backspace") return;
|
|
1475
|
+
const O = I.target;
|
|
1476
|
+
O && (O.tagName === "INPUT" || O.tagName === "TEXTAREA" || O.isContentEditable) || i(I) && (I.preventDefault(), I.stopPropagation(), y());
|
|
1477
1477
|
}
|
|
1478
1478
|
return window.addEventListener("keydown", h, { capture: !0 }), () => window.removeEventListener("keydown", h, { capture: !0 });
|
|
1479
1479
|
}, [v]);
|
|
1480
|
-
const
|
|
1481
|
-
const h = `${
|
|
1480
|
+
const R = v.size > 0, S = C && (() => {
|
|
1481
|
+
const h = `${C.ringIdx}:${C.vertIdx}`, I = v.has(h) && v.size > 1;
|
|
1482
1482
|
return /* @__PURE__ */ X(
|
|
1483
1483
|
Ko,
|
|
1484
1484
|
{
|
|
1485
|
-
x:
|
|
1486
|
-
y:
|
|
1487
|
-
onClose:
|
|
1485
|
+
x: C.x,
|
|
1486
|
+
y: C.y,
|
|
1487
|
+
onClose: F,
|
|
1488
1488
|
items: [
|
|
1489
|
-
{ label: "Edit coordinates…", icon: /* @__PURE__ */ X(rr, { size: 16 }), onClick: () => N({ ringIdx:
|
|
1489
|
+
{ label: "Edit coordinates…", icon: /* @__PURE__ */ X(rr, { size: 16 }), onClick: () => N({ ringIdx: C.ringIdx, vertIdx: C.vertIdx }) },
|
|
1490
1490
|
{ separator: !0 },
|
|
1491
1491
|
{
|
|
1492
|
-
label:
|
|
1492
|
+
label: I ? `Delete ${v.size} points` : "Delete point",
|
|
1493
1493
|
icon: /* @__PURE__ */ X(sr, { size: 16 }),
|
|
1494
|
-
onClick: () =>
|
|
1494
|
+
onClick: () => I ? y() : x(C.ringIdx, C.vertIdx)
|
|
1495
1495
|
}
|
|
1496
1496
|
]
|
|
1497
1497
|
}
|
|
1498
1498
|
);
|
|
1499
|
-
})(), L =
|
|
1499
|
+
})(), L = k && Oe(t.geometry, u), B = L && k ? (j = ot(L)[k.ringIdx]) == null ? void 0 : j[k.vertIdx] : void 0, V = k && L && B && /* @__PURE__ */ X(
|
|
1500
1500
|
Un,
|
|
1501
1501
|
{
|
|
1502
1502
|
map: e,
|
|
1503
1503
|
coords: B,
|
|
1504
1504
|
onSave: (h) => {
|
|
1505
|
-
if (o.getState().takeSnapshot(), D(Mt(L,
|
|
1506
|
-
const
|
|
1507
|
-
|
|
1505
|
+
if (o.getState().takeSnapshot(), D(Mt(L, k.ringIdx, k.vertIdx, h)), L.type === "Polygon" && r.getState().topoEditEnabled) {
|
|
1506
|
+
const I = o.getState();
|
|
1507
|
+
I.updateFeatures(on(I.features, t.id, B, h));
|
|
1508
1508
|
}
|
|
1509
1509
|
},
|
|
1510
1510
|
onClose: () => N(null)
|
|
1511
1511
|
},
|
|
1512
|
-
`${
|
|
1512
|
+
`${k.ringIdx}:${k.vertIdx}`
|
|
1513
1513
|
);
|
|
1514
1514
|
return /* @__PURE__ */ fe(lt, { children: [
|
|
1515
1515
|
S,
|
|
1516
1516
|
V,
|
|
1517
|
-
|
|
1517
|
+
R && /* @__PURE__ */ X(
|
|
1518
1518
|
No,
|
|
1519
1519
|
{
|
|
1520
1520
|
mapContainer: e.getContainer(),
|
|
1521
1521
|
count: v.size,
|
|
1522
1522
|
onSimplify: m,
|
|
1523
|
-
onDelete:
|
|
1523
|
+
onDelete: y
|
|
1524
1524
|
}
|
|
1525
1525
|
)
|
|
1526
1526
|
] });
|
|
@@ -1625,30 +1625,30 @@ function kt(e, t, n) {
|
|
|
1625
1625
|
function Yr(e, t, n, o, r) {
|
|
1626
1626
|
const [s, i] = t, l = Ke(r), u = Math.cos(l), c = Math.sin(l), v = Te(i);
|
|
1627
1627
|
return e.map(([d, g]) => {
|
|
1628
|
-
const w = (d - s) * v,
|
|
1629
|
-
return [s +
|
|
1628
|
+
const w = (d - s) * v, C = g - i, T = w * u + C * c, F = -w * c + C * u, k = T * n, N = F * o, P = k * u - N * c, _ = k * c + N * u;
|
|
1629
|
+
return [s + P / v, i + _];
|
|
1630
1630
|
});
|
|
1631
1631
|
}
|
|
1632
1632
|
function Gr(e, t, n, o) {
|
|
1633
1633
|
const r = me(t), s = Ke(o), i = Math.cos(s), l = Math.sin(s);
|
|
1634
1634
|
function u(c) {
|
|
1635
|
-
const v = me(c), d = v[0] - r[0], g = v[1] - r[1], w = d * i + g * l,
|
|
1636
|
-
return Ot([r[0] +
|
|
1635
|
+
const v = me(c), d = v[0] - r[0], g = v[1] - r[1], w = d * i + g * l, C = -d * l + g * i, T = w * n, F = C * n, k = T * i - F * l, N = T * l + F * i;
|
|
1636
|
+
return Ot([r[0] + k, r[1] + N]);
|
|
1637
1637
|
}
|
|
1638
1638
|
return { ...e, geometry: _n(e.geometry, u) };
|
|
1639
1639
|
}
|
|
1640
1640
|
function Wr(e, t, n, o) {
|
|
1641
1641
|
const r = me(t), s = Ke(o), i = Math.cos(s), l = Math.sin(s);
|
|
1642
1642
|
return e.map((u) => {
|
|
1643
|
-
const c = me(u), v = c[0] - r[0], d = c[1] - r[1], g = v * i + d * l, w = -v * l + d * i,
|
|
1644
|
-
return Ot([r[0] +
|
|
1643
|
+
const c = me(u), v = c[0] - r[0], d = c[1] - r[1], g = v * i + d * l, w = -v * l + d * i, C = g * n, T = w * n, F = C * i - T * l, k = C * l + T * i;
|
|
1644
|
+
return Ot([r[0] + F, r[1] + k]);
|
|
1645
1645
|
});
|
|
1646
1646
|
}
|
|
1647
1647
|
function Ur(e, t, n, o, r) {
|
|
1648
1648
|
const [s, i] = t, l = Ke(r), u = Math.cos(l), c = Math.sin(l), v = Te(i);
|
|
1649
1649
|
function d(g) {
|
|
1650
|
-
const w = (g[0] - s) * v,
|
|
1651
|
-
return [s +
|
|
1650
|
+
const w = (g[0] - s) * v, C = g[1] - i, T = w * u + C * c, F = -w * c + C * u, k = T * n, N = F * o, P = k * u - N * c, _ = k * c + N * u;
|
|
1651
|
+
return [s + P / v, i + _];
|
|
1652
1652
|
}
|
|
1653
1653
|
return { ...e, geometry: _n(e.geometry, d) };
|
|
1654
1654
|
}
|
|
@@ -1659,34 +1659,34 @@ function qr(e, t, n, o) {
|
|
|
1659
1659
|
const r = o ? e.initialBbox.center : e.origin, s = Math.cos(Ke(e.rotationAngle)), i = Math.sin(Ke(e.rotationAngle));
|
|
1660
1660
|
let l;
|
|
1661
1661
|
if (n) {
|
|
1662
|
-
const
|
|
1663
|
-
l = (
|
|
1664
|
-
const N = me(
|
|
1665
|
-
return [
|
|
1662
|
+
const F = me(r);
|
|
1663
|
+
l = (k) => {
|
|
1664
|
+
const N = me(k), P = N[0] - F[0], _ = N[1] - F[1];
|
|
1665
|
+
return [P * s + _ * i, -P * i + _ * s];
|
|
1666
1666
|
};
|
|
1667
1667
|
} else {
|
|
1668
|
-
const
|
|
1669
|
-
l = (
|
|
1670
|
-
const N = (
|
|
1671
|
-
return [N * s +
|
|
1668
|
+
const F = Te(r[1]);
|
|
1669
|
+
l = (k) => {
|
|
1670
|
+
const N = (k[0] - r[0]) * F, P = k[1] - r[1];
|
|
1671
|
+
return [N * s + P * i, -N * i + P * s];
|
|
1672
1672
|
};
|
|
1673
1673
|
}
|
|
1674
|
-
const [u, c] = l(e.startLngLat), [v, d] = l(t), g = e.edgeIndex === 0 || e.edgeIndex === 2, w = e.edgeIndex === 1 || e.edgeIndex === 3,
|
|
1674
|
+
const [u, c] = l(e.startLngLat), [v, d] = l(t), g = e.edgeIndex === 0 || e.edgeIndex === 2, w = e.edgeIndex === 1 || e.edgeIndex === 3, C = (F) => Math.abs(F) < 0.01 ? F < 0 ? -0.01 : 0.01 : F, T = (F, k) => Math.abs(k) > 1e-9 ? F / k : 1;
|
|
1675
1675
|
if (n) {
|
|
1676
|
-
let
|
|
1677
|
-
if (g)
|
|
1678
|
-
else if (w)
|
|
1676
|
+
let F;
|
|
1677
|
+
if (g) F = T(d, c);
|
|
1678
|
+
else if (w) F = T(v, u);
|
|
1679
1679
|
else {
|
|
1680
|
-
const
|
|
1681
|
-
|
|
1680
|
+
const k = u * u + c * c;
|
|
1681
|
+
F = k > 1e-18 ? (v * u + d * c) / k : 1;
|
|
1682
1682
|
}
|
|
1683
|
-
return { origin: r, uniform: !0, factor:
|
|
1683
|
+
return { origin: r, uniform: !0, factor: C(F) };
|
|
1684
1684
|
}
|
|
1685
1685
|
return {
|
|
1686
1686
|
origin: r,
|
|
1687
1687
|
uniform: !1,
|
|
1688
|
-
scaleX: w || !g ?
|
|
1689
|
-
scaleY: g || !w ?
|
|
1688
|
+
scaleX: w || !g ? C(T(v, u)) : 1,
|
|
1689
|
+
scaleY: g || !w ? C(T(d, c)) : 1
|
|
1690
1690
|
};
|
|
1691
1691
|
}
|
|
1692
1692
|
function Jr(e, t, n, o) {
|
|
@@ -1748,7 +1748,7 @@ function It(e) {
|
|
|
1748
1748
|
].join(";"), t;
|
|
1749
1749
|
}
|
|
1750
1750
|
function es({ map: e, features: t }) {
|
|
1751
|
-
const { dataStore: n, uiStore: o } = Le(), r = he((
|
|
1751
|
+
const { dataStore: n, uiStore: o } = Le(), r = he((p) => p.selectedIds), s = W((p) => p.transformActive), i = W((p) => p.setTransformDragging), l = $(t);
|
|
1752
1752
|
l.current = t;
|
|
1753
1753
|
const [u, c] = le(null), v = $(null);
|
|
1754
1754
|
v.current = u;
|
|
@@ -1756,75 +1756,75 @@ function es({ map: e, features: t }) {
|
|
|
1756
1756
|
K(() => {
|
|
1757
1757
|
c(null), d.current = 0;
|
|
1758
1758
|
}, [g]);
|
|
1759
|
-
const w = $(null),
|
|
1760
|
-
function
|
|
1761
|
-
T.current.forEach((
|
|
1759
|
+
const w = $(null), C = $(null), T = $([]);
|
|
1760
|
+
function F() {
|
|
1761
|
+
T.current.forEach((p) => p.remove()), T.current = [];
|
|
1762
1762
|
}
|
|
1763
|
-
function
|
|
1763
|
+
function k(p) {
|
|
1764
1764
|
const f = /* @__PURE__ */ new Map();
|
|
1765
|
-
for (const b of
|
|
1765
|
+
for (const b of p) f.set(String(b.id ?? ""), b.geometry);
|
|
1766
1766
|
Vt(e, f);
|
|
1767
1767
|
}
|
|
1768
|
-
function N(
|
|
1768
|
+
function N(p) {
|
|
1769
1769
|
const f = T.current;
|
|
1770
1770
|
if (f.length === 9) {
|
|
1771
|
-
for (let b = 0; b < 4; b++) f[b].setLngLat(
|
|
1772
|
-
for (let b = 0; b < 4; b++) f[4 + b].setLngLat(
|
|
1773
|
-
f[8].setLngLat(
|
|
1771
|
+
for (let b = 0; b < 4; b++) f[b].setLngLat(p.corners[b]);
|
|
1772
|
+
for (let b = 0; b < 4; b++) f[4 + b].setLngLat(p.edges[b]);
|
|
1773
|
+
f[8].setLngLat(p.rotateHandle);
|
|
1774
1774
|
}
|
|
1775
1775
|
}
|
|
1776
|
-
const
|
|
1776
|
+
const P = $(null);
|
|
1777
1777
|
K(() => {
|
|
1778
1778
|
if (!s || t.length === 0) return;
|
|
1779
|
-
|
|
1780
|
-
const
|
|
1781
|
-
|
|
1782
|
-
const a = It(f[
|
|
1783
|
-
a.addEventListener("mousedown", (
|
|
1784
|
-
}),
|
|
1785
|
-
const a = It(b[
|
|
1786
|
-
a.addEventListener("mousedown", (
|
|
1779
|
+
F();
|
|
1780
|
+
const p = v.current ?? it(t), f = ["nw", "ne", "se", "sw"], b = ["n", "e", "s", "w"], M = [];
|
|
1781
|
+
p.corners.forEach((A, E) => {
|
|
1782
|
+
const a = It(f[E]), x = new De.Marker({ element: a, draggable: !1 }).setLngLat(A).addTo(e);
|
|
1783
|
+
a.addEventListener("mousedown", (y) => D(y, E, !1)), M.push(x);
|
|
1784
|
+
}), p.edges.forEach((A, E) => {
|
|
1785
|
+
const a = It(b[E]), x = new De.Marker({ element: a, draggable: !1 }).setLngLat(A).addTo(e);
|
|
1786
|
+
a.addEventListener("mousedown", (y) => D(y, E, !0)), M.push(x);
|
|
1787
1787
|
});
|
|
1788
1788
|
{
|
|
1789
|
-
const
|
|
1790
|
-
|
|
1789
|
+
const A = It("rotate"), E = new De.Marker({ element: A, anchor: "bottom", draggable: !1 }).setLngLat(p.rotateHandle).addTo(e);
|
|
1790
|
+
A.addEventListener("mousedown", (a) => q(a)), M.push(E);
|
|
1791
1791
|
}
|
|
1792
|
-
return T.current =
|
|
1793
|
-
|
|
1792
|
+
return T.current = M, () => {
|
|
1793
|
+
F();
|
|
1794
1794
|
};
|
|
1795
1795
|
}, [s, g, u, e]), K(() => {
|
|
1796
|
-
function
|
|
1796
|
+
function p(S) {
|
|
1797
1797
|
const L = e.getCanvasContainer().getBoundingClientRect(), B = e.unproject([S.clientX - L.left, S.clientY - L.top]);
|
|
1798
1798
|
return [B.lng, B.lat];
|
|
1799
1799
|
}
|
|
1800
|
-
const f = ze(
|
|
1800
|
+
const f = ze(E);
|
|
1801
1801
|
let b = null;
|
|
1802
|
-
function
|
|
1803
|
-
|
|
1802
|
+
function M(S) {
|
|
1803
|
+
P.current && (S.preventDefault(), b = { clientX: S.clientX, clientY: S.clientY }, f.schedule(S));
|
|
1804
1804
|
}
|
|
1805
|
-
function
|
|
1805
|
+
function A(S) {
|
|
1806
1806
|
var L;
|
|
1807
|
-
S.key !== "Shift" && S.key !== "Alt" || ((L =
|
|
1807
|
+
S.key !== "Shift" && S.key !== "Alt" || ((L = P.current) == null ? void 0 : L.type) !== "scale" || !b || (S.preventDefault(), f.schedule({ ...b, shiftKey: S.shiftKey, altKey: S.altKey }));
|
|
1808
1808
|
}
|
|
1809
|
-
function
|
|
1810
|
-
const L =
|
|
1809
|
+
function E(S) {
|
|
1810
|
+
const L = P.current;
|
|
1811
1811
|
if (!L) return;
|
|
1812
|
-
const [B, V] =
|
|
1812
|
+
const [B, V] = p(S), j = n.getState().geometryMode;
|
|
1813
1813
|
if (L.type === "move") {
|
|
1814
1814
|
if (!L.moving) {
|
|
1815
1815
|
const H = e.getCanvasContainer().getBoundingClientRect();
|
|
1816
1816
|
if (Math.hypot(S.clientX - H.left - L.startPoint.x, S.clientY - H.top - L.startPoint.y) < Vr) return;
|
|
1817
1817
|
L.moving = !0, i(!0);
|
|
1818
1818
|
}
|
|
1819
|
-
const h = j === "visual",
|
|
1820
|
-
corners: st(z.corners,
|
|
1821
|
-
edges: st(z.edges,
|
|
1822
|
-
center: st([z.center],
|
|
1823
|
-
rotateHandle: st([z.rotateHandle],
|
|
1819
|
+
const h = j === "visual", I = zr(L.startLngLat, [B, V], h), O = L.initialFeatures.map((H) => ({ ...H, geometry: $t(H.geometry, I, h) })), z = L.initialBbox, G = {
|
|
1820
|
+
corners: st(z.corners, I, h),
|
|
1821
|
+
edges: st(z.edges, I, h),
|
|
1822
|
+
center: st([z.center], I, h)[0],
|
|
1823
|
+
rotateHandle: st([z.rotateHandle], I, h)[0]
|
|
1824
1824
|
};
|
|
1825
|
-
w.current = O,
|
|
1825
|
+
w.current = O, C.current = G, k(O), N(G);
|
|
1826
1826
|
} else if (L.type === "rotate") {
|
|
1827
|
-
const h = L.center,
|
|
1827
|
+
const h = L.center, I = Te(h[1]), O = V - h[1], z = j === "visual" ? (B - h[0]) * I : B - h[0], H = (Math.atan2(O, z) - L.initialAngle) * (180 / Math.PI), te = L.initialFeatures.map(
|
|
1828
1828
|
(ne) => j === "visual" ? Po(ne, h, 1, 1, H) : ir(ne, H, { pivot: h })
|
|
1829
1829
|
), Z = {
|
|
1830
1830
|
corners: kt(L.initialBbox.corners, h, H),
|
|
@@ -1832,25 +1832,25 @@ function es({ map: e, features: t }) {
|
|
|
1832
1832
|
center: h,
|
|
1833
1833
|
rotateHandle: kt([L.initialBbox.rotateHandle], h, H)[0]
|
|
1834
1834
|
};
|
|
1835
|
-
w.current = te,
|
|
1835
|
+
w.current = te, C.current = Z, k(te), N(Z);
|
|
1836
1836
|
} else if (L.type === "scale") {
|
|
1837
|
-
const h = L.rotationAngle,
|
|
1837
|
+
const h = L.rotationAngle, I = qr({
|
|
1838
1838
|
initialBbox: L.initialBbox,
|
|
1839
1839
|
origin: L.origin,
|
|
1840
1840
|
startLngLat: L.startLngLat,
|
|
1841
1841
|
edgeIndex: L.edgeIndex,
|
|
1842
1842
|
rotationAngle: h
|
|
1843
|
-
}, [B, V], S.shiftKey, S.altKey), O = Jr(L.initialFeatures, L.initialBbox,
|
|
1844
|
-
w.current = O.features,
|
|
1843
|
+
}, [B, V], S.shiftKey, S.altKey), O = Jr(L.initialFeatures, L.initialBbox, I, h);
|
|
1844
|
+
w.current = O.features, C.current = O.box, k(O.features), N(O.box);
|
|
1845
1845
|
}
|
|
1846
1846
|
}
|
|
1847
1847
|
function a() {
|
|
1848
1848
|
f.flush();
|
|
1849
|
-
const S =
|
|
1849
|
+
const S = P.current;
|
|
1850
1850
|
if (!S) return;
|
|
1851
|
-
const L = w.current, B =
|
|
1852
|
-
if (
|
|
1853
|
-
const j = e.getContainer(), h = (
|
|
1851
|
+
const L = w.current, B = C.current, V = S.type === "rotate";
|
|
1852
|
+
if (P.current = null, b = null, w.current = null, C.current = null, e.dragPan.enable(), i(!1), S.type === "move" && L) {
|
|
1853
|
+
const j = e.getContainer(), h = (I) => I.stopPropagation();
|
|
1854
1854
|
j.addEventListener("click", h, !0), setTimeout(() => j.removeEventListener("click", h, !0), 0);
|
|
1855
1855
|
}
|
|
1856
1856
|
if (L && (n.getState().takeSnapshot(), n.getState().updateFeatures(Eo(
|
|
@@ -1859,7 +1859,7 @@ function es({ map: e, features: t }) {
|
|
|
1859
1859
|
o.getState().topoEditEnabled
|
|
1860
1860
|
))), B) {
|
|
1861
1861
|
if (V) {
|
|
1862
|
-
const j = B.center, h = B.edges[1],
|
|
1862
|
+
const j = B.center, h = B.edges[1], I = Te(j[1]), O = (h[0] - j[0]) * I, z = h[1] - j[1];
|
|
1863
1863
|
d.current = Math.atan2(z, O) * (180 / Math.PI);
|
|
1864
1864
|
}
|
|
1865
1865
|
c(B);
|
|
@@ -1867,21 +1867,21 @@ function es({ map: e, features: t }) {
|
|
|
1867
1867
|
}
|
|
1868
1868
|
function x(S, L, B) {
|
|
1869
1869
|
S.preventDefault(), S.stopPropagation(), e.dragPan.disable();
|
|
1870
|
-
const V = v.current ?? it(l.current), [j, h] =
|
|
1871
|
-
|
|
1870
|
+
const V = v.current ?? it(l.current), [j, h] = p(S), I = B ? V.edges[(L + 2) % 4] : V.corners[(L + 2) % 4];
|
|
1871
|
+
P.current = {
|
|
1872
1872
|
type: "scale",
|
|
1873
1873
|
initialFeatures: structuredClone(l.current),
|
|
1874
1874
|
initialBbox: V,
|
|
1875
1875
|
rotationAngle: d.current,
|
|
1876
|
-
origin:
|
|
1876
|
+
origin: I,
|
|
1877
1877
|
startLngLat: [j, h],
|
|
1878
1878
|
edgeIndex: B ? L : void 0
|
|
1879
1879
|
}, i(!0);
|
|
1880
1880
|
}
|
|
1881
|
-
function
|
|
1881
|
+
function y(S) {
|
|
1882
1882
|
S.preventDefault(), S.stopPropagation(), e.dragPan.disable();
|
|
1883
|
-
const L = v.current ?? it(l.current), B = L.center, [V, j] =
|
|
1884
|
-
|
|
1883
|
+
const L = v.current ?? it(l.current), B = L.center, [V, j] = p(S), h = n.getState().geometryMode, I = Te(B[1]), O = j - B[1], z = h === "visual" ? (V - B[0]) * I : V - B[0];
|
|
1884
|
+
P.current = {
|
|
1885
1885
|
type: "rotate",
|
|
1886
1886
|
initialFeatures: structuredClone(l.current),
|
|
1887
1887
|
initialBbox: L,
|
|
@@ -1891,38 +1891,38 @@ function es({ map: e, features: t }) {
|
|
|
1891
1891
|
}, i(!0);
|
|
1892
1892
|
}
|
|
1893
1893
|
function m(S) {
|
|
1894
|
-
if (
|
|
1894
|
+
if (P.current || S.button !== 0 || S.shiftKey || S.altKey || S.ctrlKey || S.metaKey || S.target !== e.getCanvas()) return;
|
|
1895
1895
|
const L = o.getState();
|
|
1896
1896
|
if (!L.transformActive || L.readonly || L.editingMode !== "none" || L.vertexEditActive) return;
|
|
1897
1897
|
const B = l.current;
|
|
1898
1898
|
if (B.length === 0) return;
|
|
1899
1899
|
const V = v.current ?? it(B), j = e.getCanvasContainer().getBoundingClientRect(), h = { x: S.clientX - j.left, y: S.clientY - j.top };
|
|
1900
|
-
Hr(h, V.corners.map((
|
|
1900
|
+
Hr(h, V.corners.map((I) => e.project(I)), Xr) && (S.preventDefault(), S.stopPropagation(), e.dragPan.disable(), P.current = {
|
|
1901
1901
|
type: "move",
|
|
1902
1902
|
initialFeatures: structuredClone(B),
|
|
1903
1903
|
initialBbox: V,
|
|
1904
1904
|
rotationAngle: d.current,
|
|
1905
|
-
startLngLat:
|
|
1905
|
+
startLngLat: p(S),
|
|
1906
1906
|
startPoint: h,
|
|
1907
1907
|
moving: !1
|
|
1908
1908
|
});
|
|
1909
1909
|
}
|
|
1910
|
-
const
|
|
1911
|
-
return
|
|
1912
|
-
f.cancel(),
|
|
1910
|
+
const R = e.getContainer();
|
|
1911
|
+
return R.addEventListener("mousedown", m, !0), _.current.handleScaleStart = x, _.current.handleRotateStart = y, document.addEventListener("mousemove", M), document.addEventListener("mouseup", a), document.addEventListener("keydown", A), document.addEventListener("keyup", A), () => {
|
|
1912
|
+
f.cancel(), R.removeEventListener("mousedown", m, !0), document.removeEventListener("mousemove", M), document.removeEventListener("mouseup", a), document.removeEventListener("keydown", A), document.removeEventListener("keyup", A);
|
|
1913
1913
|
};
|
|
1914
1914
|
}, [e, n, o, i]);
|
|
1915
|
-
const
|
|
1915
|
+
const _ = $({
|
|
1916
1916
|
handleScaleStart: () => {
|
|
1917
1917
|
},
|
|
1918
1918
|
handleRotateStart: () => {
|
|
1919
1919
|
}
|
|
1920
1920
|
});
|
|
1921
|
-
function D(
|
|
1922
|
-
|
|
1921
|
+
function D(p, f, b) {
|
|
1922
|
+
_.current.handleScaleStart(p, f, b);
|
|
1923
1923
|
}
|
|
1924
|
-
function q(
|
|
1925
|
-
|
|
1924
|
+
function q(p) {
|
|
1925
|
+
_.current.handleRotateStart(p);
|
|
1926
1926
|
}
|
|
1927
1927
|
return null;
|
|
1928
1928
|
}
|
|
@@ -2012,36 +2012,36 @@ function os(e, t) {
|
|
|
2012
2012
|
function rs({ map: e, onVertexBoxSelect: t }) {
|
|
2013
2013
|
const { dataStore: n } = Le(), o = W((d) => d.editingMode), r = W((d) => d.vertexEditActive), s = W((d) => d.transformActive), i = W((d) => d.readonly), l = $(o), u = $(r), c = $(s), v = $(i);
|
|
2014
2014
|
return l.current = o, u.current = r, c.current = s, v.current = i, K(() => {
|
|
2015
|
-
const d = e.getCanvas(), g = e.getContainer(), w = (
|
|
2016
|
-
if (!
|
|
2015
|
+
const d = e.getCanvas(), g = e.getContainer(), w = (C) => {
|
|
2016
|
+
if (!C.shiftKey || v.current || c.current) return;
|
|
2017
2017
|
const T = u.current;
|
|
2018
2018
|
if (!T && l.current !== "none") return;
|
|
2019
|
-
|
|
2020
|
-
const
|
|
2021
|
-
|
|
2019
|
+
C.preventDefault(), e.dragPan.disable(), e.boxZoom.disable();
|
|
2020
|
+
const F = C.clientX, k = C.clientY, N = g.getBoundingClientRect(), P = [...n.getState().selectedIds], _ = document.createElement("div");
|
|
2021
|
+
_.style.cssText = [
|
|
2022
2022
|
"position:absolute",
|
|
2023
2023
|
"pointer-events:none",
|
|
2024
2024
|
"border:2px solid var(--color-primary-500)",
|
|
2025
2025
|
"background:color-mix(in srgb, var(--color-primary-500) 8%, transparent)",
|
|
2026
2026
|
"z-index:9999",
|
|
2027
2027
|
"border-radius:2px"
|
|
2028
|
-
].join(";"), g.appendChild(
|
|
2028
|
+
].join(";"), g.appendChild(_);
|
|
2029
2029
|
let D = !1, q = 0;
|
|
2030
|
-
function
|
|
2031
|
-
const x = Math.min(
|
|
2030
|
+
function p(a) {
|
|
2031
|
+
const x = Math.min(F, a.clientX) - N.left, y = Math.min(k, a.clientY) - N.top, m = Math.max(F, a.clientX) - N.left, R = Math.max(k, a.clientY) - N.top, S = e.unproject([x, y]), L = e.unproject([m, R]);
|
|
2032
2032
|
return {
|
|
2033
2033
|
boxW: S.lng,
|
|
2034
2034
|
boxE: L.lng,
|
|
2035
2035
|
boxN: S.lat,
|
|
2036
2036
|
boxS: L.lat,
|
|
2037
2037
|
overlayX: x,
|
|
2038
|
-
overlayY:
|
|
2038
|
+
overlayY: y,
|
|
2039
2039
|
overlayW: m - x,
|
|
2040
|
-
overlayH:
|
|
2040
|
+
overlayH: R - y
|
|
2041
2041
|
};
|
|
2042
2042
|
}
|
|
2043
2043
|
function f(a) {
|
|
2044
|
-
const { boxW: x, boxE:
|
|
2044
|
+
const { boxW: x, boxE: y, boxN: m, boxS: R } = p(a), S = n.getState(), L = new Set(S.groups.filter((h) => h.hidden).map((h) => h.id)), B = S.features.filter(
|
|
2045
2045
|
(h) => !h.hidden && (!h.groupId || !L.has(h.groupId))
|
|
2046
2046
|
), V = {
|
|
2047
2047
|
type: "Feature",
|
|
@@ -2049,23 +2049,23 @@ function rs({ map: e, onVertexBoxSelect: t }) {
|
|
|
2049
2049
|
geometry: {
|
|
2050
2050
|
type: "Polygon",
|
|
2051
2051
|
coordinates: [[
|
|
2052
|
-
[x,
|
|
2053
|
-
[
|
|
2054
|
-
[
|
|
2052
|
+
[x, R],
|
|
2053
|
+
[y, R],
|
|
2054
|
+
[y, m],
|
|
2055
2055
|
[x, m],
|
|
2056
|
-
[x,
|
|
2056
|
+
[x, R]
|
|
2057
2057
|
]]
|
|
2058
2058
|
}
|
|
2059
2059
|
}, j = [];
|
|
2060
2060
|
for (const h of B) {
|
|
2061
2061
|
if (h.geometry.type === "Point") {
|
|
2062
2062
|
const [te, Z] = h.geometry.coordinates;
|
|
2063
|
-
te >= x && te <=
|
|
2063
|
+
te >= x && te <= y && Z >= R && Z <= m && j.push(h.id);
|
|
2064
2064
|
continue;
|
|
2065
2065
|
}
|
|
2066
|
-
const
|
|
2067
|
-
if (G >= x && O <=
|
|
2068
|
-
if (ns(
|
|
2066
|
+
const I = h.bbox ?? Nn(h.geometry), [O, z, G, H] = I;
|
|
2067
|
+
if (G >= x && O <= y && H >= R && z <= m) {
|
|
2068
|
+
if (ns(I, x, R, y, m)) {
|
|
2069
2069
|
j.push(h.id);
|
|
2070
2070
|
continue;
|
|
2071
2071
|
}
|
|
@@ -2079,53 +2079,53 @@ function rs({ map: e, onVertexBoxSelect: t }) {
|
|
|
2079
2079
|
return j;
|
|
2080
2080
|
}
|
|
2081
2081
|
function b(a) {
|
|
2082
|
-
const x = new Set(
|
|
2083
|
-
a.forEach((
|
|
2084
|
-
const
|
|
2085
|
-
os(m.selectedIds,
|
|
2082
|
+
const x = new Set(P);
|
|
2083
|
+
a.forEach((R) => x.add(R));
|
|
2084
|
+
const y = Array.from(x), m = n.getState();
|
|
2085
|
+
os(m.selectedIds, y) && m.selectedGroupId === null || m.setSelection(y);
|
|
2086
2086
|
}
|
|
2087
|
-
function
|
|
2087
|
+
function M(a) {
|
|
2088
2088
|
const x = n.getState().selectedIds[0];
|
|
2089
2089
|
if (!x) return null;
|
|
2090
|
-
const
|
|
2091
|
-
if (!
|
|
2090
|
+
const y = n.getState().features.find((j) => j.id === x);
|
|
2091
|
+
if (!y) return null;
|
|
2092
2092
|
let m;
|
|
2093
|
-
if (
|
|
2094
|
-
m =
|
|
2095
|
-
else if (
|
|
2096
|
-
m =
|
|
2093
|
+
if (y.geometry.type === "LineString")
|
|
2094
|
+
m = y.geometry.coordinates;
|
|
2095
|
+
else if (y.geometry.type === "Polygon")
|
|
2096
|
+
m = y.geometry.coordinates[0].slice(0, -1);
|
|
2097
2097
|
else
|
|
2098
2098
|
return null;
|
|
2099
|
-
const { boxW:
|
|
2099
|
+
const { boxW: R, boxE: S, boxN: L, boxS: B } = p(a), V = [];
|
|
2100
2100
|
for (let j = 0; j < m.length; j++) {
|
|
2101
|
-
const [h,
|
|
2102
|
-
h >=
|
|
2101
|
+
const [h, I] = m[j];
|
|
2102
|
+
h >= R && h <= S && I >= B && I <= L && V.push(j);
|
|
2103
2103
|
}
|
|
2104
2104
|
return { id: x, indices: V };
|
|
2105
2105
|
}
|
|
2106
|
-
const
|
|
2107
|
-
const x = Math.abs(a.clientX -
|
|
2108
|
-
if (!D && x < 5 &&
|
|
2106
|
+
const A = (a) => {
|
|
2107
|
+
const x = Math.abs(a.clientX - F), y = Math.abs(a.clientY - k);
|
|
2108
|
+
if (!D && x < 5 && y < 5) return;
|
|
2109
2109
|
D = !0;
|
|
2110
|
-
const { overlayX: m, overlayY:
|
|
2111
|
-
|
|
2112
|
-
},
|
|
2113
|
-
if (
|
|
2110
|
+
const { overlayX: m, overlayY: R, overlayW: S, overlayH: L } = p(a);
|
|
2111
|
+
_.style.left = `${m}px`, _.style.top = `${R}px`, _.style.width = `${S}px`, _.style.height = `${L}px`, !T && Date.now() - q > 30 && (b(f(a)), q = Date.now());
|
|
2112
|
+
}, E = (a) => {
|
|
2113
|
+
if (_.remove(), e.dragPan.enable(), e.boxZoom.enable(), window.removeEventListener("mousemove", A), window.removeEventListener("mouseup", E), !D) return;
|
|
2114
2114
|
if (T) {
|
|
2115
|
-
const
|
|
2116
|
-
|
|
2115
|
+
const y = M(a);
|
|
2116
|
+
y && y.indices.length > 0 && t && t(y.id, y.indices);
|
|
2117
2117
|
return;
|
|
2118
2118
|
}
|
|
2119
2119
|
const x = f(a);
|
|
2120
|
-
if (b(x), x.length === 0 &&
|
|
2121
|
-
const
|
|
2122
|
-
if (
|
|
2123
|
-
const m =
|
|
2120
|
+
if (b(x), x.length === 0 && P.length === 1 && t) {
|
|
2121
|
+
const y = n.getState().features.find((m) => m.id === P[0]);
|
|
2122
|
+
if (y && (y.geometry.type === "LineString" || y.geometry.type === "Polygon")) {
|
|
2123
|
+
const m = M(a);
|
|
2124
2124
|
m && m.indices.length > 0 && t(m.id, m.indices);
|
|
2125
2125
|
}
|
|
2126
2126
|
}
|
|
2127
2127
|
};
|
|
2128
|
-
window.addEventListener("mousemove",
|
|
2128
|
+
window.addEventListener("mousemove", A), window.addEventListener("mouseup", E);
|
|
2129
2129
|
};
|
|
2130
2130
|
return d.addEventListener("mousedown", w), () => d.removeEventListener("mousedown", w);
|
|
2131
2131
|
}, [e, n, t]), null;
|
|
@@ -2237,49 +2237,49 @@ function us({ map: e }) {
|
|
|
2237
2237
|
ct();
|
|
2238
2238
|
}, [r.length, i]), K(() => {
|
|
2239
2239
|
if (!i) return;
|
|
2240
|
-
const a = t.getState(), x = a.selectedIds.length === 1 ? a.features.find((m) => m.id === a.selectedIds[0]) : void 0,
|
|
2241
|
-
|
|
2240
|
+
const a = t.getState(), x = a.selectedIds.length === 1 ? a.features.find((m) => m.id === a.selectedIds[0]) : void 0, y = Co(x);
|
|
2241
|
+
y && o({ type: "warning", message: y });
|
|
2242
2242
|
}, [i, t, o]);
|
|
2243
2243
|
const v = $(!1);
|
|
2244
2244
|
K(() => {
|
|
2245
2245
|
if (!l || v.current) return;
|
|
2246
|
-
const a = t.getState(), x = a.selectedIds.length === 1 ? a.features.find((
|
|
2246
|
+
const a = t.getState(), x = a.selectedIds.length === 1 ? a.features.find((y) => y.id === a.selectedIds[0]) : void 0;
|
|
2247
2247
|
(x == null ? void 0 : x._drawType) === "route" && (o({ type: "warning", message: "Transforming may break road alignment." }), v.current = !0);
|
|
2248
2248
|
}, [l, s, t, o]);
|
|
2249
|
-
const d = $(null), g = $(null), [w,
|
|
2249
|
+
const d = $(null), g = $(null), [w, C] = le(null), [T, F] = le(null), [k, N] = le(null);
|
|
2250
2250
|
K(() => {
|
|
2251
|
-
!i &&
|
|
2252
|
-
}, [i,
|
|
2253
|
-
const
|
|
2251
|
+
!i && k && N(null);
|
|
2252
|
+
}, [i, k]);
|
|
2253
|
+
const P = is(c), _ = Jo();
|
|
2254
2254
|
K(() => {
|
|
2255
2255
|
if (c) return;
|
|
2256
|
-
const a = e.getCanvasContainer(), x = (
|
|
2257
|
-
var
|
|
2258
|
-
|
|
2259
|
-
const m = a.getBoundingClientRect(),
|
|
2256
|
+
const a = e.getCanvasContainer(), x = (y) => {
|
|
2257
|
+
var I, O;
|
|
2258
|
+
y.preventDefault();
|
|
2259
|
+
const m = a.getBoundingClientRect(), R = [y.clientX - m.left, y.clientY - m.top], S = $e(e, R, Be);
|
|
2260
2260
|
if (S.length === 0) return;
|
|
2261
|
-
const L = String(S[0].id ?? ((
|
|
2261
|
+
const L = String(S[0].id ?? ((I = S[0].properties) == null ? void 0 : I.id) ?? "");
|
|
2262
2262
|
if (!L) return;
|
|
2263
2263
|
const B = t.getState(), V = B.features.find((z) => z.id === L);
|
|
2264
2264
|
if (!V) return;
|
|
2265
2265
|
const j = B.selectedIds;
|
|
2266
2266
|
j.length >= 2 && j.includes(L) || B.selectFeature(L);
|
|
2267
2267
|
const h = V.geometry.type === "Point" && ((O = V.properties) == null ? void 0 : O._isText) !== "true";
|
|
2268
|
-
|
|
2268
|
+
_.open(y.clientX, y.clientY, {
|
|
2269
2269
|
feature: V,
|
|
2270
|
-
requestPreciseCoords: h ? () =>
|
|
2270
|
+
requestPreciseCoords: h ? () => F(L) : void 0
|
|
2271
2271
|
});
|
|
2272
2272
|
};
|
|
2273
2273
|
return a.addEventListener("contextmenu", x), () => {
|
|
2274
2274
|
a.removeEventListener("contextmenu", x);
|
|
2275
2275
|
};
|
|
2276
|
-
}, [c, t, e,
|
|
2277
|
-
const a = u !== "none", x = (
|
|
2278
|
-
bt(e, null, d.current), d.current = null,
|
|
2279
|
-
},
|
|
2276
|
+
}, [c, t, e, _]), K(() => {
|
|
2277
|
+
const a = u !== "none", x = (R = !0) => {
|
|
2278
|
+
bt(e, null, d.current), d.current = null, R && Pt(e, null), ct(), P.leave(a ? void 0 : "");
|
|
2279
|
+
}, y = (R) => {
|
|
2280
2280
|
var V, j;
|
|
2281
2281
|
if (e.dragPan.isActive() || (V = g.current) != null && V.dragging) return;
|
|
2282
|
-
const S = $e(e,
|
|
2282
|
+
const S = $e(e, R.point, Be), L = S.length > 0 ? String(S[0].id ?? ((j = S[0].properties) == null ? void 0 : j.id)) : null;
|
|
2283
2283
|
if (L === d.current) return;
|
|
2284
2284
|
if (!L) {
|
|
2285
2285
|
x();
|
|
@@ -2287,28 +2287,28 @@ function us({ map: e }) {
|
|
|
2287
2287
|
}
|
|
2288
2288
|
Gt() !== L && Pt(e, null), a || bt(e, L, d.current), d.current = L;
|
|
2289
2289
|
const B = t.getState().features.find((h) => h.id === L);
|
|
2290
|
-
B ? Nr(B, n,
|
|
2290
|
+
B ? Nr(B, n, R.originalEvent) : ct(), P.enter(e.getCanvas(), R.originalEvent, a ? void 0 : "pointer");
|
|
2291
2291
|
};
|
|
2292
|
-
e.on("mousemove",
|
|
2292
|
+
e.on("mousemove", y);
|
|
2293
2293
|
const m = () => x();
|
|
2294
2294
|
return e.on("mouseout", m), () => {
|
|
2295
|
-
e.off("mousemove",
|
|
2295
|
+
e.off("mousemove", y), e.off("mouseout", m);
|
|
2296
2296
|
try {
|
|
2297
2297
|
x(!1);
|
|
2298
2298
|
} catch {
|
|
2299
2299
|
}
|
|
2300
2300
|
};
|
|
2301
|
-
}, [u, e, t, n,
|
|
2301
|
+
}, [u, e, t, n, P]);
|
|
2302
2302
|
const D = $(r);
|
|
2303
2303
|
K(() => {
|
|
2304
2304
|
const a = D.current;
|
|
2305
2305
|
if (D.current = r, r.length <= a.length) return;
|
|
2306
|
-
const
|
|
2307
|
-
if (m.x <
|
|
2308
|
-
const
|
|
2306
|
+
const y = e.getCanvas().getBoundingClientRect(), m = cs();
|
|
2307
|
+
if (m.x < y.left || m.x > y.right || m.y < y.top || m.y > y.bottom) return;
|
|
2308
|
+
const R = new Set(a.map((h) => h.id)), S = new Set(r.filter((h) => !R.has(h.id)).map((h) => h.id)), L = [m.x - y.left, m.y - y.top], B = () => {
|
|
2309
2309
|
var h;
|
|
2310
2310
|
try {
|
|
2311
|
-
const
|
|
2311
|
+
const I = e.unproject(L), O = $e(e, e.project(I), Be)[0], z = O ? String(O.id ?? ((h = O.properties) == null ? void 0 : h.id)) : null;
|
|
2312
2312
|
z && S.has(z) && Pt(e, z), e.fire("mousemove", {
|
|
2313
2313
|
// A real Point: a plain { x, y } makes every listener's
|
|
2314
2314
|
// queryRenderedFeatures(e.point) hit the whole viewport, so the
|
|
@@ -2316,8 +2316,8 @@ function us({ map: e }) {
|
|
|
2316
2316
|
// `map.project` returns the map's own Point class (a `new Point` from the
|
|
2317
2317
|
// peer copy fails maplibre's instanceof check when the host bundles its own
|
|
2318
2318
|
// maplibre, e.g. MapTiler SDK) and avoids a named import from CJS maplibre-gl.
|
|
2319
|
-
point: e.project(
|
|
2320
|
-
lngLat:
|
|
2319
|
+
point: e.project(I),
|
|
2320
|
+
lngLat: I,
|
|
2321
2321
|
originalEvent: new MouseEvent("mousemove", {
|
|
2322
2322
|
clientX: m.x,
|
|
2323
2323
|
clientY: m.y,
|
|
@@ -2341,12 +2341,12 @@ function us({ map: e }) {
|
|
|
2341
2341
|
const a = (x) => {
|
|
2342
2342
|
var L;
|
|
2343
2343
|
if (Gn()) return;
|
|
2344
|
-
const
|
|
2345
|
-
if (
|
|
2344
|
+
const y = $e(e, x.point, Be), m = t.getState();
|
|
2345
|
+
if (y.length === 0) {
|
|
2346
2346
|
i ? n.getState().setVertexEditActive(!1) : m.clearSelection();
|
|
2347
2347
|
return;
|
|
2348
2348
|
}
|
|
2349
|
-
const
|
|
2349
|
+
const R = y[0], S = String(R.id ?? ((L = R.properties) == null ? void 0 : L.id) ?? "");
|
|
2350
2350
|
if (S)
|
|
2351
2351
|
if (x.originalEvent.shiftKey) {
|
|
2352
2352
|
const B = m.selectedIds;
|
|
@@ -2361,19 +2361,19 @@ function us({ map: e }) {
|
|
|
2361
2361
|
if (c || u !== "none") return;
|
|
2362
2362
|
const a = (x) => {
|
|
2363
2363
|
var S, L;
|
|
2364
|
-
const
|
|
2365
|
-
if (
|
|
2364
|
+
const y = $e(e, x.point, Be);
|
|
2365
|
+
if (y.length === 0) return;
|
|
2366
2366
|
x.preventDefault();
|
|
2367
|
-
const m = String(
|
|
2367
|
+
const m = String(y[0].id ?? ((S = y[0].properties) == null ? void 0 : S.id) ?? "");
|
|
2368
2368
|
if (!m) return;
|
|
2369
|
-
const
|
|
2370
|
-
if (
|
|
2371
|
-
if (((L =
|
|
2372
|
-
t.getState().selectFeature(m),
|
|
2369
|
+
const R = t.getState().features.find((B) => B.id === m);
|
|
2370
|
+
if (R) {
|
|
2371
|
+
if (((L = R.properties) == null ? void 0 : L._isText) === "true") {
|
|
2372
|
+
t.getState().selectFeature(m), C(m);
|
|
2373
2373
|
return;
|
|
2374
2374
|
}
|
|
2375
|
-
if (t.getState().selectFeature(m), ht(
|
|
2376
|
-
const B = Dr(
|
|
2375
|
+
if (t.getState().selectFeature(m), ht(R.geometry)) {
|
|
2376
|
+
const B = Dr(R.geometry, [x.lngLat.lng, x.lngLat.lat]);
|
|
2377
2377
|
n.getState().setSelectedPartIndex(B);
|
|
2378
2378
|
} else
|
|
2379
2379
|
n.getState().setSelectedPartIndex(null);
|
|
@@ -2385,26 +2385,26 @@ function us({ map: e }) {
|
|
|
2385
2385
|
};
|
|
2386
2386
|
}, [c, u, t, n, e]), K(() => {
|
|
2387
2387
|
if (c || i) return;
|
|
2388
|
-
const x = u !== "none",
|
|
2388
|
+
const x = u !== "none", y = (m) => {
|
|
2389
2389
|
var re;
|
|
2390
2390
|
if (m.originalEvent.shiftKey) return;
|
|
2391
|
-
const
|
|
2392
|
-
if (x && !
|
|
2391
|
+
const R = m.originalEvent.altKey, S = m.originalEvent.ctrlKey || m.originalEvent.metaKey;
|
|
2392
|
+
if (x && !R && !S) return;
|
|
2393
2393
|
const L = $e(e, m.point, Be);
|
|
2394
2394
|
if (L.length === 0) return;
|
|
2395
2395
|
const B = String(L[0].id ?? ((re = L[0].properties) == null ? void 0 : re.id) ?? "");
|
|
2396
2396
|
if (!B) return;
|
|
2397
2397
|
const V = t.getState();
|
|
2398
|
-
if (V.selectedIds.includes(B) && V.selectedIds.length >= 2 && !
|
|
2398
|
+
if (V.selectedIds.includes(B) && V.selectedIds.length >= 2 && !R && !S) return;
|
|
2399
2399
|
V.selectedIds.includes(B) || V.selectFeature(B);
|
|
2400
|
-
const h = t.getState().selectedIds,
|
|
2401
|
-
|
|
2400
|
+
const h = t.getState().selectedIds, I = h.includes(B) ? h : [B], O = new Map(
|
|
2401
|
+
I.flatMap((J) => {
|
|
2402
2402
|
const ce = V.features.find((U) => U.id === J);
|
|
2403
2403
|
return ce ? [[J, ce.geometry]] : [];
|
|
2404
2404
|
})
|
|
2405
|
-
), z =
|
|
2405
|
+
), z = R, G = V.geometryMode, H = [m.lngLat.lng, m.lngLat.lat], te = G === "visual" ? me(H) : H;
|
|
2406
2406
|
e.dragPan.disable(), g.current = {
|
|
2407
|
-
featureIds:
|
|
2407
|
+
featureIds: I,
|
|
2408
2408
|
startLngLat: H,
|
|
2409
2409
|
startProjected: te,
|
|
2410
2410
|
geometryMode: G,
|
|
@@ -2455,7 +2455,7 @@ function us({ map: e }) {
|
|
|
2455
2455
|
const J = g.current;
|
|
2456
2456
|
if (g.current = null, e.dragPan.enable(), J != null && J.dragging) {
|
|
2457
2457
|
const ce = Ge(n.getState().editingMode);
|
|
2458
|
-
if (
|
|
2458
|
+
if (P.leave(ce), e.getCanvas().style.cursor = ce, bt(e, null, d.current), d.current = null, Ce(!1), Mr(), t.getState().takeSnapshot(), J.duplicate) {
|
|
2459
2459
|
const U = [];
|
|
2460
2460
|
for (const ee of J.featureIds) {
|
|
2461
2461
|
const oe = Z.get(ee);
|
|
@@ -2474,47 +2474,47 @@ function us({ map: e }) {
|
|
|
2474
2474
|
};
|
|
2475
2475
|
e.on("mousemove", se), e.on("mouseup", ie);
|
|
2476
2476
|
};
|
|
2477
|
-
return e.on("mousedown",
|
|
2478
|
-
e.off("mousedown",
|
|
2477
|
+
return e.on("mousedown", y), () => {
|
|
2478
|
+
e.off("mousedown", y);
|
|
2479
2479
|
};
|
|
2480
|
-
}, [c, u, i, t, n, e,
|
|
2481
|
-
const q = s.length === 1 ? r.find((a) => a.id === s[0]) ?? null : null,
|
|
2480
|
+
}, [c, u, i, t, n, e, P]);
|
|
2481
|
+
const q = s.length === 1 ? r.find((a) => a.id === s[0]) ?? null : null, p = r.filter((a) => s.includes(a.id)), f = _.state && /* @__PURE__ */ X(
|
|
2482
2482
|
Bo,
|
|
2483
2483
|
{
|
|
2484
|
-
x:
|
|
2485
|
-
y:
|
|
2486
|
-
data:
|
|
2487
|
-
onClose:
|
|
2484
|
+
x: _.state.x,
|
|
2485
|
+
y: _.state.y,
|
|
2486
|
+
data: _.state.data,
|
|
2487
|
+
onClose: _.close
|
|
2488
2488
|
}
|
|
2489
|
-
), b = w ? r.find((a) => a.id === w) ?? null : null,
|
|
2489
|
+
), b = w ? r.find((a) => a.id === w) ?? null : null, M = b && /* @__PURE__ */ X(
|
|
2490
2490
|
ts,
|
|
2491
2491
|
{
|
|
2492
2492
|
map: e,
|
|
2493
2493
|
feature: b,
|
|
2494
|
-
onDone: () =>
|
|
2494
|
+
onDone: () => C(null)
|
|
2495
2495
|
}
|
|
2496
|
-
),
|
|
2496
|
+
), A = T ? r.find((a) => a.id === T) ?? null : null, E = A && A.geometry.type === "Point" && /* @__PURE__ */ X(
|
|
2497
2497
|
Un,
|
|
2498
2498
|
{
|
|
2499
2499
|
map: e,
|
|
2500
|
-
coords:
|
|
2500
|
+
coords: A.geometry.coordinates,
|
|
2501
2501
|
onSave: (a) => {
|
|
2502
|
-
t.getState().takeSnapshot(), t.getState().updateFeature(
|
|
2502
|
+
t.getState().takeSnapshot(), t.getState().updateFeature(A.id, { geometry: { type: "Point", coordinates: Ve(A.geometry.coordinates, a) } });
|
|
2503
2503
|
},
|
|
2504
|
-
onClose: () =>
|
|
2504
|
+
onClose: () => F(null)
|
|
2505
2505
|
}
|
|
2506
2506
|
);
|
|
2507
2507
|
return c || u !== "none" ? /* @__PURE__ */ fe(lt, { children: [
|
|
2508
2508
|
f,
|
|
2509
|
-
|
|
2510
|
-
|
|
2509
|
+
M,
|
|
2510
|
+
E
|
|
2511
2511
|
] }) : /* @__PURE__ */ fe(lt, { children: [
|
|
2512
2512
|
i && q && /* @__PURE__ */ X(
|
|
2513
2513
|
$r,
|
|
2514
2514
|
{
|
|
2515
2515
|
map: e,
|
|
2516
2516
|
feature: q,
|
|
2517
|
-
initialSelectedIndices:
|
|
2517
|
+
initialSelectedIndices: k ?? void 0
|
|
2518
2518
|
}
|
|
2519
2519
|
),
|
|
2520
2520
|
/* @__PURE__ */ X(
|
|
@@ -2530,10 +2530,10 @@ function us({ map: e }) {
|
|
|
2530
2530
|
}
|
|
2531
2531
|
}
|
|
2532
2532
|
),
|
|
2533
|
-
l && !i &&
|
|
2533
|
+
l && !i && p.length >= 1 && /* @__PURE__ */ X(es, { map: e, features: p }),
|
|
2534
2534
|
f,
|
|
2535
|
-
|
|
2536
|
-
|
|
2535
|
+
M,
|
|
2536
|
+
E
|
|
2537
2537
|
] });
|
|
2538
2538
|
}
|
|
2539
2539
|
const Me = "elm-snap", eo = [
|
|
@@ -2601,47 +2601,47 @@ function gs({ map: e }) {
|
|
|
2601
2601
|
c();
|
|
2602
2602
|
return;
|
|
2603
2603
|
}
|
|
2604
|
-
const
|
|
2605
|
-
if (
|
|
2604
|
+
const F = T.originalEvent;
|
|
2605
|
+
if (F.metaKey || F.ctrlKey) {
|
|
2606
2606
|
c();
|
|
2607
2607
|
return;
|
|
2608
2608
|
}
|
|
2609
|
-
const
|
|
2610
|
-
if ((D =
|
|
2609
|
+
const k = F.target;
|
|
2610
|
+
if ((D = k == null ? void 0 : k.closest) != null && D.call(k, ".elm-midpoint-marker")) {
|
|
2611
2611
|
c();
|
|
2612
2612
|
return;
|
|
2613
2613
|
}
|
|
2614
|
-
const N = Gt(),
|
|
2615
|
-
if (!
|
|
2614
|
+
const N = Gt(), P = Vn(T.lngLat.lng, T.lngLat.lat, e, s, 15, new Set(N ? [N] : []));
|
|
2615
|
+
if (!P) {
|
|
2616
2616
|
c();
|
|
2617
2617
|
return;
|
|
2618
2618
|
}
|
|
2619
|
-
if (i &&
|
|
2619
|
+
if (i && P.isVertex) {
|
|
2620
2620
|
const q = new Set(n.getState().selectedIds);
|
|
2621
|
-
if (
|
|
2621
|
+
if (P.featureId && q.has(P.featureId)) {
|
|
2622
2622
|
c();
|
|
2623
2623
|
return;
|
|
2624
2624
|
}
|
|
2625
2625
|
}
|
|
2626
|
-
t.getState().setSnappedCoord(
|
|
2627
|
-
const
|
|
2628
|
-
|
|
2626
|
+
t.getState().setSnappedCoord(P.lnglat);
|
|
2627
|
+
const _ = e.getSource(Me);
|
|
2628
|
+
_ == null || _.setData({
|
|
2629
2629
|
type: "FeatureCollection",
|
|
2630
2630
|
features: [{
|
|
2631
2631
|
type: "Feature",
|
|
2632
|
-
properties: { _kind:
|
|
2633
|
-
geometry: { type: "Point", coordinates:
|
|
2632
|
+
properties: { _kind: P.isVertex ? "vertex" : "edge" },
|
|
2633
|
+
geometry: { type: "Point", coordinates: P.lnglat }
|
|
2634
2634
|
}]
|
|
2635
2635
|
});
|
|
2636
|
-
}), g = (T) => d.schedule(T), w = () => d.flush(),
|
|
2636
|
+
}), g = (T) => d.schedule(T), w = () => d.flush(), C = () => {
|
|
2637
2637
|
d.cancel(), c();
|
|
2638
2638
|
};
|
|
2639
|
-
return e.on("mousemove", g), e.on("mouseout",
|
|
2640
|
-
d.cancel(), e.off("mousemove", g), e.off("mouseout",
|
|
2639
|
+
return e.on("mousemove", g), e.on("mouseout", C), window.addEventListener("pointerdown", w, !0), window.addEventListener("pointerup", w, !0), () => {
|
|
2640
|
+
d.cancel(), e.off("mousemove", g), e.off("mouseout", C), window.removeEventListener("pointerdown", w, !0), window.removeEventListener("pointerup", w, !0);
|
|
2641
2641
|
};
|
|
2642
2642
|
}, [o, r, s, i, e, t, n, l]), null;
|
|
2643
2643
|
}
|
|
2644
|
-
function
|
|
2644
|
+
function ii({ map: e }) {
|
|
2645
2645
|
const t = he((n) => n.features);
|
|
2646
2646
|
return K(() => {
|
|
2647
2647
|
if (t.length === 0) return;
|
|
@@ -3034,125 +3034,125 @@ const Ls = ao(function({
|
|
|
3034
3034
|
);
|
|
3035
3035
|
});
|
|
3036
3036
|
function Es({ map: e }) {
|
|
3037
|
-
const t = vt(), n = W((
|
|
3037
|
+
const t = vt(), n = W((p) => p.editingMode), o = W((p) => p.measurePoints), r = W((p) => p.measureMode), s = W((p) => p.completedMeasurements), i = W((p) => p.selectedMeasurementId), l = W((p) => p.snappedCoord), u = W((p) => p.toggleMeasurementSelection), c = W((p) => p.setSelectedMeasurementId), v = oo(e, n, n === "measure"), { units: d } = ke(), g = { unit: d.length, display: d.display, precision: d.precision }, w = { unit: d.area, display: d.display, precision: d.precision }, [C, T] = le(null), F = n === "measure", k = F ? l ?? v : null, N = o.length > 0 ? o[o.length - 1] : null;
|
|
3038
3038
|
K(() => {
|
|
3039
|
-
const
|
|
3039
|
+
const p = [];
|
|
3040
3040
|
for (const f of s) {
|
|
3041
|
-
const b =
|
|
3041
|
+
const b = C === f.id, M = i === f.id;
|
|
3042
3042
|
if (f.mode === "distance") {
|
|
3043
|
-
for (let
|
|
3044
|
-
|
|
3043
|
+
for (let E = 0; E < f.points.length - 1; E++)
|
|
3044
|
+
p.push({
|
|
3045
3045
|
type: "Feature",
|
|
3046
|
-
properties: { _kind: "segment", _id: f.id, _segIdx:
|
|
3047
|
-
geometry: { type: "LineString", coordinates: [f.points[
|
|
3046
|
+
properties: { _kind: "segment", _id: f.id, _segIdx: E, _hovered: b, _selected: M },
|
|
3047
|
+
geometry: { type: "LineString", coordinates: [f.points[E], f.points[E + 1]] }
|
|
3048
3048
|
});
|
|
3049
|
-
f.points.forEach((
|
|
3050
|
-
|
|
3049
|
+
f.points.forEach((E, a) => {
|
|
3050
|
+
p.push({
|
|
3051
3051
|
type: "Feature",
|
|
3052
3052
|
properties: { _kind: "dot", _id: f.id, _isFirst: a === 0 },
|
|
3053
|
-
geometry: { type: "Point", coordinates:
|
|
3053
|
+
geometry: { type: "Point", coordinates: E }
|
|
3054
3054
|
});
|
|
3055
3055
|
});
|
|
3056
3056
|
} else
|
|
3057
|
-
|
|
3057
|
+
p.push({
|
|
3058
3058
|
type: "Feature",
|
|
3059
|
-
properties: { _kind: "area", _id: f.id, _hovered: b, _selected:
|
|
3059
|
+
properties: { _kind: "area", _id: f.id, _hovered: b, _selected: M },
|
|
3060
3060
|
geometry: { type: "Polygon", coordinates: [f.points] }
|
|
3061
|
-
}),
|
|
3061
|
+
}), p.push({
|
|
3062
3062
|
type: "Feature",
|
|
3063
|
-
properties: { _kind: "segment", _id: f.id, _hovered: b, _selected:
|
|
3063
|
+
properties: { _kind: "segment", _id: f.id, _hovered: b, _selected: M },
|
|
3064
3064
|
geometry: { type: "LineString", coordinates: f.points }
|
|
3065
|
-
}), f.points.slice(0, -1).forEach((
|
|
3066
|
-
|
|
3065
|
+
}), f.points.slice(0, -1).forEach((E, a) => {
|
|
3066
|
+
p.push({
|
|
3067
3067
|
type: "Feature",
|
|
3068
3068
|
properties: { _kind: "dot", _id: f.id, _isFirst: a === 0 },
|
|
3069
|
-
geometry: { type: "Point", coordinates:
|
|
3069
|
+
geometry: { type: "Point", coordinates: E }
|
|
3070
3070
|
});
|
|
3071
3071
|
});
|
|
3072
3072
|
}
|
|
3073
|
-
|
|
3073
|
+
F && o.length >= 2 && p.push({
|
|
3074
3074
|
type: "Feature",
|
|
3075
3075
|
properties: { _kind: "live-line" },
|
|
3076
3076
|
geometry: { type: "LineString", coordinates: o }
|
|
3077
|
-
}),
|
|
3077
|
+
}), F && r === "area" && o.length >= 3 && p.push({
|
|
3078
3078
|
type: "Feature",
|
|
3079
3079
|
properties: { _kind: "live-area" },
|
|
3080
3080
|
geometry: { type: "Polygon", coordinates: [[...o, o[0]]] }
|
|
3081
|
-
}),
|
|
3081
|
+
}), F && k && N && p.push({
|
|
3082
3082
|
type: "Feature",
|
|
3083
3083
|
properties: { _kind: "ghost" },
|
|
3084
|
-
geometry: { type: "LineString", coordinates: [N,
|
|
3085
|
-
}),
|
|
3084
|
+
geometry: { type: "LineString", coordinates: [N, k] }
|
|
3085
|
+
}), F && r === "area" && k && o.length >= 2 && p.push({
|
|
3086
3086
|
type: "Feature",
|
|
3087
3087
|
properties: { _kind: "close-hint" },
|
|
3088
|
-
geometry: { type: "LineString", coordinates: [
|
|
3089
|
-
}),
|
|
3090
|
-
|
|
3088
|
+
geometry: { type: "LineString", coordinates: [k, o[0]] }
|
|
3089
|
+
}), F && o.forEach((f, b) => {
|
|
3090
|
+
p.push({
|
|
3091
3091
|
type: "Feature",
|
|
3092
3092
|
properties: { _kind: "live-dot", _isFirst: b === 0 },
|
|
3093
3093
|
geometry: { type: "Point", coordinates: f }
|
|
3094
3094
|
});
|
|
3095
|
-
}), ws(e,
|
|
3095
|
+
}), ws(e, p);
|
|
3096
3096
|
}, [
|
|
3097
3097
|
e,
|
|
3098
|
-
|
|
3098
|
+
F,
|
|
3099
3099
|
o,
|
|
3100
3100
|
r,
|
|
3101
3101
|
s,
|
|
3102
|
-
|
|
3102
|
+
C,
|
|
3103
3103
|
i,
|
|
3104
|
-
|
|
3104
|
+
k,
|
|
3105
3105
|
N,
|
|
3106
3106
|
t
|
|
3107
3107
|
]), K(() => {
|
|
3108
|
-
const
|
|
3109
|
-
var
|
|
3110
|
-
const a = (
|
|
3108
|
+
const p = (E) => {
|
|
3109
|
+
var y, m;
|
|
3110
|
+
const a = (y = E.features) == null ? void 0 : y[0];
|
|
3111
3111
|
if (!a) return;
|
|
3112
3112
|
const x = (m = a.properties) == null ? void 0 : m._id;
|
|
3113
|
-
x && (Pr(),
|
|
3114
|
-
}, f = (
|
|
3115
|
-
var
|
|
3116
|
-
const a = (
|
|
3113
|
+
x && (Pr(), E.originalEvent.stopPropagation(), u(x));
|
|
3114
|
+
}, f = (E) => {
|
|
3115
|
+
var R, S, L, B;
|
|
3116
|
+
const a = (R = E.features) == null ? void 0 : R[0];
|
|
3117
3117
|
if (!a) return;
|
|
3118
3118
|
const x = (S = a.properties) == null ? void 0 : S._id;
|
|
3119
3119
|
if (!x) return;
|
|
3120
3120
|
T(x);
|
|
3121
|
-
const
|
|
3122
|
-
if (
|
|
3121
|
+
const y = (L = a.properties) == null ? void 0 : L._kind, m = (B = a.properties) == null ? void 0 : B._segIdx;
|
|
3122
|
+
if (y === "segment" && typeof m == "number") {
|
|
3123
3123
|
const V = s.find((j) => j.id === x);
|
|
3124
3124
|
if (V && V.mode === "distance") {
|
|
3125
3125
|
const j = V.points[m], h = V.points[m + 1];
|
|
3126
3126
|
if (j && h) {
|
|
3127
|
-
const
|
|
3128
|
-
Ss(`${
|
|
3127
|
+
const I = mt(_e(We([j, h])) * 1e3, g);
|
|
3128
|
+
Ss(`${I.value} ${I.unit}`, E.originalEvent.clientX, E.originalEvent.clientY);
|
|
3129
3129
|
}
|
|
3130
3130
|
}
|
|
3131
3131
|
}
|
|
3132
|
-
}, b = (
|
|
3133
|
-
var
|
|
3134
|
-
const a = (
|
|
3132
|
+
}, b = (E) => {
|
|
3133
|
+
var y, m;
|
|
3134
|
+
const a = (y = E.features) == null ? void 0 : y[0];
|
|
3135
3135
|
if (!a) return;
|
|
3136
|
-
((m = a.properties) == null ? void 0 : m._kind) === "segment" && ro(
|
|
3137
|
-
},
|
|
3136
|
+
((m = a.properties) == null ? void 0 : m._kind) === "segment" && ro(E.originalEvent.clientX, E.originalEvent.clientY);
|
|
3137
|
+
}, M = () => {
|
|
3138
3138
|
T(null), Cn();
|
|
3139
|
-
},
|
|
3139
|
+
}, A = (E) => {
|
|
3140
3140
|
try {
|
|
3141
|
-
e.queryRenderedFeatures(
|
|
3141
|
+
e.queryRenderedFeatures(E.point, { layers: Rt }).length === 0 && c(null);
|
|
3142
3142
|
} catch {
|
|
3143
3143
|
}
|
|
3144
3144
|
};
|
|
3145
|
-
for (const
|
|
3146
|
-
e.on("click",
|
|
3147
|
-
return e.on("click",
|
|
3148
|
-
for (const
|
|
3149
|
-
e.off("click",
|
|
3150
|
-
e.off("click",
|
|
3145
|
+
for (const E of Rt)
|
|
3146
|
+
e.on("click", E, p), e.on("mouseenter", E, f), e.on("mousemove", E, b), e.on("mouseleave", E, M);
|
|
3147
|
+
return e.on("click", A), () => {
|
|
3148
|
+
for (const E of Rt)
|
|
3149
|
+
e.off("click", E, p), e.off("mouseenter", E, f), e.off("mousemove", E, b), e.off("mouseleave", E, M);
|
|
3150
|
+
e.off("click", A), Cn();
|
|
3151
3151
|
};
|
|
3152
3152
|
}, [e, u, c, s, g.unit, g.display, g.precision]);
|
|
3153
|
-
const
|
|
3153
|
+
const P = r === "distance" ? 1 : 2, _ = k && o.length >= P ? [...o, k] : o, D = bs(_, r, g, w), q = k ?? N;
|
|
3154
3154
|
return /* @__PURE__ */ fe(lt, { children: [
|
|
3155
|
-
s.map((
|
|
3155
|
+
s.map((p) => /* @__PURE__ */ X(Ls, { map: e, m: p }, p.id)),
|
|
3156
3156
|
D && q && /* @__PURE__ */ X(so, { map: e, position: q, parts: D })
|
|
3157
3157
|
] });
|
|
3158
3158
|
}
|
|
@@ -3271,42 +3271,42 @@ async function Fs(e, t) {
|
|
|
3271
3271
|
function _s({ map: e }) {
|
|
3272
3272
|
const { dataStore: t, uiStore: n } = Le(), o = ke().network, r = $(o);
|
|
3273
3273
|
r.current = o;
|
|
3274
|
-
const s = Ue(), i = zt(), l = W((
|
|
3274
|
+
const s = Ue(), i = zt(), l = W((p) => p.editingMode), [u, c] = le(null), [v, d] = le(null), g = Oo(), w = An(), C = $(null), T = $(null), F = $(null), k = $(null);
|
|
3275
3275
|
K(() => () => {
|
|
3276
|
-
|
|
3276
|
+
F.current && (F.current.remove(), F.current = null);
|
|
3277
3277
|
}, [e]);
|
|
3278
3278
|
const N = vt();
|
|
3279
3279
|
K(() => {
|
|
3280
3280
|
ks(e, u, v);
|
|
3281
3281
|
}, [e, u, v, N]);
|
|
3282
|
-
const
|
|
3283
|
-
(
|
|
3282
|
+
const P = ve(
|
|
3283
|
+
(p) => Mo(t.getState(), n.getState(), p),
|
|
3284
3284
|
[t, n]
|
|
3285
|
-
),
|
|
3286
|
-
|
|
3285
|
+
), _ = ve(() => {
|
|
3286
|
+
F.current && (F.current.remove(), F.current = null);
|
|
3287
3287
|
}, []), D = ve(() => {
|
|
3288
|
-
c(null), d(null),
|
|
3289
|
-
}, [
|
|
3290
|
-
const f =
|
|
3291
|
-
if (D(), !("pieces" in
|
|
3292
|
-
|
|
3288
|
+
c(null), d(null), C.current = null, _(), T.current && (T.current.abort(), T.current = null);
|
|
3289
|
+
}, [_]), q = ve((p) => {
|
|
3290
|
+
const f = C.current;
|
|
3291
|
+
if (D(), !("pieces" in p)) {
|
|
3292
|
+
P(p);
|
|
3293
3293
|
return;
|
|
3294
3294
|
}
|
|
3295
3295
|
if (!f) return;
|
|
3296
3296
|
const b = new AbortController();
|
|
3297
|
-
T.current = b, Fs(
|
|
3298
|
-
b.signal.aborted || (T.current = null,
|
|
3297
|
+
T.current = b, Fs(p, f).then((M) => {
|
|
3298
|
+
b.signal.aborted || (T.current = null, M && P(M));
|
|
3299
3299
|
});
|
|
3300
|
-
}, [
|
|
3300
|
+
}, [P, D]);
|
|
3301
3301
|
return K(() => {
|
|
3302
3302
|
if (!u && l !== "pick-shape") return;
|
|
3303
|
-
function
|
|
3303
|
+
function p(f) {
|
|
3304
3304
|
f.key === "Escape" && i(f) && D();
|
|
3305
3305
|
}
|
|
3306
|
-
return window.addEventListener("keydown",
|
|
3306
|
+
return window.addEventListener("keydown", p), () => window.removeEventListener("keydown", p);
|
|
3307
3307
|
}, [u, l, D, i]), K(() => {
|
|
3308
3308
|
if (l !== "pick-shape") return;
|
|
3309
|
-
const
|
|
3309
|
+
const p = (f) => {
|
|
3310
3310
|
if (e.getZoom() < Ro) {
|
|
3311
3311
|
s({ type: "warning", message: "Zoom in further to use the picker" });
|
|
3312
3312
|
return;
|
|
@@ -3314,72 +3314,72 @@ function _s({ map: e }) {
|
|
|
3314
3314
|
f.originalEvent.preventDefault(), D();
|
|
3315
3315
|
const b = new AbortController();
|
|
3316
3316
|
T.current = b;
|
|
3317
|
-
const
|
|
3318
|
-
|
|
3319
|
-
const
|
|
3320
|
-
|
|
3317
|
+
const M = f.lngLat.lng, A = f.lngLat.lat;
|
|
3318
|
+
C.current = [M, A], Ps();
|
|
3319
|
+
const E = document.createElement("div");
|
|
3320
|
+
E.style.cssText = "width:64px;height:64px;pointer-events:none;display:flex;align-items:center;justify-content:center;", E.innerHTML = `
|
|
3321
3321
|
<div class="elm-osm-pulse-ring" style="position:absolute"></div>
|
|
3322
3322
|
<div class="elm-osm-spinner"></div>
|
|
3323
|
-
`,
|
|
3324
|
-
const a = Rs(e, f.point), { overpass: x, fetch:
|
|
3325
|
-
(a.length > 0 || m ? Promise.resolve(a) : Qo(
|
|
3326
|
-
|
|
3323
|
+
`, F.current = new De.Marker({ element: E, anchor: "center" }).setLngLat([M, A]).addTo(e);
|
|
3324
|
+
const a = Rs(e, f.point), { overpass: x, fetch: y } = r.current, m = x === !1;
|
|
3325
|
+
(a.length > 0 || m ? Promise.resolve(a) : Qo(A, M, Fo(e.getZoom()), [M, A], { ...x, fetch: y, signal: b.signal })).then((S) => {
|
|
3326
|
+
_(), S.length === 0 ? (s({ type: "warning", message: m ? "No shape here in the basemap" : "No features found here" }), D()) : S.length === 1 ? q(S[0]) : c(S);
|
|
3327
3327
|
}).catch((S) => {
|
|
3328
|
-
(S == null ? void 0 : S.name) !== "AbortError" && (
|
|
3328
|
+
(S == null ? void 0 : S.name) !== "AbortError" && (_(), s({ type: "error", code: S instanceof tr ? S.code : "unknown", source: "picker", message: er(S), cause: S }), D());
|
|
3329
3329
|
});
|
|
3330
3330
|
};
|
|
3331
|
-
return e.on("click",
|
|
3332
|
-
e.off("click",
|
|
3331
|
+
return e.on("click", p), () => {
|
|
3332
|
+
e.off("click", p);
|
|
3333
3333
|
};
|
|
3334
|
-
}, [l, e, D,
|
|
3335
|
-
if (!u || !
|
|
3336
|
-
const
|
|
3334
|
+
}, [l, e, D, _, q, s]), K(() => {
|
|
3335
|
+
if (!u || !C.current) return;
|
|
3336
|
+
const p = C.current;
|
|
3337
3337
|
let f;
|
|
3338
3338
|
function b() {
|
|
3339
|
-
if (!
|
|
3339
|
+
if (!k.current) {
|
|
3340
3340
|
f = requestAnimationFrame(b);
|
|
3341
3341
|
return;
|
|
3342
3342
|
}
|
|
3343
|
-
const
|
|
3344
|
-
|
|
3343
|
+
const M = e.project(p), A = e.getContainer().getBoundingClientRect();
|
|
3344
|
+
k.current.style.left = `${A.left + M.x + 16}px`, k.current.style.top = `${A.top + M.y - 8}px`, f = requestAnimationFrame(b);
|
|
3345
3345
|
}
|
|
3346
3346
|
return f = requestAnimationFrame(b), () => cancelAnimationFrame(f);
|
|
3347
3347
|
}, [u, e]), K(() => {
|
|
3348
3348
|
if (!u) return;
|
|
3349
|
-
const
|
|
3350
|
-
var m,
|
|
3351
|
-
const a = (m =
|
|
3349
|
+
const p = (E) => {
|
|
3350
|
+
var m, R;
|
|
3351
|
+
const a = (m = E.features) == null ? void 0 : m[0];
|
|
3352
3352
|
if (!a) return;
|
|
3353
|
-
const x = (
|
|
3353
|
+
const x = (R = a.properties) == null ? void 0 : R._idx;
|
|
3354
3354
|
if (typeof x != "number") return;
|
|
3355
|
-
|
|
3356
|
-
const
|
|
3357
|
-
|
|
3358
|
-
}, f = (
|
|
3359
|
-
var
|
|
3360
|
-
const a = (
|
|
3355
|
+
E.originalEvent.stopPropagation();
|
|
3356
|
+
const y = u[x];
|
|
3357
|
+
y && q(y);
|
|
3358
|
+
}, f = (E) => {
|
|
3359
|
+
var y, m;
|
|
3360
|
+
const a = (y = E.features) == null ? void 0 : y[0];
|
|
3361
3361
|
if (!a) return;
|
|
3362
3362
|
const x = (m = a.properties) == null ? void 0 : m._idx;
|
|
3363
3363
|
typeof x == "number" && d(x), e.getCanvas().style.cursor = "pointer";
|
|
3364
3364
|
}, b = () => {
|
|
3365
3365
|
e.getCanvas().style.cursor = Ge(n.getState().editingMode);
|
|
3366
|
-
},
|
|
3366
|
+
}, M = () => {
|
|
3367
3367
|
d(null), b();
|
|
3368
|
-
},
|
|
3369
|
-
for (const
|
|
3370
|
-
e.on("click",
|
|
3368
|
+
}, A = ["elm-osm-trace-fill", "elm-osm-trace-line"];
|
|
3369
|
+
for (const E of A)
|
|
3370
|
+
e.on("click", E, p), e.on("mouseenter", E, f), e.on("mouseleave", E, M);
|
|
3371
3371
|
return () => {
|
|
3372
|
-
for (const
|
|
3373
|
-
e.off("click",
|
|
3372
|
+
for (const E of A)
|
|
3373
|
+
e.off("click", E, p), e.off("mouseenter", E, f), e.off("mouseleave", E, M);
|
|
3374
3374
|
b();
|
|
3375
3375
|
};
|
|
3376
3376
|
}, [u, e, q, n]), K(() => {
|
|
3377
3377
|
l !== "pick-shape" && D();
|
|
3378
3378
|
}, [l, D]), u ? Ze(
|
|
3379
|
-
/* @__PURE__ */ X("div", { ref:
|
|
3379
|
+
/* @__PURE__ */ X("div", { ref: k, "data-elm-portal": !0, "data-elm-theme": w, style: { ...g, position: "fixed", zIndex: 1e4 }, children: /* @__PURE__ */ X("div", { className: "bg-elm-surface/95 backdrop-blur-md border border-elm-border/80 text-elm-text-secondary shadow-elm rounded-elm overflow-hidden min-w-[180px] max-w-[280px] text-sm py-1", children: u.map((p, f) => /* @__PURE__ */ fe(
|
|
3380
3380
|
"button",
|
|
3381
3381
|
{
|
|
3382
|
-
onClick: () => q(
|
|
3382
|
+
onClick: () => q(p),
|
|
3383
3383
|
onMouseEnter: () => d(f),
|
|
3384
3384
|
onMouseLeave: () => d(null),
|
|
3385
3385
|
className: `w-full text-left px-3 py-2 flex items-center gap-2 transition-colors ${v === f ? "bg-primary-50 dark:bg-white/5" : "hover:bg-(--elm-surface-hover,var(--color-gray-50)) dark:hover:bg-elm-surface-hover"}`,
|
|
@@ -3392,12 +3392,12 @@ function _s({ map: e }) {
|
|
|
3392
3392
|
}
|
|
3393
3393
|
),
|
|
3394
3394
|
/* @__PURE__ */ fe("span", { className: "flex flex-col min-w-0", children: [
|
|
3395
|
-
/* @__PURE__ */ X("span", { className: "font-medium text-(--elm-text,var(--color-gray-800)) dark:text-(--elm-text,var(--color-gray-100)) truncate", children:
|
|
3396
|
-
/* @__PURE__ */ X("span", { className: "text-xs text-(--elm-text-subtle,var(--color-gray-400))", children:
|
|
3395
|
+
/* @__PURE__ */ X("span", { className: "font-medium text-(--elm-text,var(--color-gray-800)) dark:text-(--elm-text,var(--color-gray-100)) truncate", children: p.name || `Unnamed ${p.type.toLowerCase()}` }),
|
|
3396
|
+
/* @__PURE__ */ X("span", { className: "text-xs text-(--elm-text-subtle,var(--color-gray-400))", children: p.type })
|
|
3397
3397
|
] })
|
|
3398
3398
|
]
|
|
3399
3399
|
},
|
|
3400
|
-
"key" in
|
|
3400
|
+
"key" in p ? p.key : `${p.osmId}/${f}`
|
|
3401
3401
|
)) }) }),
|
|
3402
3402
|
document.body
|
|
3403
3403
|
) : null;
|
|
@@ -3435,84 +3435,84 @@ function Ds(e, t) {
|
|
|
3435
3435
|
}
|
|
3436
3436
|
function Ks({ map: e }) {
|
|
3437
3437
|
const { units: t } = ke(), n = { unit: t.length, display: t.display, precision: t.precision }, o = { unit: t.area, display: t.display, precision: t.precision }, r = (f) => {
|
|
3438
|
-
const { value: b, unit:
|
|
3439
|
-
return `${b} ${
|
|
3438
|
+
const { value: b, unit: M } = mt(f * 1e3, n);
|
|
3439
|
+
return `${b} ${M}`;
|
|
3440
3440
|
}, s = (f) => {
|
|
3441
|
-
const { value: b, unit:
|
|
3442
|
-
return `${b} ${
|
|
3443
|
-
}, i = W((f) => f.showMeasurements), l = W((f) => f.editingMode), u = W((f) => f.snappedCoord), c = W((f) => f.lineInProgress), v = W((f) => f.polygonInProgress), d = W((f) => f.circleCenter), g = W((f) => f.rectCorner), w = W((f) => f.freehandPoints),
|
|
3441
|
+
const { value: b, unit: M } = Ht(f, o);
|
|
3442
|
+
return `${b} ${M}`;
|
|
3443
|
+
}, i = W((f) => f.showMeasurements), l = W((f) => f.editingMode), u = W((f) => f.snappedCoord), c = W((f) => f.lineInProgress), v = W((f) => f.polygonInProgress), d = W((f) => f.circleCenter), g = W((f) => f.rectCorner), w = W((f) => f.freehandPoints), C = W((f) => f.freehandClosed), T = W((f) => f.routeWaypoints), F = oo(e, l, l !== "none"), [k, N] = le(null), P = u ?? F;
|
|
3444
3444
|
K(() => {
|
|
3445
|
-
if (!
|
|
3445
|
+
if (!P) {
|
|
3446
3446
|
N(null);
|
|
3447
3447
|
return;
|
|
3448
3448
|
}
|
|
3449
|
-
N(e.project(
|
|
3450
|
-
const f = () => N(
|
|
3449
|
+
N(e.project(P));
|
|
3450
|
+
const f = () => N(P ? e.project(P) : null);
|
|
3451
3451
|
return e.on("move", f), e.on("zoom", f), () => {
|
|
3452
3452
|
e.off("move", f), e.off("zoom", f);
|
|
3453
3453
|
};
|
|
3454
|
-
}, [e,
|
|
3455
|
-
const
|
|
3454
|
+
}, [e, P == null ? void 0 : P[0], P == null ? void 0 : P[1]]);
|
|
3455
|
+
const _ = $(null), [D, q] = le({ w: 0, h: 0 });
|
|
3456
3456
|
if (uo(() => {
|
|
3457
|
-
const f =
|
|
3457
|
+
const f = _.current;
|
|
3458
3458
|
f && (f.offsetWidth !== D.w || f.offsetHeight !== D.h) && q({ w: f.offsetWidth, h: f.offsetHeight });
|
|
3459
|
-
}), !i || l === "none" || !
|
|
3460
|
-
const
|
|
3459
|
+
}), !i || l === "none" || !P || !k) return null;
|
|
3460
|
+
const p = [];
|
|
3461
3461
|
try {
|
|
3462
3462
|
if (l === "place-point")
|
|
3463
|
-
|
|
3463
|
+
p.push({ label: "", value: `${P[1].toFixed(6)}, ${P[0].toFixed(6)}` });
|
|
3464
3464
|
else if (l === "draw-line" || l === "slice-shape") {
|
|
3465
|
-
const f = [...c,
|
|
3465
|
+
const f = [...c, P];
|
|
3466
3466
|
if (f.length >= 2) {
|
|
3467
3467
|
const b = We(f);
|
|
3468
|
-
|
|
3468
|
+
p.push({ label: "Length", value: r(_e(b)) }), p.push({ label: "Segment length", value: r(Pe(f[f.length - 2], f[f.length - 1])) });
|
|
3469
3469
|
}
|
|
3470
|
-
|
|
3470
|
+
p.push({ label: "", value: `${P[1].toFixed(6)}, ${P[0].toFixed(6)}` });
|
|
3471
3471
|
} else if (l === "draw-polygon" || l === "cut-hole") {
|
|
3472
|
-
const f = [...v,
|
|
3472
|
+
const f = [...v, P];
|
|
3473
3473
|
if (f.length >= 3) {
|
|
3474
|
-
const b = [...f, f[0]],
|
|
3475
|
-
|
|
3476
|
-
const
|
|
3477
|
-
|
|
3478
|
-
} else f.length === 2 &&
|
|
3479
|
-
|
|
3474
|
+
const b = [...f, f[0]], M = ut([b]);
|
|
3475
|
+
p.push({ label: "Area", value: s(dt(M)) }), p.push({ label: "Perimeter", value: r(_e(M)) });
|
|
3476
|
+
const A = Bn(M);
|
|
3477
|
+
p.push({ label: "Height", value: r(Pe([A[0], A[1]], [A[0], A[3]])) }), p.push({ label: "Width", value: r(Pe([A[0], A[1]], [A[2], A[1]])) });
|
|
3478
|
+
} else f.length === 2 && p.push({ label: "Segment length", value: r(Pe(f[0], f[1])) });
|
|
3479
|
+
p.push({ label: "", value: `${P[1].toFixed(6)}, ${P[0].toFixed(6)}` });
|
|
3480
3480
|
} else if (l === "draw-circle") {
|
|
3481
3481
|
if (d) {
|
|
3482
|
-
const f = Pe(d,
|
|
3483
|
-
|
|
3482
|
+
const f = Pe(d, P);
|
|
3483
|
+
p.push({ label: "Radius", value: r(f) }), p.push({ label: "Area", value: s(Math.PI * (f * 1e3) * (f * 1e3)) });
|
|
3484
3484
|
}
|
|
3485
|
-
|
|
3485
|
+
p.push({ label: "", value: `${P[1].toFixed(6)}, ${P[0].toFixed(6)}` });
|
|
3486
3486
|
} else if (l === "draw-rect") {
|
|
3487
3487
|
if (g) {
|
|
3488
|
-
const f = Pe([g[0], g[1]], [
|
|
3489
|
-
|
|
3488
|
+
const f = Pe([g[0], g[1]], [P[0], g[1]]), b = Pe([g[0], g[1]], [g[0], P[1]]), M = f * b * 1e6;
|
|
3489
|
+
p.push({ label: "Area", value: s(M) }), p.push({ label: "Width", value: r(f) }), p.push({ label: "Height", value: r(b) });
|
|
3490
3490
|
}
|
|
3491
|
-
|
|
3491
|
+
p.push({ label: "", value: `${P[1].toFixed(6)}, ${P[0].toFixed(6)}` });
|
|
3492
3492
|
} else if (l === "draw-route") {
|
|
3493
|
-
const f = [...T,
|
|
3494
|
-
f.length >= 2 &&
|
|
3493
|
+
const f = [...T, P];
|
|
3494
|
+
f.length >= 2 && p.push({ label: "Straight distance", value: r(Pe(f[f.length - 2], f[f.length - 1])) }), p.push({ label: "", value: `${P[1].toFixed(6)}, ${P[0].toFixed(6)}` });
|
|
3495
3495
|
} else if (l === "draw-freehand") {
|
|
3496
|
-
if (w.length >= 3 &&
|
|
3496
|
+
if (w.length >= 3 && C) {
|
|
3497
3497
|
const f = [...w, w[0]], b = ut([f]);
|
|
3498
|
-
|
|
3498
|
+
p.push({ label: "Area", value: s(dt(b)) }), p.push({ label: "Perimeter", value: r(_e(b)) });
|
|
3499
3499
|
} else if (w.length >= 2) {
|
|
3500
3500
|
const f = We(w);
|
|
3501
|
-
|
|
3501
|
+
p.push({ label: "Length", value: r(_e(f)) });
|
|
3502
3502
|
}
|
|
3503
|
-
|
|
3503
|
+
p.push({ label: "", value: `${P[1].toFixed(6)}, ${P[0].toFixed(6)}` });
|
|
3504
3504
|
}
|
|
3505
3505
|
} catch {
|
|
3506
3506
|
}
|
|
3507
|
-
return
|
|
3507
|
+
return p.length === 0 ? null : Ze(
|
|
3508
3508
|
/* @__PURE__ */ X(
|
|
3509
3509
|
"div",
|
|
3510
3510
|
{
|
|
3511
|
-
ref:
|
|
3511
|
+
ref: _,
|
|
3512
3512
|
className: "elm-measurement-tooltip",
|
|
3513
3513
|
style: {
|
|
3514
3514
|
position: "absolute",
|
|
3515
|
-
...Fn(
|
|
3515
|
+
...Fn(k.x, k.y, D.w, D.h, {
|
|
3516
3516
|
x: "after",
|
|
3517
3517
|
y: "center",
|
|
3518
3518
|
gapX: 20,
|
|
@@ -3531,7 +3531,7 @@ function Ks({ map: e }) {
|
|
|
3531
3531
|
color: "var(--elm-text-secondary, rgb(75, 85, 99))",
|
|
3532
3532
|
fontFamily: "var(--elm-font, ui-sans-serif, system-ui, sans-serif)"
|
|
3533
3533
|
},
|
|
3534
|
-
children: /* @__PURE__ */ X("div", { style: { display: "flex", flexDirection: "column", gap: 4, textAlign: "left" }, children:
|
|
3534
|
+
children: /* @__PURE__ */ X("div", { style: { display: "flex", flexDirection: "column", gap: 4, textAlign: "left" }, children: p.map((f, b) => /* @__PURE__ */ fe("div", { style: { display: "flex", gap: 8, alignItems: "center", lineHeight: 1.3 }, children: [
|
|
3535
3535
|
f.label && /* @__PURE__ */ fe("span", { style: { fontWeight: 600, color: "var(--elm-text, rgb(17, 24, 39))" }, children: [
|
|
3536
3536
|
f.label,
|
|
3537
3537
|
":"
|
|
@@ -3544,7 +3544,7 @@ function Ks({ map: e }) {
|
|
|
3544
3544
|
);
|
|
3545
3545
|
}
|
|
3546
3546
|
const Qt = Nt(null);
|
|
3547
|
-
function
|
|
3547
|
+
function ci() {
|
|
3548
3548
|
const e = pt(Qt);
|
|
3549
3549
|
if (!e) throw new Error("useMapLibre must be used inside ElementEditorControls");
|
|
3550
3550
|
return e;
|
|
@@ -3631,7 +3631,7 @@ const Os = In(
|
|
|
3631
3631
|
t.children
|
|
3632
3632
|
] });
|
|
3633
3633
|
}
|
|
3634
|
-
),
|
|
3634
|
+
), li = In(
|
|
3635
3635
|
function(t, n) {
|
|
3636
3636
|
const [o, r] = le(() => t.map.isStyleLoaded()), [s, i] = le(0);
|
|
3637
3637
|
K(() => Ds(t.map, () => {
|
|
@@ -3659,7 +3659,7 @@ function je(e, t) {
|
|
|
3659
3659
|
const n = e.id ?? e.label ?? ("url" in e ? e.url : typeof e.style == "string" ? e.style : void 0);
|
|
3660
3660
|
return n || (t >= 0 ? `custom-${t}` : (Ft.has(e) || Ft.set(e, `custom-anon-${++js}`), Ft.get(e)));
|
|
3661
3661
|
}
|
|
3662
|
-
const io = () => import("./style-
|
|
3662
|
+
const io = () => import("./style-DVShZtJT.js"), zs = () => Promise.all([io(), import("./catalog-gI-xABuu.js")]).then(([e, t]) => ({ ...e, ...t }));
|
|
3663
3663
|
let yt = !1;
|
|
3664
3664
|
const co = (e) => new Tt(
|
|
3665
3665
|
"network",
|
|
@@ -3694,99 +3694,99 @@ function Hs(e, t, n) {
|
|
|
3694
3694
|
const g = c(t);
|
|
3695
3695
|
if (v.current === "" && (v.current = je(i.resolveBasemap(d.current.basemap, d.current.theme), -1)), v.current === g) return;
|
|
3696
3696
|
let w = !1;
|
|
3697
|
-
const
|
|
3698
|
-
N(), v.current = null, u(new Tt(ln(D.error), "basemap", `The basemap could not be loaded (${
|
|
3697
|
+
const C = (D) => D instanceof Error ? D.message : String(D), T = i.resolveBasemap(t, o), F = typeof T == "object" && "style" in T && typeof T.style == "string", k = (D) => {
|
|
3698
|
+
N(), v.current = null, u(new Tt(ln(D.error), "basemap", `The basemap could not be loaded (${C(D.error)}).`, { cause: D.error }));
|
|
3699
3699
|
}, N = () => {
|
|
3700
|
-
e.off("error",
|
|
3701
|
-
},
|
|
3702
|
-
w || !(e.isStyleLoaded() || e.getSource("elm-features")) || (w = !0, e.off("styledata",
|
|
3703
|
-
|
|
3700
|
+
e.off("error", k), e.off("styledata", N);
|
|
3701
|
+
}, P = () => {
|
|
3702
|
+
w || !(e.isStyleLoaded() || e.getSource("elm-features")) || (w = !0, e.off("styledata", P), v.current = g, i.setBasemap(e, t, { theme: o, network: s.current }).then(() => {
|
|
3703
|
+
F && !_ && (e.on("error", k), e.once("styledata", N));
|
|
3704
3704
|
}, (D) => {
|
|
3705
|
-
v.current = null, u(new Tt(ln(D), "basemap", `The basemap could not be switched (${
|
|
3705
|
+
v.current = null, u(new Tt(ln(D), "basemap", `The basemap could not be switched (${C(D)}). The map keeps the previous one.`, { cause: D }));
|
|
3706
3706
|
}));
|
|
3707
3707
|
};
|
|
3708
|
-
let
|
|
3709
|
-
return e.on("styledata",
|
|
3710
|
-
w = !0,
|
|
3708
|
+
let _ = !1;
|
|
3709
|
+
return e.on("styledata", P), P(), () => {
|
|
3710
|
+
w = !0, _ = !0, e.off("styledata", P), N();
|
|
3711
3711
|
};
|
|
3712
3712
|
}, [e, i, t, o]);
|
|
3713
3713
|
}
|
|
3714
|
-
function
|
|
3715
|
-
const { basemaps: t, value: n, defaultValue: o = "auto", onChange: r, storageKey: s, initialApplied: i, size: l, tooltipSide: u } = e, c = Ns(), v = e.map ?? c, d = An(), [g, w] = le(null),
|
|
3714
|
+
function ai(e) {
|
|
3715
|
+
const { basemaps: t, value: n, defaultValue: o = "auto", onChange: r, storageKey: s, initialApplied: i, size: l, tooltipSide: u } = e, c = Ns(), v = e.map ?? c, d = An(), [g, w] = le(null), C = lo();
|
|
3716
3716
|
K(() => {
|
|
3717
3717
|
let a = !0;
|
|
3718
3718
|
return zs().then((x) => a && w(x), (x) => {
|
|
3719
|
-
a && !yt && (yt = !0,
|
|
3719
|
+
a && !yt && (yt = !0, C(co(x)));
|
|
3720
3720
|
}), () => {
|
|
3721
3721
|
a = !1;
|
|
3722
3722
|
};
|
|
3723
3723
|
}, []);
|
|
3724
|
-
const T = ke(),
|
|
3725
|
-
(
|
|
3724
|
+
const T = ke(), F = Bt(() => t ?? ["auto", ...$s], [t]), k = F.map(je);
|
|
3725
|
+
(F.filter((a) => typeof a == "object" && !a.id && !a.label && !("url" in a) && typeof a.style != "string").length > 1 || new Set(k).size < k.length) && Rn("basemap-ids", "BasemapControl: give each custom basemap a unique `id` (two entries without one, or with the same id/label, cannot be told apart).");
|
|
3726
3726
|
const [N] = le(() => {
|
|
3727
3727
|
const a = s ? nr(s, T) : null;
|
|
3728
|
-
return a ?
|
|
3729
|
-
}), [
|
|
3730
|
-
Hs(D || n !== void 0 ? v : null,
|
|
3728
|
+
return a ? F.find((x, y) => je(x, y) === a) : void 0;
|
|
3729
|
+
}), [P, _] = le(N ?? o), [D, q] = le(n !== void 0 || e.defaultValue !== void 0 || N !== void 0), p = n ?? P, f = F.indexOf(p), b = f >= 0 ? k[f] : je(p, -1);
|
|
3730
|
+
Hs(D || n !== void 0 ? v : null, p, {
|
|
3731
3731
|
theme: d,
|
|
3732
|
-
initialApplied: D && i && b === je(o,
|
|
3732
|
+
initialApplied: D && i && b === je(o, F.indexOf(o))
|
|
3733
3733
|
});
|
|
3734
|
-
const
|
|
3735
|
-
const x =
|
|
3734
|
+
const M = ve((a) => {
|
|
3735
|
+
const x = k.indexOf(a);
|
|
3736
3736
|
if (x < 0) return;
|
|
3737
|
-
const
|
|
3738
|
-
q(!0), n === void 0 &&
|
|
3739
|
-
}, [
|
|
3737
|
+
const y = F[x];
|
|
3738
|
+
q(!0), n === void 0 && _(y), s && (typeof y == "string" || y.id) && or(s, a, T), r == null || r(y);
|
|
3739
|
+
}, [k, F, n, s, r, T]);
|
|
3740
3740
|
if (!g) return null;
|
|
3741
|
-
const
|
|
3741
|
+
const A = (a) => {
|
|
3742
3742
|
var x;
|
|
3743
|
-
return (x = g.BASEMAPS.find((
|
|
3744
|
-
},
|
|
3745
|
-
const
|
|
3743
|
+
return (x = g.BASEMAPS.find((y) => y.id === a)) == null ? void 0 : x.thumbnail;
|
|
3744
|
+
}, E = F.map((a, x) => {
|
|
3745
|
+
const y = k[x], m = typeof a == "string" ? g.BASEMAPS.find((R) => R.id === a) : void 0;
|
|
3746
3746
|
return {
|
|
3747
|
-
id:
|
|
3748
|
-
label: a === "auto" ? "Auto" : (m == null ? void 0 : m.label) ?? (typeof a == "object" && a.label ||
|
|
3747
|
+
id: y,
|
|
3748
|
+
label: a === "auto" ? "Auto" : (m == null ? void 0 : m.label) ?? (typeof a == "object" && a.label || y),
|
|
3749
3749
|
// Auto shows both looks it switches between (light → streets, dark → dark).
|
|
3750
|
-
thumbnail: a === "auto" ? [
|
|
3750
|
+
thumbnail: a === "auto" ? [A("streets"), A("dark")].every(Boolean) ? [A("streets"), A("dark")] : void 0 : typeof a == "string" ? A(a) : a.thumbnail
|
|
3751
3751
|
};
|
|
3752
3752
|
});
|
|
3753
|
-
return /* @__PURE__ */ X(Uo, { options:
|
|
3753
|
+
return /* @__PURE__ */ X(Uo, { options: E, value: b, onChange: M, size: l, tooltipSide: u });
|
|
3754
3754
|
}
|
|
3755
3755
|
export {
|
|
3756
|
-
|
|
3757
|
-
|
|
3756
|
+
fi as ActiveDrawingToolbar,
|
|
3757
|
+
ai as BasemapControl,
|
|
3758
3758
|
ys as BoundaryLayer,
|
|
3759
3759
|
rs as BoxSelectHandler,
|
|
3760
3760
|
Rr as DrawingLayer,
|
|
3761
3761
|
Ar as DrawingPreviewLayer,
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3762
|
+
gi as EditingToolbar,
|
|
3763
|
+
li as ElementEditorControls,
|
|
3764
|
+
Ci as ElementEditorError,
|
|
3765
|
+
yi as ElementEditorUIProvider,
|
|
3766
3766
|
us as FeatureInteractionLayer,
|
|
3767
3767
|
Er as FeatureLayer,
|
|
3768
3768
|
gr as FeatureStyleProvider,
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3769
|
+
ii as FitBounds,
|
|
3770
|
+
pi as FloatingToolbar,
|
|
3771
|
+
hi as GeoStoreProvider,
|
|
3772
3772
|
ms as GeometryProcessingPreview,
|
|
3773
|
-
|
|
3773
|
+
mi as MapControllerProvider,
|
|
3774
3774
|
Es as MeasurePreviewLayer,
|
|
3775
3775
|
Ks as MeasurementTooltip,
|
|
3776
3776
|
_s as OsmTraceHandler,
|
|
3777
3777
|
gs as SnapController,
|
|
3778
|
-
|
|
3778
|
+
vi as StoreContext,
|
|
3779
3779
|
es as TransformControls,
|
|
3780
3780
|
$r as VertexEditor,
|
|
3781
3781
|
Vn as findSnapPoint,
|
|
3782
3782
|
Dt as snapToAngle,
|
|
3783
3783
|
Hs as useBasemap,
|
|
3784
|
-
|
|
3784
|
+
xi as useDataStore,
|
|
3785
3785
|
yr as useFeatureStyle,
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3786
|
+
wi as useGeoStore,
|
|
3787
|
+
Si as useKeyboardShortcuts,
|
|
3788
|
+
bi as useMapController,
|
|
3789
|
+
ci as useMapLibre,
|
|
3790
|
+
Li as useSetMapController,
|
|
3791
|
+
Ei as useUIStore
|
|
3792
3792
|
};
|