@watergis/maplibre-gl-terradraw 1.3.4 → 1.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/maplibre-gl-terradraw.es.js +544 -519
- package/dist/maplibre-gl-terradraw.es.js.map +1 -1
- package/dist/maplibre-gl-terradraw.umd.js +3 -3
- package/dist/maplibre-gl-terradraw.umd.js.map +1 -1
- package/dist/types/helpers/calcDistance.d.ts.map +1 -1
- package/dist/types/helpers/convertMetricDistance.d.ts +5 -0
- package/dist/types/helpers/convertMetricDistance.d.ts.map +1 -0
- package/dist/types/helpers/index.d.ts +1 -0
- package/dist/types/helpers/index.d.ts.map +1 -1
- package/package.json +20 -19
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var k = (s, t, e) =>
|
|
1
|
+
var Ve = Object.defineProperty;
|
|
2
|
+
var Ue = (s, t, e) => t in s ? Ve(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
3
|
+
var k = (s, t, e) => Ue(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) {
|
|
@@ -24,7 +24,7 @@ function Ut(s) {
|
|
|
24
24
|
return typeof t == "number" && !isNaN(new Date(t).valueOf());
|
|
25
25
|
}(s);
|
|
26
26
|
}
|
|
27
|
-
const
|
|
27
|
+
const Re = "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: Re } : 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 ze extends N {
|
|
130
130
|
constructor(...t) {
|
|
131
131
|
super(...t), this.type = $.Select;
|
|
132
132
|
}
|
|
@@ -135,34 +135,34 @@ 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 ge = 63710088e-1;
|
|
139
|
+
function O(s) {
|
|
140
140
|
return s % 360 * Math.PI / 180;
|
|
141
141
|
}
|
|
142
|
-
function
|
|
142
|
+
function ye(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 Rt = 57.29577951308232, zt = 0.017453292519943295, ft = 6378137, x = (s, t) => ({ x: s === 0 ? 0 : s * zt * ft, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * zt / 2)) * ft }), j = (s, t) => ({ lng: s === 0 ? 0 : Rt * (s / ft), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / ft)) - Math.PI / 2) * Rt });
|
|
153
|
+
function Xe(s, t, e) {
|
|
154
|
+
const i = O(s[0]), o = O(s[1]), r = O(e), n = ye(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
157
|
function Xt(s) {
|
|
158
158
|
const { center: t, radiusKilometers: e, coordinatePrecision: i } = s, o = s.steps ? s.steps : 64, r = [];
|
|
159
159
|
for (let n = 0; n < o; n++) {
|
|
160
|
-
const a =
|
|
161
|
-
r.push([
|
|
160
|
+
const a = Xe(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
|
}
|
|
165
|
-
function
|
|
165
|
+
function Lt(s) {
|
|
166
166
|
let t;
|
|
167
167
|
if (s.geometry.type === "Polygon") t = s.geometry.coordinates;
|
|
168
168
|
else {
|
|
@@ -178,12 +178,12 @@ function _t(s) {
|
|
|
178
178
|
function o(r, n, a, l) {
|
|
179
179
|
const d = t[r][n], c = t[r][n + 1], h = t[a][l], u = t[a][l + 1], p = function(v, f, m, C) {
|
|
180
180
|
if (ct(v, m) || ct(v, C) || ct(f, m) || ct(C, m)) return null;
|
|
181
|
-
const P = v[0], S = v[1], M = f[0],
|
|
182
|
-
return
|
|
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
183
|
}(d, c, h, u);
|
|
184
184
|
if (p === null) return;
|
|
185
|
-
let
|
|
186
|
-
|
|
185
|
+
let y, g;
|
|
186
|
+
y = c[0] !== d[0] ? (p[0] - d[0]) / (c[0] - d[0]) : (p[1] - d[1]) / (c[1] - d[1]), g = u[0] !== h[0] ? (p[0] - h[0]) / (u[0] - h[0]) : (p[1] - h[1]) / (u[1] - h[1]), i(y) || i(g) || (p.toString(), e.push(p));
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
function ct(s, t) {
|
|
@@ -201,26 +201,26 @@ function Kt(s) {
|
|
|
201
201
|
for (; Math.round(s * t) / t !== s; ) t *= 10, e++;
|
|
202
202
|
return e;
|
|
203
203
|
}
|
|
204
|
-
const
|
|
204
|
+
const Ke = "Feature has holes", Ye = "Feature has less than 4 coordinates", $e = "Feature has invalid coordinates", He = "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: Ke };
|
|
208
|
+
if (s.geometry.coordinates[0].length < 4) return { valid: !1, reason: Ye };
|
|
209
209
|
for (let o = 0; o < s.geometry.coordinates[0].length; o++) {
|
|
210
|
-
if (!kt(s.geometry.coordinates[0][o])) return { valid: !1, reason:
|
|
210
|
+
if (!kt(s.geometry.coordinates[0][o])) return { valid: !1, reason: $e };
|
|
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: He } : { valid: !0 };
|
|
214
214
|
var e, i;
|
|
215
215
|
}
|
|
216
216
|
function lt(s, t) {
|
|
217
217
|
const e = xt(s, t);
|
|
218
|
-
return e.valid ?
|
|
218
|
+
return e.valid ? Lt(s) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
|
|
219
219
|
}
|
|
220
|
-
const
|
|
221
|
-
let
|
|
220
|
+
const qe = { cancel: "Escape", finish: "Enter" }, Je = { start: "crosshair" };
|
|
221
|
+
let fe = 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 = qe, this.cursors = Je, 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);
|
|
@@ -288,12 +288,12 @@ let ve = class extends N {
|
|
|
288
288
|
return Math.sqrt(Math.pow(c - l, 2) + Math.pow(h - 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, c = 1e3 * a, [h, u] = n, { x: p, y
|
|
291
|
+
const { center: n, radiusKilometers: a, coordinatePrecision: l } = r, d = r.steps ? r.steps : 64, c = 1e3 * a, [h, u] = n, { x: p, y } = x(h, u), g = [];
|
|
292
292
|
for (let v = 0; v < d; v++) {
|
|
293
|
-
const f = 360 * v / d * Math.PI / 180, m = c * Math.cos(f), C = c * Math.sin(f), [P, S] = [p + m,
|
|
294
|
-
|
|
293
|
+
const f = 360 * v / d * Math.PI / 180, m = c * Math.cos(f), C = c * 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");
|
|
@@ -304,7 +304,7 @@ let ve = class extends N {
|
|
|
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 Ze = { cancel: "Escape", finish: "Enter" }, Qe = { start: "crosshair", close: "pointer" };
|
|
323
|
+
class me 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 = Ze, this.cursors = Qe, 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, c] = e.coordinates[0][0], { x: h, y: u } = this.project(d, c);
|
|
352
|
+
if (E({ x: h, 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 ve({ 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 ve({ 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 _t = 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
|
}
|
|
@@ -443,16 +443,16 @@ let Lt = class extends W {
|
|
|
443
443
|
}
|
|
444
444
|
};
|
|
445
445
|
function Yt(s, t, e) {
|
|
446
|
-
const i =
|
|
447
|
-
return [
|
|
446
|
+
const i = O(s[0]), o = O(s[1]), r = O(e), n = ye(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
453
|
function $t(s, t) {
|
|
454
|
-
const e =
|
|
455
|
-
return
|
|
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,7 +461,7 @@ 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 ti(s, t, e) {
|
|
465
465
|
const i = [], o = s.length;
|
|
466
466
|
let r, n, a, l = 0;
|
|
467
467
|
for (let c = 0; c < s.length && !(t >= l && c === s.length - 1); c++) {
|
|
@@ -483,7 +483,7 @@ function ht(s) {
|
|
|
483
483
|
function Ht(s) {
|
|
484
484
|
return s * (180 / Math.PI);
|
|
485
485
|
}
|
|
486
|
-
class
|
|
486
|
+
class ei extends W {
|
|
487
487
|
constructor(t) {
|
|
488
488
|
super(t), this.config = void 0, this.config = t;
|
|
489
489
|
}
|
|
@@ -496,7 +496,7 @@ 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 c =
|
|
499
|
+
const c = ti(o, i * d, i * (d + 1));
|
|
500
500
|
a.push(c);
|
|
501
501
|
}
|
|
502
502
|
const l = [];
|
|
@@ -507,26 +507,26 @@ class oi extends W {
|
|
|
507
507
|
const o = A(t, e), r = function(n, a, l) {
|
|
508
508
|
const d = [], c = ht(n[1]), h = ht(n[0]), u = ht(a[1]), p = ht(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 - c) / 2) ** 2 + Math.cos(c) * Math.cos(u) * Math.sin((p - h) / 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(c) * Math.cos(h) + m * Math.cos(u) * Math.cos(p), P = f * Math.cos(c) * Math.sin(h) + m * Math.cos(u) * Math.sin(p), S = f * Math.sin(c) + m * Math.sin(u);
|
|
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([Ht(F), Ht(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 Ce(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++) {
|
|
@@ -546,26 +546,26 @@ function X(s, 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 [
|
|
553
|
+
const [t, e, i] = s, o = R(Math.asin(i));
|
|
554
|
+
return [R(Math.atan2(e, t)), o];
|
|
555
555
|
}
|
|
556
|
-
function
|
|
557
|
-
const i = Mt(s), o = Mt(t), r = Mt(e), [n, a, l] = r, [d, c, h] = function(B,
|
|
558
|
-
const [Bt, Nt, Gt] = B, [Tt, At, Vt] =
|
|
556
|
+
function ii(s, t, e) {
|
|
557
|
+
const i = Mt(s), o = Mt(t), r = Mt(e), [n, a, l] = r, [d, c, h] = function(B, z) {
|
|
558
|
+
const [Bt, Nt, Gt] = B, [Tt, At, Vt] = z;
|
|
559
559
|
return [Nt * Vt - Gt * At, Gt * Tt - Bt * Vt, Bt * At - Nt * Tt];
|
|
560
|
-
}(i, o), u = c * l - h * a, p = h * n - d * l,
|
|
561
|
-
let
|
|
562
|
-
return
|
|
560
|
+
}(i, o), u = c * l - h * a, p = h * n - d * l, y = d * a - c * n, g = y * c - p * h, v = u * h - y * d, f = p * d - u * c, 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
563
|
}
|
|
564
|
-
function
|
|
564
|
+
function oi(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 Pe 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
|
}
|
|
@@ -583,38 +583,38 @@ class xe extends W {
|
|
|
583
583
|
let d;
|
|
584
584
|
const c = [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: _ } = oi(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
|
|
599
|
+
return g === 1 / 0 ? void 0 : { coordinate: y, lineIndex: v, distance: g };
|
|
600
600
|
}(c, l) : this.config.projection === "globe" && (d = function(u, p) {
|
|
601
|
-
let
|
|
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] = ii(m, C, u), P && (S = A(u, P), S < g && (y = P, g = S, v = p.indexOf(f)));
|
|
606
606
|
}
|
|
607
|
-
return
|
|
607
|
+
return g === 1 / 0 ? void 0 : { coordinate: y, distance: g, lineIndex: v };
|
|
608
608
|
}(c, l)), !d) return;
|
|
609
609
|
const h = this.pixelDistance.measure(t, d.coordinate);
|
|
610
610
|
h < r.minDistance && h < this.pointerDistance && (r.featureId = n.id, r.coordinate = d.coordinate, r.featureCoordinateIndex = d.lineIndex, r.minDistance = h);
|
|
611
611
|
}), r;
|
|
612
612
|
}
|
|
613
613
|
}
|
|
614
|
-
const
|
|
615
|
-
class
|
|
614
|
+
const si = { cancel: "Escape", finish: "Enter" }, ri = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
615
|
+
class Se 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 = si, this.snapping = void 0, this.cursors = ri, 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 _t(t, new nt(t), new rt(t)), this.insertPoint = new ei(t), this.clickBoundingBox = new rt(t), this.pixelDistance = new nt(t), this.lineSnapping = new Pe(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new _t(t, this.pixelDistance, this.clickBoundingBox);
|
|
664
664
|
}
|
|
665
665
|
start() {
|
|
666
666
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -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) => Ce(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 ni = "Feature is not a Point", ai = "Feature has invalid coordinates", li = "Feature has coordinates with excessive precision";
|
|
780
|
+
function xe(s, t) {
|
|
781
|
+
return s.geometry.type !== "Point" ? { valid: !1, reason: ni } : kt(s.geometry.coordinates) ? St(s.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: li } : { valid: !1, reason: ai };
|
|
782
782
|
}
|
|
783
|
-
const
|
|
784
|
-
class
|
|
783
|
+
const di = { create: "crosshair", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
784
|
+
class Ie extends N {
|
|
785
785
|
constructor(t) {
|
|
786
|
-
super(t, !0), this.mode = "point", this.cursors =
|
|
786
|
+
super(t, !0), this.mode = "point", this.cursors = di, 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) => xe(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 ci 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 hi = { cancel: "Escape", finish: "Enter" }, ui = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
887
|
+
class be 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 = hi, this.cursors = ui, 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 Pe(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new _t(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new ci(t, this.pixelDistance);
|
|
907
907
|
}
|
|
908
908
|
start() {
|
|
909
909
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -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;
|
|
@@ -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 pi = { cancel: "Escape", finish: "Enter" }, gi = { start: "crosshair" };
|
|
1060
|
+
class Me 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 = pi, this.cursors = gi, 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 = xe(i, this.coordinatePrecision).valid || xt(i, this.coordinatePrecision).valid || Ce(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
1173
|
function jt(s, t, e) {
|
|
1174
1174
|
let i = t;
|
|
1175
1175
|
t < 0 && (i = -Math.abs(i));
|
|
1176
|
-
const o = i /
|
|
1176
|
+
const o = i / ge, 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
1179
|
const c = Math.log(Math.tan(d / 2 + Math.PI / 4) / Math.tan(n / 2 + Math.PI / 4)), h = Math.abs(c) > 1e-11 ? l / c : Math.cos(n), u = [(180 * (r + o * Math.sin(a) / h) / Math.PI + 540) % 360 - 180, 180 * d / Math.PI];
|
|
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 we(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
|
|
1186
|
+
function yi(s, t, e) {
|
|
1187
1187
|
const i = jt(s, 1e3 * A(s, t) / 2, mt(s, t));
|
|
1188
|
-
return [
|
|
1188
|
+
return [w(i[0], e), w(i[1], e)];
|
|
1189
1189
|
}
|
|
1190
1190
|
function Jt({ 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 = we(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 = yi(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 fi 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
|
}
|
|
@@ -1226,7 +1226,7 @@ class vi extends W {
|
|
|
1226
1226
|
if (this._midPoints.length !== 0) return Jt({ featureCoords: t, precision: this.coordinatePrecision, project: this.config.project, unproject: this.config.unproject, projection: this.config.projection }).map((e, i) => ({ id: this._midPoints[i], geometry: { type: "Point", coordinates: e } }));
|
|
1227
1227
|
}
|
|
1228
1228
|
}
|
|
1229
|
-
class
|
|
1229
|
+
class mi extends W {
|
|
1230
1230
|
constructor(t) {
|
|
1231
1231
|
super(t), this._selectionPoints = [];
|
|
1232
1232
|
}
|
|
@@ -1252,7 +1252,7 @@ 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 Fe(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];
|
|
@@ -1261,7 +1261,7 @@ function Oe(s, t) {
|
|
|
1261
1261
|
var i, o, r;
|
|
1262
1262
|
return e;
|
|
1263
1263
|
}
|
|
1264
|
-
const
|
|
1264
|
+
const Ee = (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,7 +1270,7 @@ 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 vi 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
|
}
|
|
@@ -1278,26 +1278,26 @@ class Pi extends W {
|
|
|
1278
1278
|
let i, o, r, n, a = 1 / 0, l = 1 / 0, d = 1 / 0;
|
|
1279
1279
|
const c = this.createClickBoundingBox.create(t), h = this.store.search(c);
|
|
1280
1280
|
for (let u = 0; u < h.length; u++) {
|
|
1281
|
-
const p = h[u],
|
|
1282
|
-
if (
|
|
1281
|
+
const p = h[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 = Ee({ 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
|
+
Fe([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 Ci 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
|
}
|
|
@@ -1324,13 +1324,13 @@ class Si extends W {
|
|
|
1324
1324
|
const c = r[d];
|
|
1325
1325
|
let h, u;
|
|
1326
1326
|
if (this.config.projection === "web-mercator") {
|
|
1327
|
-
const p = x(this.dragPosition[0], this.dragPosition[1]),
|
|
1327
|
+
const p = x(this.dragPosition[0], this.dragPosition[1]), y = x(o[0], o[1]), g = x(c[0], c[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
1328
|
h = C, u = P;
|
|
1329
1329
|
} else {
|
|
1330
1330
|
const p = [this.dragPosition[0] - o[0], this.dragPosition[1] - o[1]];
|
|
1331
1331
|
h = c[0] - p[0], u = c[1] - p[1];
|
|
1332
1332
|
}
|
|
1333
|
-
if (h =
|
|
1333
|
+
if (h = w(h, this.config.coordinatePrecision), u = w(u, this.config.coordinatePrecision), h > 180 || h < -180 || u > 90 || u < -90) return !1;
|
|
1334
1334
|
r[d] = [h, u];
|
|
1335
1335
|
}
|
|
1336
1336
|
i.type === "Polygon" && (r[r.length - 1] = [r[0][0], r[0][1]]);
|
|
@@ -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 Pi 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
|
}
|
|
@@ -1375,7 +1375,7 @@ class xi extends W {
|
|
|
1375
1375
|
n[0] = a, n[h] = a;
|
|
1376
1376
|
}
|
|
1377
1377
|
const l = this.selectionPoints.getOneUpdated(o, a), d = l ? [l] : [], c = this.midPoints.getUpdated(n) || [];
|
|
1378
|
-
return !(r.type !== "Point" && !e &&
|
|
1378
|
+
return !(r.type !== "Point" && !e && Lt({ geometry: r }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: r, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: I.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: r }, ...d, ...c]), 0));
|
|
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 Oe(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 = ge, 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);
|
|
@@ -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 Si 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
|
}
|
|
@@ -1441,9 +1441,9 @@ class Ii extends W {
|
|
|
1441
1441
|
if (n = T(Ct(a), x(t.lng, t.lat)), !this.lastBearing) return void (this.lastBearing = n);
|
|
1442
1442
|
((h, u) => {
|
|
1443
1443
|
if (u === 0 || u === 360 || u === -360) return h;
|
|
1444
|
-
const p = 0.017453292519943295 * u,
|
|
1445
|
-
|
|
1446
|
-
const v =
|
|
1444
|
+
const p = 0.017453292519943295 * u, y = (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.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
1447
|
h.geometry.type === "Polygon" ? h.geometry.coordinates[0] = v : h.geometry.coordinates = v;
|
|
1448
1448
|
})(a, -(this.lastBearing - n));
|
|
1449
1449
|
} else {
|
|
@@ -1452,22 +1452,22 @@ class Ii extends W {
|
|
|
1452
1452
|
(function(h, u) {
|
|
1453
1453
|
if (u === 0 || u === 360 || u === -360) return h;
|
|
1454
1454
|
const p = vt(h);
|
|
1455
|
-
(h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).forEach((
|
|
1456
|
-
const
|
|
1457
|
-
|
|
1455
|
+
(h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).forEach((y) => {
|
|
1456
|
+
const g = mt(p, y) + u, v = Oe(p, y), f = jt(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
1462
|
l.forEach((h) => {
|
|
1463
|
-
h[0] =
|
|
1463
|
+
h[0] = w(h[0], this.coordinatePrecision), h[1] = w(h[1], this.coordinatePrecision);
|
|
1464
1464
|
});
|
|
1465
1465
|
const d = this.midPoints.getUpdated(l) || [], c = 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
1467
|
this.store.updateGeometry([{ id: e, geometry: o }, ...c, ...d]), this.projection === "web-mercator" ? this.lastBearing = n : this.projection === "globe" && (this.lastBearing = n + 180);
|
|
1468
1468
|
}
|
|
1469
1469
|
}
|
|
1470
|
-
class
|
|
1470
|
+
class xi 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 = Oe(g, f), C = mt(g, f), P = jt(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
1505
|
const c = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
|
|
1506
1506
|
c.forEach((p) => {
|
|
1507
|
-
p[0] =
|
|
1507
|
+
p[0] = w(p[0], this.coordinatePrecision), p[1] = w(p[1], this.coordinatePrecision);
|
|
1508
1508
|
});
|
|
1509
1509
|
const h = this.midPoints.getUpdated(c) || [], u = this.selectionPoints.getUpdated(c) || [];
|
|
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
1511
|
this.store.updateGeometry([{ id: e, geometry: o }, ...u, ...h]), this.lastDistance = a;
|
|
1512
1512
|
}
|
|
1513
1513
|
}
|
|
1514
|
-
class
|
|
1514
|
+
class Ii 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
|
}
|
|
@@ -1585,7 +1585,7 @@ class Mi extends W {
|
|
|
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) {
|
|
@@ -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");
|
|
@@ -1667,16 +1667,16 @@ class Mi extends W {
|
|
|
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
1669
|
const c = r[d];
|
|
1670
|
-
if (c[0] =
|
|
1670
|
+
if (c[0] = w(c[0], this.coordinatePrecision), c[1] = w(c[1], this.coordinatePrecision), !St(c, 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 bi = { deselect: "Escape", delete: "Delete", rotate: ["Control", "r"], scale: ["Control", "s"] }, Zt = { pointerOver: "move", dragStart: "move", dragEnd: "move", insertMidpoint: "crosshair" };
|
|
1677
|
+
class De extends ze {
|
|
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 = bi, this.cursors = Zt, this.validations = {}, this.selectionPoints = void 0, this.midPoints = void 0, this.featuresAtMouseEvent = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.dragFeature = void 0, this.dragCoordinate = void 0, this.rotateFeature = void 0, this.scaleFeature = void 0, this.dragCoordinateResizeFeature = void 0, this.updateOptions(t);
|
|
1680
1680
|
}
|
|
1681
1681
|
updateOptions(t) {
|
|
1682
1682
|
if (super.updateOptions(t), this.cursors = t && t.cursors ? b({}, this.cursors, t.cursors) : Zt, (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { deselect: null, delete: null, rotate: null, scale: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents)), (t == null ? void 0 : t.dragEventThrottle) !== void 0 && (this.dragEventThrottle = t.dragEventThrottle), (t == null ? void 0 : t.allowManualDeselection) !== void 0 && (this.allowManualDeselection = t.allowManualDeselection), t != null && t.flags) {
|
|
@@ -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 vi(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new mi(t), this.midPoints = new fi(t, this.selectionPoints), this.rotateFeature = new Si(t, this.selectionPoints, this.midPoints), this.scaleFeature = new xi(t, this.selectionPoints, this.midPoints), this.dragFeature = new Ci(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints), this.dragCoordinate = new Pi(t, this.pixelDistance, this.selectionPoints, this.midPoints), this.dragCoordinateResizeFeature = new Ii(t, this.pixelDistance, this.selectionPoints, this.midPoints);
|
|
1699
1699
|
}
|
|
1700
1700
|
deselectFeature() {
|
|
1701
1701
|
this.deselect();
|
|
@@ -1839,7 +1839,7 @@ class _e extends Ke {
|
|
|
1839
1839
|
return e;
|
|
1840
1840
|
}
|
|
1841
1841
|
}
|
|
1842
|
-
class
|
|
1842
|
+
class Mi 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 _e(s, t, e, i, o) {
|
|
1871
1871
|
for (; i > e; ) {
|
|
1872
1872
|
if (i - e > 600) {
|
|
1873
1873
|
const l = i - e + 1, d = t - e + 1, c = Math.log(l), h = 0.5 * Math.exp(2 * c / 3), u = 0.5 * Math.sqrt(c * h * (l - h) / l) * (d - l / 2 < 0 ? -1 : 1);
|
|
1874
|
-
|
|
1874
|
+
_e(s, t, Math.max(e, Math.floor(t - d * h / l + u)), Math.min(i, Math.floor(t + (l - d) * h / 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 wi(s, t) {
|
|
1904
1904
|
return s.minX - t.minX;
|
|
1905
1905
|
}
|
|
1906
|
-
function
|
|
1906
|
+
function Fi(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 Ei(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
|
}
|
|
@@ -1930,10 +1930,10 @@ function Qt(s, t, e, i, o) {
|
|
|
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
|
+
_e(s, n, t, e, o), r.push(t, n, n, e);
|
|
1934
1934
|
}
|
|
1935
1935
|
}
|
|
1936
|
-
class
|
|
1936
|
+
class Oi {
|
|
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
|
}
|
|
@@ -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), c =
|
|
2065
|
+
const l = it(t, 0, a, this.toBBox), d = it(t, a, i, this.toBBox), c = Ei(l, d), h = wt(l) + wt(d);
|
|
2066
2066
|
c < r ? (r = c, o = a, n = h < n ? h : n) : c === r && h < n && (n = h, 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 : wi, r = t.leaf ? this.compareMinY : Fi;
|
|
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) {
|
|
@@ -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 Di {
|
|
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 Oi(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 _i = { 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 Li {
|
|
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 Di(), this.tracked = !t || t.tracked !== !1, this.idStrategy = t && t.idStrategy ? t.idStrategy : _i;
|
|
2156
2156
|
}
|
|
2157
2157
|
clone(t) {
|
|
2158
2158
|
return JSON.parse(JSON.stringify(t));
|
|
@@ -2249,16 +2249,16 @@ class ji {
|
|
|
2249
2249
|
return Object.keys(this.store).length;
|
|
2250
2250
|
}
|
|
2251
2251
|
}
|
|
2252
|
-
const
|
|
2252
|
+
const ki = "Feature is not a Polygon or LineString", ji = "Feature intersects itself", Wi = (s) => s.geometry.type !== "Polygon" && s.geometry.type !== "LineString" ? { valid: !1, reason: ki } : Lt(s) ? { valid: !1, reason: ji } : { valid: !0 };
|
|
2253
2253
|
function te(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 Bi = { cancel: "Escape", finish: "Enter" }, Ni = { start: "crosshair", close: "pointer" };
|
|
2259
|
+
class Le 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 = Bi, this.cursors = Ni, 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 = we(o, r, this.coordinatePrecision, this.project, this.unproject), a = x(o[0], o[1]), l = x(n[0], n[1]), d = x(r[0], r[1]), c = x(t.lng, t.lat), h = E(c, a) < E(c, d), u = te(a, l, c), p = h ? 90 - u : te(a, l, c) - 90, y = E(l, c), 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, c) === "right" ? -90 : 90), f = at(a,
|
|
2288
|
+
}(a, d, c) === "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 ke(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 Gi = { cancel: "Escape", finish: "Enter" }, Ti = { start: "crosshair", close: "pointer" };
|
|
2341
|
+
class je 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 = Gi, this.direction = void 0, this.arcPoints = 64, this.cursors = Ti, 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 = ke(a, l, d);
|
|
2372
2372
|
this.direction = C ? "clockwise" : "anticlockwise";
|
|
2373
2373
|
}
|
|
2374
|
-
const c =
|
|
2374
|
+
const c = E(a, l), h = T(a, l), u = T(a, d), p = this.arcPoints, y = [o], g = Y(h), 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, c,
|
|
2381
|
-
|
|
2380
|
+
const P = at(a, c, 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 Ai = { cancel: "Escape", finish: "Enter" }, Vi = { start: "crosshair", close: "pointer" };
|
|
2428
|
+
class We 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 = Ai, this.direction = void 0, this.arcPoints = 64, this.cursors = Vi, 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 = ke(l, n, a);
|
|
2456
2456
|
this.direction = m ? "clockwise" : "anticlockwise";
|
|
2457
2457
|
}
|
|
2458
|
-
const c = T(l, n), h = T(l, a), u = this.arcPoints, p = [o],
|
|
2458
|
+
const c = T(l, n), h = T(l, a), u = this.arcPoints, p = [o], y = Y(c), g = Y(h);
|
|
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]), c =
|
|
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]), c = E(d, a), h = E(d, n) < c ? 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, h), 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,9 +2528,108 @@ 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 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 Ui = { __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
|
+
} };
|
|
2531
2630
|
class Ri {
|
|
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
|
|
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 Mi();
|
|
2534
2633
|
const e = /* @__PURE__ */ new Set(), i = t.modes.reduce((c, h) => {
|
|
2535
2634
|
if (e.has(h.mode)) throw new Error(`There is already a ${h.mode} mode provided`);
|
|
2536
2635
|
return e.add(h.mode), c[h.mode] = h, c;
|
|
@@ -2541,7 +2640,7 @@ class Ri {
|
|
|
2541
2640
|
if (this._instanceSelectMode) throw new Error("only one type of select mode can be provided");
|
|
2542
2641
|
this._instanceSelectMode = c;
|
|
2543
2642
|
}
|
|
2544
|
-
}), this._modes = b({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new
|
|
2643
|
+
}), this._modes = b({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new Li({ tracked: !!t.tracked, idStrategy: t.idStrategy ? t.idStrategy : void 0 });
|
|
2545
2644
|
const r = (c) => {
|
|
2546
2645
|
const h = [], u = this._store.copyAll().filter((p) => !c.includes(p.id) || (h.push(p), !1));
|
|
2547
2646
|
return { changed: h, unchanged: u };
|
|
@@ -2551,8 +2650,8 @@ class Ri {
|
|
|
2551
2650
|
});
|
|
2552
2651
|
}, a = (c, h) => {
|
|
2553
2652
|
if (!this._enabled) return;
|
|
2554
|
-
this._eventListeners.change.forEach((
|
|
2555
|
-
|
|
2653
|
+
this._eventListeners.change.forEach((y) => {
|
|
2654
|
+
y(c, h);
|
|
2556
2655
|
});
|
|
2557
2656
|
const { changed: u, unchanged: p } = r(c);
|
|
2558
2657
|
h === "create" ? this._adapter.render({ created: u, deletedIds: [], unchanged: p, updated: [] }, this.getModeStyles()) : h === "update" ? this._adapter.render({ created: [], deletedIds: [], unchanged: p, updated: u }, this.getModeStyles()) : h === "delete" ? this._adapter.render({ created: [], deletedIds: c, unchanged: p, updated: [] }, this.getModeStyles()) : h === "styling" && this._adapter.render({ created: [], deletedIds: [], unchanged: p, updated: [] }, this.getModeStyles());
|
|
@@ -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 =
|
|
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 = ve({ unproject: n, point: l, pointerDistance: o });
|
|
2589
2688
|
return this._store.search(d).filter((c) => {
|
|
2590
2689
|
if (r && (c.properties[U.MID_POINT] || c.properties[U.SELECTION_POINT])) return !1;
|
|
2591
2690
|
if (c.geometry.type === "Point") {
|
|
2592
2691
|
const h = c.geometry.coordinates, u = a(h[0], h[1]);
|
|
2593
|
-
return
|
|
2692
|
+
return E(l, u) < o;
|
|
2594
2693
|
}
|
|
2595
2694
|
if (c.geometry.type === "LineString") {
|
|
2596
2695
|
const h = c.geometry.coordinates;
|
|
2597
2696
|
for (let u = 0; u < h.length - 1; u++) {
|
|
2598
|
-
const p = h[u],
|
|
2599
|
-
if (
|
|
2697
|
+
const p = h[u], y = h[u + 1];
|
|
2698
|
+
if (Ee(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 !!Fe([t, e], c.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 zi extends Ui.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 });
|
|
@@ -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 Oo = [
|
|
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
|
+
], Xi = {
|
|
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 Ie({
|
|
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 Se({
|
|
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 be({
|
|
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 Me({
|
|
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 Le({
|
|
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 fe({
|
|
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 me({
|
|
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 We({
|
|
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 je({
|
|
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 De({
|
|
3062
3051
|
flags: {
|
|
3063
3052
|
point: {
|
|
3064
3053
|
feature: {
|
|
@@ -3216,7 +3205,7 @@ const _o = [
|
|
|
3216
3205
|
["==", ["get", "total"], 0],
|
|
3217
3206
|
"",
|
|
3218
3207
|
["concat", `
|
|
3219
|
-
(`, ["to-string", ["get", "total"]], " ", ["get", "
|
|
3208
|
+
(`, ["to-string", ["get", "total"]], " ", ["get", "totalUnit"], ")"]
|
|
3220
3209
|
],
|
|
3221
3210
|
[
|
|
3222
3211
|
"case",
|
|
@@ -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
|
+
}, Ki = () => ({
|
|
3316
3305
|
render: new et({
|
|
3317
3306
|
modeName: "render",
|
|
3318
3307
|
styles: {}
|
|
3319
3308
|
}),
|
|
3320
|
-
point: new
|
|
3309
|
+
point: new Ie({
|
|
3321
3310
|
editable: !0
|
|
3322
3311
|
}),
|
|
3323
|
-
linestring: new
|
|
3312
|
+
linestring: new Se({
|
|
3324
3313
|
editable: !0
|
|
3325
3314
|
}),
|
|
3326
|
-
polygon: new
|
|
3315
|
+
polygon: new be({
|
|
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" ? Wi(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 Me(),
|
|
3325
|
+
"angled-rectangle": new Le(),
|
|
3326
|
+
circle: new fe(),
|
|
3327
|
+
freehand: new me(),
|
|
3328
|
+
sensor: new We(),
|
|
3329
|
+
sector: new je(),
|
|
3330
|
+
select: new De({
|
|
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, Yi = {
|
|
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 $i(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 Hi(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 (!ee(s[0]) || !ee(s[1]))
|
|
3484
3473
|
throw new Error("coordinates must contain numbers");
|
|
3485
|
-
return
|
|
3474
|
+
return $i({
|
|
3486
3475
|
type: "Point",
|
|
3487
3476
|
coordinates: s
|
|
3488
3477
|
}, t, e);
|
|
3489
3478
|
}
|
|
3490
|
-
function
|
|
3491
|
-
const e =
|
|
3479
|
+
function qi(s, t = "kilometers") {
|
|
3480
|
+
const e = Yi[t];
|
|
3492
3481
|
if (!e)
|
|
3493
3482
|
throw new Error(t + " units is invalid");
|
|
3494
3483
|
return s * e;
|
|
@@ -3496,13 +3485,13 @@ function Zi(s, t = "kilometers") {
|
|
|
3496
3485
|
function gt(s) {
|
|
3497
3486
|
return s % 360 * Math.PI / 180;
|
|
3498
3487
|
}
|
|
3499
|
-
function
|
|
3488
|
+
function ee(s) {
|
|
3500
3489
|
return !isNaN(s) && s !== null && !Array.isArray(s);
|
|
3501
3490
|
}
|
|
3502
|
-
function
|
|
3491
|
+
function Be(s, t, e) {
|
|
3503
3492
|
if (s !== null)
|
|
3504
|
-
for (var i, o, r, n, a, l, d, c = 0, h = 0, u, p = s.type,
|
|
3505
|
-
d =
|
|
3493
|
+
for (var i, o, r, n, a, l, d, c = 0, h = 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) {
|
|
@@ -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 (Be(n.geometries[i], t) === !1)
|
|
3580
3569
|
return !1;
|
|
3581
3570
|
break;
|
|
3582
3571
|
default:
|
|
@@ -3586,10 +3575,10 @@ function Ge(s, t, e) {
|
|
|
3586
3575
|
}
|
|
3587
3576
|
}
|
|
3588
3577
|
}
|
|
3589
|
-
function
|
|
3590
|
-
var e, i, o, r, n, a, l, d, c, h, u = 0, p = s.type === "FeatureCollection",
|
|
3591
|
-
for (e = 0; e <
|
|
3592
|
-
for (a = p ? s.features[e].geometry :
|
|
3578
|
+
function Ji(s, t) {
|
|
3579
|
+
var e, i, o, r, n, a, l, d, c, h, 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 : {}, c = p ? s.features[e].bbox : y ? s.bbox : void 0, h = 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,
|
|
@@ -3637,9 +3626,9 @@ function Qi(s, t) {
|
|
|
3637
3626
|
u++;
|
|
3638
3627
|
}
|
|
3639
3628
|
}
|
|
3640
|
-
function
|
|
3629
|
+
function Zi(s, t, e) {
|
|
3641
3630
|
var i = e;
|
|
3642
|
-
return
|
|
3631
|
+
return Ji(
|
|
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 Qi(s) {
|
|
3646
|
+
return Zi(
|
|
3658
3647
|
s,
|
|
3659
|
-
(t, e) => t +
|
|
3648
|
+
(t, e) => t + to(e),
|
|
3660
3649
|
0
|
|
3661
3650
|
);
|
|
3662
3651
|
}
|
|
3663
|
-
function
|
|
3652
|
+
function to(s) {
|
|
3664
3653
|
let t = 0, e;
|
|
3665
3654
|
switch (s.type) {
|
|
3666
3655
|
case "Polygon":
|
|
3667
|
-
return
|
|
3656
|
+
return ie(s.coordinates);
|
|
3668
3657
|
case "MultiPolygon":
|
|
3669
3658
|
for (e = 0; e < s.coordinates.length; e++)
|
|
3670
|
-
t +=
|
|
3659
|
+
t += ie(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 ie(s) {
|
|
3681
3670
|
let t = 0;
|
|
3682
3671
|
if (s && s.length > 0) {
|
|
3683
|
-
t += Math.abs(
|
|
3672
|
+
t += Math.abs(oe(s[0]));
|
|
3684
3673
|
for (let e = 1; e < s.length; e++)
|
|
3685
|
-
t -= Math.abs(
|
|
3674
|
+
t -= Math.abs(oe(s[e]));
|
|
3686
3675
|
}
|
|
3687
3676
|
return t;
|
|
3688
3677
|
}
|
|
3689
|
-
var
|
|
3690
|
-
function
|
|
3678
|
+
var eo = L * L / 2, Et = Math.PI / 180;
|
|
3679
|
+
function oe(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 * eo;
|
|
3699
3688
|
}
|
|
3700
|
-
var
|
|
3701
|
-
const
|
|
3689
|
+
var io = Qi;
|
|
3690
|
+
const oo = (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
|
+
}, se = (s, t, e) => {
|
|
3705
3694
|
if (s.geometry.type !== "Polygon") return s;
|
|
3706
|
-
const i =
|
|
3695
|
+
const i = io(s.geometry), o = oo(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 re(s) {
|
|
3710
3699
|
if (!s)
|
|
3711
3700
|
throw new Error("coord is required");
|
|
3712
3701
|
if (!Array.isArray(s)) {
|
|
@@ -3719,52 +3708,87 @@ 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 so(s, t, e = {}) {
|
|
3712
|
+
var i = re(s), o = re(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 qi(
|
|
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 ro = so;
|
|
3719
|
+
const ne = (s) => s === "degrees" ? "°" : s === "miles" ? "mi" : s === "radians" ? "rad" : "km", Ot = (s) => {
|
|
3720
|
+
if (s >= 1)
|
|
3721
|
+
return {
|
|
3722
|
+
distance: s,
|
|
3723
|
+
unit: "km"
|
|
3724
|
+
};
|
|
3725
|
+
const t = s * 1e3;
|
|
3726
|
+
return t >= 1 ? {
|
|
3727
|
+
distance: t,
|
|
3728
|
+
unit: "m"
|
|
3729
|
+
} : {
|
|
3730
|
+
distance: t * 100,
|
|
3731
|
+
unit: "cm"
|
|
3732
|
+
};
|
|
3733
|
+
}, ae = (s, t, e, i, o, r) => {
|
|
3731
3734
|
if (s.geometry.type !== "LineString") return s;
|
|
3732
3735
|
const n = s.geometry.coordinates;
|
|
3733
3736
|
let a = 0;
|
|
3734
3737
|
const l = [];
|
|
3735
3738
|
for (let d = 0; d < n.length - 1; d++) {
|
|
3736
|
-
const c = n[d], h = n[d + 1], u =
|
|
3739
|
+
const c = n[d], h = n[d + 1], u = ro(c, h, { units: t });
|
|
3737
3740
|
a += u;
|
|
3738
3741
|
const p = JSON.parse(JSON.stringify(s));
|
|
3739
|
-
if (p.id = `${p.id}-${d}`, p.geometry.coordinates = [c, h], p.properties.originalId = s.id, p.properties.distance =
|
|
3740
|
-
const
|
|
3741
|
-
|
|
3742
|
-
const
|
|
3743
|
-
|
|
3742
|
+
if (p.id = `${p.id}-${d}`, p.geometry.coordinates = [c, h], p.properties.originalId = s.id, p.properties.distance = u, p.properties.total = a, p.properties.unit = ne(t), p.properties.totalUnit = ne(t), o === !0 && r === void 0) {
|
|
3743
|
+
const y = i == null ? void 0 : i.queryTerrainElevation(c);
|
|
3744
|
+
y && (p.properties.elevation_start = y);
|
|
3745
|
+
const g = i == null ? void 0 : i.queryTerrainElevation(h);
|
|
3746
|
+
g && (p.properties.elevation_end = g);
|
|
3744
3747
|
}
|
|
3745
3748
|
l.push(p);
|
|
3746
3749
|
}
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3750
|
+
if (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)), t === "kilometers") {
|
|
3751
|
+
const d = Ot(s.properties.distance);
|
|
3752
|
+
s.properties.distance = d.distance, s.properties.unit = d.unit, s.properties.segments.forEach(
|
|
3753
|
+
(c) => {
|
|
3754
|
+
const h = Ot(c.properties.distance);
|
|
3755
|
+
c.properties.distance = h.distance, c.properties.unit = h.unit;
|
|
3756
|
+
const u = Ot(c.properties.total);
|
|
3757
|
+
c.properties.total = u.distance, c.properties.totalUnit = u.unit;
|
|
3758
|
+
}
|
|
3759
|
+
);
|
|
3760
|
+
}
|
|
3761
|
+
return s.properties.distance = parseFloat(
|
|
3762
|
+
s.properties.distance.toFixed(e)
|
|
3763
|
+
), s.properties.segments.forEach(
|
|
3764
|
+
(d) => {
|
|
3765
|
+
d.properties.distance = parseFloat(
|
|
3766
|
+
d.properties.distance.toFixed(e)
|
|
3767
|
+
), d.properties.total = parseFloat(
|
|
3768
|
+
d.properties.total.toFixed(e)
|
|
3769
|
+
);
|
|
3770
|
+
}
|
|
3771
|
+
), s;
|
|
3772
|
+
}, le = (s) => s.charAt(0).toUpperCase() + s.slice(1), It = ["td-point", "td-linestring", "td-polygon"];
|
|
3773
|
+
var he, ue, pe;
|
|
3774
|
+
const Do = [
|
|
3751
3775
|
...It,
|
|
3752
|
-
(
|
|
3753
|
-
(
|
|
3754
|
-
(
|
|
3755
|
-
],
|
|
3776
|
+
(he = yt.polygonLayerSpec) == null ? void 0 : he.source,
|
|
3777
|
+
(ue = yt.lineLayerLabelSpec) == null ? void 0 : ue.source,
|
|
3778
|
+
(pe = yt.pointLayerLabelSpec) == null ? void 0 : pe.source
|
|
3779
|
+
], Ne = (s, t, e = It) => {
|
|
3756
3780
|
const i = JSON.parse(JSON.stringify(s));
|
|
3757
3781
|
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
3782
|
e.includes(o) || delete i.sources[o];
|
|
3759
3783
|
})) : t.excludeTerraDrawLayers === !0 && (i.layers = i.layers.filter((o) => "source" in o && !e.includes(o.source)), Object.keys(i.sources).forEach((o) => {
|
|
3760
3784
|
e.includes(o) && delete i.sources[o];
|
|
3761
3785
|
}))), i;
|
|
3762
|
-
},
|
|
3786
|
+
}, no = (s, t = 250) => {
|
|
3763
3787
|
let e;
|
|
3764
3788
|
return (...i) => {
|
|
3765
3789
|
clearTimeout(e), e = setTimeout(() => s(...i), t);
|
|
3766
3790
|
};
|
|
3767
|
-
},
|
|
3791
|
+
}, de = (s, t, e, i) => {
|
|
3768
3792
|
if (s.geometry.type !== "Point") return s;
|
|
3769
3793
|
const o = s.geometry.coordinates;
|
|
3770
3794
|
if (e === !0 && i === void 0) {
|
|
@@ -3773,58 +3797,58 @@ const ko = [
|
|
|
3773
3797
|
}
|
|
3774
3798
|
return s;
|
|
3775
3799
|
};
|
|
3776
|
-
var
|
|
3777
|
-
function
|
|
3800
|
+
var ao = Object.defineProperty, lo = (s, t, e) => t in s ? ao(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, tt = (s, t, e) => lo(s, typeof t != "symbol" ? t + "" : t, e), Pt = 2 * Math.PI * 6378137 / 2;
|
|
3801
|
+
function co(s) {
|
|
3778
3802
|
return s = s || 256, 2 * Math.PI * 6378137 / s;
|
|
3779
3803
|
}
|
|
3780
|
-
function
|
|
3804
|
+
function ho(s, t, e = { enable: !0, decimal: 1 }) {
|
|
3781
3805
|
s = Wt(s);
|
|
3782
3806
|
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
3807
|
return n = n * Pt / 180, e.enable && (r = Number(r.toFixed(e.decimal)), n = Number(n.toFixed(e.decimal))), [r, n];
|
|
3784
3808
|
}
|
|
3785
|
-
function
|
|
3786
|
-
var i = s[0], o = s[1], r =
|
|
3809
|
+
function uo(s, t, e) {
|
|
3810
|
+
var i = s[0], o = s[1], r = vo(t, e), n = (i + Pt) / r, a = (o + Pt) / r;
|
|
3787
3811
|
return [n, a, t];
|
|
3788
3812
|
}
|
|
3789
|
-
function
|
|
3813
|
+
function Ge(s, t, e) {
|
|
3790
3814
|
s = Wt(s);
|
|
3791
|
-
var i =
|
|
3792
|
-
return
|
|
3815
|
+
var i = ho(s), o = uo(i, t);
|
|
3816
|
+
return go(o);
|
|
3793
3817
|
}
|
|
3794
|
-
function
|
|
3818
|
+
function po(s, t, e) {
|
|
3795
3819
|
if (s = Wt(s), t === 0)
|
|
3796
3820
|
return [0, 0, 0];
|
|
3797
|
-
var i =
|
|
3798
|
-
return
|
|
3821
|
+
var i = Ge(s, t);
|
|
3822
|
+
return yo(i);
|
|
3799
3823
|
}
|
|
3800
|
-
function
|
|
3824
|
+
function go(s, t, e) {
|
|
3801
3825
|
t = t || 256;
|
|
3802
3826
|
var i = s[0], o = s[1], r = s[2];
|
|
3803
3827
|
if (r === 0) return [0, 0, 0];
|
|
3804
|
-
|
|
3828
|
+
Te(r);
|
|
3805
3829
|
var n = Math.ceil(i / t) - 1, a = Math.ceil(o / t) - 1;
|
|
3806
3830
|
return n < 0 && (n = 0), a < 0 && (a = 0), [n, a, r];
|
|
3807
3831
|
}
|
|
3808
|
-
function
|
|
3809
|
-
|
|
3832
|
+
function yo(s, t) {
|
|
3833
|
+
fo(s);
|
|
3810
3834
|
var e = s[0], i = s[1], o = s[2];
|
|
3811
3835
|
if (o === 0)
|
|
3812
3836
|
return [0, 0, 0];
|
|
3813
3837
|
var r = e, n = Math.pow(2, o) - 1 - i;
|
|
3814
3838
|
return [r, n, o];
|
|
3815
3839
|
}
|
|
3816
|
-
function
|
|
3840
|
+
function fo(s, t) {
|
|
3817
3841
|
var e = s[0], i = s[1], o = s[2];
|
|
3818
3842
|
if (o == null) throw new Error("<zoom> is required");
|
|
3819
3843
|
if (e == null) throw new Error("<x> is required");
|
|
3820
3844
|
if (i == null) throw new Error("<y> is required");
|
|
3821
|
-
return o =
|
|
3845
|
+
return o = Te(o), s = mo(s), s;
|
|
3822
3846
|
}
|
|
3823
|
-
function
|
|
3847
|
+
function mo(s) {
|
|
3824
3848
|
var t = s[0], e = s[1], i = s[2], o = Math.pow(2, i);
|
|
3825
3849
|
return t = t % o, t < 0 && (t = t + o), [t, e, i];
|
|
3826
3850
|
}
|
|
3827
|
-
function
|
|
3851
|
+
function Te(s) {
|
|
3828
3852
|
if (s === !1) return s;
|
|
3829
3853
|
if (s == null)
|
|
3830
3854
|
throw new Error("<zoom> is required");
|
|
@@ -3835,21 +3859,21 @@ function Ve(s) {
|
|
|
3835
3859
|
return s;
|
|
3836
3860
|
}
|
|
3837
3861
|
function Wt(s, t) {
|
|
3838
|
-
var e =
|
|
3862
|
+
var e = Po(s[0]), i = Co(s[1]);
|
|
3839
3863
|
return i > 85 && (i = 85), i < -85 && (i = -85), [e, i];
|
|
3840
3864
|
}
|
|
3841
|
-
function
|
|
3842
|
-
return
|
|
3865
|
+
function vo(s, t) {
|
|
3866
|
+
return co(t) / Math.pow(2, s);
|
|
3843
3867
|
}
|
|
3844
|
-
function
|
|
3868
|
+
function Co(s) {
|
|
3845
3869
|
if (s == null) throw new Error("lat is required");
|
|
3846
3870
|
return (s > 90 || s < -90) && (s = s % 180, s > 90 && (s = -180 + s), s < -90 && (s = 180 + s), s === 0 && (s = 0)), s;
|
|
3847
3871
|
}
|
|
3848
|
-
function
|
|
3872
|
+
function Po(s) {
|
|
3849
3873
|
if (s == null) throw new Error("lng is required");
|
|
3850
3874
|
return (s > 180 || s < -180) && (s = s % 360, s > 180 && (s = -360 + s), s < -180 && (s = 360 + s), s === 0 && (s = 0)), s;
|
|
3851
3875
|
}
|
|
3852
|
-
class
|
|
3876
|
+
class Ae {
|
|
3853
3877
|
/**
|
|
3854
3878
|
* Constructor
|
|
3855
3879
|
* @param url URL for terrain RGB raster tilesets
|
|
@@ -3874,7 +3898,7 @@ class Ue {
|
|
|
3874
3898
|
const r = t[0], n = t[1];
|
|
3875
3899
|
let a = e;
|
|
3876
3900
|
e > this.maxzoom ? a = this.maxzoom : e < this.minzoom && (a = this.minzoom);
|
|
3877
|
-
const l = this.tms ?
|
|
3901
|
+
const l = this.tms ? Ge([r, n], a) : po([r, n], a), d = this.url.replace(/{x}/g, l[0].toString()).replace(/{y}/g, l[1].toString()).replace(/{z}/g, l[2].toString());
|
|
3878
3902
|
let c = this.getUrlExtension(d);
|
|
3879
3903
|
switch (c || (c = "png"), c) {
|
|
3880
3904
|
case "png":
|
|
@@ -3914,8 +3938,8 @@ class Ue {
|
|
|
3914
3938
|
const h = c.getContext("2d");
|
|
3915
3939
|
if (!h) return l(new Error("Failed to create canvas context"));
|
|
3916
3940
|
h.drawImage(d, 0, 0);
|
|
3917
|
-
const u = h.getImageData(0, 0, d.width, d.height).data, p = this.pixels2rgba(new Uint8Array(u), e, i, o),
|
|
3918
|
-
a(
|
|
3941
|
+
const u = h.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]);
|
|
3942
|
+
a(y);
|
|
3919
3943
|
}, d.onerror = () => a(void 0), d.src = URL.createObjectURL(n);
|
|
3920
3944
|
});
|
|
3921
3945
|
}
|
|
@@ -3930,8 +3954,8 @@ class Ue {
|
|
|
3930
3954
|
pixels2rgba(t, e, i, o) {
|
|
3931
3955
|
const r = [];
|
|
3932
3956
|
for (let d = 0; d < t.length; d += 4) {
|
|
3933
|
-
const c = t[d], h = t[d + 1], u = t[d + 2], p = t[d + 3],
|
|
3934
|
-
r.push(
|
|
3957
|
+
const c = t[d], h = t[d + 1], u = t[d + 2], p = t[d + 3], y = [c, h, u, p];
|
|
3958
|
+
r.push(y);
|
|
3935
3959
|
}
|
|
3936
3960
|
const n = this.tileToBBOX(e), a = this.getPixelPosition(i, o, n), l = a[0] + a[1] * this.tileSize;
|
|
3937
3961
|
return r[l];
|
|
@@ -3976,7 +4000,7 @@ class Ue {
|
|
|
3976
4000
|
return i * Math.atan(0.5 * (Math.exp(o) - Math.exp(-o)));
|
|
3977
4001
|
}
|
|
3978
4002
|
}
|
|
3979
|
-
class
|
|
4003
|
+
class So extends Ae {
|
|
3980
4004
|
/**
|
|
3981
4005
|
* Constructor
|
|
3982
4006
|
* @param url URL for terrain RGB raster tilesets
|
|
@@ -4008,7 +4032,7 @@ class bo extends Ue {
|
|
|
4008
4032
|
return -1e4 + (t * 256 * 256 + e * 256 + i) * 0.1;
|
|
4009
4033
|
}
|
|
4010
4034
|
}
|
|
4011
|
-
class
|
|
4035
|
+
class xo extends Ae {
|
|
4012
4036
|
/**
|
|
4013
4037
|
* Constructor
|
|
4014
4038
|
* @param url URL for terrarium raster tilesets
|
|
@@ -4042,14 +4066,14 @@ class Mo extends Ue {
|
|
|
4042
4066
|
return parseInt(o.toFixed(0));
|
|
4043
4067
|
}
|
|
4044
4068
|
}
|
|
4045
|
-
const
|
|
4069
|
+
const ce = async (s, t) => {
|
|
4046
4070
|
const e = [];
|
|
4047
4071
|
for (const i of s)
|
|
4048
4072
|
e.push(
|
|
4049
4073
|
new Promise((o) => {
|
|
4050
4074
|
if (i.geometry.type !== "Point" && o(i), t) {
|
|
4051
4075
|
const r = t.url, n = t.encoding ?? "mapbox", a = t.tileSize ?? 512, l = t.minzoom ?? 5, d = t.maxzoom ?? 15, c = t.tms ?? !1;
|
|
4052
|
-
(n === "mapbox" ? new
|
|
4076
|
+
(n === "mapbox" ? new So(r, a, l, d, c) : new xo(r, a, l, d, c)).getElevation(i.geometry.coordinates, d).then((h) => {
|
|
4053
4077
|
h && (i.properties.elevation = h), o(i);
|
|
4054
4078
|
}).catch(() => o(i));
|
|
4055
4079
|
} else
|
|
@@ -4057,7 +4081,7 @@ const ue = async (s, t) => {
|
|
|
4057
4081
|
})
|
|
4058
4082
|
);
|
|
4059
4083
|
return await Promise.all(e);
|
|
4060
|
-
},
|
|
4084
|
+
}, _o = (s, t = 9) => {
|
|
4061
4085
|
function e(o) {
|
|
4062
4086
|
return [Number(o[0].toFixed(t)), Number(o[1].toFixed(t))];
|
|
4063
4087
|
}
|
|
@@ -4092,7 +4116,7 @@ const ue = async (s, t) => {
|
|
|
4092
4116
|
geometry: i(o.geometry)
|
|
4093
4117
|
}));
|
|
4094
4118
|
};
|
|
4095
|
-
class
|
|
4119
|
+
class Io {
|
|
4096
4120
|
/**
|
|
4097
4121
|
* Constructor
|
|
4098
4122
|
* @param options Plugin control options
|
|
@@ -4103,7 +4127,7 @@ class wo {
|
|
|
4103
4127
|
k(this, "modeButtons", {});
|
|
4104
4128
|
k(this, "_isExpanded", !1);
|
|
4105
4129
|
k(this, "terradraw");
|
|
4106
|
-
k(this, "options",
|
|
4130
|
+
k(this, "options", Xi);
|
|
4107
4131
|
k(this, "events", {});
|
|
4108
4132
|
k(this, "defaultMode", "render");
|
|
4109
4133
|
this.modeButtons = {}, t && (this.options = Object.assign(this.options, t));
|
|
@@ -4147,7 +4171,7 @@ class wo {
|
|
|
4147
4171
|
if (this.options && this.options.modes && this.options.modes.length === 0)
|
|
4148
4172
|
throw new Error("At least a mode must be enabled.");
|
|
4149
4173
|
this.map = t;
|
|
4150
|
-
const e =
|
|
4174
|
+
const e = Ki(), i = [];
|
|
4151
4175
|
return (r = (o = this.options) == null ? void 0 : o.modes) == null || r.forEach((d) => {
|
|
4152
4176
|
if (this.options.modeOptions && this.options.modeOptions[d]) {
|
|
4153
4177
|
const c = this.options.modeOptions[d];
|
|
@@ -4170,7 +4194,7 @@ class wo {
|
|
|
4170
4194
|
styles: {}
|
|
4171
4195
|
})
|
|
4172
4196
|
), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new Ri({
|
|
4173
|
-
adapter: new
|
|
4197
|
+
adapter: new zi({ map: t, ...this.options.adapterOptions }),
|
|
4174
4198
|
modes: i
|
|
4175
4199
|
}), 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
4200
|
d.mode !== "default" && this.addTerradrawButton(d.mode);
|
|
@@ -4267,7 +4291,7 @@ class wo {
|
|
|
4267
4291
|
*/
|
|
4268
4292
|
addTerradrawButton(t) {
|
|
4269
4293
|
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 =
|
|
4294
|
+
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 = le("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 = le(t.replace(/-/g, " ")), t === "delete" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.addEventListener("click", () => {
|
|
4271
4295
|
this.terradraw && this.terradraw.enabled && (this.terradraw.clear(), this.deactivate(), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.dispatchEvent("feature-deleted"));
|
|
4272
4296
|
})) : t === "delete-selection" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.classList.add("hidden-delete-selection"), e.addEventListener("click", () => {
|
|
4273
4297
|
var r;
|
|
@@ -4317,7 +4341,7 @@ class wo {
|
|
|
4317
4341
|
* @returns
|
|
4318
4342
|
*/
|
|
4319
4343
|
cleanStyle(t, e) {
|
|
4320
|
-
return
|
|
4344
|
+
return Ne(t, e, It);
|
|
4321
4345
|
}
|
|
4322
4346
|
/**
|
|
4323
4347
|
* Download button click event handler
|
|
@@ -4363,16 +4387,16 @@ class wo {
|
|
|
4363
4387
|
}
|
|
4364
4388
|
}
|
|
4365
4389
|
}
|
|
4366
|
-
function
|
|
4390
|
+
function bo(s, t = {}) {
|
|
4367
4391
|
let e = 0, i = 0, o = 0;
|
|
4368
|
-
return
|
|
4392
|
+
return Be(
|
|
4369
4393
|
s,
|
|
4370
4394
|
function(r) {
|
|
4371
4395
|
e += r[0], i += r[1], o++;
|
|
4372
4396
|
}
|
|
4373
|
-
),
|
|
4397
|
+
), Hi([e / o, i / o], t.properties);
|
|
4374
4398
|
}
|
|
4375
|
-
class
|
|
4399
|
+
class Lo extends Io {
|
|
4376
4400
|
/**
|
|
4377
4401
|
* Constructor
|
|
4378
4402
|
* @param options Plugin control options
|
|
@@ -4411,7 +4435,7 @@ class Wo extends wo {
|
|
|
4411
4435
|
* Handle finish event of terradraw. It will be called after finishing adding a feature
|
|
4412
4436
|
* @param id Feature ID
|
|
4413
4437
|
*/
|
|
4414
|
-
k(this, "handleTerradrawFeatureReady",
|
|
4438
|
+
k(this, "handleTerradrawFeatureReady", no((e) => {
|
|
4415
4439
|
this.map && (this.computeElevationByLineFeatureID(e), this.computeElevationByPointFeatureID(e));
|
|
4416
4440
|
}, 300));
|
|
4417
4441
|
/**
|
|
@@ -4429,7 +4453,7 @@ class Wo extends wo {
|
|
|
4429
4453
|
}
|
|
4430
4454
|
);
|
|
4431
4455
|
if (o && o.length > 0) {
|
|
4432
|
-
const r = await
|
|
4456
|
+
const r = await ce(
|
|
4433
4457
|
o,
|
|
4434
4458
|
this.measureOptions.terrainSource
|
|
4435
4459
|
);
|
|
@@ -4457,7 +4481,7 @@ class Wo extends wo {
|
|
|
4457
4481
|
}
|
|
4458
4482
|
);
|
|
4459
4483
|
if (o && o.length > 0) {
|
|
4460
|
-
const r = await
|
|
4484
|
+
const r = await ce(
|
|
4461
4485
|
o,
|
|
4462
4486
|
this.measureOptions.terrainSource
|
|
4463
4487
|
);
|
|
@@ -4592,7 +4616,7 @@ class Wo extends wo {
|
|
|
4592
4616
|
const n = (d = this.measureOptions.lineLayerLabelSpec) == null ? void 0 : d.source;
|
|
4593
4617
|
n && o.push(n);
|
|
4594
4618
|
const a = (c = this.measureOptions.pointLayerLabelSpec) == null ? void 0 : c.source;
|
|
4595
|
-
return a && o.push(a),
|
|
4619
|
+
return a && o.push(a), Ne(e, i, o);
|
|
4596
4620
|
}
|
|
4597
4621
|
/**
|
|
4598
4622
|
* Register measure control related maplibre sources and layers
|
|
@@ -4765,7 +4789,7 @@ class Wo extends wo {
|
|
|
4765
4789
|
}
|
|
4766
4790
|
));
|
|
4767
4791
|
const l = JSON.parse(JSON.stringify(r));
|
|
4768
|
-
l.id = l.id + "-area-label", l.geometry =
|
|
4792
|
+
l.id = l.id + "-area-label", l.geometry = bo(r.geometry).geometry, l.properties.originalId = r.id, r = se(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
4793
|
this.measureOptions.polygonLayerSpec.source
|
|
4770
4794
|
)) == null || n.setData(a.data), this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && this.map.moveLayer(
|
|
4771
4795
|
this.measureOptions.lineLayerLabelSpec.id
|
|
@@ -4798,7 +4822,7 @@ class Wo extends wo {
|
|
|
4798
4822
|
var c;
|
|
4799
4823
|
return ((c = d.properties) == null ? void 0 : c.originalId) !== e;
|
|
4800
4824
|
}
|
|
4801
|
-
)), r =
|
|
4825
|
+
)), r = ae(
|
|
4802
4826
|
r,
|
|
4803
4827
|
this.distanceUnit,
|
|
4804
4828
|
this.distancePrecision,
|
|
@@ -4812,17 +4836,17 @@ class Wo extends wo {
|
|
|
4812
4836
|
typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(c);
|
|
4813
4837
|
const h = c.geometry.coordinates, u = h[0], p = h[1];
|
|
4814
4838
|
if (d === 0) {
|
|
4815
|
-
const
|
|
4816
|
-
|
|
4839
|
+
const g = JSON.parse(JSON.stringify(c));
|
|
4840
|
+
g.id = `${c.id}-node-${d}`, g.geometry = {
|
|
4817
4841
|
type: "Point",
|
|
4818
4842
|
coordinates: u
|
|
4819
|
-
},
|
|
4843
|
+
}, g.properties.distance = 0, g.properties.total = 0, c.properties.elevation_start && (g.properties.elevation = c.properties.elevation_start), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(g);
|
|
4820
4844
|
}
|
|
4821
|
-
const
|
|
4822
|
-
|
|
4845
|
+
const y = JSON.parse(JSON.stringify(c));
|
|
4846
|
+
y.id = `${c.id}-node-${d + 1}`, y.geometry = {
|
|
4823
4847
|
type: "Point",
|
|
4824
4848
|
coordinates: p
|
|
4825
|
-
}, c.properties.elevation_end && (
|
|
4849
|
+
}, c.properties.elevation_end && (y.properties.elevation = c.properties.elevation_end), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(y);
|
|
4826
4850
|
}
|
|
4827
4851
|
(n = this.map.getSource(
|
|
4828
4852
|
this.measureOptions.lineLayerLabelSpec.source
|
|
@@ -4847,7 +4871,7 @@ class Wo extends wo {
|
|
|
4847
4871
|
let r = o == null ? void 0 : o.find((a) => a.id === e && a.geometry.type === "Point");
|
|
4848
4872
|
if (r) {
|
|
4849
4873
|
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 =
|
|
4874
|
+
a && (typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter((l) => l.id !== e)), r = de(
|
|
4851
4875
|
r,
|
|
4852
4876
|
this.map,
|
|
4853
4877
|
this.computeElevation,
|
|
@@ -4892,14 +4916,14 @@ class Wo extends wo {
|
|
|
4892
4916
|
const r = i.features[o];
|
|
4893
4917
|
if (!this.map || !this.map.loaded()) continue;
|
|
4894
4918
|
const n = r.geometry.type;
|
|
4895
|
-
n === "LineString" ? i.features[o] =
|
|
4919
|
+
n === "LineString" ? i.features[o] = ae(
|
|
4896
4920
|
r,
|
|
4897
4921
|
this.distanceUnit,
|
|
4898
4922
|
this.distancePrecision,
|
|
4899
4923
|
this.map,
|
|
4900
4924
|
this.computeElevation,
|
|
4901
4925
|
this.measureOptions.terrainSource
|
|
4902
|
-
) : n === "Polygon" ? i.features[o] =
|
|
4926
|
+
) : n === "Polygon" ? i.features[o] = se(r, this.areaUnit, this.areaPrecision) : n === "Point" && (i.features[o] = de(
|
|
4903
4927
|
r,
|
|
4904
4928
|
this.map,
|
|
4905
4929
|
this.computeElevation,
|
|
@@ -4910,23 +4934,24 @@ class Wo extends wo {
|
|
|
4910
4934
|
}
|
|
4911
4935
|
}
|
|
4912
4936
|
export {
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4937
|
+
Oo as AvailableModes,
|
|
4938
|
+
Lo as MaplibreMeasureControl,
|
|
4939
|
+
Io as MaplibreTerradrawControl,
|
|
4940
|
+
Do as TERRADRAW_MEASURE_SOURCE_IDS,
|
|
4917
4941
|
It as TERRADRAW_SOURCE_IDS,
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4942
|
+
se as calcArea,
|
|
4943
|
+
ae as calcDistance,
|
|
4944
|
+
le as capitalize,
|
|
4945
|
+
Ne as cleanMaplibreStyle,
|
|
4946
|
+
oo as convertAreaUnit,
|
|
4947
|
+
Ot as convertMetricDistance,
|
|
4948
|
+
no as debounce,
|
|
4949
|
+
Xi as defaultControlOptions,
|
|
4925
4950
|
yt as defaultMeasureControlOptions,
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4951
|
+
Ki as getDefaultModeOptions,
|
|
4952
|
+
ne as getDistanceUnitName,
|
|
4953
|
+
de as queryElevationByPoint,
|
|
4954
|
+
ce as queryElevationFromRasterDEM,
|
|
4955
|
+
_o as roundFeatureCoordinates
|
|
4931
4956
|
};
|
|
4932
4957
|
//# sourceMappingURL=maplibre-gl-terradraw.es.js.map
|