@watergis/maplibre-gl-terradraw 0.8.1 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/maplibre-gl-terradraw.es.js +887 -805
- package/dist/maplibre-gl-terradraw.es.js.map +1 -1
- package/dist/maplibre-gl-terradraw.umd.js +3 -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 +4 -0
- package/dist/types/controls/MaplibreMeasureControl.d.ts.map +1 -1
- package/dist/types/interfaces/MeasureControlOptions.d.ts +1 -0
- package/dist/types/interfaces/MeasureControlOptions.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
var
|
|
2
|
-
var Wt = (
|
|
3
|
-
var
|
|
1
|
+
var kt = Object.defineProperty;
|
|
2
|
+
var Wt = (s, e, t) => e in s ? kt(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var k = (s, e, t) => Wt(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
function M() {
|
|
5
|
-
return M = Object.assign ? Object.assign.bind() : function(
|
|
5
|
+
return M = Object.assign ? Object.assign.bind() : function(s) {
|
|
6
6
|
for (var e = 1; e < arguments.length; e++) {
|
|
7
7
|
var t = arguments[e];
|
|
8
|
-
for (var i in t) Object.prototype.hasOwnProperty.call(t, i) && (
|
|
8
|
+
for (var i in t) Object.prototype.hasOwnProperty.call(t, i) && (s[i] = t[i]);
|
|
9
9
|
}
|
|
10
|
-
return
|
|
10
|
+
return s;
|
|
11
11
|
}, M.apply(this, arguments);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function E(s, e = 9) {
|
|
14
14
|
const t = Math.pow(10, e);
|
|
15
|
-
return Math.round(
|
|
15
|
+
return Math.round(s * t) / t;
|
|
16
16
|
}
|
|
17
|
-
const
|
|
18
|
-
const { x: t, y: i } =
|
|
17
|
+
const F = (s, e) => {
|
|
18
|
+
const { x: t, y: i } = s, { x: n, y: o } = e, r = n - t, a = o - i;
|
|
19
19
|
return Math.sqrt(a * a + r * r);
|
|
20
20
|
};
|
|
21
|
-
class
|
|
21
|
+
class $ {
|
|
22
22
|
constructor({ name: e, callback: t, unregister: i, register: n }) {
|
|
23
23
|
this.name = void 0, this.callback = void 0, this.registered = !1, this.register = void 0, this.unregister = void 0, this.name = e, this.register = () => {
|
|
24
24
|
this.registered || (this.registered = !0, n(t));
|
|
@@ -41,8 +41,8 @@ class ct {
|
|
|
41
41
|
getDrawEventFromEvent(e) {
|
|
42
42
|
const t = this.getLngLatFromEvent(e);
|
|
43
43
|
if (!t) return null;
|
|
44
|
-
const { lng: i, lat: n } = t, { containerX:
|
|
45
|
-
return { lng:
|
|
44
|
+
const { lng: i, lat: n } = t, { containerX: o, containerY: r } = this.getMapElementXYPosition(e), a = this.getButton(e), l = Array.from(this._heldKeys);
|
|
45
|
+
return { lng: E(i, this._coordinatePrecision), lat: E(n, this._coordinatePrecision), containerX: o, containerY: r, button: a, heldKeys: l };
|
|
46
46
|
}
|
|
47
47
|
register(e) {
|
|
48
48
|
this._currentModeCallbacks = e, this._listeners = this.getAdapterListeners(), this._listeners.forEach((t) => {
|
|
@@ -53,7 +53,7 @@ class ct {
|
|
|
53
53
|
return this._coordinatePrecision;
|
|
54
54
|
}
|
|
55
55
|
getAdapterListeners() {
|
|
56
|
-
return [new
|
|
56
|
+
return [new $({ name: "pointerdown", callback: (e) => {
|
|
57
57
|
if (!this._currentModeCallbacks || !e.isPrimary) return;
|
|
58
58
|
const t = this.getDrawEventFromEvent(e);
|
|
59
59
|
t && (this._dragState = "pre-dragging", this._lastDrawEvent = t);
|
|
@@ -61,16 +61,16 @@ class ct {
|
|
|
61
61
|
this.getMapEventElement().addEventListener("pointerdown", e);
|
|
62
62
|
}, unregister: (e) => {
|
|
63
63
|
this.getMapEventElement().removeEventListener("pointerdown", e);
|
|
64
|
-
} }), new
|
|
64
|
+
} }), new $({ name: "pointermove", callback: (e) => {
|
|
65
65
|
if (!this._currentModeCallbacks || !e.isPrimary) return;
|
|
66
66
|
e.preventDefault();
|
|
67
67
|
const t = this.getDrawEventFromEvent(e);
|
|
68
68
|
if (t) if (this._dragState === "not-dragging") this._currentModeCallbacks.onMouseMove(t), this._lastDrawEvent = t;
|
|
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 }, n = { x: t.containerX, y: t.containerY },
|
|
71
|
+
const i = { x: this._lastDrawEvent.containerX, y: this._lastDrawEvent.containerY }, n = { x: t.containerX, y: t.containerY }, o = this._currentModeCallbacks.getState(), r = F(i, n);
|
|
72
72
|
let a = !1;
|
|
73
|
-
if (a =
|
|
73
|
+
if (a = o === "drawing" ? r < this._minPixelDragDistanceDrawing : o === "selecting" ? r < this._minPixelDragDistanceSelecting : r < this._minPixelDragDistance, a) return;
|
|
74
74
|
this._dragState = "dragging", this._currentModeCallbacks.onDragStart(t, (l) => {
|
|
75
75
|
this.setDraggability.bind(this)(l);
|
|
76
76
|
});
|
|
@@ -81,13 +81,13 @@ class ct {
|
|
|
81
81
|
this.getMapEventElement().addEventListener("pointermove", e);
|
|
82
82
|
}, unregister: (e) => {
|
|
83
83
|
this.getMapEventElement().removeEventListener("pointermove", e);
|
|
84
|
-
} }), new
|
|
84
|
+
} }), new $({ name: "contextmenu", callback: (e) => {
|
|
85
85
|
this._currentModeCallbacks && e.preventDefault();
|
|
86
86
|
}, register: (e) => {
|
|
87
87
|
this.getMapEventElement().addEventListener("contextmenu", e);
|
|
88
88
|
}, unregister: (e) => {
|
|
89
89
|
this.getMapEventElement().removeEventListener("contextmenu", e);
|
|
90
|
-
} }), new
|
|
90
|
+
} }), new $({ name: "pointerup", callback: (e) => {
|
|
91
91
|
if (!this._currentModeCallbacks || e.target !== this.getMapEventElement() || !e.isPrimary) return;
|
|
92
92
|
const t = this.getDrawEventFromEvent(e);
|
|
93
93
|
t && (this._dragState === "dragging" ? this._currentModeCallbacks.onDragEnd(t, (i) => {
|
|
@@ -97,13 +97,13 @@ class ct {
|
|
|
97
97
|
this.getMapEventElement().addEventListener("pointerup", e);
|
|
98
98
|
}, unregister: (e) => {
|
|
99
99
|
this.getMapEventElement().removeEventListener("pointerup", e);
|
|
100
|
-
} }), new
|
|
100
|
+
} }), new $({ name: "keyup", callback: (e) => {
|
|
101
101
|
this._currentModeCallbacks && (this._heldKeys.delete(e.key), this._currentModeCallbacks.onKeyUp({ key: e.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => e.preventDefault() }));
|
|
102
102
|
}, register: (e) => {
|
|
103
103
|
this.getMapEventElement().addEventListener("keyup", e);
|
|
104
104
|
}, unregister: (e) => {
|
|
105
105
|
this.getMapEventElement().removeEventListener("keyup", e);
|
|
106
|
-
} }), new
|
|
106
|
+
} }), new $({ name: "keydown", callback: (e) => {
|
|
107
107
|
this._currentModeCallbacks && (this._heldKeys.add(e.key), this._currentModeCallbacks.onKeyDown({ key: e.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => e.preventDefault() }));
|
|
108
108
|
}, register: (e) => {
|
|
109
109
|
this.getMapEventElement().addEventListener("keydown", e);
|
|
@@ -185,18 +185,18 @@ class jt extends ct {
|
|
|
185
185
|
}
|
|
186
186
|
render(e, t) {
|
|
187
187
|
this.updateChangedIds(e), this._nextRender && cancelAnimationFrame(this._nextRender), this._nextRender = requestAnimationFrame(() => {
|
|
188
|
-
const i = [...e.created, ...e.updated, ...e.unchanged], n = [],
|
|
188
|
+
const i = [...e.created, ...e.updated, ...e.unchanged], n = [], o = [], r = [];
|
|
189
189
|
for (let a = 0; a < i.length; a++) {
|
|
190
190
|
const l = i[a], { properties: d } = l, c = t[d.mode](l);
|
|
191
|
-
l.geometry.type === "Point" ? (d.pointColor = c.pointColor, d.pointOutlineColor = c.pointOutlineColor, d.pointOutlineWidth = c.pointOutlineWidth, d.pointWidth = c.pointWidth, n.push(l)) : l.geometry.type === "LineString" ? (d.lineStringColor = c.lineStringColor, d.lineStringWidth = c.lineStringWidth,
|
|
191
|
+
l.geometry.type === "Point" ? (d.pointColor = c.pointColor, d.pointOutlineColor = c.pointOutlineColor, d.pointOutlineWidth = c.pointOutlineWidth, d.pointWidth = c.pointWidth, n.push(l)) : l.geometry.type === "LineString" ? (d.lineStringColor = c.lineStringColor, d.lineStringWidth = c.lineStringWidth, o.push(l)) : l.geometry.type === "Polygon" && (d.polygonFillColor = c.polygonFillColor, d.polygonFillOpacity = c.polygonFillOpacity, d.polygonOutlineColor = c.polygonOutlineColor, d.polygonOutlineWidth = c.polygonOutlineWidth, r.push(l));
|
|
192
192
|
}
|
|
193
193
|
if (this._rendered) {
|
|
194
194
|
const a = this.changedIds.deletion || this.changedIds.styling, l = a || this.changedIds.linestrings, d = a || this.changedIds.polygons;
|
|
195
195
|
let c;
|
|
196
|
-
(a || this.changedIds.points) && (c = this._setGeoJSONLayerData("Point", n)), l && this._setGeoJSONLayerData("LineString",
|
|
196
|
+
(a || this.changedIds.points) && (c = this._setGeoJSONLayerData("Point", n)), l && this._setGeoJSONLayerData("LineString", o), d && this._setGeoJSONLayerData("Polygon", r), c && this._map.moveLayer(c);
|
|
197
197
|
} else {
|
|
198
198
|
const a = this._addGeoJSONLayer("Point", n);
|
|
199
|
-
this._addGeoJSONLayer("LineString",
|
|
199
|
+
this._addGeoJSONLayer("LineString", o), this._addGeoJSONLayer("Polygon", r), this._rendered = !0, a && this._map.moveLayer(a);
|
|
200
200
|
}
|
|
201
201
|
this.changedIds = { points: !1, linestrings: !1, polygons: !1, deletion: !1, styling: !1 };
|
|
202
202
|
});
|
|
@@ -258,8 +258,8 @@ class Bt extends ct {
|
|
|
258
258
|
}
|
|
259
259
|
const Nt = { radians: 6370997 / (2 * Math.PI), degrees: 2 * Math.PI * 6370997 / 360, ft: 0.3048, m: 1, "us-ft": 1200 / 3937 };
|
|
260
260
|
var ht = class {
|
|
261
|
-
constructor(
|
|
262
|
-
this.code_ =
|
|
261
|
+
constructor(s) {
|
|
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;
|
|
263
263
|
}
|
|
264
264
|
canWrapX() {
|
|
265
265
|
return this.canWrapX_;
|
|
@@ -285,102 +285,102 @@ var ht = class {
|
|
|
285
285
|
isGlobal() {
|
|
286
286
|
return this.global_;
|
|
287
287
|
}
|
|
288
|
-
setGlobal(
|
|
289
|
-
this.global_ =
|
|
288
|
+
setGlobal(s) {
|
|
289
|
+
this.global_ = s, this.canWrapX_ = !(!s || !this.extent_);
|
|
290
290
|
}
|
|
291
291
|
getDefaultTileGrid() {
|
|
292
292
|
return this.defaultTileGrid_;
|
|
293
293
|
}
|
|
294
|
-
setDefaultTileGrid(
|
|
295
|
-
this.defaultTileGrid_ =
|
|
294
|
+
setDefaultTileGrid(s) {
|
|
295
|
+
this.defaultTileGrid_ = s;
|
|
296
296
|
}
|
|
297
|
-
setExtent(
|
|
298
|
-
this.extent_ =
|
|
297
|
+
setExtent(s) {
|
|
298
|
+
this.extent_ = s, this.canWrapX_ = !(!this.global_ || !s);
|
|
299
299
|
}
|
|
300
|
-
setWorldExtent(
|
|
301
|
-
this.worldExtent_ =
|
|
300
|
+
setWorldExtent(s) {
|
|
301
|
+
this.worldExtent_ = s;
|
|
302
302
|
}
|
|
303
|
-
setGetPointResolution(
|
|
304
|
-
this.getPointResolutionFunc_ =
|
|
303
|
+
setGetPointResolution(s) {
|
|
304
|
+
this.getPointResolutionFunc_ = s;
|
|
305
305
|
}
|
|
306
306
|
getPointResolutionFunc() {
|
|
307
307
|
return this.getPointResolutionFunc_;
|
|
308
308
|
}
|
|
309
309
|
};
|
|
310
|
-
const re = 6378137, Q = Math.PI * re,
|
|
311
|
-
class
|
|
310
|
+
const re = 6378137, Q = Math.PI * re, At = [-Q, -Q, Q, Q], Gt = [-180, -85, 180, 85], ce = re * Math.log(Math.tan(Math.PI / 2));
|
|
311
|
+
class J extends ht {
|
|
312
312
|
constructor(e) {
|
|
313
|
-
super({ code: e, units: "m", extent:
|
|
313
|
+
super({ code: e, units: "m", extent: At, global: !0, worldExtent: Gt, getPointResolution: function(t, i) {
|
|
314
314
|
return t / Math.cosh(i[1] / re);
|
|
315
315
|
} });
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
|
-
const
|
|
319
|
-
class
|
|
318
|
+
const Te = [new J("EPSG:3857"), new J("EPSG:102100"), new J("EPSG:102113"), new J("EPSG:900913"), new J("http://www.opengis.net/def/crs/EPSG/0/3857"), new J("http://www.opengis.net/gml/srs/epsg.xml#3857")], Ue = [-180, -90, 180, 90], Vt = 6378137 * Math.PI / 180;
|
|
319
|
+
class U extends ht {
|
|
320
320
|
constructor(e, t) {
|
|
321
|
-
super({ code: e, units: "degrees", extent:
|
|
321
|
+
super({ code: e, units: "degrees", extent: Ue, axisOrientation: t, global: !0, metersPerUnit: Vt, worldExtent: Ue });
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
|
-
const Re = [new
|
|
324
|
+
const Re = [new U("CRS:84"), new U("EPSG:4326", "neu"), new U("urn:ogc:def:crs:OGC:1.3:CRS84"), new U("urn:ogc:def:crs:OGC:2:84"), new U("http://www.opengis.net/def/crs/OGC/1.3/CRS84"), new U("http://www.opengis.net/gml/srs/epsg.xml#4326", "neu"), new U("http://www.opengis.net/def/crs/EPSG/0/4326", "neu")];
|
|
325
325
|
let Me = {};
|
|
326
|
-
function
|
|
327
|
-
const i =
|
|
326
|
+
function fe(s, e, t) {
|
|
327
|
+
const i = s.getCode(), n = e.getCode();
|
|
328
328
|
i in Me || (Me[i] = {}), Me[i][n] = t;
|
|
329
329
|
}
|
|
330
|
-
function ut(
|
|
331
|
-
if (e !== void 0) for (let t = 0, i =
|
|
332
|
-
else e =
|
|
330
|
+
function ut(s, e) {
|
|
331
|
+
if (e !== void 0) for (let t = 0, i = s.length; t < i; ++t) e[t] = s[t];
|
|
332
|
+
else e = s.slice();
|
|
333
333
|
return e;
|
|
334
334
|
}
|
|
335
|
-
function
|
|
336
|
-
|
|
335
|
+
function Tt(s) {
|
|
336
|
+
s.getCode(), fe(s, s, ut);
|
|
337
337
|
}
|
|
338
|
-
function Xe(
|
|
338
|
+
function Xe(s) {
|
|
339
339
|
(function(e) {
|
|
340
|
-
e.forEach(
|
|
341
|
-
})(
|
|
342
|
-
|
|
343
|
-
e !== t &&
|
|
340
|
+
e.forEach(Tt);
|
|
341
|
+
})(s), s.forEach(function(e) {
|
|
342
|
+
s.forEach(function(t) {
|
|
343
|
+
e !== t && fe(e, t, ut);
|
|
344
344
|
});
|
|
345
345
|
});
|
|
346
346
|
}
|
|
347
|
-
var
|
|
348
|
-
Xe(
|
|
349
|
-
const i =
|
|
350
|
-
t = t > 1 ? t : 2, e === void 0 && (e = t > 2 ?
|
|
347
|
+
var ze, Ke, Ye, b;
|
|
348
|
+
Xe(Te), Xe(Re), ze = Te, Ke = function(s, e, t) {
|
|
349
|
+
const i = s.length;
|
|
350
|
+
t = t > 1 ? t : 2, e === void 0 && (e = t > 2 ? s.slice() : new Array(i));
|
|
351
351
|
for (let n = 0; n < i; n += t) {
|
|
352
|
-
e[n] = Q *
|
|
353
|
-
let
|
|
354
|
-
|
|
352
|
+
e[n] = Q * s[n] / 180;
|
|
353
|
+
let o = re * Math.log(Math.tan(Math.PI * (+s[n + 1] + 90) / 360));
|
|
354
|
+
o > ce ? o = ce : o < -ce && (o = -ce), e[n + 1] = o;
|
|
355
355
|
}
|
|
356
356
|
return e;
|
|
357
|
-
}, Ye = function(
|
|
358
|
-
const i =
|
|
359
|
-
t = t > 1 ? t : 2, e === void 0 && (e = t > 2 ?
|
|
360
|
-
for (let n = 0; n < i; n += t) e[n] = 180 *
|
|
357
|
+
}, Ye = function(s, e, t) {
|
|
358
|
+
const i = s.length;
|
|
359
|
+
t = t > 1 ? t : 2, e === void 0 && (e = t > 2 ? s.slice() : new Array(i));
|
|
360
|
+
for (let n = 0; n < i; n += t) e[n] = 180 * s[n] / Q, e[n + 1] = 360 * Math.atan(Math.exp(s[n + 1] / re)) / Math.PI - 90;
|
|
361
361
|
return e;
|
|
362
|
-
}, Re.forEach(function(
|
|
363
|
-
|
|
364
|
-
|
|
362
|
+
}, Re.forEach(function(s) {
|
|
363
|
+
ze.forEach(function(e) {
|
|
364
|
+
fe(s, e, Ke), fe(e, s, Ye);
|
|
365
365
|
});
|
|
366
366
|
});
|
|
367
|
-
(function(
|
|
368
|
-
|
|
367
|
+
(function(s) {
|
|
368
|
+
s.Commit = "commit", s.Provisional = "provisional", s.Finish = "finish";
|
|
369
369
|
})(b || (b = {}));
|
|
370
|
-
const
|
|
371
|
-
function we(
|
|
372
|
-
return !!(
|
|
370
|
+
const De = "selected", se = "midPoint", ae = "closingPoint", _e = "snappingPoint";
|
|
371
|
+
function we(s) {
|
|
372
|
+
return !!(s && typeof s == "object" && s !== null && !Array.isArray(s));
|
|
373
373
|
}
|
|
374
|
-
function He(
|
|
374
|
+
function He(s) {
|
|
375
375
|
return !!function(e) {
|
|
376
376
|
return typeof e == "number" && !isNaN(new Date(e).valueOf());
|
|
377
|
-
}(
|
|
377
|
+
}(s);
|
|
378
378
|
}
|
|
379
|
-
const
|
|
380
|
-
var
|
|
381
|
-
(function(
|
|
382
|
-
|
|
383
|
-
})(
|
|
379
|
+
const Ut = "Feature mode property does not match the mode being added to";
|
|
380
|
+
var K;
|
|
381
|
+
(function(s) {
|
|
382
|
+
s.Drawing = "drawing", s.Select = "select", s.Static = "static", s.Render = "render";
|
|
383
|
+
})(K || (K = {}));
|
|
384
384
|
class N {
|
|
385
385
|
get state() {
|
|
386
386
|
return this._state;
|
|
@@ -398,7 +398,7 @@ class N {
|
|
|
398
398
|
registerBehaviors(e) {
|
|
399
399
|
}
|
|
400
400
|
constructor(e) {
|
|
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 =
|
|
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 = K.Drawing, this.mode = "base", this._state = "unregistered", this._styles = e && e.styles ? M({}, e.styles) : {}, this.pointerDistance = e && e.pointerDistance || 40, this.validate = e && e.validation, this.projection = e && e.projection || "web-mercator";
|
|
402
402
|
}
|
|
403
403
|
setDrawing() {
|
|
404
404
|
if (this._state !== "started") throw new Error("Mode must be unregistered or stopped to start");
|
|
@@ -422,18 +422,18 @@ class N {
|
|
|
422
422
|
performFeatureValidation(e) {
|
|
423
423
|
if (this._state === "unregistered") throw new Error("Mode must be registered");
|
|
424
424
|
const t = function(i, n) {
|
|
425
|
-
let
|
|
426
|
-
if (we(i)) if (i.id == null)
|
|
427
|
-
else if (typeof i.id != "string" && typeof i.id != "number")
|
|
425
|
+
let o;
|
|
426
|
+
if (we(i)) if (i.id == null) o = "Feature has no id";
|
|
427
|
+
else if (typeof i.id != "string" && typeof i.id != "number") o = "Feature must be string or number as per GeoJSON spec";
|
|
428
428
|
else if (n(i.id)) if (we(i.geometry)) if (we(i.properties)) if (typeof i.geometry.type == "string" && ["Polygon", "LineString", "Point"].includes(i.geometry.type)) if (Array.isArray(i.geometry.coordinates)) {
|
|
429
429
|
if (!i.properties.mode || typeof i.properties.mode != "string") return { valid: !1, reason: "Feature does not have a valid mode property" };
|
|
430
|
-
} else
|
|
431
|
-
else
|
|
432
|
-
else
|
|
433
|
-
else
|
|
434
|
-
else
|
|
435
|
-
else
|
|
436
|
-
return
|
|
430
|
+
} else o = "Feature coordinates is not an array";
|
|
431
|
+
else o = "Feature is not Point, LineString or Polygon";
|
|
432
|
+
else o = "Feature has no properties";
|
|
433
|
+
else o = "Feature has no geometry";
|
|
434
|
+
else o = "Feature must match the id strategy (default is UUID4)";
|
|
435
|
+
else o = "Feature is not object";
|
|
436
|
+
return o ? { valid: !1, reason: o } : { valid: !0 };
|
|
437
437
|
}(e, this.store.idStrategy.isValidId);
|
|
438
438
|
if (this.validate) {
|
|
439
439
|
const i = this.validate(e, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Provisional });
|
|
@@ -443,7 +443,7 @@ class N {
|
|
|
443
443
|
}
|
|
444
444
|
validateModeFeature(e, t) {
|
|
445
445
|
const i = this.performFeatureValidation(e);
|
|
446
|
-
return i.valid ? e.properties.mode !== this.mode ? { valid: !1, reason:
|
|
446
|
+
return i.valid ? e.properties.mode !== this.mode ? { valid: !1, reason: Ut } : t(e) : { valid: !1, reason: i.reason };
|
|
447
447
|
}
|
|
448
448
|
onFinish(e, t) {
|
|
449
449
|
}
|
|
@@ -477,81 +477,81 @@ class N {
|
|
|
477
477
|
}
|
|
478
478
|
class Rt extends N {
|
|
479
479
|
constructor(...e) {
|
|
480
|
-
super(...e), this.type =
|
|
480
|
+
super(...e), this.type = K.Select;
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
|
-
function V(
|
|
484
|
-
const t = (d) => d * Math.PI / 180, i = t(
|
|
483
|
+
function V(s, e) {
|
|
484
|
+
const t = (d) => d * Math.PI / 180, i = t(s[1]), n = t(s[0]), o = t(e[1]), r = o - i, a = t(e[0]) - n, l = Math.sin(r / 2) * Math.sin(r / 2) + Math.cos(i) * Math.cos(o) * Math.sin(a / 2) * Math.sin(a / 2);
|
|
485
485
|
return 2 * Math.atan2(Math.sqrt(l), Math.sqrt(1 - l)) * 6371e3 / 1e3;
|
|
486
486
|
}
|
|
487
487
|
const Oe = 63710088e-1;
|
|
488
|
-
function
|
|
489
|
-
return
|
|
488
|
+
function D(s) {
|
|
489
|
+
return s % 360 * Math.PI / 180;
|
|
490
490
|
}
|
|
491
|
-
function gt(
|
|
492
|
-
return
|
|
491
|
+
function gt(s) {
|
|
492
|
+
return s / (Oe / 1e3);
|
|
493
493
|
}
|
|
494
|
-
function
|
|
495
|
-
return
|
|
494
|
+
function T(s) {
|
|
495
|
+
return s % (2 * Math.PI) * 180 / Math.PI;
|
|
496
496
|
}
|
|
497
|
-
const
|
|
498
|
-
function Xt(
|
|
499
|
-
const i =
|
|
500
|
-
return [
|
|
497
|
+
const $e = 57.29577951308232, Je = 0.017453292519943295, me = 6378137, S = (s, e) => ({ x: s === 0 ? 0 : s * Je * me, y: e === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + e * Je / 2)) * me }), W = (s, e) => ({ lng: s === 0 ? 0 : $e * (s / me), lat: e === 0 ? 0 : (2 * Math.atan(Math.exp(e / me)) - Math.PI / 2) * $e });
|
|
498
|
+
function Xt(s, e, t) {
|
|
499
|
+
const i = D(s[0]), n = D(s[1]), o = D(t), r = gt(e), a = Math.asin(Math.sin(n) * Math.cos(r) + Math.cos(n) * Math.sin(r) * Math.cos(o));
|
|
500
|
+
return [T(i + Math.atan2(Math.sin(o) * Math.sin(r) * Math.cos(n), Math.cos(r) - Math.sin(n) * Math.sin(a))), T(a)];
|
|
501
501
|
}
|
|
502
|
-
function qe(
|
|
503
|
-
const { center: e, radiusKilometers: t, coordinatePrecision: i } =
|
|
502
|
+
function qe(s) {
|
|
503
|
+
const { center: e, radiusKilometers: t, coordinatePrecision: i } = s, n = s.steps ? s.steps : 64, o = [];
|
|
504
504
|
for (let r = 0; r < n; r++) {
|
|
505
505
|
const a = Xt(e, t, -360 * r / n);
|
|
506
|
-
|
|
506
|
+
o.push([E(a[0], i), E(a[1], i)]);
|
|
507
507
|
}
|
|
508
|
-
return
|
|
508
|
+
return o.push(o[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [o] }, properties: {} };
|
|
509
509
|
}
|
|
510
|
-
function
|
|
510
|
+
function Le(s) {
|
|
511
511
|
const e = { epsilon: 0 };
|
|
512
512
|
let t;
|
|
513
|
-
if (
|
|
513
|
+
if (s.geometry.type === "Polygon") t = s.geometry.coordinates;
|
|
514
514
|
else {
|
|
515
|
-
if (
|
|
516
|
-
t = [
|
|
515
|
+
if (s.geometry.type !== "LineString") throw new Error("Self intersects only accepts Polygons and LineStrings");
|
|
516
|
+
t = [s.geometry.coordinates];
|
|
517
517
|
}
|
|
518
518
|
const i = [];
|
|
519
|
-
for (let r = 0; r < t.length; r++) for (let a = 0; a < t[r].length - 1; a++) for (let l = 0; l < t.length; l++) for (let d = 0; d < t[l].length - 1; d++)
|
|
519
|
+
for (let r = 0; r < t.length; r++) for (let a = 0; a < t[r].length - 1; a++) for (let l = 0; l < t.length; l++) for (let d = 0; d < t[l].length - 1; d++) o(r, a, l, d);
|
|
520
520
|
return i.length > 0;
|
|
521
521
|
function n(r) {
|
|
522
522
|
return r < 0 - e.epsilon || r > 1 + e.epsilon;
|
|
523
523
|
}
|
|
524
|
-
function
|
|
525
|
-
const c = t[r][a], h = t[r][a + 1], u = t[l][d], g = t[l][d + 1],
|
|
526
|
-
if (he(
|
|
527
|
-
const x =
|
|
528
|
-
return H === 0 ? null : [((x *
|
|
524
|
+
function o(r, a, l, d) {
|
|
525
|
+
const c = t[r][a], h = t[r][a + 1], u = t[l][d], g = t[l][d + 1], p = function(f, C, m, v) {
|
|
526
|
+
if (he(f, m) || he(f, v) || he(C, m) || he(v, m)) return null;
|
|
527
|
+
const x = f[0], w = f[1], I = C[0], _ = C[1], A = m[0], O = m[1], B = v[0], Y = v[1], H = (x - I) * (O - Y) - (w - _) * (A - B);
|
|
528
|
+
return H === 0 ? null : [((x * _ - w * I) * (A - B) - (x - I) * (A * Y - O * B)) / H, ((x * _ - w * I) * (O - Y) - (w - _) * (A * Y - O * B)) / H];
|
|
529
529
|
}(c, h, u, g);
|
|
530
|
-
if (
|
|
531
|
-
let
|
|
532
|
-
|
|
530
|
+
if (p === null) return;
|
|
531
|
+
let y, P;
|
|
532
|
+
y = h[0] !== c[0] ? (p[0] - c[0]) / (h[0] - c[0]) : (p[1] - c[1]) / (h[1] - c[1]), P = g[0] !== u[0] ? (p[0] - u[0]) / (g[0] - u[0]) : (p[1] - u[1]) / (g[1] - u[1]), n(y) || n(P) || (p.toString(), i.push(p));
|
|
533
533
|
}
|
|
534
534
|
}
|
|
535
|
-
function he(
|
|
536
|
-
return
|
|
535
|
+
function he(s, e) {
|
|
536
|
+
return s[0] === e[0] && s[1] === e[1];
|
|
537
537
|
}
|
|
538
|
-
function xe(
|
|
539
|
-
return
|
|
538
|
+
function xe(s, e) {
|
|
539
|
+
return s.length === 2 && typeof s[0] == "number" && typeof s[1] == "number" && s[0] !== 1 / 0 && s[1] !== 1 / 0 && (i = s[0]) >= -180 && i <= 180 && (t = s[1]) >= -90 && t <= 90 && Ze(s[0]) <= e && Ze(s[1]) <= e;
|
|
540
540
|
var t, i;
|
|
541
541
|
}
|
|
542
|
-
function Ze(
|
|
542
|
+
function Ze(s) {
|
|
543
543
|
let e = 1, t = 0;
|
|
544
|
-
for (; Math.round(
|
|
544
|
+
for (; Math.round(s * e) / e !== s; ) e *= 10, t++;
|
|
545
545
|
return t;
|
|
546
546
|
}
|
|
547
|
-
const
|
|
548
|
-
function Se(
|
|
549
|
-
return
|
|
547
|
+
const zt = "Feature is not a Polygon", Kt = "Feature has holes", Yt = "Feature has less than 4 coordinates", Ht = "Feature has invalid coordinates", $t = "Feature coordinates are not closed";
|
|
548
|
+
function Se(s, e) {
|
|
549
|
+
return s.geometry.type !== "Polygon" ? { valid: !1, reason: zt } : s.geometry.coordinates.length !== 1 ? { valid: !1, reason: Kt } : s.geometry.coordinates[0].length < 4 ? { valid: !1, reason: Yt } : s.geometry.coordinates[0].every((n) => xe(n, e)) ? (t = s.geometry.coordinates[0][0])[0] !== (i = s.geometry.coordinates[0][s.geometry.coordinates[0].length - 1])[0] || t[1] !== i[1] ? { valid: !1, reason: $t } : { valid: !0 } : { valid: !1, reason: Ht };
|
|
550
550
|
var t, i;
|
|
551
551
|
}
|
|
552
|
-
function de(
|
|
553
|
-
const t = Se(
|
|
554
|
-
return t.valid ?
|
|
552
|
+
function de(s, e) {
|
|
553
|
+
const t = Se(s, e);
|
|
554
|
+
return t.valid ? Le(s) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : t;
|
|
555
555
|
}
|
|
556
556
|
class pt extends N {
|
|
557
557
|
constructor(e) {
|
|
@@ -621,19 +621,19 @@ class pt extends N {
|
|
|
621
621
|
const t = V(this.center, [e.lng, e.lat]);
|
|
622
622
|
let i;
|
|
623
623
|
if (this.projection === "web-mercator") {
|
|
624
|
-
const n = function(
|
|
625
|
-
const a = 1e3 * V(
|
|
624
|
+
const n = function(o, r) {
|
|
625
|
+
const a = 1e3 * V(o, r);
|
|
626
626
|
if (a === 0) return 1;
|
|
627
|
-
const { x: l, y: d } = S(
|
|
627
|
+
const { x: l, y: d } = S(o[0], o[1]), { x: c, y: h } = S(r[0], r[1]);
|
|
628
628
|
return Math.sqrt(Math.pow(c - l, 2) + Math.pow(h - d, 2)) / a;
|
|
629
629
|
}(this.center, [e.lng, e.lat]);
|
|
630
|
-
i = function(
|
|
631
|
-
const { center: r, radiusKilometers: a, coordinatePrecision: l } =
|
|
630
|
+
i = function(o) {
|
|
631
|
+
const { center: r, radiusKilometers: a, coordinatePrecision: l } = o, d = o.steps ? o.steps : 64, c = 1e3 * a, [h, u] = r, { x: g, y: p } = S(h, u), y = [];
|
|
632
632
|
for (let P = 0; P < d; P++) {
|
|
633
|
-
const
|
|
634
|
-
|
|
633
|
+
const f = 360 * P / d * Math.PI / 180, C = c * Math.cos(f), m = c * Math.sin(f), [v, x] = [g + C, p + m], { lng: w, lat: I } = W(v, x);
|
|
634
|
+
y.push([E(w, l), E(I, l)]);
|
|
635
635
|
}
|
|
636
|
-
return
|
|
636
|
+
return y.push(y[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [y] }, properties: {} };
|
|
637
637
|
}({ center: this.center, radiusKilometers: t * n, coordinatePrecision: this.coordinatePrecision });
|
|
638
638
|
} else {
|
|
639
639
|
if (this.projection !== "globe") throw new Error("Invalid projection");
|
|
@@ -644,7 +644,7 @@ class pt extends N {
|
|
|
644
644
|
}
|
|
645
645
|
}
|
|
646
646
|
}
|
|
647
|
-
class
|
|
647
|
+
class yt extends N {
|
|
648
648
|
constructor(e) {
|
|
649
649
|
super(e), 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;
|
|
650
650
|
const t = { start: "crosshair", close: "pointer" };
|
|
@@ -673,8 +673,8 @@ class ft extends N {
|
|
|
673
673
|
}
|
|
674
674
|
onMouseMove(e) {
|
|
675
675
|
if (this.currentId === void 0 || this.startingClick === !1) return;
|
|
676
|
-
const t = this.store.getGeometryCopy(this.currentId), i = t.coordinates[0].length - 2, [n,
|
|
677
|
-
if (
|
|
676
|
+
const t = this.store.getGeometryCopy(this.currentId), i = t.coordinates[0].length - 2, [n, o] = t.coordinates[0][i], { x: r, y: a } = this.project(n, o), l = F({ x: r, y: a }, { x: e.containerX, y: e.containerY }), [d, c] = t.coordinates[0][0], { x: h, y: u } = this.project(d, c);
|
|
677
|
+
if (F({ x: h, y: u }, { x: e.containerX, y: e.containerY }) < this.pointerDistance) {
|
|
678
678
|
if (this.autoClose && this.hasLeftStartingPoint && (this.preventNewFeature = !0, setTimeout(() => {
|
|
679
679
|
this.preventNewFeature = !1;
|
|
680
680
|
}, this.autoCloseTimeout), this.close()), this.setCursor(this.cursors.close), this.preventPointsNearClose) return;
|
|
@@ -720,39 +720,39 @@ class ft extends N {
|
|
|
720
720
|
return this.validateModeFeature(e, (t) => Se(t, this.coordinatePrecision));
|
|
721
721
|
}
|
|
722
722
|
}
|
|
723
|
-
class
|
|
724
|
-
constructor({ store: e, mode: t, project: i, unproject: n, pointerDistance:
|
|
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 = e, this.mode = t, this.project = i, this.unproject = n, this.pointerDistance =
|
|
723
|
+
class j {
|
|
724
|
+
constructor({ store: e, mode: t, project: i, unproject: n, pointerDistance: o, coordinatePrecision: r, projection: a }) {
|
|
725
|
+
this.store = void 0, this.mode = void 0, this.project = void 0, this.unproject = void 0, this.pointerDistance = void 0, this.coordinatePrecision = void 0, this.projection = void 0, this.store = e, this.mode = t, this.project = i, this.unproject = n, this.pointerDistance = o, this.coordinatePrecision = r, this.projection = a;
|
|
726
726
|
}
|
|
727
727
|
}
|
|
728
|
-
function
|
|
729
|
-
const i = t / 2, { x: n, y:
|
|
730
|
-
return { type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [[
|
|
728
|
+
function ft({ unproject: s, point: e, pointerDistance: t }) {
|
|
729
|
+
const i = t / 2, { x: n, y: o } = e;
|
|
730
|
+
return { type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [[s(n - i, o - i), s(n + i, o - i), s(n + i, o + i), s(n - i, o + i), s(n - i, o - i)].map((r) => [r.lng, r.lat])] } };
|
|
731
731
|
}
|
|
732
|
-
class
|
|
732
|
+
class ke extends j {
|
|
733
733
|
constructor(e) {
|
|
734
734
|
super(e);
|
|
735
735
|
}
|
|
736
736
|
create(e) {
|
|
737
737
|
const { containerX: t, containerY: i } = e;
|
|
738
|
-
return
|
|
738
|
+
return ft({ unproject: this.unproject, point: { x: t, y: i }, pointerDistance: this.pointerDistance });
|
|
739
739
|
}
|
|
740
740
|
}
|
|
741
|
-
class We extends
|
|
741
|
+
class We extends j {
|
|
742
742
|
constructor(e) {
|
|
743
743
|
super(e);
|
|
744
744
|
}
|
|
745
745
|
measure(e, t) {
|
|
746
746
|
const { x: i, y: n } = this.project(t[0], t[1]);
|
|
747
|
-
return
|
|
747
|
+
return F({ x: i, y: n }, { x: e.containerX, y: e.containerY });
|
|
748
748
|
}
|
|
749
749
|
}
|
|
750
|
-
class mt extends
|
|
750
|
+
class mt extends j {
|
|
751
751
|
constructor(e, t, i) {
|
|
752
|
-
super(e), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (n) => this.getSnappable(n, (
|
|
752
|
+
super(e), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (n) => this.getSnappable(n, (o) => !!(o.properties && o.properties.mode === this.mode)), this.getSnappableCoordinate = (n, o) => this.getSnappable(n, (r) => !!(r.properties && r.properties.mode === this.mode && r.id !== o)), this.config = e, this.pixelDistance = t, this.clickBoundingBox = i;
|
|
753
753
|
}
|
|
754
754
|
getSnappable(e, t) {
|
|
755
|
-
const i = this.clickBoundingBox.create(e), n = this.store.search(i, t),
|
|
755
|
+
const i = this.clickBoundingBox.create(e), n = this.store.search(i, t), o = { coord: void 0, minDist: 1 / 0 };
|
|
756
756
|
return n.forEach((r) => {
|
|
757
757
|
let a;
|
|
758
758
|
if (r.geometry.type === "Polygon") a = r.geometry.coordinates[0];
|
|
@@ -762,66 +762,66 @@ class mt extends W {
|
|
|
762
762
|
}
|
|
763
763
|
a.forEach((l) => {
|
|
764
764
|
const d = this.pixelDistance.measure(e, l);
|
|
765
|
-
d <
|
|
765
|
+
d < o.minDist && d < this.pointerDistance && (o.coord = l, o.minDist = d);
|
|
766
766
|
});
|
|
767
|
-
}),
|
|
767
|
+
}), o.coord;
|
|
768
768
|
}
|
|
769
769
|
}
|
|
770
|
-
function Qe(
|
|
771
|
-
const i =
|
|
772
|
-
return [
|
|
770
|
+
function Qe(s, e, t) {
|
|
771
|
+
const i = D(s[0]), n = D(s[1]), o = D(t), r = gt(e), a = Math.asin(Math.sin(n) * Math.cos(r) + Math.cos(n) * Math.sin(r) * Math.cos(o));
|
|
772
|
+
return [T(i + Math.atan2(Math.sin(o) * Math.sin(r) * Math.cos(n), Math.cos(r) - Math.sin(n) * Math.sin(a))), T(a)];
|
|
773
773
|
}
|
|
774
|
-
function le({ x:
|
|
775
|
-
const n =
|
|
776
|
-
return { x:
|
|
774
|
+
function le({ x: s, y: e }, t, i) {
|
|
775
|
+
const n = D(i);
|
|
776
|
+
return { x: s + t * Math.cos(n), y: e + t * Math.sin(n) };
|
|
777
777
|
}
|
|
778
|
-
function et(
|
|
779
|
-
const t =
|
|
780
|
-
return
|
|
778
|
+
function et(s, e) {
|
|
779
|
+
const t = D(s[0]), i = D(e[0]), n = D(s[1]), o = D(e[1]), r = Math.sin(i - t) * Math.cos(o), a = Math.cos(n) * Math.sin(o) - Math.sin(n) * Math.cos(o) * Math.cos(i - t);
|
|
780
|
+
return T(Math.atan2(r, a));
|
|
781
781
|
}
|
|
782
|
-
function
|
|
783
|
-
let n = Math.atan2(i - e, t -
|
|
782
|
+
function G({ x: s, y: e }, { x: t, y: i }) {
|
|
783
|
+
let n = Math.atan2(i - e, t - s);
|
|
784
784
|
return n *= 180 / Math.PI, n > 180 ? n -= 360 : n < -180 && (n += 360), n;
|
|
785
785
|
}
|
|
786
|
-
function
|
|
787
|
-
return (
|
|
786
|
+
function z(s) {
|
|
787
|
+
return (s + 360) % 360;
|
|
788
788
|
}
|
|
789
|
-
function
|
|
790
|
-
const i = [], n =
|
|
791
|
-
let
|
|
792
|
-
for (let c = 0; c <
|
|
789
|
+
function Jt(s, e, t) {
|
|
790
|
+
const i = [], n = s.length;
|
|
791
|
+
let o, r, a, l = 0;
|
|
792
|
+
for (let c = 0; c < s.length && !(e >= l && c === s.length - 1); c++) {
|
|
793
793
|
if (l > e && i.length === 0) {
|
|
794
|
-
if (
|
|
795
|
-
r = et(
|
|
794
|
+
if (o = e - l, !o) return i.push(s[c]), i;
|
|
795
|
+
r = et(s[c], s[c - 1]) - 180, a = Qe(s[c], o, r), i.push(a);
|
|
796
796
|
}
|
|
797
|
-
if (l >= t) return
|
|
798
|
-
if (l >= e && i.push(
|
|
799
|
-
l += V(
|
|
797
|
+
if (l >= t) return o = t - l, o ? (r = et(s[c], s[c - 1]) - 180, a = Qe(s[c], o, r), i.push(a), i) : (i.push(s[c]), i);
|
|
798
|
+
if (l >= e && i.push(s[c]), c === s.length - 1) return i;
|
|
799
|
+
l += V(s[c], s[c + 1]);
|
|
800
800
|
}
|
|
801
|
-
if (l < e &&
|
|
802
|
-
const d =
|
|
801
|
+
if (l < e && s.length === n) throw new Error("Start position is beyond line");
|
|
802
|
+
const d = s[s.length - 1];
|
|
803
803
|
return [d, d];
|
|
804
804
|
}
|
|
805
|
-
function ue(
|
|
806
|
-
return
|
|
805
|
+
function ue(s) {
|
|
806
|
+
return s * (Math.PI / 180);
|
|
807
807
|
}
|
|
808
|
-
function tt(
|
|
809
|
-
return
|
|
808
|
+
function tt(s) {
|
|
809
|
+
return s * (180 / Math.PI);
|
|
810
810
|
}
|
|
811
|
-
class qt extends
|
|
811
|
+
class qt extends j {
|
|
812
812
|
constructor(e) {
|
|
813
813
|
super(e), this.config = void 0, this.config = e;
|
|
814
814
|
}
|
|
815
815
|
generateInsertionCoordinates(e, t, i) {
|
|
816
816
|
const n = [e, t];
|
|
817
|
-
let
|
|
818
|
-
for (let d = 0; d < n.length - 1; d++)
|
|
819
|
-
if (
|
|
820
|
-
let r =
|
|
817
|
+
let o = 0;
|
|
818
|
+
for (let d = 0; d < n.length - 1; d++) o += V(n[0], n[1]);
|
|
819
|
+
if (o <= i) return n;
|
|
820
|
+
let r = o / i - 1;
|
|
821
821
|
Number.isInteger(r) || (r = Math.floor(r) + 1);
|
|
822
822
|
const a = [];
|
|
823
823
|
for (let d = 0; d < r; d++) {
|
|
824
|
-
const c =
|
|
824
|
+
const c = Jt(n, i * d, i * (d + 1));
|
|
825
825
|
a.push(c);
|
|
826
826
|
}
|
|
827
827
|
const l = [];
|
|
@@ -829,30 +829,30 @@ class qt extends W {
|
|
|
829
829
|
return this.limitCoordinates(l);
|
|
830
830
|
}
|
|
831
831
|
generateInsertionGeodesicCoordinates(e, t, i) {
|
|
832
|
-
const n = V(e, t),
|
|
832
|
+
const n = V(e, t), o = function(r, a, l) {
|
|
833
833
|
const d = [], c = ue(r[1]), h = ue(r[0]), u = ue(a[1]), g = ue(a[0]);
|
|
834
834
|
l += 1;
|
|
835
|
-
const
|
|
836
|
-
if (
|
|
837
|
-
for (let
|
|
838
|
-
const P =
|
|
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;
|
|
837
|
+
for (let y = 0; y <= l; y++) {
|
|
838
|
+
const P = y / l, f = Math.sin((1 - P) * p) / Math.sin(p), C = Math.sin(P * p) / Math.sin(p), m = f * Math.cos(c) * Math.cos(h) + C * Math.cos(u) * Math.cos(g), v = f * Math.cos(c) * Math.sin(h) + C * Math.cos(u) * Math.sin(g), x = f * Math.sin(c) + C * Math.sin(u);
|
|
839
839
|
if (isNaN(m) || isNaN(v) || isNaN(x)) continue;
|
|
840
840
|
const w = Math.atan2(x, Math.sqrt(m ** 2 + v ** 2)), I = Math.atan2(v, m);
|
|
841
841
|
isNaN(w) || isNaN(I) || d.push([tt(I), tt(w)]);
|
|
842
842
|
}
|
|
843
843
|
return d.slice(1, -1);
|
|
844
844
|
}(e, t, Math.floor(n / i));
|
|
845
|
-
return this.limitCoordinates(
|
|
845
|
+
return this.limitCoordinates(o);
|
|
846
846
|
}
|
|
847
847
|
limitCoordinates(e) {
|
|
848
|
-
return e.map((t) => [
|
|
848
|
+
return e.map((t) => [E(t[0], this.config.coordinatePrecision), E(t[1], this.config.coordinatePrecision)]);
|
|
849
849
|
}
|
|
850
850
|
}
|
|
851
|
-
function ee(
|
|
852
|
-
return
|
|
851
|
+
function ee(s, e) {
|
|
852
|
+
return s[0] === e[0] && s[1] === e[1];
|
|
853
853
|
}
|
|
854
|
-
function Ct(
|
|
855
|
-
return
|
|
854
|
+
function Ct(s, e) {
|
|
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((t) => xe(t, e)) ? { valid: !0 } : { valid: !1, reason: "Feature has invalid coordinates" };
|
|
856
856
|
}
|
|
857
857
|
class Pt extends N {
|
|
858
858
|
constructor(e) {
|
|
@@ -876,8 +876,8 @@ class Pt extends N {
|
|
|
876
876
|
if (!this.currentId) return;
|
|
877
877
|
const n = { type: "LineString", coordinates: e };
|
|
878
878
|
if (this.validate && !this.validate({ type: "Feature", geometry: n }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: i }).valid) return;
|
|
879
|
-
const
|
|
880
|
-
this.closingPointId && t &&
|
|
879
|
+
const o = [{ id: this.currentId, geometry: n }];
|
|
880
|
+
this.closingPointId && t && o.push({ id: this.closingPointId, geometry: { type: "Point", coordinates: t } }), i === "commit" && (this.lastCommitedCoordinates = n.coordinates), this.store.updateGeometry(o);
|
|
881
881
|
}
|
|
882
882
|
generateInsertCoordinates(e, t) {
|
|
883
883
|
if (!this.insertCoordinates || !this.lastCommitedCoordinates) throw new Error("Not able to insert coordinates");
|
|
@@ -899,14 +899,14 @@ class Pt extends N {
|
|
|
899
899
|
}
|
|
900
900
|
updateToLine(e, t) {
|
|
901
901
|
if (!this.currentId) return;
|
|
902
|
-
const i = this.store.getGeometryCopy(this.currentId).coordinates, [n,
|
|
903
|
-
if (
|
|
902
|
+
const i = this.store.getGeometryCopy(this.currentId).coordinates, [n, o] = this.lastCommitedCoordinates ? this.lastCommitedCoordinates[this.lastCommitedCoordinates.length - 1] : i[i.length - 2], { x: r, y: a } = this.project(n, o);
|
|
903
|
+
if (F({ x: r, y: a }, { x: t.x, y: t.y }) < this.pointerDistance) return void this.close();
|
|
904
904
|
this.setCursor(this.cursors.close);
|
|
905
905
|
const l = [...i, e];
|
|
906
906
|
this.updateGeometries(l, i[i.length - 1], b.Commit), this.currentCoordinate++;
|
|
907
907
|
}
|
|
908
908
|
registerBehaviors(e) {
|
|
909
|
-
this.coordinateSnapping = new mt(e, new We(e), new
|
|
909
|
+
this.coordinateSnapping = new mt(e, new We(e), new ke(e)), this.insertPoint = new qt(e);
|
|
910
910
|
}
|
|
911
911
|
start() {
|
|
912
912
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -920,7 +920,7 @@ class Pt extends N {
|
|
|
920
920
|
if (t) {
|
|
921
921
|
if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: t } }]);
|
|
922
922
|
else {
|
|
923
|
-
const [r] = this.store.create([{ geometry: { type: "Point", coordinates: t }, properties: { mode: this.mode, [
|
|
923
|
+
const [r] = this.store.create([{ geometry: { type: "Point", coordinates: t }, properties: { mode: this.mode, [_e]: !0 } }]);
|
|
924
924
|
this.snappedPointId = r;
|
|
925
925
|
}
|
|
926
926
|
e.lng = t[0], e.lat = t[1];
|
|
@@ -930,17 +930,17 @@ class Pt extends N {
|
|
|
930
930
|
const n = this.store.getGeometryCopy(this.currentId).coordinates;
|
|
931
931
|
if (n.pop(), this.closingPointId) {
|
|
932
932
|
const [r, a] = n[n.length - 1], { x: l, y: d } = this.project(r, a);
|
|
933
|
-
|
|
933
|
+
F({ x: l, y: d }, { x: e.containerX, y: e.containerY }) < this.pointerDistance && this.setCursor(this.cursors.close);
|
|
934
934
|
}
|
|
935
|
-
let
|
|
935
|
+
let o = [...n, i];
|
|
936
936
|
if (this.insertCoordinates && this.currentId && this.lastCommitedCoordinates) {
|
|
937
937
|
const r = this.lastCommitedCoordinates[this.lastCommitedCoordinates.length - 1], a = i;
|
|
938
938
|
if (!ee(r, a)) {
|
|
939
939
|
const l = this.generateInsertCoordinates(r, a);
|
|
940
|
-
|
|
940
|
+
o = [...this.lastCommitedCoordinates.slice(0, -1), ...l, i];
|
|
941
941
|
}
|
|
942
942
|
}
|
|
943
|
-
this.updateGeometries(
|
|
943
|
+
this.updateGeometries(o, void 0, b.Provisional);
|
|
944
944
|
}
|
|
945
945
|
onClick(e) {
|
|
946
946
|
this.currentCoordinate > 0 && !this.mouseMove && this.onMouseMove(e), this.mouseMove = !1, this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0);
|
|
@@ -985,8 +985,8 @@ class Pt extends N {
|
|
|
985
985
|
}
|
|
986
986
|
}
|
|
987
987
|
const Zt = "Feature is not a Point", Qt = "Feature has invalid coordinates";
|
|
988
|
-
function vt(
|
|
989
|
-
return
|
|
988
|
+
function vt(s, e) {
|
|
989
|
+
return s.geometry.type !== "Point" ? { valid: !1, reason: Zt } : xe(s.geometry.coordinates, e) ? { valid: !0 } : { valid: !1, reason: Qt };
|
|
990
990
|
}
|
|
991
991
|
class ei extends N {
|
|
992
992
|
constructor(e) {
|
|
@@ -1029,7 +1029,7 @@ class ei extends N {
|
|
|
1029
1029
|
return this.validateModeFeature(e, (t) => vt(t, this.coordinatePrecision));
|
|
1030
1030
|
}
|
|
1031
1031
|
}
|
|
1032
|
-
class ti extends
|
|
1032
|
+
class ti extends j {
|
|
1033
1033
|
constructor(e, t) {
|
|
1034
1034
|
super(e), this.config = void 0, this.pixelDistance = void 0, this._startEndPoints = [], this.config = e, this.pixelDistance = t;
|
|
1035
1035
|
}
|
|
@@ -1051,46 +1051,46 @@ class ti extends W {
|
|
|
1051
1051
|
this.store.updateGeometry([{ id: this.ids[0], geometry: { type: "Point", coordinates: e[0] } }, { id: this.ids[1], geometry: { type: "Point", coordinates: e[e.length - 3] } }]);
|
|
1052
1052
|
}
|
|
1053
1053
|
isClosingPoint(e) {
|
|
1054
|
-
const t = this.store.getGeometryCopy(this.ids[0]), i = this.store.getGeometryCopy(this.ids[1]), n = this.pixelDistance.measure(e, t.coordinates),
|
|
1055
|
-
return { isClosing: n < this.pointerDistance, isPreviousClosing:
|
|
1054
|
+
const t = this.store.getGeometryCopy(this.ids[0]), i = this.store.getGeometryCopy(this.ids[1]), n = this.pixelDistance.measure(e, t.coordinates), o = this.pixelDistance.measure(e, i.coordinates);
|
|
1055
|
+
return { isClosing: n < this.pointerDistance, isPreviousClosing: o < this.pointerDistance };
|
|
1056
1056
|
}
|
|
1057
1057
|
}
|
|
1058
|
-
function it(
|
|
1059
|
-
return Math.sqrt(Math.pow(
|
|
1058
|
+
function it(s) {
|
|
1059
|
+
return Math.sqrt(Math.pow(s[0], 2) + Math.pow(s[1], 2) + Math.pow(s[2], 2));
|
|
1060
1060
|
}
|
|
1061
|
-
function R(
|
|
1061
|
+
function R(s, e) {
|
|
1062
1062
|
const t = function(i, n) {
|
|
1063
|
-
const [
|
|
1064
|
-
return
|
|
1065
|
-
}(
|
|
1063
|
+
const [o, r, a] = i, [l, d, c] = n;
|
|
1064
|
+
return o * l + r * d + a * c;
|
|
1065
|
+
}(s, e) / (it(s) * it(e));
|
|
1066
1066
|
return Math.acos(Math.min(Math.max(t, -1), 1));
|
|
1067
1067
|
}
|
|
1068
|
-
function be(
|
|
1069
|
-
const e =
|
|
1068
|
+
function be(s) {
|
|
1069
|
+
const e = D(s[1]), t = D(s[0]);
|
|
1070
1070
|
return [Math.cos(e) * Math.cos(t), Math.cos(e) * Math.sin(t), Math.sin(e)];
|
|
1071
1071
|
}
|
|
1072
|
-
function X(
|
|
1073
|
-
const [e, t, i] =
|
|
1074
|
-
return [
|
|
1072
|
+
function X(s) {
|
|
1073
|
+
const [e, t, i] = s, n = T(Math.asin(i));
|
|
1074
|
+
return [T(Math.atan2(t, e)), n];
|
|
1075
1075
|
}
|
|
1076
|
-
function ii(
|
|
1077
|
-
const i = be(
|
|
1078
|
-
const [H, Be, Ne] = B, [
|
|
1079
|
-
return [Be * Ve - Ne *
|
|
1080
|
-
}(i, n), u = c * l - h * a, g = h * r - d * l,
|
|
1076
|
+
function ii(s, e, t) {
|
|
1077
|
+
const i = be(s), n = be(e), o = be(t), [r, a, l] = o, [d, c, h] = function(B, Y) {
|
|
1078
|
+
const [H, Be, Ne] = B, [Ae, Ge, Ve] = Y;
|
|
1079
|
+
return [Be * Ve - Ne * Ge, Ne * Ae - H * Ve, H * Ge - Be * Ae];
|
|
1080
|
+
}(i, n), u = c * l - h * a, g = h * r - d * l, p = d * a - c * r, y = p * c - g * h, P = u * h - p * d, f = g * d - u * c, C = 1 / Math.sqrt(Math.pow(y, 2) + Math.pow(P, 2) + Math.pow(f, 2)), m = [y * C, P * C, f * C], v = [-1 * y * C, -1 * P * C, -1 * f * C], x = R(i, n), w = R(i, m), I = R(n, m), _ = R(i, v), A = R(n, v);
|
|
1081
1081
|
let O;
|
|
1082
|
-
return O = w <
|
|
1082
|
+
return O = w < _ && w < A || I < _ && I < A ? m : v, R(i, O) > x || R(n, O) > x ? V(X(O), X(i)) <= V(X(O), X(n)) ? [X(i), !0, !1] : [X(n), !1, !0] : [X(O), !1, !1];
|
|
1083
1083
|
}
|
|
1084
|
-
function ni(
|
|
1085
|
-
const i = e.x -
|
|
1086
|
-
return { x:
|
|
1084
|
+
function ni(s, e, t) {
|
|
1085
|
+
const i = e.x - s.x, n = e.y - s.y, o = Math.max(0, Math.min(1, ((t.x - s.x) * i + (t.y - s.y) * n) / (i * i + n * n)));
|
|
1086
|
+
return { x: s.x + o * i, y: s.y + o * n };
|
|
1087
1087
|
}
|
|
1088
|
-
class
|
|
1088
|
+
class oi extends j {
|
|
1089
1089
|
constructor(e, t, i) {
|
|
1090
|
-
super(e), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (n) => this.getSnappable(n, (
|
|
1090
|
+
super(e), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (n) => this.getSnappable(n, (o) => !!(o.properties && o.properties.mode === this.mode)), this.getSnappableCoordinate = (n, o) => this.getSnappable(n, (r) => !!(r.properties && r.properties.mode === this.mode && r.id !== o)), this.config = e, this.pixelDistance = t, this.clickBoundingBox = i;
|
|
1091
1091
|
}
|
|
1092
1092
|
getSnappable(e, t) {
|
|
1093
|
-
const i = this.clickBoundingBox.create(e), n = this.store.search(i, t),
|
|
1093
|
+
const i = this.clickBoundingBox.create(e), n = this.store.search(i, t), o = { coord: void 0, minDistance: 1 / 0 };
|
|
1094
1094
|
return n.forEach((r) => {
|
|
1095
1095
|
let a;
|
|
1096
1096
|
if (r.geometry.type === "Polygon") a = r.geometry.coordinates[0];
|
|
@@ -1103,32 +1103,32 @@ class si extends W {
|
|
|
1103
1103
|
let d;
|
|
1104
1104
|
const c = [e.lng, e.lat];
|
|
1105
1105
|
if (this.config.projection === "web-mercator" ? d = function(u, g) {
|
|
1106
|
-
let
|
|
1106
|
+
let p = [1 / 0, 1 / 0], y = 1 / 0;
|
|
1107
1107
|
for (let P of g) {
|
|
1108
|
-
const
|
|
1108
|
+
const f = P[0], C = P[1];
|
|
1109
1109
|
let m, v = 1 / 0;
|
|
1110
|
-
const x = S(
|
|
1111
|
-
if (
|
|
1110
|
+
const x = S(f[0], f[1]), w = S(C[0], C[1]), I = S(u[0], u[1]);
|
|
1111
|
+
if (f[0] === u[0] && f[1] === u[1]) m = f;
|
|
1112
1112
|
else if (C[0] === u[0] && C[1] === u[1]) m = C;
|
|
1113
1113
|
else {
|
|
1114
|
-
const { x:
|
|
1114
|
+
const { x: _, y: A } = ni(x, w, I), { lng: O, lat: B } = W(_, A);
|
|
1115
1115
|
m = [O, B];
|
|
1116
1116
|
}
|
|
1117
|
-
m && (v =
|
|
1117
|
+
m && (v = F(I, S(m[0], m[1])), v < y && (p = m, y = v));
|
|
1118
1118
|
}
|
|
1119
|
-
return
|
|
1119
|
+
return y === 1 / 0 ? void 0 : { coordinate: p, distance: y };
|
|
1120
1120
|
}(c, l) : this.config.projection === "globe" && (d = function(u, g) {
|
|
1121
|
-
let
|
|
1121
|
+
let p = [1 / 0, 1 / 0], y = 1 / 0;
|
|
1122
1122
|
for (let P of g) {
|
|
1123
|
-
const
|
|
1123
|
+
const f = P[0], C = P[1];
|
|
1124
1124
|
let m, v = 1 / 0;
|
|
1125
|
-
|
|
1125
|
+
f[0] === u[0] && f[1] === u[1] ? m = f : C[0] === u[0] && C[1] === u[1] ? m = C : [m] = ii(f, C, u), m && (v = V(u, m), v < y && (p = m, y = v));
|
|
1126
1126
|
}
|
|
1127
|
-
return
|
|
1127
|
+
return y === 1 / 0 ? void 0 : { coordinate: p, distance: y };
|
|
1128
1128
|
}(c, l)), !d) return;
|
|
1129
1129
|
const h = this.pixelDistance.measure(e, d.coordinate);
|
|
1130
|
-
h <
|
|
1131
|
-
}),
|
|
1130
|
+
h < o.minDistance && h < this.pointerDistance && (o.coord = d.coordinate, o.minDistance = h);
|
|
1131
|
+
}), o.coord;
|
|
1132
1132
|
}
|
|
1133
1133
|
}
|
|
1134
1134
|
class xt extends N {
|
|
@@ -1149,8 +1149,8 @@ class xt extends N {
|
|
|
1149
1149
|
this.snappedPointId && this.store.delete([this.snappedPointId]), this.currentCoordinate = 0, this.currentId = void 0, this.snappedPointId = void 0, this.closingPoints.delete(), this.state === "drawing" && this.setStarted(), this.onFinish(t, { mode: this.mode, action: "draw" });
|
|
1150
1150
|
}
|
|
1151
1151
|
registerBehaviors(e) {
|
|
1152
|
-
const t = new
|
|
1153
|
-
this.pixelDistance = new We(e), this.lineSnapping = new
|
|
1152
|
+
const t = new ke(e);
|
|
1153
|
+
this.pixelDistance = new We(e), this.lineSnapping = new oi(e, this.pixelDistance, t), this.coordinateSnapping = new mt(e, this.pixelDistance, t), this.closingPoints = new ti(e, this.pixelDistance);
|
|
1154
1154
|
}
|
|
1155
1155
|
start() {
|
|
1156
1156
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -1164,8 +1164,8 @@ class xt extends N {
|
|
|
1164
1164
|
if (t) {
|
|
1165
1165
|
if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: t } }]);
|
|
1166
1166
|
else {
|
|
1167
|
-
const [
|
|
1168
|
-
this.snappedPointId =
|
|
1167
|
+
const [o] = this.store.create([{ geometry: { type: "Point", coordinates: t }, properties: { mode: this.mode, [_e]: !0 } }]);
|
|
1168
|
+
this.snappedPointId = o;
|
|
1169
1169
|
}
|
|
1170
1170
|
e.lng = t[0], e.lat = t[1];
|
|
1171
1171
|
} else this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0);
|
|
@@ -1173,12 +1173,12 @@ class xt extends N {
|
|
|
1173
1173
|
const i = this.store.getGeometryCopy(this.currentId).coordinates[0];
|
|
1174
1174
|
let n;
|
|
1175
1175
|
if (this.currentCoordinate === 1) {
|
|
1176
|
-
const
|
|
1176
|
+
const o = 1 / Math.pow(10, this.coordinatePrecision - 1), r = Math.max(1e-6, o);
|
|
1177
1177
|
n = [i[0], [e.lng, e.lat], [e.lng, e.lat - r], i[0]];
|
|
1178
1178
|
} else if (this.currentCoordinate === 2) n = [i[0], i[1], [e.lng, e.lat], i[0]];
|
|
1179
1179
|
else {
|
|
1180
|
-
const { isClosing:
|
|
1181
|
-
r ||
|
|
1180
|
+
const { isClosing: o, isPreviousClosing: r } = this.closingPoints.isClosingPoint(e);
|
|
1181
|
+
r || o ? (this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.setCursor(this.cursors.close), n = [...i.slice(0, -2), i[0], i[0]]) : n = [...i.slice(0, -2), [e.lng, e.lat], i[0]];
|
|
1182
1182
|
}
|
|
1183
1183
|
this.updatePolygonGeometry(n, b.Provisional);
|
|
1184
1184
|
}
|
|
@@ -1189,16 +1189,16 @@ class xt extends N {
|
|
|
1189
1189
|
}
|
|
1190
1190
|
snapCoordinate(e) {
|
|
1191
1191
|
var t, i, n;
|
|
1192
|
-
let
|
|
1192
|
+
let o;
|
|
1193
1193
|
if ((t = this.snapping) != null && t.toLine) {
|
|
1194
1194
|
let r;
|
|
1195
|
-
r = this.currentId ? this.lineSnapping.getSnappableCoordinate(e, this.currentId) : this.lineSnapping.getSnappableCoordinateFirstClick(e), r && (
|
|
1195
|
+
r = this.currentId ? this.lineSnapping.getSnappableCoordinate(e, this.currentId) : this.lineSnapping.getSnappableCoordinateFirstClick(e), r && (o = r);
|
|
1196
1196
|
}
|
|
1197
1197
|
if ((i = this.snapping) != null && i.toCoordinate) {
|
|
1198
1198
|
let r;
|
|
1199
|
-
r = this.currentId ? this.coordinateSnapping.getSnappableCoordinate(e, this.currentId) : this.coordinateSnapping.getSnappableCoordinateFirstClick(e), r && (
|
|
1199
|
+
r = this.currentId ? this.coordinateSnapping.getSnappableCoordinate(e, this.currentId) : this.coordinateSnapping.getSnappableCoordinateFirstClick(e), r && (o = r);
|
|
1200
1200
|
}
|
|
1201
|
-
return (n = this.snapping) != null && n.toCustom && (
|
|
1201
|
+
return (n = this.snapping) != null && n.toCustom && (o = this.snapping.toCustom(e)), o;
|
|
1202
1202
|
}
|
|
1203
1203
|
onClick(e) {
|
|
1204
1204
|
if (this.currentCoordinate > 0 && !this.mouseMove && this.onMouseMove(e), this.mouseMove = !1, this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.currentCoordinate === 0) {
|
|
@@ -1222,8 +1222,8 @@ class xt extends N {
|
|
|
1222
1222
|
const t = this.store.getGeometryCopy(this.currentId).coordinates[0], { isClosing: i, isPreviousClosing: n } = this.closingPoints.isClosingPoint(e);
|
|
1223
1223
|
if (n || i) this.close();
|
|
1224
1224
|
else {
|
|
1225
|
-
const
|
|
1226
|
-
if (
|
|
1225
|
+
const o = this.snapCoordinate(e);
|
|
1226
|
+
if (o && (e.lng = o[0], e.lat = o[1]), ee([e.lng, e.lat], t[this.currentCoordinate - 1])) return;
|
|
1227
1227
|
const r = /* @__PURE__ */ function(a = [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]) {
|
|
1228
1228
|
return { type: "Feature", geometry: { type: "Polygon", coordinates: a }, properties: {} };
|
|
1229
1229
|
}([[...t.slice(0, -1), [e.lng, e.lat], t[0]]]);
|
|
@@ -1258,7 +1258,7 @@ class xt extends N {
|
|
|
1258
1258
|
if (e.properties.mode === this.mode) {
|
|
1259
1259
|
if (e.geometry.type === "Polygon") return t.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, t.polygonFillColor, e), t.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, t.polygonOutlineColor, e), t.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, t.polygonOutlineWidth, e), t.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, t.polygonFillOpacity, e), t.zIndex = 10, t;
|
|
1260
1260
|
if (e.geometry.type === "Point") {
|
|
1261
|
-
const i = e.properties[ae], n = e.properties[
|
|
1261
|
+
const i = e.properties[ae], n = e.properties[_e];
|
|
1262
1262
|
return t.pointWidth = this.getNumericStylingValue(i ? this.styles.closingPointWidth : n ? this.styles.snappingPointWidth : t.pointWidth, t.pointWidth, e), t.pointColor = this.getHexColorStylingValue(i ? this.styles.closingPointColor : n ? this.styles.snappingPointColor : t.pointColor, t.pointColor, e), t.pointOutlineColor = this.getHexColorStylingValue(i ? this.styles.closingPointOutlineColor : n ? this.styles.snappingPointOutlineColor : t.pointOutlineColor, t.pointOutlineColor, e), t.pointOutlineWidth = this.getNumericStylingValue(i ? this.styles.closingPointOutlineWidth : n ? this.styles.snappingPointOutlineWidth : 2, 2, e), t.zIndex = 30, t;
|
|
1263
1263
|
}
|
|
1264
1264
|
}
|
|
@@ -1330,7 +1330,7 @@ class St extends N {
|
|
|
1330
1330
|
}
|
|
1331
1331
|
class ie extends N {
|
|
1332
1332
|
constructor(e) {
|
|
1333
|
-
super({ styles: e.styles }), this.type =
|
|
1333
|
+
super({ styles: e.styles }), this.type = K.Render, this.mode = "render", this.mode = e.modeName;
|
|
1334
1334
|
}
|
|
1335
1335
|
registerBehaviors(e) {
|
|
1336
1336
|
this.mode = e.mode;
|
|
@@ -1369,44 +1369,44 @@ class ie extends N {
|
|
|
1369
1369
|
return t;
|
|
1370
1370
|
}
|
|
1371
1371
|
}
|
|
1372
|
-
function Ce(
|
|
1373
|
-
const t =
|
|
1374
|
-
let r =
|
|
1372
|
+
function Ce(s, e) {
|
|
1373
|
+
const t = s, i = e, n = D(t[1]), o = D(i[1]);
|
|
1374
|
+
let r = D(i[0] - t[0]);
|
|
1375
1375
|
r > Math.PI && (r -= 2 * Math.PI), r < -Math.PI && (r += 2 * Math.PI);
|
|
1376
|
-
const a = Math.log(Math.tan(
|
|
1376
|
+
const a = Math.log(Math.tan(o / 2 + Math.PI / 4) / Math.tan(n / 2 + Math.PI / 4)), l = (T(Math.atan2(r, a)) + 360) % 360;
|
|
1377
1377
|
return l > 180 ? -(360 - l) : l;
|
|
1378
1378
|
}
|
|
1379
|
-
function je(
|
|
1379
|
+
function je(s, e, t) {
|
|
1380
1380
|
let i = e;
|
|
1381
1381
|
e < 0 && (i = -Math.abs(i));
|
|
1382
|
-
const n = i / Oe,
|
|
1382
|
+
const n = i / Oe, o = s[0] * Math.PI / 180, r = D(s[1]), a = D(t), l = n * Math.cos(a);
|
|
1383
1383
|
let d = r + l;
|
|
1384
1384
|
Math.abs(d) > Math.PI / 2 && (d = d > 0 ? Math.PI - d : -Math.PI - d);
|
|
1385
|
-
const c = Math.log(Math.tan(d / 2 + Math.PI / 4) / Math.tan(r / 2 + Math.PI / 4)), h = Math.abs(c) > 1e-11 ? l / c : Math.cos(r), u = [(180 * (
|
|
1386
|
-
return u[0] += u[0] -
|
|
1385
|
+
const c = Math.log(Math.tan(d / 2 + Math.PI / 4) / Math.tan(r / 2 + Math.PI / 4)), h = Math.abs(c) > 1e-11 ? l / c : Math.cos(r), u = [(180 * (o + n * Math.sin(a) / h) / Math.PI + 540) % 360 - 180, 180 * d / Math.PI];
|
|
1386
|
+
return u[0] += u[0] - s[0] > 180 ? -360 : s[0] - u[0] > 180 ? 360 : 0, u;
|
|
1387
1387
|
}
|
|
1388
|
-
function Mt(
|
|
1389
|
-
const
|
|
1390
|
-
return [
|
|
1388
|
+
function Mt(s, e, t, i, n) {
|
|
1389
|
+
const o = i(s[0], s[1]), r = i(e[0], e[1]), { lng: a, lat: l } = n((o.x + r.x) / 2, (o.y + r.y) / 2);
|
|
1390
|
+
return [E(a, t), E(l, t)];
|
|
1391
1391
|
}
|
|
1392
|
-
function
|
|
1393
|
-
const i = je(
|
|
1394
|
-
return [
|
|
1392
|
+
function si(s, e, t) {
|
|
1393
|
+
const i = je(s, 1e3 * V(s, e) / 2, Ce(s, e));
|
|
1394
|
+
return [E(i[0], t), E(i[1], t)];
|
|
1395
1395
|
}
|
|
1396
|
-
function nt({ featureCoords:
|
|
1397
|
-
const
|
|
1398
|
-
for (let r = 0; r <
|
|
1396
|
+
function nt({ featureCoords: s, precision: e, unproject: t, project: i, projection: n }) {
|
|
1397
|
+
const o = [];
|
|
1398
|
+
for (let r = 0; r < s.length - 1; r++) {
|
|
1399
1399
|
let a;
|
|
1400
|
-
if (n === "web-mercator") a = Mt(
|
|
1400
|
+
if (n === "web-mercator") a = Mt(s[r], s[r + 1], e, i, t);
|
|
1401
1401
|
else {
|
|
1402
1402
|
if (n !== "globe") throw new Error("Invalid projection");
|
|
1403
|
-
a =
|
|
1403
|
+
a = si(s[r], s[r + 1], e);
|
|
1404
1404
|
}
|
|
1405
|
-
|
|
1405
|
+
o.push(a);
|
|
1406
1406
|
}
|
|
1407
|
-
return
|
|
1407
|
+
return o;
|
|
1408
1408
|
}
|
|
1409
|
-
class ri extends
|
|
1409
|
+
class ri extends j {
|
|
1410
1410
|
constructor(e, t) {
|
|
1411
1411
|
super(e), this.config = void 0, this.selectionPointBehavior = void 0, this._midPoints = [], this.config = e, this.selectionPointBehavior = t;
|
|
1412
1412
|
}
|
|
@@ -1416,14 +1416,14 @@ class ri extends W {
|
|
|
1416
1416
|
set ids(e) {
|
|
1417
1417
|
}
|
|
1418
1418
|
insert(e, t) {
|
|
1419
|
-
const i = this.store.getGeometryCopy(e), { midPointFeatureId: n, midPointSegment:
|
|
1420
|
-
a.splice(
|
|
1419
|
+
const i = this.store.getGeometryCopy(e), { midPointFeatureId: n, midPointSegment: o } = this.store.getPropertiesCopy(e), r = this.store.getGeometryCopy(n), a = r.type === "Polygon" ? r.coordinates[0] : r.coordinates;
|
|
1420
|
+
a.splice(o + 1, 0, i.coordinates), r.coordinates = r.type === "Polygon" ? [a] : a, this.store.updateGeometry([{ id: n, geometry: r }]), this.store.delete([...this._midPoints, ...this.selectionPointBehavior.ids]), this.create(a, n, t), this.selectionPointBehavior.create(a, r.type, n);
|
|
1421
1421
|
}
|
|
1422
1422
|
create(e, t, i) {
|
|
1423
1423
|
if (!this.store.has(t)) throw new Error("Store does not have feature with this id");
|
|
1424
|
-
this._midPoints = this.store.create(function(n,
|
|
1425
|
-
return nt({ featureCoords: n, precision: r, project: a, unproject: l, projection: d }).map((c, h) => ({ geometry: { type: "Point", coordinates: c }, properties:
|
|
1426
|
-
}(e, (n) => ({ mode: this.mode, [
|
|
1424
|
+
this._midPoints = this.store.create(function(n, o, r, a, l, d) {
|
|
1425
|
+
return nt({ featureCoords: n, precision: r, project: a, unproject: l, projection: d }).map((c, h) => ({ geometry: { type: "Point", coordinates: c }, properties: o(h) }));
|
|
1426
|
+
}(e, (n) => ({ mode: this.mode, [se]: !0, midPointSegment: n, midPointFeatureId: t }), i, this.config.project, this.config.unproject, this.projection));
|
|
1427
1427
|
}
|
|
1428
1428
|
delete() {
|
|
1429
1429
|
this._midPoints.length && (this.store.delete(this._midPoints), this._midPoints = []);
|
|
@@ -1432,7 +1432,7 @@ class ri extends W {
|
|
|
1432
1432
|
if (this._midPoints.length !== 0) return nt({ featureCoords: e, precision: this.coordinatePrecision, project: this.config.project, unproject: this.config.unproject, projection: this.config.projection }).map((t, i) => ({ id: this._midPoints[i], geometry: { type: "Point", coordinates: t } }));
|
|
1433
1433
|
}
|
|
1434
1434
|
}
|
|
1435
|
-
class ai extends
|
|
1435
|
+
class ai extends j {
|
|
1436
1436
|
constructor(e) {
|
|
1437
1437
|
super(e), this._selectionPoints = [];
|
|
1438
1438
|
}
|
|
@@ -1442,8 +1442,8 @@ class ai extends W {
|
|
|
1442
1442
|
set ids(e) {
|
|
1443
1443
|
}
|
|
1444
1444
|
create(e, t, i) {
|
|
1445
|
-
this._selectionPoints = this.store.create(function(n,
|
|
1446
|
-
const a = [], l =
|
|
1445
|
+
this._selectionPoints = this.store.create(function(n, o, r) {
|
|
1446
|
+
const a = [], l = o === "Polygon" ? n.length - 1 : n.length;
|
|
1447
1447
|
for (let d = 0; d < l; d++) a.push({ geometry: { type: "Point", coordinates: n[d] }, properties: r(d) });
|
|
1448
1448
|
return a;
|
|
1449
1449
|
}(e, t, (n) => ({ mode: this.mode, selectionPoint: !0, selectionPointFeatureId: i, index: n })));
|
|
@@ -1458,52 +1458,52 @@ class ai extends W {
|
|
|
1458
1458
|
if (this._selectionPoints[e] !== void 0) return { id: this._selectionPoints[e], geometry: { type: "Point", coordinates: t } };
|
|
1459
1459
|
}
|
|
1460
1460
|
}
|
|
1461
|
-
function wt(
|
|
1461
|
+
function wt(s, e) {
|
|
1462
1462
|
let t = !1;
|
|
1463
1463
|
for (let r = 0, a = e.length; r < a; r++) {
|
|
1464
1464
|
const l = e[r];
|
|
1465
|
-
for (let d = 0, c = l.length, h = c - 1; d < c; h = d++) (n = l[d])[1] > (i =
|
|
1465
|
+
for (let d = 0, c = l.length, h = c - 1; d < c; h = d++) (n = l[d])[1] > (i = s)[1] != (o = l[h])[1] > i[1] && i[0] < (o[0] - n[0]) * (i[1] - n[1]) / (o[1] - n[1]) + n[0] && (t = !t);
|
|
1466
1466
|
}
|
|
1467
|
-
var i, n,
|
|
1467
|
+
var i, n, o;
|
|
1468
1468
|
return t;
|
|
1469
1469
|
}
|
|
1470
|
-
const bt = (
|
|
1471
|
-
const i = (
|
|
1472
|
-
return Math.sqrt(((
|
|
1470
|
+
const bt = (s, e, t) => {
|
|
1471
|
+
const i = (o) => o * o, n = (o, r) => i(o.x - r.x) + i(o.y - r.y);
|
|
1472
|
+
return Math.sqrt(((o, r, a) => {
|
|
1473
1473
|
const l = n(r, a);
|
|
1474
|
-
if (l === 0) return n(
|
|
1475
|
-
let d = ((
|
|
1476
|
-
return d = Math.max(0, Math.min(1, d)), n(
|
|
1477
|
-
})(
|
|
1474
|
+
if (l === 0) return n(o, r);
|
|
1475
|
+
let d = ((o.x - r.x) * (a.x - r.x) + (o.y - r.y) * (a.y - r.y)) / l;
|
|
1476
|
+
return d = Math.max(0, Math.min(1, d)), n(o, { x: r.x + d * (a.x - r.x), y: r.y + d * (a.y - r.y) });
|
|
1477
|
+
})(s, e, t));
|
|
1478
1478
|
};
|
|
1479
|
-
class li extends
|
|
1479
|
+
class li extends j {
|
|
1480
1480
|
constructor(e, t, i) {
|
|
1481
1481
|
super(e), this.config = void 0, this.createClickBoundingBox = void 0, this.pixelDistance = void 0, this.config = e, this.createClickBoundingBox = t, this.pixelDistance = i;
|
|
1482
1482
|
}
|
|
1483
1483
|
find(e, t) {
|
|
1484
|
-
let i, n,
|
|
1484
|
+
let i, n, o, r, a = 1 / 0, l = 1 / 0, d = 1 / 0;
|
|
1485
1485
|
const c = this.createClickBoundingBox.create(e), h = this.store.search(c);
|
|
1486
1486
|
for (let u = 0; u < h.length; u++) {
|
|
1487
|
-
const g = h[u],
|
|
1488
|
-
if (
|
|
1489
|
-
if (g.properties.selectionPoint || !t && g.properties[
|
|
1490
|
-
const
|
|
1491
|
-
g.properties[
|
|
1492
|
-
} else if (
|
|
1487
|
+
const g = h[u], p = g.geometry;
|
|
1488
|
+
if (p.type === "Point") {
|
|
1489
|
+
if (g.properties.selectionPoint || !t && g.properties[se]) continue;
|
|
1490
|
+
const y = this.pixelDistance.measure(e, p.coordinates);
|
|
1491
|
+
g.properties[se] && y < this.pointerDistance && y < d ? (d = y, o = g) : !g.properties[se] && y < this.pointerDistance && y < a && (a = y, i = g);
|
|
1492
|
+
} else if (p.type === "LineString") {
|
|
1493
1493
|
if (i) continue;
|
|
1494
|
-
for (let
|
|
1495
|
-
const P =
|
|
1494
|
+
for (let y = 0; y < p.coordinates.length - 1; y++) {
|
|
1495
|
+
const P = p.coordinates[y], f = p.coordinates[y + 1], C = bt({ x: e.containerX, y: e.containerY }, this.project(P[0], P[1]), this.project(f[0], f[1]));
|
|
1496
1496
|
C < this.pointerDistance && C < l && (l = C, n = g);
|
|
1497
1497
|
}
|
|
1498
|
-
} else if (
|
|
1498
|
+
} else if (p.type === "Polygon") {
|
|
1499
1499
|
if (i || n) continue;
|
|
1500
|
-
wt([e.lng, e.lat],
|
|
1500
|
+
wt([e.lng, e.lat], p.coordinates) && (r = g);
|
|
1501
1501
|
}
|
|
1502
1502
|
}
|
|
1503
|
-
return { clickedFeature: i || n || r, clickedMidPoint:
|
|
1503
|
+
return { clickedFeature: i || n || r, clickedMidPoint: o };
|
|
1504
1504
|
}
|
|
1505
1505
|
}
|
|
1506
|
-
class di extends
|
|
1506
|
+
class di extends j {
|
|
1507
1507
|
constructor(e, t, i, n) {
|
|
1508
1508
|
super(e), 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 = e, this.featuresAtCursorEvent = t, this.selectionPoints = i, this.midPoints = n;
|
|
1509
1509
|
}
|
|
@@ -1524,29 +1524,29 @@ class di extends W {
|
|
|
1524
1524
|
if (!this.draggedFeatureId) return;
|
|
1525
1525
|
const i = this.store.getGeometryCopy(this.draggedFeatureId), n = [e.lng, e.lat];
|
|
1526
1526
|
if (i.type === "Polygon" || i.type === "LineString") {
|
|
1527
|
-
let
|
|
1528
|
-
if (i.type === "Polygon" ? (
|
|
1527
|
+
let o, r;
|
|
1528
|
+
if (i.type === "Polygon" ? (o = i.coordinates[0], r = o.length - 1) : (o = i.coordinates, r = o.length), !this.dragPosition) return !1;
|
|
1529
1529
|
for (let d = 0; d < r; d++) {
|
|
1530
|
-
const c =
|
|
1530
|
+
const c = o[d];
|
|
1531
1531
|
let h, u;
|
|
1532
1532
|
if (this.config.projection === "web-mercator") {
|
|
1533
|
-
const g = S(this.dragPosition[0], this.dragPosition[1]),
|
|
1533
|
+
const g = S(this.dragPosition[0], this.dragPosition[1]), p = S(n[0], n[1]), y = S(c[0], c[1]), P = { x: g.x - p.x, y: g.y - p.y }, f = y.x - P.x, C = y.y - P.y, { lng: m, lat: v } = W(f, C);
|
|
1534
1534
|
h = m, u = v;
|
|
1535
1535
|
} else {
|
|
1536
1536
|
const g = [this.dragPosition[0] - n[0], this.dragPosition[1] - n[1]];
|
|
1537
1537
|
h = c[0] - g[0], u = c[1] - g[1];
|
|
1538
1538
|
}
|
|
1539
|
-
if (h =
|
|
1540
|
-
|
|
1539
|
+
if (h = E(h, this.config.coordinatePrecision), u = E(u, this.config.coordinatePrecision), h > 180 || h < -180 || u > 90 || u < -90) return !1;
|
|
1540
|
+
o[d] = [h, u];
|
|
1541
1541
|
}
|
|
1542
|
-
i.type === "Polygon" && (
|
|
1543
|
-
const a = this.selectionPoints.getUpdated(
|
|
1542
|
+
i.type === "Polygon" && (o[o.length - 1] = [o[0][0], o[0][1]]);
|
|
1543
|
+
const a = this.selectionPoints.getUpdated(o) || [], l = this.midPoints.getUpdated(o) || [];
|
|
1544
1544
|
if (t && !t({ 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;
|
|
1545
1545
|
this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: i }, ...a, ...l]), this.dragPosition = [e.lng, e.lat];
|
|
1546
1546
|
} else i.type === "Point" && (this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: { type: "Point", coordinates: n } }]), this.dragPosition = [e.lng, e.lat]);
|
|
1547
1547
|
}
|
|
1548
1548
|
}
|
|
1549
|
-
class ci extends
|
|
1549
|
+
class ci extends j {
|
|
1550
1550
|
constructor(e, t, i, n) {
|
|
1551
1551
|
super(e), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.draggedCoordinate = { id: null, index: -1 }, this.config = e, this.pixelDistance = t, this.selectionPoints = i, this.midPoints = n;
|
|
1552
1552
|
}
|
|
@@ -1558,11 +1558,11 @@ class ci extends W {
|
|
|
1558
1558
|
if (t.type !== "Polygon") return i;
|
|
1559
1559
|
n = t.coordinates[0];
|
|
1560
1560
|
}
|
|
1561
|
-
for (let
|
|
1562
|
-
const r = this.pixelDistance.measure(e, n[
|
|
1561
|
+
for (let o = 0; o < n.length; o++) {
|
|
1562
|
+
const r = this.pixelDistance.measure(e, n[o]);
|
|
1563
1563
|
if (r < this.pointerDistance && r < i.dist) {
|
|
1564
|
-
const a = t.type === "Polygon" && (
|
|
1565
|
-
i.dist = r, i.index = a ? 0 :
|
|
1564
|
+
const a = t.type === "Polygon" && (o === n.length - 1 || o === 0);
|
|
1565
|
+
i.dist = r, i.index = a ? 0 : o, i.isFirstOrLastPolygonCoord = a;
|
|
1566
1566
|
}
|
|
1567
1567
|
}
|
|
1568
1568
|
return i;
|
|
@@ -1573,15 +1573,15 @@ class ci extends W {
|
|
|
1573
1573
|
}
|
|
1574
1574
|
drag(e, t, i) {
|
|
1575
1575
|
if (!this.draggedCoordinate.id) return !1;
|
|
1576
|
-
const n = this.draggedCoordinate.index,
|
|
1576
|
+
const n = this.draggedCoordinate.index, o = this.store.getGeometryCopy(this.draggedCoordinate.id), r = o.type === "LineString" ? o.coordinates : o.coordinates[0], a = [e.lng, e.lat];
|
|
1577
1577
|
if (e.lng > 180 || e.lng < -180 || e.lat > 90 || e.lat < -90) return !1;
|
|
1578
|
-
if (
|
|
1578
|
+
if (o.type !== "Polygon" || n !== r.length - 1 && n !== 0) r[n] = a;
|
|
1579
1579
|
else {
|
|
1580
1580
|
const h = r.length - 1;
|
|
1581
1581
|
r[0] = a, r[h] = a;
|
|
1582
1582
|
}
|
|
1583
1583
|
const l = this.selectionPoints.getOneUpdated(n, a), d = l ? [l] : [], c = this.midPoints.getUpdated(r) || [];
|
|
1584
|
-
return !(
|
|
1584
|
+
return !(o.type !== "Point" && !t && Le({ type: "Feature", geometry: o, properties: {} }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: o, 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: o }, ...d, ...c]), 0));
|
|
1585
1585
|
}
|
|
1586
1586
|
isDragging() {
|
|
1587
1587
|
return this.draggedCoordinate.id !== null;
|
|
@@ -1593,44 +1593,44 @@ class ci extends W {
|
|
|
1593
1593
|
this.draggedCoordinate = { id: null, index: -1 };
|
|
1594
1594
|
}
|
|
1595
1595
|
}
|
|
1596
|
-
function Pe(
|
|
1596
|
+
function Pe(s) {
|
|
1597
1597
|
let e = 0, t = 0, i = 0;
|
|
1598
|
-
return (
|
|
1598
|
+
return (s.geometry.type === "Polygon" ? s.geometry.coordinates[0].slice(0, -1) : s.geometry.coordinates).forEach((n) => {
|
|
1599
1599
|
e += n[0], t += n[1], i++;
|
|
1600
1600
|
}, !0), [e / i, t / i];
|
|
1601
1601
|
}
|
|
1602
|
-
function It(
|
|
1603
|
-
|
|
1604
|
-
const t = Oe, i = e[1] * Math.PI / 180, n =
|
|
1605
|
-
let r = Math.abs(
|
|
1602
|
+
function It(s, e) {
|
|
1603
|
+
s[0] += s[0] - e[0] > 180 ? -360 : e[0] - s[0] > 180 ? 360 : 0;
|
|
1604
|
+
const t = Oe, i = e[1] * Math.PI / 180, n = s[1] * Math.PI / 180, o = n - i;
|
|
1605
|
+
let r = Math.abs(s[0] - e[0]) * Math.PI / 180;
|
|
1606
1606
|
r > Math.PI && (r -= 2 * Math.PI);
|
|
1607
|
-
const a = Math.log(Math.tan(n / 2 + Math.PI / 4) / Math.tan(i / 2 + Math.PI / 4)), l = Math.abs(a) > 1e-11 ?
|
|
1608
|
-
return Math.sqrt(
|
|
1607
|
+
const a = Math.log(Math.tan(n / 2 + Math.PI / 4) / Math.tan(i / 2 + Math.PI / 4)), l = Math.abs(a) > 1e-11 ? o / a : Math.cos(i);
|
|
1608
|
+
return Math.sqrt(o * o + l * l * r * r) * t;
|
|
1609
1609
|
}
|
|
1610
|
-
function ve(
|
|
1611
|
-
const e = (
|
|
1610
|
+
function ve(s) {
|
|
1611
|
+
const e = (s.geometry.type === "Polygon" ? s.geometry.coordinates[0] : s.geometry.coordinates).map((t) => {
|
|
1612
1612
|
const { x: i, y: n } = S(t[0], t[1]);
|
|
1613
1613
|
return [i, n];
|
|
1614
1614
|
});
|
|
1615
|
-
return
|
|
1616
|
-
let i = 0, n = 0,
|
|
1615
|
+
return s.geometry.type === "Polygon" ? function(t) {
|
|
1616
|
+
let i = 0, n = 0, o = 0;
|
|
1617
1617
|
const r = t.length;
|
|
1618
1618
|
for (let a = 0; a < r - 1; a++) {
|
|
1619
1619
|
const [l, d] = t[a], [c, h] = t[a + 1], u = l * h - c * d;
|
|
1620
|
-
i += u, n += (l + c) * u,
|
|
1620
|
+
i += u, n += (l + c) * u, o += (d + h) * u;
|
|
1621
1621
|
}
|
|
1622
|
-
return i /= 2, n /= 6 * i,
|
|
1622
|
+
return i /= 2, n /= 6 * i, o /= 6 * i, { x: n, y: o };
|
|
1623
1623
|
}(e) : function(t) {
|
|
1624
1624
|
const i = t.length;
|
|
1625
|
-
let n = 0,
|
|
1625
|
+
let n = 0, o = 0;
|
|
1626
1626
|
for (let r = 0; r < i; r++) {
|
|
1627
1627
|
const [a, l] = t[r];
|
|
1628
|
-
n += a,
|
|
1628
|
+
n += a, o += l;
|
|
1629
1629
|
}
|
|
1630
|
-
return { x: n / i, y:
|
|
1630
|
+
return { x: n / i, y: o / i };
|
|
1631
1631
|
}(e);
|
|
1632
1632
|
}
|
|
1633
|
-
class hi extends
|
|
1633
|
+
class hi extends j {
|
|
1634
1634
|
constructor(e, t, i) {
|
|
1635
1635
|
super(e), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastBearing = void 0, this.config = e, this.selectionPoints = t, this.midPoints = i;
|
|
1636
1636
|
}
|
|
@@ -1640,40 +1640,40 @@ class hi extends W {
|
|
|
1640
1640
|
rotate(e, t, i) {
|
|
1641
1641
|
const n = this.store.getGeometryCopy(t);
|
|
1642
1642
|
if (n.type !== "Polygon" && n.type !== "LineString") return;
|
|
1643
|
-
const
|
|
1643
|
+
const o = [e.lng, e.lat];
|
|
1644
1644
|
let r;
|
|
1645
1645
|
const a = { type: "Feature", geometry: n, properties: {} };
|
|
1646
1646
|
if (this.config.projection === "web-mercator") {
|
|
1647
|
-
if (r =
|
|
1647
|
+
if (r = G(ve(a), S(e.lng, e.lat)), !this.lastBearing) return void (this.lastBearing = r);
|
|
1648
1648
|
((h, u) => {
|
|
1649
1649
|
if (u === 0 || u === 360 || u === -360) return h;
|
|
1650
|
-
const g = 0.017453292519943295 * u,
|
|
1651
|
-
|
|
1652
|
-
const P =
|
|
1650
|
+
const g = 0.017453292519943295 * u, p = (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).map(([f, C]) => S(f, C)), y = p.reduce((f, C) => ({ x: f.x + C.x, y: f.y + C.y }), { x: 0, y: 0 });
|
|
1651
|
+
y.x /= p.length, y.y /= p.length;
|
|
1652
|
+
const P = 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 }) => [W(f, C).lng, W(f, C).lat]);
|
|
1653
1653
|
h.geometry.type === "Polygon" ? h.geometry.coordinates[0] = P : h.geometry.coordinates = P;
|
|
1654
1654
|
})(a, -(this.lastBearing - r));
|
|
1655
1655
|
} else {
|
|
1656
1656
|
if (this.config.projection !== "globe") throw new Error("Unsupported projection");
|
|
1657
|
-
if (r = Ce(Pe({ type: "Feature", geometry: n, properties: {} }),
|
|
1657
|
+
if (r = Ce(Pe({ type: "Feature", geometry: n, properties: {} }), o), !this.lastBearing) return void (this.lastBearing = r + 180);
|
|
1658
1658
|
(function(h, u) {
|
|
1659
1659
|
if (u === 0 || u === 360 || u === -360) return h;
|
|
1660
1660
|
const g = Pe(h);
|
|
1661
|
-
(h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).forEach((
|
|
1662
|
-
const
|
|
1663
|
-
|
|
1661
|
+
(h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).forEach((p) => {
|
|
1662
|
+
const y = Ce(g, p) + u, P = It(g, p), f = je(g, P, y);
|
|
1663
|
+
p[0] = f[0], p[1] = f[1];
|
|
1664
1664
|
});
|
|
1665
1665
|
})(a, -(this.lastBearing - (r + 180)));
|
|
1666
1666
|
}
|
|
1667
1667
|
const l = n.type === "Polygon" ? n.coordinates[0] : n.coordinates;
|
|
1668
1668
|
l.forEach((h) => {
|
|
1669
|
-
h[0] =
|
|
1669
|
+
h[0] = E(h[0], this.coordinatePrecision), h[1] = E(h[1], this.coordinatePrecision);
|
|
1670
1670
|
});
|
|
1671
1671
|
const d = this.midPoints.getUpdated(l) || [], c = this.selectionPoints.getUpdated(l) || [];
|
|
1672
1672
|
if (i && !i({ id: t, type: "Feature", geometry: n, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional })) return !1;
|
|
1673
1673
|
this.store.updateGeometry([{ id: t, geometry: n }, ...c, ...d]), this.projection === "web-mercator" ? this.lastBearing = r : this.projection === "globe" && (this.lastBearing = r + 180);
|
|
1674
1674
|
}
|
|
1675
1675
|
}
|
|
1676
|
-
class ui extends
|
|
1676
|
+
class ui extends j {
|
|
1677
1677
|
constructor(e, t, i) {
|
|
1678
1678
|
super(e), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastDistance = void 0, this.config = e, this.selectionPoints = t, this.midPoints = i;
|
|
1679
1679
|
}
|
|
@@ -1683,41 +1683,41 @@ class ui extends W {
|
|
|
1683
1683
|
scale(e, t, i) {
|
|
1684
1684
|
const n = this.store.getGeometryCopy(t);
|
|
1685
1685
|
if (n.type !== "Polygon" && n.type !== "LineString") return;
|
|
1686
|
-
const
|
|
1686
|
+
const o = [e.lng, e.lat], r = { type: "Feature", geometry: n, properties: {} };
|
|
1687
1687
|
let a;
|
|
1688
1688
|
const l = ve(r);
|
|
1689
1689
|
if (this.config.projection === "web-mercator") {
|
|
1690
1690
|
const g = S(e.lng, e.lat);
|
|
1691
|
-
a =
|
|
1691
|
+
a = F(l, g);
|
|
1692
1692
|
} else {
|
|
1693
1693
|
if (this.config.projection !== "globe") throw new Error("Invalid projection");
|
|
1694
|
-
a = V(Pe({ type: "Feature", geometry: n, properties: {} }),
|
|
1694
|
+
a = V(Pe({ type: "Feature", geometry: n, properties: {} }), o);
|
|
1695
1695
|
}
|
|
1696
1696
|
if (!this.lastDistance) return void (this.lastDistance = a);
|
|
1697
1697
|
const d = 1 - (this.lastDistance - a) / a;
|
|
1698
1698
|
if (this.config.projection === "web-mercator") {
|
|
1699
|
-
const { lng: g, lat:
|
|
1700
|
-
(function(
|
|
1701
|
-
if (P === 1) return
|
|
1702
|
-
const C = (
|
|
1703
|
-
|
|
1704
|
-
})(r, d, [g,
|
|
1705
|
-
} else this.config.projection === "globe" && function(g,
|
|
1706
|
-
|
|
1707
|
-
const C = It(
|
|
1708
|
-
P !== "x" && P !== "xy" || (
|
|
1699
|
+
const { lng: g, lat: p } = W(l.x, l.y);
|
|
1700
|
+
(function(y, P, f) {
|
|
1701
|
+
if (P === 1) return y;
|
|
1702
|
+
const C = (y.geometry.type === "Polygon" ? y.geometry.coordinates[0] : y.geometry.coordinates).map(([x, w]) => S(x, w)), m = S(f[0], f[1]), v = C.map((x) => ({ x: m.x + (x.x - m.x) * P, y: m.y + (x.y - m.y) * P })).map(({ x, y: w }) => [W(x, w).lng, W(x, w).lat]);
|
|
1703
|
+
y.geometry.type === "Polygon" ? y.geometry.coordinates[0] = v : y.geometry.coordinates = v;
|
|
1704
|
+
})(r, d, [g, p]);
|
|
1705
|
+
} else this.config.projection === "globe" && function(g, p, y, P = "xy") {
|
|
1706
|
+
p === 1 || (g.geometry.type === "Polygon" ? g.geometry.coordinates[0] : g.geometry.coordinates).forEach((f) => {
|
|
1707
|
+
const C = It(y, f), m = Ce(y, f), v = je(y, C * p, m);
|
|
1708
|
+
P !== "x" && P !== "xy" || (f[0] = v[0]), P !== "y" && P !== "xy" || (f[1] = v[1]);
|
|
1709
1709
|
});
|
|
1710
1710
|
}(r, d, Pe(r));
|
|
1711
1711
|
const c = n.type === "Polygon" ? n.coordinates[0] : n.coordinates;
|
|
1712
1712
|
c.forEach((g) => {
|
|
1713
|
-
g[0] =
|
|
1713
|
+
g[0] = E(g[0], this.coordinatePrecision), g[1] = E(g[1], this.coordinatePrecision);
|
|
1714
1714
|
});
|
|
1715
1715
|
const h = this.midPoints.getUpdated(c) || [], u = this.selectionPoints.getUpdated(c) || [];
|
|
1716
1716
|
if (i && !i({ id: t, type: "Feature", geometry: n, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional })) return !1;
|
|
1717
1717
|
this.store.updateGeometry([{ id: t, geometry: n }, ...u, ...h]), this.lastDistance = a;
|
|
1718
1718
|
}
|
|
1719
1719
|
}
|
|
1720
|
-
class gi extends
|
|
1720
|
+
class gi extends j {
|
|
1721
1721
|
constructor(e, t, i, n) {
|
|
1722
1722
|
super(e), 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 = e, this.pixelDistance = t, this.selectionPoints = i, this.midPoints = n;
|
|
1723
1723
|
}
|
|
@@ -1729,11 +1729,11 @@ class gi extends W {
|
|
|
1729
1729
|
if (t.type !== "Polygon") return i;
|
|
1730
1730
|
n = t.coordinates[0];
|
|
1731
1731
|
}
|
|
1732
|
-
for (let
|
|
1733
|
-
const r = this.pixelDistance.measure(e, n[
|
|
1732
|
+
for (let o = 0; o < n.length; o++) {
|
|
1733
|
+
const r = this.pixelDistance.measure(e, n[o]);
|
|
1734
1734
|
if (r < this.pointerDistance && r < i.dist) {
|
|
1735
|
-
const a = t.type === "Polygon" && (
|
|
1736
|
-
i.dist = r, i.index = a ? 0 :
|
|
1735
|
+
const a = t.type === "Polygon" && (o === n.length - 1 || o === 0);
|
|
1736
|
+
i.dist = r, i.index = a ? 0 : o, i.isFirstOrLastPolygonCoord = a;
|
|
1737
1737
|
}
|
|
1738
1738
|
}
|
|
1739
1739
|
return i;
|
|
@@ -1776,43 +1776,43 @@ class gi extends W {
|
|
|
1776
1776
|
centerWebMercatorDrag(e) {
|
|
1777
1777
|
const t = this.getSelectedFeatureDataWebMercator();
|
|
1778
1778
|
if (!t) return null;
|
|
1779
|
-
const { feature: i, boundingBox: n, updatedCoords:
|
|
1779
|
+
const { feature: i, boundingBox: n, updatedCoords: o, selectedCoordinate: r } = t, a = ve(i);
|
|
1780
1780
|
if (!a) return null;
|
|
1781
1781
|
const l = S(r[0], r[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(n, l), c = S(e.lng, e.lat);
|
|
1782
|
-
return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords:
|
|
1782
|
+
return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), o;
|
|
1783
1783
|
}
|
|
1784
1784
|
centerFixedWebMercatorDrag(e) {
|
|
1785
1785
|
const t = this.getSelectedFeatureDataWebMercator();
|
|
1786
1786
|
if (!t) return null;
|
|
1787
|
-
const { feature: i, boundingBox: n, updatedCoords:
|
|
1787
|
+
const { feature: i, boundingBox: n, updatedCoords: o, selectedCoordinate: r } = t, a = ve(i);
|
|
1788
1788
|
if (!a) return null;
|
|
1789
1789
|
const l = S(r[0], r[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(n, l), c = S(e.lng, e.lat);
|
|
1790
|
-
return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords:
|
|
1790
|
+
return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), o;
|
|
1791
1791
|
}
|
|
1792
|
-
scaleFixedWebMercator({ closestBBoxIndex: e, webMercatorOrigin: t, webMercatorSelected: i, webMercatorCursor: n, updatedCoords:
|
|
1792
|
+
scaleFixedWebMercator({ closestBBoxIndex: e, webMercatorOrigin: t, webMercatorSelected: i, webMercatorCursor: n, updatedCoords: o }) {
|
|
1793
1793
|
if (!this.isValidDragWebMercator(e, t.x - n.x, t.y - n.y)) return null;
|
|
1794
|
-
let r =
|
|
1795
|
-
return r < 0 && (r = this.minimumScale), this.performWebMercatorScale(
|
|
1794
|
+
let r = F(t, n) / F(t, i);
|
|
1795
|
+
return r < 0 && (r = this.minimumScale), this.performWebMercatorScale(o, t.x, t.y, r, r), o;
|
|
1796
1796
|
}
|
|
1797
1797
|
oppositeFixedWebMercatorDrag(e) {
|
|
1798
1798
|
const t = this.getSelectedFeatureDataWebMercator();
|
|
1799
1799
|
if (!t) return null;
|
|
1800
|
-
const { boundingBox: i, updatedCoords: n, selectedCoordinate:
|
|
1800
|
+
const { boundingBox: i, updatedCoords: n, selectedCoordinate: o } = t, r = S(o[0], o[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, r), d = { x: i[a][0], y: i[a][1] }, c = S(e.lng, e.lat);
|
|
1801
1801
|
return this.scaleFixedWebMercator({ closestBBoxIndex: l, updatedCoords: n, webMercatorCursor: c, webMercatorSelected: r, webMercatorOrigin: d }), n;
|
|
1802
1802
|
}
|
|
1803
1803
|
oppositeWebMercatorDrag(e) {
|
|
1804
1804
|
const t = this.getSelectedFeatureDataWebMercator();
|
|
1805
1805
|
if (!t) return null;
|
|
1806
|
-
const { boundingBox: i, updatedCoords: n, selectedCoordinate:
|
|
1806
|
+
const { boundingBox: i, updatedCoords: n, selectedCoordinate: o } = t, r = S(o[0], o[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, r), d = { x: i[a][0], y: i[a][1] }, c = S(e.lng, e.lat);
|
|
1807
1807
|
return this.scaleWebMercator({ closestBBoxIndex: l, updatedCoords: n, webMercatorCursor: c, webMercatorSelected: r, webMercatorOrigin: d }), n;
|
|
1808
1808
|
}
|
|
1809
|
-
scaleWebMercator({ closestBBoxIndex: e, webMercatorOrigin: t, webMercatorSelected: i, webMercatorCursor: n, updatedCoords:
|
|
1809
|
+
scaleWebMercator({ closestBBoxIndex: e, webMercatorOrigin: t, webMercatorSelected: i, webMercatorCursor: n, updatedCoords: o }) {
|
|
1810
1810
|
const r = t.x - n.x, a = t.y - n.y;
|
|
1811
1811
|
if (!this.isValidDragWebMercator(e, r, a)) return null;
|
|
1812
1812
|
let l = 1;
|
|
1813
1813
|
r !== 0 && e !== 1 && e !== 5 && (l = 1 - (t.x - i.x - r) / r);
|
|
1814
1814
|
let d = 1;
|
|
1815
|
-
return a !== 0 && e !== 3 && e !== 7 && (d = 1 - (t.y - i.y - a) / a), this.validateScale(l, d) ? (l < 0 && (l = this.minimumScale), d < 0 && (d = this.minimumScale), this.performWebMercatorScale(
|
|
1815
|
+
return a !== 0 && e !== 3 && e !== 7 && (d = 1 - (t.y - i.y - a) / a), this.validateScale(l, d) ? (l < 0 && (l = this.minimumScale), d < 0 && (d = this.minimumScale), this.performWebMercatorScale(o, t.x, t.y, l, d), o) : null;
|
|
1816
1816
|
}
|
|
1817
1817
|
getFeature(e) {
|
|
1818
1818
|
if (this.draggedCoordinate.id === null) return null;
|
|
@@ -1826,9 +1826,9 @@ class gi extends W {
|
|
|
1826
1826
|
const i = !isNaN(e) && t < Number.MAX_SAFE_INTEGER, n = !isNaN(t) && t < Number.MAX_SAFE_INTEGER;
|
|
1827
1827
|
return i && n;
|
|
1828
1828
|
}
|
|
1829
|
-
performWebMercatorScale(e, t, i, n,
|
|
1829
|
+
performWebMercatorScale(e, t, i, n, o) {
|
|
1830
1830
|
e.forEach((r) => {
|
|
1831
|
-
const { x: a, y: l } = S(r[0], r[1]), d = t + (a - t) * n, c = i + (l - i) *
|
|
1831
|
+
const { x: a, y: l } = S(r[0], r[1]), d = t + (a - t) * n, c = i + (l - i) * o, { lng: h, lat: u } = W(d, c);
|
|
1832
1832
|
r[0] = h, r[1] = u;
|
|
1833
1833
|
});
|
|
1834
1834
|
}
|
|
@@ -1840,14 +1840,14 @@ class gi extends W {
|
|
|
1840
1840
|
})).forEach(([a, l]) => {
|
|
1841
1841
|
a < t[0] && (t[0] = a), l < t[1] && (t[1] = l), a > t[2] && (t[2] = a), l > t[3] && (t[3] = l);
|
|
1842
1842
|
});
|
|
1843
|
-
const [i, n,
|
|
1844
|
-
return [[i, r], [(i +
|
|
1843
|
+
const [i, n, o, r] = t;
|
|
1844
|
+
return [[i, r], [(i + o) / 2, r], [o, r], [o, r + (n - r) / 2], [o, n], [(i + o) / 2, n], [i, n], [i, r + (n - r) / 2]];
|
|
1845
1845
|
}
|
|
1846
1846
|
getIndexesWebMercator(e, t) {
|
|
1847
1847
|
let i, n = 1 / 0;
|
|
1848
|
-
for (let
|
|
1849
|
-
const r =
|
|
1850
|
-
r < n && (i =
|
|
1848
|
+
for (let o = 0; o < e.length; o++) {
|
|
1849
|
+
const r = F({ x: t.x, y: t.y }, { x: e[o][0], y: e[o][1] });
|
|
1850
|
+
r < n && (i = o, n = r);
|
|
1851
1851
|
}
|
|
1852
1852
|
if (i === void 0) throw new Error("No closest coordinate found");
|
|
1853
1853
|
return { oppositeBboxIndex: this.boundingBoxMaps.opposite[i], closestBBoxIndex: i };
|
|
@@ -1869,13 +1869,13 @@ class gi extends W {
|
|
|
1869
1869
|
if (!this.draggedCoordinate.id) return !1;
|
|
1870
1870
|
const n = this.getFeature(this.draggedCoordinate.id);
|
|
1871
1871
|
if (!n) return !1;
|
|
1872
|
-
let
|
|
1873
|
-
if (t === "center" ?
|
|
1874
|
-
for (let d = 0; d <
|
|
1875
|
-
const c =
|
|
1876
|
-
if (c[0] =
|
|
1872
|
+
let o = null;
|
|
1873
|
+
if (t === "center" ? o = this.centerWebMercatorDrag(e) : t === "opposite" ? o = this.oppositeWebMercatorDrag(e) : t === "center-fixed" ? o = this.centerFixedWebMercatorDrag(e) : t === "opposite-fixed" && (o = this.oppositeFixedWebMercatorDrag(e)), !o) return !1;
|
|
1874
|
+
for (let d = 0; d < o.length; d++) {
|
|
1875
|
+
const c = o[d];
|
|
1876
|
+
if (c[0] = E(c[0], this.coordinatePrecision), c[1] = E(c[1], this.coordinatePrecision), !xe(c, this.coordinatePrecision)) return !1;
|
|
1877
1877
|
}
|
|
1878
|
-
const r = this.midPoints.getUpdated(
|
|
1878
|
+
const r = this.midPoints.getUpdated(o) || [], a = this.selectionPoints.getUpdated(o) || [], l = { type: n.geometry.type, coordinates: n.geometry.type === "Polygon" ? [o] : o };
|
|
1879
1879
|
return !(i && !i({ id: this.draggedCoordinate.id, type: "Feature", geometry: l, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: l }, ...a, ...r]), 0));
|
|
1880
1880
|
}
|
|
1881
1881
|
}
|
|
@@ -1890,8 +1890,8 @@ class pi extends Rt {
|
|
|
1890
1890
|
this.keyEvents = e && e.keyEvents ? M({}, n, e.keyEvents) : n;
|
|
1891
1891
|
}
|
|
1892
1892
|
if (this.dragEventThrottle = e && e.dragEventThrottle !== void 0 && e.dragEventThrottle || 5, this.allowManualDeselection = (t = e == null ? void 0 : e.allowManualDeselection) == null || t, e && e.flags && e.flags) for (const n in e.flags) {
|
|
1893
|
-
const
|
|
1894
|
-
|
|
1893
|
+
const o = e.flags[n].feature;
|
|
1894
|
+
o && o.validation && (this.validations[n] = o.validation);
|
|
1895
1895
|
}
|
|
1896
1896
|
}
|
|
1897
1897
|
selectFeature(e) {
|
|
@@ -1902,13 +1902,13 @@ class pi extends Rt {
|
|
|
1902
1902
|
this._state = "selecting";
|
|
1903
1903
|
}
|
|
1904
1904
|
registerBehaviors(e) {
|
|
1905
|
-
this.pixelDistance = new We(e), this.clickBoundingBox = new
|
|
1905
|
+
this.pixelDistance = new We(e), this.clickBoundingBox = new ke(e), this.featuresAtMouseEvent = new li(e, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new ai(e), this.midPoints = new ri(e, this.selectionPoints), this.rotateFeature = new hi(e, this.selectionPoints, this.midPoints), this.scaleFeature = new ui(e, this.selectionPoints, this.midPoints), this.dragFeature = new di(e, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints), this.dragCoordinate = new ci(e, this.pixelDistance, this.selectionPoints, this.midPoints), this.dragCoordinateResizeFeature = new gi(e, this.pixelDistance, this.selectionPoints, this.midPoints);
|
|
1906
1906
|
}
|
|
1907
1907
|
deselectFeature() {
|
|
1908
1908
|
this.deselect();
|
|
1909
1909
|
}
|
|
1910
1910
|
deselect() {
|
|
1911
|
-
const e = this.selected.filter((t) => this.store.has(t)).map((t) => ({ id: t, property:
|
|
1911
|
+
const e = this.selected.filter((t) => this.store.has(t)).map((t) => ({ id: t, property: De, value: !1 }));
|
|
1912
1912
|
this.store.updateProperty(e), this.onDeselect(this.selected[0]), this.selected = [], this.selectionPoints.delete(), this.midPoints.delete();
|
|
1913
1913
|
}
|
|
1914
1914
|
deleteSelected() {
|
|
@@ -1921,7 +1921,7 @@ class pi extends Rt {
|
|
|
1921
1921
|
const u = this.store.getGeometryCopy(h), g = this.pixelDistance.measure(e, u.coordinates);
|
|
1922
1922
|
g < this.pointerDistance && g < i && (i = g, t = this.store.getPropertiesCopy(h));
|
|
1923
1923
|
}), !t) return;
|
|
1924
|
-
const n = t.selectionPointFeatureId,
|
|
1924
|
+
const n = t.selectionPointFeatureId, o = t.index, r = this.store.getPropertiesCopy(n), a = this.flags[r.mode], l = this.validations[r.mode];
|
|
1925
1925
|
if (!(a && a.feature && a.feature.coordinates && a.feature.coordinates.deletable)) return;
|
|
1926
1926
|
const d = this.store.getGeometryCopy(n);
|
|
1927
1927
|
let c;
|
|
@@ -1929,7 +1929,7 @@ class pi extends Rt {
|
|
|
1929
1929
|
if (c = d.coordinates[0], c.length <= 4) return;
|
|
1930
1930
|
} else if (d.type === "LineString" && (c = d.coordinates, c.length <= 3)) return;
|
|
1931
1931
|
if (c) {
|
|
1932
|
-
if (d.type === "Polygon" &&
|
|
1932
|
+
if (d.type === "Polygon" && o === 0 || o === c.length - 1 ? (c.shift(), c.pop(), c.push([c[0][0], c[0][1]])) : c.splice(o, 1), l && !l({ id: n, type: "Feature", geometry: d, properties: r }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Commit }).valid) return;
|
|
1933
1933
|
this.store.delete([...this.midPoints.ids, ...this.selectionPoints.ids]), this.store.updateGeometry([{ id: n, geometry: d }]), this.selectionPoints.create(c, d.type, n), a && a.feature && a.feature.coordinates && a.feature.coordinates.midpoints && this.midPoints.create(c, n, this.coordinatePrecision);
|
|
1934
1934
|
}
|
|
1935
1935
|
}
|
|
@@ -1937,9 +1937,9 @@ class pi extends Rt {
|
|
|
1937
1937
|
if (this.selected[0] === e) return;
|
|
1938
1938
|
const { mode: i } = this.store.getPropertiesCopy(e), n = this.flags[i];
|
|
1939
1939
|
if (!n || !n.feature) return;
|
|
1940
|
-
const
|
|
1941
|
-
if (
|
|
1942
|
-
if (
|
|
1940
|
+
const o = this.selected[0];
|
|
1941
|
+
if (o) {
|
|
1942
|
+
if (o === e) return;
|
|
1943
1943
|
this.deselect();
|
|
1944
1944
|
}
|
|
1945
1945
|
t && this.setCursor(this.cursors.pointerOver), this.selected = [e], this.store.updateProperty([{ id: e, property: "selected", value: !0 }]), this.onSelect(e);
|
|
@@ -1990,20 +1990,20 @@ class pi extends Rt {
|
|
|
1990
1990
|
const i = this.store.getPropertiesCopy(this.selected[0]), n = this.flags[i.mode];
|
|
1991
1991
|
if (!(n && n.feature && (n.feature.draggable || n.feature.coordinates && n.feature.coordinates.draggable || n.feature.coordinates && n.feature.coordinates.resizable))) return;
|
|
1992
1992
|
this.dragEventCount = 0;
|
|
1993
|
-
const
|
|
1994
|
-
return n && n.feature && n.feature.coordinates && (n.feature.coordinates.draggable || n.feature.coordinates.resizable) && r !== -1 ? (this.setCursor(this.cursors.dragStart), n.feature.coordinates.resizable ? this.dragCoordinateResizeFeature.startDragging(
|
|
1993
|
+
const o = this.selected[0], r = this.dragCoordinate.getDraggableIndex(e, o);
|
|
1994
|
+
return n && n.feature && n.feature.coordinates && (n.feature.coordinates.draggable || n.feature.coordinates.resizable) && r !== -1 ? (this.setCursor(this.cursors.dragStart), n.feature.coordinates.resizable ? this.dragCoordinateResizeFeature.startDragging(o, r) : this.dragCoordinate.startDragging(o, r), void t(!1)) : n && n.feature && n.feature.draggable && this.dragFeature.canDrag(e, o) ? (this.setCursor(this.cursors.dragStart), this.dragFeature.startDragging(e, o), void t(!1)) : void 0;
|
|
1995
1995
|
}
|
|
1996
1996
|
onDrag(e, t) {
|
|
1997
1997
|
const i = this.selected[0];
|
|
1998
1998
|
if (!i) return;
|
|
1999
|
-
const n = this.store.getPropertiesCopy(i),
|
|
1999
|
+
const n = this.store.getPropertiesCopy(i), o = this.flags[n.mode], r = (o && o.feature && o.feature.selfIntersectable) === !0;
|
|
2000
2000
|
if (this.dragEventCount++, this.dragEventCount % this.dragEventThrottle == 0) return;
|
|
2001
2001
|
const a = this.validations[n.mode];
|
|
2002
|
-
if (
|
|
2003
|
-
if (
|
|
2004
|
-
if (this.dragCoordinateResizeFeature.isDragging() &&
|
|
2002
|
+
if (o && o.feature && o.feature.rotateable && this.canRotate(e)) return t(!1), void this.rotateFeature.rotate(e, i, a);
|
|
2003
|
+
if (o && o.feature && o.feature.scaleable && this.canScale(e)) return t(!1), void this.scaleFeature.scale(e, i, a);
|
|
2004
|
+
if (this.dragCoordinateResizeFeature.isDragging() && o.feature && o.feature.coordinates && o.feature.coordinates.resizable) {
|
|
2005
2005
|
if (this.projection === "globe") throw new Error("Globe is currently unsupported projection for resizable");
|
|
2006
|
-
return t(!1), void this.dragCoordinateResizeFeature.drag(e,
|
|
2006
|
+
return t(!1), void this.dragCoordinateResizeFeature.drag(e, o.feature.coordinates.resizable, a);
|
|
2007
2007
|
}
|
|
2008
2008
|
this.dragCoordinate.isDragging() ? this.dragCoordinate.drag(e, r, a) : this.dragFeature.isDragging() ? this.dragFeature.drag(e, a) : t(!0);
|
|
2009
2009
|
}
|
|
@@ -2014,14 +2014,14 @@ class pi extends Rt {
|
|
|
2014
2014
|
if (!this.selected.length) return void this.setCursor("unset");
|
|
2015
2015
|
if (this.dragFeature.isDragging()) return;
|
|
2016
2016
|
let t = !1;
|
|
2017
|
-
this.midPoints.ids.forEach((
|
|
2017
|
+
this.midPoints.ids.forEach((o) => {
|
|
2018
2018
|
if (t) return;
|
|
2019
|
-
const r = this.store.getGeometryCopy(
|
|
2019
|
+
const r = this.store.getGeometryCopy(o);
|
|
2020
2020
|
this.pixelDistance.measure(e, r.coordinates) < this.pointerDistance && (t = !0);
|
|
2021
2021
|
});
|
|
2022
2022
|
let i = !1;
|
|
2023
|
-
if (this.selectionPoints.ids.forEach((
|
|
2024
|
-
const r = this.store.getGeometryCopy(
|
|
2023
|
+
if (this.selectionPoints.ids.forEach((o) => {
|
|
2024
|
+
const r = this.store.getGeometryCopy(o);
|
|
2025
2025
|
this.pixelDistance.measure(e, r.coordinates) < this.pointerDistance && (t = !1, i = !0);
|
|
2026
2026
|
}), t) return void this.setCursor(this.cursors.insertMidpoint);
|
|
2027
2027
|
const { clickedFeature: n } = this.featuresAtMouseEvent.find(e, !0);
|
|
@@ -2032,7 +2032,7 @@ class pi extends Rt {
|
|
|
2032
2032
|
if (e.properties.mode === this.mode && e.geometry.type === "Point") {
|
|
2033
2033
|
if (e.properties.selectionPoint) return t.pointColor = this.getHexColorStylingValue(this.styles.selectionPointColor, t.pointColor, e), t.pointOutlineColor = this.getHexColorStylingValue(this.styles.selectionPointOutlineColor, t.pointOutlineColor, e), t.pointWidth = this.getNumericStylingValue(this.styles.selectionPointWidth, t.pointWidth, e), t.pointOutlineWidth = this.getNumericStylingValue(this.styles.selectionPointOutlineWidth, 2, e), t.zIndex = 30, t;
|
|
2034
2034
|
if (e.properties.midPoint) return t.pointColor = this.getHexColorStylingValue(this.styles.midPointColor, t.pointColor, e), t.pointOutlineColor = this.getHexColorStylingValue(this.styles.midPointOutlineColor, t.pointOutlineColor, e), t.pointWidth = this.getNumericStylingValue(this.styles.midPointWidth, 4, e), t.pointOutlineWidth = this.getNumericStylingValue(this.styles.midPointOutlineWidth, 2, e), t.zIndex = 40, t;
|
|
2035
|
-
} else if (e.properties[
|
|
2035
|
+
} else if (e.properties[De]) {
|
|
2036
2036
|
if (e.geometry.type === "Polygon") return t.polygonFillColor = this.getHexColorStylingValue(this.styles.selectedPolygonColor, t.polygonFillColor, e), t.polygonOutlineWidth = this.getNumericStylingValue(this.styles.selectedPolygonOutlineWidth, t.polygonOutlineWidth, e), t.polygonOutlineColor = this.getHexColorStylingValue(this.styles.selectedPolygonOutlineColor, t.polygonOutlineColor, e), t.polygonFillOpacity = this.getNumericStylingValue(this.styles.selectedPolygonFillOpacity, t.polygonFillOpacity, e), t.zIndex = 10, t;
|
|
2037
2037
|
if (e.geometry.type === "LineString") return t.lineStringColor = this.getHexColorStylingValue(this.styles.selectedLineStringColor, t.lineStringColor, e), t.lineStringWidth = this.getNumericStylingValue(this.styles.selectedLineStringWidth, t.lineStringWidth, e), t.zIndex = 10, t;
|
|
2038
2038
|
if (e.geometry.type === "Point") return t.pointWidth = this.getNumericStylingValue(this.styles.selectedPointWidth, t.pointWidth, e), t.pointColor = this.getHexColorStylingValue(this.styles.selectedPointColor, t.pointColor, e), t.pointOutlineColor = this.getHexColorStylingValue(this.styles.selectedPointOutlineColor, t.pointOutlineColor, e), t.pointOutlineWidth = this.getNumericStylingValue(this.styles.selectedPointOutlineWidth, t.pointOutlineWidth, e), t.zIndex = 10, t;
|
|
@@ -2040,9 +2040,9 @@ class pi extends Rt {
|
|
|
2040
2040
|
return t;
|
|
2041
2041
|
}
|
|
2042
2042
|
}
|
|
2043
|
-
class
|
|
2043
|
+
class yi extends N {
|
|
2044
2044
|
constructor(...e) {
|
|
2045
|
-
super(...e), this.type =
|
|
2045
|
+
super(...e), this.type = K.Static, this.mode = "static";
|
|
2046
2046
|
}
|
|
2047
2047
|
start() {
|
|
2048
2048
|
}
|
|
@@ -2068,70 +2068,70 @@ class fi extends N {
|
|
|
2068
2068
|
return M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
2069
2069
|
}
|
|
2070
2070
|
}
|
|
2071
|
-
function
|
|
2071
|
+
function Et(s, e, t, i, n) {
|
|
2072
2072
|
for (; i > t; ) {
|
|
2073
2073
|
if (i - t > 600) {
|
|
2074
2074
|
const l = i - t + 1, d = e - t + 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);
|
|
2075
|
-
|
|
2075
|
+
Et(s, e, Math.max(t, Math.floor(e - d * h / l + u)), Math.min(i, Math.floor(e + (l - d) * h / l + u)), n);
|
|
2076
2076
|
}
|
|
2077
|
-
const
|
|
2077
|
+
const o = s[e];
|
|
2078
2078
|
let r = t, a = i;
|
|
2079
|
-
for (te(
|
|
2080
|
-
for (te(
|
|
2081
|
-
for (; n(
|
|
2079
|
+
for (te(s, t, e), n(s[i], o) > 0 && te(s, t, i); r < a; ) {
|
|
2080
|
+
for (te(s, r, a), r++, a--; n(s[r], o) < 0; ) r++;
|
|
2081
|
+
for (; n(s[a], o) > 0; ) a--;
|
|
2082
2082
|
}
|
|
2083
|
-
n(
|
|
2083
|
+
n(s[t], o) === 0 ? te(s, t, a) : (a++, te(s, a, i)), a <= e && (t = a + 1), e <= a && (i = a - 1);
|
|
2084
2084
|
}
|
|
2085
2085
|
}
|
|
2086
|
-
function te(
|
|
2087
|
-
const i =
|
|
2088
|
-
|
|
2086
|
+
function te(s, e, t) {
|
|
2087
|
+
const i = s[e];
|
|
2088
|
+
s[e] = s[t], s[t] = i;
|
|
2089
2089
|
}
|
|
2090
|
-
function q(
|
|
2091
|
-
ne(
|
|
2090
|
+
function q(s, e) {
|
|
2091
|
+
ne(s, 0, s.children.length, e, s);
|
|
2092
2092
|
}
|
|
2093
|
-
function ne(
|
|
2093
|
+
function ne(s, e, t, i, n) {
|
|
2094
2094
|
n || (n = Z([])), n.minX = 1 / 0, n.minY = 1 / 0, n.maxX = -1 / 0, n.maxY = -1 / 0;
|
|
2095
|
-
for (let
|
|
2096
|
-
const r =
|
|
2097
|
-
|
|
2095
|
+
for (let o = e; o < t; o++) {
|
|
2096
|
+
const r = s.children[o];
|
|
2097
|
+
oe(n, s.leaf ? i(r) : r);
|
|
2098
2098
|
}
|
|
2099
2099
|
return n;
|
|
2100
2100
|
}
|
|
2101
|
-
function
|
|
2102
|
-
return
|
|
2101
|
+
function oe(s, e) {
|
|
2102
|
+
return s.minX = Math.min(s.minX, e.minX), s.minY = Math.min(s.minY, e.minY), s.maxX = Math.max(s.maxX, e.maxX), s.maxY = Math.max(s.maxY, e.maxY), s;
|
|
2103
2103
|
}
|
|
2104
|
-
function
|
|
2105
|
-
return
|
|
2104
|
+
function fi(s, e) {
|
|
2105
|
+
return s.minX - e.minX;
|
|
2106
2106
|
}
|
|
2107
|
-
function mi(
|
|
2108
|
-
return
|
|
2107
|
+
function mi(s, e) {
|
|
2108
|
+
return s.minY - e.minY;
|
|
2109
2109
|
}
|
|
2110
|
-
function Ie(
|
|
2111
|
-
return (
|
|
2110
|
+
function Ie(s) {
|
|
2111
|
+
return (s.maxX - s.minX) * (s.maxY - s.minY);
|
|
2112
2112
|
}
|
|
2113
|
-
function ge(
|
|
2114
|
-
return
|
|
2113
|
+
function ge(s) {
|
|
2114
|
+
return s.maxX - s.minX + (s.maxY - s.minY);
|
|
2115
2115
|
}
|
|
2116
|
-
function Ci(
|
|
2117
|
-
const t = Math.max(
|
|
2118
|
-
return Math.max(0, n - t) * Math.max(0,
|
|
2116
|
+
function Ci(s, e) {
|
|
2117
|
+
const t = Math.max(s.minX, e.minX), i = Math.max(s.minY, e.minY), n = Math.min(s.maxX, e.maxX), o = Math.min(s.maxY, e.maxY);
|
|
2118
|
+
return Math.max(0, n - t) * Math.max(0, o - i);
|
|
2119
2119
|
}
|
|
2120
|
-
function
|
|
2121
|
-
return
|
|
2120
|
+
function Ee(s, e) {
|
|
2121
|
+
return s.minX <= e.minX && s.minY <= e.minY && e.maxX <= s.maxX && e.maxY <= s.maxY;
|
|
2122
2122
|
}
|
|
2123
|
-
function pe(
|
|
2124
|
-
return e.minX <=
|
|
2123
|
+
function pe(s, e) {
|
|
2124
|
+
return e.minX <= s.maxX && e.minY <= s.maxY && e.maxX >= s.minX && e.maxY >= s.minY;
|
|
2125
2125
|
}
|
|
2126
|
-
function Z(
|
|
2127
|
-
return { children:
|
|
2126
|
+
function Z(s) {
|
|
2127
|
+
return { children: s, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
|
|
2128
2128
|
}
|
|
2129
|
-
function
|
|
2130
|
-
const
|
|
2131
|
-
for (;
|
|
2132
|
-
if ((t =
|
|
2129
|
+
function ot(s, e, t, i, n) {
|
|
2130
|
+
const o = [e, t];
|
|
2131
|
+
for (; o.length; ) {
|
|
2132
|
+
if ((t = o.pop()) - (e = o.pop()) <= i) continue;
|
|
2133
2133
|
const r = e + Math.ceil((t - e) / i / 2) * i;
|
|
2134
|
-
|
|
2134
|
+
Et(s, r, e, t, n), o.push(e, r, r, t);
|
|
2135
2135
|
}
|
|
2136
2136
|
}
|
|
2137
2137
|
class Pi {
|
|
@@ -2142,13 +2142,13 @@ class Pi {
|
|
|
2142
2142
|
let t = this.data;
|
|
2143
2143
|
const i = [];
|
|
2144
2144
|
if (!pe(e, t)) return i;
|
|
2145
|
-
const n = this.toBBox,
|
|
2145
|
+
const n = this.toBBox, o = [];
|
|
2146
2146
|
for (; t; ) {
|
|
2147
2147
|
for (let r = 0; r < t.children.length; r++) {
|
|
2148
2148
|
const a = t.children[r], l = t.leaf ? n(a) : a;
|
|
2149
|
-
pe(e, l) && (t.leaf ? i.push(a) :
|
|
2149
|
+
pe(e, l) && (t.leaf ? i.push(a) : Ee(e, l) ? this._all(a, i) : o.push(a));
|
|
2150
2150
|
}
|
|
2151
|
-
t =
|
|
2151
|
+
t = o.pop();
|
|
2152
2152
|
}
|
|
2153
2153
|
return i;
|
|
2154
2154
|
}
|
|
@@ -2158,10 +2158,10 @@ class Pi {
|
|
|
2158
2158
|
const i = [];
|
|
2159
2159
|
for (; t; ) {
|
|
2160
2160
|
for (let n = 0; n < t.children.length; n++) {
|
|
2161
|
-
const
|
|
2161
|
+
const o = t.children[n], r = t.leaf ? this.toBBox(o) : o;
|
|
2162
2162
|
if (pe(e, r)) {
|
|
2163
|
-
if (t.leaf ||
|
|
2164
|
-
i.push(
|
|
2163
|
+
if (t.leaf || Ee(e, r)) return !0;
|
|
2164
|
+
i.push(o);
|
|
2165
2165
|
}
|
|
2166
2166
|
}
|
|
2167
2167
|
t = i.pop();
|
|
@@ -2193,14 +2193,14 @@ class Pi {
|
|
|
2193
2193
|
}
|
|
2194
2194
|
remove(e) {
|
|
2195
2195
|
let t = this.data;
|
|
2196
|
-
const i = this.toBBox(e), n = [],
|
|
2196
|
+
const i = this.toBBox(e), n = [], o = [];
|
|
2197
2197
|
let r, a, l = !1;
|
|
2198
2198
|
for (; t || n.length; ) {
|
|
2199
|
-
if (t || (t = n.pop(), a = n[n.length - 1], r =
|
|
2199
|
+
if (t || (t = n.pop(), a = n[n.length - 1], r = o.pop(), l = !0), t.leaf) {
|
|
2200
2200
|
const d = t.children.indexOf(e);
|
|
2201
2201
|
d !== -1 && (t.children.splice(d, 1), n.push(t), this._condense(n));
|
|
2202
2202
|
}
|
|
2203
|
-
l || t.leaf || !
|
|
2203
|
+
l || t.leaf || !Ee(t, i) ? a ? (r++, t = a.children[r], l = !1) : t = null : (n.push(t), o.push(r), r = 0, a = t, t = t.children[0]);
|
|
2204
2204
|
}
|
|
2205
2205
|
}
|
|
2206
2206
|
toBBox(e) {
|
|
@@ -2218,15 +2218,15 @@ class Pi {
|
|
|
2218
2218
|
return t;
|
|
2219
2219
|
}
|
|
2220
2220
|
_build(e, t, i, n) {
|
|
2221
|
-
const
|
|
2221
|
+
const o = i - t + 1;
|
|
2222
2222
|
let r, a = this._maxEntries;
|
|
2223
|
-
if (
|
|
2224
|
-
n || (n = Math.ceil(Math.log(
|
|
2225
|
-
const l = Math.ceil(
|
|
2226
|
-
|
|
2223
|
+
if (o <= a) return r = Z(e.slice(t, i + 1)), q(r, this.toBBox), r;
|
|
2224
|
+
n || (n = Math.ceil(Math.log(o) / Math.log(a)), a = Math.ceil(o / Math.pow(a, n - 1))), r = Z([]), r.leaf = !1, r.height = n;
|
|
2225
|
+
const l = Math.ceil(o / a), d = l * Math.ceil(Math.sqrt(a));
|
|
2226
|
+
ot(e, t, i, d, this.compareMinX);
|
|
2227
2227
|
for (let c = t; c <= i; c += d) {
|
|
2228
2228
|
const h = Math.min(c + d - 1, i);
|
|
2229
|
-
|
|
2229
|
+
ot(e, c, h, l, this.compareMinY);
|
|
2230
2230
|
for (let u = c; u <= h; u += l) {
|
|
2231
2231
|
const g = Math.min(u + l - 1, h);
|
|
2232
2232
|
r.children.push(this._build(e, u, g, n - 1));
|
|
@@ -2238,56 +2238,56 @@ class Pi {
|
|
|
2238
2238
|
for (; n.push(t), !t.leaf && n.length - 1 !== i; ) {
|
|
2239
2239
|
let a, l = 1 / 0, d = 1 / 0;
|
|
2240
2240
|
for (let c = 0; c < t.children.length; c++) {
|
|
2241
|
-
const h = t.children[c], u = Ie(h), g = (
|
|
2241
|
+
const h = t.children[c], u = Ie(h), g = (o = e, r = h, (Math.max(r.maxX, o.maxX) - Math.min(r.minX, o.minX)) * (Math.max(r.maxY, o.maxY) - Math.min(r.minY, o.minY)) - u);
|
|
2242
2242
|
g < d ? (d = g, l = u < l ? u : l, a = h) : g === d && u < l && (l = u, a = h);
|
|
2243
2243
|
}
|
|
2244
2244
|
t = a || t.children[0];
|
|
2245
2245
|
}
|
|
2246
|
-
var
|
|
2246
|
+
var o, r;
|
|
2247
2247
|
return t;
|
|
2248
2248
|
}
|
|
2249
2249
|
_insert(e, t, i) {
|
|
2250
|
-
const n = i ? e : this.toBBox(e),
|
|
2251
|
-
for (r.children.push(e),
|
|
2252
|
-
this._adjustParentBBoxes(n,
|
|
2250
|
+
const n = i ? e : this.toBBox(e), o = [], r = this._chooseSubtree(n, this.data, t, o);
|
|
2251
|
+
for (r.children.push(e), oe(r, n); t >= 0 && o[t].children.length > this._maxEntries; ) this._split(o, t), t--;
|
|
2252
|
+
this._adjustParentBBoxes(n, o, t);
|
|
2253
2253
|
}
|
|
2254
2254
|
_split(e, t) {
|
|
2255
|
-
const i = e[t], n = i.children.length,
|
|
2256
|
-
this._chooseSplitAxis(i,
|
|
2257
|
-
const r = this._chooseSplitIndex(i,
|
|
2255
|
+
const i = e[t], n = i.children.length, o = this._minEntries;
|
|
2256
|
+
this._chooseSplitAxis(i, o, n);
|
|
2257
|
+
const r = this._chooseSplitIndex(i, o, n), a = Z(i.children.splice(r, i.children.length - r));
|
|
2258
2258
|
a.height = i.height, a.leaf = i.leaf, q(i, this.toBBox), q(a, this.toBBox), t ? e[t - 1].children.push(a) : this._splitRoot(i, a);
|
|
2259
2259
|
}
|
|
2260
2260
|
_splitRoot(e, t) {
|
|
2261
2261
|
this.data = Z([e, t]), this.data.height = e.height + 1, this.data.leaf = !1, q(this.data, this.toBBox);
|
|
2262
2262
|
}
|
|
2263
2263
|
_chooseSplitIndex(e, t, i) {
|
|
2264
|
-
let n,
|
|
2264
|
+
let n, o = 1 / 0, r = 1 / 0;
|
|
2265
2265
|
for (let a = t; a <= i - t; a++) {
|
|
2266
2266
|
const l = ne(e, 0, a, this.toBBox), d = ne(e, a, i, this.toBBox), c = Ci(l, d), h = Ie(l) + Ie(d);
|
|
2267
|
-
c <
|
|
2267
|
+
c < o ? (o = c, n = a, r = h < r ? h : r) : c === o && h < r && (r = h, n = a);
|
|
2268
2268
|
}
|
|
2269
2269
|
return n || i - t;
|
|
2270
2270
|
}
|
|
2271
2271
|
_chooseSplitAxis(e, t, i) {
|
|
2272
|
-
const n = e.leaf ? this.compareMinX :
|
|
2273
|
-
this._allDistMargin(e, t, i, n) < this._allDistMargin(e, t, i,
|
|
2272
|
+
const n = e.leaf ? this.compareMinX : fi, o = e.leaf ? this.compareMinY : mi;
|
|
2273
|
+
this._allDistMargin(e, t, i, n) < this._allDistMargin(e, t, i, o) && e.children.sort(n);
|
|
2274
2274
|
}
|
|
2275
2275
|
_allDistMargin(e, t, i, n) {
|
|
2276
2276
|
e.children.sort(n);
|
|
2277
|
-
const
|
|
2277
|
+
const o = this.toBBox, r = ne(e, 0, t, o), a = ne(e, i - t, i, o);
|
|
2278
2278
|
let l = ge(r) + ge(a);
|
|
2279
2279
|
for (let d = t; d < i - t; d++) {
|
|
2280
2280
|
const c = e.children[d];
|
|
2281
|
-
|
|
2281
|
+
oe(r, e.leaf ? o(c) : c), l += ge(r);
|
|
2282
2282
|
}
|
|
2283
2283
|
for (let d = i - t - 1; d >= t; d--) {
|
|
2284
2284
|
const c = e.children[d];
|
|
2285
|
-
|
|
2285
|
+
oe(a, e.leaf ? o(c) : c), l += ge(a);
|
|
2286
2286
|
}
|
|
2287
2287
|
return l;
|
|
2288
2288
|
}
|
|
2289
2289
|
_adjustParentBBoxes(e, t, i) {
|
|
2290
|
-
for (let n = i; n >= 0; n--)
|
|
2290
|
+
for (let n = i; n >= 0; n--) oe(t[n], e);
|
|
2291
2291
|
}
|
|
2292
2292
|
_condense(e) {
|
|
2293
2293
|
for (let t, i = e.length - 1; i >= 0; i--) e[i].children.length === 0 ? i > 0 ? (t = e[i - 1].children, t.splice(t.indexOf(e[i]), 1)) : this.clear() : q(e[i], this.toBBox);
|
|
@@ -2310,8 +2310,8 @@ class vi {
|
|
|
2310
2310
|
n = [e.geometry.coordinates];
|
|
2311
2311
|
}
|
|
2312
2312
|
for (let a = 0; a < n.length; a++) i.push(n[a][1]), t.push(n[a][0]);
|
|
2313
|
-
const
|
|
2314
|
-
return { minX: Math.min(...t), minY:
|
|
2313
|
+
const o = Math.min(...i), r = Math.max(...i);
|
|
2314
|
+
return { minX: Math.min(...t), minY: o, maxX: Math.max(...t), maxY: r };
|
|
2315
2315
|
}
|
|
2316
2316
|
insert(e) {
|
|
2317
2317
|
if (this.idToNode.get(String(e.id))) throw new Error("Feature already exists");
|
|
@@ -2321,9 +2321,9 @@ class vi {
|
|
|
2321
2321
|
load(e) {
|
|
2322
2322
|
const t = [], i = /* @__PURE__ */ new Set();
|
|
2323
2323
|
e.forEach((n) => {
|
|
2324
|
-
const
|
|
2325
|
-
if (this.setMaps(n,
|
|
2326
|
-
i.add(String(n.id)), t.push(
|
|
2324
|
+
const o = this.toBBox(n);
|
|
2325
|
+
if (this.setMaps(n, o), i.has(String(n.id))) throw new Error(`Duplicate feature ID found ${n.id}`);
|
|
2326
|
+
i.add(String(n.id)), t.push(o);
|
|
2327
2327
|
}), this.tree.load(t);
|
|
2328
2328
|
}
|
|
2329
2329
|
update(e) {
|
|
@@ -2346,10 +2346,10 @@ class vi {
|
|
|
2346
2346
|
return this.tree.collides(this.toBBox(e));
|
|
2347
2347
|
}
|
|
2348
2348
|
}
|
|
2349
|
-
const xi = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(
|
|
2349
|
+
const xi = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(s) {
|
|
2350
2350
|
const e = 16 * Math.random() | 0;
|
|
2351
|
-
return (
|
|
2352
|
-
}), isValidId: (
|
|
2351
|
+
return (s == "x" ? e : 3 & e | 8).toString(16);
|
|
2352
|
+
}), isValidId: (s) => typeof s == "string" && s.length === 36 };
|
|
2353
2353
|
class Si {
|
|
2354
2354
|
constructor(e) {
|
|
2355
2355
|
this.idStrategy = void 0, this.tracked = void 0, this.spatialIndex = void 0, this.store = void 0, this._onChange = () => {
|
|
@@ -2367,24 +2367,24 @@ class Si {
|
|
|
2367
2367
|
load(e, t) {
|
|
2368
2368
|
if (e.length === 0) return [];
|
|
2369
2369
|
let i = this.clone(e);
|
|
2370
|
-
const n = [],
|
|
2370
|
+
const n = [], o = [];
|
|
2371
2371
|
return i = i.filter((r) => {
|
|
2372
2372
|
r.id == null && (r.id = this.idStrategy.getId());
|
|
2373
2373
|
const a = r.id;
|
|
2374
2374
|
if (t) {
|
|
2375
2375
|
const l = t(r);
|
|
2376
|
-
if (!l.valid) return
|
|
2376
|
+
if (!l.valid) return o.push({ id: a, valid: !1, reason: l.reason }), !1;
|
|
2377
2377
|
}
|
|
2378
2378
|
if (this.tracked) {
|
|
2379
2379
|
if (r.properties.createdAt) {
|
|
2380
|
-
if (!He(r.properties.createdAt)) return
|
|
2380
|
+
if (!He(r.properties.createdAt)) return o.push({ id: r.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
|
|
2381
2381
|
} else r.properties.createdAt = +/* @__PURE__ */ new Date();
|
|
2382
2382
|
if (r.properties.updatedAt) {
|
|
2383
|
-
if (!He(r.properties.updatedAt)) return
|
|
2383
|
+
if (!He(r.properties.updatedAt)) return o.push({ id: r.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
|
|
2384
2384
|
} else r.properties.updatedAt = +/* @__PURE__ */ new Date();
|
|
2385
2385
|
}
|
|
2386
|
-
return this.has(a) ? (
|
|
2387
|
-
}), this.spatialIndex.load(i), this._onChange(n, "create"),
|
|
2386
|
+
return this.has(a) ? (o.push({ id: a, valid: !1, reason: `Feature already exists with this id: ${a}` }), !1) : (this.store[a] = r, n.push(a), o.push({ id: a, valid: !0 }), !0);
|
|
2387
|
+
}), this.spatialIndex.load(i), this._onChange(n, "create"), o;
|
|
2388
2388
|
}
|
|
2389
2389
|
search(e, t) {
|
|
2390
2390
|
const i = this.spatialIndex.search(e).map((n) => this.store[n]);
|
|
@@ -2407,26 +2407,26 @@ class Si {
|
|
|
2407
2407
|
}
|
|
2408
2408
|
updateProperty(e) {
|
|
2409
2409
|
const t = [];
|
|
2410
|
-
e.forEach(({ id: i, property: n, value:
|
|
2410
|
+
e.forEach(({ id: i, property: n, value: o }) => {
|
|
2411
2411
|
const r = this.store[i];
|
|
2412
2412
|
if (!r) throw new Error(`No feature with this (${i}), can not update geometry`);
|
|
2413
|
-
t.push(i), r.properties[n] =
|
|
2413
|
+
t.push(i), r.properties[n] = o, this.tracked && (r.properties.updatedAt = +/* @__PURE__ */ new Date());
|
|
2414
2414
|
}), this._onChange && this._onChange(t, "update");
|
|
2415
2415
|
}
|
|
2416
2416
|
updateGeometry(e) {
|
|
2417
2417
|
const t = [];
|
|
2418
2418
|
e.forEach(({ id: i, geometry: n }) => {
|
|
2419
2419
|
t.push(i);
|
|
2420
|
-
const
|
|
2421
|
-
if (!
|
|
2422
|
-
|
|
2420
|
+
const o = this.store[i];
|
|
2421
|
+
if (!o) throw new Error(`No feature with this (${i}), can not update geometry`);
|
|
2422
|
+
o.geometry = this.clone(n), this.spatialIndex.update(o), this.tracked && (o.properties.updatedAt = +/* @__PURE__ */ new Date());
|
|
2423
2423
|
}), this._onChange && this._onChange(t, "update");
|
|
2424
2424
|
}
|
|
2425
2425
|
create(e) {
|
|
2426
2426
|
const t = [];
|
|
2427
2427
|
return e.forEach(({ geometry: i, properties: n }) => {
|
|
2428
|
-
let
|
|
2429
|
-
this.tracked && (
|
|
2428
|
+
let o, r = M({}, n);
|
|
2429
|
+
this.tracked && (o = +/* @__PURE__ */ new Date(), n ? (r.createdAt = typeof n.createdAt == "number" ? n.createdAt : o, r.updatedAt = typeof n.updatedAt == "number" ? n.updatedAt : o) : r = { createdAt: o, updatedAt: o });
|
|
2430
2430
|
const a = this.getId(), l = { id: a, type: "Feature", geometry: i, properties: r };
|
|
2431
2431
|
this.store[a] = l, this.spatialIndex.insert(l), t.push(a);
|
|
2432
2432
|
}), this._onChange && this._onChange([...t], "create"), t;
|
|
@@ -2447,13 +2447,13 @@ class Si {
|
|
|
2447
2447
|
return Object.keys(this.store).length;
|
|
2448
2448
|
}
|
|
2449
2449
|
}
|
|
2450
|
-
const Mi = "Feature is not a Polygon or LineString", wi = "Feature intersects itself", bi = (
|
|
2451
|
-
function
|
|
2452
|
-
const i =
|
|
2453
|
-
let n =
|
|
2450
|
+
const Mi = "Feature is not a Polygon or LineString", wi = "Feature intersects itself", bi = (s) => s.geometry.type !== "Polygon" && s.geometry.type !== "LineString" ? { valid: !1, reason: Mi } : Le(s) ? { valid: !1, reason: wi } : { valid: !0 };
|
|
2451
|
+
function st(s, e, t) {
|
|
2452
|
+
const i = G(s, e);
|
|
2453
|
+
let n = G(e, t) - i;
|
|
2454
2454
|
return n < 0 && (n += 360), 180 - Math.abs(n - 90 - 90);
|
|
2455
2455
|
}
|
|
2456
|
-
class
|
|
2456
|
+
class Ft extends N {
|
|
2457
2457
|
constructor(e) {
|
|
2458
2458
|
super(e), this.mode = "angled-rectangle", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.cursors = void 0, this.mouseMove = !1;
|
|
2459
2459
|
const t = { start: "crosshair", close: "pointer" };
|
|
@@ -2479,13 +2479,13 @@ class Et extends N {
|
|
|
2479
2479
|
const t = this.store.getGeometryCopy(this.currentId).coordinates[0];
|
|
2480
2480
|
let i;
|
|
2481
2481
|
if (this.currentCoordinate === 1) {
|
|
2482
|
-
const n = 1 / Math.pow(10, this.coordinatePrecision - 1),
|
|
2483
|
-
i = [t[0], [e.lng, e.lat], [e.lng, e.lat -
|
|
2482
|
+
const n = 1 / Math.pow(10, this.coordinatePrecision - 1), o = Math.max(1e-6, n);
|
|
2483
|
+
i = [t[0], [e.lng, e.lat], [e.lng, e.lat - o], t[0]];
|
|
2484
2484
|
} else if (this.currentCoordinate === 2) {
|
|
2485
|
-
const n = t[0],
|
|
2486
|
-
const
|
|
2487
|
-
return
|
|
2488
|
-
}(a, d, c) === "right" ? -90 : 90),
|
|
2485
|
+
const n = t[0], o = t[1], r = Mt(n, o, this.coordinatePrecision, this.project, this.unproject), a = S(n[0], n[1]), l = S(r[0], r[1]), d = S(o[0], o[1]), c = S(e.lng, e.lat), h = F(c, a) < F(c, d), u = st(a, l, c), g = h ? 90 - u : st(a, l, c) - 90, p = F(l, c), y = Math.cos(D(g)) * p, P = G(a, d) + (function(x, w, I) {
|
|
2486
|
+
const _ = (I.x - w.x) * (x.y - w.y) - (I.y - w.y) * (x.x - w.x);
|
|
2487
|
+
return _ > 1e-10 ? "left" : _ < -1e-10 ? "right" : "left";
|
|
2488
|
+
}(a, d, c) === "right" ? -90 : 90), f = le(a, y, P), C = le(d, y, P), m = W(f.x, f.y), v = W(C.x, C.y);
|
|
2489
2489
|
i = [t[0], t[1], [v.lng, v.lat], [m.lng, m.lat], t[0]];
|
|
2490
2490
|
}
|
|
2491
2491
|
i && this.updatePolygonGeometry(this.currentId, i, b.Provisional);
|
|
@@ -2530,10 +2530,10 @@ class Et extends N {
|
|
|
2530
2530
|
return this.validateModeFeature(e, (t) => de(t, this.coordinatePrecision));
|
|
2531
2531
|
}
|
|
2532
2532
|
}
|
|
2533
|
-
function
|
|
2534
|
-
return (e.x -
|
|
2533
|
+
function Dt(s, e, t) {
|
|
2534
|
+
return (e.x - s.x) * (t.y - s.y) - (e.y - s.y) * (t.x - s.x) <= 0;
|
|
2535
2535
|
}
|
|
2536
|
-
class
|
|
2536
|
+
class _t extends N {
|
|
2537
2537
|
constructor(e) {
|
|
2538
2538
|
super(e), 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;
|
|
2539
2539
|
const t = { start: "crosshair", close: "pointer" };
|
|
@@ -2560,24 +2560,24 @@ class Dt extends N {
|
|
|
2560
2560
|
const t = this.store.getGeometryCopy(this.currentId).coordinates[0];
|
|
2561
2561
|
let i;
|
|
2562
2562
|
if (this.currentCoordinate === 1) {
|
|
2563
|
-
const n = 1 / Math.pow(10, this.coordinatePrecision - 1),
|
|
2564
|
-
i = [t[0], [e.lng, e.lat], [e.lng, e.lat -
|
|
2563
|
+
const n = 1 / Math.pow(10, this.coordinatePrecision - 1), o = Math.max(1e-6, n);
|
|
2564
|
+
i = [t[0], [e.lng, e.lat], [e.lng, e.lat - o], t[0]];
|
|
2565
2565
|
} else if (this.currentCoordinate === 2) {
|
|
2566
|
-
const n = t[0],
|
|
2566
|
+
const n = t[0], o = t[1], r = [e.lng, e.lat], a = S(n[0], n[1]), l = S(o[0], o[1]), d = S(r[0], r[1]);
|
|
2567
2567
|
if (this.direction === void 0) {
|
|
2568
|
-
const m =
|
|
2568
|
+
const m = Dt(a, l, d);
|
|
2569
2569
|
this.direction = m ? "clockwise" : "anticlockwise";
|
|
2570
2570
|
}
|
|
2571
|
-
const c =
|
|
2572
|
-
let
|
|
2573
|
-
this.direction === "anticlockwise" ? (
|
|
2574
|
-
const C = (this.direction === "anticlockwise" ? 1 : -1) *
|
|
2575
|
-
|
|
2571
|
+
const c = F(a, l), h = G(a, l), u = G(a, d), g = this.arcPoints, p = [n], y = z(h), P = z(u);
|
|
2572
|
+
let f;
|
|
2573
|
+
this.direction === "anticlockwise" ? (f = P - y, f < 0 && (f += 360)) : (f = y - P, f < 0 && (f += 360));
|
|
2574
|
+
const C = (this.direction === "anticlockwise" ? 1 : -1) * f / g;
|
|
2575
|
+
p.push(o);
|
|
2576
2576
|
for (let m = 0; m <= g; m++) {
|
|
2577
|
-
const v = le(a, c,
|
|
2578
|
-
I[0] !==
|
|
2577
|
+
const v = le(a, c, y + m * C), { lng: x, lat: w } = W(v.x, v.y), I = [E(x, this.coordinatePrecision), E(w, this.coordinatePrecision)];
|
|
2578
|
+
I[0] !== p[p.length - 1][0] && I[1] !== p[p.length - 1][1] && p.push(I);
|
|
2579
2579
|
}
|
|
2580
|
-
|
|
2580
|
+
p.push(n), i = [...p];
|
|
2581
2581
|
}
|
|
2582
2582
|
i && this.updatePolygonGeometry(this.currentId, i, b.Provisional);
|
|
2583
2583
|
}
|
|
@@ -2646,28 +2646,28 @@ class Ot extends N {
|
|
|
2646
2646
|
onMouseMove(e) {
|
|
2647
2647
|
if (this.mouseMove = !0, this.setCursor(this.cursors.start), this.currentInitialArcId !== void 0 && this.currentStartingPointId !== void 0 && this.currentCoordinate !== 0) {
|
|
2648
2648
|
if (this.currentCoordinate === 2) {
|
|
2649
|
-
const t = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, n = t[0],
|
|
2649
|
+
const t = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, n = t[0], o = [e.lng, e.lat], r = S(n[0], n[1]), a = S(o[0], o[1]), l = S(i[0], i[1]), d = F(l, r);
|
|
2650
2650
|
if (this.direction === void 0) {
|
|
2651
|
-
const C =
|
|
2651
|
+
const C = Dt(l, r, a);
|
|
2652
2652
|
this.direction = C ? "clockwise" : "anticlockwise";
|
|
2653
2653
|
}
|
|
2654
|
-
const c =
|
|
2654
|
+
const c = G(l, r), h = G(l, a), u = this.arcPoints, g = [n], p = z(c), y = z(h);
|
|
2655
2655
|
let P;
|
|
2656
|
-
this.direction === "anticlockwise" ? (P =
|
|
2657
|
-
const
|
|
2656
|
+
this.direction === "anticlockwise" ? (P = y - p, P < 0 && (P += 360)) : (P = p - y, P < 0 && (P += 360));
|
|
2657
|
+
const f = (this.direction === "anticlockwise" ? 1 : -1) * P / u;
|
|
2658
2658
|
for (let C = 0; C <= u; C++) {
|
|
2659
|
-
const m = le(l, d,
|
|
2659
|
+
const m = le(l, d, p + C * f), { lng: v, lat: x } = W(m.x, m.y), w = [E(v, this.coordinatePrecision), E(x, this.coordinatePrecision)];
|
|
2660
2660
|
w[0] !== g[g.length - 1][0] && w[1] !== g[g.length - 1][1] && g.push(w);
|
|
2661
2661
|
}
|
|
2662
2662
|
this.updateLineStringGeometry(this.currentInitialArcId, g, b.Provisional);
|
|
2663
2663
|
} else if (this.currentCoordinate === 3) {
|
|
2664
2664
|
const t = this.store.getGeometryCopy(this.currentInitialArcId).coordinates;
|
|
2665
2665
|
if (t.length < 2 || !this.direction) return;
|
|
2666
|
-
const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, n = t[0],
|
|
2667
|
-
if (this.notInSector({ normalizedCursor:
|
|
2668
|
-
const C = this.getDeltaBearing(this.direction,
|
|
2666
|
+
const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, n = t[0], o = t[t.length - 1], r = S(e.lng, e.lat), a = S(n[0], n[1]), l = S(o[0], o[1]), d = S(i[0], i[1]), c = F(d, a), h = F(d, r) < c ? a : r, u = G(d, r), g = G(d, a), p = G(d, l), y = z(g), P = z(p), f = z(u);
|
|
2667
|
+
if (this.notInSector({ normalizedCursor: f, normalizedStart: y, normalizedEnd: P, direction: this.direction })) return;
|
|
2668
|
+
const C = this.getDeltaBearing(this.direction, y, P), m = this.arcPoints, v = (this.direction === "anticlockwise" ? 1 : -1) * C / m, x = F(d, h), w = [];
|
|
2669
2669
|
for (let I = 0; I <= m; I++) {
|
|
2670
|
-
const
|
|
2670
|
+
const _ = le(d, x, y + I * v), { lng: A, lat: O } = W(_.x, _.y), B = [E(A, this.coordinatePrecision), E(O, this.coordinatePrecision)];
|
|
2671
2671
|
B[0] !== t[t.length - 1][0] && B[1] !== t[t.length - 1][1] && w.unshift(B);
|
|
2672
2672
|
}
|
|
2673
2673
|
t.push(...w), t.push(t[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, t, b.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [t] }, properties: { mode: this.mode } }]);
|
|
@@ -2726,19 +2726,19 @@ class Ot extends N {
|
|
|
2726
2726
|
}
|
|
2727
2727
|
class Ii {
|
|
2728
2728
|
constructor(e) {
|
|
2729
|
-
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 = e.adapter, this._mode = new
|
|
2729
|
+
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 = e.adapter, this._mode = new yi();
|
|
2730
2730
|
const t = /* @__PURE__ */ new Set(), i = e.modes.reduce((c, h) => {
|
|
2731
2731
|
if (t.has(h.mode)) throw new Error(`There is already a ${h.mode} mode provided`);
|
|
2732
2732
|
return t.add(h.mode), c[h.mode] = h, c;
|
|
2733
2733
|
}, {}), n = Object.keys(i);
|
|
2734
2734
|
if (n.length === 0) throw new Error("No modes provided");
|
|
2735
2735
|
n.forEach((c) => {
|
|
2736
|
-
if (i[c].type ===
|
|
2736
|
+
if (i[c].type === K.Select) {
|
|
2737
2737
|
if (this._instanceSelectMode) throw new Error("only one type of select mode can be provided");
|
|
2738
2738
|
this._instanceSelectMode = c;
|
|
2739
2739
|
}
|
|
2740
2740
|
}), this._modes = M({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new Si({ tracked: !!e.tracked, idStrategy: e.idStrategy ? e.idStrategy : void 0 });
|
|
2741
|
-
const
|
|
2741
|
+
const o = (c) => {
|
|
2742
2742
|
const h = [], u = this._store.copyAll().filter((g) => !c.includes(g.id) || (h.push(g), !1));
|
|
2743
2743
|
return { changed: h, unchanged: u };
|
|
2744
2744
|
}, r = (c, h) => {
|
|
@@ -2747,24 +2747,24 @@ class Ii {
|
|
|
2747
2747
|
});
|
|
2748
2748
|
}, a = (c, h) => {
|
|
2749
2749
|
if (!this._enabled) return;
|
|
2750
|
-
this._eventListeners.change.forEach((
|
|
2751
|
-
|
|
2750
|
+
this._eventListeners.change.forEach((p) => {
|
|
2751
|
+
p(c, h);
|
|
2752
2752
|
});
|
|
2753
|
-
const { changed: u, unchanged: g } =
|
|
2753
|
+
const { changed: u, unchanged: g } = o(c);
|
|
2754
2754
|
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());
|
|
2755
2755
|
}, l = (c) => {
|
|
2756
2756
|
if (!this._enabled) return;
|
|
2757
2757
|
this._eventListeners.select.forEach((g) => {
|
|
2758
2758
|
g(c);
|
|
2759
2759
|
});
|
|
2760
|
-
const { changed: h, unchanged: u } =
|
|
2760
|
+
const { changed: h, unchanged: u } = o([c]);
|
|
2761
2761
|
this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: h }, this.getModeStyles());
|
|
2762
2762
|
}, d = (c) => {
|
|
2763
2763
|
if (!this._enabled) return;
|
|
2764
2764
|
this._eventListeners.deselect.forEach((g) => {
|
|
2765
2765
|
g();
|
|
2766
2766
|
});
|
|
2767
|
-
const { changed: h, unchanged: u } =
|
|
2767
|
+
const { changed: h, unchanged: u } = o([c]);
|
|
2768
2768
|
h && this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: h }, this.getModeStyles());
|
|
2769
2769
|
};
|
|
2770
2770
|
Object.keys(this._modes).forEach((c) => {
|
|
@@ -2777,22 +2777,22 @@ class Ii {
|
|
|
2777
2777
|
getModeStyles() {
|
|
2778
2778
|
const e = {};
|
|
2779
2779
|
return Object.keys(this._modes).forEach((t) => {
|
|
2780
|
-
e[t] = (i) => this._instanceSelectMode && i.properties[
|
|
2780
|
+
e[t] = (i) => this._instanceSelectMode && i.properties[De] ? this._modes[this._instanceSelectMode].styleFeature.bind(this._modes[this._instanceSelectMode])(i) : this._modes[t].styleFeature.bind(this._modes[t])(i);
|
|
2781
2781
|
}), e;
|
|
2782
2782
|
}
|
|
2783
2783
|
featuresAtLocation({ lng: e, lat: t }, i) {
|
|
2784
|
-
const n = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30,
|
|
2784
|
+
const n = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, o = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, r = this._adapter.unproject.bind(this._adapter), a = this._adapter.project.bind(this._adapter), l = a(e, t), d = ft({ unproject: r, point: l, pointerDistance: n });
|
|
2785
2785
|
return this._store.search(d).filter((c) => {
|
|
2786
|
-
if (
|
|
2786
|
+
if (o && (c.properties[se] || c.properties.selectionPoint)) return !1;
|
|
2787
2787
|
if (c.geometry.type === "Point") {
|
|
2788
2788
|
const h = c.geometry.coordinates, u = a(h[0], h[1]);
|
|
2789
|
-
return
|
|
2789
|
+
return F(l, u) < n;
|
|
2790
2790
|
}
|
|
2791
2791
|
if (c.geometry.type === "LineString") {
|
|
2792
2792
|
const h = c.geometry.coordinates;
|
|
2793
2793
|
for (let u = 0; u < h.length - 1; u++) {
|
|
2794
|
-
const g = h[u],
|
|
2795
|
-
if (bt(l, a(g[0], g[1]), a(
|
|
2794
|
+
const g = h[u], p = h[u + 1];
|
|
2795
|
+
if (bt(l, a(g[0], g[1]), a(p[0], p[1])) < n) return !0;
|
|
2796
2796
|
}
|
|
2797
2797
|
return !1;
|
|
2798
2798
|
}
|
|
@@ -2848,8 +2848,8 @@ class Ii {
|
|
|
2848
2848
|
}(t)) {
|
|
2849
2849
|
const i = t.properties.mode, n = this._modes[i];
|
|
2850
2850
|
if (!n) return { id: t.id, valid: !1, reason: `${i} mode is not in the list of instantiated modes` };
|
|
2851
|
-
const
|
|
2852
|
-
return { id: t.id, valid:
|
|
2851
|
+
const o = n.validateFeature.bind(n)(t);
|
|
2852
|
+
return { id: t.id, valid: o.valid, reason: o.reason ? o.reason : o.valid ? void 0 : "Feature is invalid" };
|
|
2853
2853
|
}
|
|
2854
2854
|
return { id: t.id, valid: !1, reason: "Mode property does not exist" };
|
|
2855
2855
|
});
|
|
@@ -2926,7 +2926,7 @@ const Ri = [
|
|
|
2926
2926
|
"delete-selection",
|
|
2927
2927
|
"delete",
|
|
2928
2928
|
"download"
|
|
2929
|
-
],
|
|
2929
|
+
], Ei = {
|
|
2930
2930
|
modes: [
|
|
2931
2931
|
"render",
|
|
2932
2932
|
"point",
|
|
@@ -2944,7 +2944,7 @@ const Ri = [
|
|
|
2944
2944
|
"download"
|
|
2945
2945
|
],
|
|
2946
2946
|
open: !1
|
|
2947
|
-
},
|
|
2947
|
+
}, Fi = {
|
|
2948
2948
|
modes: [
|
|
2949
2949
|
"render",
|
|
2950
2950
|
"linestring",
|
|
@@ -2965,75 +2965,79 @@ const Ri = [
|
|
|
2965
2965
|
modeOptions: {
|
|
2966
2966
|
linestring: new Pt({
|
|
2967
2967
|
styles: {
|
|
2968
|
-
lineStringColor: "#
|
|
2968
|
+
lineStringColor: "#232E3D",
|
|
2969
2969
|
lineStringWidth: 2,
|
|
2970
2970
|
closingPointColor: "#FFFFFF",
|
|
2971
|
-
closingPointWidth:
|
|
2972
|
-
closingPointOutlineColor: "#
|
|
2971
|
+
closingPointWidth: 3,
|
|
2972
|
+
closingPointOutlineColor: "#232E3D",
|
|
2973
2973
|
closingPointOutlineWidth: 1
|
|
2974
2974
|
}
|
|
2975
2975
|
}),
|
|
2976
2976
|
polygon: new xt({
|
|
2977
2977
|
styles: {
|
|
2978
|
-
fillColor: "#
|
|
2978
|
+
fillColor: "#EDEFF0",
|
|
2979
2979
|
fillOpacity: 0.7,
|
|
2980
|
-
outlineColor: "#
|
|
2980
|
+
outlineColor: "#232E3D",
|
|
2981
2981
|
outlineWidth: 2,
|
|
2982
|
-
closingPointColor: "#
|
|
2983
|
-
closingPointWidth:
|
|
2984
|
-
closingPointOutlineColor: "#
|
|
2982
|
+
closingPointColor: "#FAFAFA",
|
|
2983
|
+
closingPointWidth: 3,
|
|
2984
|
+
closingPointOutlineColor: "#232E3D",
|
|
2985
2985
|
closingPointOutlineWidth: 1
|
|
2986
2986
|
}
|
|
2987
2987
|
}),
|
|
2988
2988
|
rectangle: new St({
|
|
2989
2989
|
styles: {
|
|
2990
|
-
fillColor: "#
|
|
2990
|
+
fillColor: "#EDEFF0",
|
|
2991
2991
|
fillOpacity: 0.7,
|
|
2992
|
-
outlineColor: "#
|
|
2992
|
+
outlineColor: "#232E3D",
|
|
2993
2993
|
outlineWidth: 2
|
|
2994
2994
|
}
|
|
2995
2995
|
}),
|
|
2996
|
-
"angled-rectangle": new
|
|
2996
|
+
"angled-rectangle": new Ft({
|
|
2997
2997
|
styles: {
|
|
2998
|
-
fillColor: "#
|
|
2998
|
+
fillColor: "#EDEFF0",
|
|
2999
2999
|
fillOpacity: 0.7,
|
|
3000
|
-
outlineColor: "#
|
|
3000
|
+
outlineColor: "#232E3D",
|
|
3001
3001
|
outlineWidth: 2
|
|
3002
3002
|
}
|
|
3003
3003
|
}),
|
|
3004
3004
|
circle: new pt({
|
|
3005
3005
|
styles: {
|
|
3006
|
-
fillColor: "#
|
|
3006
|
+
fillColor: "#EDEFF0",
|
|
3007
3007
|
fillOpacity: 0.7,
|
|
3008
|
-
outlineColor: "#
|
|
3008
|
+
outlineColor: "#232E3D",
|
|
3009
3009
|
outlineWidth: 2
|
|
3010
3010
|
}
|
|
3011
3011
|
}),
|
|
3012
|
-
freehand: new
|
|
3012
|
+
freehand: new yt({
|
|
3013
3013
|
styles: {
|
|
3014
|
-
fillColor: "#
|
|
3014
|
+
fillColor: "#EDEFF0",
|
|
3015
3015
|
fillOpacity: 0.7,
|
|
3016
|
-
outlineColor: "#
|
|
3017
|
-
outlineWidth: 2
|
|
3016
|
+
outlineColor: "#232E3D",
|
|
3017
|
+
outlineWidth: 2,
|
|
3018
|
+
closingPointColor: "#FAFAFA",
|
|
3019
|
+
closingPointWidth: 3,
|
|
3020
|
+
closingPointOutlineColor: "#232E3D",
|
|
3021
|
+
closingPointOutlineWidth: 1
|
|
3018
3022
|
}
|
|
3019
3023
|
}),
|
|
3020
3024
|
sensor: new Ot({
|
|
3021
3025
|
styles: {
|
|
3022
|
-
fillColor: "#
|
|
3026
|
+
fillColor: "#EDEFF0",
|
|
3023
3027
|
fillOpacity: 0.7,
|
|
3024
|
-
outlineColor: "#
|
|
3028
|
+
outlineColor: "#232E3D",
|
|
3025
3029
|
outlineWidth: 2,
|
|
3026
|
-
centerPointColor: "#
|
|
3027
|
-
centerPointWidth:
|
|
3028
|
-
centerPointOutlineColor: "#
|
|
3030
|
+
centerPointColor: "#FAFAFA",
|
|
3031
|
+
centerPointWidth: 3,
|
|
3032
|
+
centerPointOutlineColor: "#232E3D",
|
|
3029
3033
|
centerPointOutlineWidth: 1
|
|
3030
3034
|
}
|
|
3031
3035
|
}),
|
|
3032
|
-
sector: new
|
|
3036
|
+
sector: new _t({
|
|
3033
3037
|
styles: {
|
|
3034
|
-
fillColor: "#
|
|
3038
|
+
fillColor: "#EDEFF0",
|
|
3035
3039
|
fillOpacity: 0.7,
|
|
3036
|
-
outlineColor: "#
|
|
3040
|
+
outlineColor: "#232E3D",
|
|
3037
3041
|
outlineWidth: 2
|
|
3038
3042
|
}
|
|
3039
3043
|
})
|
|
@@ -3042,7 +3046,7 @@ const Ri = [
|
|
|
3042
3046
|
id: "terradraw-measure-line-label",
|
|
3043
3047
|
type: "symbol",
|
|
3044
3048
|
source: "terradraw-measure-line-source",
|
|
3045
|
-
filter: ["
|
|
3049
|
+
filter: ["==", "$type", "Point"],
|
|
3046
3050
|
layout: {
|
|
3047
3051
|
"text-field": [
|
|
3048
3052
|
"concat",
|
|
@@ -3055,30 +3059,51 @@ const Ri = [
|
|
|
3055
3059
|
"",
|
|
3056
3060
|
["concat", `
|
|
3057
3061
|
(`, ["to-string", ["get", "total"]], " ", ["get", "unit"], ")"]
|
|
3062
|
+
],
|
|
3063
|
+
[
|
|
3064
|
+
"case",
|
|
3065
|
+
["all", ["has", "elevation"], [">", ["get", "elevation"], 0]],
|
|
3066
|
+
["concat", `
|
|
3067
|
+
Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
3068
|
+
""
|
|
3058
3069
|
]
|
|
3059
3070
|
],
|
|
3060
3071
|
"symbol-placement": "point",
|
|
3061
|
-
"text-
|
|
3062
|
-
|
|
3072
|
+
"text-size": [
|
|
3073
|
+
"interpolate",
|
|
3074
|
+
["linear"],
|
|
3075
|
+
["zoom"],
|
|
3076
|
+
5,
|
|
3077
|
+
10,
|
|
3078
|
+
10,
|
|
3079
|
+
12,
|
|
3080
|
+
13,
|
|
3081
|
+
14,
|
|
3082
|
+
14,
|
|
3083
|
+
16,
|
|
3084
|
+
18,
|
|
3085
|
+
18
|
|
3086
|
+
],
|
|
3063
3087
|
"text-overlap": "always",
|
|
3064
3088
|
"text-variable-anchor": ["left", "right", "top", "bottom"],
|
|
3065
|
-
"text-radial-offset":
|
|
3066
|
-
"text-justify": "center"
|
|
3089
|
+
"text-radial-offset": 0.5,
|
|
3090
|
+
"text-justify": "center",
|
|
3091
|
+
"text-letter-spacing": 0.05
|
|
3067
3092
|
},
|
|
3068
3093
|
paint: {
|
|
3069
|
-
"text-halo-color": "#
|
|
3070
|
-
"text-halo-width":
|
|
3071
|
-
"text-color": "#
|
|
3094
|
+
"text-halo-color": "#F7F7F7",
|
|
3095
|
+
"text-halo-width": 2,
|
|
3096
|
+
"text-color": "#232E3D"
|
|
3072
3097
|
}
|
|
3073
3098
|
},
|
|
3074
3099
|
lineLayerNodeSpec: {
|
|
3075
3100
|
id: "terradraw-measure-line-node",
|
|
3076
3101
|
type: "circle",
|
|
3077
3102
|
source: "terradraw-measure-line-source",
|
|
3078
|
-
filter: ["
|
|
3103
|
+
filter: ["==", "$type", "Point"],
|
|
3079
3104
|
layout: {},
|
|
3080
3105
|
paint: {
|
|
3081
|
-
"circle-radius":
|
|
3106
|
+
"circle-radius": 3,
|
|
3082
3107
|
"circle-color": "#FFFFFF",
|
|
3083
3108
|
"circle-stroke-color": "#000000",
|
|
3084
3109
|
"circle-stroke-width": 1
|
|
@@ -3088,21 +3113,35 @@ const Ri = [
|
|
|
3088
3113
|
id: "terradraw-measure-polygon-label",
|
|
3089
3114
|
type: "symbol",
|
|
3090
3115
|
source: "terradraw-measure-polygon-source",
|
|
3091
|
-
filter: ["
|
|
3116
|
+
filter: ["==", "$type", "Point"],
|
|
3092
3117
|
layout: {
|
|
3093
3118
|
"text-field": ["concat", ["to-string", ["get", "area"]], " ", ["get", "unit"]],
|
|
3094
3119
|
"symbol-placement": "point",
|
|
3095
|
-
"text-
|
|
3096
|
-
|
|
3097
|
-
|
|
3120
|
+
"text-size": [
|
|
3121
|
+
"interpolate",
|
|
3122
|
+
["linear"],
|
|
3123
|
+
["zoom"],
|
|
3124
|
+
5,
|
|
3125
|
+
10,
|
|
3126
|
+
10,
|
|
3127
|
+
12,
|
|
3128
|
+
13,
|
|
3129
|
+
14,
|
|
3130
|
+
14,
|
|
3131
|
+
16,
|
|
3132
|
+
18,
|
|
3133
|
+
18
|
|
3134
|
+
],
|
|
3135
|
+
"text-overlap": "always",
|
|
3136
|
+
"text-letter-spacing": 0.05
|
|
3098
3137
|
},
|
|
3099
3138
|
paint: {
|
|
3100
|
-
"text-halo-color": "#
|
|
3101
|
-
"text-halo-width":
|
|
3102
|
-
"text-color": "#
|
|
3139
|
+
"text-halo-color": "#F7F7F7",
|
|
3140
|
+
"text-halo-width": 2,
|
|
3141
|
+
"text-color": "#232E3D"
|
|
3103
3142
|
}
|
|
3104
3143
|
}
|
|
3105
|
-
},
|
|
3144
|
+
}, Di = () => ({
|
|
3106
3145
|
render: new ie({
|
|
3107
3146
|
modeName: "render",
|
|
3108
3147
|
styles: {}
|
|
@@ -3118,11 +3157,11 @@ const Ri = [
|
|
|
3118
3157
|
}
|
|
3119
3158
|
}),
|
|
3120
3159
|
rectangle: new St(),
|
|
3121
|
-
"angled-rectangle": new
|
|
3160
|
+
"angled-rectangle": new Ft(),
|
|
3122
3161
|
circle: new pt(),
|
|
3123
|
-
freehand: new
|
|
3162
|
+
freehand: new yt(),
|
|
3124
3163
|
sensor: new Ot(),
|
|
3125
|
-
sector: new
|
|
3164
|
+
sector: new _t(),
|
|
3126
3165
|
select: new pi({
|
|
3127
3166
|
flags: {
|
|
3128
3167
|
point: {
|
|
@@ -3237,20 +3276,20 @@ const Ri = [
|
|
|
3237
3276
|
styles: {}
|
|
3238
3277
|
})
|
|
3239
3278
|
});
|
|
3240
|
-
class
|
|
3279
|
+
class _i {
|
|
3241
3280
|
/**
|
|
3242
3281
|
* Constructor
|
|
3243
3282
|
* @param options Plugin control options
|
|
3244
3283
|
*/
|
|
3245
3284
|
constructor(e) {
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3285
|
+
k(this, "controlContainer");
|
|
3286
|
+
k(this, "map");
|
|
3287
|
+
k(this, "modeButtons", {});
|
|
3288
|
+
k(this, "isExpanded", !1);
|
|
3289
|
+
k(this, "terradraw");
|
|
3290
|
+
k(this, "options", Ei);
|
|
3291
|
+
k(this, "events", {});
|
|
3292
|
+
k(this, "defaultMode", "render");
|
|
3254
3293
|
this.modeButtons = {}, e && (this.options = Object.assign(this.options, e));
|
|
3255
3294
|
}
|
|
3256
3295
|
/**
|
|
@@ -3266,12 +3305,12 @@ class Di {
|
|
|
3266
3305
|
* @returns HTML Element
|
|
3267
3306
|
*/
|
|
3268
3307
|
onAdd(e) {
|
|
3269
|
-
var n,
|
|
3308
|
+
var n, o, r, a, l;
|
|
3270
3309
|
if (this.options && this.options.modes && this.options.modes.length === 0)
|
|
3271
3310
|
throw new Error("At least a mode must be enabled.");
|
|
3272
3311
|
this.map = e;
|
|
3273
|
-
const t =
|
|
3274
|
-
return (
|
|
3312
|
+
const t = Di(), i = [];
|
|
3313
|
+
return (o = (n = this.options) == null ? void 0 : n.modes) == null || o.forEach((d) => {
|
|
3275
3314
|
if (this.options.modeOptions && this.options.modeOptions[d]) {
|
|
3276
3315
|
const c = this.options.modeOptions[d];
|
|
3277
3316
|
if (d === "select") {
|
|
@@ -3334,8 +3373,8 @@ class Di {
|
|
|
3334
3373
|
*/
|
|
3335
3374
|
dispatchEvent(e) {
|
|
3336
3375
|
this.events[e] && this.events[e].forEach((t) => {
|
|
3337
|
-
var
|
|
3338
|
-
const i = (
|
|
3376
|
+
var o, r;
|
|
3377
|
+
const i = (o = this.terradraw) == null ? void 0 : o.getSnapshot(), n = i == null ? void 0 : i.filter((a) => a.properties.selected === !0);
|
|
3339
3378
|
t({ feature: n, mode: (r = this.terradraw) == null ? void 0 : r.getMode() });
|
|
3340
3379
|
});
|
|
3341
3380
|
}
|
|
@@ -3366,8 +3405,8 @@ class Di {
|
|
|
3366
3405
|
var i, n;
|
|
3367
3406
|
if (!this.terradraw) return;
|
|
3368
3407
|
const e = document.getElementsByClassName("maplibregl-terradraw-add-control");
|
|
3369
|
-
for (let
|
|
3370
|
-
const r = e.item(
|
|
3408
|
+
for (let o = 0; o < e.length; o++) {
|
|
3409
|
+
const r = e.item(o);
|
|
3371
3410
|
r && (this.isExpanded ? r.classList.add("hidden") : r.classList.remove("hidden"));
|
|
3372
3411
|
}
|
|
3373
3412
|
const t = document.getElementsByClassName("maplibregl-terradraw-render-button");
|
|
@@ -3396,9 +3435,9 @@ class Di {
|
|
|
3396
3435
|
t.type = "button", this.modeButtons[e] = t, e === "render" ? (t.classList.add(`maplibregl-terradraw-${e}-button`), this.isExpanded && t.classList.add("enabled"), t.type = "button", t.title = this.capitalize("expand or collapse drawing tool"), t.addEventListener("click", this.toggleEditor.bind(this))) : (t.classList.add("maplibregl-terradraw-add-control"), this.isExpanded || t.classList.add("hidden"), t.title = this.capitalize(e.replace(/-/g, " ")), e === "delete" ? (t.classList.add(`maplibregl-terradraw-${e}-button`), t.addEventListener("click", () => {
|
|
3397
3436
|
this.terradraw && this.terradraw.enabled && (this.terradraw.clear(), this.deactivate(), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.dispatchEvent("feature-deleted"));
|
|
3398
3437
|
})) : e === "delete-selection" ? (t.classList.add(`maplibregl-terradraw-${e}-button`), t.classList.add("hidden-delete-selection"), t.addEventListener("click", () => {
|
|
3399
|
-
var
|
|
3438
|
+
var o;
|
|
3400
3439
|
if (!this.terradraw || !this.terradraw.enabled) return;
|
|
3401
|
-
const n = ((
|
|
3440
|
+
const n = ((o = this.terradraw) == null ? void 0 : o.getSnapshot()).filter((r) => r.properties.selected === !0);
|
|
3402
3441
|
if (n.length > 0) {
|
|
3403
3442
|
const r = this.terradraw.getMode();
|
|
3404
3443
|
this.terradraw.setMode(this.defaultMode);
|
|
@@ -3418,11 +3457,11 @@ class Di {
|
|
|
3418
3457
|
* @returns FeatureCollection in GeoJSON format
|
|
3419
3458
|
*/
|
|
3420
3459
|
getFeatures(e = !1) {
|
|
3421
|
-
var
|
|
3460
|
+
var o;
|
|
3422
3461
|
if (!this.terradraw) return;
|
|
3423
3462
|
const n = {
|
|
3424
3463
|
type: "FeatureCollection",
|
|
3425
|
-
features: ((
|
|
3464
|
+
features: ((o = this.terradraw) == null ? void 0 : o.getSnapshot()).filter((r) => r.properties.mode !== "select")
|
|
3426
3465
|
};
|
|
3427
3466
|
return e !== !0 || (n.features = n.features.filter((r) => r.properties.selected === !0)), n;
|
|
3428
3467
|
}
|
|
@@ -3444,9 +3483,9 @@ class Di {
|
|
|
3444
3483
|
"maplibregl-terradraw-delete-button"
|
|
3445
3484
|
];
|
|
3446
3485
|
for (const n of i) {
|
|
3447
|
-
const
|
|
3448
|
-
for (let r = 0; r <
|
|
3449
|
-
const a =
|
|
3486
|
+
const o = this.controlContainer.getElementsByClassName(n);
|
|
3487
|
+
for (let r = 0; r < o.length; r++) {
|
|
3488
|
+
const a = o.item(r);
|
|
3450
3489
|
a && (a.disabled = !t);
|
|
3451
3490
|
}
|
|
3452
3491
|
}
|
|
@@ -3456,10 +3495,10 @@ class Di {
|
|
|
3456
3495
|
*/
|
|
3457
3496
|
toggleDeleteSelectionButton() {
|
|
3458
3497
|
var a, l;
|
|
3459
|
-
const e = ((a = this.terradraw) == null ? void 0 : a.enabled) || !1, t = (l = this.terradraw) == null ? void 0 : l.getMode(), i = this.getFeatures(!1), n = i && i.features.length > 0,
|
|
3498
|
+
const e = ((a = this.terradraw) == null ? void 0 : a.enabled) || !1, t = (l = this.terradraw) == null ? void 0 : l.getMode(), i = this.getFeatures(!1), n = i && i.features.length > 0, o = n && e && t === "select", r = document.getElementsByClassName("maplibregl-terradraw-delete-selection-button");
|
|
3460
3499
|
for (let d = 0; d < r.length; d++) {
|
|
3461
3500
|
const c = r.item(d);
|
|
3462
|
-
c && (
|
|
3501
|
+
c && (o ? c.classList.remove("hidden-delete-selection") : c.classList.add("hidden-delete-selection"));
|
|
3463
3502
|
}
|
|
3464
3503
|
if (!n) {
|
|
3465
3504
|
const d = document.getElementsByClassName("maplibregl-terradraw-add-select-button");
|
|
@@ -3478,77 +3517,77 @@ class Di {
|
|
|
3478
3517
|
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
3479
3518
|
}
|
|
3480
3519
|
}
|
|
3481
|
-
var
|
|
3482
|
-
centimeters:
|
|
3483
|
-
centimetres:
|
|
3520
|
+
var L = 63710088e-1, Oi = {
|
|
3521
|
+
centimeters: L * 100,
|
|
3522
|
+
centimetres: L * 100,
|
|
3484
3523
|
degrees: 360 / (2 * Math.PI),
|
|
3485
|
-
feet:
|
|
3486
|
-
inches:
|
|
3487
|
-
kilometers:
|
|
3488
|
-
kilometres:
|
|
3489
|
-
meters:
|
|
3490
|
-
metres:
|
|
3491
|
-
miles:
|
|
3492
|
-
millimeters:
|
|
3493
|
-
millimetres:
|
|
3494
|
-
nauticalmiles:
|
|
3524
|
+
feet: L * 3.28084,
|
|
3525
|
+
inches: L * 39.37,
|
|
3526
|
+
kilometers: L / 1e3,
|
|
3527
|
+
kilometres: L / 1e3,
|
|
3528
|
+
meters: L,
|
|
3529
|
+
metres: L,
|
|
3530
|
+
miles: L / 1609.344,
|
|
3531
|
+
millimeters: L * 1e3,
|
|
3532
|
+
millimetres: L * 1e3,
|
|
3533
|
+
nauticalmiles: L / 1852,
|
|
3495
3534
|
radians: 1,
|
|
3496
|
-
yards:
|
|
3535
|
+
yards: L * 1.0936
|
|
3497
3536
|
};
|
|
3498
|
-
function
|
|
3537
|
+
function Li(s, e, t = {}) {
|
|
3499
3538
|
const i = { type: "Feature" };
|
|
3500
|
-
return (t.id === 0 || t.id) && (i.id = t.id), t.bbox && (i.bbox = t.bbox), i.properties = e || {}, i.geometry =
|
|
3539
|
+
return (t.id === 0 || t.id) && (i.id = t.id), t.bbox && (i.bbox = t.bbox), i.properties = e || {}, i.geometry = s, i;
|
|
3501
3540
|
}
|
|
3502
|
-
function
|
|
3503
|
-
if (!
|
|
3541
|
+
function ki(s, e, t = {}) {
|
|
3542
|
+
if (!s)
|
|
3504
3543
|
throw new Error("coordinates is required");
|
|
3505
|
-
if (!Array.isArray(
|
|
3544
|
+
if (!Array.isArray(s))
|
|
3506
3545
|
throw new Error("coordinates must be an Array");
|
|
3507
|
-
if (
|
|
3546
|
+
if (s.length < 2)
|
|
3508
3547
|
throw new Error("coordinates must be at least 2 numbers long");
|
|
3509
|
-
if (!rt(
|
|
3548
|
+
if (!rt(s[0]) || !rt(s[1]))
|
|
3510
3549
|
throw new Error("coordinates must contain numbers");
|
|
3511
|
-
return
|
|
3550
|
+
return Li({
|
|
3512
3551
|
type: "Point",
|
|
3513
|
-
coordinates:
|
|
3552
|
+
coordinates: s
|
|
3514
3553
|
}, e, t);
|
|
3515
3554
|
}
|
|
3516
|
-
function Wi(
|
|
3555
|
+
function Wi(s, e = "kilometers") {
|
|
3517
3556
|
const t = Oi[e];
|
|
3518
3557
|
if (!t)
|
|
3519
3558
|
throw new Error(e + " units is invalid");
|
|
3520
|
-
return
|
|
3559
|
+
return s * t;
|
|
3521
3560
|
}
|
|
3522
|
-
function
|
|
3523
|
-
return
|
|
3561
|
+
function ye(s) {
|
|
3562
|
+
return s % 360 * Math.PI / 180;
|
|
3524
3563
|
}
|
|
3525
|
-
function rt(
|
|
3526
|
-
return !isNaN(
|
|
3564
|
+
function rt(s) {
|
|
3565
|
+
return !isNaN(s) && s !== null && !Array.isArray(s);
|
|
3527
3566
|
}
|
|
3528
|
-
function at(
|
|
3529
|
-
if (!
|
|
3567
|
+
function at(s) {
|
|
3568
|
+
if (!s)
|
|
3530
3569
|
throw new Error("coord is required");
|
|
3531
|
-
if (!Array.isArray(
|
|
3532
|
-
if (
|
|
3533
|
-
return [...
|
|
3534
|
-
if (
|
|
3535
|
-
return [...
|
|
3536
|
-
}
|
|
3537
|
-
if (Array.isArray(
|
|
3538
|
-
return [...
|
|
3570
|
+
if (!Array.isArray(s)) {
|
|
3571
|
+
if (s.type === "Feature" && s.geometry !== null && s.geometry.type === "Point")
|
|
3572
|
+
return [...s.geometry.coordinates];
|
|
3573
|
+
if (s.type === "Point")
|
|
3574
|
+
return [...s.coordinates];
|
|
3575
|
+
}
|
|
3576
|
+
if (Array.isArray(s) && s.length >= 2 && !Array.isArray(s[0]) && !Array.isArray(s[1]))
|
|
3577
|
+
return [...s];
|
|
3539
3578
|
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
3540
3579
|
}
|
|
3541
|
-
function ji(
|
|
3542
|
-
var i = at(
|
|
3580
|
+
function ji(s, e, t = {}) {
|
|
3581
|
+
var i = at(s), n = at(e), o = ye(n[1] - i[1]), r = ye(n[0] - i[0]), a = ye(i[1]), l = ye(n[1]), d = Math.pow(Math.sin(o / 2), 2) + Math.pow(Math.sin(r / 2), 2) * Math.cos(a) * Math.cos(l);
|
|
3543
3582
|
return Wi(
|
|
3544
3583
|
2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
|
|
3545
3584
|
t.units
|
|
3546
3585
|
);
|
|
3547
3586
|
}
|
|
3548
|
-
function
|
|
3549
|
-
if (
|
|
3550
|
-
for (var i, n,
|
|
3551
|
-
d =
|
|
3587
|
+
function Lt(s, e, t) {
|
|
3588
|
+
if (s !== null)
|
|
3589
|
+
for (var i, n, o, r, a, l, d, c = 0, h = 0, u, g = s.type, p = g === "FeatureCollection", y = g === "Feature", P = p ? s.features.length : 1, f = 0; f < P; f++) {
|
|
3590
|
+
d = p ? s.features[f].geometry : y ? s.geometry : s, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
|
|
3552
3591
|
for (var C = 0; C < a; C++) {
|
|
3553
3592
|
var m = 0, v = 0;
|
|
3554
3593
|
if (r = u ? d.geometries[C] : d, r !== null) {
|
|
@@ -3561,7 +3600,7 @@ function kt(o, e, t) {
|
|
|
3561
3600
|
if (e(
|
|
3562
3601
|
l,
|
|
3563
3602
|
h,
|
|
3564
|
-
|
|
3603
|
+
f,
|
|
3565
3604
|
m,
|
|
3566
3605
|
v
|
|
3567
3606
|
) === !1)
|
|
@@ -3574,7 +3613,7 @@ function kt(o, e, t) {
|
|
|
3574
3613
|
if (e(
|
|
3575
3614
|
l[i],
|
|
3576
3615
|
h,
|
|
3577
|
-
|
|
3616
|
+
f,
|
|
3578
3617
|
m,
|
|
3579
3618
|
v
|
|
3580
3619
|
) === !1)
|
|
@@ -3590,7 +3629,7 @@ function kt(o, e, t) {
|
|
|
3590
3629
|
if (e(
|
|
3591
3630
|
l[i][n],
|
|
3592
3631
|
h,
|
|
3593
|
-
|
|
3632
|
+
f,
|
|
3594
3633
|
m,
|
|
3595
3634
|
v
|
|
3596
3635
|
) === !1)
|
|
@@ -3604,11 +3643,11 @@ function kt(o, e, t) {
|
|
|
3604
3643
|
case "MultiPolygon":
|
|
3605
3644
|
for (i = 0; i < l.length; i++) {
|
|
3606
3645
|
for (v = 0, n = 0; n < l[i].length; n++) {
|
|
3607
|
-
for (
|
|
3646
|
+
for (o = 0; o < l[i][n].length - c; o++) {
|
|
3608
3647
|
if (e(
|
|
3609
|
-
l[i][n][
|
|
3648
|
+
l[i][n][o],
|
|
3610
3649
|
h,
|
|
3611
|
-
|
|
3650
|
+
f,
|
|
3612
3651
|
m,
|
|
3613
3652
|
v
|
|
3614
3653
|
) === !1)
|
|
@@ -3622,7 +3661,7 @@ function kt(o, e, t) {
|
|
|
3622
3661
|
break;
|
|
3623
3662
|
case "GeometryCollection":
|
|
3624
3663
|
for (i = 0; i < r.geometries.length; i++)
|
|
3625
|
-
if (
|
|
3664
|
+
if (Lt(r.geometries[i], e) === !1)
|
|
3626
3665
|
return !1;
|
|
3627
3666
|
break;
|
|
3628
3667
|
default:
|
|
@@ -3632,11 +3671,11 @@ function kt(o, e, t) {
|
|
|
3632
3671
|
}
|
|
3633
3672
|
}
|
|
3634
3673
|
}
|
|
3635
|
-
function Bi(
|
|
3636
|
-
var t, i, n,
|
|
3637
|
-
for (t = 0; t <
|
|
3638
|
-
for (a = g ?
|
|
3639
|
-
if (
|
|
3674
|
+
function Bi(s, e) {
|
|
3675
|
+
var t, i, n, o, r, a, l, d, c, h, u = 0, g = s.type === "FeatureCollection", p = s.type === "Feature", y = g ? s.features.length : 1;
|
|
3676
|
+
for (t = 0; t < y; t++) {
|
|
3677
|
+
for (a = g ? s.features[t].geometry : p ? s.geometry : s, d = g ? s.features[t].properties : p ? s.properties : {}, c = g ? s.features[t].bbox : p ? s.bbox : void 0, h = g ? s.features[t].id : p ? s.id : void 0, l = a ? a.type === "GeometryCollection" : !1, r = l ? a.geometries.length : 1, n = 0; n < r; n++) {
|
|
3678
|
+
if (o = l ? a.geometries[n] : a, o === null) {
|
|
3640
3679
|
if (e(
|
|
3641
3680
|
null,
|
|
3642
3681
|
u,
|
|
@@ -3647,7 +3686,7 @@ function Bi(o, e) {
|
|
|
3647
3686
|
return !1;
|
|
3648
3687
|
continue;
|
|
3649
3688
|
}
|
|
3650
|
-
switch (
|
|
3689
|
+
switch (o.type) {
|
|
3651
3690
|
case "Point":
|
|
3652
3691
|
case "LineString":
|
|
3653
3692
|
case "MultiPoint":
|
|
@@ -3655,7 +3694,7 @@ function Bi(o, e) {
|
|
|
3655
3694
|
case "MultiLineString":
|
|
3656
3695
|
case "MultiPolygon": {
|
|
3657
3696
|
if (e(
|
|
3658
|
-
|
|
3697
|
+
o,
|
|
3659
3698
|
u,
|
|
3660
3699
|
d,
|
|
3661
3700
|
c,
|
|
@@ -3665,9 +3704,9 @@ function Bi(o, e) {
|
|
|
3665
3704
|
break;
|
|
3666
3705
|
}
|
|
3667
3706
|
case "GeometryCollection": {
|
|
3668
|
-
for (i = 0; i <
|
|
3707
|
+
for (i = 0; i < o.geometries.length; i++)
|
|
3669
3708
|
if (e(
|
|
3670
|
-
|
|
3709
|
+
o.geometries[i],
|
|
3671
3710
|
u,
|
|
3672
3711
|
d,
|
|
3673
3712
|
c,
|
|
@@ -3683,15 +3722,15 @@ function Bi(o, e) {
|
|
|
3683
3722
|
u++;
|
|
3684
3723
|
}
|
|
3685
3724
|
}
|
|
3686
|
-
function Ni(
|
|
3725
|
+
function Ni(s, e, t) {
|
|
3687
3726
|
var i = t;
|
|
3688
3727
|
return Bi(
|
|
3689
|
-
|
|
3690
|
-
function(n,
|
|
3691
|
-
|
|
3728
|
+
s,
|
|
3729
|
+
function(n, o, r, a, l) {
|
|
3730
|
+
o === 0 && t === void 0 ? i = n : i = e(
|
|
3692
3731
|
i,
|
|
3693
3732
|
n,
|
|
3694
|
-
|
|
3733
|
+
o,
|
|
3695
3734
|
r,
|
|
3696
3735
|
a,
|
|
3697
3736
|
l
|
|
@@ -3699,21 +3738,21 @@ function Ni(o, e, t) {
|
|
|
3699
3738
|
}
|
|
3700
3739
|
), i;
|
|
3701
3740
|
}
|
|
3702
|
-
function
|
|
3741
|
+
function Ai(s) {
|
|
3703
3742
|
return Ni(
|
|
3704
|
-
|
|
3705
|
-
(e, t) => e +
|
|
3743
|
+
s,
|
|
3744
|
+
(e, t) => e + Gi(t),
|
|
3706
3745
|
0
|
|
3707
3746
|
);
|
|
3708
3747
|
}
|
|
3709
|
-
function
|
|
3748
|
+
function Gi(s) {
|
|
3710
3749
|
let e = 0, t;
|
|
3711
|
-
switch (
|
|
3750
|
+
switch (s.type) {
|
|
3712
3751
|
case "Polygon":
|
|
3713
|
-
return lt(
|
|
3752
|
+
return lt(s.coordinates);
|
|
3714
3753
|
case "MultiPolygon":
|
|
3715
|
-
for (t = 0; t <
|
|
3716
|
-
e += lt(
|
|
3754
|
+
for (t = 0; t < s.coordinates.length; t++)
|
|
3755
|
+
e += lt(s.coordinates[t]);
|
|
3717
3756
|
return e;
|
|
3718
3757
|
case "Point":
|
|
3719
3758
|
case "MultiPoint":
|
|
@@ -3723,62 +3762,63 @@ function Ai(o) {
|
|
|
3723
3762
|
}
|
|
3724
3763
|
return 0;
|
|
3725
3764
|
}
|
|
3726
|
-
function lt(
|
|
3765
|
+
function lt(s) {
|
|
3727
3766
|
let e = 0;
|
|
3728
|
-
if (
|
|
3729
|
-
e += Math.abs(dt(
|
|
3730
|
-
for (let t = 1; t <
|
|
3731
|
-
e -= Math.abs(dt(
|
|
3767
|
+
if (s && s.length > 0) {
|
|
3768
|
+
e += Math.abs(dt(s[0]));
|
|
3769
|
+
for (let t = 1; t < s.length; t++)
|
|
3770
|
+
e -= Math.abs(dt(s[t]));
|
|
3732
3771
|
}
|
|
3733
3772
|
return e;
|
|
3734
3773
|
}
|
|
3735
|
-
var Vi =
|
|
3736
|
-
function dt(
|
|
3737
|
-
const e =
|
|
3774
|
+
var Vi = L * L / 2, Fe = Math.PI / 180;
|
|
3775
|
+
function dt(s) {
|
|
3776
|
+
const e = s.length - 1;
|
|
3738
3777
|
if (e <= 2) return 0;
|
|
3739
3778
|
let t = 0, i = 0;
|
|
3740
3779
|
for (; i < e; ) {
|
|
3741
|
-
const n =
|
|
3780
|
+
const n = s[i], o = s[i + 1 === e ? 0 : i + 1], r = s[i + 2 >= e ? (i + 2) % e : i + 2], a = n[0] * Fe, l = o[1] * Fe, d = r[0] * Fe;
|
|
3742
3781
|
t += (d - a) * Math.sin(l), i++;
|
|
3743
3782
|
}
|
|
3744
3783
|
return t * Vi;
|
|
3745
3784
|
}
|
|
3746
|
-
function
|
|
3785
|
+
function Ti(s, e = {}) {
|
|
3747
3786
|
let t = 0, i = 0, n = 0;
|
|
3748
|
-
return
|
|
3749
|
-
|
|
3750
|
-
function(
|
|
3751
|
-
t +=
|
|
3787
|
+
return Lt(
|
|
3788
|
+
s,
|
|
3789
|
+
function(o) {
|
|
3790
|
+
t += o[0], i += o[1], n++;
|
|
3752
3791
|
}
|
|
3753
|
-
),
|
|
3792
|
+
), ki([t / n, i / n], e.properties);
|
|
3754
3793
|
}
|
|
3755
|
-
class
|
|
3794
|
+
class zi extends _i {
|
|
3756
3795
|
/**
|
|
3757
3796
|
* Constructor
|
|
3758
3797
|
* @param options Plugin control options
|
|
3759
3798
|
*/
|
|
3760
3799
|
constructor(t) {
|
|
3761
|
-
let i =
|
|
3800
|
+
let i = Fi;
|
|
3762
3801
|
t && (i = Object.assign(i, t));
|
|
3763
3802
|
super({
|
|
3764
3803
|
modes: i.modes,
|
|
3765
3804
|
open: i.open,
|
|
3766
3805
|
modeOptions: i.modeOptions
|
|
3767
3806
|
});
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3807
|
+
k(this, "lineLayerLabelSpec");
|
|
3808
|
+
k(this, "lineLayerNodeSpec");
|
|
3809
|
+
k(this, "polygonLayerSpec");
|
|
3810
|
+
k(this, "computeElevation");
|
|
3771
3811
|
/**
|
|
3772
3812
|
* Calculate area / distance and update a feature properties
|
|
3773
3813
|
* @param feature GeoJSON feature
|
|
3774
3814
|
* @returns updated GeoJSON feature
|
|
3775
3815
|
*/
|
|
3776
|
-
|
|
3816
|
+
k(this, "updateFeatureProperties", (t) => {
|
|
3777
3817
|
if (!this.map || !this.map.loaded()) return t;
|
|
3778
3818
|
const i = t.geometry.type;
|
|
3779
3819
|
return i === "LineString" ? t = this.calcDistance(t) : i === "Polygon" && (t = this.calcArea(t)), t;
|
|
3780
3820
|
});
|
|
3781
|
-
this.lineLayerLabelSpec = i.lineLayerLabelSpec, this.lineLayerNodeSpec = i.lineLayerNodeSpec, this.polygonLayerSpec = i.polygonLayerSpec;
|
|
3821
|
+
this.lineLayerLabelSpec = i.lineLayerLabelSpec, this.lineLayerNodeSpec = i.lineLayerNodeSpec, this.polygonLayerSpec = i.polygonLayerSpec, this.computeElevation = i.computeElevation ?? !1;
|
|
3782
3822
|
}
|
|
3783
3823
|
/**
|
|
3784
3824
|
* add the plugin control to maplibre
|
|
@@ -3786,7 +3826,7 @@ class Ki extends Di {
|
|
|
3786
3826
|
* @returns HTML Element
|
|
3787
3827
|
*/
|
|
3788
3828
|
onAdd(t) {
|
|
3789
|
-
return this.controlContainer = super.onAdd(t),
|
|
3829
|
+
return this.controlContainer = super.onAdd(t), this.controlContainer;
|
|
3790
3830
|
}
|
|
3791
3831
|
/**
|
|
3792
3832
|
* Remove the plugin control from maplibre
|
|
@@ -3795,18 +3835,48 @@ class Ki extends Di {
|
|
|
3795
3835
|
onRemove() {
|
|
3796
3836
|
this.unregisterMesureControl(), super.onRemove();
|
|
3797
3837
|
}
|
|
3838
|
+
/**
|
|
3839
|
+
* Activate Terra Draw to start drawing
|
|
3840
|
+
*/
|
|
3841
|
+
activate() {
|
|
3842
|
+
super.activate(), this.registerMesureControl();
|
|
3843
|
+
}
|
|
3844
|
+
/**
|
|
3845
|
+
* Recalculate area and distance in TerraDraw snapshot
|
|
3846
|
+
*
|
|
3847
|
+
* if you use `addFeatures` to restore GeoJSON features to TerraDraw, this recalc method needs to be called to re-measure again.
|
|
3848
|
+
*
|
|
3849
|
+
* For example, the below code is an example usage.
|
|
3850
|
+
* ```
|
|
3851
|
+
* drawInstance?.addFeatures(initData);
|
|
3852
|
+
* map?.once('idle', ()=>{
|
|
3853
|
+
* drawControl.recalc()
|
|
3854
|
+
* })
|
|
3855
|
+
* ```
|
|
3856
|
+
*/
|
|
3857
|
+
recalc() {
|
|
3858
|
+
const t = this.getTerraDrawInstance();
|
|
3859
|
+
if (t) {
|
|
3860
|
+
this.registerMesureControl();
|
|
3861
|
+
const i = t.getSnapshot();
|
|
3862
|
+
for (const n of i) {
|
|
3863
|
+
const o = n.id, r = n.geometry.type, a = n.properties.mode;
|
|
3864
|
+
a === "linestring" && r === "LineString" ? this.measureLine(o) : !["point", "linestring", "select", "render"].includes(a) && r === "Polygon" && this.measurePolygon(o);
|
|
3865
|
+
}
|
|
3866
|
+
}
|
|
3867
|
+
}
|
|
3798
3868
|
/**
|
|
3799
3869
|
* Register measure control related maplibre sources and layers
|
|
3800
3870
|
*/
|
|
3801
3871
|
registerMesureControl() {
|
|
3802
|
-
var n,
|
|
3872
|
+
var n, o;
|
|
3803
3873
|
if (!this.map) return;
|
|
3804
3874
|
const t = (n = this.options.modes) == null ? void 0 : n.filter((r) => ["linestring"].includes(r));
|
|
3805
3875
|
t && t.length > 0 && (this.map.getSource(this.lineLayerLabelSpec.source) || this.map.addSource(this.lineLayerLabelSpec.source, {
|
|
3806
3876
|
type: "geojson",
|
|
3807
3877
|
data: { type: "FeatureCollection", features: [] }
|
|
3808
3878
|
}), this.map.getLayer(this.lineLayerNodeSpec.id) || this.map.addLayer(this.lineLayerNodeSpec), this.map.getLayer(this.lineLayerLabelSpec.id) || this.map.addLayer(this.lineLayerLabelSpec));
|
|
3809
|
-
const i = (
|
|
3879
|
+
const i = (o = this.options.modes) == null ? void 0 : o.filter(
|
|
3810
3880
|
(r) => [
|
|
3811
3881
|
"polygon",
|
|
3812
3882
|
"rectangle",
|
|
@@ -3822,20 +3892,25 @@ class Ki extends Di {
|
|
|
3822
3892
|
data: { type: "FeatureCollection", features: [] }
|
|
3823
3893
|
}), this.map.getLayer(this.polygonLayerSpec.id) || this.map.addLayer(this.polygonLayerSpec)), t && t.length > 0 || i && i.length > 0) {
|
|
3824
3894
|
const r = this.getTerraDrawInstance();
|
|
3825
|
-
r && (r.on("change", (
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3895
|
+
r && (r.on("change", this.handleTerradrawFeatureChanged.bind(this)), this.on("feature-deleted", this.onFeatureDeleted.bind(this)));
|
|
3896
|
+
}
|
|
3897
|
+
}
|
|
3898
|
+
/**
|
|
3899
|
+
* Handle change event of TerraDraw
|
|
3900
|
+
* @param ids Feature IDs
|
|
3901
|
+
*/
|
|
3902
|
+
handleTerradrawFeatureChanged(t) {
|
|
3903
|
+
if (!this.map) return;
|
|
3904
|
+
const i = this.getTerraDrawInstance();
|
|
3905
|
+
if (!i) return;
|
|
3906
|
+
const n = i.getSnapshot();
|
|
3907
|
+
for (const o of t) {
|
|
3908
|
+
const r = n.find((a) => a.id === o);
|
|
3909
|
+
if (r) {
|
|
3910
|
+
const a = r.geometry.type, l = r.properties.mode;
|
|
3911
|
+
l === "linestring" && a === "LineString" ? this.measureLine(o) : !["point", "linestring", "select", "render"].includes(l) && a === "Polygon" && this.measurePolygon(o);
|
|
3912
|
+
} else
|
|
3913
|
+
this.clearMeasureFeatures(o, this.lineLayerNodeSpec.source), this.clearMeasureFeatures(o, this.lineLayerLabelSpec.source), this.clearMeasureFeatures(o, this.polygonLayerSpec.source);
|
|
3839
3914
|
}
|
|
3840
3915
|
}
|
|
3841
3916
|
/**
|
|
@@ -3851,7 +3926,7 @@ class Ki extends Di {
|
|
|
3851
3926
|
* @returns void
|
|
3852
3927
|
*/
|
|
3853
3928
|
clearMeasureFeatures(t, i) {
|
|
3854
|
-
var
|
|
3929
|
+
var o;
|
|
3855
3930
|
if (!this.map) return;
|
|
3856
3931
|
const n = this.map.getStyle().sources[i];
|
|
3857
3932
|
n && typeof n.data != "string" && n.data.type === "FeatureCollection" && (n.data.features = n.data.features.filter(
|
|
@@ -3859,7 +3934,7 @@ class Ki extends Di {
|
|
|
3859
3934
|
var a;
|
|
3860
3935
|
return ((a = r.properties) == null ? void 0 : a.originalId) !== t;
|
|
3861
3936
|
}
|
|
3862
|
-
), (
|
|
3937
|
+
), (o = this.map.getSource(i)) == null || o.setData(n.data));
|
|
3863
3938
|
}
|
|
3864
3939
|
/**
|
|
3865
3940
|
* Calculate area from polygon feature
|
|
@@ -3868,9 +3943,9 @@ class Ki extends Di {
|
|
|
3868
3943
|
*/
|
|
3869
3944
|
calcArea(t) {
|
|
3870
3945
|
if (t.geometry.type !== "Polygon") return t;
|
|
3871
|
-
const i =
|
|
3872
|
-
let n = i,
|
|
3873
|
-
return i > 1e4 ? (n = i / 1e4,
|
|
3946
|
+
const i = Ai(t.geometry);
|
|
3947
|
+
let n = i, o = "m2";
|
|
3948
|
+
return i > 1e4 ? (n = i / 1e4, o = "ha") : i > 1e3 && (n = i / 1e3, o = "km2"), n = parseFloat(n.toFixed(2)), t.properties.area = n, t.properties.unit = o, t;
|
|
3874
3949
|
}
|
|
3875
3950
|
/**
|
|
3876
3951
|
* Caclulate distance for each segment on a given feature
|
|
@@ -3878,17 +3953,24 @@ class Ki extends Di {
|
|
|
3878
3953
|
* @returns The returning feature will contain `segments`, `distance`, `unit` properties. `segments` will have multiple point features.
|
|
3879
3954
|
*/
|
|
3880
3955
|
calcDistance(t) {
|
|
3956
|
+
var r, a;
|
|
3881
3957
|
if (t.geometry.type !== "LineString") return t;
|
|
3882
3958
|
const i = t.geometry.coordinates;
|
|
3883
3959
|
let n = 0;
|
|
3884
|
-
const
|
|
3885
|
-
for (let
|
|
3886
|
-
const
|
|
3887
|
-
n +=
|
|
3888
|
-
const
|
|
3889
|
-
|
|
3960
|
+
const o = [];
|
|
3961
|
+
for (let l = 0; l < i.length - 1; l++) {
|
|
3962
|
+
const d = i[l], c = i[l + 1], h = ji(d, c, { units: "kilometers" });
|
|
3963
|
+
n += h;
|
|
3964
|
+
const u = JSON.parse(JSON.stringify(t));
|
|
3965
|
+
if (u.id = `${u.id}-${l}`, u.geometry.coordinates = [d, c], u.properties.originalId = t.id, u.properties.distance = parseFloat(h.toFixed(2)), u.properties.total = parseFloat(n.toFixed(2)), u.properties.unit = "km", this.computeElevation === !0) {
|
|
3966
|
+
const g = (r = this.map) == null ? void 0 : r.queryTerrainElevation(d);
|
|
3967
|
+
g && (u.properties.elevation_start = g);
|
|
3968
|
+
const p = (a = this.map) == null ? void 0 : a.queryTerrainElevation(c);
|
|
3969
|
+
p && (u.properties.elevation_end = p);
|
|
3970
|
+
}
|
|
3971
|
+
o.push(u);
|
|
3890
3972
|
}
|
|
3891
|
-
return t.properties.distance =
|
|
3973
|
+
return t.properties.distance = o[o.length - 1].properties.total, t.properties.unit = o[o.length - 1].properties.unit, t.properties.segments = JSON.parse(JSON.stringify(o)), t;
|
|
3892
3974
|
}
|
|
3893
3975
|
/**
|
|
3894
3976
|
* measure polygon area for given feature ID
|
|
@@ -3900,8 +3982,8 @@ class Ki extends Di {
|
|
|
3900
3982
|
const i = this.getTerraDrawInstance();
|
|
3901
3983
|
if (!i) return;
|
|
3902
3984
|
const n = i.getSnapshot();
|
|
3903
|
-
let
|
|
3904
|
-
if (
|
|
3985
|
+
let o = n == null ? void 0 : n.find((a) => a.id === t && a.geometry.type === "Polygon");
|
|
3986
|
+
if (o) {
|
|
3905
3987
|
const a = this.map.getStyle().sources[this.polygonLayerSpec.source];
|
|
3906
3988
|
if (a) {
|
|
3907
3989
|
typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
|
|
@@ -3910,10 +3992,10 @@ class Ki extends Di {
|
|
|
3910
3992
|
return ((c = d.properties) == null ? void 0 : c.originalId) !== t;
|
|
3911
3993
|
}
|
|
3912
3994
|
));
|
|
3913
|
-
const l = JSON.parse(JSON.stringify(
|
|
3914
|
-
l.id = l.id + "-area-label", l.geometry =
|
|
3995
|
+
const l = JSON.parse(JSON.stringify(o));
|
|
3996
|
+
l.id = l.id + "-area-label", l.geometry = Ti(o.geometry).geometry, l.properties.originalId = o.id, o = this.calcArea(o), l.properties.area = o.properties.area, l.properties.unit = o.properties.unit, typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(l), (r = this.map.getSource(this.polygonLayerSpec.source)) == null || r.setData(
|
|
3915
3997
|
a.data
|
|
3916
|
-
), this.map.moveLayer(this.polygonLayerSpec.id);
|
|
3998
|
+
), this.map.moveLayer(this.polygonLayerSpec.id), this.map.getLayer(this.lineLayerLabelSpec.id) && this.map.moveLayer(this.lineLayerLabelSpec.id), this.map.getLayer(this.lineLayerNodeSpec.id) && this.map.moveLayer(this.lineLayerNodeSpec.id);
|
|
3917
3999
|
}
|
|
3918
4000
|
}
|
|
3919
4001
|
}
|
|
@@ -3927,8 +4009,8 @@ class Ki extends Di {
|
|
|
3927
4009
|
const i = this.getTerraDrawInstance();
|
|
3928
4010
|
if (!i) return;
|
|
3929
4011
|
const n = i.getSnapshot();
|
|
3930
|
-
let
|
|
3931
|
-
if (
|
|
4012
|
+
let o = n == null ? void 0 : n.find((a) => a.id === t && a.geometry.type === "LineString");
|
|
4013
|
+
if (o) {
|
|
3932
4014
|
const a = this.map.getStyle().sources[this.lineLayerLabelSpec.source];
|
|
3933
4015
|
if (a) {
|
|
3934
4016
|
typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
|
|
@@ -3936,28 +4018,28 @@ class Ki extends Di {
|
|
|
3936
4018
|
var c;
|
|
3937
4019
|
return ((c = d.properties) == null ? void 0 : c.originalId) !== t;
|
|
3938
4020
|
}
|
|
3939
|
-
)),
|
|
3940
|
-
const l =
|
|
4021
|
+
)), o = this.calcDistance(o);
|
|
4022
|
+
const l = o.properties.segments;
|
|
3941
4023
|
for (let d = 0; d < l.length; d++) {
|
|
3942
4024
|
const c = l[d];
|
|
3943
4025
|
typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(c);
|
|
3944
4026
|
const h = c.geometry.coordinates, u = h[0], g = h[1];
|
|
3945
4027
|
if (d === 0) {
|
|
3946
|
-
const
|
|
3947
|
-
|
|
4028
|
+
const y = JSON.parse(JSON.stringify(c));
|
|
4029
|
+
y.id = `${c.id}-node-${d}`, y.geometry = {
|
|
3948
4030
|
type: "Point",
|
|
3949
4031
|
coordinates: u
|
|
3950
|
-
},
|
|
4032
|
+
}, y.properties.distance = 0, y.properties.total = 0, c.properties.elevation_start && (y.properties.elevation = c.properties.elevation_start), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(y);
|
|
3951
4033
|
}
|
|
3952
|
-
const
|
|
3953
|
-
|
|
4034
|
+
const p = JSON.parse(JSON.stringify(c));
|
|
4035
|
+
p.id = `${c.id}-node-${d + 1}`, p.geometry = {
|
|
3954
4036
|
type: "Point",
|
|
3955
4037
|
coordinates: g
|
|
3956
|
-
}, typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(
|
|
4038
|
+
}, c.properties.elevation_end && (p.properties.elevation = c.properties.elevation_end), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(p);
|
|
3957
4039
|
}
|
|
3958
4040
|
(r = this.map.getSource(this.lineLayerLabelSpec.source)) == null || r.setData(
|
|
3959
4041
|
a.data
|
|
3960
|
-
), this.map.moveLayer(this.lineLayerLabelSpec.id), this.map.moveLayer(this.lineLayerNodeSpec.id);
|
|
4042
|
+
), this.map.getLayer(this.polygonLayerSpec.id) && this.map.moveLayer(this.polygonLayerSpec.id), this.map.moveLayer(this.lineLayerLabelSpec.id), this.map.moveLayer(this.lineLayerNodeSpec.id);
|
|
3961
4043
|
}
|
|
3962
4044
|
}
|
|
3963
4045
|
}
|
|
@@ -3969,8 +4051,8 @@ class Ki extends Di {
|
|
|
3969
4051
|
if (!this.map) return;
|
|
3970
4052
|
const t = this.getTerraDrawInstance();
|
|
3971
4053
|
if (t) {
|
|
3972
|
-
const
|
|
3973
|
-
for (const r of
|
|
4054
|
+
const o = [this.lineLayerLabelSpec.source, this.polygonLayerSpec.source];
|
|
4055
|
+
for (const r of o) {
|
|
3974
4056
|
const a = this.map.getStyle().sources[r];
|
|
3975
4057
|
if (a) {
|
|
3976
4058
|
const l = t.getSnapshot(), c = (l == null ? void 0 : l.filter(
|
|
@@ -4006,10 +4088,10 @@ class Ki extends Di {
|
|
|
4006
4088
|
export {
|
|
4007
4089
|
Xi as AvailableMeasureModes,
|
|
4008
4090
|
Ri as AvailableModes,
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4091
|
+
zi as MaplibreMeasureControl,
|
|
4092
|
+
_i as MaplibreTerradrawControl,
|
|
4093
|
+
Ei as defaultControlOptions,
|
|
4094
|
+
Fi as defaultMeasureControlOptions,
|
|
4095
|
+
Di as getDefaultModeOptions
|
|
4014
4096
|
};
|
|
4015
4097
|
//# sourceMappingURL=maplibre-gl-terradraw.es.js.map
|