@watergis/maplibre-gl-terradraw 1.3.2 → 1.3.4
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/dist/maplibre-gl-terradraw.es.js +626 -571
- package/dist/maplibre-gl-terradraw.es.js.map +1 -1
- package/dist/maplibre-gl-terradraw.umd.js +2 -2
- package/dist/maplibre-gl-terradraw.umd.js.map +1 -1
- package/dist/types/controls/MaplibreMeasureControl.d.ts.map +1 -1
- package/dist/types/helpers/calcArea.d.ts.map +1 -1
- package/dist/types/helpers/calcDistance.d.ts.map +1 -1
- package/dist/types/helpers/capitalize.d.ts.map +1 -1
- package/dist/types/helpers/cleanMaplibreStyle.d.ts.map +1 -1
- package/dist/types/helpers/convertAreaUnit.d.ts.map +1 -1
- package/dist/types/helpers/debounce.d.ts.map +1 -1
- package/dist/types/helpers/getDistanceUnitName.d.ts.map +1 -1
- package/dist/types/helpers/index.d.ts +1 -0
- package/dist/types/helpers/index.d.ts.map +1 -1
- package/dist/types/helpers/queryElevationByPoint.d.ts.map +1 -1
- package/dist/types/helpers/queryElevationFromRasterDEM.d.ts.map +1 -1
- package/dist/types/helpers/roundFeatureCoordinates.d.ts +11 -0
- package/dist/types/helpers/roundFeatureCoordinates.d.ts.map +1 -0
- package/package.json +25 -23
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var k = (s, t, e) =>
|
|
1
|
+
var ze = Object.defineProperty;
|
|
2
|
+
var Re = (s, t, e) => t in s ? ze(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
3
|
+
var k = (s, t, e) => Re(s, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import "maplibre-gl";
|
|
5
5
|
function b() {
|
|
6
6
|
return b = Object.assign ? Object.assign.bind() : function(s) {
|
|
@@ -19,12 +19,12 @@ const U = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT: "selec
|
|
|
19
19
|
function bt(s) {
|
|
20
20
|
return !!(s && typeof s == "object" && s !== null && !Array.isArray(s));
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function Ut(s) {
|
|
23
23
|
return !!function(t) {
|
|
24
24
|
return typeof t == "number" && !isNaN(new Date(t).valueOf());
|
|
25
25
|
}(s);
|
|
26
26
|
}
|
|
27
|
-
const
|
|
27
|
+
const Xe = "Feature mode property does not match the mode being added to";
|
|
28
28
|
var $;
|
|
29
29
|
(function(s) {
|
|
30
30
|
s.Drawing = "drawing", s.Select = "select", s.Static = "static", s.Render = "render";
|
|
@@ -94,7 +94,7 @@ class N {
|
|
|
94
94
|
}
|
|
95
95
|
validateModeFeature(t, e) {
|
|
96
96
|
const i = this.performFeatureValidation(t);
|
|
97
|
-
return i.valid ? t.properties.mode !== this.mode ? { valid: !1, reason:
|
|
97
|
+
return i.valid ? t.properties.mode !== this.mode ? { valid: !1, reason: Xe } : e(t) : { valid: !1, reason: i.reason };
|
|
98
98
|
}
|
|
99
99
|
onFinish(t, e) {
|
|
100
100
|
}
|
|
@@ -126,7 +126,7 @@ class N {
|
|
|
126
126
|
return t === void 0 ? e : typeof t == "function" ? t(i) : t;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
class
|
|
129
|
+
class Ke extends N {
|
|
130
130
|
constructor(...t) {
|
|
131
131
|
super(...t), this.type = $.Select;
|
|
132
132
|
}
|
|
@@ -135,11 +135,11 @@ function A(s, t) {
|
|
|
135
135
|
const e = (d) => d * Math.PI / 180, i = e(s[1]), o = e(s[0]), r = e(t[1]), n = r - i, a = e(t[0]) - o, l = Math.sin(n / 2) * Math.sin(n / 2) + Math.cos(i) * Math.cos(r) * Math.sin(a / 2) * Math.sin(a / 2);
|
|
136
136
|
return 2 * Math.atan2(Math.sqrt(l), Math.sqrt(1 - l)) * 6371e3 / 1e3;
|
|
137
137
|
}
|
|
138
|
-
const
|
|
138
|
+
const fe = 63710088e-1;
|
|
139
139
|
function E(s) {
|
|
140
140
|
return s % 360 * Math.PI / 180;
|
|
141
141
|
}
|
|
142
|
-
function
|
|
142
|
+
function me(s) {
|
|
143
143
|
return s / 6371.0088;
|
|
144
144
|
}
|
|
145
145
|
function z(s) {
|
|
@@ -149,15 +149,15 @@ function F(s, t = 9) {
|
|
|
149
149
|
const e = Math.pow(10, t);
|
|
150
150
|
return Math.round(s * e) / e;
|
|
151
151
|
}
|
|
152
|
-
const
|
|
153
|
-
function
|
|
154
|
-
const i = E(s[0]), o = E(s[1]), r = E(e), n =
|
|
152
|
+
const zt = 57.29577951308232, Rt = 0.017453292519943295, ft = 6378137, x = (s, t) => ({ x: s === 0 ? 0 : s * Rt * ft, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * Rt / 2)) * ft }), j = (s, t) => ({ lng: s === 0 ? 0 : zt * (s / ft), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / ft)) - Math.PI / 2) * zt });
|
|
153
|
+
function Ye(s, t, e) {
|
|
154
|
+
const i = E(s[0]), o = E(s[1]), r = E(e), n = me(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(r));
|
|
155
155
|
return [z(i + Math.atan2(Math.sin(r) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), z(a)];
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function Xt(s) {
|
|
158
158
|
const { center: t, radiusKilometers: e, coordinatePrecision: i } = s, o = s.steps ? s.steps : 64, r = [];
|
|
159
159
|
for (let n = 0; n < o; n++) {
|
|
160
|
-
const a =
|
|
160
|
+
const a = Ye(t, e, -360 * n / o);
|
|
161
161
|
r.push([F(a[0], i), F(a[1], i)]);
|
|
162
162
|
}
|
|
163
163
|
return r.push(r[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [r] }, properties: {} };
|
|
@@ -176,41 +176,51 @@ function _t(s) {
|
|
|
176
176
|
return r < 0 || r > 1;
|
|
177
177
|
}
|
|
178
178
|
function o(r, n, a, l) {
|
|
179
|
-
const d = t[r][n],
|
|
180
|
-
if (
|
|
179
|
+
const d = t[r][n], c = t[r][n + 1], h = t[a][l], u = t[a][l + 1], p = function(v, f, m, C) {
|
|
180
|
+
if (ct(v, m) || ct(v, C) || ct(f, m) || ct(C, m)) return null;
|
|
181
181
|
const P = v[0], S = v[1], M = f[0], w = f[1], D = m[0], G = m[1], L = C[0], B = C[1], R = (P - M) * (G - B) - (S - w) * (D - L);
|
|
182
182
|
return R === 0 ? null : [((P * w - S * M) * (D - L) - (P - M) * (D * B - G * L)) / R, ((P * w - S * M) * (G - B) - (S - w) * (D * B - G * L)) / R];
|
|
183
|
-
}(d,
|
|
183
|
+
}(d, c, h, u);
|
|
184
184
|
if (p === null) return;
|
|
185
185
|
let g, y;
|
|
186
|
-
g =
|
|
186
|
+
g = c[0] !== d[0] ? (p[0] - d[0]) / (c[0] - d[0]) : (p[1] - d[1]) / (c[1] - d[1]), y = u[0] !== h[0] ? (p[0] - h[0]) / (u[0] - h[0]) : (p[1] - h[1]) / (u[1] - h[1]), i(g) || i(y) || (p.toString(), e.push(p));
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
function
|
|
189
|
+
function ct(s, t) {
|
|
190
190
|
return s[0] === t[0] && s[1] === t[1];
|
|
191
191
|
}
|
|
192
192
|
function St(s, t) {
|
|
193
|
-
return
|
|
194
|
-
var e, i;
|
|
193
|
+
return Kt(s[0]) <= t && Kt(s[1]) <= t;
|
|
195
194
|
}
|
|
196
|
-
function
|
|
195
|
+
function kt(s) {
|
|
196
|
+
return s.length === 2 && typeof s[0] == "number" && typeof s[1] == "number" && s[0] !== 1 / 0 && s[1] !== 1 / 0 && (e = s[0]) >= -180 && e <= 180 && (t = s[1]) >= -90 && t <= 90;
|
|
197
|
+
var t, e;
|
|
198
|
+
}
|
|
199
|
+
function Kt(s) {
|
|
197
200
|
let t = 1, e = 0;
|
|
198
201
|
for (; Math.round(s * t) / t !== s; ) t *= 10, e++;
|
|
199
202
|
return e;
|
|
200
203
|
}
|
|
201
|
-
const
|
|
204
|
+
const $e = "Feature has holes", He = "Feature has less than 4 coordinates", qe = "Feature has invalid coordinates", Je = "Feature coordinates are not closed";
|
|
202
205
|
function xt(s, t) {
|
|
203
|
-
|
|
206
|
+
if (s.geometry.type !== "Polygon") return { valid: !1, reason: "Feature is not a Polygon" };
|
|
207
|
+
if (s.geometry.coordinates.length !== 1) return { valid: !1, reason: $e };
|
|
208
|
+
if (s.geometry.coordinates[0].length < 4) return { valid: !1, reason: He };
|
|
209
|
+
for (let o = 0; o < s.geometry.coordinates[0].length; o++) {
|
|
210
|
+
if (!kt(s.geometry.coordinates[0][o])) return { valid: !1, reason: qe };
|
|
211
|
+
if (!St(s.geometry.coordinates[0][o], t)) return { valid: !1, reason: "Feature has coordinates with excessive precision" };
|
|
212
|
+
}
|
|
213
|
+
return (e = s.geometry.coordinates[0][0])[0] !== (i = s.geometry.coordinates[0][s.geometry.coordinates[0].length - 1])[0] || e[1] !== i[1] ? { valid: !1, reason: Je } : { valid: !0 };
|
|
204
214
|
var e, i;
|
|
205
215
|
}
|
|
206
216
|
function lt(s, t) {
|
|
207
217
|
const e = xt(s, t);
|
|
208
218
|
return e.valid ? _t(s) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
|
|
209
219
|
}
|
|
210
|
-
const
|
|
211
|
-
let
|
|
220
|
+
const Ze = { cancel: "Escape", finish: "Enter" }, Qe = { start: "crosshair" };
|
|
221
|
+
let ve = class extends N {
|
|
212
222
|
constructor(t) {
|
|
213
|
-
super(t, !0), this.mode = "circle", this.center = void 0, this.clickCount = 0, this.currentCircleId = void 0, this.keyEvents =
|
|
223
|
+
super(t, !0), this.mode = "circle", this.center = void 0, this.clickCount = 0, this.currentCircleId = void 0, this.keyEvents = Ze, this.cursors = Qe, this.startingRadiusKilometers = 1e-5, this.cursorMovedAfterInitialCursorDown = !1, this.updateOptions(t);
|
|
214
224
|
}
|
|
215
225
|
updateOptions(t) {
|
|
216
226
|
super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents)), t != null && t.startingRadiusKilometers && (this.startingRadiusKilometers = t.startingRadiusKilometers);
|
|
@@ -233,7 +243,7 @@ let me = class extends N {
|
|
|
233
243
|
onClick(t) {
|
|
234
244
|
if (this.clickCount === 0) {
|
|
235
245
|
this.center = [t.lng, t.lat];
|
|
236
|
-
const e =
|
|
246
|
+
const e = Xt({ center: this.center, radiusKilometers: this.startingRadiusKilometers, coordinatePrecision: this.coordinatePrecision }), [i] = this.store.create([{ geometry: e.geometry, properties: { mode: this.mode, radiusKilometers: this.startingRadiusKilometers } }]);
|
|
237
247
|
this.currentCircleId = i, this.clickCount++, this.cursorMovedAfterInitialCursorDown = !1, this.setDrawing();
|
|
238
248
|
} else this.clickCount === 1 && this.center && this.currentCircleId !== void 0 && this.cursorMovedAfterInitialCursorDown && this.updateCircle(t), this.close();
|
|
239
249
|
}
|
|
@@ -274,20 +284,20 @@ let me = class extends N {
|
|
|
274
284
|
const o = function(r, n) {
|
|
275
285
|
const a = 1e3 * A(r, n);
|
|
276
286
|
if (a === 0) return 1;
|
|
277
|
-
const { x: l, y: d } = x(r[0], r[1]), { x:
|
|
278
|
-
return Math.sqrt(Math.pow(
|
|
287
|
+
const { x: l, y: d } = x(r[0], r[1]), { x: c, y: h } = x(n[0], n[1]);
|
|
288
|
+
return Math.sqrt(Math.pow(c - l, 2) + Math.pow(h - d, 2)) / a;
|
|
279
289
|
}(this.center, [t.lng, t.lat]);
|
|
280
290
|
i = function(r) {
|
|
281
|
-
const { center: n, radiusKilometers: a, coordinatePrecision: l } = r, d = r.steps ? r.steps : 64,
|
|
291
|
+
const { center: n, radiusKilometers: a, coordinatePrecision: l } = r, d = r.steps ? r.steps : 64, c = 1e3 * a, [h, u] = n, { x: p, y: g } = x(h, u), y = [];
|
|
282
292
|
for (let v = 0; v < d; v++) {
|
|
283
|
-
const f = 360 * v / d * Math.PI / 180, m =
|
|
293
|
+
const f = 360 * v / d * Math.PI / 180, m = c * Math.cos(f), C = c * Math.sin(f), [P, S] = [p + m, g + C], { lng: M, lat: w } = j(P, S);
|
|
284
294
|
y.push([F(M, l), F(w, l)]);
|
|
285
295
|
}
|
|
286
296
|
return y.push(y[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [y] }, properties: {} };
|
|
287
297
|
}({ center: this.center, radiusKilometers: e * o, coordinatePrecision: this.coordinatePrecision });
|
|
288
298
|
} else {
|
|
289
299
|
if (this.projection !== "globe") throw new Error("Invalid projection");
|
|
290
|
-
i =
|
|
300
|
+
i = Xt({ center: this.center, radiusKilometers: e, coordinatePrecision: this.coordinatePrecision });
|
|
291
301
|
}
|
|
292
302
|
if (this.validate && !this.validate({ type: "Feature", id: this.currentCircleId, geometry: i.geometry, properties: { radiusKilometers: e } }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: I.Provisional }).valid) return;
|
|
293
303
|
this.store.updateGeometry([{ id: this.currentCircleId, geometry: i.geometry }]), this.store.updateProperty([{ id: this.currentCircleId, property: "radiusKilometers", value: e }]);
|
|
@@ -309,10 +319,10 @@ function dt(s) {
|
|
|
309
319
|
return o < 0;
|
|
310
320
|
}(s)) return { type: "Polygon", coordinates: [s.coordinates[0].reverse()] };
|
|
311
321
|
}
|
|
312
|
-
const
|
|
313
|
-
|
|
322
|
+
const ti = { cancel: "Escape", finish: "Enter" }, ei = { start: "crosshair", close: "pointer" };
|
|
323
|
+
class Ce extends N {
|
|
314
324
|
constructor(t) {
|
|
315
|
-
super(t, !0), this.mode = "freehand", this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.minDistance = 20, this.keyEvents =
|
|
325
|
+
super(t, !0), this.mode = "freehand", this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.minDistance = 20, this.keyEvents = ti, this.cursors = ei, this.preventPointsNearClose = !0, this.autoClose = !1, this.autoCloseTimeout = 500, this.hasLeftStartingPoint = !1, this.preventNewFeature = !1, this.updateOptions(t);
|
|
316
326
|
}
|
|
317
327
|
updateOptions(t) {
|
|
318
328
|
super.updateOptions(t), t != null && t.minDistance && (this.minDistance = t.minDistance), (t == null ? void 0 : t.preventPointsNearClose) !== void 0 && (this.preventPointsNearClose = t.preventPointsNearClose), (t == null ? void 0 : t.autoClose) !== void 0 && (this.autoClose = t.autoClose), t != null && t.autoCloseTimeout && (this.autoCloseTimeout = t.autoCloseTimeout), (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents)), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors));
|
|
@@ -338,8 +348,8 @@ let ve = class extends N {
|
|
|
338
348
|
}
|
|
339
349
|
onMouseMove(t) {
|
|
340
350
|
if (this.currentId === void 0 || this.startingClick === !1) return;
|
|
341
|
-
const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates[0].length - 2, [o, r] = e.coordinates[0][i], { x: n, y: a } = this.project(o, r), l = O({ x: n, y: a }, { x: t.containerX, y: t.containerY }), [d,
|
|
342
|
-
if (O({ x:
|
|
351
|
+
const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates[0].length - 2, [o, r] = e.coordinates[0][i], { x: n, y: a } = this.project(o, r), l = O({ x: n, y: a }, { x: t.containerX, y: t.containerY }), [d, c] = e.coordinates[0][0], { x: h, y: u } = this.project(d, c);
|
|
352
|
+
if (O({ x: h, y: u }, { x: t.containerX, y: t.containerY }) < this.pointerDistance) {
|
|
343
353
|
if (this.autoClose && this.hasLeftStartingPoint && (this.preventNewFeature = !0, setTimeout(() => {
|
|
344
354
|
this.preventNewFeature = !1;
|
|
345
355
|
}, this.autoCloseTimeout), this.close()), this.setCursor(this.cursors.close), this.preventPointsNearClose) return;
|
|
@@ -384,26 +394,26 @@ let ve = class extends N {
|
|
|
384
394
|
validateFeature(t) {
|
|
385
395
|
return this.validateModeFeature(t, (e) => xt(e, this.coordinatePrecision));
|
|
386
396
|
}
|
|
387
|
-
}
|
|
388
|
-
class
|
|
397
|
+
}
|
|
398
|
+
class W {
|
|
389
399
|
constructor({ store: t, mode: e, project: i, unproject: o, pointerDistance: r, coordinatePrecision: n, projection: a }) {
|
|
390
400
|
this.store = void 0, this.mode = void 0, this.project = void 0, this.unproject = void 0, this.pointerDistance = void 0, this.coordinatePrecision = void 0, this.projection = void 0, this.store = t, this.mode = e, this.project = i, this.unproject = o, this.pointerDistance = r, this.coordinatePrecision = n, this.projection = a;
|
|
391
401
|
}
|
|
392
402
|
}
|
|
393
|
-
function
|
|
403
|
+
function Pe({ unproject: s, point: t, pointerDistance: e }) {
|
|
394
404
|
const i = e / 2, { x: o, y: r } = t;
|
|
395
405
|
return { type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [[s(o - i, r - i), s(o + i, r - i), s(o + i, r + i), s(o - i, r + i), s(o - i, r - i)].map((n) => [n.lng, n.lat])] } };
|
|
396
406
|
}
|
|
397
|
-
|
|
407
|
+
class rt extends W {
|
|
398
408
|
constructor(t) {
|
|
399
409
|
super(t);
|
|
400
410
|
}
|
|
401
411
|
create(t) {
|
|
402
412
|
const { containerX: e, containerY: i } = t;
|
|
403
|
-
return
|
|
413
|
+
return Pe({ unproject: this.unproject, point: { x: e, y: i }, pointerDistance: this.pointerDistance });
|
|
404
414
|
}
|
|
405
|
-
}
|
|
406
|
-
class nt extends
|
|
415
|
+
}
|
|
416
|
+
class nt extends W {
|
|
407
417
|
constructor(t) {
|
|
408
418
|
super(t);
|
|
409
419
|
}
|
|
@@ -412,7 +422,7 @@ class nt extends j {
|
|
|
412
422
|
return O({ x: i, y: o }, { x: t.containerX, y: t.containerY });
|
|
413
423
|
}
|
|
414
424
|
}
|
|
415
|
-
|
|
425
|
+
let Lt = class extends W {
|
|
416
426
|
constructor(t, e, i) {
|
|
417
427
|
super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => this.getSnappable(o, (r) => !!(r.properties && r.properties.mode === this.mode)).coordinate, this.getSnappableCoordinate = (o, r) => this.getSnappable(o, (n) => !!(n.properties && n.properties.mode === this.mode && n.id !== r)).coordinate, this.config = t, this.pixelDistance = e, this.clickBoundingBox = i;
|
|
418
428
|
}
|
|
@@ -426,21 +436,21 @@ class Lt extends j {
|
|
|
426
436
|
a = n.geometry.coordinates;
|
|
427
437
|
}
|
|
428
438
|
a.forEach((l, d) => {
|
|
429
|
-
const
|
|
430
|
-
|
|
439
|
+
const c = this.pixelDistance.measure(t, l);
|
|
440
|
+
c < r.minDist && c < this.pointerDistance && (r.coordinate = l, r.minDist = c, r.featureId = n.id, r.featureCoordinateIndex = d);
|
|
431
441
|
});
|
|
432
442
|
}), r;
|
|
433
443
|
}
|
|
434
|
-
}
|
|
435
|
-
function
|
|
436
|
-
const i = E(s[0]), o = E(s[1]), r = E(e), n =
|
|
444
|
+
};
|
|
445
|
+
function Yt(s, t, e) {
|
|
446
|
+
const i = E(s[0]), o = E(s[1]), r = E(e), n = me(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(r));
|
|
437
447
|
return [z(i + Math.atan2(Math.sin(r) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), z(a)];
|
|
438
448
|
}
|
|
439
449
|
function at({ x: s, y: t }, e, i) {
|
|
440
450
|
const o = E(i);
|
|
441
451
|
return { x: s + e * Math.cos(o), y: t + e * Math.sin(o) };
|
|
442
452
|
}
|
|
443
|
-
function
|
|
453
|
+
function $t(s, t) {
|
|
444
454
|
const e = E(s[0]), i = E(t[0]), o = E(s[1]), r = E(t[1]), n = Math.sin(i - e) * Math.cos(r), a = Math.cos(o) * Math.sin(r) - Math.sin(o) * Math.cos(r) * Math.cos(i - e);
|
|
445
455
|
return z(Math.atan2(n, a));
|
|
446
456
|
}
|
|
@@ -451,29 +461,29 @@ function T({ x: s, y: t }, { x: e, y: i }) {
|
|
|
451
461
|
function Y(s) {
|
|
452
462
|
return (s + 360) % 360;
|
|
453
463
|
}
|
|
454
|
-
function
|
|
464
|
+
function ii(s, t, e) {
|
|
455
465
|
const i = [], o = s.length;
|
|
456
466
|
let r, n, a, l = 0;
|
|
457
|
-
for (let
|
|
467
|
+
for (let c = 0; c < s.length && !(t >= l && c === s.length - 1); c++) {
|
|
458
468
|
if (l > t && i.length === 0) {
|
|
459
|
-
if (r = t - l, !r) return i.push(s[
|
|
460
|
-
n =
|
|
469
|
+
if (r = t - l, !r) return i.push(s[c]), i;
|
|
470
|
+
n = $t(s[c], s[c - 1]) - 180, a = Yt(s[c], r, n), i.push(a);
|
|
461
471
|
}
|
|
462
|
-
if (l >= e) return r = e - l, r ? (n =
|
|
463
|
-
if (l >= t && i.push(s[
|
|
464
|
-
l += A(s[
|
|
472
|
+
if (l >= e) return r = e - l, r ? (n = $t(s[c], s[c - 1]) - 180, a = Yt(s[c], r, n), i.push(a), i) : (i.push(s[c]), i);
|
|
473
|
+
if (l >= t && i.push(s[c]), c === s.length - 1) return i;
|
|
474
|
+
l += A(s[c], s[c + 1]);
|
|
465
475
|
}
|
|
466
476
|
if (l < t && s.length === o) throw new Error("Start position is beyond line");
|
|
467
477
|
const d = s[s.length - 1];
|
|
468
478
|
return [d, d];
|
|
469
479
|
}
|
|
470
|
-
function
|
|
480
|
+
function ht(s) {
|
|
471
481
|
return s * (Math.PI / 180);
|
|
472
482
|
}
|
|
473
|
-
function
|
|
483
|
+
function Ht(s) {
|
|
474
484
|
return s * (180 / Math.PI);
|
|
475
485
|
}
|
|
476
|
-
class
|
|
486
|
+
class oi extends W {
|
|
477
487
|
constructor(t) {
|
|
478
488
|
super(t), this.config = void 0, this.config = t;
|
|
479
489
|
}
|
|
@@ -486,8 +496,8 @@ class ii extends j {
|
|
|
486
496
|
Number.isInteger(n) || (n = Math.floor(n) + 1);
|
|
487
497
|
const a = [];
|
|
488
498
|
for (let d = 0; d < n; d++) {
|
|
489
|
-
const
|
|
490
|
-
a.push(
|
|
499
|
+
const c = ii(o, i * d, i * (d + 1));
|
|
500
|
+
a.push(c);
|
|
491
501
|
}
|
|
492
502
|
const l = [];
|
|
493
503
|
for (let d = 0; d < a.length; d++) l.push(a[d][1]);
|
|
@@ -495,15 +505,15 @@ class ii extends j {
|
|
|
495
505
|
}
|
|
496
506
|
generateInsertionGeodesicCoordinates(t, e, i) {
|
|
497
507
|
const o = A(t, e), r = function(n, a, l) {
|
|
498
|
-
const d = [],
|
|
508
|
+
const d = [], c = ht(n[1]), h = ht(n[0]), u = ht(a[1]), p = ht(a[0]);
|
|
499
509
|
l += 1;
|
|
500
|
-
const g = 2 * Math.asin(Math.sqrt(Math.sin((u -
|
|
510
|
+
const g = 2 * Math.asin(Math.sqrt(Math.sin((u - c) / 2) ** 2 + Math.cos(c) * Math.cos(u) * Math.sin((p - h) / 2) ** 2));
|
|
501
511
|
if (g === 0 || isNaN(g)) return d;
|
|
502
512
|
for (let y = 0; y <= l; y++) {
|
|
503
|
-
const v = y / l, f = Math.sin((1 - v) * g) / Math.sin(g), m = Math.sin(v * g) / Math.sin(g), C = f * Math.cos(
|
|
513
|
+
const v = y / l, f = Math.sin((1 - v) * g) / Math.sin(g), m = Math.sin(v * g) / Math.sin(g), C = f * Math.cos(c) * Math.cos(h) + m * Math.cos(u) * Math.cos(p), P = f * Math.cos(c) * Math.sin(h) + m * Math.cos(u) * Math.sin(p), S = f * Math.sin(c) + m * Math.sin(u);
|
|
504
514
|
if (isNaN(C) || isNaN(P) || isNaN(S)) continue;
|
|
505
515
|
const M = Math.atan2(S, Math.sqrt(C ** 2 + P ** 2)), w = Math.atan2(P, C);
|
|
506
|
-
isNaN(M) || isNaN(w) || d.push([
|
|
516
|
+
isNaN(M) || isNaN(w) || d.push([Ht(w), Ht(M)]);
|
|
507
517
|
}
|
|
508
518
|
return d.slice(1, -1);
|
|
509
519
|
}(t, e, Math.floor(o / i));
|
|
@@ -516,17 +526,23 @@ class ii extends j {
|
|
|
516
526
|
function Z(s, t) {
|
|
517
527
|
return s[0] === t[0] && s[1] === t[1];
|
|
518
528
|
}
|
|
519
|
-
function
|
|
520
|
-
|
|
529
|
+
function Se(s, t) {
|
|
530
|
+
if (s.geometry.type !== "LineString") return { valid: !1, reason: "Feature is not a LineString" };
|
|
531
|
+
if (s.geometry.coordinates.length < 2) return { valid: !1, reason: "Feature has less than 2 coordinates" };
|
|
532
|
+
for (let e = 0; e < s.geometry.coordinates.length; e++) {
|
|
533
|
+
if (!kt(s.geometry.coordinates[e])) return { valid: !1, reason: "Feature has invalid coordinates" };
|
|
534
|
+
if (!St(s.geometry.coordinates[e], t)) return { valid: !1, reason: "Feature has coordinates with excessive precision" };
|
|
535
|
+
}
|
|
536
|
+
return { valid: !0 };
|
|
521
537
|
}
|
|
522
|
-
function
|
|
538
|
+
function qt(s) {
|
|
523
539
|
return Math.sqrt(Math.pow(s[0], 2) + Math.pow(s[1], 2) + Math.pow(s[2], 2));
|
|
524
540
|
}
|
|
525
541
|
function X(s, t) {
|
|
526
542
|
const e = function(i, o) {
|
|
527
|
-
const [r, n, a] = i, [l, d,
|
|
528
|
-
return r * l + n * d + a *
|
|
529
|
-
}(s, t) / (
|
|
543
|
+
const [r, n, a] = i, [l, d, c] = o;
|
|
544
|
+
return r * l + n * d + a * c;
|
|
545
|
+
}(s, t) / (qt(s) * qt(t));
|
|
530
546
|
return Math.acos(Math.min(Math.max(e, -1), 1));
|
|
531
547
|
}
|
|
532
548
|
function Mt(s) {
|
|
@@ -537,19 +553,19 @@ function K(s) {
|
|
|
537
553
|
const [t, e, i] = s, o = z(Math.asin(i));
|
|
538
554
|
return [z(Math.atan2(e, t)), o];
|
|
539
555
|
}
|
|
540
|
-
function
|
|
541
|
-
const i = Mt(s), o = Mt(t), r = Mt(e), [n, a, l] = r, [d,
|
|
542
|
-
const [
|
|
543
|
-
return [
|
|
544
|
-
}(i, o), u =
|
|
556
|
+
function si(s, t, e) {
|
|
557
|
+
const i = Mt(s), o = Mt(t), r = Mt(e), [n, a, l] = r, [d, c, h] = function(B, R) {
|
|
558
|
+
const [Bt, Nt, Gt] = B, [Tt, At, Vt] = R;
|
|
559
|
+
return [Nt * Vt - Gt * At, Gt * Tt - Bt * Vt, Bt * At - Nt * Tt];
|
|
560
|
+
}(i, o), u = c * l - h * a, p = h * n - d * l, g = d * a - c * n, y = g * c - p * h, v = u * h - g * d, f = p * d - u * c, m = 1 / Math.sqrt(Math.pow(y, 2) + Math.pow(v, 2) + Math.pow(f, 2)), C = [y * m, v * m, f * m], P = [-1 * y * m, -1 * v * m, -1 * f * m], S = X(i, o), M = X(i, C), w = X(o, C), D = X(i, P), G = X(o, P);
|
|
545
561
|
let L;
|
|
546
562
|
return L = M < D && M < G || w < D && w < G ? C : P, X(i, L) > S || X(o, L) > S ? A(K(L), K(i)) <= A(K(L), K(o)) ? [K(i), !0, !1] : [K(o), !1, !0] : [K(L), !1, !1];
|
|
547
563
|
}
|
|
548
|
-
function
|
|
564
|
+
function ri(s, t, e) {
|
|
549
565
|
const i = t.x - s.x, o = t.y - s.y, r = Math.max(0, Math.min(1, ((e.x - s.x) * i + (e.y - s.y) * o) / (i * i + o * o)));
|
|
550
566
|
return { x: s.x + r * i, y: s.y + r * o };
|
|
551
567
|
}
|
|
552
|
-
class
|
|
568
|
+
class xe extends W {
|
|
553
569
|
constructor(t, e, i) {
|
|
554
570
|
super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => this.getSnappable(o, (r) => !!(r.properties && r.properties.mode === this.mode)).coordinate, this.getSnappableCoordinate = (o, r) => this.getSnappable(o, (n) => !!(n.properties && n.properties.mode === this.mode && n.id !== r)).coordinate, this.config = t, this.pixelDistance = e, this.clickBoundingBox = i;
|
|
555
571
|
}
|
|
@@ -565,7 +581,7 @@ class Se extends j {
|
|
|
565
581
|
const l = [];
|
|
566
582
|
for (let u = 0; u < a.length - 1; u++) l.push([a[u], a[u + 1]]);
|
|
567
583
|
let d;
|
|
568
|
-
const
|
|
584
|
+
const c = [t.lng, t.lat];
|
|
569
585
|
if (this.config.projection === "web-mercator" ? d = function(u, p) {
|
|
570
586
|
let g = [1 / 0, 1 / 0], y = 1 / 0, v = 0;
|
|
571
587
|
for (let f of p) {
|
|
@@ -575,30 +591,30 @@ class Se extends j {
|
|
|
575
591
|
if (m[0] === u[0] && m[1] === u[1]) P = m;
|
|
576
592
|
else if (C[0] === u[0] && C[1] === u[1]) P = C;
|
|
577
593
|
else {
|
|
578
|
-
const { x: G, y: L } =
|
|
594
|
+
const { x: G, y: L } = ri(M, w, D), { lng: B, lat: R } = j(G, L);
|
|
579
595
|
P = [B, R];
|
|
580
596
|
}
|
|
581
597
|
P && (S = O(D, x(P[0], P[1])), S < y && (g = P, y = S, v = p.indexOf(f)));
|
|
582
598
|
}
|
|
583
599
|
return y === 1 / 0 ? void 0 : { coordinate: g, lineIndex: v, distance: y };
|
|
584
|
-
}(
|
|
600
|
+
}(c, l) : this.config.projection === "globe" && (d = function(u, p) {
|
|
585
601
|
let g = [1 / 0, 1 / 0], y = 1 / 0, v = 0;
|
|
586
602
|
for (let f of p) {
|
|
587
603
|
const m = f[0], C = f[1];
|
|
588
604
|
let P, S = 1 / 0;
|
|
589
|
-
m[0] === u[0] && m[1] === u[1] ? P = m : C[0] === u[0] && C[1] === u[1] ? P = C : [P] =
|
|
605
|
+
m[0] === u[0] && m[1] === u[1] ? P = m : C[0] === u[0] && C[1] === u[1] ? P = C : [P] = si(m, C, u), P && (S = A(u, P), S < y && (g = P, y = S, v = p.indexOf(f)));
|
|
590
606
|
}
|
|
591
607
|
return y === 1 / 0 ? void 0 : { coordinate: g, distance: y, lineIndex: v };
|
|
592
|
-
}(
|
|
593
|
-
const
|
|
594
|
-
|
|
608
|
+
}(c, l)), !d) return;
|
|
609
|
+
const h = this.pixelDistance.measure(t, d.coordinate);
|
|
610
|
+
h < r.minDistance && h < this.pointerDistance && (r.featureId = n.id, r.coordinate = d.coordinate, r.featureCoordinateIndex = d.lineIndex, r.minDistance = h);
|
|
595
611
|
}), r;
|
|
596
612
|
}
|
|
597
613
|
}
|
|
598
|
-
const
|
|
599
|
-
class
|
|
614
|
+
const ni = { cancel: "Escape", finish: "Enter" }, ai = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
615
|
+
class Ie extends N {
|
|
600
616
|
constructor(t) {
|
|
601
|
-
super(t, !0), this.mode = "linestring", this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.keyEvents =
|
|
617
|
+
super(t, !0), this.mode = "linestring", this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.keyEvents = ni, this.snapping = void 0, this.cursors = ai, this.mouseMove = !1, this.insertCoordinates = void 0, this.lastCommitedCoordinates = void 0, this.snappedPointId = void 0, this.editable = !1, this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedSnapType = void 0, this.editedInsertIndex = void 0, this.editedPointId = void 0, this.coordinateSnapping = void 0, this.insertPoint = void 0, this.lineSnapping = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.updateOptions(t);
|
|
602
618
|
}
|
|
603
619
|
updateOptions(t) {
|
|
604
620
|
super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), t != null && t.snapping && (this.snapping = t.snapping), (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents)), t != null && t.insertCoordinates && (this.insertCoordinates = t.insertCoordinates), t && t.editable && (this.editable = t.editable);
|
|
@@ -644,7 +660,7 @@ class xe extends N {
|
|
|
644
660
|
this.updateGeometries(l, i[i.length - 1], I.Commit), this.currentCoordinate++;
|
|
645
661
|
}
|
|
646
662
|
registerBehaviors(t) {
|
|
647
|
-
this.coordinateSnapping = new Lt(t, new nt(t), new rt(t)), this.insertPoint = new
|
|
663
|
+
this.coordinateSnapping = new Lt(t, new nt(t), new rt(t)), this.insertPoint = new oi(t), this.clickBoundingBox = new rt(t), this.pixelDistance = new nt(t), this.lineSnapping = new xe(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new Lt(t, this.pixelDistance, this.clickBoundingBox);
|
|
648
664
|
}
|
|
649
665
|
start() {
|
|
650
666
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -682,7 +698,7 @@ class xe extends N {
|
|
|
682
698
|
}
|
|
683
699
|
onRightClick(t) {
|
|
684
700
|
if (!this.editable || this.state !== "started") return;
|
|
685
|
-
const { featureId: e, featureCoordinateIndex: i } = this.coordinateSnapping.getSnappable(t, (n) => n
|
|
701
|
+
const { featureId: e, featureCoordinateIndex: i } = this.coordinateSnapping.getSnappable(t, (n) => this.lineStringFilter(n));
|
|
686
702
|
if (!e || i === void 0) return;
|
|
687
703
|
const o = this.store.getGeometryCopy(e);
|
|
688
704
|
let r;
|
|
@@ -708,9 +724,9 @@ class xe extends N {
|
|
|
708
724
|
if (!this.editable) return;
|
|
709
725
|
let i;
|
|
710
726
|
if (this.state === "started") {
|
|
711
|
-
const o = this.lineSnapping.getSnappable(t);
|
|
727
|
+
const o = this.lineSnapping.getSnappable(t, (n) => this.lineStringFilter(n));
|
|
712
728
|
o.coordinate && (this.editedSnapType = "line", this.editedFeatureCoordinateIndex = o.featureCoordinateIndex, this.editedFeatureId = o.featureId, i = o.coordinate);
|
|
713
|
-
const r = this.coordinateSnapping.getSnappable(t);
|
|
729
|
+
const r = this.coordinateSnapping.getSnappable(t, (n) => this.lineStringFilter(n));
|
|
714
730
|
r.coordinate && (this.editedSnapType = "coordinate", this.editedFeatureCoordinateIndex = r.featureCoordinateIndex, this.editedFeatureId = r.featureId, i = r.coordinate);
|
|
715
731
|
}
|
|
716
732
|
if (this.editedFeatureId && i) {
|
|
@@ -749,7 +765,10 @@ class xe extends N {
|
|
|
749
765
|
return e;
|
|
750
766
|
}
|
|
751
767
|
validateFeature(t) {
|
|
752
|
-
return this.validateModeFeature(t, (e) =>
|
|
768
|
+
return this.validateModeFeature(t, (e) => Se(e, this.coordinatePrecision));
|
|
769
|
+
}
|
|
770
|
+
lineStringFilter(t) {
|
|
771
|
+
return !!(t.geometry.type === "LineString" && t.properties && t.properties.mode === this.mode);
|
|
753
772
|
}
|
|
754
773
|
snapCoordinate(t) {
|
|
755
774
|
var e, i;
|
|
@@ -757,14 +776,14 @@ class xe extends N {
|
|
|
757
776
|
return (e = this.snapping) != null && e.toCoordinate && (o = this.currentId ? this.coordinateSnapping.getSnappableCoordinate(t, this.currentId) : this.coordinateSnapping.getSnappableCoordinateFirstClick(t)), (i = this.snapping) != null && i.toCustom && (o = this.snapping.toCustom(t)), o;
|
|
758
777
|
}
|
|
759
778
|
}
|
|
760
|
-
const
|
|
761
|
-
function
|
|
762
|
-
return s.geometry.type !== "Point" ? { valid: !1, reason:
|
|
779
|
+
const li = "Feature is not a Point", di = "Feature has invalid coordinates", ci = "Feature has coordinates with excessive precision";
|
|
780
|
+
function be(s, t) {
|
|
781
|
+
return s.geometry.type !== "Point" ? { valid: !1, reason: li } : kt(s.geometry.coordinates) ? St(s.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: ci } : { valid: !1, reason: di };
|
|
763
782
|
}
|
|
764
|
-
const
|
|
765
|
-
class
|
|
783
|
+
const hi = { create: "crosshair", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
784
|
+
class Me extends N {
|
|
766
785
|
constructor(t) {
|
|
767
|
-
super(t, !0), this.mode = "point", this.cursors =
|
|
786
|
+
super(t, !0), this.mode = "point", this.cursors = hi, this.editable = !1, this.editedFeatureId = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.updateOptions(t);
|
|
768
787
|
}
|
|
769
788
|
updateOptions(t) {
|
|
770
789
|
super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), t != null && t.editable && (this.editable = t.editable);
|
|
@@ -813,7 +832,7 @@ class be extends N {
|
|
|
813
832
|
return e;
|
|
814
833
|
}
|
|
815
834
|
validateFeature(t) {
|
|
816
|
-
return this.validateModeFeature(t, (e) =>
|
|
835
|
+
return this.validateModeFeature(t, (e) => be(e, this.coordinatePrecision));
|
|
817
836
|
}
|
|
818
837
|
onLeftClick(t) {
|
|
819
838
|
const e = { type: "Point", coordinates: [t.lng, t.lat] }, i = { mode: this.mode };
|
|
@@ -838,7 +857,7 @@ class be extends N {
|
|
|
838
857
|
return o;
|
|
839
858
|
}
|
|
840
859
|
}
|
|
841
|
-
class
|
|
860
|
+
class ui extends W {
|
|
842
861
|
constructor(t, e) {
|
|
843
862
|
super(t), this.config = void 0, this.pixelDistance = void 0, this._startEndPoints = [], this.config = t, this.pixelDistance = e;
|
|
844
863
|
}
|
|
@@ -864,10 +883,10 @@ class hi extends j {
|
|
|
864
883
|
return { isClosing: o < this.pointerDistance, isPreviousClosing: r < this.pointerDistance };
|
|
865
884
|
}
|
|
866
885
|
}
|
|
867
|
-
const
|
|
868
|
-
class
|
|
886
|
+
const pi = { cancel: "Escape", finish: "Enter" }, gi = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
887
|
+
class we extends N {
|
|
869
888
|
constructor(t) {
|
|
870
|
-
super(t, !0), this.mode = "polygon", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents =
|
|
889
|
+
super(t, !0), this.mode = "polygon", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = pi, this.cursors = gi, this.mouseMove = !1, this.snapping = void 0, this.snappedPointId = void 0, this.editable = !1, this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedSnapType = void 0, this.editedInsertIndex = void 0, this.editedPointId = void 0, this.lineSnapping = void 0, this.coordinateSnapping = void 0, this.pixelDistance = void 0, this.closingPoints = void 0, this.clickBoundingBox = void 0, this.updateOptions(t);
|
|
871
890
|
}
|
|
872
891
|
updateOptions(t) {
|
|
873
892
|
super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents)), t != null && t.snapping && (this.snapping = t.snapping), t != null && t.editable && (this.editable = t.editable);
|
|
@@ -884,7 +903,7 @@ class Me extends N {
|
|
|
884
903
|
this.snappedPointId && this.store.delete([this.snappedPointId]), this.currentCoordinate = 0, this.currentId = void 0, this.snappedPointId = void 0, this.closingPoints.delete(), this.state === "drawing" && this.setStarted(), this.onFinish(e, { mode: this.mode, action: "draw" });
|
|
885
904
|
}
|
|
886
905
|
registerBehaviors(t) {
|
|
887
|
-
this.clickBoundingBox = new rt(t), this.pixelDistance = new nt(t), this.lineSnapping = new
|
|
906
|
+
this.clickBoundingBox = new rt(t), this.pixelDistance = new nt(t), this.lineSnapping = new xe(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new Lt(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new ui(t, this.pixelDistance);
|
|
888
907
|
}
|
|
889
908
|
start() {
|
|
890
909
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -932,11 +951,14 @@ class Me extends N {
|
|
|
932
951
|
let n;
|
|
933
952
|
n = this.currentId ? this.coordinateSnapping.getSnappableCoordinate(t, this.currentId) : this.coordinateSnapping.getSnappableCoordinateFirstClick(t), n && (r = n);
|
|
934
953
|
}
|
|
935
|
-
return (o = this.snapping) != null && o.toCustom && (r = this.snapping.toCustom(t)), r;
|
|
954
|
+
return (o = this.snapping) != null && o.toCustom && (r = this.snapping.toCustom(t, { currentCoordinate: this.currentCoordinate, currentId: this.currentId, getCurrentGeometrySnapshot: this.currentId ? () => this.store.getGeometryCopy(this.currentId) : () => null, project: this.project, unproject: this.unproject })), r;
|
|
955
|
+
}
|
|
956
|
+
polygonFilter(t) {
|
|
957
|
+
return !!(t.geometry.type === "Polygon" && t.properties && t.properties.mode === this.mode);
|
|
936
958
|
}
|
|
937
959
|
onRightClick(t) {
|
|
938
960
|
if (!this.editable) return;
|
|
939
|
-
const { featureId: e, featureCoordinateIndex: i } = this.coordinateSnapping.getSnappable(t, (n) => n
|
|
961
|
+
const { featureId: e, featureCoordinateIndex: i } = this.coordinateSnapping.getSnappable(t, (n) => this.polygonFilter(n));
|
|
940
962
|
if (!e || i === void 0) return;
|
|
941
963
|
const o = this.store.getGeometryCopy(e);
|
|
942
964
|
let r;
|
|
@@ -986,9 +1008,9 @@ class Me extends N {
|
|
|
986
1008
|
if (!this.editable) return;
|
|
987
1009
|
let i;
|
|
988
1010
|
if (this.state === "started") {
|
|
989
|
-
const o = this.lineSnapping.getSnappable(t);
|
|
1011
|
+
const o = this.lineSnapping.getSnappable(t, (n) => this.polygonFilter(n));
|
|
990
1012
|
o.coordinate && (this.editedSnapType = "line", this.editedFeatureCoordinateIndex = o.featureCoordinateIndex, this.editedFeatureId = o.featureId, i = o.coordinate);
|
|
991
|
-
const r = this.coordinateSnapping.getSnappable(t);
|
|
1013
|
+
const r = this.coordinateSnapping.getSnappable(t, (n) => this.polygonFilter(n));
|
|
992
1014
|
r.coordinate && (this.editedSnapType = "coordinate", this.editedFeatureCoordinateIndex = r.featureCoordinateIndex, this.editedFeatureId = r.featureId, i = r.coordinate);
|
|
993
1015
|
}
|
|
994
1016
|
if (this.editedFeatureId && i) {
|
|
@@ -1034,10 +1056,10 @@ class Me extends N {
|
|
|
1034
1056
|
return this.validateModeFeature(t, (e) => xt(e, this.coordinatePrecision));
|
|
1035
1057
|
}
|
|
1036
1058
|
}
|
|
1037
|
-
const
|
|
1038
|
-
class
|
|
1059
|
+
const yi = { cancel: "Escape", finish: "Enter" }, fi = { start: "crosshair" };
|
|
1060
|
+
class Fe extends N {
|
|
1039
1061
|
constructor(t) {
|
|
1040
|
-
super(t, !0), this.mode = "rectangle", this.center = void 0, this.clickCount = 0, this.currentRectangleId = void 0, this.keyEvents =
|
|
1062
|
+
super(t, !0), this.mode = "rectangle", this.center = void 0, this.clickCount = 0, this.currentRectangleId = void 0, this.keyEvents = yi, this.cursors = fi, this.updateOptions(t);
|
|
1041
1063
|
}
|
|
1042
1064
|
updateOptions(t) {
|
|
1043
1065
|
super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents));
|
|
@@ -1135,7 +1157,7 @@ class et extends N {
|
|
|
1135
1157
|
validateFeature(t) {
|
|
1136
1158
|
const e = super.validateFeature(t);
|
|
1137
1159
|
if (e.valid) {
|
|
1138
|
-
const i = t, o =
|
|
1160
|
+
const i = t, o = be(i, this.coordinatePrecision).valid || xt(i, this.coordinatePrecision).valid || Se(i, this.coordinatePrecision).valid;
|
|
1139
1161
|
return o ? { valid: !0 } : { valid: o, reason: "Feature is not a valid Point, Polygon or LineString feature" };
|
|
1140
1162
|
}
|
|
1141
1163
|
return e;
|
|
@@ -1148,37 +1170,37 @@ function mt(s, t) {
|
|
|
1148
1170
|
const a = Math.log(Math.tan(r / 2 + Math.PI / 4) / Math.tan(o / 2 + Math.PI / 4)), l = (z(Math.atan2(n, a)) + 360) % 360;
|
|
1149
1171
|
return l > 180 ? -(360 - l) : l;
|
|
1150
1172
|
}
|
|
1151
|
-
function
|
|
1173
|
+
function jt(s, t, e) {
|
|
1152
1174
|
let i = t;
|
|
1153
1175
|
t < 0 && (i = -Math.abs(i));
|
|
1154
|
-
const o = i /
|
|
1176
|
+
const o = i / fe, r = s[0] * Math.PI / 180, n = E(s[1]), a = E(e), l = o * Math.cos(a);
|
|
1155
1177
|
let d = n + l;
|
|
1156
1178
|
Math.abs(d) > Math.PI / 2 && (d = d > 0 ? Math.PI - d : -Math.PI - d);
|
|
1157
|
-
const
|
|
1179
|
+
const c = Math.log(Math.tan(d / 2 + Math.PI / 4) / Math.tan(n / 2 + Math.PI / 4)), h = Math.abs(c) > 1e-11 ? l / c : Math.cos(n), u = [(180 * (r + o * Math.sin(a) / h) / Math.PI + 540) % 360 - 180, 180 * d / Math.PI];
|
|
1158
1180
|
return u[0] += u[0] - s[0] > 180 ? -360 : s[0] - u[0] > 180 ? 360 : 0, u;
|
|
1159
1181
|
}
|
|
1160
|
-
function
|
|
1182
|
+
function Ee(s, t, e, i, o) {
|
|
1161
1183
|
const r = i(s[0], s[1]), n = i(t[0], t[1]), { lng: a, lat: l } = o((r.x + n.x) / 2, (r.y + n.y) / 2);
|
|
1162
1184
|
return [F(a, e), F(l, e)];
|
|
1163
1185
|
}
|
|
1164
|
-
function
|
|
1165
|
-
const i =
|
|
1186
|
+
function mi(s, t, e) {
|
|
1187
|
+
const i = jt(s, 1e3 * A(s, t) / 2, mt(s, t));
|
|
1166
1188
|
return [F(i[0], e), F(i[1], e)];
|
|
1167
1189
|
}
|
|
1168
|
-
function
|
|
1190
|
+
function Jt({ featureCoords: s, precision: t, unproject: e, project: i, projection: o }) {
|
|
1169
1191
|
const r = [];
|
|
1170
1192
|
for (let n = 0; n < s.length - 1; n++) {
|
|
1171
1193
|
let a;
|
|
1172
|
-
if (o === "web-mercator") a =
|
|
1194
|
+
if (o === "web-mercator") a = Ee(s[n], s[n + 1], t, i, e);
|
|
1173
1195
|
else {
|
|
1174
1196
|
if (o !== "globe") throw new Error("Invalid projection");
|
|
1175
|
-
a =
|
|
1197
|
+
a = mi(s[n], s[n + 1], t);
|
|
1176
1198
|
}
|
|
1177
1199
|
r.push(a);
|
|
1178
1200
|
}
|
|
1179
1201
|
return r;
|
|
1180
1202
|
}
|
|
1181
|
-
class
|
|
1203
|
+
class vi extends W {
|
|
1182
1204
|
constructor(t, e) {
|
|
1183
1205
|
super(t), this.config = void 0, this.selectionPointBehavior = void 0, this._midPoints = [], this.config = t, this.selectionPointBehavior = e;
|
|
1184
1206
|
}
|
|
@@ -1194,17 +1216,17 @@ class fi extends j {
|
|
|
1194
1216
|
create(t, e, i) {
|
|
1195
1217
|
if (!this.store.has(e)) throw new Error("Store does not have feature with this id");
|
|
1196
1218
|
this._midPoints = this.store.create(function(o, r, n, a, l, d) {
|
|
1197
|
-
return
|
|
1219
|
+
return Jt({ featureCoords: o, precision: n, project: a, unproject: l, projection: d }).map((c, h) => ({ geometry: { type: "Point", coordinates: c }, properties: r(h) }));
|
|
1198
1220
|
}(t, (o) => ({ mode: this.mode, [U.MID_POINT]: !0, midPointSegment: o, midPointFeatureId: e }), i, this.config.project, this.config.unproject, this.projection));
|
|
1199
1221
|
}
|
|
1200
1222
|
delete() {
|
|
1201
1223
|
this._midPoints.length && (this.store.delete(this._midPoints), this._midPoints = []);
|
|
1202
1224
|
}
|
|
1203
1225
|
getUpdated(t) {
|
|
1204
|
-
if (this._midPoints.length !== 0) return
|
|
1226
|
+
if (this._midPoints.length !== 0) return Jt({ featureCoords: t, precision: this.coordinatePrecision, project: this.config.project, unproject: this.config.unproject, projection: this.config.projection }).map((e, i) => ({ id: this._midPoints[i], geometry: { type: "Point", coordinates: e } }));
|
|
1205
1227
|
}
|
|
1206
1228
|
}
|
|
1207
|
-
class
|
|
1229
|
+
class Ci extends W {
|
|
1208
1230
|
constructor(t) {
|
|
1209
1231
|
super(t), this._selectionPoints = [];
|
|
1210
1232
|
}
|
|
@@ -1230,16 +1252,16 @@ class mi extends j {
|
|
|
1230
1252
|
if (this._selectionPoints[t] !== void 0) return { id: this._selectionPoints[t], geometry: { type: "Point", coordinates: e } };
|
|
1231
1253
|
}
|
|
1232
1254
|
}
|
|
1233
|
-
function
|
|
1255
|
+
function Oe(s, t) {
|
|
1234
1256
|
let e = !1;
|
|
1235
1257
|
for (let n = 0, a = t.length; n < a; n++) {
|
|
1236
1258
|
const l = t[n];
|
|
1237
|
-
for (let d = 0,
|
|
1259
|
+
for (let d = 0, c = l.length, h = c - 1; d < c; h = d++) (o = l[d])[1] > (i = s)[1] != (r = l[h])[1] > i[1] && i[0] < (r[0] - o[0]) * (i[1] - o[1]) / (r[1] - o[1]) + o[0] && (e = !e);
|
|
1238
1260
|
}
|
|
1239
1261
|
var i, o, r;
|
|
1240
1262
|
return e;
|
|
1241
1263
|
}
|
|
1242
|
-
const
|
|
1264
|
+
const De = (s, t, e) => {
|
|
1243
1265
|
const i = (r) => r * r, o = (r, n) => i(r.x - n.x) + i(r.y - n.y);
|
|
1244
1266
|
return Math.sqrt(((r, n, a) => {
|
|
1245
1267
|
const l = o(n, a);
|
|
@@ -1248,15 +1270,15 @@ const Oe = (s, t, e) => {
|
|
|
1248
1270
|
return d = Math.max(0, Math.min(1, d)), o(r, { x: n.x + d * (a.x - n.x), y: n.y + d * (a.y - n.y) });
|
|
1249
1271
|
})(s, t, e));
|
|
1250
1272
|
};
|
|
1251
|
-
class
|
|
1273
|
+
class Pi extends W {
|
|
1252
1274
|
constructor(t, e, i) {
|
|
1253
1275
|
super(t), this.config = void 0, this.createClickBoundingBox = void 0, this.pixelDistance = void 0, this.config = t, this.createClickBoundingBox = e, this.pixelDistance = i;
|
|
1254
1276
|
}
|
|
1255
1277
|
find(t, e) {
|
|
1256
1278
|
let i, o, r, n, a = 1 / 0, l = 1 / 0, d = 1 / 0;
|
|
1257
|
-
const
|
|
1258
|
-
for (let u = 0; u <
|
|
1259
|
-
const p =
|
|
1279
|
+
const c = this.createClickBoundingBox.create(t), h = this.store.search(c);
|
|
1280
|
+
for (let u = 0; u < h.length; u++) {
|
|
1281
|
+
const p = h[u], g = p.geometry;
|
|
1260
1282
|
if (g.type === "Point") {
|
|
1261
1283
|
if (p.properties.selectionPoint || !e && p.properties[U.MID_POINT]) continue;
|
|
1262
1284
|
const y = this.pixelDistance.measure(t, g.coordinates);
|
|
@@ -1264,18 +1286,18 @@ class vi extends j {
|
|
|
1264
1286
|
} else if (g.type === "LineString") {
|
|
1265
1287
|
if (i) continue;
|
|
1266
1288
|
for (let y = 0; y < g.coordinates.length - 1; y++) {
|
|
1267
|
-
const v = g.coordinates[y], f = g.coordinates[y + 1], m =
|
|
1289
|
+
const v = g.coordinates[y], f = g.coordinates[y + 1], m = De({ x: t.containerX, y: t.containerY }, this.project(v[0], v[1]), this.project(f[0], f[1]));
|
|
1268
1290
|
m < this.pointerDistance && m < l && (l = m, o = p);
|
|
1269
1291
|
}
|
|
1270
1292
|
} else if (g.type === "Polygon") {
|
|
1271
1293
|
if (i || o) continue;
|
|
1272
|
-
|
|
1294
|
+
Oe([t.lng, t.lat], g.coordinates) && (n = p);
|
|
1273
1295
|
}
|
|
1274
1296
|
}
|
|
1275
1297
|
return { clickedFeature: i || o || n, clickedMidPoint: r };
|
|
1276
1298
|
}
|
|
1277
1299
|
}
|
|
1278
|
-
class
|
|
1300
|
+
class Si extends W {
|
|
1279
1301
|
constructor(t, e, i, o) {
|
|
1280
1302
|
super(t), this.config = void 0, this.featuresAtCursorEvent = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.draggedFeatureId = null, this.dragPosition = void 0, this.config = t, this.featuresAtCursorEvent = e, this.selectionPoints = i, this.midPoints = o;
|
|
1281
1303
|
}
|
|
@@ -1299,17 +1321,17 @@ class Ci extends j {
|
|
|
1299
1321
|
let r, n;
|
|
1300
1322
|
if (i.type === "Polygon" ? (r = i.coordinates[0], n = r.length - 1) : (r = i.coordinates, n = r.length), !this.dragPosition) return !1;
|
|
1301
1323
|
for (let d = 0; d < n; d++) {
|
|
1302
|
-
const
|
|
1303
|
-
let
|
|
1324
|
+
const c = r[d];
|
|
1325
|
+
let h, u;
|
|
1304
1326
|
if (this.config.projection === "web-mercator") {
|
|
1305
|
-
const p = x(this.dragPosition[0], this.dragPosition[1]), g = x(o[0], o[1]), y = x(
|
|
1306
|
-
|
|
1327
|
+
const p = x(this.dragPosition[0], this.dragPosition[1]), g = x(o[0], o[1]), y = x(c[0], c[1]), v = { x: p.x - g.x, y: p.y - g.y }, f = y.x - v.x, m = y.y - v.y, { lng: C, lat: P } = j(f, m);
|
|
1328
|
+
h = C, u = P;
|
|
1307
1329
|
} else {
|
|
1308
1330
|
const p = [this.dragPosition[0] - o[0], this.dragPosition[1] - o[1]];
|
|
1309
|
-
|
|
1331
|
+
h = c[0] - p[0], u = c[1] - p[1];
|
|
1310
1332
|
}
|
|
1311
|
-
if (
|
|
1312
|
-
r[d] = [
|
|
1333
|
+
if (h = F(h, this.config.coordinatePrecision), u = F(u, this.config.coordinatePrecision), h > 180 || h < -180 || u > 90 || u < -90) return !1;
|
|
1334
|
+
r[d] = [h, u];
|
|
1313
1335
|
}
|
|
1314
1336
|
i.type === "Polygon" && (r[r.length - 1] = [r[0][0], r[0][1]]);
|
|
1315
1337
|
const a = this.selectionPoints.getUpdated(r) || [], l = this.midPoints.getUpdated(r) || [];
|
|
@@ -1318,7 +1340,7 @@ class Ci extends j {
|
|
|
1318
1340
|
} else i.type === "Point" && (this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: { type: "Point", coordinates: o } }]), this.dragPosition = [t.lng, t.lat]);
|
|
1319
1341
|
}
|
|
1320
1342
|
}
|
|
1321
|
-
class
|
|
1343
|
+
class xi extends W {
|
|
1322
1344
|
constructor(t, e, i, o) {
|
|
1323
1345
|
super(t), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.draggedCoordinate = { id: null, index: -1 }, this.config = t, this.pixelDistance = e, this.selectionPoints = i, this.midPoints = o;
|
|
1324
1346
|
}
|
|
@@ -1349,11 +1371,11 @@ class Pi extends j {
|
|
|
1349
1371
|
if (t.lng > 180 || t.lng < -180 || t.lat > 90 || t.lat < -90) return !1;
|
|
1350
1372
|
if (r.type !== "Polygon" || o !== n.length - 1 && o !== 0) n[o] = a;
|
|
1351
1373
|
else {
|
|
1352
|
-
const
|
|
1353
|
-
n[0] = a, n[
|
|
1374
|
+
const h = n.length - 1;
|
|
1375
|
+
n[0] = a, n[h] = a;
|
|
1354
1376
|
}
|
|
1355
|
-
const l = this.selectionPoints.getOneUpdated(o, a), d = l ? [l] : [],
|
|
1356
|
-
return !(r.type !== "Point" && !e && _t({ geometry: r }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: r, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: I.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: r }, ...d, ...
|
|
1377
|
+
const l = this.selectionPoints.getOneUpdated(o, a), d = l ? [l] : [], c = this.midPoints.getUpdated(n) || [];
|
|
1378
|
+
return !(r.type !== "Point" && !e && _t({ geometry: r }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: r, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: I.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: r }, ...d, ...c]), 0));
|
|
1357
1379
|
}
|
|
1358
1380
|
isDragging() {
|
|
1359
1381
|
return this.draggedCoordinate.id !== null;
|
|
@@ -1371,9 +1393,9 @@ function vt(s) {
|
|
|
1371
1393
|
t += o[0], e += o[1], i++;
|
|
1372
1394
|
}, !0), [t / i, e / i];
|
|
1373
1395
|
}
|
|
1374
|
-
function
|
|
1396
|
+
function Le(s, t) {
|
|
1375
1397
|
s[0] += s[0] - t[0] > 180 ? -360 : t[0] - s[0] > 180 ? 360 : 0;
|
|
1376
|
-
const e =
|
|
1398
|
+
const e = fe, i = t[1] * Math.PI / 180, o = s[1] * Math.PI / 180, r = o - i;
|
|
1377
1399
|
let n = Math.abs(s[0] - t[0]) * Math.PI / 180;
|
|
1378
1400
|
n > Math.PI && (n -= 2 * Math.PI);
|
|
1379
1401
|
const a = Math.log(Math.tan(o / 2 + Math.PI / 4) / Math.tan(i / 2 + Math.PI / 4)), l = Math.abs(a) > 1e-11 ? r / a : Math.cos(i);
|
|
@@ -1388,8 +1410,8 @@ function Ct(s) {
|
|
|
1388
1410
|
let i = 0, o = 0, r = 0;
|
|
1389
1411
|
const n = e.length;
|
|
1390
1412
|
for (let a = 0; a < n - 1; a++) {
|
|
1391
|
-
const [l, d] = e[a], [
|
|
1392
|
-
i += u, o += (l +
|
|
1413
|
+
const [l, d] = e[a], [c, h] = e[a + 1], u = l * h - c * d;
|
|
1414
|
+
i += u, o += (l + c) * u, r += (d + h) * u;
|
|
1393
1415
|
}
|
|
1394
1416
|
return i /= 2, o /= 6 * i, r /= 6 * i, { x: o, y: r };
|
|
1395
1417
|
}(t) : function(e) {
|
|
@@ -1402,7 +1424,7 @@ function Ct(s) {
|
|
|
1402
1424
|
return { x: o / i, y: r / i };
|
|
1403
1425
|
}(t);
|
|
1404
1426
|
}
|
|
1405
|
-
class
|
|
1427
|
+
class Ii extends W {
|
|
1406
1428
|
constructor(t, e, i) {
|
|
1407
1429
|
super(t), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastBearing = void 0, this.config = t, this.selectionPoints = e, this.midPoints = i;
|
|
1408
1430
|
}
|
|
@@ -1417,35 +1439,35 @@ class Si extends j {
|
|
|
1417
1439
|
const a = { type: "Feature", geometry: o, properties: {} };
|
|
1418
1440
|
if (this.config.projection === "web-mercator") {
|
|
1419
1441
|
if (n = T(Ct(a), x(t.lng, t.lat)), !this.lastBearing) return void (this.lastBearing = n);
|
|
1420
|
-
((
|
|
1421
|
-
if (u === 0 || u === 360 || u === -360) return
|
|
1422
|
-
const p = 0.017453292519943295 * u, g = (
|
|
1442
|
+
((h, u) => {
|
|
1443
|
+
if (u === 0 || u === 360 || u === -360) return h;
|
|
1444
|
+
const p = 0.017453292519943295 * u, g = (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).map(([f, m]) => x(f, m)), y = g.reduce((f, m) => ({ x: f.x + m.x, y: f.y + m.y }), { x: 0, y: 0 });
|
|
1423
1445
|
y.x /= g.length, y.y /= g.length;
|
|
1424
|
-
const v = g.map((f) => ({ x: y.x + (f.x - y.x) * Math.cos(p) - (f.y - y.y) * Math.sin(p), y: y.y + (f.x - y.x) * Math.sin(p) + (f.y - y.y) * Math.cos(p) })).map(({ x: f, y: m }) => [
|
|
1425
|
-
|
|
1446
|
+
const v = g.map((f) => ({ x: y.x + (f.x - y.x) * Math.cos(p) - (f.y - y.y) * Math.sin(p), y: y.y + (f.x - y.x) * Math.sin(p) + (f.y - y.y) * Math.cos(p) })).map(({ x: f, y: m }) => [j(f, m).lng, j(f, m).lat]);
|
|
1447
|
+
h.geometry.type === "Polygon" ? h.geometry.coordinates[0] = v : h.geometry.coordinates = v;
|
|
1426
1448
|
})(a, -(this.lastBearing - n));
|
|
1427
1449
|
} else {
|
|
1428
1450
|
if (this.config.projection !== "globe") throw new Error("Unsupported projection");
|
|
1429
1451
|
if (n = mt(vt({ geometry: o }), r), !this.lastBearing) return void (this.lastBearing = n + 180);
|
|
1430
|
-
(function(
|
|
1431
|
-
if (u === 0 || u === 360 || u === -360) return
|
|
1432
|
-
const p = vt(
|
|
1433
|
-
(
|
|
1434
|
-
const y = mt(p, g) + u, v =
|
|
1452
|
+
(function(h, u) {
|
|
1453
|
+
if (u === 0 || u === 360 || u === -360) return h;
|
|
1454
|
+
const p = vt(h);
|
|
1455
|
+
(h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).forEach((g) => {
|
|
1456
|
+
const y = mt(p, g) + u, v = Le(p, g), f = jt(p, v, y);
|
|
1435
1457
|
g[0] = f[0], g[1] = f[1];
|
|
1436
1458
|
});
|
|
1437
1459
|
})(a, -(this.lastBearing - (n + 180)));
|
|
1438
1460
|
}
|
|
1439
1461
|
const l = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
|
|
1440
|
-
l.forEach((
|
|
1441
|
-
|
|
1462
|
+
l.forEach((h) => {
|
|
1463
|
+
h[0] = F(h[0], this.coordinatePrecision), h[1] = F(h[1], this.coordinatePrecision);
|
|
1442
1464
|
});
|
|
1443
|
-
const d = this.midPoints.getUpdated(l) || [],
|
|
1465
|
+
const d = this.midPoints.getUpdated(l) || [], c = this.selectionPoints.getUpdated(l) || [];
|
|
1444
1466
|
if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: I.Provisional })) return !1;
|
|
1445
|
-
this.store.updateGeometry([{ id: e, geometry: o }, ...
|
|
1467
|
+
this.store.updateGeometry([{ id: e, geometry: o }, ...c, ...d]), this.projection === "web-mercator" ? this.lastBearing = n : this.projection === "globe" && (this.lastBearing = n + 180);
|
|
1446
1468
|
}
|
|
1447
1469
|
}
|
|
1448
|
-
class
|
|
1470
|
+
class bi extends W {
|
|
1449
1471
|
constructor(t, e, i) {
|
|
1450
1472
|
super(t), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastDistance = void 0, this.config = t, this.selectionPoints = e, this.midPoints = i;
|
|
1451
1473
|
}
|
|
@@ -1468,28 +1490,28 @@ class xi extends j {
|
|
|
1468
1490
|
if (!this.lastDistance) return void (this.lastDistance = a);
|
|
1469
1491
|
const d = 1 - (this.lastDistance - a) / a;
|
|
1470
1492
|
if (this.config.projection === "web-mercator") {
|
|
1471
|
-
const { lng: p, lat: g } =
|
|
1493
|
+
const { lng: p, lat: g } = j(l.x, l.y);
|
|
1472
1494
|
(function(y, v, f) {
|
|
1473
1495
|
if (v === 1) return y;
|
|
1474
|
-
const m = (y.geometry.type === "Polygon" ? y.geometry.coordinates[0] : y.geometry.coordinates).map(([S, M]) => x(S, M)), C = x(f[0], f[1]), P = m.map((S) => ({ x: C.x + (S.x - C.x) * v, y: C.y + (S.y - C.y) * v })).map(({ x: S, y: M }) => [
|
|
1496
|
+
const m = (y.geometry.type === "Polygon" ? y.geometry.coordinates[0] : y.geometry.coordinates).map(([S, M]) => x(S, M)), C = x(f[0], f[1]), P = m.map((S) => ({ x: C.x + (S.x - C.x) * v, y: C.y + (S.y - C.y) * v })).map(({ x: S, y: M }) => [j(S, M).lng, j(S, M).lat]);
|
|
1475
1497
|
y.geometry.type === "Polygon" ? y.geometry.coordinates[0] = P : y.geometry.coordinates = P;
|
|
1476
1498
|
})(n, d, [p, g]);
|
|
1477
1499
|
} else this.config.projection === "globe" && function(p, g, y, v = "xy") {
|
|
1478
1500
|
g === 1 || (p.geometry.type === "Polygon" ? p.geometry.coordinates[0] : p.geometry.coordinates).forEach((f) => {
|
|
1479
|
-
const m =
|
|
1501
|
+
const m = Le(y, f), C = mt(y, f), P = jt(y, m * g, C);
|
|
1480
1502
|
v !== "x" && v !== "xy" || (f[0] = P[0]), v !== "y" && v !== "xy" || (f[1] = P[1]);
|
|
1481
1503
|
});
|
|
1482
1504
|
}(n, d, vt(n));
|
|
1483
|
-
const
|
|
1484
|
-
|
|
1505
|
+
const c = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
|
|
1506
|
+
c.forEach((p) => {
|
|
1485
1507
|
p[0] = F(p[0], this.coordinatePrecision), p[1] = F(p[1], this.coordinatePrecision);
|
|
1486
1508
|
});
|
|
1487
|
-
const
|
|
1509
|
+
const h = this.midPoints.getUpdated(c) || [], u = this.selectionPoints.getUpdated(c) || [];
|
|
1488
1510
|
if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: I.Provisional })) return !1;
|
|
1489
|
-
this.store.updateGeometry([{ id: e, geometry: o }, ...u, ...
|
|
1511
|
+
this.store.updateGeometry([{ id: e, geometry: o }, ...u, ...h]), this.lastDistance = a;
|
|
1490
1512
|
}
|
|
1491
1513
|
}
|
|
1492
|
-
class
|
|
1514
|
+
class Mi extends W {
|
|
1493
1515
|
constructor(t, e, i, o) {
|
|
1494
1516
|
super(t), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.minimumScale = 1e-4, this.draggedCoordinate = { id: null, index: -1 }, this.boundingBoxMaps = { opposite: { 0: 4, 1: 5, 2: 6, 3: 7, 4: 0, 5: 1, 6: 2, 7: 3 } }, this.config = t, this.pixelDistance = e, this.selectionPoints = i, this.midPoints = o;
|
|
1495
1517
|
}
|
|
@@ -1550,16 +1572,16 @@ class Ii extends j {
|
|
|
1550
1572
|
if (!e) return null;
|
|
1551
1573
|
const { feature: i, boundingBox: o, updatedCoords: r, selectedCoordinate: n } = e, a = Ct(i);
|
|
1552
1574
|
if (!a) return null;
|
|
1553
|
-
const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l),
|
|
1554
|
-
return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: r, webMercatorCursor:
|
|
1575
|
+
const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), c = x(t.lng, t.lat);
|
|
1576
|
+
return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: r, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), r;
|
|
1555
1577
|
}
|
|
1556
1578
|
centerFixedWebMercatorDrag(t) {
|
|
1557
1579
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1558
1580
|
if (!e) return null;
|
|
1559
1581
|
const { feature: i, boundingBox: o, updatedCoords: r, selectedCoordinate: n } = e, a = Ct(i);
|
|
1560
1582
|
if (!a) return null;
|
|
1561
|
-
const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l),
|
|
1562
|
-
return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: r, webMercatorCursor:
|
|
1583
|
+
const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), c = x(t.lng, t.lat);
|
|
1584
|
+
return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: r, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), r;
|
|
1563
1585
|
}
|
|
1564
1586
|
scaleFixedWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: r }) {
|
|
1565
1587
|
if (!this.isValidDragWebMercator(t, e.x - o.x, e.y - o.y)) return null;
|
|
@@ -1569,14 +1591,14 @@ class Ii extends j {
|
|
|
1569
1591
|
oppositeFixedWebMercatorDrag(t) {
|
|
1570
1592
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1571
1593
|
if (!e) return null;
|
|
1572
|
-
const { boundingBox: i, updatedCoords: o, selectedCoordinate: r } = e, n = x(r[0], r[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] },
|
|
1573
|
-
return this.scaleFixedWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor:
|
|
1594
|
+
const { boundingBox: i, updatedCoords: o, selectedCoordinate: r } = e, n = x(r[0], r[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] }, c = x(t.lng, t.lat);
|
|
1595
|
+
return this.scaleFixedWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: n, webMercatorOrigin: d }), o;
|
|
1574
1596
|
}
|
|
1575
1597
|
oppositeWebMercatorDrag(t) {
|
|
1576
1598
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1577
1599
|
if (!e) return null;
|
|
1578
|
-
const { boundingBox: i, updatedCoords: o, selectedCoordinate: r } = e, n = x(r[0], r[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] },
|
|
1579
|
-
return this.scaleWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor:
|
|
1600
|
+
const { boundingBox: i, updatedCoords: o, selectedCoordinate: r } = e, n = x(r[0], r[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] }, c = x(t.lng, t.lat);
|
|
1601
|
+
return this.scaleWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: n, webMercatorOrigin: d }), o;
|
|
1580
1602
|
}
|
|
1581
1603
|
scaleWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: r }) {
|
|
1582
1604
|
const n = e.x - o.x, a = e.y - o.y;
|
|
@@ -1600,8 +1622,8 @@ class Ii extends j {
|
|
|
1600
1622
|
}
|
|
1601
1623
|
performWebMercatorScale(t, e, i, o, r) {
|
|
1602
1624
|
t.forEach((n) => {
|
|
1603
|
-
const { x: a, y: l } = x(n[0], n[1]), d = e + (a - e) * o,
|
|
1604
|
-
n[0] =
|
|
1625
|
+
const { x: a, y: l } = x(n[0], n[1]), d = e + (a - e) * o, c = i + (l - i) * r, { lng: h, lat: u } = j(d, c);
|
|
1626
|
+
n[0] = h, n[1] = u;
|
|
1605
1627
|
});
|
|
1606
1628
|
}
|
|
1607
1629
|
getBBoxWebMercator(t) {
|
|
@@ -1644,20 +1666,20 @@ class Ii extends j {
|
|
|
1644
1666
|
let r = null;
|
|
1645
1667
|
if (e === "center" ? r = this.centerWebMercatorDrag(t) : e === "opposite" ? r = this.oppositeWebMercatorDrag(t) : e === "center-fixed" ? r = this.centerFixedWebMercatorDrag(t) : e === "opposite-fixed" && (r = this.oppositeFixedWebMercatorDrag(t)), !r) return !1;
|
|
1646
1668
|
for (let d = 0; d < r.length; d++) {
|
|
1647
|
-
const
|
|
1648
|
-
if (
|
|
1669
|
+
const c = r[d];
|
|
1670
|
+
if (c[0] = F(c[0], this.coordinatePrecision), c[1] = F(c[1], this.coordinatePrecision), !St(c, this.coordinatePrecision)) return !1;
|
|
1649
1671
|
}
|
|
1650
1672
|
const n = this.midPoints.getUpdated(r) || [], a = this.selectionPoints.getUpdated(r) || [], l = { type: o.geometry.type, coordinates: o.geometry.type === "Polygon" ? [r] : r };
|
|
1651
1673
|
return !(i && !i({ id: this.draggedCoordinate.id, type: "Feature", geometry: l, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: I.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: l }, ...a, ...n]), 0));
|
|
1652
1674
|
}
|
|
1653
1675
|
}
|
|
1654
|
-
const
|
|
1655
|
-
class
|
|
1676
|
+
const wi = { deselect: "Escape", delete: "Delete", rotate: ["Control", "r"], scale: ["Control", "s"] }, Zt = { pointerOver: "move", dragStart: "move", dragEnd: "move", insertMidpoint: "crosshair" };
|
|
1677
|
+
class _e extends Ke {
|
|
1656
1678
|
constructor(t) {
|
|
1657
|
-
super(t, !0), this.mode = "select", this.allowManualDeselection = !0, this.dragEventThrottle = 5, this.dragEventCount = 0, this.selected = [], this.flags = {}, this.keyEvents =
|
|
1679
|
+
super(t, !0), this.mode = "select", this.allowManualDeselection = !0, this.dragEventThrottle = 5, this.dragEventCount = 0, this.selected = [], this.flags = {}, this.keyEvents = wi, this.cursors = Zt, this.validations = {}, this.selectionPoints = void 0, this.midPoints = void 0, this.featuresAtMouseEvent = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.dragFeature = void 0, this.dragCoordinate = void 0, this.rotateFeature = void 0, this.scaleFeature = void 0, this.dragCoordinateResizeFeature = void 0, this.updateOptions(t);
|
|
1658
1680
|
}
|
|
1659
1681
|
updateOptions(t) {
|
|
1660
|
-
if (super.updateOptions(t), this.cursors = t && t.cursors ? b({}, this.cursors, t.cursors) :
|
|
1682
|
+
if (super.updateOptions(t), this.cursors = t && t.cursors ? b({}, this.cursors, t.cursors) : Zt, (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { deselect: null, delete: null, rotate: null, scale: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents)), (t == null ? void 0 : t.dragEventThrottle) !== void 0 && (this.dragEventThrottle = t.dragEventThrottle), (t == null ? void 0 : t.allowManualDeselection) !== void 0 && (this.allowManualDeselection = t.allowManualDeselection), t != null && t.flags) {
|
|
1661
1683
|
this.flags = b({}, this.flags, t.flags), this.validations = {};
|
|
1662
1684
|
for (const e in this.flags) {
|
|
1663
1685
|
const i = this.flags[e].feature;
|
|
@@ -1673,7 +1695,7 @@ class Le extends Xe {
|
|
|
1673
1695
|
this._state = "selecting";
|
|
1674
1696
|
}
|
|
1675
1697
|
registerBehaviors(t) {
|
|
1676
|
-
this.pixelDistance = new nt(t), this.clickBoundingBox = new rt(t), this.featuresAtMouseEvent = new
|
|
1698
|
+
this.pixelDistance = new nt(t), this.clickBoundingBox = new rt(t), this.featuresAtMouseEvent = new Pi(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new Ci(t), this.midPoints = new vi(t, this.selectionPoints), this.rotateFeature = new Ii(t, this.selectionPoints, this.midPoints), this.scaleFeature = new bi(t, this.selectionPoints, this.midPoints), this.dragFeature = new Si(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints), this.dragCoordinate = new xi(t, this.pixelDistance, this.selectionPoints, this.midPoints), this.dragCoordinateResizeFeature = new Mi(t, this.pixelDistance, this.selectionPoints, this.midPoints);
|
|
1677
1699
|
}
|
|
1678
1700
|
deselectFeature() {
|
|
1679
1701
|
this.deselect();
|
|
@@ -1688,18 +1710,18 @@ class Le extends Xe {
|
|
|
1688
1710
|
onRightClick(t) {
|
|
1689
1711
|
if (!this.selectionPoints.ids.length) return;
|
|
1690
1712
|
let e, i = 1 / 0;
|
|
1691
|
-
if (this.selectionPoints.ids.forEach((
|
|
1692
|
-
const u = this.store.getGeometryCopy(
|
|
1693
|
-
p < this.pointerDistance && p < i && (i = p, e = this.store.getPropertiesCopy(
|
|
1713
|
+
if (this.selectionPoints.ids.forEach((h) => {
|
|
1714
|
+
const u = this.store.getGeometryCopy(h), p = this.pixelDistance.measure(t, u.coordinates);
|
|
1715
|
+
p < this.pointerDistance && p < i && (i = p, e = this.store.getPropertiesCopy(h));
|
|
1694
1716
|
}), !e) return;
|
|
1695
1717
|
const o = e.selectionPointFeatureId, r = e.index, n = this.store.getPropertiesCopy(o), a = this.flags[n.mode], l = this.validations[n.mode];
|
|
1696
1718
|
if (!(a && a.feature && a.feature.coordinates && a.feature.coordinates.deletable)) return;
|
|
1697
1719
|
const d = this.store.getGeometryCopy(o);
|
|
1698
|
-
let
|
|
1720
|
+
let c;
|
|
1699
1721
|
if (d.type === "Polygon") {
|
|
1700
|
-
if (
|
|
1701
|
-
} else if (d.type === "LineString" && (
|
|
1702
|
-
|
|
1722
|
+
if (c = d.coordinates[0], c.length <= 4) return;
|
|
1723
|
+
} else if (d.type === "LineString" && (c = d.coordinates, c.length <= 2)) return;
|
|
1724
|
+
c && (d.type !== "Polygon" || r !== 0 && r !== c.length - 1 ? c.splice(r, 1) : (c.shift(), c.pop(), c.push([c[0][0], c[0][1]])), (!l || l({ id: o, type: "Feature", geometry: d, properties: n }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: I.Commit }).valid) && (this.store.delete([...this.midPoints.ids, ...this.selectionPoints.ids]), this.store.updateGeometry([{ id: o, geometry: d }]), this.selectionPoints.create(c, d.type, o), a && a.feature && a.feature.coordinates && a.feature.coordinates.midpoints && this.midPoints.create(c, o, this.coordinatePrecision)));
|
|
1703
1725
|
}
|
|
1704
1726
|
select(t, e = !0) {
|
|
1705
1727
|
if (this.selected[0] === t) return;
|
|
@@ -1756,10 +1778,19 @@ class Le extends Xe {
|
|
|
1756
1778
|
onDragStart(t, e) {
|
|
1757
1779
|
if (!this.selected.length) return;
|
|
1758
1780
|
const i = this.store.getPropertiesCopy(this.selected[0]), o = this.flags[i.mode];
|
|
1759
|
-
if (!(o && o.feature && (o.feature.draggable || o.feature.coordinates && o.feature.coordinates.draggable || o.feature.coordinates && o.feature.coordinates.resizable))) return;
|
|
1781
|
+
if (!(o && o.feature && (o.feature.draggable || o.feature.coordinates && o.feature.coordinates.draggable || o.feature.coordinates && o.feature.coordinates.resizable || o.feature.coordinates && typeof o.feature.coordinates.midpoints == "object" && o.feature.coordinates.midpoints.draggable))) return;
|
|
1760
1782
|
this.dragEventCount = 0;
|
|
1761
1783
|
const r = this.selected[0], n = this.dragCoordinate.getDraggableIndex(t, r);
|
|
1762
|
-
|
|
1784
|
+
if (o && o.feature && o.feature.coordinates && (o.feature.coordinates.draggable || o.feature.coordinates.resizable) && n !== -1) return this.setCursor(this.cursors.dragStart), o.feature.coordinates.resizable ? this.dragCoordinateResizeFeature.startDragging(r, n) : this.dragCoordinate.startDragging(r, n), void e(!1);
|
|
1785
|
+
if (o && o.feature && o.feature.coordinates && typeof o.feature.coordinates.midpoints == "object" && o.feature.coordinates.midpoints.draggable) {
|
|
1786
|
+
const { clickedMidPoint: a } = this.featuresAtMouseEvent.find(t, this.selected.length > 0);
|
|
1787
|
+
if (this.selected.length && a) {
|
|
1788
|
+
this.midPoints.insert(a.id, this.coordinatePrecision);
|
|
1789
|
+
const l = this.dragCoordinate.getDraggableIndex(t, r);
|
|
1790
|
+
return this.dragCoordinate.startDragging(r, l), void e(!1);
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
return o && o.feature && o.feature.draggable && this.dragFeature.canDrag(t, r) ? (this.setCursor(this.cursors.dragStart), this.dragFeature.startDragging(t, r), void e(!1)) : void 0;
|
|
1763
1794
|
}
|
|
1764
1795
|
onDrag(t, e) {
|
|
1765
1796
|
const i = this.selected[0];
|
|
@@ -1808,7 +1839,7 @@ class Le extends Xe {
|
|
|
1808
1839
|
return e;
|
|
1809
1840
|
}
|
|
1810
1841
|
}
|
|
1811
|
-
class
|
|
1842
|
+
class Fi extends N {
|
|
1812
1843
|
constructor(...t) {
|
|
1813
1844
|
super(...t), this.type = $.Static, this.mode = "static";
|
|
1814
1845
|
}
|
|
@@ -1836,11 +1867,11 @@ class Mi extends N {
|
|
|
1836
1867
|
return b({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
1837
1868
|
}
|
|
1838
1869
|
}
|
|
1839
|
-
function
|
|
1870
|
+
function ke(s, t, e, i, o) {
|
|
1840
1871
|
for (; i > e; ) {
|
|
1841
1872
|
if (i - e > 600) {
|
|
1842
|
-
const l = i - e + 1, d = t - e + 1,
|
|
1843
|
-
|
|
1873
|
+
const l = i - e + 1, d = t - e + 1, c = Math.log(l), h = 0.5 * Math.exp(2 * c / 3), u = 0.5 * Math.sqrt(c * h * (l - h) / l) * (d - l / 2 < 0 ? -1 : 1);
|
|
1874
|
+
ke(s, t, Math.max(e, Math.floor(t - d * h / l + u)), Math.min(i, Math.floor(t + (l - d) * h / l + u)), o);
|
|
1844
1875
|
}
|
|
1845
1876
|
const r = s[t];
|
|
1846
1877
|
let n = e, a = i;
|
|
@@ -1869,10 +1900,10 @@ function it(s, t, e, i, o) {
|
|
|
1869
1900
|
function ot(s, t) {
|
|
1870
1901
|
return s.minX = Math.min(s.minX, t.minX), s.minY = Math.min(s.minY, t.minY), s.maxX = Math.max(s.maxX, t.maxX), s.maxY = Math.max(s.maxY, t.maxY), s;
|
|
1871
1902
|
}
|
|
1872
|
-
function
|
|
1903
|
+
function Ei(s, t) {
|
|
1873
1904
|
return s.minX - t.minX;
|
|
1874
1905
|
}
|
|
1875
|
-
function
|
|
1906
|
+
function Oi(s, t) {
|
|
1876
1907
|
return s.minY - t.minY;
|
|
1877
1908
|
}
|
|
1878
1909
|
function wt(s) {
|
|
@@ -1881,7 +1912,7 @@ function wt(s) {
|
|
|
1881
1912
|
function ut(s) {
|
|
1882
1913
|
return s.maxX - s.minX + (s.maxY - s.minY);
|
|
1883
1914
|
}
|
|
1884
|
-
function
|
|
1915
|
+
function Di(s, t) {
|
|
1885
1916
|
const e = Math.max(s.minX, t.minX), i = Math.max(s.minY, t.minY), o = Math.min(s.maxX, t.maxX), r = Math.min(s.maxY, t.maxY);
|
|
1886
1917
|
return Math.max(0, o - e) * Math.max(0, r - i);
|
|
1887
1918
|
}
|
|
@@ -1894,15 +1925,15 @@ function pt(s, t) {
|
|
|
1894
1925
|
function J(s) {
|
|
1895
1926
|
return { children: s, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
|
|
1896
1927
|
}
|
|
1897
|
-
function
|
|
1928
|
+
function Qt(s, t, e, i, o) {
|
|
1898
1929
|
const r = [t, e];
|
|
1899
1930
|
for (; r.length; ) {
|
|
1900
1931
|
if ((e = r.pop()) - (t = r.pop()) <= i) continue;
|
|
1901
1932
|
const n = t + Math.ceil((e - t) / i / 2) * i;
|
|
1902
|
-
|
|
1933
|
+
ke(s, n, t, e, o), r.push(t, n, n, e);
|
|
1903
1934
|
}
|
|
1904
1935
|
}
|
|
1905
|
-
class
|
|
1936
|
+
class Li {
|
|
1906
1937
|
constructor(t) {
|
|
1907
1938
|
this._maxEntries = void 0, this._minEntries = void 0, this.data = void 0, this._maxEntries = Math.max(4, t), this._minEntries = Math.max(2, Math.ceil(0.4 * this._maxEntries)), this.clear();
|
|
1908
1939
|
}
|
|
@@ -1991,12 +2022,12 @@ class Oi {
|
|
|
1991
2022
|
if (r <= a) return n = J(t.slice(e, i + 1)), H(n, this.toBBox), n;
|
|
1992
2023
|
o || (o = Math.ceil(Math.log(r) / Math.log(a)), a = Math.ceil(r / Math.pow(a, o - 1))), n = J([]), n.leaf = !1, n.height = o;
|
|
1993
2024
|
const l = Math.ceil(r / a), d = l * Math.ceil(Math.sqrt(a));
|
|
1994
|
-
|
|
1995
|
-
for (let
|
|
1996
|
-
const
|
|
1997
|
-
|
|
1998
|
-
for (let u =
|
|
1999
|
-
const p = Math.min(u + l - 1,
|
|
2025
|
+
Qt(t, e, i, d, this.compareMinX);
|
|
2026
|
+
for (let c = e; c <= i; c += d) {
|
|
2027
|
+
const h = Math.min(c + d - 1, i);
|
|
2028
|
+
Qt(t, c, h, l, this.compareMinY);
|
|
2029
|
+
for (let u = c; u <= h; u += l) {
|
|
2030
|
+
const p = Math.min(u + l - 1, h);
|
|
2000
2031
|
n.children.push(this._build(t, u, p, o - 1));
|
|
2001
2032
|
}
|
|
2002
2033
|
}
|
|
@@ -2005,9 +2036,9 @@ class Oi {
|
|
|
2005
2036
|
_chooseSubtree(t, e, i, o) {
|
|
2006
2037
|
for (; o.push(e), !e.leaf && o.length - 1 !== i; ) {
|
|
2007
2038
|
let a, l = 1 / 0, d = 1 / 0;
|
|
2008
|
-
for (let
|
|
2009
|
-
const
|
|
2010
|
-
p < d ? (d = p, l = u < l ? u : l, a =
|
|
2039
|
+
for (let c = 0; c < e.children.length; c++) {
|
|
2040
|
+
const h = e.children[c], u = wt(h), p = (r = t, n = h, (Math.max(n.maxX, r.maxX) - Math.min(n.minX, r.minX)) * (Math.max(n.maxY, r.maxY) - Math.min(n.minY, r.minY)) - u);
|
|
2041
|
+
p < d ? (d = p, l = u < l ? u : l, a = h) : p === d && u < l && (l = u, a = h);
|
|
2011
2042
|
}
|
|
2012
2043
|
e = a || e.children[0];
|
|
2013
2044
|
}
|
|
@@ -2031,13 +2062,13 @@ class Oi {
|
|
|
2031
2062
|
_chooseSplitIndex(t, e, i) {
|
|
2032
2063
|
let o, r = 1 / 0, n = 1 / 0;
|
|
2033
2064
|
for (let a = e; a <= i - e; a++) {
|
|
2034
|
-
const l = it(t, 0, a, this.toBBox), d = it(t, a, i, this.toBBox),
|
|
2035
|
-
|
|
2065
|
+
const l = it(t, 0, a, this.toBBox), d = it(t, a, i, this.toBBox), c = Di(l, d), h = wt(l) + wt(d);
|
|
2066
|
+
c < r ? (r = c, o = a, n = h < n ? h : n) : c === r && h < n && (n = h, o = a);
|
|
2036
2067
|
}
|
|
2037
2068
|
return o || i - e;
|
|
2038
2069
|
}
|
|
2039
2070
|
_chooseSplitAxis(t, e, i) {
|
|
2040
|
-
const o = t.leaf ? this.compareMinX :
|
|
2071
|
+
const o = t.leaf ? this.compareMinX : Ei, r = t.leaf ? this.compareMinY : Oi;
|
|
2041
2072
|
this._allDistMargin(t, e, i, o) < this._allDistMargin(t, e, i, r) && t.children.sort(o);
|
|
2042
2073
|
}
|
|
2043
2074
|
_allDistMargin(t, e, i, o) {
|
|
@@ -2045,12 +2076,12 @@ class Oi {
|
|
|
2045
2076
|
const r = this.toBBox, n = it(t, 0, e, r), a = it(t, i - e, i, r);
|
|
2046
2077
|
let l = ut(n) + ut(a);
|
|
2047
2078
|
for (let d = e; d < i - e; d++) {
|
|
2048
|
-
const
|
|
2049
|
-
ot(n, t.leaf ? r(
|
|
2079
|
+
const c = t.children[d];
|
|
2080
|
+
ot(n, t.leaf ? r(c) : c), l += ut(n);
|
|
2050
2081
|
}
|
|
2051
2082
|
for (let d = i - e - 1; d >= e; d--) {
|
|
2052
|
-
const
|
|
2053
|
-
ot(a, t.leaf ? r(
|
|
2083
|
+
const c = t.children[d];
|
|
2084
|
+
ot(a, t.leaf ? r(c) : c), l += ut(a);
|
|
2054
2085
|
}
|
|
2055
2086
|
return l;
|
|
2056
2087
|
}
|
|
@@ -2061,9 +2092,9 @@ class Oi {
|
|
|
2061
2092
|
for (let e, i = t.length - 1; i >= 0; i--) t[i].children.length === 0 ? i > 0 ? (e = t[i - 1].children, e.splice(e.indexOf(t[i]), 1)) : this.clear() : H(t[i], this.toBBox);
|
|
2062
2093
|
}
|
|
2063
2094
|
}
|
|
2064
|
-
class
|
|
2095
|
+
class _i {
|
|
2065
2096
|
constructor(t) {
|
|
2066
|
-
this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new
|
|
2097
|
+
this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new Li(t && t.maxEntries ? t.maxEntries : 9), this.idToNode = /* @__PURE__ */ new Map(), this.nodeToId = /* @__PURE__ */ new Map();
|
|
2067
2098
|
}
|
|
2068
2099
|
setMaps(t, e) {
|
|
2069
2100
|
this.idToNode.set(t.id, e), this.nodeToId.set(e, t.id);
|
|
@@ -2114,14 +2145,14 @@ class Di {
|
|
|
2114
2145
|
return this.tree.collides(this.toBBox(t));
|
|
2115
2146
|
}
|
|
2116
2147
|
}
|
|
2117
|
-
const
|
|
2148
|
+
const ki = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(s) {
|
|
2118
2149
|
const t = 16 * Math.random() | 0;
|
|
2119
2150
|
return (s == "x" ? t : 3 & t | 8).toString(16);
|
|
2120
2151
|
}), isValidId: (s) => typeof s == "string" && s.length === 36 };
|
|
2121
|
-
class
|
|
2152
|
+
class ji {
|
|
2122
2153
|
constructor(t) {
|
|
2123
2154
|
this.idStrategy = void 0, this.tracked = void 0, this.spatialIndex = void 0, this.store = void 0, this._onChange = () => {
|
|
2124
|
-
}, this.store = {}, this.spatialIndex = new
|
|
2155
|
+
}, this.store = {}, this.spatialIndex = new _i(), this.tracked = !t || t.tracked !== !1, this.idStrategy = t && t.idStrategy ? t.idStrategy : ki;
|
|
2125
2156
|
}
|
|
2126
2157
|
clone(t) {
|
|
2127
2158
|
return JSON.parse(JSON.stringify(t));
|
|
@@ -2145,10 +2176,10 @@ class _i {
|
|
|
2145
2176
|
}
|
|
2146
2177
|
if (this.tracked) {
|
|
2147
2178
|
if (n.properties.createdAt) {
|
|
2148
|
-
if (!
|
|
2179
|
+
if (!Ut(n.properties.createdAt)) return r.push({ id: n.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
|
|
2149
2180
|
} else n.properties.createdAt = +/* @__PURE__ */ new Date();
|
|
2150
2181
|
if (n.properties.updatedAt) {
|
|
2151
|
-
if (!
|
|
2182
|
+
if (!Ut(n.properties.updatedAt)) return r.push({ id: n.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
|
|
2152
2183
|
} else n.properties.updatedAt = +/* @__PURE__ */ new Date();
|
|
2153
2184
|
}
|
|
2154
2185
|
return this.has(a) ? (r.push({ id: a, valid: !1, reason: `Feature already exists with this id: ${a}` }), !1) : (this.store[a] = n, o.push(a), r.push({ id: a, valid: !0 }), !0);
|
|
@@ -2218,16 +2249,16 @@ class _i {
|
|
|
2218
2249
|
return Object.keys(this.store).length;
|
|
2219
2250
|
}
|
|
2220
2251
|
}
|
|
2221
|
-
const
|
|
2222
|
-
function
|
|
2252
|
+
const Wi = "Feature is not a Polygon or LineString", Bi = "Feature intersects itself", Ni = (s) => s.geometry.type !== "Polygon" && s.geometry.type !== "LineString" ? { valid: !1, reason: Wi } : _t(s) ? { valid: !1, reason: Bi } : { valid: !0 };
|
|
2253
|
+
function te(s, t, e) {
|
|
2223
2254
|
const i = T(s, t);
|
|
2224
2255
|
let o = T(t, e) - i;
|
|
2225
2256
|
return o < 0 && (o += 360), 180 - Math.abs(o - 90 - 90);
|
|
2226
2257
|
}
|
|
2227
|
-
const
|
|
2228
|
-
class
|
|
2258
|
+
const Gi = { cancel: "Escape", finish: "Enter" }, Ti = { start: "crosshair", close: "pointer" };
|
|
2259
|
+
class je extends N {
|
|
2229
2260
|
constructor(t) {
|
|
2230
|
-
super(t, !0), this.mode = "angled-rectangle", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents =
|
|
2261
|
+
super(t, !0), this.mode = "angled-rectangle", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = Gi, this.cursors = Ti, this.mouseMove = !1, this.updateOptions(t);
|
|
2231
2262
|
}
|
|
2232
2263
|
updateOptions(t) {
|
|
2233
2264
|
super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents));
|
|
@@ -2251,10 +2282,10 @@ class ke extends N {
|
|
|
2251
2282
|
const o = 1 / Math.pow(10, this.coordinatePrecision - 1), r = Math.max(1e-6, o);
|
|
2252
2283
|
i = [e[0], [t.lng, t.lat], [t.lng, t.lat - r], e[0]];
|
|
2253
2284
|
} else if (this.currentCoordinate === 2) {
|
|
2254
|
-
const o = e[0], r = e[1], n =
|
|
2285
|
+
const o = e[0], r = e[1], n = Ee(o, r, this.coordinatePrecision, this.project, this.unproject), a = x(o[0], o[1]), l = x(n[0], n[1]), d = x(r[0], r[1]), c = x(t.lng, t.lat), h = O(c, a) < O(c, d), u = te(a, l, c), p = h ? 90 - u : te(a, l, c) - 90, g = O(l, c), y = Math.cos(E(p)) * g, v = T(a, d) + (function(S, M, w) {
|
|
2255
2286
|
const D = (w.x - M.x) * (S.y - M.y) - (w.y - M.y) * (S.x - M.x);
|
|
2256
2287
|
return D > 1e-10 ? "left" : D < -1e-10 ? "right" : "left";
|
|
2257
|
-
}(a, d,
|
|
2288
|
+
}(a, d, c) === "right" ? -90 : 90), f = at(a, y, v), m = at(d, y, v), C = j(f.x, f.y), P = j(m.x, m.y);
|
|
2258
2289
|
i = [e[0], e[1], [P.lng, P.lat], [C.lng, C.lat], e[0]];
|
|
2259
2290
|
}
|
|
2260
2291
|
i && this.updatePolygonGeometry(this.currentId, i, I.Provisional);
|
|
@@ -2306,10 +2337,10 @@ class ke extends N {
|
|
|
2306
2337
|
function We(s, t, e) {
|
|
2307
2338
|
return (t.x - s.x) * (e.y - s.y) - (t.y - s.y) * (e.x - s.x) <= 0;
|
|
2308
2339
|
}
|
|
2309
|
-
const
|
|
2310
|
-
class
|
|
2340
|
+
const Ai = { cancel: "Escape", finish: "Enter" }, Vi = { start: "crosshair", close: "pointer" };
|
|
2341
|
+
class Be extends N {
|
|
2311
2342
|
constructor(t) {
|
|
2312
|
-
super(t, !0), this.mode = "sector", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents =
|
|
2343
|
+
super(t, !0), this.mode = "sector", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = Ai, this.direction = void 0, this.arcPoints = 64, this.cursors = Vi, this.mouseMove = !1, this.updateOptions(t);
|
|
2313
2344
|
}
|
|
2314
2345
|
updateOptions(t) {
|
|
2315
2346
|
super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents)), t != null && t.arcPoints && (this.arcPoints = t.arcPoints);
|
|
@@ -2340,13 +2371,13 @@ class je extends N {
|
|
|
2340
2371
|
const C = We(a, l, d);
|
|
2341
2372
|
this.direction = C ? "clockwise" : "anticlockwise";
|
|
2342
2373
|
}
|
|
2343
|
-
const
|
|
2374
|
+
const c = O(a, l), h = T(a, l), u = T(a, d), p = this.arcPoints, g = [o], y = Y(h), v = Y(u);
|
|
2344
2375
|
let f;
|
|
2345
2376
|
this.direction === "anticlockwise" ? (f = v - y, f < 0 && (f += 360)) : (f = y - v, f < 0 && (f += 360));
|
|
2346
2377
|
const m = (this.direction === "anticlockwise" ? 1 : -1) * f / p;
|
|
2347
2378
|
g.push(r);
|
|
2348
2379
|
for (let C = 0; C <= p; C++) {
|
|
2349
|
-
const P = at(a,
|
|
2380
|
+
const P = at(a, c, y + C * m), { lng: S, lat: M } = j(P.x, P.y), w = [F(S, this.coordinatePrecision), F(M, this.coordinatePrecision)];
|
|
2350
2381
|
w[0] !== g[g.length - 1][0] && w[1] !== g[g.length - 1][1] && g.push(w);
|
|
2351
2382
|
}
|
|
2352
2383
|
g.push(o), i = [...g];
|
|
@@ -2393,10 +2424,10 @@ class je extends N {
|
|
|
2393
2424
|
return this.validateModeFeature(t, (e) => lt(e, this.coordinatePrecision));
|
|
2394
2425
|
}
|
|
2395
2426
|
}
|
|
2396
|
-
const
|
|
2397
|
-
class
|
|
2427
|
+
const Ui = { cancel: "Escape", finish: "Enter" }, zi = { start: "crosshair", close: "pointer" };
|
|
2428
|
+
class Ne extends N {
|
|
2398
2429
|
constructor(t) {
|
|
2399
|
-
super(t, !0), this.mode = "sensor", this.currentCoordinate = 0, this.currentId = void 0, this.currentInitialArcId = void 0, this.currentStartingPointId = void 0, this.keyEvents =
|
|
2430
|
+
super(t, !0), this.mode = "sensor", this.currentCoordinate = 0, this.currentId = void 0, this.currentInitialArcId = void 0, this.currentStartingPointId = void 0, this.keyEvents = Ui, this.direction = void 0, this.arcPoints = 64, this.cursors = zi, this.mouseMove = !1, this.updateOptions(t);
|
|
2400
2431
|
}
|
|
2401
2432
|
updateOptions(t) {
|
|
2402
2433
|
super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents)), t != null && t.arcPoints && (this.arcPoints = t.arcPoints);
|
|
@@ -2424,23 +2455,23 @@ class Be extends N {
|
|
|
2424
2455
|
const m = We(l, n, a);
|
|
2425
2456
|
this.direction = m ? "clockwise" : "anticlockwise";
|
|
2426
2457
|
}
|
|
2427
|
-
const
|
|
2458
|
+
const c = T(l, n), h = T(l, a), u = this.arcPoints, p = [o], g = Y(c), y = Y(h);
|
|
2428
2459
|
let v;
|
|
2429
2460
|
this.direction === "anticlockwise" ? (v = y - g, v < 0 && (v += 360)) : (v = g - y, v < 0 && (v += 360));
|
|
2430
2461
|
const f = (this.direction === "anticlockwise" ? 1 : -1) * v / u;
|
|
2431
2462
|
for (let m = 0; m <= u; m++) {
|
|
2432
|
-
const C = at(l, d, g + m * f), { lng: P, lat: S } =
|
|
2463
|
+
const C = at(l, d, g + m * f), { lng: P, lat: S } = j(C.x, C.y), M = [F(P, this.coordinatePrecision), F(S, this.coordinatePrecision)];
|
|
2433
2464
|
M[0] !== p[p.length - 1][0] && M[1] !== p[p.length - 1][1] && p.push(M);
|
|
2434
2465
|
}
|
|
2435
2466
|
this.updateLineStringGeometry(this.currentInitialArcId, p, I.Provisional);
|
|
2436
2467
|
} else if (this.currentCoordinate === 3) {
|
|
2437
2468
|
const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates;
|
|
2438
2469
|
if (e.length < 2 || !this.direction) return;
|
|
2439
|
-
const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], r = e[e.length - 1], n = x(t.lng, t.lat), a = x(o[0], o[1]), l = x(r[0], r[1]), d = x(i[0], i[1]),
|
|
2470
|
+
const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], r = e[e.length - 1], n = x(t.lng, t.lat), a = x(o[0], o[1]), l = x(r[0], r[1]), d = x(i[0], i[1]), c = O(d, a), h = O(d, n) < c ? a : n, u = T(d, n), p = T(d, a), g = T(d, l), y = Y(p), v = Y(g), f = Y(u);
|
|
2440
2471
|
if (this.notInSector({ normalizedCursor: f, normalizedStart: y, normalizedEnd: v, direction: this.direction })) return;
|
|
2441
|
-
const m = this.getDeltaBearing(this.direction, y, v), C = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * m / C, S = O(d,
|
|
2472
|
+
const m = this.getDeltaBearing(this.direction, y, v), C = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * m / C, S = O(d, h), M = [];
|
|
2442
2473
|
for (let w = 0; w <= C; w++) {
|
|
2443
|
-
const D = at(d, S, y + w * P), { lng: G, lat: L } =
|
|
2474
|
+
const D = at(d, S, y + w * P), { lng: G, lat: L } = j(D.x, D.y), B = [F(G, this.coordinatePrecision), F(L, this.coordinatePrecision)];
|
|
2444
2475
|
B[0] !== e[e.length - 1][0] && B[1] !== e[e.length - 1][1] && M.unshift(B);
|
|
2445
2476
|
}
|
|
2446
2477
|
e.push(...M), e.push(e[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, e, I.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [e] }, properties: { mode: this.mode } }]);
|
|
@@ -2497,51 +2528,51 @@ class Be extends N {
|
|
|
2497
2528
|
return o === "clockwise" ? e <= i ? t >= e && t <= i : t >= e || t <= i : e >= i ? t <= e && t >= i : t <= e || t >= i;
|
|
2498
2529
|
}
|
|
2499
2530
|
}
|
|
2500
|
-
class
|
|
2531
|
+
class Ri {
|
|
2501
2532
|
constructor(t) {
|
|
2502
|
-
this._modes = void 0, this._mode = void 0, this._adapter = void 0, this._enabled = !1, this._store = void 0, this._eventListeners = void 0, this._instanceSelectMode = void 0, this._adapter = t.adapter, this._mode = new
|
|
2503
|
-
const e = /* @__PURE__ */ new Set(), i = t.modes.reduce((
|
|
2504
|
-
if (e.has(
|
|
2505
|
-
return e.add(
|
|
2533
|
+
this._modes = void 0, this._mode = void 0, this._adapter = void 0, this._enabled = !1, this._store = void 0, this._eventListeners = void 0, this._instanceSelectMode = void 0, this._adapter = t.adapter, this._mode = new Fi();
|
|
2534
|
+
const e = /* @__PURE__ */ new Set(), i = t.modes.reduce((c, h) => {
|
|
2535
|
+
if (e.has(h.mode)) throw new Error(`There is already a ${h.mode} mode provided`);
|
|
2536
|
+
return e.add(h.mode), c[h.mode] = h, c;
|
|
2506
2537
|
}, {}), o = Object.keys(i);
|
|
2507
2538
|
if (o.length === 0) throw new Error("No modes provided");
|
|
2508
|
-
o.forEach((
|
|
2509
|
-
if (i[
|
|
2539
|
+
o.forEach((c) => {
|
|
2540
|
+
if (i[c].type === $.Select) {
|
|
2510
2541
|
if (this._instanceSelectMode) throw new Error("only one type of select mode can be provided");
|
|
2511
|
-
this._instanceSelectMode =
|
|
2542
|
+
this._instanceSelectMode = c;
|
|
2512
2543
|
}
|
|
2513
|
-
}), this._modes = b({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new
|
|
2514
|
-
const r = (
|
|
2515
|
-
const
|
|
2516
|
-
return { changed:
|
|
2517
|
-
}, n = (
|
|
2544
|
+
}), this._modes = b({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new ji({ tracked: !!t.tracked, idStrategy: t.idStrategy ? t.idStrategy : void 0 });
|
|
2545
|
+
const r = (c) => {
|
|
2546
|
+
const h = [], u = this._store.copyAll().filter((p) => !c.includes(p.id) || (h.push(p), !1));
|
|
2547
|
+
return { changed: h, unchanged: u };
|
|
2548
|
+
}, n = (c, h) => {
|
|
2518
2549
|
this._enabled && this._eventListeners.finish.forEach((u) => {
|
|
2519
|
-
u(
|
|
2550
|
+
u(c, h);
|
|
2520
2551
|
});
|
|
2521
|
-
}, a = (
|
|
2552
|
+
}, a = (c, h) => {
|
|
2522
2553
|
if (!this._enabled) return;
|
|
2523
2554
|
this._eventListeners.change.forEach((g) => {
|
|
2524
|
-
g(
|
|
2555
|
+
g(c, h);
|
|
2525
2556
|
});
|
|
2526
|
-
const { changed: u, unchanged: p } = r(
|
|
2527
|
-
|
|
2528
|
-
}, l = (
|
|
2557
|
+
const { changed: u, unchanged: p } = r(c);
|
|
2558
|
+
h === "create" ? this._adapter.render({ created: u, deletedIds: [], unchanged: p, updated: [] }, this.getModeStyles()) : h === "update" ? this._adapter.render({ created: [], deletedIds: [], unchanged: p, updated: u }, this.getModeStyles()) : h === "delete" ? this._adapter.render({ created: [], deletedIds: c, unchanged: p, updated: [] }, this.getModeStyles()) : h === "styling" && this._adapter.render({ created: [], deletedIds: [], unchanged: p, updated: [] }, this.getModeStyles());
|
|
2559
|
+
}, l = (c) => {
|
|
2529
2560
|
if (!this._enabled) return;
|
|
2530
2561
|
this._eventListeners.select.forEach((p) => {
|
|
2531
|
-
p(
|
|
2562
|
+
p(c);
|
|
2532
2563
|
});
|
|
2533
|
-
const { changed:
|
|
2534
|
-
this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated:
|
|
2535
|
-
}, d = (
|
|
2564
|
+
const { changed: h, unchanged: u } = r([c]);
|
|
2565
|
+
this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: h }, this.getModeStyles());
|
|
2566
|
+
}, d = (c) => {
|
|
2536
2567
|
if (!this._enabled) return;
|
|
2537
2568
|
this._eventListeners.deselect.forEach((p) => {
|
|
2538
2569
|
p();
|
|
2539
2570
|
});
|
|
2540
|
-
const { changed:
|
|
2541
|
-
|
|
2571
|
+
const { changed: h, unchanged: u } = r([c]);
|
|
2572
|
+
h && this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: h }, this.getModeStyles());
|
|
2542
2573
|
};
|
|
2543
|
-
Object.keys(this._modes).forEach((
|
|
2544
|
-
this._modes[
|
|
2574
|
+
Object.keys(this._modes).forEach((c) => {
|
|
2575
|
+
this._modes[c].register({ mode: c, store: this._store, setCursor: this._adapter.setCursor.bind(this._adapter), project: this._adapter.project.bind(this._adapter), unproject: this._adapter.unproject.bind(this._adapter), setDoubleClickToZoom: this._adapter.setDoubleClickToZoom.bind(this._adapter), onChange: a, onSelect: l, onDeselect: d, onFinish: n, coordinatePrecision: this._adapter.getCoordinatePrecision() });
|
|
2545
2576
|
});
|
|
2546
2577
|
}
|
|
2547
2578
|
checkEnabled() {
|
|
@@ -2554,22 +2585,22 @@ class Ui {
|
|
|
2554
2585
|
}), t;
|
|
2555
2586
|
}
|
|
2556
2587
|
featuresAtLocation({ lng: t, lat: e }, i) {
|
|
2557
|
-
const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, r = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, n = this._adapter.unproject.bind(this._adapter), a = this._adapter.project.bind(this._adapter), l = a(t, e), d =
|
|
2558
|
-
return this._store.search(d).filter((
|
|
2559
|
-
if (r && (
|
|
2560
|
-
if (
|
|
2561
|
-
const
|
|
2588
|
+
const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, r = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, n = this._adapter.unproject.bind(this._adapter), a = this._adapter.project.bind(this._adapter), l = a(t, e), d = Pe({ unproject: n, point: l, pointerDistance: o });
|
|
2589
|
+
return this._store.search(d).filter((c) => {
|
|
2590
|
+
if (r && (c.properties[U.MID_POINT] || c.properties[U.SELECTION_POINT])) return !1;
|
|
2591
|
+
if (c.geometry.type === "Point") {
|
|
2592
|
+
const h = c.geometry.coordinates, u = a(h[0], h[1]);
|
|
2562
2593
|
return O(l, u) < o;
|
|
2563
2594
|
}
|
|
2564
|
-
if (
|
|
2565
|
-
const
|
|
2566
|
-
for (let u = 0; u <
|
|
2567
|
-
const p =
|
|
2568
|
-
if (
|
|
2595
|
+
if (c.geometry.type === "LineString") {
|
|
2596
|
+
const h = c.geometry.coordinates;
|
|
2597
|
+
for (let u = 0; u < h.length - 1; u++) {
|
|
2598
|
+
const p = h[u], g = h[u + 1];
|
|
2599
|
+
if (De(l, a(p[0], p[1]), a(g[0], g[1])) < o) return !0;
|
|
2569
2600
|
}
|
|
2570
2601
|
return !1;
|
|
2571
2602
|
}
|
|
2572
|
-
return !!
|
|
2603
|
+
return !!Oe([t, e], c.geometry.coordinates) || void 0;
|
|
2573
2604
|
});
|
|
2574
2605
|
}
|
|
2575
2606
|
getSelectMode() {
|
|
@@ -2677,14 +2708,14 @@ class Ui {
|
|
|
2677
2708
|
i.includes(e) && i.splice(i.indexOf(e), 1);
|
|
2678
2709
|
}
|
|
2679
2710
|
}
|
|
2680
|
-
var
|
|
2681
|
-
function
|
|
2711
|
+
var ee, Et, ie;
|
|
2712
|
+
function oe(s, t = 9) {
|
|
2682
2713
|
const e = Math.pow(10, t);
|
|
2683
2714
|
return Math.round(s * e) / e;
|
|
2684
2715
|
}
|
|
2685
|
-
(Et =
|
|
2716
|
+
(Et = ee || (ee = {})).Commit = "commit", Et.Provisional = "provisional", Et.Finish = "finish", function(s) {
|
|
2686
2717
|
s.Drawing = "drawing", s.Select = "select", s.Static = "static", s.Render = "render";
|
|
2687
|
-
}(
|
|
2718
|
+
}(ie || (ie = {}));
|
|
2688
2719
|
class q {
|
|
2689
2720
|
constructor({ name: t, callback: e, unregister: i, register: o }) {
|
|
2690
2721
|
this.name = void 0, this.callback = void 0, this.registered = !1, this.register = void 0, this.unregister = void 0, this.name = t, this.register = () => {
|
|
@@ -2694,7 +2725,7 @@ class q {
|
|
|
2694
2725
|
}, this.callback = e;
|
|
2695
2726
|
}
|
|
2696
2727
|
}
|
|
2697
|
-
var
|
|
2728
|
+
var Xi = class {
|
|
2698
2729
|
constructor(s) {
|
|
2699
2730
|
this._minPixelDragDistance = void 0, this._minPixelDragDistanceDrawing = void 0, this._minPixelDragDistanceSelecting = void 0, this._lastDrawEvent = void 0, this._coordinatePrecision = void 0, this._heldKeys = /* @__PURE__ */ new Set(), this._listeners = [], this._dragState = "not-dragging", this._currentModeCallbacks = void 0, this._minPixelDragDistance = typeof s.minPixelDragDistance == "number" ? s.minPixelDragDistance : 1, this._minPixelDragDistanceSelecting = typeof s.minPixelDragDistanceSelecting == "number" ? s.minPixelDragDistanceSelecting : 1, this._minPixelDragDistanceDrawing = typeof s.minPixelDragDistanceDrawing == "number" ? s.minPixelDragDistanceDrawing : 8, this._coordinatePrecision = typeof s.coordinatePrecision == "number" ? s.coordinatePrecision : 9;
|
|
2700
2731
|
}
|
|
@@ -2709,7 +2740,7 @@ var zi = class {
|
|
|
2709
2740
|
const t = this.getLngLatFromEvent(s);
|
|
2710
2741
|
if (!t) return null;
|
|
2711
2742
|
const { lng: e, lat: i } = t, { containerX: o, containerY: r } = this.getMapElementXYPosition(s), n = this.getButton(s), a = Array.from(this._heldKeys);
|
|
2712
|
-
return { lng:
|
|
2743
|
+
return { lng: oe(e, this._coordinatePrecision), lat: oe(i, this._coordinatePrecision), containerX: o, containerY: r, button: n, heldKeys: a };
|
|
2713
2744
|
}
|
|
2714
2745
|
register(s) {
|
|
2715
2746
|
this._currentModeCallbacks = s, this._listeners = this.getAdapterListeners(), this._listeners.forEach((t) => {
|
|
@@ -2736,7 +2767,7 @@ var zi = class {
|
|
|
2736
2767
|
else if (this._dragState === "pre-dragging") {
|
|
2737
2768
|
if (!this._lastDrawEvent) return;
|
|
2738
2769
|
const e = { x: this._lastDrawEvent.containerX, y: this._lastDrawEvent.containerY }, i = { x: t.containerX, y: t.containerY }, o = this._currentModeCallbacks.getState(), r = ((a, l) => {
|
|
2739
|
-
const { x: d, y:
|
|
2770
|
+
const { x: d, y: c } = a, { x: h, y: u } = l, p = h - d, g = u - c;
|
|
2740
2771
|
return Math.sqrt(g * g + p * p);
|
|
2741
2772
|
})(e, i);
|
|
2742
2773
|
let n = !1;
|
|
@@ -2787,7 +2818,7 @@ var zi = class {
|
|
|
2787
2818
|
}), this.clear();
|
|
2788
2819
|
}
|
|
2789
2820
|
};
|
|
2790
|
-
class
|
|
2821
|
+
class Ki extends Xi {
|
|
2791
2822
|
constructor(t) {
|
|
2792
2823
|
super(t), this._nextRender = void 0, this._map = void 0, this._container = void 0, this._rendered = !1, this.changedIds = { deletion: !1, points: !1, linestrings: !1, polygons: !1, styling: !1 }, this._map = t.map, this._container = this._map.getContainer();
|
|
2793
2824
|
}
|
|
@@ -2857,13 +2888,13 @@ class Ri extends zi {
|
|
|
2857
2888
|
this.updateChangedIds(t), this._nextRender && cancelAnimationFrame(this._nextRender), this._nextRender = requestAnimationFrame(() => {
|
|
2858
2889
|
const i = [...t.created, ...t.updated, ...t.unchanged], o = [], r = [], n = [];
|
|
2859
2890
|
for (let a = 0; a < i.length; a++) {
|
|
2860
|
-
const l = i[a], { properties: d } = l,
|
|
2861
|
-
l.geometry.type === "Point" ? (d.pointColor =
|
|
2891
|
+
const l = i[a], { properties: d } = l, c = e[d.mode](l);
|
|
2892
|
+
l.geometry.type === "Point" ? (d.pointColor = c.pointColor, d.pointOutlineColor = c.pointOutlineColor, d.pointOutlineWidth = c.pointOutlineWidth, d.pointWidth = c.pointWidth, o.push(l)) : l.geometry.type === "LineString" ? (d.lineStringColor = c.lineStringColor, d.lineStringWidth = c.lineStringWidth, r.push(l)) : l.geometry.type === "Polygon" && (d.polygonFillColor = c.polygonFillColor, d.polygonFillOpacity = c.polygonFillOpacity, d.polygonOutlineColor = c.polygonOutlineColor, d.polygonOutlineWidth = c.polygonOutlineWidth, n.push(l));
|
|
2862
2893
|
}
|
|
2863
2894
|
if (this._rendered) {
|
|
2864
2895
|
const a = this.changedIds.deletion || this.changedIds.styling, l = a || this.changedIds.linestrings, d = a || this.changedIds.polygons;
|
|
2865
|
-
let
|
|
2866
|
-
(a || this.changedIds.points) && (
|
|
2896
|
+
let c;
|
|
2897
|
+
(a || this.changedIds.points) && (c = this._setGeoJSONLayerData("Point", o)), l && this._setGeoJSONLayerData("LineString", r), d && this._setGeoJSONLayerData("Polygon", n), c && this._map.moveLayer(c);
|
|
2867
2898
|
} else {
|
|
2868
2899
|
const a = this._addGeoJSONLayer("Point", o);
|
|
2869
2900
|
this._addGeoJSONLayer("LineString", r), this._addGeoJSONLayer("Polygon", n), this._rendered = !0, a && this._map.moveLayer(a);
|
|
@@ -2885,7 +2916,7 @@ class Ri extends zi {
|
|
|
2885
2916
|
super.register(t), (e = this._currentModeCallbacks) != null && e.onReady && this._currentModeCallbacks.onReady();
|
|
2886
2917
|
}
|
|
2887
2918
|
}
|
|
2888
|
-
const
|
|
2919
|
+
const _o = [
|
|
2889
2920
|
"render",
|
|
2890
2921
|
"point",
|
|
2891
2922
|
"linestring",
|
|
@@ -2900,7 +2931,7 @@ const Lo = [
|
|
|
2900
2931
|
"delete-selection",
|
|
2901
2932
|
"delete",
|
|
2902
2933
|
"download"
|
|
2903
|
-
],
|
|
2934
|
+
], Yi = {
|
|
2904
2935
|
modes: [
|
|
2905
2936
|
"render",
|
|
2906
2937
|
"point",
|
|
@@ -2938,7 +2969,7 @@ const Lo = [
|
|
|
2938
2969
|
open: !1,
|
|
2939
2970
|
// see styling parameters of Terra Draw at https://github.com/JamesLMilner/terra-draw/blob/main/guides/5.STYLING.md
|
|
2940
2971
|
modeOptions: {
|
|
2941
|
-
point: new
|
|
2972
|
+
point: new Me({
|
|
2942
2973
|
editable: !0,
|
|
2943
2974
|
styles: {
|
|
2944
2975
|
pointColor: "#FFFFFF",
|
|
@@ -2947,7 +2978,7 @@ const Lo = [
|
|
|
2947
2978
|
pointOutlineWidth: 1
|
|
2948
2979
|
}
|
|
2949
2980
|
}),
|
|
2950
|
-
linestring: new
|
|
2981
|
+
linestring: new Ie({
|
|
2951
2982
|
editable: !0,
|
|
2952
2983
|
styles: {
|
|
2953
2984
|
lineStringColor: "#232E3D",
|
|
@@ -2958,7 +2989,7 @@ const Lo = [
|
|
|
2958
2989
|
closingPointOutlineWidth: 1
|
|
2959
2990
|
}
|
|
2960
2991
|
}),
|
|
2961
|
-
polygon: new
|
|
2992
|
+
polygon: new we({
|
|
2962
2993
|
editable: !0,
|
|
2963
2994
|
styles: {
|
|
2964
2995
|
fillColor: "#EDEFF0",
|
|
@@ -2971,7 +3002,7 @@ const Lo = [
|
|
|
2971
3002
|
closingPointOutlineWidth: 1
|
|
2972
3003
|
}
|
|
2973
3004
|
}),
|
|
2974
|
-
rectangle: new
|
|
3005
|
+
rectangle: new Fe({
|
|
2975
3006
|
styles: {
|
|
2976
3007
|
fillColor: "#EDEFF0",
|
|
2977
3008
|
fillOpacity: 0.7,
|
|
@@ -2979,7 +3010,7 @@ const Lo = [
|
|
|
2979
3010
|
outlineWidth: 2
|
|
2980
3011
|
}
|
|
2981
3012
|
}),
|
|
2982
|
-
"angled-rectangle": new
|
|
3013
|
+
"angled-rectangle": new je({
|
|
2983
3014
|
styles: {
|
|
2984
3015
|
fillColor: "#EDEFF0",
|
|
2985
3016
|
fillOpacity: 0.7,
|
|
@@ -2987,7 +3018,7 @@ const Lo = [
|
|
|
2987
3018
|
outlineWidth: 2
|
|
2988
3019
|
}
|
|
2989
3020
|
}),
|
|
2990
|
-
circle: new
|
|
3021
|
+
circle: new ve({
|
|
2991
3022
|
styles: {
|
|
2992
3023
|
fillColor: "#EDEFF0",
|
|
2993
3024
|
fillOpacity: 0.7,
|
|
@@ -2995,7 +3026,7 @@ const Lo = [
|
|
|
2995
3026
|
outlineWidth: 2
|
|
2996
3027
|
}
|
|
2997
3028
|
}),
|
|
2998
|
-
freehand: new
|
|
3029
|
+
freehand: new Ce({
|
|
2999
3030
|
styles: {
|
|
3000
3031
|
fillColor: "#EDEFF0",
|
|
3001
3032
|
fillOpacity: 0.7,
|
|
@@ -3007,7 +3038,7 @@ const Lo = [
|
|
|
3007
3038
|
closingPointOutlineWidth: 1
|
|
3008
3039
|
}
|
|
3009
3040
|
}),
|
|
3010
|
-
sensor: new
|
|
3041
|
+
sensor: new Ne({
|
|
3011
3042
|
styles: {
|
|
3012
3043
|
fillColor: "#EDEFF0",
|
|
3013
3044
|
fillOpacity: 0.7,
|
|
@@ -3019,7 +3050,7 @@ const Lo = [
|
|
|
3019
3050
|
centerPointOutlineWidth: 1
|
|
3020
3051
|
}
|
|
3021
3052
|
}),
|
|
3022
|
-
sector: new
|
|
3053
|
+
sector: new Be({
|
|
3023
3054
|
styles: {
|
|
3024
3055
|
fillColor: "#EDEFF0",
|
|
3025
3056
|
fillOpacity: 0.7,
|
|
@@ -3027,7 +3058,7 @@ const Lo = [
|
|
|
3027
3058
|
outlineWidth: 2
|
|
3028
3059
|
}
|
|
3029
3060
|
}),
|
|
3030
|
-
select: new
|
|
3061
|
+
select: new _e({
|
|
3031
3062
|
flags: {
|
|
3032
3063
|
point: {
|
|
3033
3064
|
feature: {
|
|
@@ -3281,33 +3312,33 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3281
3312
|
distancePrecision: 2,
|
|
3282
3313
|
areaUnit: "metric",
|
|
3283
3314
|
areaPrecision: 2
|
|
3284
|
-
},
|
|
3315
|
+
}, $i = () => ({
|
|
3285
3316
|
render: new et({
|
|
3286
3317
|
modeName: "render",
|
|
3287
3318
|
styles: {}
|
|
3288
3319
|
}),
|
|
3289
|
-
point: new
|
|
3320
|
+
point: new Me({
|
|
3290
3321
|
editable: !0
|
|
3291
3322
|
}),
|
|
3292
|
-
linestring: new
|
|
3323
|
+
linestring: new Ie({
|
|
3293
3324
|
editable: !0
|
|
3294
3325
|
}),
|
|
3295
|
-
polygon: new
|
|
3326
|
+
polygon: new we({
|
|
3296
3327
|
editable: !0,
|
|
3297
3328
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3298
3329
|
// @ts-ignore
|
|
3299
3330
|
validation: (t, e) => {
|
|
3300
3331
|
const i = e.updateType;
|
|
3301
|
-
return i === "finish" || i === "commit" ?
|
|
3332
|
+
return i === "finish" || i === "commit" ? Ni(t) : { valid: !0 };
|
|
3302
3333
|
}
|
|
3303
3334
|
}),
|
|
3304
|
-
rectangle: new
|
|
3305
|
-
"angled-rectangle": new
|
|
3306
|
-
circle: new
|
|
3307
|
-
freehand: new
|
|
3308
|
-
sensor: new
|
|
3309
|
-
sector: new
|
|
3310
|
-
select: new
|
|
3335
|
+
rectangle: new Fe(),
|
|
3336
|
+
"angled-rectangle": new je(),
|
|
3337
|
+
circle: new ve(),
|
|
3338
|
+
freehand: new Ce(),
|
|
3339
|
+
sensor: new Ne(),
|
|
3340
|
+
sector: new Be(),
|
|
3341
|
+
select: new _e({
|
|
3311
3342
|
flags: {
|
|
3312
3343
|
point: {
|
|
3313
3344
|
feature: {
|
|
@@ -3421,7 +3452,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3421
3452
|
styles: {}
|
|
3422
3453
|
})
|
|
3423
3454
|
});
|
|
3424
|
-
var _ = 63710088e-1,
|
|
3455
|
+
var _ = 63710088e-1, Hi = {
|
|
3425
3456
|
centimeters: _ * 100,
|
|
3426
3457
|
centimetres: _ * 100,
|
|
3427
3458
|
degrees: 360 / (2 * Math.PI),
|
|
@@ -3438,26 +3469,26 @@ var _ = 63710088e-1, Yi = {
|
|
|
3438
3469
|
radians: 1,
|
|
3439
3470
|
yards: _ * 1.0936
|
|
3440
3471
|
};
|
|
3441
|
-
function
|
|
3472
|
+
function qi(s, t, e = {}) {
|
|
3442
3473
|
const i = { type: "Feature" };
|
|
3443
3474
|
return (e.id === 0 || e.id) && (i.id = e.id), e.bbox && (i.bbox = e.bbox), i.properties = t || {}, i.geometry = s, i;
|
|
3444
3475
|
}
|
|
3445
|
-
function
|
|
3476
|
+
function Ji(s, t, e = {}) {
|
|
3446
3477
|
if (!s)
|
|
3447
3478
|
throw new Error("coordinates is required");
|
|
3448
3479
|
if (!Array.isArray(s))
|
|
3449
3480
|
throw new Error("coordinates must be an Array");
|
|
3450
3481
|
if (s.length < 2)
|
|
3451
3482
|
throw new Error("coordinates must be at least 2 numbers long");
|
|
3452
|
-
if (!
|
|
3483
|
+
if (!se(s[0]) || !se(s[1]))
|
|
3453
3484
|
throw new Error("coordinates must contain numbers");
|
|
3454
|
-
return
|
|
3485
|
+
return qi({
|
|
3455
3486
|
type: "Point",
|
|
3456
3487
|
coordinates: s
|
|
3457
3488
|
}, t, e);
|
|
3458
3489
|
}
|
|
3459
|
-
function
|
|
3460
|
-
const e =
|
|
3490
|
+
function Zi(s, t = "kilometers") {
|
|
3491
|
+
const e = Hi[t];
|
|
3461
3492
|
if (!e)
|
|
3462
3493
|
throw new Error(t + " units is invalid");
|
|
3463
3494
|
return s * e;
|
|
@@ -3465,60 +3496,60 @@ function qi(s, t = "kilometers") {
|
|
|
3465
3496
|
function gt(s) {
|
|
3466
3497
|
return s % 360 * Math.PI / 180;
|
|
3467
3498
|
}
|
|
3468
|
-
function
|
|
3499
|
+
function se(s) {
|
|
3469
3500
|
return !isNaN(s) && s !== null && !Array.isArray(s);
|
|
3470
3501
|
}
|
|
3471
|
-
function
|
|
3502
|
+
function Ge(s, t, e) {
|
|
3472
3503
|
if (s !== null)
|
|
3473
|
-
for (var i, o, r, n, a, l, d,
|
|
3504
|
+
for (var i, o, r, n, a, l, d, c = 0, h = 0, u, p = s.type, g = p === "FeatureCollection", y = p === "Feature", v = g ? s.features.length : 1, f = 0; f < v; f++) {
|
|
3474
3505
|
d = g ? s.features[f].geometry : y ? s.geometry : s, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
|
|
3475
3506
|
for (var m = 0; m < a; m++) {
|
|
3476
3507
|
var C = 0, P = 0;
|
|
3477
3508
|
if (n = u ? d.geometries[m] : d, n !== null) {
|
|
3478
3509
|
l = n.coordinates;
|
|
3479
3510
|
var S = n.type;
|
|
3480
|
-
switch (
|
|
3511
|
+
switch (c = S === "Polygon" || S === "MultiPolygon" ? 1 : 0, S) {
|
|
3481
3512
|
case null:
|
|
3482
3513
|
break;
|
|
3483
3514
|
case "Point":
|
|
3484
3515
|
if (t(
|
|
3485
3516
|
l,
|
|
3486
|
-
|
|
3517
|
+
h,
|
|
3487
3518
|
f,
|
|
3488
3519
|
C,
|
|
3489
3520
|
P
|
|
3490
3521
|
) === !1)
|
|
3491
3522
|
return !1;
|
|
3492
|
-
|
|
3523
|
+
h++, C++;
|
|
3493
3524
|
break;
|
|
3494
3525
|
case "LineString":
|
|
3495
3526
|
case "MultiPoint":
|
|
3496
3527
|
for (i = 0; i < l.length; i++) {
|
|
3497
3528
|
if (t(
|
|
3498
3529
|
l[i],
|
|
3499
|
-
|
|
3530
|
+
h,
|
|
3500
3531
|
f,
|
|
3501
3532
|
C,
|
|
3502
3533
|
P
|
|
3503
3534
|
) === !1)
|
|
3504
3535
|
return !1;
|
|
3505
|
-
|
|
3536
|
+
h++, S === "MultiPoint" && C++;
|
|
3506
3537
|
}
|
|
3507
3538
|
S === "LineString" && C++;
|
|
3508
3539
|
break;
|
|
3509
3540
|
case "Polygon":
|
|
3510
3541
|
case "MultiLineString":
|
|
3511
3542
|
for (i = 0; i < l.length; i++) {
|
|
3512
|
-
for (o = 0; o < l[i].length -
|
|
3543
|
+
for (o = 0; o < l[i].length - c; o++) {
|
|
3513
3544
|
if (t(
|
|
3514
3545
|
l[i][o],
|
|
3515
|
-
|
|
3546
|
+
h,
|
|
3516
3547
|
f,
|
|
3517
3548
|
C,
|
|
3518
3549
|
P
|
|
3519
3550
|
) === !1)
|
|
3520
3551
|
return !1;
|
|
3521
|
-
|
|
3552
|
+
h++;
|
|
3522
3553
|
}
|
|
3523
3554
|
S === "MultiLineString" && C++, S === "Polygon" && P++;
|
|
3524
3555
|
}
|
|
@@ -3527,16 +3558,16 @@ function Ne(s, t, e) {
|
|
|
3527
3558
|
case "MultiPolygon":
|
|
3528
3559
|
for (i = 0; i < l.length; i++) {
|
|
3529
3560
|
for (P = 0, o = 0; o < l[i].length; o++) {
|
|
3530
|
-
for (r = 0; r < l[i][o].length -
|
|
3561
|
+
for (r = 0; r < l[i][o].length - c; r++) {
|
|
3531
3562
|
if (t(
|
|
3532
3563
|
l[i][o][r],
|
|
3533
|
-
|
|
3564
|
+
h,
|
|
3534
3565
|
f,
|
|
3535
3566
|
C,
|
|
3536
3567
|
P
|
|
3537
3568
|
) === !1)
|
|
3538
3569
|
return !1;
|
|
3539
|
-
|
|
3570
|
+
h++;
|
|
3540
3571
|
}
|
|
3541
3572
|
P++;
|
|
3542
3573
|
}
|
|
@@ -3545,7 +3576,7 @@ function Ne(s, t, e) {
|
|
|
3545
3576
|
break;
|
|
3546
3577
|
case "GeometryCollection":
|
|
3547
3578
|
for (i = 0; i < n.geometries.length; i++)
|
|
3548
|
-
if (
|
|
3579
|
+
if (Ge(n.geometries[i], t) === !1)
|
|
3549
3580
|
return !1;
|
|
3550
3581
|
break;
|
|
3551
3582
|
default:
|
|
@@ -3555,17 +3586,17 @@ function Ne(s, t, e) {
|
|
|
3555
3586
|
}
|
|
3556
3587
|
}
|
|
3557
3588
|
}
|
|
3558
|
-
function
|
|
3559
|
-
var e, i, o, r, n, a, l, d,
|
|
3589
|
+
function Qi(s, t) {
|
|
3590
|
+
var e, i, o, r, n, a, l, d, c, h, u = 0, p = s.type === "FeatureCollection", g = s.type === "Feature", y = p ? s.features.length : 1;
|
|
3560
3591
|
for (e = 0; e < y; e++) {
|
|
3561
|
-
for (a = p ? s.features[e].geometry : g ? s.geometry : s, d = p ? s.features[e].properties : g ? s.properties : {},
|
|
3592
|
+
for (a = p ? s.features[e].geometry : g ? s.geometry : s, d = p ? s.features[e].properties : g ? s.properties : {}, c = p ? s.features[e].bbox : g ? s.bbox : void 0, h = p ? s.features[e].id : g ? s.id : void 0, l = a ? a.type === "GeometryCollection" : !1, n = l ? a.geometries.length : 1, o = 0; o < n; o++) {
|
|
3562
3593
|
if (r = l ? a.geometries[o] : a, r === null) {
|
|
3563
3594
|
if (t(
|
|
3564
3595
|
null,
|
|
3565
3596
|
u,
|
|
3566
3597
|
d,
|
|
3567
|
-
|
|
3568
|
-
|
|
3598
|
+
c,
|
|
3599
|
+
h
|
|
3569
3600
|
) === !1)
|
|
3570
3601
|
return !1;
|
|
3571
3602
|
continue;
|
|
@@ -3581,8 +3612,8 @@ function Ji(s, t) {
|
|
|
3581
3612
|
r,
|
|
3582
3613
|
u,
|
|
3583
3614
|
d,
|
|
3584
|
-
|
|
3585
|
-
|
|
3615
|
+
c,
|
|
3616
|
+
h
|
|
3586
3617
|
) === !1)
|
|
3587
3618
|
return !1;
|
|
3588
3619
|
break;
|
|
@@ -3593,8 +3624,8 @@ function Ji(s, t) {
|
|
|
3593
3624
|
r.geometries[i],
|
|
3594
3625
|
u,
|
|
3595
3626
|
d,
|
|
3596
|
-
|
|
3597
|
-
|
|
3627
|
+
c,
|
|
3628
|
+
h
|
|
3598
3629
|
) === !1)
|
|
3599
3630
|
return !1;
|
|
3600
3631
|
break;
|
|
@@ -3606,9 +3637,9 @@ function Ji(s, t) {
|
|
|
3606
3637
|
u++;
|
|
3607
3638
|
}
|
|
3608
3639
|
}
|
|
3609
|
-
function
|
|
3640
|
+
function to(s, t, e) {
|
|
3610
3641
|
var i = e;
|
|
3611
|
-
return
|
|
3642
|
+
return Qi(
|
|
3612
3643
|
s,
|
|
3613
3644
|
function(o, r, n, a, l) {
|
|
3614
3645
|
r === 0 && e === void 0 ? i = o : i = t(
|
|
@@ -3622,21 +3653,21 @@ function Zi(s, t, e) {
|
|
|
3622
3653
|
}
|
|
3623
3654
|
), i;
|
|
3624
3655
|
}
|
|
3625
|
-
function
|
|
3626
|
-
return
|
|
3656
|
+
function eo(s) {
|
|
3657
|
+
return to(
|
|
3627
3658
|
s,
|
|
3628
|
-
(t, e) => t +
|
|
3659
|
+
(t, e) => t + io(e),
|
|
3629
3660
|
0
|
|
3630
3661
|
);
|
|
3631
3662
|
}
|
|
3632
|
-
function
|
|
3663
|
+
function io(s) {
|
|
3633
3664
|
let t = 0, e;
|
|
3634
3665
|
switch (s.type) {
|
|
3635
3666
|
case "Polygon":
|
|
3636
|
-
return
|
|
3667
|
+
return re(s.coordinates);
|
|
3637
3668
|
case "MultiPolygon":
|
|
3638
3669
|
for (e = 0; e < s.coordinates.length; e++)
|
|
3639
|
-
t +=
|
|
3670
|
+
t += re(s.coordinates[e]);
|
|
3640
3671
|
return t;
|
|
3641
3672
|
case "Point":
|
|
3642
3673
|
case "MultiPoint":
|
|
@@ -3646,17 +3677,17 @@ function to(s) {
|
|
|
3646
3677
|
}
|
|
3647
3678
|
return 0;
|
|
3648
3679
|
}
|
|
3649
|
-
function
|
|
3680
|
+
function re(s) {
|
|
3650
3681
|
let t = 0;
|
|
3651
3682
|
if (s && s.length > 0) {
|
|
3652
|
-
t += Math.abs(
|
|
3683
|
+
t += Math.abs(ne(s[0]));
|
|
3653
3684
|
for (let e = 1; e < s.length; e++)
|
|
3654
|
-
t -= Math.abs(
|
|
3685
|
+
t -= Math.abs(ne(s[e]));
|
|
3655
3686
|
}
|
|
3656
3687
|
return t;
|
|
3657
3688
|
}
|
|
3658
|
-
var
|
|
3659
|
-
function
|
|
3689
|
+
var oo = _ * _ / 2, Ot = Math.PI / 180;
|
|
3690
|
+
function ne(s) {
|
|
3660
3691
|
const t = s.length - 1;
|
|
3661
3692
|
if (t <= 2) return 0;
|
|
3662
3693
|
let e = 0, i = 0;
|
|
@@ -3664,18 +3695,18 @@ function re(s) {
|
|
|
3664
3695
|
const o = s[i], r = s[i + 1 === t ? 0 : i + 1], n = s[i + 2 >= t ? (i + 2) % t : i + 2], a = o[0] * Ot, l = r[1] * Ot, d = n[0] * Ot;
|
|
3665
3696
|
e += (d - a) * Math.sin(l), i++;
|
|
3666
3697
|
}
|
|
3667
|
-
return e *
|
|
3698
|
+
return e * oo;
|
|
3668
3699
|
}
|
|
3669
|
-
var
|
|
3670
|
-
const
|
|
3700
|
+
var so = eo;
|
|
3701
|
+
const ro = (s, t) => {
|
|
3671
3702
|
let e = s, i = "m²";
|
|
3672
3703
|
return t === "metric" ? s >= 1e6 ? (e = s / 1e6, i = "km²") : s >= 1e4 && (e = s / 1e4, i = "ha") : s >= 258998811e-2 ? (e = s / 258998811e-2, i = "mi²") : s >= 4046.856 ? (e = s / 4046.856, i = "acre") : s >= 0.83612736 && (e = s / 0.83612736, i = "yd²"), { area: e, unit: i };
|
|
3673
|
-
},
|
|
3704
|
+
}, ae = (s, t, e) => {
|
|
3674
3705
|
if (s.geometry.type !== "Polygon") return s;
|
|
3675
|
-
const i =
|
|
3706
|
+
const i = so(s.geometry), o = ro(i, t);
|
|
3676
3707
|
return o.area = parseFloat(o.area.toFixed(e)), s.properties.area = o.area, s.properties.unit = o.unit, s;
|
|
3677
3708
|
};
|
|
3678
|
-
function
|
|
3709
|
+
function le(s) {
|
|
3679
3710
|
if (!s)
|
|
3680
3711
|
throw new Error("coord is required");
|
|
3681
3712
|
if (!Array.isArray(s)) {
|
|
@@ -3688,47 +3719,47 @@ function ae(s) {
|
|
|
3688
3719
|
return [...s];
|
|
3689
3720
|
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
3690
3721
|
}
|
|
3691
|
-
function
|
|
3692
|
-
var i =
|
|
3693
|
-
return
|
|
3722
|
+
function no(s, t, e = {}) {
|
|
3723
|
+
var i = le(s), o = le(t), r = gt(o[1] - i[1]), n = gt(o[0] - i[0]), a = gt(i[1]), l = gt(o[1]), d = Math.pow(Math.sin(r / 2), 2) + Math.pow(Math.sin(n / 2), 2) * Math.cos(a) * Math.cos(l);
|
|
3724
|
+
return Zi(
|
|
3694
3725
|
2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
|
|
3695
3726
|
e.units
|
|
3696
3727
|
);
|
|
3697
3728
|
}
|
|
3698
|
-
var
|
|
3699
|
-
const
|
|
3729
|
+
var ao = no;
|
|
3730
|
+
const lo = (s) => s === "degrees" ? "°" : s === "miles" ? "mi" : s === "radians" ? "rad" : "km", de = (s, t, e, i, o, r) => {
|
|
3700
3731
|
if (s.geometry.type !== "LineString") return s;
|
|
3701
3732
|
const n = s.geometry.coordinates;
|
|
3702
3733
|
let a = 0;
|
|
3703
3734
|
const l = [];
|
|
3704
3735
|
for (let d = 0; d < n.length - 1; d++) {
|
|
3705
|
-
const
|
|
3736
|
+
const c = n[d], h = n[d + 1], u = ao(c, h, { units: t });
|
|
3706
3737
|
a += u;
|
|
3707
3738
|
const p = JSON.parse(JSON.stringify(s));
|
|
3708
|
-
if (p.id = `${p.id}-${d}`, p.geometry.coordinates = [
|
|
3709
|
-
const g = i == null ? void 0 : i.queryTerrainElevation(
|
|
3739
|
+
if (p.id = `${p.id}-${d}`, p.geometry.coordinates = [c, h], p.properties.originalId = s.id, p.properties.distance = parseFloat(u.toFixed(e)), p.properties.total = parseFloat(a.toFixed(e)), p.properties.unit = lo(t), o === !0 && r === void 0) {
|
|
3740
|
+
const g = i == null ? void 0 : i.queryTerrainElevation(c);
|
|
3710
3741
|
g && (p.properties.elevation_start = g);
|
|
3711
|
-
const y = i == null ? void 0 : i.queryTerrainElevation(
|
|
3742
|
+
const y = i == null ? void 0 : i.queryTerrainElevation(h);
|
|
3712
3743
|
y && (p.properties.elevation_end = y);
|
|
3713
3744
|
}
|
|
3714
3745
|
l.push(p);
|
|
3715
3746
|
}
|
|
3716
3747
|
return s.properties.distance = l[l.length - 1].properties.total, s.properties.unit = l[l.length - 1].properties.unit, s.properties.segments = JSON.parse(JSON.stringify(l)), s;
|
|
3717
|
-
},
|
|
3718
|
-
var
|
|
3719
|
-
const
|
|
3748
|
+
}, ce = (s) => s.charAt(0).toUpperCase() + s.slice(1), It = ["td-point", "td-linestring", "td-polygon"];
|
|
3749
|
+
var pe, ge, ye;
|
|
3750
|
+
const ko = [
|
|
3720
3751
|
...It,
|
|
3721
|
-
(
|
|
3722
|
-
(
|
|
3723
|
-
(
|
|
3724
|
-
],
|
|
3752
|
+
(pe = yt.polygonLayerSpec) == null ? void 0 : pe.source,
|
|
3753
|
+
(ge = yt.lineLayerLabelSpec) == null ? void 0 : ge.source,
|
|
3754
|
+
(ye = yt.pointLayerLabelSpec) == null ? void 0 : ye.source
|
|
3755
|
+
], Te = (s, t, e = It) => {
|
|
3725
3756
|
const i = JSON.parse(JSON.stringify(s));
|
|
3726
3757
|
return t && (t.onlyTerraDrawLayers === !0 ? (i.layers = i.layers.filter((o) => "source" in o && e.includes(o.source)), Object.keys(i.sources).forEach((o) => {
|
|
3727
3758
|
e.includes(o) || delete i.sources[o];
|
|
3728
3759
|
})) : t.excludeTerraDrawLayers === !0 && (i.layers = i.layers.filter((o) => "source" in o && !e.includes(o.source)), Object.keys(i.sources).forEach((o) => {
|
|
3729
3760
|
e.includes(o) && delete i.sources[o];
|
|
3730
3761
|
}))), i;
|
|
3731
|
-
},
|
|
3762
|
+
}, co = (s, t = 250) => {
|
|
3732
3763
|
let e;
|
|
3733
3764
|
return (...i) => {
|
|
3734
3765
|
clearTimeout(e), e = setTimeout(() => s(...i), t);
|
|
@@ -3742,58 +3773,58 @@ const _o = [
|
|
|
3742
3773
|
}
|
|
3743
3774
|
return s;
|
|
3744
3775
|
};
|
|
3745
|
-
var
|
|
3746
|
-
function
|
|
3776
|
+
var ho = Object.defineProperty, uo = (s, t, e) => t in s ? ho(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, tt = (s, t, e) => uo(s, typeof t != "symbol" ? t + "" : t, e), Pt = 2 * Math.PI * 6378137 / 2;
|
|
3777
|
+
function po(s) {
|
|
3747
3778
|
return s = s || 256, 2 * Math.PI * 6378137 / s;
|
|
3748
3779
|
}
|
|
3749
|
-
function
|
|
3780
|
+
function go(s, t, e = { enable: !0, decimal: 1 }) {
|
|
3750
3781
|
s = Wt(s);
|
|
3751
3782
|
var i = s[0], o = s[1], r = i * Pt / 180, n = Math.log(Math.tan((90 + o) * Math.PI / 360)) / (Math.PI / 180);
|
|
3752
3783
|
return n = n * Pt / 180, e.enable && (r = Number(r.toFixed(e.decimal)), n = Number(n.toFixed(e.decimal))), [r, n];
|
|
3753
3784
|
}
|
|
3754
|
-
function
|
|
3755
|
-
var i = s[0], o = s[1], r =
|
|
3785
|
+
function yo(s, t, e) {
|
|
3786
|
+
var i = s[0], o = s[1], r = So(t, e), n = (i + Pt) / r, a = (o + Pt) / r;
|
|
3756
3787
|
return [n, a, t];
|
|
3757
3788
|
}
|
|
3758
|
-
function
|
|
3789
|
+
function Ae(s, t, e) {
|
|
3759
3790
|
s = Wt(s);
|
|
3760
|
-
var i =
|
|
3761
|
-
return
|
|
3791
|
+
var i = go(s), o = yo(i, t);
|
|
3792
|
+
return mo(o);
|
|
3762
3793
|
}
|
|
3763
|
-
function
|
|
3794
|
+
function fo(s, t, e) {
|
|
3764
3795
|
if (s = Wt(s), t === 0)
|
|
3765
3796
|
return [0, 0, 0];
|
|
3766
|
-
var i =
|
|
3767
|
-
return
|
|
3797
|
+
var i = Ae(s, t);
|
|
3798
|
+
return vo(i);
|
|
3768
3799
|
}
|
|
3769
|
-
function
|
|
3800
|
+
function mo(s, t, e) {
|
|
3770
3801
|
t = t || 256;
|
|
3771
3802
|
var i = s[0], o = s[1], r = s[2];
|
|
3772
3803
|
if (r === 0) return [0, 0, 0];
|
|
3773
|
-
|
|
3804
|
+
Ve(r);
|
|
3774
3805
|
var n = Math.ceil(i / t) - 1, a = Math.ceil(o / t) - 1;
|
|
3775
3806
|
return n < 0 && (n = 0), a < 0 && (a = 0), [n, a, r];
|
|
3776
3807
|
}
|
|
3777
|
-
function
|
|
3778
|
-
|
|
3808
|
+
function vo(s, t) {
|
|
3809
|
+
Co(s);
|
|
3779
3810
|
var e = s[0], i = s[1], o = s[2];
|
|
3780
3811
|
if (o === 0)
|
|
3781
3812
|
return [0, 0, 0];
|
|
3782
3813
|
var r = e, n = Math.pow(2, o) - 1 - i;
|
|
3783
3814
|
return [r, n, o];
|
|
3784
3815
|
}
|
|
3785
|
-
function
|
|
3816
|
+
function Co(s, t) {
|
|
3786
3817
|
var e = s[0], i = s[1], o = s[2];
|
|
3787
3818
|
if (o == null) throw new Error("<zoom> is required");
|
|
3788
3819
|
if (e == null) throw new Error("<x> is required");
|
|
3789
3820
|
if (i == null) throw new Error("<y> is required");
|
|
3790
|
-
return o =
|
|
3821
|
+
return o = Ve(o), s = Po(s), s;
|
|
3791
3822
|
}
|
|
3792
|
-
function
|
|
3823
|
+
function Po(s) {
|
|
3793
3824
|
var t = s[0], e = s[1], i = s[2], o = Math.pow(2, i);
|
|
3794
3825
|
return t = t % o, t < 0 && (t = t + o), [t, e, i];
|
|
3795
3826
|
}
|
|
3796
|
-
function
|
|
3827
|
+
function Ve(s) {
|
|
3797
3828
|
if (s === !1) return s;
|
|
3798
3829
|
if (s == null)
|
|
3799
3830
|
throw new Error("<zoom> is required");
|
|
@@ -3804,21 +3835,21 @@ function Ae(s) {
|
|
|
3804
3835
|
return s;
|
|
3805
3836
|
}
|
|
3806
3837
|
function Wt(s, t) {
|
|
3807
|
-
var e =
|
|
3838
|
+
var e = Io(s[0]), i = xo(s[1]);
|
|
3808
3839
|
return i > 85 && (i = 85), i < -85 && (i = -85), [e, i];
|
|
3809
3840
|
}
|
|
3810
|
-
function
|
|
3811
|
-
return
|
|
3841
|
+
function So(s, t) {
|
|
3842
|
+
return po(t) / Math.pow(2, s);
|
|
3812
3843
|
}
|
|
3813
|
-
function
|
|
3844
|
+
function xo(s) {
|
|
3814
3845
|
if (s == null) throw new Error("lat is required");
|
|
3815
3846
|
return (s > 90 || s < -90) && (s = s % 180, s > 90 && (s = -180 + s), s < -90 && (s = 180 + s), s === 0 && (s = 0)), s;
|
|
3816
3847
|
}
|
|
3817
|
-
function
|
|
3848
|
+
function Io(s) {
|
|
3818
3849
|
if (s == null) throw new Error("lng is required");
|
|
3819
3850
|
return (s > 180 || s < -180) && (s = s % 360, s > 180 && (s = -360 + s), s < -180 && (s = 360 + s), s === 0 && (s = 0)), s;
|
|
3820
3851
|
}
|
|
3821
|
-
class
|
|
3852
|
+
class Ue {
|
|
3822
3853
|
/**
|
|
3823
3854
|
* Constructor
|
|
3824
3855
|
* @param url URL for terrain RGB raster tilesets
|
|
@@ -3843,17 +3874,17 @@ class Ve {
|
|
|
3843
3874
|
const r = t[0], n = t[1];
|
|
3844
3875
|
let a = e;
|
|
3845
3876
|
e > this.maxzoom ? a = this.maxzoom : e < this.minzoom && (a = this.minzoom);
|
|
3846
|
-
const l = this.tms ?
|
|
3847
|
-
let
|
|
3848
|
-
switch (
|
|
3877
|
+
const l = this.tms ? Ae([r, n], a) : fo([r, n], a), d = this.url.replace(/{x}/g, l[0].toString()).replace(/{y}/g, l[1].toString()).replace(/{z}/g, l[2].toString());
|
|
3878
|
+
let c = this.getUrlExtension(d);
|
|
3879
|
+
switch (c || (c = "png"), c) {
|
|
3849
3880
|
case "png":
|
|
3850
3881
|
case "webp":
|
|
3851
|
-
this.getValueFromRaster(d, l, r, n).then((
|
|
3852
|
-
i(
|
|
3882
|
+
this.getValueFromRaster(d, l, r, n).then((h) => {
|
|
3883
|
+
i(h);
|
|
3853
3884
|
});
|
|
3854
3885
|
break;
|
|
3855
3886
|
default:
|
|
3856
|
-
o(new Error(`Invalid file extension: ${
|
|
3887
|
+
o(new Error(`Invalid file extension: ${c}`));
|
|
3857
3888
|
break;
|
|
3858
3889
|
}
|
|
3859
3890
|
}
|
|
@@ -3878,12 +3909,12 @@ class Ve {
|
|
|
3878
3909
|
return new Promise((a, l) => {
|
|
3879
3910
|
const d = new Image();
|
|
3880
3911
|
d.onload = () => {
|
|
3881
|
-
const
|
|
3882
|
-
|
|
3883
|
-
const
|
|
3884
|
-
if (!
|
|
3885
|
-
|
|
3886
|
-
const u =
|
|
3912
|
+
const c = document.createElement("canvas");
|
|
3913
|
+
c.width = d.width, c.height = d.height;
|
|
3914
|
+
const h = c.getContext("2d");
|
|
3915
|
+
if (!h) return l(new Error("Failed to create canvas context"));
|
|
3916
|
+
h.drawImage(d, 0, 0);
|
|
3917
|
+
const u = h.getImageData(0, 0, d.width, d.height).data, p = this.pixels2rgba(new Uint8Array(u), e, i, o), g = this.calc(p[0], p[1], p[2], p[3]);
|
|
3887
3918
|
a(g);
|
|
3888
3919
|
}, d.onerror = () => a(void 0), d.src = URL.createObjectURL(n);
|
|
3889
3920
|
});
|
|
@@ -3899,7 +3930,7 @@ class Ve {
|
|
|
3899
3930
|
pixels2rgba(t, e, i, o) {
|
|
3900
3931
|
const r = [];
|
|
3901
3932
|
for (let d = 0; d < t.length; d += 4) {
|
|
3902
|
-
const
|
|
3933
|
+
const c = t[d], h = t[d + 1], u = t[d + 2], p = t[d + 3], g = [c, h, u, p];
|
|
3903
3934
|
r.push(g);
|
|
3904
3935
|
}
|
|
3905
3936
|
const n = this.tileToBBOX(e), a = this.getPixelPosition(i, o, n), l = a[0] + a[1] * this.tileSize;
|
|
@@ -3913,8 +3944,8 @@ class Ve {
|
|
|
3913
3944
|
* @returns The position in pixel
|
|
3914
3945
|
*/
|
|
3915
3946
|
getPixelPosition(t, e, i) {
|
|
3916
|
-
const o = this.tileSize, r = this.tileSize, n = i[2] - i[0], a = i[3] - i[1], l = (t - i[0]) / n, d = (e - i[1]) / a,
|
|
3917
|
-
return [
|
|
3947
|
+
const o = this.tileSize, r = this.tileSize, n = i[2] - i[0], a = i[3] - i[1], l = (t - i[0]) / n, d = (e - i[1]) / a, c = Math.floor(o * l), h = Math.floor(r * (1 - d));
|
|
3948
|
+
return [c, h];
|
|
3918
3949
|
}
|
|
3919
3950
|
/**
|
|
3920
3951
|
* Get file extenstion name from the URL
|
|
@@ -3945,7 +3976,7 @@ class Ve {
|
|
|
3945
3976
|
return i * Math.atan(0.5 * (Math.exp(o) - Math.exp(-o)));
|
|
3946
3977
|
}
|
|
3947
3978
|
}
|
|
3948
|
-
class
|
|
3979
|
+
class bo extends Ue {
|
|
3949
3980
|
/**
|
|
3950
3981
|
* Constructor
|
|
3951
3982
|
* @param url URL for terrain RGB raster tilesets
|
|
@@ -3977,7 +4008,7 @@ class xo extends Ve {
|
|
|
3977
4008
|
return -1e4 + (t * 256 * 256 + e * 256 + i) * 0.1;
|
|
3978
4009
|
}
|
|
3979
4010
|
}
|
|
3980
|
-
class
|
|
4011
|
+
class Mo extends Ue {
|
|
3981
4012
|
/**
|
|
3982
4013
|
* Constructor
|
|
3983
4014
|
* @param url URL for terrarium raster tilesets
|
|
@@ -4011,23 +4042,57 @@ class Io extends Ve {
|
|
|
4011
4042
|
return parseInt(o.toFixed(0));
|
|
4012
4043
|
}
|
|
4013
4044
|
}
|
|
4014
|
-
const
|
|
4045
|
+
const ue = async (s, t) => {
|
|
4015
4046
|
const e = [];
|
|
4016
4047
|
for (const i of s)
|
|
4017
4048
|
e.push(
|
|
4018
4049
|
new Promise((o) => {
|
|
4019
4050
|
if (i.geometry.type !== "Point" && o(i), t) {
|
|
4020
|
-
const r = t.url, n = t.encoding ?? "mapbox", a = t.tileSize ?? 512, l = t.minzoom ?? 5, d = t.maxzoom ?? 15,
|
|
4021
|
-
(n === "mapbox" ? new
|
|
4022
|
-
|
|
4051
|
+
const r = t.url, n = t.encoding ?? "mapbox", a = t.tileSize ?? 512, l = t.minzoom ?? 5, d = t.maxzoom ?? 15, c = t.tms ?? !1;
|
|
4052
|
+
(n === "mapbox" ? new bo(r, a, l, d, c) : new Mo(r, a, l, d, c)).getElevation(i.geometry.coordinates, d).then((h) => {
|
|
4053
|
+
h && (i.properties.elevation = h), o(i);
|
|
4023
4054
|
}).catch(() => o(i));
|
|
4024
4055
|
} else
|
|
4025
4056
|
o(i);
|
|
4026
4057
|
})
|
|
4027
4058
|
);
|
|
4028
4059
|
return await Promise.all(e);
|
|
4060
|
+
}, jo = (s, t = 9) => {
|
|
4061
|
+
function e(o) {
|
|
4062
|
+
return [Number(o[0].toFixed(t)), Number(o[1].toFixed(t))];
|
|
4063
|
+
}
|
|
4064
|
+
function i(o) {
|
|
4065
|
+
const r = o.type;
|
|
4066
|
+
let n = o.coordinates;
|
|
4067
|
+
switch (r) {
|
|
4068
|
+
case "Point":
|
|
4069
|
+
n = e(n);
|
|
4070
|
+
break;
|
|
4071
|
+
case "LineString":
|
|
4072
|
+
case "MultiPoint":
|
|
4073
|
+
n = n.map(e);
|
|
4074
|
+
break;
|
|
4075
|
+
case "Polygon":
|
|
4076
|
+
case "MultiLineString":
|
|
4077
|
+
n = n.map((a) => a.map(e));
|
|
4078
|
+
break;
|
|
4079
|
+
case "MultiPolygon":
|
|
4080
|
+
n = n.map(
|
|
4081
|
+
(a) => a.map((l) => l.map(e))
|
|
4082
|
+
);
|
|
4083
|
+
break;
|
|
4084
|
+
}
|
|
4085
|
+
return {
|
|
4086
|
+
...o,
|
|
4087
|
+
coordinates: n
|
|
4088
|
+
};
|
|
4089
|
+
}
|
|
4090
|
+
return s.map((o) => ({
|
|
4091
|
+
...o,
|
|
4092
|
+
geometry: i(o.geometry)
|
|
4093
|
+
}));
|
|
4029
4094
|
};
|
|
4030
|
-
class
|
|
4095
|
+
class wo {
|
|
4031
4096
|
/**
|
|
4032
4097
|
* Constructor
|
|
4033
4098
|
* @param options Plugin control options
|
|
@@ -4038,7 +4103,7 @@ class bo {
|
|
|
4038
4103
|
k(this, "modeButtons", {});
|
|
4039
4104
|
k(this, "_isExpanded", !1);
|
|
4040
4105
|
k(this, "terradraw");
|
|
4041
|
-
k(this, "options",
|
|
4106
|
+
k(this, "options", Yi);
|
|
4042
4107
|
k(this, "events", {});
|
|
4043
4108
|
k(this, "defaultMode", "render");
|
|
4044
4109
|
this.modeButtons = {}, t && (this.options = Object.assign(this.options, t));
|
|
@@ -4082,20 +4147,20 @@ class bo {
|
|
|
4082
4147
|
if (this.options && this.options.modes && this.options.modes.length === 0)
|
|
4083
4148
|
throw new Error("At least a mode must be enabled.");
|
|
4084
4149
|
this.map = t;
|
|
4085
|
-
const e =
|
|
4150
|
+
const e = $i(), i = [];
|
|
4086
4151
|
return (r = (o = this.options) == null ? void 0 : o.modes) == null || r.forEach((d) => {
|
|
4087
4152
|
if (this.options.modeOptions && this.options.modeOptions[d]) {
|
|
4088
|
-
const
|
|
4153
|
+
const c = this.options.modeOptions[d];
|
|
4089
4154
|
if (d === "select") {
|
|
4090
|
-
const
|
|
4091
|
-
if (
|
|
4092
|
-
const u =
|
|
4155
|
+
const h = e[d];
|
|
4156
|
+
if (h) {
|
|
4157
|
+
const u = h.flags;
|
|
4093
4158
|
Object.keys(u).forEach((p) => {
|
|
4094
|
-
|
|
4159
|
+
c.flags[p] || (c.flags[p] = u[p]);
|
|
4095
4160
|
});
|
|
4096
4161
|
}
|
|
4097
4162
|
}
|
|
4098
|
-
i.push(
|
|
4163
|
+
i.push(c);
|
|
4099
4164
|
} else e[d] && i.push(e[d]);
|
|
4100
4165
|
}), i.forEach((d) => {
|
|
4101
4166
|
d.state !== "unregistered" && (d._state = "unregistered");
|
|
@@ -4104,14 +4169,14 @@ class bo {
|
|
|
4104
4169
|
modeName: "default",
|
|
4105
4170
|
styles: {}
|
|
4106
4171
|
})
|
|
4107
|
-
), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new
|
|
4108
|
-
adapter: new
|
|
4172
|
+
), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new Ri({
|
|
4173
|
+
adapter: new Ki({ map: t, ...this.options.adapterOptions }),
|
|
4109
4174
|
modes: i
|
|
4110
4175
|
}), this.terradraw.start(), this.controlContainer = document.createElement("div"), this.controlContainer.classList.add("maplibregl-ctrl"), this.controlContainer.classList.add("maplibregl-ctrl-group"), i.forEach((d) => {
|
|
4111
4176
|
d.mode !== "default" && this.addTerradrawButton(d.mode);
|
|
4112
4177
|
}), Object.values(this.modeButtons).forEach((d) => {
|
|
4113
|
-
var
|
|
4114
|
-
(
|
|
4178
|
+
var c;
|
|
4179
|
+
(c = this.controlContainer) == null || c.appendChild(d);
|
|
4115
4180
|
}), (l = this.terradraw) == null || l.on("change", this.toggleButtonsWhenNoFeature.bind(this)), this.toggleButtonsWhenNoFeature(), this.controlContainer;
|
|
4116
4181
|
}
|
|
4117
4182
|
/**
|
|
@@ -4202,7 +4267,7 @@ class bo {
|
|
|
4202
4267
|
*/
|
|
4203
4268
|
addTerradrawButton(t) {
|
|
4204
4269
|
const e = document.createElement("button");
|
|
4205
|
-
e.type = "button", this.modeButtons[t] = e, t === "render" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), this.isExpanded && e.classList.add("enabled"), e.type = "button", e.title =
|
|
4270
|
+
e.type = "button", this.modeButtons[t] = e, t === "render" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), this.isExpanded && e.classList.add("enabled"), e.type = "button", e.title = ce("expand or collapse drawing tool"), e.addEventListener("click", this.toggleEditor.bind(this))) : (e.classList.add("maplibregl-terradraw-add-control"), this.isExpanded || e.classList.add("hidden"), e.title = ce(t.replace(/-/g, " ")), t === "delete" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.addEventListener("click", () => {
|
|
4206
4271
|
this.terradraw && this.terradraw.enabled && (this.terradraw.clear(), this.deactivate(), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.dispatchEvent("feature-deleted"));
|
|
4207
4272
|
})) : t === "delete-selection" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.classList.add("hidden-delete-selection"), e.addEventListener("click", () => {
|
|
4208
4273
|
var r;
|
|
@@ -4252,7 +4317,7 @@ class bo {
|
|
|
4252
4317
|
* @returns
|
|
4253
4318
|
*/
|
|
4254
4319
|
cleanStyle(t, e) {
|
|
4255
|
-
return
|
|
4320
|
+
return Te(t, e, It);
|
|
4256
4321
|
}
|
|
4257
4322
|
/**
|
|
4258
4323
|
* Download button click event handler
|
|
@@ -4286,28 +4351,28 @@ class bo {
|
|
|
4286
4351
|
var a, l;
|
|
4287
4352
|
const t = ((a = this.terradraw) == null ? void 0 : a.enabled) || !1, e = (l = this.terradraw) == null ? void 0 : l.getMode(), i = this.getFeatures(!1), o = i && i.features.length > 0, r = o && t && e === "select", n = document.getElementsByClassName("maplibregl-terradraw-delete-selection-button");
|
|
4288
4353
|
for (let d = 0; d < n.length; d++) {
|
|
4289
|
-
const
|
|
4290
|
-
|
|
4354
|
+
const c = n.item(d);
|
|
4355
|
+
c && (r ? c.classList.remove("hidden-delete-selection") : c.classList.add("hidden-delete-selection"));
|
|
4291
4356
|
}
|
|
4292
4357
|
if (!o) {
|
|
4293
4358
|
const d = document.getElementsByClassName("maplibregl-terradraw-add-select-button");
|
|
4294
|
-
for (let
|
|
4295
|
-
const
|
|
4296
|
-
|
|
4359
|
+
for (let c = 0; c < d.length; c++) {
|
|
4360
|
+
const h = d.item(c);
|
|
4361
|
+
h && h.classList.remove("active");
|
|
4297
4362
|
}
|
|
4298
4363
|
}
|
|
4299
4364
|
}
|
|
4300
4365
|
}
|
|
4301
|
-
function
|
|
4366
|
+
function Fo(s, t = {}) {
|
|
4302
4367
|
let e = 0, i = 0, o = 0;
|
|
4303
|
-
return
|
|
4368
|
+
return Ge(
|
|
4304
4369
|
s,
|
|
4305
4370
|
function(r) {
|
|
4306
4371
|
e += r[0], i += r[1], o++;
|
|
4307
4372
|
}
|
|
4308
|
-
),
|
|
4373
|
+
), Ji([e / o, i / o], t.properties);
|
|
4309
4374
|
}
|
|
4310
|
-
class
|
|
4375
|
+
class Wo extends wo {
|
|
4311
4376
|
/**
|
|
4312
4377
|
* Constructor
|
|
4313
4378
|
* @param options Plugin control options
|
|
@@ -4346,7 +4411,7 @@ class ko extends bo {
|
|
|
4346
4411
|
* Handle finish event of terradraw. It will be called after finishing adding a feature
|
|
4347
4412
|
* @param id Feature ID
|
|
4348
4413
|
*/
|
|
4349
|
-
k(this, "handleTerradrawFeatureReady",
|
|
4414
|
+
k(this, "handleTerradrawFeatureReady", co((e) => {
|
|
4350
4415
|
this.map && (this.computeElevationByLineFeatureID(e), this.computeElevationByPointFeatureID(e));
|
|
4351
4416
|
}, 300));
|
|
4352
4417
|
/**
|
|
@@ -4364,7 +4429,7 @@ class ko extends bo {
|
|
|
4364
4429
|
}
|
|
4365
4430
|
);
|
|
4366
4431
|
if (o && o.length > 0) {
|
|
4367
|
-
const r = await
|
|
4432
|
+
const r = await ue(
|
|
4368
4433
|
o,
|
|
4369
4434
|
this.measureOptions.terrainSource
|
|
4370
4435
|
);
|
|
@@ -4392,7 +4457,7 @@ class ko extends bo {
|
|
|
4392
4457
|
}
|
|
4393
4458
|
);
|
|
4394
4459
|
if (o && o.length > 0) {
|
|
4395
|
-
const r = await
|
|
4460
|
+
const r = await ue(
|
|
4396
4461
|
o,
|
|
4397
4462
|
this.measureOptions.terrainSource
|
|
4398
4463
|
);
|
|
@@ -4521,13 +4586,13 @@ class ko extends bo {
|
|
|
4521
4586
|
* @returns
|
|
4522
4587
|
*/
|
|
4523
4588
|
cleanStyle(e, i) {
|
|
4524
|
-
var l, d,
|
|
4589
|
+
var l, d, c;
|
|
4525
4590
|
const o = It, r = (l = this.measureOptions.polygonLayerSpec) == null ? void 0 : l.source;
|
|
4526
4591
|
r && o.push(r);
|
|
4527
4592
|
const n = (d = this.measureOptions.lineLayerLabelSpec) == null ? void 0 : d.source;
|
|
4528
4593
|
n && o.push(n);
|
|
4529
|
-
const a = (
|
|
4530
|
-
return a && o.push(a),
|
|
4594
|
+
const a = (c = this.measureOptions.pointLayerLabelSpec) == null ? void 0 : c.source;
|
|
4595
|
+
return a && o.push(a), Te(e, i, o);
|
|
4531
4596
|
}
|
|
4532
4597
|
/**
|
|
4533
4598
|
* Register measure control related maplibre sources and layers
|
|
@@ -4582,29 +4647,27 @@ class ko extends bo {
|
|
|
4582
4647
|
* @param ids Feature IDs
|
|
4583
4648
|
*/
|
|
4584
4649
|
handleTerradrawFeatureChanged(e, i) {
|
|
4585
|
-
if (!this.map || i === "
|
|
4586
|
-
const
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4650
|
+
if (!this.map || i === "styling") return;
|
|
4651
|
+
const r = [
|
|
4652
|
+
this.measureOptions.pointLayerLabelSpec,
|
|
4653
|
+
this.measureOptions.lineLayerLabelSpec,
|
|
4654
|
+
this.measureOptions.lineLayerNodeSpec,
|
|
4655
|
+
this.measureOptions.polygonLayerSpec
|
|
4656
|
+
].map((l) => l.source);
|
|
4657
|
+
if (i === "delete") {
|
|
4658
|
+
this.clearMeasureFeatures(r, e);
|
|
4659
|
+
return;
|
|
4660
|
+
}
|
|
4661
|
+
const n = this.getTerraDrawInstance();
|
|
4662
|
+
if (!n) return;
|
|
4663
|
+
const a = n.getSnapshot();
|
|
4664
|
+
for (const l of e) {
|
|
4665
|
+
const d = a.find((c) => c.id === l);
|
|
4666
|
+
if (d) {
|
|
4667
|
+
const c = d.geometry.type, h = d.properties.mode;
|
|
4668
|
+
h === "linestring" && c === "LineString" ? this.measureLine(l) : h === "point" && c === "Point" ? this.measurePoint(l) : !["point", "linestring", "select", "render"].includes(h) && c === "Polygon" && this.measurePolygon(l);
|
|
4594
4669
|
} else
|
|
4595
|
-
this.clearMeasureFeatures(
|
|
4596
|
-
n,
|
|
4597
|
-
this.measureOptions.lineLayerNodeSpec.source
|
|
4598
|
-
), this.clearMeasureFeatures(
|
|
4599
|
-
n,
|
|
4600
|
-
this.measureOptions.lineLayerLabelSpec.source
|
|
4601
|
-
), this.clearMeasureFeatures(
|
|
4602
|
-
n,
|
|
4603
|
-
this.measureOptions.polygonLayerSpec.source
|
|
4604
|
-
), this.clearMeasureFeatures(
|
|
4605
|
-
n,
|
|
4606
|
-
this.measureOptions.pointLayerLabelSpec.source
|
|
4607
|
-
);
|
|
4670
|
+
this.clearMeasureFeatures(r, [l]);
|
|
4608
4671
|
}
|
|
4609
4672
|
}
|
|
4610
4673
|
/**
|
|
@@ -4627,20 +4690,20 @@ class ko extends bo {
|
|
|
4627
4690
|
}
|
|
4628
4691
|
/**
|
|
4629
4692
|
* Clear GeoJSON feature related to measure control by TerraDraw feature ID
|
|
4630
|
-
* @param
|
|
4631
|
-
* @param
|
|
4693
|
+
* @param sourceIds the array of source ID to delete
|
|
4694
|
+
* @param ids the array of feature ID. Optional, if undefined, delete all labels for source
|
|
4632
4695
|
* @returns void
|
|
4633
4696
|
*/
|
|
4634
|
-
clearMeasureFeatures(e, i) {
|
|
4635
|
-
var
|
|
4636
|
-
if (
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4697
|
+
clearMeasureFeatures(e, i = void 0) {
|
|
4698
|
+
var o;
|
|
4699
|
+
if (this.map)
|
|
4700
|
+
for (const r of e) {
|
|
4701
|
+
const n = this.map.getStyle().sources[r];
|
|
4702
|
+
n && typeof n.data != "string" && n.data.type === "FeatureCollection" && (i === void 0 ? n.data.features = [] : n.data.features = n.data.features.filter((a) => {
|
|
4703
|
+
var l;
|
|
4704
|
+
return (l = a.properties) != null && l.originalId ? !i.includes(a.properties.originalId) : !i.includes(a.id);
|
|
4705
|
+
}), (o = this.map.getSource(r)) == null || o.setData(n.data));
|
|
4642
4706
|
}
|
|
4643
|
-
), (r = this.map.getSource(i)) == null || r.setData(o.data));
|
|
4644
4707
|
}
|
|
4645
4708
|
/**
|
|
4646
4709
|
* Replace GeoJSON source with updated features for a given source ID
|
|
@@ -4649,32 +4712,35 @@ class ko extends bo {
|
|
|
4649
4712
|
* @param type either 'linestring' or 'point'
|
|
4650
4713
|
*/
|
|
4651
4714
|
replaceGeoJSONSource(e, i, o) {
|
|
4652
|
-
var n;
|
|
4715
|
+
var n, a;
|
|
4653
4716
|
if (!this.map) return;
|
|
4654
4717
|
const r = this.map.getStyle().sources[i];
|
|
4655
4718
|
if (r && typeof r.data != "string" && r.data.type === "FeatureCollection") {
|
|
4656
|
-
const
|
|
4719
|
+
const l = [];
|
|
4720
|
+
for (const c of e)
|
|
4721
|
+
(n = this.terradraw) != null && n.getSnapshotFeature(c.id) && l.push(c);
|
|
4722
|
+
const d = l.map((c) => c.id);
|
|
4657
4723
|
if (typeof r.data != "string" && r.data.type === "FeatureCollection") {
|
|
4658
4724
|
o === "linestring" ? r.data.features = [
|
|
4659
4725
|
...r.data.features = r.data.features.filter(
|
|
4660
|
-
(
|
|
4661
|
-
var
|
|
4662
|
-
return !(
|
|
4726
|
+
(h) => {
|
|
4727
|
+
var u;
|
|
4728
|
+
return !(d.includes((u = h.properties) == null ? void 0 : u.originalId) && h.geometry.type === "Point");
|
|
4663
4729
|
}
|
|
4664
4730
|
),
|
|
4665
|
-
...
|
|
4731
|
+
...l
|
|
4666
4732
|
] : o === "point" && (r.data.features = [
|
|
4667
4733
|
...r.data.features = r.data.features.filter(
|
|
4668
|
-
(
|
|
4734
|
+
(h) => !(d.includes(h.id) && h.geometry.type === "Point")
|
|
4669
4735
|
),
|
|
4670
|
-
...
|
|
4736
|
+
...l
|
|
4671
4737
|
]);
|
|
4672
|
-
const
|
|
4673
|
-
r.data.features.forEach((
|
|
4674
|
-
var
|
|
4675
|
-
const
|
|
4676
|
-
|
|
4677
|
-
}), r.data.features = Array.from(Object.values(
|
|
4738
|
+
const c = {};
|
|
4739
|
+
r.data.features.forEach((h) => {
|
|
4740
|
+
var p;
|
|
4741
|
+
const u = h.id;
|
|
4742
|
+
c[u] ? !c[u].properties.elevation && ((p = h.properties) != null && p.elevation) && (c[u] = h) : c[u] = h;
|
|
4743
|
+
}), r.data.features = Array.from(Object.values(c)), (a = this.map.getSource(i)) == null || a.setData(r.data);
|
|
4678
4744
|
}
|
|
4679
4745
|
}
|
|
4680
4746
|
}
|
|
@@ -4694,12 +4760,12 @@ class ko extends bo {
|
|
|
4694
4760
|
if (a) {
|
|
4695
4761
|
typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
|
|
4696
4762
|
(d) => {
|
|
4697
|
-
var
|
|
4698
|
-
return ((
|
|
4763
|
+
var c;
|
|
4764
|
+
return ((c = d.properties) == null ? void 0 : c.originalId) !== e;
|
|
4699
4765
|
}
|
|
4700
4766
|
));
|
|
4701
4767
|
const l = JSON.parse(JSON.stringify(r));
|
|
4702
|
-
l.id = l.id + "-area-label", l.geometry =
|
|
4768
|
+
l.id = l.id + "-area-label", l.geometry = Fo(r.geometry).geometry, l.properties.originalId = r.id, r = ae(r, this.areaUnit, this.areaPrecision), l.properties.area = r.properties.area, l.properties.unit = r.properties.unit, typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(l), (n = this.map.getSource(
|
|
4703
4769
|
this.measureOptions.polygonLayerSpec.source
|
|
4704
4770
|
)) == null || n.setData(a.data), this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && this.map.moveLayer(
|
|
4705
4771
|
this.measureOptions.lineLayerLabelSpec.id
|
|
@@ -4729,10 +4795,10 @@ class ko extends bo {
|
|
|
4729
4795
|
if (a) {
|
|
4730
4796
|
typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
|
|
4731
4797
|
(d) => {
|
|
4732
|
-
var
|
|
4733
|
-
return ((
|
|
4798
|
+
var c;
|
|
4799
|
+
return ((c = d.properties) == null ? void 0 : c.originalId) !== e;
|
|
4734
4800
|
}
|
|
4735
|
-
)), r =
|
|
4801
|
+
)), r = de(
|
|
4736
4802
|
r,
|
|
4737
4803
|
this.distanceUnit,
|
|
4738
4804
|
this.distancePrecision,
|
|
@@ -4742,21 +4808,21 @@ class ko extends bo {
|
|
|
4742
4808
|
);
|
|
4743
4809
|
const l = r.properties.segments;
|
|
4744
4810
|
for (let d = 0; d < l.length; d++) {
|
|
4745
|
-
const
|
|
4746
|
-
typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(
|
|
4747
|
-
const
|
|
4811
|
+
const c = l[d];
|
|
4812
|
+
typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(c);
|
|
4813
|
+
const h = c.geometry.coordinates, u = h[0], p = h[1];
|
|
4748
4814
|
if (d === 0) {
|
|
4749
|
-
const y = JSON.parse(JSON.stringify(
|
|
4750
|
-
y.id = `${
|
|
4815
|
+
const y = JSON.parse(JSON.stringify(c));
|
|
4816
|
+
y.id = `${c.id}-node-${d}`, y.geometry = {
|
|
4751
4817
|
type: "Point",
|
|
4752
4818
|
coordinates: u
|
|
4753
|
-
}, y.properties.distance = 0, y.properties.total = 0,
|
|
4819
|
+
}, y.properties.distance = 0, y.properties.total = 0, c.properties.elevation_start && (y.properties.elevation = c.properties.elevation_start), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(y);
|
|
4754
4820
|
}
|
|
4755
|
-
const g = JSON.parse(JSON.stringify(
|
|
4756
|
-
g.id = `${
|
|
4821
|
+
const g = JSON.parse(JSON.stringify(c));
|
|
4822
|
+
g.id = `${c.id}-node-${d + 1}`, g.geometry = {
|
|
4757
4823
|
type: "Point",
|
|
4758
4824
|
coordinates: p
|
|
4759
|
-
},
|
|
4825
|
+
}, c.properties.elevation_end && (g.properties.elevation = c.properties.elevation_end), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(g);
|
|
4760
4826
|
}
|
|
4761
4827
|
(n = this.map.getSource(
|
|
4762
4828
|
this.measureOptions.lineLayerLabelSpec.source
|
|
@@ -4801,29 +4867,17 @@ class ko extends bo {
|
|
|
4801
4867
|
* Event definition when feature is deleted by terradraw
|
|
4802
4868
|
*/
|
|
4803
4869
|
onFeatureDeleted(e) {
|
|
4804
|
-
var o, r;
|
|
4805
4870
|
if (!this.map) return;
|
|
4806
4871
|
if (this.getTerraDrawInstance()) {
|
|
4807
|
-
let
|
|
4808
|
-
typeof e == "object" && e !== null && "deletedIds" in e && (
|
|
4809
|
-
const
|
|
4872
|
+
let o = [];
|
|
4873
|
+
typeof e == "object" && e !== null && "deletedIds" in e && (o = e.deletedIds);
|
|
4874
|
+
const n = [
|
|
4810
4875
|
this.measureOptions.pointLayerLabelSpec,
|
|
4811
4876
|
this.measureOptions.lineLayerLabelSpec,
|
|
4877
|
+
this.measureOptions.lineLayerNodeSpec,
|
|
4812
4878
|
this.measureOptions.polygonLayerSpec
|
|
4813
|
-
];
|
|
4814
|
-
|
|
4815
|
-
for (const l of a) {
|
|
4816
|
-
const d = this.map.getStyle().sources[l.source];
|
|
4817
|
-
d && (typeof d.data != "string" && d.data.type === "FeatureCollection" && (d.data.features = d.data.features.filter((h) => {
|
|
4818
|
-
var c;
|
|
4819
|
-
return (c = h.properties) != null && c.originalId ? !n.includes(h.properties.originalId) : !n.includes(h.id);
|
|
4820
|
-
})), (o = this.map.getSource(l.source)) == null || o.setData(d.data));
|
|
4821
|
-
}
|
|
4822
|
-
else
|
|
4823
|
-
for (const l of a) {
|
|
4824
|
-
const d = this.map.getStyle().sources[l.source];
|
|
4825
|
-
d && (typeof d.data != "string" && d.data.type === "FeatureCollection" && (d.data.features = []), (r = this.map.getSource(l.source)) == null || r.setData(d.data));
|
|
4826
|
-
}
|
|
4879
|
+
].map((a) => a.source);
|
|
4880
|
+
o && o.length > 0 ? this.clearMeasureFeatures(n, o) : this.clearMeasureFeatures(n, void 0);
|
|
4827
4881
|
}
|
|
4828
4882
|
}
|
|
4829
4883
|
/**
|
|
@@ -4838,14 +4892,14 @@ class ko extends bo {
|
|
|
4838
4892
|
const r = i.features[o];
|
|
4839
4893
|
if (!this.map || !this.map.loaded()) continue;
|
|
4840
4894
|
const n = r.geometry.type;
|
|
4841
|
-
n === "LineString" ? i.features[o] =
|
|
4895
|
+
n === "LineString" ? i.features[o] = de(
|
|
4842
4896
|
r,
|
|
4843
4897
|
this.distanceUnit,
|
|
4844
4898
|
this.distancePrecision,
|
|
4845
4899
|
this.map,
|
|
4846
4900
|
this.computeElevation,
|
|
4847
4901
|
this.measureOptions.terrainSource
|
|
4848
|
-
) : n === "Polygon" ? i.features[o] =
|
|
4902
|
+
) : n === "Polygon" ? i.features[o] = ae(r, this.areaUnit, this.areaPrecision) : n === "Point" && (i.features[o] = he(
|
|
4849
4903
|
r,
|
|
4850
4904
|
this.map,
|
|
4851
4905
|
this.computeElevation,
|
|
@@ -4856,22 +4910,23 @@ class ko extends bo {
|
|
|
4856
4910
|
}
|
|
4857
4911
|
}
|
|
4858
4912
|
export {
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4913
|
+
_o as AvailableModes,
|
|
4914
|
+
Wo as MaplibreMeasureControl,
|
|
4915
|
+
wo as MaplibreTerradrawControl,
|
|
4916
|
+
ko as TERRADRAW_MEASURE_SOURCE_IDS,
|
|
4863
4917
|
It as TERRADRAW_SOURCE_IDS,
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4918
|
+
ae as calcArea,
|
|
4919
|
+
de as calcDistance,
|
|
4920
|
+
ce as capitalize,
|
|
4921
|
+
Te as cleanMaplibreStyle,
|
|
4922
|
+
ro as convertAreaUnit,
|
|
4923
|
+
co as debounce,
|
|
4924
|
+
Yi as defaultControlOptions,
|
|
4871
4925
|
yt as defaultMeasureControlOptions,
|
|
4872
|
-
|
|
4873
|
-
|
|
4926
|
+
$i as getDefaultModeOptions,
|
|
4927
|
+
lo as getDistanceUnitName,
|
|
4874
4928
|
he as queryElevationByPoint,
|
|
4875
|
-
|
|
4929
|
+
ue as queryElevationFromRasterDEM,
|
|
4930
|
+
jo as roundFeatureCoordinates
|
|
4876
4931
|
};
|
|
4877
4932
|
//# sourceMappingURL=maplibre-gl-terradraw.es.js.map
|