@watergis/maplibre-gl-terradraw 1.3.4 → 1.3.5
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var k = (s, t, e) =>
|
|
1
|
+
var Te = Object.defineProperty;
|
|
2
|
+
var Ae = (s, t, e) => t in s ? Te(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
3
|
+
var k = (s, t, e) => Ae(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) {
|
|
@@ -15,16 +15,16 @@ var I;
|
|
|
15
15
|
(function(s) {
|
|
16
16
|
s.Commit = "commit", s.Provisional = "provisional", s.Finish = "finish";
|
|
17
17
|
})(I || (I = {}));
|
|
18
|
-
const U = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT: "selectionPoint" }, V = "edited", st = "closingPoint",
|
|
18
|
+
const U = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT: "selectionPoint" }, V = "edited", st = "closingPoint", Ot = "snappingPoint";
|
|
19
19
|
function bt(s) {
|
|
20
20
|
return !!(s && typeof s == "object" && s !== null && !Array.isArray(s));
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function Vt(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 Ve = "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: Ve } : 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 Ue extends N {
|
|
130
130
|
constructor(...t) {
|
|
131
131
|
super(...t), this.type = $.Select;
|
|
132
132
|
}
|
|
@@ -135,30 +135,30 @@ 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
|
|
139
|
-
function
|
|
138
|
+
const ue = 63710088e-1;
|
|
139
|
+
function O(s) {
|
|
140
140
|
return s % 360 * Math.PI / 180;
|
|
141
141
|
}
|
|
142
|
-
function
|
|
142
|
+
function pe(s) {
|
|
143
143
|
return s / 6371.0088;
|
|
144
144
|
}
|
|
145
|
-
function
|
|
145
|
+
function R(s) {
|
|
146
146
|
return s % (2 * Math.PI) * 180 / Math.PI;
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function w(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 =
|
|
155
|
-
return [
|
|
152
|
+
const Ut = 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 : Ut * (s / ft), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / ft)) - Math.PI / 2) * Ut });
|
|
153
|
+
function Re(s, t, e) {
|
|
154
|
+
const i = O(s[0]), o = O(s[1]), r = O(e), n = pe(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(r));
|
|
155
|
+
return [R(i + Math.atan2(Math.sin(r) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), R(a)];
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function zt(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 =
|
|
161
|
-
r.push([
|
|
160
|
+
const a = Re(t, e, -360 * n / o);
|
|
161
|
+
r.push([w(a[0], i), w(a[1], i)]);
|
|
162
162
|
}
|
|
163
163
|
return r.push(r[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [r] }, properties: {} };
|
|
164
164
|
}
|
|
@@ -176,51 +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 (
|
|
181
|
-
const P = v[0], S = v[1], M = f[0],
|
|
182
|
-
return
|
|
183
|
-
}(d,
|
|
179
|
+
const d = t[r][n], h = t[r][n + 1], c = t[a][l], u = t[a][l + 1], p = function(v, f, m, C) {
|
|
180
|
+
if (ht(v, m) || ht(v, C) || ht(f, m) || ht(C, m)) return null;
|
|
181
|
+
const P = v[0], S = v[1], M = f[0], F = f[1], D = m[0], G = m[1], _ = C[0], B = C[1], z = (P - M) * (G - B) - (S - F) * (D - _);
|
|
182
|
+
return z === 0 ? null : [((P * F - S * M) * (D - _) - (P - M) * (D * B - G * _)) / z, ((P * F - S * M) * (G - B) - (S - F) * (D * B - G * _)) / z];
|
|
183
|
+
}(d, h, c, u);
|
|
184
184
|
if (p === null) return;
|
|
185
|
-
let
|
|
186
|
-
|
|
185
|
+
let y, g;
|
|
186
|
+
y = h[0] !== d[0] ? (p[0] - d[0]) / (h[0] - d[0]) : (p[1] - d[1]) / (h[1] - d[1]), g = u[0] !== c[0] ? (p[0] - c[0]) / (u[0] - c[0]) : (p[1] - c[1]) / (u[1] - c[1]), i(y) || i(g) || (p.toString(), e.push(p));
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
function
|
|
189
|
+
function ht(s, t) {
|
|
190
190
|
return s[0] === t[0] && s[1] === t[1];
|
|
191
191
|
}
|
|
192
192
|
function St(s, t) {
|
|
193
|
-
return
|
|
193
|
+
return Xt(s[0]) <= t && Xt(s[1]) <= t;
|
|
194
194
|
}
|
|
195
|
-
function
|
|
195
|
+
function Lt(s) {
|
|
196
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
197
|
var t, e;
|
|
198
198
|
}
|
|
199
|
-
function
|
|
199
|
+
function Xt(s) {
|
|
200
200
|
let t = 1, e = 0;
|
|
201
201
|
for (; Math.round(s * t) / t !== s; ) t *= 10, e++;
|
|
202
202
|
return e;
|
|
203
203
|
}
|
|
204
|
-
const
|
|
204
|
+
const ze = "Feature has holes", Xe = "Feature has less than 4 coordinates", Ke = "Feature has invalid coordinates", Ye = "Feature coordinates are not closed";
|
|
205
205
|
function xt(s, t) {
|
|
206
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:
|
|
208
|
-
if (s.geometry.coordinates[0].length < 4) return { valid: !1, reason:
|
|
207
|
+
if (s.geometry.coordinates.length !== 1) return { valid: !1, reason: ze };
|
|
208
|
+
if (s.geometry.coordinates[0].length < 4) return { valid: !1, reason: Xe };
|
|
209
209
|
for (let o = 0; o < s.geometry.coordinates[0].length; o++) {
|
|
210
|
-
if (!
|
|
210
|
+
if (!Lt(s.geometry.coordinates[0][o])) return { valid: !1, reason: Ke };
|
|
211
211
|
if (!St(s.geometry.coordinates[0][o], t)) return { valid: !1, reason: "Feature has coordinates with excessive precision" };
|
|
212
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:
|
|
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: Ye } : { valid: !0 };
|
|
214
214
|
var e, i;
|
|
215
215
|
}
|
|
216
216
|
function lt(s, t) {
|
|
217
217
|
const e = xt(s, t);
|
|
218
218
|
return e.valid ? _t(s) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
|
|
219
219
|
}
|
|
220
|
-
const
|
|
221
|
-
let
|
|
220
|
+
const $e = { cancel: "Escape", finish: "Enter" }, He = { start: "crosshair" };
|
|
221
|
+
let ge = class extends N {
|
|
222
222
|
constructor(t) {
|
|
223
|
-
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 = $e, this.cursors = He, this.startingRadiusKilometers = 1e-5, this.cursorMovedAfterInitialCursorDown = !1, this.updateOptions(t);
|
|
224
224
|
}
|
|
225
225
|
updateOptions(t) {
|
|
226
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);
|
|
@@ -243,7 +243,7 @@ let ve = class extends N {
|
|
|
243
243
|
onClick(t) {
|
|
244
244
|
if (this.clickCount === 0) {
|
|
245
245
|
this.center = [t.lng, t.lat];
|
|
246
|
-
const e =
|
|
246
|
+
const e = zt({ center: this.center, radiusKilometers: this.startingRadiusKilometers, coordinatePrecision: this.coordinatePrecision }), [i] = this.store.create([{ geometry: e.geometry, properties: { mode: this.mode, radiusKilometers: this.startingRadiusKilometers } }]);
|
|
247
247
|
this.currentCircleId = i, this.clickCount++, this.cursorMovedAfterInitialCursorDown = !1, this.setDrawing();
|
|
248
248
|
} else this.clickCount === 1 && this.center && this.currentCircleId !== void 0 && this.cursorMovedAfterInitialCursorDown && this.updateCircle(t), this.close();
|
|
249
249
|
}
|
|
@@ -284,27 +284,27 @@ let ve = class extends N {
|
|
|
284
284
|
const o = function(r, n) {
|
|
285
285
|
const a = 1e3 * A(r, n);
|
|
286
286
|
if (a === 0) return 1;
|
|
287
|
-
const { x: l, y: d } = x(r[0], r[1]), { x:
|
|
288
|
-
return Math.sqrt(Math.pow(
|
|
287
|
+
const { x: l, y: d } = x(r[0], r[1]), { x: h, y: c } = x(n[0], n[1]);
|
|
288
|
+
return Math.sqrt(Math.pow(h - l, 2) + Math.pow(c - d, 2)) / a;
|
|
289
289
|
}(this.center, [t.lng, t.lat]);
|
|
290
290
|
i = function(r) {
|
|
291
|
-
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, h = 1e3 * a, [c, u] = n, { x: p, y } = x(c, u), g = [];
|
|
292
292
|
for (let v = 0; v < d; v++) {
|
|
293
|
-
const f = 360 * v / d * Math.PI / 180, m =
|
|
294
|
-
|
|
293
|
+
const f = 360 * v / d * Math.PI / 180, m = h * Math.cos(f), C = h * Math.sin(f), [P, S] = [p + m, y + C], { lng: M, lat: F } = j(P, S);
|
|
294
|
+
g.push([w(M, l), w(F, l)]);
|
|
295
295
|
}
|
|
296
|
-
return
|
|
296
|
+
return g.push(g[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [g] }, properties: {} };
|
|
297
297
|
}({ center: this.center, radiusKilometers: e * o, coordinatePrecision: this.coordinatePrecision });
|
|
298
298
|
} else {
|
|
299
299
|
if (this.projection !== "globe") throw new Error("Invalid projection");
|
|
300
|
-
i =
|
|
300
|
+
i = zt({ center: this.center, radiusKilometers: e, coordinatePrecision: this.coordinatePrecision });
|
|
301
301
|
}
|
|
302
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;
|
|
303
303
|
this.store.updateGeometry([{ id: this.currentCircleId, geometry: i.geometry }]), this.store.updateProperty([{ id: this.currentCircleId, property: "radiusKilometers", value: e }]);
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
306
|
};
|
|
307
|
-
const
|
|
307
|
+
const E = (s, t) => {
|
|
308
308
|
const { x: e, y: i } = s, { x: o, y: r } = t, n = o - e, a = r - i;
|
|
309
309
|
return Math.sqrt(a * a + n * n);
|
|
310
310
|
};
|
|
@@ -319,10 +319,10 @@ function dt(s) {
|
|
|
319
319
|
return o < 0;
|
|
320
320
|
}(s)) return { type: "Polygon", coordinates: [s.coordinates[0].reverse()] };
|
|
321
321
|
}
|
|
322
|
-
const
|
|
323
|
-
class
|
|
322
|
+
const qe = { cancel: "Escape", finish: "Enter" }, Je = { start: "crosshair", close: "pointer" };
|
|
323
|
+
class ye extends N {
|
|
324
324
|
constructor(t) {
|
|
325
|
-
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 = qe, this.cursors = Je, this.preventPointsNearClose = !0, this.autoClose = !1, this.autoCloseTimeout = 500, this.hasLeftStartingPoint = !1, this.preventNewFeature = !1, this.updateOptions(t);
|
|
326
326
|
}
|
|
327
327
|
updateOptions(t) {
|
|
328
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));
|
|
@@ -348,8 +348,8 @@ class Ce extends N {
|
|
|
348
348
|
}
|
|
349
349
|
onMouseMove(t) {
|
|
350
350
|
if (this.currentId === void 0 || this.startingClick === !1) return;
|
|
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 =
|
|
352
|
-
if (
|
|
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 = E({ x: n, y: a }, { x: t.containerX, y: t.containerY }), [d, h] = e.coordinates[0][0], { x: c, y: u } = this.project(d, h);
|
|
352
|
+
if (E({ x: c, y: u }, { x: t.containerX, y: t.containerY }) < this.pointerDistance) {
|
|
353
353
|
if (this.autoClose && this.hasLeftStartingPoint && (this.preventNewFeature = !0, setTimeout(() => {
|
|
354
354
|
this.preventNewFeature = !1;
|
|
355
355
|
}, this.autoCloseTimeout), this.close()), this.setCursor(this.cursors.close), this.preventPointsNearClose) return;
|
|
@@ -400,7 +400,7 @@ class W {
|
|
|
400
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;
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
|
-
function
|
|
403
|
+
function fe({ unproject: s, point: t, pointerDistance: e }) {
|
|
404
404
|
const i = e / 2, { x: o, y: r } = t;
|
|
405
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])] } };
|
|
406
406
|
}
|
|
@@ -410,7 +410,7 @@ class rt extends W {
|
|
|
410
410
|
}
|
|
411
411
|
create(t) {
|
|
412
412
|
const { containerX: e, containerY: i } = t;
|
|
413
|
-
return
|
|
413
|
+
return fe({ unproject: this.unproject, point: { x: e, y: i }, pointerDistance: this.pointerDistance });
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
416
|
class nt extends W {
|
|
@@ -419,10 +419,10 @@ class nt extends W {
|
|
|
419
419
|
}
|
|
420
420
|
measure(t, e) {
|
|
421
421
|
const { x: i, y: o } = this.project(e[0], e[1]);
|
|
422
|
-
return
|
|
422
|
+
return E({ x: i, y: o }, { x: t.containerX, y: t.containerY });
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
|
-
let
|
|
425
|
+
let Dt = class extends W {
|
|
426
426
|
constructor(t, e, i) {
|
|
427
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;
|
|
428
428
|
}
|
|
@@ -436,23 +436,23 @@ let Lt = class extends W {
|
|
|
436
436
|
a = n.geometry.coordinates;
|
|
437
437
|
}
|
|
438
438
|
a.forEach((l, d) => {
|
|
439
|
-
const
|
|
440
|
-
|
|
439
|
+
const h = this.pixelDistance.measure(t, l);
|
|
440
|
+
h < r.minDist && h < this.pointerDistance && (r.coordinate = l, r.minDist = h, r.featureId = n.id, r.featureCoordinateIndex = d);
|
|
441
441
|
});
|
|
442
442
|
}), r;
|
|
443
443
|
}
|
|
444
444
|
};
|
|
445
|
-
function
|
|
446
|
-
const i =
|
|
447
|
-
return [
|
|
445
|
+
function Kt(s, t, e) {
|
|
446
|
+
const i = O(s[0]), o = O(s[1]), r = O(e), n = pe(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(r));
|
|
447
|
+
return [R(i + Math.atan2(Math.sin(r) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), R(a)];
|
|
448
448
|
}
|
|
449
449
|
function at({ x: s, y: t }, e, i) {
|
|
450
|
-
const o =
|
|
450
|
+
const o = O(i);
|
|
451
451
|
return { x: s + e * Math.cos(o), y: t + e * Math.sin(o) };
|
|
452
452
|
}
|
|
453
|
-
function
|
|
454
|
-
const e =
|
|
455
|
-
return
|
|
453
|
+
function Yt(s, t) {
|
|
454
|
+
const e = O(s[0]), i = O(t[0]), o = O(s[1]), r = O(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);
|
|
455
|
+
return R(Math.atan2(n, a));
|
|
456
456
|
}
|
|
457
457
|
function T({ x: s, y: t }, { x: e, y: i }) {
|
|
458
458
|
let o = Math.atan2(i - t, e - s);
|
|
@@ -461,29 +461,29 @@ function T({ x: s, y: t }, { x: e, y: i }) {
|
|
|
461
461
|
function Y(s) {
|
|
462
462
|
return (s + 360) % 360;
|
|
463
463
|
}
|
|
464
|
-
function
|
|
464
|
+
function Ze(s, t, e) {
|
|
465
465
|
const i = [], o = s.length;
|
|
466
466
|
let r, n, a, l = 0;
|
|
467
|
-
for (let
|
|
467
|
+
for (let h = 0; h < s.length && !(t >= l && h === s.length - 1); h++) {
|
|
468
468
|
if (l > t && i.length === 0) {
|
|
469
|
-
if (r = t - l, !r) return i.push(s[
|
|
470
|
-
n =
|
|
469
|
+
if (r = t - l, !r) return i.push(s[h]), i;
|
|
470
|
+
n = Yt(s[h], s[h - 1]) - 180, a = Kt(s[h], r, n), i.push(a);
|
|
471
471
|
}
|
|
472
|
-
if (l >= e) return r = e - l, r ? (n =
|
|
473
|
-
if (l >= t && i.push(s[
|
|
474
|
-
l += A(s[
|
|
472
|
+
if (l >= e) return r = e - l, r ? (n = Yt(s[h], s[h - 1]) - 180, a = Kt(s[h], r, n), i.push(a), i) : (i.push(s[h]), i);
|
|
473
|
+
if (l >= t && i.push(s[h]), h === s.length - 1) return i;
|
|
474
|
+
l += A(s[h], s[h + 1]);
|
|
475
475
|
}
|
|
476
476
|
if (l < t && s.length === o) throw new Error("Start position is beyond line");
|
|
477
477
|
const d = s[s.length - 1];
|
|
478
478
|
return [d, d];
|
|
479
479
|
}
|
|
480
|
-
function
|
|
480
|
+
function ct(s) {
|
|
481
481
|
return s * (Math.PI / 180);
|
|
482
482
|
}
|
|
483
|
-
function
|
|
483
|
+
function $t(s) {
|
|
484
484
|
return s * (180 / Math.PI);
|
|
485
485
|
}
|
|
486
|
-
class
|
|
486
|
+
class Qe extends W {
|
|
487
487
|
constructor(t) {
|
|
488
488
|
super(t), this.config = void 0, this.config = t;
|
|
489
489
|
}
|
|
@@ -496,8 +496,8 @@ class oi extends W {
|
|
|
496
496
|
Number.isInteger(n) || (n = Math.floor(n) + 1);
|
|
497
497
|
const a = [];
|
|
498
498
|
for (let d = 0; d < n; d++) {
|
|
499
|
-
const
|
|
500
|
-
a.push(
|
|
499
|
+
const h = Ze(o, i * d, i * (d + 1));
|
|
500
|
+
a.push(h);
|
|
501
501
|
}
|
|
502
502
|
const l = [];
|
|
503
503
|
for (let d = 0; d < a.length; d++) l.push(a[d][1]);
|
|
@@ -505,67 +505,67 @@ class oi extends W {
|
|
|
505
505
|
}
|
|
506
506
|
generateInsertionGeodesicCoordinates(t, e, i) {
|
|
507
507
|
const o = A(t, e), r = function(n, a, l) {
|
|
508
|
-
const d = [],
|
|
508
|
+
const d = [], h = ct(n[1]), c = ct(n[0]), u = ct(a[1]), p = ct(a[0]);
|
|
509
509
|
l += 1;
|
|
510
|
-
const
|
|
511
|
-
if (
|
|
512
|
-
for (let
|
|
513
|
-
const v =
|
|
510
|
+
const y = 2 * Math.asin(Math.sqrt(Math.sin((u - h) / 2) ** 2 + Math.cos(h) * Math.cos(u) * Math.sin((p - c) / 2) ** 2));
|
|
511
|
+
if (y === 0 || isNaN(y)) return d;
|
|
512
|
+
for (let g = 0; g <= l; g++) {
|
|
513
|
+
const v = g / l, f = Math.sin((1 - v) * y) / Math.sin(y), m = Math.sin(v * y) / Math.sin(y), C = f * Math.cos(h) * Math.cos(c) + m * Math.cos(u) * Math.cos(p), P = f * Math.cos(h) * Math.sin(c) + m * Math.cos(u) * Math.sin(p), S = f * Math.sin(h) + m * Math.sin(u);
|
|
514
514
|
if (isNaN(C) || isNaN(P) || isNaN(S)) continue;
|
|
515
|
-
const M = Math.atan2(S, Math.sqrt(C ** 2 + P ** 2)),
|
|
516
|
-
isNaN(M) || isNaN(
|
|
515
|
+
const M = Math.atan2(S, Math.sqrt(C ** 2 + P ** 2)), F = Math.atan2(P, C);
|
|
516
|
+
isNaN(M) || isNaN(F) || d.push([$t(F), $t(M)]);
|
|
517
517
|
}
|
|
518
518
|
return d.slice(1, -1);
|
|
519
519
|
}(t, e, Math.floor(o / i));
|
|
520
520
|
return this.limitCoordinates(r);
|
|
521
521
|
}
|
|
522
522
|
limitCoordinates(t) {
|
|
523
|
-
return t.map((e) => [
|
|
523
|
+
return t.map((e) => [w(e[0], this.config.coordinatePrecision), w(e[1], this.config.coordinatePrecision)]);
|
|
524
524
|
}
|
|
525
525
|
}
|
|
526
526
|
function Z(s, t) {
|
|
527
527
|
return s[0] === t[0] && s[1] === t[1];
|
|
528
528
|
}
|
|
529
|
-
function
|
|
529
|
+
function me(s, t) {
|
|
530
530
|
if (s.geometry.type !== "LineString") return { valid: !1, reason: "Feature is not a LineString" };
|
|
531
531
|
if (s.geometry.coordinates.length < 2) return { valid: !1, reason: "Feature has less than 2 coordinates" };
|
|
532
532
|
for (let e = 0; e < s.geometry.coordinates.length; e++) {
|
|
533
|
-
if (!
|
|
533
|
+
if (!Lt(s.geometry.coordinates[e])) return { valid: !1, reason: "Feature has invalid coordinates" };
|
|
534
534
|
if (!St(s.geometry.coordinates[e], t)) return { valid: !1, reason: "Feature has coordinates with excessive precision" };
|
|
535
535
|
}
|
|
536
536
|
return { valid: !0 };
|
|
537
537
|
}
|
|
538
|
-
function
|
|
538
|
+
function Ht(s) {
|
|
539
539
|
return Math.sqrt(Math.pow(s[0], 2) + Math.pow(s[1], 2) + Math.pow(s[2], 2));
|
|
540
540
|
}
|
|
541
541
|
function X(s, t) {
|
|
542
542
|
const e = function(i, o) {
|
|
543
|
-
const [r, n, a] = i, [l, d,
|
|
544
|
-
return r * l + n * d + a *
|
|
545
|
-
}(s, t) / (
|
|
543
|
+
const [r, n, a] = i, [l, d, h] = o;
|
|
544
|
+
return r * l + n * d + a * h;
|
|
545
|
+
}(s, t) / (Ht(s) * Ht(t));
|
|
546
546
|
return Math.acos(Math.min(Math.max(e, -1), 1));
|
|
547
547
|
}
|
|
548
548
|
function Mt(s) {
|
|
549
|
-
const t =
|
|
549
|
+
const t = O(s[1]), e = O(s[0]);
|
|
550
550
|
return [Math.cos(t) * Math.cos(e), Math.cos(t) * Math.sin(e), Math.sin(t)];
|
|
551
551
|
}
|
|
552
552
|
function K(s) {
|
|
553
|
-
const [t, e, i] = s, o =
|
|
554
|
-
return [
|
|
555
|
-
}
|
|
556
|
-
function
|
|
557
|
-
const i = Mt(s), o = Mt(t), r = Mt(e), [n, a, l] = r, [d,
|
|
558
|
-
const [Bt, Nt
|
|
559
|
-
return [
|
|
560
|
-
}(i, o), u =
|
|
561
|
-
let
|
|
562
|
-
return
|
|
563
|
-
}
|
|
564
|
-
function
|
|
553
|
+
const [t, e, i] = s, o = R(Math.asin(i));
|
|
554
|
+
return [R(Math.atan2(e, t)), o];
|
|
555
|
+
}
|
|
556
|
+
function ti(s, t, e) {
|
|
557
|
+
const i = Mt(s), o = Mt(t), r = Mt(e), [n, a, l] = r, [d, h, c] = function(B, z) {
|
|
558
|
+
const [Wt, Bt, Nt] = B, [Gt, Tt, At] = z;
|
|
559
|
+
return [Bt * At - Nt * Tt, Nt * Gt - Wt * At, Wt * Tt - Bt * Gt];
|
|
560
|
+
}(i, o), u = h * l - c * a, p = c * n - d * l, y = d * a - h * n, g = y * h - p * c, v = u * c - y * d, f = p * d - u * h, m = 1 / Math.sqrt(Math.pow(g, 2) + Math.pow(v, 2) + Math.pow(f, 2)), C = [g * m, v * m, f * m], P = [-1 * g * m, -1 * v * m, -1 * f * m], S = X(i, o), M = X(i, C), F = X(o, C), D = X(i, P), G = X(o, P);
|
|
561
|
+
let _;
|
|
562
|
+
return _ = M < D && M < G || F < D && F < G ? C : P, X(i, _) > S || X(o, _) > S ? A(K(_), K(i)) <= A(K(_), K(o)) ? [K(i), !0, !1] : [K(o), !1, !0] : [K(_), !1, !1];
|
|
563
|
+
}
|
|
564
|
+
function ei(s, t, e) {
|
|
565
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)));
|
|
566
566
|
return { x: s.x + r * i, y: s.y + r * o };
|
|
567
567
|
}
|
|
568
|
-
class
|
|
568
|
+
class ve extends W {
|
|
569
569
|
constructor(t, e, i) {
|
|
570
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;
|
|
571
571
|
}
|
|
@@ -581,40 +581,40 @@ class xe extends W {
|
|
|
581
581
|
const l = [];
|
|
582
582
|
for (let u = 0; u < a.length - 1; u++) l.push([a[u], a[u + 1]]);
|
|
583
583
|
let d;
|
|
584
|
-
const
|
|
584
|
+
const h = [t.lng, t.lat];
|
|
585
585
|
if (this.config.projection === "web-mercator" ? d = function(u, p) {
|
|
586
|
-
let
|
|
586
|
+
let y = [1 / 0, 1 / 0], g = 1 / 0, v = 0;
|
|
587
587
|
for (let f of p) {
|
|
588
588
|
const m = f[0], C = f[1];
|
|
589
589
|
let P, S = 1 / 0;
|
|
590
|
-
const M = x(m[0], m[1]),
|
|
590
|
+
const M = x(m[0], m[1]), F = x(C[0], C[1]), D = x(u[0], u[1]);
|
|
591
591
|
if (m[0] === u[0] && m[1] === u[1]) P = m;
|
|
592
592
|
else if (C[0] === u[0] && C[1] === u[1]) P = C;
|
|
593
593
|
else {
|
|
594
|
-
const { x: G, y:
|
|
595
|
-
P = [B,
|
|
594
|
+
const { x: G, y: _ } = ei(M, F, D), { lng: B, lat: z } = j(G, _);
|
|
595
|
+
P = [B, z];
|
|
596
596
|
}
|
|
597
|
-
P && (S =
|
|
597
|
+
P && (S = E(D, x(P[0], P[1])), S < g && (y = P, g = S, v = p.indexOf(f)));
|
|
598
598
|
}
|
|
599
|
-
return
|
|
600
|
-
}(
|
|
601
|
-
let
|
|
599
|
+
return g === 1 / 0 ? void 0 : { coordinate: y, lineIndex: v, distance: g };
|
|
600
|
+
}(h, l) : this.config.projection === "globe" && (d = function(u, p) {
|
|
601
|
+
let y = [1 / 0, 1 / 0], g = 1 / 0, v = 0;
|
|
602
602
|
for (let f of p) {
|
|
603
603
|
const m = f[0], C = f[1];
|
|
604
604
|
let P, S = 1 / 0;
|
|
605
|
-
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] = ti(m, C, u), P && (S = A(u, P), S < g && (y = P, g = S, v = p.indexOf(f)));
|
|
606
606
|
}
|
|
607
|
-
return
|
|
608
|
-
}(
|
|
609
|
-
const
|
|
610
|
-
|
|
607
|
+
return g === 1 / 0 ? void 0 : { coordinate: y, distance: g, lineIndex: v };
|
|
608
|
+
}(h, l)), !d) return;
|
|
609
|
+
const c = this.pixelDistance.measure(t, d.coordinate);
|
|
610
|
+
c < r.minDistance && c < this.pointerDistance && (r.featureId = n.id, r.coordinate = d.coordinate, r.featureCoordinateIndex = d.lineIndex, r.minDistance = c);
|
|
611
611
|
}), r;
|
|
612
612
|
}
|
|
613
613
|
}
|
|
614
|
-
const
|
|
615
|
-
class
|
|
614
|
+
const ii = { cancel: "Escape", finish: "Enter" }, oi = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
615
|
+
class Ce extends N {
|
|
616
616
|
constructor(t) {
|
|
617
|
-
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 = ii, this.snapping = void 0, this.cursors = oi, 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);
|
|
618
618
|
}
|
|
619
619
|
updateOptions(t) {
|
|
620
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);
|
|
@@ -654,13 +654,13 @@ class Ie extends N {
|
|
|
654
654
|
updateToLine(t, e) {
|
|
655
655
|
if (!this.currentId) return;
|
|
656
656
|
const i = this.store.getGeometryCopy(this.currentId).coordinates, [o, r] = this.lastCommitedCoordinates ? this.lastCommitedCoordinates[this.lastCommitedCoordinates.length - 1] : i[i.length - 2], { x: n, y: a } = this.project(o, r);
|
|
657
|
-
if (
|
|
657
|
+
if (E({ x: n, y: a }, { x: e.x, y: e.y }) < this.pointerDistance) return void this.close();
|
|
658
658
|
this.setCursor(this.cursors.close);
|
|
659
659
|
const l = [...i, t];
|
|
660
660
|
this.updateGeometries(l, i[i.length - 1], I.Commit), this.currentCoordinate++;
|
|
661
661
|
}
|
|
662
662
|
registerBehaviors(t) {
|
|
663
|
-
this.coordinateSnapping = new
|
|
663
|
+
this.coordinateSnapping = new Dt(t, new nt(t), new rt(t)), this.insertPoint = new Qe(t), this.clickBoundingBox = new rt(t), this.pixelDistance = new nt(t), this.lineSnapping = new ve(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new Dt(t, this.pixelDistance, this.clickBoundingBox);
|
|
664
664
|
}
|
|
665
665
|
start() {
|
|
666
666
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -674,7 +674,7 @@ class Ie extends N {
|
|
|
674
674
|
if (e) {
|
|
675
675
|
if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: e } }]);
|
|
676
676
|
else {
|
|
677
|
-
const [n] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [
|
|
677
|
+
const [n] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [Ot]: !0 } }]);
|
|
678
678
|
this.snappedPointId = n;
|
|
679
679
|
}
|
|
680
680
|
t.lng = e[0], t.lat = e[1];
|
|
@@ -684,7 +684,7 @@ class Ie extends N {
|
|
|
684
684
|
const o = this.store.getGeometryCopy(this.currentId).coordinates;
|
|
685
685
|
if (o.pop(), this.closingPointId) {
|
|
686
686
|
const [n, a] = o[o.length - 1], { x: l, y: d } = this.project(n, a);
|
|
687
|
-
|
|
687
|
+
E({ x: l, y: d }, { x: t.containerX, y: t.containerY }) < this.pointerDistance && this.setCursor(this.cursors.close);
|
|
688
688
|
}
|
|
689
689
|
let r = [...o, i];
|
|
690
690
|
if (this.insertCoordinates && this.currentId && this.lastCommitedCoordinates) {
|
|
@@ -704,7 +704,7 @@ class Ie extends N {
|
|
|
704
704
|
let r;
|
|
705
705
|
if (o.type === "LineString" && (r = o.coordinates, !(r.length <= 2))) {
|
|
706
706
|
if (r.splice(i, 1), this.validate && !this.validate({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: I.Commit }).valid) return;
|
|
707
|
-
this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: e, geometry: o }]);
|
|
707
|
+
this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: e, geometry: o }]), this.onFinish(e, { mode: this.mode, action: "edit" });
|
|
708
708
|
}
|
|
709
709
|
}
|
|
710
710
|
onLeftClick(t) {
|
|
@@ -745,7 +745,7 @@ class Ie extends N {
|
|
|
745
745
|
this.validate && !this.validate({ type: "Feature", geometry: o, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: I.Provisional }).valid || (this.snapping && this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: this.editedFeatureId, geometry: o }]), this.editedPointId && this.store.updateGeometry([{ id: this.editedPointId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: V, value: !0 }]), e(!0));
|
|
746
746
|
}
|
|
747
747
|
onDragEnd(t, e) {
|
|
748
|
-
this.editedFeatureId !== void 0 && (this.setCursor(this.cursors.dragEnd), this.editedPointId && (this.store.delete([this.editedPointId]), this.editedPointId = void 0), this.store.updateProperty([{ id: this.editedFeatureId, property: V, value: !1 }]), this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedInsertIndex = void 0, this.editedSnapType = void 0, e(!0));
|
|
748
|
+
this.editedFeatureId !== void 0 && (this.setCursor(this.cursors.dragEnd), this.editedPointId && (this.store.delete([this.editedPointId]), this.editedPointId = void 0), this.store.updateProperty([{ id: this.editedFeatureId, property: V, value: !1 }]), this.onFinish(this.editedFeatureId, { mode: this.mode, action: "edit" }), this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedInsertIndex = void 0, this.editedSnapType = void 0, e(!0));
|
|
749
749
|
}
|
|
750
750
|
cleanUp() {
|
|
751
751
|
const t = this.currentId, e = this.closingPointId, i = this.snappedPointId;
|
|
@@ -765,7 +765,7 @@ class Ie extends N {
|
|
|
765
765
|
return e;
|
|
766
766
|
}
|
|
767
767
|
validateFeature(t) {
|
|
768
|
-
return this.validateModeFeature(t, (e) =>
|
|
768
|
+
return this.validateModeFeature(t, (e) => me(e, this.coordinatePrecision));
|
|
769
769
|
}
|
|
770
770
|
lineStringFilter(t) {
|
|
771
771
|
return !!(t.geometry.type === "LineString" && t.properties && t.properties.mode === this.mode);
|
|
@@ -776,14 +776,14 @@ class Ie extends N {
|
|
|
776
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;
|
|
777
777
|
}
|
|
778
778
|
}
|
|
779
|
-
const
|
|
780
|
-
function
|
|
781
|
-
return s.geometry.type !== "Point" ? { valid: !1, reason:
|
|
779
|
+
const si = "Feature is not a Point", ri = "Feature has invalid coordinates", ni = "Feature has coordinates with excessive precision";
|
|
780
|
+
function Pe(s, t) {
|
|
781
|
+
return s.geometry.type !== "Point" ? { valid: !1, reason: si } : Lt(s.geometry.coordinates) ? St(s.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: ni } : { valid: !1, reason: ri };
|
|
782
782
|
}
|
|
783
|
-
const
|
|
784
|
-
class
|
|
783
|
+
const ai = { create: "crosshair", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
784
|
+
class Se extends N {
|
|
785
785
|
constructor(t) {
|
|
786
|
-
super(t, !0), this.mode = "point", this.cursors =
|
|
786
|
+
super(t, !0), this.mode = "point", this.cursors = ai, this.editable = !1, this.editedFeatureId = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.updateOptions(t);
|
|
787
787
|
}
|
|
788
788
|
updateOptions(t) {
|
|
789
789
|
super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), t != null && t.editable && (this.editable = t.editable);
|
|
@@ -832,7 +832,7 @@ class Me extends N {
|
|
|
832
832
|
return e;
|
|
833
833
|
}
|
|
834
834
|
validateFeature(t) {
|
|
835
|
-
return this.validateModeFeature(t, (e) =>
|
|
835
|
+
return this.validateModeFeature(t, (e) => Pe(e, this.coordinatePrecision));
|
|
836
836
|
}
|
|
837
837
|
onLeftClick(t) {
|
|
838
838
|
const e = { type: "Point", coordinates: [t.lng, t.lat] }, i = { mode: this.mode };
|
|
@@ -857,7 +857,7 @@ class Me extends N {
|
|
|
857
857
|
return o;
|
|
858
858
|
}
|
|
859
859
|
}
|
|
860
|
-
class
|
|
860
|
+
class li extends W {
|
|
861
861
|
constructor(t, e) {
|
|
862
862
|
super(t), this.config = void 0, this.pixelDistance = void 0, this._startEndPoints = [], this.config = t, this.pixelDistance = e;
|
|
863
863
|
}
|
|
@@ -883,10 +883,10 @@ class ui extends W {
|
|
|
883
883
|
return { isClosing: o < this.pointerDistance, isPreviousClosing: r < this.pointerDistance };
|
|
884
884
|
}
|
|
885
885
|
}
|
|
886
|
-
const
|
|
887
|
-
class
|
|
886
|
+
const di = { cancel: "Escape", finish: "Enter" }, hi = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
887
|
+
class xe extends N {
|
|
888
888
|
constructor(t) {
|
|
889
|
-
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 = di, this.cursors = hi, 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);
|
|
890
890
|
}
|
|
891
891
|
updateOptions(t) {
|
|
892
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);
|
|
@@ -903,7 +903,7 @@ class we extends N {
|
|
|
903
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" });
|
|
904
904
|
}
|
|
905
905
|
registerBehaviors(t) {
|
|
906
|
-
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 ve(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new Dt(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new li(t, this.pixelDistance);
|
|
907
907
|
}
|
|
908
908
|
start() {
|
|
909
909
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -917,7 +917,7 @@ class we extends N {
|
|
|
917
917
|
if (e) {
|
|
918
918
|
if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: e } }]);
|
|
919
919
|
else {
|
|
920
|
-
const [r] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [
|
|
920
|
+
const [r] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [Ot]: !0 } }]);
|
|
921
921
|
this.snappedPointId = r;
|
|
922
922
|
}
|
|
923
923
|
t.lng = e[0], t.lat = e[1];
|
|
@@ -962,7 +962,7 @@ class we extends N {
|
|
|
962
962
|
if (!e || i === void 0) return;
|
|
963
963
|
const o = this.store.getGeometryCopy(e);
|
|
964
964
|
let r;
|
|
965
|
-
o.type === "Polygon" && (r = o.coordinates[0], r.length <= 4 || (o.type !== "Polygon" || i !== 0 && i !== r.length - 1 ? r.splice(i, 1) : (r.shift(), r.pop(), r.push([r[0][0], r[0][1]])), (!this.validate || this.validate({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: I.Commit }).valid) && (this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: e, geometry: o }]))));
|
|
965
|
+
o.type === "Polygon" && (r = o.coordinates[0], r.length <= 4 || (o.type !== "Polygon" || i !== 0 && i !== r.length - 1 ? r.splice(i, 1) : (r.shift(), r.pop(), r.push([r[0][0], r[0][1]])), (!this.validate || this.validate({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: I.Commit }).valid) && (this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: e, geometry: o }]), this.onFinish(e, { mode: this.mode, action: "edit" }))));
|
|
966
966
|
}
|
|
967
967
|
onLeftClick(t) {
|
|
968
968
|
if (this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.currentCoordinate === 0) {
|
|
@@ -1029,7 +1029,7 @@ class we extends N {
|
|
|
1029
1029
|
this.validate && !this.validate({ type: "Feature", geometry: r, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: I.Provisional }).valid || (this.snapping && this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: this.editedFeatureId, geometry: r }]), this.editedPointId && this.store.updateGeometry([{ id: this.editedPointId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: V, value: !0 }]), e(!0));
|
|
1030
1030
|
}
|
|
1031
1031
|
onDragEnd(t, e) {
|
|
1032
|
-
this.editedFeatureId !== void 0 && (this.setCursor(this.cursors.dragEnd), this.editedPointId && (this.store.delete([this.editedPointId]), this.editedPointId = void 0), this.store.updateProperty([{ id: this.editedFeatureId, property: V, value: !1 }]), this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedInsertIndex = void 0, this.editedSnapType = void 0, e(!0));
|
|
1032
|
+
this.editedFeatureId !== void 0 && (this.setCursor(this.cursors.dragEnd), this.editedPointId && (this.store.delete([this.editedPointId]), this.editedPointId = void 0), this.store.updateProperty([{ id: this.editedFeatureId, property: V, value: !1 }]), this.onFinish(this.editedFeatureId, { mode: this.mode, action: "edit" }), this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedInsertIndex = void 0, this.editedSnapType = void 0, e(!0));
|
|
1033
1033
|
}
|
|
1034
1034
|
cleanUp() {
|
|
1035
1035
|
const t = this.currentId, e = this.snappedPointId, i = this.editedPointId;
|
|
@@ -1044,7 +1044,7 @@ class we extends N {
|
|
|
1044
1044
|
if (t.properties.mode === this.mode) {
|
|
1045
1045
|
if (t.geometry.type === "Polygon") return e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10, e;
|
|
1046
1046
|
if (t.geometry.type === "Point") {
|
|
1047
|
-
const i = t.properties[V], o = i ? "editedPoint" : t.properties[st] ? "closingPoint" : t.properties[
|
|
1047
|
+
const i = t.properties[V], o = i ? "editedPoint" : t.properties[st] ? "closingPoint" : t.properties[Ot] ? "snappingPoint" : void 0;
|
|
1048
1048
|
if (!o) return e;
|
|
1049
1049
|
const r = { editedPoint: { width: this.styles.editedPointOutlineWidth, color: this.styles.editedPointColor, outlineColor: this.styles.editedPointOutlineColor, outlineWidth: this.styles.editedPointOutlineWidth }, closingPoint: { width: this.styles.closingPointWidth, color: this.styles.closingPointColor, outlineColor: this.styles.closingPointOutlineColor, outlineWidth: this.styles.closingPointOutlineWidth }, snappingPoint: { width: this.styles.snappingPointWidth, color: this.styles.snappingPointColor, outlineColor: this.styles.snappingPointOutlineColor, outlineWidth: this.styles.snappingPointOutlineWidth } };
|
|
1050
1050
|
return e.pointWidth = this.getNumericStylingValue(r[o].width, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(r[o].color, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(r[o].outlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(r[o].outlineWidth, 2, t), e.zIndex = i ? 35 : 30, e;
|
|
@@ -1056,10 +1056,10 @@ class we extends N {
|
|
|
1056
1056
|
return this.validateModeFeature(t, (e) => xt(e, this.coordinatePrecision));
|
|
1057
1057
|
}
|
|
1058
1058
|
}
|
|
1059
|
-
const
|
|
1060
|
-
class
|
|
1059
|
+
const ci = { cancel: "Escape", finish: "Enter" }, ui = { start: "crosshair" };
|
|
1060
|
+
class Ie extends N {
|
|
1061
1061
|
constructor(t) {
|
|
1062
|
-
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 = ci, this.cursors = ui, this.updateOptions(t);
|
|
1063
1063
|
}
|
|
1064
1064
|
updateOptions(t) {
|
|
1065
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));
|
|
@@ -1157,50 +1157,50 @@ class et extends N {
|
|
|
1157
1157
|
validateFeature(t) {
|
|
1158
1158
|
const e = super.validateFeature(t);
|
|
1159
1159
|
if (e.valid) {
|
|
1160
|
-
const i = t, o =
|
|
1160
|
+
const i = t, o = Pe(i, this.coordinatePrecision).valid || xt(i, this.coordinatePrecision).valid || me(i, this.coordinatePrecision).valid;
|
|
1161
1161
|
return o ? { valid: !0 } : { valid: o, reason: "Feature is not a valid Point, Polygon or LineString feature" };
|
|
1162
1162
|
}
|
|
1163
1163
|
return e;
|
|
1164
1164
|
}
|
|
1165
1165
|
}
|
|
1166
1166
|
function mt(s, t) {
|
|
1167
|
-
const e = s, i = t, o =
|
|
1168
|
-
let n =
|
|
1167
|
+
const e = s, i = t, o = O(e[1]), r = O(i[1]);
|
|
1168
|
+
let n = O(i[0] - e[0]);
|
|
1169
1169
|
n > Math.PI && (n -= 2 * Math.PI), n < -Math.PI && (n += 2 * Math.PI);
|
|
1170
|
-
const a = Math.log(Math.tan(r / 2 + Math.PI / 4) / Math.tan(o / 2 + Math.PI / 4)), l = (
|
|
1170
|
+
const a = Math.log(Math.tan(r / 2 + Math.PI / 4) / Math.tan(o / 2 + Math.PI / 4)), l = (R(Math.atan2(n, a)) + 360) % 360;
|
|
1171
1171
|
return l > 180 ? -(360 - l) : l;
|
|
1172
1172
|
}
|
|
1173
|
-
function
|
|
1173
|
+
function kt(s, t, e) {
|
|
1174
1174
|
let i = t;
|
|
1175
1175
|
t < 0 && (i = -Math.abs(i));
|
|
1176
|
-
const o = i /
|
|
1176
|
+
const o = i / ue, r = s[0] * Math.PI / 180, n = O(s[1]), a = O(e), l = o * Math.cos(a);
|
|
1177
1177
|
let d = n + l;
|
|
1178
1178
|
Math.abs(d) > Math.PI / 2 && (d = d > 0 ? Math.PI - d : -Math.PI - d);
|
|
1179
|
-
const
|
|
1179
|
+
const h = Math.log(Math.tan(d / 2 + Math.PI / 4) / Math.tan(n / 2 + Math.PI / 4)), c = Math.abs(h) > 1e-11 ? l / h : Math.cos(n), u = [(180 * (r + o * Math.sin(a) / c) / Math.PI + 540) % 360 - 180, 180 * d / Math.PI];
|
|
1180
1180
|
return u[0] += u[0] - s[0] > 180 ? -360 : s[0] - u[0] > 180 ? 360 : 0, u;
|
|
1181
1181
|
}
|
|
1182
|
-
function
|
|
1182
|
+
function be(s, t, e, i, o) {
|
|
1183
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);
|
|
1184
|
-
return [
|
|
1184
|
+
return [w(a, e), w(l, e)];
|
|
1185
1185
|
}
|
|
1186
|
-
function
|
|
1187
|
-
const i =
|
|
1188
|
-
return [
|
|
1186
|
+
function pi(s, t, e) {
|
|
1187
|
+
const i = kt(s, 1e3 * A(s, t) / 2, mt(s, t));
|
|
1188
|
+
return [w(i[0], e), w(i[1], e)];
|
|
1189
1189
|
}
|
|
1190
|
-
function
|
|
1190
|
+
function qt({ featureCoords: s, precision: t, unproject: e, project: i, projection: o }) {
|
|
1191
1191
|
const r = [];
|
|
1192
1192
|
for (let n = 0; n < s.length - 1; n++) {
|
|
1193
1193
|
let a;
|
|
1194
|
-
if (o === "web-mercator") a =
|
|
1194
|
+
if (o === "web-mercator") a = be(s[n], s[n + 1], t, i, e);
|
|
1195
1195
|
else {
|
|
1196
1196
|
if (o !== "globe") throw new Error("Invalid projection");
|
|
1197
|
-
a =
|
|
1197
|
+
a = pi(s[n], s[n + 1], t);
|
|
1198
1198
|
}
|
|
1199
1199
|
r.push(a);
|
|
1200
1200
|
}
|
|
1201
1201
|
return r;
|
|
1202
1202
|
}
|
|
1203
|
-
class
|
|
1203
|
+
class gi extends W {
|
|
1204
1204
|
constructor(t, e) {
|
|
1205
1205
|
super(t), this.config = void 0, this.selectionPointBehavior = void 0, this._midPoints = [], this.config = t, this.selectionPointBehavior = e;
|
|
1206
1206
|
}
|
|
@@ -1216,17 +1216,17 @@ class vi extends W {
|
|
|
1216
1216
|
create(t, e, i) {
|
|
1217
1217
|
if (!this.store.has(e)) throw new Error("Store does not have feature with this id");
|
|
1218
1218
|
this._midPoints = this.store.create(function(o, r, n, a, l, d) {
|
|
1219
|
-
return
|
|
1219
|
+
return qt({ featureCoords: o, precision: n, project: a, unproject: l, projection: d }).map((h, c) => ({ geometry: { type: "Point", coordinates: h }, properties: r(c) }));
|
|
1220
1220
|
}(t, (o) => ({ mode: this.mode, [U.MID_POINT]: !0, midPointSegment: o, midPointFeatureId: e }), i, this.config.project, this.config.unproject, this.projection));
|
|
1221
1221
|
}
|
|
1222
1222
|
delete() {
|
|
1223
1223
|
this._midPoints.length && (this.store.delete(this._midPoints), this._midPoints = []);
|
|
1224
1224
|
}
|
|
1225
1225
|
getUpdated(t) {
|
|
1226
|
-
if (this._midPoints.length !== 0) return
|
|
1226
|
+
if (this._midPoints.length !== 0) return qt({ 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 } }));
|
|
1227
1227
|
}
|
|
1228
1228
|
}
|
|
1229
|
-
class
|
|
1229
|
+
class yi extends W {
|
|
1230
1230
|
constructor(t) {
|
|
1231
1231
|
super(t), this._selectionPoints = [];
|
|
1232
1232
|
}
|
|
@@ -1252,16 +1252,16 @@ class Ci extends W {
|
|
|
1252
1252
|
if (this._selectionPoints[t] !== void 0) return { id: this._selectionPoints[t], geometry: { type: "Point", coordinates: e } };
|
|
1253
1253
|
}
|
|
1254
1254
|
}
|
|
1255
|
-
function
|
|
1255
|
+
function Me(s, t) {
|
|
1256
1256
|
let e = !1;
|
|
1257
1257
|
for (let n = 0, a = t.length; n < a; n++) {
|
|
1258
1258
|
const l = t[n];
|
|
1259
|
-
for (let d = 0,
|
|
1259
|
+
for (let d = 0, h = l.length, c = h - 1; d < h; c = d++) (o = l[d])[1] > (i = s)[1] != (r = l[c])[1] > i[1] && i[0] < (r[0] - o[0]) * (i[1] - o[1]) / (r[1] - o[1]) + o[0] && (e = !e);
|
|
1260
1260
|
}
|
|
1261
1261
|
var i, o, r;
|
|
1262
1262
|
return e;
|
|
1263
1263
|
}
|
|
1264
|
-
const
|
|
1264
|
+
const we = (s, t, e) => {
|
|
1265
1265
|
const i = (r) => r * r, o = (r, n) => i(r.x - n.x) + i(r.y - n.y);
|
|
1266
1266
|
return Math.sqrt(((r, n, a) => {
|
|
1267
1267
|
const l = o(n, a);
|
|
@@ -1270,34 +1270,34 @@ const De = (s, t, e) => {
|
|
|
1270
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) });
|
|
1271
1271
|
})(s, t, e));
|
|
1272
1272
|
};
|
|
1273
|
-
class
|
|
1273
|
+
class fi extends W {
|
|
1274
1274
|
constructor(t, e, i) {
|
|
1275
1275
|
super(t), this.config = void 0, this.createClickBoundingBox = void 0, this.pixelDistance = void 0, this.config = t, this.createClickBoundingBox = e, this.pixelDistance = i;
|
|
1276
1276
|
}
|
|
1277
1277
|
find(t, e) {
|
|
1278
1278
|
let i, o, r, n, a = 1 / 0, l = 1 / 0, d = 1 / 0;
|
|
1279
|
-
const
|
|
1280
|
-
for (let u = 0; u <
|
|
1281
|
-
const p =
|
|
1282
|
-
if (
|
|
1279
|
+
const h = this.createClickBoundingBox.create(t), c = this.store.search(h);
|
|
1280
|
+
for (let u = 0; u < c.length; u++) {
|
|
1281
|
+
const p = c[u], y = p.geometry;
|
|
1282
|
+
if (y.type === "Point") {
|
|
1283
1283
|
if (p.properties.selectionPoint || !e && p.properties[U.MID_POINT]) continue;
|
|
1284
|
-
const
|
|
1285
|
-
p.properties[U.MID_POINT] &&
|
|
1286
|
-
} else if (
|
|
1284
|
+
const g = this.pixelDistance.measure(t, y.coordinates);
|
|
1285
|
+
p.properties[U.MID_POINT] && g < this.pointerDistance && g < d ? (d = g, r = p) : !p.properties[U.MID_POINT] && g < this.pointerDistance && g < a && (a = g, i = p);
|
|
1286
|
+
} else if (y.type === "LineString") {
|
|
1287
1287
|
if (i) continue;
|
|
1288
|
-
for (let
|
|
1289
|
-
const v =
|
|
1288
|
+
for (let g = 0; g < y.coordinates.length - 1; g++) {
|
|
1289
|
+
const v = y.coordinates[g], f = y.coordinates[g + 1], m = we({ x: t.containerX, y: t.containerY }, this.project(v[0], v[1]), this.project(f[0], f[1]));
|
|
1290
1290
|
m < this.pointerDistance && m < l && (l = m, o = p);
|
|
1291
1291
|
}
|
|
1292
|
-
} else if (
|
|
1292
|
+
} else if (y.type === "Polygon") {
|
|
1293
1293
|
if (i || o) continue;
|
|
1294
|
-
|
|
1294
|
+
Me([t.lng, t.lat], y.coordinates) && (n = p);
|
|
1295
1295
|
}
|
|
1296
1296
|
}
|
|
1297
1297
|
return { clickedFeature: i || o || n, clickedMidPoint: r };
|
|
1298
1298
|
}
|
|
1299
1299
|
}
|
|
1300
|
-
class
|
|
1300
|
+
class mi extends W {
|
|
1301
1301
|
constructor(t, e, i, o) {
|
|
1302
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;
|
|
1303
1303
|
}
|
|
@@ -1321,17 +1321,17 @@ class Si extends W {
|
|
|
1321
1321
|
let r, n;
|
|
1322
1322
|
if (i.type === "Polygon" ? (r = i.coordinates[0], n = r.length - 1) : (r = i.coordinates, n = r.length), !this.dragPosition) return !1;
|
|
1323
1323
|
for (let d = 0; d < n; d++) {
|
|
1324
|
-
const
|
|
1325
|
-
let
|
|
1324
|
+
const h = r[d];
|
|
1325
|
+
let c, u;
|
|
1326
1326
|
if (this.config.projection === "web-mercator") {
|
|
1327
|
-
const p = x(this.dragPosition[0], this.dragPosition[1]),
|
|
1328
|
-
|
|
1327
|
+
const p = x(this.dragPosition[0], this.dragPosition[1]), y = x(o[0], o[1]), g = x(h[0], h[1]), v = { x: p.x - y.x, y: p.y - y.y }, f = g.x - v.x, m = g.y - v.y, { lng: C, lat: P } = j(f, m);
|
|
1328
|
+
c = C, u = P;
|
|
1329
1329
|
} else {
|
|
1330
1330
|
const p = [this.dragPosition[0] - o[0], this.dragPosition[1] - o[1]];
|
|
1331
|
-
|
|
1331
|
+
c = h[0] - p[0], u = h[1] - p[1];
|
|
1332
1332
|
}
|
|
1333
|
-
if (
|
|
1334
|
-
r[d] = [
|
|
1333
|
+
if (c = w(c, this.config.coordinatePrecision), u = w(u, this.config.coordinatePrecision), c > 180 || c < -180 || u > 90 || u < -90) return !1;
|
|
1334
|
+
r[d] = [c, u];
|
|
1335
1335
|
}
|
|
1336
1336
|
i.type === "Polygon" && (r[r.length - 1] = [r[0][0], r[0][1]]);
|
|
1337
1337
|
const a = this.selectionPoints.getUpdated(r) || [], l = this.midPoints.getUpdated(r) || [];
|
|
@@ -1340,7 +1340,7 @@ class Si extends W {
|
|
|
1340
1340
|
} else i.type === "Point" && (this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: { type: "Point", coordinates: o } }]), this.dragPosition = [t.lng, t.lat]);
|
|
1341
1341
|
}
|
|
1342
1342
|
}
|
|
1343
|
-
class
|
|
1343
|
+
class vi extends W {
|
|
1344
1344
|
constructor(t, e, i, o) {
|
|
1345
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;
|
|
1346
1346
|
}
|
|
@@ -1371,11 +1371,11 @@ class xi extends W {
|
|
|
1371
1371
|
if (t.lng > 180 || t.lng < -180 || t.lat > 90 || t.lat < -90) return !1;
|
|
1372
1372
|
if (r.type !== "Polygon" || o !== n.length - 1 && o !== 0) n[o] = a;
|
|
1373
1373
|
else {
|
|
1374
|
-
const
|
|
1375
|
-
n[0] = a, n[
|
|
1374
|
+
const c = n.length - 1;
|
|
1375
|
+
n[0] = a, n[c] = a;
|
|
1376
1376
|
}
|
|
1377
|
-
const l = this.selectionPoints.getOneUpdated(o, a), d = l ? [l] : [],
|
|
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, ...
|
|
1377
|
+
const l = this.selectionPoints.getOneUpdated(o, a), d = l ? [l] : [], h = 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, ...h]), 0));
|
|
1379
1379
|
}
|
|
1380
1380
|
isDragging() {
|
|
1381
1381
|
return this.draggedCoordinate.id !== null;
|
|
@@ -1393,9 +1393,9 @@ function vt(s) {
|
|
|
1393
1393
|
t += o[0], e += o[1], i++;
|
|
1394
1394
|
}, !0), [t / i, e / i];
|
|
1395
1395
|
}
|
|
1396
|
-
function
|
|
1396
|
+
function Fe(s, t) {
|
|
1397
1397
|
s[0] += s[0] - t[0] > 180 ? -360 : t[0] - s[0] > 180 ? 360 : 0;
|
|
1398
|
-
const e =
|
|
1398
|
+
const e = ue, i = t[1] * Math.PI / 180, o = s[1] * Math.PI / 180, r = o - i;
|
|
1399
1399
|
let n = Math.abs(s[0] - t[0]) * Math.PI / 180;
|
|
1400
1400
|
n > Math.PI && (n -= 2 * Math.PI);
|
|
1401
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);
|
|
@@ -1410,8 +1410,8 @@ function Ct(s) {
|
|
|
1410
1410
|
let i = 0, o = 0, r = 0;
|
|
1411
1411
|
const n = e.length;
|
|
1412
1412
|
for (let a = 0; a < n - 1; a++) {
|
|
1413
|
-
const [l, d] = e[a], [
|
|
1414
|
-
i += u, o += (l +
|
|
1413
|
+
const [l, d] = e[a], [h, c] = e[a + 1], u = l * c - h * d;
|
|
1414
|
+
i += u, o += (l + h) * u, r += (d + c) * u;
|
|
1415
1415
|
}
|
|
1416
1416
|
return i /= 2, o /= 6 * i, r /= 6 * i, { x: o, y: r };
|
|
1417
1417
|
}(t) : function(e) {
|
|
@@ -1424,7 +1424,7 @@ function Ct(s) {
|
|
|
1424
1424
|
return { x: o / i, y: r / i };
|
|
1425
1425
|
}(t);
|
|
1426
1426
|
}
|
|
1427
|
-
class
|
|
1427
|
+
class Ci extends W {
|
|
1428
1428
|
constructor(t, e, i) {
|
|
1429
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;
|
|
1430
1430
|
}
|
|
@@ -1439,35 +1439,35 @@ class Ii extends W {
|
|
|
1439
1439
|
const a = { type: "Feature", geometry: o, properties: {} };
|
|
1440
1440
|
if (this.config.projection === "web-mercator") {
|
|
1441
1441
|
if (n = T(Ct(a), x(t.lng, t.lat)), !this.lastBearing) return void (this.lastBearing = n);
|
|
1442
|
-
((
|
|
1443
|
-
if (u === 0 || u === 360 || u === -360) return
|
|
1444
|
-
const p = 0.017453292519943295 * u,
|
|
1445
|
-
|
|
1446
|
-
const v =
|
|
1447
|
-
|
|
1442
|
+
((c, u) => {
|
|
1443
|
+
if (u === 0 || u === 360 || u === -360) return c;
|
|
1444
|
+
const p = 0.017453292519943295 * u, y = (c.geometry.type === "Polygon" ? c.geometry.coordinates[0] : c.geometry.coordinates).map(([f, m]) => x(f, m)), g = y.reduce((f, m) => ({ x: f.x + m.x, y: f.y + m.y }), { x: 0, y: 0 });
|
|
1445
|
+
g.x /= y.length, g.y /= y.length;
|
|
1446
|
+
const v = y.map((f) => ({ x: g.x + (f.x - g.x) * Math.cos(p) - (f.y - g.y) * Math.sin(p), y: g.y + (f.x - g.x) * Math.sin(p) + (f.y - g.y) * Math.cos(p) })).map(({ x: f, y: m }) => [j(f, m).lng, j(f, m).lat]);
|
|
1447
|
+
c.geometry.type === "Polygon" ? c.geometry.coordinates[0] = v : c.geometry.coordinates = v;
|
|
1448
1448
|
})(a, -(this.lastBearing - n));
|
|
1449
1449
|
} else {
|
|
1450
1450
|
if (this.config.projection !== "globe") throw new Error("Unsupported projection");
|
|
1451
1451
|
if (n = mt(vt({ geometry: o }), r), !this.lastBearing) return void (this.lastBearing = n + 180);
|
|
1452
|
-
(function(
|
|
1453
|
-
if (u === 0 || u === 360 || u === -360) return
|
|
1454
|
-
const p = vt(
|
|
1455
|
-
(
|
|
1456
|
-
const
|
|
1457
|
-
|
|
1452
|
+
(function(c, u) {
|
|
1453
|
+
if (u === 0 || u === 360 || u === -360) return c;
|
|
1454
|
+
const p = vt(c);
|
|
1455
|
+
(c.geometry.type === "Polygon" ? c.geometry.coordinates[0] : c.geometry.coordinates).forEach((y) => {
|
|
1456
|
+
const g = mt(p, y) + u, v = Fe(p, y), f = kt(p, v, g);
|
|
1457
|
+
y[0] = f[0], y[1] = f[1];
|
|
1458
1458
|
});
|
|
1459
1459
|
})(a, -(this.lastBearing - (n + 180)));
|
|
1460
1460
|
}
|
|
1461
1461
|
const l = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
|
|
1462
|
-
l.forEach((
|
|
1463
|
-
|
|
1462
|
+
l.forEach((c) => {
|
|
1463
|
+
c[0] = w(c[0], this.coordinatePrecision), c[1] = w(c[1], this.coordinatePrecision);
|
|
1464
1464
|
});
|
|
1465
|
-
const d = this.midPoints.getUpdated(l) || [],
|
|
1465
|
+
const d = this.midPoints.getUpdated(l) || [], h = this.selectionPoints.getUpdated(l) || [];
|
|
1466
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;
|
|
1467
|
-
this.store.updateGeometry([{ id: e, geometry: o }, ...
|
|
1467
|
+
this.store.updateGeometry([{ id: e, geometry: o }, ...h, ...d]), this.projection === "web-mercator" ? this.lastBearing = n : this.projection === "globe" && (this.lastBearing = n + 180);
|
|
1468
1468
|
}
|
|
1469
1469
|
}
|
|
1470
|
-
class
|
|
1470
|
+
class Pi extends W {
|
|
1471
1471
|
constructor(t, e, i) {
|
|
1472
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;
|
|
1473
1473
|
}
|
|
@@ -1482,7 +1482,7 @@ class bi extends W {
|
|
|
1482
1482
|
const l = Ct(n);
|
|
1483
1483
|
if (this.config.projection === "web-mercator") {
|
|
1484
1484
|
const p = x(t.lng, t.lat);
|
|
1485
|
-
a =
|
|
1485
|
+
a = E(l, p);
|
|
1486
1486
|
} else {
|
|
1487
1487
|
if (this.config.projection !== "globe") throw new Error("Invalid projection");
|
|
1488
1488
|
a = A(vt({ geometry: o }), r);
|
|
@@ -1490,28 +1490,28 @@ class bi extends W {
|
|
|
1490
1490
|
if (!this.lastDistance) return void (this.lastDistance = a);
|
|
1491
1491
|
const d = 1 - (this.lastDistance - a) / a;
|
|
1492
1492
|
if (this.config.projection === "web-mercator") {
|
|
1493
|
-
const { lng: p, lat:
|
|
1494
|
-
(function(
|
|
1495
|
-
if (v === 1) return
|
|
1496
|
-
const m = (
|
|
1497
|
-
|
|
1498
|
-
})(n, d, [p,
|
|
1499
|
-
} else this.config.projection === "globe" && function(p,
|
|
1500
|
-
|
|
1501
|
-
const m =
|
|
1493
|
+
const { lng: p, lat: y } = j(l.x, l.y);
|
|
1494
|
+
(function(g, v, f) {
|
|
1495
|
+
if (v === 1) return g;
|
|
1496
|
+
const m = (g.geometry.type === "Polygon" ? g.geometry.coordinates[0] : g.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]);
|
|
1497
|
+
g.geometry.type === "Polygon" ? g.geometry.coordinates[0] = P : g.geometry.coordinates = P;
|
|
1498
|
+
})(n, d, [p, y]);
|
|
1499
|
+
} else this.config.projection === "globe" && function(p, y, g, v = "xy") {
|
|
1500
|
+
y === 1 || (p.geometry.type === "Polygon" ? p.geometry.coordinates[0] : p.geometry.coordinates).forEach((f) => {
|
|
1501
|
+
const m = Fe(g, f), C = mt(g, f), P = kt(g, m * y, C);
|
|
1502
1502
|
v !== "x" && v !== "xy" || (f[0] = P[0]), v !== "y" && v !== "xy" || (f[1] = P[1]);
|
|
1503
1503
|
});
|
|
1504
1504
|
}(n, d, vt(n));
|
|
1505
|
-
const
|
|
1506
|
-
|
|
1507
|
-
p[0] =
|
|
1505
|
+
const h = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
|
|
1506
|
+
h.forEach((p) => {
|
|
1507
|
+
p[0] = w(p[0], this.coordinatePrecision), p[1] = w(p[1], this.coordinatePrecision);
|
|
1508
1508
|
});
|
|
1509
|
-
const
|
|
1509
|
+
const c = this.midPoints.getUpdated(h) || [], u = this.selectionPoints.getUpdated(h) || [];
|
|
1510
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;
|
|
1511
|
-
this.store.updateGeometry([{ id: e, geometry: o }, ...u, ...
|
|
1511
|
+
this.store.updateGeometry([{ id: e, geometry: o }, ...u, ...c]), this.lastDistance = a;
|
|
1512
1512
|
}
|
|
1513
1513
|
}
|
|
1514
|
-
class
|
|
1514
|
+
class Si extends W {
|
|
1515
1515
|
constructor(t, e, i, o) {
|
|
1516
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;
|
|
1517
1517
|
}
|
|
@@ -1572,33 +1572,33 @@ class Mi extends W {
|
|
|
1572
1572
|
if (!e) return null;
|
|
1573
1573
|
const { feature: i, boundingBox: o, updatedCoords: r, selectedCoordinate: n } = e, a = Ct(i);
|
|
1574
1574
|
if (!a) return null;
|
|
1575
|
-
const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l),
|
|
1576
|
-
return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: r, webMercatorCursor:
|
|
1575
|
+
const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), h = x(t.lng, t.lat);
|
|
1576
|
+
return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: r, webMercatorCursor: h, webMercatorSelected: l, webMercatorOrigin: a }), r;
|
|
1577
1577
|
}
|
|
1578
1578
|
centerFixedWebMercatorDrag(t) {
|
|
1579
1579
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1580
1580
|
if (!e) return null;
|
|
1581
1581
|
const { feature: i, boundingBox: o, updatedCoords: r, selectedCoordinate: n } = e, a = Ct(i);
|
|
1582
1582
|
if (!a) return null;
|
|
1583
|
-
const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l),
|
|
1584
|
-
return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: r, webMercatorCursor:
|
|
1583
|
+
const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), h = x(t.lng, t.lat);
|
|
1584
|
+
return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: r, webMercatorCursor: h, webMercatorSelected: l, webMercatorOrigin: a }), r;
|
|
1585
1585
|
}
|
|
1586
1586
|
scaleFixedWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: r }) {
|
|
1587
1587
|
if (!this.isValidDragWebMercator(t, e.x - o.x, e.y - o.y)) return null;
|
|
1588
|
-
let n =
|
|
1588
|
+
let n = E(e, o) / E(e, i);
|
|
1589
1589
|
return n < 0 && (n = this.minimumScale), this.performWebMercatorScale(r, e.x, e.y, n, n), r;
|
|
1590
1590
|
}
|
|
1591
1591
|
oppositeFixedWebMercatorDrag(t) {
|
|
1592
1592
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1593
1593
|
if (!e) return null;
|
|
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] },
|
|
1595
|
-
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] }, h = x(t.lng, t.lat);
|
|
1595
|
+
return this.scaleFixedWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: h, webMercatorSelected: n, webMercatorOrigin: d }), o;
|
|
1596
1596
|
}
|
|
1597
1597
|
oppositeWebMercatorDrag(t) {
|
|
1598
1598
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1599
1599
|
if (!e) return null;
|
|
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] },
|
|
1601
|
-
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] }, h = x(t.lng, t.lat);
|
|
1601
|
+
return this.scaleWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: h, webMercatorSelected: n, webMercatorOrigin: d }), o;
|
|
1602
1602
|
}
|
|
1603
1603
|
scaleWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: r }) {
|
|
1604
1604
|
const n = e.x - o.x, a = e.y - o.y;
|
|
@@ -1622,8 +1622,8 @@ class Mi extends W {
|
|
|
1622
1622
|
}
|
|
1623
1623
|
performWebMercatorScale(t, e, i, o, r) {
|
|
1624
1624
|
t.forEach((n) => {
|
|
1625
|
-
const { x: a, y: l } = x(n[0], n[1]), d = e + (a - e) * o,
|
|
1626
|
-
n[0] =
|
|
1625
|
+
const { x: a, y: l } = x(n[0], n[1]), d = e + (a - e) * o, h = i + (l - i) * r, { lng: c, lat: u } = j(d, h);
|
|
1626
|
+
n[0] = c, n[1] = u;
|
|
1627
1627
|
});
|
|
1628
1628
|
}
|
|
1629
1629
|
getBBoxWebMercator(t) {
|
|
@@ -1640,7 +1640,7 @@ class Mi extends W {
|
|
|
1640
1640
|
getIndexesWebMercator(t, e) {
|
|
1641
1641
|
let i, o = 1 / 0;
|
|
1642
1642
|
for (let r = 0; r < t.length; r++) {
|
|
1643
|
-
const n =
|
|
1643
|
+
const n = E({ x: e.x, y: e.y }, { x: t[r][0], y: t[r][1] });
|
|
1644
1644
|
n < o && (i = r, o = n);
|
|
1645
1645
|
}
|
|
1646
1646
|
if (i === void 0) throw new Error("No closest coordinate found");
|
|
@@ -1666,20 +1666,20 @@ class Mi extends W {
|
|
|
1666
1666
|
let r = null;
|
|
1667
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;
|
|
1668
1668
|
for (let d = 0; d < r.length; d++) {
|
|
1669
|
-
const
|
|
1670
|
-
if (
|
|
1669
|
+
const h = r[d];
|
|
1670
|
+
if (h[0] = w(h[0], this.coordinatePrecision), h[1] = w(h[1], this.coordinatePrecision), !St(h, this.coordinatePrecision)) return !1;
|
|
1671
1671
|
}
|
|
1672
1672
|
const n = this.midPoints.getUpdated(r) || [], a = this.selectionPoints.getUpdated(r) || [], l = { type: o.geometry.type, coordinates: o.geometry.type === "Polygon" ? [r] : r };
|
|
1673
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));
|
|
1674
1674
|
}
|
|
1675
1675
|
}
|
|
1676
|
-
const
|
|
1677
|
-
class
|
|
1676
|
+
const xi = { deselect: "Escape", delete: "Delete", rotate: ["Control", "r"], scale: ["Control", "s"] }, Jt = { pointerOver: "move", dragStart: "move", dragEnd: "move", insertMidpoint: "crosshair" };
|
|
1677
|
+
class Ee extends Ue {
|
|
1678
1678
|
constructor(t) {
|
|
1679
|
-
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 = xi, this.cursors = Jt, 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);
|
|
1680
1680
|
}
|
|
1681
1681
|
updateOptions(t) {
|
|
1682
|
-
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) : Jt, (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) {
|
|
1683
1683
|
this.flags = b({}, this.flags, t.flags), this.validations = {};
|
|
1684
1684
|
for (const e in this.flags) {
|
|
1685
1685
|
const i = this.flags[e].feature;
|
|
@@ -1695,7 +1695,7 @@ class _e extends Ke {
|
|
|
1695
1695
|
this._state = "selecting";
|
|
1696
1696
|
}
|
|
1697
1697
|
registerBehaviors(t) {
|
|
1698
|
-
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 fi(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new yi(t), this.midPoints = new gi(t, this.selectionPoints), this.rotateFeature = new Ci(t, this.selectionPoints, this.midPoints), this.scaleFeature = new Pi(t, this.selectionPoints, this.midPoints), this.dragFeature = new mi(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints), this.dragCoordinate = new vi(t, this.pixelDistance, this.selectionPoints, this.midPoints), this.dragCoordinateResizeFeature = new Si(t, this.pixelDistance, this.selectionPoints, this.midPoints);
|
|
1699
1699
|
}
|
|
1700
1700
|
deselectFeature() {
|
|
1701
1701
|
this.deselect();
|
|
@@ -1710,18 +1710,18 @@ class _e extends Ke {
|
|
|
1710
1710
|
onRightClick(t) {
|
|
1711
1711
|
if (!this.selectionPoints.ids.length) return;
|
|
1712
1712
|
let e, i = 1 / 0;
|
|
1713
|
-
if (this.selectionPoints.ids.forEach((
|
|
1714
|
-
const u = this.store.getGeometryCopy(
|
|
1715
|
-
p < this.pointerDistance && p < i && (i = p, e = this.store.getPropertiesCopy(
|
|
1713
|
+
if (this.selectionPoints.ids.forEach((c) => {
|
|
1714
|
+
const u = this.store.getGeometryCopy(c), p = this.pixelDistance.measure(t, u.coordinates);
|
|
1715
|
+
p < this.pointerDistance && p < i && (i = p, e = this.store.getPropertiesCopy(c));
|
|
1716
1716
|
}), !e) return;
|
|
1717
1717
|
const o = e.selectionPointFeatureId, r = e.index, n = this.store.getPropertiesCopy(o), a = this.flags[n.mode], l = this.validations[n.mode];
|
|
1718
1718
|
if (!(a && a.feature && a.feature.coordinates && a.feature.coordinates.deletable)) return;
|
|
1719
1719
|
const d = this.store.getGeometryCopy(o);
|
|
1720
|
-
let
|
|
1720
|
+
let h;
|
|
1721
1721
|
if (d.type === "Polygon") {
|
|
1722
|
-
if (
|
|
1723
|
-
} else if (d.type === "LineString" && (
|
|
1724
|
-
|
|
1722
|
+
if (h = d.coordinates[0], h.length <= 4) return;
|
|
1723
|
+
} else if (d.type === "LineString" && (h = d.coordinates, h.length <= 2)) return;
|
|
1724
|
+
h && (d.type !== "Polygon" || r !== 0 && r !== h.length - 1 ? h.splice(r, 1) : (h.shift(), h.pop(), h.push([h[0][0], h[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(h, d.type, o), a && a.feature && a.feature.coordinates && a.feature.coordinates.midpoints && this.midPoints.create(h, o, this.coordinatePrecision)));
|
|
1725
1725
|
}
|
|
1726
1726
|
select(t, e = !0) {
|
|
1727
1727
|
if (this.selected[0] === t) return;
|
|
@@ -1839,7 +1839,7 @@ class _e extends Ke {
|
|
|
1839
1839
|
return e;
|
|
1840
1840
|
}
|
|
1841
1841
|
}
|
|
1842
|
-
class
|
|
1842
|
+
class Ii extends N {
|
|
1843
1843
|
constructor(...t) {
|
|
1844
1844
|
super(...t), this.type = $.Static, this.mode = "static";
|
|
1845
1845
|
}
|
|
@@ -1867,11 +1867,11 @@ class Fi extends N {
|
|
|
1867
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 });
|
|
1868
1868
|
}
|
|
1869
1869
|
}
|
|
1870
|
-
function
|
|
1870
|
+
function Oe(s, t, e, i, o) {
|
|
1871
1871
|
for (; i > e; ) {
|
|
1872
1872
|
if (i - e > 600) {
|
|
1873
|
-
const l = i - e + 1, d = t - e + 1,
|
|
1874
|
-
|
|
1873
|
+
const l = i - e + 1, d = t - e + 1, h = Math.log(l), c = 0.5 * Math.exp(2 * h / 3), u = 0.5 * Math.sqrt(h * c * (l - c) / l) * (d - l / 2 < 0 ? -1 : 1);
|
|
1874
|
+
Oe(s, t, Math.max(e, Math.floor(t - d * c / l + u)), Math.min(i, Math.floor(t + (l - d) * c / l + u)), o);
|
|
1875
1875
|
}
|
|
1876
1876
|
const r = s[t];
|
|
1877
1877
|
let n = e, a = i;
|
|
@@ -1900,10 +1900,10 @@ function it(s, t, e, i, o) {
|
|
|
1900
1900
|
function ot(s, t) {
|
|
1901
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;
|
|
1902
1902
|
}
|
|
1903
|
-
function
|
|
1903
|
+
function bi(s, t) {
|
|
1904
1904
|
return s.minX - t.minX;
|
|
1905
1905
|
}
|
|
1906
|
-
function
|
|
1906
|
+
function Mi(s, t) {
|
|
1907
1907
|
return s.minY - t.minY;
|
|
1908
1908
|
}
|
|
1909
1909
|
function wt(s) {
|
|
@@ -1912,7 +1912,7 @@ function wt(s) {
|
|
|
1912
1912
|
function ut(s) {
|
|
1913
1913
|
return s.maxX - s.minX + (s.maxY - s.minY);
|
|
1914
1914
|
}
|
|
1915
|
-
function
|
|
1915
|
+
function wi(s, t) {
|
|
1916
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);
|
|
1917
1917
|
return Math.max(0, o - e) * Math.max(0, r - i);
|
|
1918
1918
|
}
|
|
@@ -1925,15 +1925,15 @@ function pt(s, t) {
|
|
|
1925
1925
|
function J(s) {
|
|
1926
1926
|
return { children: s, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
|
|
1927
1927
|
}
|
|
1928
|
-
function
|
|
1928
|
+
function Zt(s, t, e, i, o) {
|
|
1929
1929
|
const r = [t, e];
|
|
1930
1930
|
for (; r.length; ) {
|
|
1931
1931
|
if ((e = r.pop()) - (t = r.pop()) <= i) continue;
|
|
1932
1932
|
const n = t + Math.ceil((e - t) / i / 2) * i;
|
|
1933
|
-
|
|
1933
|
+
Oe(s, n, t, e, o), r.push(t, n, n, e);
|
|
1934
1934
|
}
|
|
1935
1935
|
}
|
|
1936
|
-
class
|
|
1936
|
+
class Fi {
|
|
1937
1937
|
constructor(t) {
|
|
1938
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();
|
|
1939
1939
|
}
|
|
@@ -2022,12 +2022,12 @@ class Li {
|
|
|
2022
2022
|
if (r <= a) return n = J(t.slice(e, i + 1)), H(n, this.toBBox), n;
|
|
2023
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;
|
|
2024
2024
|
const l = Math.ceil(r / a), d = l * Math.ceil(Math.sqrt(a));
|
|
2025
|
-
|
|
2026
|
-
for (let
|
|
2027
|
-
const
|
|
2028
|
-
|
|
2029
|
-
for (let u =
|
|
2030
|
-
const p = Math.min(u + l - 1,
|
|
2025
|
+
Zt(t, e, i, d, this.compareMinX);
|
|
2026
|
+
for (let h = e; h <= i; h += d) {
|
|
2027
|
+
const c = Math.min(h + d - 1, i);
|
|
2028
|
+
Zt(t, h, c, l, this.compareMinY);
|
|
2029
|
+
for (let u = h; u <= c; u += l) {
|
|
2030
|
+
const p = Math.min(u + l - 1, c);
|
|
2031
2031
|
n.children.push(this._build(t, u, p, o - 1));
|
|
2032
2032
|
}
|
|
2033
2033
|
}
|
|
@@ -2036,9 +2036,9 @@ class Li {
|
|
|
2036
2036
|
_chooseSubtree(t, e, i, o) {
|
|
2037
2037
|
for (; o.push(e), !e.leaf && o.length - 1 !== i; ) {
|
|
2038
2038
|
let a, l = 1 / 0, d = 1 / 0;
|
|
2039
|
-
for (let
|
|
2040
|
-
const
|
|
2041
|
-
p < d ? (d = p, l = u < l ? u : l, a =
|
|
2039
|
+
for (let h = 0; h < e.children.length; h++) {
|
|
2040
|
+
const c = e.children[h], u = wt(c), p = (r = t, n = c, (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 = c) : p === d && u < l && (l = u, a = c);
|
|
2042
2042
|
}
|
|
2043
2043
|
e = a || e.children[0];
|
|
2044
2044
|
}
|
|
@@ -2062,13 +2062,13 @@ class Li {
|
|
|
2062
2062
|
_chooseSplitIndex(t, e, i) {
|
|
2063
2063
|
let o, r = 1 / 0, n = 1 / 0;
|
|
2064
2064
|
for (let a = e; a <= i - e; a++) {
|
|
2065
|
-
const l = it(t, 0, a, this.toBBox), d = it(t, a, i, this.toBBox),
|
|
2066
|
-
|
|
2065
|
+
const l = it(t, 0, a, this.toBBox), d = it(t, a, i, this.toBBox), h = wi(l, d), c = wt(l) + wt(d);
|
|
2066
|
+
h < r ? (r = h, o = a, n = c < n ? c : n) : h === r && c < n && (n = c, o = a);
|
|
2067
2067
|
}
|
|
2068
2068
|
return o || i - e;
|
|
2069
2069
|
}
|
|
2070
2070
|
_chooseSplitAxis(t, e, i) {
|
|
2071
|
-
const o = t.leaf ? this.compareMinX :
|
|
2071
|
+
const o = t.leaf ? this.compareMinX : bi, r = t.leaf ? this.compareMinY : Mi;
|
|
2072
2072
|
this._allDistMargin(t, e, i, o) < this._allDistMargin(t, e, i, r) && t.children.sort(o);
|
|
2073
2073
|
}
|
|
2074
2074
|
_allDistMargin(t, e, i, o) {
|
|
@@ -2076,12 +2076,12 @@ class Li {
|
|
|
2076
2076
|
const r = this.toBBox, n = it(t, 0, e, r), a = it(t, i - e, i, r);
|
|
2077
2077
|
let l = ut(n) + ut(a);
|
|
2078
2078
|
for (let d = e; d < i - e; d++) {
|
|
2079
|
-
const
|
|
2080
|
-
ot(n, t.leaf ? r(
|
|
2079
|
+
const h = t.children[d];
|
|
2080
|
+
ot(n, t.leaf ? r(h) : h), l += ut(n);
|
|
2081
2081
|
}
|
|
2082
2082
|
for (let d = i - e - 1; d >= e; d--) {
|
|
2083
|
-
const
|
|
2084
|
-
ot(a, t.leaf ? r(
|
|
2083
|
+
const h = t.children[d];
|
|
2084
|
+
ot(a, t.leaf ? r(h) : h), l += ut(a);
|
|
2085
2085
|
}
|
|
2086
2086
|
return l;
|
|
2087
2087
|
}
|
|
@@ -2092,9 +2092,9 @@ class Li {
|
|
|
2092
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);
|
|
2093
2093
|
}
|
|
2094
2094
|
}
|
|
2095
|
-
class
|
|
2095
|
+
class Ei {
|
|
2096
2096
|
constructor(t) {
|
|
2097
|
-
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 Fi(t && t.maxEntries ? t.maxEntries : 9), this.idToNode = /* @__PURE__ */ new Map(), this.nodeToId = /* @__PURE__ */ new Map();
|
|
2098
2098
|
}
|
|
2099
2099
|
setMaps(t, e) {
|
|
2100
2100
|
this.idToNode.set(t.id, e), this.nodeToId.set(e, t.id);
|
|
@@ -2145,14 +2145,14 @@ class _i {
|
|
|
2145
2145
|
return this.tree.collides(this.toBBox(t));
|
|
2146
2146
|
}
|
|
2147
2147
|
}
|
|
2148
|
-
const
|
|
2148
|
+
const Oi = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(s) {
|
|
2149
2149
|
const t = 16 * Math.random() | 0;
|
|
2150
2150
|
return (s == "x" ? t : 3 & t | 8).toString(16);
|
|
2151
2151
|
}), isValidId: (s) => typeof s == "string" && s.length === 36 };
|
|
2152
|
-
class
|
|
2152
|
+
class Di {
|
|
2153
2153
|
constructor(t) {
|
|
2154
2154
|
this.idStrategy = void 0, this.tracked = void 0, this.spatialIndex = void 0, this.store = void 0, this._onChange = () => {
|
|
2155
|
-
}, this.store = {}, this.spatialIndex = new
|
|
2155
|
+
}, this.store = {}, this.spatialIndex = new Ei(), this.tracked = !t || t.tracked !== !1, this.idStrategy = t && t.idStrategy ? t.idStrategy : Oi;
|
|
2156
2156
|
}
|
|
2157
2157
|
clone(t) {
|
|
2158
2158
|
return JSON.parse(JSON.stringify(t));
|
|
@@ -2176,10 +2176,10 @@ class ji {
|
|
|
2176
2176
|
}
|
|
2177
2177
|
if (this.tracked) {
|
|
2178
2178
|
if (n.properties.createdAt) {
|
|
2179
|
-
if (!
|
|
2179
|
+
if (!Vt(n.properties.createdAt)) return r.push({ id: n.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
|
|
2180
2180
|
} else n.properties.createdAt = +/* @__PURE__ */ new Date();
|
|
2181
2181
|
if (n.properties.updatedAt) {
|
|
2182
|
-
if (!
|
|
2182
|
+
if (!Vt(n.properties.updatedAt)) return r.push({ id: n.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
|
|
2183
2183
|
} else n.properties.updatedAt = +/* @__PURE__ */ new Date();
|
|
2184
2184
|
}
|
|
2185
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);
|
|
@@ -2249,16 +2249,16 @@ class ji {
|
|
|
2249
2249
|
return Object.keys(this.store).length;
|
|
2250
2250
|
}
|
|
2251
2251
|
}
|
|
2252
|
-
const
|
|
2253
|
-
function
|
|
2252
|
+
const _i = "Feature is not a Polygon or LineString", Li = "Feature intersects itself", ki = (s) => s.geometry.type !== "Polygon" && s.geometry.type !== "LineString" ? { valid: !1, reason: _i } : _t(s) ? { valid: !1, reason: Li } : { valid: !0 };
|
|
2253
|
+
function Qt(s, t, e) {
|
|
2254
2254
|
const i = T(s, t);
|
|
2255
2255
|
let o = T(t, e) - i;
|
|
2256
2256
|
return o < 0 && (o += 360), 180 - Math.abs(o - 90 - 90);
|
|
2257
2257
|
}
|
|
2258
|
-
const
|
|
2259
|
-
class
|
|
2258
|
+
const ji = { cancel: "Escape", finish: "Enter" }, Wi = { start: "crosshair", close: "pointer" };
|
|
2259
|
+
class De extends N {
|
|
2260
2260
|
constructor(t) {
|
|
2261
|
-
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 = ji, this.cursors = Wi, this.mouseMove = !1, this.updateOptions(t);
|
|
2262
2262
|
}
|
|
2263
2263
|
updateOptions(t) {
|
|
2264
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));
|
|
@@ -2282,10 +2282,10 @@ class je extends N {
|
|
|
2282
2282
|
const o = 1 / Math.pow(10, this.coordinatePrecision - 1), r = Math.max(1e-6, o);
|
|
2283
2283
|
i = [e[0], [t.lng, t.lat], [t.lng, t.lat - r], e[0]];
|
|
2284
2284
|
} else if (this.currentCoordinate === 2) {
|
|
2285
|
-
const o = e[0], r = e[1], n =
|
|
2286
|
-
const D = (
|
|
2285
|
+
const o = e[0], r = e[1], n = be(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]), h = x(t.lng, t.lat), c = E(h, a) < E(h, d), u = Qt(a, l, h), p = c ? 90 - u : Qt(a, l, h) - 90, y = E(l, h), g = Math.cos(O(p)) * y, v = T(a, d) + (function(S, M, F) {
|
|
2286
|
+
const D = (F.x - M.x) * (S.y - M.y) - (F.y - M.y) * (S.x - M.x);
|
|
2287
2287
|
return D > 1e-10 ? "left" : D < -1e-10 ? "right" : "left";
|
|
2288
|
-
}(a, d,
|
|
2288
|
+
}(a, d, h) === "right" ? -90 : 90), f = at(a, g, v), m = at(d, g, v), C = j(f.x, f.y), P = j(m.x, m.y);
|
|
2289
2289
|
i = [e[0], e[1], [P.lng, P.lat], [C.lng, C.lat], e[0]];
|
|
2290
2290
|
}
|
|
2291
2291
|
i && this.updatePolygonGeometry(this.currentId, i, I.Provisional);
|
|
@@ -2334,13 +2334,13 @@ class je extends N {
|
|
|
2334
2334
|
return this.validateModeFeature(t, (e) => lt(e, this.coordinatePrecision));
|
|
2335
2335
|
}
|
|
2336
2336
|
}
|
|
2337
|
-
function
|
|
2337
|
+
function _e(s, t, e) {
|
|
2338
2338
|
return (t.x - s.x) * (e.y - s.y) - (t.y - s.y) * (e.x - s.x) <= 0;
|
|
2339
2339
|
}
|
|
2340
|
-
const
|
|
2341
|
-
class
|
|
2340
|
+
const Bi = { cancel: "Escape", finish: "Enter" }, Ni = { start: "crosshair", close: "pointer" };
|
|
2341
|
+
class Le extends N {
|
|
2342
2342
|
constructor(t) {
|
|
2343
|
-
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 = Bi, this.direction = void 0, this.arcPoints = 64, this.cursors = Ni, this.mouseMove = !1, this.updateOptions(t);
|
|
2344
2344
|
}
|
|
2345
2345
|
updateOptions(t) {
|
|
2346
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);
|
|
@@ -2368,19 +2368,19 @@ class Be extends N {
|
|
|
2368
2368
|
} else if (this.currentCoordinate === 2) {
|
|
2369
2369
|
const o = e[0], r = e[1], n = [t.lng, t.lat], a = x(o[0], o[1]), l = x(r[0], r[1]), d = x(n[0], n[1]);
|
|
2370
2370
|
if (this.direction === void 0) {
|
|
2371
|
-
const C =
|
|
2371
|
+
const C = _e(a, l, d);
|
|
2372
2372
|
this.direction = C ? "clockwise" : "anticlockwise";
|
|
2373
2373
|
}
|
|
2374
|
-
const
|
|
2374
|
+
const h = E(a, l), c = T(a, l), u = T(a, d), p = this.arcPoints, y = [o], g = Y(c), v = Y(u);
|
|
2375
2375
|
let f;
|
|
2376
|
-
this.direction === "anticlockwise" ? (f = v -
|
|
2376
|
+
this.direction === "anticlockwise" ? (f = v - g, f < 0 && (f += 360)) : (f = g - v, f < 0 && (f += 360));
|
|
2377
2377
|
const m = (this.direction === "anticlockwise" ? 1 : -1) * f / p;
|
|
2378
|
-
|
|
2378
|
+
y.push(r);
|
|
2379
2379
|
for (let C = 0; C <= p; C++) {
|
|
2380
|
-
const P = at(a,
|
|
2381
|
-
|
|
2380
|
+
const P = at(a, h, g + C * m), { lng: S, lat: M } = j(P.x, P.y), F = [w(S, this.coordinatePrecision), w(M, this.coordinatePrecision)];
|
|
2381
|
+
F[0] !== y[y.length - 1][0] && F[1] !== y[y.length - 1][1] && y.push(F);
|
|
2382
2382
|
}
|
|
2383
|
-
|
|
2383
|
+
y.push(o), i = [...y];
|
|
2384
2384
|
}
|
|
2385
2385
|
i && this.updatePolygonGeometry(this.currentId, i, I.Provisional);
|
|
2386
2386
|
}
|
|
@@ -2424,10 +2424,10 @@ class Be extends N {
|
|
|
2424
2424
|
return this.validateModeFeature(t, (e) => lt(e, this.coordinatePrecision));
|
|
2425
2425
|
}
|
|
2426
2426
|
}
|
|
2427
|
-
const
|
|
2428
|
-
class
|
|
2427
|
+
const Gi = { cancel: "Escape", finish: "Enter" }, Ti = { start: "crosshair", close: "pointer" };
|
|
2428
|
+
class ke extends N {
|
|
2429
2429
|
constructor(t) {
|
|
2430
|
-
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 = Gi, this.direction = void 0, this.arcPoints = 64, this.cursors = Ti, this.mouseMove = !1, this.updateOptions(t);
|
|
2431
2431
|
}
|
|
2432
2432
|
updateOptions(t) {
|
|
2433
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);
|
|
@@ -2450,28 +2450,28 @@ class Ne extends N {
|
|
|
2450
2450
|
onMouseMove(t) {
|
|
2451
2451
|
if (this.mouseMove = !0, this.setCursor(this.cursors.start), this.currentInitialArcId !== void 0 && this.currentStartingPointId !== void 0 && this.currentCoordinate !== 0) {
|
|
2452
2452
|
if (this.currentCoordinate === 2) {
|
|
2453
|
-
const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], r = [t.lng, t.lat], n = x(o[0], o[1]), a = x(r[0], r[1]), l = x(i[0], i[1]), d =
|
|
2453
|
+
const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], r = [t.lng, t.lat], n = x(o[0], o[1]), a = x(r[0], r[1]), l = x(i[0], i[1]), d = E(l, n);
|
|
2454
2454
|
if (this.direction === void 0) {
|
|
2455
|
-
const m =
|
|
2455
|
+
const m = _e(l, n, a);
|
|
2456
2456
|
this.direction = m ? "clockwise" : "anticlockwise";
|
|
2457
2457
|
}
|
|
2458
|
-
const
|
|
2458
|
+
const h = T(l, n), c = T(l, a), u = this.arcPoints, p = [o], y = Y(h), g = Y(c);
|
|
2459
2459
|
let v;
|
|
2460
|
-
this.direction === "anticlockwise" ? (v =
|
|
2460
|
+
this.direction === "anticlockwise" ? (v = g - y, v < 0 && (v += 360)) : (v = y - g, v < 0 && (v += 360));
|
|
2461
2461
|
const f = (this.direction === "anticlockwise" ? 1 : -1) * v / u;
|
|
2462
2462
|
for (let m = 0; m <= u; m++) {
|
|
2463
|
-
const C = at(l, d,
|
|
2463
|
+
const C = at(l, d, y + m * f), { lng: P, lat: S } = j(C.x, C.y), M = [w(P, this.coordinatePrecision), w(S, this.coordinatePrecision)];
|
|
2464
2464
|
M[0] !== p[p.length - 1][0] && M[1] !== p[p.length - 1][1] && p.push(M);
|
|
2465
2465
|
}
|
|
2466
2466
|
this.updateLineStringGeometry(this.currentInitialArcId, p, I.Provisional);
|
|
2467
2467
|
} else if (this.currentCoordinate === 3) {
|
|
2468
2468
|
const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates;
|
|
2469
2469
|
if (e.length < 2 || !this.direction) return;
|
|
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]),
|
|
2471
|
-
if (this.notInSector({ normalizedCursor: f, normalizedStart:
|
|
2472
|
-
const m = this.getDeltaBearing(this.direction,
|
|
2473
|
-
for (let
|
|
2474
|
-
const D = at(d, S,
|
|
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]), h = E(d, a), c = E(d, n) < h ? a : n, u = T(d, n), p = T(d, a), y = T(d, l), g = Y(p), v = Y(y), f = Y(u);
|
|
2471
|
+
if (this.notInSector({ normalizedCursor: f, normalizedStart: g, normalizedEnd: v, direction: this.direction })) return;
|
|
2472
|
+
const m = this.getDeltaBearing(this.direction, g, v), C = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * m / C, S = E(d, c), M = [];
|
|
2473
|
+
for (let F = 0; F <= C; F++) {
|
|
2474
|
+
const D = at(d, S, g + F * P), { lng: G, lat: _ } = j(D.x, D.y), B = [w(G, this.coordinatePrecision), w(_, this.coordinatePrecision)];
|
|
2475
2475
|
B[0] !== e[e.length - 1][0] && B[1] !== e[e.length - 1][1] && M.unshift(B);
|
|
2476
2476
|
}
|
|
2477
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 } }]);
|
|
@@ -2528,51 +2528,150 @@ class Ne extends N {
|
|
|
2528
2528
|
return o === "clockwise" ? e <= i ? t >= e && t <= i : t >= e || t <= i : e >= i ? t <= e && t >= i : t <= e || t >= i;
|
|
2529
2529
|
}
|
|
2530
2530
|
}
|
|
2531
|
-
class
|
|
2531
|
+
class q {
|
|
2532
|
+
constructor({ name: t, callback: e, unregister: i, register: o }) {
|
|
2533
|
+
this.name = void 0, this.callback = void 0, this.registered = !1, this.register = void 0, this.unregister = void 0, this.name = t, this.register = () => {
|
|
2534
|
+
this.registered || (this.registered = !0, o(e));
|
|
2535
|
+
}, this.unregister = () => {
|
|
2536
|
+
this.register && (this.registered = !1, i(e));
|
|
2537
|
+
}, this.callback = e;
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
var Ai = { __proto__: null, TerraDrawBaseAdapter: class {
|
|
2541
|
+
constructor(s) {
|
|
2542
|
+
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;
|
|
2543
|
+
}
|
|
2544
|
+
getButton(s) {
|
|
2545
|
+
return s.button === -1 ? "neither" : s.button === 0 ? "left" : s.button === 1 ? "middle" : s.button === 2 ? "right" : "neither";
|
|
2546
|
+
}
|
|
2547
|
+
getMapElementXYPosition(s) {
|
|
2548
|
+
const t = this.getMapEventElement(), { left: e, top: i } = t.getBoundingClientRect();
|
|
2549
|
+
return { containerX: s.clientX - e, containerY: s.clientY - i };
|
|
2550
|
+
}
|
|
2551
|
+
getDrawEventFromEvent(s) {
|
|
2552
|
+
const t = this.getLngLatFromEvent(s);
|
|
2553
|
+
if (!t) return null;
|
|
2554
|
+
const { lng: e, lat: i } = t, { containerX: o, containerY: r } = this.getMapElementXYPosition(s), n = this.getButton(s), a = Array.from(this._heldKeys);
|
|
2555
|
+
return { lng: w(e, this._coordinatePrecision), lat: w(i, this._coordinatePrecision), containerX: o, containerY: r, button: n, heldKeys: a };
|
|
2556
|
+
}
|
|
2557
|
+
register(s) {
|
|
2558
|
+
this._currentModeCallbacks = s, this._listeners = this.getAdapterListeners(), this._listeners.forEach((t) => {
|
|
2559
|
+
t.register();
|
|
2560
|
+
});
|
|
2561
|
+
}
|
|
2562
|
+
getCoordinatePrecision() {
|
|
2563
|
+
return this._coordinatePrecision;
|
|
2564
|
+
}
|
|
2565
|
+
getAdapterListeners() {
|
|
2566
|
+
return [new q({ name: "pointerdown", callback: (s) => {
|
|
2567
|
+
if (!this._currentModeCallbacks || !s.isPrimary) return;
|
|
2568
|
+
const t = this.getDrawEventFromEvent(s);
|
|
2569
|
+
t && (this._dragState = "pre-dragging", this._lastDrawEvent = t);
|
|
2570
|
+
}, register: (s) => {
|
|
2571
|
+
this.getMapEventElement().addEventListener("pointerdown", s);
|
|
2572
|
+
}, unregister: (s) => {
|
|
2573
|
+
this.getMapEventElement().removeEventListener("pointerdown", s);
|
|
2574
|
+
} }), new q({ name: "pointermove", callback: (s) => {
|
|
2575
|
+
if (!this._currentModeCallbacks || !s.isPrimary) return;
|
|
2576
|
+
s.preventDefault();
|
|
2577
|
+
const t = this.getDrawEventFromEvent(s);
|
|
2578
|
+
if (t) if (this._dragState === "not-dragging") this._currentModeCallbacks.onMouseMove(t), this._lastDrawEvent = t;
|
|
2579
|
+
else if (this._dragState === "pre-dragging") {
|
|
2580
|
+
if (!this._lastDrawEvent) return;
|
|
2581
|
+
const e = { x: this._lastDrawEvent.containerX, y: this._lastDrawEvent.containerY }, i = { x: t.containerX, y: t.containerY }, o = this._currentModeCallbacks.getState(), r = E(e, i);
|
|
2582
|
+
let n = !1;
|
|
2583
|
+
if (n = o === "drawing" ? r < this._minPixelDragDistanceDrawing : o === "selecting" ? r < this._minPixelDragDistanceSelecting : r < this._minPixelDragDistance, n) return;
|
|
2584
|
+
this._dragState = "dragging", this._currentModeCallbacks.onDragStart(t, (a) => {
|
|
2585
|
+
this.setDraggability.bind(this)(a);
|
|
2586
|
+
});
|
|
2587
|
+
} else this._dragState === "dragging" && this._currentModeCallbacks.onDrag(t, (e) => {
|
|
2588
|
+
this.setDraggability.bind(this)(e);
|
|
2589
|
+
});
|
|
2590
|
+
}, register: (s) => {
|
|
2591
|
+
this.getMapEventElement().addEventListener("pointermove", s);
|
|
2592
|
+
}, unregister: (s) => {
|
|
2593
|
+
this.getMapEventElement().removeEventListener("pointermove", s);
|
|
2594
|
+
} }), new q({ name: "contextmenu", callback: (s) => {
|
|
2595
|
+
this._currentModeCallbacks && s.preventDefault();
|
|
2596
|
+
}, register: (s) => {
|
|
2597
|
+
this.getMapEventElement().addEventListener("contextmenu", s);
|
|
2598
|
+
}, unregister: (s) => {
|
|
2599
|
+
this.getMapEventElement().removeEventListener("contextmenu", s);
|
|
2600
|
+
} }), new q({ name: "pointerup", callback: (s) => {
|
|
2601
|
+
if (!this._currentModeCallbacks || s.target !== this.getMapEventElement() || !s.isPrimary) return;
|
|
2602
|
+
const t = this.getDrawEventFromEvent(s);
|
|
2603
|
+
t && (this._dragState === "dragging" ? this._currentModeCallbacks.onDragEnd(t, (e) => {
|
|
2604
|
+
this.setDraggability.bind(this)(e);
|
|
2605
|
+
}) : this._dragState !== "not-dragging" && this._dragState !== "pre-dragging" || this._currentModeCallbacks.onClick(t), this._dragState = "not-dragging", this.setDraggability(!0));
|
|
2606
|
+
}, register: (s) => {
|
|
2607
|
+
this.getMapEventElement().addEventListener("pointerup", s);
|
|
2608
|
+
}, unregister: (s) => {
|
|
2609
|
+
this.getMapEventElement().removeEventListener("pointerup", s);
|
|
2610
|
+
} }), new q({ name: "keyup", callback: (s) => {
|
|
2611
|
+
this._currentModeCallbacks && (this._heldKeys.delete(s.key), this._currentModeCallbacks.onKeyUp({ key: s.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => s.preventDefault() }));
|
|
2612
|
+
}, register: (s) => {
|
|
2613
|
+
this.getMapEventElement().addEventListener("keyup", s);
|
|
2614
|
+
}, unregister: (s) => {
|
|
2615
|
+
this.getMapEventElement().removeEventListener("keyup", s);
|
|
2616
|
+
} }), new q({ name: "keydown", callback: (s) => {
|
|
2617
|
+
this._currentModeCallbacks && (this._heldKeys.add(s.key), this._currentModeCallbacks.onKeyDown({ key: s.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => s.preventDefault() }));
|
|
2618
|
+
}, register: (s) => {
|
|
2619
|
+
this.getMapEventElement().addEventListener("keydown", s);
|
|
2620
|
+
}, unregister: (s) => {
|
|
2621
|
+
this.getMapEventElement().removeEventListener("keydown", s);
|
|
2622
|
+
} })];
|
|
2623
|
+
}
|
|
2624
|
+
unregister() {
|
|
2625
|
+
this._listeners.forEach((s) => {
|
|
2626
|
+
s.unregister();
|
|
2627
|
+
}), this.clear();
|
|
2628
|
+
}
|
|
2629
|
+
} };
|
|
2630
|
+
class Vi {
|
|
2532
2631
|
constructor(t) {
|
|
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
|
|
2534
|
-
const e = /* @__PURE__ */ new Set(), i = t.modes.reduce((
|
|
2535
|
-
if (e.has(
|
|
2536
|
-
return e.add(
|
|
2632
|
+
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 Ii();
|
|
2633
|
+
const e = /* @__PURE__ */ new Set(), i = t.modes.reduce((h, c) => {
|
|
2634
|
+
if (e.has(c.mode)) throw new Error(`There is already a ${c.mode} mode provided`);
|
|
2635
|
+
return e.add(c.mode), h[c.mode] = c, h;
|
|
2537
2636
|
}, {}), o = Object.keys(i);
|
|
2538
2637
|
if (o.length === 0) throw new Error("No modes provided");
|
|
2539
|
-
o.forEach((
|
|
2540
|
-
if (i[
|
|
2638
|
+
o.forEach((h) => {
|
|
2639
|
+
if (i[h].type === $.Select) {
|
|
2541
2640
|
if (this._instanceSelectMode) throw new Error("only one type of select mode can be provided");
|
|
2542
|
-
this._instanceSelectMode =
|
|
2641
|
+
this._instanceSelectMode = h;
|
|
2543
2642
|
}
|
|
2544
|
-
}), this._modes = b({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new
|
|
2545
|
-
const r = (
|
|
2546
|
-
const
|
|
2547
|
-
return { changed:
|
|
2548
|
-
}, n = (
|
|
2643
|
+
}), this._modes = b({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new Di({ tracked: !!t.tracked, idStrategy: t.idStrategy ? t.idStrategy : void 0 });
|
|
2644
|
+
const r = (h) => {
|
|
2645
|
+
const c = [], u = this._store.copyAll().filter((p) => !h.includes(p.id) || (c.push(p), !1));
|
|
2646
|
+
return { changed: c, unchanged: u };
|
|
2647
|
+
}, n = (h, c) => {
|
|
2549
2648
|
this._enabled && this._eventListeners.finish.forEach((u) => {
|
|
2550
|
-
u(
|
|
2649
|
+
u(h, c);
|
|
2551
2650
|
});
|
|
2552
|
-
}, a = (
|
|
2651
|
+
}, a = (h, c) => {
|
|
2553
2652
|
if (!this._enabled) return;
|
|
2554
|
-
this._eventListeners.change.forEach((
|
|
2555
|
-
|
|
2653
|
+
this._eventListeners.change.forEach((y) => {
|
|
2654
|
+
y(h, c);
|
|
2556
2655
|
});
|
|
2557
|
-
const { changed: u, unchanged: p } = r(
|
|
2558
|
-
|
|
2559
|
-
}, l = (
|
|
2656
|
+
const { changed: u, unchanged: p } = r(h);
|
|
2657
|
+
c === "create" ? this._adapter.render({ created: u, deletedIds: [], unchanged: p, updated: [] }, this.getModeStyles()) : c === "update" ? this._adapter.render({ created: [], deletedIds: [], unchanged: p, updated: u }, this.getModeStyles()) : c === "delete" ? this._adapter.render({ created: [], deletedIds: h, unchanged: p, updated: [] }, this.getModeStyles()) : c === "styling" && this._adapter.render({ created: [], deletedIds: [], unchanged: p, updated: [] }, this.getModeStyles());
|
|
2658
|
+
}, l = (h) => {
|
|
2560
2659
|
if (!this._enabled) return;
|
|
2561
2660
|
this._eventListeners.select.forEach((p) => {
|
|
2562
|
-
p(
|
|
2661
|
+
p(h);
|
|
2563
2662
|
});
|
|
2564
|
-
const { changed:
|
|
2565
|
-
this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated:
|
|
2566
|
-
}, d = (
|
|
2663
|
+
const { changed: c, unchanged: u } = r([h]);
|
|
2664
|
+
this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: c }, this.getModeStyles());
|
|
2665
|
+
}, d = (h) => {
|
|
2567
2666
|
if (!this._enabled) return;
|
|
2568
2667
|
this._eventListeners.deselect.forEach((p) => {
|
|
2569
2668
|
p();
|
|
2570
2669
|
});
|
|
2571
|
-
const { changed:
|
|
2572
|
-
|
|
2670
|
+
const { changed: c, unchanged: u } = r([h]);
|
|
2671
|
+
c && this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: c }, this.getModeStyles());
|
|
2573
2672
|
};
|
|
2574
|
-
Object.keys(this._modes).forEach((
|
|
2575
|
-
this._modes[
|
|
2673
|
+
Object.keys(this._modes).forEach((h) => {
|
|
2674
|
+
this._modes[h].register({ mode: h, 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() });
|
|
2576
2675
|
});
|
|
2577
2676
|
}
|
|
2578
2677
|
checkEnabled() {
|
|
@@ -2585,22 +2684,22 @@ class Ri {
|
|
|
2585
2684
|
}), t;
|
|
2586
2685
|
}
|
|
2587
2686
|
featuresAtLocation({ lng: t, lat: e }, i) {
|
|
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 =
|
|
2589
|
-
return this._store.search(d).filter((
|
|
2590
|
-
if (r && (
|
|
2591
|
-
if (
|
|
2592
|
-
const
|
|
2593
|
-
return
|
|
2687
|
+
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 = fe({ unproject: n, point: l, pointerDistance: o });
|
|
2688
|
+
return this._store.search(d).filter((h) => {
|
|
2689
|
+
if (r && (h.properties[U.MID_POINT] || h.properties[U.SELECTION_POINT])) return !1;
|
|
2690
|
+
if (h.geometry.type === "Point") {
|
|
2691
|
+
const c = h.geometry.coordinates, u = a(c[0], c[1]);
|
|
2692
|
+
return E(l, u) < o;
|
|
2594
2693
|
}
|
|
2595
|
-
if (
|
|
2596
|
-
const
|
|
2597
|
-
for (let u = 0; u <
|
|
2598
|
-
const p =
|
|
2599
|
-
if (
|
|
2694
|
+
if (h.geometry.type === "LineString") {
|
|
2695
|
+
const c = h.geometry.coordinates;
|
|
2696
|
+
for (let u = 0; u < c.length - 1; u++) {
|
|
2697
|
+
const p = c[u], y = c[u + 1];
|
|
2698
|
+
if (we(l, a(p[0], p[1]), a(y[0], y[1])) < o) return !0;
|
|
2600
2699
|
}
|
|
2601
2700
|
return !1;
|
|
2602
2701
|
}
|
|
2603
|
-
return !!
|
|
2702
|
+
return !!Me([t, e], h.geometry.coordinates) || void 0;
|
|
2604
2703
|
});
|
|
2605
2704
|
}
|
|
2606
2705
|
getSelectMode() {
|
|
@@ -2708,119 +2807,9 @@ class Ri {
|
|
|
2708
2807
|
i.includes(e) && i.splice(i.indexOf(e), 1);
|
|
2709
2808
|
}
|
|
2710
2809
|
}
|
|
2711
|
-
|
|
2712
|
-
function oe(s, t = 9) {
|
|
2713
|
-
const e = Math.pow(10, t);
|
|
2714
|
-
return Math.round(s * e) / e;
|
|
2715
|
-
}
|
|
2716
|
-
(Et = ee || (ee = {})).Commit = "commit", Et.Provisional = "provisional", Et.Finish = "finish", function(s) {
|
|
2717
|
-
s.Drawing = "drawing", s.Select = "select", s.Static = "static", s.Render = "render";
|
|
2718
|
-
}(ie || (ie = {}));
|
|
2719
|
-
class q {
|
|
2720
|
-
constructor({ name: t, callback: e, unregister: i, register: o }) {
|
|
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 = () => {
|
|
2722
|
-
this.registered || (this.registered = !0, o(e));
|
|
2723
|
-
}, this.unregister = () => {
|
|
2724
|
-
this.register && (this.registered = !1, i(e));
|
|
2725
|
-
}, this.callback = e;
|
|
2726
|
-
}
|
|
2727
|
-
}
|
|
2728
|
-
var Xi = class {
|
|
2729
|
-
constructor(s) {
|
|
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;
|
|
2731
|
-
}
|
|
2732
|
-
getButton(s) {
|
|
2733
|
-
return s.button === -1 ? "neither" : s.button === 0 ? "left" : s.button === 1 ? "middle" : s.button === 2 ? "right" : "neither";
|
|
2734
|
-
}
|
|
2735
|
-
getMapElementXYPosition(s) {
|
|
2736
|
-
const t = this.getMapEventElement(), { left: e, top: i } = t.getBoundingClientRect();
|
|
2737
|
-
return { containerX: s.clientX - e, containerY: s.clientY - i };
|
|
2738
|
-
}
|
|
2739
|
-
getDrawEventFromEvent(s) {
|
|
2740
|
-
const t = this.getLngLatFromEvent(s);
|
|
2741
|
-
if (!t) return null;
|
|
2742
|
-
const { lng: e, lat: i } = t, { containerX: o, containerY: r } = this.getMapElementXYPosition(s), n = this.getButton(s), a = Array.from(this._heldKeys);
|
|
2743
|
-
return { lng: oe(e, this._coordinatePrecision), lat: oe(i, this._coordinatePrecision), containerX: o, containerY: r, button: n, heldKeys: a };
|
|
2744
|
-
}
|
|
2745
|
-
register(s) {
|
|
2746
|
-
this._currentModeCallbacks = s, this._listeners = this.getAdapterListeners(), this._listeners.forEach((t) => {
|
|
2747
|
-
t.register();
|
|
2748
|
-
});
|
|
2749
|
-
}
|
|
2750
|
-
getCoordinatePrecision() {
|
|
2751
|
-
return this._coordinatePrecision;
|
|
2752
|
-
}
|
|
2753
|
-
getAdapterListeners() {
|
|
2754
|
-
return [new q({ name: "pointerdown", callback: (s) => {
|
|
2755
|
-
if (!this._currentModeCallbacks || !s.isPrimary) return;
|
|
2756
|
-
const t = this.getDrawEventFromEvent(s);
|
|
2757
|
-
t && (this._dragState = "pre-dragging", this._lastDrawEvent = t);
|
|
2758
|
-
}, register: (s) => {
|
|
2759
|
-
this.getMapEventElement().addEventListener("pointerdown", s);
|
|
2760
|
-
}, unregister: (s) => {
|
|
2761
|
-
this.getMapEventElement().removeEventListener("pointerdown", s);
|
|
2762
|
-
} }), new q({ name: "pointermove", callback: (s) => {
|
|
2763
|
-
if (!this._currentModeCallbacks || !s.isPrimary) return;
|
|
2764
|
-
s.preventDefault();
|
|
2765
|
-
const t = this.getDrawEventFromEvent(s);
|
|
2766
|
-
if (t) if (this._dragState === "not-dragging") this._currentModeCallbacks.onMouseMove(t), this._lastDrawEvent = t;
|
|
2767
|
-
else if (this._dragState === "pre-dragging") {
|
|
2768
|
-
if (!this._lastDrawEvent) return;
|
|
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) => {
|
|
2770
|
-
const { x: d, y: c } = a, { x: h, y: u } = l, p = h - d, g = u - c;
|
|
2771
|
-
return Math.sqrt(g * g + p * p);
|
|
2772
|
-
})(e, i);
|
|
2773
|
-
let n = !1;
|
|
2774
|
-
if (n = o === "drawing" ? r < this._minPixelDragDistanceDrawing : o === "selecting" ? r < this._minPixelDragDistanceSelecting : r < this._minPixelDragDistance, n) return;
|
|
2775
|
-
this._dragState = "dragging", this._currentModeCallbacks.onDragStart(t, (a) => {
|
|
2776
|
-
this.setDraggability.bind(this)(a);
|
|
2777
|
-
});
|
|
2778
|
-
} else this._dragState === "dragging" && this._currentModeCallbacks.onDrag(t, (e) => {
|
|
2779
|
-
this.setDraggability.bind(this)(e);
|
|
2780
|
-
});
|
|
2781
|
-
}, register: (s) => {
|
|
2782
|
-
this.getMapEventElement().addEventListener("pointermove", s);
|
|
2783
|
-
}, unregister: (s) => {
|
|
2784
|
-
this.getMapEventElement().removeEventListener("pointermove", s);
|
|
2785
|
-
} }), new q({ name: "contextmenu", callback: (s) => {
|
|
2786
|
-
this._currentModeCallbacks && s.preventDefault();
|
|
2787
|
-
}, register: (s) => {
|
|
2788
|
-
this.getMapEventElement().addEventListener("contextmenu", s);
|
|
2789
|
-
}, unregister: (s) => {
|
|
2790
|
-
this.getMapEventElement().removeEventListener("contextmenu", s);
|
|
2791
|
-
} }), new q({ name: "pointerup", callback: (s) => {
|
|
2792
|
-
if (!this._currentModeCallbacks || s.target !== this.getMapEventElement() || !s.isPrimary) return;
|
|
2793
|
-
const t = this.getDrawEventFromEvent(s);
|
|
2794
|
-
t && (this._dragState === "dragging" ? this._currentModeCallbacks.onDragEnd(t, (e) => {
|
|
2795
|
-
this.setDraggability.bind(this)(e);
|
|
2796
|
-
}) : this._dragState !== "not-dragging" && this._dragState !== "pre-dragging" || this._currentModeCallbacks.onClick(t), this._dragState = "not-dragging", this.setDraggability(!0));
|
|
2797
|
-
}, register: (s) => {
|
|
2798
|
-
this.getMapEventElement().addEventListener("pointerup", s);
|
|
2799
|
-
}, unregister: (s) => {
|
|
2800
|
-
this.getMapEventElement().removeEventListener("pointerup", s);
|
|
2801
|
-
} }), new q({ name: "keyup", callback: (s) => {
|
|
2802
|
-
this._currentModeCallbacks && (this._heldKeys.delete(s.key), this._currentModeCallbacks.onKeyUp({ key: s.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => s.preventDefault() }));
|
|
2803
|
-
}, register: (s) => {
|
|
2804
|
-
this.getMapEventElement().addEventListener("keyup", s);
|
|
2805
|
-
}, unregister: (s) => {
|
|
2806
|
-
this.getMapEventElement().removeEventListener("keyup", s);
|
|
2807
|
-
} }), new q({ name: "keydown", callback: (s) => {
|
|
2808
|
-
this._currentModeCallbacks && (this._heldKeys.add(s.key), this._currentModeCallbacks.onKeyDown({ key: s.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => s.preventDefault() }));
|
|
2809
|
-
}, register: (s) => {
|
|
2810
|
-
this.getMapEventElement().addEventListener("keydown", s);
|
|
2811
|
-
}, unregister: (s) => {
|
|
2812
|
-
this.getMapEventElement().removeEventListener("keydown", s);
|
|
2813
|
-
} })];
|
|
2814
|
-
}
|
|
2815
|
-
unregister() {
|
|
2816
|
-
this._listeners.forEach((s) => {
|
|
2817
|
-
s.unregister();
|
|
2818
|
-
}), this.clear();
|
|
2819
|
-
}
|
|
2820
|
-
};
|
|
2821
|
-
class Ki extends Xi {
|
|
2810
|
+
class Ui extends Ai.TerraDrawBaseAdapter {
|
|
2822
2811
|
constructor(t) {
|
|
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();
|
|
2812
|
+
super(t), this._initialDragPan = void 0, this._initialDragRotate = void 0, 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(), this._initialDragRotate = this._map.dragRotate.isEnabled(), this._initialDragPan = this._map.dragPan.isEnabled();
|
|
2824
2813
|
}
|
|
2825
2814
|
clearLayers() {
|
|
2826
2815
|
this._rendered && (["point", "linestring", "polygon"].forEach((t) => {
|
|
@@ -2867,7 +2856,7 @@ class Ki extends Xi {
|
|
|
2867
2856
|
return this._map.getCanvas();
|
|
2868
2857
|
}
|
|
2869
2858
|
setDraggability(t) {
|
|
2870
|
-
t ? (this._map.dragRotate.enable(), this._map.dragPan.enable()) : (this._map.dragRotate.disable(), this._map.dragPan.disable());
|
|
2859
|
+
t ? (this._initialDragRotate && this._map.dragRotate.enable(), this._initialDragPan && this._map.dragPan.enable()) : (this._initialDragRotate && this._map.dragRotate.disable(), this._initialDragPan && this._map.dragPan.disable());
|
|
2871
2860
|
}
|
|
2872
2861
|
project(t, e) {
|
|
2873
2862
|
const { x: i, y: o } = this._map.project({ lng: t, lat: e });
|
|
@@ -2888,13 +2877,13 @@ class Ki extends Xi {
|
|
|
2888
2877
|
this.updateChangedIds(t), this._nextRender && cancelAnimationFrame(this._nextRender), this._nextRender = requestAnimationFrame(() => {
|
|
2889
2878
|
const i = [...t.created, ...t.updated, ...t.unchanged], o = [], r = [], n = [];
|
|
2890
2879
|
for (let a = 0; a < i.length; a++) {
|
|
2891
|
-
const l = i[a], { properties: d } = l,
|
|
2892
|
-
l.geometry.type === "Point" ? (d.pointColor =
|
|
2880
|
+
const l = i[a], { properties: d } = l, h = e[d.mode](l);
|
|
2881
|
+
l.geometry.type === "Point" ? (d.pointColor = h.pointColor, d.pointOutlineColor = h.pointOutlineColor, d.pointOutlineWidth = h.pointOutlineWidth, d.pointWidth = h.pointWidth, o.push(l)) : l.geometry.type === "LineString" ? (d.lineStringColor = h.lineStringColor, d.lineStringWidth = h.lineStringWidth, r.push(l)) : l.geometry.type === "Polygon" && (d.polygonFillColor = h.polygonFillColor, d.polygonFillOpacity = h.polygonFillOpacity, d.polygonOutlineColor = h.polygonOutlineColor, d.polygonOutlineWidth = h.polygonOutlineWidth, n.push(l));
|
|
2893
2882
|
}
|
|
2894
2883
|
if (this._rendered) {
|
|
2895
2884
|
const a = this.changedIds.deletion || this.changedIds.styling, l = a || this.changedIds.linestrings, d = a || this.changedIds.polygons;
|
|
2896
|
-
let
|
|
2897
|
-
(a || this.changedIds.points) && (
|
|
2885
|
+
let h;
|
|
2886
|
+
(a || this.changedIds.points) && (h = this._setGeoJSONLayerData("Point", o)), l && this._setGeoJSONLayerData("LineString", r), d && this._setGeoJSONLayerData("Polygon", n), h && this._map.moveLayer(h);
|
|
2898
2887
|
} else {
|
|
2899
2888
|
const a = this._addGeoJSONLayer("Point", o);
|
|
2900
2889
|
this._addGeoJSONLayer("LineString", r), this._addGeoJSONLayer("Polygon", n), this._rendered = !0, a && this._map.moveLayer(a);
|
|
@@ -2916,7 +2905,7 @@ class Ki extends Xi {
|
|
|
2916
2905
|
super.register(t), (e = this._currentModeCallbacks) != null && e.onReady && this._currentModeCallbacks.onReady();
|
|
2917
2906
|
}
|
|
2918
2907
|
}
|
|
2919
|
-
const
|
|
2908
|
+
const Eo = [
|
|
2920
2909
|
"render",
|
|
2921
2910
|
"point",
|
|
2922
2911
|
"linestring",
|
|
@@ -2931,7 +2920,7 @@ const _o = [
|
|
|
2931
2920
|
"delete-selection",
|
|
2932
2921
|
"delete",
|
|
2933
2922
|
"download"
|
|
2934
|
-
],
|
|
2923
|
+
], Ri = {
|
|
2935
2924
|
modes: [
|
|
2936
2925
|
"render",
|
|
2937
2926
|
"point",
|
|
@@ -2969,96 +2958,96 @@ const _o = [
|
|
|
2969
2958
|
open: !1,
|
|
2970
2959
|
// see styling parameters of Terra Draw at https://github.com/JamesLMilner/terra-draw/blob/main/guides/5.STYLING.md
|
|
2971
2960
|
modeOptions: {
|
|
2972
|
-
point: new
|
|
2961
|
+
point: new Se({
|
|
2973
2962
|
editable: !0,
|
|
2974
2963
|
styles: {
|
|
2975
2964
|
pointColor: "#FFFFFF",
|
|
2976
2965
|
pointWidth: 5,
|
|
2977
|
-
pointOutlineColor: "#
|
|
2966
|
+
pointOutlineColor: "#666666",
|
|
2978
2967
|
pointOutlineWidth: 1
|
|
2979
2968
|
}
|
|
2980
2969
|
}),
|
|
2981
|
-
linestring: new
|
|
2970
|
+
linestring: new Ce({
|
|
2982
2971
|
editable: !0,
|
|
2983
2972
|
styles: {
|
|
2984
|
-
lineStringColor: "#
|
|
2973
|
+
lineStringColor: "#666666",
|
|
2985
2974
|
lineStringWidth: 2,
|
|
2986
2975
|
closingPointColor: "#FFFFFF",
|
|
2987
2976
|
closingPointWidth: 3,
|
|
2988
|
-
closingPointOutlineColor: "#
|
|
2977
|
+
closingPointOutlineColor: "#666666",
|
|
2989
2978
|
closingPointOutlineWidth: 1
|
|
2990
2979
|
}
|
|
2991
2980
|
}),
|
|
2992
|
-
polygon: new
|
|
2981
|
+
polygon: new xe({
|
|
2993
2982
|
editable: !0,
|
|
2994
2983
|
styles: {
|
|
2995
2984
|
fillColor: "#EDEFF0",
|
|
2996
2985
|
fillOpacity: 0.7,
|
|
2997
|
-
outlineColor: "#
|
|
2986
|
+
outlineColor: "#666666",
|
|
2998
2987
|
outlineWidth: 2,
|
|
2999
2988
|
closingPointColor: "#FAFAFA",
|
|
3000
2989
|
closingPointWidth: 3,
|
|
3001
|
-
closingPointOutlineColor: "#
|
|
2990
|
+
closingPointOutlineColor: "#666666",
|
|
3002
2991
|
closingPointOutlineWidth: 1
|
|
3003
2992
|
}
|
|
3004
2993
|
}),
|
|
3005
|
-
rectangle: new
|
|
2994
|
+
rectangle: new Ie({
|
|
3006
2995
|
styles: {
|
|
3007
2996
|
fillColor: "#EDEFF0",
|
|
3008
2997
|
fillOpacity: 0.7,
|
|
3009
|
-
outlineColor: "#
|
|
2998
|
+
outlineColor: "#666666",
|
|
3010
2999
|
outlineWidth: 2
|
|
3011
3000
|
}
|
|
3012
3001
|
}),
|
|
3013
|
-
"angled-rectangle": new
|
|
3002
|
+
"angled-rectangle": new De({
|
|
3014
3003
|
styles: {
|
|
3015
3004
|
fillColor: "#EDEFF0",
|
|
3016
3005
|
fillOpacity: 0.7,
|
|
3017
|
-
outlineColor: "#
|
|
3006
|
+
outlineColor: "#666666",
|
|
3018
3007
|
outlineWidth: 2
|
|
3019
3008
|
}
|
|
3020
3009
|
}),
|
|
3021
|
-
circle: new
|
|
3010
|
+
circle: new ge({
|
|
3022
3011
|
styles: {
|
|
3023
3012
|
fillColor: "#EDEFF0",
|
|
3024
3013
|
fillOpacity: 0.7,
|
|
3025
|
-
outlineColor: "#
|
|
3014
|
+
outlineColor: "#666666",
|
|
3026
3015
|
outlineWidth: 2
|
|
3027
3016
|
}
|
|
3028
3017
|
}),
|
|
3029
|
-
freehand: new
|
|
3018
|
+
freehand: new ye({
|
|
3030
3019
|
styles: {
|
|
3031
3020
|
fillColor: "#EDEFF0",
|
|
3032
3021
|
fillOpacity: 0.7,
|
|
3033
|
-
outlineColor: "#
|
|
3022
|
+
outlineColor: "#666666",
|
|
3034
3023
|
outlineWidth: 2,
|
|
3035
3024
|
closingPointColor: "#FAFAFA",
|
|
3036
3025
|
closingPointWidth: 3,
|
|
3037
|
-
closingPointOutlineColor: "#
|
|
3026
|
+
closingPointOutlineColor: "#666666",
|
|
3038
3027
|
closingPointOutlineWidth: 1
|
|
3039
3028
|
}
|
|
3040
3029
|
}),
|
|
3041
|
-
sensor: new
|
|
3030
|
+
sensor: new ke({
|
|
3042
3031
|
styles: {
|
|
3043
3032
|
fillColor: "#EDEFF0",
|
|
3044
3033
|
fillOpacity: 0.7,
|
|
3045
|
-
outlineColor: "#
|
|
3034
|
+
outlineColor: "#666666",
|
|
3046
3035
|
outlineWidth: 2,
|
|
3047
3036
|
centerPointColor: "#FAFAFA",
|
|
3048
3037
|
centerPointWidth: 3,
|
|
3049
|
-
centerPointOutlineColor: "#
|
|
3038
|
+
centerPointOutlineColor: "#666666",
|
|
3050
3039
|
centerPointOutlineWidth: 1
|
|
3051
3040
|
}
|
|
3052
3041
|
}),
|
|
3053
|
-
sector: new
|
|
3042
|
+
sector: new Le({
|
|
3054
3043
|
styles: {
|
|
3055
3044
|
fillColor: "#EDEFF0",
|
|
3056
3045
|
fillOpacity: 0.7,
|
|
3057
|
-
outlineColor: "#
|
|
3046
|
+
outlineColor: "#666666",
|
|
3058
3047
|
outlineWidth: 2
|
|
3059
3048
|
}
|
|
3060
3049
|
}),
|
|
3061
|
-
select: new
|
|
3050
|
+
select: new Ee({
|
|
3062
3051
|
flags: {
|
|
3063
3052
|
point: {
|
|
3064
3053
|
feature: {
|
|
@@ -3312,33 +3301,33 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3312
3301
|
distancePrecision: 2,
|
|
3313
3302
|
areaUnit: "metric",
|
|
3314
3303
|
areaPrecision: 2
|
|
3315
|
-
},
|
|
3304
|
+
}, zi = () => ({
|
|
3316
3305
|
render: new et({
|
|
3317
3306
|
modeName: "render",
|
|
3318
3307
|
styles: {}
|
|
3319
3308
|
}),
|
|
3320
|
-
point: new
|
|
3309
|
+
point: new Se({
|
|
3321
3310
|
editable: !0
|
|
3322
3311
|
}),
|
|
3323
|
-
linestring: new
|
|
3312
|
+
linestring: new Ce({
|
|
3324
3313
|
editable: !0
|
|
3325
3314
|
}),
|
|
3326
|
-
polygon: new
|
|
3315
|
+
polygon: new xe({
|
|
3327
3316
|
editable: !0,
|
|
3328
3317
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3329
3318
|
// @ts-ignore
|
|
3330
3319
|
validation: (t, e) => {
|
|
3331
3320
|
const i = e.updateType;
|
|
3332
|
-
return i === "finish" || i === "commit" ?
|
|
3321
|
+
return i === "finish" || i === "commit" ? ki(t) : { valid: !0 };
|
|
3333
3322
|
}
|
|
3334
3323
|
}),
|
|
3335
|
-
rectangle: new
|
|
3336
|
-
"angled-rectangle": new
|
|
3337
|
-
circle: new
|
|
3338
|
-
freehand: new
|
|
3339
|
-
sensor: new
|
|
3340
|
-
sector: new
|
|
3341
|
-
select: new
|
|
3324
|
+
rectangle: new Ie(),
|
|
3325
|
+
"angled-rectangle": new De(),
|
|
3326
|
+
circle: new ge(),
|
|
3327
|
+
freehand: new ye(),
|
|
3328
|
+
sensor: new ke(),
|
|
3329
|
+
sector: new Le(),
|
|
3330
|
+
select: new Ee({
|
|
3342
3331
|
flags: {
|
|
3343
3332
|
point: {
|
|
3344
3333
|
feature: {
|
|
@@ -3452,43 +3441,43 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3452
3441
|
styles: {}
|
|
3453
3442
|
})
|
|
3454
3443
|
});
|
|
3455
|
-
var
|
|
3456
|
-
centimeters:
|
|
3457
|
-
centimetres:
|
|
3444
|
+
var L = 63710088e-1, Xi = {
|
|
3445
|
+
centimeters: L * 100,
|
|
3446
|
+
centimetres: L * 100,
|
|
3458
3447
|
degrees: 360 / (2 * Math.PI),
|
|
3459
|
-
feet:
|
|
3460
|
-
inches:
|
|
3461
|
-
kilometers:
|
|
3462
|
-
kilometres:
|
|
3463
|
-
meters:
|
|
3464
|
-
metres:
|
|
3465
|
-
miles:
|
|
3466
|
-
millimeters:
|
|
3467
|
-
millimetres:
|
|
3468
|
-
nauticalmiles:
|
|
3448
|
+
feet: L * 3.28084,
|
|
3449
|
+
inches: L * 39.37,
|
|
3450
|
+
kilometers: L / 1e3,
|
|
3451
|
+
kilometres: L / 1e3,
|
|
3452
|
+
meters: L,
|
|
3453
|
+
metres: L,
|
|
3454
|
+
miles: L / 1609.344,
|
|
3455
|
+
millimeters: L * 1e3,
|
|
3456
|
+
millimetres: L * 1e3,
|
|
3457
|
+
nauticalmiles: L / 1852,
|
|
3469
3458
|
radians: 1,
|
|
3470
|
-
yards:
|
|
3459
|
+
yards: L * 1.0936
|
|
3471
3460
|
};
|
|
3472
|
-
function
|
|
3461
|
+
function Ki(s, t, e = {}) {
|
|
3473
3462
|
const i = { type: "Feature" };
|
|
3474
3463
|
return (e.id === 0 || e.id) && (i.id = e.id), e.bbox && (i.bbox = e.bbox), i.properties = t || {}, i.geometry = s, i;
|
|
3475
3464
|
}
|
|
3476
|
-
function
|
|
3465
|
+
function Yi(s, t, e = {}) {
|
|
3477
3466
|
if (!s)
|
|
3478
3467
|
throw new Error("coordinates is required");
|
|
3479
3468
|
if (!Array.isArray(s))
|
|
3480
3469
|
throw new Error("coordinates must be an Array");
|
|
3481
3470
|
if (s.length < 2)
|
|
3482
3471
|
throw new Error("coordinates must be at least 2 numbers long");
|
|
3483
|
-
if (!
|
|
3472
|
+
if (!te(s[0]) || !te(s[1]))
|
|
3484
3473
|
throw new Error("coordinates must contain numbers");
|
|
3485
|
-
return
|
|
3474
|
+
return Ki({
|
|
3486
3475
|
type: "Point",
|
|
3487
3476
|
coordinates: s
|
|
3488
3477
|
}, t, e);
|
|
3489
3478
|
}
|
|
3490
|
-
function
|
|
3491
|
-
const e =
|
|
3479
|
+
function $i(s, t = "kilometers") {
|
|
3480
|
+
const e = Xi[t];
|
|
3492
3481
|
if (!e)
|
|
3493
3482
|
throw new Error(t + " units is invalid");
|
|
3494
3483
|
return s * e;
|
|
@@ -3496,60 +3485,60 @@ function Zi(s, t = "kilometers") {
|
|
|
3496
3485
|
function gt(s) {
|
|
3497
3486
|
return s % 360 * Math.PI / 180;
|
|
3498
3487
|
}
|
|
3499
|
-
function
|
|
3488
|
+
function te(s) {
|
|
3500
3489
|
return !isNaN(s) && s !== null && !Array.isArray(s);
|
|
3501
3490
|
}
|
|
3502
|
-
function
|
|
3491
|
+
function je(s, t, e) {
|
|
3503
3492
|
if (s !== null)
|
|
3504
|
-
for (var i, o, r, n, a, l, d,
|
|
3505
|
-
d =
|
|
3493
|
+
for (var i, o, r, n, a, l, d, h = 0, c = 0, u, p = s.type, y = p === "FeatureCollection", g = p === "Feature", v = y ? s.features.length : 1, f = 0; f < v; f++) {
|
|
3494
|
+
d = y ? s.features[f].geometry : g ? s.geometry : s, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
|
|
3506
3495
|
for (var m = 0; m < a; m++) {
|
|
3507
3496
|
var C = 0, P = 0;
|
|
3508
3497
|
if (n = u ? d.geometries[m] : d, n !== null) {
|
|
3509
3498
|
l = n.coordinates;
|
|
3510
3499
|
var S = n.type;
|
|
3511
|
-
switch (
|
|
3500
|
+
switch (h = S === "Polygon" || S === "MultiPolygon" ? 1 : 0, S) {
|
|
3512
3501
|
case null:
|
|
3513
3502
|
break;
|
|
3514
3503
|
case "Point":
|
|
3515
3504
|
if (t(
|
|
3516
3505
|
l,
|
|
3517
|
-
|
|
3506
|
+
c,
|
|
3518
3507
|
f,
|
|
3519
3508
|
C,
|
|
3520
3509
|
P
|
|
3521
3510
|
) === !1)
|
|
3522
3511
|
return !1;
|
|
3523
|
-
|
|
3512
|
+
c++, C++;
|
|
3524
3513
|
break;
|
|
3525
3514
|
case "LineString":
|
|
3526
3515
|
case "MultiPoint":
|
|
3527
3516
|
for (i = 0; i < l.length; i++) {
|
|
3528
3517
|
if (t(
|
|
3529
3518
|
l[i],
|
|
3530
|
-
|
|
3519
|
+
c,
|
|
3531
3520
|
f,
|
|
3532
3521
|
C,
|
|
3533
3522
|
P
|
|
3534
3523
|
) === !1)
|
|
3535
3524
|
return !1;
|
|
3536
|
-
|
|
3525
|
+
c++, S === "MultiPoint" && C++;
|
|
3537
3526
|
}
|
|
3538
3527
|
S === "LineString" && C++;
|
|
3539
3528
|
break;
|
|
3540
3529
|
case "Polygon":
|
|
3541
3530
|
case "MultiLineString":
|
|
3542
3531
|
for (i = 0; i < l.length; i++) {
|
|
3543
|
-
for (o = 0; o < l[i].length -
|
|
3532
|
+
for (o = 0; o < l[i].length - h; o++) {
|
|
3544
3533
|
if (t(
|
|
3545
3534
|
l[i][o],
|
|
3546
|
-
|
|
3535
|
+
c,
|
|
3547
3536
|
f,
|
|
3548
3537
|
C,
|
|
3549
3538
|
P
|
|
3550
3539
|
) === !1)
|
|
3551
3540
|
return !1;
|
|
3552
|
-
|
|
3541
|
+
c++;
|
|
3553
3542
|
}
|
|
3554
3543
|
S === "MultiLineString" && C++, S === "Polygon" && P++;
|
|
3555
3544
|
}
|
|
@@ -3558,16 +3547,16 @@ function Ge(s, t, e) {
|
|
|
3558
3547
|
case "MultiPolygon":
|
|
3559
3548
|
for (i = 0; i < l.length; i++) {
|
|
3560
3549
|
for (P = 0, o = 0; o < l[i].length; o++) {
|
|
3561
|
-
for (r = 0; r < l[i][o].length -
|
|
3550
|
+
for (r = 0; r < l[i][o].length - h; r++) {
|
|
3562
3551
|
if (t(
|
|
3563
3552
|
l[i][o][r],
|
|
3564
|
-
|
|
3553
|
+
c,
|
|
3565
3554
|
f,
|
|
3566
3555
|
C,
|
|
3567
3556
|
P
|
|
3568
3557
|
) === !1)
|
|
3569
3558
|
return !1;
|
|
3570
|
-
|
|
3559
|
+
c++;
|
|
3571
3560
|
}
|
|
3572
3561
|
P++;
|
|
3573
3562
|
}
|
|
@@ -3576,7 +3565,7 @@ function Ge(s, t, e) {
|
|
|
3576
3565
|
break;
|
|
3577
3566
|
case "GeometryCollection":
|
|
3578
3567
|
for (i = 0; i < n.geometries.length; i++)
|
|
3579
|
-
if (
|
|
3568
|
+
if (je(n.geometries[i], t) === !1)
|
|
3580
3569
|
return !1;
|
|
3581
3570
|
break;
|
|
3582
3571
|
default:
|
|
@@ -3586,17 +3575,17 @@ function Ge(s, t, e) {
|
|
|
3586
3575
|
}
|
|
3587
3576
|
}
|
|
3588
3577
|
}
|
|
3589
|
-
function
|
|
3590
|
-
var e, i, o, r, n, a, l, d,
|
|
3591
|
-
for (e = 0; e <
|
|
3592
|
-
for (a = p ? s.features[e].geometry :
|
|
3578
|
+
function Hi(s, t) {
|
|
3579
|
+
var e, i, o, r, n, a, l, d, h, c, u = 0, p = s.type === "FeatureCollection", y = s.type === "Feature", g = p ? s.features.length : 1;
|
|
3580
|
+
for (e = 0; e < g; e++) {
|
|
3581
|
+
for (a = p ? s.features[e].geometry : y ? s.geometry : s, d = p ? s.features[e].properties : y ? s.properties : {}, h = p ? s.features[e].bbox : y ? s.bbox : void 0, c = p ? s.features[e].id : y ? s.id : void 0, l = a ? a.type === "GeometryCollection" : !1, n = l ? a.geometries.length : 1, o = 0; o < n; o++) {
|
|
3593
3582
|
if (r = l ? a.geometries[o] : a, r === null) {
|
|
3594
3583
|
if (t(
|
|
3595
3584
|
null,
|
|
3596
3585
|
u,
|
|
3597
3586
|
d,
|
|
3598
|
-
|
|
3599
|
-
|
|
3587
|
+
h,
|
|
3588
|
+
c
|
|
3600
3589
|
) === !1)
|
|
3601
3590
|
return !1;
|
|
3602
3591
|
continue;
|
|
@@ -3612,8 +3601,8 @@ function Qi(s, t) {
|
|
|
3612
3601
|
r,
|
|
3613
3602
|
u,
|
|
3614
3603
|
d,
|
|
3615
|
-
|
|
3616
|
-
|
|
3604
|
+
h,
|
|
3605
|
+
c
|
|
3617
3606
|
) === !1)
|
|
3618
3607
|
return !1;
|
|
3619
3608
|
break;
|
|
@@ -3624,8 +3613,8 @@ function Qi(s, t) {
|
|
|
3624
3613
|
r.geometries[i],
|
|
3625
3614
|
u,
|
|
3626
3615
|
d,
|
|
3627
|
-
|
|
3628
|
-
|
|
3616
|
+
h,
|
|
3617
|
+
c
|
|
3629
3618
|
) === !1)
|
|
3630
3619
|
return !1;
|
|
3631
3620
|
break;
|
|
@@ -3637,9 +3626,9 @@ function Qi(s, t) {
|
|
|
3637
3626
|
u++;
|
|
3638
3627
|
}
|
|
3639
3628
|
}
|
|
3640
|
-
function
|
|
3629
|
+
function qi(s, t, e) {
|
|
3641
3630
|
var i = e;
|
|
3642
|
-
return
|
|
3631
|
+
return Hi(
|
|
3643
3632
|
s,
|
|
3644
3633
|
function(o, r, n, a, l) {
|
|
3645
3634
|
r === 0 && e === void 0 ? i = o : i = t(
|
|
@@ -3653,21 +3642,21 @@ function to(s, t, e) {
|
|
|
3653
3642
|
}
|
|
3654
3643
|
), i;
|
|
3655
3644
|
}
|
|
3656
|
-
function
|
|
3657
|
-
return
|
|
3645
|
+
function Ji(s) {
|
|
3646
|
+
return qi(
|
|
3658
3647
|
s,
|
|
3659
|
-
(t, e) => t +
|
|
3648
|
+
(t, e) => t + Zi(e),
|
|
3660
3649
|
0
|
|
3661
3650
|
);
|
|
3662
3651
|
}
|
|
3663
|
-
function
|
|
3652
|
+
function Zi(s) {
|
|
3664
3653
|
let t = 0, e;
|
|
3665
3654
|
switch (s.type) {
|
|
3666
3655
|
case "Polygon":
|
|
3667
|
-
return
|
|
3656
|
+
return ee(s.coordinates);
|
|
3668
3657
|
case "MultiPolygon":
|
|
3669
3658
|
for (e = 0; e < s.coordinates.length; e++)
|
|
3670
|
-
t +=
|
|
3659
|
+
t += ee(s.coordinates[e]);
|
|
3671
3660
|
return t;
|
|
3672
3661
|
case "Point":
|
|
3673
3662
|
case "MultiPoint":
|
|
@@ -3677,36 +3666,36 @@ function io(s) {
|
|
|
3677
3666
|
}
|
|
3678
3667
|
return 0;
|
|
3679
3668
|
}
|
|
3680
|
-
function
|
|
3669
|
+
function ee(s) {
|
|
3681
3670
|
let t = 0;
|
|
3682
3671
|
if (s && s.length > 0) {
|
|
3683
|
-
t += Math.abs(
|
|
3672
|
+
t += Math.abs(ie(s[0]));
|
|
3684
3673
|
for (let e = 1; e < s.length; e++)
|
|
3685
|
-
t -= Math.abs(
|
|
3674
|
+
t -= Math.abs(ie(s[e]));
|
|
3686
3675
|
}
|
|
3687
3676
|
return t;
|
|
3688
3677
|
}
|
|
3689
|
-
var
|
|
3690
|
-
function
|
|
3678
|
+
var Qi = L * L / 2, Et = Math.PI / 180;
|
|
3679
|
+
function ie(s) {
|
|
3691
3680
|
const t = s.length - 1;
|
|
3692
3681
|
if (t <= 2) return 0;
|
|
3693
3682
|
let e = 0, i = 0;
|
|
3694
3683
|
for (; i < t; ) {
|
|
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] *
|
|
3684
|
+
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] * Et, l = r[1] * Et, d = n[0] * Et;
|
|
3696
3685
|
e += (d - a) * Math.sin(l), i++;
|
|
3697
3686
|
}
|
|
3698
|
-
return e *
|
|
3687
|
+
return e * Qi;
|
|
3699
3688
|
}
|
|
3700
|
-
var
|
|
3701
|
-
const
|
|
3689
|
+
var to = Ji;
|
|
3690
|
+
const eo = (s, t) => {
|
|
3702
3691
|
let e = s, i = "m²";
|
|
3703
3692
|
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 };
|
|
3704
|
-
},
|
|
3693
|
+
}, oe = (s, t, e) => {
|
|
3705
3694
|
if (s.geometry.type !== "Polygon") return s;
|
|
3706
|
-
const i =
|
|
3695
|
+
const i = to(s.geometry), o = eo(i, t);
|
|
3707
3696
|
return o.area = parseFloat(o.area.toFixed(e)), s.properties.area = o.area, s.properties.unit = o.unit, s;
|
|
3708
3697
|
};
|
|
3709
|
-
function
|
|
3698
|
+
function se(s) {
|
|
3710
3699
|
if (!s)
|
|
3711
3700
|
throw new Error("coord is required");
|
|
3712
3701
|
if (!Array.isArray(s)) {
|
|
@@ -3719,52 +3708,52 @@ function le(s) {
|
|
|
3719
3708
|
return [...s];
|
|
3720
3709
|
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
3721
3710
|
}
|
|
3722
|
-
function
|
|
3723
|
-
var i =
|
|
3724
|
-
return
|
|
3711
|
+
function io(s, t, e = {}) {
|
|
3712
|
+
var i = se(s), o = se(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);
|
|
3713
|
+
return $i(
|
|
3725
3714
|
2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
|
|
3726
3715
|
e.units
|
|
3727
3716
|
);
|
|
3728
3717
|
}
|
|
3729
|
-
var
|
|
3730
|
-
const
|
|
3718
|
+
var oo = io;
|
|
3719
|
+
const so = (s) => s === "degrees" ? "°" : s === "miles" ? "mi" : s === "radians" ? "rad" : "km", re = (s, t, e, i, o, r) => {
|
|
3731
3720
|
if (s.geometry.type !== "LineString") return s;
|
|
3732
3721
|
const n = s.geometry.coordinates;
|
|
3733
3722
|
let a = 0;
|
|
3734
3723
|
const l = [];
|
|
3735
3724
|
for (let d = 0; d < n.length - 1; d++) {
|
|
3736
|
-
const
|
|
3725
|
+
const h = n[d], c = n[d + 1], u = oo(h, c, { units: t });
|
|
3737
3726
|
a += u;
|
|
3738
3727
|
const p = JSON.parse(JSON.stringify(s));
|
|
3739
|
-
if (p.id = `${p.id}-${d}`, p.geometry.coordinates = [
|
|
3740
|
-
const g = i == null ? void 0 : i.queryTerrainElevation(c);
|
|
3741
|
-
g && (p.properties.elevation_start = g);
|
|
3728
|
+
if (p.id = `${p.id}-${d}`, p.geometry.coordinates = [h, c], p.properties.originalId = s.id, p.properties.distance = parseFloat(u.toFixed(e)), p.properties.total = parseFloat(a.toFixed(e)), p.properties.unit = so(t), o === !0 && r === void 0) {
|
|
3742
3729
|
const y = i == null ? void 0 : i.queryTerrainElevation(h);
|
|
3743
|
-
y && (p.properties.
|
|
3730
|
+
y && (p.properties.elevation_start = y);
|
|
3731
|
+
const g = i == null ? void 0 : i.queryTerrainElevation(c);
|
|
3732
|
+
g && (p.properties.elevation_end = g);
|
|
3744
3733
|
}
|
|
3745
3734
|
l.push(p);
|
|
3746
3735
|
}
|
|
3747
3736
|
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;
|
|
3748
|
-
},
|
|
3749
|
-
var
|
|
3750
|
-
const
|
|
3737
|
+
}, ne = (s) => s.charAt(0).toUpperCase() + s.slice(1), It = ["td-point", "td-linestring", "td-polygon"];
|
|
3738
|
+
var de, he, ce;
|
|
3739
|
+
const Oo = [
|
|
3751
3740
|
...It,
|
|
3752
|
-
(
|
|
3753
|
-
(
|
|
3754
|
-
(
|
|
3755
|
-
],
|
|
3741
|
+
(de = yt.polygonLayerSpec) == null ? void 0 : de.source,
|
|
3742
|
+
(he = yt.lineLayerLabelSpec) == null ? void 0 : he.source,
|
|
3743
|
+
(ce = yt.pointLayerLabelSpec) == null ? void 0 : ce.source
|
|
3744
|
+
], We = (s, t, e = It) => {
|
|
3756
3745
|
const i = JSON.parse(JSON.stringify(s));
|
|
3757
3746
|
return t && (t.onlyTerraDrawLayers === !0 ? (i.layers = i.layers.filter((o) => "source" in o && e.includes(o.source)), Object.keys(i.sources).forEach((o) => {
|
|
3758
3747
|
e.includes(o) || delete i.sources[o];
|
|
3759
3748
|
})) : t.excludeTerraDrawLayers === !0 && (i.layers = i.layers.filter((o) => "source" in o && !e.includes(o.source)), Object.keys(i.sources).forEach((o) => {
|
|
3760
3749
|
e.includes(o) && delete i.sources[o];
|
|
3761
3750
|
}))), i;
|
|
3762
|
-
},
|
|
3751
|
+
}, ro = (s, t = 250) => {
|
|
3763
3752
|
let e;
|
|
3764
3753
|
return (...i) => {
|
|
3765
3754
|
clearTimeout(e), e = setTimeout(() => s(...i), t);
|
|
3766
3755
|
};
|
|
3767
|
-
},
|
|
3756
|
+
}, ae = (s, t, e, i) => {
|
|
3768
3757
|
if (s.geometry.type !== "Point") return s;
|
|
3769
3758
|
const o = s.geometry.coordinates;
|
|
3770
3759
|
if (e === !0 && i === void 0) {
|
|
@@ -3773,58 +3762,58 @@ const ko = [
|
|
|
3773
3762
|
}
|
|
3774
3763
|
return s;
|
|
3775
3764
|
};
|
|
3776
|
-
var
|
|
3777
|
-
function
|
|
3765
|
+
var no = Object.defineProperty, ao = (s, t, e) => t in s ? no(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, tt = (s, t, e) => ao(s, typeof t != "symbol" ? t + "" : t, e), Pt = 2 * Math.PI * 6378137 / 2;
|
|
3766
|
+
function lo(s) {
|
|
3778
3767
|
return s = s || 256, 2 * Math.PI * 6378137 / s;
|
|
3779
3768
|
}
|
|
3780
|
-
function
|
|
3781
|
-
s =
|
|
3769
|
+
function ho(s, t, e = { enable: !0, decimal: 1 }) {
|
|
3770
|
+
s = jt(s);
|
|
3782
3771
|
var i = s[0], o = s[1], r = i * Pt / 180, n = Math.log(Math.tan((90 + o) * Math.PI / 360)) / (Math.PI / 180);
|
|
3783
3772
|
return n = n * Pt / 180, e.enable && (r = Number(r.toFixed(e.decimal)), n = Number(n.toFixed(e.decimal))), [r, n];
|
|
3784
3773
|
}
|
|
3785
|
-
function
|
|
3786
|
-
var i = s[0], o = s[1], r =
|
|
3774
|
+
function co(s, t, e) {
|
|
3775
|
+
var i = s[0], o = s[1], r = mo(t, e), n = (i + Pt) / r, a = (o + Pt) / r;
|
|
3787
3776
|
return [n, a, t];
|
|
3788
3777
|
}
|
|
3789
|
-
function
|
|
3790
|
-
s =
|
|
3791
|
-
var i =
|
|
3792
|
-
return
|
|
3778
|
+
function Be(s, t, e) {
|
|
3779
|
+
s = jt(s);
|
|
3780
|
+
var i = ho(s), o = co(i, t);
|
|
3781
|
+
return po(o);
|
|
3793
3782
|
}
|
|
3794
|
-
function
|
|
3795
|
-
if (s =
|
|
3783
|
+
function uo(s, t, e) {
|
|
3784
|
+
if (s = jt(s), t === 0)
|
|
3796
3785
|
return [0, 0, 0];
|
|
3797
|
-
var i =
|
|
3798
|
-
return
|
|
3786
|
+
var i = Be(s, t);
|
|
3787
|
+
return go(i);
|
|
3799
3788
|
}
|
|
3800
|
-
function
|
|
3789
|
+
function po(s, t, e) {
|
|
3801
3790
|
t = t || 256;
|
|
3802
3791
|
var i = s[0], o = s[1], r = s[2];
|
|
3803
3792
|
if (r === 0) return [0, 0, 0];
|
|
3804
|
-
|
|
3793
|
+
Ne(r);
|
|
3805
3794
|
var n = Math.ceil(i / t) - 1, a = Math.ceil(o / t) - 1;
|
|
3806
3795
|
return n < 0 && (n = 0), a < 0 && (a = 0), [n, a, r];
|
|
3807
3796
|
}
|
|
3808
|
-
function
|
|
3809
|
-
|
|
3797
|
+
function go(s, t) {
|
|
3798
|
+
yo(s);
|
|
3810
3799
|
var e = s[0], i = s[1], o = s[2];
|
|
3811
3800
|
if (o === 0)
|
|
3812
3801
|
return [0, 0, 0];
|
|
3813
3802
|
var r = e, n = Math.pow(2, o) - 1 - i;
|
|
3814
3803
|
return [r, n, o];
|
|
3815
3804
|
}
|
|
3816
|
-
function
|
|
3805
|
+
function yo(s, t) {
|
|
3817
3806
|
var e = s[0], i = s[1], o = s[2];
|
|
3818
3807
|
if (o == null) throw new Error("<zoom> is required");
|
|
3819
3808
|
if (e == null) throw new Error("<x> is required");
|
|
3820
3809
|
if (i == null) throw new Error("<y> is required");
|
|
3821
|
-
return o =
|
|
3810
|
+
return o = Ne(o), s = fo(s), s;
|
|
3822
3811
|
}
|
|
3823
|
-
function
|
|
3812
|
+
function fo(s) {
|
|
3824
3813
|
var t = s[0], e = s[1], i = s[2], o = Math.pow(2, i);
|
|
3825
3814
|
return t = t % o, t < 0 && (t = t + o), [t, e, i];
|
|
3826
3815
|
}
|
|
3827
|
-
function
|
|
3816
|
+
function Ne(s) {
|
|
3828
3817
|
if (s === !1) return s;
|
|
3829
3818
|
if (s == null)
|
|
3830
3819
|
throw new Error("<zoom> is required");
|
|
@@ -3834,22 +3823,22 @@ function Ve(s) {
|
|
|
3834
3823
|
throw new Error("<zoom> cannot be greater than 32");
|
|
3835
3824
|
return s;
|
|
3836
3825
|
}
|
|
3837
|
-
function
|
|
3838
|
-
var e =
|
|
3826
|
+
function jt(s, t) {
|
|
3827
|
+
var e = Co(s[0]), i = vo(s[1]);
|
|
3839
3828
|
return i > 85 && (i = 85), i < -85 && (i = -85), [e, i];
|
|
3840
3829
|
}
|
|
3841
|
-
function
|
|
3842
|
-
return
|
|
3830
|
+
function mo(s, t) {
|
|
3831
|
+
return lo(t) / Math.pow(2, s);
|
|
3843
3832
|
}
|
|
3844
|
-
function
|
|
3833
|
+
function vo(s) {
|
|
3845
3834
|
if (s == null) throw new Error("lat is required");
|
|
3846
3835
|
return (s > 90 || s < -90) && (s = s % 180, s > 90 && (s = -180 + s), s < -90 && (s = 180 + s), s === 0 && (s = 0)), s;
|
|
3847
3836
|
}
|
|
3848
|
-
function
|
|
3837
|
+
function Co(s) {
|
|
3849
3838
|
if (s == null) throw new Error("lng is required");
|
|
3850
3839
|
return (s > 180 || s < -180) && (s = s % 360, s > 180 && (s = -360 + s), s < -180 && (s = 360 + s), s === 0 && (s = 0)), s;
|
|
3851
3840
|
}
|
|
3852
|
-
class
|
|
3841
|
+
class Ge {
|
|
3853
3842
|
/**
|
|
3854
3843
|
* Constructor
|
|
3855
3844
|
* @param url URL for terrain RGB raster tilesets
|
|
@@ -3874,17 +3863,17 @@ class Ue {
|
|
|
3874
3863
|
const r = t[0], n = t[1];
|
|
3875
3864
|
let a = e;
|
|
3876
3865
|
e > this.maxzoom ? a = this.maxzoom : e < this.minzoom && (a = this.minzoom);
|
|
3877
|
-
const l = this.tms ?
|
|
3878
|
-
let
|
|
3879
|
-
switch (
|
|
3866
|
+
const l = this.tms ? Be([r, n], a) : uo([r, n], a), d = this.url.replace(/{x}/g, l[0].toString()).replace(/{y}/g, l[1].toString()).replace(/{z}/g, l[2].toString());
|
|
3867
|
+
let h = this.getUrlExtension(d);
|
|
3868
|
+
switch (h || (h = "png"), h) {
|
|
3880
3869
|
case "png":
|
|
3881
3870
|
case "webp":
|
|
3882
|
-
this.getValueFromRaster(d, l, r, n).then((
|
|
3883
|
-
i(
|
|
3871
|
+
this.getValueFromRaster(d, l, r, n).then((c) => {
|
|
3872
|
+
i(c);
|
|
3884
3873
|
});
|
|
3885
3874
|
break;
|
|
3886
3875
|
default:
|
|
3887
|
-
o(new Error(`Invalid file extension: ${
|
|
3876
|
+
o(new Error(`Invalid file extension: ${h}`));
|
|
3888
3877
|
break;
|
|
3889
3878
|
}
|
|
3890
3879
|
}
|
|
@@ -3909,13 +3898,13 @@ class Ue {
|
|
|
3909
3898
|
return new Promise((a, l) => {
|
|
3910
3899
|
const d = new Image();
|
|
3911
3900
|
d.onload = () => {
|
|
3912
|
-
const
|
|
3913
|
-
|
|
3914
|
-
const
|
|
3915
|
-
if (!
|
|
3916
|
-
|
|
3917
|
-
const u =
|
|
3918
|
-
a(
|
|
3901
|
+
const h = document.createElement("canvas");
|
|
3902
|
+
h.width = d.width, h.height = d.height;
|
|
3903
|
+
const c = h.getContext("2d");
|
|
3904
|
+
if (!c) return l(new Error("Failed to create canvas context"));
|
|
3905
|
+
c.drawImage(d, 0, 0);
|
|
3906
|
+
const u = c.getImageData(0, 0, d.width, d.height).data, p = this.pixels2rgba(new Uint8Array(u), e, i, o), y = this.calc(p[0], p[1], p[2], p[3]);
|
|
3907
|
+
a(y);
|
|
3919
3908
|
}, d.onerror = () => a(void 0), d.src = URL.createObjectURL(n);
|
|
3920
3909
|
});
|
|
3921
3910
|
}
|
|
@@ -3930,8 +3919,8 @@ class Ue {
|
|
|
3930
3919
|
pixels2rgba(t, e, i, o) {
|
|
3931
3920
|
const r = [];
|
|
3932
3921
|
for (let d = 0; d < t.length; d += 4) {
|
|
3933
|
-
const
|
|
3934
|
-
r.push(
|
|
3922
|
+
const h = t[d], c = t[d + 1], u = t[d + 2], p = t[d + 3], y = [h, c, u, p];
|
|
3923
|
+
r.push(y);
|
|
3935
3924
|
}
|
|
3936
3925
|
const n = this.tileToBBOX(e), a = this.getPixelPosition(i, o, n), l = a[0] + a[1] * this.tileSize;
|
|
3937
3926
|
return r[l];
|
|
@@ -3944,8 +3933,8 @@ class Ue {
|
|
|
3944
3933
|
* @returns The position in pixel
|
|
3945
3934
|
*/
|
|
3946
3935
|
getPixelPosition(t, e, i) {
|
|
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,
|
|
3948
|
-
return [
|
|
3936
|
+
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, h = Math.floor(o * l), c = Math.floor(r * (1 - d));
|
|
3937
|
+
return [h, c];
|
|
3949
3938
|
}
|
|
3950
3939
|
/**
|
|
3951
3940
|
* Get file extenstion name from the URL
|
|
@@ -3976,7 +3965,7 @@ class Ue {
|
|
|
3976
3965
|
return i * Math.atan(0.5 * (Math.exp(o) - Math.exp(-o)));
|
|
3977
3966
|
}
|
|
3978
3967
|
}
|
|
3979
|
-
class
|
|
3968
|
+
class Po extends Ge {
|
|
3980
3969
|
/**
|
|
3981
3970
|
* Constructor
|
|
3982
3971
|
* @param url URL for terrain RGB raster tilesets
|
|
@@ -4008,7 +3997,7 @@ class bo extends Ue {
|
|
|
4008
3997
|
return -1e4 + (t * 256 * 256 + e * 256 + i) * 0.1;
|
|
4009
3998
|
}
|
|
4010
3999
|
}
|
|
4011
|
-
class
|
|
4000
|
+
class So extends Ge {
|
|
4012
4001
|
/**
|
|
4013
4002
|
* Constructor
|
|
4014
4003
|
* @param url URL for terrarium raster tilesets
|
|
@@ -4042,22 +4031,22 @@ class Mo extends Ue {
|
|
|
4042
4031
|
return parseInt(o.toFixed(0));
|
|
4043
4032
|
}
|
|
4044
4033
|
}
|
|
4045
|
-
const
|
|
4034
|
+
const le = async (s, t) => {
|
|
4046
4035
|
const e = [];
|
|
4047
4036
|
for (const i of s)
|
|
4048
4037
|
e.push(
|
|
4049
4038
|
new Promise((o) => {
|
|
4050
4039
|
if (i.geometry.type !== "Point" && o(i), t) {
|
|
4051
|
-
const r = t.url, n = t.encoding ?? "mapbox", a = t.tileSize ?? 512, l = t.minzoom ?? 5, d = t.maxzoom ?? 15,
|
|
4052
|
-
(n === "mapbox" ? new
|
|
4053
|
-
|
|
4040
|
+
const r = t.url, n = t.encoding ?? "mapbox", a = t.tileSize ?? 512, l = t.minzoom ?? 5, d = t.maxzoom ?? 15, h = t.tms ?? !1;
|
|
4041
|
+
(n === "mapbox" ? new Po(r, a, l, d, h) : new So(r, a, l, d, h)).getElevation(i.geometry.coordinates, d).then((c) => {
|
|
4042
|
+
c && (i.properties.elevation = c), o(i);
|
|
4054
4043
|
}).catch(() => o(i));
|
|
4055
4044
|
} else
|
|
4056
4045
|
o(i);
|
|
4057
4046
|
})
|
|
4058
4047
|
);
|
|
4059
4048
|
return await Promise.all(e);
|
|
4060
|
-
},
|
|
4049
|
+
}, Do = (s, t = 9) => {
|
|
4061
4050
|
function e(o) {
|
|
4062
4051
|
return [Number(o[0].toFixed(t)), Number(o[1].toFixed(t))];
|
|
4063
4052
|
}
|
|
@@ -4092,7 +4081,7 @@ const ue = async (s, t) => {
|
|
|
4092
4081
|
geometry: i(o.geometry)
|
|
4093
4082
|
}));
|
|
4094
4083
|
};
|
|
4095
|
-
class
|
|
4084
|
+
class xo {
|
|
4096
4085
|
/**
|
|
4097
4086
|
* Constructor
|
|
4098
4087
|
* @param options Plugin control options
|
|
@@ -4103,7 +4092,7 @@ class wo {
|
|
|
4103
4092
|
k(this, "modeButtons", {});
|
|
4104
4093
|
k(this, "_isExpanded", !1);
|
|
4105
4094
|
k(this, "terradraw");
|
|
4106
|
-
k(this, "options",
|
|
4095
|
+
k(this, "options", Ri);
|
|
4107
4096
|
k(this, "events", {});
|
|
4108
4097
|
k(this, "defaultMode", "render");
|
|
4109
4098
|
this.modeButtons = {}, t && (this.options = Object.assign(this.options, t));
|
|
@@ -4147,20 +4136,20 @@ class wo {
|
|
|
4147
4136
|
if (this.options && this.options.modes && this.options.modes.length === 0)
|
|
4148
4137
|
throw new Error("At least a mode must be enabled.");
|
|
4149
4138
|
this.map = t;
|
|
4150
|
-
const e =
|
|
4139
|
+
const e = zi(), i = [];
|
|
4151
4140
|
return (r = (o = this.options) == null ? void 0 : o.modes) == null || r.forEach((d) => {
|
|
4152
4141
|
if (this.options.modeOptions && this.options.modeOptions[d]) {
|
|
4153
|
-
const
|
|
4142
|
+
const h = this.options.modeOptions[d];
|
|
4154
4143
|
if (d === "select") {
|
|
4155
|
-
const
|
|
4156
|
-
if (
|
|
4157
|
-
const u =
|
|
4144
|
+
const c = e[d];
|
|
4145
|
+
if (c) {
|
|
4146
|
+
const u = c.flags;
|
|
4158
4147
|
Object.keys(u).forEach((p) => {
|
|
4159
|
-
|
|
4148
|
+
h.flags[p] || (h.flags[p] = u[p]);
|
|
4160
4149
|
});
|
|
4161
4150
|
}
|
|
4162
4151
|
}
|
|
4163
|
-
i.push(
|
|
4152
|
+
i.push(h);
|
|
4164
4153
|
} else e[d] && i.push(e[d]);
|
|
4165
4154
|
}), i.forEach((d) => {
|
|
4166
4155
|
d.state !== "unregistered" && (d._state = "unregistered");
|
|
@@ -4169,14 +4158,14 @@ class wo {
|
|
|
4169
4158
|
modeName: "default",
|
|
4170
4159
|
styles: {}
|
|
4171
4160
|
})
|
|
4172
|
-
), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new
|
|
4173
|
-
adapter: new
|
|
4161
|
+
), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new Vi({
|
|
4162
|
+
adapter: new Ui({ map: t, ...this.options.adapterOptions }),
|
|
4174
4163
|
modes: i
|
|
4175
4164
|
}), this.terradraw.start(), this.controlContainer = document.createElement("div"), this.controlContainer.classList.add("maplibregl-ctrl"), this.controlContainer.classList.add("maplibregl-ctrl-group"), i.forEach((d) => {
|
|
4176
4165
|
d.mode !== "default" && this.addTerradrawButton(d.mode);
|
|
4177
4166
|
}), Object.values(this.modeButtons).forEach((d) => {
|
|
4178
|
-
var
|
|
4179
|
-
(
|
|
4167
|
+
var h;
|
|
4168
|
+
(h = this.controlContainer) == null || h.appendChild(d);
|
|
4180
4169
|
}), (l = this.terradraw) == null || l.on("change", this.toggleButtonsWhenNoFeature.bind(this)), this.toggleButtonsWhenNoFeature(), this.controlContainer;
|
|
4181
4170
|
}
|
|
4182
4171
|
/**
|
|
@@ -4267,7 +4256,7 @@ class wo {
|
|
|
4267
4256
|
*/
|
|
4268
4257
|
addTerradrawButton(t) {
|
|
4269
4258
|
const e = document.createElement("button");
|
|
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 =
|
|
4259
|
+
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 = ne("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 = ne(t.replace(/-/g, " ")), t === "delete" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.addEventListener("click", () => {
|
|
4271
4260
|
this.terradraw && this.terradraw.enabled && (this.terradraw.clear(), this.deactivate(), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.dispatchEvent("feature-deleted"));
|
|
4272
4261
|
})) : t === "delete-selection" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.classList.add("hidden-delete-selection"), e.addEventListener("click", () => {
|
|
4273
4262
|
var r;
|
|
@@ -4317,7 +4306,7 @@ class wo {
|
|
|
4317
4306
|
* @returns
|
|
4318
4307
|
*/
|
|
4319
4308
|
cleanStyle(t, e) {
|
|
4320
|
-
return
|
|
4309
|
+
return We(t, e, It);
|
|
4321
4310
|
}
|
|
4322
4311
|
/**
|
|
4323
4312
|
* Download button click event handler
|
|
@@ -4351,28 +4340,28 @@ class wo {
|
|
|
4351
4340
|
var a, l;
|
|
4352
4341
|
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");
|
|
4353
4342
|
for (let d = 0; d < n.length; d++) {
|
|
4354
|
-
const
|
|
4355
|
-
|
|
4343
|
+
const h = n.item(d);
|
|
4344
|
+
h && (r ? h.classList.remove("hidden-delete-selection") : h.classList.add("hidden-delete-selection"));
|
|
4356
4345
|
}
|
|
4357
4346
|
if (!o) {
|
|
4358
4347
|
const d = document.getElementsByClassName("maplibregl-terradraw-add-select-button");
|
|
4359
|
-
for (let
|
|
4360
|
-
const
|
|
4361
|
-
|
|
4348
|
+
for (let h = 0; h < d.length; h++) {
|
|
4349
|
+
const c = d.item(h);
|
|
4350
|
+
c && c.classList.remove("active");
|
|
4362
4351
|
}
|
|
4363
4352
|
}
|
|
4364
4353
|
}
|
|
4365
4354
|
}
|
|
4366
|
-
function
|
|
4355
|
+
function Io(s, t = {}) {
|
|
4367
4356
|
let e = 0, i = 0, o = 0;
|
|
4368
|
-
return
|
|
4357
|
+
return je(
|
|
4369
4358
|
s,
|
|
4370
4359
|
function(r) {
|
|
4371
4360
|
e += r[0], i += r[1], o++;
|
|
4372
4361
|
}
|
|
4373
|
-
),
|
|
4362
|
+
), Yi([e / o, i / o], t.properties);
|
|
4374
4363
|
}
|
|
4375
|
-
class
|
|
4364
|
+
class _o extends xo {
|
|
4376
4365
|
/**
|
|
4377
4366
|
* Constructor
|
|
4378
4367
|
* @param options Plugin control options
|
|
@@ -4411,7 +4400,7 @@ class Wo extends wo {
|
|
|
4411
4400
|
* Handle finish event of terradraw. It will be called after finishing adding a feature
|
|
4412
4401
|
* @param id Feature ID
|
|
4413
4402
|
*/
|
|
4414
|
-
k(this, "handleTerradrawFeatureReady",
|
|
4403
|
+
k(this, "handleTerradrawFeatureReady", ro((e) => {
|
|
4415
4404
|
this.map && (this.computeElevationByLineFeatureID(e), this.computeElevationByPointFeatureID(e));
|
|
4416
4405
|
}, 300));
|
|
4417
4406
|
/**
|
|
@@ -4429,7 +4418,7 @@ class Wo extends wo {
|
|
|
4429
4418
|
}
|
|
4430
4419
|
);
|
|
4431
4420
|
if (o && o.length > 0) {
|
|
4432
|
-
const r = await
|
|
4421
|
+
const r = await le(
|
|
4433
4422
|
o,
|
|
4434
4423
|
this.measureOptions.terrainSource
|
|
4435
4424
|
);
|
|
@@ -4457,7 +4446,7 @@ class Wo extends wo {
|
|
|
4457
4446
|
}
|
|
4458
4447
|
);
|
|
4459
4448
|
if (o && o.length > 0) {
|
|
4460
|
-
const r = await
|
|
4449
|
+
const r = await le(
|
|
4461
4450
|
o,
|
|
4462
4451
|
this.measureOptions.terrainSource
|
|
4463
4452
|
);
|
|
@@ -4586,13 +4575,13 @@ class Wo extends wo {
|
|
|
4586
4575
|
* @returns
|
|
4587
4576
|
*/
|
|
4588
4577
|
cleanStyle(e, i) {
|
|
4589
|
-
var l, d,
|
|
4578
|
+
var l, d, h;
|
|
4590
4579
|
const o = It, r = (l = this.measureOptions.polygonLayerSpec) == null ? void 0 : l.source;
|
|
4591
4580
|
r && o.push(r);
|
|
4592
4581
|
const n = (d = this.measureOptions.lineLayerLabelSpec) == null ? void 0 : d.source;
|
|
4593
4582
|
n && o.push(n);
|
|
4594
|
-
const a = (
|
|
4595
|
-
return a && o.push(a),
|
|
4583
|
+
const a = (h = this.measureOptions.pointLayerLabelSpec) == null ? void 0 : h.source;
|
|
4584
|
+
return a && o.push(a), We(e, i, o);
|
|
4596
4585
|
}
|
|
4597
4586
|
/**
|
|
4598
4587
|
* Register measure control related maplibre sources and layers
|
|
@@ -4662,10 +4651,10 @@ class Wo extends wo {
|
|
|
4662
4651
|
if (!n) return;
|
|
4663
4652
|
const a = n.getSnapshot();
|
|
4664
4653
|
for (const l of e) {
|
|
4665
|
-
const d = a.find((
|
|
4654
|
+
const d = a.find((h) => h.id === l);
|
|
4666
4655
|
if (d) {
|
|
4667
|
-
const
|
|
4668
|
-
|
|
4656
|
+
const h = d.geometry.type, c = d.properties.mode;
|
|
4657
|
+
c === "linestring" && h === "LineString" ? this.measureLine(l) : c === "point" && h === "Point" ? this.measurePoint(l) : !["point", "linestring", "select", "render"].includes(c) && h === "Polygon" && this.measurePolygon(l);
|
|
4669
4658
|
} else
|
|
4670
4659
|
this.clearMeasureFeatures(r, [l]);
|
|
4671
4660
|
}
|
|
@@ -4717,30 +4706,30 @@ class Wo extends wo {
|
|
|
4717
4706
|
const r = this.map.getStyle().sources[i];
|
|
4718
4707
|
if (r && typeof r.data != "string" && r.data.type === "FeatureCollection") {
|
|
4719
4708
|
const l = [];
|
|
4720
|
-
for (const
|
|
4721
|
-
(n = this.terradraw) != null && n.getSnapshotFeature(
|
|
4722
|
-
const d = l.map((
|
|
4709
|
+
for (const h of e)
|
|
4710
|
+
(n = this.terradraw) != null && n.getSnapshotFeature(h.id) && l.push(h);
|
|
4711
|
+
const d = l.map((h) => h.id);
|
|
4723
4712
|
if (typeof r.data != "string" && r.data.type === "FeatureCollection") {
|
|
4724
4713
|
o === "linestring" ? r.data.features = [
|
|
4725
4714
|
...r.data.features = r.data.features.filter(
|
|
4726
|
-
(
|
|
4715
|
+
(c) => {
|
|
4727
4716
|
var u;
|
|
4728
|
-
return !(d.includes((u =
|
|
4717
|
+
return !(d.includes((u = c.properties) == null ? void 0 : u.originalId) && c.geometry.type === "Point");
|
|
4729
4718
|
}
|
|
4730
4719
|
),
|
|
4731
4720
|
...l
|
|
4732
4721
|
] : o === "point" && (r.data.features = [
|
|
4733
4722
|
...r.data.features = r.data.features.filter(
|
|
4734
|
-
(
|
|
4723
|
+
(c) => !(d.includes(c.id) && c.geometry.type === "Point")
|
|
4735
4724
|
),
|
|
4736
4725
|
...l
|
|
4737
4726
|
]);
|
|
4738
|
-
const
|
|
4739
|
-
r.data.features.forEach((
|
|
4727
|
+
const h = {};
|
|
4728
|
+
r.data.features.forEach((c) => {
|
|
4740
4729
|
var p;
|
|
4741
|
-
const u =
|
|
4742
|
-
|
|
4743
|
-
}), r.data.features = Array.from(Object.values(
|
|
4730
|
+
const u = c.id;
|
|
4731
|
+
h[u] ? !h[u].properties.elevation && ((p = c.properties) != null && p.elevation) && (h[u] = c) : h[u] = c;
|
|
4732
|
+
}), r.data.features = Array.from(Object.values(h)), (a = this.map.getSource(i)) == null || a.setData(r.data);
|
|
4744
4733
|
}
|
|
4745
4734
|
}
|
|
4746
4735
|
}
|
|
@@ -4760,12 +4749,12 @@ class Wo extends wo {
|
|
|
4760
4749
|
if (a) {
|
|
4761
4750
|
typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
|
|
4762
4751
|
(d) => {
|
|
4763
|
-
var
|
|
4764
|
-
return ((
|
|
4752
|
+
var h;
|
|
4753
|
+
return ((h = d.properties) == null ? void 0 : h.originalId) !== e;
|
|
4765
4754
|
}
|
|
4766
4755
|
));
|
|
4767
4756
|
const l = JSON.parse(JSON.stringify(r));
|
|
4768
|
-
l.id = l.id + "-area-label", l.geometry =
|
|
4757
|
+
l.id = l.id + "-area-label", l.geometry = Io(r.geometry).geometry, l.properties.originalId = r.id, r = oe(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(
|
|
4769
4758
|
this.measureOptions.polygonLayerSpec.source
|
|
4770
4759
|
)) == null || n.setData(a.data), this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && this.map.moveLayer(
|
|
4771
4760
|
this.measureOptions.lineLayerLabelSpec.id
|
|
@@ -4795,10 +4784,10 @@ class Wo extends wo {
|
|
|
4795
4784
|
if (a) {
|
|
4796
4785
|
typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
|
|
4797
4786
|
(d) => {
|
|
4798
|
-
var
|
|
4799
|
-
return ((
|
|
4787
|
+
var h;
|
|
4788
|
+
return ((h = d.properties) == null ? void 0 : h.originalId) !== e;
|
|
4800
4789
|
}
|
|
4801
|
-
)), r =
|
|
4790
|
+
)), r = re(
|
|
4802
4791
|
r,
|
|
4803
4792
|
this.distanceUnit,
|
|
4804
4793
|
this.distancePrecision,
|
|
@@ -4808,21 +4797,21 @@ class Wo extends wo {
|
|
|
4808
4797
|
);
|
|
4809
4798
|
const l = r.properties.segments;
|
|
4810
4799
|
for (let d = 0; d < l.length; d++) {
|
|
4811
|
-
const
|
|
4812
|
-
typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(
|
|
4813
|
-
const
|
|
4800
|
+
const h = l[d];
|
|
4801
|
+
typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(h);
|
|
4802
|
+
const c = h.geometry.coordinates, u = c[0], p = c[1];
|
|
4814
4803
|
if (d === 0) {
|
|
4815
|
-
const
|
|
4816
|
-
|
|
4804
|
+
const g = JSON.parse(JSON.stringify(h));
|
|
4805
|
+
g.id = `${h.id}-node-${d}`, g.geometry = {
|
|
4817
4806
|
type: "Point",
|
|
4818
4807
|
coordinates: u
|
|
4819
|
-
},
|
|
4808
|
+
}, g.properties.distance = 0, g.properties.total = 0, h.properties.elevation_start && (g.properties.elevation = h.properties.elevation_start), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(g);
|
|
4820
4809
|
}
|
|
4821
|
-
const
|
|
4822
|
-
|
|
4810
|
+
const y = JSON.parse(JSON.stringify(h));
|
|
4811
|
+
y.id = `${h.id}-node-${d + 1}`, y.geometry = {
|
|
4823
4812
|
type: "Point",
|
|
4824
4813
|
coordinates: p
|
|
4825
|
-
},
|
|
4814
|
+
}, h.properties.elevation_end && (y.properties.elevation = h.properties.elevation_end), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(y);
|
|
4826
4815
|
}
|
|
4827
4816
|
(n = this.map.getSource(
|
|
4828
4817
|
this.measureOptions.lineLayerLabelSpec.source
|
|
@@ -4847,7 +4836,7 @@ class Wo extends wo {
|
|
|
4847
4836
|
let r = o == null ? void 0 : o.find((a) => a.id === e && a.geometry.type === "Point");
|
|
4848
4837
|
if (r) {
|
|
4849
4838
|
const a = this.map.getStyle().sources[this.measureOptions.pointLayerLabelSpec.source];
|
|
4850
|
-
a && (typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter((l) => l.id !== e)), r =
|
|
4839
|
+
a && (typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter((l) => l.id !== e)), r = ae(
|
|
4851
4840
|
r,
|
|
4852
4841
|
this.map,
|
|
4853
4842
|
this.computeElevation,
|
|
@@ -4892,14 +4881,14 @@ class Wo extends wo {
|
|
|
4892
4881
|
const r = i.features[o];
|
|
4893
4882
|
if (!this.map || !this.map.loaded()) continue;
|
|
4894
4883
|
const n = r.geometry.type;
|
|
4895
|
-
n === "LineString" ? i.features[o] =
|
|
4884
|
+
n === "LineString" ? i.features[o] = re(
|
|
4896
4885
|
r,
|
|
4897
4886
|
this.distanceUnit,
|
|
4898
4887
|
this.distancePrecision,
|
|
4899
4888
|
this.map,
|
|
4900
4889
|
this.computeElevation,
|
|
4901
4890
|
this.measureOptions.terrainSource
|
|
4902
|
-
) : n === "Polygon" ? i.features[o] =
|
|
4891
|
+
) : n === "Polygon" ? i.features[o] = oe(r, this.areaUnit, this.areaPrecision) : n === "Point" && (i.features[o] = ae(
|
|
4903
4892
|
r,
|
|
4904
4893
|
this.map,
|
|
4905
4894
|
this.computeElevation,
|
|
@@ -4910,23 +4899,23 @@ class Wo extends wo {
|
|
|
4910
4899
|
}
|
|
4911
4900
|
}
|
|
4912
4901
|
export {
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4902
|
+
Eo as AvailableModes,
|
|
4903
|
+
_o as MaplibreMeasureControl,
|
|
4904
|
+
xo as MaplibreTerradrawControl,
|
|
4905
|
+
Oo as TERRADRAW_MEASURE_SOURCE_IDS,
|
|
4917
4906
|
It as TERRADRAW_SOURCE_IDS,
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4907
|
+
oe as calcArea,
|
|
4908
|
+
re as calcDistance,
|
|
4909
|
+
ne as capitalize,
|
|
4910
|
+
We as cleanMaplibreStyle,
|
|
4911
|
+
eo as convertAreaUnit,
|
|
4912
|
+
ro as debounce,
|
|
4913
|
+
Ri as defaultControlOptions,
|
|
4925
4914
|
yt as defaultMeasureControlOptions,
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4915
|
+
zi as getDefaultModeOptions,
|
|
4916
|
+
so as getDistanceUnitName,
|
|
4917
|
+
ae as queryElevationByPoint,
|
|
4918
|
+
le as queryElevationFromRasterDEM,
|
|
4919
|
+
Do as roundFeatureCoordinates
|
|
4931
4920
|
};
|
|
4932
4921
|
//# sourceMappingURL=maplibre-gl-terradraw.es.js.map
|