@watergis/maplibre-gl-terradraw 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/maplibre-gl-terradraw.es.js +287 -239
- package/dist/maplibre-gl-terradraw.es.js.map +1 -1
- package/dist/maplibre-gl-terradraw.umd.js +1 -1
- package/dist/maplibre-gl-terradraw.umd.js.map +1 -1
- package/dist/types/MaplibreTerradrawControl.d.ts.map +1 -1
- package/dist/types/constants/AvailableModes.d.ts +1 -1
- package/dist/types/constants/AvailableModes.d.ts.map +1 -1
- package/dist/types/helpers/getTerraDrawModes.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var k = (s, t, e) =>
|
|
1
|
+
var ce = Object.defineProperty;
|
|
2
|
+
var ue = (s, t, e) => t in s ? ce(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
3
|
+
var k = (s, t, e) => ue(s, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
function f() {
|
|
5
5
|
return f = Object.assign ? Object.assign.bind() : function(s) {
|
|
6
6
|
for (var t = 1; t < arguments.length; t++) {
|
|
@@ -18,7 +18,7 @@ const I = (s, t) => {
|
|
|
18
18
|
const { x: e, y: i } = s, { x: o, y: n } = t, r = o - e, a = n - i;
|
|
19
19
|
return Math.sqrt(a * a + r * r);
|
|
20
20
|
};
|
|
21
|
-
class
|
|
21
|
+
class A {
|
|
22
22
|
constructor({ name: t, callback: e, unregister: i, register: o }) {
|
|
23
23
|
this.name = void 0, this.callback = void 0, this.registered = !1, this.register = void 0, this.unregister = void 0, this.name = t, this.register = () => {
|
|
24
24
|
this.registered || (this.registered = !0, o(e));
|
|
@@ -53,7 +53,7 @@ class Jt {
|
|
|
53
53
|
return this._coordinatePrecision;
|
|
54
54
|
}
|
|
55
55
|
getAdapterListeners() {
|
|
56
|
-
return [new
|
|
56
|
+
return [new A({ name: "pointerdown", callback: (t) => {
|
|
57
57
|
if (!this._currentModeCallbacks || !t.isPrimary) return;
|
|
58
58
|
const e = this.getDrawEventFromEvent(t);
|
|
59
59
|
e && (this._dragState = "pre-dragging", this._lastDrawEvent = e);
|
|
@@ -61,7 +61,7 @@ class Jt {
|
|
|
61
61
|
this.getMapEventElement().addEventListener("pointerdown", t);
|
|
62
62
|
}, unregister: (t) => {
|
|
63
63
|
this.getMapEventElement().removeEventListener("pointerdown", t);
|
|
64
|
-
} }), new
|
|
64
|
+
} }), new A({ name: "pointermove", callback: (t) => {
|
|
65
65
|
if (!this._currentModeCallbacks || !t.isPrimary) return;
|
|
66
66
|
t.preventDefault();
|
|
67
67
|
const e = this.getDrawEventFromEvent(t);
|
|
@@ -81,13 +81,13 @@ class Jt {
|
|
|
81
81
|
this.getMapEventElement().addEventListener("pointermove", t);
|
|
82
82
|
}, unregister: (t) => {
|
|
83
83
|
this.getMapEventElement().removeEventListener("pointermove", t);
|
|
84
|
-
} }), new
|
|
84
|
+
} }), new A({ name: "contextmenu", callback: (t) => {
|
|
85
85
|
this._currentModeCallbacks && t.preventDefault();
|
|
86
86
|
}, register: (t) => {
|
|
87
87
|
this.getMapEventElement().addEventListener("contextmenu", t);
|
|
88
88
|
}, unregister: (t) => {
|
|
89
89
|
this.getMapEventElement().removeEventListener("contextmenu", t);
|
|
90
|
-
} }), new
|
|
90
|
+
} }), new A({ name: "pointerup", callback: (t) => {
|
|
91
91
|
if (!this._currentModeCallbacks || t.target !== this.getMapEventElement() || !t.isPrimary) return;
|
|
92
92
|
const e = this.getDrawEventFromEvent(t);
|
|
93
93
|
e && (this._dragState === "dragging" ? this._currentModeCallbacks.onDragEnd(e, (i) => {
|
|
@@ -97,13 +97,13 @@ class Jt {
|
|
|
97
97
|
this.getMapEventElement().addEventListener("pointerup", t);
|
|
98
98
|
}, unregister: (t) => {
|
|
99
99
|
this.getMapEventElement().removeEventListener("pointerup", t);
|
|
100
|
-
} }), new
|
|
100
|
+
} }), new A({ name: "keyup", callback: (t) => {
|
|
101
101
|
this._currentModeCallbacks && (this._heldKeys.delete(t.key), this._currentModeCallbacks.onKeyUp({ key: t.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => t.preventDefault() }));
|
|
102
102
|
}, register: (t) => {
|
|
103
103
|
this.getMapEventElement().addEventListener("keyup", t);
|
|
104
104
|
}, unregister: (t) => {
|
|
105
105
|
this.getMapEventElement().removeEventListener("keyup", t);
|
|
106
|
-
} }), new
|
|
106
|
+
} }), new A({ name: "keydown", callback: (t) => {
|
|
107
107
|
this._currentModeCallbacks && (this._heldKeys.add(t.key), this._currentModeCallbacks.onKeyDown({ key: t.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => t.preventDefault() }));
|
|
108
108
|
}, register: (t) => {
|
|
109
109
|
this.getMapEventElement().addEventListener("keydown", t);
|
|
@@ -117,7 +117,7 @@ class Jt {
|
|
|
117
117
|
}), this.clear();
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
class
|
|
120
|
+
class ge extends Jt {
|
|
121
121
|
constructor(t) {
|
|
122
122
|
super(t), this._nextRender = void 0, this._map = void 0, this._container = void 0, this._rendered = !1, this.changedIds = { deletion: !1, points: !1, linestrings: !1, polygons: !1, styling: !1 }, this._map = t.map, this._container = this._map.getContainer();
|
|
123
123
|
}
|
|
@@ -226,9 +226,9 @@ class ue extends Jt {
|
|
|
226
226
|
super.register(t), this._currentModeCallbacks && this._currentModeCallbacks.onReady && this._currentModeCallbacks.onReady();
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
|
-
class
|
|
229
|
+
class pe extends Jt {
|
|
230
230
|
constructor(t) {
|
|
231
|
-
super(t), this.mapboxglAdapter = void 0, this.mapboxglAdapter = new
|
|
231
|
+
super(t), this.mapboxglAdapter = void 0, this.mapboxglAdapter = new ge(t);
|
|
232
232
|
}
|
|
233
233
|
register(t) {
|
|
234
234
|
this.mapboxglAdapter.register(t);
|
|
@@ -267,7 +267,7 @@ class ge extends Jt {
|
|
|
267
267
|
this.mapboxglAdapter.clear();
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
|
-
let
|
|
270
|
+
let ye = 0;
|
|
271
271
|
const L = typeof navigator < "u" && navigator.userAgent !== void 0 ? navigator.userAgent.toLowerCase() : "";
|
|
272
272
|
L.includes("firefox"), L.includes("safari") && !L.includes("chrom") && (L.includes("version/15.4") || /cpu (os|iphone os) 15_4 like mac os x/.test(L)), L.includes("webkit") && L.includes("edge"), L.includes("macintosh");
|
|
273
273
|
typeof WorkerGlobalScope < "u" && typeof OffscreenCanvas < "u" && self instanceof WorkerGlobalScope;
|
|
@@ -281,7 +281,7 @@ typeof WorkerGlobalScope < "u" && typeof OffscreenCanvas < "u" && self instanceo
|
|
|
281
281
|
} catch {
|
|
282
282
|
}
|
|
283
283
|
})();
|
|
284
|
-
var
|
|
284
|
+
var me = class {
|
|
285
285
|
constructor() {
|
|
286
286
|
this.disposed = !1;
|
|
287
287
|
}
|
|
@@ -301,12 +301,12 @@ var ye = class {
|
|
|
301
301
|
this.propagationStopped = !0;
|
|
302
302
|
}
|
|
303
303
|
};
|
|
304
|
-
function
|
|
304
|
+
function St() {
|
|
305
305
|
}
|
|
306
306
|
function Zt(s) {
|
|
307
307
|
for (const t in s) delete s[t];
|
|
308
308
|
}
|
|
309
|
-
var
|
|
309
|
+
var fe = class extends me {
|
|
310
310
|
constructor(s) {
|
|
311
311
|
super(), this.eventTarget_ = s, this.pendingRemovals_ = null, this.dispatching_ = null, this.listeners_ = null;
|
|
312
312
|
}
|
|
@@ -329,7 +329,7 @@ var me = class extends ye {
|
|
|
329
329
|
}
|
|
330
330
|
if (--n[e] == 0) {
|
|
331
331
|
let l = r[e];
|
|
332
|
-
for (delete r[e]; l--; ) this.removeEventListener(e,
|
|
332
|
+
for (delete r[e]; l--; ) this.removeEventListener(e, St);
|
|
333
333
|
delete n[e];
|
|
334
334
|
}
|
|
335
335
|
return a;
|
|
@@ -348,10 +348,10 @@ var me = class extends ye {
|
|
|
348
348
|
const e = this.listeners_[s];
|
|
349
349
|
if (!e) return;
|
|
350
350
|
const i = e.indexOf(t);
|
|
351
|
-
i !== -1 && (this.pendingRemovals_ && s in this.pendingRemovals_ ? (e[i] =
|
|
351
|
+
i !== -1 && (this.pendingRemovals_ && s in this.pendingRemovals_ ? (e[i] = St, ++this.pendingRemovals_[s]) : (e.splice(i, 1), e.length === 0 && delete this.listeners_[s]));
|
|
352
352
|
}
|
|
353
|
-
},
|
|
354
|
-
function
|
|
353
|
+
}, ve = "change";
|
|
354
|
+
function xt(s, t, e, i, o) {
|
|
355
355
|
if (o) {
|
|
356
356
|
const r = e;
|
|
357
357
|
e = function() {
|
|
@@ -361,18 +361,18 @@ function Ct(s, t, e, i, o) {
|
|
|
361
361
|
const n = { target: s, type: t, listener: e };
|
|
362
362
|
return s.addEventListener(t, e), n;
|
|
363
363
|
}
|
|
364
|
-
function
|
|
365
|
-
return
|
|
364
|
+
function wt(s, t, e, i) {
|
|
365
|
+
return xt(s, t, e, i, !0);
|
|
366
366
|
}
|
|
367
367
|
function It(s) {
|
|
368
368
|
s && s.target && (s.target.removeEventListener(s.type, s.listener), Zt(s));
|
|
369
369
|
}
|
|
370
|
-
var
|
|
370
|
+
var Ce = class extends fe {
|
|
371
371
|
constructor() {
|
|
372
372
|
super(), this.on = this.onInternal, this.once = this.onceInternal, this.un = this.unInternal, this.revision_ = 0;
|
|
373
373
|
}
|
|
374
374
|
changed() {
|
|
375
|
-
++this.revision_, this.dispatchEvent(
|
|
375
|
+
++this.revision_, this.dispatchEvent(ve);
|
|
376
376
|
}
|
|
377
377
|
getRevision() {
|
|
378
378
|
return this.revision_;
|
|
@@ -380,18 +380,18 @@ var ve = class extends me {
|
|
|
380
380
|
onInternal(s, t) {
|
|
381
381
|
if (Array.isArray(s)) {
|
|
382
382
|
const e = s.length, i = new Array(e);
|
|
383
|
-
for (let o = 0; o < e; ++o) i[o] =
|
|
383
|
+
for (let o = 0; o < e; ++o) i[o] = xt(this, s[o], t);
|
|
384
384
|
return i;
|
|
385
385
|
}
|
|
386
|
-
return
|
|
386
|
+
return xt(this, s, t);
|
|
387
387
|
}
|
|
388
388
|
onceInternal(s, t) {
|
|
389
389
|
let e;
|
|
390
390
|
if (Array.isArray(s)) {
|
|
391
391
|
const i = s.length;
|
|
392
392
|
e = new Array(i);
|
|
393
|
-
for (let o = 0; o < i; ++o) e[o] =
|
|
394
|
-
} else e =
|
|
393
|
+
for (let o = 0; o < i; ++o) e[o] = wt(this, s[o], t);
|
|
394
|
+
} else e = wt(this, s, t);
|
|
395
395
|
return t.ol_key = e, e;
|
|
396
396
|
}
|
|
397
397
|
unInternal(s, t) {
|
|
@@ -409,9 +409,9 @@ class Dt extends qt {
|
|
|
409
409
|
super(t), this.key = e, this.oldValue = i;
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
|
-
new class extends
|
|
412
|
+
new class extends Ce {
|
|
413
413
|
constructor(s) {
|
|
414
|
-
super(), this.ol_uid || (this.ol_uid = String(++
|
|
414
|
+
super(), this.ol_uid || (this.ol_uid = String(++ye)), this.values_ = null, s !== void 0 && this.setProperties(s);
|
|
415
415
|
}
|
|
416
416
|
get(s) {
|
|
417
417
|
let t;
|
|
@@ -464,7 +464,7 @@ new class extends ve {
|
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
466
|
}();
|
|
467
|
-
const
|
|
467
|
+
const xe = { radians: 6370997 / (2 * Math.PI), degrees: 2 * Math.PI * 6370997 / 360, ft: 0.3048, m: 1, "us-ft": 1200 / 3937 };
|
|
468
468
|
var Qt = class {
|
|
469
469
|
constructor(s) {
|
|
470
470
|
this.code_ = s.code, this.units_ = s.units, this.extent_ = s.extent !== void 0 ? s.extent : null, this.worldExtent_ = s.worldExtent !== void 0 ? s.worldExtent : null, this.axisOrientation_ = s.axisOrientation !== void 0 ? s.axisOrientation : "enu", this.global_ = s.global !== void 0 && s.global, this.canWrapX_ = !(!this.global_ || !this.extent_), this.getPointResolutionFunc_ = s.getPointResolution, this.defaultTileGrid_ = null, this.metersPerUnit_ = s.metersPerUnit;
|
|
@@ -482,7 +482,7 @@ var Qt = class {
|
|
|
482
482
|
return this.units_;
|
|
483
483
|
}
|
|
484
484
|
getMetersPerUnit() {
|
|
485
|
-
return this.metersPerUnit_ ||
|
|
485
|
+
return this.metersPerUnit_ || xe[this.units_];
|
|
486
486
|
}
|
|
487
487
|
getWorldExtent() {
|
|
488
488
|
return this.worldExtent_;
|
|
@@ -515,81 +515,81 @@ var Qt = class {
|
|
|
515
515
|
return this.getPointResolutionFunc_;
|
|
516
516
|
}
|
|
517
517
|
};
|
|
518
|
-
const J = 6378137, T = Math.PI * J,
|
|
519
|
-
class
|
|
518
|
+
const J = 6378137, T = Math.PI * J, Pe = [-T, -T, T, T], Me = [-180, -85, 180, 85], it = J * Math.log(Math.tan(Math.PI / 2));
|
|
519
|
+
class V extends Qt {
|
|
520
520
|
constructor(t) {
|
|
521
|
-
super({ code: t, units: "m", extent:
|
|
521
|
+
super({ code: t, units: "m", extent: Pe, global: !0, worldExtent: Me, getPointResolution: function(e, i) {
|
|
522
522
|
return e / Math.cosh(i[1] / J);
|
|
523
523
|
} });
|
|
524
524
|
}
|
|
525
525
|
}
|
|
526
|
-
const Ft = [new
|
|
527
|
-
class
|
|
526
|
+
const Ft = [new V("EPSG:3857"), new V("EPSG:102100"), new V("EPSG:102113"), new V("EPSG:900913"), new V("http://www.opengis.net/def/crs/EPSG/0/3857"), new V("http://www.opengis.net/gml/srs/epsg.xml#3857")], kt = [-180, -90, 180, 90], _e = 6378137 * Math.PI / 180;
|
|
527
|
+
class N extends Qt {
|
|
528
528
|
constructor(t, e) {
|
|
529
|
-
super({ code: t, units: "degrees", extent: kt, axisOrientation: e, global: !0, metersPerUnit:
|
|
529
|
+
super({ code: t, units: "degrees", extent: kt, axisOrientation: e, global: !0, metersPerUnit: _e, worldExtent: kt });
|
|
530
530
|
}
|
|
531
531
|
}
|
|
532
|
-
const Ot = [new
|
|
533
|
-
let
|
|
534
|
-
function
|
|
532
|
+
const Ot = [new N("CRS:84"), new N("EPSG:4326", "neu"), new N("urn:ogc:def:crs:OGC:1.3:CRS84"), new N("urn:ogc:def:crs:OGC:2:84"), new N("http://www.opengis.net/def/crs/OGC/1.3/CRS84"), new N("http://www.opengis.net/gml/srs/epsg.xml#4326", "neu"), new N("http://www.opengis.net/def/crs/EPSG/0/4326", "neu")];
|
|
533
|
+
let mt = {};
|
|
534
|
+
function at(s, t, e) {
|
|
535
535
|
const i = s.getCode(), o = t.getCode();
|
|
536
|
-
i in
|
|
536
|
+
i in mt || (mt[i] = {}), mt[i][o] = e;
|
|
537
537
|
}
|
|
538
538
|
function te(s, t) {
|
|
539
539
|
if (t !== void 0) for (let e = 0, i = s.length; e < i; ++e) t[e] = s[e];
|
|
540
540
|
else t = s.slice();
|
|
541
541
|
return t;
|
|
542
542
|
}
|
|
543
|
-
function
|
|
544
|
-
s.getCode(),
|
|
543
|
+
function be(s) {
|
|
544
|
+
s.getCode(), at(s, s, te);
|
|
545
545
|
}
|
|
546
546
|
function jt(s) {
|
|
547
547
|
(function(t) {
|
|
548
|
-
t.forEach(
|
|
548
|
+
t.forEach(be);
|
|
549
549
|
})(s), s.forEach(function(t) {
|
|
550
550
|
s.forEach(function(e) {
|
|
551
|
-
t !== e &&
|
|
551
|
+
t !== e && at(t, e, te);
|
|
552
552
|
});
|
|
553
553
|
});
|
|
554
554
|
}
|
|
555
|
-
var Lt,
|
|
556
|
-
jt(Ft), jt(Ot), Lt = Ft,
|
|
555
|
+
var Lt, Wt, Bt, C;
|
|
556
|
+
jt(Ft), jt(Ot), Lt = Ft, Wt = function(s, t, e) {
|
|
557
557
|
const i = s.length;
|
|
558
558
|
e = e > 1 ? e : 2, t === void 0 && (t = e > 2 ? s.slice() : new Array(i));
|
|
559
559
|
for (let o = 0; o < i; o += e) {
|
|
560
560
|
t[o] = T * s[o] / 180;
|
|
561
561
|
let n = J * Math.log(Math.tan(Math.PI * (+s[o + 1] + 90) / 360));
|
|
562
|
-
n >
|
|
562
|
+
n > it ? n = it : n < -it && (n = -it), t[o + 1] = n;
|
|
563
563
|
}
|
|
564
564
|
return t;
|
|
565
|
-
},
|
|
565
|
+
}, Bt = function(s, t, e) {
|
|
566
566
|
const i = s.length;
|
|
567
567
|
e = e > 1 ? e : 2, t === void 0 && (t = e > 2 ? s.slice() : new Array(i));
|
|
568
568
|
for (let o = 0; o < i; o += e) t[o] = 180 * s[o] / T, t[o + 1] = 360 * Math.atan(Math.exp(s[o + 1] / J)) / Math.PI - 90;
|
|
569
569
|
return t;
|
|
570
570
|
}, Ot.forEach(function(s) {
|
|
571
571
|
Lt.forEach(function(t) {
|
|
572
|
-
|
|
572
|
+
at(s, t, Wt), at(t, s, Bt);
|
|
573
573
|
});
|
|
574
574
|
});
|
|
575
575
|
(function(s) {
|
|
576
576
|
s.Commit = "commit", s.Provisional = "provisional", s.Finish = "finish";
|
|
577
577
|
})(C || (C = {}));
|
|
578
|
-
const
|
|
579
|
-
function
|
|
578
|
+
const Pt = "selected", H = "midPoint", Nt = "closingPoint";
|
|
579
|
+
function ft(s) {
|
|
580
580
|
return !!(s && typeof s == "object" && s !== null && !Array.isArray(s));
|
|
581
581
|
}
|
|
582
|
-
function
|
|
582
|
+
function Gt(s) {
|
|
583
583
|
if (!function(t) {
|
|
584
584
|
return typeof t == "number" && !isNaN(new Date(t).valueOf());
|
|
585
585
|
}(s)) throw new Error("updatedAt and createdAt are not valid timestamps");
|
|
586
586
|
return !0;
|
|
587
587
|
}
|
|
588
|
-
var
|
|
588
|
+
var G;
|
|
589
589
|
(function(s) {
|
|
590
590
|
s.Drawing = "drawing", s.Select = "select", s.Static = "static", s.Render = "render";
|
|
591
|
-
})(
|
|
592
|
-
class
|
|
591
|
+
})(G || (G = {}));
|
|
592
|
+
class O {
|
|
593
593
|
get state() {
|
|
594
594
|
return this._state;
|
|
595
595
|
}
|
|
@@ -606,7 +606,7 @@ class j {
|
|
|
606
606
|
registerBehaviors(t) {
|
|
607
607
|
}
|
|
608
608
|
constructor(t) {
|
|
609
|
-
this._state = void 0, this._styles = void 0, this.behaviors = [], this.validate = void 0, this.pointerDistance = void 0, this.coordinatePrecision = void 0, this.onStyleChange = void 0, this.store = void 0, this.setDoubleClickToZoom = void 0, this.unproject = void 0, this.project = void 0, this.setCursor = void 0, this.projection = void 0, this.type =
|
|
609
|
+
this._state = void 0, this._styles = void 0, this.behaviors = [], this.validate = void 0, this.pointerDistance = void 0, this.coordinatePrecision = void 0, this.onStyleChange = void 0, this.store = void 0, this.setDoubleClickToZoom = void 0, this.unproject = void 0, this.project = void 0, this.setCursor = void 0, this.projection = void 0, this.type = G.Drawing, this.mode = "base", this._state = "unregistered", this._styles = t && t.styles ? f({}, t.styles) : {}, this.pointerDistance = t && t.pointerDistance || 40, this.validate = t && t.validation, this.projection = t && t.projection || "web-mercator";
|
|
610
610
|
}
|
|
611
611
|
setDrawing() {
|
|
612
612
|
if (this._state !== "started") throw new Error("Mode must be unregistered or stopped to start");
|
|
@@ -628,9 +628,9 @@ class j {
|
|
|
628
628
|
if (this._state === "unregistered") throw new Error("Mode must be registered");
|
|
629
629
|
const e = function(i, o) {
|
|
630
630
|
let n;
|
|
631
|
-
if (
|
|
631
|
+
if (ft(i)) if (i.id == null) n = "Feature has no id";
|
|
632
632
|
else if (typeof i.id != "string" && typeof i.id != "number") n = "Feature must be string or number as per GeoJSON spec";
|
|
633
|
-
else if (o(i.id)) if (
|
|
633
|
+
else if (o(i.id)) if (ft(i.geometry)) if (ft(i.properties)) if (typeof i.geometry.type == "string" && ["Polygon", "LineString", "Point"].includes(i.geometry.type)) if (Array.isArray(i.geometry.coordinates)) {
|
|
634
634
|
if (!i.properties.mode || typeof i.properties.mode != "string") throw new Error("Feature does not have a valid mode property");
|
|
635
635
|
} else n = "Feature coordinates is not an array";
|
|
636
636
|
else n = "Feature is not Point, LineString or Polygon";
|
|
@@ -673,39 +673,39 @@ class j {
|
|
|
673
673
|
return t === void 0 ? e : typeof t == "function" ? t(i) : t;
|
|
674
674
|
}
|
|
675
675
|
}
|
|
676
|
-
class
|
|
676
|
+
class Ee extends O {
|
|
677
677
|
constructor(...t) {
|
|
678
|
-
super(...t), this.type =
|
|
678
|
+
super(...t), this.type = G.Select;
|
|
679
679
|
}
|
|
680
680
|
}
|
|
681
|
-
function
|
|
681
|
+
function W(s, t) {
|
|
682
682
|
const e = (d) => d * Math.PI / 180, i = e(s[1]), o = e(s[0]), n = e(t[1]), r = n - i, a = e(t[0]) - o, l = Math.sin(r / 2) * Math.sin(r / 2) + Math.cos(i) * Math.cos(n) * Math.sin(a / 2) * Math.sin(a / 2);
|
|
683
683
|
return 2 * Math.atan2(Math.sqrt(l), Math.sqrt(1 - l)) * 6371e3 / 1e3;
|
|
684
684
|
}
|
|
685
|
-
const
|
|
686
|
-
function
|
|
685
|
+
const Mt = 63710088e-1;
|
|
686
|
+
function w(s) {
|
|
687
687
|
return s % 360 * Math.PI / 180;
|
|
688
688
|
}
|
|
689
689
|
function ee(s) {
|
|
690
|
-
return s / (
|
|
690
|
+
return s / (Mt / 1e3);
|
|
691
691
|
}
|
|
692
692
|
function X(s) {
|
|
693
693
|
return s % (2 * Math.PI) * 180 / Math.PI;
|
|
694
694
|
}
|
|
695
|
-
const At = 57.29577951308232,
|
|
696
|
-
function
|
|
697
|
-
const i =
|
|
695
|
+
const At = 57.29577951308232, Vt = 0.017453292519943295, lt = 6378137, P = (s, t) => ({ x: s === 0 ? 0 : s * Vt * lt, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * Vt / 2)) * lt }), j = (s, t) => ({ lng: s === 0 ? 0 : At * (s / lt), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / lt)) - Math.PI / 2) * At });
|
|
696
|
+
function Se(s, t, e) {
|
|
697
|
+
const i = w(s[0]), o = w(s[1]), n = w(e), r = ee(t), a = Math.asin(Math.sin(o) * Math.cos(r) + Math.cos(o) * Math.sin(r) * Math.cos(n));
|
|
698
698
|
return [X(i + Math.atan2(Math.sin(n) * Math.sin(r) * Math.cos(o), Math.cos(r) - Math.sin(o) * Math.sin(a))), X(a)];
|
|
699
699
|
}
|
|
700
|
-
function
|
|
700
|
+
function Rt(s) {
|
|
701
701
|
const { center: t, radiusKilometers: e, coordinatePrecision: i } = s, o = s.steps ? s.steps : 64, n = [];
|
|
702
702
|
for (let r = 0; r < o; r++) {
|
|
703
|
-
const a =
|
|
703
|
+
const a = Se(t, e, -360 * r / o);
|
|
704
704
|
n.push([b(a[0], i), b(a[1], i)]);
|
|
705
705
|
}
|
|
706
706
|
return n.push(n[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [n] }, properties: {} };
|
|
707
707
|
}
|
|
708
|
-
function
|
|
708
|
+
function _t(s) {
|
|
709
709
|
const t = { epsilon: 0 };
|
|
710
710
|
let e;
|
|
711
711
|
if (s.geometry.type === "Polygon") e = s.geometry.coordinates;
|
|
@@ -721,35 +721,35 @@ function Mt(s) {
|
|
|
721
721
|
}
|
|
722
722
|
function n(r, a, l, d) {
|
|
723
723
|
const h = e[r][a], c = e[r][a + 1], u = e[l][d], g = e[l][d + 1], p = function(m, x, M, E) {
|
|
724
|
-
if (
|
|
725
|
-
const _ = m[0],
|
|
726
|
-
return
|
|
724
|
+
if (ot(m, M) || ot(m, E) || ot(x, M) || ot(E, M)) return null;
|
|
725
|
+
const _ = m[0], S = m[1], F = x[0], B = x[1], Z = M[0], Q = M[1], tt = E[0], et = E[1], yt = (_ - F) * (Q - et) - (S - B) * (Z - tt);
|
|
726
|
+
return yt === 0 ? null : [((_ * B - S * F) * (Z - tt) - (_ - F) * (Z * et - Q * tt)) / yt, ((_ * B - S * F) * (Q - et) - (S - B) * (Z * et - Q * tt)) / yt];
|
|
727
727
|
}(h, c, u, g);
|
|
728
728
|
if (p === null) return;
|
|
729
729
|
let y, v;
|
|
730
730
|
y = c[0] !== h[0] ? (p[0] - h[0]) / (c[0] - h[0]) : (p[1] - h[1]) / (c[1] - h[1]), v = g[0] !== u[0] ? (p[0] - u[0]) / (g[0] - u[0]) : (p[1] - u[1]) / (g[1] - u[1]), o(y) || o(v) || (p.toString(), i.push(p));
|
|
731
731
|
}
|
|
732
732
|
}
|
|
733
|
-
function
|
|
733
|
+
function ot(s, t) {
|
|
734
734
|
return s[0] === t[0] && s[1] === t[1];
|
|
735
735
|
}
|
|
736
|
-
function
|
|
737
|
-
return s.length === 2 && typeof s[0] == "number" && typeof s[1] == "number" && s[0] !== 1 / 0 && s[1] !== 1 / 0 && (i = s[0]) >= -180 && i <= 180 && (e = s[1]) >= -90 && e <= 90 &&
|
|
736
|
+
function gt(s, t) {
|
|
737
|
+
return s.length === 2 && typeof s[0] == "number" && typeof s[1] == "number" && s[0] !== 1 / 0 && s[1] !== 1 / 0 && (i = s[0]) >= -180 && i <= 180 && (e = s[1]) >= -90 && e <= 90 && Ut(s[0]) <= t && Ut(s[1]) <= t;
|
|
738
738
|
var e, i;
|
|
739
739
|
}
|
|
740
|
-
function
|
|
740
|
+
function Ut(s) {
|
|
741
741
|
let t = 1, e = 0;
|
|
742
742
|
for (; Math.round(s * t) / t !== s; ) t *= 10, e++;
|
|
743
743
|
return e;
|
|
744
744
|
}
|
|
745
|
-
function
|
|
746
|
-
return s.geometry.type === "Polygon" && s.geometry.coordinates.length === 1 && s.geometry.coordinates[0].length >= 4 && s.geometry.coordinates[0].every((o) =>
|
|
745
|
+
function q(s, t) {
|
|
746
|
+
return s.geometry.type === "Polygon" && s.geometry.coordinates.length === 1 && s.geometry.coordinates[0].length >= 4 && s.geometry.coordinates[0].every((o) => gt(o, t)) && (e = s.geometry.coordinates[0][0])[0] === (i = s.geometry.coordinates[0][s.geometry.coordinates[0].length - 1])[0] && e[1] === i[1];
|
|
747
747
|
var e, i;
|
|
748
748
|
}
|
|
749
749
|
function ie(s, t) {
|
|
750
|
-
return
|
|
750
|
+
return q(s, t) && !_t(s);
|
|
751
751
|
}
|
|
752
|
-
class we extends
|
|
752
|
+
class we extends O {
|
|
753
753
|
constructor(t) {
|
|
754
754
|
var e;
|
|
755
755
|
super(t), this.mode = "circle", this.center = void 0, this.clickCount = 0, this.currentCircleId = void 0, this.keyEvents = void 0, this.cursors = void 0, this.startingRadiusKilometers = 1e-5;
|
|
@@ -779,7 +779,7 @@ class we extends j {
|
|
|
779
779
|
onClick(t) {
|
|
780
780
|
if (this.clickCount === 0) {
|
|
781
781
|
this.center = [t.lng, t.lat];
|
|
782
|
-
const e =
|
|
782
|
+
const e = Rt({ center: this.center, radiusKilometers: this.startingRadiusKilometers, coordinatePrecision: this.coordinatePrecision }), [i] = this.store.create([{ geometry: e.geometry, properties: { mode: this.mode, radiusKilometers: this.startingRadiusKilometers } }]);
|
|
783
783
|
this.currentCircleId = i, this.clickCount++, this.setDrawing();
|
|
784
784
|
} else this.clickCount === 1 && this.center && this.currentCircleId !== void 0 && this.updateCircle(t), this.close();
|
|
785
785
|
}
|
|
@@ -814,11 +814,11 @@ class we extends j {
|
|
|
814
814
|
}
|
|
815
815
|
updateCircle(t) {
|
|
816
816
|
if (this.clickCount === 1 && this.center && this.currentCircleId) {
|
|
817
|
-
const e =
|
|
817
|
+
const e = W(this.center, [t.lng, t.lat]);
|
|
818
818
|
let i;
|
|
819
819
|
if (this.projection === "web-mercator") {
|
|
820
820
|
const o = function(n, r) {
|
|
821
|
-
const a = 1e3 *
|
|
821
|
+
const a = 1e3 * W(n, r);
|
|
822
822
|
if (a === 0) return 1;
|
|
823
823
|
const { x: l, y: d } = P(n[0], n[1]), { x: h, y: c } = P(r[0], r[1]);
|
|
824
824
|
return Math.sqrt(Math.pow(h - l, 2) + Math.pow(c - d, 2)) / a;
|
|
@@ -826,21 +826,21 @@ class we extends j {
|
|
|
826
826
|
i = function(n) {
|
|
827
827
|
const { center: r, radiusKilometers: a, coordinatePrecision: l } = n, d = n.steps ? n.steps : 64, h = 1e3 * a, [c, u] = r, { x: g, y: p } = P(c, u), y = [];
|
|
828
828
|
for (let v = 0; v < d; v++) {
|
|
829
|
-
const m = 360 * v / d * Math.PI / 180, x = h * Math.cos(m), M = h * Math.sin(m), [E, _] = [g + x, p + M], { lng:
|
|
830
|
-
y.push([b(
|
|
829
|
+
const m = 360 * v / d * Math.PI / 180, x = h * Math.cos(m), M = h * Math.sin(m), [E, _] = [g + x, p + M], { lng: S, lat: F } = j(E, _);
|
|
830
|
+
y.push([b(S, l), b(F, l)]);
|
|
831
831
|
}
|
|
832
832
|
return y.push(y[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [y] }, properties: {} };
|
|
833
833
|
}({ center: this.center, radiusKilometers: e * o, coordinatePrecision: this.coordinatePrecision });
|
|
834
834
|
} else {
|
|
835
835
|
if (this.projection !== "globe") throw new Error("Invalid projection");
|
|
836
|
-
i =
|
|
836
|
+
i = Rt({ center: this.center, radiusKilometers: e, coordinatePrecision: this.coordinatePrecision });
|
|
837
837
|
}
|
|
838
838
|
if (this.validate && !this.validate({ type: "Feature", id: this.currentCircleId, geometry: i.geometry, properties: { radiusKilometers: e } }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: C.Provisional })) return;
|
|
839
839
|
this.store.updateGeometry([{ id: this.currentCircleId, geometry: i.geometry }]), this.store.updateProperty([{ id: this.currentCircleId, property: "radiusKilometers", value: e }]);
|
|
840
840
|
}
|
|
841
841
|
}
|
|
842
842
|
}
|
|
843
|
-
class
|
|
843
|
+
class Ie extends O {
|
|
844
844
|
constructor(t) {
|
|
845
845
|
super(t), this.mode = "freehand", this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.minDistance = void 0, this.keyEvents = void 0, this.cursors = void 0, this.preventPointsNearClose = void 0;
|
|
846
846
|
const e = { start: "crosshair", close: "pointer" };
|
|
@@ -908,7 +908,7 @@ class Se extends j {
|
|
|
908
908
|
return t.type === "Feature" && t.geometry.type === "Polygon" && t.properties.mode === this.mode ? (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10, e) : (t.type === "Feature" && t.geometry.type === "Point" && t.properties.mode === this.mode && (e.pointWidth = this.getNumericStylingValue(this.styles.closingPointWidth, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(this.styles.closingPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.closingPointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.closingPointOutlineWidth, 2, t), e.zIndex = 40), e);
|
|
909
909
|
}
|
|
910
910
|
validateFeature(t) {
|
|
911
|
-
return !!super.validateFeature(t) && t.properties.mode === this.mode &&
|
|
911
|
+
return !!super.validateFeature(t) && t.properties.mode === this.mode && q(t, this.coordinatePrecision);
|
|
912
912
|
}
|
|
913
913
|
}
|
|
914
914
|
class D {
|
|
@@ -929,7 +929,7 @@ class bt extends D {
|
|
|
929
929
|
return oe({ unproject: this.unproject, point: { x: e, y: i }, pointerDistance: this.pointerDistance });
|
|
930
930
|
}
|
|
931
931
|
}
|
|
932
|
-
class
|
|
932
|
+
class pt extends D {
|
|
933
933
|
constructor(t) {
|
|
934
934
|
super(t);
|
|
935
935
|
}
|
|
@@ -958,58 +958,58 @@ class se extends D {
|
|
|
958
958
|
}), n.coord;
|
|
959
959
|
}
|
|
960
960
|
}
|
|
961
|
-
function
|
|
962
|
-
const i =
|
|
961
|
+
function Tt(s, t, e) {
|
|
962
|
+
const i = w(s[0]), o = w(s[1]), n = w(e), r = ee(t), a = Math.asin(Math.sin(o) * Math.cos(r) + Math.cos(o) * Math.sin(r) * Math.cos(n));
|
|
963
963
|
return [X(i + Math.atan2(Math.sin(n) * Math.sin(r) * Math.cos(o), Math.cos(r) - Math.sin(o) * Math.sin(a))), X(a)];
|
|
964
964
|
}
|
|
965
965
|
function Xt({ x: s, y: t }, e, i) {
|
|
966
|
-
const o =
|
|
966
|
+
const o = w(i);
|
|
967
967
|
return { x: s + e * Math.cos(o), y: t + e * Math.sin(o) };
|
|
968
968
|
}
|
|
969
969
|
function Kt(s, t) {
|
|
970
|
-
const e =
|
|
970
|
+
const e = w(s[0]), i = w(t[0]), o = w(s[1]), n = w(t[1]), r = Math.sin(i - e) * Math.cos(n), a = Math.cos(o) * Math.sin(n) - Math.sin(o) * Math.cos(n) * Math.cos(i - e);
|
|
971
971
|
return X(Math.atan2(r, a));
|
|
972
972
|
}
|
|
973
|
-
function
|
|
973
|
+
function ht({ x: s, y: t }, { x: e, y: i }) {
|
|
974
974
|
let o = Math.atan2(i - t, e - s);
|
|
975
975
|
return o *= 180 / Math.PI, o > 180 ? o -= 360 : o < -180 && (o += 360), o;
|
|
976
976
|
}
|
|
977
|
-
function
|
|
977
|
+
function De(s, t, e) {
|
|
978
978
|
const i = [], o = s.length;
|
|
979
979
|
let n, r, a, l = 0;
|
|
980
980
|
for (let h = 0; h < s.length && !(t >= l && h === s.length - 1); h++) {
|
|
981
981
|
if (l > t && i.length === 0) {
|
|
982
982
|
if (n = t - l, !n) return i.push(s[h]), i;
|
|
983
|
-
r = Kt(s[h], s[h - 1]) - 180, a =
|
|
983
|
+
r = Kt(s[h], s[h - 1]) - 180, a = Tt(s[h], n, r), i.push(a);
|
|
984
984
|
}
|
|
985
|
-
if (l >= e) return n = e - l, n ? (r = Kt(s[h], s[h - 1]) - 180, a =
|
|
985
|
+
if (l >= e) return n = e - l, n ? (r = Kt(s[h], s[h - 1]) - 180, a = Tt(s[h], n, r), i.push(a), i) : (i.push(s[h]), i);
|
|
986
986
|
if (l >= t && i.push(s[h]), h === s.length - 1) return i;
|
|
987
|
-
l +=
|
|
987
|
+
l += W(s[h], s[h + 1]);
|
|
988
988
|
}
|
|
989
989
|
if (l < t && s.length === o) throw new Error("Start position is beyond line");
|
|
990
990
|
const d = s[s.length - 1];
|
|
991
991
|
return [d, d];
|
|
992
992
|
}
|
|
993
|
-
function
|
|
993
|
+
function st(s) {
|
|
994
994
|
return s * (Math.PI / 180);
|
|
995
995
|
}
|
|
996
996
|
function Yt(s) {
|
|
997
997
|
return s * (180 / Math.PI);
|
|
998
998
|
}
|
|
999
|
-
class
|
|
999
|
+
class Fe extends D {
|
|
1000
1000
|
constructor(t) {
|
|
1001
1001
|
super(t), this.config = void 0, this.config = t;
|
|
1002
1002
|
}
|
|
1003
1003
|
generateInsertionCoordinates(t, e, i) {
|
|
1004
1004
|
const o = [t, e];
|
|
1005
1005
|
let n = 0;
|
|
1006
|
-
for (let d = 0; d < o.length - 1; d++) n +=
|
|
1006
|
+
for (let d = 0; d < o.length - 1; d++) n += W(o[0], o[1]);
|
|
1007
1007
|
if (n <= i) return o;
|
|
1008
1008
|
let r = n / i - 1;
|
|
1009
1009
|
Number.isInteger(r) || (r = Math.floor(r) + 1);
|
|
1010
1010
|
const a = [];
|
|
1011
1011
|
for (let d = 0; d < r; d++) {
|
|
1012
|
-
const h =
|
|
1012
|
+
const h = De(o, i * d, i * (d + 1));
|
|
1013
1013
|
a.push(h);
|
|
1014
1014
|
}
|
|
1015
1015
|
const l = [];
|
|
@@ -1017,16 +1017,16 @@ class De extends D {
|
|
|
1017
1017
|
return this.limitCoordinates(l);
|
|
1018
1018
|
}
|
|
1019
1019
|
generateInsertionGeodesicCoordinates(t, e, i) {
|
|
1020
|
-
const o =
|
|
1021
|
-
const d = [], h =
|
|
1020
|
+
const o = W(t, e), n = function(r, a, l) {
|
|
1021
|
+
const d = [], h = st(r[1]), c = st(r[0]), u = st(a[1]), g = st(a[0]);
|
|
1022
1022
|
l += 1;
|
|
1023
1023
|
const p = 2 * Math.asin(Math.sqrt(Math.sin((u - h) / 2) ** 2 + Math.cos(h) * Math.cos(u) * Math.sin((g - c) / 2) ** 2));
|
|
1024
1024
|
if (p === 0 || isNaN(p)) return d;
|
|
1025
1025
|
for (let y = 0; y <= l; y++) {
|
|
1026
1026
|
const v = y / l, m = Math.sin((1 - v) * p) / Math.sin(p), x = Math.sin(v * p) / Math.sin(p), M = m * Math.cos(h) * Math.cos(c) + x * Math.cos(u) * Math.cos(g), E = m * Math.cos(h) * Math.sin(c) + x * Math.cos(u) * Math.sin(g), _ = m * Math.sin(h) + x * Math.sin(u);
|
|
1027
1027
|
if (isNaN(M) || isNaN(E) || isNaN(_)) continue;
|
|
1028
|
-
const
|
|
1029
|
-
isNaN(
|
|
1028
|
+
const S = Math.atan2(_, Math.sqrt(M ** 2 + E ** 2)), F = Math.atan2(E, M);
|
|
1029
|
+
isNaN(S) || isNaN(F) || d.push([Yt(F), Yt(S)]);
|
|
1030
1030
|
}
|
|
1031
1031
|
return d.slice(1, -1);
|
|
1032
1032
|
}(t, e, Math.floor(o / i));
|
|
@@ -1039,7 +1039,7 @@ class De extends D {
|
|
|
1039
1039
|
function $(s, t) {
|
|
1040
1040
|
return s[0] === t[0] && s[1] === t[1];
|
|
1041
1041
|
}
|
|
1042
|
-
class
|
|
1042
|
+
class ke extends O {
|
|
1043
1043
|
constructor(t) {
|
|
1044
1044
|
super(t), this.mode = "linestring", this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.keyEvents = void 0, this.snappingEnabled = void 0, this.cursors = void 0, this.mouseMove = !1, this.insertCoordinates = void 0, this.lastCommitedCoordinates = void 0, this.snapping = void 0, this.insertPoint = void 0;
|
|
1045
1045
|
const e = { start: "crosshair", close: "pointer" };
|
|
@@ -1067,7 +1067,7 @@ class Fe extends j {
|
|
|
1067
1067
|
generateInsertCoordinates(t, e) {
|
|
1068
1068
|
if (!this.insertCoordinates || !this.lastCommitedCoordinates) throw new Error("Not able to insert coordinates");
|
|
1069
1069
|
if (this.insertCoordinates.strategy !== "amount") throw new Error("Strategy does not exist");
|
|
1070
|
-
const i =
|
|
1070
|
+
const i = W(t, e) / (this.insertCoordinates.value + 1);
|
|
1071
1071
|
let o = [];
|
|
1072
1072
|
return this.projection === "globe" ? o = this.insertPoint.generateInsertionGeodesicCoordinates(t, e, i) : this.projection === "web-mercator" && (o = this.insertPoint.generateInsertionCoordinates(t, e, i)), o;
|
|
1073
1073
|
}
|
|
@@ -1091,7 +1091,7 @@ class Fe extends j {
|
|
|
1091
1091
|
this.updateGeometries(l, i[i.length - 1], C.Commit), this.currentCoordinate++;
|
|
1092
1092
|
}
|
|
1093
1093
|
registerBehaviors(t) {
|
|
1094
|
-
this.snapping = new se(t, new
|
|
1094
|
+
this.snapping = new se(t, new pt(t), new bt(t)), this.insertPoint = new Fe(t);
|
|
1095
1095
|
}
|
|
1096
1096
|
start() {
|
|
1097
1097
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -1150,10 +1150,10 @@ class Fe extends j {
|
|
|
1150
1150
|
return !!super.validateFeature(t) && t.geometry.type === "LineString" && t.properties.mode === this.mode && t.geometry.coordinates.length >= 2;
|
|
1151
1151
|
}
|
|
1152
1152
|
}
|
|
1153
|
-
function
|
|
1154
|
-
return s.geometry.type === "Point" &&
|
|
1153
|
+
function ne(s, t) {
|
|
1154
|
+
return s.geometry.type === "Point" && gt(s.geometry.coordinates, t);
|
|
1155
1155
|
}
|
|
1156
|
-
class Oe extends
|
|
1156
|
+
class Oe extends O {
|
|
1157
1157
|
constructor(t) {
|
|
1158
1158
|
super(t), this.mode = "point", this.cursors = void 0;
|
|
1159
1159
|
const e = { create: "crosshair" };
|
|
@@ -1191,7 +1191,7 @@ class Oe extends j {
|
|
|
1191
1191
|
return t.type === "Feature" && t.geometry.type === "Point" && t.properties.mode === this.mode && (e.pointWidth = this.getNumericStylingValue(this.styles.pointWidth, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(this.styles.pointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.pointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.pointOutlineWidth, 2, t), e.zIndex = 30), e;
|
|
1192
1192
|
}
|
|
1193
1193
|
validateFeature(t) {
|
|
1194
|
-
return !!super.validateFeature(t) && t.properties.mode === this.mode &&
|
|
1194
|
+
return !!super.validateFeature(t) && t.properties.mode === this.mode && ne(t, this.coordinatePrecision);
|
|
1195
1195
|
}
|
|
1196
1196
|
}
|
|
1197
1197
|
class je extends D {
|
|
@@ -1206,7 +1206,7 @@ class je extends D {
|
|
|
1206
1206
|
create(t, e) {
|
|
1207
1207
|
if (this.ids.length) throw new Error("Opening and closing points already created");
|
|
1208
1208
|
if (t.length <= 3) throw new Error("Requires at least 4 coordinates");
|
|
1209
|
-
this._startEndPoints = this.store.create([{ geometry: { type: "Point", coordinates: t[0] }, properties: { mode: e, [
|
|
1209
|
+
this._startEndPoints = this.store.create([{ geometry: { type: "Point", coordinates: t[0] }, properties: { mode: e, [Nt]: !0 } }, { geometry: { type: "Point", coordinates: t[t.length - 2] }, properties: { mode: e, [Nt]: !0 } }]);
|
|
1210
1210
|
}
|
|
1211
1211
|
delete() {
|
|
1212
1212
|
this.ids.length && (this.store.delete(this.ids), this._startEndPoints = []);
|
|
@@ -1220,7 +1220,7 @@ class je extends D {
|
|
|
1220
1220
|
return { isClosing: o < this.pointerDistance, isPreviousClosing: n < this.pointerDistance };
|
|
1221
1221
|
}
|
|
1222
1222
|
}
|
|
1223
|
-
class Le extends
|
|
1223
|
+
class Le extends O {
|
|
1224
1224
|
constructor(t) {
|
|
1225
1225
|
super(t), this.mode = "polygon", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.snappingEnabled = void 0, this.snapping = void 0, this.pixelDistance = void 0, this.closingPoints = void 0, this.cursors = void 0, this.mouseMove = !1;
|
|
1226
1226
|
const e = { start: "crosshair", close: "pointer" };
|
|
@@ -1238,7 +1238,7 @@ class Le extends j {
|
|
|
1238
1238
|
this.currentCoordinate = 0, this.currentId = void 0, this.closingPoints.delete(), this.state === "drawing" && this.setStarted(), this.onFinish(e, { mode: this.mode, action: "draw" });
|
|
1239
1239
|
}
|
|
1240
1240
|
registerBehaviors(t) {
|
|
1241
|
-
this.pixelDistance = new
|
|
1241
|
+
this.pixelDistance = new pt(t), this.snapping = new se(t, this.pixelDistance, new bt(t)), this.closingPoints = new je(t, this.pixelDistance);
|
|
1242
1242
|
}
|
|
1243
1243
|
start() {
|
|
1244
1244
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -1326,10 +1326,10 @@ class Le extends j {
|
|
|
1326
1326
|
return e;
|
|
1327
1327
|
}
|
|
1328
1328
|
validateFeature(t) {
|
|
1329
|
-
return !!super.validateFeature(t) && t.properties.mode === this.mode &&
|
|
1329
|
+
return !!super.validateFeature(t) && t.properties.mode === this.mode && q(t, this.coordinatePrecision);
|
|
1330
1330
|
}
|
|
1331
1331
|
}
|
|
1332
|
-
class
|
|
1332
|
+
class We extends O {
|
|
1333
1333
|
constructor(t) {
|
|
1334
1334
|
super(t), this.mode = "rectangle", this.center = void 0, this.clickCount = 0, this.currentRectangleId = void 0, this.keyEvents = void 0, this.cursors = void 0;
|
|
1335
1335
|
const e = { start: "crosshair" };
|
|
@@ -1389,9 +1389,47 @@ class Be extends j {
|
|
|
1389
1389
|
return !!super.validateFeature(t) && t.properties.mode === this.mode && ie(t, this.coordinatePrecision);
|
|
1390
1390
|
}
|
|
1391
1391
|
}
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1392
|
+
class Be extends O {
|
|
1393
|
+
constructor(t) {
|
|
1394
|
+
super({ styles: t.styles }), this.type = G.Render, this.mode = "render", this.mode = t.modeName;
|
|
1395
|
+
}
|
|
1396
|
+
registerBehaviors(t) {
|
|
1397
|
+
this.mode = t.mode;
|
|
1398
|
+
}
|
|
1399
|
+
start() {
|
|
1400
|
+
this.setStarted();
|
|
1401
|
+
}
|
|
1402
|
+
stop() {
|
|
1403
|
+
this.setStopped();
|
|
1404
|
+
}
|
|
1405
|
+
onKeyUp() {
|
|
1406
|
+
}
|
|
1407
|
+
onKeyDown() {
|
|
1408
|
+
}
|
|
1409
|
+
onClick() {
|
|
1410
|
+
}
|
|
1411
|
+
onDragStart() {
|
|
1412
|
+
}
|
|
1413
|
+
onDrag() {
|
|
1414
|
+
}
|
|
1415
|
+
onDragEnd() {
|
|
1416
|
+
}
|
|
1417
|
+
onMouseMove() {
|
|
1418
|
+
}
|
|
1419
|
+
cleanUp() {
|
|
1420
|
+
}
|
|
1421
|
+
styleFeature(t) {
|
|
1422
|
+
return { pointColor: this.getHexColorStylingValue(this.styles.pointColor, "#3f97e0", t), pointWidth: this.getNumericStylingValue(this.styles.pointWidth, 6, t), pointOutlineColor: this.getHexColorStylingValue(this.styles.pointOutlineColor, "#ffffff", t), pointOutlineWidth: this.getNumericStylingValue(this.styles.pointOutlineWidth, 0, t), polygonFillColor: this.getHexColorStylingValue(this.styles.polygonFillColor, "#3f97e0", t), polygonFillOpacity: this.getNumericStylingValue(this.styles.polygonFillOpacity, 0.3, t), polygonOutlineColor: this.getHexColorStylingValue(this.styles.polygonOutlineColor, "#3f97e0", t), polygonOutlineWidth: this.getNumericStylingValue(this.styles.polygonOutlineWidth, 4, t), lineStringWidth: this.getNumericStylingValue(this.styles.lineStringWidth, 4, t), lineStringColor: this.getHexColorStylingValue(this.styles.lineStringColor, "#3f97e0", t), zIndex: this.getNumericStylingValue(this.styles.zIndex, 0, t) };
|
|
1423
|
+
}
|
|
1424
|
+
validateFeature(t) {
|
|
1425
|
+
return super.validateFeature(t) && (ne(t, this.coordinatePrecision) || q(t, this.coordinatePrecision) || function(e, i) {
|
|
1426
|
+
return e.geometry.type === "LineString" && e.geometry.coordinates.length >= 2 && e.geometry.coordinates.every((o) => gt(o, i));
|
|
1427
|
+
}(t, this.coordinatePrecision));
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
function dt(s, t) {
|
|
1431
|
+
const e = s, i = t, o = w(e[1]), n = w(i[1]);
|
|
1432
|
+
let r = w(i[0] - e[0]);
|
|
1395
1433
|
r > Math.PI && (r -= 2 * Math.PI), r < -Math.PI && (r += 2 * Math.PI);
|
|
1396
1434
|
const a = Math.log(Math.tan(n / 2 + Math.PI / 4) / Math.tan(o / 2 + Math.PI / 4)), l = (X(Math.atan2(r, a)) + 360) % 360;
|
|
1397
1435
|
return l > 180 ? -(360 - l) : l;
|
|
@@ -1399,28 +1437,28 @@ function ht(s, t) {
|
|
|
1399
1437
|
function Et(s, t, e) {
|
|
1400
1438
|
let i = t;
|
|
1401
1439
|
t < 0 && (i = -Math.abs(i));
|
|
1402
|
-
const o = i /
|
|
1440
|
+
const o = i / Mt, n = s[0] * Math.PI / 180, r = w(s[1]), a = w(e), l = o * Math.cos(a);
|
|
1403
1441
|
let d = r + l;
|
|
1404
1442
|
Math.abs(d) > Math.PI / 2 && (d = d > 0 ? Math.PI - d : -Math.PI - d);
|
|
1405
1443
|
const h = Math.log(Math.tan(d / 2 + Math.PI / 4) / Math.tan(r / 2 + Math.PI / 4)), c = Math.abs(h) > 1e-11 ? l / h : Math.cos(r), u = [(180 * (n + o * Math.sin(a) / c) / Math.PI + 540) % 360 - 180, 180 * d / Math.PI];
|
|
1406
1444
|
return u[0] += u[0] - s[0] > 180 ? -360 : s[0] - u[0] > 180 ? 360 : 0, u;
|
|
1407
1445
|
}
|
|
1408
|
-
function
|
|
1446
|
+
function re(s, t, e, i, o) {
|
|
1409
1447
|
const n = i(s[0], s[1]), r = i(t[0], t[1]), { lng: a, lat: l } = o((n.x + r.x) / 2, (n.y + r.y) / 2);
|
|
1410
1448
|
return [b(a, e), b(l, e)];
|
|
1411
1449
|
}
|
|
1412
|
-
function
|
|
1413
|
-
const i = Et(s, 1e3 *
|
|
1450
|
+
function Ne(s, t, e) {
|
|
1451
|
+
const i = Et(s, 1e3 * W(s, t) / 2, dt(s, t));
|
|
1414
1452
|
return [b(i[0], e), b(i[1], e)];
|
|
1415
1453
|
}
|
|
1416
1454
|
function zt({ featureCoords: s, precision: t, unproject: e, project: i, projection: o }) {
|
|
1417
1455
|
const n = [];
|
|
1418
1456
|
for (let r = 0; r < s.length - 1; r++) {
|
|
1419
1457
|
let a;
|
|
1420
|
-
if (o === "web-mercator") a =
|
|
1458
|
+
if (o === "web-mercator") a = re(s[r], s[r + 1], t, i, e);
|
|
1421
1459
|
else {
|
|
1422
1460
|
if (o !== "globe") throw new Error("Invalid projection");
|
|
1423
|
-
a =
|
|
1461
|
+
a = Ne(s[r], s[r + 1], t);
|
|
1424
1462
|
}
|
|
1425
1463
|
n.push(a);
|
|
1426
1464
|
}
|
|
@@ -1452,7 +1490,7 @@ class Ge extends D {
|
|
|
1452
1490
|
if (this._midPoints.length !== 0) return zt({ featureCoords: t, precision: this.coordinatePrecision, project: this.config.project, unproject: this.config.unproject, projection: this.config.projection }).map((e, i) => ({ id: this._midPoints[i], geometry: { type: "Point", coordinates: e } }));
|
|
1453
1491
|
}
|
|
1454
1492
|
}
|
|
1455
|
-
class
|
|
1493
|
+
class Ae extends D {
|
|
1456
1494
|
constructor(t) {
|
|
1457
1495
|
super(t), this._selectionPoints = [];
|
|
1458
1496
|
}
|
|
@@ -1478,7 +1516,7 @@ class Ne extends D {
|
|
|
1478
1516
|
if (this._selectionPoints[t] !== void 0) return { id: this._selectionPoints[t], geometry: { type: "Point", coordinates: e } };
|
|
1479
1517
|
}
|
|
1480
1518
|
}
|
|
1481
|
-
function
|
|
1519
|
+
function ae(s, t) {
|
|
1482
1520
|
let e = !1;
|
|
1483
1521
|
for (let r = 0, a = t.length; r < a; r++) {
|
|
1484
1522
|
const l = t[r];
|
|
@@ -1487,7 +1525,7 @@ function re(s, t) {
|
|
|
1487
1525
|
var i, o, n;
|
|
1488
1526
|
return e;
|
|
1489
1527
|
}
|
|
1490
|
-
const
|
|
1528
|
+
const le = (s, t, e) => {
|
|
1491
1529
|
const i = (n) => n * n, o = (n, r) => i(n.x - r.x) + i(n.y - r.y);
|
|
1492
1530
|
return Math.sqrt(((n, r, a) => {
|
|
1493
1531
|
const l = o(r, a);
|
|
@@ -1496,7 +1534,7 @@ const ae = (s, t, e) => {
|
|
|
1496
1534
|
return d = Math.max(0, Math.min(1, d)), o(n, { x: r.x + d * (a.x - r.x), y: r.y + d * (a.y - r.y) });
|
|
1497
1535
|
})(s, t, e));
|
|
1498
1536
|
};
|
|
1499
|
-
class
|
|
1537
|
+
class Ve extends D {
|
|
1500
1538
|
constructor(t, e, i) {
|
|
1501
1539
|
super(t), this.config = void 0, this.createClickBoundingBox = void 0, this.pixelDistance = void 0, this.config = t, this.createClickBoundingBox = e, this.pixelDistance = i;
|
|
1502
1540
|
}
|
|
@@ -1510,10 +1548,10 @@ class Ae extends D {
|
|
|
1510
1548
|
const u = this.pixelDistance.measure(t, c.coordinates);
|
|
1511
1549
|
h.properties[H] && u < this.pointerDistance && u < r ? (r = u, o = h) : !h.properties[H] && u < this.pointerDistance && u < n && (n = u, i = h);
|
|
1512
1550
|
} else if (c.type === "LineString") for (let u = 0; u < c.coordinates.length - 1; u++) {
|
|
1513
|
-
const g = c.coordinates[u], p = c.coordinates[u + 1], y =
|
|
1551
|
+
const g = c.coordinates[u], p = c.coordinates[u + 1], y = le({ x: t.containerX, y: t.containerY }, this.project(g[0], g[1]), this.project(p[0], p[1]));
|
|
1514
1552
|
y < this.pointerDistance && y < n && (n = y, i = h);
|
|
1515
1553
|
}
|
|
1516
|
-
else c.type === "Polygon" &&
|
|
1554
|
+
else c.type === "Polygon" && ae([t.lng, t.lat], c.coordinates) && (n = 0, i = h);
|
|
1517
1555
|
}
|
|
1518
1556
|
return { clickedFeature: i, clickedMidPoint: o };
|
|
1519
1557
|
}
|
|
@@ -1553,7 +1591,7 @@ class Re extends D {
|
|
|
1553
1591
|
} else i.type === "Point" && (this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: { type: "Point", coordinates: o } }]), this.dragPosition = [t.lng, t.lat]);
|
|
1554
1592
|
}
|
|
1555
1593
|
}
|
|
1556
|
-
class
|
|
1594
|
+
class Ue extends D {
|
|
1557
1595
|
constructor(t, e, i, o) {
|
|
1558
1596
|
super(t), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.draggedCoordinate = { id: null, index: -1 }, this.config = t, this.pixelDistance = e, this.selectionPoints = i, this.midPoints = o;
|
|
1559
1597
|
}
|
|
@@ -1588,7 +1626,7 @@ class Ve extends D {
|
|
|
1588
1626
|
r[0] = a, r[c] = a;
|
|
1589
1627
|
}
|
|
1590
1628
|
const l = this.selectionPoints.getOneUpdated(o, a), d = l ? [l] : [], h = this.midPoints.getUpdated(r) || [];
|
|
1591
|
-
return !(n.type !== "Point" && !e &&
|
|
1629
|
+
return !(n.type !== "Point" && !e && _t({ type: "Feature", geometry: n, properties: {} }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: n, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: C.Provisional }) || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: n }, ...d, ...h]), 0));
|
|
1592
1630
|
}
|
|
1593
1631
|
isDragging() {
|
|
1594
1632
|
return this.draggedCoordinate.id !== null;
|
|
@@ -1600,21 +1638,21 @@ class Ve extends D {
|
|
|
1600
1638
|
this.draggedCoordinate = { id: null, index: -1 };
|
|
1601
1639
|
}
|
|
1602
1640
|
}
|
|
1603
|
-
function
|
|
1641
|
+
function ct(s) {
|
|
1604
1642
|
let t = 0, e = 0, i = 0;
|
|
1605
1643
|
return (s.geometry.type === "Polygon" ? s.geometry.coordinates[0].slice(0, -1) : s.geometry.coordinates).forEach((o) => {
|
|
1606
1644
|
t += o[0], e += o[1], i++;
|
|
1607
1645
|
}, !0), [t / i, e / i];
|
|
1608
1646
|
}
|
|
1609
|
-
function
|
|
1647
|
+
function he(s, t) {
|
|
1610
1648
|
s[0] += s[0] - t[0] > 180 ? -360 : t[0] - s[0] > 180 ? 360 : 0;
|
|
1611
|
-
const e =
|
|
1649
|
+
const e = Mt, i = t[1] * Math.PI / 180, o = s[1] * Math.PI / 180, n = o - i;
|
|
1612
1650
|
let r = Math.abs(s[0] - t[0]) * Math.PI / 180;
|
|
1613
1651
|
r > Math.PI && (r -= 2 * Math.PI);
|
|
1614
1652
|
const a = Math.log(Math.tan(o / 2 + Math.PI / 4) / Math.tan(i / 2 + Math.PI / 4)), l = Math.abs(a) > 1e-11 ? n / a : Math.cos(i);
|
|
1615
1653
|
return Math.sqrt(n * n + l * l * r * r) * e;
|
|
1616
1654
|
}
|
|
1617
|
-
function
|
|
1655
|
+
function ut(s) {
|
|
1618
1656
|
const t = (s.geometry.type === "Polygon" ? s.geometry.coordinates[0] : s.geometry.coordinates).map((e) => {
|
|
1619
1657
|
const { x: i, y: o } = P(e[0], e[1]);
|
|
1620
1658
|
return [i, o];
|
|
@@ -1651,22 +1689,22 @@ class Te extends D {
|
|
|
1651
1689
|
let r;
|
|
1652
1690
|
const a = { type: "Feature", geometry: o, properties: {} };
|
|
1653
1691
|
if (this.config.projection === "web-mercator") {
|
|
1654
|
-
if (r =
|
|
1692
|
+
if (r = ht(ut(a), P(t.lng, t.lat)), !this.lastBearing) return void (this.lastBearing = r);
|
|
1655
1693
|
((c, u) => {
|
|
1656
1694
|
if (u === 0 || u === 360 || u === -360) return c;
|
|
1657
1695
|
const g = 0.017453292519943295 * u, p = (c.geometry.type === "Polygon" ? c.geometry.coordinates[0] : c.geometry.coordinates).map(([m, x]) => P(m, x)), y = p.reduce((m, x) => ({ x: m.x + x.x, y: m.y + x.y }), { x: 0, y: 0 });
|
|
1658
1696
|
y.x /= p.length, y.y /= p.length;
|
|
1659
|
-
const v = p.map((m) => ({ x: y.x + (m.x - y.x) * Math.cos(g) - (m.y - y.y) * Math.sin(g), y: y.y + (m.x - y.x) * Math.sin(g) + (m.y - y.y) * Math.cos(g) })).map(({ x: m, y: x }) => [
|
|
1697
|
+
const v = p.map((m) => ({ x: y.x + (m.x - y.x) * Math.cos(g) - (m.y - y.y) * Math.sin(g), y: y.y + (m.x - y.x) * Math.sin(g) + (m.y - y.y) * Math.cos(g) })).map(({ x: m, y: x }) => [j(m, x).lng, j(m, x).lat]);
|
|
1660
1698
|
c.geometry.type === "Polygon" ? c.geometry.coordinates[0] = v : (console.log("rotatedCoordinates linestring", v), c.geometry.coordinates = v);
|
|
1661
1699
|
})(a, -(this.lastBearing - r));
|
|
1662
1700
|
} else {
|
|
1663
1701
|
if (this.config.projection !== "globe") throw new Error("Unsupported projection");
|
|
1664
|
-
if (r =
|
|
1702
|
+
if (r = dt(ct({ type: "Feature", geometry: o, properties: {} }), n), !this.lastBearing) return void (this.lastBearing = r + 180);
|
|
1665
1703
|
(function(c, u) {
|
|
1666
1704
|
if (u === 0 || u === 360 || u === -360) return c;
|
|
1667
|
-
const g =
|
|
1705
|
+
const g = ct(c);
|
|
1668
1706
|
(c.geometry.type === "Polygon" ? c.geometry.coordinates[0] : c.geometry.coordinates).forEach((p) => {
|
|
1669
|
-
const y =
|
|
1707
|
+
const y = dt(g, p) + u, v = he(g, p), m = Et(g, v, y);
|
|
1670
1708
|
p[0] = m[0], p[1] = m[1];
|
|
1671
1709
|
});
|
|
1672
1710
|
})(a, -(this.lastBearing - (r + 180)));
|
|
@@ -1680,7 +1718,7 @@ class Te extends D {
|
|
|
1680
1718
|
this.store.updateGeometry([{ id: e, geometry: o }, ...h, ...d]), this.projection === "web-mercator" ? this.lastBearing = r : this.projection === "globe" && (this.lastBearing = r + 180);
|
|
1681
1719
|
}
|
|
1682
1720
|
}
|
|
1683
|
-
class
|
|
1721
|
+
class Xe extends D {
|
|
1684
1722
|
constructor(t, e, i) {
|
|
1685
1723
|
super(t), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastDistance = void 0, this.config = t, this.selectionPoints = e, this.midPoints = i;
|
|
1686
1724
|
}
|
|
@@ -1692,29 +1730,29 @@ class Ue extends D {
|
|
|
1692
1730
|
if (o.type !== "Polygon" && o.type !== "LineString") return;
|
|
1693
1731
|
const n = [t.lng, t.lat], r = { type: "Feature", geometry: o, properties: {} };
|
|
1694
1732
|
let a;
|
|
1695
|
-
const l =
|
|
1733
|
+
const l = ut(r);
|
|
1696
1734
|
if (this.config.projection === "web-mercator") {
|
|
1697
1735
|
const g = P(t.lng, t.lat);
|
|
1698
1736
|
a = I(l, g);
|
|
1699
1737
|
} else {
|
|
1700
1738
|
if (this.config.projection !== "globe") throw new Error("Invalid projection");
|
|
1701
|
-
a =
|
|
1739
|
+
a = W(ct({ type: "Feature", geometry: o, properties: {} }), n);
|
|
1702
1740
|
}
|
|
1703
1741
|
if (!this.lastDistance) return void (this.lastDistance = a);
|
|
1704
1742
|
const d = 1 - (this.lastDistance - a) / a;
|
|
1705
1743
|
if (this.config.projection === "web-mercator") {
|
|
1706
|
-
const { lng: g, lat: p } =
|
|
1744
|
+
const { lng: g, lat: p } = j(l.x, l.y);
|
|
1707
1745
|
(function(y, v, m) {
|
|
1708
1746
|
if (v === 1) return y;
|
|
1709
|
-
const x = (y.geometry.type === "Polygon" ? y.geometry.coordinates[0] : y.geometry.coordinates).map(([_,
|
|
1747
|
+
const x = (y.geometry.type === "Polygon" ? y.geometry.coordinates[0] : y.geometry.coordinates).map(([_, S]) => P(_, S)), M = P(m[0], m[1]), E = x.map((_) => ({ x: M.x + (_.x - M.x) * v, y: M.y + (_.y - M.y) * v })).map(({ x: _, y: S }) => [j(_, S).lng, j(_, S).lat]);
|
|
1710
1748
|
y.geometry.type === "Polygon" ? y.geometry.coordinates[0] = E : y.geometry.coordinates = E;
|
|
1711
1749
|
})(r, d, [g, p]);
|
|
1712
1750
|
} else this.config.projection === "globe" && function(g, p, y, v = "xy") {
|
|
1713
1751
|
p === 1 || (g.geometry.type === "Polygon" ? g.geometry.coordinates[0] : g.geometry.coordinates).forEach((m) => {
|
|
1714
|
-
const x =
|
|
1752
|
+
const x = he(y, m), M = dt(y, m), E = Et(y, x * p, M);
|
|
1715
1753
|
v !== "x" && v !== "xy" || (m[0] = E[0]), v !== "y" && v !== "xy" || (m[1] = E[1]);
|
|
1716
1754
|
});
|
|
1717
|
-
}(r, d,
|
|
1755
|
+
}(r, d, ct(r));
|
|
1718
1756
|
const h = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
|
|
1719
1757
|
h.forEach((g) => {
|
|
1720
1758
|
g[0] = b(g[0], this.coordinatePrecision), g[1] = b(g[1], this.coordinatePrecision);
|
|
@@ -1724,7 +1762,7 @@ class Ue extends D {
|
|
|
1724
1762
|
this.store.updateGeometry([{ id: e, geometry: o }, ...u, ...c]), this.lastDistance = a;
|
|
1725
1763
|
}
|
|
1726
1764
|
}
|
|
1727
|
-
class
|
|
1765
|
+
class Ke extends D {
|
|
1728
1766
|
constructor(t, e, i, o) {
|
|
1729
1767
|
super(t), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.minimumScale = 1e-4, this.draggedCoordinate = { id: null, index: -1 }, this.boundingBoxMaps = { opposite: { 0: 4, 1: 5, 2: 6, 3: 7, 4: 0, 5: 1, 6: 2, 7: 3 } }, this.config = t, this.pixelDistance = e, this.selectionPoints = i, this.midPoints = o;
|
|
1730
1768
|
}
|
|
@@ -1783,7 +1821,7 @@ class Xe extends D {
|
|
|
1783
1821
|
centerWebMercatorDrag(t) {
|
|
1784
1822
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1785
1823
|
if (!e) return null;
|
|
1786
|
-
const { feature: i, boundingBox: o, updatedCoords: n, selectedCoordinate: r } = e, a =
|
|
1824
|
+
const { feature: i, boundingBox: o, updatedCoords: n, selectedCoordinate: r } = e, a = ut(i);
|
|
1787
1825
|
if (!a) return null;
|
|
1788
1826
|
const l = P(r[0], r[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), h = P(t.lng, t.lat);
|
|
1789
1827
|
return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: n, webMercatorCursor: h, webMercatorSelected: l, webMercatorOrigin: a }), n;
|
|
@@ -1791,7 +1829,7 @@ class Xe extends D {
|
|
|
1791
1829
|
centerFixedWebMercatorDrag(t) {
|
|
1792
1830
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1793
1831
|
if (!e) return null;
|
|
1794
|
-
const { feature: i, boundingBox: o, updatedCoords: n, selectedCoordinate: r } = e, a =
|
|
1832
|
+
const { feature: i, boundingBox: o, updatedCoords: n, selectedCoordinate: r } = e, a = ut(i);
|
|
1795
1833
|
if (!a) return null;
|
|
1796
1834
|
const l = P(r[0], r[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), h = P(t.lng, t.lat);
|
|
1797
1835
|
return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: n, webMercatorCursor: h, webMercatorSelected: l, webMercatorOrigin: a }), n;
|
|
@@ -1835,7 +1873,7 @@ class Xe extends D {
|
|
|
1835
1873
|
}
|
|
1836
1874
|
performWebMercatorScale(t, e, i, o, n) {
|
|
1837
1875
|
t.forEach((r) => {
|
|
1838
|
-
const { x: a, y: l } = P(r[0], r[1]), d = e + (a - e) * o, h = i + (l - i) * n, { lng: c, lat: u } =
|
|
1876
|
+
const { x: a, y: l } = P(r[0], r[1]), d = e + (a - e) * o, h = i + (l - i) * n, { lng: c, lat: u } = j(d, h);
|
|
1839
1877
|
r[0] = c, r[1] = u;
|
|
1840
1878
|
});
|
|
1841
1879
|
}
|
|
@@ -1880,13 +1918,13 @@ class Xe extends D {
|
|
|
1880
1918
|
if (e === "center" ? n = this.centerWebMercatorDrag(t) : e === "opposite" ? n = this.oppositeWebMercatorDrag(t) : e === "center-fixed" ? n = this.centerFixedWebMercatorDrag(t) : e === "opposite-fixed" && (n = this.oppositeFixedWebMercatorDrag(t)), !n) return !1;
|
|
1881
1919
|
for (let d = 0; d < n.length; d++) {
|
|
1882
1920
|
const h = n[d];
|
|
1883
|
-
if (h[0] = b(h[0], this.coordinatePrecision), h[1] = b(h[1], this.coordinatePrecision), !
|
|
1921
|
+
if (h[0] = b(h[0], this.coordinatePrecision), h[1] = b(h[1], this.coordinatePrecision), !gt(h, this.coordinatePrecision)) return !1;
|
|
1884
1922
|
}
|
|
1885
1923
|
const r = this.midPoints.getUpdated(n) || [], a = this.selectionPoints.getUpdated(n) || [], l = { type: o.geometry.type, coordinates: o.geometry.type === "Polygon" ? [n] : n };
|
|
1886
1924
|
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: C.Provisional }) || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: l }, ...a, ...r]), 0));
|
|
1887
1925
|
}
|
|
1888
1926
|
}
|
|
1889
|
-
class
|
|
1927
|
+
class Ye extends Ee {
|
|
1890
1928
|
constructor(t) {
|
|
1891
1929
|
var e;
|
|
1892
1930
|
super(t), this.mode = "select", this.allowManualDeselection = !0, this.dragEventThrottle = 5, this.dragEventCount = 0, this.selected = [], this.flags = void 0, this.keyEvents = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.featuresAtMouseEvent = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.dragFeature = void 0, this.dragCoordinate = void 0, this.rotateFeature = void 0, this.scaleFeature = void 0, this.dragCoordinateResizeFeature = void 0, this.cursors = void 0, this.validations = {}, this.flags = t && t.flags ? t.flags : {};
|
|
@@ -1909,13 +1947,13 @@ class Ke extends be {
|
|
|
1909
1947
|
this._state = "selecting";
|
|
1910
1948
|
}
|
|
1911
1949
|
registerBehaviors(t) {
|
|
1912
|
-
this.pixelDistance = new
|
|
1950
|
+
this.pixelDistance = new pt(t), this.clickBoundingBox = new bt(t), this.featuresAtMouseEvent = new Ve(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new Ae(t), this.midPoints = new Ge(t, this.selectionPoints), this.rotateFeature = new Te(t, this.selectionPoints, this.midPoints), this.scaleFeature = new Xe(t, this.selectionPoints, this.midPoints), this.dragFeature = new Re(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints), this.dragCoordinate = new Ue(t, this.pixelDistance, this.selectionPoints, this.midPoints), this.dragCoordinateResizeFeature = new Ke(t, this.pixelDistance, this.selectionPoints, this.midPoints);
|
|
1913
1951
|
}
|
|
1914
1952
|
deselectFeature() {
|
|
1915
1953
|
this.deselect();
|
|
1916
1954
|
}
|
|
1917
1955
|
deselect() {
|
|
1918
|
-
const t = this.selected.filter((e) => this.store.has(e)).map((e) => ({ id: e, property:
|
|
1956
|
+
const t = this.selected.filter((e) => this.store.has(e)).map((e) => ({ id: e, property: Pt, value: !1 }));
|
|
1919
1957
|
this.store.updateProperty(t), this.onDeselect(this.selected[0]), this.selected = [], this.selectionPoints.delete(), this.midPoints.delete();
|
|
1920
1958
|
}
|
|
1921
1959
|
deleteSelected() {
|
|
@@ -2039,7 +2077,7 @@ class Ke extends be {
|
|
|
2039
2077
|
if (t.properties.mode === this.mode && t.geometry.type === "Point") {
|
|
2040
2078
|
if (t.properties.selectionPoint) return e.pointColor = this.getHexColorStylingValue(this.styles.selectionPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.selectionPointOutlineColor, e.pointOutlineColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.selectionPointWidth, e.pointWidth, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.selectionPointOutlineWidth, 2, t), e.zIndex = 30, e;
|
|
2041
2079
|
if (t.properties.midPoint) return e.pointColor = this.getHexColorStylingValue(this.styles.midPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.midPointOutlineColor, e.pointOutlineColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.midPointWidth, 4, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.midPointOutlineWidth, 2, t), e.zIndex = 40, e;
|
|
2042
|
-
} else if (t.properties[
|
|
2080
|
+
} else if (t.properties[Pt]) {
|
|
2043
2081
|
if (t.geometry.type === "Polygon") return e.polygonFillColor = this.getHexColorStylingValue(this.styles.selectedPolygonColor, e.polygonFillColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.selectedPolygonOutlineWidth, e.polygonOutlineWidth, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.selectedPolygonOutlineColor, e.polygonOutlineColor, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.selectedPolygonFillOpacity, e.polygonFillOpacity, t), e.zIndex = 10, e;
|
|
2044
2082
|
if (t.geometry.type === "LineString") return e.lineStringColor = this.getHexColorStylingValue(this.styles.selectedLineStringColor, e.lineStringColor, t), e.lineStringWidth = this.getNumericStylingValue(this.styles.selectedLineStringWidth, e.lineStringWidth, t), e.zIndex = 10, e;
|
|
2045
2083
|
if (t.geometry.type === "Point") return e.pointWidth = this.getNumericStylingValue(this.styles.selectedPointWidth, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(this.styles.selectedPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.selectedPointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.selectedPointOutlineWidth, e.pointOutlineWidth, t), e.zIndex = 10, e;
|
|
@@ -2047,9 +2085,9 @@ class Ke extends be {
|
|
|
2047
2085
|
return e;
|
|
2048
2086
|
}
|
|
2049
2087
|
}
|
|
2050
|
-
class
|
|
2088
|
+
class ze extends O {
|
|
2051
2089
|
constructor(...t) {
|
|
2052
|
-
super(...t), this.type =
|
|
2090
|
+
super(...t), this.type = G.Static, this.mode = "static";
|
|
2053
2091
|
}
|
|
2054
2092
|
start() {
|
|
2055
2093
|
}
|
|
@@ -2075,11 +2113,11 @@ class Ye extends j {
|
|
|
2075
2113
|
return f({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
2076
2114
|
}
|
|
2077
2115
|
}
|
|
2078
|
-
function
|
|
2116
|
+
function de(s, t, e, i, o) {
|
|
2079
2117
|
for (; i > e; ) {
|
|
2080
2118
|
if (i - e > 600) {
|
|
2081
2119
|
const l = i - e + 1, d = t - e + 1, h = Math.log(l), c = 0.5 * Math.exp(2 * h / 3), u = 0.5 * Math.sqrt(h * c * (l - c) / l) * (d - l / 2 < 0 ? -1 : 1);
|
|
2082
|
-
|
|
2120
|
+
de(s, t, Math.max(e, Math.floor(t - d * c / l + u)), Math.min(i, Math.floor(t + (l - d) * c / l + u)), o);
|
|
2083
2121
|
}
|
|
2084
2122
|
const n = s[t];
|
|
2085
2123
|
let r = e, a = i;
|
|
@@ -2098,7 +2136,7 @@ function R(s, t) {
|
|
|
2098
2136
|
Y(s, 0, s.children.length, t, s);
|
|
2099
2137
|
}
|
|
2100
2138
|
function Y(s, t, e, i, o) {
|
|
2101
|
-
o || (o =
|
|
2139
|
+
o || (o = U([])), o.minX = 1 / 0, o.minY = 1 / 0, o.maxX = -1 / 0, o.maxY = -1 / 0;
|
|
2102
2140
|
for (let n = t; n < e; n++) {
|
|
2103
2141
|
const r = s.children[n];
|
|
2104
2142
|
z(o, s.leaf ? i(r) : r);
|
|
@@ -2108,29 +2146,29 @@ function Y(s, t, e, i, o) {
|
|
|
2108
2146
|
function z(s, t) {
|
|
2109
2147
|
return s.minX = Math.min(s.minX, t.minX), s.minY = Math.min(s.minY, t.minY), s.maxX = Math.max(s.maxX, t.maxX), s.maxY = Math.max(s.maxY, t.maxY), s;
|
|
2110
2148
|
}
|
|
2111
|
-
function
|
|
2149
|
+
function He(s, t) {
|
|
2112
2150
|
return s.minX - t.minX;
|
|
2113
2151
|
}
|
|
2114
|
-
function
|
|
2152
|
+
function $e(s, t) {
|
|
2115
2153
|
return s.minY - t.minY;
|
|
2116
2154
|
}
|
|
2117
|
-
function
|
|
2155
|
+
function vt(s) {
|
|
2118
2156
|
return (s.maxX - s.minX) * (s.maxY - s.minY);
|
|
2119
2157
|
}
|
|
2120
|
-
function
|
|
2158
|
+
function nt(s) {
|
|
2121
2159
|
return s.maxX - s.minX + (s.maxY - s.minY);
|
|
2122
2160
|
}
|
|
2123
|
-
function
|
|
2161
|
+
function Je(s, t) {
|
|
2124
2162
|
const e = Math.max(s.minX, t.minX), i = Math.max(s.minY, t.minY), o = Math.min(s.maxX, t.maxX), n = Math.min(s.maxY, t.maxY);
|
|
2125
2163
|
return Math.max(0, o - e) * Math.max(0, n - i);
|
|
2126
2164
|
}
|
|
2127
|
-
function
|
|
2165
|
+
function Ct(s, t) {
|
|
2128
2166
|
return s.minX <= t.minX && s.minY <= t.minY && t.maxX <= s.maxX && t.maxY <= s.maxY;
|
|
2129
2167
|
}
|
|
2130
|
-
function
|
|
2168
|
+
function rt(s, t) {
|
|
2131
2169
|
return t.minX <= s.maxX && t.minY <= s.maxY && t.maxX >= s.minX && t.maxY >= s.minY;
|
|
2132
2170
|
}
|
|
2133
|
-
function
|
|
2171
|
+
function U(s) {
|
|
2134
2172
|
return { children: s, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
|
|
2135
2173
|
}
|
|
2136
2174
|
function Ht(s, t, e, i, o) {
|
|
@@ -2138,22 +2176,22 @@ function Ht(s, t, e, i, o) {
|
|
|
2138
2176
|
for (; n.length; ) {
|
|
2139
2177
|
if ((e = n.pop()) - (t = n.pop()) <= i) continue;
|
|
2140
2178
|
const r = t + Math.ceil((e - t) / i / 2) * i;
|
|
2141
|
-
|
|
2179
|
+
de(s, r, t, e, o), n.push(t, r, r, e);
|
|
2142
2180
|
}
|
|
2143
2181
|
}
|
|
2144
|
-
class
|
|
2182
|
+
class qe {
|
|
2145
2183
|
constructor(t) {
|
|
2146
2184
|
this._maxEntries = void 0, this._minEntries = void 0, this.data = void 0, this._maxEntries = Math.max(4, t), this._minEntries = Math.max(2, Math.ceil(0.4 * this._maxEntries)), this.clear();
|
|
2147
2185
|
}
|
|
2148
2186
|
search(t) {
|
|
2149
2187
|
let e = this.data;
|
|
2150
2188
|
const i = [];
|
|
2151
|
-
if (!
|
|
2189
|
+
if (!rt(t, e)) return i;
|
|
2152
2190
|
const o = this.toBBox, n = [];
|
|
2153
2191
|
for (; e; ) {
|
|
2154
2192
|
for (let r = 0; r < e.children.length; r++) {
|
|
2155
2193
|
const a = e.children[r], l = e.leaf ? o(a) : a;
|
|
2156
|
-
|
|
2194
|
+
rt(t, l) && (e.leaf ? i.push(a) : Ct(t, l) ? this._all(a, i) : n.push(a));
|
|
2157
2195
|
}
|
|
2158
2196
|
e = n.pop();
|
|
2159
2197
|
}
|
|
@@ -2161,13 +2199,13 @@ class Je {
|
|
|
2161
2199
|
}
|
|
2162
2200
|
collides(t) {
|
|
2163
2201
|
let e = this.data;
|
|
2164
|
-
if (
|
|
2202
|
+
if (rt(t, e)) {
|
|
2165
2203
|
const i = [];
|
|
2166
2204
|
for (; e; ) {
|
|
2167
2205
|
for (let o = 0; o < e.children.length; o++) {
|
|
2168
2206
|
const n = e.children[o], r = e.leaf ? this.toBBox(n) : n;
|
|
2169
|
-
if (
|
|
2170
|
-
if (e.leaf ||
|
|
2207
|
+
if (rt(t, r)) {
|
|
2208
|
+
if (e.leaf || Ct(t, r)) return !0;
|
|
2171
2209
|
i.push(n);
|
|
2172
2210
|
}
|
|
2173
2211
|
}
|
|
@@ -2196,7 +2234,7 @@ class Je {
|
|
|
2196
2234
|
this._insert(t, this.data.height - 1);
|
|
2197
2235
|
}
|
|
2198
2236
|
clear() {
|
|
2199
|
-
this.data =
|
|
2237
|
+
this.data = U([]);
|
|
2200
2238
|
}
|
|
2201
2239
|
remove(t) {
|
|
2202
2240
|
let e = this.data;
|
|
@@ -2207,7 +2245,7 @@ class Je {
|
|
|
2207
2245
|
const d = e.children.indexOf(t);
|
|
2208
2246
|
d !== -1 && (e.children.splice(d, 1), o.push(e), this._condense(o));
|
|
2209
2247
|
}
|
|
2210
|
-
l || e.leaf || !
|
|
2248
|
+
l || e.leaf || !Ct(e, i) ? a ? (r++, e = a.children[r], l = !1) : e = null : (o.push(e), n.push(r), r = 0, a = e, e = e.children[0]);
|
|
2211
2249
|
}
|
|
2212
2250
|
}
|
|
2213
2251
|
toBBox(t) {
|
|
@@ -2227,8 +2265,8 @@ class Je {
|
|
|
2227
2265
|
_build(t, e, i, o) {
|
|
2228
2266
|
const n = i - e + 1;
|
|
2229
2267
|
let r, a = this._maxEntries;
|
|
2230
|
-
if (n <= a) return r =
|
|
2231
|
-
o || (o = Math.ceil(Math.log(n) / Math.log(a)), a = Math.ceil(n / Math.pow(a, o - 1))), r =
|
|
2268
|
+
if (n <= a) return r = U(t.slice(e, i + 1)), R(r, this.toBBox), r;
|
|
2269
|
+
o || (o = Math.ceil(Math.log(n) / Math.log(a)), a = Math.ceil(n / Math.pow(a, o - 1))), r = U([]), r.leaf = !1, r.height = o;
|
|
2232
2270
|
const l = Math.ceil(n / a), d = l * Math.ceil(Math.sqrt(a));
|
|
2233
2271
|
Ht(t, e, i, d, this.compareMinX);
|
|
2234
2272
|
for (let h = e; h <= i; h += d) {
|
|
@@ -2245,7 +2283,7 @@ class Je {
|
|
|
2245
2283
|
for (; o.push(e), !e.leaf && o.length - 1 !== i; ) {
|
|
2246
2284
|
let a, l = 1 / 0, d = 1 / 0;
|
|
2247
2285
|
for (let h = 0; h < e.children.length; h++) {
|
|
2248
|
-
const c = e.children[h], u =
|
|
2286
|
+
const c = e.children[h], u = vt(c), g = (n = t, r = c, (Math.max(r.maxX, n.maxX) - Math.min(r.minX, n.minX)) * (Math.max(r.maxY, n.maxY) - Math.min(r.minY, n.minY)) - u);
|
|
2249
2287
|
g < d ? (d = g, l = u < l ? u : l, a = c) : g === d && u < l && (l = u, a = c);
|
|
2250
2288
|
}
|
|
2251
2289
|
e = a || e.children[0];
|
|
@@ -2261,35 +2299,35 @@ class Je {
|
|
|
2261
2299
|
_split(t, e) {
|
|
2262
2300
|
const i = t[e], o = i.children.length, n = this._minEntries;
|
|
2263
2301
|
this._chooseSplitAxis(i, n, o);
|
|
2264
|
-
const r = this._chooseSplitIndex(i, n, o), a =
|
|
2302
|
+
const r = this._chooseSplitIndex(i, n, o), a = U(i.children.splice(r, i.children.length - r));
|
|
2265
2303
|
a.height = i.height, a.leaf = i.leaf, R(i, this.toBBox), R(a, this.toBBox), e ? t[e - 1].children.push(a) : this._splitRoot(i, a);
|
|
2266
2304
|
}
|
|
2267
2305
|
_splitRoot(t, e) {
|
|
2268
|
-
this.data =
|
|
2306
|
+
this.data = U([t, e]), this.data.height = t.height + 1, this.data.leaf = !1, R(this.data, this.toBBox);
|
|
2269
2307
|
}
|
|
2270
2308
|
_chooseSplitIndex(t, e, i) {
|
|
2271
2309
|
let o, n = 1 / 0, r = 1 / 0;
|
|
2272
2310
|
for (let a = e; a <= i - e; a++) {
|
|
2273
|
-
const l = Y(t, 0, a, this.toBBox), d = Y(t, a, i, this.toBBox), h =
|
|
2311
|
+
const l = Y(t, 0, a, this.toBBox), d = Y(t, a, i, this.toBBox), h = Je(l, d), c = vt(l) + vt(d);
|
|
2274
2312
|
h < n ? (n = h, o = a, r = c < r ? c : r) : h === n && c < r && (r = c, o = a);
|
|
2275
2313
|
}
|
|
2276
2314
|
return o || i - e;
|
|
2277
2315
|
}
|
|
2278
2316
|
_chooseSplitAxis(t, e, i) {
|
|
2279
|
-
const o = t.leaf ? this.compareMinX :
|
|
2317
|
+
const o = t.leaf ? this.compareMinX : He, n = t.leaf ? this.compareMinY : $e;
|
|
2280
2318
|
this._allDistMargin(t, e, i, o) < this._allDistMargin(t, e, i, n) && t.children.sort(o);
|
|
2281
2319
|
}
|
|
2282
2320
|
_allDistMargin(t, e, i, o) {
|
|
2283
2321
|
t.children.sort(o);
|
|
2284
2322
|
const n = this.toBBox, r = Y(t, 0, e, n), a = Y(t, i - e, i, n);
|
|
2285
|
-
let l =
|
|
2323
|
+
let l = nt(r) + nt(a);
|
|
2286
2324
|
for (let d = e; d < i - e; d++) {
|
|
2287
2325
|
const h = t.children[d];
|
|
2288
|
-
z(r, t.leaf ? n(h) : h), l +=
|
|
2326
|
+
z(r, t.leaf ? n(h) : h), l += nt(r);
|
|
2289
2327
|
}
|
|
2290
2328
|
for (let d = i - e - 1; d >= e; d--) {
|
|
2291
2329
|
const h = t.children[d];
|
|
2292
|
-
z(a, t.leaf ? n(h) : h), l +=
|
|
2330
|
+
z(a, t.leaf ? n(h) : h), l += nt(a);
|
|
2293
2331
|
}
|
|
2294
2332
|
return l;
|
|
2295
2333
|
}
|
|
@@ -2300,9 +2338,9 @@ class Je {
|
|
|
2300
2338
|
for (let e, i = t.length - 1; i >= 0; i--) t[i].children.length === 0 ? i > 0 ? (e = t[i - 1].children, e.splice(e.indexOf(t[i]), 1)) : this.clear() : R(t[i], this.toBBox);
|
|
2301
2339
|
}
|
|
2302
2340
|
}
|
|
2303
|
-
class
|
|
2341
|
+
class Ze {
|
|
2304
2342
|
constructor(t) {
|
|
2305
|
-
this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new
|
|
2343
|
+
this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new qe(t && t.maxEntries ? t.maxEntries : 9), this.idToNode = /* @__PURE__ */ new Map(), this.nodeToId = /* @__PURE__ */ new Map();
|
|
2306
2344
|
}
|
|
2307
2345
|
setMaps(t, e) {
|
|
2308
2346
|
this.idToNode.set(t.id, e), this.nodeToId.set(e, t.id);
|
|
@@ -2353,14 +2391,14 @@ class qe {
|
|
|
2353
2391
|
return this.tree.collides(this.toBBox(t));
|
|
2354
2392
|
}
|
|
2355
2393
|
}
|
|
2356
|
-
const
|
|
2394
|
+
const Qe = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(s) {
|
|
2357
2395
|
const t = 16 * Math.random() | 0;
|
|
2358
2396
|
return (s == "x" ? t : 3 & t | 8).toString(16);
|
|
2359
2397
|
}), isValidId: (s) => typeof s == "string" && s.length === 36 };
|
|
2360
|
-
class
|
|
2398
|
+
class ti {
|
|
2361
2399
|
constructor(t) {
|
|
2362
2400
|
this.idStrategy = void 0, this.tracked = void 0, this.spatialIndex = void 0, this.store = void 0, this._onChange = () => {
|
|
2363
|
-
}, this.store = {}, this.spatialIndex = new
|
|
2401
|
+
}, this.store = {}, this.spatialIndex = new Ze(), this.tracked = !t || t.tracked !== !1, this.idStrategy = t && t.idStrategy ? t.idStrategy : Qe;
|
|
2364
2402
|
}
|
|
2365
2403
|
clone(t) {
|
|
2366
2404
|
return JSON.parse(JSON.stringify(t));
|
|
@@ -2375,7 +2413,7 @@ class Qe {
|
|
|
2375
2413
|
if (t.length === 0) return;
|
|
2376
2414
|
const i = this.clone(t);
|
|
2377
2415
|
i.forEach((n) => {
|
|
2378
|
-
n.id == null && (n.id = this.idStrategy.getId()), this.tracked && (n.properties.createdAt ?
|
|
2416
|
+
n.id == null && (n.id = this.idStrategy.getId()), this.tracked && (n.properties.createdAt ? Gt(n.properties.createdAt) : n.properties.createdAt = +/* @__PURE__ */ new Date(), n.properties.updatedAt ? Gt(n.properties.updatedAt) : n.properties.updatedAt = +/* @__PURE__ */ new Date());
|
|
2379
2417
|
});
|
|
2380
2418
|
const o = [];
|
|
2381
2419
|
i.forEach((n) => {
|
|
@@ -2446,13 +2484,13 @@ class Qe {
|
|
|
2446
2484
|
return Object.keys(this.store).length;
|
|
2447
2485
|
}
|
|
2448
2486
|
}
|
|
2449
|
-
const
|
|
2487
|
+
const ei = (s) => (s.geometry.type === "Polygon" || s.geometry.type === "LineString") && !_t(s);
|
|
2450
2488
|
function $t(s, t, e) {
|
|
2451
|
-
const i =
|
|
2452
|
-
let o =
|
|
2489
|
+
const i = ht(s, t);
|
|
2490
|
+
let o = ht(t, e) - i;
|
|
2453
2491
|
return o < 0 && (o += 360), 180 - Math.abs(o - 90 - 90);
|
|
2454
2492
|
}
|
|
2455
|
-
class
|
|
2493
|
+
class ii extends O {
|
|
2456
2494
|
constructor(t) {
|
|
2457
2495
|
super(t), this.mode = "angled-rectangle", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.pixelDistance = void 0, this.cursors = void 0, this.mouseMove = !1;
|
|
2458
2496
|
const e = { start: "crosshair", close: "pointer" };
|
|
@@ -2468,7 +2506,7 @@ class ei extends j {
|
|
|
2468
2506
|
this.currentCoordinate = 0, this.currentId = void 0, this.state === "drawing" && this.setStarted(), this.onFinish(t, { mode: this.mode, action: "draw" });
|
|
2469
2507
|
}
|
|
2470
2508
|
registerBehaviors(t) {
|
|
2471
|
-
this.pixelDistance = new
|
|
2509
|
+
this.pixelDistance = new pt(t);
|
|
2472
2510
|
}
|
|
2473
2511
|
start() {
|
|
2474
2512
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -2484,10 +2522,10 @@ class ei extends j {
|
|
|
2484
2522
|
const o = 1 / Math.pow(10, this.coordinatePrecision - 1), n = Math.max(1e-6, o);
|
|
2485
2523
|
i = [e[0], [t.lng, t.lat], [t.lng, t.lat - n], e[0]];
|
|
2486
2524
|
} else if (this.currentCoordinate === 2) {
|
|
2487
|
-
const o = e[0], n = e[1], r =
|
|
2488
|
-
const
|
|
2489
|
-
return
|
|
2490
|
-
}(a, d, h) === "right" ? -90 : 90), m = Xt(a, y, v), x = Xt(d, y, v), M =
|
|
2525
|
+
const o = e[0], n = e[1], r = re(o, n, this.coordinatePrecision, this.project, this.unproject), a = P(o[0], o[1]), l = P(r[0], r[1]), d = P(n[0], n[1]), h = P(t.lng, t.lat), c = I(h, a) < I(h, d), u = $t(a, l, h), g = c ? 90 - u : $t(a, l, h) - 90, p = I(l, h), y = Math.cos(w(g)) * p, v = ht(a, d) + (function(_, S, F) {
|
|
2526
|
+
const B = (F.x - S.x) * (_.y - S.y) - (F.y - S.y) * (_.x - S.x);
|
|
2527
|
+
return B > 1e-10 ? "left" : B < -1e-10 ? "right" : "left";
|
|
2528
|
+
}(a, d, h) === "right" ? -90 : 90), m = Xt(a, y, v), x = Xt(d, y, v), M = j(m.x, m.y), E = j(x.x, x.y);
|
|
2491
2529
|
i = [e[0], e[1], [E.lng, E.lat], [M.lng, M.lat], e[0]];
|
|
2492
2530
|
}
|
|
2493
2531
|
i && this.updatePolygonGeometry(this.currentId, i, C.Provisional);
|
|
@@ -2529,23 +2567,23 @@ class ei extends j {
|
|
|
2529
2567
|
return t.properties.mode === this.mode && t.geometry.type === "Polygon" && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
|
|
2530
2568
|
}
|
|
2531
2569
|
validateFeature(t) {
|
|
2532
|
-
return !!super.validateFeature(t) && t.properties.mode === this.mode &&
|
|
2570
|
+
return !!super.validateFeature(t) && t.properties.mode === this.mode && q(t, this.coordinatePrecision);
|
|
2533
2571
|
}
|
|
2534
2572
|
}
|
|
2535
|
-
class
|
|
2573
|
+
class oi {
|
|
2536
2574
|
constructor(t) {
|
|
2537
|
-
this._modes = void 0, this._mode = void 0, this._adapter = void 0, this._enabled = !1, this._store = void 0, this._eventListeners = void 0, this._instanceSelectMode = void 0, this._adapter = t.adapter, this._mode = new
|
|
2575
|
+
this._modes = void 0, this._mode = void 0, this._adapter = void 0, this._enabled = !1, this._store = void 0, this._eventListeners = void 0, this._instanceSelectMode = void 0, this._adapter = t.adapter, this._mode = new ze();
|
|
2538
2576
|
const e = /* @__PURE__ */ new Set(), i = t.modes.reduce((h, c) => {
|
|
2539
2577
|
if (e.has(c.mode)) throw new Error(`There is already a ${c.mode} mode provided`);
|
|
2540
2578
|
return e.add(c.mode), h[c.mode] = c, h;
|
|
2541
2579
|
}, {}), o = Object.keys(i);
|
|
2542
2580
|
if (o.length === 0) throw new Error("No modes provided");
|
|
2543
2581
|
o.forEach((h) => {
|
|
2544
|
-
if (i[h].type ===
|
|
2582
|
+
if (i[h].type === G.Select) {
|
|
2545
2583
|
if (this._instanceSelectMode) throw new Error("only one type of select mode can be provided");
|
|
2546
2584
|
this._instanceSelectMode = h;
|
|
2547
2585
|
}
|
|
2548
|
-
}), this._modes = f({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new
|
|
2586
|
+
}), this._modes = f({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new ti({ tracked: !!t.tracked, idStrategy: t.idStrategy ? t.idStrategy : void 0 });
|
|
2549
2587
|
const n = (h) => {
|
|
2550
2588
|
const c = [], u = this._store.copyAll().filter((g) => !h.includes(g.id) || (c.push(g), !1));
|
|
2551
2589
|
return { changed: c, unchanged: u };
|
|
@@ -2585,7 +2623,7 @@ class ii {
|
|
|
2585
2623
|
getModeStyles() {
|
|
2586
2624
|
const t = {};
|
|
2587
2625
|
return Object.keys(this._modes).forEach((e) => {
|
|
2588
|
-
t[e] = (i) => this._instanceSelectMode && i.properties[
|
|
2626
|
+
t[e] = (i) => this._instanceSelectMode && i.properties[Pt] ? this._modes[this._instanceSelectMode].styleFeature.bind(this._modes[this._instanceSelectMode])(i) : this._modes[e].styleFeature.bind(this._modes[e])(i);
|
|
2589
2627
|
}), t;
|
|
2590
2628
|
}
|
|
2591
2629
|
featuresAtLocation({ lng: t, lat: e }, i) {
|
|
@@ -2600,11 +2638,11 @@ class ii {
|
|
|
2600
2638
|
const c = h.geometry.coordinates;
|
|
2601
2639
|
for (let u = 0; u < c.length - 1; u++) {
|
|
2602
2640
|
const g = c[u], p = c[u + 1];
|
|
2603
|
-
if (
|
|
2641
|
+
if (le(l, a(g[0], g[1]), a(p[0], p[1])) < o) return !0;
|
|
2604
2642
|
}
|
|
2605
2643
|
return !1;
|
|
2606
2644
|
}
|
|
2607
|
-
return !!
|
|
2645
|
+
return !!ae([t, e], h.geometry.coordinates) || void 0;
|
|
2608
2646
|
});
|
|
2609
2647
|
}
|
|
2610
2648
|
getSelectMode() {
|
|
@@ -2701,7 +2739,7 @@ class ii {
|
|
|
2701
2739
|
i.includes(e) && i.splice(i.indexOf(e), 1);
|
|
2702
2740
|
}
|
|
2703
2741
|
}
|
|
2704
|
-
const
|
|
2742
|
+
const si = {
|
|
2705
2743
|
point: !0,
|
|
2706
2744
|
line: !0,
|
|
2707
2745
|
polygon: !0,
|
|
@@ -2710,19 +2748,24 @@ const oi = {
|
|
|
2710
2748
|
freehand: !0,
|
|
2711
2749
|
angledRectangle: !0,
|
|
2712
2750
|
select: !0
|
|
2713
|
-
},
|
|
2751
|
+
}, ni = (s) => {
|
|
2714
2752
|
const t = [];
|
|
2715
|
-
return
|
|
2753
|
+
return t.push(
|
|
2754
|
+
new Be({
|
|
2755
|
+
modeName: "render",
|
|
2756
|
+
styles: {}
|
|
2757
|
+
})
|
|
2758
|
+
), s.point === !0 && t.push(new Oe()), s.line === !0 && t.push(new ke()), s.polygon === !0 && t.push(
|
|
2716
2759
|
new Le({
|
|
2717
2760
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2718
2761
|
// @ts-ignore
|
|
2719
2762
|
validation: (e, i) => {
|
|
2720
2763
|
const o = i.updateType;
|
|
2721
|
-
return o === "finish" || o === "commit" ?
|
|
2764
|
+
return o === "finish" || o === "commit" ? ei(e) : !0;
|
|
2722
2765
|
}
|
|
2723
2766
|
})
|
|
2724
|
-
), s.rectangle === !0 && t.push(new
|
|
2725
|
-
new
|
|
2767
|
+
), s.rectangle === !0 && t.push(new We()), s.angledRectangle === !0 && t.push(new ii()), s.circle === !0 && t.push(new we()), s.freehand === !0 && t.push(new Ie()), s.select === !0 && t.push(
|
|
2768
|
+
new Ye({
|
|
2726
2769
|
flags: {
|
|
2727
2770
|
point: {
|
|
2728
2771
|
feature: {
|
|
@@ -2799,7 +2842,7 @@ const oi = {
|
|
|
2799
2842
|
})
|
|
2800
2843
|
), t;
|
|
2801
2844
|
};
|
|
2802
|
-
class
|
|
2845
|
+
class ai {
|
|
2803
2846
|
constructor(t) {
|
|
2804
2847
|
k(this, "controlContainer");
|
|
2805
2848
|
k(this, "map");
|
|
@@ -2809,19 +2852,19 @@ class ri {
|
|
|
2809
2852
|
k(this, "isExpanded", !1);
|
|
2810
2853
|
k(this, "activeMode");
|
|
2811
2854
|
k(this, "terradraw");
|
|
2812
|
-
k(this, "options",
|
|
2813
|
-
this.modeButtons = {}, this.activeMode = "", t && (this.options = Object.assign(this.options, t));
|
|
2855
|
+
k(this, "options", si);
|
|
2856
|
+
this.modeButtons = {}, this.activeMode = "render", t && (this.options = Object.assign(this.options, t));
|
|
2814
2857
|
}
|
|
2815
2858
|
getDefaultPosition() {
|
|
2816
2859
|
return "top-right";
|
|
2817
2860
|
}
|
|
2818
2861
|
onAdd(t) {
|
|
2819
2862
|
this.map = t;
|
|
2820
|
-
const e =
|
|
2863
|
+
const e = ni(this.options);
|
|
2821
2864
|
if (e.length === 0)
|
|
2822
2865
|
throw new Error("At least a mode must be enabled.");
|
|
2823
|
-
return this.terradraw = new
|
|
2824
|
-
adapter: new
|
|
2866
|
+
return this.terradraw = new oi({
|
|
2867
|
+
adapter: new pe({ map: t }),
|
|
2825
2868
|
modes: e
|
|
2826
2869
|
}), this.terradraw.start(), this.controlContainer = document.createElement("div"), this.controlContainer.classList.add("maplibregl-ctrl"), this.controlContainer.classList.add("maplibregl-ctrl-group"), this.addButton = document.createElement("button"), this.addButton.classList.add("maplibregl-terradraw-add-button"), this.addButton.type = "button", this.addButton.addEventListener("click", () => {
|
|
2827
2870
|
var o, n;
|
|
@@ -2833,7 +2876,7 @@ class ri {
|
|
|
2833
2876
|
}
|
|
2834
2877
|
this.isExpanded = !this.isExpanded;
|
|
2835
2878
|
}), e.forEach((i) => {
|
|
2836
|
-
this.addTerradrawButton(i.mode);
|
|
2879
|
+
i.mode !== "render" && this.addTerradrawButton(i.mode);
|
|
2837
2880
|
}), this.deleteButton = document.createElement("button"), this.deleteButton.classList.add("maplibregl-terradraw-add-control"), this.deleteButton.classList.add("maplibregl-terradraw-delete-button"), this.deleteButton.classList.add("hidden"), this.deleteButton.type = "button", this.deleteButton.addEventListener("click", () => {
|
|
2838
2881
|
this.terradraw && this.terradraw.enabled && (this.terradraw.clear(), this.deactivate());
|
|
2839
2882
|
}), this.controlContainer.appendChild(this.addButton), Object.values(this.modeButtons).forEach((i) => {
|
|
@@ -2848,27 +2891,32 @@ class ri {
|
|
|
2848
2891
|
this.terradraw && (this.terradraw.enabled || this.terradraw.start());
|
|
2849
2892
|
}
|
|
2850
2893
|
deactivate() {
|
|
2851
|
-
this.terradraw && this.terradraw.enabled && (this.
|
|
2894
|
+
this.terradraw && this.terradraw.enabled && (this.resetActiveMode(), this.terradraw.stop());
|
|
2852
2895
|
}
|
|
2853
2896
|
getTerraDrawInstance() {
|
|
2854
2897
|
return this.terradraw;
|
|
2855
2898
|
}
|
|
2856
2899
|
resetActiveMode() {
|
|
2857
|
-
|
|
2900
|
+
var e;
|
|
2901
|
+
if (!this.terradraw) return;
|
|
2902
|
+
this.terradraw.enabled || this.terradraw.start();
|
|
2858
2903
|
const t = document.getElementsByClassName("maplibregl-terradraw-add-control");
|
|
2859
|
-
for (let
|
|
2860
|
-
const
|
|
2861
|
-
|
|
2904
|
+
for (let i = 0; i < t.length; i++) {
|
|
2905
|
+
const o = t.item(i);
|
|
2906
|
+
o && o.classList.remove("active");
|
|
2862
2907
|
}
|
|
2908
|
+
this.activeMode = "render", (e = this.terradraw) == null || e.setMode("render");
|
|
2863
2909
|
}
|
|
2864
2910
|
addTerradrawButton(t) {
|
|
2865
2911
|
const e = document.createElement("button");
|
|
2866
2912
|
e.classList.add("maplibregl-terradraw-add-control"), e.classList.add(`maplibregl-terradraw-add-${t}-button`), e.classList.add("hidden"), e.type = "button", e.addEventListener("click", () => {
|
|
2867
|
-
|
|
2913
|
+
if (!this.terradraw) return;
|
|
2914
|
+
const i = e.classList.contains("active");
|
|
2915
|
+
this.activate(), this.resetActiveMode(), i || (this.terradraw.setMode(t), this.activeMode = t, e.classList.add("active"));
|
|
2868
2916
|
}), this.modeButtons[t] = e;
|
|
2869
2917
|
}
|
|
2870
2918
|
}
|
|
2871
2919
|
export {
|
|
2872
|
-
|
|
2920
|
+
ai as default
|
|
2873
2921
|
};
|
|
2874
2922
|
//# sourceMappingURL=maplibre-gl-terradraw.es.js.map
|