@watergis/maplibre-gl-terradraw 0.7.1 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
var Le = Object.defineProperty;
|
|
2
|
-
var We = (
|
|
3
|
-
var j = (
|
|
2
|
+
var We = (r, t, e) => t in r ? Le(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
+
var j = (r, t, e) => We(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
function M() {
|
|
5
|
-
return M = Object.assign ? Object.assign.bind() : function(
|
|
5
|
+
return M = Object.assign ? Object.assign.bind() : function(r) {
|
|
6
6
|
for (var t = 1; t < arguments.length; t++) {
|
|
7
7
|
var e = arguments[t];
|
|
8
|
-
for (var i in e) Object.prototype.hasOwnProperty.call(e, i) && (
|
|
8
|
+
for (var i in e) Object.prototype.hasOwnProperty.call(e, i) && (r[i] = e[i]);
|
|
9
9
|
}
|
|
10
|
-
return
|
|
10
|
+
return r;
|
|
11
11
|
}, M.apply(this, arguments);
|
|
12
12
|
}
|
|
13
|
-
function F(
|
|
13
|
+
function F(r, t = 9) {
|
|
14
14
|
const e = Math.pow(10, t);
|
|
15
|
-
return Math.round(
|
|
15
|
+
return Math.round(r * e) / e;
|
|
16
16
|
}
|
|
17
|
-
const E = (
|
|
18
|
-
const { x: e, y: i } =
|
|
19
|
-
return Math.sqrt(a * a +
|
|
17
|
+
const E = (r, t) => {
|
|
18
|
+
const { x: e, y: i } = r, { x: o, y: s } = t, n = o - e, a = s - i;
|
|
19
|
+
return Math.sqrt(a * a + n * n);
|
|
20
20
|
};
|
|
21
21
|
class J {
|
|
22
22
|
constructor({ name: t, callback: e, unregister: i, register: o }) {
|
|
@@ -41,8 +41,8 @@ class ce {
|
|
|
41
41
|
getDrawEventFromEvent(t) {
|
|
42
42
|
const e = this.getLngLatFromEvent(t);
|
|
43
43
|
if (!e) return null;
|
|
44
|
-
const { lng: i, lat: o } = e, { containerX: s, containerY:
|
|
45
|
-
return { lng: F(i, this._coordinatePrecision), lat: F(o, this._coordinatePrecision), containerX: s, containerY:
|
|
44
|
+
const { lng: i, lat: o } = e, { containerX: s, containerY: n } = this.getMapElementXYPosition(t), a = this.getButton(t), l = Array.from(this._heldKeys);
|
|
45
|
+
return { lng: F(i, this._coordinatePrecision), lat: F(o, this._coordinatePrecision), containerX: s, containerY: n, button: a, heldKeys: l };
|
|
46
46
|
}
|
|
47
47
|
register(t) {
|
|
48
48
|
this._currentModeCallbacks = t, this._listeners = this.getAdapterListeners(), this._listeners.forEach((e) => {
|
|
@@ -68,9 +68,9 @@ class ce {
|
|
|
68
68
|
if (e) if (this._dragState === "not-dragging") this._currentModeCallbacks.onMouseMove(e), this._lastDrawEvent = e;
|
|
69
69
|
else if (this._dragState === "pre-dragging") {
|
|
70
70
|
if (!this._lastDrawEvent) return;
|
|
71
|
-
const i = { x: this._lastDrawEvent.containerX, y: this._lastDrawEvent.containerY }, o = { x: e.containerX, y: e.containerY }, s = this._currentModeCallbacks.getState(),
|
|
71
|
+
const i = { x: this._lastDrawEvent.containerX, y: this._lastDrawEvent.containerY }, o = { x: e.containerX, y: e.containerY }, s = this._currentModeCallbacks.getState(), n = E(i, o);
|
|
72
72
|
let a = !1;
|
|
73
|
-
if (a = s === "drawing" ?
|
|
73
|
+
if (a = s === "drawing" ? n < this._minPixelDragDistanceDrawing : s === "selecting" ? n < this._minPixelDragDistanceSelecting : n < this._minPixelDragDistance, a) return;
|
|
74
74
|
this._dragState = "dragging", this._currentModeCallbacks.onDragStart(e, (l) => {
|
|
75
75
|
this.setDraggability.bind(this)(l);
|
|
76
76
|
});
|
|
@@ -185,18 +185,18 @@ class je extends ce {
|
|
|
185
185
|
}
|
|
186
186
|
render(t, e) {
|
|
187
187
|
this.updateChangedIds(t), this._nextRender && cancelAnimationFrame(this._nextRender), this._nextRender = requestAnimationFrame(() => {
|
|
188
|
-
const i = [...t.created, ...t.updated, ...t.unchanged], o = [], s = [],
|
|
188
|
+
const i = [...t.created, ...t.updated, ...t.unchanged], o = [], s = [], n = [];
|
|
189
189
|
for (let a = 0; a < i.length; a++) {
|
|
190
190
|
const l = i[a], { properties: d } = l, c = e[d.mode](l);
|
|
191
|
-
l.geometry.type === "Point" ? (d.pointColor = c.pointColor, d.pointOutlineColor = c.pointOutlineColor, d.pointOutlineWidth = c.pointOutlineWidth, d.pointWidth = c.pointWidth, o.push(l)) : l.geometry.type === "LineString" ? (d.lineStringColor = c.lineStringColor, d.lineStringWidth = c.lineStringWidth, s.push(l)) : l.geometry.type === "Polygon" && (d.polygonFillColor = c.polygonFillColor, d.polygonFillOpacity = c.polygonFillOpacity, d.polygonOutlineColor = c.polygonOutlineColor, d.polygonOutlineWidth = c.polygonOutlineWidth,
|
|
191
|
+
l.geometry.type === "Point" ? (d.pointColor = c.pointColor, d.pointOutlineColor = c.pointOutlineColor, d.pointOutlineWidth = c.pointOutlineWidth, d.pointWidth = c.pointWidth, o.push(l)) : l.geometry.type === "LineString" ? (d.lineStringColor = c.lineStringColor, d.lineStringWidth = c.lineStringWidth, s.push(l)) : l.geometry.type === "Polygon" && (d.polygonFillColor = c.polygonFillColor, d.polygonFillOpacity = c.polygonFillOpacity, d.polygonOutlineColor = c.polygonOutlineColor, d.polygonOutlineWidth = c.polygonOutlineWidth, n.push(l));
|
|
192
192
|
}
|
|
193
193
|
if (this._rendered) {
|
|
194
194
|
const a = this.changedIds.deletion || this.changedIds.styling, l = a || this.changedIds.linestrings, d = a || this.changedIds.polygons;
|
|
195
195
|
let c;
|
|
196
|
-
(a || this.changedIds.points) && (c = this._setGeoJSONLayerData("Point", o)), l && this._setGeoJSONLayerData("LineString", s), d && this._setGeoJSONLayerData("Polygon",
|
|
196
|
+
(a || this.changedIds.points) && (c = this._setGeoJSONLayerData("Point", o)), l && this._setGeoJSONLayerData("LineString", s), d && this._setGeoJSONLayerData("Polygon", n), c && this._map.moveLayer(c);
|
|
197
197
|
} else {
|
|
198
198
|
const a = this._addGeoJSONLayer("Point", o);
|
|
199
|
-
this._addGeoJSONLayer("LineString", s), this._addGeoJSONLayer("Polygon",
|
|
199
|
+
this._addGeoJSONLayer("LineString", s), this._addGeoJSONLayer("Polygon", n), this._rendered = !0, a && this._map.moveLayer(a);
|
|
200
200
|
}
|
|
201
201
|
this.changedIds = { points: !1, linestrings: !1, polygons: !1, deletion: !1, styling: !1 };
|
|
202
202
|
});
|
|
@@ -258,8 +258,8 @@ class Be extends ce {
|
|
|
258
258
|
}
|
|
259
259
|
const Ne = { radians: 6370997 / (2 * Math.PI), degrees: 2 * Math.PI * 6370997 / 360, ft: 0.3048, m: 1, "us-ft": 1200 / 3937 };
|
|
260
260
|
var he = class {
|
|
261
|
-
constructor(
|
|
262
|
-
this.code_ =
|
|
261
|
+
constructor(r) {
|
|
262
|
+
this.code_ = r.code, this.units_ = r.units, this.extent_ = r.extent !== void 0 ? r.extent : null, this.worldExtent_ = r.worldExtent !== void 0 ? r.worldExtent : null, this.axisOrientation_ = r.axisOrientation !== void 0 ? r.axisOrientation : "enu", this.global_ = r.global !== void 0 && r.global, this.canWrapX_ = !(!this.global_ || !this.extent_), this.getPointResolutionFunc_ = r.getPointResolution, this.defaultTileGrid_ = null, this.metersPerUnit_ = r.metersPerUnit;
|
|
263
263
|
}
|
|
264
264
|
canWrapX() {
|
|
265
265
|
return this.canWrapX_;
|
|
@@ -285,33 +285,33 @@ var he = class {
|
|
|
285
285
|
isGlobal() {
|
|
286
286
|
return this.global_;
|
|
287
287
|
}
|
|
288
|
-
setGlobal(
|
|
289
|
-
this.global_ =
|
|
288
|
+
setGlobal(r) {
|
|
289
|
+
this.global_ = r, this.canWrapX_ = !(!r || !this.extent_);
|
|
290
290
|
}
|
|
291
291
|
getDefaultTileGrid() {
|
|
292
292
|
return this.defaultTileGrid_;
|
|
293
293
|
}
|
|
294
|
-
setDefaultTileGrid(
|
|
295
|
-
this.defaultTileGrid_ =
|
|
294
|
+
setDefaultTileGrid(r) {
|
|
295
|
+
this.defaultTileGrid_ = r;
|
|
296
296
|
}
|
|
297
|
-
setExtent(
|
|
298
|
-
this.extent_ =
|
|
297
|
+
setExtent(r) {
|
|
298
|
+
this.extent_ = r, this.canWrapX_ = !(!this.global_ || !r);
|
|
299
299
|
}
|
|
300
|
-
setWorldExtent(
|
|
301
|
-
this.worldExtent_ =
|
|
300
|
+
setWorldExtent(r) {
|
|
301
|
+
this.worldExtent_ = r;
|
|
302
302
|
}
|
|
303
|
-
setGetPointResolution(
|
|
304
|
-
this.getPointResolutionFunc_ =
|
|
303
|
+
setGetPointResolution(r) {
|
|
304
|
+
this.getPointResolutionFunc_ = r;
|
|
305
305
|
}
|
|
306
306
|
getPointResolutionFunc() {
|
|
307
307
|
return this.getPointResolutionFunc_;
|
|
308
308
|
}
|
|
309
309
|
};
|
|
310
|
-
const
|
|
310
|
+
const nt = 6378137, Q = Math.PI * nt, Ge = [-Q, -Q, Q, Q], Ae = [-180, -85, 180, 85], ct = nt * Math.log(Math.tan(Math.PI / 2));
|
|
311
311
|
class $ extends he {
|
|
312
312
|
constructor(t) {
|
|
313
313
|
super({ code: t, units: "m", extent: Ge, global: !0, worldExtent: Ae, getPointResolution: function(e, i) {
|
|
314
|
-
return e / Math.cosh(i[1] /
|
|
314
|
+
return e / Math.cosh(i[1] / nt);
|
|
315
315
|
} });
|
|
316
316
|
}
|
|
317
317
|
}
|
|
@@ -323,63 +323,63 @@ class T extends he {
|
|
|
323
323
|
}
|
|
324
324
|
const Rt = [new T("CRS:84"), new T("EPSG:4326", "neu"), new T("urn:ogc:def:crs:OGC:1.3:CRS84"), new T("urn:ogc:def:crs:OGC:2:84"), new T("http://www.opengis.net/def/crs/OGC/1.3/CRS84"), new T("http://www.opengis.net/gml/srs/epsg.xml#4326", "neu"), new T("http://www.opengis.net/def/crs/EPSG/0/4326", "neu")];
|
|
325
325
|
let Mt = {};
|
|
326
|
-
function ft(
|
|
327
|
-
const i =
|
|
326
|
+
function ft(r, t, e) {
|
|
327
|
+
const i = r.getCode(), o = t.getCode();
|
|
328
328
|
i in Mt || (Mt[i] = {}), Mt[i][o] = e;
|
|
329
329
|
}
|
|
330
|
-
function ue(
|
|
331
|
-
if (t !== void 0) for (let e = 0, i =
|
|
332
|
-
else t =
|
|
330
|
+
function ue(r, t) {
|
|
331
|
+
if (t !== void 0) for (let e = 0, i = r.length; e < i; ++e) t[e] = r[e];
|
|
332
|
+
else t = r.slice();
|
|
333
333
|
return t;
|
|
334
334
|
}
|
|
335
|
-
function Ue(
|
|
336
|
-
|
|
335
|
+
function Ue(r) {
|
|
336
|
+
r.getCode(), ft(r, r, ue);
|
|
337
337
|
}
|
|
338
|
-
function Xt(
|
|
338
|
+
function Xt(r) {
|
|
339
339
|
(function(t) {
|
|
340
340
|
t.forEach(Ue);
|
|
341
|
-
})(
|
|
342
|
-
|
|
341
|
+
})(r), r.forEach(function(t) {
|
|
342
|
+
r.forEach(function(e) {
|
|
343
343
|
t !== e && ft(t, e, ue);
|
|
344
344
|
});
|
|
345
345
|
});
|
|
346
346
|
}
|
|
347
|
-
var Kt, zt, Yt,
|
|
348
|
-
Xt(Ut), Xt(Rt), Kt = Ut, zt = function(
|
|
349
|
-
const i =
|
|
350
|
-
e = e > 1 ? e : 2, t === void 0 && (t = e > 2 ?
|
|
347
|
+
var Kt, zt, Yt, b;
|
|
348
|
+
Xt(Ut), Xt(Rt), Kt = Ut, zt = function(r, t, e) {
|
|
349
|
+
const i = r.length;
|
|
350
|
+
e = e > 1 ? e : 2, t === void 0 && (t = e > 2 ? r.slice() : new Array(i));
|
|
351
351
|
for (let o = 0; o < i; o += e) {
|
|
352
|
-
t[o] = Q *
|
|
353
|
-
let s =
|
|
352
|
+
t[o] = Q * r[o] / 180;
|
|
353
|
+
let s = nt * Math.log(Math.tan(Math.PI * (+r[o + 1] + 90) / 360));
|
|
354
354
|
s > ct ? s = ct : s < -ct && (s = -ct), t[o + 1] = s;
|
|
355
355
|
}
|
|
356
356
|
return t;
|
|
357
|
-
}, Yt = function(
|
|
358
|
-
const i =
|
|
359
|
-
e = e > 1 ? e : 2, t === void 0 && (t = e > 2 ?
|
|
360
|
-
for (let o = 0; o < i; o += e) t[o] = 180 *
|
|
357
|
+
}, Yt = function(r, t, e) {
|
|
358
|
+
const i = r.length;
|
|
359
|
+
e = e > 1 ? e : 2, t === void 0 && (t = e > 2 ? r.slice() : new Array(i));
|
|
360
|
+
for (let o = 0; o < i; o += e) t[o] = 180 * r[o] / Q, t[o + 1] = 360 * Math.atan(Math.exp(r[o + 1] / nt)) / Math.PI - 90;
|
|
361
361
|
return t;
|
|
362
|
-
}, Rt.forEach(function(
|
|
362
|
+
}, Rt.forEach(function(r) {
|
|
363
363
|
Kt.forEach(function(t) {
|
|
364
|
-
ft(
|
|
364
|
+
ft(r, t, zt), ft(t, r, Yt);
|
|
365
365
|
});
|
|
366
366
|
});
|
|
367
|
-
(function(
|
|
368
|
-
|
|
369
|
-
})(
|
|
370
|
-
const _t = "selected",
|
|
371
|
-
function
|
|
372
|
-
return !!(
|
|
373
|
-
}
|
|
374
|
-
function Ht(
|
|
367
|
+
(function(r) {
|
|
368
|
+
r.Commit = "commit", r.Provisional = "provisional", r.Finish = "finish";
|
|
369
|
+
})(b || (b = {}));
|
|
370
|
+
const _t = "selected", rt = "midPoint", at = "closingPoint", Dt = "snappingPoint";
|
|
371
|
+
function wt(r) {
|
|
372
|
+
return !!(r && typeof r == "object" && r !== null && !Array.isArray(r));
|
|
373
|
+
}
|
|
374
|
+
function Ht(r) {
|
|
375
375
|
return !!function(t) {
|
|
376
376
|
return typeof t == "number" && !isNaN(new Date(t).valueOf());
|
|
377
|
-
}(
|
|
377
|
+
}(r);
|
|
378
378
|
}
|
|
379
379
|
const Te = "Feature mode property does not match the mode being added to";
|
|
380
380
|
var z;
|
|
381
|
-
(function(
|
|
382
|
-
|
|
381
|
+
(function(r) {
|
|
382
|
+
r.Drawing = "drawing", r.Select = "select", r.Static = "static", r.Render = "render";
|
|
383
383
|
})(z || (z = {}));
|
|
384
384
|
class N {
|
|
385
385
|
get state() {
|
|
@@ -423,9 +423,9 @@ class N {
|
|
|
423
423
|
if (this._state === "unregistered") throw new Error("Mode must be registered");
|
|
424
424
|
const e = function(i, o) {
|
|
425
425
|
let s;
|
|
426
|
-
if (
|
|
426
|
+
if (wt(i)) if (i.id == null) s = "Feature has no id";
|
|
427
427
|
else if (typeof i.id != "string" && typeof i.id != "number") s = "Feature must be string or number as per GeoJSON spec";
|
|
428
|
-
else if (o(i.id)) if (
|
|
428
|
+
else if (o(i.id)) if (wt(i.geometry)) if (wt(i.properties)) if (typeof i.geometry.type == "string" && ["Polygon", "LineString", "Point"].includes(i.geometry.type)) if (Array.isArray(i.geometry.coordinates)) {
|
|
429
429
|
if (!i.properties.mode || typeof i.properties.mode != "string") return { valid: !1, reason: "Feature does not have a valid mode property" };
|
|
430
430
|
} else s = "Feature coordinates is not an array";
|
|
431
431
|
else s = "Feature is not Point, LineString or Polygon";
|
|
@@ -436,7 +436,7 @@ class N {
|
|
|
436
436
|
return s ? { valid: !1, reason: s } : { valid: !0 };
|
|
437
437
|
}(t, this.store.idStrategy.isValidId);
|
|
438
438
|
if (this.validate) {
|
|
439
|
-
const i = this.validate(t, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
439
|
+
const i = this.validate(t, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Provisional });
|
|
440
440
|
return { valid: e.valid && i.valid, reason: i.reason };
|
|
441
441
|
}
|
|
442
442
|
return { valid: e.valid, reason: e.reason };
|
|
@@ -480,78 +480,78 @@ class Re extends N {
|
|
|
480
480
|
super(...t), this.type = z.Select;
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
|
-
function V(
|
|
484
|
-
const e = (d) => d * Math.PI / 180, i = e(
|
|
483
|
+
function V(r, t) {
|
|
484
|
+
const e = (d) => d * Math.PI / 180, i = e(r[1]), o = e(r[0]), s = e(t[1]), n = s - i, a = e(t[0]) - o, l = Math.sin(n / 2) * Math.sin(n / 2) + Math.cos(i) * Math.cos(s) * Math.sin(a / 2) * Math.sin(a / 2);
|
|
485
485
|
return 2 * Math.atan2(Math.sqrt(l), Math.sqrt(1 - l)) * 6371e3 / 1e3;
|
|
486
486
|
}
|
|
487
487
|
const Ot = 63710088e-1;
|
|
488
|
-
function _(
|
|
489
|
-
return
|
|
488
|
+
function _(r) {
|
|
489
|
+
return r % 360 * Math.PI / 180;
|
|
490
490
|
}
|
|
491
|
-
function ge(
|
|
492
|
-
return
|
|
491
|
+
function ge(r) {
|
|
492
|
+
return r / (Ot / 1e3);
|
|
493
493
|
}
|
|
494
|
-
function U(
|
|
495
|
-
return
|
|
494
|
+
function U(r) {
|
|
495
|
+
return r % (2 * Math.PI) * 180 / Math.PI;
|
|
496
496
|
}
|
|
497
|
-
const Jt = 57.29577951308232, $t = 0.017453292519943295, mt = 6378137, S = (
|
|
498
|
-
function Xe(
|
|
499
|
-
const i = _(
|
|
500
|
-
return [U(i + Math.atan2(Math.sin(s) * Math.sin(
|
|
497
|
+
const Jt = 57.29577951308232, $t = 0.017453292519943295, mt = 6378137, S = (r, t) => ({ x: r === 0 ? 0 : r * $t * mt, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * $t / 2)) * mt }), L = (r, t) => ({ lng: r === 0 ? 0 : Jt * (r / mt), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / mt)) - Math.PI / 2) * Jt });
|
|
498
|
+
function Xe(r, t, e) {
|
|
499
|
+
const i = _(r[0]), o = _(r[1]), s = _(e), n = ge(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(s));
|
|
500
|
+
return [U(i + Math.atan2(Math.sin(s) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), U(a)];
|
|
501
501
|
}
|
|
502
|
-
function qt(
|
|
503
|
-
const { center: t, radiusKilometers: e, coordinatePrecision: i } =
|
|
504
|
-
for (let
|
|
505
|
-
const a = Xe(t, e, -360 *
|
|
502
|
+
function qt(r) {
|
|
503
|
+
const { center: t, radiusKilometers: e, coordinatePrecision: i } = r, o = r.steps ? r.steps : 64, s = [];
|
|
504
|
+
for (let n = 0; n < o; n++) {
|
|
505
|
+
const a = Xe(t, e, -360 * n / o);
|
|
506
506
|
s.push([F(a[0], i), F(a[1], i)]);
|
|
507
507
|
}
|
|
508
508
|
return s.push(s[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [s] }, properties: {} };
|
|
509
509
|
}
|
|
510
|
-
function kt(
|
|
510
|
+
function kt(r) {
|
|
511
511
|
const t = { epsilon: 0 };
|
|
512
512
|
let e;
|
|
513
|
-
if (
|
|
513
|
+
if (r.geometry.type === "Polygon") e = r.geometry.coordinates;
|
|
514
514
|
else {
|
|
515
|
-
if (
|
|
516
|
-
e = [
|
|
515
|
+
if (r.geometry.type !== "LineString") throw new Error("Self intersects only accepts Polygons and LineStrings");
|
|
516
|
+
e = [r.geometry.coordinates];
|
|
517
517
|
}
|
|
518
518
|
const i = [];
|
|
519
|
-
for (let
|
|
519
|
+
for (let n = 0; n < e.length; n++) for (let a = 0; a < e[n].length - 1; a++) for (let l = 0; l < e.length; l++) for (let d = 0; d < e[l].length - 1; d++) s(n, a, l, d);
|
|
520
520
|
return i.length > 0;
|
|
521
|
-
function o(
|
|
522
|
-
return
|
|
521
|
+
function o(n) {
|
|
522
|
+
return n < 0 - t.epsilon || n > 1 + t.epsilon;
|
|
523
523
|
}
|
|
524
|
-
function s(
|
|
525
|
-
const c = e[
|
|
524
|
+
function s(n, a, l, d) {
|
|
525
|
+
const c = e[n][a], h = e[n][a + 1], u = e[l][d], g = e[l][d + 1], y = function(f, v, m, P) {
|
|
526
526
|
if (ht(f, m) || ht(f, P) || ht(v, m) || ht(P, m)) return null;
|
|
527
|
-
const x = f[0],
|
|
528
|
-
return H === 0 ? null : [((x * D -
|
|
527
|
+
const x = f[0], w = f[1], I = v[0], D = v[1], G = m[0], O = m[1], B = P[0], Y = P[1], H = (x - I) * (O - Y) - (w - D) * (G - B);
|
|
528
|
+
return H === 0 ? null : [((x * D - w * I) * (G - B) - (x - I) * (G * Y - O * B)) / H, ((x * D - w * I) * (O - Y) - (w - D) * (G * Y - O * B)) / H];
|
|
529
529
|
}(c, h, u, g);
|
|
530
530
|
if (y === null) return;
|
|
531
531
|
let p, C;
|
|
532
532
|
p = h[0] !== c[0] ? (y[0] - c[0]) / (h[0] - c[0]) : (y[1] - c[1]) / (h[1] - c[1]), C = g[0] !== u[0] ? (y[0] - u[0]) / (g[0] - u[0]) : (y[1] - u[1]) / (g[1] - u[1]), o(p) || o(C) || (y.toString(), i.push(y));
|
|
533
533
|
}
|
|
534
534
|
}
|
|
535
|
-
function ht(
|
|
536
|
-
return
|
|
535
|
+
function ht(r, t) {
|
|
536
|
+
return r[0] === t[0] && r[1] === t[1];
|
|
537
537
|
}
|
|
538
|
-
function xt(
|
|
539
|
-
return
|
|
538
|
+
function xt(r, t) {
|
|
539
|
+
return r.length === 2 && typeof r[0] == "number" && typeof r[1] == "number" && r[0] !== 1 / 0 && r[1] !== 1 / 0 && (i = r[0]) >= -180 && i <= 180 && (e = r[1]) >= -90 && e <= 90 && Zt(r[0]) <= t && Zt(r[1]) <= t;
|
|
540
540
|
var e, i;
|
|
541
541
|
}
|
|
542
|
-
function Zt(
|
|
542
|
+
function Zt(r) {
|
|
543
543
|
let t = 1, e = 0;
|
|
544
|
-
for (; Math.round(
|
|
544
|
+
for (; Math.round(r * t) / t !== r; ) t *= 10, e++;
|
|
545
545
|
return e;
|
|
546
546
|
}
|
|
547
547
|
const Ke = "Feature is not a Polygon", ze = "Feature has holes", Ye = "Feature has less than 4 coordinates", He = "Feature has invalid coordinates", Je = "Feature coordinates are not closed";
|
|
548
|
-
function St(
|
|
549
|
-
return
|
|
548
|
+
function St(r, t) {
|
|
549
|
+
return r.geometry.type !== "Polygon" ? { valid: !1, reason: Ke } : r.geometry.coordinates.length !== 1 ? { valid: !1, reason: ze } : r.geometry.coordinates[0].length < 4 ? { valid: !1, reason: Ye } : r.geometry.coordinates[0].every((o) => xt(o, t)) ? (e = r.geometry.coordinates[0][0])[0] !== (i = r.geometry.coordinates[0][r.geometry.coordinates[0].length - 1])[0] || e[1] !== i[1] ? { valid: !1, reason: Je } : { valid: !0 } : { valid: !1, reason: He };
|
|
550
550
|
var e, i;
|
|
551
551
|
}
|
|
552
|
-
function dt(
|
|
553
|
-
const e = St(
|
|
554
|
-
return e.valid ? kt(
|
|
552
|
+
function dt(r, t) {
|
|
553
|
+
const e = St(r, t);
|
|
554
|
+
return e.valid ? kt(r) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
|
|
555
555
|
}
|
|
556
556
|
class pe extends N {
|
|
557
557
|
constructor(t) {
|
|
@@ -570,7 +570,7 @@ class pe extends N {
|
|
|
570
570
|
const t = this.currentCircleId;
|
|
571
571
|
if (this.validate && t) {
|
|
572
572
|
const e = this.store.getGeometryCopy(t);
|
|
573
|
-
if (!this.validate({ type: "Feature", id: t, geometry: e, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
573
|
+
if (!this.validate({ type: "Feature", id: t, geometry: e, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Finish }).valid) return;
|
|
574
574
|
}
|
|
575
575
|
this.cursorMovedAfterInitialCursorDown = !1, this.center = void 0, this.currentCircleId = void 0, this.clickCount = 0, this.state === "drawing" && this.setStarted(), this.onFinish(t, { mode: this.mode, action: "draw" });
|
|
576
576
|
}
|
|
@@ -621,17 +621,17 @@ class pe extends N {
|
|
|
621
621
|
const e = V(this.center, [t.lng, t.lat]);
|
|
622
622
|
let i;
|
|
623
623
|
if (this.projection === "web-mercator") {
|
|
624
|
-
const o = function(s,
|
|
625
|
-
const a = 1e3 * V(s,
|
|
624
|
+
const o = function(s, n) {
|
|
625
|
+
const a = 1e3 * V(s, n);
|
|
626
626
|
if (a === 0) return 1;
|
|
627
|
-
const { x: l, y: d } = S(s[0], s[1]), { x: c, y: h } = S(
|
|
627
|
+
const { x: l, y: d } = S(s[0], s[1]), { x: c, y: h } = S(n[0], n[1]);
|
|
628
628
|
return Math.sqrt(Math.pow(c - l, 2) + Math.pow(h - d, 2)) / a;
|
|
629
629
|
}(this.center, [t.lng, t.lat]);
|
|
630
630
|
i = function(s) {
|
|
631
|
-
const { center:
|
|
631
|
+
const { center: n, radiusKilometers: a, coordinatePrecision: l } = s, d = s.steps ? s.steps : 64, c = 1e3 * a, [h, u] = n, { x: g, y } = S(h, u), p = [];
|
|
632
632
|
for (let C = 0; C < d; C++) {
|
|
633
|
-
const f = 360 * C / d * Math.PI / 180, v = c * Math.cos(f), m = c * Math.sin(f), [P, x] = [g + v, y + m], { lng:
|
|
634
|
-
p.push([F(
|
|
633
|
+
const f = 360 * C / d * Math.PI / 180, v = c * Math.cos(f), m = c * Math.sin(f), [P, x] = [g + v, y + m], { lng: w, lat: I } = L(P, x);
|
|
634
|
+
p.push([F(w, l), F(I, l)]);
|
|
635
635
|
}
|
|
636
636
|
return p.push(p[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [p] }, properties: {} };
|
|
637
637
|
}({ center: this.center, radiusKilometers: e * o, coordinatePrecision: this.coordinatePrecision });
|
|
@@ -639,7 +639,7 @@ class pe extends N {
|
|
|
639
639
|
if (this.projection !== "globe") throw new Error("Invalid projection");
|
|
640
640
|
i = qt({ center: this.center, radiusKilometers: e, coordinatePrecision: this.coordinatePrecision });
|
|
641
641
|
}
|
|
642
|
-
if (this.validate && !this.validate({ type: "Feature", id: this.currentCircleId, geometry: i.geometry, properties: { radiusKilometers: e } }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
642
|
+
if (this.validate && !this.validate({ type: "Feature", id: this.currentCircleId, geometry: i.geometry, properties: { radiusKilometers: e } }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Provisional }).valid) return;
|
|
643
643
|
this.store.updateGeometry([{ id: this.currentCircleId, geometry: i.geometry }]), this.store.updateProperty([{ id: this.currentCircleId, property: "radiusKilometers", value: e }]);
|
|
644
644
|
}
|
|
645
645
|
}
|
|
@@ -661,7 +661,7 @@ class ye extends N {
|
|
|
661
661
|
const t = this.currentId;
|
|
662
662
|
if (this.validate && t) {
|
|
663
663
|
const e = this.store.getGeometryCopy(t);
|
|
664
|
-
if (!this.validate({ type: "Feature", id: t, geometry: e, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
664
|
+
if (!this.validate({ type: "Feature", id: t, geometry: e, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Finish }).valid) return;
|
|
665
665
|
}
|
|
666
666
|
this.closingPointId && this.store.delete([this.closingPointId]), this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.hasLeftStartingPoint = !1, this.state === "drawing" && this.setStarted(), this.onFinish(t, { mode: this.mode, action: "draw" });
|
|
667
667
|
}
|
|
@@ -673,7 +673,7 @@ class ye extends N {
|
|
|
673
673
|
}
|
|
674
674
|
onMouseMove(t) {
|
|
675
675
|
if (this.currentId === void 0 || this.startingClick === !1) return;
|
|
676
|
-
const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates[0].length - 2, [o, s] = e.coordinates[0][i], { x:
|
|
676
|
+
const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates[0].length - 2, [o, s] = e.coordinates[0][i], { x: n, y: a } = this.project(o, s), 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);
|
|
677
677
|
if (E({ x: h, y: u }, { x: t.containerX, y: t.containerY }) < this.pointerDistance) {
|
|
678
678
|
if (this.autoClose && this.hasLeftStartingPoint && (this.preventNewFeature = !0, setTimeout(() => {
|
|
679
679
|
this.preventNewFeature = !1;
|
|
@@ -682,7 +682,7 @@ class ye extends N {
|
|
|
682
682
|
if (l < this.minDistance) return;
|
|
683
683
|
e.coordinates[0].pop();
|
|
684
684
|
const g = { type: "Polygon", coordinates: [[...e.coordinates[0], [t.lng, t.lat], e.coordinates[0][0]]] };
|
|
685
|
-
this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: g, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
685
|
+
this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: g, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Provisional }).valid || this.store.updateGeometry([{ id: this.currentId, geometry: g }]);
|
|
686
686
|
}
|
|
687
687
|
onClick(t) {
|
|
688
688
|
if (!this.preventNewFeature) {
|
|
@@ -721,13 +721,13 @@ class ye extends N {
|
|
|
721
721
|
}
|
|
722
722
|
}
|
|
723
723
|
class W {
|
|
724
|
-
constructor({ store: t, mode: e, project: i, unproject: o, pointerDistance: s, coordinatePrecision:
|
|
725
|
-
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 = s, this.coordinatePrecision =
|
|
724
|
+
constructor({ store: t, mode: e, project: i, unproject: o, pointerDistance: s, coordinatePrecision: n, projection: a }) {
|
|
725
|
+
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 = s, this.coordinatePrecision = n, this.projection = a;
|
|
726
726
|
}
|
|
727
727
|
}
|
|
728
|
-
function fe({ unproject:
|
|
728
|
+
function fe({ unproject: r, point: t, pointerDistance: e }) {
|
|
729
729
|
const i = e / 2, { x: o, y: s } = t;
|
|
730
|
-
return { type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [[
|
|
730
|
+
return { type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [[r(o - i, s - i), r(o + i, s - i), r(o + i, s + i), r(o - i, s + i), r(o - i, s - i)].map((n) => [n.lng, n.lat])] } };
|
|
731
731
|
}
|
|
732
732
|
class Lt extends W {
|
|
733
733
|
constructor(t) {
|
|
@@ -749,16 +749,16 @@ class Wt extends W {
|
|
|
749
749
|
}
|
|
750
750
|
class me extends W {
|
|
751
751
|
constructor(t, e, i) {
|
|
752
|
-
super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => this.getSnappable(o, (s) => !!(s.properties && s.properties.mode === this.mode)), this.getSnappableCoordinate = (o, s) => this.getSnappable(o, (
|
|
752
|
+
super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => this.getSnappable(o, (s) => !!(s.properties && s.properties.mode === this.mode)), this.getSnappableCoordinate = (o, s) => this.getSnappable(o, (n) => !!(n.properties && n.properties.mode === this.mode && n.id !== s)), this.config = t, this.pixelDistance = e, this.clickBoundingBox = i;
|
|
753
753
|
}
|
|
754
754
|
getSnappable(t, e) {
|
|
755
755
|
const i = this.clickBoundingBox.create(t), o = this.store.search(i, e), s = { coord: void 0, minDist: 1 / 0 };
|
|
756
|
-
return o.forEach((
|
|
756
|
+
return o.forEach((n) => {
|
|
757
757
|
let a;
|
|
758
|
-
if (
|
|
758
|
+
if (n.geometry.type === "Polygon") a = n.geometry.coordinates[0];
|
|
759
759
|
else {
|
|
760
|
-
if (
|
|
761
|
-
a =
|
|
760
|
+
if (n.geometry.type !== "LineString") return;
|
|
761
|
+
a = n.geometry.coordinates;
|
|
762
762
|
}
|
|
763
763
|
a.forEach((l) => {
|
|
764
764
|
const d = this.pixelDistance.measure(t, l);
|
|
@@ -767,46 +767,46 @@ class me extends W {
|
|
|
767
767
|
}), s.coord;
|
|
768
768
|
}
|
|
769
769
|
}
|
|
770
|
-
function Qt(
|
|
771
|
-
const i = _(
|
|
772
|
-
return [U(i + Math.atan2(Math.sin(s) * Math.sin(
|
|
770
|
+
function Qt(r, t, e) {
|
|
771
|
+
const i = _(r[0]), o = _(r[1]), s = _(e), n = ge(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(s));
|
|
772
|
+
return [U(i + Math.atan2(Math.sin(s) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), U(a)];
|
|
773
773
|
}
|
|
774
|
-
function lt({ x:
|
|
774
|
+
function lt({ x: r, y: t }, e, i) {
|
|
775
775
|
const o = _(i);
|
|
776
|
-
return { x:
|
|
776
|
+
return { x: r + e * Math.cos(o), y: t + e * Math.sin(o) };
|
|
777
777
|
}
|
|
778
|
-
function te(
|
|
779
|
-
const e = _(
|
|
780
|
-
return U(Math.atan2(
|
|
778
|
+
function te(r, t) {
|
|
779
|
+
const e = _(r[0]), i = _(t[0]), o = _(r[1]), s = _(t[1]), n = Math.sin(i - e) * Math.cos(s), a = Math.cos(o) * Math.sin(s) - Math.sin(o) * Math.cos(s) * Math.cos(i - e);
|
|
780
|
+
return U(Math.atan2(n, a));
|
|
781
781
|
}
|
|
782
|
-
function A({ x:
|
|
783
|
-
let o = Math.atan2(i - t, e -
|
|
782
|
+
function A({ x: r, y: t }, { x: e, y: i }) {
|
|
783
|
+
let o = Math.atan2(i - t, e - r);
|
|
784
784
|
return o *= 180 / Math.PI, o > 180 ? o -= 360 : o < -180 && (o += 360), o;
|
|
785
785
|
}
|
|
786
|
-
function K(
|
|
787
|
-
return (
|
|
786
|
+
function K(r) {
|
|
787
|
+
return (r + 360) % 360;
|
|
788
788
|
}
|
|
789
|
-
function $e(
|
|
790
|
-
const i = [], o =
|
|
791
|
-
let s,
|
|
792
|
-
for (let c = 0; c <
|
|
789
|
+
function $e(r, t, e) {
|
|
790
|
+
const i = [], o = r.length;
|
|
791
|
+
let s, n, a, l = 0;
|
|
792
|
+
for (let c = 0; c < r.length && !(t >= l && c === r.length - 1); c++) {
|
|
793
793
|
if (l > t && i.length === 0) {
|
|
794
|
-
if (s = t - l, !s) return i.push(
|
|
795
|
-
|
|
794
|
+
if (s = t - l, !s) return i.push(r[c]), i;
|
|
795
|
+
n = te(r[c], r[c - 1]) - 180, a = Qt(r[c], s, n), i.push(a);
|
|
796
796
|
}
|
|
797
|
-
if (l >= e) return s = e - l, s ? (
|
|
798
|
-
if (l >= t && i.push(
|
|
799
|
-
l += V(
|
|
797
|
+
if (l >= e) return s = e - l, s ? (n = te(r[c], r[c - 1]) - 180, a = Qt(r[c], s, n), i.push(a), i) : (i.push(r[c]), i);
|
|
798
|
+
if (l >= t && i.push(r[c]), c === r.length - 1) return i;
|
|
799
|
+
l += V(r[c], r[c + 1]);
|
|
800
800
|
}
|
|
801
|
-
if (l < t &&
|
|
802
|
-
const d =
|
|
801
|
+
if (l < t && r.length === o) throw new Error("Start position is beyond line");
|
|
802
|
+
const d = r[r.length - 1];
|
|
803
803
|
return [d, d];
|
|
804
804
|
}
|
|
805
|
-
function ut(
|
|
806
|
-
return
|
|
805
|
+
function ut(r) {
|
|
806
|
+
return r * (Math.PI / 180);
|
|
807
807
|
}
|
|
808
|
-
function ee(
|
|
809
|
-
return
|
|
808
|
+
function ee(r) {
|
|
809
|
+
return r * (180 / Math.PI);
|
|
810
810
|
}
|
|
811
811
|
class qe extends W {
|
|
812
812
|
constructor(t) {
|
|
@@ -817,10 +817,10 @@ class qe extends W {
|
|
|
817
817
|
let s = 0;
|
|
818
818
|
for (let d = 0; d < o.length - 1; d++) s += V(o[0], o[1]);
|
|
819
819
|
if (s <= i) return o;
|
|
820
|
-
let
|
|
821
|
-
Number.isInteger(
|
|
820
|
+
let n = s / i - 1;
|
|
821
|
+
Number.isInteger(n) || (n = Math.floor(n) + 1);
|
|
822
822
|
const a = [];
|
|
823
|
-
for (let d = 0; d <
|
|
823
|
+
for (let d = 0; d < n; d++) {
|
|
824
824
|
const c = $e(o, i * d, i * (d + 1));
|
|
825
825
|
a.push(c);
|
|
826
826
|
}
|
|
@@ -829,16 +829,16 @@ class qe extends W {
|
|
|
829
829
|
return this.limitCoordinates(l);
|
|
830
830
|
}
|
|
831
831
|
generateInsertionGeodesicCoordinates(t, e, i) {
|
|
832
|
-
const o = V(t, e), s = function(
|
|
833
|
-
const d = [], c = ut(
|
|
832
|
+
const o = V(t, e), s = function(n, a, l) {
|
|
833
|
+
const d = [], c = ut(n[1]), h = ut(n[0]), u = ut(a[1]), g = ut(a[0]);
|
|
834
834
|
l += 1;
|
|
835
835
|
const y = 2 * Math.asin(Math.sqrt(Math.sin((u - c) / 2) ** 2 + Math.cos(c) * Math.cos(u) * Math.sin((g - h) / 2) ** 2));
|
|
836
836
|
if (y === 0 || isNaN(y)) return d;
|
|
837
837
|
for (let p = 0; p <= l; p++) {
|
|
838
838
|
const C = p / l, f = Math.sin((1 - C) * y) / Math.sin(y), v = Math.sin(C * y) / Math.sin(y), m = f * Math.cos(c) * Math.cos(h) + v * Math.cos(u) * Math.cos(g), P = f * Math.cos(c) * Math.sin(h) + v * Math.cos(u) * Math.sin(g), x = f * Math.sin(c) + v * Math.sin(u);
|
|
839
839
|
if (isNaN(m) || isNaN(P) || isNaN(x)) continue;
|
|
840
|
-
const
|
|
841
|
-
isNaN(
|
|
840
|
+
const w = Math.atan2(x, Math.sqrt(m ** 2 + P ** 2)), I = Math.atan2(P, m);
|
|
841
|
+
isNaN(w) || isNaN(I) || d.push([ee(I), ee(w)]);
|
|
842
842
|
}
|
|
843
843
|
return d.slice(1, -1);
|
|
844
844
|
}(t, e, Math.floor(o / i));
|
|
@@ -848,17 +848,17 @@ class qe extends W {
|
|
|
848
848
|
return t.map((e) => [F(e[0], this.config.coordinatePrecision), F(e[1], this.config.coordinatePrecision)]);
|
|
849
849
|
}
|
|
850
850
|
}
|
|
851
|
-
function tt(
|
|
852
|
-
return
|
|
851
|
+
function tt(r, t) {
|
|
852
|
+
return r[0] === t[0] && r[1] === t[1];
|
|
853
853
|
}
|
|
854
|
-
function ve(
|
|
855
|
-
return
|
|
854
|
+
function ve(r, t) {
|
|
855
|
+
return r.geometry.type !== "LineString" ? { valid: !1, reason: "Feature is not a LineString" } : r.geometry.coordinates.length < 2 ? { valid: !1, reason: "Feature has less than 2 coordinates" } : r.geometry.coordinates.every((e) => xt(e, t)) ? { valid: !0 } : { valid: !1, reason: "Feature has invalid coordinates" };
|
|
856
856
|
}
|
|
857
857
|
class Ce extends N {
|
|
858
858
|
constructor(t) {
|
|
859
|
-
super(t), this.mode = "linestring", this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.keyEvents = void 0, this.
|
|
859
|
+
super(t), this.mode = "linestring", this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.keyEvents = void 0, this.snapping = void 0, this.cursors = void 0, this.mouseMove = !1, this.insertCoordinates = void 0, this.lastCommitedCoordinates = void 0, this.snappedPointId = void 0, this.coordinateSnapping = void 0, this.insertPoint = void 0;
|
|
860
860
|
const e = { start: "crosshair", close: "pointer" };
|
|
861
|
-
if (this.cursors = t && t.cursors ? M({}, e, t.cursors) : e, this.
|
|
861
|
+
if (this.cursors = t && t.cursors ? M({}, e, t.cursors) : e, this.snapping = t && t.snapping ? t.snapping : void 0, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
|
|
862
862
|
else {
|
|
863
863
|
const i = { cancel: "Escape", finish: "Enter" };
|
|
864
864
|
this.keyEvents = t && t.keyEvents ? M({}, i, t.keyEvents) : i;
|
|
@@ -866,11 +866,11 @@ class Ce extends N {
|
|
|
866
866
|
this.validate = t == null ? void 0 : t.validation, this.insertCoordinates = t == null ? void 0 : t.insertCoordinates;
|
|
867
867
|
}
|
|
868
868
|
close() {
|
|
869
|
-
if (
|
|
869
|
+
if (this.currentId === void 0) return;
|
|
870
870
|
const t = this.store.getGeometryCopy(this.currentId);
|
|
871
|
-
t.coordinates.pop(), this.updateGeometries([...t.coordinates], void 0,
|
|
871
|
+
t.coordinates.pop(), this.updateGeometries([...t.coordinates], void 0, b.Commit);
|
|
872
872
|
const e = this.currentId;
|
|
873
|
-
this.closingPointId && this.store.delete([this.closingPointId]), this.snappedPointId && this.store.delete([this.snappedPointId]), this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.snappedPointId = void 0, this.lastCommitedCoordinates = void 0, this.state === "drawing" && this.setStarted(),
|
|
873
|
+
this.closingPointId && this.store.delete([this.closingPointId]), this.snappedPointId && this.store.delete([this.snappedPointId]), this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.snappedPointId = void 0, this.lastCommitedCoordinates = void 0, this.state === "drawing" && this.setStarted(), this.onFinish(e, { mode: this.mode, action: "draw" });
|
|
874
874
|
}
|
|
875
875
|
updateGeometries(t, e, i) {
|
|
876
876
|
if (!this.currentId) return;
|
|
@@ -895,15 +895,15 @@ class Ce extends N {
|
|
|
895
895
|
const e = this.store.getGeometryCopy(this.currentId).coordinates, [i] = this.store.create([{ geometry: { type: "Point", coordinates: [...t] }, properties: { mode: this.mode } }]);
|
|
896
896
|
this.closingPointId = i, this.setCursor(this.cursors.close);
|
|
897
897
|
const o = [...e, t];
|
|
898
|
-
this.updateGeometries(o, void 0,
|
|
898
|
+
this.updateGeometries(o, void 0, b.Commit), this.currentCoordinate++;
|
|
899
899
|
}
|
|
900
900
|
updateToLine(t, e) {
|
|
901
901
|
if (!this.currentId) return;
|
|
902
|
-
const i = this.store.getGeometryCopy(this.currentId).coordinates, [o, s] = this.lastCommitedCoordinates ? this.lastCommitedCoordinates[this.lastCommitedCoordinates.length - 1] : i[i.length - 2], { x:
|
|
903
|
-
if (E({ x:
|
|
902
|
+
const i = this.store.getGeometryCopy(this.currentId).coordinates, [o, s] = this.lastCommitedCoordinates ? this.lastCommitedCoordinates[this.lastCommitedCoordinates.length - 1] : i[i.length - 2], { x: n, y: a } = this.project(o, s);
|
|
903
|
+
if (E({ x: n, y: a }, { x: e.x, y: e.y }) < this.pointerDistance) return void this.close();
|
|
904
904
|
this.setCursor(this.cursors.close);
|
|
905
905
|
const l = [...i, t];
|
|
906
|
-
this.updateGeometries(l, i[i.length - 1],
|
|
906
|
+
this.updateGeometries(l, i[i.length - 1], b.Commit), this.currentCoordinate++;
|
|
907
907
|
}
|
|
908
908
|
registerBehaviors(t) {
|
|
909
909
|
this.coordinateSnapping = new me(t, new Wt(t), new Lt(t)), this.insertPoint = new qe(t);
|
|
@@ -915,12 +915,13 @@ class Ce extends N {
|
|
|
915
915
|
this.cleanUp(), this.setStopped(), this.setCursor("unset");
|
|
916
916
|
}
|
|
917
917
|
onMouseMove(t) {
|
|
918
|
-
|
|
919
|
-
|
|
918
|
+
this.mouseMove = !0, this.setCursor(this.cursors.start);
|
|
919
|
+
const e = this.snapCoordinate(t);
|
|
920
|
+
if (e) {
|
|
920
921
|
if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: e } }]);
|
|
921
922
|
else {
|
|
922
|
-
const [
|
|
923
|
-
this.snappedPointId =
|
|
923
|
+
const [n] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [Dt]: !0 } }]);
|
|
924
|
+
this.snappedPointId = n;
|
|
924
925
|
}
|
|
925
926
|
t.lng = e[0], t.lat = e[1];
|
|
926
927
|
} else this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0);
|
|
@@ -928,30 +929,23 @@ class Ce extends N {
|
|
|
928
929
|
if (this.currentId === void 0 || this.currentCoordinate === 0) return;
|
|
929
930
|
const o = this.store.getGeometryCopy(this.currentId).coordinates;
|
|
930
931
|
if (o.pop(), this.closingPointId) {
|
|
931
|
-
const [
|
|
932
|
+
const [n, a] = o[o.length - 1], { x: l, y: d } = this.project(n, a);
|
|
932
933
|
E({ x: l, y: d }, { x: t.containerX, y: t.containerY }) < this.pointerDistance && this.setCursor(this.cursors.close);
|
|
933
934
|
}
|
|
934
935
|
let s = [...o, i];
|
|
935
936
|
if (this.insertCoordinates && this.currentId && this.lastCommitedCoordinates) {
|
|
936
|
-
const
|
|
937
|
-
if (!tt(
|
|
938
|
-
const l = this.generateInsertCoordinates(
|
|
937
|
+
const n = this.lastCommitedCoordinates[this.lastCommitedCoordinates.length - 1], a = i;
|
|
938
|
+
if (!tt(n, a)) {
|
|
939
|
+
const l = this.generateInsertCoordinates(n, a);
|
|
939
940
|
s = [...this.lastCommitedCoordinates.slice(0, -1), ...l, i];
|
|
940
941
|
}
|
|
941
942
|
}
|
|
942
|
-
this.updateGeometries(s, void 0,
|
|
943
|
+
this.updateGeometries(s, void 0, b.Provisional);
|
|
943
944
|
}
|
|
944
945
|
onClick(t) {
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
} else if (this.currentCoordinate === 1 && this.currentId) {
|
|
949
|
-
const e = this.snappingEnabled && this.coordinateSnapping.getSnappableCoordinate(t, this.currentId);
|
|
950
|
-
this.firstUpdateToLine(e || [t.lng, t.lat]);
|
|
951
|
-
} else if (this.currentId) {
|
|
952
|
-
const e = this.snappingEnabled && this.coordinateSnapping.getSnappableCoordinate(t, this.currentId);
|
|
953
|
-
this.updateToLine(e || [t.lng, t.lat], { x: t.containerX, y: t.containerY });
|
|
954
|
-
}
|
|
946
|
+
this.currentCoordinate > 0 && !this.mouseMove && this.onMouseMove(t), this.mouseMove = !1, this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0);
|
|
947
|
+
const e = this.snapCoordinate(t) || [t.lng, t.lat];
|
|
948
|
+
this.currentCoordinate === 0 ? this.createLine(e) : this.currentCoordinate === 1 && this.currentId ? this.firstUpdateToLine(e) : this.currentId && this.updateToLine(e, { x: t.containerX, y: t.containerY });
|
|
955
949
|
}
|
|
956
950
|
onKeyDown() {
|
|
957
951
|
}
|
|
@@ -984,10 +978,15 @@ class Ce extends N {
|
|
|
984
978
|
validateFeature(t) {
|
|
985
979
|
return this.validateModeFeature(t, (e) => ve(e, this.coordinatePrecision));
|
|
986
980
|
}
|
|
981
|
+
snapCoordinate(t) {
|
|
982
|
+
var e, i;
|
|
983
|
+
let o;
|
|
984
|
+
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;
|
|
985
|
+
}
|
|
987
986
|
}
|
|
988
987
|
const Ze = "Feature is not a Point", Qe = "Feature has invalid coordinates";
|
|
989
|
-
function Pe(
|
|
990
|
-
return
|
|
988
|
+
function Pe(r, t) {
|
|
989
|
+
return r.geometry.type !== "Point" ? { valid: !1, reason: Ze } : xt(r.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: Qe };
|
|
991
990
|
}
|
|
992
991
|
class ti extends N {
|
|
993
992
|
constructor(t) {
|
|
@@ -1004,7 +1003,7 @@ class ti extends N {
|
|
|
1004
1003
|
onClick(t) {
|
|
1005
1004
|
if (!this.store) throw new Error("Mode must be registered first");
|
|
1006
1005
|
const e = { type: "Point", coordinates: [t.lng, t.lat] }, i = { mode: this.mode };
|
|
1007
|
-
if (this.validate && !this.validate({ type: "Feature", geometry: e, properties: i }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
1006
|
+
if (this.validate && !this.validate({ type: "Feature", geometry: e, properties: i }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Finish }).valid) return;
|
|
1008
1007
|
const [o] = this.store.create([{ geometry: e, properties: i }]);
|
|
1009
1008
|
this.onFinish(o, { mode: this.mode, action: "draw" });
|
|
1010
1009
|
}
|
|
@@ -1056,48 +1055,48 @@ class ei extends W {
|
|
|
1056
1055
|
return { isClosing: o < this.pointerDistance, isPreviousClosing: s < this.pointerDistance };
|
|
1057
1056
|
}
|
|
1058
1057
|
}
|
|
1059
|
-
function ie(
|
|
1060
|
-
return Math.sqrt(Math.pow(
|
|
1058
|
+
function ie(r) {
|
|
1059
|
+
return Math.sqrt(Math.pow(r[0], 2) + Math.pow(r[1], 2) + Math.pow(r[2], 2));
|
|
1061
1060
|
}
|
|
1062
|
-
function R(
|
|
1061
|
+
function R(r, t) {
|
|
1063
1062
|
const e = function(i, o) {
|
|
1064
|
-
const [s,
|
|
1065
|
-
return s * l +
|
|
1066
|
-
}(
|
|
1063
|
+
const [s, n, a] = i, [l, d, c] = o;
|
|
1064
|
+
return s * l + n * d + a * c;
|
|
1065
|
+
}(r, t) / (ie(r) * ie(t));
|
|
1067
1066
|
return Math.acos(Math.min(Math.max(e, -1), 1));
|
|
1068
1067
|
}
|
|
1069
|
-
function
|
|
1070
|
-
const t = _(
|
|
1068
|
+
function bt(r) {
|
|
1069
|
+
const t = _(r[1]), e = _(r[0]);
|
|
1071
1070
|
return [Math.cos(t) * Math.cos(e), Math.cos(t) * Math.sin(e), Math.sin(t)];
|
|
1072
1071
|
}
|
|
1073
|
-
function X(
|
|
1074
|
-
const [t, e, i] =
|
|
1072
|
+
function X(r) {
|
|
1073
|
+
const [t, e, i] = r, o = U(Math.asin(i));
|
|
1075
1074
|
return [U(Math.atan2(e, t)), o];
|
|
1076
1075
|
}
|
|
1077
|
-
function ii(
|
|
1078
|
-
const i =
|
|
1076
|
+
function ii(r, t, e) {
|
|
1077
|
+
const i = bt(r), o = bt(t), s = bt(e), [n, a, l] = s, [d, c, h] = function(B, Y) {
|
|
1079
1078
|
const [H, Bt, Nt] = B, [Gt, At, Vt] = Y;
|
|
1080
1079
|
return [Bt * Vt - Nt * At, Nt * Gt - H * Vt, H * At - Bt * Gt];
|
|
1081
|
-
}(i, o), u = c * l - h * a, g = h *
|
|
1080
|
+
}(i, o), u = c * l - h * a, g = h * n - d * l, y = d * a - c * n, p = y * c - g * h, C = u * h - y * d, f = g * d - u * c, v = 1 / Math.sqrt(Math.pow(p, 2) + Math.pow(C, 2) + Math.pow(f, 2)), m = [p * v, C * v, f * v], P = [-1 * p * v, -1 * C * v, -1 * f * v], x = R(i, o), w = R(i, m), I = R(o, m), D = R(i, P), G = R(o, P);
|
|
1082
1081
|
let O;
|
|
1083
|
-
return O =
|
|
1082
|
+
return O = w < D && w < G || I < D && I < G ? m : P, R(i, O) > x || R(o, O) > x ? V(X(O), X(i)) <= V(X(O), X(o)) ? [X(i), !0, !1] : [X(o), !1, !0] : [X(O), !1, !1];
|
|
1084
1083
|
}
|
|
1085
|
-
function oi(
|
|
1086
|
-
const i = t.x -
|
|
1087
|
-
return { x:
|
|
1084
|
+
function oi(r, t, e) {
|
|
1085
|
+
const i = t.x - r.x, o = t.y - r.y, s = Math.max(0, Math.min(1, ((e.x - r.x) * i + (e.y - r.y) * o) / (i * i + o * o)));
|
|
1086
|
+
return { x: r.x + s * i, y: r.y + s * o };
|
|
1088
1087
|
}
|
|
1089
1088
|
class si extends W {
|
|
1090
1089
|
constructor(t, e, i) {
|
|
1091
|
-
super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => this.getSnappable(o, (s) => !!(s.properties && s.properties.mode === this.mode)), this.getSnappableCoordinate = (o, s) => this.getSnappable(o, (
|
|
1090
|
+
super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => this.getSnappable(o, (s) => !!(s.properties && s.properties.mode === this.mode)), this.getSnappableCoordinate = (o, s) => this.getSnappable(o, (n) => !!(n.properties && n.properties.mode === this.mode && n.id !== s)), this.config = t, this.pixelDistance = e, this.clickBoundingBox = i;
|
|
1092
1091
|
}
|
|
1093
1092
|
getSnappable(t, e) {
|
|
1094
1093
|
const i = this.clickBoundingBox.create(t), o = this.store.search(i, e), s = { coord: void 0, minDistance: 1 / 0 };
|
|
1095
|
-
return o.forEach((
|
|
1094
|
+
return o.forEach((n) => {
|
|
1096
1095
|
let a;
|
|
1097
|
-
if (
|
|
1096
|
+
if (n.geometry.type === "Polygon") a = n.geometry.coordinates[0];
|
|
1098
1097
|
else {
|
|
1099
|
-
if (
|
|
1100
|
-
a =
|
|
1098
|
+
if (n.geometry.type !== "LineString") return;
|
|
1099
|
+
a = n.geometry.coordinates;
|
|
1101
1100
|
}
|
|
1102
1101
|
const l = [];
|
|
1103
1102
|
for (let u = 0; u < a.length - 1; u++) l.push([a[u], a[u + 1]]);
|
|
@@ -1108,11 +1107,11 @@ class si extends W {
|
|
|
1108
1107
|
for (let C of g) {
|
|
1109
1108
|
const f = C[0], v = C[1];
|
|
1110
1109
|
let m, P = 1 / 0;
|
|
1111
|
-
const x = S(f[0], f[1]),
|
|
1110
|
+
const x = S(f[0], f[1]), w = S(v[0], v[1]), I = S(u[0], u[1]);
|
|
1112
1111
|
if (f[0] === u[0] && f[1] === u[1]) m = f;
|
|
1113
1112
|
else if (v[0] === u[0] && v[1] === u[1]) m = v;
|
|
1114
1113
|
else {
|
|
1115
|
-
const { x: D, y: G } = oi(x,
|
|
1114
|
+
const { x: D, y: G } = oi(x, w, I), { lng: O, lat: B } = L(D, G);
|
|
1116
1115
|
m = [O, B];
|
|
1117
1116
|
}
|
|
1118
1117
|
m && (P = E(I, S(m[0], m[1])), P < p && (y = m, p = P));
|
|
@@ -1134,9 +1133,9 @@ class si extends W {
|
|
|
1134
1133
|
}
|
|
1135
1134
|
class xe extends N {
|
|
1136
1135
|
constructor(t) {
|
|
1137
|
-
super(t), this.mode = "polygon", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.
|
|
1136
|
+
super(t), this.mode = "polygon", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.snapping = void 0, this.snappedPointId = void 0, this.lineSnapping = void 0, this.coordinateSnapping = void 0, this.pixelDistance = void 0, this.closingPoints = void 0, this.cursors = void 0, this.mouseMove = !1;
|
|
1138
1137
|
const e = { start: "crosshair", close: "pointer" };
|
|
1139
|
-
if (this.cursors = t && t.cursors ? M({}, e, t.cursors) : e, this.
|
|
1138
|
+
if (this.cursors = t && t.cursors ? M({}, e, t.cursors) : e, this.snapping = t && t.snapping ? t.snapping : void 0, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
|
|
1140
1139
|
else {
|
|
1141
1140
|
const i = { cancel: "Escape", finish: "Enter" };
|
|
1142
1141
|
this.keyEvents = t && t.keyEvents ? M({}, i, t.keyEvents) : i;
|
|
@@ -1145,7 +1144,7 @@ class xe extends N {
|
|
|
1145
1144
|
close() {
|
|
1146
1145
|
if (this.currentId === void 0) return;
|
|
1147
1146
|
const t = this.store.getGeometryCopy(this.currentId).coordinates[0];
|
|
1148
|
-
if (t.length < 5 || !this.updatePolygonGeometry([...t.slice(0, -2), t[0]],
|
|
1147
|
+
if (t.length < 5 || !this.updatePolygonGeometry([...t.slice(0, -2), t[0]], b.Finish)) return;
|
|
1149
1148
|
const e = this.currentId;
|
|
1150
1149
|
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" });
|
|
1151
1150
|
}
|
|
@@ -1174,14 +1173,14 @@ class xe extends N {
|
|
|
1174
1173
|
const i = this.store.getGeometryCopy(this.currentId).coordinates[0];
|
|
1175
1174
|
let o;
|
|
1176
1175
|
if (this.currentCoordinate === 1) {
|
|
1177
|
-
const s = 1 / Math.pow(10, this.coordinatePrecision - 1),
|
|
1178
|
-
o = [i[0], [t.lng, t.lat], [t.lng, t.lat -
|
|
1176
|
+
const s = 1 / Math.pow(10, this.coordinatePrecision - 1), n = Math.max(1e-6, s);
|
|
1177
|
+
o = [i[0], [t.lng, t.lat], [t.lng, t.lat - n], i[0]];
|
|
1179
1178
|
} else if (this.currentCoordinate === 2) o = [i[0], i[1], [t.lng, t.lat], i[0]];
|
|
1180
1179
|
else {
|
|
1181
|
-
const { isClosing: s, isPreviousClosing:
|
|
1182
|
-
|
|
1180
|
+
const { isClosing: s, isPreviousClosing: n } = this.closingPoints.isClosingPoint(t);
|
|
1181
|
+
n || s ? (this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.setCursor(this.cursors.close), o = [...i.slice(0, -2), i[0], i[0]]) : o = [...i.slice(0, -2), [t.lng, t.lat], i[0]];
|
|
1183
1182
|
}
|
|
1184
|
-
this.updatePolygonGeometry(o,
|
|
1183
|
+
this.updatePolygonGeometry(o, b.Provisional);
|
|
1185
1184
|
}
|
|
1186
1185
|
updatePolygonGeometry(t, e) {
|
|
1187
1186
|
if (!this.currentId) return !1;
|
|
@@ -1189,17 +1188,17 @@ class xe extends N {
|
|
|
1189
1188
|
return !(this.validate && !this.validate({ type: "Feature", geometry: i }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: e }).valid || (this.store.updateGeometry([{ id: this.currentId, geometry: i }]), 0));
|
|
1190
1189
|
}
|
|
1191
1190
|
snapCoordinate(t) {
|
|
1192
|
-
var e, i;
|
|
1193
|
-
let
|
|
1194
|
-
if ((e = this.
|
|
1195
|
-
let
|
|
1196
|
-
|
|
1191
|
+
var e, i, o;
|
|
1192
|
+
let s;
|
|
1193
|
+
if ((e = this.snapping) != null && e.toLine) {
|
|
1194
|
+
let n;
|
|
1195
|
+
n = this.currentId ? this.lineSnapping.getSnappableCoordinate(t, this.currentId) : this.lineSnapping.getSnappableCoordinateFirstClick(t), n && (s = n);
|
|
1197
1196
|
}
|
|
1198
|
-
if ((i = this.
|
|
1199
|
-
let
|
|
1200
|
-
|
|
1197
|
+
if ((i = this.snapping) != null && i.toCoordinate) {
|
|
1198
|
+
let n;
|
|
1199
|
+
n = this.currentId ? this.coordinateSnapping.getSnappableCoordinate(t, this.currentId) : this.coordinateSnapping.getSnappableCoordinateFirstClick(t), n && (s = n);
|
|
1201
1200
|
}
|
|
1202
|
-
return o;
|
|
1201
|
+
return (o = this.snapping) != null && o.toCustom && (s = this.snapping.toCustom(t)), s;
|
|
1203
1202
|
}
|
|
1204
1203
|
onClick(t) {
|
|
1205
1204
|
if (this.currentCoordinate > 0 && !this.mouseMove && this.onMouseMove(t), this.mouseMove = !1, this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.currentCoordinate === 0) {
|
|
@@ -1211,13 +1210,13 @@ class xe extends N {
|
|
|
1211
1210
|
const e = this.snapCoordinate(t);
|
|
1212
1211
|
e && (t.lng = e[0], t.lat = e[1]);
|
|
1213
1212
|
const i = this.store.getGeometryCopy(this.currentId);
|
|
1214
|
-
if (tt([t.lng, t.lat], i.coordinates[0][0]) || !this.updatePolygonGeometry([i.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], i.coordinates[0][0]],
|
|
1213
|
+
if (tt([t.lng, t.lat], i.coordinates[0][0]) || !this.updatePolygonGeometry([i.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], i.coordinates[0][0]], b.Commit)) return;
|
|
1215
1214
|
this.currentCoordinate++;
|
|
1216
1215
|
} else if (this.currentCoordinate === 2 && this.currentId) {
|
|
1217
1216
|
const e = this.snapCoordinate(t);
|
|
1218
1217
|
e && (t.lng = e[0], t.lat = e[1]);
|
|
1219
1218
|
const i = this.store.getGeometryCopy(this.currentId).coordinates[0];
|
|
1220
|
-
if (tt([t.lng, t.lat], i[1]) || !this.updatePolygonGeometry([i[0], i[1], [t.lng, t.lat], [t.lng, t.lat], i[0]],
|
|
1219
|
+
if (tt([t.lng, t.lat], i[1]) || !this.updatePolygonGeometry([i[0], i[1], [t.lng, t.lat], [t.lng, t.lat], i[0]], b.Commit)) return;
|
|
1221
1220
|
this.currentCoordinate === 2 && this.closingPoints.create(i, "polygon"), this.currentCoordinate++;
|
|
1222
1221
|
} else if (this.currentId) {
|
|
1223
1222
|
const e = this.store.getGeometryCopy(this.currentId).coordinates[0], { isClosing: i, isPreviousClosing: o } = this.closingPoints.isClosingPoint(t);
|
|
@@ -1225,11 +1224,11 @@ class xe extends N {
|
|
|
1225
1224
|
else {
|
|
1226
1225
|
const s = this.snapCoordinate(t);
|
|
1227
1226
|
if (s && (t.lng = s[0], t.lat = s[1]), tt([t.lng, t.lat], e[this.currentCoordinate - 1])) return;
|
|
1228
|
-
const
|
|
1227
|
+
const n = /* @__PURE__ */ function(a = [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]) {
|
|
1229
1228
|
return { type: "Feature", geometry: { type: "Polygon", coordinates: a }, properties: {} };
|
|
1230
1229
|
}([[...e.slice(0, -1), [t.lng, t.lat], e[0]]]);
|
|
1231
|
-
if (!this.updatePolygonGeometry(
|
|
1232
|
-
this.currentCoordinate++, this.closingPoints.ids.length && this.closingPoints.update(
|
|
1230
|
+
if (!this.updatePolygonGeometry(n.geometry.coordinates[0], b.Commit)) return;
|
|
1231
|
+
this.currentCoordinate++, this.closingPoints.ids.length && this.closingPoints.update(n.geometry.coordinates[0]);
|
|
1233
1232
|
}
|
|
1234
1233
|
}
|
|
1235
1234
|
}
|
|
@@ -1301,10 +1300,10 @@ class Se extends N {
|
|
|
1301
1300
|
this.center = [t.lng, t.lat];
|
|
1302
1301
|
const [e] = this.store.create([{ geometry: { type: "Polygon", coordinates: [[[t.lng, t.lat], [t.lng, t.lat], [t.lng, t.lat], [t.lng, t.lat]]] }, properties: { mode: this.mode } }]);
|
|
1303
1302
|
this.currentRectangleId = e, this.clickCount++, this.setDrawing();
|
|
1304
|
-
} else this.updateRectangle(t,
|
|
1303
|
+
} else this.updateRectangle(t, b.Finish), this.close();
|
|
1305
1304
|
}
|
|
1306
1305
|
onMouseMove(t) {
|
|
1307
|
-
this.updateRectangle(t,
|
|
1306
|
+
this.updateRectangle(t, b.Provisional);
|
|
1308
1307
|
}
|
|
1309
1308
|
onKeyDown() {
|
|
1310
1309
|
}
|
|
@@ -1370,44 +1369,44 @@ class it extends N {
|
|
|
1370
1369
|
return e;
|
|
1371
1370
|
}
|
|
1372
1371
|
}
|
|
1373
|
-
function vt(
|
|
1374
|
-
const e =
|
|
1375
|
-
let
|
|
1376
|
-
|
|
1377
|
-
const a = Math.log(Math.tan(s / 2 + Math.PI / 4) / Math.tan(o / 2 + Math.PI / 4)), l = (U(Math.atan2(
|
|
1372
|
+
function vt(r, t) {
|
|
1373
|
+
const e = r, i = t, o = _(e[1]), s = _(i[1]);
|
|
1374
|
+
let n = _(i[0] - e[0]);
|
|
1375
|
+
n > Math.PI && (n -= 2 * Math.PI), n < -Math.PI && (n += 2 * Math.PI);
|
|
1376
|
+
const a = Math.log(Math.tan(s / 2 + Math.PI / 4) / Math.tan(o / 2 + Math.PI / 4)), l = (U(Math.atan2(n, a)) + 360) % 360;
|
|
1378
1377
|
return l > 180 ? -(360 - l) : l;
|
|
1379
1378
|
}
|
|
1380
|
-
function jt(
|
|
1379
|
+
function jt(r, t, e) {
|
|
1381
1380
|
let i = t;
|
|
1382
1381
|
t < 0 && (i = -Math.abs(i));
|
|
1383
|
-
const o = i / Ot, s =
|
|
1384
|
-
let d =
|
|
1382
|
+
const o = i / Ot, s = r[0] * Math.PI / 180, n = _(r[1]), a = _(e), l = o * Math.cos(a);
|
|
1383
|
+
let d = n + l;
|
|
1385
1384
|
Math.abs(d) > Math.PI / 2 && (d = d > 0 ? Math.PI - d : -Math.PI - d);
|
|
1386
|
-
const c = Math.log(Math.tan(d / 2 + Math.PI / 4) / Math.tan(
|
|
1387
|
-
return u[0] += u[0] -
|
|
1385
|
+
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 * (s + o * Math.sin(a) / h) / Math.PI + 540) % 360 - 180, 180 * d / Math.PI];
|
|
1386
|
+
return u[0] += u[0] - r[0] > 180 ? -360 : r[0] - u[0] > 180 ? 360 : 0, u;
|
|
1388
1387
|
}
|
|
1389
|
-
function Me(
|
|
1390
|
-
const s = i(
|
|
1388
|
+
function Me(r, t, e, i, o) {
|
|
1389
|
+
const s = i(r[0], r[1]), n = i(t[0], t[1]), { lng: a, lat: l } = o((s.x + n.x) / 2, (s.y + n.y) / 2);
|
|
1391
1390
|
return [F(a, e), F(l, e)];
|
|
1392
1391
|
}
|
|
1393
|
-
function
|
|
1394
|
-
const i = jt(
|
|
1392
|
+
function ri(r, t, e) {
|
|
1393
|
+
const i = jt(r, 1e3 * V(r, t) / 2, vt(r, t));
|
|
1395
1394
|
return [F(i[0], e), F(i[1], e)];
|
|
1396
1395
|
}
|
|
1397
|
-
function oe({ featureCoords:
|
|
1396
|
+
function oe({ featureCoords: r, precision: t, unproject: e, project: i, projection: o }) {
|
|
1398
1397
|
const s = [];
|
|
1399
|
-
for (let
|
|
1398
|
+
for (let n = 0; n < r.length - 1; n++) {
|
|
1400
1399
|
let a;
|
|
1401
|
-
if (o === "web-mercator") a = Me(n
|
|
1400
|
+
if (o === "web-mercator") a = Me(r[n], r[n + 1], t, i, e);
|
|
1402
1401
|
else {
|
|
1403
1402
|
if (o !== "globe") throw new Error("Invalid projection");
|
|
1404
|
-
a =
|
|
1403
|
+
a = ri(r[n], r[n + 1], t);
|
|
1405
1404
|
}
|
|
1406
1405
|
s.push(a);
|
|
1407
1406
|
}
|
|
1408
1407
|
return s;
|
|
1409
1408
|
}
|
|
1410
|
-
class
|
|
1409
|
+
class ni extends W {
|
|
1411
1410
|
constructor(t, e) {
|
|
1412
1411
|
super(t), this.config = void 0, this.selectionPointBehavior = void 0, this._midPoints = [], this.config = t, this.selectionPointBehavior = e;
|
|
1413
1412
|
}
|
|
@@ -1417,14 +1416,14 @@ class ri extends W {
|
|
|
1417
1416
|
set ids(t) {
|
|
1418
1417
|
}
|
|
1419
1418
|
insert(t, e) {
|
|
1420
|
-
const i = this.store.getGeometryCopy(t), { midPointFeatureId: o, midPointSegment: s } = this.store.getPropertiesCopy(t),
|
|
1421
|
-
a.splice(s + 1, 0, i.coordinates),
|
|
1419
|
+
const i = this.store.getGeometryCopy(t), { midPointFeatureId: o, midPointSegment: s } = this.store.getPropertiesCopy(t), n = this.store.getGeometryCopy(o), a = n.type === "Polygon" ? n.coordinates[0] : n.coordinates;
|
|
1420
|
+
a.splice(s + 1, 0, i.coordinates), n.coordinates = n.type === "Polygon" ? [a] : a, this.store.updateGeometry([{ id: o, geometry: n }]), this.store.delete([...this._midPoints, ...this.selectionPointBehavior.ids]), this.create(a, o, e), this.selectionPointBehavior.create(a, n.type, o);
|
|
1422
1421
|
}
|
|
1423
1422
|
create(t, e, i) {
|
|
1424
1423
|
if (!this.store.has(e)) throw new Error("Store does not have feature with this id");
|
|
1425
|
-
this._midPoints = this.store.create(function(o, s,
|
|
1426
|
-
return oe({ featureCoords: o, precision:
|
|
1427
|
-
}(t, (o) => ({ mode: this.mode, [
|
|
1424
|
+
this._midPoints = this.store.create(function(o, s, n, a, l, d) {
|
|
1425
|
+
return oe({ featureCoords: o, precision: n, project: a, unproject: l, projection: d }).map((c, h) => ({ geometry: { type: "Point", coordinates: c }, properties: s(h) }));
|
|
1426
|
+
}(t, (o) => ({ mode: this.mode, [rt]: !0, midPointSegment: o, midPointFeatureId: e }), i, this.config.project, this.config.unproject, this.projection));
|
|
1428
1427
|
}
|
|
1429
1428
|
delete() {
|
|
1430
1429
|
this._midPoints.length && (this.store.delete(this._midPoints), this._midPoints = []);
|
|
@@ -1443,9 +1442,9 @@ class ai extends W {
|
|
|
1443
1442
|
set ids(t) {
|
|
1444
1443
|
}
|
|
1445
1444
|
create(t, e, i) {
|
|
1446
|
-
this._selectionPoints = this.store.create(function(o, s,
|
|
1445
|
+
this._selectionPoints = this.store.create(function(o, s, n) {
|
|
1447
1446
|
const a = [], l = s === "Polygon" ? o.length - 1 : o.length;
|
|
1448
|
-
for (let d = 0; d < l; d++) a.push({ geometry: { type: "Point", coordinates: o[d] }, properties:
|
|
1447
|
+
for (let d = 0; d < l; d++) a.push({ geometry: { type: "Point", coordinates: o[d] }, properties: n(d) });
|
|
1449
1448
|
return a;
|
|
1450
1449
|
}(t, e, (o) => ({ mode: this.mode, selectionPoint: !0, selectionPointFeatureId: i, index: o })));
|
|
1451
1450
|
}
|
|
@@ -1459,49 +1458,49 @@ class ai extends W {
|
|
|
1459
1458
|
if (this._selectionPoints[t] !== void 0) return { id: this._selectionPoints[t], geometry: { type: "Point", coordinates: e } };
|
|
1460
1459
|
}
|
|
1461
1460
|
}
|
|
1462
|
-
function
|
|
1461
|
+
function we(r, t) {
|
|
1463
1462
|
let e = !1;
|
|
1464
|
-
for (let
|
|
1465
|
-
const l = t[
|
|
1466
|
-
for (let d = 0, c = l.length, h = c - 1; d < c; h = d++) (o = l[d])[1] > (i =
|
|
1463
|
+
for (let n = 0, a = t.length; n < a; n++) {
|
|
1464
|
+
const l = t[n];
|
|
1465
|
+
for (let d = 0, c = l.length, h = c - 1; d < c; h = d++) (o = l[d])[1] > (i = r)[1] != (s = l[h])[1] > i[1] && i[0] < (s[0] - o[0]) * (i[1] - o[1]) / (s[1] - o[1]) + o[0] && (e = !e);
|
|
1467
1466
|
}
|
|
1468
1467
|
var i, o, s;
|
|
1469
1468
|
return e;
|
|
1470
1469
|
}
|
|
1471
|
-
const
|
|
1472
|
-
const i = (s) => s * s, o = (s,
|
|
1473
|
-
return Math.sqrt(((s,
|
|
1474
|
-
const l = o(
|
|
1475
|
-
if (l === 0) return o(s,
|
|
1476
|
-
let d = ((s.x -
|
|
1477
|
-
return d = Math.max(0, Math.min(1, d)), o(s, { x:
|
|
1478
|
-
})(
|
|
1470
|
+
const be = (r, t, e) => {
|
|
1471
|
+
const i = (s) => s * s, o = (s, n) => i(s.x - n.x) + i(s.y - n.y);
|
|
1472
|
+
return Math.sqrt(((s, n, a) => {
|
|
1473
|
+
const l = o(n, a);
|
|
1474
|
+
if (l === 0) return o(s, n);
|
|
1475
|
+
let d = ((s.x - n.x) * (a.x - n.x) + (s.y - n.y) * (a.y - n.y)) / l;
|
|
1476
|
+
return d = Math.max(0, Math.min(1, d)), o(s, { x: n.x + d * (a.x - n.x), y: n.y + d * (a.y - n.y) });
|
|
1477
|
+
})(r, t, e));
|
|
1479
1478
|
};
|
|
1480
1479
|
class li extends W {
|
|
1481
1480
|
constructor(t, e, i) {
|
|
1482
1481
|
super(t), this.config = void 0, this.createClickBoundingBox = void 0, this.pixelDistance = void 0, this.config = t, this.createClickBoundingBox = e, this.pixelDistance = i;
|
|
1483
1482
|
}
|
|
1484
1483
|
find(t, e) {
|
|
1485
|
-
let i, o, s,
|
|
1484
|
+
let i, o, s, n, a = 1 / 0, l = 1 / 0, d = 1 / 0;
|
|
1486
1485
|
const c = this.createClickBoundingBox.create(t), h = this.store.search(c);
|
|
1487
1486
|
for (let u = 0; u < h.length; u++) {
|
|
1488
1487
|
const g = h[u], y = g.geometry;
|
|
1489
1488
|
if (y.type === "Point") {
|
|
1490
|
-
if (g.properties.selectionPoint || !e && g.properties[
|
|
1489
|
+
if (g.properties.selectionPoint || !e && g.properties[rt]) continue;
|
|
1491
1490
|
const p = this.pixelDistance.measure(t, y.coordinates);
|
|
1492
|
-
g.properties[
|
|
1491
|
+
g.properties[rt] && p < this.pointerDistance && p < d ? (d = p, s = g) : !g.properties[rt] && p < this.pointerDistance && p < a && (a = p, i = g);
|
|
1493
1492
|
} else if (y.type === "LineString") {
|
|
1494
1493
|
if (i) continue;
|
|
1495
1494
|
for (let p = 0; p < y.coordinates.length - 1; p++) {
|
|
1496
|
-
const C = y.coordinates[p], f = y.coordinates[p + 1], v =
|
|
1495
|
+
const C = y.coordinates[p], f = y.coordinates[p + 1], v = be({ x: t.containerX, y: t.containerY }, this.project(C[0], C[1]), this.project(f[0], f[1]));
|
|
1497
1496
|
v < this.pointerDistance && v < l && (l = v, o = g);
|
|
1498
1497
|
}
|
|
1499
1498
|
} else if (y.type === "Polygon") {
|
|
1500
1499
|
if (i || o) continue;
|
|
1501
|
-
|
|
1500
|
+
we([t.lng, t.lat], y.coordinates) && (n = g);
|
|
1502
1501
|
}
|
|
1503
1502
|
}
|
|
1504
|
-
return { clickedFeature: i || o ||
|
|
1503
|
+
return { clickedFeature: i || o || n, clickedMidPoint: s };
|
|
1505
1504
|
}
|
|
1506
1505
|
}
|
|
1507
1506
|
class di extends W {
|
|
@@ -1525,9 +1524,9 @@ class di extends W {
|
|
|
1525
1524
|
if (!this.draggedFeatureId) return;
|
|
1526
1525
|
const i = this.store.getGeometryCopy(this.draggedFeatureId), o = [t.lng, t.lat];
|
|
1527
1526
|
if (i.type === "Polygon" || i.type === "LineString") {
|
|
1528
|
-
let s,
|
|
1529
|
-
if (i.type === "Polygon" ? (s = i.coordinates[0],
|
|
1530
|
-
for (let d = 0; d <
|
|
1527
|
+
let s, n;
|
|
1528
|
+
if (i.type === "Polygon" ? (s = i.coordinates[0], n = s.length - 1) : (s = i.coordinates, n = s.length), !this.dragPosition) return !1;
|
|
1529
|
+
for (let d = 0; d < n; d++) {
|
|
1531
1530
|
const c = s[d];
|
|
1532
1531
|
let h, u;
|
|
1533
1532
|
if (this.config.projection === "web-mercator") {
|
|
@@ -1542,7 +1541,7 @@ class di extends W {
|
|
|
1542
1541
|
}
|
|
1543
1542
|
i.type === "Polygon" && (s[s.length - 1] = [s[0][0], s[0][1]]);
|
|
1544
1543
|
const a = this.selectionPoints.getUpdated(s) || [], l = this.midPoints.getUpdated(s) || [];
|
|
1545
|
-
if (e && !e({ type: "Feature", id: this.draggedFeatureId, geometry: i, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType:
|
|
1544
|
+
if (e && !e({ type: "Feature", id: this.draggedFeatureId, geometry: i, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional }).valid) return !1;
|
|
1546
1545
|
this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: i }, ...a, ...l]), this.dragPosition = [t.lng, t.lat];
|
|
1547
1546
|
} else i.type === "Point" && (this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: { type: "Point", coordinates: o } }]), this.dragPosition = [t.lng, t.lat]);
|
|
1548
1547
|
}
|
|
@@ -1560,10 +1559,10 @@ class ci extends W {
|
|
|
1560
1559
|
o = e.coordinates[0];
|
|
1561
1560
|
}
|
|
1562
1561
|
for (let s = 0; s < o.length; s++) {
|
|
1563
|
-
const
|
|
1564
|
-
if (
|
|
1562
|
+
const n = this.pixelDistance.measure(t, o[s]);
|
|
1563
|
+
if (n < this.pointerDistance && n < i.dist) {
|
|
1565
1564
|
const a = e.type === "Polygon" && (s === o.length - 1 || s === 0);
|
|
1566
|
-
i.dist =
|
|
1565
|
+
i.dist = n, i.index = a ? 0 : s, i.isFirstOrLastPolygonCoord = a;
|
|
1567
1566
|
}
|
|
1568
1567
|
}
|
|
1569
1568
|
return i;
|
|
@@ -1574,15 +1573,15 @@ class ci extends W {
|
|
|
1574
1573
|
}
|
|
1575
1574
|
drag(t, e, i) {
|
|
1576
1575
|
if (!this.draggedCoordinate.id) return !1;
|
|
1577
|
-
const o = this.draggedCoordinate.index, s = this.store.getGeometryCopy(this.draggedCoordinate.id),
|
|
1576
|
+
const o = this.draggedCoordinate.index, s = this.store.getGeometryCopy(this.draggedCoordinate.id), n = s.type === "LineString" ? s.coordinates : s.coordinates[0], a = [t.lng, t.lat];
|
|
1578
1577
|
if (t.lng > 180 || t.lng < -180 || t.lat > 90 || t.lat < -90) return !1;
|
|
1579
|
-
if (s.type !== "Polygon" || o !==
|
|
1578
|
+
if (s.type !== "Polygon" || o !== n.length - 1 && o !== 0) n[o] = a;
|
|
1580
1579
|
else {
|
|
1581
|
-
const h =
|
|
1582
|
-
|
|
1580
|
+
const h = n.length - 1;
|
|
1581
|
+
n[0] = a, n[h] = a;
|
|
1583
1582
|
}
|
|
1584
|
-
const l = this.selectionPoints.getOneUpdated(o, a), d = l ? [l] : [], c = this.midPoints.getUpdated(
|
|
1585
|
-
return !(s.type !== "Point" && !e && kt({ type: "Feature", geometry: s, properties: {} }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: s, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType:
|
|
1583
|
+
const l = this.selectionPoints.getOneUpdated(o, a), d = l ? [l] : [], c = this.midPoints.getUpdated(n) || [];
|
|
1584
|
+
return !(s.type !== "Point" && !e && kt({ type: "Feature", geometry: s, properties: {} }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: s, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: s }, ...d, ...c]), 0));
|
|
1586
1585
|
}
|
|
1587
1586
|
isDragging() {
|
|
1588
1587
|
return this.draggedCoordinate.id !== null;
|
|
@@ -1594,29 +1593,29 @@ class ci extends W {
|
|
|
1594
1593
|
this.draggedCoordinate = { id: null, index: -1 };
|
|
1595
1594
|
}
|
|
1596
1595
|
}
|
|
1597
|
-
function Ct(
|
|
1596
|
+
function Ct(r) {
|
|
1598
1597
|
let t = 0, e = 0, i = 0;
|
|
1599
|
-
return (
|
|
1598
|
+
return (r.geometry.type === "Polygon" ? r.geometry.coordinates[0].slice(0, -1) : r.geometry.coordinates).forEach((o) => {
|
|
1600
1599
|
t += o[0], e += o[1], i++;
|
|
1601
1600
|
}, !0), [t / i, e / i];
|
|
1602
1601
|
}
|
|
1603
|
-
function Ie(
|
|
1604
|
-
|
|
1605
|
-
const e = Ot, i = t[1] * Math.PI / 180, o =
|
|
1606
|
-
let
|
|
1607
|
-
|
|
1602
|
+
function Ie(r, t) {
|
|
1603
|
+
r[0] += r[0] - t[0] > 180 ? -360 : t[0] - r[0] > 180 ? 360 : 0;
|
|
1604
|
+
const e = Ot, i = t[1] * Math.PI / 180, o = r[1] * Math.PI / 180, s = o - i;
|
|
1605
|
+
let n = Math.abs(r[0] - t[0]) * Math.PI / 180;
|
|
1606
|
+
n > Math.PI && (n -= 2 * Math.PI);
|
|
1608
1607
|
const a = Math.log(Math.tan(o / 2 + Math.PI / 4) / Math.tan(i / 2 + Math.PI / 4)), l = Math.abs(a) > 1e-11 ? s / a : Math.cos(i);
|
|
1609
|
-
return Math.sqrt(s * s + l * l *
|
|
1608
|
+
return Math.sqrt(s * s + l * l * n * n) * e;
|
|
1610
1609
|
}
|
|
1611
|
-
function Pt(
|
|
1612
|
-
const t = (
|
|
1610
|
+
function Pt(r) {
|
|
1611
|
+
const t = (r.geometry.type === "Polygon" ? r.geometry.coordinates[0] : r.geometry.coordinates).map((e) => {
|
|
1613
1612
|
const { x: i, y: o } = S(e[0], e[1]);
|
|
1614
1613
|
return [i, o];
|
|
1615
1614
|
});
|
|
1616
|
-
return
|
|
1615
|
+
return r.geometry.type === "Polygon" ? function(e) {
|
|
1617
1616
|
let i = 0, o = 0, s = 0;
|
|
1618
|
-
const
|
|
1619
|
-
for (let a = 0; a <
|
|
1617
|
+
const n = e.length;
|
|
1618
|
+
for (let a = 0; a < n - 1; a++) {
|
|
1620
1619
|
const [l, d] = e[a], [c, h] = e[a + 1], u = l * h - c * d;
|
|
1621
1620
|
i += u, o += (l + c) * u, s += (d + h) * u;
|
|
1622
1621
|
}
|
|
@@ -1624,8 +1623,8 @@ function Pt(n) {
|
|
|
1624
1623
|
}(t) : function(e) {
|
|
1625
1624
|
const i = e.length;
|
|
1626
1625
|
let o = 0, s = 0;
|
|
1627
|
-
for (let
|
|
1628
|
-
const [a, l] = e[
|
|
1626
|
+
for (let n = 0; n < i; n++) {
|
|
1627
|
+
const [a, l] = e[n];
|
|
1629
1628
|
o += a, s += l;
|
|
1630
1629
|
}
|
|
1631
1630
|
return { x: o / i, y: s / i };
|
|
@@ -1642,20 +1641,20 @@ class hi extends W {
|
|
|
1642
1641
|
const o = this.store.getGeometryCopy(e);
|
|
1643
1642
|
if (o.type !== "Polygon" && o.type !== "LineString") return;
|
|
1644
1643
|
const s = [t.lng, t.lat];
|
|
1645
|
-
let
|
|
1644
|
+
let n;
|
|
1646
1645
|
const a = { type: "Feature", geometry: o, properties: {} };
|
|
1647
1646
|
if (this.config.projection === "web-mercator") {
|
|
1648
|
-
if (
|
|
1647
|
+
if (n = A(Pt(a), S(t.lng, t.lat)), !this.lastBearing) return void (this.lastBearing = n);
|
|
1649
1648
|
((h, u) => {
|
|
1650
1649
|
if (u === 0 || u === 360 || u === -360) return h;
|
|
1651
1650
|
const g = 0.017453292519943295 * u, y = (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).map(([f, v]) => S(f, v)), p = y.reduce((f, v) => ({ x: f.x + v.x, y: f.y + v.y }), { x: 0, y: 0 });
|
|
1652
1651
|
p.x /= y.length, p.y /= y.length;
|
|
1653
1652
|
const C = y.map((f) => ({ x: p.x + (f.x - p.x) * Math.cos(g) - (f.y - p.y) * Math.sin(g), y: p.y + (f.x - p.x) * Math.sin(g) + (f.y - p.y) * Math.cos(g) })).map(({ x: f, y: v }) => [L(f, v).lng, L(f, v).lat]);
|
|
1654
1653
|
h.geometry.type === "Polygon" ? h.geometry.coordinates[0] = C : h.geometry.coordinates = C;
|
|
1655
|
-
})(a, -(this.lastBearing -
|
|
1654
|
+
})(a, -(this.lastBearing - n));
|
|
1656
1655
|
} else {
|
|
1657
1656
|
if (this.config.projection !== "globe") throw new Error("Unsupported projection");
|
|
1658
|
-
if (
|
|
1657
|
+
if (n = vt(Ct({ type: "Feature", geometry: o, properties: {} }), s), !this.lastBearing) return void (this.lastBearing = n + 180);
|
|
1659
1658
|
(function(h, u) {
|
|
1660
1659
|
if (u === 0 || u === 360 || u === -360) return h;
|
|
1661
1660
|
const g = Ct(h);
|
|
@@ -1663,15 +1662,15 @@ class hi extends W {
|
|
|
1663
1662
|
const p = vt(g, y) + u, C = Ie(g, y), f = jt(g, C, p);
|
|
1664
1663
|
y[0] = f[0], y[1] = f[1];
|
|
1665
1664
|
});
|
|
1666
|
-
})(a, -(this.lastBearing - (
|
|
1665
|
+
})(a, -(this.lastBearing - (n + 180)));
|
|
1667
1666
|
}
|
|
1668
1667
|
const l = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
|
|
1669
1668
|
l.forEach((h) => {
|
|
1670
1669
|
h[0] = F(h[0], this.coordinatePrecision), h[1] = F(h[1], this.coordinatePrecision);
|
|
1671
1670
|
});
|
|
1672
1671
|
const d = this.midPoints.getUpdated(l) || [], c = this.selectionPoints.getUpdated(l) || [];
|
|
1673
|
-
if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType:
|
|
1674
|
-
this.store.updateGeometry([{ id: e, geometry: o }, ...c, ...d]), this.projection === "web-mercator" ? this.lastBearing =
|
|
1672
|
+
if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional })) return !1;
|
|
1673
|
+
this.store.updateGeometry([{ id: e, geometry: o }, ...c, ...d]), this.projection === "web-mercator" ? this.lastBearing = n : this.projection === "globe" && (this.lastBearing = n + 180);
|
|
1675
1674
|
}
|
|
1676
1675
|
}
|
|
1677
1676
|
class ui extends W {
|
|
@@ -1684,9 +1683,9 @@ class ui extends W {
|
|
|
1684
1683
|
scale(t, e, i) {
|
|
1685
1684
|
const o = this.store.getGeometryCopy(e);
|
|
1686
1685
|
if (o.type !== "Polygon" && o.type !== "LineString") return;
|
|
1687
|
-
const s = [t.lng, t.lat],
|
|
1686
|
+
const s = [t.lng, t.lat], n = { type: "Feature", geometry: o, properties: {} };
|
|
1688
1687
|
let a;
|
|
1689
|
-
const l = Pt(
|
|
1688
|
+
const l = Pt(n);
|
|
1690
1689
|
if (this.config.projection === "web-mercator") {
|
|
1691
1690
|
const g = S(t.lng, t.lat);
|
|
1692
1691
|
a = E(l, g);
|
|
@@ -1700,21 +1699,21 @@ class ui extends W {
|
|
|
1700
1699
|
const { lng: g, lat: y } = L(l.x, l.y);
|
|
1701
1700
|
(function(p, C, f) {
|
|
1702
1701
|
if (C === 1) return p;
|
|
1703
|
-
const v = (p.geometry.type === "Polygon" ? p.geometry.coordinates[0] : p.geometry.coordinates).map(([x,
|
|
1702
|
+
const v = (p.geometry.type === "Polygon" ? p.geometry.coordinates[0] : p.geometry.coordinates).map(([x, w]) => S(x, w)), m = S(f[0], f[1]), P = v.map((x) => ({ x: m.x + (x.x - m.x) * C, y: m.y + (x.y - m.y) * C })).map(({ x, y: w }) => [L(x, w).lng, L(x, w).lat]);
|
|
1704
1703
|
p.geometry.type === "Polygon" ? p.geometry.coordinates[0] = P : p.geometry.coordinates = P;
|
|
1705
|
-
})(
|
|
1704
|
+
})(n, d, [g, y]);
|
|
1706
1705
|
} else this.config.projection === "globe" && function(g, y, p, C = "xy") {
|
|
1707
1706
|
y === 1 || (g.geometry.type === "Polygon" ? g.geometry.coordinates[0] : g.geometry.coordinates).forEach((f) => {
|
|
1708
1707
|
const v = Ie(p, f), m = vt(p, f), P = jt(p, v * y, m);
|
|
1709
1708
|
C !== "x" && C !== "xy" || (f[0] = P[0]), C !== "y" && C !== "xy" || (f[1] = P[1]);
|
|
1710
1709
|
});
|
|
1711
|
-
}(
|
|
1710
|
+
}(n, d, Ct(n));
|
|
1712
1711
|
const c = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
|
|
1713
1712
|
c.forEach((g) => {
|
|
1714
1713
|
g[0] = F(g[0], this.coordinatePrecision), g[1] = F(g[1], this.coordinatePrecision);
|
|
1715
1714
|
});
|
|
1716
1715
|
const h = this.midPoints.getUpdated(c) || [], u = this.selectionPoints.getUpdated(c) || [];
|
|
1717
|
-
if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType:
|
|
1716
|
+
if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional })) return !1;
|
|
1718
1717
|
this.store.updateGeometry([{ id: e, geometry: o }, ...u, ...h]), this.lastDistance = a;
|
|
1719
1718
|
}
|
|
1720
1719
|
}
|
|
@@ -1731,10 +1730,10 @@ class gi extends W {
|
|
|
1731
1730
|
o = e.coordinates[0];
|
|
1732
1731
|
}
|
|
1733
1732
|
for (let s = 0; s < o.length; s++) {
|
|
1734
|
-
const
|
|
1735
|
-
if (
|
|
1733
|
+
const n = this.pixelDistance.measure(t, o[s]);
|
|
1734
|
+
if (n < this.pointerDistance && n < i.dist) {
|
|
1736
1735
|
const a = e.type === "Polygon" && (s === o.length - 1 || s === 0);
|
|
1737
|
-
i.dist =
|
|
1736
|
+
i.dist = n, i.index = a ? 0 : s, i.isFirstOrLastPolygonCoord = a;
|
|
1738
1737
|
}
|
|
1739
1738
|
}
|
|
1740
1739
|
return i;
|
|
@@ -1777,41 +1776,41 @@ class gi extends W {
|
|
|
1777
1776
|
centerWebMercatorDrag(t) {
|
|
1778
1777
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1779
1778
|
if (!e) return null;
|
|
1780
|
-
const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate:
|
|
1779
|
+
const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a = Pt(i);
|
|
1781
1780
|
if (!a) return null;
|
|
1782
|
-
const l = S(
|
|
1781
|
+
const l = S(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), c = S(t.lng, t.lat);
|
|
1783
1782
|
return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: s, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), s;
|
|
1784
1783
|
}
|
|
1785
1784
|
centerFixedWebMercatorDrag(t) {
|
|
1786
1785
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1787
1786
|
if (!e) return null;
|
|
1788
|
-
const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate:
|
|
1787
|
+
const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a = Pt(i);
|
|
1789
1788
|
if (!a) return null;
|
|
1790
|
-
const l = S(
|
|
1789
|
+
const l = S(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), c = S(t.lng, t.lat);
|
|
1791
1790
|
return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: s, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), s;
|
|
1792
1791
|
}
|
|
1793
1792
|
scaleFixedWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: s }) {
|
|
1794
1793
|
if (!this.isValidDragWebMercator(t, e.x - o.x, e.y - o.y)) return null;
|
|
1795
|
-
let
|
|
1796
|
-
return
|
|
1794
|
+
let n = E(e, o) / E(e, i);
|
|
1795
|
+
return n < 0 && (n = this.minimumScale), this.performWebMercatorScale(s, e.x, e.y, n, n), s;
|
|
1797
1796
|
}
|
|
1798
1797
|
oppositeFixedWebMercatorDrag(t) {
|
|
1799
1798
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1800
1799
|
if (!e) return null;
|
|
1801
|
-
const { boundingBox: i, updatedCoords: o, selectedCoordinate: s } = e,
|
|
1802
|
-
return this.scaleFixedWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: c, webMercatorSelected:
|
|
1800
|
+
const { boundingBox: i, updatedCoords: o, selectedCoordinate: s } = e, n = S(s[0], s[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] }, c = S(t.lng, t.lat);
|
|
1801
|
+
return this.scaleFixedWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: n, webMercatorOrigin: d }), o;
|
|
1803
1802
|
}
|
|
1804
1803
|
oppositeWebMercatorDrag(t) {
|
|
1805
1804
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1806
1805
|
if (!e) return null;
|
|
1807
|
-
const { boundingBox: i, updatedCoords: o, selectedCoordinate: s } = e,
|
|
1808
|
-
return this.scaleWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: c, webMercatorSelected:
|
|
1806
|
+
const { boundingBox: i, updatedCoords: o, selectedCoordinate: s } = e, n = S(s[0], s[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] }, c = S(t.lng, t.lat);
|
|
1807
|
+
return this.scaleWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: n, webMercatorOrigin: d }), o;
|
|
1809
1808
|
}
|
|
1810
1809
|
scaleWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: s }) {
|
|
1811
|
-
const
|
|
1812
|
-
if (!this.isValidDragWebMercator(t,
|
|
1810
|
+
const n = e.x - o.x, a = e.y - o.y;
|
|
1811
|
+
if (!this.isValidDragWebMercator(t, n, a)) return null;
|
|
1813
1812
|
let l = 1;
|
|
1814
|
-
|
|
1813
|
+
n !== 0 && t !== 1 && t !== 5 && (l = 1 - (e.x - i.x - n) / n);
|
|
1815
1814
|
let d = 1;
|
|
1816
1815
|
return a !== 0 && t !== 3 && t !== 7 && (d = 1 - (e.y - i.y - a) / a), this.validateScale(l, d) ? (l < 0 && (l = this.minimumScale), d < 0 && (d = this.minimumScale), this.performWebMercatorScale(s, e.x, e.y, l, d), s) : null;
|
|
1817
1816
|
}
|
|
@@ -1828,9 +1827,9 @@ class gi extends W {
|
|
|
1828
1827
|
return i && o;
|
|
1829
1828
|
}
|
|
1830
1829
|
performWebMercatorScale(t, e, i, o, s) {
|
|
1831
|
-
t.forEach((
|
|
1832
|
-
const { x: a, y: l } = S(
|
|
1833
|
-
|
|
1830
|
+
t.forEach((n) => {
|
|
1831
|
+
const { x: a, y: l } = S(n[0], n[1]), d = e + (a - e) * o, c = i + (l - i) * s, { lng: h, lat: u } = L(d, c);
|
|
1832
|
+
n[0] = h, n[1] = u;
|
|
1834
1833
|
});
|
|
1835
1834
|
}
|
|
1836
1835
|
getBBoxWebMercator(t) {
|
|
@@ -1841,14 +1840,14 @@ class gi extends W {
|
|
|
1841
1840
|
})).forEach(([a, l]) => {
|
|
1842
1841
|
a < e[0] && (e[0] = a), l < e[1] && (e[1] = l), a > e[2] && (e[2] = a), l > e[3] && (e[3] = l);
|
|
1843
1842
|
});
|
|
1844
|
-
const [i, o, s,
|
|
1845
|
-
return [[i,
|
|
1843
|
+
const [i, o, s, n] = e;
|
|
1844
|
+
return [[i, n], [(i + s) / 2, n], [s, n], [s, n + (o - n) / 2], [s, o], [(i + s) / 2, o], [i, o], [i, n + (o - n) / 2]];
|
|
1846
1845
|
}
|
|
1847
1846
|
getIndexesWebMercator(t, e) {
|
|
1848
1847
|
let i, o = 1 / 0;
|
|
1849
1848
|
for (let s = 0; s < t.length; s++) {
|
|
1850
|
-
const
|
|
1851
|
-
|
|
1849
|
+
const n = E({ x: e.x, y: e.y }, { x: t[s][0], y: t[s][1] });
|
|
1850
|
+
n < o && (i = s, o = n);
|
|
1852
1851
|
}
|
|
1853
1852
|
if (i === void 0) throw new Error("No closest coordinate found");
|
|
1854
1853
|
return { oppositeBboxIndex: this.boundingBoxMaps.opposite[i], closestBBoxIndex: i };
|
|
@@ -1876,8 +1875,8 @@ class gi extends W {
|
|
|
1876
1875
|
const c = s[d];
|
|
1877
1876
|
if (c[0] = F(c[0], this.coordinatePrecision), c[1] = F(c[1], this.coordinatePrecision), !xt(c, this.coordinatePrecision)) return !1;
|
|
1878
1877
|
}
|
|
1879
|
-
const
|
|
1880
|
-
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:
|
|
1878
|
+
const n = this.midPoints.getUpdated(s) || [], a = this.selectionPoints.getUpdated(s) || [], l = { type: o.geometry.type, coordinates: o.geometry.type === "Polygon" ? [s] : s };
|
|
1879
|
+
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: b.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: l }, ...a, ...n]), 0));
|
|
1881
1880
|
}
|
|
1882
1881
|
}
|
|
1883
1882
|
class pi extends Re {
|
|
@@ -1903,7 +1902,7 @@ class pi extends Re {
|
|
|
1903
1902
|
this._state = "selecting";
|
|
1904
1903
|
}
|
|
1905
1904
|
registerBehaviors(t) {
|
|
1906
|
-
this.pixelDistance = new Wt(t), this.clickBoundingBox = new Lt(t), this.featuresAtMouseEvent = new li(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new ai(t), this.midPoints = new
|
|
1905
|
+
this.pixelDistance = new Wt(t), this.clickBoundingBox = new Lt(t), this.featuresAtMouseEvent = new li(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new ai(t), this.midPoints = new ni(t, this.selectionPoints), this.rotateFeature = new hi(t, this.selectionPoints, this.midPoints), this.scaleFeature = new ui(t, this.selectionPoints, this.midPoints), this.dragFeature = new di(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints), this.dragCoordinate = new ci(t, this.pixelDistance, this.selectionPoints, this.midPoints), this.dragCoordinateResizeFeature = new gi(t, this.pixelDistance, this.selectionPoints, this.midPoints);
|
|
1907
1906
|
}
|
|
1908
1907
|
deselectFeature() {
|
|
1909
1908
|
this.deselect();
|
|
@@ -1922,7 +1921,7 @@ class pi extends Re {
|
|
|
1922
1921
|
const u = this.store.getGeometryCopy(h), g = this.pixelDistance.measure(t, u.coordinates);
|
|
1923
1922
|
g < this.pointerDistance && g < i && (i = g, e = this.store.getPropertiesCopy(h));
|
|
1924
1923
|
}), !e) return;
|
|
1925
|
-
const o = e.selectionPointFeatureId, s = e.index,
|
|
1924
|
+
const o = e.selectionPointFeatureId, s = e.index, n = this.store.getPropertiesCopy(o), a = this.flags[n.mode], l = this.validations[n.mode];
|
|
1926
1925
|
if (!(a && a.feature && a.feature.coordinates && a.feature.coordinates.deletable)) return;
|
|
1927
1926
|
const d = this.store.getGeometryCopy(o);
|
|
1928
1927
|
let c;
|
|
@@ -1930,7 +1929,7 @@ class pi extends Re {
|
|
|
1930
1929
|
if (c = d.coordinates[0], c.length <= 4) return;
|
|
1931
1930
|
} else if (d.type === "LineString" && (c = d.coordinates, c.length <= 3)) return;
|
|
1932
1931
|
if (c) {
|
|
1933
|
-
if (d.type === "Polygon" && s === 0 || s === c.length - 1 ? (c.shift(), c.pop(), c.push([c[0][0], c[0][1]])) : c.splice(s, 1), l && !l({ id: o, type: "Feature", geometry: d, properties:
|
|
1932
|
+
if (d.type === "Polygon" && s === 0 || s === c.length - 1 ? (c.shift(), c.pop(), c.push([c[0][0], c[0][1]])) : c.splice(s, 1), l && !l({ id: o, type: "Feature", geometry: d, properties: n }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Commit }).valid) return;
|
|
1934
1933
|
this.store.delete([...this.midPoints.ids, ...this.selectionPoints.ids]), this.store.updateGeometry([{ id: o, geometry: d }]), this.selectionPoints.create(c, d.type, o), a && a.feature && a.feature.coordinates && a.feature.coordinates.midpoints && this.midPoints.create(c, o, this.coordinatePrecision);
|
|
1935
1934
|
}
|
|
1936
1935
|
}
|
|
@@ -1944,10 +1943,10 @@ class pi extends Re {
|
|
|
1944
1943
|
this.deselect();
|
|
1945
1944
|
}
|
|
1946
1945
|
e && this.setCursor(this.cursors.pointerOver), this.selected = [t], this.store.updateProperty([{ id: t, property: "selected", value: !0 }]), this.onSelect(t);
|
|
1947
|
-
const { type:
|
|
1948
|
-
if (
|
|
1949
|
-
const l =
|
|
1950
|
-
l && o && o.feature.coordinates && (this.selectionPoints.create(l,
|
|
1946
|
+
const { type: n, coordinates: a } = this.store.getGeometryCopy(t);
|
|
1947
|
+
if (n !== "LineString" && n !== "Polygon") return;
|
|
1948
|
+
const l = n === "LineString" ? a : a[0];
|
|
1949
|
+
l && o && o.feature.coordinates && (this.selectionPoints.create(l, n, t), o.feature.coordinates.midpoints && this.midPoints.create(l, t, this.coordinatePrecision));
|
|
1951
1950
|
}
|
|
1952
1951
|
onLeftClick(t) {
|
|
1953
1952
|
const { clickedFeature: e, clickedMidPoint: i } = this.featuresAtMouseEvent.find(t, this.selected.length > 0);
|
|
@@ -1991,13 +1990,13 @@ class pi extends Re {
|
|
|
1991
1990
|
const i = this.store.getPropertiesCopy(this.selected[0]), o = this.flags[i.mode];
|
|
1992
1991
|
if (!(o && o.feature && (o.feature.draggable || o.feature.coordinates && o.feature.coordinates.draggable || o.feature.coordinates && o.feature.coordinates.resizable))) return;
|
|
1993
1992
|
this.dragEventCount = 0;
|
|
1994
|
-
const s = this.selected[0],
|
|
1995
|
-
return o && o.feature && o.feature.coordinates && (o.feature.coordinates.draggable || o.feature.coordinates.resizable) &&
|
|
1993
|
+
const s = this.selected[0], n = this.dragCoordinate.getDraggableIndex(t, s);
|
|
1994
|
+
return o && o.feature && o.feature.coordinates && (o.feature.coordinates.draggable || o.feature.coordinates.resizable) && n !== -1 ? (this.setCursor(this.cursors.dragStart), o.feature.coordinates.resizable ? this.dragCoordinateResizeFeature.startDragging(s, n) : this.dragCoordinate.startDragging(s, n), void e(!1)) : o && o.feature && o.feature.draggable && this.dragFeature.canDrag(t, s) ? (this.setCursor(this.cursors.dragStart), this.dragFeature.startDragging(t, s), void e(!1)) : void 0;
|
|
1996
1995
|
}
|
|
1997
1996
|
onDrag(t, e) {
|
|
1998
1997
|
const i = this.selected[0];
|
|
1999
1998
|
if (!i) return;
|
|
2000
|
-
const o = this.store.getPropertiesCopy(i), s = this.flags[o.mode],
|
|
1999
|
+
const o = this.store.getPropertiesCopy(i), s = this.flags[o.mode], n = (s && s.feature && s.feature.selfIntersectable) === !0;
|
|
2001
2000
|
if (this.dragEventCount++, this.dragEventCount % this.dragEventThrottle == 0) return;
|
|
2002
2001
|
const a = this.validations[o.mode];
|
|
2003
2002
|
if (s && s.feature && s.feature.rotateable && this.canRotate(t)) return e(!1), void this.rotateFeature.rotate(t, i, a);
|
|
@@ -2006,7 +2005,7 @@ class pi extends Re {
|
|
|
2006
2005
|
if (this.projection === "globe") throw new Error("Globe is currently unsupported projection for resizable");
|
|
2007
2006
|
return e(!1), void this.dragCoordinateResizeFeature.drag(t, s.feature.coordinates.resizable, a);
|
|
2008
2007
|
}
|
|
2009
|
-
this.dragCoordinate.isDragging() ? this.dragCoordinate.drag(t,
|
|
2008
|
+
this.dragCoordinate.isDragging() ? this.dragCoordinate.drag(t, n, a) : this.dragFeature.isDragging() ? this.dragFeature.drag(t, a) : e(!0);
|
|
2010
2009
|
}
|
|
2011
2010
|
onDragEnd(t, e) {
|
|
2012
2011
|
this.setCursor(this.cursors.dragEnd), this.dragCoordinate.isDragging() ? this.onFinish(this.selected[0], { mode: this.mode, action: "dragCoordinate" }) : this.dragFeature.isDragging() ? this.onFinish(this.selected[0], { mode: this.mode, action: "dragFeature" }) : this.dragCoordinateResizeFeature.isDragging() && this.onFinish(this.selected[0], { mode: this.mode, action: "dragCoordinateResize" }), this.dragCoordinate.stopDragging(), this.dragFeature.stopDragging(), this.dragCoordinateResizeFeature.stopDragging(), this.rotateFeature.reset(), this.scaleFeature.reset(), e(!0);
|
|
@@ -2017,13 +2016,13 @@ class pi extends Re {
|
|
|
2017
2016
|
let e = !1;
|
|
2018
2017
|
this.midPoints.ids.forEach((s) => {
|
|
2019
2018
|
if (e) return;
|
|
2020
|
-
const
|
|
2021
|
-
this.pixelDistance.measure(t,
|
|
2019
|
+
const n = this.store.getGeometryCopy(s);
|
|
2020
|
+
this.pixelDistance.measure(t, n.coordinates) < this.pointerDistance && (e = !0);
|
|
2022
2021
|
});
|
|
2023
2022
|
let i = !1;
|
|
2024
2023
|
if (this.selectionPoints.ids.forEach((s) => {
|
|
2025
|
-
const
|
|
2026
|
-
this.pixelDistance.measure(t,
|
|
2024
|
+
const n = this.store.getGeometryCopy(s);
|
|
2025
|
+
this.pixelDistance.measure(t, n.coordinates) < this.pointerDistance && (e = !1, i = !0);
|
|
2027
2026
|
}), e) return void this.setCursor(this.cursors.insertMidpoint);
|
|
2028
2027
|
const { clickedFeature: o } = this.featuresAtMouseEvent.find(t, !0);
|
|
2029
2028
|
this.setCursor(this.selected.length > 0 && (o && o.id === this.selected[0] || i) ? this.cursors.pointerOver : "unset");
|
|
@@ -2069,70 +2068,70 @@ class yi extends N {
|
|
|
2069
2068
|
return M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
2070
2069
|
}
|
|
2071
2070
|
}
|
|
2072
|
-
function Fe(
|
|
2071
|
+
function Fe(r, t, e, i, o) {
|
|
2073
2072
|
for (; i > e; ) {
|
|
2074
2073
|
if (i - e > 600) {
|
|
2075
2074
|
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);
|
|
2076
|
-
Fe(
|
|
2075
|
+
Fe(r, t, Math.max(e, Math.floor(t - d * h / l + u)), Math.min(i, Math.floor(t + (l - d) * h / l + u)), o);
|
|
2077
2076
|
}
|
|
2078
|
-
const s =
|
|
2079
|
-
let
|
|
2080
|
-
for (et(
|
|
2081
|
-
for (et(
|
|
2082
|
-
for (; o(
|
|
2077
|
+
const s = r[t];
|
|
2078
|
+
let n = e, a = i;
|
|
2079
|
+
for (et(r, e, t), o(r[i], s) > 0 && et(r, e, i); n < a; ) {
|
|
2080
|
+
for (et(r, n, a), n++, a--; o(r[n], s) < 0; ) n++;
|
|
2081
|
+
for (; o(r[a], s) > 0; ) a--;
|
|
2083
2082
|
}
|
|
2084
|
-
o(
|
|
2083
|
+
o(r[e], s) === 0 ? et(r, e, a) : (a++, et(r, a, i)), a <= t && (e = a + 1), t <= a && (i = a - 1);
|
|
2085
2084
|
}
|
|
2086
2085
|
}
|
|
2087
|
-
function et(
|
|
2088
|
-
const i =
|
|
2089
|
-
|
|
2086
|
+
function et(r, t, e) {
|
|
2087
|
+
const i = r[t];
|
|
2088
|
+
r[t] = r[e], r[e] = i;
|
|
2090
2089
|
}
|
|
2091
|
-
function q(
|
|
2092
|
-
ot(
|
|
2090
|
+
function q(r, t) {
|
|
2091
|
+
ot(r, 0, r.children.length, t, r);
|
|
2093
2092
|
}
|
|
2094
|
-
function ot(
|
|
2093
|
+
function ot(r, t, e, i, o) {
|
|
2095
2094
|
o || (o = Z([])), o.minX = 1 / 0, o.minY = 1 / 0, o.maxX = -1 / 0, o.maxY = -1 / 0;
|
|
2096
2095
|
for (let s = t; s < e; s++) {
|
|
2097
|
-
const
|
|
2098
|
-
st(o,
|
|
2096
|
+
const n = r.children[s];
|
|
2097
|
+
st(o, r.leaf ? i(n) : n);
|
|
2099
2098
|
}
|
|
2100
2099
|
return o;
|
|
2101
2100
|
}
|
|
2102
|
-
function st(
|
|
2103
|
-
return
|
|
2101
|
+
function st(r, t) {
|
|
2102
|
+
return r.minX = Math.min(r.minX, t.minX), r.minY = Math.min(r.minY, t.minY), r.maxX = Math.max(r.maxX, t.maxX), r.maxY = Math.max(r.maxY, t.maxY), r;
|
|
2104
2103
|
}
|
|
2105
|
-
function fi(
|
|
2106
|
-
return
|
|
2104
|
+
function fi(r, t) {
|
|
2105
|
+
return r.minX - t.minX;
|
|
2107
2106
|
}
|
|
2108
|
-
function mi(
|
|
2109
|
-
return
|
|
2107
|
+
function mi(r, t) {
|
|
2108
|
+
return r.minY - t.minY;
|
|
2110
2109
|
}
|
|
2111
|
-
function It(
|
|
2112
|
-
return (
|
|
2110
|
+
function It(r) {
|
|
2111
|
+
return (r.maxX - r.minX) * (r.maxY - r.minY);
|
|
2113
2112
|
}
|
|
2114
|
-
function gt(
|
|
2115
|
-
return
|
|
2113
|
+
function gt(r) {
|
|
2114
|
+
return r.maxX - r.minX + (r.maxY - r.minY);
|
|
2116
2115
|
}
|
|
2117
|
-
function vi(
|
|
2118
|
-
const e = Math.max(
|
|
2116
|
+
function vi(r, t) {
|
|
2117
|
+
const e = Math.max(r.minX, t.minX), i = Math.max(r.minY, t.minY), o = Math.min(r.maxX, t.maxX), s = Math.min(r.maxY, t.maxY);
|
|
2119
2118
|
return Math.max(0, o - e) * Math.max(0, s - i);
|
|
2120
2119
|
}
|
|
2121
|
-
function Ft(
|
|
2122
|
-
return
|
|
2120
|
+
function Ft(r, t) {
|
|
2121
|
+
return r.minX <= t.minX && r.minY <= t.minY && t.maxX <= r.maxX && t.maxY <= r.maxY;
|
|
2123
2122
|
}
|
|
2124
|
-
function pt(
|
|
2125
|
-
return t.minX <=
|
|
2123
|
+
function pt(r, t) {
|
|
2124
|
+
return t.minX <= r.maxX && t.minY <= r.maxY && t.maxX >= r.minX && t.maxY >= r.minY;
|
|
2126
2125
|
}
|
|
2127
|
-
function Z(
|
|
2128
|
-
return { children:
|
|
2126
|
+
function Z(r) {
|
|
2127
|
+
return { children: r, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
|
|
2129
2128
|
}
|
|
2130
|
-
function se(
|
|
2129
|
+
function se(r, t, e, i, o) {
|
|
2131
2130
|
const s = [t, e];
|
|
2132
2131
|
for (; s.length; ) {
|
|
2133
2132
|
if ((e = s.pop()) - (t = s.pop()) <= i) continue;
|
|
2134
|
-
const
|
|
2135
|
-
Fe(
|
|
2133
|
+
const n = t + Math.ceil((e - t) / i / 2) * i;
|
|
2134
|
+
Fe(r, n, t, e, o), s.push(t, n, n, e);
|
|
2136
2135
|
}
|
|
2137
2136
|
}
|
|
2138
2137
|
class Ci {
|
|
@@ -2145,8 +2144,8 @@ class Ci {
|
|
|
2145
2144
|
if (!pt(t, e)) return i;
|
|
2146
2145
|
const o = this.toBBox, s = [];
|
|
2147
2146
|
for (; e; ) {
|
|
2148
|
-
for (let
|
|
2149
|
-
const a = e.children[
|
|
2147
|
+
for (let n = 0; n < e.children.length; n++) {
|
|
2148
|
+
const a = e.children[n], l = e.leaf ? o(a) : a;
|
|
2150
2149
|
pt(t, l) && (e.leaf ? i.push(a) : Ft(t, l) ? this._all(a, i) : s.push(a));
|
|
2151
2150
|
}
|
|
2152
2151
|
e = s.pop();
|
|
@@ -2159,9 +2158,9 @@ class Ci {
|
|
|
2159
2158
|
const i = [];
|
|
2160
2159
|
for (; e; ) {
|
|
2161
2160
|
for (let o = 0; o < e.children.length; o++) {
|
|
2162
|
-
const s = e.children[o],
|
|
2163
|
-
if (pt(t,
|
|
2164
|
-
if (e.leaf || Ft(t,
|
|
2161
|
+
const s = e.children[o], n = e.leaf ? this.toBBox(s) : s;
|
|
2162
|
+
if (pt(t, n)) {
|
|
2163
|
+
if (e.leaf || Ft(t, n)) return !0;
|
|
2165
2164
|
i.push(s);
|
|
2166
2165
|
}
|
|
2167
2166
|
}
|
|
@@ -2195,13 +2194,13 @@ class Ci {
|
|
|
2195
2194
|
remove(t) {
|
|
2196
2195
|
let e = this.data;
|
|
2197
2196
|
const i = this.toBBox(t), o = [], s = [];
|
|
2198
|
-
let
|
|
2197
|
+
let n, a, l = !1;
|
|
2199
2198
|
for (; e || o.length; ) {
|
|
2200
|
-
if (e || (e = o.pop(), a = o[o.length - 1],
|
|
2199
|
+
if (e || (e = o.pop(), a = o[o.length - 1], n = s.pop(), l = !0), e.leaf) {
|
|
2201
2200
|
const d = e.children.indexOf(t);
|
|
2202
2201
|
d !== -1 && (e.children.splice(d, 1), o.push(e), this._condense(o));
|
|
2203
2202
|
}
|
|
2204
|
-
l || e.leaf || !Ft(e, i) ? a ? (
|
|
2203
|
+
l || e.leaf || !Ft(e, i) ? a ? (n++, e = a.children[n], l = !1) : e = null : (o.push(e), s.push(n), n = 0, a = e, e = e.children[0]);
|
|
2205
2204
|
}
|
|
2206
2205
|
}
|
|
2207
2206
|
toBBox(t) {
|
|
@@ -2220,9 +2219,9 @@ class Ci {
|
|
|
2220
2219
|
}
|
|
2221
2220
|
_build(t, e, i, o) {
|
|
2222
2221
|
const s = i - e + 1;
|
|
2223
|
-
let
|
|
2224
|
-
if (s <= a) return
|
|
2225
|
-
o || (o = Math.ceil(Math.log(s) / Math.log(a)), a = Math.ceil(s / Math.pow(a, o - 1))),
|
|
2222
|
+
let n, a = this._maxEntries;
|
|
2223
|
+
if (s <= a) return n = Z(t.slice(e, i + 1)), q(n, this.toBBox), n;
|
|
2224
|
+
o || (o = Math.ceil(Math.log(s) / Math.log(a)), a = Math.ceil(s / Math.pow(a, o - 1))), n = Z([]), n.leaf = !1, n.height = o;
|
|
2226
2225
|
const l = Math.ceil(s / a), d = l * Math.ceil(Math.sqrt(a));
|
|
2227
2226
|
se(t, e, i, d, this.compareMinX);
|
|
2228
2227
|
for (let c = e; c <= i; c += d) {
|
|
@@ -2230,42 +2229,42 @@ class Ci {
|
|
|
2230
2229
|
se(t, c, h, l, this.compareMinY);
|
|
2231
2230
|
for (let u = c; u <= h; u += l) {
|
|
2232
2231
|
const g = Math.min(u + l - 1, h);
|
|
2233
|
-
|
|
2232
|
+
n.children.push(this._build(t, u, g, o - 1));
|
|
2234
2233
|
}
|
|
2235
2234
|
}
|
|
2236
|
-
return q(
|
|
2235
|
+
return q(n, this.toBBox), n;
|
|
2237
2236
|
}
|
|
2238
2237
|
_chooseSubtree(t, e, i, o) {
|
|
2239
2238
|
for (; o.push(e), !e.leaf && o.length - 1 !== i; ) {
|
|
2240
2239
|
let a, l = 1 / 0, d = 1 / 0;
|
|
2241
2240
|
for (let c = 0; c < e.children.length; c++) {
|
|
2242
|
-
const h = e.children[c], u = It(h), g = (s = t,
|
|
2241
|
+
const h = e.children[c], u = It(h), g = (s = t, n = h, (Math.max(n.maxX, s.maxX) - Math.min(n.minX, s.minX)) * (Math.max(n.maxY, s.maxY) - Math.min(n.minY, s.minY)) - u);
|
|
2243
2242
|
g < d ? (d = g, l = u < l ? u : l, a = h) : g === d && u < l && (l = u, a = h);
|
|
2244
2243
|
}
|
|
2245
2244
|
e = a || e.children[0];
|
|
2246
2245
|
}
|
|
2247
|
-
var s,
|
|
2246
|
+
var s, n;
|
|
2248
2247
|
return e;
|
|
2249
2248
|
}
|
|
2250
2249
|
_insert(t, e, i) {
|
|
2251
|
-
const o = i ? t : this.toBBox(t), s = [],
|
|
2252
|
-
for (
|
|
2250
|
+
const o = i ? t : this.toBBox(t), s = [], n = this._chooseSubtree(o, this.data, e, s);
|
|
2251
|
+
for (n.children.push(t), st(n, o); e >= 0 && s[e].children.length > this._maxEntries; ) this._split(s, e), e--;
|
|
2253
2252
|
this._adjustParentBBoxes(o, s, e);
|
|
2254
2253
|
}
|
|
2255
2254
|
_split(t, e) {
|
|
2256
2255
|
const i = t[e], o = i.children.length, s = this._minEntries;
|
|
2257
2256
|
this._chooseSplitAxis(i, s, o);
|
|
2258
|
-
const
|
|
2257
|
+
const n = this._chooseSplitIndex(i, s, o), a = Z(i.children.splice(n, i.children.length - n));
|
|
2259
2258
|
a.height = i.height, a.leaf = i.leaf, q(i, this.toBBox), q(a, this.toBBox), e ? t[e - 1].children.push(a) : this._splitRoot(i, a);
|
|
2260
2259
|
}
|
|
2261
2260
|
_splitRoot(t, e) {
|
|
2262
2261
|
this.data = Z([t, e]), this.data.height = t.height + 1, this.data.leaf = !1, q(this.data, this.toBBox);
|
|
2263
2262
|
}
|
|
2264
2263
|
_chooseSplitIndex(t, e, i) {
|
|
2265
|
-
let o, s = 1 / 0,
|
|
2264
|
+
let o, s = 1 / 0, n = 1 / 0;
|
|
2266
2265
|
for (let a = e; a <= i - e; a++) {
|
|
2267
2266
|
const l = ot(t, 0, a, this.toBBox), d = ot(t, a, i, this.toBBox), c = vi(l, d), h = It(l) + It(d);
|
|
2268
|
-
c < s ? (s = c, o = a,
|
|
2267
|
+
c < s ? (s = c, o = a, n = h < n ? h : n) : c === s && h < n && (n = h, o = a);
|
|
2269
2268
|
}
|
|
2270
2269
|
return o || i - e;
|
|
2271
2270
|
}
|
|
@@ -2275,11 +2274,11 @@ class Ci {
|
|
|
2275
2274
|
}
|
|
2276
2275
|
_allDistMargin(t, e, i, o) {
|
|
2277
2276
|
t.children.sort(o);
|
|
2278
|
-
const s = this.toBBox,
|
|
2279
|
-
let l = gt(
|
|
2277
|
+
const s = this.toBBox, n = ot(t, 0, e, s), a = ot(t, i - e, i, s);
|
|
2278
|
+
let l = gt(n) + gt(a);
|
|
2280
2279
|
for (let d = e; d < i - e; d++) {
|
|
2281
2280
|
const c = t.children[d];
|
|
2282
|
-
st(
|
|
2281
|
+
st(n, t.leaf ? s(c) : c), l += gt(n);
|
|
2283
2282
|
}
|
|
2284
2283
|
for (let d = i - e - 1; d >= e; d--) {
|
|
2285
2284
|
const c = t.children[d];
|
|
@@ -2311,8 +2310,8 @@ class Pi {
|
|
|
2311
2310
|
o = [t.geometry.coordinates];
|
|
2312
2311
|
}
|
|
2313
2312
|
for (let a = 0; a < o.length; a++) i.push(o[a][1]), e.push(o[a][0]);
|
|
2314
|
-
const s = Math.min(...i),
|
|
2315
|
-
return { minX: Math.min(...e), minY: s, maxX: Math.max(...e), maxY:
|
|
2313
|
+
const s = Math.min(...i), n = Math.max(...i);
|
|
2314
|
+
return { minX: Math.min(...e), minY: s, maxX: Math.max(...e), maxY: n };
|
|
2316
2315
|
}
|
|
2317
2316
|
insert(t) {
|
|
2318
2317
|
if (this.idToNode.get(String(t.id))) throw new Error("Feature already exists");
|
|
@@ -2347,10 +2346,10 @@ class Pi {
|
|
|
2347
2346
|
return this.tree.collides(this.toBBox(t));
|
|
2348
2347
|
}
|
|
2349
2348
|
}
|
|
2350
|
-
const xi = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(
|
|
2349
|
+
const xi = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(r) {
|
|
2351
2350
|
const t = 16 * Math.random() | 0;
|
|
2352
|
-
return (
|
|
2353
|
-
}), isValidId: (
|
|
2351
|
+
return (r == "x" ? t : 3 & t | 8).toString(16);
|
|
2352
|
+
}), isValidId: (r) => typeof r == "string" && r.length === 36 };
|
|
2354
2353
|
class Si {
|
|
2355
2354
|
constructor(t) {
|
|
2356
2355
|
this.idStrategy = void 0, this.tracked = void 0, this.spatialIndex = void 0, this.store = void 0, this._onChange = () => {
|
|
@@ -2369,22 +2368,22 @@ class Si {
|
|
|
2369
2368
|
if (t.length === 0) return [];
|
|
2370
2369
|
let i = this.clone(t);
|
|
2371
2370
|
const o = [], s = [];
|
|
2372
|
-
return i = i.filter((
|
|
2373
|
-
|
|
2374
|
-
const a =
|
|
2371
|
+
return i = i.filter((n) => {
|
|
2372
|
+
n.id == null && (n.id = this.idStrategy.getId());
|
|
2373
|
+
const a = n.id;
|
|
2375
2374
|
if (e) {
|
|
2376
|
-
const l = e(
|
|
2375
|
+
const l = e(n);
|
|
2377
2376
|
if (!l.valid) return s.push({ id: a, valid: !1, reason: l.reason }), !1;
|
|
2378
2377
|
}
|
|
2379
2378
|
if (this.tracked) {
|
|
2380
|
-
if (
|
|
2381
|
-
if (!Ht(
|
|
2382
|
-
} else
|
|
2383
|
-
if (
|
|
2384
|
-
if (!Ht(
|
|
2385
|
-
} else
|
|
2379
|
+
if (n.properties.createdAt) {
|
|
2380
|
+
if (!Ht(n.properties.createdAt)) return s.push({ id: n.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
|
|
2381
|
+
} else n.properties.createdAt = +/* @__PURE__ */ new Date();
|
|
2382
|
+
if (n.properties.updatedAt) {
|
|
2383
|
+
if (!Ht(n.properties.updatedAt)) return s.push({ id: n.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
|
|
2384
|
+
} else n.properties.updatedAt = +/* @__PURE__ */ new Date();
|
|
2386
2385
|
}
|
|
2387
|
-
return this.has(a) ? (s.push({ id: a, valid: !1, reason: `Feature already exists with this id: ${a}` }), !1) : (this.store[a] =
|
|
2386
|
+
return this.has(a) ? (s.push({ id: a, valid: !1, reason: `Feature already exists with this id: ${a}` }), !1) : (this.store[a] = n, o.push(a), s.push({ id: a, valid: !0 }), !0);
|
|
2388
2387
|
}), this.spatialIndex.load(i), this._onChange(o, "create"), s;
|
|
2389
2388
|
}
|
|
2390
2389
|
search(t, e) {
|
|
@@ -2409,9 +2408,9 @@ class Si {
|
|
|
2409
2408
|
updateProperty(t) {
|
|
2410
2409
|
const e = [];
|
|
2411
2410
|
t.forEach(({ id: i, property: o, value: s }) => {
|
|
2412
|
-
const
|
|
2413
|
-
if (!
|
|
2414
|
-
e.push(i),
|
|
2411
|
+
const n = this.store[i];
|
|
2412
|
+
if (!n) throw new Error(`No feature with this (${i}), can not update geometry`);
|
|
2413
|
+
e.push(i), n.properties[o] = s, this.tracked && (n.properties.updatedAt = +/* @__PURE__ */ new Date());
|
|
2415
2414
|
}), this._onChange && this._onChange(e, "update");
|
|
2416
2415
|
}
|
|
2417
2416
|
updateGeometry(t) {
|
|
@@ -2426,9 +2425,9 @@ class Si {
|
|
|
2426
2425
|
create(t) {
|
|
2427
2426
|
const e = [];
|
|
2428
2427
|
return t.forEach(({ geometry: i, properties: o }) => {
|
|
2429
|
-
let s,
|
|
2430
|
-
this.tracked && (s = +/* @__PURE__ */ new Date(), o ? (
|
|
2431
|
-
const a = this.getId(), l = { id: a, type: "Feature", geometry: i, properties:
|
|
2428
|
+
let s, n = M({}, o);
|
|
2429
|
+
this.tracked && (s = +/* @__PURE__ */ new Date(), o ? (n.createdAt = typeof o.createdAt == "number" ? o.createdAt : s, n.updatedAt = typeof o.updatedAt == "number" ? o.updatedAt : s) : n = { createdAt: s, updatedAt: s });
|
|
2430
|
+
const a = this.getId(), l = { id: a, type: "Feature", geometry: i, properties: n };
|
|
2432
2431
|
this.store[a] = l, this.spatialIndex.insert(l), e.push(a);
|
|
2433
2432
|
}), this._onChange && this._onChange([...e], "create"), e;
|
|
2434
2433
|
}
|
|
@@ -2448,9 +2447,9 @@ class Si {
|
|
|
2448
2447
|
return Object.keys(this.store).length;
|
|
2449
2448
|
}
|
|
2450
2449
|
}
|
|
2451
|
-
const Mi = "Feature is not a Polygon or LineString",
|
|
2452
|
-
function
|
|
2453
|
-
const i = A(
|
|
2450
|
+
const Mi = "Feature is not a Polygon or LineString", wi = "Feature intersects itself", bi = (r) => r.geometry.type !== "Polygon" && r.geometry.type !== "LineString" ? { valid: !1, reason: Mi } : kt(r) ? { valid: !1, reason: wi } : { valid: !0 };
|
|
2451
|
+
function re(r, t, e) {
|
|
2452
|
+
const i = A(r, t);
|
|
2454
2453
|
let o = A(t, e) - i;
|
|
2455
2454
|
return o < 0 && (o += 360), 180 - Math.abs(o - 90 - 90);
|
|
2456
2455
|
}
|
|
@@ -2483,13 +2482,13 @@ class Ee extends N {
|
|
|
2483
2482
|
const o = 1 / Math.pow(10, this.coordinatePrecision - 1), s = Math.max(1e-6, o);
|
|
2484
2483
|
i = [e[0], [t.lng, t.lat], [t.lng, t.lat - s], e[0]];
|
|
2485
2484
|
} else if (this.currentCoordinate === 2) {
|
|
2486
|
-
const o = e[0], s = e[1],
|
|
2487
|
-
const D = (I.x -
|
|
2485
|
+
const o = e[0], s = e[1], n = Me(o, s, this.coordinatePrecision, this.project, this.unproject), a = S(o[0], o[1]), l = S(n[0], n[1]), d = S(s[0], s[1]), c = S(t.lng, t.lat), h = E(c, a) < E(c, d), u = re(a, l, c), g = h ? 90 - u : re(a, l, c) - 90, y = E(l, c), p = Math.cos(_(g)) * y, C = A(a, d) + (function(x, w, I) {
|
|
2486
|
+
const D = (I.x - w.x) * (x.y - w.y) - (I.y - w.y) * (x.x - w.x);
|
|
2488
2487
|
return D > 1e-10 ? "left" : D < -1e-10 ? "right" : "left";
|
|
2489
2488
|
}(a, d, c) === "right" ? -90 : 90), f = lt(a, p, C), v = lt(d, p, C), m = L(f.x, f.y), P = L(v.x, v.y);
|
|
2490
2489
|
i = [e[0], e[1], [P.lng, P.lat], [m.lng, m.lat], e[0]];
|
|
2491
2490
|
}
|
|
2492
|
-
i && this.updatePolygonGeometry(this.currentId, i,
|
|
2491
|
+
i && this.updatePolygonGeometry(this.currentId, i, b.Provisional);
|
|
2493
2492
|
}
|
|
2494
2493
|
updatePolygonGeometry(t, e, i) {
|
|
2495
2494
|
const o = { type: "Polygon", coordinates: [e] };
|
|
@@ -2501,7 +2500,7 @@ class Ee extends N {
|
|
|
2501
2500
|
this.currentId = e, this.currentCoordinate++, this.setDrawing();
|
|
2502
2501
|
} else if (this.currentCoordinate === 1 && this.currentId) {
|
|
2503
2502
|
const e = this.store.getGeometryCopy(this.currentId);
|
|
2504
|
-
if (tt([t.lng, t.lat], e.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [e.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], e.coordinates[0][0]],
|
|
2503
|
+
if (tt([t.lng, t.lat], e.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [e.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], e.coordinates[0][0]], b.Commit)) return;
|
|
2505
2504
|
this.currentCoordinate++;
|
|
2506
2505
|
} else this.currentCoordinate === 2 && this.currentId && this.close();
|
|
2507
2506
|
}
|
|
@@ -2531,8 +2530,8 @@ class Ee extends N {
|
|
|
2531
2530
|
return this.validateModeFeature(t, (e) => dt(e, this.coordinatePrecision));
|
|
2532
2531
|
}
|
|
2533
2532
|
}
|
|
2534
|
-
function _e(
|
|
2535
|
-
return (t.x -
|
|
2533
|
+
function _e(r, t, e) {
|
|
2534
|
+
return (t.x - r.x) * (e.y - r.y) - (t.y - r.y) * (e.x - r.x) <= 0;
|
|
2536
2535
|
}
|
|
2537
2536
|
class De extends N {
|
|
2538
2537
|
constructor(t) {
|
|
@@ -2564,7 +2563,7 @@ class De extends N {
|
|
|
2564
2563
|
const o = 1 / Math.pow(10, this.coordinatePrecision - 1), s = Math.max(1e-6, o);
|
|
2565
2564
|
i = [e[0], [t.lng, t.lat], [t.lng, t.lat - s], e[0]];
|
|
2566
2565
|
} else if (this.currentCoordinate === 2) {
|
|
2567
|
-
const o = e[0], s = e[1],
|
|
2566
|
+
const o = e[0], s = e[1], n = [t.lng, t.lat], a = S(o[0], o[1]), l = S(s[0], s[1]), d = S(n[0], n[1]);
|
|
2568
2567
|
if (this.direction === void 0) {
|
|
2569
2568
|
const m = _e(a, l, d);
|
|
2570
2569
|
this.direction = m ? "clockwise" : "anticlockwise";
|
|
@@ -2575,12 +2574,12 @@ class De extends N {
|
|
|
2575
2574
|
const v = (this.direction === "anticlockwise" ? 1 : -1) * f / g;
|
|
2576
2575
|
y.push(s);
|
|
2577
2576
|
for (let m = 0; m <= g; m++) {
|
|
2578
|
-
const P = lt(a, c, p + m * v), { lng: x, lat:
|
|
2577
|
+
const P = lt(a, c, p + m * v), { lng: x, lat: w } = L(P.x, P.y), I = [F(x, this.coordinatePrecision), F(w, this.coordinatePrecision)];
|
|
2579
2578
|
I[0] !== y[y.length - 1][0] && I[1] !== y[y.length - 1][1] && y.push(I);
|
|
2580
2579
|
}
|
|
2581
2580
|
y.push(o), i = [...y];
|
|
2582
2581
|
}
|
|
2583
|
-
i && this.updatePolygonGeometry(this.currentId, i,
|
|
2582
|
+
i && this.updatePolygonGeometry(this.currentId, i, b.Provisional);
|
|
2584
2583
|
}
|
|
2585
2584
|
updatePolygonGeometry(t, e, i) {
|
|
2586
2585
|
const o = { type: "Polygon", coordinates: [e] };
|
|
@@ -2592,7 +2591,7 @@ class De extends N {
|
|
|
2592
2591
|
this.currentId = e, this.currentCoordinate++, this.setDrawing();
|
|
2593
2592
|
} else if (this.currentCoordinate === 1 && this.currentId) {
|
|
2594
2593
|
const e = this.store.getGeometryCopy(this.currentId);
|
|
2595
|
-
if (tt([t.lng, t.lat], e.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [e.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], e.coordinates[0][0]],
|
|
2594
|
+
if (tt([t.lng, t.lat], e.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [e.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], e.coordinates[0][0]], b.Commit)) return;
|
|
2596
2595
|
this.currentCoordinate++;
|
|
2597
2596
|
} else this.currentCoordinate === 2 && this.currentId && this.close();
|
|
2598
2597
|
}
|
|
@@ -2647,31 +2646,31 @@ class Oe extends N {
|
|
|
2647
2646
|
onMouseMove(t) {
|
|
2648
2647
|
if (this.mouseMove = !0, this.setCursor(this.cursors.start), this.currentInitialArcId !== void 0 && this.currentStartingPointId !== void 0 && this.currentCoordinate !== 0) {
|
|
2649
2648
|
if (this.currentCoordinate === 2) {
|
|
2650
|
-
const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = [t.lng, t.lat],
|
|
2649
|
+
const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = [t.lng, t.lat], n = S(o[0], o[1]), a = S(s[0], s[1]), l = S(i[0], i[1]), d = E(l, n);
|
|
2651
2650
|
if (this.direction === void 0) {
|
|
2652
|
-
const v = _e(l,
|
|
2651
|
+
const v = _e(l, n, a);
|
|
2653
2652
|
this.direction = v ? "clockwise" : "anticlockwise";
|
|
2654
2653
|
}
|
|
2655
|
-
const c = A(l,
|
|
2654
|
+
const c = A(l, n), h = A(l, a), u = this.arcPoints, g = [o], y = K(c), p = K(h);
|
|
2656
2655
|
let C;
|
|
2657
2656
|
this.direction === "anticlockwise" ? (C = p - y, C < 0 && (C += 360)) : (C = y - p, C < 0 && (C += 360));
|
|
2658
2657
|
const f = (this.direction === "anticlockwise" ? 1 : -1) * C / u;
|
|
2659
2658
|
for (let v = 0; v <= u; v++) {
|
|
2660
|
-
const m = lt(l, d, y + v * f), { lng: P, lat: x } = L(m.x, m.y),
|
|
2661
|
-
|
|
2659
|
+
const m = lt(l, d, y + v * f), { lng: P, lat: x } = L(m.x, m.y), w = [F(P, this.coordinatePrecision), F(x, this.coordinatePrecision)];
|
|
2660
|
+
w[0] !== g[g.length - 1][0] && w[1] !== g[g.length - 1][1] && g.push(w);
|
|
2662
2661
|
}
|
|
2663
|
-
this.updateLineStringGeometry(this.currentInitialArcId, g,
|
|
2662
|
+
this.updateLineStringGeometry(this.currentInitialArcId, g, b.Provisional);
|
|
2664
2663
|
} else if (this.currentCoordinate === 3) {
|
|
2665
2664
|
const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates;
|
|
2666
2665
|
if (e.length < 2 || !this.direction) return;
|
|
2667
|
-
const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = e[e.length - 1],
|
|
2666
|
+
const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = e[e.length - 1], n = S(t.lng, t.lat), a = S(o[0], o[1]), l = S(s[0], s[1]), d = S(i[0], i[1]), c = E(d, a), h = E(d, n) < c ? a : n, u = A(d, n), g = A(d, a), y = A(d, l), p = K(g), C = K(y), f = K(u);
|
|
2668
2667
|
if (this.notInSector({ normalizedCursor: f, normalizedStart: p, normalizedEnd: C, direction: this.direction })) return;
|
|
2669
|
-
const v = this.getDeltaBearing(this.direction, p, C), m = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * v / m, x = E(d, h),
|
|
2668
|
+
const v = this.getDeltaBearing(this.direction, p, C), m = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * v / m, x = E(d, h), w = [];
|
|
2670
2669
|
for (let I = 0; I <= m; I++) {
|
|
2671
2670
|
const D = lt(d, x, p + I * P), { lng: G, lat: O } = L(D.x, D.y), B = [F(G, this.coordinatePrecision), F(O, this.coordinatePrecision)];
|
|
2672
|
-
B[0] !== e[e.length - 1][0] && B[1] !== e[e.length - 1][1] &&
|
|
2671
|
+
B[0] !== e[e.length - 1][0] && B[1] !== e[e.length - 1][1] && w.unshift(B);
|
|
2673
2672
|
}
|
|
2674
|
-
e.push(...
|
|
2673
|
+
e.push(...w), e.push(e[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, e, b.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [e] }, properties: { mode: this.mode } }]);
|
|
2675
2674
|
}
|
|
2676
2675
|
}
|
|
2677
2676
|
}
|
|
@@ -2742,7 +2741,7 @@ class Ii {
|
|
|
2742
2741
|
const s = (c) => {
|
|
2743
2742
|
const h = [], u = this._store.copyAll().filter((g) => !c.includes(g.id) || (h.push(g), !1));
|
|
2744
2743
|
return { changed: h, unchanged: u };
|
|
2745
|
-
},
|
|
2744
|
+
}, n = (c, h) => {
|
|
2746
2745
|
this._enabled && this._eventListeners.finish.forEach((u) => {
|
|
2747
2746
|
u(c, h);
|
|
2748
2747
|
});
|
|
@@ -2769,7 +2768,7 @@ class Ii {
|
|
|
2769
2768
|
h && this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: h }, this.getModeStyles());
|
|
2770
2769
|
};
|
|
2771
2770
|
Object.keys(this._modes).forEach((c) => {
|
|
2772
|
-
this._modes[c].register({ mode: c, store: this._store, setCursor: this._adapter.setCursor.bind(this._adapter), project: this._adapter.project.bind(this._adapter), unproject: this._adapter.unproject.bind(this._adapter), setDoubleClickToZoom: this._adapter.setDoubleClickToZoom.bind(this._adapter), onChange: a, onSelect: l, onDeselect: d, onFinish:
|
|
2771
|
+
this._modes[c].register({ mode: c, store: this._store, setCursor: this._adapter.setCursor.bind(this._adapter), project: this._adapter.project.bind(this._adapter), unproject: this._adapter.unproject.bind(this._adapter), setDoubleClickToZoom: this._adapter.setDoubleClickToZoom.bind(this._adapter), onChange: a, onSelect: l, onDeselect: d, onFinish: n, coordinatePrecision: this._adapter.getCoordinatePrecision() });
|
|
2773
2772
|
});
|
|
2774
2773
|
}
|
|
2775
2774
|
checkEnabled() {
|
|
@@ -2782,9 +2781,9 @@ class Ii {
|
|
|
2782
2781
|
}), t;
|
|
2783
2782
|
}
|
|
2784
2783
|
featuresAtLocation({ lng: t, lat: e }, i) {
|
|
2785
|
-
const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, s = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures,
|
|
2784
|
+
const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, s = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, n = this._adapter.unproject.bind(this._adapter), a = this._adapter.project.bind(this._adapter), l = a(t, e), d = fe({ unproject: n, point: l, pointerDistance: o });
|
|
2786
2785
|
return this._store.search(d).filter((c) => {
|
|
2787
|
-
if (s && (c.properties[
|
|
2786
|
+
if (s && (c.properties[rt] || c.properties.selectionPoint)) return !1;
|
|
2788
2787
|
if (c.geometry.type === "Point") {
|
|
2789
2788
|
const h = c.geometry.coordinates, u = a(h[0], h[1]);
|
|
2790
2789
|
return E(l, u) < o;
|
|
@@ -2793,11 +2792,11 @@ class Ii {
|
|
|
2793
2792
|
const h = c.geometry.coordinates;
|
|
2794
2793
|
for (let u = 0; u < h.length - 1; u++) {
|
|
2795
2794
|
const g = h[u], y = h[u + 1];
|
|
2796
|
-
if (
|
|
2795
|
+
if (be(l, a(g[0], g[1]), a(y[0], y[1])) < o) return !0;
|
|
2797
2796
|
}
|
|
2798
2797
|
return !1;
|
|
2799
2798
|
}
|
|
2800
|
-
return !!
|
|
2799
|
+
return !!we([t, e], c.geometry.coordinates) || void 0;
|
|
2801
2800
|
});
|
|
2802
2801
|
}
|
|
2803
2802
|
getSelectMode() {
|
|
@@ -3115,7 +3114,7 @@ const Ri = [
|
|
|
3115
3114
|
// @ts-ignore
|
|
3116
3115
|
validation: (t, e) => {
|
|
3117
3116
|
const i = e.updateType;
|
|
3118
|
-
return i === "finish" || i === "commit" ?
|
|
3117
|
+
return i === "finish" || i === "commit" ? bi(t) : { valid: !0 };
|
|
3119
3118
|
}
|
|
3120
3119
|
}),
|
|
3121
3120
|
rectangle: new Se(),
|
|
@@ -3267,7 +3266,7 @@ class Di {
|
|
|
3267
3266
|
* @returns HTML Element
|
|
3268
3267
|
*/
|
|
3269
3268
|
onAdd(t) {
|
|
3270
|
-
var o, s,
|
|
3269
|
+
var o, s, n, a, l;
|
|
3271
3270
|
if (this.options && this.options.modes && this.options.modes.length === 0)
|
|
3272
3271
|
throw new Error("At least a mode must be enabled.");
|
|
3273
3272
|
this.map = t;
|
|
@@ -3288,7 +3287,7 @@ class Di {
|
|
|
3288
3287
|
} else e[d] && i.push(e[d]);
|
|
3289
3288
|
}), i.forEach((d) => {
|
|
3290
3289
|
d.state !== "unregistered" && (d._state = "unregistered");
|
|
3291
|
-
}), (a = (
|
|
3290
|
+
}), (a = (n = this.options) == null ? void 0 : n.modes) != null && a.includes("render") || (i.push(
|
|
3292
3291
|
new it({
|
|
3293
3292
|
modeName: "default",
|
|
3294
3293
|
styles: {}
|
|
@@ -3335,9 +3334,9 @@ class Di {
|
|
|
3335
3334
|
*/
|
|
3336
3335
|
dispatchEvent(t) {
|
|
3337
3336
|
this.events[t] && this.events[t].forEach((e) => {
|
|
3338
|
-
var s,
|
|
3337
|
+
var s, n;
|
|
3339
3338
|
const i = (s = this.terradraw) == null ? void 0 : s.getSnapshot(), o = i == null ? void 0 : i.filter((a) => a.properties.selected === !0);
|
|
3340
|
-
e({ feature: o, mode: (
|
|
3339
|
+
e({ feature: o, mode: (n = this.terradraw) == null ? void 0 : n.getMode() });
|
|
3341
3340
|
});
|
|
3342
3341
|
}
|
|
3343
3342
|
/**
|
|
@@ -3368,8 +3367,8 @@ class Di {
|
|
|
3368
3367
|
if (!this.terradraw) return;
|
|
3369
3368
|
const t = document.getElementsByClassName("maplibregl-terradraw-add-control");
|
|
3370
3369
|
for (let s = 0; s < t.length; s++) {
|
|
3371
|
-
const
|
|
3372
|
-
|
|
3370
|
+
const n = t.item(s);
|
|
3371
|
+
n && (this.isExpanded ? n.classList.add("hidden") : n.classList.remove("hidden"));
|
|
3373
3372
|
}
|
|
3374
3373
|
const e = document.getElementsByClassName("maplibregl-terradraw-render-button");
|
|
3375
3374
|
e && e.length > 0 && (this.isExpanded ? ((i = e.item(0)) == null || i.classList.remove("enabled"), this.resetActiveMode()) : (o = e.item(0)) == null || o.classList.add("enabled")), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.isExpanded = !this.isExpanded;
|
|
@@ -3399,12 +3398,12 @@ class Di {
|
|
|
3399
3398
|
})) : t === "delete-selection" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.classList.add("hidden-delete-selection"), e.addEventListener("click", () => {
|
|
3400
3399
|
var s;
|
|
3401
3400
|
if (!this.terradraw || !this.terradraw.enabled) return;
|
|
3402
|
-
const o = ((s = this.terradraw) == null ? void 0 : s.getSnapshot()).filter((
|
|
3401
|
+
const o = ((s = this.terradraw) == null ? void 0 : s.getSnapshot()).filter((n) => n.properties.selected === !0);
|
|
3403
3402
|
if (o.length > 0) {
|
|
3404
|
-
const
|
|
3403
|
+
const n = this.terradraw.getMode();
|
|
3405
3404
|
this.terradraw.setMode(this.defaultMode);
|
|
3406
3405
|
const a = o.map((l) => l.id);
|
|
3407
|
-
this.terradraw.removeFeatures(a), this.terradraw.setMode(
|
|
3406
|
+
this.terradraw.removeFeatures(a), this.terradraw.setMode(n), this.dispatchEvent("feature-deleted");
|
|
3408
3407
|
}
|
|
3409
3408
|
this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature();
|
|
3410
3409
|
})) : t === "download" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.addEventListener("click", this.handleDownload.bind(this))) : (e.classList.add(`maplibregl-terradraw-add-${t}-button`), e.addEventListener("click", () => {
|
|
@@ -3423,9 +3422,9 @@ class Di {
|
|
|
3423
3422
|
if (!this.terradraw) return;
|
|
3424
3423
|
const o = {
|
|
3425
3424
|
type: "FeatureCollection",
|
|
3426
|
-
features: ((s = this.terradraw) == null ? void 0 : s.getSnapshot()).filter((
|
|
3425
|
+
features: ((s = this.terradraw) == null ? void 0 : s.getSnapshot()).filter((n) => n.properties.mode !== "select")
|
|
3427
3426
|
};
|
|
3428
|
-
return t !== !0 || (o.features = o.features.filter((
|
|
3427
|
+
return t !== !0 || (o.features = o.features.filter((n) => n.properties.selected === !0)), o;
|
|
3429
3428
|
}
|
|
3430
3429
|
/**
|
|
3431
3430
|
* Download button click event handler
|
|
@@ -3446,8 +3445,8 @@ class Di {
|
|
|
3446
3445
|
];
|
|
3447
3446
|
for (const o of i) {
|
|
3448
3447
|
const s = this.controlContainer.getElementsByClassName(o);
|
|
3449
|
-
for (let
|
|
3450
|
-
const a = s.item(
|
|
3448
|
+
for (let n = 0; n < s.length; n++) {
|
|
3449
|
+
const a = s.item(n);
|
|
3451
3450
|
a && (a.disabled = !e);
|
|
3452
3451
|
}
|
|
3453
3452
|
}
|
|
@@ -3457,9 +3456,9 @@ class Di {
|
|
|
3457
3456
|
*/
|
|
3458
3457
|
toggleDeleteSelectionButton() {
|
|
3459
3458
|
var a, l;
|
|
3460
|
-
const t = ((a = this.terradraw) == null ? void 0 : a.enabled) || !1, e = (l = this.terradraw) == null ? void 0 : l.getMode(), i = this.getFeatures(!1), o = i && i.features.length > 0, s = o && t && e === "select",
|
|
3461
|
-
for (let d = 0; d <
|
|
3462
|
-
const c =
|
|
3459
|
+
const t = ((a = this.terradraw) == null ? void 0 : a.enabled) || !1, e = (l = this.terradraw) == null ? void 0 : l.getMode(), i = this.getFeatures(!1), o = i && i.features.length > 0, s = o && t && e === "select", n = document.getElementsByClassName("maplibregl-terradraw-delete-selection-button");
|
|
3460
|
+
for (let d = 0; d < n.length; d++) {
|
|
3461
|
+
const c = n.item(d);
|
|
3463
3462
|
c && (s ? c.classList.remove("hidden-delete-selection") : c.classList.add("hidden-delete-selection"));
|
|
3464
3463
|
}
|
|
3465
3464
|
if (!o) {
|
|
@@ -3496,65 +3495,65 @@ var k = 63710088e-1, Oi = {
|
|
|
3496
3495
|
radians: 1,
|
|
3497
3496
|
yards: k * 1.0936
|
|
3498
3497
|
};
|
|
3499
|
-
function ki(
|
|
3498
|
+
function ki(r, t, e = {}) {
|
|
3500
3499
|
const i = { type: "Feature" };
|
|
3501
|
-
return (e.id === 0 || e.id) && (i.id = e.id), e.bbox && (i.bbox = e.bbox), i.properties = t || {}, i.geometry =
|
|
3500
|
+
return (e.id === 0 || e.id) && (i.id = e.id), e.bbox && (i.bbox = e.bbox), i.properties = t || {}, i.geometry = r, i;
|
|
3502
3501
|
}
|
|
3503
|
-
function Li(
|
|
3504
|
-
if (!
|
|
3502
|
+
function Li(r, t, e = {}) {
|
|
3503
|
+
if (!r)
|
|
3505
3504
|
throw new Error("coordinates is required");
|
|
3506
|
-
if (!Array.isArray(
|
|
3505
|
+
if (!Array.isArray(r))
|
|
3507
3506
|
throw new Error("coordinates must be an Array");
|
|
3508
|
-
if (
|
|
3507
|
+
if (r.length < 2)
|
|
3509
3508
|
throw new Error("coordinates must be at least 2 numbers long");
|
|
3510
|
-
if (!
|
|
3509
|
+
if (!ne(r[0]) || !ne(r[1]))
|
|
3511
3510
|
throw new Error("coordinates must contain numbers");
|
|
3512
3511
|
return ki({
|
|
3513
3512
|
type: "Point",
|
|
3514
|
-
coordinates:
|
|
3513
|
+
coordinates: r
|
|
3515
3514
|
}, t, e);
|
|
3516
3515
|
}
|
|
3517
|
-
function Wi(
|
|
3516
|
+
function Wi(r, t = "kilometers") {
|
|
3518
3517
|
const e = Oi[t];
|
|
3519
3518
|
if (!e)
|
|
3520
3519
|
throw new Error(t + " units is invalid");
|
|
3521
|
-
return
|
|
3520
|
+
return r * e;
|
|
3522
3521
|
}
|
|
3523
|
-
function yt(
|
|
3524
|
-
return
|
|
3522
|
+
function yt(r) {
|
|
3523
|
+
return r % 360 * Math.PI / 180;
|
|
3525
3524
|
}
|
|
3526
|
-
function
|
|
3527
|
-
return !isNaN(
|
|
3525
|
+
function ne(r) {
|
|
3526
|
+
return !isNaN(r) && r !== null && !Array.isArray(r);
|
|
3528
3527
|
}
|
|
3529
|
-
function ae(
|
|
3530
|
-
if (!
|
|
3528
|
+
function ae(r) {
|
|
3529
|
+
if (!r)
|
|
3531
3530
|
throw new Error("coord is required");
|
|
3532
|
-
if (!Array.isArray(
|
|
3533
|
-
if (
|
|
3534
|
-
return [...
|
|
3535
|
-
if (
|
|
3536
|
-
return [...
|
|
3537
|
-
}
|
|
3538
|
-
if (Array.isArray(
|
|
3539
|
-
return [...
|
|
3531
|
+
if (!Array.isArray(r)) {
|
|
3532
|
+
if (r.type === "Feature" && r.geometry !== null && r.geometry.type === "Point")
|
|
3533
|
+
return [...r.geometry.coordinates];
|
|
3534
|
+
if (r.type === "Point")
|
|
3535
|
+
return [...r.coordinates];
|
|
3536
|
+
}
|
|
3537
|
+
if (Array.isArray(r) && r.length >= 2 && !Array.isArray(r[0]) && !Array.isArray(r[1]))
|
|
3538
|
+
return [...r];
|
|
3540
3539
|
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
3541
3540
|
}
|
|
3542
|
-
function ji(
|
|
3543
|
-
var i = ae(
|
|
3541
|
+
function ji(r, t, e = {}) {
|
|
3542
|
+
var i = ae(r), o = ae(t), s = yt(o[1] - i[1]), n = yt(o[0] - i[0]), a = yt(i[1]), l = yt(o[1]), d = Math.pow(Math.sin(s / 2), 2) + Math.pow(Math.sin(n / 2), 2) * Math.cos(a) * Math.cos(l);
|
|
3544
3543
|
return Wi(
|
|
3545
3544
|
2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
|
|
3546
3545
|
e.units
|
|
3547
3546
|
);
|
|
3548
3547
|
}
|
|
3549
|
-
function ke(
|
|
3550
|
-
if (
|
|
3551
|
-
for (var i, o, s,
|
|
3552
|
-
d = y ?
|
|
3548
|
+
function ke(r, t, e) {
|
|
3549
|
+
if (r !== null)
|
|
3550
|
+
for (var i, o, s, n, a, l, d, c = 0, h = 0, u, g = r.type, y = g === "FeatureCollection", p = g === "Feature", C = y ? r.features.length : 1, f = 0; f < C; f++) {
|
|
3551
|
+
d = y ? r.features[f].geometry : p ? r.geometry : r, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
|
|
3553
3552
|
for (var v = 0; v < a; v++) {
|
|
3554
3553
|
var m = 0, P = 0;
|
|
3555
|
-
if (
|
|
3556
|
-
l =
|
|
3557
|
-
var x =
|
|
3554
|
+
if (n = u ? d.geometries[v] : d, n !== null) {
|
|
3555
|
+
l = n.coordinates;
|
|
3556
|
+
var x = n.type;
|
|
3558
3557
|
switch (c = x === "Polygon" || x === "MultiPolygon" ? 1 : 0, x) {
|
|
3559
3558
|
case null:
|
|
3560
3559
|
break;
|
|
@@ -3622,8 +3621,8 @@ function ke(n, t, e) {
|
|
|
3622
3621
|
}
|
|
3623
3622
|
break;
|
|
3624
3623
|
case "GeometryCollection":
|
|
3625
|
-
for (i = 0; i <
|
|
3626
|
-
if (ke(
|
|
3624
|
+
for (i = 0; i < n.geometries.length; i++)
|
|
3625
|
+
if (ke(n.geometries[i], t) === !1)
|
|
3627
3626
|
return !1;
|
|
3628
3627
|
break;
|
|
3629
3628
|
default:
|
|
@@ -3633,10 +3632,10 @@ function ke(n, t, e) {
|
|
|
3633
3632
|
}
|
|
3634
3633
|
}
|
|
3635
3634
|
}
|
|
3636
|
-
function Bi(
|
|
3637
|
-
var e, i, o, s,
|
|
3635
|
+
function Bi(r, t) {
|
|
3636
|
+
var e, i, o, s, n, a, l, d, c, h, u = 0, g = r.type === "FeatureCollection", y = r.type === "Feature", p = g ? r.features.length : 1;
|
|
3638
3637
|
for (e = 0; e < p; e++) {
|
|
3639
|
-
for (a = g ?
|
|
3638
|
+
for (a = g ? r.features[e].geometry : y ? r.geometry : r, d = g ? r.features[e].properties : y ? r.properties : {}, c = g ? r.features[e].bbox : y ? r.bbox : void 0, h = g ? r.features[e].id : y ? r.id : void 0, l = a ? a.type === "GeometryCollection" : !1, n = l ? a.geometries.length : 1, o = 0; o < n; o++) {
|
|
3640
3639
|
if (s = l ? a.geometries[o] : a, s === null) {
|
|
3641
3640
|
if (t(
|
|
3642
3641
|
null,
|
|
@@ -3684,37 +3683,37 @@ function Bi(n, t) {
|
|
|
3684
3683
|
u++;
|
|
3685
3684
|
}
|
|
3686
3685
|
}
|
|
3687
|
-
function Ni(
|
|
3686
|
+
function Ni(r, t, e) {
|
|
3688
3687
|
var i = e;
|
|
3689
3688
|
return Bi(
|
|
3690
|
-
|
|
3691
|
-
function(o, s,
|
|
3689
|
+
r,
|
|
3690
|
+
function(o, s, n, a, l) {
|
|
3692
3691
|
s === 0 && e === void 0 ? i = o : i = t(
|
|
3693
3692
|
i,
|
|
3694
3693
|
o,
|
|
3695
3694
|
s,
|
|
3696
|
-
|
|
3695
|
+
n,
|
|
3697
3696
|
a,
|
|
3698
3697
|
l
|
|
3699
3698
|
);
|
|
3700
3699
|
}
|
|
3701
3700
|
), i;
|
|
3702
3701
|
}
|
|
3703
|
-
function Gi(
|
|
3702
|
+
function Gi(r) {
|
|
3704
3703
|
return Ni(
|
|
3705
|
-
|
|
3704
|
+
r,
|
|
3706
3705
|
(t, e) => t + Ai(e),
|
|
3707
3706
|
0
|
|
3708
3707
|
);
|
|
3709
3708
|
}
|
|
3710
|
-
function Ai(
|
|
3709
|
+
function Ai(r) {
|
|
3711
3710
|
let t = 0, e;
|
|
3712
|
-
switch (
|
|
3711
|
+
switch (r.type) {
|
|
3713
3712
|
case "Polygon":
|
|
3714
|
-
return le(
|
|
3713
|
+
return le(r.coordinates);
|
|
3715
3714
|
case "MultiPolygon":
|
|
3716
|
-
for (e = 0; e <
|
|
3717
|
-
t += le(
|
|
3715
|
+
for (e = 0; e < r.coordinates.length; e++)
|
|
3716
|
+
t += le(r.coordinates[e]);
|
|
3718
3717
|
return t;
|
|
3719
3718
|
case "Point":
|
|
3720
3719
|
case "MultiPoint":
|
|
@@ -3724,31 +3723,30 @@ function Ai(n) {
|
|
|
3724
3723
|
}
|
|
3725
3724
|
return 0;
|
|
3726
3725
|
}
|
|
3727
|
-
function le(
|
|
3726
|
+
function le(r) {
|
|
3728
3727
|
let t = 0;
|
|
3729
|
-
if (
|
|
3730
|
-
t += Math.abs(de(
|
|
3731
|
-
for (let e = 1; e <
|
|
3732
|
-
t -= Math.abs(de(
|
|
3728
|
+
if (r && r.length > 0) {
|
|
3729
|
+
t += Math.abs(de(r[0]));
|
|
3730
|
+
for (let e = 1; e < r.length; e++)
|
|
3731
|
+
t -= Math.abs(de(r[e]));
|
|
3733
3732
|
}
|
|
3734
3733
|
return t;
|
|
3735
3734
|
}
|
|
3736
3735
|
var Vi = k * k / 2, Et = Math.PI / 180;
|
|
3737
|
-
function de(
|
|
3738
|
-
const t =
|
|
3739
|
-
if (t <= 2)
|
|
3740
|
-
return 0;
|
|
3736
|
+
function de(r) {
|
|
3737
|
+
const t = r.length - 1;
|
|
3738
|
+
if (t <= 2) return 0;
|
|
3741
3739
|
let e = 0, i = 0;
|
|
3742
3740
|
for (; i < t; ) {
|
|
3743
|
-
const o =
|
|
3741
|
+
const o = r[i], s = r[i + 1 === t ? 0 : i + 1], n = r[i + 2 >= t ? (i + 2) % t : i + 2], a = o[0] * Et, l = s[1] * Et, d = n[0] * Et;
|
|
3744
3742
|
e += (d - a) * Math.sin(l), i++;
|
|
3745
3743
|
}
|
|
3746
3744
|
return e * Vi;
|
|
3747
3745
|
}
|
|
3748
|
-
function Ui(
|
|
3746
|
+
function Ui(r, t = {}) {
|
|
3749
3747
|
let e = 0, i = 0, o = 0;
|
|
3750
3748
|
return ke(
|
|
3751
|
-
|
|
3749
|
+
r,
|
|
3752
3750
|
function(s) {
|
|
3753
3751
|
e += s[0], i += s[1], o++;
|
|
3754
3752
|
}
|
|
@@ -3803,13 +3801,13 @@ class Ki extends Di {
|
|
|
3803
3801
|
registerMesureControl() {
|
|
3804
3802
|
var o, s;
|
|
3805
3803
|
if (!this.map) return;
|
|
3806
|
-
const e = (o = this.options.modes) == null ? void 0 : o.filter((
|
|
3804
|
+
const e = (o = this.options.modes) == null ? void 0 : o.filter((n) => ["linestring"].includes(n));
|
|
3807
3805
|
e && e.length > 0 && (this.map.getSource(this.lineLayerLabelSpec.source) || this.map.addSource(this.lineLayerLabelSpec.source, {
|
|
3808
3806
|
type: "geojson",
|
|
3809
3807
|
data: { type: "FeatureCollection", features: [] }
|
|
3810
3808
|
}), this.map.getLayer(this.lineLayerNodeSpec.id) || this.map.addLayer(this.lineLayerNodeSpec), this.map.getLayer(this.lineLayerLabelSpec.id) || this.map.addLayer(this.lineLayerLabelSpec));
|
|
3811
3809
|
const i = (s = this.options.modes) == null ? void 0 : s.filter(
|
|
3812
|
-
(
|
|
3810
|
+
(n) => [
|
|
3813
3811
|
"polygon",
|
|
3814
3812
|
"rectangle",
|
|
3815
3813
|
"angled-rectangle",
|
|
@@ -3817,14 +3815,14 @@ class Ki extends Di {
|
|
|
3817
3815
|
"sector",
|
|
3818
3816
|
"sensor",
|
|
3819
3817
|
"freehand"
|
|
3820
|
-
].includes(
|
|
3818
|
+
].includes(n)
|
|
3821
3819
|
);
|
|
3822
3820
|
if (i && i.length > 0 && (this.map.getSource(this.polygonLayerSpec.source) || this.map.addSource(this.polygonLayerSpec.source, {
|
|
3823
3821
|
type: "geojson",
|
|
3824
3822
|
data: { type: "FeatureCollection", features: [] }
|
|
3825
3823
|
}), this.map.getLayer(this.polygonLayerSpec.id) || this.map.addLayer(this.polygonLayerSpec)), e && e.length > 0 || i && i.length > 0) {
|
|
3826
|
-
const
|
|
3827
|
-
|
|
3824
|
+
const n = this.getTerraDrawInstance();
|
|
3825
|
+
n && (n.on("change", (a) => {
|
|
3828
3826
|
if (!this.map) return;
|
|
3829
3827
|
const l = this.getTerraDrawInstance();
|
|
3830
3828
|
if (!l) return;
|
|
@@ -3857,9 +3855,9 @@ class Ki extends Di {
|
|
|
3857
3855
|
if (!this.map) return;
|
|
3858
3856
|
const o = this.map.getStyle().sources[i];
|
|
3859
3857
|
o && typeof o.data != "string" && o.data.type === "FeatureCollection" && (o.data.features = o.data.features.filter(
|
|
3860
|
-
(
|
|
3858
|
+
(n) => {
|
|
3861
3859
|
var a;
|
|
3862
|
-
return ((a =
|
|
3860
|
+
return ((a = n.properties) == null ? void 0 : a.originalId) !== e;
|
|
3863
3861
|
}
|
|
3864
3862
|
), (s = this.map.getSource(i)) == null || s.setData(o.data));
|
|
3865
3863
|
}
|
|
@@ -3884,11 +3882,11 @@ class Ki extends Di {
|
|
|
3884
3882
|
const i = e.geometry.coordinates;
|
|
3885
3883
|
let o = 0;
|
|
3886
3884
|
const s = [];
|
|
3887
|
-
for (let
|
|
3888
|
-
const a = i[
|
|
3885
|
+
for (let n = 0; n < i.length - 1; n++) {
|
|
3886
|
+
const a = i[n], l = i[n + 1], d = ji(a, l, { units: "kilometers" });
|
|
3889
3887
|
o += d;
|
|
3890
3888
|
const c = JSON.parse(JSON.stringify(e));
|
|
3891
|
-
c.id = `${c.id}-${
|
|
3889
|
+
c.id = `${c.id}-${n}`, c.geometry.coordinates = [a, l], c.properties.originalId = e.id, c.properties.distance = parseFloat(d.toFixed(2)), c.properties.total = parseFloat(o.toFixed(2)), c.properties.unit = "km", s.push(c);
|
|
3892
3890
|
}
|
|
3893
3891
|
return e.properties.distance = s[s.length - 1].properties.total, e.properties.unit = s[s.length - 1].properties.unit, e.properties.segments = JSON.parse(JSON.stringify(s)), e;
|
|
3894
3892
|
}
|
|
@@ -3897,7 +3895,7 @@ class Ki extends Di {
|
|
|
3897
3895
|
* @param id terradraw feature id
|
|
3898
3896
|
*/
|
|
3899
3897
|
measurePolygon(e) {
|
|
3900
|
-
var
|
|
3898
|
+
var n;
|
|
3901
3899
|
if (!this.map) return;
|
|
3902
3900
|
const i = this.getTerraDrawInstance();
|
|
3903
3901
|
if (!i) return;
|
|
@@ -3913,7 +3911,7 @@ class Ki extends Di {
|
|
|
3913
3911
|
}
|
|
3914
3912
|
));
|
|
3915
3913
|
const l = JSON.parse(JSON.stringify(s));
|
|
3916
|
-
l.id = l.id + "-area-label", l.geometry = Ui(s.geometry).geometry, l.properties.originalId = s.id, s = this.calcArea(s), l.properties.area = s.properties.area, l.properties.unit = s.properties.unit, typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(l), (
|
|
3914
|
+
l.id = l.id + "-area-label", l.geometry = Ui(s.geometry).geometry, l.properties.originalId = s.id, s = this.calcArea(s), l.properties.area = s.properties.area, l.properties.unit = s.properties.unit, typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(l), (n = this.map.getSource(this.polygonLayerSpec.source)) == null || n.setData(
|
|
3917
3915
|
a.data
|
|
3918
3916
|
), this.map.moveLayer(this.polygonLayerSpec.id);
|
|
3919
3917
|
}
|
|
@@ -3924,7 +3922,7 @@ class Ki extends Di {
|
|
|
3924
3922
|
* @param id terradraw feature id
|
|
3925
3923
|
*/
|
|
3926
3924
|
measureLine(e) {
|
|
3927
|
-
var
|
|
3925
|
+
var n;
|
|
3928
3926
|
if (!this.map) return;
|
|
3929
3927
|
const i = this.getTerraDrawInstance();
|
|
3930
3928
|
if (!i) return;
|
|
@@ -3957,7 +3955,7 @@ class Ki extends Di {
|
|
|
3957
3955
|
coordinates: g
|
|
3958
3956
|
}, typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(y);
|
|
3959
3957
|
}
|
|
3960
|
-
(
|
|
3958
|
+
(n = this.map.getSource(this.lineLayerLabelSpec.source)) == null || n.setData(
|
|
3961
3959
|
a.data
|
|
3962
3960
|
), this.map.moveLayer(this.lineLayerLabelSpec.id), this.map.moveLayer(this.lineLayerNodeSpec.id);
|
|
3963
3961
|
}
|
|
@@ -3972,8 +3970,8 @@ class Ki extends Di {
|
|
|
3972
3970
|
const e = this.getTerraDrawInstance();
|
|
3973
3971
|
if (e) {
|
|
3974
3972
|
const s = [this.lineLayerLabelSpec.source, this.polygonLayerSpec.source];
|
|
3975
|
-
for (const
|
|
3976
|
-
const a = this.map.getStyle().sources[
|
|
3973
|
+
for (const n of s) {
|
|
3974
|
+
const a = this.map.getStyle().sources[n];
|
|
3977
3975
|
if (a) {
|
|
3978
3976
|
const l = e.getSnapshot(), c = (l == null ? void 0 : l.filter(
|
|
3979
3977
|
(h) => ["LineString", "Polygon"].includes(h.geometry.type)
|
|
@@ -3983,9 +3981,9 @@ class Ki extends Di {
|
|
|
3983
3981
|
var u;
|
|
3984
3982
|
return c.includes((u = h.properties) == null ? void 0 : u.originalId);
|
|
3985
3983
|
}
|
|
3986
|
-
)),
|
|
3984
|
+
)), n === this.lineLayerLabelSpec.source ? ((i = this.map.getSource(this.lineLayerLabelSpec.source)) == null || i.setData(
|
|
3987
3985
|
a.data
|
|
3988
|
-
), this.map.getLayer(this.lineLayerNodeSpec.id) && this.map.moveLayer(this.lineLayerNodeSpec.id), this.map.getLayer(this.lineLayerLabelSpec.id) && this.map.moveLayer(this.lineLayerLabelSpec.id)) :
|
|
3986
|
+
), this.map.getLayer(this.lineLayerNodeSpec.id) && this.map.moveLayer(this.lineLayerNodeSpec.id), this.map.getLayer(this.lineLayerLabelSpec.id) && this.map.moveLayer(this.lineLayerLabelSpec.id)) : n === this.polygonLayerSpec.source && ((o = this.map.getSource(this.polygonLayerSpec.source)) == null || o.setData(
|
|
3989
3987
|
a.data
|
|
3990
3988
|
), this.map.getLayer(this.polygonLayerSpec.id) && this.map.moveLayer(this.polygonLayerSpec.id));
|
|
3991
3989
|
}
|