@watergis/maplibre-gl-terradraw 0.8.3 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/maplibre-gl-terradraw.es.js +852 -756
- package/dist/maplibre-gl-terradraw.es.js.map +1 -1
- package/dist/maplibre-gl-terradraw.umd.js +2 -2
- package/dist/maplibre-gl-terradraw.umd.js.map +1 -1
- package/dist/types/constants/defaultMeasureControlOptions.d.ts.map +1 -1
- package/dist/types/controls/MaplibreMeasureControl.d.ts +11 -5
- package/dist/types/controls/MaplibreMeasureControl.d.ts.map +1 -1
- package/dist/types/interfaces/AreaUnit.d.ts +2 -0
- package/dist/types/interfaces/AreaUnit.d.ts.map +1 -0
- package/dist/types/interfaces/DistanceUnit.d.ts +2 -0
- package/dist/types/interfaces/DistanceUnit.d.ts.map +1 -0
- package/dist/types/interfaces/MeasureControlOptions.d.ts +6 -0
- package/dist/types/interfaces/MeasureControlOptions.d.ts.map +1 -1
- package/dist/types/interfaces/index.d.ts +2 -0
- package/dist/types/interfaces/index.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
var kt = Object.defineProperty;
|
|
2
|
-
var Wt = (
|
|
3
|
-
var
|
|
2
|
+
var Wt = (o, e, t) => e in o ? kt(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var A = (o, e, t) => Wt(o, 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(o) {
|
|
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) && (o[i] = t[i]);
|
|
9
9
|
}
|
|
10
|
-
return
|
|
10
|
+
return o;
|
|
11
11
|
}, M.apply(this, arguments);
|
|
12
12
|
}
|
|
13
|
-
function E(
|
|
13
|
+
function E(o, e = 9) {
|
|
14
14
|
const t = Math.pow(10, e);
|
|
15
|
-
return Math.round(
|
|
15
|
+
return Math.round(o * t) / t;
|
|
16
16
|
}
|
|
17
|
-
const F = (
|
|
18
|
-
const { x: t, y: i } =
|
|
17
|
+
const F = (o, e) => {
|
|
18
|
+
const { x: t, y: i } = o, { x: n, y: s } = e, r = n - t, a = s - i;
|
|
19
19
|
return Math.sqrt(a * a + r * r);
|
|
20
20
|
};
|
|
21
21
|
class $ {
|
|
@@ -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: E(i, this._coordinatePrecision), lat: E(n, this._coordinatePrecision), containerX:
|
|
44
|
+
const { lng: i, lat: n } = t, { containerX: s, 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: s, 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) => {
|
|
@@ -68,9 +68,9 @@ class ct {
|
|
|
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 }, s = this._currentModeCallbacks.getState(), r = F(i, n);
|
|
72
72
|
let a = !1;
|
|
73
|
-
if (a =
|
|
73
|
+
if (a = s === "drawing" ? r < this._minPixelDragDistanceDrawing : s === "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
|
});
|
|
@@ -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 = [], s = [], 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, s.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", s), 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", s), 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(o) {
|
|
262
|
+
this.code_ = o.code, this.units_ = o.units, this.extent_ = o.extent !== void 0 ? o.extent : null, this.worldExtent_ = o.worldExtent !== void 0 ? o.worldExtent : null, this.axisOrientation_ = o.axisOrientation !== void 0 ? o.axisOrientation : "enu", this.global_ = o.global !== void 0 && o.global, this.canWrapX_ = !(!this.global_ || !this.extent_), this.getPointResolutionFunc_ = o.getPointResolution, this.defaultTileGrid_ = null, this.metersPerUnit_ = o.metersPerUnit;
|
|
263
263
|
}
|
|
264
264
|
canWrapX() {
|
|
265
265
|
return this.canWrapX_;
|
|
@@ -285,23 +285,23 @@ var ht = class {
|
|
|
285
285
|
isGlobal() {
|
|
286
286
|
return this.global_;
|
|
287
287
|
}
|
|
288
|
-
setGlobal(
|
|
289
|
-
this.global_ =
|
|
288
|
+
setGlobal(o) {
|
|
289
|
+
this.global_ = o, this.canWrapX_ = !(!o || !this.extent_);
|
|
290
290
|
}
|
|
291
291
|
getDefaultTileGrid() {
|
|
292
292
|
return this.defaultTileGrid_;
|
|
293
293
|
}
|
|
294
|
-
setDefaultTileGrid(
|
|
295
|
-
this.defaultTileGrid_ =
|
|
294
|
+
setDefaultTileGrid(o) {
|
|
295
|
+
this.defaultTileGrid_ = o;
|
|
296
296
|
}
|
|
297
|
-
setExtent(
|
|
298
|
-
this.extent_ =
|
|
297
|
+
setExtent(o) {
|
|
298
|
+
this.extent_ = o, this.canWrapX_ = !(!this.global_ || !o);
|
|
299
299
|
}
|
|
300
|
-
setWorldExtent(
|
|
301
|
-
this.worldExtent_ =
|
|
300
|
+
setWorldExtent(o) {
|
|
301
|
+
this.worldExtent_ = o;
|
|
302
302
|
}
|
|
303
|
-
setGetPointResolution(
|
|
304
|
-
this.getPointResolutionFunc_ =
|
|
303
|
+
setGetPointResolution(o) {
|
|
304
|
+
this.getPointResolutionFunc_ = o;
|
|
305
305
|
}
|
|
306
306
|
getPointResolutionFunc() {
|
|
307
307
|
return this.getPointResolutionFunc_;
|
|
@@ -315,73 +315,73 @@ class J extends ht {
|
|
|
315
315
|
} });
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
|
-
const
|
|
319
|
-
class
|
|
318
|
+
const Ue = [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")], Te = [-180, -90, 180, 90], Vt = 6378137 * Math.PI / 180;
|
|
319
|
+
class T extends ht {
|
|
320
320
|
constructor(e, t) {
|
|
321
|
-
super({ code: e, units: "degrees", extent:
|
|
321
|
+
super({ code: e, units: "degrees", extent: Te, axisOrientation: t, global: !0, metersPerUnit: Vt, worldExtent: Te });
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
|
-
const Re = [new
|
|
324
|
+
const Re = [new T("CRS:84"), new T("EPSG:4326", "neu"), new T("urn:ogc:def:crs:OGC:1.3:CRS84"), new T("urn:ogc:def:crs:OGC:2:84"), new T("http://www.opengis.net/def/crs/OGC/1.3/CRS84"), new T("http://www.opengis.net/gml/srs/epsg.xml#4326", "neu"), new T("http://www.opengis.net/def/crs/EPSG/0/4326", "neu")];
|
|
325
325
|
let Me = {};
|
|
326
|
-
function
|
|
327
|
-
const i =
|
|
326
|
+
function ye(o, e, t) {
|
|
327
|
+
const i = o.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(o, e) {
|
|
331
|
+
if (e !== void 0) for (let t = 0, i = o.length; t < i; ++t) e[t] = o[t];
|
|
332
|
+
else e = o.slice();
|
|
333
333
|
return e;
|
|
334
334
|
}
|
|
335
|
-
function
|
|
336
|
-
|
|
335
|
+
function Ut(o) {
|
|
336
|
+
o.getCode(), ye(o, o, ut);
|
|
337
337
|
}
|
|
338
|
-
function Xe(
|
|
338
|
+
function Xe(o) {
|
|
339
339
|
(function(e) {
|
|
340
|
-
e.forEach(
|
|
341
|
-
})(
|
|
342
|
-
|
|
343
|
-
e !== t &&
|
|
340
|
+
e.forEach(Ut);
|
|
341
|
+
})(o), o.forEach(function(e) {
|
|
342
|
+
o.forEach(function(t) {
|
|
343
|
+
e !== t && ye(e, t, ut);
|
|
344
344
|
});
|
|
345
345
|
});
|
|
346
346
|
}
|
|
347
347
|
var ze, Ke, Ye, b;
|
|
348
|
-
Xe(
|
|
349
|
-
const i =
|
|
350
|
-
t = t > 1 ? t : 2, e === void 0 && (e = t > 2 ?
|
|
348
|
+
Xe(Ue), Xe(Re), ze = Ue, Ke = function(o, e, t) {
|
|
349
|
+
const i = o.length;
|
|
350
|
+
t = t > 1 ? t : 2, e === void 0 && (e = t > 2 ? o.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 * o[n] / 180;
|
|
353
|
+
let s = re * Math.log(Math.tan(Math.PI * (+o[n + 1] + 90) / 360));
|
|
354
|
+
s > ce ? s = ce : s < -ce && (s = -ce), e[n + 1] = s;
|
|
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(o, e, t) {
|
|
358
|
+
const i = o.length;
|
|
359
|
+
t = t > 1 ? t : 2, e === void 0 && (e = t > 2 ? o.slice() : new Array(i));
|
|
360
|
+
for (let n = 0; n < i; n += t) e[n] = 180 * o[n] / Q, e[n + 1] = 360 * Math.atan(Math.exp(o[n + 1] / re)) / Math.PI - 90;
|
|
361
361
|
return e;
|
|
362
|
-
}, Re.forEach(function(
|
|
362
|
+
}, Re.forEach(function(o) {
|
|
363
363
|
ze.forEach(function(e) {
|
|
364
|
-
|
|
364
|
+
ye(o, e, Ke), ye(e, o, Ye);
|
|
365
365
|
});
|
|
366
366
|
});
|
|
367
|
-
(function(
|
|
368
|
-
|
|
367
|
+
(function(o) {
|
|
368
|
+
o.Commit = "commit", o.Provisional = "provisional", o.Finish = "finish";
|
|
369
369
|
})(b || (b = {}));
|
|
370
|
-
const De = "selected",
|
|
371
|
-
function we(
|
|
372
|
-
return !!(
|
|
370
|
+
const De = "selected", oe = "midPoint", ae = "closingPoint", Oe = "snappingPoint";
|
|
371
|
+
function we(o) {
|
|
372
|
+
return !!(o && typeof o == "object" && o !== null && !Array.isArray(o));
|
|
373
373
|
}
|
|
374
|
-
function He(
|
|
374
|
+
function He(o) {
|
|
375
375
|
return !!function(e) {
|
|
376
376
|
return typeof e == "number" && !isNaN(new Date(e).valueOf());
|
|
377
|
-
}(
|
|
377
|
+
}(o);
|
|
378
378
|
}
|
|
379
|
-
const
|
|
379
|
+
const Tt = "Feature mode property does not match the mode being added to";
|
|
380
380
|
var K;
|
|
381
|
-
(function(
|
|
382
|
-
|
|
381
|
+
(function(o) {
|
|
382
|
+
o.Drawing = "drawing", o.Select = "select", o.Static = "static", o.Render = "render";
|
|
383
383
|
})(K || (K = {}));
|
|
384
|
-
class
|
|
384
|
+
class B {
|
|
385
385
|
get state() {
|
|
386
386
|
return this._state;
|
|
387
387
|
}
|
|
@@ -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 s;
|
|
426
|
+
if (we(i)) if (i.id == null) s = "Feature has no id";
|
|
427
|
+
else if (typeof i.id != "string" && typeof i.id != "number") s = "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 s = "Feature coordinates is not an array";
|
|
431
|
+
else s = "Feature is not Point, LineString or Polygon";
|
|
432
|
+
else s = "Feature has no properties";
|
|
433
|
+
else s = "Feature has no geometry";
|
|
434
|
+
else s = "Feature must match the id strategy (default is UUID4)";
|
|
435
|
+
else s = "Feature is not object";
|
|
436
|
+
return s ? { valid: !1, reason: s } : { 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: Tt } : t(e) : { valid: !1, reason: i.reason };
|
|
447
447
|
}
|
|
448
448
|
onFinish(e, t) {
|
|
449
449
|
}
|
|
@@ -475,85 +475,85 @@ class N {
|
|
|
475
475
|
return e === void 0 ? t : typeof e == "function" ? e(i) : e;
|
|
476
476
|
}
|
|
477
477
|
}
|
|
478
|
-
class Rt extends
|
|
478
|
+
class Rt extends B {
|
|
479
479
|
constructor(...e) {
|
|
480
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(o, e) {
|
|
484
|
+
const t = (d) => d * Math.PI / 180, i = t(o[1]), n = t(o[0]), s = t(e[1]), r = s - i, a = t(e[0]) - n, l = Math.sin(r / 2) * Math.sin(r / 2) + Math.cos(i) * Math.cos(s) * Math.sin(a / 2) * Math.sin(a / 2);
|
|
485
485
|
return 2 * Math.atan2(Math.sqrt(l), Math.sqrt(1 - l)) * 6371e3 / 1e3;
|
|
486
486
|
}
|
|
487
|
-
const
|
|
488
|
-
function D(
|
|
489
|
-
return
|
|
487
|
+
const _e = 63710088e-1;
|
|
488
|
+
function D(o) {
|
|
489
|
+
return o % 360 * Math.PI / 180;
|
|
490
490
|
}
|
|
491
|
-
function
|
|
492
|
-
return
|
|
491
|
+
function pt(o) {
|
|
492
|
+
return o / (_e / 1e3);
|
|
493
493
|
}
|
|
494
|
-
function
|
|
495
|
-
return
|
|
494
|
+
function U(o) {
|
|
495
|
+
return o % (2 * Math.PI) * 180 / Math.PI;
|
|
496
496
|
}
|
|
497
|
-
const $e = 57.29577951308232, Je = 0.017453292519943295, me = 6378137, S = (
|
|
498
|
-
function Xt(
|
|
499
|
-
const i = D(
|
|
500
|
-
return [
|
|
497
|
+
const $e = 57.29577951308232, Je = 0.017453292519943295, me = 6378137, S = (o, e) => ({ x: o === 0 ? 0 : o * Je * me, y: e === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + e * Je / 2)) * me }), k = (o, e) => ({ lng: o === 0 ? 0 : $e * (o / me), lat: e === 0 ? 0 : (2 * Math.atan(Math.exp(e / me)) - Math.PI / 2) * $e });
|
|
498
|
+
function Xt(o, e, t) {
|
|
499
|
+
const i = D(o[0]), n = D(o[1]), s = D(t), r = pt(e), a = Math.asin(Math.sin(n) * Math.cos(r) + Math.cos(n) * Math.sin(r) * Math.cos(s));
|
|
500
|
+
return [U(i + Math.atan2(Math.sin(s) * Math.sin(r) * Math.cos(n), Math.cos(r) - Math.sin(n) * Math.sin(a))), U(a)];
|
|
501
501
|
}
|
|
502
|
-
function qe(
|
|
503
|
-
const { center: e, radiusKilometers: t, coordinatePrecision: i } =
|
|
502
|
+
function qe(o) {
|
|
503
|
+
const { center: e, radiusKilometers: t, coordinatePrecision: i } = o, n = o.steps ? o.steps : 64, s = [];
|
|
504
504
|
for (let r = 0; r < n; r++) {
|
|
505
505
|
const a = Xt(e, t, -360 * r / n);
|
|
506
|
-
|
|
506
|
+
s.push([E(a[0], i), E(a[1], i)]);
|
|
507
507
|
}
|
|
508
|
-
return
|
|
508
|
+
return s.push(s[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [s] }, properties: {} };
|
|
509
509
|
}
|
|
510
|
-
function Le(
|
|
510
|
+
function Le(o) {
|
|
511
511
|
const e = { epsilon: 0 };
|
|
512
512
|
let t;
|
|
513
|
-
if (
|
|
513
|
+
if (o.geometry.type === "Polygon") t = o.geometry.coordinates;
|
|
514
514
|
else {
|
|
515
|
-
if (
|
|
516
|
-
t = [
|
|
515
|
+
if (o.geometry.type !== "LineString") throw new Error("Self intersects only accepts Polygons and LineStrings");
|
|
516
|
+
t = [o.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++) s(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],
|
|
526
|
-
if (he(
|
|
527
|
-
const x =
|
|
528
|
-
return H === 0 ? null : [((x *
|
|
529
|
-
}(c, h, u,
|
|
530
|
-
if (
|
|
531
|
-
let
|
|
532
|
-
|
|
524
|
+
function s(r, a, l, d) {
|
|
525
|
+
const c = t[r][a], h = t[r][a + 1], u = t[l][d], p = t[l][d + 1], g = function(y, C, m, v) {
|
|
526
|
+
if (he(y, m) || he(y, v) || he(C, m) || he(v, m)) return null;
|
|
527
|
+
const x = y[0], w = y[1], I = C[0], O = C[1], N = m[0], _ = m[1], j = v[0], Y = v[1], H = (x - I) * (_ - Y) - (w - O) * (N - j);
|
|
528
|
+
return H === 0 ? null : [((x * O - w * I) * (N - j) - (x - I) * (N * Y - _ * j)) / H, ((x * O - w * I) * (_ - Y) - (w - O) * (N * Y - _ * j)) / H];
|
|
529
|
+
}(c, h, u, p);
|
|
530
|
+
if (g === null) return;
|
|
531
|
+
let f, P;
|
|
532
|
+
f = h[0] !== c[0] ? (g[0] - c[0]) / (h[0] - c[0]) : (g[1] - c[1]) / (h[1] - c[1]), P = p[0] !== u[0] ? (g[0] - u[0]) / (p[0] - u[0]) : (g[1] - u[1]) / (p[1] - u[1]), n(f) || n(P) || (g.toString(), i.push(g));
|
|
533
533
|
}
|
|
534
534
|
}
|
|
535
|
-
function he(
|
|
536
|
-
return
|
|
535
|
+
function he(o, e) {
|
|
536
|
+
return o[0] === e[0] && o[1] === e[1];
|
|
537
537
|
}
|
|
538
|
-
function xe(
|
|
539
|
-
return
|
|
538
|
+
function xe(o, e) {
|
|
539
|
+
return o.length === 2 && typeof o[0] == "number" && typeof o[1] == "number" && o[0] !== 1 / 0 && o[1] !== 1 / 0 && (i = o[0]) >= -180 && i <= 180 && (t = o[1]) >= -90 && t <= 90 && Ze(o[0]) <= e && Ze(o[1]) <= e;
|
|
540
540
|
var t, i;
|
|
541
541
|
}
|
|
542
|
-
function Ze(
|
|
542
|
+
function Ze(o) {
|
|
543
543
|
let e = 1, t = 0;
|
|
544
|
-
for (; Math.round(
|
|
544
|
+
for (; Math.round(o * e) / e !== o; ) e *= 10, t++;
|
|
545
545
|
return t;
|
|
546
546
|
}
|
|
547
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(
|
|
549
|
-
return
|
|
548
|
+
function Se(o, e) {
|
|
549
|
+
return o.geometry.type !== "Polygon" ? { valid: !1, reason: zt } : o.geometry.coordinates.length !== 1 ? { valid: !1, reason: Kt } : o.geometry.coordinates[0].length < 4 ? { valid: !1, reason: Yt } : o.geometry.coordinates[0].every((n) => xe(n, e)) ? (t = o.geometry.coordinates[0][0])[0] !== (i = o.geometry.coordinates[0][o.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 ? Le(
|
|
552
|
+
function de(o, e) {
|
|
553
|
+
const t = Se(o, e);
|
|
554
|
+
return t.valid ? Le(o) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : t;
|
|
555
555
|
}
|
|
556
|
-
class
|
|
556
|
+
class gt extends B {
|
|
557
557
|
constructor(e) {
|
|
558
558
|
var t;
|
|
559
559
|
super(e), this.mode = "circle", this.center = void 0, this.clickCount = 0, this.currentCircleId = void 0, this.keyEvents = void 0, this.cursors = void 0, this.startingRadiusKilometers = 1e-5, this.cursorMovedAfterInitialCursorDown = !1;
|
|
@@ -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(s, r) {
|
|
625
|
+
const a = 1e3 * V(s, r);
|
|
626
626
|
if (a === 0) return 1;
|
|
627
|
-
const { x: l, y: d } = S(
|
|
627
|
+
const { x: l, y: d } = S(s[0], s[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(s) {
|
|
631
|
+
const { center: r, radiusKilometers: a, coordinatePrecision: l } = s, d = s.steps ? s.steps : 64, c = 1e3 * a, [h, u] = r, { x: p, y: g } = S(h, u), f = [];
|
|
632
632
|
for (let P = 0; P < d; P++) {
|
|
633
|
-
const
|
|
634
|
-
|
|
633
|
+
const y = 360 * P / d * Math.PI / 180, C = c * Math.cos(y), m = c * Math.sin(y), [v, x] = [p + C, g + m], { lng: w, lat: I } = k(v, x);
|
|
634
|
+
f.push([E(w, l), E(I, l)]);
|
|
635
635
|
}
|
|
636
|
-
return
|
|
636
|
+
return f.push(f[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [f] }, 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 ft extends B {
|
|
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,7 +673,7 @@ class yt 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,
|
|
676
|
+
const t = this.store.getGeometryCopy(this.currentId), i = t.coordinates[0].length - 2, [n, s] = t.coordinates[0][i], { x: r, y: a } = this.project(n, s), 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
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;
|
|
@@ -681,8 +681,8 @@ class yt extends N {
|
|
|
681
681
|
} else this.hasLeftStartingPoint = !0, this.setCursor(this.cursors.start);
|
|
682
682
|
if (l < this.minDistance) return;
|
|
683
683
|
t.coordinates[0].pop();
|
|
684
|
-
const
|
|
685
|
-
this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry:
|
|
684
|
+
const p = { type: "Polygon", coordinates: [[...t.coordinates[0], [e.lng, e.lat], t.coordinates[0][0]]] };
|
|
685
|
+
this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: p, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Provisional }).valid || this.store.updateGeometry([{ id: this.currentId, geometry: p }]);
|
|
686
686
|
}
|
|
687
687
|
onClick(e) {
|
|
688
688
|
if (!this.preventNewFeature) {
|
|
@@ -720,25 +720,25 @@ class yt 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 W {
|
|
724
|
+
constructor({ store: e, mode: t, project: i, unproject: n, pointerDistance: s, 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 = s, 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 yt({ unproject: o, point: e, pointerDistance: t }) {
|
|
729
|
+
const i = t / 2, { x: n, y: s } = e;
|
|
730
|
+
return { type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [[o(n - i, s - i), o(n + i, s - i), o(n + i, s + i), o(n - i, s + i), o(n - i, s - i)].map((r) => [r.lng, r.lat])] } };
|
|
731
731
|
}
|
|
732
|
-
class ke extends
|
|
732
|
+
class ke extends W {
|
|
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 yt({ unproject: this.unproject, point: { x: t, y: i }, pointerDistance: this.pointerDistance });
|
|
739
739
|
}
|
|
740
740
|
}
|
|
741
|
-
class We extends
|
|
741
|
+
class We extends W {
|
|
742
742
|
constructor(e) {
|
|
743
743
|
super(e);
|
|
744
744
|
}
|
|
@@ -747,12 +747,12 @@ class We extends j {
|
|
|
747
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 W {
|
|
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, (s) => !!(s.properties && s.properties.mode === this.mode)), this.getSnappableCoordinate = (n, s) => this.getSnappable(n, (r) => !!(r.properties && r.properties.mode === this.mode && r.id !== s)), 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), s = { 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,62 +762,62 @@ class mt extends j {
|
|
|
762
762
|
}
|
|
763
763
|
a.forEach((l) => {
|
|
764
764
|
const d = this.pixelDistance.measure(e, l);
|
|
765
|
-
d <
|
|
765
|
+
d < s.minDist && d < this.pointerDistance && (s.coord = l, s.minDist = d);
|
|
766
766
|
});
|
|
767
|
-
}),
|
|
767
|
+
}), s.coord;
|
|
768
768
|
}
|
|
769
769
|
}
|
|
770
|
-
function Qe(
|
|
771
|
-
const i = D(
|
|
772
|
-
return [
|
|
770
|
+
function Qe(o, e, t) {
|
|
771
|
+
const i = D(o[0]), n = D(o[1]), s = D(t), r = pt(e), a = Math.asin(Math.sin(n) * Math.cos(r) + Math.cos(n) * Math.sin(r) * Math.cos(s));
|
|
772
|
+
return [U(i + Math.atan2(Math.sin(s) * Math.sin(r) * Math.cos(n), Math.cos(r) - Math.sin(n) * Math.sin(a))), U(a)];
|
|
773
773
|
}
|
|
774
|
-
function le({ x:
|
|
774
|
+
function le({ x: o, y: e }, t, i) {
|
|
775
775
|
const n = D(i);
|
|
776
|
-
return { x:
|
|
776
|
+
return { x: o + t * Math.cos(n), y: e + t * Math.sin(n) };
|
|
777
777
|
}
|
|
778
|
-
function et(
|
|
779
|
-
const t = D(
|
|
780
|
-
return
|
|
778
|
+
function et(o, e) {
|
|
779
|
+
const t = D(o[0]), i = D(e[0]), n = D(o[1]), s = D(e[1]), r = Math.sin(i - t) * Math.cos(s), a = Math.cos(n) * Math.sin(s) - Math.sin(n) * Math.cos(s) * Math.cos(i - t);
|
|
780
|
+
return U(Math.atan2(r, a));
|
|
781
781
|
}
|
|
782
|
-
function G({ x:
|
|
783
|
-
let n = Math.atan2(i - e, t -
|
|
782
|
+
function G({ x: o, y: e }, { x: t, y: i }) {
|
|
783
|
+
let n = Math.atan2(i - e, t - o);
|
|
784
784
|
return n *= 180 / Math.PI, n > 180 ? n -= 360 : n < -180 && (n += 360), n;
|
|
785
785
|
}
|
|
786
|
-
function z(
|
|
787
|
-
return (
|
|
786
|
+
function z(o) {
|
|
787
|
+
return (o + 360) % 360;
|
|
788
788
|
}
|
|
789
|
-
function Jt(
|
|
790
|
-
const i = [], n =
|
|
791
|
-
let
|
|
792
|
-
for (let c = 0; c <
|
|
789
|
+
function Jt(o, e, t) {
|
|
790
|
+
const i = [], n = o.length;
|
|
791
|
+
let s, r, a, l = 0;
|
|
792
|
+
for (let c = 0; c < o.length && !(e >= l && c === o.length - 1); c++) {
|
|
793
793
|
if (l > e && i.length === 0) {
|
|
794
|
-
if (
|
|
795
|
-
r = et(
|
|
794
|
+
if (s = e - l, !s) return i.push(o[c]), i;
|
|
795
|
+
r = et(o[c], o[c - 1]) - 180, a = Qe(o[c], s, 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 s = t - l, s ? (r = et(o[c], o[c - 1]) - 180, a = Qe(o[c], s, r), i.push(a), i) : (i.push(o[c]), i);
|
|
798
|
+
if (l >= e && i.push(o[c]), c === o.length - 1) return i;
|
|
799
|
+
l += V(o[c], o[c + 1]);
|
|
800
800
|
}
|
|
801
|
-
if (l < e &&
|
|
802
|
-
const d =
|
|
801
|
+
if (l < e && o.length === n) throw new Error("Start position is beyond line");
|
|
802
|
+
const d = o[o.length - 1];
|
|
803
803
|
return [d, d];
|
|
804
804
|
}
|
|
805
|
-
function ue(
|
|
806
|
-
return
|
|
805
|
+
function ue(o) {
|
|
806
|
+
return o * (Math.PI / 180);
|
|
807
807
|
}
|
|
808
|
-
function tt(
|
|
809
|
-
return
|
|
808
|
+
function tt(o) {
|
|
809
|
+
return o * (180 / Math.PI);
|
|
810
810
|
}
|
|
811
|
-
class qt extends
|
|
811
|
+
class qt extends W {
|
|
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 s = 0;
|
|
818
|
+
for (let d = 0; d < n.length - 1; d++) s += V(n[0], n[1]);
|
|
819
|
+
if (s <= i) return n;
|
|
820
|
+
let r = s / 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++) {
|
|
@@ -829,32 +829,32 @@ class qt extends j {
|
|
|
829
829
|
return this.limitCoordinates(l);
|
|
830
830
|
}
|
|
831
831
|
generateInsertionGeodesicCoordinates(e, t, i) {
|
|
832
|
-
const n = V(e, t),
|
|
833
|
-
const d = [], c = ue(r[1]), h = ue(r[0]), u = ue(a[1]),
|
|
832
|
+
const n = V(e, t), s = function(r, a, l) {
|
|
833
|
+
const d = [], c = ue(r[1]), h = ue(r[0]), u = ue(a[1]), p = ue(a[0]);
|
|
834
834
|
l += 1;
|
|
835
|
-
const
|
|
836
|
-
if (
|
|
837
|
-
for (let
|
|
838
|
-
const P =
|
|
835
|
+
const g = 2 * Math.asin(Math.sqrt(Math.sin((u - c) / 2) ** 2 + Math.cos(c) * Math.cos(u) * Math.sin((p - h) / 2) ** 2));
|
|
836
|
+
if (g === 0 || isNaN(g)) return d;
|
|
837
|
+
for (let f = 0; f <= l; f++) {
|
|
838
|
+
const P = f / l, y = Math.sin((1 - P) * g) / Math.sin(g), C = Math.sin(P * g) / Math.sin(g), m = y * Math.cos(c) * Math.cos(h) + C * Math.cos(u) * Math.cos(p), v = y * Math.cos(c) * Math.sin(h) + C * Math.cos(u) * Math.sin(p), x = y * 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(s);
|
|
846
846
|
}
|
|
847
847
|
limitCoordinates(e) {
|
|
848
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(o, e) {
|
|
852
|
+
return o[0] === e[0] && o[1] === e[1];
|
|
853
853
|
}
|
|
854
|
-
function Ct(
|
|
855
|
-
return
|
|
854
|
+
function Ct(o, e) {
|
|
855
|
+
return o.geometry.type !== "LineString" ? { valid: !1, reason: "Feature is not a LineString" } : o.geometry.coordinates.length < 2 ? { valid: !1, reason: "Feature has less than 2 coordinates" } : o.geometry.coordinates.every((t) => xe(t, e)) ? { valid: !0 } : { valid: !1, reason: "Feature has invalid coordinates" };
|
|
856
856
|
}
|
|
857
|
-
class Pt extends
|
|
857
|
+
class Pt extends B {
|
|
858
858
|
constructor(e) {
|
|
859
859
|
super(e), this.mode = "linestring", this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.keyEvents = void 0, this.snapping = void 0, this.cursors = void 0, this.mouseMove = !1, this.insertCoordinates = void 0, this.lastCommitedCoordinates = void 0, this.snappedPointId = void 0, this.coordinateSnapping = void 0, this.insertPoint = void 0;
|
|
860
860
|
const t = { start: "crosshair", close: "pointer" };
|
|
@@ -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 s = [{ id: this.currentId, geometry: n }];
|
|
880
|
+
this.closingPointId && t && s.push({ id: this.closingPointId, geometry: { type: "Point", coordinates: t } }), i === "commit" && (this.lastCommitedCoordinates = n.coordinates), this.store.updateGeometry(s);
|
|
881
881
|
}
|
|
882
882
|
generateInsertCoordinates(e, t) {
|
|
883
883
|
if (!this.insertCoordinates || !this.lastCommitedCoordinates) throw new Error("Not able to insert coordinates");
|
|
@@ -899,7 +899,7 @@ 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,
|
|
902
|
+
const i = this.store.getGeometryCopy(this.currentId).coordinates, [n, s] = this.lastCommitedCoordinates ? this.lastCommitedCoordinates[this.lastCommitedCoordinates.length - 1] : i[i.length - 2], { x: r, y: a } = this.project(n, s);
|
|
903
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];
|
|
@@ -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, [Oe]: !0 } }]);
|
|
924
924
|
this.snappedPointId = r;
|
|
925
925
|
}
|
|
926
926
|
e.lng = t[0], e.lat = t[1];
|
|
@@ -932,15 +932,15 @@ class Pt extends N {
|
|
|
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 s = [...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
|
+
s = [...this.lastCommitedCoordinates.slice(0, -1), ...l, i];
|
|
941
941
|
}
|
|
942
942
|
}
|
|
943
|
-
this.updateGeometries(
|
|
943
|
+
this.updateGeometries(s, 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,10 +985,10 @@ 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(o, e) {
|
|
989
|
+
return o.geometry.type !== "Point" ? { valid: !1, reason: Zt } : xe(o.geometry.coordinates, e) ? { valid: !0 } : { valid: !1, reason: Qt };
|
|
990
990
|
}
|
|
991
|
-
class ei extends
|
|
991
|
+
class ei extends B {
|
|
992
992
|
constructor(e) {
|
|
993
993
|
super(e), this.mode = "point", this.cursors = void 0;
|
|
994
994
|
const t = { create: "crosshair" };
|
|
@@ -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 W {
|
|
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 j {
|
|
|
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), s = this.pixelDistance.measure(e, i.coordinates);
|
|
1055
|
+
return { isClosing: n < this.pointerDistance, isPreviousClosing: s < this.pointerDistance };
|
|
1056
1056
|
}
|
|
1057
1057
|
}
|
|
1058
|
-
function it(
|
|
1059
|
-
return Math.sqrt(Math.pow(
|
|
1058
|
+
function it(o) {
|
|
1059
|
+
return Math.sqrt(Math.pow(o[0], 2) + Math.pow(o[1], 2) + Math.pow(o[2], 2));
|
|
1060
1060
|
}
|
|
1061
|
-
function R(
|
|
1061
|
+
function R(o, e) {
|
|
1062
1062
|
const t = function(i, n) {
|
|
1063
|
-
const [
|
|
1064
|
-
return
|
|
1065
|
-
}(
|
|
1063
|
+
const [s, r, a] = i, [l, d, c] = n;
|
|
1064
|
+
return s * l + r * d + a * c;
|
|
1065
|
+
}(o, e) / (it(o) * it(e));
|
|
1066
1066
|
return Math.acos(Math.min(Math.max(t, -1), 1));
|
|
1067
1067
|
}
|
|
1068
|
-
function be(
|
|
1069
|
-
const e = D(
|
|
1068
|
+
function be(o) {
|
|
1069
|
+
const e = D(o[1]), t = D(o[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(o) {
|
|
1073
|
+
const [e, t, i] = o, n = U(Math.asin(i));
|
|
1074
|
+
return [U(Math.atan2(t, e)), n];
|
|
1075
1075
|
}
|
|
1076
|
-
function ii(
|
|
1077
|
-
const i = be(
|
|
1078
|
-
const [H, Be, Ne] =
|
|
1076
|
+
function ii(o, e, t) {
|
|
1077
|
+
const i = be(o), n = be(e), s = be(t), [r, a, l] = s, [d, c, h] = function(j, Y) {
|
|
1078
|
+
const [H, Be, Ne] = j, [Ae, Ge, Ve] = Y;
|
|
1079
1079
|
return [Be * Ve - Ne * Ge, Ne * Ae - H * Ve, H * Ge - Be * Ae];
|
|
1080
|
-
}(i, n), u = c * l - h * a,
|
|
1081
|
-
let
|
|
1082
|
-
return
|
|
1080
|
+
}(i, n), u = c * l - h * a, p = h * r - d * l, g = d * a - c * r, f = g * c - p * h, P = u * h - g * d, y = p * d - u * c, C = 1 / Math.sqrt(Math.pow(f, 2) + Math.pow(P, 2) + Math.pow(y, 2)), m = [f * C, P * C, y * C], v = [-1 * f * C, -1 * P * C, -1 * y * C], x = R(i, n), w = R(i, m), I = R(n, m), O = R(i, v), N = R(n, v);
|
|
1081
|
+
let _;
|
|
1082
|
+
return _ = w < O && w < N || I < O && I < N ? m : v, R(i, _) > x || R(n, _) > x ? V(X(_), X(i)) <= V(X(_), X(n)) ? [X(i), !0, !1] : [X(n), !1, !0] : [X(_), !1, !1];
|
|
1083
1083
|
}
|
|
1084
|
-
function ni(
|
|
1085
|
-
const i = e.x -
|
|
1086
|
-
return { x:
|
|
1084
|
+
function ni(o, e, t) {
|
|
1085
|
+
const i = e.x - o.x, n = e.y - o.y, s = Math.max(0, Math.min(1, ((t.x - o.x) * i + (t.y - o.y) * n) / (i * i + n * n)));
|
|
1086
|
+
return { x: o.x + s * i, y: o.y + s * n };
|
|
1087
1087
|
}
|
|
1088
|
-
class
|
|
1088
|
+
class si extends W {
|
|
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, (s) => !!(s.properties && s.properties.mode === this.mode)), this.getSnappableCoordinate = (n, s) => this.getSnappable(n, (r) => !!(r.properties && r.properties.mode === this.mode && r.id !== s)), 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), s = { 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];
|
|
@@ -1102,36 +1102,36 @@ class oi extends j {
|
|
|
1102
1102
|
for (let u = 0; u < a.length - 1; u++) l.push([a[u], a[u + 1]]);
|
|
1103
1103
|
let d;
|
|
1104
1104
|
const c = [e.lng, e.lat];
|
|
1105
|
-
if (this.config.projection === "web-mercator" ? d = function(u,
|
|
1106
|
-
let
|
|
1107
|
-
for (let P of
|
|
1108
|
-
const
|
|
1105
|
+
if (this.config.projection === "web-mercator" ? d = function(u, p) {
|
|
1106
|
+
let g = [1 / 0, 1 / 0], f = 1 / 0;
|
|
1107
|
+
for (let P of p) {
|
|
1108
|
+
const y = P[0], C = P[1];
|
|
1109
1109
|
let m, v = 1 / 0;
|
|
1110
|
-
const x = S(
|
|
1111
|
-
if (
|
|
1110
|
+
const x = S(y[0], y[1]), w = S(C[0], C[1]), I = S(u[0], u[1]);
|
|
1111
|
+
if (y[0] === u[0] && y[1] === u[1]) m = y;
|
|
1112
1112
|
else if (C[0] === u[0] && C[1] === u[1]) m = C;
|
|
1113
1113
|
else {
|
|
1114
|
-
const { x:
|
|
1115
|
-
m = [
|
|
1114
|
+
const { x: O, y: N } = ni(x, w, I), { lng: _, lat: j } = k(O, N);
|
|
1115
|
+
m = [_, j];
|
|
1116
1116
|
}
|
|
1117
|
-
m && (v = F(I, S(m[0], m[1])), v <
|
|
1117
|
+
m && (v = F(I, S(m[0], m[1])), v < f && (g = m, f = v));
|
|
1118
1118
|
}
|
|
1119
|
-
return
|
|
1120
|
-
}(c, l) : this.config.projection === "globe" && (d = function(u,
|
|
1121
|
-
let
|
|
1122
|
-
for (let P of
|
|
1123
|
-
const
|
|
1119
|
+
return f === 1 / 0 ? void 0 : { coordinate: g, distance: f };
|
|
1120
|
+
}(c, l) : this.config.projection === "globe" && (d = function(u, p) {
|
|
1121
|
+
let g = [1 / 0, 1 / 0], f = 1 / 0;
|
|
1122
|
+
for (let P of p) {
|
|
1123
|
+
const y = P[0], C = P[1];
|
|
1124
1124
|
let m, v = 1 / 0;
|
|
1125
|
-
|
|
1125
|
+
y[0] === u[0] && y[1] === u[1] ? m = y : C[0] === u[0] && C[1] === u[1] ? m = C : [m] = ii(y, C, u), m && (v = V(u, m), v < f && (g = m, f = v));
|
|
1126
1126
|
}
|
|
1127
|
-
return
|
|
1127
|
+
return f === 1 / 0 ? void 0 : { coordinate: g, distance: f };
|
|
1128
1128
|
}(c, l)), !d) return;
|
|
1129
1129
|
const h = this.pixelDistance.measure(e, d.coordinate);
|
|
1130
|
-
h <
|
|
1131
|
-
}),
|
|
1130
|
+
h < s.minDistance && h < this.pointerDistance && (s.coord = d.coordinate, s.minDistance = h);
|
|
1131
|
+
}), s.coord;
|
|
1132
1132
|
}
|
|
1133
1133
|
}
|
|
1134
|
-
class xt extends
|
|
1134
|
+
class xt extends B {
|
|
1135
1135
|
constructor(e) {
|
|
1136
1136
|
super(e), this.mode = "polygon", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.snapping = void 0, this.snappedPointId = void 0, this.lineSnapping = void 0, this.coordinateSnapping = void 0, this.pixelDistance = void 0, this.closingPoints = void 0, this.cursors = void 0, this.mouseMove = !1;
|
|
1137
1137
|
const t = { start: "crosshair", close: "pointer" };
|
|
@@ -1150,7 +1150,7 @@ class xt extends N {
|
|
|
1150
1150
|
}
|
|
1151
1151
|
registerBehaviors(e) {
|
|
1152
1152
|
const t = new ke(e);
|
|
1153
|
-
this.pixelDistance = new We(e), this.lineSnapping = new
|
|
1153
|
+
this.pixelDistance = new We(e), this.lineSnapping = new si(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 [s] = this.store.create([{ geometry: { type: "Point", coordinates: t }, properties: { mode: this.mode, [Oe]: !0 } }]);
|
|
1168
|
+
this.snappedPointId = s;
|
|
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 s = 1 / Math.pow(10, this.coordinatePrecision - 1), r = Math.max(1e-6, s);
|
|
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: s, isPreviousClosing: r } = this.closingPoints.isClosingPoint(e);
|
|
1181
|
+
r || s ? (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 s;
|
|
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 && (s = 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 && (s = r);
|
|
1200
1200
|
}
|
|
1201
|
-
return (n = this.snapping) != null && n.toCustom && (
|
|
1201
|
+
return (n = this.snapping) != null && n.toCustom && (s = this.snapping.toCustom(e)), s;
|
|
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 s = this.snapCoordinate(e);
|
|
1226
|
+
if (s && (e.lng = s[0], e.lat = s[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[Oe];
|
|
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
|
}
|
|
@@ -1268,7 +1268,7 @@ class xt extends N {
|
|
|
1268
1268
|
return this.validateModeFeature(e, (t) => Se(t, this.coordinatePrecision));
|
|
1269
1269
|
}
|
|
1270
1270
|
}
|
|
1271
|
-
class St extends
|
|
1271
|
+
class St extends B {
|
|
1272
1272
|
constructor(e) {
|
|
1273
1273
|
super(e), this.mode = "rectangle", this.center = void 0, this.clickCount = 0, this.currentRectangleId = void 0, this.keyEvents = void 0, this.cursors = void 0;
|
|
1274
1274
|
const t = { start: "crosshair" };
|
|
@@ -1328,7 +1328,7 @@ class St extends N {
|
|
|
1328
1328
|
return this.validateModeFeature(e, (t) => de(t, this.coordinatePrecision));
|
|
1329
1329
|
}
|
|
1330
1330
|
}
|
|
1331
|
-
class ie extends
|
|
1331
|
+
class ie extends B {
|
|
1332
1332
|
constructor(e) {
|
|
1333
1333
|
super({ styles: e.styles }), this.type = K.Render, this.mode = "render", this.mode = e.modeName;
|
|
1334
1334
|
}
|
|
@@ -1369,44 +1369,44 @@ class ie extends N {
|
|
|
1369
1369
|
return t;
|
|
1370
1370
|
}
|
|
1371
1371
|
}
|
|
1372
|
-
function Ce(
|
|
1373
|
-
const t =
|
|
1372
|
+
function Ce(o, e) {
|
|
1373
|
+
const t = o, i = e, n = D(t[1]), s = D(i[1]);
|
|
1374
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(s / 2 + Math.PI / 4) / Math.tan(n / 2 + Math.PI / 4)), l = (U(Math.atan2(r, a)) + 360) % 360;
|
|
1377
1377
|
return l > 180 ? -(360 - l) : l;
|
|
1378
1378
|
}
|
|
1379
|
-
function je(
|
|
1379
|
+
function je(o, e, t) {
|
|
1380
1380
|
let i = e;
|
|
1381
1381
|
e < 0 && (i = -Math.abs(i));
|
|
1382
|
-
const n = i /
|
|
1382
|
+
const n = i / _e, s = o[0] * Math.PI / 180, r = D(o[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 * (s + n * Math.sin(a) / h) / Math.PI + 540) % 360 - 180, 180 * d / Math.PI];
|
|
1386
|
+
return u[0] += u[0] - o[0] > 180 ? -360 : o[0] - u[0] > 180 ? 360 : 0, u;
|
|
1387
1387
|
}
|
|
1388
|
-
function Mt(
|
|
1389
|
-
const
|
|
1388
|
+
function Mt(o, e, t, i, n) {
|
|
1389
|
+
const s = i(o[0], o[1]), r = i(e[0], e[1]), { lng: a, lat: l } = n((s.x + r.x) / 2, (s.y + r.y) / 2);
|
|
1390
1390
|
return [E(a, t), E(l, t)];
|
|
1391
1391
|
}
|
|
1392
|
-
function
|
|
1393
|
-
const i = je(
|
|
1392
|
+
function oi(o, e, t) {
|
|
1393
|
+
const i = je(o, 1e3 * V(o, e) / 2, Ce(o, e));
|
|
1394
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: o, precision: e, unproject: t, project: i, projection: n }) {
|
|
1397
|
+
const s = [];
|
|
1398
|
+
for (let r = 0; r < o.length - 1; r++) {
|
|
1399
1399
|
let a;
|
|
1400
|
-
if (n === "web-mercator") a = Mt(
|
|
1400
|
+
if (n === "web-mercator") a = Mt(o[r], o[r + 1], e, i, t);
|
|
1401
1401
|
else {
|
|
1402
1402
|
if (n !== "globe") throw new Error("Invalid projection");
|
|
1403
|
-
a =
|
|
1403
|
+
a = oi(o[r], o[r + 1], e);
|
|
1404
1404
|
}
|
|
1405
|
-
|
|
1405
|
+
s.push(a);
|
|
1406
1406
|
}
|
|
1407
|
-
return
|
|
1407
|
+
return s;
|
|
1408
1408
|
}
|
|
1409
|
-
class ri extends
|
|
1409
|
+
class ri extends W {
|
|
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 j {
|
|
|
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: s } = this.store.getPropertiesCopy(e), r = this.store.getGeometryCopy(n), a = r.type === "Polygon" ? r.coordinates[0] : r.coordinates;
|
|
1420
|
+
a.splice(s + 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, s, 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: s(h) }));
|
|
1426
|
+
}(e, (n) => ({ mode: this.mode, [oe]: !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 j {
|
|
|
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 W {
|
|
1436
1436
|
constructor(e) {
|
|
1437
1437
|
super(e), this._selectionPoints = [];
|
|
1438
1438
|
}
|
|
@@ -1442,8 +1442,8 @@ class ai extends j {
|
|
|
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, s, r) {
|
|
1446
|
+
const a = [], l = s === "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 j {
|
|
|
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(o, 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 = o)[1] != (s = l[h])[1] > i[1] && i[0] < (s[0] - n[0]) * (i[1] - n[1]) / (s[1] - n[1]) + n[0] && (t = !t);
|
|
1466
1466
|
}
|
|
1467
|
-
var i, n,
|
|
1467
|
+
var i, n, s;
|
|
1468
1468
|
return t;
|
|
1469
1469
|
}
|
|
1470
|
-
const bt = (
|
|
1471
|
-
const i = (
|
|
1472
|
-
return Math.sqrt(((
|
|
1470
|
+
const bt = (o, e, t) => {
|
|
1471
|
+
const i = (s) => s * s, n = (s, r) => i(s.x - r.x) + i(s.y - r.y);
|
|
1472
|
+
return Math.sqrt(((s, 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(s, r);
|
|
1475
|
+
let d = ((s.x - r.x) * (a.x - r.x) + (s.y - r.y) * (a.y - r.y)) / l;
|
|
1476
|
+
return d = Math.max(0, Math.min(1, d)), n(s, { x: r.x + d * (a.x - r.x), y: r.y + d * (a.y - r.y) });
|
|
1477
|
+
})(o, e, t));
|
|
1478
1478
|
};
|
|
1479
|
-
class li extends
|
|
1479
|
+
class li extends W {
|
|
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, s, 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
|
|
1488
|
-
if (
|
|
1489
|
-
if (
|
|
1490
|
-
const
|
|
1491
|
-
|
|
1492
|
-
} else if (
|
|
1487
|
+
const p = h[u], g = p.geometry;
|
|
1488
|
+
if (g.type === "Point") {
|
|
1489
|
+
if (p.properties.selectionPoint || !t && p.properties[oe]) continue;
|
|
1490
|
+
const f = this.pixelDistance.measure(e, g.coordinates);
|
|
1491
|
+
p.properties[oe] && f < this.pointerDistance && f < d ? (d = f, s = p) : !p.properties[oe] && f < this.pointerDistance && f < a && (a = f, i = p);
|
|
1492
|
+
} else if (g.type === "LineString") {
|
|
1493
1493
|
if (i) continue;
|
|
1494
|
-
for (let
|
|
1495
|
-
const P =
|
|
1496
|
-
C < this.pointerDistance && C < l && (l = C, n =
|
|
1494
|
+
for (let f = 0; f < g.coordinates.length - 1; f++) {
|
|
1495
|
+
const P = g.coordinates[f], y = g.coordinates[f + 1], C = bt({ x: e.containerX, y: e.containerY }, this.project(P[0], P[1]), this.project(y[0], y[1]));
|
|
1496
|
+
C < this.pointerDistance && C < l && (l = C, n = p);
|
|
1497
1497
|
}
|
|
1498
|
-
} else if (
|
|
1498
|
+
} else if (g.type === "Polygon") {
|
|
1499
1499
|
if (i || n) continue;
|
|
1500
|
-
wt([e.lng, e.lat],
|
|
1500
|
+
wt([e.lng, e.lat], g.coordinates) && (r = p);
|
|
1501
1501
|
}
|
|
1502
1502
|
}
|
|
1503
|
-
return { clickedFeature: i || n || r, clickedMidPoint:
|
|
1503
|
+
return { clickedFeature: i || n || r, clickedMidPoint: s };
|
|
1504
1504
|
}
|
|
1505
1505
|
}
|
|
1506
|
-
class di extends
|
|
1506
|
+
class di extends W {
|
|
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 j {
|
|
|
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 s, r;
|
|
1528
|
+
if (i.type === "Polygon" ? (s = i.coordinates[0], r = s.length - 1) : (s = i.coordinates, r = s.length), !this.dragPosition) return !1;
|
|
1529
1529
|
for (let d = 0; d < r; d++) {
|
|
1530
|
-
const c =
|
|
1530
|
+
const c = s[d];
|
|
1531
1531
|
let h, u;
|
|
1532
1532
|
if (this.config.projection === "web-mercator") {
|
|
1533
|
-
const
|
|
1533
|
+
const p = S(this.dragPosition[0], this.dragPosition[1]), g = S(n[0], n[1]), f = S(c[0], c[1]), P = { x: p.x - g.x, y: p.y - g.y }, y = f.x - P.x, C = f.y - P.y, { lng: m, lat: v } = k(y, C);
|
|
1534
1534
|
h = m, u = v;
|
|
1535
1535
|
} else {
|
|
1536
|
-
const
|
|
1537
|
-
h = c[0] -
|
|
1536
|
+
const p = [this.dragPosition[0] - n[0], this.dragPosition[1] - n[1]];
|
|
1537
|
+
h = c[0] - p[0], u = c[1] - p[1];
|
|
1538
1538
|
}
|
|
1539
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
|
-
|
|
1540
|
+
s[d] = [h, u];
|
|
1541
1541
|
}
|
|
1542
|
-
i.type === "Polygon" && (
|
|
1543
|
-
const a = this.selectionPoints.getUpdated(
|
|
1542
|
+
i.type === "Polygon" && (s[s.length - 1] = [s[0][0], s[0][1]]);
|
|
1543
|
+
const a = this.selectionPoints.getUpdated(s) || [], l = this.midPoints.getUpdated(s) || [];
|
|
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 W {
|
|
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 j {
|
|
|
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 s = 0; s < n.length; s++) {
|
|
1562
|
+
const r = this.pixelDistance.measure(e, n[s]);
|
|
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" && (s === n.length - 1 || s === 0);
|
|
1565
|
+
i.dist = r, i.index = a ? 0 : s, i.isFirstOrLastPolygonCoord = a;
|
|
1566
1566
|
}
|
|
1567
1567
|
}
|
|
1568
1568
|
return i;
|
|
@@ -1573,15 +1573,15 @@ class ci extends j {
|
|
|
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, s = this.store.getGeometryCopy(this.draggedCoordinate.id), r = s.type === "LineString" ? s.coordinates : s.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 (s.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 !(s.type !== "Point" && !t && Le({ type: "Feature", geometry: s, properties: {} }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: s, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: s }, ...d, ...c]), 0));
|
|
1585
1585
|
}
|
|
1586
1586
|
isDragging() {
|
|
1587
1587
|
return this.draggedCoordinate.id !== null;
|
|
@@ -1593,44 +1593,44 @@ class ci extends j {
|
|
|
1593
1593
|
this.draggedCoordinate = { id: null, index: -1 };
|
|
1594
1594
|
}
|
|
1595
1595
|
}
|
|
1596
|
-
function Pe(
|
|
1596
|
+
function Pe(o) {
|
|
1597
1597
|
let e = 0, t = 0, i = 0;
|
|
1598
|
-
return (
|
|
1598
|
+
return (o.geometry.type === "Polygon" ? o.geometry.coordinates[0].slice(0, -1) : o.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 =
|
|
1605
|
-
let r = Math.abs(
|
|
1602
|
+
function It(o, e) {
|
|
1603
|
+
o[0] += o[0] - e[0] > 180 ? -360 : e[0] - o[0] > 180 ? 360 : 0;
|
|
1604
|
+
const t = _e, i = e[1] * Math.PI / 180, n = o[1] * Math.PI / 180, s = n - i;
|
|
1605
|
+
let r = Math.abs(o[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 ? s / a : Math.cos(i);
|
|
1608
|
+
return Math.sqrt(s * s + l * l * r * r) * t;
|
|
1609
1609
|
}
|
|
1610
|
-
function ve(
|
|
1611
|
-
const e = (
|
|
1610
|
+
function ve(o) {
|
|
1611
|
+
const e = (o.geometry.type === "Polygon" ? o.geometry.coordinates[0] : o.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 o.geometry.type === "Polygon" ? function(t) {
|
|
1616
|
+
let i = 0, n = 0, s = 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, s += (d + h) * u;
|
|
1621
1621
|
}
|
|
1622
|
-
return i /= 2, n /= 6 * i,
|
|
1622
|
+
return i /= 2, n /= 6 * i, s /= 6 * i, { x: n, y: s };
|
|
1623
1623
|
}(e) : function(t) {
|
|
1624
1624
|
const i = t.length;
|
|
1625
|
-
let n = 0,
|
|
1625
|
+
let n = 0, s = 0;
|
|
1626
1626
|
for (let r = 0; r < i; r++) {
|
|
1627
1627
|
const [a, l] = t[r];
|
|
1628
|
-
n += a,
|
|
1628
|
+
n += a, s += l;
|
|
1629
1629
|
}
|
|
1630
|
-
return { x: n / i, y:
|
|
1630
|
+
return { x: n / i, y: s / i };
|
|
1631
1631
|
}(e);
|
|
1632
1632
|
}
|
|
1633
|
-
class hi extends
|
|
1633
|
+
class hi extends W {
|
|
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,27 +1640,27 @@ class hi extends j {
|
|
|
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 s = [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
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
|
|
1651
|
-
|
|
1652
|
-
const P =
|
|
1650
|
+
const p = 0.017453292519943295 * u, g = (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).map(([y, C]) => S(y, C)), f = g.reduce((y, C) => ({ x: y.x + C.x, y: y.y + C.y }), { x: 0, y: 0 });
|
|
1651
|
+
f.x /= g.length, f.y /= g.length;
|
|
1652
|
+
const P = g.map((y) => ({ x: f.x + (y.x - f.x) * Math.cos(p) - (y.y - f.y) * Math.sin(p), y: f.y + (y.x - f.x) * Math.sin(p) + (y.y - f.y) * Math.cos(p) })).map(({ x: y, y: C }) => [k(y, C).lng, k(y, 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: {} }), s), !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
|
-
const
|
|
1661
|
-
(h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).forEach((
|
|
1662
|
-
const
|
|
1663
|
-
|
|
1660
|
+
const p = Pe(h);
|
|
1661
|
+
(h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).forEach((g) => {
|
|
1662
|
+
const f = Ce(p, g) + u, P = It(p, g), y = je(p, P, f);
|
|
1663
|
+
g[0] = y[0], g[1] = y[1];
|
|
1664
1664
|
});
|
|
1665
1665
|
})(a, -(this.lastBearing - (r + 180)));
|
|
1666
1666
|
}
|
|
@@ -1673,7 +1673,7 @@ class hi extends j {
|
|
|
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 W {
|
|
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 j {
|
|
|
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 s = [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
|
-
const
|
|
1691
|
-
a = F(l,
|
|
1690
|
+
const p = S(e.lng, e.lat);
|
|
1691
|
+
a = F(l, p);
|
|
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: {} }), s);
|
|
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:
|
|
1700
|
-
(function(
|
|
1701
|
-
if (P === 1) return
|
|
1702
|
-
const C = (
|
|
1703
|
-
|
|
1704
|
-
})(r, d, [
|
|
1705
|
-
} else this.config.projection === "globe" && function(
|
|
1706
|
-
|
|
1707
|
-
const C = It(
|
|
1708
|
-
P !== "x" && P !== "xy" || (
|
|
1699
|
+
const { lng: p, lat: g } = k(l.x, l.y);
|
|
1700
|
+
(function(f, P, y) {
|
|
1701
|
+
if (P === 1) return f;
|
|
1702
|
+
const C = (f.geometry.type === "Polygon" ? f.geometry.coordinates[0] : f.geometry.coordinates).map(([x, w]) => S(x, w)), m = S(y[0], y[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 }) => [k(x, w).lng, k(x, w).lat]);
|
|
1703
|
+
f.geometry.type === "Polygon" ? f.geometry.coordinates[0] = v : f.geometry.coordinates = v;
|
|
1704
|
+
})(r, d, [p, g]);
|
|
1705
|
+
} else this.config.projection === "globe" && function(p, g, f, P = "xy") {
|
|
1706
|
+
g === 1 || (p.geometry.type === "Polygon" ? p.geometry.coordinates[0] : p.geometry.coordinates).forEach((y) => {
|
|
1707
|
+
const C = It(f, y), m = Ce(f, y), v = je(f, C * g, m);
|
|
1708
|
+
P !== "x" && P !== "xy" || (y[0] = v[0]), P !== "y" && P !== "xy" || (y[1] = v[1]);
|
|
1709
1709
|
});
|
|
1710
1710
|
}(r, d, Pe(r));
|
|
1711
1711
|
const c = n.type === "Polygon" ? n.coordinates[0] : n.coordinates;
|
|
1712
|
-
c.forEach((
|
|
1713
|
-
|
|
1712
|
+
c.forEach((p) => {
|
|
1713
|
+
p[0] = E(p[0], this.coordinatePrecision), p[1] = E(p[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
|
|
1720
|
+
class pi extends W {
|
|
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 j {
|
|
|
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 s = 0; s < n.length; s++) {
|
|
1733
|
+
const r = this.pixelDistance.measure(e, n[s]);
|
|
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" && (s === n.length - 1 || s === 0);
|
|
1736
|
+
i.dist = r, i.index = a ? 0 : s, i.isFirstOrLastPolygonCoord = a;
|
|
1737
1737
|
}
|
|
1738
1738
|
}
|
|
1739
1739
|
return i;
|
|
@@ -1776,43 +1776,43 @@ class gi extends j {
|
|
|
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: s, 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: s, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), s;
|
|
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: s, 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: s, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), s;
|
|
1791
1791
|
}
|
|
1792
|
-
scaleFixedWebMercator({ closestBBoxIndex: e, webMercatorOrigin: t, webMercatorSelected: i, webMercatorCursor: n, updatedCoords:
|
|
1792
|
+
scaleFixedWebMercator({ closestBBoxIndex: e, webMercatorOrigin: t, webMercatorSelected: i, webMercatorCursor: n, updatedCoords: s }) {
|
|
1793
1793
|
if (!this.isValidDragWebMercator(e, t.x - n.x, t.y - n.y)) return null;
|
|
1794
1794
|
let r = F(t, n) / F(t, i);
|
|
1795
|
-
return r < 0 && (r = this.minimumScale), this.performWebMercatorScale(
|
|
1795
|
+
return r < 0 && (r = this.minimumScale), this.performWebMercatorScale(s, t.x, t.y, r, r), s;
|
|
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: s } = t, r = S(s[0], s[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: s } = t, r = S(s[0], s[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: s }) {
|
|
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(s, t.x, t.y, l, d), s) : null;
|
|
1816
1816
|
}
|
|
1817
1817
|
getFeature(e) {
|
|
1818
1818
|
if (this.draggedCoordinate.id === null) return null;
|
|
@@ -1826,9 +1826,9 @@ class gi extends j {
|
|
|
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, s) {
|
|
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) * s, { lng: h, lat: u } = k(d, c);
|
|
1832
1832
|
r[0] = h, r[1] = u;
|
|
1833
1833
|
});
|
|
1834
1834
|
}
|
|
@@ -1840,14 +1840,14 @@ class gi extends j {
|
|
|
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, s, r] = t;
|
|
1844
|
+
return [[i, r], [(i + s) / 2, r], [s, r], [s, r + (n - r) / 2], [s, n], [(i + s) / 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 = F({ x: t.x, y: t.y }, { x: e[
|
|
1850
|
-
r < n && (i =
|
|
1848
|
+
for (let s = 0; s < e.length; s++) {
|
|
1849
|
+
const r = F({ x: t.x, y: t.y }, { x: e[s][0], y: e[s][1] });
|
|
1850
|
+
r < n && (i = s, 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,17 +1869,17 @@ class gi extends j {
|
|
|
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 =
|
|
1872
|
+
let s = null;
|
|
1873
|
+
if (t === "center" ? s = this.centerWebMercatorDrag(e) : t === "opposite" ? s = this.oppositeWebMercatorDrag(e) : t === "center-fixed" ? s = this.centerFixedWebMercatorDrag(e) : t === "opposite-fixed" && (s = this.oppositeFixedWebMercatorDrag(e)), !s) return !1;
|
|
1874
|
+
for (let d = 0; d < s.length; d++) {
|
|
1875
|
+
const c = s[d];
|
|
1876
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(s) || [], a = this.selectionPoints.getUpdated(s) || [], l = { type: n.geometry.type, coordinates: n.geometry.type === "Polygon" ? [s] : s };
|
|
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
|
}
|
|
1882
|
-
class
|
|
1882
|
+
class gi extends Rt {
|
|
1883
1883
|
constructor(e) {
|
|
1884
1884
|
var t;
|
|
1885
1885
|
super(e), this.mode = "select", this.allowManualDeselection = !0, this.dragEventThrottle = 5, this.dragEventCount = 0, this.selected = [], this.flags = void 0, this.keyEvents = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.featuresAtMouseEvent = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.dragFeature = void 0, this.dragCoordinate = void 0, this.rotateFeature = void 0, this.scaleFeature = void 0, this.dragCoordinateResizeFeature = void 0, this.cursors = void 0, this.validations = {}, this.flags = e && e.flags ? e.flags : {};
|
|
@@ -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 s = e.flags[n].feature;
|
|
1894
|
+
s && s.validation && (this.validations[n] = s.validation);
|
|
1895
1895
|
}
|
|
1896
1896
|
}
|
|
1897
1897
|
selectFeature(e) {
|
|
@@ -1902,7 +1902,7 @@ class pi extends Rt {
|
|
|
1902
1902
|
this._state = "selecting";
|
|
1903
1903
|
}
|
|
1904
1904
|
registerBehaviors(e) {
|
|
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
|
|
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 pi(e, this.pixelDistance, this.selectionPoints, this.midPoints);
|
|
1906
1906
|
}
|
|
1907
1907
|
deselectFeature() {
|
|
1908
1908
|
this.deselect();
|
|
@@ -1918,10 +1918,10 @@ class pi extends Rt {
|
|
|
1918
1918
|
if (!this.selectionPoints.ids.length) return;
|
|
1919
1919
|
let t, i = 1 / 0;
|
|
1920
1920
|
if (this.selectionPoints.ids.forEach((h) => {
|
|
1921
|
-
const u = this.store.getGeometryCopy(h),
|
|
1922
|
-
|
|
1921
|
+
const u = this.store.getGeometryCopy(h), p = this.pixelDistance.measure(e, u.coordinates);
|
|
1922
|
+
p < this.pointerDistance && p < i && (i = p, t = this.store.getPropertiesCopy(h));
|
|
1923
1923
|
}), !t) return;
|
|
1924
|
-
const n = t.selectionPointFeatureId,
|
|
1924
|
+
const n = t.selectionPointFeatureId, s = 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" && s === 0 || s === c.length - 1 ? (c.shift(), c.pop(), c.push([c[0][0], c[0][1]])) : c.splice(s, 1), l && !l({ id: 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 s = this.selected[0];
|
|
1941
|
+
if (s) {
|
|
1942
|
+
if (s === 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 s = this.selected[0], r = this.dragCoordinate.getDraggableIndex(e, s);
|
|
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(s, r) : this.dragCoordinate.startDragging(s, r), void t(!1)) : n && n.feature && n.feature.draggable && this.dragFeature.canDrag(e, s) ? (this.setCursor(this.cursors.dragStart), this.dragFeature.startDragging(e, s), 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), s = this.flags[n.mode], r = (s && s.feature && s.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 (s && s.feature && s.feature.rotateable && this.canRotate(e)) return t(!1), void this.rotateFeature.rotate(e, i, a);
|
|
2003
|
+
if (s && s.feature && s.feature.scaleable && this.canScale(e)) return t(!1), void this.scaleFeature.scale(e, i, a);
|
|
2004
|
+
if (this.dragCoordinateResizeFeature.isDragging() && s.feature && s.feature.coordinates && s.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, s.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((s) => {
|
|
2018
2018
|
if (t) return;
|
|
2019
|
-
const r = this.store.getGeometryCopy(
|
|
2019
|
+
const r = this.store.getGeometryCopy(s);
|
|
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((s) => {
|
|
2024
|
+
const r = this.store.getGeometryCopy(s);
|
|
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);
|
|
@@ -2040,7 +2040,7 @@ class pi extends Rt {
|
|
|
2040
2040
|
return t;
|
|
2041
2041
|
}
|
|
2042
2042
|
}
|
|
2043
|
-
class
|
|
2043
|
+
class fi extends B {
|
|
2044
2044
|
constructor(...e) {
|
|
2045
2045
|
super(...e), this.type = K.Static, this.mode = "static";
|
|
2046
2046
|
}
|
|
@@ -2068,70 +2068,70 @@ class yi 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 Et(
|
|
2071
|
+
function Et(o, 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
|
-
Et(
|
|
2075
|
+
Et(o, 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 s = o[e];
|
|
2078
2078
|
let r = t, a = i;
|
|
2079
|
-
for (te(
|
|
2080
|
-
for (te(
|
|
2081
|
-
for (; n(
|
|
2079
|
+
for (te(o, t, e), n(o[i], s) > 0 && te(o, t, i); r < a; ) {
|
|
2080
|
+
for (te(o, r, a), r++, a--; n(o[r], s) < 0; ) r++;
|
|
2081
|
+
for (; n(o[a], s) > 0; ) a--;
|
|
2082
2082
|
}
|
|
2083
|
-
n(
|
|
2083
|
+
n(o[t], s) === 0 ? te(o, t, a) : (a++, te(o, 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(o, e, t) {
|
|
2087
|
+
const i = o[e];
|
|
2088
|
+
o[e] = o[t], o[t] = i;
|
|
2089
2089
|
}
|
|
2090
|
-
function q(
|
|
2091
|
-
ne(
|
|
2090
|
+
function q(o, e) {
|
|
2091
|
+
ne(o, 0, o.children.length, e, o);
|
|
2092
2092
|
}
|
|
2093
|
-
function ne(
|
|
2093
|
+
function ne(o, 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 s = e; s < t; s++) {
|
|
2096
|
+
const r = o.children[s];
|
|
2097
|
+
se(n, o.leaf ? i(r) : r);
|
|
2098
2098
|
}
|
|
2099
2099
|
return n;
|
|
2100
2100
|
}
|
|
2101
|
-
function
|
|
2102
|
-
return
|
|
2101
|
+
function se(o, e) {
|
|
2102
|
+
return o.minX = Math.min(o.minX, e.minX), o.minY = Math.min(o.minY, e.minY), o.maxX = Math.max(o.maxX, e.maxX), o.maxY = Math.max(o.maxY, e.maxY), o;
|
|
2103
2103
|
}
|
|
2104
|
-
function
|
|
2105
|
-
return
|
|
2104
|
+
function yi(o, e) {
|
|
2105
|
+
return o.minX - e.minX;
|
|
2106
2106
|
}
|
|
2107
|
-
function mi(
|
|
2108
|
-
return
|
|
2107
|
+
function mi(o, e) {
|
|
2108
|
+
return o.minY - e.minY;
|
|
2109
2109
|
}
|
|
2110
|
-
function Ie(
|
|
2111
|
-
return (
|
|
2110
|
+
function Ie(o) {
|
|
2111
|
+
return (o.maxX - o.minX) * (o.maxY - o.minY);
|
|
2112
2112
|
}
|
|
2113
|
-
function
|
|
2114
|
-
return
|
|
2113
|
+
function pe(o) {
|
|
2114
|
+
return o.maxX - o.minX + (o.maxY - o.minY);
|
|
2115
2115
|
}
|
|
2116
|
-
function Ci(
|
|
2117
|
-
const t = Math.max(
|
|
2118
|
-
return Math.max(0, n - t) * Math.max(0,
|
|
2116
|
+
function Ci(o, e) {
|
|
2117
|
+
const t = Math.max(o.minX, e.minX), i = Math.max(o.minY, e.minY), n = Math.min(o.maxX, e.maxX), s = Math.min(o.maxY, e.maxY);
|
|
2118
|
+
return Math.max(0, n - t) * Math.max(0, s - i);
|
|
2119
2119
|
}
|
|
2120
|
-
function Ee(
|
|
2121
|
-
return
|
|
2120
|
+
function Ee(o, e) {
|
|
2121
|
+
return o.minX <= e.minX && o.minY <= e.minY && e.maxX <= o.maxX && e.maxY <= o.maxY;
|
|
2122
2122
|
}
|
|
2123
|
-
function
|
|
2124
|
-
return e.minX <=
|
|
2123
|
+
function ge(o, e) {
|
|
2124
|
+
return e.minX <= o.maxX && e.minY <= o.maxY && e.maxX >= o.minX && e.maxY >= o.minY;
|
|
2125
2125
|
}
|
|
2126
|
-
function Z(
|
|
2127
|
-
return { children:
|
|
2126
|
+
function Z(o) {
|
|
2127
|
+
return { children: o, 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 st(o, e, t, i, n) {
|
|
2130
|
+
const s = [e, t];
|
|
2131
|
+
for (; s.length; ) {
|
|
2132
|
+
if ((t = s.pop()) - (e = s.pop()) <= i) continue;
|
|
2133
2133
|
const r = e + Math.ceil((t - e) / i / 2) * i;
|
|
2134
|
-
Et(
|
|
2134
|
+
Et(o, r, e, t, n), s.push(e, r, r, t);
|
|
2135
2135
|
}
|
|
2136
2136
|
}
|
|
2137
2137
|
class Pi {
|
|
@@ -2141,27 +2141,27 @@ class Pi {
|
|
|
2141
2141
|
search(e) {
|
|
2142
2142
|
let t = this.data;
|
|
2143
2143
|
const i = [];
|
|
2144
|
-
if (!
|
|
2145
|
-
const n = this.toBBox,
|
|
2144
|
+
if (!ge(e, t)) return i;
|
|
2145
|
+
const n = this.toBBox, s = [];
|
|
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
|
-
|
|
2149
|
+
ge(e, l) && (t.leaf ? i.push(a) : Ee(e, l) ? this._all(a, i) : s.push(a));
|
|
2150
2150
|
}
|
|
2151
|
-
t =
|
|
2151
|
+
t = s.pop();
|
|
2152
2152
|
}
|
|
2153
2153
|
return i;
|
|
2154
2154
|
}
|
|
2155
2155
|
collides(e) {
|
|
2156
2156
|
let t = this.data;
|
|
2157
|
-
if (
|
|
2157
|
+
if (ge(e, t)) {
|
|
2158
2158
|
const i = [];
|
|
2159
2159
|
for (; t; ) {
|
|
2160
2160
|
for (let n = 0; n < t.children.length; n++) {
|
|
2161
|
-
const
|
|
2162
|
-
if (
|
|
2161
|
+
const s = t.children[n], r = t.leaf ? this.toBBox(s) : s;
|
|
2162
|
+
if (ge(e, r)) {
|
|
2163
2163
|
if (t.leaf || Ee(e, r)) return !0;
|
|
2164
|
-
i.push(
|
|
2164
|
+
i.push(s);
|
|
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 = [], s = [];
|
|
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 = s.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 || !Ee(t, i) ? a ? (r++, t = a.children[r], l = !1) : t = null : (n.push(t),
|
|
2203
|
+
l || t.leaf || !Ee(t, i) ? a ? (r++, t = a.children[r], l = !1) : t = null : (n.push(t), s.push(r), r = 0, a = t, t = t.children[0]);
|
|
2204
2204
|
}
|
|
2205
2205
|
}
|
|
2206
2206
|
toBBox(e) {
|
|
@@ -2218,18 +2218,18 @@ class Pi {
|
|
|
2218
2218
|
return t;
|
|
2219
2219
|
}
|
|
2220
2220
|
_build(e, t, i, n) {
|
|
2221
|
-
const
|
|
2221
|
+
const s = 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 (s <= a) return r = Z(e.slice(t, i + 1)), q(r, this.toBBox), r;
|
|
2224
|
+
n || (n = Math.ceil(Math.log(s) / Math.log(a)), a = Math.ceil(s / Math.pow(a, n - 1))), r = Z([]), r.leaf = !1, r.height = n;
|
|
2225
|
+
const l = Math.ceil(s / a), d = l * Math.ceil(Math.sqrt(a));
|
|
2226
|
+
st(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
|
+
st(e, c, h, l, this.compareMinY);
|
|
2230
2230
|
for (let u = c; u <= h; u += l) {
|
|
2231
|
-
const
|
|
2232
|
-
r.children.push(this._build(e, u,
|
|
2231
|
+
const p = Math.min(u + l - 1, h);
|
|
2232
|
+
r.children.push(this._build(e, u, p, n - 1));
|
|
2233
2233
|
}
|
|
2234
2234
|
}
|
|
2235
2235
|
return q(r, this.toBBox), r;
|
|
@@ -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),
|
|
2242
|
-
|
|
2241
|
+
const h = t.children[c], u = Ie(h), p = (s = e, r = h, (Math.max(r.maxX, s.maxX) - Math.min(r.minX, s.minX)) * (Math.max(r.maxY, s.maxY) - Math.min(r.minY, s.minY)) - u);
|
|
2242
|
+
p < d ? (d = p, l = u < l ? u : l, a = h) : p === d && u < l && (l = u, a = h);
|
|
2243
2243
|
}
|
|
2244
2244
|
t = a || t.children[0];
|
|
2245
2245
|
}
|
|
2246
|
-
var
|
|
2246
|
+
var s, 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), s = [], r = this._chooseSubtree(n, this.data, t, s);
|
|
2251
|
+
for (r.children.push(e), se(r, n); t >= 0 && s[t].children.length > this._maxEntries; ) this._split(s, t), t--;
|
|
2252
|
+
this._adjustParentBBoxes(n, s, 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, s = this._minEntries;
|
|
2256
|
+
this._chooseSplitAxis(i, s, n);
|
|
2257
|
+
const r = this._chooseSplitIndex(i, s, 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, s = 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 < s ? (s = c, n = a, r = h < r ? h : r) : c === s && 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 : yi, s = e.leaf ? this.compareMinY : mi;
|
|
2273
|
+
this._allDistMargin(e, t, i, n) < this._allDistMargin(e, t, i, s) && e.children.sort(n);
|
|
2274
2274
|
}
|
|
2275
2275
|
_allDistMargin(e, t, i, n) {
|
|
2276
2276
|
e.children.sort(n);
|
|
2277
|
-
const
|
|
2278
|
-
let l =
|
|
2277
|
+
const s = this.toBBox, r = ne(e, 0, t, s), a = ne(e, i - t, i, s);
|
|
2278
|
+
let l = pe(r) + pe(a);
|
|
2279
2279
|
for (let d = t; d < i - t; d++) {
|
|
2280
2280
|
const c = e.children[d];
|
|
2281
|
-
|
|
2281
|
+
se(r, e.leaf ? s(c) : c), l += pe(r);
|
|
2282
2282
|
}
|
|
2283
2283
|
for (let d = i - t - 1; d >= t; d--) {
|
|
2284
2284
|
const c = e.children[d];
|
|
2285
|
-
|
|
2285
|
+
se(a, e.leaf ? s(c) : c), l += pe(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--) se(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 s = Math.min(...i), r = Math.max(...i);
|
|
2314
|
+
return { minX: Math.min(...t), minY: s, 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 s = this.toBBox(n);
|
|
2325
|
+
if (this.setMaps(n, s), i.has(String(n.id))) throw new Error(`Duplicate feature ID found ${n.id}`);
|
|
2326
|
+
i.add(String(n.id)), t.push(s);
|
|
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(o) {
|
|
2350
2350
|
const e = 16 * Math.random() | 0;
|
|
2351
|
-
return (
|
|
2352
|
-
}), isValidId: (
|
|
2351
|
+
return (o == "x" ? e : 3 & e | 8).toString(16);
|
|
2352
|
+
}), isValidId: (o) => typeof o == "string" && o.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 = [], s = [];
|
|
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 s.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 s.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 s.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) ? (s.push({ id: a, valid: !1, reason: `Feature already exists with this id: ${a}` }), !1) : (this.store[a] = r, n.push(a), s.push({ id: a, valid: !0 }), !0);
|
|
2387
|
+
}), this.spatialIndex.load(i), this._onChange(n, "create"), s;
|
|
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: s }) => {
|
|
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] = s, 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 s = this.store[i];
|
|
2421
|
+
if (!s) throw new Error(`No feature with this (${i}), can not update geometry`);
|
|
2422
|
+
s.geometry = this.clone(n), this.spatialIndex.update(s), this.tracked && (s.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 s, r = M({}, n);
|
|
2429
|
+
this.tracked && (s = +/* @__PURE__ */ new Date(), n ? (r.createdAt = typeof n.createdAt == "number" ? n.createdAt : s, r.updatedAt = typeof n.updatedAt == "number" ? n.updatedAt : s) : r = { createdAt: s, updatedAt: s });
|
|
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 = G(
|
|
2450
|
+
const Mi = "Feature is not a Polygon or LineString", wi = "Feature intersects itself", bi = (o) => o.geometry.type !== "Polygon" && o.geometry.type !== "LineString" ? { valid: !1, reason: Mi } : Le(o) ? { valid: !1, reason: wi } : { valid: !0 };
|
|
2451
|
+
function ot(o, e, t) {
|
|
2452
|
+
const i = G(o, e);
|
|
2453
2453
|
let n = G(e, t) - i;
|
|
2454
2454
|
return n < 0 && (n += 360), 180 - Math.abs(n - 90 - 90);
|
|
2455
2455
|
}
|
|
2456
|
-
class Ft extends
|
|
2456
|
+
class Ft extends B {
|
|
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 Ft 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), s = Math.max(1e-6, n);
|
|
2483
|
+
i = [t[0], [e.lng, e.lat], [e.lng, e.lat - s], 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], s = t[1], r = Mt(n, s, this.coordinatePrecision, this.project, this.unproject), a = S(n[0], n[1]), l = S(r[0], r[1]), d = S(s[0], s[1]), c = S(e.lng, e.lat), h = F(c, a) < F(c, d), u = ot(a, l, c), p = h ? 90 - u : ot(a, l, c) - 90, g = F(l, c), f = Math.cos(D(p)) * g, P = G(a, d) + (function(x, w, I) {
|
|
2486
|
+
const O = (I.x - w.x) * (x.y - w.y) - (I.y - w.y) * (x.x - w.x);
|
|
2487
|
+
return O > 1e-10 ? "left" : O < -1e-10 ? "right" : "left";
|
|
2488
|
+
}(a, d, c) === "right" ? -90 : 90), y = le(a, f, P), C = le(d, f, P), m = k(y.x, y.y), v = k(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 Ft extends N {
|
|
|
2530
2530
|
return this.validateModeFeature(e, (t) => de(t, this.coordinatePrecision));
|
|
2531
2531
|
}
|
|
2532
2532
|
}
|
|
2533
|
-
function Dt(
|
|
2534
|
-
return (e.x -
|
|
2533
|
+
function Dt(o, e, t) {
|
|
2534
|
+
return (e.x - o.x) * (t.y - o.y) - (e.y - o.y) * (t.x - o.x) <= 0;
|
|
2535
2535
|
}
|
|
2536
|
-
class
|
|
2536
|
+
class Ot extends B {
|
|
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 _t 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), s = Math.max(1e-6, n);
|
|
2564
|
+
i = [t[0], [e.lng, e.lat], [e.lng, e.lat - s], t[0]];
|
|
2565
2565
|
} else if (this.currentCoordinate === 2) {
|
|
2566
|
-
const n = t[0],
|
|
2566
|
+
const n = t[0], s = t[1], r = [e.lng, e.lat], a = S(n[0], n[1]), l = S(s[0], s[1]), d = S(r[0], r[1]);
|
|
2567
2567
|
if (this.direction === void 0) {
|
|
2568
2568
|
const m = Dt(a, l, d);
|
|
2569
2569
|
this.direction = m ? "clockwise" : "anticlockwise";
|
|
2570
2570
|
}
|
|
2571
|
-
const c = F(a, l), h = G(a, l), u = G(a, d),
|
|
2572
|
-
let
|
|
2573
|
-
this.direction === "anticlockwise" ? (
|
|
2574
|
-
const C = (this.direction === "anticlockwise" ? 1 : -1) *
|
|
2575
|
-
|
|
2576
|
-
for (let m = 0; m <=
|
|
2577
|
-
const v = le(a, c,
|
|
2578
|
-
I[0] !==
|
|
2571
|
+
const c = F(a, l), h = G(a, l), u = G(a, d), p = this.arcPoints, g = [n], f = z(h), P = z(u);
|
|
2572
|
+
let y;
|
|
2573
|
+
this.direction === "anticlockwise" ? (y = P - f, y < 0 && (y += 360)) : (y = f - P, y < 0 && (y += 360));
|
|
2574
|
+
const C = (this.direction === "anticlockwise" ? 1 : -1) * y / p;
|
|
2575
|
+
g.push(s);
|
|
2576
|
+
for (let m = 0; m <= p; m++) {
|
|
2577
|
+
const v = le(a, c, f + m * C), { lng: x, lat: w } = k(v.x, v.y), I = [E(x, this.coordinatePrecision), E(w, this.coordinatePrecision)];
|
|
2578
|
+
I[0] !== g[g.length - 1][0] && I[1] !== g[g.length - 1][1] && g.push(I);
|
|
2579
2579
|
}
|
|
2580
|
-
|
|
2580
|
+
g.push(n), i = [...g];
|
|
2581
2581
|
}
|
|
2582
2582
|
i && this.updatePolygonGeometry(this.currentId, i, b.Provisional);
|
|
2583
2583
|
}
|
|
@@ -2621,7 +2621,7 @@ class _t extends N {
|
|
|
2621
2621
|
return this.validateModeFeature(e, (t) => de(t, this.coordinatePrecision));
|
|
2622
2622
|
}
|
|
2623
2623
|
}
|
|
2624
|
-
class
|
|
2624
|
+
class _t extends B {
|
|
2625
2625
|
constructor(e) {
|
|
2626
2626
|
super(e), this.mode = "sensor", this.currentCoordinate = 0, this.currentId = void 0, this.currentInitialArcId = void 0, this.currentStartingPointId = void 0, this.keyEvents = void 0, this.direction = void 0, this.arcPoints = void 0, this.cursors = void 0, this.mouseMove = !1;
|
|
2627
2627
|
const t = { start: "crosshair", close: "pointer" };
|
|
@@ -2646,29 +2646,29 @@ 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], s = [e.lng, e.lat], r = S(n[0], n[1]), a = S(s[0], s[1]), l = S(i[0], i[1]), d = F(l, r);
|
|
2650
2650
|
if (this.direction === void 0) {
|
|
2651
2651
|
const C = Dt(l, r, a);
|
|
2652
2652
|
this.direction = C ? "clockwise" : "anticlockwise";
|
|
2653
2653
|
}
|
|
2654
|
-
const c = G(l, r), h = G(l, a), u = this.arcPoints,
|
|
2654
|
+
const c = G(l, r), h = G(l, a), u = this.arcPoints, p = [n], g = z(c), f = z(h);
|
|
2655
2655
|
let P;
|
|
2656
|
-
this.direction === "anticlockwise" ? (P =
|
|
2657
|
-
const
|
|
2656
|
+
this.direction === "anticlockwise" ? (P = f - g, P < 0 && (P += 360)) : (P = g - f, P < 0 && (P += 360));
|
|
2657
|
+
const y = (this.direction === "anticlockwise" ? 1 : -1) * P / u;
|
|
2658
2658
|
for (let C = 0; C <= u; C++) {
|
|
2659
|
-
const m = le(l, d,
|
|
2660
|
-
w[0] !==
|
|
2659
|
+
const m = le(l, d, g + C * y), { lng: v, lat: x } = k(m.x, m.y), w = [E(v, this.coordinatePrecision), E(x, this.coordinatePrecision)];
|
|
2660
|
+
w[0] !== p[p.length - 1][0] && w[1] !== p[p.length - 1][1] && p.push(w);
|
|
2661
2661
|
}
|
|
2662
|
-
this.updateLineStringGeometry(this.currentInitialArcId,
|
|
2662
|
+
this.updateLineStringGeometry(this.currentInitialArcId, p, 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], s = t[t.length - 1], r = S(e.lng, e.lat), a = S(n[0], n[1]), l = S(s[0], s[1]), d = S(i[0], i[1]), c = F(d, a), h = F(d, r) < c ? a : r, u = G(d, r), p = G(d, a), g = G(d, l), f = z(p), P = z(g), y = z(u);
|
|
2667
|
+
if (this.notInSector({ normalizedCursor: y, normalizedStart: f, normalizedEnd: P, direction: this.direction })) return;
|
|
2668
|
+
const C = this.getDeltaBearing(this.direction, f, 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
|
|
2671
|
-
|
|
2670
|
+
const O = le(d, x, f + I * v), { lng: N, lat: _ } = k(O.x, O.y), j = [E(N, this.coordinatePrecision), E(_, this.coordinatePrecision)];
|
|
2671
|
+
j[0] !== t[t.length - 1][0] && j[1] !== t[t.length - 1][1] && w.unshift(j);
|
|
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 } }]);
|
|
2674
2674
|
}
|
|
@@ -2726,7 +2726,7 @@ 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 fi();
|
|
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;
|
|
@@ -2738,8 +2738,8 @@ class Ii {
|
|
|
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
|
|
2742
|
-
const h = [], u = this._store.copyAll().filter((
|
|
2741
|
+
const s = (c) => {
|
|
2742
|
+
const h = [], u = this._store.copyAll().filter((p) => !c.includes(p.id) || (h.push(p), !1));
|
|
2743
2743
|
return { changed: h, unchanged: u };
|
|
2744
2744
|
}, r = (c, h) => {
|
|
2745
2745
|
this._enabled && this._eventListeners.finish.forEach((u) => {
|
|
@@ -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((g) => {
|
|
2751
|
+
g(c, h);
|
|
2752
2752
|
});
|
|
2753
|
-
const { changed: u, unchanged:
|
|
2754
|
-
h === "create" ? this._adapter.render({ created: u, deletedIds: [], unchanged:
|
|
2753
|
+
const { changed: u, unchanged: p } = s(c);
|
|
2754
|
+
h === "create" ? this._adapter.render({ created: u, deletedIds: [], unchanged: p, updated: [] }, this.getModeStyles()) : h === "update" ? this._adapter.render({ created: [], deletedIds: [], unchanged: p, updated: u }, this.getModeStyles()) : h === "delete" ? this._adapter.render({ created: [], deletedIds: c, unchanged: p, updated: [] }, this.getModeStyles()) : h === "styling" && this._adapter.render({ created: [], deletedIds: [], unchanged: p, updated: [] }, this.getModeStyles());
|
|
2755
2755
|
}, l = (c) => {
|
|
2756
2756
|
if (!this._enabled) return;
|
|
2757
|
-
this._eventListeners.select.forEach((
|
|
2758
|
-
|
|
2757
|
+
this._eventListeners.select.forEach((p) => {
|
|
2758
|
+
p(c);
|
|
2759
2759
|
});
|
|
2760
|
-
const { changed: h, unchanged: u } =
|
|
2760
|
+
const { changed: h, unchanged: u } = s([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
|
-
this._eventListeners.deselect.forEach((
|
|
2765
|
-
|
|
2764
|
+
this._eventListeners.deselect.forEach((p) => {
|
|
2765
|
+
p();
|
|
2766
2766
|
});
|
|
2767
|
-
const { changed: h, unchanged: u } =
|
|
2767
|
+
const { changed: h, unchanged: u } = s([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) => {
|
|
@@ -2781,9 +2781,9 @@ class Ii {
|
|
|
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, s = !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 = yt({ unproject: r, point: l, pointerDistance: n });
|
|
2785
2785
|
return this._store.search(d).filter((c) => {
|
|
2786
|
-
if (
|
|
2786
|
+
if (s && (c.properties[oe] || 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
2789
|
return F(l, u) < n;
|
|
@@ -2791,8 +2791,8 @@ class Ii {
|
|
|
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
|
|
2795
|
-
if (bt(l, a(
|
|
2794
|
+
const p = h[u], g = h[u + 1];
|
|
2795
|
+
if (bt(l, a(p[0], p[1]), a(g[0], g[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 s = n.validateFeature.bind(n)(t);
|
|
2852
|
+
return { id: t.id, valid: s.valid, reason: s.reason ? s.reason : s.valid ? void 0 : "Feature is invalid" };
|
|
2853
2853
|
}
|
|
2854
2854
|
return { id: t.id, valid: !1, reason: "Mode property does not exist" };
|
|
2855
2855
|
});
|
|
@@ -3001,7 +3001,7 @@ const Ri = [
|
|
|
3001
3001
|
outlineWidth: 2
|
|
3002
3002
|
}
|
|
3003
3003
|
}),
|
|
3004
|
-
circle: new
|
|
3004
|
+
circle: new gt({
|
|
3005
3005
|
styles: {
|
|
3006
3006
|
fillColor: "#EDEFF0",
|
|
3007
3007
|
fillOpacity: 0.7,
|
|
@@ -3009,7 +3009,7 @@ const Ri = [
|
|
|
3009
3009
|
outlineWidth: 2
|
|
3010
3010
|
}
|
|
3011
3011
|
}),
|
|
3012
|
-
freehand: new
|
|
3012
|
+
freehand: new ft({
|
|
3013
3013
|
styles: {
|
|
3014
3014
|
fillColor: "#EDEFF0",
|
|
3015
3015
|
fillOpacity: 0.7,
|
|
@@ -3021,7 +3021,7 @@ const Ri = [
|
|
|
3021
3021
|
closingPointOutlineWidth: 1
|
|
3022
3022
|
}
|
|
3023
3023
|
}),
|
|
3024
|
-
sensor: new
|
|
3024
|
+
sensor: new _t({
|
|
3025
3025
|
styles: {
|
|
3026
3026
|
fillColor: "#EDEFF0",
|
|
3027
3027
|
fillOpacity: 0.7,
|
|
@@ -3033,7 +3033,7 @@ const Ri = [
|
|
|
3033
3033
|
centerPointOutlineWidth: 1
|
|
3034
3034
|
}
|
|
3035
3035
|
}),
|
|
3036
|
-
sector: new
|
|
3036
|
+
sector: new Ot({
|
|
3037
3037
|
styles: {
|
|
3038
3038
|
fillColor: "#EDEFF0",
|
|
3039
3039
|
fillOpacity: 0.7,
|
|
@@ -3140,7 +3140,12 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3140
3140
|
"text-halo-width": 2,
|
|
3141
3141
|
"text-color": "#232E3D"
|
|
3142
3142
|
}
|
|
3143
|
-
}
|
|
3143
|
+
},
|
|
3144
|
+
computeElevation: !1,
|
|
3145
|
+
distanceUnit: "kilometers",
|
|
3146
|
+
distancePrecision: 2,
|
|
3147
|
+
areaUnit: "metric",
|
|
3148
|
+
areaPrecision: 2
|
|
3144
3149
|
}, Di = () => ({
|
|
3145
3150
|
render: new ie({
|
|
3146
3151
|
modeName: "render",
|
|
@@ -3158,11 +3163,11 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3158
3163
|
}),
|
|
3159
3164
|
rectangle: new St(),
|
|
3160
3165
|
"angled-rectangle": new Ft(),
|
|
3161
|
-
circle: new
|
|
3162
|
-
freehand: new
|
|
3163
|
-
sensor: new
|
|
3164
|
-
sector: new
|
|
3165
|
-
select: new
|
|
3166
|
+
circle: new gt(),
|
|
3167
|
+
freehand: new ft(),
|
|
3168
|
+
sensor: new _t(),
|
|
3169
|
+
sector: new Ot(),
|
|
3170
|
+
select: new gi({
|
|
3166
3171
|
flags: {
|
|
3167
3172
|
point: {
|
|
3168
3173
|
feature: {
|
|
@@ -3276,20 +3281,20 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3276
3281
|
styles: {}
|
|
3277
3282
|
})
|
|
3278
3283
|
});
|
|
3279
|
-
class
|
|
3284
|
+
class Oi {
|
|
3280
3285
|
/**
|
|
3281
3286
|
* Constructor
|
|
3282
3287
|
* @param options Plugin control options
|
|
3283
3288
|
*/
|
|
3284
3289
|
constructor(e) {
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3290
|
+
A(this, "controlContainer");
|
|
3291
|
+
A(this, "map");
|
|
3292
|
+
A(this, "modeButtons", {});
|
|
3293
|
+
A(this, "isExpanded", !1);
|
|
3294
|
+
A(this, "terradraw");
|
|
3295
|
+
A(this, "options", Ei);
|
|
3296
|
+
A(this, "events", {});
|
|
3297
|
+
A(this, "defaultMode", "render");
|
|
3293
3298
|
this.modeButtons = {}, e && (this.options = Object.assign(this.options, e));
|
|
3294
3299
|
}
|
|
3295
3300
|
/**
|
|
@@ -3305,20 +3310,20 @@ class _i {
|
|
|
3305
3310
|
* @returns HTML Element
|
|
3306
3311
|
*/
|
|
3307
3312
|
onAdd(e) {
|
|
3308
|
-
var n,
|
|
3313
|
+
var n, s, r, a, l;
|
|
3309
3314
|
if (this.options && this.options.modes && this.options.modes.length === 0)
|
|
3310
3315
|
throw new Error("At least a mode must be enabled.");
|
|
3311
3316
|
this.map = e;
|
|
3312
3317
|
const t = Di(), i = [];
|
|
3313
|
-
return (
|
|
3318
|
+
return (s = (n = this.options) == null ? void 0 : n.modes) == null || s.forEach((d) => {
|
|
3314
3319
|
if (this.options.modeOptions && this.options.modeOptions[d]) {
|
|
3315
3320
|
const c = this.options.modeOptions[d];
|
|
3316
3321
|
if (d === "select") {
|
|
3317
3322
|
const h = t[d];
|
|
3318
3323
|
if (h) {
|
|
3319
3324
|
const u = h.flags;
|
|
3320
|
-
Object.keys(u).forEach((
|
|
3321
|
-
c.flags[
|
|
3325
|
+
Object.keys(u).forEach((p) => {
|
|
3326
|
+
c.flags[p] || (c.flags[p] = u[p]);
|
|
3322
3327
|
});
|
|
3323
3328
|
}
|
|
3324
3329
|
}
|
|
@@ -3373,8 +3378,8 @@ class _i {
|
|
|
3373
3378
|
*/
|
|
3374
3379
|
dispatchEvent(e) {
|
|
3375
3380
|
this.events[e] && this.events[e].forEach((t) => {
|
|
3376
|
-
var
|
|
3377
|
-
const i = (
|
|
3381
|
+
var s, r;
|
|
3382
|
+
const i = (s = this.terradraw) == null ? void 0 : s.getSnapshot(), n = i == null ? void 0 : i.filter((a) => a.properties.selected === !0);
|
|
3378
3383
|
t({ feature: n, mode: (r = this.terradraw) == null ? void 0 : r.getMode() });
|
|
3379
3384
|
});
|
|
3380
3385
|
}
|
|
@@ -3405,8 +3410,8 @@ class _i {
|
|
|
3405
3410
|
var i, n;
|
|
3406
3411
|
if (!this.terradraw) return;
|
|
3407
3412
|
const e = document.getElementsByClassName("maplibregl-terradraw-add-control");
|
|
3408
|
-
for (let
|
|
3409
|
-
const r = e.item(
|
|
3413
|
+
for (let s = 0; s < e.length; s++) {
|
|
3414
|
+
const r = e.item(s);
|
|
3410
3415
|
r && (this.isExpanded ? r.classList.add("hidden") : r.classList.remove("hidden"));
|
|
3411
3416
|
}
|
|
3412
3417
|
const t = document.getElementsByClassName("maplibregl-terradraw-render-button");
|
|
@@ -3435,9 +3440,9 @@ class _i {
|
|
|
3435
3440
|
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", () => {
|
|
3436
3441
|
this.terradraw && this.terradraw.enabled && (this.terradraw.clear(), this.deactivate(), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.dispatchEvent("feature-deleted"));
|
|
3437
3442
|
})) : e === "delete-selection" ? (t.classList.add(`maplibregl-terradraw-${e}-button`), t.classList.add("hidden-delete-selection"), t.addEventListener("click", () => {
|
|
3438
|
-
var
|
|
3443
|
+
var s;
|
|
3439
3444
|
if (!this.terradraw || !this.terradraw.enabled) return;
|
|
3440
|
-
const n = ((
|
|
3445
|
+
const n = ((s = this.terradraw) == null ? void 0 : s.getSnapshot()).filter((r) => r.properties.selected === !0);
|
|
3441
3446
|
if (n.length > 0) {
|
|
3442
3447
|
const r = this.terradraw.getMode();
|
|
3443
3448
|
this.terradraw.setMode(this.defaultMode);
|
|
@@ -3457,11 +3462,11 @@ class _i {
|
|
|
3457
3462
|
* @returns FeatureCollection in GeoJSON format
|
|
3458
3463
|
*/
|
|
3459
3464
|
getFeatures(e = !1) {
|
|
3460
|
-
var
|
|
3465
|
+
var s;
|
|
3461
3466
|
if (!this.terradraw) return;
|
|
3462
3467
|
const n = {
|
|
3463
3468
|
type: "FeatureCollection",
|
|
3464
|
-
features: ((
|
|
3469
|
+
features: ((s = this.terradraw) == null ? void 0 : s.getSnapshot()).filter((r) => r.properties.mode !== "select")
|
|
3465
3470
|
};
|
|
3466
3471
|
return e !== !0 || (n.features = n.features.filter((r) => r.properties.selected === !0)), n;
|
|
3467
3472
|
}
|
|
@@ -3483,9 +3488,9 @@ class _i {
|
|
|
3483
3488
|
"maplibregl-terradraw-delete-button"
|
|
3484
3489
|
];
|
|
3485
3490
|
for (const n of i) {
|
|
3486
|
-
const
|
|
3487
|
-
for (let r = 0; r <
|
|
3488
|
-
const a =
|
|
3491
|
+
const s = this.controlContainer.getElementsByClassName(n);
|
|
3492
|
+
for (let r = 0; r < s.length; r++) {
|
|
3493
|
+
const a = s.item(r);
|
|
3489
3494
|
a && (a.disabled = !t);
|
|
3490
3495
|
}
|
|
3491
3496
|
}
|
|
@@ -3495,10 +3500,10 @@ class _i {
|
|
|
3495
3500
|
*/
|
|
3496
3501
|
toggleDeleteSelectionButton() {
|
|
3497
3502
|
var a, l;
|
|
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,
|
|
3503
|
+
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, s = n && e && t === "select", r = document.getElementsByClassName("maplibregl-terradraw-delete-selection-button");
|
|
3499
3504
|
for (let d = 0; d < r.length; d++) {
|
|
3500
3505
|
const c = r.item(d);
|
|
3501
|
-
c && (
|
|
3506
|
+
c && (s ? c.classList.remove("hidden-delete-selection") : c.classList.add("hidden-delete-selection"));
|
|
3502
3507
|
}
|
|
3503
3508
|
if (!n) {
|
|
3504
3509
|
const d = document.getElementsByClassName("maplibregl-terradraw-add-select-button");
|
|
@@ -3517,7 +3522,7 @@ class _i {
|
|
|
3517
3522
|
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
3518
3523
|
}
|
|
3519
3524
|
}
|
|
3520
|
-
var L = 63710088e-1,
|
|
3525
|
+
var L = 63710088e-1, _i = {
|
|
3521
3526
|
centimeters: L * 100,
|
|
3522
3527
|
centimetres: L * 100,
|
|
3523
3528
|
degrees: 360 / (2 * Math.PI),
|
|
@@ -3534,60 +3539,60 @@ var L = 63710088e-1, Oi = {
|
|
|
3534
3539
|
radians: 1,
|
|
3535
3540
|
yards: L * 1.0936
|
|
3536
3541
|
};
|
|
3537
|
-
function Li(
|
|
3542
|
+
function Li(o, e, t = {}) {
|
|
3538
3543
|
const i = { type: "Feature" };
|
|
3539
|
-
return (t.id === 0 || t.id) && (i.id = t.id), t.bbox && (i.bbox = t.bbox), i.properties = e || {}, i.geometry =
|
|
3544
|
+
return (t.id === 0 || t.id) && (i.id = t.id), t.bbox && (i.bbox = t.bbox), i.properties = e || {}, i.geometry = o, i;
|
|
3540
3545
|
}
|
|
3541
|
-
function ki(
|
|
3542
|
-
if (!
|
|
3546
|
+
function ki(o, e, t = {}) {
|
|
3547
|
+
if (!o)
|
|
3543
3548
|
throw new Error("coordinates is required");
|
|
3544
|
-
if (!Array.isArray(
|
|
3549
|
+
if (!Array.isArray(o))
|
|
3545
3550
|
throw new Error("coordinates must be an Array");
|
|
3546
|
-
if (
|
|
3551
|
+
if (o.length < 2)
|
|
3547
3552
|
throw new Error("coordinates must be at least 2 numbers long");
|
|
3548
|
-
if (!rt(
|
|
3553
|
+
if (!rt(o[0]) || !rt(o[1]))
|
|
3549
3554
|
throw new Error("coordinates must contain numbers");
|
|
3550
3555
|
return Li({
|
|
3551
3556
|
type: "Point",
|
|
3552
|
-
coordinates:
|
|
3557
|
+
coordinates: o
|
|
3553
3558
|
}, e, t);
|
|
3554
3559
|
}
|
|
3555
|
-
function Wi(
|
|
3556
|
-
const t =
|
|
3560
|
+
function Wi(o, e = "kilometers") {
|
|
3561
|
+
const t = _i[e];
|
|
3557
3562
|
if (!t)
|
|
3558
3563
|
throw new Error(e + " units is invalid");
|
|
3559
|
-
return
|
|
3564
|
+
return o * t;
|
|
3560
3565
|
}
|
|
3561
|
-
function
|
|
3562
|
-
return
|
|
3566
|
+
function fe(o) {
|
|
3567
|
+
return o % 360 * Math.PI / 180;
|
|
3563
3568
|
}
|
|
3564
|
-
function rt(
|
|
3565
|
-
return !isNaN(
|
|
3569
|
+
function rt(o) {
|
|
3570
|
+
return !isNaN(o) && o !== null && !Array.isArray(o);
|
|
3566
3571
|
}
|
|
3567
|
-
function at(
|
|
3568
|
-
if (!
|
|
3572
|
+
function at(o) {
|
|
3573
|
+
if (!o)
|
|
3569
3574
|
throw new Error("coord is required");
|
|
3570
|
-
if (!Array.isArray(
|
|
3571
|
-
if (
|
|
3572
|
-
return [...
|
|
3573
|
-
if (
|
|
3574
|
-
return [...
|
|
3575
|
-
}
|
|
3576
|
-
if (Array.isArray(
|
|
3577
|
-
return [...
|
|
3575
|
+
if (!Array.isArray(o)) {
|
|
3576
|
+
if (o.type === "Feature" && o.geometry !== null && o.geometry.type === "Point")
|
|
3577
|
+
return [...o.geometry.coordinates];
|
|
3578
|
+
if (o.type === "Point")
|
|
3579
|
+
return [...o.coordinates];
|
|
3580
|
+
}
|
|
3581
|
+
if (Array.isArray(o) && o.length >= 2 && !Array.isArray(o[0]) && !Array.isArray(o[1]))
|
|
3582
|
+
return [...o];
|
|
3578
3583
|
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
3579
3584
|
}
|
|
3580
|
-
function ji(
|
|
3581
|
-
var i = at(
|
|
3585
|
+
function ji(o, e, t = {}) {
|
|
3586
|
+
var i = at(o), n = at(e), s = fe(n[1] - i[1]), r = fe(n[0] - i[0]), a = fe(i[1]), l = fe(n[1]), d = Math.pow(Math.sin(s / 2), 2) + Math.pow(Math.sin(r / 2), 2) * Math.cos(a) * Math.cos(l);
|
|
3582
3587
|
return Wi(
|
|
3583
3588
|
2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
|
|
3584
3589
|
t.units
|
|
3585
3590
|
);
|
|
3586
3591
|
}
|
|
3587
|
-
function Lt(
|
|
3588
|
-
if (
|
|
3589
|
-
for (var i, n,
|
|
3590
|
-
d =
|
|
3592
|
+
function Lt(o, e, t) {
|
|
3593
|
+
if (o !== null)
|
|
3594
|
+
for (var i, n, s, r, a, l, d, c = 0, h = 0, u, p = o.type, g = p === "FeatureCollection", f = p === "Feature", P = g ? o.features.length : 1, y = 0; y < P; y++) {
|
|
3595
|
+
d = g ? o.features[y].geometry : f ? o.geometry : o, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
|
|
3591
3596
|
for (var C = 0; C < a; C++) {
|
|
3592
3597
|
var m = 0, v = 0;
|
|
3593
3598
|
if (r = u ? d.geometries[C] : d, r !== null) {
|
|
@@ -3600,7 +3605,7 @@ function Lt(s, e, t) {
|
|
|
3600
3605
|
if (e(
|
|
3601
3606
|
l,
|
|
3602
3607
|
h,
|
|
3603
|
-
|
|
3608
|
+
y,
|
|
3604
3609
|
m,
|
|
3605
3610
|
v
|
|
3606
3611
|
) === !1)
|
|
@@ -3613,7 +3618,7 @@ function Lt(s, e, t) {
|
|
|
3613
3618
|
if (e(
|
|
3614
3619
|
l[i],
|
|
3615
3620
|
h,
|
|
3616
|
-
|
|
3621
|
+
y,
|
|
3617
3622
|
m,
|
|
3618
3623
|
v
|
|
3619
3624
|
) === !1)
|
|
@@ -3629,7 +3634,7 @@ function Lt(s, e, t) {
|
|
|
3629
3634
|
if (e(
|
|
3630
3635
|
l[i][n],
|
|
3631
3636
|
h,
|
|
3632
|
-
|
|
3637
|
+
y,
|
|
3633
3638
|
m,
|
|
3634
3639
|
v
|
|
3635
3640
|
) === !1)
|
|
@@ -3643,11 +3648,11 @@ function Lt(s, e, t) {
|
|
|
3643
3648
|
case "MultiPolygon":
|
|
3644
3649
|
for (i = 0; i < l.length; i++) {
|
|
3645
3650
|
for (v = 0, n = 0; n < l[i].length; n++) {
|
|
3646
|
-
for (
|
|
3651
|
+
for (s = 0; s < l[i][n].length - c; s++) {
|
|
3647
3652
|
if (e(
|
|
3648
|
-
l[i][n][
|
|
3653
|
+
l[i][n][s],
|
|
3649
3654
|
h,
|
|
3650
|
-
|
|
3655
|
+
y,
|
|
3651
3656
|
m,
|
|
3652
3657
|
v
|
|
3653
3658
|
) === !1)
|
|
@@ -3671,11 +3676,11 @@ function Lt(s, e, t) {
|
|
|
3671
3676
|
}
|
|
3672
3677
|
}
|
|
3673
3678
|
}
|
|
3674
|
-
function Bi(
|
|
3675
|
-
var t, i, n,
|
|
3676
|
-
for (t = 0; t <
|
|
3677
|
-
for (a =
|
|
3678
|
-
if (
|
|
3679
|
+
function Bi(o, e) {
|
|
3680
|
+
var t, i, n, s, r, a, l, d, c, h, u = 0, p = o.type === "FeatureCollection", g = o.type === "Feature", f = p ? o.features.length : 1;
|
|
3681
|
+
for (t = 0; t < f; t++) {
|
|
3682
|
+
for (a = p ? o.features[t].geometry : g ? o.geometry : o, d = p ? o.features[t].properties : g ? o.properties : {}, c = p ? o.features[t].bbox : g ? o.bbox : void 0, h = p ? o.features[t].id : g ? o.id : void 0, l = a ? a.type === "GeometryCollection" : !1, r = l ? a.geometries.length : 1, n = 0; n < r; n++) {
|
|
3683
|
+
if (s = l ? a.geometries[n] : a, s === null) {
|
|
3679
3684
|
if (e(
|
|
3680
3685
|
null,
|
|
3681
3686
|
u,
|
|
@@ -3686,7 +3691,7 @@ function Bi(s, e) {
|
|
|
3686
3691
|
return !1;
|
|
3687
3692
|
continue;
|
|
3688
3693
|
}
|
|
3689
|
-
switch (
|
|
3694
|
+
switch (s.type) {
|
|
3690
3695
|
case "Point":
|
|
3691
3696
|
case "LineString":
|
|
3692
3697
|
case "MultiPoint":
|
|
@@ -3694,7 +3699,7 @@ function Bi(s, e) {
|
|
|
3694
3699
|
case "MultiLineString":
|
|
3695
3700
|
case "MultiPolygon": {
|
|
3696
3701
|
if (e(
|
|
3697
|
-
|
|
3702
|
+
s,
|
|
3698
3703
|
u,
|
|
3699
3704
|
d,
|
|
3700
3705
|
c,
|
|
@@ -3704,9 +3709,9 @@ function Bi(s, e) {
|
|
|
3704
3709
|
break;
|
|
3705
3710
|
}
|
|
3706
3711
|
case "GeometryCollection": {
|
|
3707
|
-
for (i = 0; i <
|
|
3712
|
+
for (i = 0; i < s.geometries.length; i++)
|
|
3708
3713
|
if (e(
|
|
3709
|
-
|
|
3714
|
+
s.geometries[i],
|
|
3710
3715
|
u,
|
|
3711
3716
|
d,
|
|
3712
3717
|
c,
|
|
@@ -3722,15 +3727,15 @@ function Bi(s, e) {
|
|
|
3722
3727
|
u++;
|
|
3723
3728
|
}
|
|
3724
3729
|
}
|
|
3725
|
-
function Ni(
|
|
3730
|
+
function Ni(o, e, t) {
|
|
3726
3731
|
var i = t;
|
|
3727
3732
|
return Bi(
|
|
3728
|
-
|
|
3729
|
-
function(n,
|
|
3730
|
-
|
|
3733
|
+
o,
|
|
3734
|
+
function(n, s, r, a, l) {
|
|
3735
|
+
s === 0 && t === void 0 ? i = n : i = e(
|
|
3731
3736
|
i,
|
|
3732
3737
|
n,
|
|
3733
|
-
|
|
3738
|
+
s,
|
|
3734
3739
|
r,
|
|
3735
3740
|
a,
|
|
3736
3741
|
l
|
|
@@ -3738,21 +3743,21 @@ function Ni(s, e, t) {
|
|
|
3738
3743
|
}
|
|
3739
3744
|
), i;
|
|
3740
3745
|
}
|
|
3741
|
-
function Ai(
|
|
3746
|
+
function Ai(o) {
|
|
3742
3747
|
return Ni(
|
|
3743
|
-
|
|
3748
|
+
o,
|
|
3744
3749
|
(e, t) => e + Gi(t),
|
|
3745
3750
|
0
|
|
3746
3751
|
);
|
|
3747
3752
|
}
|
|
3748
|
-
function Gi(
|
|
3753
|
+
function Gi(o) {
|
|
3749
3754
|
let e = 0, t;
|
|
3750
|
-
switch (
|
|
3755
|
+
switch (o.type) {
|
|
3751
3756
|
case "Polygon":
|
|
3752
|
-
return lt(
|
|
3757
|
+
return lt(o.coordinates);
|
|
3753
3758
|
case "MultiPolygon":
|
|
3754
|
-
for (t = 0; t <
|
|
3755
|
-
e += lt(
|
|
3759
|
+
for (t = 0; t < o.coordinates.length; t++)
|
|
3760
|
+
e += lt(o.coordinates[t]);
|
|
3756
3761
|
return e;
|
|
3757
3762
|
case "Point":
|
|
3758
3763
|
case "MultiPoint":
|
|
@@ -3762,36 +3767,36 @@ function Gi(s) {
|
|
|
3762
3767
|
}
|
|
3763
3768
|
return 0;
|
|
3764
3769
|
}
|
|
3765
|
-
function lt(
|
|
3770
|
+
function lt(o) {
|
|
3766
3771
|
let e = 0;
|
|
3767
|
-
if (
|
|
3768
|
-
e += Math.abs(dt(
|
|
3769
|
-
for (let t = 1; t <
|
|
3770
|
-
e -= Math.abs(dt(
|
|
3772
|
+
if (o && o.length > 0) {
|
|
3773
|
+
e += Math.abs(dt(o[0]));
|
|
3774
|
+
for (let t = 1; t < o.length; t++)
|
|
3775
|
+
e -= Math.abs(dt(o[t]));
|
|
3771
3776
|
}
|
|
3772
3777
|
return e;
|
|
3773
3778
|
}
|
|
3774
3779
|
var Vi = L * L / 2, Fe = Math.PI / 180;
|
|
3775
|
-
function dt(
|
|
3776
|
-
const e =
|
|
3780
|
+
function dt(o) {
|
|
3781
|
+
const e = o.length - 1;
|
|
3777
3782
|
if (e <= 2) return 0;
|
|
3778
3783
|
let t = 0, i = 0;
|
|
3779
3784
|
for (; i < e; ) {
|
|
3780
|
-
const n =
|
|
3785
|
+
const n = o[i], s = o[i + 1 === e ? 0 : i + 1], r = o[i + 2 >= e ? (i + 2) % e : i + 2], a = n[0] * Fe, l = s[1] * Fe, d = r[0] * Fe;
|
|
3781
3786
|
t += (d - a) * Math.sin(l), i++;
|
|
3782
3787
|
}
|
|
3783
3788
|
return t * Vi;
|
|
3784
3789
|
}
|
|
3785
|
-
function
|
|
3790
|
+
function Ui(o, e = {}) {
|
|
3786
3791
|
let t = 0, i = 0, n = 0;
|
|
3787
3792
|
return Lt(
|
|
3788
|
-
|
|
3789
|
-
function(
|
|
3790
|
-
t +=
|
|
3793
|
+
o,
|
|
3794
|
+
function(s) {
|
|
3795
|
+
t += s[0], i += s[1], n++;
|
|
3791
3796
|
}
|
|
3792
3797
|
), ki([t / n, i / n], e.properties);
|
|
3793
3798
|
}
|
|
3794
|
-
class zi extends
|
|
3799
|
+
class zi extends Oi {
|
|
3795
3800
|
/**
|
|
3796
3801
|
* Constructor
|
|
3797
3802
|
* @param options Plugin control options
|
|
@@ -3804,21 +3809,60 @@ class zi extends _i {
|
|
|
3804
3809
|
open: i.open,
|
|
3805
3810
|
modeOptions: i.modeOptions
|
|
3806
3811
|
});
|
|
3807
|
-
|
|
3808
|
-
k(this, "lineLayerNodeSpec");
|
|
3809
|
-
k(this, "polygonLayerSpec");
|
|
3810
|
-
k(this, "computeElevation");
|
|
3812
|
+
A(this, "measureOptions");
|
|
3811
3813
|
/**
|
|
3812
3814
|
* Calculate area / distance and update a feature properties
|
|
3813
3815
|
* @param feature GeoJSON feature
|
|
3814
3816
|
* @returns updated GeoJSON feature
|
|
3815
3817
|
*/
|
|
3816
|
-
|
|
3818
|
+
A(this, "updateFeatureProperties", (t) => {
|
|
3817
3819
|
if (!this.map || !this.map.loaded()) return t;
|
|
3818
3820
|
const i = t.geometry.type;
|
|
3819
3821
|
return i === "LineString" ? t = this.calcDistance(t) : i === "Polygon" && (t = this.calcArea(t)), t;
|
|
3820
3822
|
});
|
|
3821
|
-
this.
|
|
3823
|
+
this.measureOptions = i;
|
|
3824
|
+
}
|
|
3825
|
+
/**
|
|
3826
|
+
* The unit of distance can be degrees, radians, miles, or kilometers (default 'kilometers')
|
|
3827
|
+
* The measuring result will be recalculated once new value is set
|
|
3828
|
+
*/
|
|
3829
|
+
get distanceUnit() {
|
|
3830
|
+
return this.measureOptions.distanceUnit ?? "kilometers";
|
|
3831
|
+
}
|
|
3832
|
+
set distanceUnit(t) {
|
|
3833
|
+
const i = this.measureOptions.distanceUnit === t;
|
|
3834
|
+
this.measureOptions.distanceUnit = t, this.measureOptions.distanceUnit === "degrees" ? this.distancePrecision = 6 : this.distancePrecision = 2, i || this.recalc();
|
|
3835
|
+
}
|
|
3836
|
+
/**
|
|
3837
|
+
* The precision of distance value. It will be set different value dwhen distance unit is changed. Using setter to override the value if you want.
|
|
3838
|
+
*/
|
|
3839
|
+
get distancePrecision() {
|
|
3840
|
+
return this.measureOptions.distancePrecision ?? 2;
|
|
3841
|
+
}
|
|
3842
|
+
set distancePrecision(t) {
|
|
3843
|
+
const i = this.measureOptions.distancePrecision === t;
|
|
3844
|
+
this.measureOptions.distancePrecision = t, i || this.recalc();
|
|
3845
|
+
}
|
|
3846
|
+
/**
|
|
3847
|
+
* The unit of area can be metric (m², ha, km²) or imperial (yd², acre, mi²). Default is metric.
|
|
3848
|
+
* The measuring result will be recalculated once new value is set
|
|
3849
|
+
*/
|
|
3850
|
+
get areaUnit() {
|
|
3851
|
+
return this.measureOptions.areaUnit ?? "metric";
|
|
3852
|
+
}
|
|
3853
|
+
set areaUnit(t) {
|
|
3854
|
+
const i = this.measureOptions.areaUnit === t;
|
|
3855
|
+
this.measureOptions.areaUnit = t, i || this.recalc();
|
|
3856
|
+
}
|
|
3857
|
+
/**
|
|
3858
|
+
* The precision of area value. Using setter to override the value if you want.
|
|
3859
|
+
*/
|
|
3860
|
+
get areaPrecision() {
|
|
3861
|
+
return this.measureOptions.areaPrecision ?? 2;
|
|
3862
|
+
}
|
|
3863
|
+
set areaPrecision(t) {
|
|
3864
|
+
const i = this.measureOptions.areaPrecision === t;
|
|
3865
|
+
this.measureOptions.areaPrecision = t, i || this.recalc();
|
|
3822
3866
|
}
|
|
3823
3867
|
/**
|
|
3824
3868
|
* add the plugin control to maplibre
|
|
@@ -3860,8 +3904,8 @@ class zi extends _i {
|
|
|
3860
3904
|
this.registerMesureControl();
|
|
3861
3905
|
const i = t.getSnapshot();
|
|
3862
3906
|
for (const n of i) {
|
|
3863
|
-
const
|
|
3864
|
-
a === "linestring" && r === "LineString" ? this.measureLine(
|
|
3907
|
+
const s = n.id, r = n.geometry.type, a = n.properties.mode;
|
|
3908
|
+
a === "linestring" && r === "LineString" ? this.measureLine(s) : !["point", "linestring", "select", "render"].includes(a) && r === "Polygon" && this.measurePolygon(s);
|
|
3865
3909
|
}
|
|
3866
3910
|
}
|
|
3867
3911
|
}
|
|
@@ -3869,14 +3913,19 @@ class zi extends _i {
|
|
|
3869
3913
|
* Register measure control related maplibre sources and layers
|
|
3870
3914
|
*/
|
|
3871
3915
|
registerMesureControl() {
|
|
3872
|
-
var n,
|
|
3916
|
+
var n, s;
|
|
3873
3917
|
if (!this.map) return;
|
|
3874
3918
|
const t = (n = this.options.modes) == null ? void 0 : n.filter((r) => ["linestring"].includes(r));
|
|
3875
|
-
t && t.length > 0 && (this.map.getSource(
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3919
|
+
t && t.length > 0 && (this.map.getSource(
|
|
3920
|
+
this.measureOptions.lineLayerLabelSpec.source
|
|
3921
|
+
) || this.map.addSource(
|
|
3922
|
+
this.measureOptions.lineLayerLabelSpec.source,
|
|
3923
|
+
{
|
|
3924
|
+
type: "geojson",
|
|
3925
|
+
data: { type: "FeatureCollection", features: [] }
|
|
3926
|
+
}
|
|
3927
|
+
), this.map.getLayer(this.measureOptions.lineLayerNodeSpec.id) || this.map.addLayer(this.measureOptions.lineLayerNodeSpec), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) || this.map.addLayer(this.measureOptions.lineLayerLabelSpec));
|
|
3928
|
+
const i = (s = this.options.modes) == null ? void 0 : s.filter(
|
|
3880
3929
|
(r) => [
|
|
3881
3930
|
"polygon",
|
|
3882
3931
|
"rectangle",
|
|
@@ -3887,10 +3936,15 @@ class zi extends _i {
|
|
|
3887
3936
|
"freehand"
|
|
3888
3937
|
].includes(r)
|
|
3889
3938
|
);
|
|
3890
|
-
if (i && i.length > 0 && (this.map.getSource(
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3939
|
+
if (i && i.length > 0 && (this.map.getSource(
|
|
3940
|
+
this.measureOptions.polygonLayerSpec.source
|
|
3941
|
+
) || this.map.addSource(
|
|
3942
|
+
this.measureOptions.polygonLayerSpec.source,
|
|
3943
|
+
{
|
|
3944
|
+
type: "geojson",
|
|
3945
|
+
data: { type: "FeatureCollection", features: [] }
|
|
3946
|
+
}
|
|
3947
|
+
), this.map.getLayer(this.measureOptions.polygonLayerSpec.id) || this.map.addLayer(this.measureOptions.polygonLayerSpec)), t && t.length > 0 || i && i.length > 0) {
|
|
3894
3948
|
const r = this.getTerraDrawInstance();
|
|
3895
3949
|
r && (r.on("change", this.handleTerradrawFeatureChanged.bind(this)), this.on("feature-deleted", this.onFeatureDeleted.bind(this)));
|
|
3896
3950
|
}
|
|
@@ -3904,20 +3958,35 @@ class zi extends _i {
|
|
|
3904
3958
|
const i = this.getTerraDrawInstance();
|
|
3905
3959
|
if (!i) return;
|
|
3906
3960
|
const n = i.getSnapshot();
|
|
3907
|
-
for (const
|
|
3908
|
-
const r = n.find((a) => a.id ===
|
|
3961
|
+
for (const s of t) {
|
|
3962
|
+
const r = n.find((a) => a.id === s);
|
|
3909
3963
|
if (r) {
|
|
3910
3964
|
const a = r.geometry.type, l = r.properties.mode;
|
|
3911
|
-
l === "linestring" && a === "LineString" ? this.measureLine(
|
|
3965
|
+
l === "linestring" && a === "LineString" ? this.measureLine(s) : !["point", "linestring", "select", "render"].includes(l) && a === "Polygon" && this.measurePolygon(s);
|
|
3912
3966
|
} else
|
|
3913
|
-
this.clearMeasureFeatures(
|
|
3967
|
+
this.clearMeasureFeatures(
|
|
3968
|
+
s,
|
|
3969
|
+
this.measureOptions.lineLayerNodeSpec.source
|
|
3970
|
+
), this.clearMeasureFeatures(
|
|
3971
|
+
s,
|
|
3972
|
+
this.measureOptions.lineLayerLabelSpec.source
|
|
3973
|
+
), this.clearMeasureFeatures(
|
|
3974
|
+
s,
|
|
3975
|
+
this.measureOptions.polygonLayerSpec.source
|
|
3976
|
+
);
|
|
3914
3977
|
}
|
|
3915
3978
|
}
|
|
3916
3979
|
/**
|
|
3917
3980
|
* Unregister measure control related maplibre sources and layers
|
|
3918
3981
|
*/
|
|
3919
3982
|
unregisterMesureControl() {
|
|
3920
|
-
this.off("feature-deleted", this.onFeatureDeleted.bind(this)), this.map && (this.map.getLayer(this.lineLayerLabelSpec.id) && this.map.removeLayer(this.lineLayerLabelSpec.id), this.map.getLayer(this.lineLayerNodeSpec.id) && this.map.removeLayer(this.lineLayerNodeSpec.id), this.map.getLayer(this.polygonLayerSpec.id) && this.map.removeLayer(this.polygonLayerSpec.id), this.map.getSource(
|
|
3983
|
+
this.off("feature-deleted", this.onFeatureDeleted.bind(this)), this.map && (this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && this.map.removeLayer(this.measureOptions.lineLayerLabelSpec.id), this.map.getLayer(this.measureOptions.lineLayerNodeSpec.id) && this.map.removeLayer(this.measureOptions.lineLayerNodeSpec.id), this.map.getLayer(this.measureOptions.polygonLayerSpec.id) && this.map.removeLayer(this.measureOptions.polygonLayerSpec.id), this.map.getSource(
|
|
3984
|
+
this.measureOptions.lineLayerLabelSpec.source
|
|
3985
|
+
) && this.map.removeSource(
|
|
3986
|
+
this.measureOptions.lineLayerLabelSpec.source
|
|
3987
|
+
), this.map.getSource(this.measureOptions.polygonLayerSpec.source) && this.map.removeSource(
|
|
3988
|
+
this.measureOptions.polygonLayerSpec.source
|
|
3989
|
+
));
|
|
3921
3990
|
}
|
|
3922
3991
|
/**
|
|
3923
3992
|
* Clear GeoJSON feature related to measure control by TerraDraw feature ID
|
|
@@ -3926,7 +3995,7 @@ class zi extends _i {
|
|
|
3926
3995
|
* @returns void
|
|
3927
3996
|
*/
|
|
3928
3997
|
clearMeasureFeatures(t, i) {
|
|
3929
|
-
var
|
|
3998
|
+
var s;
|
|
3930
3999
|
if (!this.map) return;
|
|
3931
4000
|
const n = this.map.getStyle().sources[i];
|
|
3932
4001
|
n && typeof n.data != "string" && n.data.type === "FeatureCollection" && (n.data.features = n.data.features.filter(
|
|
@@ -3934,7 +4003,7 @@ class zi extends _i {
|
|
|
3934
4003
|
var a;
|
|
3935
4004
|
return ((a = r.properties) == null ? void 0 : a.originalId) !== t;
|
|
3936
4005
|
}
|
|
3937
|
-
), (
|
|
4006
|
+
), (s = this.map.getSource(i)) == null || s.setData(n.data));
|
|
3938
4007
|
}
|
|
3939
4008
|
/**
|
|
3940
4009
|
* Calculate area from polygon feature
|
|
@@ -3944,8 +4013,16 @@ class zi extends _i {
|
|
|
3944
4013
|
calcArea(t) {
|
|
3945
4014
|
if (t.geometry.type !== "Polygon") return t;
|
|
3946
4015
|
const i = Ai(t.geometry);
|
|
3947
|
-
let n = i,
|
|
3948
|
-
return i
|
|
4016
|
+
let n = i, s = "m²";
|
|
4017
|
+
return this.areaUnit === "metric" ? i >= 1e6 ? (n = i / 1e6, s = "km²") : i >= 1e4 && (n = i / 1e4, s = "ha") : i >= 258998811e-2 ? (n = i / 258998811e-2, s = "mi²") : i >= 4046.856 ? (n = i / 4046.856, s = "acre") : i >= 0.83612736 && (n = i / 0.83612736, s = "yd²"), n = parseFloat(n.toFixed(this.areaPrecision)), t.properties.area = n, t.properties.unit = s, t;
|
|
4018
|
+
}
|
|
4019
|
+
/**
|
|
4020
|
+
* Get the equivalent unit name for displaying
|
|
4021
|
+
* @param distanceUnit distance unit
|
|
4022
|
+
* @returns Unit name for displaying
|
|
4023
|
+
*/
|
|
4024
|
+
getDistanceUnitName(t) {
|
|
4025
|
+
return t === "degrees" ? "°" : t === "miles" ? "mi" : t === "radians" ? "rad" : "km";
|
|
3949
4026
|
}
|
|
3950
4027
|
/**
|
|
3951
4028
|
* Caclulate distance for each segment on a given feature
|
|
@@ -3957,20 +4034,20 @@ class zi extends _i {
|
|
|
3957
4034
|
if (t.geometry.type !== "LineString") return t;
|
|
3958
4035
|
const i = t.geometry.coordinates;
|
|
3959
4036
|
let n = 0;
|
|
3960
|
-
const
|
|
4037
|
+
const s = [];
|
|
3961
4038
|
for (let l = 0; l < i.length - 1; l++) {
|
|
3962
|
-
const d = i[l], c = i[l + 1], h = ji(d, c, { units:
|
|
4039
|
+
const d = i[l], c = i[l + 1], h = ji(d, c, { units: this.distanceUnit });
|
|
3963
4040
|
n += h;
|
|
3964
4041
|
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(
|
|
3966
|
-
const
|
|
3967
|
-
|
|
3968
|
-
const
|
|
3969
|
-
|
|
4042
|
+
if (u.id = `${u.id}-${l}`, u.geometry.coordinates = [d, c], u.properties.originalId = t.id, u.properties.distance = parseFloat(h.toFixed(this.distancePrecision)), u.properties.total = parseFloat(n.toFixed(this.distancePrecision)), u.properties.unit = this.getDistanceUnitName(this.distanceUnit), this.measureOptions.computeElevation === !0) {
|
|
4043
|
+
const p = (r = this.map) == null ? void 0 : r.queryTerrainElevation(d);
|
|
4044
|
+
p && (u.properties.elevation_start = p);
|
|
4045
|
+
const g = (a = this.map) == null ? void 0 : a.queryTerrainElevation(c);
|
|
4046
|
+
g && (u.properties.elevation_end = g);
|
|
3970
4047
|
}
|
|
3971
|
-
|
|
4048
|
+
s.push(u);
|
|
3972
4049
|
}
|
|
3973
|
-
return t.properties.distance =
|
|
4050
|
+
return t.properties.distance = s[s.length - 1].properties.total, t.properties.unit = s[s.length - 1].properties.unit, t.properties.segments = JSON.parse(JSON.stringify(s)), t;
|
|
3974
4051
|
}
|
|
3975
4052
|
/**
|
|
3976
4053
|
* measure polygon area for given feature ID
|
|
@@ -3982,9 +4059,9 @@ class zi extends _i {
|
|
|
3982
4059
|
const i = this.getTerraDrawInstance();
|
|
3983
4060
|
if (!i) return;
|
|
3984
4061
|
const n = i.getSnapshot();
|
|
3985
|
-
let
|
|
3986
|
-
if (
|
|
3987
|
-
const a = this.map.getStyle().sources[this.polygonLayerSpec.source];
|
|
4062
|
+
let s = n == null ? void 0 : n.find((a) => a.id === t && a.geometry.type === "Polygon");
|
|
4063
|
+
if (s) {
|
|
4064
|
+
const a = this.map.getStyle().sources[this.measureOptions.polygonLayerSpec.source];
|
|
3988
4065
|
if (a) {
|
|
3989
4066
|
typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
|
|
3990
4067
|
(d) => {
|
|
@@ -3992,10 +4069,14 @@ class zi extends _i {
|
|
|
3992
4069
|
return ((c = d.properties) == null ? void 0 : c.originalId) !== t;
|
|
3993
4070
|
}
|
|
3994
4071
|
));
|
|
3995
|
-
const l = JSON.parse(JSON.stringify(
|
|
3996
|
-
l.id = l.id + "-area-label", l.geometry =
|
|
3997
|
-
|
|
3998
|
-
)
|
|
4072
|
+
const l = JSON.parse(JSON.stringify(s));
|
|
4073
|
+
l.id = l.id + "-area-label", l.geometry = Ui(s.geometry).geometry, l.properties.originalId = s.id, s = this.calcArea(s), l.properties.area = s.properties.area, l.properties.unit = s.properties.unit, typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(l), (r = this.map.getSource(
|
|
4074
|
+
this.measureOptions.polygonLayerSpec.source
|
|
4075
|
+
)) == null || r.setData(a.data), this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && this.map.moveLayer(
|
|
4076
|
+
this.measureOptions.lineLayerLabelSpec.id
|
|
4077
|
+
), this.map.getLayer(this.measureOptions.lineLayerNodeSpec.id) && this.map.moveLayer(
|
|
4078
|
+
this.measureOptions.lineLayerNodeSpec.id
|
|
4079
|
+
);
|
|
3999
4080
|
}
|
|
4000
4081
|
}
|
|
4001
4082
|
}
|
|
@@ -4009,37 +4090,37 @@ class zi extends _i {
|
|
|
4009
4090
|
const i = this.getTerraDrawInstance();
|
|
4010
4091
|
if (!i) return;
|
|
4011
4092
|
const n = i.getSnapshot();
|
|
4012
|
-
let
|
|
4013
|
-
if (
|
|
4014
|
-
const a = this.map.getStyle().sources[this.lineLayerLabelSpec.source];
|
|
4093
|
+
let s = n == null ? void 0 : n.find((a) => a.id === t && a.geometry.type === "LineString");
|
|
4094
|
+
if (s) {
|
|
4095
|
+
const a = this.map.getStyle().sources[this.measureOptions.lineLayerLabelSpec.source];
|
|
4015
4096
|
if (a) {
|
|
4016
4097
|
typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
|
|
4017
4098
|
(d) => {
|
|
4018
4099
|
var c;
|
|
4019
4100
|
return ((c = d.properties) == null ? void 0 : c.originalId) !== t;
|
|
4020
4101
|
}
|
|
4021
|
-
)),
|
|
4022
|
-
const l =
|
|
4102
|
+
)), s = this.calcDistance(s);
|
|
4103
|
+
const l = s.properties.segments;
|
|
4023
4104
|
for (let d = 0; d < l.length; d++) {
|
|
4024
4105
|
const c = l[d];
|
|
4025
4106
|
typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(c);
|
|
4026
|
-
const h = c.geometry.coordinates, u = h[0],
|
|
4107
|
+
const h = c.geometry.coordinates, u = h[0], p = h[1];
|
|
4027
4108
|
if (d === 0) {
|
|
4028
|
-
const
|
|
4029
|
-
|
|
4109
|
+
const f = JSON.parse(JSON.stringify(c));
|
|
4110
|
+
f.id = `${c.id}-node-${d}`, f.geometry = {
|
|
4030
4111
|
type: "Point",
|
|
4031
4112
|
coordinates: u
|
|
4032
|
-
},
|
|
4113
|
+
}, f.properties.distance = 0, f.properties.total = 0, c.properties.elevation_start && (f.properties.elevation = c.properties.elevation_start), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(f);
|
|
4033
4114
|
}
|
|
4034
|
-
const
|
|
4035
|
-
|
|
4115
|
+
const g = JSON.parse(JSON.stringify(c));
|
|
4116
|
+
g.id = `${c.id}-node-${d + 1}`, g.geometry = {
|
|
4036
4117
|
type: "Point",
|
|
4037
|
-
coordinates:
|
|
4038
|
-
}, c.properties.elevation_end && (
|
|
4118
|
+
coordinates: p
|
|
4119
|
+
}, c.properties.elevation_end && (g.properties.elevation = c.properties.elevation_end), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(g);
|
|
4039
4120
|
}
|
|
4040
|
-
(r = this.map.getSource(
|
|
4041
|
-
|
|
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);
|
|
4121
|
+
(r = this.map.getSource(
|
|
4122
|
+
this.measureOptions.lineLayerLabelSpec.source
|
|
4123
|
+
)) == null || r.setData(a.data), this.map.getLayer(this.measureOptions.polygonLayerSpec.id) && this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.moveLayer(this.measureOptions.lineLayerLabelSpec.id), this.map.moveLayer(this.measureOptions.lineLayerNodeSpec.id);
|
|
4043
4124
|
}
|
|
4044
4125
|
}
|
|
4045
4126
|
}
|
|
@@ -4051,8 +4132,11 @@ class zi extends _i {
|
|
|
4051
4132
|
if (!this.map) return;
|
|
4052
4133
|
const t = this.getTerraDrawInstance();
|
|
4053
4134
|
if (t) {
|
|
4054
|
-
const
|
|
4055
|
-
|
|
4135
|
+
const s = [
|
|
4136
|
+
this.measureOptions.lineLayerLabelSpec.source,
|
|
4137
|
+
this.measureOptions.polygonLayerSpec.source
|
|
4138
|
+
];
|
|
4139
|
+
for (const r of s) {
|
|
4056
4140
|
const a = this.map.getStyle().sources[r];
|
|
4057
4141
|
if (a) {
|
|
4058
4142
|
const l = t.getSnapshot(), c = (l == null ? void 0 : l.filter(
|
|
@@ -4063,11 +4147,23 @@ class zi extends _i {
|
|
|
4063
4147
|
var u;
|
|
4064
4148
|
return c.includes((u = h.properties) == null ? void 0 : u.originalId);
|
|
4065
4149
|
}
|
|
4066
|
-
)), r === this.lineLayerLabelSpec.source ? ((i = this.map.getSource(
|
|
4067
|
-
|
|
4068
|
-
)
|
|
4069
|
-
|
|
4070
|
-
)
|
|
4150
|
+
)), r === this.measureOptions.lineLayerLabelSpec.source ? ((i = this.map.getSource(
|
|
4151
|
+
this.measureOptions.lineLayerLabelSpec.source
|
|
4152
|
+
)) == null || i.setData(a.data), this.map.getLayer(
|
|
4153
|
+
this.measureOptions.lineLayerNodeSpec.id
|
|
4154
|
+
) && this.map.moveLayer(
|
|
4155
|
+
this.measureOptions.lineLayerNodeSpec.id
|
|
4156
|
+
), this.map.getLayer(
|
|
4157
|
+
this.measureOptions.lineLayerLabelSpec.id
|
|
4158
|
+
) && this.map.moveLayer(
|
|
4159
|
+
this.measureOptions.lineLayerLabelSpec.id
|
|
4160
|
+
)) : r === this.measureOptions.polygonLayerSpec.source && ((n = this.map.getSource(
|
|
4161
|
+
this.measureOptions.polygonLayerSpec.source
|
|
4162
|
+
)) == null || n.setData(a.data), this.map.getLayer(
|
|
4163
|
+
this.measureOptions.polygonLayerSpec.id
|
|
4164
|
+
) && this.map.moveLayer(
|
|
4165
|
+
this.measureOptions.polygonLayerSpec.id
|
|
4166
|
+
));
|
|
4071
4167
|
}
|
|
4072
4168
|
}
|
|
4073
4169
|
}
|
|
@@ -4089,7 +4185,7 @@ export {
|
|
|
4089
4185
|
Xi as AvailableMeasureModes,
|
|
4090
4186
|
Ri as AvailableModes,
|
|
4091
4187
|
zi as MaplibreMeasureControl,
|
|
4092
|
-
|
|
4188
|
+
Oi as MaplibreTerradrawControl,
|
|
4093
4189
|
Ei as defaultControlOptions,
|
|
4094
4190
|
Fi as defaultMeasureControlOptions,
|
|
4095
4191
|
Di as getDefaultModeOptions
|