@watergis/maplibre-gl-terradraw 0.6.4 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/maplibre-gl-terradraw.es.js +713 -653
- package/dist/maplibre-gl-terradraw.es.js.map +1 -1
- package/dist/maplibre-gl-terradraw.umd.js +2 -2
- package/dist/maplibre-gl-terradraw.umd.js.map +1 -1
- package/dist/types/constants/defaultMeasureControlOptions.d.ts.map +1 -1
- package/dist/types/controls/MaplibreMeasureControl.d.ts +1 -0
- package/dist/types/controls/MaplibreMeasureControl.d.ts.map +1 -1
- package/package.json +21 -20
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
var Me = Object.defineProperty;
|
|
2
2
|
var be = (s, t, e) => t in s ? Me(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
3
|
-
var
|
|
4
|
-
function
|
|
5
|
-
return
|
|
3
|
+
var L = (s, t, e) => be(s, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
function M() {
|
|
5
|
+
return M = Object.assign ? Object.assign.bind() : function(s) {
|
|
6
6
|
for (var t = 1; t < arguments.length; t++) {
|
|
7
7
|
var e = arguments[t];
|
|
8
8
|
for (var i in e) Object.prototype.hasOwnProperty.call(e, i) && (s[i] = e[i]);
|
|
9
9
|
}
|
|
10
10
|
return s;
|
|
11
|
-
},
|
|
11
|
+
}, M.apply(this, arguments);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function F(s, t = 9) {
|
|
14
14
|
const e = Math.pow(10, t);
|
|
15
15
|
return Math.round(s * e) / e;
|
|
16
16
|
}
|
|
17
|
-
const
|
|
17
|
+
const I = (s, t) => {
|
|
18
18
|
const { x: e, y: i } = s, { x: o, y: r } = t, n = o - e, a = r - i;
|
|
19
19
|
return Math.sqrt(a * a + n * n);
|
|
20
20
|
};
|
|
21
|
-
class
|
|
21
|
+
class X {
|
|
22
22
|
constructor({ name: t, callback: e, unregister: i, register: o }) {
|
|
23
23
|
this.name = void 0, this.callback = void 0, this.registered = !1, this.register = void 0, this.unregister = void 0, this.name = t, this.register = () => {
|
|
24
24
|
this.registered || (this.registered = !0, o(e));
|
|
@@ -27,7 +27,7 @@ class K {
|
|
|
27
27
|
}, this.callback = e;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
class
|
|
30
|
+
class te {
|
|
31
31
|
constructor(t) {
|
|
32
32
|
this._minPixelDragDistance = void 0, this._minPixelDragDistanceDrawing = void 0, this._minPixelDragDistanceSelecting = void 0, this._lastDrawEvent = void 0, this._coordinatePrecision = void 0, this._heldKeys = /* @__PURE__ */ new Set(), this._listeners = [], this._dragState = "not-dragging", this._currentModeCallbacks = void 0, this._minPixelDragDistance = typeof t.minPixelDragDistance == "number" ? t.minPixelDragDistance : 1, this._minPixelDragDistanceSelecting = typeof t.minPixelDragDistanceSelecting == "number" ? t.minPixelDragDistanceSelecting : 1, this._minPixelDragDistanceDrawing = typeof t.minPixelDragDistanceDrawing == "number" ? t.minPixelDragDistanceDrawing : 8, this._coordinatePrecision = typeof t.coordinatePrecision == "number" ? t.coordinatePrecision : 9;
|
|
33
33
|
}
|
|
@@ -42,7 +42,7 @@ class Qt {
|
|
|
42
42
|
const e = this.getLngLatFromEvent(t);
|
|
43
43
|
if (!e) return null;
|
|
44
44
|
const { lng: i, lat: o } = e, { containerX: r, containerY: n } = this.getMapElementXYPosition(t), a = this.getButton(t), l = Array.from(this._heldKeys);
|
|
45
|
-
return { lng:
|
|
45
|
+
return { lng: F(i, this._coordinatePrecision), lat: F(o, this._coordinatePrecision), containerX: r, 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) => {
|
|
@@ -53,7 +53,7 @@ class Qt {
|
|
|
53
53
|
return this._coordinatePrecision;
|
|
54
54
|
}
|
|
55
55
|
getAdapterListeners() {
|
|
56
|
-
return [new
|
|
56
|
+
return [new X({ name: "pointerdown", callback: (t) => {
|
|
57
57
|
if (!this._currentModeCallbacks || !t.isPrimary) return;
|
|
58
58
|
const e = this.getDrawEventFromEvent(t);
|
|
59
59
|
e && (this._dragState = "pre-dragging", this._lastDrawEvent = e);
|
|
@@ -61,14 +61,14 @@ class Qt {
|
|
|
61
61
|
this.getMapEventElement().addEventListener("pointerdown", t);
|
|
62
62
|
}, unregister: (t) => {
|
|
63
63
|
this.getMapEventElement().removeEventListener("pointerdown", t);
|
|
64
|
-
} }), new
|
|
64
|
+
} }), new X({ name: "pointermove", callback: (t) => {
|
|
65
65
|
if (!this._currentModeCallbacks || !t.isPrimary) return;
|
|
66
66
|
t.preventDefault();
|
|
67
67
|
const e = this.getDrawEventFromEvent(t);
|
|
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 }, r = this._currentModeCallbacks.getState(), n =
|
|
71
|
+
const i = { x: this._lastDrawEvent.containerX, y: this._lastDrawEvent.containerY }, o = { x: e.containerX, y: e.containerY }, r = this._currentModeCallbacks.getState(), n = I(i, o);
|
|
72
72
|
let a = !1;
|
|
73
73
|
if (a = r === "drawing" ? n < this._minPixelDragDistanceDrawing : r === "selecting" ? n < this._minPixelDragDistanceSelecting : n < this._minPixelDragDistance, a) return;
|
|
74
74
|
this._dragState = "dragging", this._currentModeCallbacks.onDragStart(e, (l) => {
|
|
@@ -81,13 +81,13 @@ class Qt {
|
|
|
81
81
|
this.getMapEventElement().addEventListener("pointermove", t);
|
|
82
82
|
}, unregister: (t) => {
|
|
83
83
|
this.getMapEventElement().removeEventListener("pointermove", t);
|
|
84
|
-
} }), new
|
|
84
|
+
} }), new X({ name: "contextmenu", callback: (t) => {
|
|
85
85
|
this._currentModeCallbacks && t.preventDefault();
|
|
86
86
|
}, register: (t) => {
|
|
87
87
|
this.getMapEventElement().addEventListener("contextmenu", t);
|
|
88
88
|
}, unregister: (t) => {
|
|
89
89
|
this.getMapEventElement().removeEventListener("contextmenu", t);
|
|
90
|
-
} }), new
|
|
90
|
+
} }), new X({ name: "pointerup", callback: (t) => {
|
|
91
91
|
if (!this._currentModeCallbacks || t.target !== this.getMapEventElement() || !t.isPrimary) return;
|
|
92
92
|
const e = this.getDrawEventFromEvent(t);
|
|
93
93
|
e && (this._dragState === "dragging" ? this._currentModeCallbacks.onDragEnd(e, (i) => {
|
|
@@ -97,13 +97,13 @@ class Qt {
|
|
|
97
97
|
this.getMapEventElement().addEventListener("pointerup", t);
|
|
98
98
|
}, unregister: (t) => {
|
|
99
99
|
this.getMapEventElement().removeEventListener("pointerup", t);
|
|
100
|
-
} }), new
|
|
100
|
+
} }), new X({ name: "keyup", callback: (t) => {
|
|
101
101
|
this._currentModeCallbacks && (this._heldKeys.delete(t.key), this._currentModeCallbacks.onKeyUp({ key: t.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => t.preventDefault() }));
|
|
102
102
|
}, register: (t) => {
|
|
103
103
|
this.getMapEventElement().addEventListener("keyup", t);
|
|
104
104
|
}, unregister: (t) => {
|
|
105
105
|
this.getMapEventElement().removeEventListener("keyup", t);
|
|
106
|
-
} }), new
|
|
106
|
+
} }), new X({ name: "keydown", callback: (t) => {
|
|
107
107
|
this._currentModeCallbacks && (this._heldKeys.add(t.key), this._currentModeCallbacks.onKeyDown({ key: t.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => t.preventDefault() }));
|
|
108
108
|
}, register: (t) => {
|
|
109
109
|
this.getMapEventElement().addEventListener("keydown", t);
|
|
@@ -117,7 +117,7 @@ class Qt {
|
|
|
117
117
|
}), this.clear();
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
class we extends
|
|
120
|
+
class we extends te {
|
|
121
121
|
constructor(t) {
|
|
122
122
|
super(t), this._nextRender = void 0, this._map = void 0, this._container = void 0, this._rendered = !1, this.changedIds = { deletion: !1, points: !1, linestrings: !1, polygons: !1, styling: !1 }, this._map = t.map, this._container = this._map.getContainer();
|
|
123
123
|
}
|
|
@@ -187,13 +187,13 @@ class we extends Qt {
|
|
|
187
187
|
this.updateChangedIds(t), this._nextRender && cancelAnimationFrame(this._nextRender), this._nextRender = requestAnimationFrame(() => {
|
|
188
188
|
const i = [...t.created, ...t.updated, ...t.unchanged], o = [], r = [], n = [];
|
|
189
189
|
for (let a = 0; a < i.length; a++) {
|
|
190
|
-
const l = i[a], { properties:
|
|
191
|
-
l.geometry.type === "Point" ? (
|
|
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, r.push(l)) : l.geometry.type === "Polygon" && (d.polygonFillColor = c.polygonFillColor, d.polygonFillOpacity = c.polygonFillOpacity, d.polygonOutlineColor = c.polygonOutlineColor, d.polygonOutlineWidth = c.polygonOutlineWidth, n.push(l));
|
|
192
192
|
}
|
|
193
193
|
if (this._rendered) {
|
|
194
|
-
const a = this.changedIds.deletion || this.changedIds.styling, l = a || this.changedIds.linestrings,
|
|
195
|
-
let
|
|
196
|
-
(a || this.changedIds.points) && (
|
|
194
|
+
const a = this.changedIds.deletion || this.changedIds.styling, l = a || this.changedIds.linestrings, d = a || this.changedIds.polygons;
|
|
195
|
+
let c;
|
|
196
|
+
(a || this.changedIds.points) && (c = this._setGeoJSONLayerData("Point", o)), l && this._setGeoJSONLayerData("LineString", r), d && this._setGeoJSONLayerData("Polygon", n), c && this._map.moveLayer(c);
|
|
197
197
|
} else {
|
|
198
198
|
const a = this._addGeoJSONLayer("Point", o);
|
|
199
199
|
this._addGeoJSONLayer("LineString", r), this._addGeoJSONLayer("Polygon", n), this._rendered = !0, a && this._map.moveLayer(a);
|
|
@@ -211,10 +211,11 @@ class we extends Qt {
|
|
|
211
211
|
return super.unregister();
|
|
212
212
|
}
|
|
213
213
|
register(t) {
|
|
214
|
-
|
|
214
|
+
var e;
|
|
215
|
+
super.register(t), (e = this._currentModeCallbacks) != null && e.onReady && this._currentModeCallbacks.onReady();
|
|
215
216
|
}
|
|
216
217
|
}
|
|
217
|
-
class
|
|
218
|
+
class Fe extends te {
|
|
218
219
|
constructor(t) {
|
|
219
220
|
super(t), this.mapboxglAdapter = void 0, this.mapboxglAdapter = new we(t);
|
|
220
221
|
}
|
|
@@ -255,8 +256,8 @@ class Ee extends Qt {
|
|
|
255
256
|
this.mapboxglAdapter.clear();
|
|
256
257
|
}
|
|
257
258
|
}
|
|
258
|
-
const
|
|
259
|
-
var
|
|
259
|
+
const Ee = { radians: 6370997 / (2 * Math.PI), degrees: 2 * Math.PI * 6370997 / 360, ft: 0.3048, m: 1, "us-ft": 1200 / 3937 };
|
|
260
|
+
var ee = class {
|
|
260
261
|
constructor(s) {
|
|
261
262
|
this.code_ = s.code, this.units_ = s.units, this.extent_ = s.extent !== void 0 ? s.extent : null, this.worldExtent_ = s.worldExtent !== void 0 ? s.worldExtent : null, this.axisOrientation_ = s.axisOrientation !== void 0 ? s.axisOrientation : "enu", this.global_ = s.global !== void 0 && s.global, this.canWrapX_ = !(!this.global_ || !this.extent_), this.getPointResolutionFunc_ = s.getPointResolution, this.defaultTileGrid_ = null, this.metersPerUnit_ = s.metersPerUnit;
|
|
262
263
|
}
|
|
@@ -273,7 +274,7 @@ var te = class {
|
|
|
273
274
|
return this.units_;
|
|
274
275
|
}
|
|
275
276
|
getMetersPerUnit() {
|
|
276
|
-
return this.metersPerUnit_ ||
|
|
277
|
+
return this.metersPerUnit_ || Ee[this.units_];
|
|
277
278
|
}
|
|
278
279
|
getWorldExtent() {
|
|
279
280
|
return this.worldExtent_;
|
|
@@ -306,76 +307,76 @@ var te = class {
|
|
|
306
307
|
return this.getPointResolutionFunc_;
|
|
307
308
|
}
|
|
308
309
|
};
|
|
309
|
-
const
|
|
310
|
-
class
|
|
310
|
+
const et = 6378137, H = Math.PI * et, Ie = [-H, -H, H, H], _e = [-180, -85, 180, 85], st = et * Math.log(Math.tan(Math.PI / 2));
|
|
311
|
+
class K extends ee {
|
|
311
312
|
constructor(t) {
|
|
312
|
-
super({ code: t, units: "m", extent:
|
|
313
|
-
return e / Math.cosh(i[1] /
|
|
313
|
+
super({ code: t, units: "m", extent: Ie, global: !0, worldExtent: _e, getPointResolution: function(e, i) {
|
|
314
|
+
return e / Math.cosh(i[1] / et);
|
|
314
315
|
} });
|
|
315
316
|
}
|
|
316
317
|
}
|
|
317
|
-
const
|
|
318
|
-
class A extends
|
|
318
|
+
const kt = [new K("EPSG:3857"), new K("EPSG:102100"), new K("EPSG:102113"), new K("EPSG:900913"), new K("http://www.opengis.net/def/crs/EPSG/0/3857"), new K("http://www.opengis.net/gml/srs/epsg.xml#3857")], Lt = [-180, -90, 180, 90], De = 6378137 * Math.PI / 180;
|
|
319
|
+
class A extends ee {
|
|
319
320
|
constructor(t, e) {
|
|
320
|
-
super({ code: t, units: "degrees", extent:
|
|
321
|
+
super({ code: t, units: "degrees", extent: Lt, axisOrientation: e, global: !0, metersPerUnit: De, worldExtent: Lt });
|
|
321
322
|
}
|
|
322
323
|
}
|
|
323
|
-
const
|
|
324
|
-
let
|
|
324
|
+
const Wt = [new A("CRS:84"), new A("EPSG:4326", "neu"), new A("urn:ogc:def:crs:OGC:1.3:CRS84"), new A("urn:ogc:def:crs:OGC:2:84"), new A("http://www.opengis.net/def/crs/OGC/1.3/CRS84"), new A("http://www.opengis.net/gml/srs/epsg.xml#4326", "neu"), new A("http://www.opengis.net/def/crs/EPSG/0/4326", "neu")];
|
|
325
|
+
let Pt = {};
|
|
325
326
|
function ut(s, t, e) {
|
|
326
327
|
const i = s.getCode(), o = t.getCode();
|
|
327
|
-
i in
|
|
328
|
+
i in Pt || (Pt[i] = {}), Pt[i][o] = e;
|
|
328
329
|
}
|
|
329
|
-
function
|
|
330
|
+
function ie(s, t) {
|
|
330
331
|
if (t !== void 0) for (let e = 0, i = s.length; e < i; ++e) t[e] = s[e];
|
|
331
332
|
else t = s.slice();
|
|
332
333
|
return t;
|
|
333
334
|
}
|
|
334
335
|
function Oe(s) {
|
|
335
|
-
s.getCode(), ut(s, s,
|
|
336
|
+
s.getCode(), ut(s, s, ie);
|
|
336
337
|
}
|
|
337
|
-
function
|
|
338
|
+
function jt(s) {
|
|
338
339
|
(function(t) {
|
|
339
340
|
t.forEach(Oe);
|
|
340
341
|
})(s), s.forEach(function(t) {
|
|
341
342
|
s.forEach(function(e) {
|
|
342
|
-
t !== e && ut(t, e,
|
|
343
|
+
t !== e && ut(t, e, ie);
|
|
343
344
|
});
|
|
344
345
|
});
|
|
345
346
|
}
|
|
346
|
-
var
|
|
347
|
-
|
|
347
|
+
var Bt, Nt, Gt, b;
|
|
348
|
+
jt(kt), jt(Wt), Bt = kt, Nt = function(s, t, e) {
|
|
348
349
|
const i = s.length;
|
|
349
350
|
e = e > 1 ? e : 2, t === void 0 && (t = e > 2 ? s.slice() : new Array(i));
|
|
350
351
|
for (let o = 0; o < i; o += e) {
|
|
351
|
-
t[o] =
|
|
352
|
-
let r =
|
|
352
|
+
t[o] = H * s[o] / 180;
|
|
353
|
+
let r = et * Math.log(Math.tan(Math.PI * (+s[o + 1] + 90) / 360));
|
|
353
354
|
r > st ? r = st : r < -st && (r = -st), t[o + 1] = r;
|
|
354
355
|
}
|
|
355
356
|
return t;
|
|
356
|
-
},
|
|
357
|
+
}, Gt = function(s, t, e) {
|
|
357
358
|
const i = s.length;
|
|
358
359
|
e = e > 1 ? e : 2, t === void 0 && (t = e > 2 ? s.slice() : new Array(i));
|
|
359
|
-
for (let o = 0; o < i; o += e) t[o] = 180 * s[o] /
|
|
360
|
+
for (let o = 0; o < i; o += e) t[o] = 180 * s[o] / H, t[o + 1] = 360 * Math.atan(Math.exp(s[o + 1] / et)) / Math.PI - 90;
|
|
360
361
|
return t;
|
|
361
|
-
},
|
|
362
|
-
|
|
363
|
-
ut(s, t,
|
|
362
|
+
}, Wt.forEach(function(s) {
|
|
363
|
+
Bt.forEach(function(t) {
|
|
364
|
+
ut(s, t, Nt), ut(t, s, Gt);
|
|
364
365
|
});
|
|
365
366
|
});
|
|
366
367
|
(function(s) {
|
|
367
368
|
s.Commit = "commit", s.Provisional = "provisional", s.Finish = "finish";
|
|
368
369
|
})(b || (b = {}));
|
|
369
|
-
const
|
|
370
|
-
function
|
|
370
|
+
const wt = "selected", tt = "midPoint", Ft = "closingPoint";
|
|
371
|
+
function xt(s) {
|
|
371
372
|
return !!(s && typeof s == "object" && s !== null && !Array.isArray(s));
|
|
372
373
|
}
|
|
373
|
-
function
|
|
374
|
-
|
|
374
|
+
function At(s) {
|
|
375
|
+
return !!function(t) {
|
|
375
376
|
return typeof t == "number" && !isNaN(new Date(t).valueOf());
|
|
376
|
-
}(s)
|
|
377
|
-
return !0;
|
|
377
|
+
}(s);
|
|
378
378
|
}
|
|
379
|
+
const ke = "Feature mode property does not match the mode being added to";
|
|
379
380
|
var U;
|
|
380
381
|
(function(s) {
|
|
381
382
|
s.Drawing = "drawing", s.Select = "select", s.Static = "static", s.Render = "render";
|
|
@@ -397,7 +398,7 @@ class W {
|
|
|
397
398
|
registerBehaviors(t) {
|
|
398
399
|
}
|
|
399
400
|
constructor(t) {
|
|
400
|
-
this._state = void 0, this._styles = void 0, this.behaviors = [], this.validate = void 0, this.pointerDistance = void 0, this.coordinatePrecision = void 0, this.onStyleChange = void 0, this.store = void 0, this.setDoubleClickToZoom = void 0, this.unproject = void 0, this.project = void 0, this.setCursor = void 0, this.projection = void 0, this.type = U.Drawing, this.mode = "base", this._state = "unregistered", this._styles = t && t.styles ?
|
|
401
|
+
this._state = void 0, this._styles = void 0, this.behaviors = [], this.validate = void 0, this.pointerDistance = void 0, this.coordinatePrecision = void 0, this.onStyleChange = void 0, this.store = void 0, this.setDoubleClickToZoom = void 0, this.unproject = void 0, this.project = void 0, this.setCursor = void 0, this.projection = void 0, this.type = U.Drawing, this.mode = "base", this._state = "unregistered", this._styles = t && t.styles ? M({}, t.styles) : {}, this.pointerDistance = t && t.pointerDistance || 40, this.validate = t && t.validation, this.projection = t && t.projection || "web-mercator";
|
|
401
402
|
}
|
|
402
403
|
setDrawing() {
|
|
403
404
|
if (this._state !== "started") throw new Error("Mode must be unregistered or stopped to start");
|
|
@@ -416,23 +417,33 @@ class W {
|
|
|
416
417
|
this._state = "registered", this.store = t.store, this.store.registerOnChange(t.onChange), this.setDoubleClickToZoom = t.setDoubleClickToZoom, this.project = t.project, this.unproject = t.unproject, this.onSelect = t.onSelect, this.onDeselect = t.onDeselect, this.setCursor = t.setCursor, this.onStyleChange = t.onChange, this.onFinish = t.onFinish, this.coordinatePrecision = t.coordinatePrecision, this.registerBehaviors({ mode: t.mode, store: this.store, project: this.project, unproject: this.unproject, pointerDistance: this.pointerDistance, coordinatePrecision: t.coordinatePrecision, projection: this.projection });
|
|
417
418
|
}
|
|
418
419
|
validateFeature(t) {
|
|
420
|
+
return this.performFeatureValidation(t);
|
|
421
|
+
}
|
|
422
|
+
performFeatureValidation(t) {
|
|
419
423
|
if (this._state === "unregistered") throw new Error("Mode must be registered");
|
|
420
424
|
const e = function(i, o) {
|
|
421
425
|
let r;
|
|
422
|
-
if (
|
|
426
|
+
if (xt(i)) if (i.id == null) r = "Feature has no id";
|
|
423
427
|
else if (typeof i.id != "string" && typeof i.id != "number") r = "Feature must be string or number as per GeoJSON spec";
|
|
424
|
-
else if (o(i.id)) if (
|
|
425
|
-
if (!i.properties.mode || typeof i.properties.mode != "string")
|
|
428
|
+
else if (o(i.id)) if (xt(i.geometry)) if (xt(i.properties)) if (typeof i.geometry.type == "string" && ["Polygon", "LineString", "Point"].includes(i.geometry.type)) if (Array.isArray(i.geometry.coordinates)) {
|
|
429
|
+
if (!i.properties.mode || typeof i.properties.mode != "string") return { valid: !1, reason: "Feature does not have a valid mode property" };
|
|
426
430
|
} else r = "Feature coordinates is not an array";
|
|
427
431
|
else r = "Feature is not Point, LineString or Polygon";
|
|
428
432
|
else r = "Feature has no properties";
|
|
429
433
|
else r = "Feature has no geometry";
|
|
430
434
|
else r = "Feature must match the id strategy (default is UUID4)";
|
|
431
435
|
else r = "Feature is not object";
|
|
432
|
-
|
|
433
|
-
return !0;
|
|
436
|
+
return r ? { valid: !1, reason: r } : { valid: !0 };
|
|
434
437
|
}(t, this.store.idStrategy.isValidId);
|
|
435
|
-
|
|
438
|
+
if (this.validate) {
|
|
439
|
+
const i = this.validate(t, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Provisional });
|
|
440
|
+
return { valid: e.valid && i.valid, reason: i.reason };
|
|
441
|
+
}
|
|
442
|
+
return { valid: e.valid, reason: e.reason };
|
|
443
|
+
}
|
|
444
|
+
validateModeFeature(t, e) {
|
|
445
|
+
const i = this.performFeatureValidation(t);
|
|
446
|
+
return i.valid ? t.properties.mode !== this.mode ? { valid: !1, reason: ke } : e(t) : { valid: !1, reason: i.reason };
|
|
436
447
|
}
|
|
437
448
|
onFinish(t, e) {
|
|
438
449
|
}
|
|
@@ -464,39 +475,39 @@ class W {
|
|
|
464
475
|
return t === void 0 ? e : typeof t == "function" ? t(i) : t;
|
|
465
476
|
}
|
|
466
477
|
}
|
|
467
|
-
class
|
|
478
|
+
class Le extends W {
|
|
468
479
|
constructor(...t) {
|
|
469
480
|
super(...t), this.type = U.Select;
|
|
470
481
|
}
|
|
471
482
|
}
|
|
472
483
|
function G(s, t) {
|
|
473
|
-
const e = (
|
|
484
|
+
const e = (d) => d * Math.PI / 180, i = e(s[1]), o = e(s[0]), r = e(t[1]), n = r - i, a = e(t[0]) - o, l = Math.sin(n / 2) * Math.sin(n / 2) + Math.cos(i) * Math.cos(r) * Math.sin(a / 2) * Math.sin(a / 2);
|
|
474
485
|
return 2 * Math.atan2(Math.sqrt(l), Math.sqrt(1 - l)) * 6371e3 / 1e3;
|
|
475
486
|
}
|
|
476
|
-
const
|
|
487
|
+
const Et = 63710088e-1;
|
|
477
488
|
function _(s) {
|
|
478
489
|
return s % 360 * Math.PI / 180;
|
|
479
490
|
}
|
|
480
|
-
function
|
|
481
|
-
return s / (
|
|
491
|
+
function oe(s) {
|
|
492
|
+
return s / (Et / 1e3);
|
|
482
493
|
}
|
|
483
|
-
function
|
|
494
|
+
function $(s) {
|
|
484
495
|
return s % (2 * Math.PI) * 180 / Math.PI;
|
|
485
496
|
}
|
|
486
|
-
const
|
|
487
|
-
function
|
|
488
|
-
const i = _(s[0]), o = _(s[1]), r = _(e), n =
|
|
489
|
-
return [
|
|
497
|
+
const Vt = 57.29577951308232, Ut = 0.017453292519943295, gt = 6378137, x = (s, t) => ({ x: s === 0 ? 0 : s * Ut * gt, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * Ut / 2)) * gt }), O = (s, t) => ({ lng: s === 0 ? 0 : Vt * (s / gt), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / gt)) - Math.PI / 2) * Vt });
|
|
498
|
+
function We(s, t, e) {
|
|
499
|
+
const i = _(s[0]), o = _(s[1]), r = _(e), n = oe(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(r));
|
|
500
|
+
return [$(i + Math.atan2(Math.sin(r) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), $(a)];
|
|
490
501
|
}
|
|
491
|
-
function
|
|
502
|
+
function Tt(s) {
|
|
492
503
|
const { center: t, radiusKilometers: e, coordinatePrecision: i } = s, o = s.steps ? s.steps : 64, r = [];
|
|
493
504
|
for (let n = 0; n < o; n++) {
|
|
494
|
-
const a =
|
|
495
|
-
r.push([
|
|
505
|
+
const a = We(t, e, -360 * n / o);
|
|
506
|
+
r.push([F(a[0], i), F(a[1], i)]);
|
|
496
507
|
}
|
|
497
508
|
return r.push(r[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [r] }, properties: {} };
|
|
498
509
|
}
|
|
499
|
-
function
|
|
510
|
+
function It(s) {
|
|
500
511
|
const t = { epsilon: 0 };
|
|
501
512
|
let e;
|
|
502
513
|
if (s.geometry.type === "Polygon") e = s.geometry.coordinates;
|
|
@@ -505,20 +516,20 @@ function Et(s) {
|
|
|
505
516
|
e = [s.geometry.coordinates];
|
|
506
517
|
}
|
|
507
518
|
const i = [];
|
|
508
|
-
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
|
|
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++) r(n, a, l, d);
|
|
509
520
|
return i.length > 0;
|
|
510
521
|
function o(n) {
|
|
511
522
|
return n < 0 - t.epsilon || n > 1 + t.epsilon;
|
|
512
523
|
}
|
|
513
|
-
function r(n, a, l,
|
|
514
|
-
const
|
|
515
|
-
if (nt(f,
|
|
516
|
-
const
|
|
517
|
-
return Ct === 0 ? null : [((
|
|
518
|
-
}(
|
|
524
|
+
function r(n, a, l, d) {
|
|
525
|
+
const c = e[n][a], h = e[n][a + 1], u = e[l][d], g = e[l][d + 1], p = function(f, C, v, P) {
|
|
526
|
+
if (nt(f, v) || nt(f, P) || nt(C, v) || nt(P, v)) return null;
|
|
527
|
+
const S = f[0], w = f[1], E = C[0], B = C[1], T = v[0], R = v[1], N = P[0], rt = P[1], Ct = (S - E) * (R - rt) - (w - B) * (T - N);
|
|
528
|
+
return Ct === 0 ? null : [((S * B - w * E) * (T - N) - (S - E) * (T * rt - R * N)) / Ct, ((S * B - w * E) * (R - rt) - (w - B) * (T * rt - R * N)) / Ct];
|
|
529
|
+
}(c, h, u, g);
|
|
519
530
|
if (p === null) return;
|
|
520
531
|
let y, m;
|
|
521
|
-
y =
|
|
532
|
+
y = h[0] !== c[0] ? (p[0] - c[0]) / (h[0] - c[0]) : (p[1] - c[1]) / (h[1] - c[1]), m = g[0] !== u[0] ? (p[0] - u[0]) / (g[0] - u[0]) : (p[1] - u[1]) / (g[1] - u[1]), o(y) || o(m) || (p.toString(), i.push(p));
|
|
522
533
|
}
|
|
523
534
|
}
|
|
524
535
|
function nt(s, t) {
|
|
@@ -533,22 +544,24 @@ function Rt(s) {
|
|
|
533
544
|
for (; Math.round(s * t) / t !== s; ) t *= 10, e++;
|
|
534
545
|
return e;
|
|
535
546
|
}
|
|
536
|
-
|
|
537
|
-
|
|
547
|
+
const je = "Feature is not a Polygon", Be = "Feature has holes", Ne = "Feature has less than 4 coordinates", Ge = "Feature has invalid coordinates", Ae = "Feature coordinates are not closed";
|
|
548
|
+
function vt(s, t) {
|
|
549
|
+
return s.geometry.type !== "Polygon" ? { valid: !1, reason: je } : s.geometry.coordinates.length !== 1 ? { valid: !1, reason: Be } : s.geometry.coordinates[0].length < 4 ? { valid: !1, reason: Ne } : s.geometry.coordinates[0].every((o) => mt(o, t)) ? (e = s.geometry.coordinates[0][0])[0] !== (i = s.geometry.coordinates[0][s.geometry.coordinates[0].length - 1])[0] || e[1] !== i[1] ? { valid: !1, reason: Ae } : { valid: !0 } : { valid: !1, reason: Ge };
|
|
538
550
|
var e, i;
|
|
539
551
|
}
|
|
540
|
-
function
|
|
541
|
-
|
|
552
|
+
function ot(s, t) {
|
|
553
|
+
const e = vt(s, t);
|
|
554
|
+
return e.valid ? It(s) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
|
|
542
555
|
}
|
|
543
556
|
class re extends W {
|
|
544
557
|
constructor(t) {
|
|
545
558
|
var e;
|
|
546
|
-
super(t), this.mode = "circle", this.center = void 0, this.clickCount = 0, this.currentCircleId = void 0, this.keyEvents = void 0, this.cursors = void 0, this.startingRadiusKilometers = 1e-5;
|
|
559
|
+
super(t), this.mode = "circle", this.center = void 0, this.clickCount = 0, this.currentCircleId = void 0, this.keyEvents = void 0, this.cursors = void 0, this.startingRadiusKilometers = 1e-5, this.cursorMovedAfterInitialCursorDown = !1;
|
|
547
560
|
const i = { start: "crosshair" };
|
|
548
|
-
if (this.cursors = t && t.cursors ?
|
|
561
|
+
if (this.cursors = t && t.cursors ? M({}, i, t.cursors) : i, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
|
|
549
562
|
else {
|
|
550
563
|
const o = { cancel: "Escape", finish: "Enter" };
|
|
551
|
-
this.keyEvents = t && t.keyEvents ?
|
|
564
|
+
this.keyEvents = t && t.keyEvents ? M({}, o, t.keyEvents) : o;
|
|
552
565
|
}
|
|
553
566
|
this.startingRadiusKilometers = (e = t == null ? void 0 : t.startingRadiusKilometers) != null ? e : 1e-5, this.validate = t == null ? void 0 : t.validation;
|
|
554
567
|
}
|
|
@@ -557,9 +570,9 @@ class re extends W {
|
|
|
557
570
|
const t = this.currentCircleId;
|
|
558
571
|
if (this.validate && t) {
|
|
559
572
|
const e = this.store.getGeometryCopy(t);
|
|
560
|
-
if (!this.validate({ type: "Feature", id: t, geometry: e, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Finish })) return;
|
|
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;
|
|
561
574
|
}
|
|
562
|
-
this.center = void 0, this.currentCircleId = void 0, this.clickCount = 0, this.state === "drawing" && this.setStarted(), this.onFinish(t, { mode: this.mode, action: "draw" });
|
|
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" });
|
|
563
576
|
}
|
|
564
577
|
start() {
|
|
565
578
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -570,12 +583,12 @@ class re extends W {
|
|
|
570
583
|
onClick(t) {
|
|
571
584
|
if (this.clickCount === 0) {
|
|
572
585
|
this.center = [t.lng, t.lat];
|
|
573
|
-
const e =
|
|
574
|
-
this.currentCircleId = i, this.clickCount++, this.setDrawing();
|
|
575
|
-
} else this.clickCount === 1 && this.center && this.currentCircleId !== void 0 && this.updateCircle(t), this.close();
|
|
586
|
+
const e = Tt({ center: this.center, radiusKilometers: this.startingRadiusKilometers, coordinatePrecision: this.coordinatePrecision }), [i] = this.store.create([{ geometry: e.geometry, properties: { mode: this.mode, radiusKilometers: this.startingRadiusKilometers } }]);
|
|
587
|
+
this.currentCircleId = i, this.clickCount++, this.cursorMovedAfterInitialCursorDown = !1, this.setDrawing();
|
|
588
|
+
} else this.clickCount === 1 && this.center && this.currentCircleId !== void 0 && this.cursorMovedAfterInitialCursorDown && this.updateCircle(t), this.close();
|
|
576
589
|
}
|
|
577
590
|
onMouseMove(t) {
|
|
578
|
-
this.updateCircle(t);
|
|
591
|
+
this.cursorMovedAfterInitialCursorDown = !0, this.updateCircle(t);
|
|
579
592
|
}
|
|
580
593
|
onKeyDown() {
|
|
581
594
|
}
|
|
@@ -597,11 +610,11 @@ class re extends W {
|
|
|
597
610
|
}
|
|
598
611
|
}
|
|
599
612
|
styleFeature(t) {
|
|
600
|
-
const e =
|
|
613
|
+
const e = M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
601
614
|
return t.type === "Feature" && t.geometry.type === "Polygon" && t.properties.mode === this.mode && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
|
|
602
615
|
}
|
|
603
616
|
validateFeature(t) {
|
|
604
|
-
return
|
|
617
|
+
return this.validateModeFeature(t, (e) => ot(e, this.coordinatePrecision));
|
|
605
618
|
}
|
|
606
619
|
updateCircle(t) {
|
|
607
620
|
if (this.clickCount === 1 && this.center && this.currentCircleId) {
|
|
@@ -611,34 +624,35 @@ class re extends W {
|
|
|
611
624
|
const o = function(r, n) {
|
|
612
625
|
const a = 1e3 * G(r, n);
|
|
613
626
|
if (a === 0) return 1;
|
|
614
|
-
const { x: l, y:
|
|
615
|
-
return Math.sqrt(Math.pow(
|
|
627
|
+
const { x: l, y: d } = x(r[0], r[1]), { x: c, y: h } = x(n[0], n[1]);
|
|
628
|
+
return Math.sqrt(Math.pow(c - l, 2) + Math.pow(h - d, 2)) / a;
|
|
616
629
|
}(this.center, [t.lng, t.lat]);
|
|
617
630
|
i = function(r) {
|
|
618
|
-
const { center: n, radiusKilometers: a, coordinatePrecision: l } = r,
|
|
619
|
-
for (let m = 0; m <
|
|
620
|
-
const f = 360 * m /
|
|
621
|
-
y.push([
|
|
631
|
+
const { center: n, radiusKilometers: a, coordinatePrecision: l } = r, d = r.steps ? r.steps : 64, c = 1e3 * a, [h, u] = n, { x: g, y: p } = x(h, u), y = [];
|
|
632
|
+
for (let m = 0; m < d; m++) {
|
|
633
|
+
const f = 360 * m / d * Math.PI / 180, C = c * Math.cos(f), v = c * Math.sin(f), [P, S] = [g + C, p + v], { lng: w, lat: E } = O(P, S);
|
|
634
|
+
y.push([F(w, l), F(E, l)]);
|
|
622
635
|
}
|
|
623
636
|
return y.push(y[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [y] }, properties: {} };
|
|
624
637
|
}({ center: this.center, radiusKilometers: e * o, coordinatePrecision: this.coordinatePrecision });
|
|
625
638
|
} else {
|
|
626
639
|
if (this.projection !== "globe") throw new Error("Invalid projection");
|
|
627
|
-
i =
|
|
640
|
+
i = Tt({ center: this.center, radiusKilometers: e, coordinatePrecision: this.coordinatePrecision });
|
|
628
641
|
}
|
|
629
|
-
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 })) return;
|
|
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;
|
|
630
643
|
this.store.updateGeometry([{ id: this.currentCircleId, geometry: i.geometry }]), this.store.updateProperty([{ id: this.currentCircleId, property: "radiusKilometers", value: e }]);
|
|
631
644
|
}
|
|
632
645
|
}
|
|
633
646
|
}
|
|
634
647
|
class se extends W {
|
|
635
648
|
constructor(t) {
|
|
636
|
-
super(t), this.mode = "freehand", this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.minDistance = void 0, this.keyEvents = void 0, this.cursors = void 0, this.preventPointsNearClose = void 0;
|
|
649
|
+
super(t), this.mode = "freehand", this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.minDistance = void 0, this.keyEvents = void 0, this.cursors = void 0, this.preventPointsNearClose = void 0, this.autoClose = void 0, this.autoCloseTimeout = 500, this.hasLeftStartingPoint = !1, this.preventNewFeature = !1;
|
|
637
650
|
const e = { start: "crosshair", close: "pointer" };
|
|
638
|
-
if (this.cursors = t && t.cursors ?
|
|
651
|
+
if (this.cursors = t && t.cursors ? M({}, e, t.cursors) : e, this.preventPointsNearClose = t && t.preventPointsNearClose || !0, t && t.autoCloseTimeout && !t.autoClose) throw new Error("autoCloseTimeout is set, but autoClose is not enabled");
|
|
652
|
+
if (this.autoClose = t && t.autoClose || !1, this.autoCloseTimeout = t && t.autoCloseTimeout || 500, this.minDistance = t && t.minDistance || 20, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
|
|
639
653
|
else {
|
|
640
654
|
const i = { cancel: "Escape", finish: "Enter" };
|
|
641
|
-
this.keyEvents = t && t.keyEvents ?
|
|
655
|
+
this.keyEvents = t && t.keyEvents ? M({}, i, t.keyEvents) : i;
|
|
642
656
|
}
|
|
643
657
|
this.validate = t == null ? void 0 : t.validation;
|
|
644
658
|
}
|
|
@@ -647,9 +661,9 @@ class se extends W {
|
|
|
647
661
|
const t = this.currentId;
|
|
648
662
|
if (this.validate && t) {
|
|
649
663
|
const e = this.store.getGeometryCopy(t);
|
|
650
|
-
if (!this.validate({ type: "Feature", id: t, geometry: e, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Finish })) return;
|
|
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;
|
|
651
665
|
}
|
|
652
|
-
this.closingPointId && this.store.delete([this.closingPointId]), this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.state === "drawing" && this.setStarted(), this.onFinish(t, { mode: this.mode, action: "draw" });
|
|
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" });
|
|
653
667
|
}
|
|
654
668
|
start() {
|
|
655
669
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -659,21 +673,25 @@ class se extends W {
|
|
|
659
673
|
}
|
|
660
674
|
onMouseMove(t) {
|
|
661
675
|
if (this.currentId === void 0 || this.startingClick === !1) return;
|
|
662
|
-
const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates[0].length - 2, [o, r] = e.coordinates[0][i], { x: n, y: a } = this.project(o, r), l =
|
|
663
|
-
if (
|
|
664
|
-
if (this.
|
|
665
|
-
|
|
676
|
+
const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates[0].length - 2, [o, r] = e.coordinates[0][i], { x: n, y: a } = this.project(o, r), l = I({ 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
|
+
if (I({ x: h, y: u }, { x: t.containerX, y: t.containerY }) < this.pointerDistance) {
|
|
678
|
+
if (this.autoClose && this.hasLeftStartingPoint && (this.preventNewFeature = !0, setTimeout(() => {
|
|
679
|
+
this.preventNewFeature = !1;
|
|
680
|
+
}, this.autoCloseTimeout), this.close()), this.setCursor(this.cursors.close), this.preventPointsNearClose) return;
|
|
681
|
+
} else this.hasLeftStartingPoint = !0, this.setCursor(this.cursors.start);
|
|
666
682
|
if (l < this.minDistance) return;
|
|
667
683
|
e.coordinates[0].pop();
|
|
668
684
|
const g = { type: "Polygon", coordinates: [[...e.coordinates[0], [t.lng, t.lat], e.coordinates[0][0]]] };
|
|
669
|
-
this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: g, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Provisional }) || this.store.updateGeometry([{ id: this.currentId, geometry: g }]);
|
|
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 }]);
|
|
670
686
|
}
|
|
671
687
|
onClick(t) {
|
|
672
|
-
if (this.
|
|
673
|
-
|
|
674
|
-
|
|
688
|
+
if (!this.preventNewFeature) {
|
|
689
|
+
if (this.startingClick === !1) {
|
|
690
|
+
const [e, i] = 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 } }, { geometry: { type: "Point", coordinates: [t.lng, t.lat] }, properties: { mode: this.mode, [Ft]: !0 } }]);
|
|
691
|
+
return this.currentId = e, this.closingPointId = i, this.startingClick = !0, void this.setDrawing();
|
|
692
|
+
}
|
|
693
|
+
this.close();
|
|
675
694
|
}
|
|
676
|
-
this.close();
|
|
677
695
|
}
|
|
678
696
|
onKeyDown() {
|
|
679
697
|
}
|
|
@@ -695,14 +713,14 @@ class se extends W {
|
|
|
695
713
|
}
|
|
696
714
|
}
|
|
697
715
|
styleFeature(t) {
|
|
698
|
-
const e =
|
|
716
|
+
const e = M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
699
717
|
return t.type === "Feature" && t.geometry.type === "Polygon" && t.properties.mode === this.mode ? (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10, e) : (t.type === "Feature" && t.geometry.type === "Point" && t.properties.mode === this.mode && (e.pointWidth = this.getNumericStylingValue(this.styles.closingPointWidth, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(this.styles.closingPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.closingPointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.closingPointOutlineWidth, 2, t), e.zIndex = 40), e);
|
|
700
718
|
}
|
|
701
719
|
validateFeature(t) {
|
|
702
|
-
return
|
|
720
|
+
return this.validateModeFeature(t, (e) => vt(e, this.coordinatePrecision));
|
|
703
721
|
}
|
|
704
722
|
}
|
|
705
|
-
class
|
|
723
|
+
class k {
|
|
706
724
|
constructor({ store: t, mode: e, project: i, unproject: o, pointerDistance: r, coordinatePrecision: n, projection: a }) {
|
|
707
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 = r, this.coordinatePrecision = n, this.projection = a;
|
|
708
726
|
}
|
|
@@ -711,7 +729,7 @@ function ne({ unproject: s, point: t, pointerDistance: e }) {
|
|
|
711
729
|
const i = e / 2, { x: o, y: r } = t;
|
|
712
730
|
return { type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [[s(o - i, r - i), s(o + i, r - i), s(o + i, r + i), s(o - i, r + i), s(o - i, r - i)].map((n) => [n.lng, n.lat])] } };
|
|
713
731
|
}
|
|
714
|
-
class
|
|
732
|
+
class _t extends k {
|
|
715
733
|
constructor(t) {
|
|
716
734
|
super(t);
|
|
717
735
|
}
|
|
@@ -720,16 +738,16 @@ class It extends O {
|
|
|
720
738
|
return ne({ unproject: this.unproject, point: { x: e, y: i }, pointerDistance: this.pointerDistance });
|
|
721
739
|
}
|
|
722
740
|
}
|
|
723
|
-
class
|
|
741
|
+
class Dt extends k {
|
|
724
742
|
constructor(t) {
|
|
725
743
|
super(t);
|
|
726
744
|
}
|
|
727
745
|
measure(t, e) {
|
|
728
746
|
const { x: i, y: o } = this.project(e[0], e[1]);
|
|
729
|
-
return
|
|
747
|
+
return I({ x: i, y: o }, { x: t.containerX, y: t.containerY });
|
|
730
748
|
}
|
|
731
749
|
}
|
|
732
|
-
class ae extends
|
|
750
|
+
class ae extends k {
|
|
733
751
|
constructor(t, e, i) {
|
|
734
752
|
super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => this.getSnappable(o, (r) => !!(r.properties && r.properties.mode === this.mode)), this.getSnappableCoordinate = (o, r) => this.getSnappable(o, (n) => !!(n.properties && n.properties.mode === this.mode && n.id !== r)), this.config = t, this.pixelDistance = e, this.clickBoundingBox = i;
|
|
735
753
|
}
|
|
@@ -743,23 +761,23 @@ class ae extends O {
|
|
|
743
761
|
a = n.geometry.coordinates;
|
|
744
762
|
}
|
|
745
763
|
a.forEach((l) => {
|
|
746
|
-
const
|
|
747
|
-
|
|
764
|
+
const d = this.pixelDistance.measure(t, l);
|
|
765
|
+
d < r.minDist && d < this.pointerDistance && (r.coord = l, r.minDist = d);
|
|
748
766
|
});
|
|
749
767
|
}), r.coord;
|
|
750
768
|
}
|
|
751
769
|
}
|
|
752
|
-
function
|
|
753
|
-
const i = _(s[0]), o = _(s[1]), r = _(e), n =
|
|
754
|
-
return [
|
|
770
|
+
function Xt(s, t, e) {
|
|
771
|
+
const i = _(s[0]), o = _(s[1]), r = _(e), n = oe(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(r));
|
|
772
|
+
return [$(i + Math.atan2(Math.sin(r) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), $(a)];
|
|
755
773
|
}
|
|
756
|
-
function
|
|
774
|
+
function it({ x: s, y: t }, e, i) {
|
|
757
775
|
const o = _(i);
|
|
758
776
|
return { x: s + e * Math.cos(o), y: t + e * Math.sin(o) };
|
|
759
777
|
}
|
|
760
|
-
function
|
|
778
|
+
function Kt(s, t) {
|
|
761
779
|
const e = _(s[0]), i = _(t[0]), o = _(s[1]), r = _(t[1]), n = Math.sin(i - e) * Math.cos(r), a = Math.cos(o) * Math.sin(r) - Math.sin(o) * Math.cos(r) * Math.cos(i - e);
|
|
762
|
-
return
|
|
780
|
+
return $(Math.atan2(n, a));
|
|
763
781
|
}
|
|
764
782
|
function j({ x: s, y: t }, { x: e, y: i }) {
|
|
765
783
|
let o = Math.atan2(i - t, e - s);
|
|
@@ -768,79 +786,82 @@ function j({ x: s, y: t }, { x: e, y: i }) {
|
|
|
768
786
|
function V(s) {
|
|
769
787
|
return (s + 360) % 360;
|
|
770
788
|
}
|
|
771
|
-
function
|
|
789
|
+
function Ve(s, t, e) {
|
|
772
790
|
const i = [], o = s.length;
|
|
773
791
|
let r, n, a, l = 0;
|
|
774
|
-
for (let
|
|
792
|
+
for (let c = 0; c < s.length && !(t >= l && c === s.length - 1); c++) {
|
|
775
793
|
if (l > t && i.length === 0) {
|
|
776
|
-
if (r = t - l, !r) return i.push(s[
|
|
777
|
-
n =
|
|
794
|
+
if (r = t - l, !r) return i.push(s[c]), i;
|
|
795
|
+
n = Kt(s[c], s[c - 1]) - 180, a = Xt(s[c], r, n), i.push(a);
|
|
778
796
|
}
|
|
779
|
-
if (l >= e) return r = e - l, r ? (n =
|
|
780
|
-
if (l >= t && i.push(s[
|
|
781
|
-
l += G(s[
|
|
797
|
+
if (l >= e) return r = e - l, r ? (n = Kt(s[c], s[c - 1]) - 180, a = Xt(s[c], r, n), i.push(a), i) : (i.push(s[c]), i);
|
|
798
|
+
if (l >= t && i.push(s[c]), c === s.length - 1) return i;
|
|
799
|
+
l += G(s[c], s[c + 1]);
|
|
782
800
|
}
|
|
783
801
|
if (l < t && s.length === o) throw new Error("Start position is beyond line");
|
|
784
|
-
const
|
|
785
|
-
return [
|
|
802
|
+
const d = s[s.length - 1];
|
|
803
|
+
return [d, d];
|
|
786
804
|
}
|
|
787
805
|
function at(s) {
|
|
788
806
|
return s * (Math.PI / 180);
|
|
789
807
|
}
|
|
790
|
-
function
|
|
808
|
+
function zt(s) {
|
|
791
809
|
return s * (180 / Math.PI);
|
|
792
810
|
}
|
|
793
|
-
class
|
|
811
|
+
class Ue extends k {
|
|
794
812
|
constructor(t) {
|
|
795
813
|
super(t), this.config = void 0, this.config = t;
|
|
796
814
|
}
|
|
797
815
|
generateInsertionCoordinates(t, e, i) {
|
|
798
816
|
const o = [t, e];
|
|
799
817
|
let r = 0;
|
|
800
|
-
for (let
|
|
818
|
+
for (let d = 0; d < o.length - 1; d++) r += G(o[0], o[1]);
|
|
801
819
|
if (r <= i) return o;
|
|
802
820
|
let n = r / i - 1;
|
|
803
821
|
Number.isInteger(n) || (n = Math.floor(n) + 1);
|
|
804
822
|
const a = [];
|
|
805
|
-
for (let
|
|
806
|
-
const
|
|
807
|
-
a.push(
|
|
823
|
+
for (let d = 0; d < n; d++) {
|
|
824
|
+
const c = Ve(o, i * d, i * (d + 1));
|
|
825
|
+
a.push(c);
|
|
808
826
|
}
|
|
809
827
|
const l = [];
|
|
810
|
-
for (let
|
|
828
|
+
for (let d = 0; d < a.length; d++) l.push(a[d][1]);
|
|
811
829
|
return this.limitCoordinates(l);
|
|
812
830
|
}
|
|
813
831
|
generateInsertionGeodesicCoordinates(t, e, i) {
|
|
814
832
|
const o = G(t, e), r = function(n, a, l) {
|
|
815
|
-
const
|
|
833
|
+
const d = [], c = at(n[1]), h = at(n[0]), u = at(a[1]), g = at(a[0]);
|
|
816
834
|
l += 1;
|
|
817
|
-
const p = 2 * Math.asin(Math.sqrt(Math.sin((u -
|
|
818
|
-
if (p === 0 || isNaN(p)) return
|
|
835
|
+
const p = 2 * Math.asin(Math.sqrt(Math.sin((u - c) / 2) ** 2 + Math.cos(c) * Math.cos(u) * Math.sin((g - h) / 2) ** 2));
|
|
836
|
+
if (p === 0 || isNaN(p)) return d;
|
|
819
837
|
for (let y = 0; y <= l; y++) {
|
|
820
|
-
const m = y / l, f = Math.sin((1 - m) * p) / Math.sin(p),
|
|
821
|
-
if (isNaN(
|
|
822
|
-
const w = Math.atan2(
|
|
823
|
-
isNaN(w) || isNaN(
|
|
838
|
+
const m = y / l, f = Math.sin((1 - m) * p) / Math.sin(p), C = Math.sin(m * p) / Math.sin(p), v = f * Math.cos(c) * Math.cos(h) + C * Math.cos(u) * Math.cos(g), P = f * Math.cos(c) * Math.sin(h) + C * Math.cos(u) * Math.sin(g), S = f * Math.sin(c) + C * Math.sin(u);
|
|
839
|
+
if (isNaN(v) || isNaN(P) || isNaN(S)) continue;
|
|
840
|
+
const w = Math.atan2(S, Math.sqrt(v ** 2 + P ** 2)), E = Math.atan2(P, v);
|
|
841
|
+
isNaN(w) || isNaN(E) || d.push([zt(E), zt(w)]);
|
|
824
842
|
}
|
|
825
|
-
return
|
|
843
|
+
return d.slice(1, -1);
|
|
826
844
|
}(t, e, Math.floor(o / i));
|
|
827
845
|
return this.limitCoordinates(r);
|
|
828
846
|
}
|
|
829
847
|
limitCoordinates(t) {
|
|
830
|
-
return t.map((e) => [
|
|
848
|
+
return t.map((e) => [F(e[0], this.config.coordinatePrecision), F(e[1], this.config.coordinatePrecision)]);
|
|
831
849
|
}
|
|
832
850
|
}
|
|
833
|
-
function
|
|
851
|
+
function J(s, t) {
|
|
834
852
|
return s[0] === t[0] && s[1] === t[1];
|
|
835
853
|
}
|
|
836
|
-
|
|
854
|
+
function le(s, t) {
|
|
855
|
+
return s.geometry.type !== "LineString" ? { valid: !1, reason: "Feature is not a LineString" } : s.geometry.coordinates.length < 2 ? { valid: !1, reason: "Feature has less than 2 coordinates" } : s.geometry.coordinates.every((e) => mt(e, t)) ? { valid: !0 } : { valid: !1, reason: "Feature has invalid coordinates" };
|
|
856
|
+
}
|
|
857
|
+
class de extends W {
|
|
837
858
|
constructor(t) {
|
|
838
859
|
super(t), this.mode = "linestring", this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.keyEvents = void 0, this.snappingEnabled = void 0, this.cursors = void 0, this.mouseMove = !1, this.insertCoordinates = void 0, this.lastCommitedCoordinates = void 0, this.snapping = void 0, this.insertPoint = void 0;
|
|
839
860
|
const e = { start: "crosshair", close: "pointer" };
|
|
840
|
-
if (this.cursors = t && t.cursors ?
|
|
861
|
+
if (this.cursors = t && t.cursors ? M({}, e, t.cursors) : e, this.snappingEnabled = !(!t || t.snapping === void 0) && t.snapping, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
|
|
841
862
|
else {
|
|
842
863
|
const i = { cancel: "Escape", finish: "Enter" };
|
|
843
|
-
this.keyEvents = t && t.keyEvents ?
|
|
864
|
+
this.keyEvents = t && t.keyEvents ? M({}, i, t.keyEvents) : i;
|
|
844
865
|
}
|
|
845
866
|
this.validate = t == null ? void 0 : t.validation, this.insertCoordinates = t == null ? void 0 : t.insertCoordinates;
|
|
846
867
|
}
|
|
@@ -854,7 +875,7 @@ class le extends W {
|
|
|
854
875
|
updateGeometries(t, e, i) {
|
|
855
876
|
if (!this.currentId) return;
|
|
856
877
|
const o = { type: "LineString", coordinates: t };
|
|
857
|
-
if (this.validate && !this.validate({ type: "Feature", geometry: o }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: i })) return;
|
|
878
|
+
if (this.validate && !this.validate({ type: "Feature", geometry: o }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: i }).valid) return;
|
|
858
879
|
const r = [{ id: this.currentId, geometry: o }];
|
|
859
880
|
this.closingPointId && e && r.push({ id: this.closingPointId, geometry: { type: "Point", coordinates: e } }), i === "commit" && (this.lastCommitedCoordinates = o.coordinates), this.store.updateGeometry(r);
|
|
860
881
|
}
|
|
@@ -879,13 +900,13 @@ class le extends W {
|
|
|
879
900
|
updateToLine(t, e) {
|
|
880
901
|
if (!this.currentId) return;
|
|
881
902
|
const i = this.store.getGeometryCopy(this.currentId).coordinates, [o, r] = this.lastCommitedCoordinates ? this.lastCommitedCoordinates[this.lastCommitedCoordinates.length - 1] : i[i.length - 2], { x: n, y: a } = this.project(o, r);
|
|
882
|
-
if (
|
|
903
|
+
if (I({ x: n, y: a }, { x: e.x, y: e.y }) < this.pointerDistance) return void this.close();
|
|
883
904
|
this.setCursor(this.cursors.close);
|
|
884
905
|
const l = [...i, t];
|
|
885
906
|
this.updateGeometries(l, i[i.length - 1], b.Commit), this.currentCoordinate++;
|
|
886
907
|
}
|
|
887
908
|
registerBehaviors(t) {
|
|
888
|
-
this.snapping = new ae(t, new
|
|
909
|
+
this.snapping = new ae(t, new Dt(t), new _t(t)), this.insertPoint = new Ue(t);
|
|
889
910
|
}
|
|
890
911
|
start() {
|
|
891
912
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -900,12 +921,12 @@ class le extends W {
|
|
|
900
921
|
const i = this.snappingEnabled && this.snapping.getSnappableCoordinate(t, this.currentId) || [t.lng, t.lat];
|
|
901
922
|
if (this.closingPointId) {
|
|
902
923
|
const [r, n] = e[e.length - 1], { x: a, y: l } = this.project(r, n);
|
|
903
|
-
|
|
924
|
+
I({ x: a, y: l }, { x: t.containerX, y: t.containerY }) < this.pointerDistance && this.setCursor(this.cursors.close);
|
|
904
925
|
}
|
|
905
926
|
let o = [...e, i];
|
|
906
927
|
if (this.insertCoordinates && this.currentId && this.lastCommitedCoordinates) {
|
|
907
928
|
const r = this.lastCommitedCoordinates[this.lastCommitedCoordinates.length - 1], n = i;
|
|
908
|
-
if (
|
|
929
|
+
if (!J(r, n)) {
|
|
909
930
|
const a = this.generateInsertCoordinates(r, n);
|
|
910
931
|
o = [...this.lastCommitedCoordinates.slice(0, -1), ...a, i];
|
|
911
932
|
}
|
|
@@ -937,21 +958,22 @@ class le extends W {
|
|
|
937
958
|
}
|
|
938
959
|
}
|
|
939
960
|
styleFeature(t) {
|
|
940
|
-
const e =
|
|
961
|
+
const e = M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
941
962
|
return t.type === "Feature" && t.geometry.type === "LineString" && t.properties.mode === this.mode ? (e.lineStringColor = this.getHexColorStylingValue(this.styles.lineStringColor, e.lineStringColor, t), e.lineStringWidth = this.getNumericStylingValue(this.styles.lineStringWidth, e.lineStringWidth, t), e.zIndex = 10, e) : (t.type === "Feature" && t.geometry.type === "Point" && t.properties.mode === this.mode && (e.pointColor = this.getHexColorStylingValue(this.styles.closingPointColor, e.pointColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.closingPointWidth, e.pointWidth, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.closingPointOutlineColor, "#ffffff", t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.closingPointOutlineWidth, 2, t), e.zIndex = 40), e);
|
|
942
963
|
}
|
|
943
964
|
validateFeature(t) {
|
|
944
|
-
return
|
|
965
|
+
return this.validateModeFeature(t, (e) => le(e, this.coordinatePrecision));
|
|
945
966
|
}
|
|
946
967
|
}
|
|
968
|
+
const Te = "Feature is not a Point", Re = "Feature has invalid coordinates";
|
|
947
969
|
function ce(s, t) {
|
|
948
|
-
return s.geometry.type
|
|
970
|
+
return s.geometry.type !== "Point" ? { valid: !1, reason: Te } : mt(s.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: Re };
|
|
949
971
|
}
|
|
950
|
-
class
|
|
972
|
+
class Xe extends W {
|
|
951
973
|
constructor(t) {
|
|
952
974
|
super(t), this.mode = "point", this.cursors = void 0;
|
|
953
975
|
const e = { create: "crosshair" };
|
|
954
|
-
this.cursors = t && t.cursors ?
|
|
976
|
+
this.cursors = t && t.cursors ? M({}, e, t.cursors) : e;
|
|
955
977
|
}
|
|
956
978
|
start() {
|
|
957
979
|
this.setStarted(), this.setCursor(this.cursors.create);
|
|
@@ -962,7 +984,7 @@ class Be extends W {
|
|
|
962
984
|
onClick(t) {
|
|
963
985
|
if (!this.store) throw new Error("Mode must be registered first");
|
|
964
986
|
const e = { type: "Point", coordinates: [t.lng, t.lat] }, i = { mode: this.mode };
|
|
965
|
-
if (this.validate && !this.validate({ type: "Feature", geometry: e, properties: i }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Finish })) return;
|
|
987
|
+
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;
|
|
966
988
|
const [o] = this.store.create([{ geometry: e, properties: i }]);
|
|
967
989
|
this.onFinish(o, { mode: this.mode, action: "draw" });
|
|
968
990
|
}
|
|
@@ -981,14 +1003,14 @@ class Be extends W {
|
|
|
981
1003
|
onDragEnd() {
|
|
982
1004
|
}
|
|
983
1005
|
styleFeature(t) {
|
|
984
|
-
const e =
|
|
1006
|
+
const e = M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
985
1007
|
return t.type === "Feature" && t.geometry.type === "Point" && t.properties.mode === this.mode && (e.pointWidth = this.getNumericStylingValue(this.styles.pointWidth, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(this.styles.pointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.pointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.pointOutlineWidth, 2, t), e.zIndex = 30), e;
|
|
986
1008
|
}
|
|
987
1009
|
validateFeature(t) {
|
|
988
|
-
return
|
|
1010
|
+
return this.validateModeFeature(t, (e) => ce(e, this.coordinatePrecision));
|
|
989
1011
|
}
|
|
990
1012
|
}
|
|
991
|
-
class
|
|
1013
|
+
class Ke extends k {
|
|
992
1014
|
constructor(t, e) {
|
|
993
1015
|
super(t), this.config = void 0, this.pixelDistance = void 0, this._startEndPoints = [], this.config = t, this.pixelDistance = e;
|
|
994
1016
|
}
|
|
@@ -1000,7 +1022,7 @@ class Ne extends O {
|
|
|
1000
1022
|
create(t, e) {
|
|
1001
1023
|
if (this.ids.length) throw new Error("Opening and closing points already created");
|
|
1002
1024
|
if (t.length <= 3) throw new Error("Requires at least 4 coordinates");
|
|
1003
|
-
this._startEndPoints = this.store.create([{ geometry: { type: "Point", coordinates: t[0] }, properties: { mode: e, [
|
|
1025
|
+
this._startEndPoints = this.store.create([{ geometry: { type: "Point", coordinates: t[0] }, properties: { mode: e, [Ft]: !0 } }, { geometry: { type: "Point", coordinates: t[t.length - 2] }, properties: { mode: e, [Ft]: !0 } }]);
|
|
1004
1026
|
}
|
|
1005
1027
|
delete() {
|
|
1006
1028
|
this.ids.length && (this.store.delete(this.ids), this._startEndPoints = []);
|
|
@@ -1018,10 +1040,10 @@ class he extends W {
|
|
|
1018
1040
|
constructor(t) {
|
|
1019
1041
|
super(t), this.mode = "polygon", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.snappingEnabled = void 0, this.snapping = void 0, this.pixelDistance = void 0, this.closingPoints = void 0, this.cursors = void 0, this.mouseMove = !1;
|
|
1020
1042
|
const e = { start: "crosshair", close: "pointer" };
|
|
1021
|
-
if (this.cursors = t && t.cursors ?
|
|
1043
|
+
if (this.cursors = t && t.cursors ? M({}, e, t.cursors) : e, this.snappingEnabled = !(!t || t.snapping === void 0) && t.snapping, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
|
|
1022
1044
|
else {
|
|
1023
1045
|
const i = { cancel: "Escape", finish: "Enter" };
|
|
1024
|
-
this.keyEvents = t && t.keyEvents ?
|
|
1046
|
+
this.keyEvents = t && t.keyEvents ? M({}, i, t.keyEvents) : i;
|
|
1025
1047
|
}
|
|
1026
1048
|
}
|
|
1027
1049
|
close() {
|
|
@@ -1032,7 +1054,7 @@ class he extends W {
|
|
|
1032
1054
|
this.currentCoordinate = 0, this.currentId = void 0, this.closingPoints.delete(), this.state === "drawing" && this.setStarted(), this.onFinish(e, { mode: this.mode, action: "draw" });
|
|
1033
1055
|
}
|
|
1034
1056
|
registerBehaviors(t) {
|
|
1035
|
-
this.pixelDistance = new
|
|
1057
|
+
this.pixelDistance = new Dt(t), this.snapping = new ae(t, this.pixelDistance, new _t(t)), this.closingPoints = new Ke(t, this.pixelDistance);
|
|
1036
1058
|
}
|
|
1037
1059
|
start() {
|
|
1038
1060
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -1057,7 +1079,7 @@ class he extends W {
|
|
|
1057
1079
|
updatePolygonGeometry(t, e) {
|
|
1058
1080
|
if (!this.currentId) return !1;
|
|
1059
1081
|
const i = { type: "Polygon", coordinates: [t] };
|
|
1060
|
-
return !(this.validate && !this.validate({ type: "Feature", geometry: i }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: e }) || (this.store.updateGeometry([{ id: this.currentId, geometry: i }]), 0));
|
|
1082
|
+
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));
|
|
1061
1083
|
}
|
|
1062
1084
|
onClick(t) {
|
|
1063
1085
|
if (this.currentCoordinate > 0 && !this.mouseMove && this.onMouseMove(t), this.mouseMove = !1, this.currentCoordinate === 0) {
|
|
@@ -1069,19 +1091,19 @@ class he extends W {
|
|
|
1069
1091
|
const e = this.snappingEnabled ? this.snapping.getSnappableCoordinate(t, this.currentId) : void 0;
|
|
1070
1092
|
e && (t.lng = e[0], t.lat = e[1]);
|
|
1071
1093
|
const i = this.store.getGeometryCopy(this.currentId);
|
|
1072
|
-
if (
|
|
1094
|
+
if (J([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;
|
|
1073
1095
|
this.currentCoordinate++;
|
|
1074
1096
|
} else if (this.currentCoordinate === 2 && this.currentId) {
|
|
1075
1097
|
const e = this.snappingEnabled ? this.snapping.getSnappableCoordinate(t, this.currentId) : void 0;
|
|
1076
1098
|
e && (t.lng = e[0], t.lat = e[1]);
|
|
1077
1099
|
const i = this.store.getGeometryCopy(this.currentId).coordinates[0];
|
|
1078
|
-
if (
|
|
1100
|
+
if (J([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;
|
|
1079
1101
|
this.currentCoordinate === 2 && this.closingPoints.create(i, "polygon"), this.currentCoordinate++;
|
|
1080
1102
|
} else if (this.currentId) {
|
|
1081
1103
|
const e = this.snappingEnabled ? this.snapping.getSnappableCoordinate(t, this.currentId) : void 0, i = this.store.getGeometryCopy(this.currentId).coordinates[0], { isClosing: o, isPreviousClosing: r } = this.closingPoints.isClosingPoint(t);
|
|
1082
1104
|
if (r || o) this.close();
|
|
1083
1105
|
else {
|
|
1084
|
-
if (e && (t.lng = e[0], t.lat = e[1]),
|
|
1106
|
+
if (e && (t.lng = e[0], t.lat = e[1]), J([t.lng, t.lat], i[this.currentCoordinate - 1])) return;
|
|
1085
1107
|
const n = /* @__PURE__ */ function(a = [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]) {
|
|
1086
1108
|
return { type: "Feature", geometry: { type: "Polygon", coordinates: a }, properties: {} };
|
|
1087
1109
|
}([[...i.slice(0, -1), [t.lng, t.lat], i[0]]]);
|
|
@@ -1112,7 +1134,7 @@ class he extends W {
|
|
|
1112
1134
|
}
|
|
1113
1135
|
}
|
|
1114
1136
|
styleFeature(t) {
|
|
1115
|
-
const e =
|
|
1137
|
+
const e = M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
1116
1138
|
if (t.properties.mode === this.mode) {
|
|
1117
1139
|
if (t.geometry.type === "Polygon") return e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10, e;
|
|
1118
1140
|
if (t.geometry.type === "Point") return e.pointWidth = this.getNumericStylingValue(this.styles.closingPointWidth, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(this.styles.closingPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.closingPointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.closingPointOutlineWidth, 2, t), e.zIndex = 30, e;
|
|
@@ -1120,29 +1142,29 @@ class he extends W {
|
|
|
1120
1142
|
return e;
|
|
1121
1143
|
}
|
|
1122
1144
|
validateFeature(t) {
|
|
1123
|
-
return
|
|
1145
|
+
return this.validateModeFeature(t, (e) => vt(e, this.coordinatePrecision));
|
|
1124
1146
|
}
|
|
1125
1147
|
}
|
|
1126
|
-
class
|
|
1148
|
+
class ue extends W {
|
|
1127
1149
|
constructor(t) {
|
|
1128
1150
|
super(t), this.mode = "rectangle", this.center = void 0, this.clickCount = 0, this.currentRectangleId = void 0, this.keyEvents = void 0, this.cursors = void 0;
|
|
1129
1151
|
const e = { start: "crosshair" };
|
|
1130
|
-
if (this.cursors = t && t.cursors ?
|
|
1152
|
+
if (this.cursors = t && t.cursors ? M({}, e, t.cursors) : e, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
|
|
1131
1153
|
else {
|
|
1132
1154
|
const i = { cancel: "Escape", finish: "Enter" };
|
|
1133
|
-
this.keyEvents = t && t.keyEvents ?
|
|
1155
|
+
this.keyEvents = t && t.keyEvents ? M({}, i, t.keyEvents) : i;
|
|
1134
1156
|
}
|
|
1135
1157
|
}
|
|
1136
1158
|
updateRectangle(t, e) {
|
|
1137
1159
|
if (this.clickCount === 1 && this.center && this.currentRectangleId) {
|
|
1138
1160
|
const i = this.store.getGeometryCopy(this.currentRectangleId).coordinates[0][0], o = { type: "Polygon", coordinates: [[i, [t.lng, i[1]], [t.lng, t.lat], [i[0], t.lat], i]] };
|
|
1139
|
-
if (this.validate && !this.validate({ id: this.currentRectangleId, geometry: o }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: e })) return;
|
|
1161
|
+
if (this.validate && !this.validate({ id: this.currentRectangleId, geometry: o }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: e }).valid) return;
|
|
1140
1162
|
this.store.updateGeometry([{ id: this.currentRectangleId, geometry: o }]);
|
|
1141
1163
|
}
|
|
1142
1164
|
}
|
|
1143
1165
|
close() {
|
|
1144
1166
|
const t = this.currentRectangleId;
|
|
1145
|
-
this.center = void 0, this.currentRectangleId = void 0, this.clickCount = 0, this.state === "drawing" && this.setStarted(), t && this.onFinish(t, { mode: this.mode, action: "draw" });
|
|
1167
|
+
this.center = void 0, this.currentRectangleId = void 0, this.clickCount = 0, this.state === "drawing" && this.setStarted(), t !== void 0 && this.onFinish(t, { mode: this.mode, action: "draw" });
|
|
1146
1168
|
}
|
|
1147
1169
|
start() {
|
|
1148
1170
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -1176,14 +1198,14 @@ class de extends W {
|
|
|
1176
1198
|
this.center = void 0, this.currentRectangleId = void 0, this.clickCount = 0, this.state === "drawing" && this.setStarted(), t !== void 0 && this.store.delete([t]);
|
|
1177
1199
|
}
|
|
1178
1200
|
styleFeature(t) {
|
|
1179
|
-
const e =
|
|
1201
|
+
const e = M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
1180
1202
|
return t.type === "Feature" && t.geometry.type === "Polygon" && t.properties.mode === this.mode && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
|
|
1181
1203
|
}
|
|
1182
1204
|
validateFeature(t) {
|
|
1183
|
-
return
|
|
1205
|
+
return this.validateModeFeature(t, (e) => ot(e, this.coordinatePrecision));
|
|
1184
1206
|
}
|
|
1185
1207
|
}
|
|
1186
|
-
class
|
|
1208
|
+
class ht extends W {
|
|
1187
1209
|
constructor(t) {
|
|
1188
1210
|
super({ styles: t.styles }), this.type = U.Render, this.mode = "render", this.mode = t.modeName;
|
|
1189
1211
|
}
|
|
@@ -1216,49 +1238,52 @@ class dt extends W {
|
|
|
1216
1238
|
return { pointColor: this.getHexColorStylingValue(this.styles.pointColor, "#3f97e0", t), pointWidth: this.getNumericStylingValue(this.styles.pointWidth, 6, t), pointOutlineColor: this.getHexColorStylingValue(this.styles.pointOutlineColor, "#ffffff", t), pointOutlineWidth: this.getNumericStylingValue(this.styles.pointOutlineWidth, 0, t), polygonFillColor: this.getHexColorStylingValue(this.styles.polygonFillColor, "#3f97e0", t), polygonFillOpacity: this.getNumericStylingValue(this.styles.polygonFillOpacity, 0.3, t), polygonOutlineColor: this.getHexColorStylingValue(this.styles.polygonOutlineColor, "#3f97e0", t), polygonOutlineWidth: this.getNumericStylingValue(this.styles.polygonOutlineWidth, 4, t), lineStringWidth: this.getNumericStylingValue(this.styles.lineStringWidth, 4, t), lineStringColor: this.getHexColorStylingValue(this.styles.lineStringColor, "#3f97e0", t), zIndex: this.getNumericStylingValue(this.styles.zIndex, 0, t) };
|
|
1217
1239
|
}
|
|
1218
1240
|
validateFeature(t) {
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1241
|
+
const e = super.validateFeature(t);
|
|
1242
|
+
if (e.valid) {
|
|
1243
|
+
const i = t, o = ce(i, this.coordinatePrecision).valid || vt(i, this.coordinatePrecision).valid || le(i, this.coordinatePrecision).valid;
|
|
1244
|
+
return o ? { valid: !0 } : { valid: o, reason: "Feature is not a valid Point, Polygon or LineString feature" };
|
|
1245
|
+
}
|
|
1246
|
+
return e;
|
|
1222
1247
|
}
|
|
1223
1248
|
}
|
|
1224
1249
|
function pt(s, t) {
|
|
1225
1250
|
const e = s, i = t, o = _(e[1]), r = _(i[1]);
|
|
1226
1251
|
let n = _(i[0] - e[0]);
|
|
1227
1252
|
n > Math.PI && (n -= 2 * Math.PI), n < -Math.PI && (n += 2 * Math.PI);
|
|
1228
|
-
const a = Math.log(Math.tan(r / 2 + Math.PI / 4) / Math.tan(o / 2 + Math.PI / 4)), l = (
|
|
1253
|
+
const a = Math.log(Math.tan(r / 2 + Math.PI / 4) / Math.tan(o / 2 + Math.PI / 4)), l = ($(Math.atan2(n, a)) + 360) % 360;
|
|
1229
1254
|
return l > 180 ? -(360 - l) : l;
|
|
1230
1255
|
}
|
|
1231
|
-
function
|
|
1256
|
+
function Ot(s, t, e) {
|
|
1232
1257
|
let i = t;
|
|
1233
1258
|
t < 0 && (i = -Math.abs(i));
|
|
1234
|
-
const o = i /
|
|
1235
|
-
let
|
|
1236
|
-
Math.abs(
|
|
1237
|
-
const
|
|
1259
|
+
const o = i / Et, r = s[0] * Math.PI / 180, n = _(s[1]), a = _(e), l = o * Math.cos(a);
|
|
1260
|
+
let d = n + l;
|
|
1261
|
+
Math.abs(d) > Math.PI / 2 && (d = d > 0 ? Math.PI - d : -Math.PI - d);
|
|
1262
|
+
const c = Math.log(Math.tan(d / 2 + Math.PI / 4) / Math.tan(n / 2 + Math.PI / 4)), h = Math.abs(c) > 1e-11 ? l / c : Math.cos(n), u = [(180 * (r + o * Math.sin(a) / h) / Math.PI + 540) % 360 - 180, 180 * d / Math.PI];
|
|
1238
1263
|
return u[0] += u[0] - s[0] > 180 ? -360 : s[0] - u[0] > 180 ? 360 : 0, u;
|
|
1239
1264
|
}
|
|
1240
|
-
function
|
|
1265
|
+
function ge(s, t, e, i, o) {
|
|
1241
1266
|
const r = i(s[0], s[1]), n = i(t[0], t[1]), { lng: a, lat: l } = o((r.x + n.x) / 2, (r.y + n.y) / 2);
|
|
1242
|
-
return [
|
|
1267
|
+
return [F(a, e), F(l, e)];
|
|
1243
1268
|
}
|
|
1244
|
-
function
|
|
1245
|
-
const i =
|
|
1246
|
-
return [
|
|
1269
|
+
function ze(s, t, e) {
|
|
1270
|
+
const i = Ot(s, 1e3 * G(s, t) / 2, pt(s, t));
|
|
1271
|
+
return [F(i[0], e), F(i[1], e)];
|
|
1247
1272
|
}
|
|
1248
|
-
function
|
|
1273
|
+
function Yt({ featureCoords: s, precision: t, unproject: e, project: i, projection: o }) {
|
|
1249
1274
|
const r = [];
|
|
1250
1275
|
for (let n = 0; n < s.length - 1; n++) {
|
|
1251
1276
|
let a;
|
|
1252
|
-
if (o === "web-mercator") a =
|
|
1277
|
+
if (o === "web-mercator") a = ge(s[n], s[n + 1], t, i, e);
|
|
1253
1278
|
else {
|
|
1254
1279
|
if (o !== "globe") throw new Error("Invalid projection");
|
|
1255
|
-
a =
|
|
1280
|
+
a = ze(s[n], s[n + 1], t);
|
|
1256
1281
|
}
|
|
1257
1282
|
r.push(a);
|
|
1258
1283
|
}
|
|
1259
1284
|
return r;
|
|
1260
1285
|
}
|
|
1261
|
-
class
|
|
1286
|
+
class Ye extends k {
|
|
1262
1287
|
constructor(t, e) {
|
|
1263
1288
|
super(t), this.config = void 0, this.selectionPointBehavior = void 0, this._midPoints = [], this.config = t, this.selectionPointBehavior = e;
|
|
1264
1289
|
}
|
|
@@ -1273,18 +1298,18 @@ class Ae extends O {
|
|
|
1273
1298
|
}
|
|
1274
1299
|
create(t, e, i) {
|
|
1275
1300
|
if (!this.store.has(e)) throw new Error("Store does not have feature with this id");
|
|
1276
|
-
this._midPoints = this.store.create(function(o, r, n, a, l,
|
|
1277
|
-
return
|
|
1278
|
-
}(t, (o) => ({ mode: this.mode, [
|
|
1301
|
+
this._midPoints = this.store.create(function(o, r, n, a, l, d) {
|
|
1302
|
+
return Yt({ featureCoords: o, precision: n, project: a, unproject: l, projection: d }).map((c, h) => ({ geometry: { type: "Point", coordinates: c }, properties: r(h) }));
|
|
1303
|
+
}(t, (o) => ({ mode: this.mode, [tt]: !0, midPointSegment: o, midPointFeatureId: e }), i, this.config.project, this.config.unproject, this.projection));
|
|
1279
1304
|
}
|
|
1280
1305
|
delete() {
|
|
1281
1306
|
this._midPoints.length && (this.store.delete(this._midPoints), this._midPoints = []);
|
|
1282
1307
|
}
|
|
1283
1308
|
getUpdated(t) {
|
|
1284
|
-
if (this._midPoints.length !== 0) return
|
|
1309
|
+
if (this._midPoints.length !== 0) return Yt({ featureCoords: t, precision: this.coordinatePrecision, project: this.config.project, unproject: this.config.unproject, projection: this.config.projection }).map((e, i) => ({ id: this._midPoints[i], geometry: { type: "Point", coordinates: e } }));
|
|
1285
1310
|
}
|
|
1286
1311
|
}
|
|
1287
|
-
class
|
|
1312
|
+
class He extends k {
|
|
1288
1313
|
constructor(t) {
|
|
1289
1314
|
super(t), this._selectionPoints = [];
|
|
1290
1315
|
}
|
|
@@ -1296,7 +1321,7 @@ class Ve extends O {
|
|
|
1296
1321
|
create(t, e, i) {
|
|
1297
1322
|
this._selectionPoints = this.store.create(function(o, r, n) {
|
|
1298
1323
|
const a = [], l = r === "Polygon" ? o.length - 1 : o.length;
|
|
1299
|
-
for (let
|
|
1324
|
+
for (let d = 0; d < l; d++) a.push({ geometry: { type: "Point", coordinates: o[d] }, properties: n(d) });
|
|
1300
1325
|
return a;
|
|
1301
1326
|
}(t, e, (o) => ({ mode: this.mode, selectionPoint: !0, selectionPointFeatureId: i, index: o })));
|
|
1302
1327
|
}
|
|
@@ -1310,54 +1335,54 @@ class Ve extends O {
|
|
|
1310
1335
|
if (this._selectionPoints[t] !== void 0) return { id: this._selectionPoints[t], geometry: { type: "Point", coordinates: e } };
|
|
1311
1336
|
}
|
|
1312
1337
|
}
|
|
1313
|
-
function
|
|
1338
|
+
function pe(s, t) {
|
|
1314
1339
|
let e = !1;
|
|
1315
1340
|
for (let n = 0, a = t.length; n < a; n++) {
|
|
1316
1341
|
const l = t[n];
|
|
1317
|
-
for (let
|
|
1342
|
+
for (let d = 0, c = l.length, h = c - 1; d < c; h = d++) (o = l[d])[1] > (i = s)[1] != (r = l[h])[1] > i[1] && i[0] < (r[0] - o[0]) * (i[1] - o[1]) / (r[1] - o[1]) + o[0] && (e = !e);
|
|
1318
1343
|
}
|
|
1319
1344
|
var i, o, r;
|
|
1320
1345
|
return e;
|
|
1321
1346
|
}
|
|
1322
|
-
const
|
|
1347
|
+
const ye = (s, t, e) => {
|
|
1323
1348
|
const i = (r) => r * r, o = (r, n) => i(r.x - n.x) + i(r.y - n.y);
|
|
1324
1349
|
return Math.sqrt(((r, n, a) => {
|
|
1325
1350
|
const l = o(n, a);
|
|
1326
1351
|
if (l === 0) return o(r, n);
|
|
1327
|
-
let
|
|
1328
|
-
return
|
|
1352
|
+
let d = ((r.x - n.x) * (a.x - n.x) + (r.y - n.y) * (a.y - n.y)) / l;
|
|
1353
|
+
return d = Math.max(0, Math.min(1, d)), o(r, { x: n.x + d * (a.x - n.x), y: n.y + d * (a.y - n.y) });
|
|
1329
1354
|
})(s, t, e));
|
|
1330
1355
|
};
|
|
1331
|
-
class
|
|
1356
|
+
class Je extends k {
|
|
1332
1357
|
constructor(t, e, i) {
|
|
1333
1358
|
super(t), this.config = void 0, this.createClickBoundingBox = void 0, this.pixelDistance = void 0, this.config = t, this.createClickBoundingBox = e, this.pixelDistance = i;
|
|
1334
1359
|
}
|
|
1335
1360
|
find(t, e) {
|
|
1336
|
-
let i, o, r, n, a = 1 / 0, l = 1 / 0,
|
|
1337
|
-
const
|
|
1338
|
-
for (let u = 0; u <
|
|
1339
|
-
const g =
|
|
1361
|
+
let i, o, r, n, a = 1 / 0, l = 1 / 0, d = 1 / 0;
|
|
1362
|
+
const c = this.createClickBoundingBox.create(t), h = this.store.search(c);
|
|
1363
|
+
for (let u = 0; u < h.length; u++) {
|
|
1364
|
+
const g = h[u], p = g.geometry;
|
|
1340
1365
|
if (p.type === "Point") {
|
|
1341
|
-
if (g.properties.selectionPoint || !e && g.properties[
|
|
1366
|
+
if (g.properties.selectionPoint || !e && g.properties[tt]) continue;
|
|
1342
1367
|
const y = this.pixelDistance.measure(t, p.coordinates);
|
|
1343
|
-
g.properties[
|
|
1368
|
+
g.properties[tt] && y < this.pointerDistance && y < d ? (d = y, r = g) : !g.properties[tt] && y < this.pointerDistance && y < a && (a = y, i = g);
|
|
1344
1369
|
} else if (p.type === "LineString") {
|
|
1345
1370
|
if (i) continue;
|
|
1346
1371
|
for (let y = 0; y < p.coordinates.length - 1; y++) {
|
|
1347
|
-
const m = p.coordinates[y], f = p.coordinates[y + 1],
|
|
1348
|
-
|
|
1372
|
+
const m = p.coordinates[y], f = p.coordinates[y + 1], C = ye({ x: t.containerX, y: t.containerY }, this.project(m[0], m[1]), this.project(f[0], f[1]));
|
|
1373
|
+
C < this.pointerDistance && C < l && (l = C, o = g);
|
|
1349
1374
|
}
|
|
1350
1375
|
} else if (p.type === "Polygon") {
|
|
1351
1376
|
if (i || o) continue;
|
|
1352
|
-
|
|
1377
|
+
pe([t.lng, t.lat], p.coordinates) && (n = g);
|
|
1353
1378
|
}
|
|
1354
1379
|
}
|
|
1355
1380
|
return { clickedFeature: i || o || n, clickedMidPoint: r };
|
|
1356
1381
|
}
|
|
1357
1382
|
}
|
|
1358
|
-
class
|
|
1383
|
+
class $e extends k {
|
|
1359
1384
|
constructor(t, e, i, o) {
|
|
1360
|
-
super(t), this.config = void 0, this.
|
|
1385
|
+
super(t), this.config = void 0, this.featuresAtCursorEvent = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.draggedFeatureId = null, this.dragPosition = void 0, this.config = t, this.featuresAtCursorEvent = e, this.selectionPoints = i, this.midPoints = o;
|
|
1361
1386
|
}
|
|
1362
1387
|
startDragging(t, e) {
|
|
1363
1388
|
this.draggedFeatureId = e, this.dragPosition = [t.lng, t.lat];
|
|
@@ -1369,7 +1394,7 @@ class Re extends O {
|
|
|
1369
1394
|
return this.draggedFeatureId !== null;
|
|
1370
1395
|
}
|
|
1371
1396
|
canDrag(t, e) {
|
|
1372
|
-
const { clickedFeature: i } = this.
|
|
1397
|
+
const { clickedFeature: i } = this.featuresAtCursorEvent.find(t, !0);
|
|
1373
1398
|
return !(!i || i.id !== e);
|
|
1374
1399
|
}
|
|
1375
1400
|
drag(t, e) {
|
|
@@ -1378,19 +1403,27 @@ class Re extends O {
|
|
|
1378
1403
|
if (i.type === "Polygon" || i.type === "LineString") {
|
|
1379
1404
|
let r, n;
|
|
1380
1405
|
if (i.type === "Polygon" ? (r = i.coordinates[0], n = r.length - 1) : (r = i.coordinates, n = r.length), !this.dragPosition) return !1;
|
|
1381
|
-
for (let
|
|
1382
|
-
const
|
|
1383
|
-
|
|
1384
|
-
|
|
1406
|
+
for (let d = 0; d < n; d++) {
|
|
1407
|
+
const c = r[d];
|
|
1408
|
+
let h, u;
|
|
1409
|
+
if (this.config.projection === "web-mercator") {
|
|
1410
|
+
const g = x(this.dragPosition[0], this.dragPosition[1]), p = x(o[0], o[1]), y = x(c[0], c[1]), m = { x: g.x - p.x, y: g.y - p.y }, f = y.x - m.x, C = y.y - m.y, { lng: v, lat: P } = O(f, C);
|
|
1411
|
+
h = v, u = P;
|
|
1412
|
+
} else {
|
|
1413
|
+
const g = [this.dragPosition[0] - o[0], this.dragPosition[1] - o[1]];
|
|
1414
|
+
h = c[0] - g[0], u = c[1] - g[1];
|
|
1415
|
+
}
|
|
1416
|
+
if (h = F(h, this.config.coordinatePrecision), u = F(u, this.config.coordinatePrecision), h > 180 || h < -180 || u > 90 || u < -90) return !1;
|
|
1417
|
+
r[d] = [h, u];
|
|
1385
1418
|
}
|
|
1386
1419
|
i.type === "Polygon" && (r[r.length - 1] = [r[0][0], r[0][1]]);
|
|
1387
1420
|
const a = this.selectionPoints.getUpdated(r) || [], l = this.midPoints.getUpdated(r) || [];
|
|
1388
|
-
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 })) return !1;
|
|
1421
|
+
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;
|
|
1389
1422
|
this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: i }, ...a, ...l]), this.dragPosition = [t.lng, t.lat];
|
|
1390
1423
|
} else i.type === "Point" && (this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: { type: "Point", coordinates: o } }]), this.dragPosition = [t.lng, t.lat]);
|
|
1391
1424
|
}
|
|
1392
1425
|
}
|
|
1393
|
-
class
|
|
1426
|
+
class qe extends k {
|
|
1394
1427
|
constructor(t, e, i, o) {
|
|
1395
1428
|
super(t), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.draggedCoordinate = { id: null, index: -1 }, this.config = t, this.pixelDistance = e, this.selectionPoints = i, this.midPoints = o;
|
|
1396
1429
|
}
|
|
@@ -1421,11 +1454,11 @@ class Te extends O {
|
|
|
1421
1454
|
if (t.lng > 180 || t.lng < -180 || t.lat > 90 || t.lat < -90) return !1;
|
|
1422
1455
|
if (r.type !== "Polygon" || o !== n.length - 1 && o !== 0) n[o] = a;
|
|
1423
1456
|
else {
|
|
1424
|
-
const
|
|
1425
|
-
n[0] = a, n[
|
|
1457
|
+
const h = n.length - 1;
|
|
1458
|
+
n[0] = a, n[h] = a;
|
|
1426
1459
|
}
|
|
1427
|
-
const l = this.selectionPoints.getOneUpdated(o, a),
|
|
1428
|
-
return !(r.type !== "Point" && !e &&
|
|
1460
|
+
const l = this.selectionPoints.getOneUpdated(o, a), d = l ? [l] : [], c = this.midPoints.getUpdated(n) || [];
|
|
1461
|
+
return !(r.type !== "Point" && !e && It({ type: "Feature", geometry: r, properties: {} }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: r, 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: r }, ...d, ...c]), 0));
|
|
1429
1462
|
}
|
|
1430
1463
|
isDragging() {
|
|
1431
1464
|
return this.draggedCoordinate.id !== null;
|
|
@@ -1443,9 +1476,9 @@ function yt(s) {
|
|
|
1443
1476
|
t += o[0], e += o[1], i++;
|
|
1444
1477
|
}, !0), [t / i, e / i];
|
|
1445
1478
|
}
|
|
1446
|
-
function
|
|
1479
|
+
function fe(s, t) {
|
|
1447
1480
|
s[0] += s[0] - t[0] > 180 ? -360 : t[0] - s[0] > 180 ? 360 : 0;
|
|
1448
|
-
const e =
|
|
1481
|
+
const e = Et, i = t[1] * Math.PI / 180, o = s[1] * Math.PI / 180, r = o - i;
|
|
1449
1482
|
let n = Math.abs(s[0] - t[0]) * Math.PI / 180;
|
|
1450
1483
|
n > Math.PI && (n -= 2 * Math.PI);
|
|
1451
1484
|
const a = Math.log(Math.tan(o / 2 + Math.PI / 4) / Math.tan(i / 2 + Math.PI / 4)), l = Math.abs(a) > 1e-11 ? r / a : Math.cos(i);
|
|
@@ -1453,15 +1486,15 @@ function ye(s, t) {
|
|
|
1453
1486
|
}
|
|
1454
1487
|
function ft(s) {
|
|
1455
1488
|
const t = (s.geometry.type === "Polygon" ? s.geometry.coordinates[0] : s.geometry.coordinates).map((e) => {
|
|
1456
|
-
const { x: i, y: o } =
|
|
1489
|
+
const { x: i, y: o } = x(e[0], e[1]);
|
|
1457
1490
|
return [i, o];
|
|
1458
1491
|
});
|
|
1459
1492
|
return s.geometry.type === "Polygon" ? function(e) {
|
|
1460
1493
|
let i = 0, o = 0, r = 0;
|
|
1461
1494
|
const n = e.length;
|
|
1462
1495
|
for (let a = 0; a < n - 1; a++) {
|
|
1463
|
-
const [l,
|
|
1464
|
-
i += u, o += (l +
|
|
1496
|
+
const [l, d] = e[a], [c, h] = e[a + 1], u = l * h - c * d;
|
|
1497
|
+
i += u, o += (l + c) * u, r += (d + h) * u;
|
|
1465
1498
|
}
|
|
1466
1499
|
return i /= 2, o /= 6 * i, r /= 6 * i, { x: o, y: r };
|
|
1467
1500
|
}(t) : function(e) {
|
|
@@ -1474,7 +1507,7 @@ function ft(s) {
|
|
|
1474
1507
|
return { x: o / i, y: r / i };
|
|
1475
1508
|
}(t);
|
|
1476
1509
|
}
|
|
1477
|
-
class
|
|
1510
|
+
class Ze extends k {
|
|
1478
1511
|
constructor(t, e, i) {
|
|
1479
1512
|
super(t), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastBearing = void 0, this.config = t, this.selectionPoints = e, this.midPoints = i;
|
|
1480
1513
|
}
|
|
@@ -1488,36 +1521,36 @@ class Xe extends O {
|
|
|
1488
1521
|
let n;
|
|
1489
1522
|
const a = { type: "Feature", geometry: o, properties: {} };
|
|
1490
1523
|
if (this.config.projection === "web-mercator") {
|
|
1491
|
-
if (n = j(ft(a),
|
|
1492
|
-
((
|
|
1493
|
-
if (u === 0 || u === 360 || u === -360) return
|
|
1494
|
-
const g = 0.017453292519943295 * u, p = (
|
|
1524
|
+
if (n = j(ft(a), x(t.lng, t.lat)), !this.lastBearing) return void (this.lastBearing = n);
|
|
1525
|
+
((h, u) => {
|
|
1526
|
+
if (u === 0 || u === 360 || u === -360) return h;
|
|
1527
|
+
const g = 0.017453292519943295 * u, p = (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).map(([f, C]) => x(f, C)), y = p.reduce((f, C) => ({ x: f.x + C.x, y: f.y + C.y }), { x: 0, y: 0 });
|
|
1495
1528
|
y.x /= p.length, y.y /= p.length;
|
|
1496
|
-
const m = p.map((f) => ({ x: y.x + (f.x - y.x) * Math.cos(g) - (f.y - y.y) * Math.sin(g), y: y.y + (f.x - y.x) * Math.sin(g) + (f.y - y.y) * Math.cos(g) })).map(({ x: f, y:
|
|
1497
|
-
|
|
1529
|
+
const m = p.map((f) => ({ x: y.x + (f.x - y.x) * Math.cos(g) - (f.y - y.y) * Math.sin(g), y: y.y + (f.x - y.x) * Math.sin(g) + (f.y - y.y) * Math.cos(g) })).map(({ x: f, y: C }) => [O(f, C).lng, O(f, C).lat]);
|
|
1530
|
+
h.geometry.type === "Polygon" ? h.geometry.coordinates[0] = m : h.geometry.coordinates = m;
|
|
1498
1531
|
})(a, -(this.lastBearing - n));
|
|
1499
1532
|
} else {
|
|
1500
1533
|
if (this.config.projection !== "globe") throw new Error("Unsupported projection");
|
|
1501
1534
|
if (n = pt(yt({ type: "Feature", geometry: o, properties: {} }), r), !this.lastBearing) return void (this.lastBearing = n + 180);
|
|
1502
|
-
(function(
|
|
1503
|
-
if (u === 0 || u === 360 || u === -360) return
|
|
1504
|
-
const g = yt(
|
|
1505
|
-
(
|
|
1506
|
-
const y = pt(g, p) + u, m =
|
|
1535
|
+
(function(h, u) {
|
|
1536
|
+
if (u === 0 || u === 360 || u === -360) return h;
|
|
1537
|
+
const g = yt(h);
|
|
1538
|
+
(h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).forEach((p) => {
|
|
1539
|
+
const y = pt(g, p) + u, m = fe(g, p), f = Ot(g, m, y);
|
|
1507
1540
|
p[0] = f[0], p[1] = f[1];
|
|
1508
1541
|
});
|
|
1509
1542
|
})(a, -(this.lastBearing - (n + 180)));
|
|
1510
1543
|
}
|
|
1511
1544
|
const l = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
|
|
1512
|
-
l.forEach((
|
|
1513
|
-
|
|
1545
|
+
l.forEach((h) => {
|
|
1546
|
+
h[0] = F(h[0], this.coordinatePrecision), h[1] = F(h[1], this.coordinatePrecision);
|
|
1514
1547
|
});
|
|
1515
|
-
const
|
|
1548
|
+
const d = this.midPoints.getUpdated(l) || [], c = this.selectionPoints.getUpdated(l) || [];
|
|
1516
1549
|
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;
|
|
1517
|
-
this.store.updateGeometry([{ id: e, geometry: o }, ...
|
|
1550
|
+
this.store.updateGeometry([{ id: e, geometry: o }, ...c, ...d]), this.projection === "web-mercator" ? this.lastBearing = n : this.projection === "globe" && (this.lastBearing = n + 180);
|
|
1518
1551
|
}
|
|
1519
1552
|
}
|
|
1520
|
-
class
|
|
1553
|
+
class Qe extends k {
|
|
1521
1554
|
constructor(t, e, i) {
|
|
1522
1555
|
super(t), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastDistance = void 0, this.config = t, this.selectionPoints = e, this.midPoints = i;
|
|
1523
1556
|
}
|
|
@@ -1531,37 +1564,37 @@ class Ke extends O {
|
|
|
1531
1564
|
let a;
|
|
1532
1565
|
const l = ft(n);
|
|
1533
1566
|
if (this.config.projection === "web-mercator") {
|
|
1534
|
-
const g =
|
|
1535
|
-
a =
|
|
1567
|
+
const g = x(t.lng, t.lat);
|
|
1568
|
+
a = I(l, g);
|
|
1536
1569
|
} else {
|
|
1537
1570
|
if (this.config.projection !== "globe") throw new Error("Invalid projection");
|
|
1538
1571
|
a = G(yt({ type: "Feature", geometry: o, properties: {} }), r);
|
|
1539
1572
|
}
|
|
1540
1573
|
if (!this.lastDistance) return void (this.lastDistance = a);
|
|
1541
|
-
const
|
|
1574
|
+
const d = 1 - (this.lastDistance - a) / a;
|
|
1542
1575
|
if (this.config.projection === "web-mercator") {
|
|
1543
|
-
const { lng: g, lat: p } =
|
|
1576
|
+
const { lng: g, lat: p } = O(l.x, l.y);
|
|
1544
1577
|
(function(y, m, f) {
|
|
1545
1578
|
if (m === 1) return y;
|
|
1546
|
-
const
|
|
1547
|
-
y.geometry.type === "Polygon" ? y.geometry.coordinates[0] =
|
|
1548
|
-
})(n,
|
|
1579
|
+
const C = (y.geometry.type === "Polygon" ? y.geometry.coordinates[0] : y.geometry.coordinates).map(([S, w]) => x(S, w)), v = x(f[0], f[1]), P = C.map((S) => ({ x: v.x + (S.x - v.x) * m, y: v.y + (S.y - v.y) * m })).map(({ x: S, y: w }) => [O(S, w).lng, O(S, w).lat]);
|
|
1580
|
+
y.geometry.type === "Polygon" ? y.geometry.coordinates[0] = P : y.geometry.coordinates = P;
|
|
1581
|
+
})(n, d, [g, p]);
|
|
1549
1582
|
} else this.config.projection === "globe" && function(g, p, y, m = "xy") {
|
|
1550
1583
|
p === 1 || (g.geometry.type === "Polygon" ? g.geometry.coordinates[0] : g.geometry.coordinates).forEach((f) => {
|
|
1551
|
-
const
|
|
1552
|
-
m !== "x" && m !== "xy" || (f[0] =
|
|
1584
|
+
const C = fe(y, f), v = pt(y, f), P = Ot(y, C * p, v);
|
|
1585
|
+
m !== "x" && m !== "xy" || (f[0] = P[0]), m !== "y" && m !== "xy" || (f[1] = P[1]);
|
|
1553
1586
|
});
|
|
1554
|
-
}(n,
|
|
1555
|
-
const
|
|
1556
|
-
|
|
1557
|
-
g[0] =
|
|
1587
|
+
}(n, d, yt(n));
|
|
1588
|
+
const c = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
|
|
1589
|
+
c.forEach((g) => {
|
|
1590
|
+
g[0] = F(g[0], this.coordinatePrecision), g[1] = F(g[1], this.coordinatePrecision);
|
|
1558
1591
|
});
|
|
1559
|
-
const
|
|
1592
|
+
const h = this.midPoints.getUpdated(c) || [], u = this.selectionPoints.getUpdated(c) || [];
|
|
1560
1593
|
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;
|
|
1561
|
-
this.store.updateGeometry([{ id: e, geometry: o }, ...u, ...
|
|
1594
|
+
this.store.updateGeometry([{ id: e, geometry: o }, ...u, ...h]), this.lastDistance = a;
|
|
1562
1595
|
}
|
|
1563
1596
|
}
|
|
1564
|
-
class
|
|
1597
|
+
class ti extends k {
|
|
1565
1598
|
constructor(t, e, i, o) {
|
|
1566
1599
|
super(t), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.minimumScale = 1e-4, this.draggedCoordinate = { id: null, index: -1 }, this.boundingBoxMaps = { opposite: { 0: 4, 1: 5, 2: 6, 3: 7, 4: 0, 5: 1, 6: 2, 7: 3 } }, this.config = t, this.pixelDistance = e, this.selectionPoints = i, this.midPoints = o;
|
|
1567
1600
|
}
|
|
@@ -1622,41 +1655,41 @@ class ze extends O {
|
|
|
1622
1655
|
if (!e) return null;
|
|
1623
1656
|
const { feature: i, boundingBox: o, updatedCoords: r, selectedCoordinate: n } = e, a = ft(i);
|
|
1624
1657
|
if (!a) return null;
|
|
1625
|
-
const l =
|
|
1626
|
-
return this.scaleWebMercator({ closestBBoxIndex:
|
|
1658
|
+
const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), c = x(t.lng, t.lat);
|
|
1659
|
+
return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: r, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), r;
|
|
1627
1660
|
}
|
|
1628
1661
|
centerFixedWebMercatorDrag(t) {
|
|
1629
1662
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1630
1663
|
if (!e) return null;
|
|
1631
1664
|
const { feature: i, boundingBox: o, updatedCoords: r, selectedCoordinate: n } = e, a = ft(i);
|
|
1632
1665
|
if (!a) return null;
|
|
1633
|
-
const l =
|
|
1634
|
-
return this.scaleFixedWebMercator({ closestBBoxIndex:
|
|
1666
|
+
const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), c = x(t.lng, t.lat);
|
|
1667
|
+
return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: r, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), r;
|
|
1635
1668
|
}
|
|
1636
1669
|
scaleFixedWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: r }) {
|
|
1637
1670
|
if (!this.isValidDragWebMercator(t, e.x - o.x, e.y - o.y)) return null;
|
|
1638
|
-
let n =
|
|
1671
|
+
let n = I(e, o) / I(e, i);
|
|
1639
1672
|
return n < 0 && (n = this.minimumScale), this.performWebMercatorScale(r, e.x, e.y, n, n), r;
|
|
1640
1673
|
}
|
|
1641
1674
|
oppositeFixedWebMercatorDrag(t) {
|
|
1642
1675
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1643
1676
|
if (!e) return null;
|
|
1644
|
-
const { boundingBox: i, updatedCoords: o, selectedCoordinate: r } = e, n =
|
|
1645
|
-
return this.scaleFixedWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor:
|
|
1677
|
+
const { boundingBox: i, updatedCoords: o, selectedCoordinate: r } = e, n = x(r[0], r[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] }, c = x(t.lng, t.lat);
|
|
1678
|
+
return this.scaleFixedWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: n, webMercatorOrigin: d }), o;
|
|
1646
1679
|
}
|
|
1647
1680
|
oppositeWebMercatorDrag(t) {
|
|
1648
1681
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1649
1682
|
if (!e) return null;
|
|
1650
|
-
const { boundingBox: i, updatedCoords: o, selectedCoordinate: r } = e, n =
|
|
1651
|
-
return this.scaleWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor:
|
|
1683
|
+
const { boundingBox: i, updatedCoords: o, selectedCoordinate: r } = e, n = x(r[0], r[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] }, c = x(t.lng, t.lat);
|
|
1684
|
+
return this.scaleWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: n, webMercatorOrigin: d }), o;
|
|
1652
1685
|
}
|
|
1653
1686
|
scaleWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: r }) {
|
|
1654
1687
|
const n = e.x - o.x, a = e.y - o.y;
|
|
1655
1688
|
if (!this.isValidDragWebMercator(t, n, a)) return null;
|
|
1656
1689
|
let l = 1;
|
|
1657
1690
|
n !== 0 && t !== 1 && t !== 5 && (l = 1 - (e.x - i.x - n) / n);
|
|
1658
|
-
let
|
|
1659
|
-
return a !== 0 && t !== 3 && t !== 7 && (
|
|
1691
|
+
let d = 1;
|
|
1692
|
+
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(r, e.x, e.y, l, d), r) : null;
|
|
1660
1693
|
}
|
|
1661
1694
|
getFeature(t) {
|
|
1662
1695
|
if (this.draggedCoordinate.id === null) return null;
|
|
@@ -1672,15 +1705,15 @@ class ze extends O {
|
|
|
1672
1705
|
}
|
|
1673
1706
|
performWebMercatorScale(t, e, i, o, r) {
|
|
1674
1707
|
t.forEach((n) => {
|
|
1675
|
-
const { x: a, y: l } =
|
|
1676
|
-
n[0] =
|
|
1708
|
+
const { x: a, y: l } = x(n[0], n[1]), d = e + (a - e) * o, c = i + (l - i) * r, { lng: h, lat: u } = O(d, c);
|
|
1709
|
+
n[0] = h, n[1] = u;
|
|
1677
1710
|
});
|
|
1678
1711
|
}
|
|
1679
1712
|
getBBoxWebMercator(t) {
|
|
1680
1713
|
const e = [1 / 0, 1 / 0, -1 / 0, -1 / 0];
|
|
1681
1714
|
(t = t.map((a) => {
|
|
1682
|
-
const { x: l, y:
|
|
1683
|
-
return [l,
|
|
1715
|
+
const { x: l, y: d } = x(a[0], a[1]);
|
|
1716
|
+
return [l, d];
|
|
1684
1717
|
})).forEach(([a, l]) => {
|
|
1685
1718
|
a < e[0] && (e[0] = a), l < e[1] && (e[1] = l), a > e[2] && (e[2] = a), l > e[3] && (e[3] = l);
|
|
1686
1719
|
});
|
|
@@ -1690,7 +1723,7 @@ class ze extends O {
|
|
|
1690
1723
|
getIndexesWebMercator(t, e) {
|
|
1691
1724
|
let i, o = 1 / 0;
|
|
1692
1725
|
for (let r = 0; r < t.length; r++) {
|
|
1693
|
-
const n =
|
|
1726
|
+
const n = I({ x: e.x, y: e.y }, { x: t[r][0], y: t[r][1] });
|
|
1694
1727
|
n < o && (i = r, o = n);
|
|
1695
1728
|
}
|
|
1696
1729
|
if (i === void 0) throw new Error("No closest coordinate found");
|
|
@@ -1715,23 +1748,23 @@ class ze extends O {
|
|
|
1715
1748
|
if (!o) return !1;
|
|
1716
1749
|
let r = null;
|
|
1717
1750
|
if (e === "center" ? r = this.centerWebMercatorDrag(t) : e === "opposite" ? r = this.oppositeWebMercatorDrag(t) : e === "center-fixed" ? r = this.centerFixedWebMercatorDrag(t) : e === "opposite-fixed" && (r = this.oppositeFixedWebMercatorDrag(t)), !r) return !1;
|
|
1718
|
-
for (let
|
|
1719
|
-
const
|
|
1720
|
-
if (
|
|
1751
|
+
for (let d = 0; d < r.length; d++) {
|
|
1752
|
+
const c = r[d];
|
|
1753
|
+
if (c[0] = F(c[0], this.coordinatePrecision), c[1] = F(c[1], this.coordinatePrecision), !mt(c, this.coordinatePrecision)) return !1;
|
|
1721
1754
|
}
|
|
1722
1755
|
const n = this.midPoints.getUpdated(r) || [], a = this.selectionPoints.getUpdated(r) || [], l = { type: o.geometry.type, coordinates: o.geometry.type === "Polygon" ? [r] : r };
|
|
1723
|
-
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 }) || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: l }, ...a, ...n]), 0));
|
|
1756
|
+
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));
|
|
1724
1757
|
}
|
|
1725
1758
|
}
|
|
1726
|
-
class
|
|
1759
|
+
class ei extends Le {
|
|
1727
1760
|
constructor(t) {
|
|
1728
1761
|
var e;
|
|
1729
1762
|
super(t), this.mode = "select", this.allowManualDeselection = !0, this.dragEventThrottle = 5, this.dragEventCount = 0, this.selected = [], this.flags = void 0, this.keyEvents = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.featuresAtMouseEvent = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.dragFeature = void 0, this.dragCoordinate = void 0, this.rotateFeature = void 0, this.scaleFeature = void 0, this.dragCoordinateResizeFeature = void 0, this.cursors = void 0, this.validations = {}, this.flags = t && t.flags ? t.flags : {};
|
|
1730
1763
|
const i = { pointerOver: "move", dragStart: "move", dragEnd: "move", insertMidpoint: "crosshair" };
|
|
1731
|
-
if (this.cursors = t && t.cursors ?
|
|
1764
|
+
if (this.cursors = t && t.cursors ? M({}, i, t.cursors) : i, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { deselect: null, delete: null, rotate: null, scale: null };
|
|
1732
1765
|
else {
|
|
1733
1766
|
const o = { deselect: "Escape", delete: "Delete", rotate: ["Control", "r"], scale: ["Control", "s"] };
|
|
1734
|
-
this.keyEvents = t && t.keyEvents ?
|
|
1767
|
+
this.keyEvents = t && t.keyEvents ? M({}, o, t.keyEvents) : o;
|
|
1735
1768
|
}
|
|
1736
1769
|
if (this.dragEventThrottle = t && t.dragEventThrottle !== void 0 && t.dragEventThrottle || 5, this.allowManualDeselection = (e = t == null ? void 0 : t.allowManualDeselection) == null || e, t && t.flags && t.flags) for (const o in t.flags) {
|
|
1737
1770
|
const r = t.flags[o].feature;
|
|
@@ -1746,13 +1779,13 @@ class Ye extends ke {
|
|
|
1746
1779
|
this._state = "selecting";
|
|
1747
1780
|
}
|
|
1748
1781
|
registerBehaviors(t) {
|
|
1749
|
-
this.pixelDistance = new
|
|
1782
|
+
this.pixelDistance = new Dt(t), this.clickBoundingBox = new _t(t), this.featuresAtMouseEvent = new Je(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new He(t), this.midPoints = new Ye(t, this.selectionPoints), this.rotateFeature = new Ze(t, this.selectionPoints, this.midPoints), this.scaleFeature = new Qe(t, this.selectionPoints, this.midPoints), this.dragFeature = new $e(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints), this.dragCoordinate = new qe(t, this.pixelDistance, this.selectionPoints, this.midPoints), this.dragCoordinateResizeFeature = new ti(t, this.pixelDistance, this.selectionPoints, this.midPoints);
|
|
1750
1783
|
}
|
|
1751
1784
|
deselectFeature() {
|
|
1752
1785
|
this.deselect();
|
|
1753
1786
|
}
|
|
1754
1787
|
deselect() {
|
|
1755
|
-
const t = this.selected.filter((e) => this.store.has(e)).map((e) => ({ id: e, property:
|
|
1788
|
+
const t = this.selected.filter((e) => this.store.has(e)).map((e) => ({ id: e, property: wt, value: !1 }));
|
|
1756
1789
|
this.store.updateProperty(t), this.onDeselect(this.selected[0]), this.selected = [], this.selectionPoints.delete(), this.midPoints.delete();
|
|
1757
1790
|
}
|
|
1758
1791
|
deleteSelected() {
|
|
@@ -1761,20 +1794,20 @@ class Ye extends ke {
|
|
|
1761
1794
|
onRightClick(t) {
|
|
1762
1795
|
if (!this.selectionPoints.ids.length) return;
|
|
1763
1796
|
let e, i = 1 / 0;
|
|
1764
|
-
if (this.selectionPoints.ids.forEach((
|
|
1765
|
-
const u = this.store.getGeometryCopy(
|
|
1766
|
-
g < this.pointerDistance && g < i && (i = g, e = this.store.getPropertiesCopy(
|
|
1797
|
+
if (this.selectionPoints.ids.forEach((h) => {
|
|
1798
|
+
const u = this.store.getGeometryCopy(h), g = this.pixelDistance.measure(t, u.coordinates);
|
|
1799
|
+
g < this.pointerDistance && g < i && (i = g, e = this.store.getPropertiesCopy(h));
|
|
1767
1800
|
}), !e) return;
|
|
1768
1801
|
const o = e.selectionPointFeatureId, r = e.index, n = this.store.getPropertiesCopy(o), a = this.flags[n.mode], l = this.validations[n.mode];
|
|
1769
1802
|
if (!(a && a.feature && a.feature.coordinates && a.feature.coordinates.deletable)) return;
|
|
1770
|
-
const
|
|
1771
|
-
let
|
|
1772
|
-
if (
|
|
1773
|
-
if (
|
|
1774
|
-
} else if (
|
|
1775
|
-
if (
|
|
1776
|
-
if (
|
|
1777
|
-
this.store.delete([...this.midPoints.ids, ...this.selectionPoints.ids]), this.store.updateGeometry([{ id: o, geometry:
|
|
1803
|
+
const d = this.store.getGeometryCopy(o);
|
|
1804
|
+
let c;
|
|
1805
|
+
if (d.type === "Polygon") {
|
|
1806
|
+
if (c = d.coordinates[0], c.length <= 4) return;
|
|
1807
|
+
} else if (d.type === "LineString" && (c = d.coordinates, c.length <= 3)) return;
|
|
1808
|
+
if (c) {
|
|
1809
|
+
if (d.type === "Polygon" && r === 0 || r === c.length - 1 ? (c.shift(), c.pop(), c.push([c[0][0], c[0][1]])) : c.splice(r, 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;
|
|
1810
|
+
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);
|
|
1778
1811
|
}
|
|
1779
1812
|
}
|
|
1780
1813
|
select(t, e = !0) {
|
|
@@ -1872,11 +1905,11 @@ class Ye extends ke {
|
|
|
1872
1905
|
this.setCursor(this.selected.length > 0 && (o && o.id === this.selected[0] || i) ? this.cursors.pointerOver : "unset");
|
|
1873
1906
|
}
|
|
1874
1907
|
styleFeature(t) {
|
|
1875
|
-
const e =
|
|
1908
|
+
const e = M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
1876
1909
|
if (t.properties.mode === this.mode && t.geometry.type === "Point") {
|
|
1877
1910
|
if (t.properties.selectionPoint) return e.pointColor = this.getHexColorStylingValue(this.styles.selectionPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.selectionPointOutlineColor, e.pointOutlineColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.selectionPointWidth, e.pointWidth, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.selectionPointOutlineWidth, 2, t), e.zIndex = 30, e;
|
|
1878
1911
|
if (t.properties.midPoint) return e.pointColor = this.getHexColorStylingValue(this.styles.midPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.midPointOutlineColor, e.pointOutlineColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.midPointWidth, 4, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.midPointOutlineWidth, 2, t), e.zIndex = 40, e;
|
|
1879
|
-
} else if (t.properties[
|
|
1912
|
+
} else if (t.properties[wt]) {
|
|
1880
1913
|
if (t.geometry.type === "Polygon") return e.polygonFillColor = this.getHexColorStylingValue(this.styles.selectedPolygonColor, e.polygonFillColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.selectedPolygonOutlineWidth, e.polygonOutlineWidth, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.selectedPolygonOutlineColor, e.polygonOutlineColor, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.selectedPolygonFillOpacity, e.polygonFillOpacity, t), e.zIndex = 10, e;
|
|
1881
1914
|
if (t.geometry.type === "LineString") return e.lineStringColor = this.getHexColorStylingValue(this.styles.selectedLineStringColor, e.lineStringColor, t), e.lineStringWidth = this.getNumericStylingValue(this.styles.selectedLineStringWidth, e.lineStringWidth, t), e.zIndex = 10, e;
|
|
1882
1915
|
if (t.geometry.type === "Point") return e.pointWidth = this.getNumericStylingValue(this.styles.selectedPointWidth, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(this.styles.selectedPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.selectedPointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.selectedPointOutlineWidth, e.pointOutlineWidth, t), e.zIndex = 10, e;
|
|
@@ -1884,7 +1917,7 @@ class Ye extends ke {
|
|
|
1884
1917
|
return e;
|
|
1885
1918
|
}
|
|
1886
1919
|
}
|
|
1887
|
-
class
|
|
1920
|
+
class ii extends W {
|
|
1888
1921
|
constructor(...t) {
|
|
1889
1922
|
super(...t), this.type = U.Static, this.mode = "static";
|
|
1890
1923
|
}
|
|
@@ -1909,88 +1942,88 @@ class He extends W {
|
|
|
1909
1942
|
cleanUp() {
|
|
1910
1943
|
}
|
|
1911
1944
|
styleFeature() {
|
|
1912
|
-
return
|
|
1945
|
+
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 });
|
|
1913
1946
|
}
|
|
1914
1947
|
}
|
|
1915
|
-
function
|
|
1948
|
+
function me(s, t, e, i, o) {
|
|
1916
1949
|
for (; i > e; ) {
|
|
1917
1950
|
if (i - e > 600) {
|
|
1918
|
-
const l = i - e + 1,
|
|
1919
|
-
|
|
1951
|
+
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);
|
|
1952
|
+
me(s, t, Math.max(e, Math.floor(t - d * h / l + u)), Math.min(i, Math.floor(t + (l - d) * h / l + u)), o);
|
|
1920
1953
|
}
|
|
1921
1954
|
const r = s[t];
|
|
1922
1955
|
let n = e, a = i;
|
|
1923
|
-
for (
|
|
1924
|
-
for (
|
|
1956
|
+
for (q(s, e, t), o(s[i], r) > 0 && q(s, e, i); n < a; ) {
|
|
1957
|
+
for (q(s, n, a), n++, a--; o(s[n], r) < 0; ) n++;
|
|
1925
1958
|
for (; o(s[a], r) > 0; ) a--;
|
|
1926
1959
|
}
|
|
1927
|
-
o(s[e], r) === 0 ?
|
|
1960
|
+
o(s[e], r) === 0 ? q(s, e, a) : (a++, q(s, a, i)), a <= t && (e = a + 1), t <= a && (i = a - 1);
|
|
1928
1961
|
}
|
|
1929
1962
|
}
|
|
1930
|
-
function
|
|
1963
|
+
function q(s, t, e) {
|
|
1931
1964
|
const i = s[t];
|
|
1932
1965
|
s[t] = s[e], s[e] = i;
|
|
1933
1966
|
}
|
|
1934
|
-
function
|
|
1935
|
-
|
|
1967
|
+
function z(s, t) {
|
|
1968
|
+
Z(s, 0, s.children.length, t, s);
|
|
1936
1969
|
}
|
|
1937
|
-
function
|
|
1938
|
-
o || (o =
|
|
1970
|
+
function Z(s, t, e, i, o) {
|
|
1971
|
+
o || (o = Y([])), o.minX = 1 / 0, o.minY = 1 / 0, o.maxX = -1 / 0, o.maxY = -1 / 0;
|
|
1939
1972
|
for (let r = t; r < e; r++) {
|
|
1940
1973
|
const n = s.children[r];
|
|
1941
|
-
|
|
1974
|
+
Q(o, s.leaf ? i(n) : n);
|
|
1942
1975
|
}
|
|
1943
1976
|
return o;
|
|
1944
1977
|
}
|
|
1945
|
-
function
|
|
1978
|
+
function Q(s, t) {
|
|
1946
1979
|
return s.minX = Math.min(s.minX, t.minX), s.minY = Math.min(s.minY, t.minY), s.maxX = Math.max(s.maxX, t.maxX), s.maxY = Math.max(s.maxY, t.maxY), s;
|
|
1947
1980
|
}
|
|
1948
|
-
function
|
|
1981
|
+
function oi(s, t) {
|
|
1949
1982
|
return s.minX - t.minX;
|
|
1950
1983
|
}
|
|
1951
|
-
function
|
|
1984
|
+
function ri(s, t) {
|
|
1952
1985
|
return s.minY - t.minY;
|
|
1953
1986
|
}
|
|
1954
|
-
function
|
|
1987
|
+
function St(s) {
|
|
1955
1988
|
return (s.maxX - s.minX) * (s.maxY - s.minY);
|
|
1956
1989
|
}
|
|
1957
1990
|
function lt(s) {
|
|
1958
1991
|
return s.maxX - s.minX + (s.maxY - s.minY);
|
|
1959
1992
|
}
|
|
1960
|
-
function
|
|
1993
|
+
function si(s, t) {
|
|
1961
1994
|
const e = Math.max(s.minX, t.minX), i = Math.max(s.minY, t.minY), o = Math.min(s.maxX, t.maxX), r = Math.min(s.maxY, t.maxY);
|
|
1962
1995
|
return Math.max(0, o - e) * Math.max(0, r - i);
|
|
1963
1996
|
}
|
|
1964
|
-
function
|
|
1997
|
+
function Mt(s, t) {
|
|
1965
1998
|
return s.minX <= t.minX && s.minY <= t.minY && t.maxX <= s.maxX && t.maxY <= s.maxY;
|
|
1966
1999
|
}
|
|
1967
|
-
function
|
|
2000
|
+
function dt(s, t) {
|
|
1968
2001
|
return t.minX <= s.maxX && t.minY <= s.maxY && t.maxX >= s.minX && t.maxY >= s.minY;
|
|
1969
2002
|
}
|
|
1970
|
-
function
|
|
2003
|
+
function Y(s) {
|
|
1971
2004
|
return { children: s, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
|
|
1972
2005
|
}
|
|
1973
|
-
function
|
|
2006
|
+
function Ht(s, t, e, i, o) {
|
|
1974
2007
|
const r = [t, e];
|
|
1975
2008
|
for (; r.length; ) {
|
|
1976
2009
|
if ((e = r.pop()) - (t = r.pop()) <= i) continue;
|
|
1977
2010
|
const n = t + Math.ceil((e - t) / i / 2) * i;
|
|
1978
|
-
|
|
2011
|
+
me(s, n, t, e, o), r.push(t, n, n, e);
|
|
1979
2012
|
}
|
|
1980
2013
|
}
|
|
1981
|
-
class
|
|
2014
|
+
class ni {
|
|
1982
2015
|
constructor(t) {
|
|
1983
2016
|
this._maxEntries = void 0, this._minEntries = void 0, this.data = void 0, this._maxEntries = Math.max(4, t), this._minEntries = Math.max(2, Math.ceil(0.4 * this._maxEntries)), this.clear();
|
|
1984
2017
|
}
|
|
1985
2018
|
search(t) {
|
|
1986
2019
|
let e = this.data;
|
|
1987
2020
|
const i = [];
|
|
1988
|
-
if (!
|
|
2021
|
+
if (!dt(t, e)) return i;
|
|
1989
2022
|
const o = this.toBBox, r = [];
|
|
1990
2023
|
for (; e; ) {
|
|
1991
2024
|
for (let n = 0; n < e.children.length; n++) {
|
|
1992
2025
|
const a = e.children[n], l = e.leaf ? o(a) : a;
|
|
1993
|
-
|
|
2026
|
+
dt(t, l) && (e.leaf ? i.push(a) : Mt(t, l) ? this._all(a, i) : r.push(a));
|
|
1994
2027
|
}
|
|
1995
2028
|
e = r.pop();
|
|
1996
2029
|
}
|
|
@@ -1998,13 +2031,13 @@ class Ze {
|
|
|
1998
2031
|
}
|
|
1999
2032
|
collides(t) {
|
|
2000
2033
|
let e = this.data;
|
|
2001
|
-
if (
|
|
2034
|
+
if (dt(t, e)) {
|
|
2002
2035
|
const i = [];
|
|
2003
2036
|
for (; e; ) {
|
|
2004
2037
|
for (let o = 0; o < e.children.length; o++) {
|
|
2005
2038
|
const r = e.children[o], n = e.leaf ? this.toBBox(r) : r;
|
|
2006
|
-
if (
|
|
2007
|
-
if (e.leaf ||
|
|
2039
|
+
if (dt(t, n)) {
|
|
2040
|
+
if (e.leaf || Mt(t, n)) return !0;
|
|
2008
2041
|
i.push(r);
|
|
2009
2042
|
}
|
|
2010
2043
|
}
|
|
@@ -2033,7 +2066,7 @@ class Ze {
|
|
|
2033
2066
|
this._insert(t, this.data.height - 1);
|
|
2034
2067
|
}
|
|
2035
2068
|
clear() {
|
|
2036
|
-
this.data =
|
|
2069
|
+
this.data = Y([]);
|
|
2037
2070
|
}
|
|
2038
2071
|
remove(t) {
|
|
2039
2072
|
let e = this.data;
|
|
@@ -2041,10 +2074,10 @@ class Ze {
|
|
|
2041
2074
|
let n, a, l = !1;
|
|
2042
2075
|
for (; e || o.length; ) {
|
|
2043
2076
|
if (e || (e = o.pop(), a = o[o.length - 1], n = r.pop(), l = !0), e.leaf) {
|
|
2044
|
-
const
|
|
2045
|
-
|
|
2077
|
+
const d = e.children.indexOf(t);
|
|
2078
|
+
d !== -1 && (e.children.splice(d, 1), o.push(e), this._condense(o));
|
|
2046
2079
|
}
|
|
2047
|
-
l || e.leaf || !
|
|
2080
|
+
l || e.leaf || !Mt(e, i) ? a ? (n++, e = a.children[n], l = !1) : e = null : (o.push(e), r.push(n), n = 0, a = e, e = e.children[0]);
|
|
2048
2081
|
}
|
|
2049
2082
|
}
|
|
2050
2083
|
toBBox(t) {
|
|
@@ -2064,26 +2097,26 @@ class Ze {
|
|
|
2064
2097
|
_build(t, e, i, o) {
|
|
2065
2098
|
const r = i - e + 1;
|
|
2066
2099
|
let n, a = this._maxEntries;
|
|
2067
|
-
if (r <= a) return n =
|
|
2068
|
-
o || (o = Math.ceil(Math.log(r) / Math.log(a)), a = Math.ceil(r / Math.pow(a, o - 1))), n =
|
|
2069
|
-
const l = Math.ceil(r / a),
|
|
2070
|
-
|
|
2071
|
-
for (let
|
|
2072
|
-
const
|
|
2073
|
-
|
|
2074
|
-
for (let u =
|
|
2075
|
-
const g = Math.min(u + l - 1,
|
|
2100
|
+
if (r <= a) return n = Y(t.slice(e, i + 1)), z(n, this.toBBox), n;
|
|
2101
|
+
o || (o = Math.ceil(Math.log(r) / Math.log(a)), a = Math.ceil(r / Math.pow(a, o - 1))), n = Y([]), n.leaf = !1, n.height = o;
|
|
2102
|
+
const l = Math.ceil(r / a), d = l * Math.ceil(Math.sqrt(a));
|
|
2103
|
+
Ht(t, e, i, d, this.compareMinX);
|
|
2104
|
+
for (let c = e; c <= i; c += d) {
|
|
2105
|
+
const h = Math.min(c + d - 1, i);
|
|
2106
|
+
Ht(t, c, h, l, this.compareMinY);
|
|
2107
|
+
for (let u = c; u <= h; u += l) {
|
|
2108
|
+
const g = Math.min(u + l - 1, h);
|
|
2076
2109
|
n.children.push(this._build(t, u, g, o - 1));
|
|
2077
2110
|
}
|
|
2078
2111
|
}
|
|
2079
|
-
return
|
|
2112
|
+
return z(n, this.toBBox), n;
|
|
2080
2113
|
}
|
|
2081
2114
|
_chooseSubtree(t, e, i, o) {
|
|
2082
2115
|
for (; o.push(e), !e.leaf && o.length - 1 !== i; ) {
|
|
2083
|
-
let a, l = 1 / 0,
|
|
2084
|
-
for (let
|
|
2085
|
-
const
|
|
2086
|
-
g <
|
|
2116
|
+
let a, l = 1 / 0, d = 1 / 0;
|
|
2117
|
+
for (let c = 0; c < e.children.length; c++) {
|
|
2118
|
+
const h = e.children[c], u = St(h), g = (r = t, n = h, (Math.max(n.maxX, r.maxX) - Math.min(n.minX, r.minX)) * (Math.max(n.maxY, r.maxY) - Math.min(n.minY, r.minY)) - u);
|
|
2119
|
+
g < d ? (d = g, l = u < l ? u : l, a = h) : g === d && u < l && (l = u, a = h);
|
|
2087
2120
|
}
|
|
2088
2121
|
e = a || e.children[0];
|
|
2089
2122
|
}
|
|
@@ -2092,54 +2125,54 @@ class Ze {
|
|
|
2092
2125
|
}
|
|
2093
2126
|
_insert(t, e, i) {
|
|
2094
2127
|
const o = i ? t : this.toBBox(t), r = [], n = this._chooseSubtree(o, this.data, e, r);
|
|
2095
|
-
for (n.children.push(t),
|
|
2128
|
+
for (n.children.push(t), Q(n, o); e >= 0 && r[e].children.length > this._maxEntries; ) this._split(r, e), e--;
|
|
2096
2129
|
this._adjustParentBBoxes(o, r, e);
|
|
2097
2130
|
}
|
|
2098
2131
|
_split(t, e) {
|
|
2099
2132
|
const i = t[e], o = i.children.length, r = this._minEntries;
|
|
2100
2133
|
this._chooseSplitAxis(i, r, o);
|
|
2101
|
-
const n = this._chooseSplitIndex(i, r, o), a =
|
|
2102
|
-
a.height = i.height, a.leaf = i.leaf,
|
|
2134
|
+
const n = this._chooseSplitIndex(i, r, o), a = Y(i.children.splice(n, i.children.length - n));
|
|
2135
|
+
a.height = i.height, a.leaf = i.leaf, z(i, this.toBBox), z(a, this.toBBox), e ? t[e - 1].children.push(a) : this._splitRoot(i, a);
|
|
2103
2136
|
}
|
|
2104
2137
|
_splitRoot(t, e) {
|
|
2105
|
-
this.data =
|
|
2138
|
+
this.data = Y([t, e]), this.data.height = t.height + 1, this.data.leaf = !1, z(this.data, this.toBBox);
|
|
2106
2139
|
}
|
|
2107
2140
|
_chooseSplitIndex(t, e, i) {
|
|
2108
2141
|
let o, r = 1 / 0, n = 1 / 0;
|
|
2109
2142
|
for (let a = e; a <= i - e; a++) {
|
|
2110
|
-
const l =
|
|
2111
|
-
|
|
2143
|
+
const l = Z(t, 0, a, this.toBBox), d = Z(t, a, i, this.toBBox), c = si(l, d), h = St(l) + St(d);
|
|
2144
|
+
c < r ? (r = c, o = a, n = h < n ? h : n) : c === r && h < n && (n = h, o = a);
|
|
2112
2145
|
}
|
|
2113
2146
|
return o || i - e;
|
|
2114
2147
|
}
|
|
2115
2148
|
_chooseSplitAxis(t, e, i) {
|
|
2116
|
-
const o = t.leaf ? this.compareMinX :
|
|
2149
|
+
const o = t.leaf ? this.compareMinX : oi, r = t.leaf ? this.compareMinY : ri;
|
|
2117
2150
|
this._allDistMargin(t, e, i, o) < this._allDistMargin(t, e, i, r) && t.children.sort(o);
|
|
2118
2151
|
}
|
|
2119
2152
|
_allDistMargin(t, e, i, o) {
|
|
2120
2153
|
t.children.sort(o);
|
|
2121
|
-
const r = this.toBBox, n =
|
|
2154
|
+
const r = this.toBBox, n = Z(t, 0, e, r), a = Z(t, i - e, i, r);
|
|
2122
2155
|
let l = lt(n) + lt(a);
|
|
2123
|
-
for (let
|
|
2124
|
-
const
|
|
2125
|
-
|
|
2156
|
+
for (let d = e; d < i - e; d++) {
|
|
2157
|
+
const c = t.children[d];
|
|
2158
|
+
Q(n, t.leaf ? r(c) : c), l += lt(n);
|
|
2126
2159
|
}
|
|
2127
|
-
for (let
|
|
2128
|
-
const
|
|
2129
|
-
|
|
2160
|
+
for (let d = i - e - 1; d >= e; d--) {
|
|
2161
|
+
const c = t.children[d];
|
|
2162
|
+
Q(a, t.leaf ? r(c) : c), l += lt(a);
|
|
2130
2163
|
}
|
|
2131
2164
|
return l;
|
|
2132
2165
|
}
|
|
2133
2166
|
_adjustParentBBoxes(t, e, i) {
|
|
2134
|
-
for (let o = i; o >= 0; o--)
|
|
2167
|
+
for (let o = i; o >= 0; o--) Q(e[o], t);
|
|
2135
2168
|
}
|
|
2136
2169
|
_condense(t) {
|
|
2137
|
-
for (let e, i = t.length - 1; i >= 0; i--) t[i].children.length === 0 ? i > 0 ? (e = t[i - 1].children, e.splice(e.indexOf(t[i]), 1)) : this.clear() :
|
|
2170
|
+
for (let e, i = t.length - 1; i >= 0; i--) t[i].children.length === 0 ? i > 0 ? (e = t[i - 1].children, e.splice(e.indexOf(t[i]), 1)) : this.clear() : z(t[i], this.toBBox);
|
|
2138
2171
|
}
|
|
2139
2172
|
}
|
|
2140
|
-
class
|
|
2173
|
+
class ai {
|
|
2141
2174
|
constructor(t) {
|
|
2142
|
-
this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new
|
|
2175
|
+
this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new ni(t && t.maxEntries ? t.maxEntries : 9), this.idToNode = /* @__PURE__ */ new Map(), this.nodeToId = /* @__PURE__ */ new Map();
|
|
2143
2176
|
}
|
|
2144
2177
|
setMaps(t, e) {
|
|
2145
2178
|
this.idToNode.set(t.id, e), this.nodeToId.set(e, t.id);
|
|
@@ -2190,14 +2223,14 @@ class Qe {
|
|
|
2190
2223
|
return this.tree.collides(this.toBBox(t));
|
|
2191
2224
|
}
|
|
2192
2225
|
}
|
|
2193
|
-
const
|
|
2226
|
+
const li = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(s) {
|
|
2194
2227
|
const t = 16 * Math.random() | 0;
|
|
2195
2228
|
return (s == "x" ? t : 3 & t | 8).toString(16);
|
|
2196
2229
|
}), isValidId: (s) => typeof s == "string" && s.length === 36 };
|
|
2197
|
-
class
|
|
2230
|
+
class di {
|
|
2198
2231
|
constructor(t) {
|
|
2199
2232
|
this.idStrategy = void 0, this.tracked = void 0, this.spatialIndex = void 0, this.store = void 0, this._onChange = () => {
|
|
2200
|
-
}, this.store = {}, this.spatialIndex = new
|
|
2233
|
+
}, this.store = {}, this.spatialIndex = new ai(), this.tracked = !t || t.tracked !== !1, this.idStrategy = t && t.idStrategy ? t.idStrategy : li;
|
|
2201
2234
|
}
|
|
2202
2235
|
clone(t) {
|
|
2203
2236
|
return JSON.parse(JSON.stringify(t));
|
|
@@ -2209,18 +2242,26 @@ class ei {
|
|
|
2209
2242
|
return !!this.store[t];
|
|
2210
2243
|
}
|
|
2211
2244
|
load(t, e) {
|
|
2212
|
-
if (t.length === 0) return;
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
this.
|
|
2223
|
-
|
|
2245
|
+
if (t.length === 0) return [];
|
|
2246
|
+
let i = this.clone(t);
|
|
2247
|
+
const o = [], r = [];
|
|
2248
|
+
return i = i.filter((n) => {
|
|
2249
|
+
n.id == null && (n.id = this.idStrategy.getId());
|
|
2250
|
+
const a = n.id;
|
|
2251
|
+
if (e) {
|
|
2252
|
+
const l = e(n);
|
|
2253
|
+
if (!l.valid) return r.push({ id: a, valid: !1, reason: l.reason }), !1;
|
|
2254
|
+
}
|
|
2255
|
+
if (this.tracked) {
|
|
2256
|
+
if (n.properties.createdAt) {
|
|
2257
|
+
if (!At(n.properties.createdAt)) return r.push({ id: n.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
|
|
2258
|
+
} else n.properties.createdAt = +/* @__PURE__ */ new Date();
|
|
2259
|
+
if (n.properties.updatedAt) {
|
|
2260
|
+
if (!At(n.properties.updatedAt)) return r.push({ id: n.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
|
|
2261
|
+
} else n.properties.updatedAt = +/* @__PURE__ */ new Date();
|
|
2262
|
+
}
|
|
2263
|
+
return this.has(a) ? (r.push({ id: a, valid: !1, reason: `Feature already exists with this id: ${a}` }), !1) : (this.store[a] = n, o.push(a), r.push({ id: a, valid: !0 }), !0);
|
|
2264
|
+
}), this.spatialIndex.load(i), this._onChange(o, "create"), r;
|
|
2224
2265
|
}
|
|
2225
2266
|
search(t, e) {
|
|
2226
2267
|
const i = this.spatialIndex.search(t).map((o) => this.store[o]);
|
|
@@ -2261,7 +2302,7 @@ class ei {
|
|
|
2261
2302
|
create(t) {
|
|
2262
2303
|
const e = [];
|
|
2263
2304
|
return t.forEach(({ geometry: i, properties: o }) => {
|
|
2264
|
-
let r, n =
|
|
2305
|
+
let r, n = M({}, o);
|
|
2265
2306
|
this.tracked && (r = +/* @__PURE__ */ new Date(), o ? (n.createdAt = typeof o.createdAt == "number" ? o.createdAt : r, n.updatedAt = typeof o.updatedAt == "number" ? o.updatedAt : r) : n = { createdAt: r, updatedAt: r });
|
|
2266
2307
|
const a = this.getId(), l = { id: a, type: "Feature", geometry: i, properties: n };
|
|
2267
2308
|
this.store[a] = l, this.spatialIndex.insert(l), e.push(a);
|
|
@@ -2283,20 +2324,20 @@ class ei {
|
|
|
2283
2324
|
return Object.keys(this.store).length;
|
|
2284
2325
|
}
|
|
2285
2326
|
}
|
|
2286
|
-
const
|
|
2287
|
-
function
|
|
2327
|
+
const ci = "Feature is not a Polygon or LineString", hi = "Feature intersects itself", ui = (s) => s.geometry.type !== "Polygon" && s.geometry.type !== "LineString" ? { valid: !1, reason: ci } : It(s) ? { valid: !1, reason: hi } : { valid: !0 };
|
|
2328
|
+
function Jt(s, t, e) {
|
|
2288
2329
|
const i = j(s, t);
|
|
2289
2330
|
let o = j(t, e) - i;
|
|
2290
2331
|
return o < 0 && (o += 360), 180 - Math.abs(o - 90 - 90);
|
|
2291
2332
|
}
|
|
2292
|
-
class
|
|
2333
|
+
class ve extends W {
|
|
2293
2334
|
constructor(t) {
|
|
2294
2335
|
super(t), this.mode = "angled-rectangle", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.cursors = void 0, this.mouseMove = !1;
|
|
2295
2336
|
const e = { start: "crosshair", close: "pointer" };
|
|
2296
|
-
if (this.cursors = t && t.cursors ?
|
|
2337
|
+
if (this.cursors = t && t.cursors ? M({}, e, t.cursors) : e, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
|
|
2297
2338
|
else {
|
|
2298
2339
|
const i = { cancel: "Escape", finish: "Enter" };
|
|
2299
|
-
this.keyEvents = t && t.keyEvents ?
|
|
2340
|
+
this.keyEvents = t && t.keyEvents ? M({}, i, t.keyEvents) : i;
|
|
2300
2341
|
}
|
|
2301
2342
|
}
|
|
2302
2343
|
close() {
|
|
@@ -2318,17 +2359,17 @@ class Ce extends W {
|
|
|
2318
2359
|
const o = 1 / Math.pow(10, this.coordinatePrecision - 1), r = Math.max(1e-6, o);
|
|
2319
2360
|
i = [e[0], [t.lng, t.lat], [t.lng, t.lat - r], e[0]];
|
|
2320
2361
|
} else if (this.currentCoordinate === 2) {
|
|
2321
|
-
const o = e[0], r = e[1], n =
|
|
2322
|
-
const B = (
|
|
2362
|
+
const o = e[0], r = e[1], n = ge(o, r, this.coordinatePrecision, this.project, this.unproject), a = x(o[0], o[1]), l = x(n[0], n[1]), d = x(r[0], r[1]), c = x(t.lng, t.lat), h = I(c, a) < I(c, d), u = Jt(a, l, c), g = h ? 90 - u : Jt(a, l, c) - 90, p = I(l, c), y = Math.cos(_(g)) * p, m = j(a, d) + (function(S, w, E) {
|
|
2363
|
+
const B = (E.x - w.x) * (S.y - w.y) - (E.y - w.y) * (S.x - w.x);
|
|
2323
2364
|
return B > 1e-10 ? "left" : B < -1e-10 ? "right" : "left";
|
|
2324
|
-
}(a,
|
|
2325
|
-
i = [e[0], e[1], [
|
|
2365
|
+
}(a, d, c) === "right" ? -90 : 90), f = it(a, y, m), C = it(d, y, m), v = O(f.x, f.y), P = O(C.x, C.y);
|
|
2366
|
+
i = [e[0], e[1], [P.lng, P.lat], [v.lng, v.lat], e[0]];
|
|
2326
2367
|
}
|
|
2327
2368
|
i && this.updatePolygonGeometry(this.currentId, i, b.Provisional);
|
|
2328
2369
|
}
|
|
2329
2370
|
updatePolygonGeometry(t, e, i) {
|
|
2330
2371
|
const o = { type: "Polygon", coordinates: [e] };
|
|
2331
|
-
return !(this.validate && !this.validate({ type: "Feature", geometry: o }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: i }) || (this.store.updateGeometry([{ id: t, geometry: o }]), 0));
|
|
2372
|
+
return !(this.validate && !this.validate({ type: "Feature", geometry: o }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: i }).valid || (this.store.updateGeometry([{ id: t, geometry: o }]), 0));
|
|
2332
2373
|
}
|
|
2333
2374
|
onClick(t) {
|
|
2334
2375
|
if (this.currentCoordinate > 0 && !this.mouseMove && this.onMouseMove(t), this.mouseMove = !1, this.currentCoordinate === 0) {
|
|
@@ -2336,7 +2377,7 @@ class Ce extends W {
|
|
|
2336
2377
|
this.currentId = e, this.currentCoordinate++, this.setDrawing();
|
|
2337
2378
|
} else if (this.currentCoordinate === 1 && this.currentId) {
|
|
2338
2379
|
const e = this.store.getGeometryCopy(this.currentId);
|
|
2339
|
-
if (
|
|
2380
|
+
if (J([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;
|
|
2340
2381
|
this.currentCoordinate++;
|
|
2341
2382
|
} else this.currentCoordinate === 2 && this.currentId && this.close();
|
|
2342
2383
|
}
|
|
@@ -2359,24 +2400,24 @@ class Ce extends W {
|
|
|
2359
2400
|
this.currentId = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted();
|
|
2360
2401
|
}
|
|
2361
2402
|
styleFeature(t) {
|
|
2362
|
-
const e =
|
|
2403
|
+
const e = M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
2363
2404
|
return t.properties.mode === this.mode && t.geometry.type === "Polygon" && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
|
|
2364
2405
|
}
|
|
2365
2406
|
validateFeature(t) {
|
|
2366
|
-
return
|
|
2407
|
+
return this.validateModeFeature(t, (e) => ot(e, this.coordinatePrecision));
|
|
2367
2408
|
}
|
|
2368
2409
|
}
|
|
2369
|
-
function
|
|
2410
|
+
function Ce(s, t, e) {
|
|
2370
2411
|
return (t.x - s.x) * (e.y - s.y) - (t.y - s.y) * (e.x - s.x) <= 0;
|
|
2371
2412
|
}
|
|
2372
2413
|
class Pe extends W {
|
|
2373
2414
|
constructor(t) {
|
|
2374
2415
|
super(t), this.mode = "sector", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.direction = void 0, this.arcPoints = void 0, this.cursors = void 0, this.mouseMove = !1;
|
|
2375
2416
|
const e = { start: "crosshair", close: "pointer" };
|
|
2376
|
-
if (this.cursors = t && t.cursors ?
|
|
2417
|
+
if (this.cursors = t && t.cursors ? M({}, e, t.cursors) : e, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
|
|
2377
2418
|
else {
|
|
2378
2419
|
const i = { cancel: "Escape", finish: "Enter" };
|
|
2379
|
-
this.keyEvents = t && t.keyEvents ?
|
|
2420
|
+
this.keyEvents = t && t.keyEvents ? M({}, i, t.keyEvents) : i;
|
|
2380
2421
|
}
|
|
2381
2422
|
this.arcPoints = (t == null ? void 0 : t.arcPoints) || 64;
|
|
2382
2423
|
}
|
|
@@ -2399,19 +2440,19 @@ class Pe extends W {
|
|
|
2399
2440
|
const o = 1 / Math.pow(10, this.coordinatePrecision - 1), r = Math.max(1e-6, o);
|
|
2400
2441
|
i = [e[0], [t.lng, t.lat], [t.lng, t.lat - r], e[0]];
|
|
2401
2442
|
} else if (this.currentCoordinate === 2) {
|
|
2402
|
-
const o = e[0], r = e[1], n = [t.lng, t.lat], a =
|
|
2443
|
+
const o = e[0], r = e[1], n = [t.lng, t.lat], a = x(o[0], o[1]), l = x(r[0], r[1]), d = x(n[0], n[1]);
|
|
2403
2444
|
if (this.direction === void 0) {
|
|
2404
|
-
const
|
|
2405
|
-
this.direction =
|
|
2445
|
+
const v = Ce(a, l, d);
|
|
2446
|
+
this.direction = v ? "clockwise" : "anticlockwise";
|
|
2406
2447
|
}
|
|
2407
|
-
const
|
|
2448
|
+
const c = I(a, l), h = j(a, l), u = j(a, d), g = this.arcPoints, p = [o], y = V(h), m = V(u);
|
|
2408
2449
|
let f;
|
|
2409
2450
|
this.direction === "anticlockwise" ? (f = m - y, f < 0 && (f += 360)) : (f = y - m, f < 0 && (f += 360));
|
|
2410
|
-
const
|
|
2451
|
+
const C = (this.direction === "anticlockwise" ? 1 : -1) * f / g;
|
|
2411
2452
|
p.push(r);
|
|
2412
|
-
for (let
|
|
2413
|
-
const
|
|
2414
|
-
|
|
2453
|
+
for (let v = 0; v <= g; v++) {
|
|
2454
|
+
const P = it(a, c, y + v * C), { lng: S, lat: w } = O(P.x, P.y), E = [F(S, this.coordinatePrecision), F(w, this.coordinatePrecision)];
|
|
2455
|
+
E[0] !== p[p.length - 1][0] && E[1] !== p[p.length - 1][1] && p.push(E);
|
|
2415
2456
|
}
|
|
2416
2457
|
p.push(o), i = [...p];
|
|
2417
2458
|
}
|
|
@@ -2419,7 +2460,7 @@ class Pe extends W {
|
|
|
2419
2460
|
}
|
|
2420
2461
|
updatePolygonGeometry(t, e, i) {
|
|
2421
2462
|
const o = { type: "Polygon", coordinates: [e] };
|
|
2422
|
-
return !(this.validate && !this.validate({ type: "Feature", geometry: o }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: i }) || (this.store.updateGeometry([{ id: t, geometry: o }]), 0));
|
|
2463
|
+
return !(this.validate && !this.validate({ type: "Feature", geometry: o }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: i }).valid || (this.store.updateGeometry([{ id: t, geometry: o }]), 0));
|
|
2423
2464
|
}
|
|
2424
2465
|
onClick(t) {
|
|
2425
2466
|
if (this.currentCoordinate > 0 && !this.mouseMove && this.onMouseMove(t), this.mouseMove = !1, this.currentCoordinate === 0) {
|
|
@@ -2427,7 +2468,7 @@ class Pe extends W {
|
|
|
2427
2468
|
this.currentId = e, this.currentCoordinate++, this.setDrawing();
|
|
2428
2469
|
} else if (this.currentCoordinate === 1 && this.currentId) {
|
|
2429
2470
|
const e = this.store.getGeometryCopy(this.currentId);
|
|
2430
|
-
if (
|
|
2471
|
+
if (J([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;
|
|
2431
2472
|
this.currentCoordinate++;
|
|
2432
2473
|
} else this.currentCoordinate === 2 && this.currentId && this.close();
|
|
2433
2474
|
}
|
|
@@ -2450,21 +2491,21 @@ class Pe extends W {
|
|
|
2450
2491
|
this.currentId = void 0, this.direction = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted();
|
|
2451
2492
|
}
|
|
2452
2493
|
styleFeature(t) {
|
|
2453
|
-
const e =
|
|
2494
|
+
const e = M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
2454
2495
|
return t.properties.mode === this.mode && t.geometry.type === "Polygon" && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
|
|
2455
2496
|
}
|
|
2456
2497
|
validateFeature(t) {
|
|
2457
|
-
return
|
|
2498
|
+
return this.validateModeFeature(t, (e) => ot(e, this.coordinatePrecision));
|
|
2458
2499
|
}
|
|
2459
2500
|
}
|
|
2460
2501
|
class xe extends W {
|
|
2461
2502
|
constructor(t) {
|
|
2462
2503
|
super(t), this.mode = "sensor", this.currentCoordinate = 0, this.currentId = void 0, this.currentInitialArcId = void 0, this.currentStartingPointId = void 0, this.keyEvents = void 0, this.direction = void 0, this.arcPoints = void 0, this.cursors = void 0, this.mouseMove = !1;
|
|
2463
2504
|
const e = { start: "crosshair", close: "pointer" };
|
|
2464
|
-
if (this.cursors = t && t.cursors ?
|
|
2505
|
+
if (this.cursors = t && t.cursors ? M({}, e, t.cursors) : e, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
|
|
2465
2506
|
else {
|
|
2466
2507
|
const i = { cancel: "Escape", finish: "Enter" };
|
|
2467
|
-
this.keyEvents = t && t.keyEvents ?
|
|
2508
|
+
this.keyEvents = t && t.keyEvents ? M({}, i, t.keyEvents) : i;
|
|
2468
2509
|
}
|
|
2469
2510
|
this.arcPoints = (t == null ? void 0 : t.arcPoints) || 64;
|
|
2470
2511
|
}
|
|
@@ -2482,28 +2523,28 @@ class xe extends W {
|
|
|
2482
2523
|
onMouseMove(t) {
|
|
2483
2524
|
if (this.mouseMove = !0, this.setCursor(this.cursors.start), this.currentInitialArcId !== void 0 && this.currentStartingPointId !== void 0 && this.currentCoordinate !== 0) {
|
|
2484
2525
|
if (this.currentCoordinate === 2) {
|
|
2485
|
-
const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], r = [t.lng, t.lat], n =
|
|
2526
|
+
const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], r = [t.lng, t.lat], n = x(o[0], o[1]), a = x(r[0], r[1]), l = x(i[0], i[1]), d = I(l, n);
|
|
2486
2527
|
if (this.direction === void 0) {
|
|
2487
|
-
const
|
|
2488
|
-
this.direction =
|
|
2528
|
+
const C = Ce(l, n, a);
|
|
2529
|
+
this.direction = C ? "clockwise" : "anticlockwise";
|
|
2489
2530
|
}
|
|
2490
|
-
const
|
|
2531
|
+
const c = j(l, n), h = j(l, a), u = this.arcPoints, g = [o], p = V(c), y = V(h);
|
|
2491
2532
|
let m;
|
|
2492
2533
|
this.direction === "anticlockwise" ? (m = y - p, m < 0 && (m += 360)) : (m = p - y, m < 0 && (m += 360));
|
|
2493
2534
|
const f = (this.direction === "anticlockwise" ? 1 : -1) * m / u;
|
|
2494
|
-
for (let
|
|
2495
|
-
const
|
|
2535
|
+
for (let C = 0; C <= u; C++) {
|
|
2536
|
+
const v = it(l, d, p + C * f), { lng: P, lat: S } = O(v.x, v.y), w = [F(P, this.coordinatePrecision), F(S, this.coordinatePrecision)];
|
|
2496
2537
|
w[0] !== g[g.length - 1][0] && w[1] !== g[g.length - 1][1] && g.push(w);
|
|
2497
2538
|
}
|
|
2498
2539
|
this.updateLineStringGeometry(this.currentInitialArcId, g, b.Provisional);
|
|
2499
2540
|
} else if (this.currentCoordinate === 3) {
|
|
2500
2541
|
const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates;
|
|
2501
2542
|
if (e.length < 2 || !this.direction) return;
|
|
2502
|
-
const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], r = e[e.length - 1], n =
|
|
2543
|
+
const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], r = e[e.length - 1], n = x(t.lng, t.lat), a = x(o[0], o[1]), l = x(r[0], r[1]), d = x(i[0], i[1]), c = I(d, a), h = I(d, n) < c ? a : n, u = j(d, n), g = j(d, a), p = j(d, l), y = V(g), m = V(p), f = V(u);
|
|
2503
2544
|
if (this.notInSector({ normalizedCursor: f, normalizedStart: y, normalizedEnd: m, direction: this.direction })) return;
|
|
2504
|
-
const
|
|
2505
|
-
for (let
|
|
2506
|
-
const B =
|
|
2545
|
+
const C = this.getDeltaBearing(this.direction, y, m), v = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * C / v, S = I(d, h), w = [];
|
|
2546
|
+
for (let E = 0; E <= v; E++) {
|
|
2547
|
+
const B = it(d, S, y + E * P), { lng: T, lat: R } = O(B.x, B.y), N = [F(T, this.coordinatePrecision), F(R, this.coordinatePrecision)];
|
|
2507
2548
|
N[0] !== e[e.length - 1][0] && N[1] !== e[e.length - 1][1] && w.unshift(N);
|
|
2508
2549
|
}
|
|
2509
2550
|
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 } }]);
|
|
@@ -2512,11 +2553,11 @@ class xe extends W {
|
|
|
2512
2553
|
}
|
|
2513
2554
|
updateLineStringGeometry(t, e, i) {
|
|
2514
2555
|
const o = { type: "LineString", coordinates: e };
|
|
2515
|
-
return !(this.validate && !this.validate({ type: "Feature", geometry: o }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: i }) || (this.store.updateGeometry([{ id: t, geometry: o }]), 0));
|
|
2556
|
+
return !(this.validate && !this.validate({ type: "Feature", geometry: o }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: i }).valid || (this.store.updateGeometry([{ id: t, geometry: o }]), 0));
|
|
2516
2557
|
}
|
|
2517
2558
|
updatePolygonGeometry(t, e, i) {
|
|
2518
2559
|
const o = { type: "Polygon", coordinates: [e] };
|
|
2519
|
-
return !(this.validate && !this.validate({ type: "Feature", geometry: o }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: i }) || (this.store.updateGeometry([{ id: t, geometry: o }]), 0));
|
|
2560
|
+
return !(this.validate && !this.validate({ type: "Feature", geometry: o }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: i }).valid || (this.store.updateGeometry([{ id: t, geometry: o }]), 0));
|
|
2520
2561
|
}
|
|
2521
2562
|
onClick(t) {
|
|
2522
2563
|
if (this.currentCoordinate > 0 && !this.mouseMove && this.onMouseMove(t), this.mouseMove = !1, this.currentCoordinate === 0) {
|
|
@@ -2546,11 +2587,11 @@ class xe extends W {
|
|
|
2546
2587
|
this.currentStartingPointId = void 0, this.direction = void 0, this.currentId = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted();
|
|
2547
2588
|
}
|
|
2548
2589
|
styleFeature(t) {
|
|
2549
|
-
const e =
|
|
2590
|
+
const e = M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
2550
2591
|
return t.properties.mode === this.mode && (t.geometry.type === "Polygon" ? (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10) : t.geometry.type === "LineString" ? (e.lineStringColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.lineStringWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.zIndex = 10) : t.geometry.type === "Point" && (e.pointColor = this.getHexColorStylingValue(this.styles.centerPointColor, e.pointColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.centerPointWidth, e.pointWidth, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.centerPointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.centerPointOutlineWidth, e.pointOutlineWidth, t), e.zIndex = 20)), e;
|
|
2551
2592
|
}
|
|
2552
2593
|
validateFeature(t) {
|
|
2553
|
-
return
|
|
2594
|
+
return this.validateModeFeature(t, (e) => ot(e, this.coordinatePrecision));
|
|
2554
2595
|
}
|
|
2555
2596
|
getDeltaBearing(t, e, i) {
|
|
2556
2597
|
let o;
|
|
@@ -2560,51 +2601,51 @@ class xe extends W {
|
|
|
2560
2601
|
return o === "clockwise" ? e <= i ? t >= e && t <= i : t >= e || t <= i : e >= i ? t <= e && t >= i : t <= e || t >= i;
|
|
2561
2602
|
}
|
|
2562
2603
|
}
|
|
2563
|
-
class
|
|
2604
|
+
class gi {
|
|
2564
2605
|
constructor(t) {
|
|
2565
|
-
this._modes = void 0, this._mode = void 0, this._adapter = void 0, this._enabled = !1, this._store = void 0, this._eventListeners = void 0, this._instanceSelectMode = void 0, this._adapter = t.adapter, this._mode = new
|
|
2566
|
-
const e = /* @__PURE__ */ new Set(), i = t.modes.reduce((
|
|
2567
|
-
if (e.has(
|
|
2568
|
-
return e.add(
|
|
2606
|
+
this._modes = void 0, this._mode = void 0, this._adapter = void 0, this._enabled = !1, this._store = void 0, this._eventListeners = void 0, this._instanceSelectMode = void 0, this._adapter = t.adapter, this._mode = new ii();
|
|
2607
|
+
const e = /* @__PURE__ */ new Set(), i = t.modes.reduce((c, h) => {
|
|
2608
|
+
if (e.has(h.mode)) throw new Error(`There is already a ${h.mode} mode provided`);
|
|
2609
|
+
return e.add(h.mode), c[h.mode] = h, c;
|
|
2569
2610
|
}, {}), o = Object.keys(i);
|
|
2570
2611
|
if (o.length === 0) throw new Error("No modes provided");
|
|
2571
|
-
o.forEach((
|
|
2572
|
-
if (i[
|
|
2612
|
+
o.forEach((c) => {
|
|
2613
|
+
if (i[c].type === U.Select) {
|
|
2573
2614
|
if (this._instanceSelectMode) throw new Error("only one type of select mode can be provided");
|
|
2574
|
-
this._instanceSelectMode =
|
|
2615
|
+
this._instanceSelectMode = c;
|
|
2575
2616
|
}
|
|
2576
|
-
}), this._modes =
|
|
2577
|
-
const r = (
|
|
2578
|
-
const
|
|
2579
|
-
return { changed:
|
|
2580
|
-
}, n = (
|
|
2617
|
+
}), this._modes = M({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new di({ tracked: !!t.tracked, idStrategy: t.idStrategy ? t.idStrategy : void 0 });
|
|
2618
|
+
const r = (c) => {
|
|
2619
|
+
const h = [], u = this._store.copyAll().filter((g) => !c.includes(g.id) || (h.push(g), !1));
|
|
2620
|
+
return { changed: h, unchanged: u };
|
|
2621
|
+
}, n = (c, h) => {
|
|
2581
2622
|
this._enabled && this._eventListeners.finish.forEach((u) => {
|
|
2582
|
-
u(
|
|
2623
|
+
u(c, h);
|
|
2583
2624
|
});
|
|
2584
|
-
}, a = (
|
|
2625
|
+
}, a = (c, h) => {
|
|
2585
2626
|
if (!this._enabled) return;
|
|
2586
2627
|
this._eventListeners.change.forEach((p) => {
|
|
2587
|
-
p(
|
|
2628
|
+
p(c, h);
|
|
2588
2629
|
});
|
|
2589
|
-
const { changed: u, unchanged: g } = r(
|
|
2590
|
-
|
|
2591
|
-
}, l = (
|
|
2630
|
+
const { changed: u, unchanged: g } = r(c);
|
|
2631
|
+
h === "create" ? this._adapter.render({ created: u, deletedIds: [], unchanged: g, updated: [] }, this.getModeStyles()) : h === "update" ? this._adapter.render({ created: [], deletedIds: [], unchanged: g, updated: u }, this.getModeStyles()) : h === "delete" ? this._adapter.render({ created: [], deletedIds: c, unchanged: g, updated: [] }, this.getModeStyles()) : h === "styling" && this._adapter.render({ created: [], deletedIds: [], unchanged: g, updated: [] }, this.getModeStyles());
|
|
2632
|
+
}, l = (c) => {
|
|
2592
2633
|
if (!this._enabled) return;
|
|
2593
2634
|
this._eventListeners.select.forEach((g) => {
|
|
2594
|
-
g(
|
|
2635
|
+
g(c);
|
|
2595
2636
|
});
|
|
2596
|
-
const { changed:
|
|
2597
|
-
this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated:
|
|
2598
|
-
},
|
|
2637
|
+
const { changed: h, unchanged: u } = r([c]);
|
|
2638
|
+
this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: h }, this.getModeStyles());
|
|
2639
|
+
}, d = (c) => {
|
|
2599
2640
|
if (!this._enabled) return;
|
|
2600
2641
|
this._eventListeners.deselect.forEach((g) => {
|
|
2601
2642
|
g();
|
|
2602
2643
|
});
|
|
2603
|
-
const { changed:
|
|
2604
|
-
|
|
2644
|
+
const { changed: h, unchanged: u } = r([c]);
|
|
2645
|
+
h && this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: h }, this.getModeStyles());
|
|
2605
2646
|
};
|
|
2606
|
-
Object.keys(this._modes).forEach((
|
|
2607
|
-
this._modes[
|
|
2647
|
+
Object.keys(this._modes).forEach((c) => {
|
|
2648
|
+
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() });
|
|
2608
2649
|
});
|
|
2609
2650
|
}
|
|
2610
2651
|
checkEnabled() {
|
|
@@ -2613,26 +2654,26 @@ class ii {
|
|
|
2613
2654
|
getModeStyles() {
|
|
2614
2655
|
const t = {};
|
|
2615
2656
|
return Object.keys(this._modes).forEach((e) => {
|
|
2616
|
-
t[e] = (i) => this._instanceSelectMode && i.properties[
|
|
2657
|
+
t[e] = (i) => this._instanceSelectMode && i.properties[wt] ? this._modes[this._instanceSelectMode].styleFeature.bind(this._modes[this._instanceSelectMode])(i) : this._modes[e].styleFeature.bind(this._modes[e])(i);
|
|
2617
2658
|
}), t;
|
|
2618
2659
|
}
|
|
2619
2660
|
featuresAtLocation({ lng: t, lat: e }, i) {
|
|
2620
|
-
const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, r = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, n = this._adapter.unproject.bind(this._adapter), a = this._adapter.project.bind(this._adapter), l = a(t, e),
|
|
2621
|
-
return this._store.search(
|
|
2622
|
-
if (r && (
|
|
2623
|
-
if (
|
|
2624
|
-
const
|
|
2625
|
-
return
|
|
2661
|
+
const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, r = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, n = this._adapter.unproject.bind(this._adapter), a = this._adapter.project.bind(this._adapter), l = a(t, e), d = ne({ unproject: n, point: l, pointerDistance: o });
|
|
2662
|
+
return this._store.search(d).filter((c) => {
|
|
2663
|
+
if (r && (c.properties[tt] || c.properties.selectionPoint)) return !1;
|
|
2664
|
+
if (c.geometry.type === "Point") {
|
|
2665
|
+
const h = c.geometry.coordinates, u = a(h[0], h[1]);
|
|
2666
|
+
return I(l, u) < o;
|
|
2626
2667
|
}
|
|
2627
|
-
if (
|
|
2628
|
-
const
|
|
2629
|
-
for (let u = 0; u <
|
|
2630
|
-
const g =
|
|
2631
|
-
if (
|
|
2668
|
+
if (c.geometry.type === "LineString") {
|
|
2669
|
+
const h = c.geometry.coordinates;
|
|
2670
|
+
for (let u = 0; u < h.length - 1; u++) {
|
|
2671
|
+
const g = h[u], p = h[u + 1];
|
|
2672
|
+
if (ye(l, a(g[0], g[1]), a(p[0], p[1])) < o) return !0;
|
|
2632
2673
|
}
|
|
2633
2674
|
return !1;
|
|
2634
2675
|
}
|
|
2635
|
-
return !!
|
|
2676
|
+
return !!pe([t, e], c.geometry.coordinates) || void 0;
|
|
2636
2677
|
});
|
|
2637
2678
|
}
|
|
2638
2679
|
getSelectMode() {
|
|
@@ -2678,12 +2719,16 @@ class ii {
|
|
|
2678
2719
|
return this._store.has(t);
|
|
2679
2720
|
}
|
|
2680
2721
|
addFeatures(t) {
|
|
2681
|
-
this.checkEnabled(), t.length
|
|
2682
|
-
if (
|
|
2683
|
-
|
|
2684
|
-
|
|
2722
|
+
return this.checkEnabled(), t.length === 0 ? [] : this._store.load(t, (e) => {
|
|
2723
|
+
if (function(i) {
|
|
2724
|
+
return !!(i && typeof i == "object" && "properties" in i && typeof i.properties == "object" && i.properties !== null && "mode" in i.properties);
|
|
2725
|
+
}(e)) {
|
|
2726
|
+
const i = e.properties.mode, o = this._modes[i];
|
|
2727
|
+
if (!o) return { id: e.id, valid: !1, reason: `${i} mode is not in the list of instantiated modes` };
|
|
2728
|
+
const r = o.validateFeature.bind(o)(e);
|
|
2729
|
+
return { id: e.id, valid: r.valid, reason: r.reason ? r.reason : r.valid ? void 0 : "Feature is invalid" };
|
|
2685
2730
|
}
|
|
2686
|
-
return !1;
|
|
2731
|
+
return { id: e.id, valid: !1, reason: "Mode property does not exist" };
|
|
2687
2732
|
});
|
|
2688
2733
|
}
|
|
2689
2734
|
start() {
|
|
@@ -2729,7 +2774,7 @@ class ii {
|
|
|
2729
2774
|
i.includes(e) && i.splice(i.indexOf(e), 1);
|
|
2730
2775
|
}
|
|
2731
2776
|
}
|
|
2732
|
-
const
|
|
2777
|
+
const Di = [
|
|
2733
2778
|
"render",
|
|
2734
2779
|
"point",
|
|
2735
2780
|
"linestring",
|
|
@@ -2743,7 +2788,7 @@ const vi = [
|
|
|
2743
2788
|
"select",
|
|
2744
2789
|
"delete-selection",
|
|
2745
2790
|
"delete"
|
|
2746
|
-
],
|
|
2791
|
+
], Oi = [
|
|
2747
2792
|
"render",
|
|
2748
2793
|
"linestring",
|
|
2749
2794
|
"polygon",
|
|
@@ -2756,7 +2801,7 @@ const vi = [
|
|
|
2756
2801
|
"select",
|
|
2757
2802
|
"delete-selection",
|
|
2758
2803
|
"delete"
|
|
2759
|
-
],
|
|
2804
|
+
], pi = {
|
|
2760
2805
|
modes: [
|
|
2761
2806
|
"render",
|
|
2762
2807
|
"point",
|
|
@@ -2773,7 +2818,7 @@ const vi = [
|
|
|
2773
2818
|
"delete"
|
|
2774
2819
|
],
|
|
2775
2820
|
open: !1
|
|
2776
|
-
},
|
|
2821
|
+
}, yi = {
|
|
2777
2822
|
modes: [
|
|
2778
2823
|
"render",
|
|
2779
2824
|
"linestring",
|
|
@@ -2784,12 +2829,14 @@ const vi = [
|
|
|
2784
2829
|
"sector",
|
|
2785
2830
|
"circle",
|
|
2786
2831
|
"freehand",
|
|
2832
|
+
"select",
|
|
2833
|
+
"delete-selection",
|
|
2787
2834
|
"delete"
|
|
2788
2835
|
],
|
|
2789
2836
|
open: !1,
|
|
2790
2837
|
// see styling parameters of Terra Draw at https://github.com/JamesLMilner/terra-draw/blob/main/guides/5.STYLING.md
|
|
2791
2838
|
modeOptions: {
|
|
2792
|
-
linestring: new
|
|
2839
|
+
linestring: new de({
|
|
2793
2840
|
styles: {
|
|
2794
2841
|
lineStringColor: "#000000",
|
|
2795
2842
|
lineStringWidth: 2,
|
|
@@ -2809,15 +2856,9 @@ const vi = [
|
|
|
2809
2856
|
closingPointWidth: 5,
|
|
2810
2857
|
closingPointOutlineColor: "#000000",
|
|
2811
2858
|
closingPointOutlineWidth: 1
|
|
2812
|
-
},
|
|
2813
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2814
|
-
// @ts-ignore
|
|
2815
|
-
validation: (s, t) => {
|
|
2816
|
-
const e = t.updateType;
|
|
2817
|
-
return e === "finish" || e === "commit" ? me(s) : !0;
|
|
2818
2859
|
}
|
|
2819
2860
|
}),
|
|
2820
|
-
rectangle: new
|
|
2861
|
+
rectangle: new ue({
|
|
2821
2862
|
styles: {
|
|
2822
2863
|
fillColor: "#FFFFFF",
|
|
2823
2864
|
fillOpacity: 0.7,
|
|
@@ -2825,7 +2866,7 @@ const vi = [
|
|
|
2825
2866
|
outlineWidth: 2
|
|
2826
2867
|
}
|
|
2827
2868
|
}),
|
|
2828
|
-
"angled-rectangle": new
|
|
2869
|
+
"angled-rectangle": new ve({
|
|
2829
2870
|
styles: {
|
|
2830
2871
|
fillColor: "#FFFFFF",
|
|
2831
2872
|
fillOpacity: 0.7,
|
|
@@ -2934,28 +2975,28 @@ const vi = [
|
|
|
2934
2975
|
"text-color": "#000000"
|
|
2935
2976
|
}
|
|
2936
2977
|
}
|
|
2937
|
-
},
|
|
2938
|
-
render: new
|
|
2978
|
+
}, fi = () => ({
|
|
2979
|
+
render: new ht({
|
|
2939
2980
|
modeName: "render",
|
|
2940
2981
|
styles: {}
|
|
2941
2982
|
}),
|
|
2942
|
-
point: new
|
|
2943
|
-
linestring: new
|
|
2983
|
+
point: new Xe(),
|
|
2984
|
+
linestring: new de(),
|
|
2944
2985
|
polygon: new he({
|
|
2945
2986
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2946
2987
|
// @ts-ignore
|
|
2947
2988
|
validation: (t, e) => {
|
|
2948
2989
|
const i = e.updateType;
|
|
2949
|
-
return i === "finish" || i === "commit" ?
|
|
2990
|
+
return i === "finish" || i === "commit" ? ui(t) : !0;
|
|
2950
2991
|
}
|
|
2951
2992
|
}),
|
|
2952
|
-
rectangle: new
|
|
2953
|
-
"angled-rectangle": new
|
|
2993
|
+
rectangle: new ue(),
|
|
2994
|
+
"angled-rectangle": new ve(),
|
|
2954
2995
|
circle: new re(),
|
|
2955
2996
|
freehand: new se(),
|
|
2956
2997
|
sensor: new xe(),
|
|
2957
2998
|
sector: new Pe(),
|
|
2958
|
-
select: new
|
|
2999
|
+
select: new ei({
|
|
2959
3000
|
flags: {
|
|
2960
3001
|
point: {
|
|
2961
3002
|
feature: {
|
|
@@ -3056,29 +3097,29 @@ const vi = [
|
|
|
3056
3097
|
}
|
|
3057
3098
|
}
|
|
3058
3099
|
}),
|
|
3059
|
-
delete: new
|
|
3100
|
+
delete: new ht({
|
|
3060
3101
|
modeName: "delete",
|
|
3061
3102
|
styles: {}
|
|
3062
3103
|
}),
|
|
3063
|
-
"delete-selection": new
|
|
3104
|
+
"delete-selection": new ht({
|
|
3064
3105
|
modeName: "delete-selection",
|
|
3065
3106
|
styles: {}
|
|
3066
3107
|
})
|
|
3067
3108
|
});
|
|
3068
|
-
class
|
|
3109
|
+
class mi {
|
|
3069
3110
|
/**
|
|
3070
3111
|
* Constructor
|
|
3071
3112
|
* @param options Plugin control options
|
|
3072
3113
|
*/
|
|
3073
3114
|
constructor(t) {
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3115
|
+
L(this, "controlContainer");
|
|
3116
|
+
L(this, "map");
|
|
3117
|
+
L(this, "modeButtons", {});
|
|
3118
|
+
L(this, "isExpanded", !1);
|
|
3119
|
+
L(this, "terradraw");
|
|
3120
|
+
L(this, "options", pi);
|
|
3121
|
+
L(this, "events", {});
|
|
3122
|
+
L(this, "defaultMode", "render");
|
|
3082
3123
|
this.modeButtons = {}, t && (this.options = Object.assign(this.options, t));
|
|
3083
3124
|
}
|
|
3084
3125
|
/**
|
|
@@ -3098,36 +3139,36 @@ class ni {
|
|
|
3098
3139
|
if (this.options && this.options.modes && this.options.modes.length === 0)
|
|
3099
3140
|
throw new Error("At least a mode must be enabled.");
|
|
3100
3141
|
this.map = t;
|
|
3101
|
-
const e =
|
|
3142
|
+
const e = fi(), i = [];
|
|
3102
3143
|
return (r = (o = this.options) == null ? void 0 : o.modes) == null || r.forEach((l) => {
|
|
3103
3144
|
if (this.options.modeOptions && this.options.modeOptions[l]) {
|
|
3104
|
-
const
|
|
3145
|
+
const d = this.options.modeOptions[l];
|
|
3105
3146
|
if (l === "select") {
|
|
3106
|
-
const
|
|
3107
|
-
if (
|
|
3108
|
-
const
|
|
3109
|
-
Object.keys(
|
|
3110
|
-
|
|
3147
|
+
const c = e[l];
|
|
3148
|
+
if (c) {
|
|
3149
|
+
const h = c.flags;
|
|
3150
|
+
Object.keys(h).forEach((u) => {
|
|
3151
|
+
d.flags[u] || (d.flags[u] = h[u]);
|
|
3111
3152
|
});
|
|
3112
3153
|
}
|
|
3113
3154
|
}
|
|
3114
|
-
i.push(
|
|
3155
|
+
i.push(d);
|
|
3115
3156
|
} else e[l] && i.push(e[l]);
|
|
3116
3157
|
}), i.forEach((l) => {
|
|
3117
3158
|
l.state !== "unregistered" && (l._state = "unregistered");
|
|
3118
3159
|
}), (a = (n = this.options) == null ? void 0 : n.modes) != null && a.includes("render") || (i.push(
|
|
3119
|
-
new
|
|
3160
|
+
new ht({
|
|
3120
3161
|
modeName: "default",
|
|
3121
3162
|
styles: {}
|
|
3122
3163
|
})
|
|
3123
|
-
), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new
|
|
3124
|
-
adapter: new
|
|
3164
|
+
), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new gi({
|
|
3165
|
+
adapter: new Fe({ map: t }),
|
|
3125
3166
|
modes: i
|
|
3126
3167
|
}), this.terradraw.start(), this.controlContainer = document.createElement("div"), this.controlContainer.classList.add("maplibregl-ctrl"), this.controlContainer.classList.add("maplibregl-ctrl-group"), i.forEach((l) => {
|
|
3127
3168
|
l.mode !== "default" && this.addTerradrawButton(l.mode);
|
|
3128
3169
|
}), Object.values(this.modeButtons).forEach((l) => {
|
|
3129
|
-
var
|
|
3130
|
-
(
|
|
3170
|
+
var d;
|
|
3171
|
+
(d = this.controlContainer) == null || d.appendChild(l);
|
|
3131
3172
|
}), this.controlContainer;
|
|
3132
3173
|
}
|
|
3133
3174
|
/**
|
|
@@ -3260,7 +3301,7 @@ class ni {
|
|
|
3260
3301
|
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
3261
3302
|
}
|
|
3262
3303
|
}
|
|
3263
|
-
var D = 63710088e-1,
|
|
3304
|
+
var D = 63710088e-1, vi = {
|
|
3264
3305
|
centimeters: D * 100,
|
|
3265
3306
|
centimetres: D * 100,
|
|
3266
3307
|
degrees: 360 / (2 * Math.PI),
|
|
@@ -3277,37 +3318,37 @@ var D = 63710088e-1, ai = {
|
|
|
3277
3318
|
radians: 1,
|
|
3278
3319
|
yards: D * 1.0936
|
|
3279
3320
|
};
|
|
3280
|
-
function
|
|
3321
|
+
function Ci(s, t, e = {}) {
|
|
3281
3322
|
const i = { type: "Feature" };
|
|
3282
3323
|
return (e.id === 0 || e.id) && (i.id = e.id), e.bbox && (i.bbox = e.bbox), i.properties = t || {}, i.geometry = s, i;
|
|
3283
3324
|
}
|
|
3284
|
-
function
|
|
3325
|
+
function Pi(s, t, e = {}) {
|
|
3285
3326
|
if (!s)
|
|
3286
3327
|
throw new Error("coordinates is required");
|
|
3287
3328
|
if (!Array.isArray(s))
|
|
3288
3329
|
throw new Error("coordinates must be an Array");
|
|
3289
3330
|
if (s.length < 2)
|
|
3290
3331
|
throw new Error("coordinates must be at least 2 numbers long");
|
|
3291
|
-
if (
|
|
3332
|
+
if (!$t(s[0]) || !$t(s[1]))
|
|
3292
3333
|
throw new Error("coordinates must contain numbers");
|
|
3293
|
-
return
|
|
3334
|
+
return Ci({
|
|
3294
3335
|
type: "Point",
|
|
3295
3336
|
coordinates: s
|
|
3296
3337
|
}, t, e);
|
|
3297
3338
|
}
|
|
3298
|
-
function
|
|
3299
|
-
const e =
|
|
3339
|
+
function xi(s, t = "kilometers") {
|
|
3340
|
+
const e = vi[t];
|
|
3300
3341
|
if (!e)
|
|
3301
3342
|
throw new Error(t + " units is invalid");
|
|
3302
3343
|
return s * e;
|
|
3303
3344
|
}
|
|
3304
|
-
function
|
|
3345
|
+
function ct(s) {
|
|
3305
3346
|
return s % 360 * Math.PI / 180;
|
|
3306
3347
|
}
|
|
3307
|
-
function
|
|
3348
|
+
function $t(s) {
|
|
3308
3349
|
return !isNaN(s) && s !== null && !Array.isArray(s);
|
|
3309
3350
|
}
|
|
3310
|
-
function
|
|
3351
|
+
function qt(s) {
|
|
3311
3352
|
if (!s)
|
|
3312
3353
|
throw new Error("coord is required");
|
|
3313
3354
|
if (!Array.isArray(s)) {
|
|
@@ -3320,86 +3361,86 @@ function $t(s) {
|
|
|
3320
3361
|
return [...s];
|
|
3321
3362
|
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
3322
3363
|
}
|
|
3323
|
-
function
|
|
3324
|
-
var i =
|
|
3325
|
-
return
|
|
3326
|
-
2 * Math.atan2(Math.sqrt(
|
|
3364
|
+
function Si(s, t, e = {}) {
|
|
3365
|
+
var i = qt(s), o = qt(t), r = ct(o[1] - i[1]), n = ct(o[0] - i[0]), a = ct(i[1]), l = ct(o[1]), d = Math.pow(Math.sin(r / 2), 2) + Math.pow(Math.sin(n / 2), 2) * Math.cos(a) * Math.cos(l);
|
|
3366
|
+
return xi(
|
|
3367
|
+
2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
|
|
3327
3368
|
e.units
|
|
3328
3369
|
);
|
|
3329
3370
|
}
|
|
3330
3371
|
function Se(s, t, e) {
|
|
3331
3372
|
if (s !== null)
|
|
3332
|
-
for (var i, o, r, n, a, l,
|
|
3333
|
-
|
|
3334
|
-
for (var
|
|
3335
|
-
var
|
|
3336
|
-
if (n = u ?
|
|
3373
|
+
for (var i, o, r, n, a, l, d, c = 0, h = 0, u, g = s.type, p = g === "FeatureCollection", y = g === "Feature", m = p ? s.features.length : 1, f = 0; f < m; f++) {
|
|
3374
|
+
d = p ? s.features[f].geometry : y ? s.geometry : s, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
|
|
3375
|
+
for (var C = 0; C < a; C++) {
|
|
3376
|
+
var v = 0, P = 0;
|
|
3377
|
+
if (n = u ? d.geometries[C] : d, n !== null) {
|
|
3337
3378
|
l = n.coordinates;
|
|
3338
|
-
var
|
|
3339
|
-
switch (
|
|
3379
|
+
var S = n.type;
|
|
3380
|
+
switch (c = S === "Polygon" || S === "MultiPolygon" ? 1 : 0, S) {
|
|
3340
3381
|
case null:
|
|
3341
3382
|
break;
|
|
3342
3383
|
case "Point":
|
|
3343
3384
|
if (t(
|
|
3344
3385
|
l,
|
|
3345
|
-
|
|
3386
|
+
h,
|
|
3346
3387
|
f,
|
|
3347
|
-
|
|
3348
|
-
|
|
3388
|
+
v,
|
|
3389
|
+
P
|
|
3349
3390
|
) === !1)
|
|
3350
3391
|
return !1;
|
|
3351
|
-
|
|
3392
|
+
h++, v++;
|
|
3352
3393
|
break;
|
|
3353
3394
|
case "LineString":
|
|
3354
3395
|
case "MultiPoint":
|
|
3355
3396
|
for (i = 0; i < l.length; i++) {
|
|
3356
3397
|
if (t(
|
|
3357
3398
|
l[i],
|
|
3358
|
-
|
|
3399
|
+
h,
|
|
3359
3400
|
f,
|
|
3360
|
-
|
|
3361
|
-
|
|
3401
|
+
v,
|
|
3402
|
+
P
|
|
3362
3403
|
) === !1)
|
|
3363
3404
|
return !1;
|
|
3364
|
-
|
|
3405
|
+
h++, S === "MultiPoint" && v++;
|
|
3365
3406
|
}
|
|
3366
|
-
|
|
3407
|
+
S === "LineString" && v++;
|
|
3367
3408
|
break;
|
|
3368
3409
|
case "Polygon":
|
|
3369
3410
|
case "MultiLineString":
|
|
3370
3411
|
for (i = 0; i < l.length; i++) {
|
|
3371
|
-
for (o = 0; o < l[i].length -
|
|
3412
|
+
for (o = 0; o < l[i].length - c; o++) {
|
|
3372
3413
|
if (t(
|
|
3373
3414
|
l[i][o],
|
|
3374
|
-
|
|
3415
|
+
h,
|
|
3375
3416
|
f,
|
|
3376
|
-
|
|
3377
|
-
|
|
3417
|
+
v,
|
|
3418
|
+
P
|
|
3378
3419
|
) === !1)
|
|
3379
3420
|
return !1;
|
|
3380
|
-
|
|
3421
|
+
h++;
|
|
3381
3422
|
}
|
|
3382
|
-
|
|
3423
|
+
S === "MultiLineString" && v++, S === "Polygon" && P++;
|
|
3383
3424
|
}
|
|
3384
|
-
|
|
3425
|
+
S === "Polygon" && v++;
|
|
3385
3426
|
break;
|
|
3386
3427
|
case "MultiPolygon":
|
|
3387
3428
|
for (i = 0; i < l.length; i++) {
|
|
3388
|
-
for (
|
|
3389
|
-
for (r = 0; r < l[i][o].length -
|
|
3429
|
+
for (P = 0, o = 0; o < l[i].length; o++) {
|
|
3430
|
+
for (r = 0; r < l[i][o].length - c; r++) {
|
|
3390
3431
|
if (t(
|
|
3391
3432
|
l[i][o][r],
|
|
3392
|
-
|
|
3433
|
+
h,
|
|
3393
3434
|
f,
|
|
3394
|
-
|
|
3395
|
-
|
|
3435
|
+
v,
|
|
3436
|
+
P
|
|
3396
3437
|
) === !1)
|
|
3397
3438
|
return !1;
|
|
3398
|
-
|
|
3439
|
+
h++;
|
|
3399
3440
|
}
|
|
3400
|
-
|
|
3441
|
+
P++;
|
|
3401
3442
|
}
|
|
3402
|
-
|
|
3443
|
+
v++;
|
|
3403
3444
|
}
|
|
3404
3445
|
break;
|
|
3405
3446
|
case "GeometryCollection":
|
|
@@ -3414,17 +3455,17 @@ function Se(s, t, e) {
|
|
|
3414
3455
|
}
|
|
3415
3456
|
}
|
|
3416
3457
|
}
|
|
3417
|
-
function
|
|
3418
|
-
var e, i, o, r, n, a, l, c, h,
|
|
3458
|
+
function Mi(s, t) {
|
|
3459
|
+
var e, i, o, r, n, a, l, d, c, h, u = 0, g = s.type === "FeatureCollection", p = s.type === "Feature", y = g ? s.features.length : 1;
|
|
3419
3460
|
for (e = 0; e < y; e++) {
|
|
3420
|
-
for (a = g ? s.features[e].geometry : p ? s.geometry : s,
|
|
3461
|
+
for (a = g ? s.features[e].geometry : p ? s.geometry : s, d = g ? s.features[e].properties : p ? s.properties : {}, c = g ? s.features[e].bbox : p ? s.bbox : void 0, h = g ? s.features[e].id : p ? s.id : void 0, l = a ? a.type === "GeometryCollection" : !1, n = l ? a.geometries.length : 1, o = 0; o < n; o++) {
|
|
3421
3462
|
if (r = l ? a.geometries[o] : a, r === null) {
|
|
3422
3463
|
if (t(
|
|
3423
3464
|
null,
|
|
3424
3465
|
u,
|
|
3466
|
+
d,
|
|
3425
3467
|
c,
|
|
3426
|
-
h
|
|
3427
|
-
d
|
|
3468
|
+
h
|
|
3428
3469
|
) === !1)
|
|
3429
3470
|
return !1;
|
|
3430
3471
|
continue;
|
|
@@ -3439,9 +3480,9 @@ function ui(s, t) {
|
|
|
3439
3480
|
if (t(
|
|
3440
3481
|
r,
|
|
3441
3482
|
u,
|
|
3483
|
+
d,
|
|
3442
3484
|
c,
|
|
3443
|
-
h
|
|
3444
|
-
d
|
|
3485
|
+
h
|
|
3445
3486
|
) === !1)
|
|
3446
3487
|
return !1;
|
|
3447
3488
|
break;
|
|
@@ -3451,9 +3492,9 @@ function ui(s, t) {
|
|
|
3451
3492
|
if (t(
|
|
3452
3493
|
r.geometries[i],
|
|
3453
3494
|
u,
|
|
3495
|
+
d,
|
|
3454
3496
|
c,
|
|
3455
|
-
h
|
|
3456
|
-
d
|
|
3497
|
+
h
|
|
3457
3498
|
) === !1)
|
|
3458
3499
|
return !1;
|
|
3459
3500
|
break;
|
|
@@ -3465,9 +3506,9 @@ function ui(s, t) {
|
|
|
3465
3506
|
u++;
|
|
3466
3507
|
}
|
|
3467
3508
|
}
|
|
3468
|
-
function
|
|
3509
|
+
function bi(s, t, e) {
|
|
3469
3510
|
var i = e;
|
|
3470
|
-
return
|
|
3511
|
+
return Mi(
|
|
3471
3512
|
s,
|
|
3472
3513
|
function(o, r, n, a, l) {
|
|
3473
3514
|
r === 0 && e === void 0 ? i = o : i = t(
|
|
@@ -3481,21 +3522,21 @@ function gi(s, t, e) {
|
|
|
3481
3522
|
}
|
|
3482
3523
|
), i;
|
|
3483
3524
|
}
|
|
3484
|
-
function
|
|
3485
|
-
return
|
|
3525
|
+
function wi(s) {
|
|
3526
|
+
return bi(
|
|
3486
3527
|
s,
|
|
3487
|
-
(t, e) => t +
|
|
3528
|
+
(t, e) => t + Fi(e),
|
|
3488
3529
|
0
|
|
3489
3530
|
);
|
|
3490
3531
|
}
|
|
3491
|
-
function
|
|
3532
|
+
function Fi(s) {
|
|
3492
3533
|
let t = 0, e;
|
|
3493
3534
|
switch (s.type) {
|
|
3494
3535
|
case "Polygon":
|
|
3495
|
-
return
|
|
3536
|
+
return Zt(s.coordinates);
|
|
3496
3537
|
case "MultiPolygon":
|
|
3497
3538
|
for (e = 0; e < s.coordinates.length; e++)
|
|
3498
|
-
t +=
|
|
3539
|
+
t += Zt(s.coordinates[e]);
|
|
3499
3540
|
return t;
|
|
3500
3541
|
case "Point":
|
|
3501
3542
|
case "MultiPoint":
|
|
@@ -3505,52 +3546,52 @@ function yi(s) {
|
|
|
3505
3546
|
}
|
|
3506
3547
|
return 0;
|
|
3507
3548
|
}
|
|
3508
|
-
function
|
|
3549
|
+
function Zt(s) {
|
|
3509
3550
|
let t = 0;
|
|
3510
3551
|
if (s && s.length > 0) {
|
|
3511
|
-
t += Math.abs(
|
|
3552
|
+
t += Math.abs(Qt(s[0]));
|
|
3512
3553
|
for (let e = 1; e < s.length; e++)
|
|
3513
|
-
t -= Math.abs(
|
|
3554
|
+
t -= Math.abs(Qt(s[e]));
|
|
3514
3555
|
}
|
|
3515
3556
|
return t;
|
|
3516
3557
|
}
|
|
3517
|
-
var
|
|
3518
|
-
function
|
|
3558
|
+
var Ei = D * D / 2, bt = Math.PI / 180;
|
|
3559
|
+
function Qt(s) {
|
|
3519
3560
|
const t = s.length - 1;
|
|
3520
3561
|
if (t <= 2)
|
|
3521
3562
|
return 0;
|
|
3522
3563
|
let e = 0, i = 0;
|
|
3523
3564
|
for (; i < t; ) {
|
|
3524
|
-
const o = s[i], r = s[i + 1 === t ? 0 : i + 1], n = s[i + 2 >= t ? (i + 2) % t : i + 2], a = o[0] *
|
|
3525
|
-
e += (
|
|
3565
|
+
const o = s[i], r = s[i + 1 === t ? 0 : i + 1], n = s[i + 2 >= t ? (i + 2) % t : i + 2], a = o[0] * bt, l = r[1] * bt, d = n[0] * bt;
|
|
3566
|
+
e += (d - a) * Math.sin(l), i++;
|
|
3526
3567
|
}
|
|
3527
|
-
return e *
|
|
3568
|
+
return e * Ei;
|
|
3528
3569
|
}
|
|
3529
|
-
function
|
|
3570
|
+
function Ii(s, t = {}) {
|
|
3530
3571
|
let e = 0, i = 0, o = 0;
|
|
3531
3572
|
return Se(
|
|
3532
3573
|
s,
|
|
3533
3574
|
function(r) {
|
|
3534
3575
|
e += r[0], i += r[1], o++;
|
|
3535
3576
|
}
|
|
3536
|
-
),
|
|
3577
|
+
), Pi([e / o, i / o], t.properties);
|
|
3537
3578
|
}
|
|
3538
|
-
class
|
|
3579
|
+
class ki extends mi {
|
|
3539
3580
|
/**
|
|
3540
3581
|
* Constructor
|
|
3541
3582
|
* @param options Plugin control options
|
|
3542
3583
|
*/
|
|
3543
3584
|
constructor(e) {
|
|
3544
|
-
let i =
|
|
3585
|
+
let i = yi;
|
|
3545
3586
|
e && (i = Object.assign(i, e));
|
|
3546
3587
|
super({
|
|
3547
3588
|
modes: i.modes,
|
|
3548
3589
|
open: i.open,
|
|
3549
3590
|
modeOptions: i.modeOptions
|
|
3550
3591
|
});
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3592
|
+
L(this, "lineLayerLabelSpec");
|
|
3593
|
+
L(this, "lineLayerNodeSpec");
|
|
3594
|
+
L(this, "polygonLayerSpec");
|
|
3554
3595
|
this.lineLayerLabelSpec = i.lineLayerLabelSpec, this.lineLayerNodeSpec = i.lineLayerNodeSpec, this.polygonLayerSpec = i.polygonLayerSpec;
|
|
3555
3596
|
}
|
|
3556
3597
|
/**
|
|
@@ -3599,12 +3640,14 @@ class xi extends ni {
|
|
|
3599
3640
|
if (!this.map) return;
|
|
3600
3641
|
const l = this.getTerraDrawInstance();
|
|
3601
3642
|
if (!l) return;
|
|
3602
|
-
const
|
|
3603
|
-
for (const
|
|
3604
|
-
const
|
|
3605
|
-
if (
|
|
3606
|
-
|
|
3607
|
-
|
|
3643
|
+
const d = l.getSnapshot();
|
|
3644
|
+
for (const c of a) {
|
|
3645
|
+
const h = d == null ? void 0 : d.find((u) => u.id === c);
|
|
3646
|
+
if (h) {
|
|
3647
|
+
const u = h.geometry.type, g = h.properties.mode;
|
|
3648
|
+
g === "linestring" && u === "LineString" ? this.measureLine(c) : !["point", "linestring", "select", "render"].includes(g) && u === "Polygon" && this.measurePolygon(c);
|
|
3649
|
+
} else
|
|
3650
|
+
this.clearMeasureFeatures(c, this.lineLayerNodeSpec.source), this.clearMeasureFeatures(c, this.lineLayerLabelSpec.source), this.clearMeasureFeatures(c, this.polygonLayerSpec.source);
|
|
3608
3651
|
}
|
|
3609
3652
|
}), this.on("feature-deleted", this.onFeatureDeleted.bind(this)));
|
|
3610
3653
|
}
|
|
@@ -3615,6 +3658,23 @@ class xi extends ni {
|
|
|
3615
3658
|
unregisterMesureControl() {
|
|
3616
3659
|
this.off("feature-deleted", this.onFeatureDeleted.bind(this)), this.map && (this.map.getLayer(this.lineLayerLabelSpec.id) && this.map.removeLayer(this.lineLayerLabelSpec.id), this.map.getLayer(this.lineLayerNodeSpec.id) && this.map.removeLayer(this.lineLayerNodeSpec.id), this.map.getLayer(this.polygonLayerSpec.id) && this.map.removeLayer(this.polygonLayerSpec.id), this.map.getSource(this.lineLayerLabelSpec.source) && this.map.removeSource(this.lineLayerLabelSpec.source), this.map.getSource(this.polygonLayerSpec.source) && this.map.removeSource(this.polygonLayerSpec.source));
|
|
3617
3660
|
}
|
|
3661
|
+
/**
|
|
3662
|
+
* Clear GeoJSON feature related to measure control by TerraDraw feature ID
|
|
3663
|
+
* @param id feature ID
|
|
3664
|
+
* @param sourceId source ID to delete
|
|
3665
|
+
* @returns void
|
|
3666
|
+
*/
|
|
3667
|
+
clearMeasureFeatures(e, i) {
|
|
3668
|
+
var r;
|
|
3669
|
+
if (!this.map) return;
|
|
3670
|
+
const o = this.map.getStyle().sources[i];
|
|
3671
|
+
o && typeof o.data != "string" && o.data.type === "FeatureCollection" && (o.data.features = o.data.features.filter(
|
|
3672
|
+
(n) => {
|
|
3673
|
+
var a;
|
|
3674
|
+
return ((a = n.properties) == null ? void 0 : a.originalId) !== e;
|
|
3675
|
+
}
|
|
3676
|
+
), (r = this.map.getSource(i)) == null || r.setData(o.data));
|
|
3677
|
+
}
|
|
3618
3678
|
/**
|
|
3619
3679
|
* measure polygon area for given feature ID
|
|
3620
3680
|
* @param id terradraw feature id
|
|
@@ -3634,10 +3694,10 @@ class xi extends ni {
|
|
|
3634
3694
|
return ((g = u.properties) == null ? void 0 : g.originalId) !== e;
|
|
3635
3695
|
}
|
|
3636
3696
|
));
|
|
3637
|
-
const l =
|
|
3638
|
-
|
|
3639
|
-
let
|
|
3640
|
-
l > 1e4 ? (
|
|
3697
|
+
const l = wi(r.geometry), d = JSON.parse(JSON.stringify(r));
|
|
3698
|
+
d.id = d.id + "-area-label", d.geometry = Ii(r.geometry).geometry, d.properties.originalId = r.id;
|
|
3699
|
+
let c = l, h = "m2";
|
|
3700
|
+
l > 1e4 ? (c = l / 1e4, h = "ha") : l > 1e3 && (c = l / 1e3, h = "km2"), d.properties.area = c.toFixed(2), d.properties.unit = h, typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(d), (n = this.map.getSource(this.polygonLayerSpec.source)) == null || n.setData(
|
|
3641
3701
|
a.data
|
|
3642
3702
|
), this.map.moveLayer(this.polygonLayerSpec.id);
|
|
3643
3703
|
}
|
|
@@ -3658,28 +3718,28 @@ class xi extends ni {
|
|
|
3658
3718
|
if (a) {
|
|
3659
3719
|
const l = r.geometry.coordinates;
|
|
3660
3720
|
typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
|
|
3661
|
-
(
|
|
3662
|
-
var
|
|
3663
|
-
return ((
|
|
3721
|
+
(c) => {
|
|
3722
|
+
var h;
|
|
3723
|
+
return ((h = c.properties) == null ? void 0 : h.originalId) !== e;
|
|
3664
3724
|
}
|
|
3665
3725
|
));
|
|
3666
|
-
let
|
|
3667
|
-
for (let
|
|
3668
|
-
const
|
|
3669
|
-
|
|
3726
|
+
let d = 0;
|
|
3727
|
+
for (let c = 0; c < l.length - 1; c++) {
|
|
3728
|
+
const h = l[c], u = l[c + 1], g = Si(h, u, { units: "kilometers" });
|
|
3729
|
+
d += g;
|
|
3670
3730
|
const p = JSON.parse(JSON.stringify(r));
|
|
3671
|
-
if (p.id = `${p.id}-${
|
|
3731
|
+
if (p.id = `${p.id}-${c}`, p.geometry.coordinates = [h, u], p.properties.originalId = r.id, p.properties.distance = g.toFixed(2), p.properties.total = d.toFixed(2), p.properties.unit = "km", typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(p), c === 0) {
|
|
3672
3732
|
const m = JSON.parse(JSON.stringify(r));
|
|
3673
|
-
m.id = `${p.id}-node-${
|
|
3733
|
+
m.id = `${p.id}-node-${c}`, m.geometry = {
|
|
3674
3734
|
type: "Point",
|
|
3675
|
-
coordinates:
|
|
3735
|
+
coordinates: h
|
|
3676
3736
|
}, m.properties.originalId = r.id, m.properties.distance = 0, m.properties.total = 0, m.properties.unit = "km", typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(m);
|
|
3677
3737
|
}
|
|
3678
3738
|
const y = JSON.parse(JSON.stringify(r));
|
|
3679
|
-
y.id = `${p.id}-node-${
|
|
3739
|
+
y.id = `${p.id}-node-${c + 1}`, y.geometry = {
|
|
3680
3740
|
type: "Point",
|
|
3681
3741
|
coordinates: u
|
|
3682
|
-
}, y.properties.originalId = r.id, y.properties.distance = g.toFixed(2), y.properties.total =
|
|
3742
|
+
}, y.properties.originalId = r.id, y.properties.distance = g.toFixed(2), y.properties.total = d.toFixed(2), y.properties.unit = "km", typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(y);
|
|
3683
3743
|
}
|
|
3684
3744
|
(n = this.map.getSource(this.lineLayerLabelSpec.source)) == null || n.setData(
|
|
3685
3745
|
a.data
|
|
@@ -3699,13 +3759,13 @@ class xi extends ni {
|
|
|
3699
3759
|
for (const n of r) {
|
|
3700
3760
|
const a = this.map.getStyle().sources[n];
|
|
3701
3761
|
if (a) {
|
|
3702
|
-
const l = e.getSnapshot(),
|
|
3703
|
-
(
|
|
3704
|
-
)).map((
|
|
3762
|
+
const l = e.getSnapshot(), c = (l == null ? void 0 : l.filter(
|
|
3763
|
+
(h) => ["LineString", "Polygon"].includes(h.geometry.type)
|
|
3764
|
+
)).map((h) => h.id);
|
|
3705
3765
|
typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
|
|
3706
|
-
(
|
|
3766
|
+
(h) => {
|
|
3707
3767
|
var u;
|
|
3708
|
-
return
|
|
3768
|
+
return c.includes((u = h.properties) == null ? void 0 : u.originalId);
|
|
3709
3769
|
}
|
|
3710
3770
|
)), n === this.lineLayerLabelSpec.source ? ((i = this.map.getSource(this.lineLayerLabelSpec.source)) == null || i.setData(
|
|
3711
3771
|
a.data
|
|
@@ -3718,12 +3778,12 @@ class xi extends ni {
|
|
|
3718
3778
|
}
|
|
3719
3779
|
}
|
|
3720
3780
|
export {
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3781
|
+
Oi as AvailableMeasureModes,
|
|
3782
|
+
Di as AvailableModes,
|
|
3783
|
+
ki as MaplibreMeasureControl,
|
|
3784
|
+
mi as MaplibreTerradrawControl,
|
|
3785
|
+
pi as defaultControlOptions,
|
|
3786
|
+
yi as defaultMeasureControlOptions,
|
|
3787
|
+
fi as getDefaultModeOptions
|
|
3728
3788
|
};
|
|
3729
3789
|
//# sourceMappingURL=maplibre-gl-terradraw.es.js.map
|