@watergis/maplibre-gl-terradraw 1.0.1 → 1.1.0
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 +692 -638
- 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/controls/MaplibreTerradrawControl.d.ts +3 -1
- package/dist/types/controls/MaplibreTerradrawControl.d.ts.map +1 -1
- package/dist/types/interfaces/EventTypes.d.ts +1 -1
- package/dist/types/interfaces/EventTypes.d.ts.map +1 -1
- package/package.json +10 -10
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var A = (o, e, t) =>
|
|
1
|
+
var vt = Object.defineProperty;
|
|
2
|
+
var St = (o, e, t) => e in o ? vt(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var A = (o, e, t) => St(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
function M() {
|
|
5
5
|
return M = Object.assign ? Object.assign.bind() : function(o) {
|
|
6
6
|
for (var e = 1; e < arguments.length; e++) {
|
|
@@ -10,25 +10,25 @@ function M() {
|
|
|
10
10
|
return o;
|
|
11
11
|
}, M.apply(null, arguments);
|
|
12
12
|
}
|
|
13
|
-
var
|
|
13
|
+
var w;
|
|
14
14
|
(function(o) {
|
|
15
15
|
o.Commit = "commit", o.Provisional = "provisional", o.Finish = "finish";
|
|
16
|
-
})(
|
|
17
|
-
const
|
|
18
|
-
function
|
|
16
|
+
})(w || (w = {}));
|
|
17
|
+
const V = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT: "selectionPoint" }, q = "edited", ne = "closingPoint", we = "snappingPoint";
|
|
18
|
+
function Pe(o) {
|
|
19
19
|
return !!(o && typeof o == "object" && o !== null && !Array.isArray(o));
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function We(o) {
|
|
22
22
|
return !!function(e) {
|
|
23
23
|
return typeof e == "number" && !isNaN(new Date(e).valueOf());
|
|
24
24
|
}(o);
|
|
25
25
|
}
|
|
26
|
-
const
|
|
27
|
-
var
|
|
26
|
+
const xt = "Feature mode property does not match the mode being added to";
|
|
27
|
+
var Y;
|
|
28
28
|
(function(o) {
|
|
29
29
|
o.Drawing = "drawing", o.Select = "select", o.Static = "static", o.Render = "render";
|
|
30
|
-
})(
|
|
31
|
-
class
|
|
30
|
+
})(Y || (Y = {}));
|
|
31
|
+
class B {
|
|
32
32
|
get state() {
|
|
33
33
|
return this._state;
|
|
34
34
|
}
|
|
@@ -45,7 +45,7 @@ class N {
|
|
|
45
45
|
registerBehaviors(e) {
|
|
46
46
|
}
|
|
47
47
|
constructor(e) {
|
|
48
|
-
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 =
|
|
48
|
+
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 = Y.Drawing, this.mode = "base", this._state = "unregistered", this._styles = e && e.styles ? M({}, e.styles) : {}, this.pointerDistance = e && e.pointerDistance || 40, this.validate = e && e.validation, this.projection = e && e.projection || "web-mercator";
|
|
49
49
|
}
|
|
50
50
|
setDrawing() {
|
|
51
51
|
if (this._state !== "started") throw new Error("Mode must be unregistered or stopped to start");
|
|
@@ -70,9 +70,9 @@ class N {
|
|
|
70
70
|
if (this._state === "unregistered") throw new Error("Mode must be registered");
|
|
71
71
|
const t = function(i, n) {
|
|
72
72
|
let s;
|
|
73
|
-
if (
|
|
73
|
+
if (Pe(i)) if (i.id == null) s = "Feature has no id";
|
|
74
74
|
else if (typeof i.id != "string" && typeof i.id != "number") s = "Feature must be string or number as per GeoJSON spec";
|
|
75
|
-
else if (n(i.id)) if (
|
|
75
|
+
else if (n(i.id)) if (Pe(i.geometry)) if (Pe(i.properties)) if (typeof i.geometry.type == "string" && ["Polygon", "LineString", "Point"].includes(i.geometry.type)) if (Array.isArray(i.geometry.coordinates)) {
|
|
76
76
|
if (!i.properties.mode || typeof i.properties.mode != "string") return { valid: !1, reason: "Feature does not have a valid mode property" };
|
|
77
77
|
} else s = "Feature coordinates is not an array";
|
|
78
78
|
else s = "Feature is not Point, LineString or Polygon";
|
|
@@ -83,14 +83,14 @@ class N {
|
|
|
83
83
|
return s ? { valid: !1, reason: s } : { valid: !0 };
|
|
84
84
|
}(e, this.store.idStrategy.isValidId);
|
|
85
85
|
if (this.validate) {
|
|
86
|
-
const i = this.validate(e, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
86
|
+
const i = this.validate(e, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: w.Provisional });
|
|
87
87
|
return { valid: t.valid && i.valid, reason: i.reason };
|
|
88
88
|
}
|
|
89
89
|
return { valid: t.valid, reason: t.reason };
|
|
90
90
|
}
|
|
91
91
|
validateModeFeature(e, t) {
|
|
92
92
|
const i = this.performFeatureValidation(e);
|
|
93
|
-
return i.valid ? e.properties.mode !== this.mode ? { valid: !1, reason:
|
|
93
|
+
return i.valid ? e.properties.mode !== this.mode ? { valid: !1, reason: xt } : t(e) : { valid: !1, reason: i.reason };
|
|
94
94
|
}
|
|
95
95
|
onFinish(e, t) {
|
|
96
96
|
}
|
|
@@ -122,43 +122,43 @@ class N {
|
|
|
122
122
|
return e === void 0 ? t : typeof e == "function" ? e(i) : e;
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
class
|
|
125
|
+
class Mt extends B {
|
|
126
126
|
constructor(...e) {
|
|
127
|
-
super(...e), this.type =
|
|
127
|
+
super(...e), this.type = Y.Select;
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function T(o, e) {
|
|
131
131
|
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);
|
|
132
132
|
return 2 * Math.atan2(Math.sqrt(l), Math.sqrt(1 - l)) * 6371e3 / 1e3;
|
|
133
133
|
}
|
|
134
|
-
const
|
|
135
|
-
function
|
|
134
|
+
const Qe = 63710088e-1;
|
|
135
|
+
function E(o) {
|
|
136
136
|
return o % 360 * Math.PI / 180;
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function et(o) {
|
|
139
139
|
return o / 6371.0088;
|
|
140
140
|
}
|
|
141
141
|
function U(o) {
|
|
142
142
|
return o % (2 * Math.PI) * 180 / Math.PI;
|
|
143
143
|
}
|
|
144
|
-
function
|
|
144
|
+
function F(o, e = 9) {
|
|
145
145
|
const t = Math.pow(10, e);
|
|
146
146
|
return Math.round(o * t) / t;
|
|
147
147
|
}
|
|
148
|
-
const
|
|
149
|
-
function
|
|
150
|
-
const i =
|
|
148
|
+
const je = 57.29577951308232, Be = 0.017453292519943295, ce = 6378137, x = (o, e) => ({ x: o === 0 ? 0 : o * Be * ce, y: e === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + e * Be / 2)) * ce }), L = (o, e) => ({ lng: o === 0 ? 0 : je * (o / ce), lat: e === 0 ? 0 : (2 * Math.atan(Math.exp(e / ce)) - Math.PI / 2) * je });
|
|
149
|
+
function It(o, e, t) {
|
|
150
|
+
const i = E(o[0]), n = E(o[1]), s = E(t), r = et(e), a = Math.asin(Math.sin(n) * Math.cos(r) + Math.cos(n) * Math.sin(r) * Math.cos(s));
|
|
151
151
|
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)];
|
|
152
152
|
}
|
|
153
153
|
function Ne(o) {
|
|
154
154
|
const { center: e, radiusKilometers: t, coordinatePrecision: i } = o, n = o.steps ? o.steps : 64, s = [];
|
|
155
155
|
for (let r = 0; r < n; r++) {
|
|
156
|
-
const a =
|
|
157
|
-
s.push([
|
|
156
|
+
const a = It(e, t, -360 * r / n);
|
|
157
|
+
s.push([F(a[0], i), F(a[1], i)]);
|
|
158
158
|
}
|
|
159
159
|
return s.push(s[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [s] }, properties: {} };
|
|
160
160
|
}
|
|
161
|
-
function
|
|
161
|
+
function be(o) {
|
|
162
162
|
let e;
|
|
163
163
|
if (o.geometry.type === "Polygon") e = o.geometry.coordinates;
|
|
164
164
|
else {
|
|
@@ -172,38 +172,38 @@ function Me(o) {
|
|
|
172
172
|
return s < 0 || s > 1;
|
|
173
173
|
}
|
|
174
174
|
function n(s, r, a, l) {
|
|
175
|
-
const d = e[s][r],
|
|
176
|
-
if (
|
|
177
|
-
const v =
|
|
178
|
-
return
|
|
179
|
-
}(d,
|
|
175
|
+
const d = e[s][r], h = e[s][r + 1], c = e[a][l], u = e[a][l + 1], p = function(C, f, m, P) {
|
|
176
|
+
if (re(C, m) || re(C, P) || re(f, m) || re(P, m)) return null;
|
|
177
|
+
const v = C[0], S = C[1], I = f[0], b = f[1], O = m[0], N = m[1], _ = P[0], j = P[1], R = (v - I) * (N - j) - (S - b) * (O - _);
|
|
178
|
+
return R === 0 ? null : [((v * b - S * I) * (O - _) - (v - I) * (O * j - N * _)) / R, ((v * b - S * I) * (N - j) - (S - b) * (O * j - N * _)) / R];
|
|
179
|
+
}(d, h, c, u);
|
|
180
180
|
if (p === null) return;
|
|
181
181
|
let g, y;
|
|
182
|
-
g =
|
|
182
|
+
g = h[0] !== d[0] ? (p[0] - d[0]) / (h[0] - d[0]) : (p[1] - d[1]) / (h[1] - d[1]), y = u[0] !== c[0] ? (p[0] - c[0]) / (u[0] - c[0]) : (p[1] - c[1]) / (u[1] - c[1]), i(g) || i(y) || (p.toString(), t.push(p));
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
-
function
|
|
185
|
+
function re(o, e) {
|
|
186
186
|
return o[0] === e[0] && o[1] === e[1];
|
|
187
187
|
}
|
|
188
|
-
function
|
|
189
|
-
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 &&
|
|
188
|
+
function ye(o, e) {
|
|
189
|
+
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 && Ae(o[0]) <= e && Ae(o[1]) <= e;
|
|
190
190
|
var t, i;
|
|
191
191
|
}
|
|
192
|
-
function
|
|
192
|
+
function Ae(o) {
|
|
193
193
|
let e = 1, t = 0;
|
|
194
194
|
for (; Math.round(o * e) / e !== o; ) e *= 10, t++;
|
|
195
195
|
return t;
|
|
196
196
|
}
|
|
197
|
-
const wt = "Feature has holes", bt = "Feature has less than 4 coordinates",
|
|
198
|
-
function
|
|
199
|
-
return o.geometry.type !== "Polygon" ? { valid: !1, reason: "Feature is not a Polygon" } : o.geometry.coordinates.length !== 1 ? { valid: !1, reason: wt } : o.geometry.coordinates[0].length < 4 ? { valid: !1, reason: bt } : o.geometry.coordinates[0].every((n) =>
|
|
197
|
+
const wt = "Feature has holes", bt = "Feature has less than 4 coordinates", Ft = "Feature has invalid coordinates", Et = "Feature coordinates are not closed";
|
|
198
|
+
function fe(o, e) {
|
|
199
|
+
return o.geometry.type !== "Polygon" ? { valid: !1, reason: "Feature is not a Polygon" } : o.geometry.coordinates.length !== 1 ? { valid: !1, reason: wt } : o.geometry.coordinates[0].length < 4 ? { valid: !1, reason: bt } : o.geometry.coordinates[0].every((n) => ye(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: Et } : { valid: !0 } : { valid: !1, reason: Ft };
|
|
200
200
|
var t, i;
|
|
201
201
|
}
|
|
202
|
-
function
|
|
203
|
-
const t =
|
|
204
|
-
return t.valid ?
|
|
202
|
+
function oe(o, e) {
|
|
203
|
+
const t = fe(o, e);
|
|
204
|
+
return t.valid ? be(o) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : t;
|
|
205
205
|
}
|
|
206
|
-
class
|
|
206
|
+
class tt extends B {
|
|
207
207
|
constructor(e) {
|
|
208
208
|
var t;
|
|
209
209
|
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;
|
|
@@ -220,7 +220,7 @@ class et extends N {
|
|
|
220
220
|
const e = this.currentCircleId;
|
|
221
221
|
if (this.validate && e) {
|
|
222
222
|
const t = this.store.getGeometryCopy(e);
|
|
223
|
-
if (!this.validate({ type: "Feature", id: e, geometry: t, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
223
|
+
if (!this.validate({ type: "Feature", id: e, geometry: t, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: w.Finish }).valid) return;
|
|
224
224
|
}
|
|
225
225
|
this.cursorMovedAfterInitialCursorDown = !1, this.center = void 0, this.currentCircleId = void 0, this.clickCount = 0, this.state === "drawing" && this.setStarted(), this.onFinish(e, { mode: this.mode, action: "draw" });
|
|
226
226
|
}
|
|
@@ -264,24 +264,24 @@ class et extends N {
|
|
|
264
264
|
return e.type === "Feature" && e.geometry.type === "Polygon" && e.properties.mode === this.mode && (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;
|
|
265
265
|
}
|
|
266
266
|
validateFeature(e) {
|
|
267
|
-
return this.validateModeFeature(e, (t) =>
|
|
267
|
+
return this.validateModeFeature(e, (t) => oe(t, this.coordinatePrecision));
|
|
268
268
|
}
|
|
269
269
|
updateCircle(e) {
|
|
270
270
|
if (this.clickCount === 1 && this.center && this.currentCircleId) {
|
|
271
|
-
const t =
|
|
271
|
+
const t = T(this.center, [e.lng, e.lat]);
|
|
272
272
|
let i;
|
|
273
273
|
if (this.projection === "web-mercator") {
|
|
274
274
|
const n = function(s, r) {
|
|
275
|
-
const a = 1e3 *
|
|
275
|
+
const a = 1e3 * T(s, r);
|
|
276
276
|
if (a === 0) return 1;
|
|
277
|
-
const { x: l, y: d } = x(s[0], s[1]), { x:
|
|
278
|
-
return Math.sqrt(Math.pow(
|
|
277
|
+
const { x: l, y: d } = x(s[0], s[1]), { x: h, y: c } = x(r[0], r[1]);
|
|
278
|
+
return Math.sqrt(Math.pow(h - l, 2) + Math.pow(c - d, 2)) / a;
|
|
279
279
|
}(this.center, [e.lng, e.lat]);
|
|
280
280
|
i = function(s) {
|
|
281
|
-
const { center: r, radiusKilometers: a, coordinatePrecision: l } = s, d = s.steps ? s.steps : 64,
|
|
282
|
-
for (let
|
|
283
|
-
const f = 360 *
|
|
284
|
-
y.push([
|
|
281
|
+
const { center: r, radiusKilometers: a, coordinatePrecision: l } = s, d = s.steps ? s.steps : 64, h = 1e3 * a, [c, u] = r, { x: p, y: g } = x(c, u), y = [];
|
|
282
|
+
for (let C = 0; C < d; C++) {
|
|
283
|
+
const f = 360 * C / d * Math.PI / 180, m = h * Math.cos(f), P = h * Math.sin(f), [v, S] = [p + m, g + P], { lng: I, lat: b } = L(v, S);
|
|
284
|
+
y.push([F(I, l), F(b, l)]);
|
|
285
285
|
}
|
|
286
286
|
return y.push(y[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [y] }, properties: {} };
|
|
287
287
|
}({ center: this.center, radiusKilometers: t * n, coordinatePrecision: this.coordinatePrecision });
|
|
@@ -289,7 +289,7 @@ class et extends N {
|
|
|
289
289
|
if (this.projection !== "globe") throw new Error("Invalid projection");
|
|
290
290
|
i = Ne({ center: this.center, radiusKilometers: t, coordinatePrecision: this.coordinatePrecision });
|
|
291
291
|
}
|
|
292
|
-
if (this.validate && !this.validate({ type: "Feature", id: this.currentCircleId, geometry: i.geometry, properties: { radiusKilometers: t } }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
292
|
+
if (this.validate && !this.validate({ type: "Feature", id: this.currentCircleId, geometry: i.geometry, properties: { radiusKilometers: t } }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: w.Provisional }).valid) return;
|
|
293
293
|
this.store.updateGeometry([{ id: this.currentCircleId, geometry: i.geometry }]), this.store.updateProperty([{ id: this.currentCircleId, property: "radiusKilometers", value: t }]);
|
|
294
294
|
}
|
|
295
295
|
}
|
|
@@ -298,7 +298,7 @@ const D = (o, e) => {
|
|
|
298
298
|
const { x: t, y: i } = o, { x: n, y: s } = e, r = n - t, a = s - i;
|
|
299
299
|
return Math.sqrt(a * a + r * r);
|
|
300
300
|
};
|
|
301
|
-
class
|
|
301
|
+
class it extends B {
|
|
302
302
|
constructor(e) {
|
|
303
303
|
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;
|
|
304
304
|
const t = { start: "crosshair", close: "pointer" };
|
|
@@ -315,7 +315,7 @@ class tt extends N {
|
|
|
315
315
|
const e = this.currentId;
|
|
316
316
|
if (this.validate && e) {
|
|
317
317
|
const t = this.store.getGeometryCopy(e);
|
|
318
|
-
if (!this.validate({ type: "Feature", id: e, geometry: t, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
318
|
+
if (!this.validate({ type: "Feature", id: e, geometry: t, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: w.Finish }).valid) return;
|
|
319
319
|
}
|
|
320
320
|
this.closingPointId && this.store.delete([this.closingPointId]), this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.hasLeftStartingPoint = !1, this.state === "drawing" && this.setStarted(), this.onFinish(e, { mode: this.mode, action: "draw" });
|
|
321
321
|
}
|
|
@@ -327,8 +327,8 @@ class tt extends N {
|
|
|
327
327
|
}
|
|
328
328
|
onMouseMove(e) {
|
|
329
329
|
if (this.currentId === void 0 || this.startingClick === !1) return;
|
|
330
|
-
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 = D({ x: r, y: a }, { x: e.containerX, y: e.containerY }), [d,
|
|
331
|
-
if (D({ x:
|
|
330
|
+
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 = D({ x: r, y: a }, { x: e.containerX, y: e.containerY }), [d, h] = t.coordinates[0][0], { x: c, y: u } = this.project(d, h);
|
|
331
|
+
if (D({ x: c, y: u }, { x: e.containerX, y: e.containerY }) < this.pointerDistance) {
|
|
332
332
|
if (this.autoClose && this.hasLeftStartingPoint && (this.preventNewFeature = !0, setTimeout(() => {
|
|
333
333
|
this.preventNewFeature = !1;
|
|
334
334
|
}, this.autoCloseTimeout), this.close()), this.setCursor(this.cursors.close), this.preventPointsNearClose) return;
|
|
@@ -336,12 +336,12 @@ class tt extends N {
|
|
|
336
336
|
if (l < this.minDistance) return;
|
|
337
337
|
t.coordinates[0].pop();
|
|
338
338
|
const p = { type: "Polygon", coordinates: [[...t.coordinates[0], [e.lng, e.lat], t.coordinates[0][0]]] };
|
|
339
|
-
this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: p, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
339
|
+
this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: p, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: w.Provisional }).valid || this.store.updateGeometry([{ id: this.currentId, geometry: p }]);
|
|
340
340
|
}
|
|
341
341
|
onClick(e) {
|
|
342
342
|
if (!this.preventNewFeature) {
|
|
343
343
|
if (this.startingClick === !1) {
|
|
344
|
-
const [t, i] = this.store.create([{ geometry: { type: "Polygon", coordinates: [[[e.lng, e.lat], [e.lng, e.lat], [e.lng, e.lat], [e.lng, e.lat]]] }, properties: { mode: this.mode } }, { geometry: { type: "Point", coordinates: [e.lng, e.lat] }, properties: { mode: this.mode, [
|
|
344
|
+
const [t, i] = this.store.create([{ geometry: { type: "Polygon", coordinates: [[[e.lng, e.lat], [e.lng, e.lat], [e.lng, e.lat], [e.lng, e.lat]]] }, properties: { mode: this.mode } }, { geometry: { type: "Point", coordinates: [e.lng, e.lat] }, properties: { mode: this.mode, [ne]: !0 } }]);
|
|
345
345
|
return this.currentId = t, this.closingPointId = i, this.startingClick = !0, void this.setDrawing();
|
|
346
346
|
}
|
|
347
347
|
this.close();
|
|
@@ -371,7 +371,7 @@ class tt extends N {
|
|
|
371
371
|
return e.type === "Feature" && e.geometry.type === "Polygon" && e.properties.mode === this.mode ? (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) : (e.type === "Feature" && e.geometry.type === "Point" && e.properties.mode === this.mode && (t.pointWidth = this.getNumericStylingValue(this.styles.closingPointWidth, t.pointWidth, e), t.pointColor = this.getHexColorStylingValue(this.styles.closingPointColor, t.pointColor, e), t.pointOutlineColor = this.getHexColorStylingValue(this.styles.closingPointOutlineColor, t.pointOutlineColor, e), t.pointOutlineWidth = this.getNumericStylingValue(this.styles.closingPointOutlineWidth, 2, e), t.zIndex = 40), t);
|
|
372
372
|
}
|
|
373
373
|
validateFeature(e) {
|
|
374
|
-
return this.validateModeFeature(e, (t) =>
|
|
374
|
+
return this.validateModeFeature(e, (t) => fe(t, this.coordinatePrecision));
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
377
|
class W {
|
|
@@ -379,20 +379,20 @@ class W {
|
|
|
379
379
|
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;
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
|
-
function
|
|
382
|
+
function nt({ unproject: o, point: e, pointerDistance: t }) {
|
|
383
383
|
const i = t / 2, { x: n, y: s } = e;
|
|
384
384
|
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])] } };
|
|
385
385
|
}
|
|
386
|
-
class
|
|
386
|
+
class me extends W {
|
|
387
387
|
constructor(e) {
|
|
388
388
|
super(e);
|
|
389
389
|
}
|
|
390
390
|
create(e) {
|
|
391
391
|
const { containerX: t, containerY: i } = e;
|
|
392
|
-
return
|
|
392
|
+
return nt({ unproject: this.unproject, point: { x: t, y: i }, pointerDistance: this.pointerDistance });
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
|
-
class
|
|
395
|
+
class Ce extends W {
|
|
396
396
|
constructor(e) {
|
|
397
397
|
super(e);
|
|
398
398
|
}
|
|
@@ -401,12 +401,12 @@ class be extends W {
|
|
|
401
401
|
return D({ x: i, y: n }, { x: e.containerX, y: e.containerY });
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
|
-
class
|
|
404
|
+
class st extends W {
|
|
405
405
|
constructor(e, t, i) {
|
|
406
|
-
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;
|
|
406
|
+
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)).coordinate, this.getSnappableCoordinate = (n, s) => this.getSnappable(n, (r) => !!(r.properties && r.properties.mode === this.mode && r.id !== s)).coordinate, this.config = e, this.pixelDistance = t, this.clickBoundingBox = i;
|
|
407
407
|
}
|
|
408
408
|
getSnappable(e, t) {
|
|
409
|
-
const i = this.clickBoundingBox.create(e), n = this.store.search(i, t), s = {
|
|
409
|
+
const i = this.clickBoundingBox.create(e), n = this.store.search(i, t), s = { featureId: void 0, featureCoordinateIndex: void 0, coordinate: void 0, minDist: 1 / 0 };
|
|
410
410
|
return n.forEach((r) => {
|
|
411
411
|
let a;
|
|
412
412
|
if (r.geometry.type === "Polygon") a = r.geometry.coordinates[0];
|
|
@@ -414,101 +414,101 @@ class nt extends W {
|
|
|
414
414
|
if (r.geometry.type !== "LineString") return;
|
|
415
415
|
a = r.geometry.coordinates;
|
|
416
416
|
}
|
|
417
|
-
a.forEach((l) => {
|
|
418
|
-
const
|
|
419
|
-
|
|
417
|
+
a.forEach((l, d) => {
|
|
418
|
+
const h = this.pixelDistance.measure(e, l);
|
|
419
|
+
h < s.minDist && h < this.pointerDistance && (s.coordinate = l, s.minDist = h, s.featureId = r.id, s.featureCoordinateIndex = d);
|
|
420
420
|
});
|
|
421
|
-
}), s
|
|
421
|
+
}), s;
|
|
422
422
|
}
|
|
423
423
|
}
|
|
424
|
-
function
|
|
425
|
-
const i =
|
|
424
|
+
function Ge(o, e, t) {
|
|
425
|
+
const i = E(o[0]), n = E(o[1]), s = E(t), r = et(e), a = Math.asin(Math.sin(n) * Math.cos(r) + Math.cos(n) * Math.sin(r) * Math.cos(s));
|
|
426
426
|
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)];
|
|
427
427
|
}
|
|
428
|
-
function
|
|
429
|
-
const n =
|
|
428
|
+
function se({ x: o, y: e }, t, i) {
|
|
429
|
+
const n = E(i);
|
|
430
430
|
return { x: o + t * Math.cos(n), y: e + t * Math.sin(n) };
|
|
431
431
|
}
|
|
432
|
-
function
|
|
433
|
-
const t =
|
|
432
|
+
function Te(o, e) {
|
|
433
|
+
const t = E(o[0]), i = E(e[0]), n = E(o[1]), s = E(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);
|
|
434
434
|
return U(Math.atan2(r, a));
|
|
435
435
|
}
|
|
436
436
|
function G({ x: o, y: e }, { x: t, y: i }) {
|
|
437
437
|
let n = Math.atan2(i - e, t - o);
|
|
438
438
|
return n *= 180 / Math.PI, n > 180 ? n -= 360 : n < -180 && (n += 360), n;
|
|
439
439
|
}
|
|
440
|
-
function
|
|
440
|
+
function X(o) {
|
|
441
441
|
return (o + 360) % 360;
|
|
442
442
|
}
|
|
443
|
-
function
|
|
443
|
+
function Dt(o, e, t) {
|
|
444
444
|
const i = [], n = o.length;
|
|
445
445
|
let s, r, a, l = 0;
|
|
446
|
-
for (let
|
|
446
|
+
for (let h = 0; h < o.length && !(e >= l && h === o.length - 1); h++) {
|
|
447
447
|
if (l > e && i.length === 0) {
|
|
448
|
-
if (s = e - l, !s) return i.push(o[
|
|
449
|
-
r =
|
|
448
|
+
if (s = e - l, !s) return i.push(o[h]), i;
|
|
449
|
+
r = Te(o[h], o[h - 1]) - 180, a = Ge(o[h], s, r), i.push(a);
|
|
450
450
|
}
|
|
451
|
-
if (l >= t) return s = t - l, s ? (r =
|
|
452
|
-
if (l >= e && i.push(o[
|
|
453
|
-
l +=
|
|
451
|
+
if (l >= t) return s = t - l, s ? (r = Te(o[h], o[h - 1]) - 180, a = Ge(o[h], s, r), i.push(a), i) : (i.push(o[h]), i);
|
|
452
|
+
if (l >= e && i.push(o[h]), h === o.length - 1) return i;
|
|
453
|
+
l += T(o[h], o[h + 1]);
|
|
454
454
|
}
|
|
455
455
|
if (l < e && o.length === n) throw new Error("Start position is beyond line");
|
|
456
456
|
const d = o[o.length - 1];
|
|
457
457
|
return [d, d];
|
|
458
458
|
}
|
|
459
|
-
function
|
|
459
|
+
function ae(o) {
|
|
460
460
|
return o * (Math.PI / 180);
|
|
461
461
|
}
|
|
462
462
|
function Ve(o) {
|
|
463
463
|
return o * (180 / Math.PI);
|
|
464
464
|
}
|
|
465
|
-
class
|
|
465
|
+
class Ot extends W {
|
|
466
466
|
constructor(e) {
|
|
467
467
|
super(e), this.config = void 0, this.config = e;
|
|
468
468
|
}
|
|
469
469
|
generateInsertionCoordinates(e, t, i) {
|
|
470
470
|
const n = [e, t];
|
|
471
471
|
let s = 0;
|
|
472
|
-
for (let d = 0; d < n.length - 1; d++) s +=
|
|
472
|
+
for (let d = 0; d < n.length - 1; d++) s += T(n[0], n[1]);
|
|
473
473
|
if (s <= i) return n;
|
|
474
474
|
let r = s / i - 1;
|
|
475
475
|
Number.isInteger(r) || (r = Math.floor(r) + 1);
|
|
476
476
|
const a = [];
|
|
477
477
|
for (let d = 0; d < r; d++) {
|
|
478
|
-
const
|
|
479
|
-
a.push(
|
|
478
|
+
const h = Dt(n, i * d, i * (d + 1));
|
|
479
|
+
a.push(h);
|
|
480
480
|
}
|
|
481
481
|
const l = [];
|
|
482
482
|
for (let d = 0; d < a.length; d++) l.push(a[d][1]);
|
|
483
483
|
return this.limitCoordinates(l);
|
|
484
484
|
}
|
|
485
485
|
generateInsertionGeodesicCoordinates(e, t, i) {
|
|
486
|
-
const n =
|
|
487
|
-
const d = [],
|
|
486
|
+
const n = T(e, t), s = function(r, a, l) {
|
|
487
|
+
const d = [], h = ae(r[1]), c = ae(r[0]), u = ae(a[1]), p = ae(a[0]);
|
|
488
488
|
l += 1;
|
|
489
|
-
const g = 2 * Math.asin(Math.sqrt(Math.sin((u -
|
|
489
|
+
const g = 2 * Math.asin(Math.sqrt(Math.sin((u - h) / 2) ** 2 + Math.cos(h) * Math.cos(u) * Math.sin((p - c) / 2) ** 2));
|
|
490
490
|
if (g === 0 || isNaN(g)) return d;
|
|
491
491
|
for (let y = 0; y <= l; y++) {
|
|
492
|
-
const
|
|
493
|
-
if (isNaN(
|
|
494
|
-
const
|
|
495
|
-
isNaN(
|
|
492
|
+
const C = y / l, f = Math.sin((1 - C) * g) / Math.sin(g), m = Math.sin(C * g) / Math.sin(g), P = f * Math.cos(h) * Math.cos(c) + m * Math.cos(u) * Math.cos(p), v = f * Math.cos(h) * Math.sin(c) + m * Math.cos(u) * Math.sin(p), S = f * Math.sin(h) + m * Math.sin(u);
|
|
493
|
+
if (isNaN(P) || isNaN(v) || isNaN(S)) continue;
|
|
494
|
+
const I = Math.atan2(S, Math.sqrt(P ** 2 + v ** 2)), b = Math.atan2(v, P);
|
|
495
|
+
isNaN(I) || isNaN(b) || d.push([Ve(b), Ve(I)]);
|
|
496
496
|
}
|
|
497
497
|
return d.slice(1, -1);
|
|
498
498
|
}(e, t, Math.floor(n / i));
|
|
499
499
|
return this.limitCoordinates(s);
|
|
500
500
|
}
|
|
501
501
|
limitCoordinates(e) {
|
|
502
|
-
return e.map((t) => [
|
|
502
|
+
return e.map((t) => [F(t[0], this.config.coordinatePrecision), F(t[1], this.config.coordinatePrecision)]);
|
|
503
503
|
}
|
|
504
504
|
}
|
|
505
|
-
function
|
|
505
|
+
function Z(o, e) {
|
|
506
506
|
return o[0] === e[0] && o[1] === e[1];
|
|
507
507
|
}
|
|
508
|
-
function
|
|
509
|
-
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) =>
|
|
508
|
+
function ot(o, e) {
|
|
509
|
+
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) => ye(t, e)) ? { valid: !0 } : { valid: !1, reason: "Feature has invalid coordinates" };
|
|
510
510
|
}
|
|
511
|
-
class
|
|
511
|
+
class rt extends B {
|
|
512
512
|
constructor(e) {
|
|
513
513
|
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;
|
|
514
514
|
const t = { start: "crosshair", close: "pointer" };
|
|
@@ -522,7 +522,7 @@ class ot extends N {
|
|
|
522
522
|
close() {
|
|
523
523
|
if (this.currentId === void 0) return;
|
|
524
524
|
const e = this.store.getGeometryCopy(this.currentId);
|
|
525
|
-
e.coordinates.pop(), this.updateGeometries([...e.coordinates], void 0,
|
|
525
|
+
e.coordinates.pop(), this.updateGeometries([...e.coordinates], void 0, w.Commit);
|
|
526
526
|
const t = this.currentId;
|
|
527
527
|
this.closingPointId && this.store.delete([this.closingPointId]), this.snappedPointId && this.store.delete([this.snappedPointId]), this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.snappedPointId = void 0, this.lastCommitedCoordinates = void 0, this.state === "drawing" && this.setStarted(), this.onFinish(t, { mode: this.mode, action: "draw" });
|
|
528
528
|
}
|
|
@@ -536,7 +536,7 @@ class ot extends N {
|
|
|
536
536
|
generateInsertCoordinates(e, t) {
|
|
537
537
|
if (!this.insertCoordinates || !this.lastCommitedCoordinates) throw new Error("Not able to insert coordinates");
|
|
538
538
|
if (this.insertCoordinates.strategy !== "amount") throw new Error("Strategy does not exist");
|
|
539
|
-
const i =
|
|
539
|
+
const i = T(e, t) / (this.insertCoordinates.value + 1);
|
|
540
540
|
let n = [];
|
|
541
541
|
return this.projection === "globe" ? n = this.insertPoint.generateInsertionGeodesicCoordinates(e, t, i) : this.projection === "web-mercator" && (n = this.insertPoint.generateInsertionCoordinates(e, t, i)), n;
|
|
542
542
|
}
|
|
@@ -549,7 +549,7 @@ class ot extends N {
|
|
|
549
549
|
const t = this.store.getGeometryCopy(this.currentId).coordinates, [i] = this.store.create([{ geometry: { type: "Point", coordinates: [...e] }, properties: { mode: this.mode } }]);
|
|
550
550
|
this.closingPointId = i, this.setCursor(this.cursors.close);
|
|
551
551
|
const n = [...t, e];
|
|
552
|
-
this.updateGeometries(n, void 0,
|
|
552
|
+
this.updateGeometries(n, void 0, w.Commit), this.currentCoordinate++;
|
|
553
553
|
}
|
|
554
554
|
updateToLine(e, t) {
|
|
555
555
|
if (!this.currentId) return;
|
|
@@ -557,10 +557,10 @@ class ot extends N {
|
|
|
557
557
|
if (D({ x: r, y: a }, { x: t.x, y: t.y }) < this.pointerDistance) return void this.close();
|
|
558
558
|
this.setCursor(this.cursors.close);
|
|
559
559
|
const l = [...i, e];
|
|
560
|
-
this.updateGeometries(l, i[i.length - 1],
|
|
560
|
+
this.updateGeometries(l, i[i.length - 1], w.Commit), this.currentCoordinate++;
|
|
561
561
|
}
|
|
562
562
|
registerBehaviors(e) {
|
|
563
|
-
this.coordinateSnapping = new
|
|
563
|
+
this.coordinateSnapping = new st(e, new Ce(e), new me(e)), this.insertPoint = new Ot(e);
|
|
564
564
|
}
|
|
565
565
|
start() {
|
|
566
566
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -574,7 +574,7 @@ class ot extends N {
|
|
|
574
574
|
if (t) {
|
|
575
575
|
if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: t } }]);
|
|
576
576
|
else {
|
|
577
|
-
const [r] = this.store.create([{ geometry: { type: "Point", coordinates: t }, properties: { mode: this.mode, [
|
|
577
|
+
const [r] = this.store.create([{ geometry: { type: "Point", coordinates: t }, properties: { mode: this.mode, [we]: !0 } }]);
|
|
578
578
|
this.snappedPointId = r;
|
|
579
579
|
}
|
|
580
580
|
e.lng = t[0], e.lat = t[1];
|
|
@@ -589,12 +589,12 @@ class ot extends N {
|
|
|
589
589
|
let s = [...n, i];
|
|
590
590
|
if (this.insertCoordinates && this.currentId && this.lastCommitedCoordinates) {
|
|
591
591
|
const r = this.lastCommitedCoordinates[this.lastCommitedCoordinates.length - 1], a = i;
|
|
592
|
-
if (!
|
|
592
|
+
if (!Z(r, a)) {
|
|
593
593
|
const l = this.generateInsertCoordinates(r, a);
|
|
594
594
|
s = [...this.lastCommitedCoordinates.slice(0, -1), ...l, i];
|
|
595
595
|
}
|
|
596
596
|
}
|
|
597
|
-
this.updateGeometries(s, void 0,
|
|
597
|
+
this.updateGeometries(s, void 0, w.Provisional);
|
|
598
598
|
}
|
|
599
599
|
onClick(e) {
|
|
600
600
|
this.currentCoordinate > 0 && !this.mouseMove && this.onMouseMove(e), this.mouseMove = !1, this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0);
|
|
@@ -624,13 +624,13 @@ class ot extends N {
|
|
|
624
624
|
const t = M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
625
625
|
if (e.type === "Feature" && e.geometry.type === "LineString" && e.properties.mode === this.mode) return t.lineStringColor = this.getHexColorStylingValue(this.styles.lineStringColor, t.lineStringColor, e), t.lineStringWidth = this.getNumericStylingValue(this.styles.lineStringWidth, t.lineStringWidth, e), t.zIndex = 10, t;
|
|
626
626
|
if (e.type === "Feature" && e.geometry.type === "Point" && e.properties.mode === this.mode) {
|
|
627
|
-
const i = e.properties[
|
|
627
|
+
const i = e.properties[ne];
|
|
628
628
|
return t.pointColor = this.getHexColorStylingValue(i ? this.styles.closingPointColor : this.styles.snappingPointColor, t.pointColor, e), t.pointWidth = this.getNumericStylingValue(i ? this.styles.closingPointWidth : this.styles.snappingPointWidth, t.pointWidth, e), t.pointOutlineColor = this.getHexColorStylingValue(i ? this.styles.closingPointOutlineColor : this.styles.snappingPointOutlineColor, "#ffffff", e), t.pointOutlineWidth = this.getNumericStylingValue(i ? this.styles.closingPointOutlineWidth : this.styles.snappingPointOutlineWidth, 2, e), t.zIndex = 40, t;
|
|
629
629
|
}
|
|
630
630
|
return t;
|
|
631
631
|
}
|
|
632
632
|
validateFeature(e) {
|
|
633
|
-
return this.validateModeFeature(e, (t) =>
|
|
633
|
+
return this.validateModeFeature(e, (t) => ot(t, this.coordinatePrecision));
|
|
634
634
|
}
|
|
635
635
|
snapCoordinate(e) {
|
|
636
636
|
var t, i;
|
|
@@ -638,15 +638,15 @@ class ot extends N {
|
|
|
638
638
|
return (t = this.snapping) != null && t.toCoordinate && (n = this.currentId ? this.coordinateSnapping.getSnappableCoordinate(e, this.currentId) : this.coordinateSnapping.getSnappableCoordinateFirstClick(e)), (i = this.snapping) != null && i.toCustom && (n = this.snapping.toCustom(e)), n;
|
|
639
639
|
}
|
|
640
640
|
}
|
|
641
|
-
const
|
|
642
|
-
function
|
|
643
|
-
return o.geometry.type !== "Point" ? { valid: !1, reason:
|
|
641
|
+
const _t = "Feature is not a Point", kt = "Feature has invalid coordinates";
|
|
642
|
+
function at(o, e) {
|
|
643
|
+
return o.geometry.type !== "Point" ? { valid: !1, reason: _t } : ye(o.geometry.coordinates, e) ? { valid: !0 } : { valid: !1, reason: kt };
|
|
644
644
|
}
|
|
645
|
-
class Lt extends
|
|
645
|
+
class Lt extends B {
|
|
646
646
|
constructor(e) {
|
|
647
|
-
super(e), this.mode = "point", this.cursors = void 0;
|
|
648
|
-
const t = { create: "crosshair" };
|
|
649
|
-
this.cursors = e && e.cursors ? M({}, t, e.cursors) : t;
|
|
647
|
+
super(e), this.mode = "point", this.cursors = void 0, this.editable = void 0, this.editedFeatureId = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0;
|
|
648
|
+
const t = { create: "crosshair", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
649
|
+
this.cursors = e && e.cursors ? M({}, t, e.cursors) : t, this.editable = !(!e || !e.editable) && e.editable;
|
|
650
650
|
}
|
|
651
651
|
start() {
|
|
652
652
|
this.setStarted(), this.setCursor(this.cursors.create);
|
|
@@ -657,7 +657,7 @@ class Lt extends N {
|
|
|
657
657
|
onClick(e) {
|
|
658
658
|
if (!this.store) throw new Error("Mode must be registered first");
|
|
659
659
|
const t = { type: "Point", coordinates: [e.lng, e.lat] }, i = { mode: this.mode };
|
|
660
|
-
if (this.validate && !this.validate({ type: "Feature", geometry: t, properties: i }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
660
|
+
if (this.validate && !this.validate({ type: "Feature", geometry: t, properties: i }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: w.Finish }).valid) return;
|
|
661
661
|
const [n] = this.store.create([{ geometry: t, properties: i }]);
|
|
662
662
|
this.onFinish(n, { mode: this.mode, action: "draw" });
|
|
663
663
|
}
|
|
@@ -668,22 +668,44 @@ class Lt extends N {
|
|
|
668
668
|
onKeyUp() {
|
|
669
669
|
}
|
|
670
670
|
cleanUp() {
|
|
671
|
+
this.editedFeatureId = void 0;
|
|
671
672
|
}
|
|
672
|
-
onDragStart() {
|
|
673
|
+
onDragStart(e, t) {
|
|
674
|
+
if (this.editable) {
|
|
675
|
+
const i = this.clickBoundingBox.create(e), n = this.store.search(i);
|
|
676
|
+
let s, r = 1 / 0;
|
|
677
|
+
for (let a = 0; a < n.length; a++) {
|
|
678
|
+
const l = n[a];
|
|
679
|
+
if (l.geometry.type !== "Point" || l.properties.mode !== this.mode) continue;
|
|
680
|
+
const d = this.pixelDistance.measure(e, l.geometry.coordinates);
|
|
681
|
+
d > r || d > this.pointerDistance || (r = d, s = l);
|
|
682
|
+
}
|
|
683
|
+
s && (this.editedFeatureId = s.id);
|
|
684
|
+
}
|
|
685
|
+
this.editedFeatureId && (this.setCursor(this.cursors.dragStart), t(!1));
|
|
673
686
|
}
|
|
674
|
-
onDrag() {
|
|
687
|
+
onDrag(e, t) {
|
|
688
|
+
this.editedFeatureId !== void 0 && (this.validate && !this.validate({ type: "Feature", geometry: { type: "Point", coordinates: [e.lng, e.lat] }, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: w.Finish }).valid || (this.store.updateGeometry([{ id: this.editedFeatureId, geometry: { type: "Point", coordinates: [e.lng, e.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: q, value: !0 }]), t(!0)));
|
|
675
689
|
}
|
|
676
|
-
onDragEnd() {
|
|
690
|
+
onDragEnd(e, t) {
|
|
691
|
+
this.editedFeatureId !== void 0 && (this.onFinish(this.editedFeatureId, { mode: this.mode, action: "edit" }), this.setCursor(this.cursors.dragEnd), this.store.updateProperty([{ id: this.editedFeatureId, property: q, value: !1 }]), this.editedFeatureId = void 0, t(!0));
|
|
692
|
+
}
|
|
693
|
+
registerBehaviors(e) {
|
|
694
|
+
this.pixelDistance = new Ce(e), this.clickBoundingBox = new me(e);
|
|
677
695
|
}
|
|
678
696
|
styleFeature(e) {
|
|
679
697
|
const t = M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
680
|
-
|
|
698
|
+
if (e.type === "Feature" && e.geometry.type === "Point" && e.properties.mode === this.mode) {
|
|
699
|
+
const i = !!(e.id && this.editedFeatureId === e.id);
|
|
700
|
+
t.pointWidth = this.getNumericStylingValue(i ? this.styles.editedPointWidth : this.styles.pointWidth, t.pointWidth, e), t.pointColor = this.getHexColorStylingValue(i ? this.styles.editedPointColor : this.styles.pointColor, t.pointColor, e), t.pointOutlineColor = this.getHexColorStylingValue(i ? this.styles.editedPointOutlineColor : this.styles.pointOutlineColor, t.pointOutlineColor, e), t.pointOutlineWidth = this.getNumericStylingValue(i ? this.styles.editedPointOutlineWidth : this.styles.pointOutlineWidth, 2, e), t.zIndex = 30;
|
|
701
|
+
}
|
|
702
|
+
return t;
|
|
681
703
|
}
|
|
682
704
|
validateFeature(e) {
|
|
683
|
-
return this.validateModeFeature(e, (t) =>
|
|
705
|
+
return this.validateModeFeature(e, (t) => at(t, this.coordinatePrecision));
|
|
684
706
|
}
|
|
685
707
|
}
|
|
686
|
-
class
|
|
708
|
+
class Wt extends W {
|
|
687
709
|
constructor(e, t) {
|
|
688
710
|
super(e), this.config = void 0, this.pixelDistance = void 0, this._startEndPoints = [], this.config = e, this.pixelDistance = t;
|
|
689
711
|
}
|
|
@@ -695,7 +717,7 @@ class kt extends W {
|
|
|
695
717
|
create(e, t) {
|
|
696
718
|
if (this.ids.length) throw new Error("Opening and closing points already created");
|
|
697
719
|
if (e.length <= 3) throw new Error("Requires at least 4 coordinates");
|
|
698
|
-
this._startEndPoints = this.store.create([{ geometry: { type: "Point", coordinates: e[0] }, properties: { mode: t, [
|
|
720
|
+
this._startEndPoints = this.store.create([{ geometry: { type: "Point", coordinates: e[0] }, properties: { mode: t, [ne]: !0 } }, { geometry: { type: "Point", coordinates: e[e.length - 2] }, properties: { mode: t, [ne]: !0 } }]);
|
|
699
721
|
}
|
|
700
722
|
delete() {
|
|
701
723
|
this.ids.length && (this.store.delete(this.ids), this._startEndPoints = []);
|
|
@@ -709,42 +731,42 @@ class kt extends W {
|
|
|
709
731
|
return { isClosing: n < this.pointerDistance, isPreviousClosing: s < this.pointerDistance };
|
|
710
732
|
}
|
|
711
733
|
}
|
|
712
|
-
function
|
|
734
|
+
function Ue(o) {
|
|
713
735
|
return Math.sqrt(Math.pow(o[0], 2) + Math.pow(o[1], 2) + Math.pow(o[2], 2));
|
|
714
736
|
}
|
|
715
|
-
function
|
|
737
|
+
function z(o, e) {
|
|
716
738
|
const t = function(i, n) {
|
|
717
|
-
const [s, r, a] = i, [l, d,
|
|
718
|
-
return s * l + r * d + a *
|
|
719
|
-
}(o, e) / (
|
|
739
|
+
const [s, r, a] = i, [l, d, h] = n;
|
|
740
|
+
return s * l + r * d + a * h;
|
|
741
|
+
}(o, e) / (Ue(o) * Ue(e));
|
|
720
742
|
return Math.acos(Math.min(Math.max(t, -1), 1));
|
|
721
743
|
}
|
|
722
|
-
function
|
|
723
|
-
const e =
|
|
744
|
+
function ve(o) {
|
|
745
|
+
const e = E(o[1]), t = E(o[0]);
|
|
724
746
|
return [Math.cos(e) * Math.cos(t), Math.cos(e) * Math.sin(t), Math.sin(e)];
|
|
725
747
|
}
|
|
726
|
-
function
|
|
748
|
+
function K(o) {
|
|
727
749
|
const [e, t, i] = o, n = U(Math.asin(i));
|
|
728
750
|
return [U(Math.atan2(t, e)), n];
|
|
729
751
|
}
|
|
730
|
-
function
|
|
731
|
-
const i =
|
|
732
|
-
const [Ee,
|
|
733
|
-
return [
|
|
734
|
-
}(i, n), u =
|
|
752
|
+
function jt(o, e, t) {
|
|
753
|
+
const i = ve(o), n = ve(e), s = ve(t), [r, a, l] = s, [d, h, c] = function(j, R) {
|
|
754
|
+
const [Ee, De, Oe] = j, [_e, ke, Le] = R;
|
|
755
|
+
return [De * Le - Oe * ke, Oe * _e - Ee * Le, Ee * ke - De * _e];
|
|
756
|
+
}(i, n), u = h * l - c * a, p = c * r - d * l, g = d * a - h * r, y = g * h - p * c, C = u * c - g * d, f = p * d - u * h, m = 1 / Math.sqrt(Math.pow(y, 2) + Math.pow(C, 2) + Math.pow(f, 2)), P = [y * m, C * m, f * m], v = [-1 * y * m, -1 * C * m, -1 * f * m], S = z(i, n), I = z(i, P), b = z(n, P), O = z(i, v), N = z(n, v);
|
|
735
757
|
let _;
|
|
736
|
-
return _ =
|
|
758
|
+
return _ = I < O && I < N || b < O && b < N ? P : v, z(i, _) > S || z(n, _) > S ? T(K(_), K(i)) <= T(K(_), K(n)) ? [K(i), !0, !1] : [K(n), !1, !0] : [K(_), !1, !1];
|
|
737
759
|
}
|
|
738
|
-
function
|
|
760
|
+
function Bt(o, e, t) {
|
|
739
761
|
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)));
|
|
740
762
|
return { x: o.x + s * i, y: o.y + s * n };
|
|
741
763
|
}
|
|
742
764
|
class Nt extends W {
|
|
743
765
|
constructor(e, t, i) {
|
|
744
|
-
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;
|
|
766
|
+
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)).coordinate, this.getSnappableCoordinate = (n, s) => this.getSnappable(n, (r) => !!(r.properties && r.properties.mode === this.mode && r.id !== s)).coordinate, this.config = e, this.pixelDistance = t, this.clickBoundingBox = i;
|
|
745
767
|
}
|
|
746
768
|
getSnappable(e, t) {
|
|
747
|
-
const i = this.clickBoundingBox.create(e), n = this.store.search(i, t), s = {
|
|
769
|
+
const i = this.clickBoundingBox.create(e), n = this.store.search(i, t), s = { featureId: void 0, featureCoordinateIndex: void 0, coordinate: void 0, minDistance: 1 / 0 };
|
|
748
770
|
return n.forEach((r) => {
|
|
749
771
|
let a;
|
|
750
772
|
if (r.geometry.type === "Polygon") a = r.geometry.coordinates[0];
|
|
@@ -755,56 +777,56 @@ class Nt extends W {
|
|
|
755
777
|
const l = [];
|
|
756
778
|
for (let u = 0; u < a.length - 1; u++) l.push([a[u], a[u + 1]]);
|
|
757
779
|
let d;
|
|
758
|
-
const
|
|
780
|
+
const h = [e.lng, e.lat];
|
|
759
781
|
if (this.config.projection === "web-mercator" ? d = function(u, p) {
|
|
760
|
-
let g = [1 / 0, 1 / 0], y = 1 / 0;
|
|
761
|
-
for (let
|
|
762
|
-
const
|
|
763
|
-
let
|
|
764
|
-
const
|
|
765
|
-
if (
|
|
766
|
-
else if (
|
|
782
|
+
let g = [1 / 0, 1 / 0], y = 1 / 0, C = 0;
|
|
783
|
+
for (let f of p) {
|
|
784
|
+
const m = f[0], P = f[1];
|
|
785
|
+
let v, S = 1 / 0;
|
|
786
|
+
const I = x(m[0], m[1]), b = x(P[0], P[1]), O = x(u[0], u[1]);
|
|
787
|
+
if (m[0] === u[0] && m[1] === u[1]) v = m;
|
|
788
|
+
else if (P[0] === u[0] && P[1] === u[1]) v = P;
|
|
767
789
|
else {
|
|
768
|
-
const { x:
|
|
769
|
-
|
|
790
|
+
const { x: N, y: _ } = Bt(I, b, O), { lng: j, lat: R } = L(N, _);
|
|
791
|
+
v = [j, R];
|
|
770
792
|
}
|
|
771
|
-
|
|
793
|
+
v && (S = D(O, x(v[0], v[1])), S < y && (g = v, y = S, C = p.indexOf(f)));
|
|
772
794
|
}
|
|
773
|
-
return y === 1 / 0 ? void 0 : { coordinate: g, distance: y };
|
|
774
|
-
}(
|
|
775
|
-
let g = [1 / 0, 1 / 0], y = 1 / 0;
|
|
776
|
-
for (let
|
|
777
|
-
const
|
|
778
|
-
let
|
|
779
|
-
|
|
795
|
+
return y === 1 / 0 ? void 0 : { coordinate: g, lineIndex: C, distance: y };
|
|
796
|
+
}(h, l) : this.config.projection === "globe" && (d = function(u, p) {
|
|
797
|
+
let g = [1 / 0, 1 / 0], y = 1 / 0, C = 0;
|
|
798
|
+
for (let f of p) {
|
|
799
|
+
const m = f[0], P = f[1];
|
|
800
|
+
let v, S = 1 / 0;
|
|
801
|
+
m[0] === u[0] && m[1] === u[1] ? v = m : P[0] === u[0] && P[1] === u[1] ? v = P : [v] = jt(m, P, u), v && (S = T(u, v), S < y && (g = v, y = S, C = p.indexOf(f)));
|
|
780
802
|
}
|
|
781
|
-
return y === 1 / 0 ? void 0 : { coordinate: g, distance: y };
|
|
782
|
-
}(
|
|
783
|
-
const
|
|
784
|
-
|
|
785
|
-
}), s
|
|
803
|
+
return y === 1 / 0 ? void 0 : { coordinate: g, distance: y, lineIndex: C };
|
|
804
|
+
}(h, l)), !d) return;
|
|
805
|
+
const c = this.pixelDistance.measure(e, d.coordinate);
|
|
806
|
+
c < s.minDistance && c < this.pointerDistance && (s.featureId = r.id, s.coordinate = d.coordinate, s.featureCoordinateIndex = d.lineIndex, s.minDistance = c);
|
|
807
|
+
}), s;
|
|
786
808
|
}
|
|
787
809
|
}
|
|
788
|
-
class
|
|
810
|
+
class lt extends B {
|
|
789
811
|
constructor(e) {
|
|
790
|
-
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;
|
|
791
|
-
const t = { start: "crosshair", close: "pointer" };
|
|
812
|
+
super(e), this.mode = "polygon", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.snapping = void 0, this.editable = void 0, this.snappedPointId = void 0, this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedSnapType = void 0, this.editedInsertIndex = void 0, this.editedPointId = void 0, this.lineSnapping = void 0, this.coordinateSnapping = void 0, this.pixelDistance = void 0, this.closingPoints = void 0, this.clickBoundingBox = void 0, this.cursors = void 0, this.mouseMove = !1;
|
|
813
|
+
const t = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
792
814
|
if (this.cursors = e && e.cursors ? M({}, t, e.cursors) : t, this.snapping = e && e.snapping ? e.snapping : void 0, (e == null ? void 0 : e.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
|
|
793
815
|
else {
|
|
794
816
|
const i = { cancel: "Escape", finish: "Enter" };
|
|
795
817
|
this.keyEvents = e && e.keyEvents ? M({}, i, e.keyEvents) : i;
|
|
796
818
|
}
|
|
819
|
+
this.editable = !(!e || !e.editable) && e.editable;
|
|
797
820
|
}
|
|
798
821
|
close() {
|
|
799
822
|
if (this.currentId === void 0) return;
|
|
800
823
|
const e = this.store.getGeometryCopy(this.currentId).coordinates[0];
|
|
801
|
-
if (e.length < 5 || !this.updatePolygonGeometry([...e.slice(0, -2), e[0]],
|
|
824
|
+
if (e.length < 5 || !this.updatePolygonGeometry([...e.slice(0, -2), e[0]], w.Finish)) return;
|
|
802
825
|
const t = this.currentId;
|
|
803
826
|
this.snappedPointId && this.store.delete([this.snappedPointId]), this.currentCoordinate = 0, this.currentId = void 0, this.snappedPointId = void 0, this.closingPoints.delete(), this.state === "drawing" && this.setStarted(), this.onFinish(t, { mode: this.mode, action: "draw" });
|
|
804
827
|
}
|
|
805
828
|
registerBehaviors(e) {
|
|
806
|
-
|
|
807
|
-
this.pixelDistance = new be(e), this.lineSnapping = new Nt(e, this.pixelDistance, t), this.coordinateSnapping = new nt(e, this.pixelDistance, t), this.closingPoints = new kt(e, this.pixelDistance);
|
|
829
|
+
this.clickBoundingBox = new me(e), this.pixelDistance = new Ce(e), this.lineSnapping = new Nt(e, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new st(e, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new Wt(e, this.pixelDistance);
|
|
808
830
|
}
|
|
809
831
|
start() {
|
|
810
832
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -818,7 +840,7 @@ class at extends N {
|
|
|
818
840
|
if (t) {
|
|
819
841
|
if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: t } }]);
|
|
820
842
|
else {
|
|
821
|
-
const [s] = this.store.create([{ geometry: { type: "Point", coordinates: t }, properties: { mode: this.mode, [
|
|
843
|
+
const [s] = this.store.create([{ geometry: { type: "Point", coordinates: t }, properties: { mode: this.mode, [we]: !0 } }]);
|
|
822
844
|
this.snappedPointId = s;
|
|
823
845
|
}
|
|
824
846
|
e.lng = t[0], e.lat = t[1];
|
|
@@ -834,7 +856,7 @@ class at extends N {
|
|
|
834
856
|
const { isClosing: s, isPreviousClosing: r } = this.closingPoints.isClosingPoint(e);
|
|
835
857
|
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]];
|
|
836
858
|
}
|
|
837
|
-
this.updatePolygonGeometry(n,
|
|
859
|
+
this.updatePolygonGeometry(n, w.Provisional);
|
|
838
860
|
}
|
|
839
861
|
updatePolygonGeometry(e, t) {
|
|
840
862
|
if (!this.currentId) return !1;
|
|
@@ -864,24 +886,24 @@ class at extends N {
|
|
|
864
886
|
const t = this.snapCoordinate(e);
|
|
865
887
|
t && (e.lng = t[0], e.lat = t[1]);
|
|
866
888
|
const i = this.store.getGeometryCopy(this.currentId);
|
|
867
|
-
if (
|
|
889
|
+
if (Z([e.lng, e.lat], i.coordinates[0][0]) || !this.updatePolygonGeometry([i.coordinates[0][0], [e.lng, e.lat], [e.lng, e.lat], i.coordinates[0][0]], w.Commit)) return;
|
|
868
890
|
this.currentCoordinate++;
|
|
869
891
|
} else if (this.currentCoordinate === 2 && this.currentId) {
|
|
870
892
|
const t = this.snapCoordinate(e);
|
|
871
893
|
t && (e.lng = t[0], e.lat = t[1]);
|
|
872
894
|
const i = this.store.getGeometryCopy(this.currentId).coordinates[0];
|
|
873
|
-
if (
|
|
895
|
+
if (Z([e.lng, e.lat], i[1]) || !this.updatePolygonGeometry([i[0], i[1], [e.lng, e.lat], [e.lng, e.lat], i[0]], w.Commit)) return;
|
|
874
896
|
this.currentCoordinate === 2 && this.closingPoints.create(i, "polygon"), this.currentCoordinate++;
|
|
875
897
|
} else if (this.currentId) {
|
|
876
898
|
const t = this.store.getGeometryCopy(this.currentId).coordinates[0], { isClosing: i, isPreviousClosing: n } = this.closingPoints.isClosingPoint(e);
|
|
877
899
|
if (n || i) this.close();
|
|
878
900
|
else {
|
|
879
901
|
const s = this.snapCoordinate(e);
|
|
880
|
-
if (s && (e.lng = s[0], e.lat = s[1]),
|
|
902
|
+
if (s && (e.lng = s[0], e.lat = s[1]), Z([e.lng, e.lat], t[this.currentCoordinate - 1])) return;
|
|
881
903
|
const r = /* @__PURE__ */ function(a = [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]) {
|
|
882
904
|
return { type: "Feature", geometry: { type: "Polygon", coordinates: a }, properties: {} };
|
|
883
905
|
}([[...t.slice(0, -1), [e.lng, e.lat], t[0]]]);
|
|
884
|
-
if (!this.updatePolygonGeometry(r.geometry.coordinates[0],
|
|
906
|
+
if (!this.updatePolygonGeometry(r.geometry.coordinates[0], w.Commit)) return;
|
|
885
907
|
this.currentCoordinate++, this.closingPoints.ids.length && this.closingPoints.update(r.geometry.coordinates[0]);
|
|
886
908
|
}
|
|
887
909
|
}
|
|
@@ -891,19 +913,38 @@ class at extends N {
|
|
|
891
913
|
}
|
|
892
914
|
onKeyDown() {
|
|
893
915
|
}
|
|
894
|
-
onDragStart() {
|
|
895
|
-
this.
|
|
916
|
+
onDragStart(e, t) {
|
|
917
|
+
if (!this.editable) return;
|
|
918
|
+
let i;
|
|
919
|
+
if (this.state === "started") {
|
|
920
|
+
const n = this.lineSnapping.getSnappable(e);
|
|
921
|
+
n.coordinate && (this.editedSnapType = "line", this.editedFeatureCoordinateIndex = n.featureCoordinateIndex, this.editedFeatureId = n.featureId, i = n.coordinate);
|
|
922
|
+
const s = this.coordinateSnapping.getSnappable(e);
|
|
923
|
+
s.coordinate && (this.editedSnapType = "coordinate", this.editedFeatureCoordinateIndex = s.featureCoordinateIndex, this.editedFeatureId = s.featureId, i = s.coordinate);
|
|
924
|
+
}
|
|
925
|
+
if (this.editedFeatureId && i) {
|
|
926
|
+
if (!this.editedPointId) {
|
|
927
|
+
const [n] = this.store.create([{ geometry: { type: "Point", coordinates: i }, properties: { mode: this.mode, [q]: !0 } }]);
|
|
928
|
+
this.editedPointId = n;
|
|
929
|
+
}
|
|
930
|
+
this.setCursor(this.cursors.dragStart), t(!1);
|
|
931
|
+
}
|
|
896
932
|
}
|
|
897
|
-
onDrag() {
|
|
933
|
+
onDrag(e, t) {
|
|
934
|
+
if (this.editedFeatureId === void 0 || this.editedFeatureCoordinateIndex === void 0) return;
|
|
935
|
+
const i = this.store.getGeometryCopy(this.editedFeatureId), n = i.coordinates[0];
|
|
936
|
+
this.editedSnapType === "coordinate" || this.editedSnapType === "line" && this.editedInsertIndex !== void 0 ? this.editedFeatureCoordinateIndex === 0 || this.editedFeatureCoordinateIndex === i.coordinates[0].length - 1 ? (n[0] = [e.lng, e.lat], n[n.length - 1] = [e.lng, e.lat]) : n[this.editedFeatureCoordinateIndex] = [e.lng, e.lat] : this.editedSnapType === "line" && this.editedInsertIndex === void 0 && (this.editedInsertIndex = this.editedFeatureCoordinateIndex + 1, i.coordinates[0].splice(this.editedInsertIndex, 0, [e.lng, e.lat]), this.editedFeatureCoordinateIndex++);
|
|
937
|
+
const s = { type: "Polygon", coordinates: i.coordinates };
|
|
938
|
+
this.validate && !this.validate({ type: "Feature", geometry: s, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: w.Provisional }).valid || (this.snapping && this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: this.editedFeatureId, geometry: s }]), this.editedPointId && this.store.updateGeometry([{ id: this.editedPointId, geometry: { type: "Point", coordinates: [e.lng, e.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: q, value: !0 }]), t(!0));
|
|
898
939
|
}
|
|
899
|
-
onDragEnd() {
|
|
900
|
-
this.setCursor(this.cursors.
|
|
940
|
+
onDragEnd(e, t) {
|
|
941
|
+
this.editedFeatureId !== void 0 && (this.setCursor(this.cursors.dragEnd), this.editedPointId && (this.store.delete([this.editedPointId]), this.editedPointId = void 0), this.store.updateProperty([{ id: this.editedFeatureId, property: q, value: !1 }]), this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedInsertIndex = void 0, this.editedSnapType = void 0, t(!0));
|
|
901
942
|
}
|
|
902
943
|
cleanUp() {
|
|
903
|
-
const e = this.currentId, t = this.snappedPointId;
|
|
904
|
-
this.currentId = void 0, this.snappedPointId = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted();
|
|
944
|
+
const e = this.currentId, t = this.snappedPointId, i = this.editedPointId;
|
|
945
|
+
this.currentId = void 0, this.snappedPointId = void 0, this.editedPointId = void 0, this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedInsertIndex = void 0, this.editedSnapType = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted();
|
|
905
946
|
try {
|
|
906
|
-
e !== void 0 && this.store.delete([e]), t !== void 0 && this.store.delete([t]), this.closingPoints.ids.length && this.closingPoints.delete();
|
|
947
|
+
e !== void 0 && this.store.delete([e]), i !== void 0 && this.store.delete([i]), t !== void 0 && this.store.delete([t]), this.closingPoints.ids.length && this.closingPoints.delete();
|
|
907
948
|
} catch {
|
|
908
949
|
}
|
|
909
950
|
}
|
|
@@ -912,17 +953,19 @@ class at extends N {
|
|
|
912
953
|
if (e.properties.mode === this.mode) {
|
|
913
954
|
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;
|
|
914
955
|
if (e.geometry.type === "Point") {
|
|
915
|
-
const i = e.properties[
|
|
916
|
-
|
|
956
|
+
const i = e.properties[q], n = i ? "editedPoint" : e.properties[ne] ? "closingPoint" : e.properties[we] ? "snappingPoint" : void 0;
|
|
957
|
+
if (!n) return t;
|
|
958
|
+
const s = { editedPoint: { width: this.styles.editedPointOutlineWidth, color: this.styles.editedPointColor, outlineColor: this.styles.editedPointOutlineColor, outlineWidth: this.styles.editedPointOutlineWidth }, closingPoint: { width: this.styles.closingPointWidth, color: this.styles.closingPointColor, outlineColor: this.styles.closingPointOutlineColor, outlineWidth: this.styles.closingPointOutlineWidth }, snappingPoint: { width: this.styles.snappingPointWidth, color: this.styles.snappingPointColor, outlineColor: this.styles.snappingPointOutlineColor, outlineWidth: this.styles.snappingPointOutlineWidth } };
|
|
959
|
+
return t.pointWidth = this.getNumericStylingValue(s[n].width, t.pointWidth, e), t.pointColor = this.getHexColorStylingValue(s[n].color, t.pointColor, e), t.pointOutlineColor = this.getHexColorStylingValue(s[n].outlineColor, t.pointOutlineColor, e), t.pointOutlineWidth = this.getNumericStylingValue(s[n].outlineWidth, 2, e), t.zIndex = i ? 35 : 30, t;
|
|
917
960
|
}
|
|
918
961
|
}
|
|
919
962
|
return t;
|
|
920
963
|
}
|
|
921
964
|
validateFeature(e) {
|
|
922
|
-
return this.validateModeFeature(e, (t) =>
|
|
965
|
+
return this.validateModeFeature(e, (t) => fe(t, this.coordinatePrecision));
|
|
923
966
|
}
|
|
924
967
|
}
|
|
925
|
-
class
|
|
968
|
+
class dt extends B {
|
|
926
969
|
constructor(e) {
|
|
927
970
|
super(e), this.mode = "rectangle", this.center = void 0, this.clickCount = 0, this.currentRectangleId = void 0, this.keyEvents = void 0, this.cursors = void 0;
|
|
928
971
|
const t = { start: "crosshair" };
|
|
@@ -954,10 +997,10 @@ class lt extends N {
|
|
|
954
997
|
this.center = [e.lng, e.lat];
|
|
955
998
|
const [t] = this.store.create([{ geometry: { type: "Polygon", coordinates: [[[e.lng, e.lat], [e.lng, e.lat], [e.lng, e.lat], [e.lng, e.lat]]] }, properties: { mode: this.mode } }]);
|
|
956
999
|
this.currentRectangleId = t, this.clickCount++, this.setDrawing();
|
|
957
|
-
} else this.updateRectangle(e,
|
|
1000
|
+
} else this.updateRectangle(e, w.Finish), this.close();
|
|
958
1001
|
}
|
|
959
1002
|
onMouseMove(e) {
|
|
960
|
-
this.updateRectangle(e,
|
|
1003
|
+
this.updateRectangle(e, w.Provisional);
|
|
961
1004
|
}
|
|
962
1005
|
onKeyDown() {
|
|
963
1006
|
}
|
|
@@ -979,12 +1022,12 @@ class lt extends N {
|
|
|
979
1022
|
return e.type === "Feature" && e.geometry.type === "Polygon" && e.properties.mode === this.mode && (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;
|
|
980
1023
|
}
|
|
981
1024
|
validateFeature(e) {
|
|
982
|
-
return this.validateModeFeature(e, (t) =>
|
|
1025
|
+
return this.validateModeFeature(e, (t) => oe(t, this.coordinatePrecision));
|
|
983
1026
|
}
|
|
984
1027
|
}
|
|
985
|
-
class
|
|
1028
|
+
class ee extends B {
|
|
986
1029
|
constructor(e) {
|
|
987
|
-
super({ styles: e.styles }), this.type =
|
|
1030
|
+
super({ styles: e.styles }), this.type = Y.Render, this.mode = "render", this.mode = e.modeName;
|
|
988
1031
|
}
|
|
989
1032
|
registerBehaviors(e) {
|
|
990
1033
|
this.mode = e.mode;
|
|
@@ -1017,50 +1060,50 @@ class Q extends N {
|
|
|
1017
1060
|
validateFeature(e) {
|
|
1018
1061
|
const t = super.validateFeature(e);
|
|
1019
1062
|
if (t.valid) {
|
|
1020
|
-
const i = e, n =
|
|
1063
|
+
const i = e, n = at(i, this.coordinatePrecision).valid || fe(i, this.coordinatePrecision).valid || ot(i, this.coordinatePrecision).valid;
|
|
1021
1064
|
return n ? { valid: !0 } : { valid: n, reason: "Feature is not a valid Point, Polygon or LineString feature" };
|
|
1022
1065
|
}
|
|
1023
1066
|
return t;
|
|
1024
1067
|
}
|
|
1025
1068
|
}
|
|
1026
|
-
function
|
|
1027
|
-
const t = o, i = e, n =
|
|
1028
|
-
let r =
|
|
1069
|
+
function ue(o, e) {
|
|
1070
|
+
const t = o, i = e, n = E(t[1]), s = E(i[1]);
|
|
1071
|
+
let r = E(i[0] - t[0]);
|
|
1029
1072
|
r > Math.PI && (r -= 2 * Math.PI), r < -Math.PI && (r += 2 * Math.PI);
|
|
1030
1073
|
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;
|
|
1031
1074
|
return l > 180 ? -(360 - l) : l;
|
|
1032
1075
|
}
|
|
1033
|
-
function
|
|
1076
|
+
function Fe(o, e, t) {
|
|
1034
1077
|
let i = e;
|
|
1035
1078
|
e < 0 && (i = -Math.abs(i));
|
|
1036
|
-
const n = i /
|
|
1079
|
+
const n = i / Qe, s = o[0] * Math.PI / 180, r = E(o[1]), a = E(t), l = n * Math.cos(a);
|
|
1037
1080
|
let d = r + l;
|
|
1038
1081
|
Math.abs(d) > Math.PI / 2 && (d = d > 0 ? Math.PI - d : -Math.PI - d);
|
|
1039
|
-
const
|
|
1082
|
+
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 * (s + n * Math.sin(a) / c) / Math.PI + 540) % 360 - 180, 180 * d / Math.PI];
|
|
1040
1083
|
return u[0] += u[0] - o[0] > 180 ? -360 : o[0] - u[0] > 180 ? 360 : 0, u;
|
|
1041
1084
|
}
|
|
1042
|
-
function
|
|
1085
|
+
function ht(o, e, t, i, n) {
|
|
1043
1086
|
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);
|
|
1044
|
-
return [
|
|
1087
|
+
return [F(a, t), F(l, t)];
|
|
1045
1088
|
}
|
|
1046
|
-
function
|
|
1047
|
-
const i =
|
|
1048
|
-
return [
|
|
1089
|
+
function At(o, e, t) {
|
|
1090
|
+
const i = Fe(o, 1e3 * T(o, e) / 2, ue(o, e));
|
|
1091
|
+
return [F(i[0], t), F(i[1], t)];
|
|
1049
1092
|
}
|
|
1050
|
-
function
|
|
1093
|
+
function Re({ featureCoords: o, precision: e, unproject: t, project: i, projection: n }) {
|
|
1051
1094
|
const s = [];
|
|
1052
1095
|
for (let r = 0; r < o.length - 1; r++) {
|
|
1053
1096
|
let a;
|
|
1054
|
-
if (n === "web-mercator") a =
|
|
1097
|
+
if (n === "web-mercator") a = ht(o[r], o[r + 1], e, i, t);
|
|
1055
1098
|
else {
|
|
1056
1099
|
if (n !== "globe") throw new Error("Invalid projection");
|
|
1057
|
-
a =
|
|
1100
|
+
a = At(o[r], o[r + 1], e);
|
|
1058
1101
|
}
|
|
1059
1102
|
s.push(a);
|
|
1060
1103
|
}
|
|
1061
1104
|
return s;
|
|
1062
1105
|
}
|
|
1063
|
-
class
|
|
1106
|
+
class Gt extends W {
|
|
1064
1107
|
constructor(e, t) {
|
|
1065
1108
|
super(e), this.config = void 0, this.selectionPointBehavior = void 0, this._midPoints = [], this.config = e, this.selectionPointBehavior = t;
|
|
1066
1109
|
}
|
|
@@ -1076,17 +1119,17 @@ class At extends W {
|
|
|
1076
1119
|
create(e, t, i) {
|
|
1077
1120
|
if (!this.store.has(t)) throw new Error("Store does not have feature with this id");
|
|
1078
1121
|
this._midPoints = this.store.create(function(n, s, r, a, l, d) {
|
|
1079
|
-
return
|
|
1080
|
-
}(e, (n) => ({ mode: this.mode, [
|
|
1122
|
+
return Re({ featureCoords: n, precision: r, project: a, unproject: l, projection: d }).map((h, c) => ({ geometry: { type: "Point", coordinates: h }, properties: s(c) }));
|
|
1123
|
+
}(e, (n) => ({ mode: this.mode, [V.MID_POINT]: !0, midPointSegment: n, midPointFeatureId: t }), i, this.config.project, this.config.unproject, this.projection));
|
|
1081
1124
|
}
|
|
1082
1125
|
delete() {
|
|
1083
1126
|
this._midPoints.length && (this.store.delete(this._midPoints), this._midPoints = []);
|
|
1084
1127
|
}
|
|
1085
1128
|
getUpdated(e) {
|
|
1086
|
-
if (this._midPoints.length !== 0) return
|
|
1129
|
+
if (this._midPoints.length !== 0) return Re({ 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 } }));
|
|
1087
1130
|
}
|
|
1088
1131
|
}
|
|
1089
|
-
class
|
|
1132
|
+
class Tt extends W {
|
|
1090
1133
|
constructor(e) {
|
|
1091
1134
|
super(e), this._selectionPoints = [];
|
|
1092
1135
|
}
|
|
@@ -1116,12 +1159,12 @@ function ct(o, e) {
|
|
|
1116
1159
|
let t = !1;
|
|
1117
1160
|
for (let r = 0, a = e.length; r < a; r++) {
|
|
1118
1161
|
const l = e[r];
|
|
1119
|
-
for (let d = 0,
|
|
1162
|
+
for (let d = 0, h = l.length, c = h - 1; d < h; c = d++) (n = l[d])[1] > (i = o)[1] != (s = l[c])[1] > i[1] && i[0] < (s[0] - n[0]) * (i[1] - n[1]) / (s[1] - n[1]) + n[0] && (t = !t);
|
|
1120
1163
|
}
|
|
1121
1164
|
var i, n, s;
|
|
1122
1165
|
return t;
|
|
1123
1166
|
}
|
|
1124
|
-
const
|
|
1167
|
+
const ut = (o, e, t) => {
|
|
1125
1168
|
const i = (s) => s * s, n = (s, r) => i(s.x - r.x) + i(s.y - r.y);
|
|
1126
1169
|
return Math.sqrt(((s, r, a) => {
|
|
1127
1170
|
const l = n(r, a);
|
|
@@ -1136,17 +1179,17 @@ class Vt extends W {
|
|
|
1136
1179
|
}
|
|
1137
1180
|
find(e, t) {
|
|
1138
1181
|
let i, n, s, r, a = 1 / 0, l = 1 / 0, d = 1 / 0;
|
|
1139
|
-
const
|
|
1140
|
-
for (let u = 0; u <
|
|
1141
|
-
const p =
|
|
1182
|
+
const h = this.createClickBoundingBox.create(e), c = this.store.search(h);
|
|
1183
|
+
for (let u = 0; u < c.length; u++) {
|
|
1184
|
+
const p = c[u], g = p.geometry;
|
|
1142
1185
|
if (g.type === "Point") {
|
|
1143
|
-
if (p.properties.selectionPoint || !t && p.properties[
|
|
1186
|
+
if (p.properties.selectionPoint || !t && p.properties[V.MID_POINT]) continue;
|
|
1144
1187
|
const y = this.pixelDistance.measure(e, g.coordinates);
|
|
1145
|
-
p.properties[
|
|
1188
|
+
p.properties[V.MID_POINT] && y < this.pointerDistance && y < d ? (d = y, s = p) : !p.properties[V.MID_POINT] && y < this.pointerDistance && y < a && (a = y, i = p);
|
|
1146
1189
|
} else if (g.type === "LineString") {
|
|
1147
1190
|
if (i) continue;
|
|
1148
1191
|
for (let y = 0; y < g.coordinates.length - 1; y++) {
|
|
1149
|
-
const
|
|
1192
|
+
const C = g.coordinates[y], f = g.coordinates[y + 1], m = ut({ x: e.containerX, y: e.containerY }, this.project(C[0], C[1]), this.project(f[0], f[1]));
|
|
1150
1193
|
m < this.pointerDistance && m < l && (l = m, n = p);
|
|
1151
1194
|
}
|
|
1152
1195
|
} else if (g.type === "Polygon") {
|
|
@@ -1157,7 +1200,7 @@ class Vt extends W {
|
|
|
1157
1200
|
return { clickedFeature: i || n || r, clickedMidPoint: s };
|
|
1158
1201
|
}
|
|
1159
1202
|
}
|
|
1160
|
-
class
|
|
1203
|
+
class Ut extends W {
|
|
1161
1204
|
constructor(e, t, i, n) {
|
|
1162
1205
|
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;
|
|
1163
1206
|
}
|
|
@@ -1181,26 +1224,26 @@ class Tt extends W {
|
|
|
1181
1224
|
let s, r;
|
|
1182
1225
|
if (i.type === "Polygon" ? (s = i.coordinates[0], r = s.length - 1) : (s = i.coordinates, r = s.length), !this.dragPosition) return !1;
|
|
1183
1226
|
for (let d = 0; d < r; d++) {
|
|
1184
|
-
const
|
|
1185
|
-
let
|
|
1227
|
+
const h = s[d];
|
|
1228
|
+
let c, u;
|
|
1186
1229
|
if (this.config.projection === "web-mercator") {
|
|
1187
|
-
const p = x(this.dragPosition[0], this.dragPosition[1]), g = x(n[0], n[1]), y = x(
|
|
1188
|
-
|
|
1230
|
+
const p = x(this.dragPosition[0], this.dragPosition[1]), g = x(n[0], n[1]), y = x(h[0], h[1]), C = { x: p.x - g.x, y: p.y - g.y }, f = y.x - C.x, m = y.y - C.y, { lng: P, lat: v } = L(f, m);
|
|
1231
|
+
c = P, u = v;
|
|
1189
1232
|
} else {
|
|
1190
1233
|
const p = [this.dragPosition[0] - n[0], this.dragPosition[1] - n[1]];
|
|
1191
|
-
|
|
1234
|
+
c = h[0] - p[0], u = h[1] - p[1];
|
|
1192
1235
|
}
|
|
1193
|
-
if (
|
|
1194
|
-
s[d] = [
|
|
1236
|
+
if (c = F(c, this.config.coordinatePrecision), u = F(u, this.config.coordinatePrecision), c > 180 || c < -180 || u > 90 || u < -90) return !1;
|
|
1237
|
+
s[d] = [c, u];
|
|
1195
1238
|
}
|
|
1196
1239
|
i.type === "Polygon" && (s[s.length - 1] = [s[0][0], s[0][1]]);
|
|
1197
1240
|
const a = this.selectionPoints.getUpdated(s) || [], l = this.midPoints.getUpdated(s) || [];
|
|
1198
|
-
if (t && !t({ type: "Feature", id: this.draggedFeatureId, geometry: i, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType:
|
|
1241
|
+
if (t && !t({ type: "Feature", id: this.draggedFeatureId, geometry: i, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: w.Provisional }).valid) return !1;
|
|
1199
1242
|
this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: i }, ...a, ...l]), this.dragPosition = [e.lng, e.lat];
|
|
1200
1243
|
} else i.type === "Point" && (this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: { type: "Point", coordinates: n } }]), this.dragPosition = [e.lng, e.lat]);
|
|
1201
1244
|
}
|
|
1202
1245
|
}
|
|
1203
|
-
class
|
|
1246
|
+
class Rt extends W {
|
|
1204
1247
|
constructor(e, t, i, n) {
|
|
1205
1248
|
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;
|
|
1206
1249
|
}
|
|
@@ -1226,16 +1269,16 @@ class Ut extends W {
|
|
|
1226
1269
|
return n.index === -1 ? -1 : n.index;
|
|
1227
1270
|
}
|
|
1228
1271
|
drag(e, t, i) {
|
|
1229
|
-
if (
|
|
1272
|
+
if (this.draggedCoordinate.id === null) return !1;
|
|
1230
1273
|
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];
|
|
1231
1274
|
if (e.lng > 180 || e.lng < -180 || e.lat > 90 || e.lat < -90) return !1;
|
|
1232
1275
|
if (s.type !== "Polygon" || n !== r.length - 1 && n !== 0) r[n] = a;
|
|
1233
1276
|
else {
|
|
1234
|
-
const
|
|
1235
|
-
r[0] = a, r[
|
|
1277
|
+
const c = r.length - 1;
|
|
1278
|
+
r[0] = a, r[c] = a;
|
|
1236
1279
|
}
|
|
1237
|
-
const l = this.selectionPoints.getOneUpdated(n, a), d = l ? [l] : [],
|
|
1238
|
-
return !(s.type !== "Point" && !t &&
|
|
1280
|
+
const l = this.selectionPoints.getOneUpdated(n, a), d = l ? [l] : [], h = this.midPoints.getUpdated(r) || [];
|
|
1281
|
+
return !(s.type !== "Point" && !t && be({ geometry: s }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: s, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: w.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: s }, ...d, ...h]), 0));
|
|
1239
1282
|
}
|
|
1240
1283
|
isDragging() {
|
|
1241
1284
|
return this.draggedCoordinate.id !== null;
|
|
@@ -1247,21 +1290,21 @@ class Ut extends W {
|
|
|
1247
1290
|
this.draggedCoordinate = { id: null, index: -1 };
|
|
1248
1291
|
}
|
|
1249
1292
|
}
|
|
1250
|
-
function
|
|
1293
|
+
function pe(o) {
|
|
1251
1294
|
let e = 0, t = 0, i = 0;
|
|
1252
1295
|
return (o.geometry.type === "Polygon" ? o.geometry.coordinates[0].slice(0, -1) : o.geometry.coordinates).forEach((n) => {
|
|
1253
1296
|
e += n[0], t += n[1], i++;
|
|
1254
1297
|
}, !0), [e / i, t / i];
|
|
1255
1298
|
}
|
|
1256
|
-
function
|
|
1299
|
+
function pt(o, e) {
|
|
1257
1300
|
o[0] += o[0] - e[0] > 180 ? -360 : e[0] - o[0] > 180 ? 360 : 0;
|
|
1258
|
-
const t =
|
|
1301
|
+
const t = Qe, i = e[1] * Math.PI / 180, n = o[1] * Math.PI / 180, s = n - i;
|
|
1259
1302
|
let r = Math.abs(o[0] - e[0]) * Math.PI / 180;
|
|
1260
1303
|
r > Math.PI && (r -= 2 * Math.PI);
|
|
1261
1304
|
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);
|
|
1262
1305
|
return Math.sqrt(s * s + l * l * r * r) * t;
|
|
1263
1306
|
}
|
|
1264
|
-
function
|
|
1307
|
+
function ge(o) {
|
|
1265
1308
|
const e = (o.geometry.type === "Polygon" ? o.geometry.coordinates[0] : o.geometry.coordinates).map((t) => {
|
|
1266
1309
|
const { x: i, y: n } = x(t[0], t[1]);
|
|
1267
1310
|
return [i, n];
|
|
@@ -1270,8 +1313,8 @@ function pe(o) {
|
|
|
1270
1313
|
let i = 0, n = 0, s = 0;
|
|
1271
1314
|
const r = t.length;
|
|
1272
1315
|
for (let a = 0; a < r - 1; a++) {
|
|
1273
|
-
const [l, d] = t[a], [
|
|
1274
|
-
i += u, n += (l +
|
|
1316
|
+
const [l, d] = t[a], [h, c] = t[a + 1], u = l * c - h * d;
|
|
1317
|
+
i += u, n += (l + h) * u, s += (d + c) * u;
|
|
1275
1318
|
}
|
|
1276
1319
|
return i /= 2, n /= 6 * i, s /= 6 * i, { x: n, y: s };
|
|
1277
1320
|
}(e) : function(t) {
|
|
@@ -1284,7 +1327,7 @@ function pe(o) {
|
|
|
1284
1327
|
return { x: n / i, y: s / i };
|
|
1285
1328
|
}(e);
|
|
1286
1329
|
}
|
|
1287
|
-
class
|
|
1330
|
+
class zt extends W {
|
|
1288
1331
|
constructor(e, t, i) {
|
|
1289
1332
|
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;
|
|
1290
1333
|
}
|
|
@@ -1298,36 +1341,36 @@ class Rt extends W {
|
|
|
1298
1341
|
let r;
|
|
1299
1342
|
const a = { type: "Feature", geometry: n, properties: {} };
|
|
1300
1343
|
if (this.config.projection === "web-mercator") {
|
|
1301
|
-
if (r = G(
|
|
1302
|
-
((
|
|
1303
|
-
if (u === 0 || u === 360 || u === -360) return
|
|
1304
|
-
const p = 0.017453292519943295 * u, g = (
|
|
1344
|
+
if (r = G(ge(a), x(e.lng, e.lat)), !this.lastBearing) return void (this.lastBearing = r);
|
|
1345
|
+
((c, u) => {
|
|
1346
|
+
if (u === 0 || u === 360 || u === -360) return c;
|
|
1347
|
+
const p = 0.017453292519943295 * u, g = (c.geometry.type === "Polygon" ? c.geometry.coordinates[0] : c.geometry.coordinates).map(([f, m]) => x(f, m)), y = g.reduce((f, m) => ({ x: f.x + m.x, y: f.y + m.y }), { x: 0, y: 0 });
|
|
1305
1348
|
y.x /= g.length, y.y /= g.length;
|
|
1306
|
-
const
|
|
1307
|
-
|
|
1349
|
+
const C = g.map((f) => ({ x: y.x + (f.x - y.x) * Math.cos(p) - (f.y - y.y) * Math.sin(p), y: y.y + (f.x - y.x) * Math.sin(p) + (f.y - y.y) * Math.cos(p) })).map(({ x: f, y: m }) => [L(f, m).lng, L(f, m).lat]);
|
|
1350
|
+
c.geometry.type === "Polygon" ? c.geometry.coordinates[0] = C : c.geometry.coordinates = C;
|
|
1308
1351
|
})(a, -(this.lastBearing - r));
|
|
1309
1352
|
} else {
|
|
1310
1353
|
if (this.config.projection !== "globe") throw new Error("Unsupported projection");
|
|
1311
|
-
if (r =
|
|
1312
|
-
(function(
|
|
1313
|
-
if (u === 0 || u === 360 || u === -360) return
|
|
1314
|
-
const p =
|
|
1315
|
-
(
|
|
1316
|
-
const y =
|
|
1354
|
+
if (r = ue(pe({ geometry: n }), s), !this.lastBearing) return void (this.lastBearing = r + 180);
|
|
1355
|
+
(function(c, u) {
|
|
1356
|
+
if (u === 0 || u === 360 || u === -360) return c;
|
|
1357
|
+
const p = pe(c);
|
|
1358
|
+
(c.geometry.type === "Polygon" ? c.geometry.coordinates[0] : c.geometry.coordinates).forEach((g) => {
|
|
1359
|
+
const y = ue(p, g) + u, C = pt(p, g), f = Fe(p, C, y);
|
|
1317
1360
|
g[0] = f[0], g[1] = f[1];
|
|
1318
1361
|
});
|
|
1319
1362
|
})(a, -(this.lastBearing - (r + 180)));
|
|
1320
1363
|
}
|
|
1321
1364
|
const l = n.type === "Polygon" ? n.coordinates[0] : n.coordinates;
|
|
1322
|
-
l.forEach((
|
|
1323
|
-
|
|
1365
|
+
l.forEach((c) => {
|
|
1366
|
+
c[0] = F(c[0], this.coordinatePrecision), c[1] = F(c[1], this.coordinatePrecision);
|
|
1324
1367
|
});
|
|
1325
|
-
const d = this.midPoints.getUpdated(l) || [],
|
|
1326
|
-
if (i && !i({ id: t, type: "Feature", geometry: n, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType:
|
|
1327
|
-
this.store.updateGeometry([{ id: t, geometry: n }, ...
|
|
1368
|
+
const d = this.midPoints.getUpdated(l) || [], h = this.selectionPoints.getUpdated(l) || [];
|
|
1369
|
+
if (i && !i({ id: t, type: "Feature", geometry: n, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: w.Provisional })) return !1;
|
|
1370
|
+
this.store.updateGeometry([{ id: t, geometry: n }, ...h, ...d]), this.projection === "web-mercator" ? this.lastBearing = r : this.projection === "globe" && (this.lastBearing = r + 180);
|
|
1328
1371
|
}
|
|
1329
1372
|
}
|
|
1330
|
-
class
|
|
1373
|
+
class Kt extends W {
|
|
1331
1374
|
constructor(e, t, i) {
|
|
1332
1375
|
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;
|
|
1333
1376
|
}
|
|
@@ -1339,39 +1382,39 @@ class zt extends W {
|
|
|
1339
1382
|
if (n.type !== "Polygon" && n.type !== "LineString") return;
|
|
1340
1383
|
const s = [e.lng, e.lat], r = { type: "Feature", geometry: n, properties: {} };
|
|
1341
1384
|
let a;
|
|
1342
|
-
const l =
|
|
1385
|
+
const l = ge(r);
|
|
1343
1386
|
if (this.config.projection === "web-mercator") {
|
|
1344
1387
|
const p = x(e.lng, e.lat);
|
|
1345
1388
|
a = D(l, p);
|
|
1346
1389
|
} else {
|
|
1347
1390
|
if (this.config.projection !== "globe") throw new Error("Invalid projection");
|
|
1348
|
-
a =
|
|
1391
|
+
a = T(pe({ geometry: n }), s);
|
|
1349
1392
|
}
|
|
1350
1393
|
if (!this.lastDistance) return void (this.lastDistance = a);
|
|
1351
1394
|
const d = 1 - (this.lastDistance - a) / a;
|
|
1352
1395
|
if (this.config.projection === "web-mercator") {
|
|
1353
|
-
const { lng: p, lat: g } =
|
|
1354
|
-
(function(y,
|
|
1355
|
-
if (
|
|
1356
|
-
const m = (y.geometry.type === "Polygon" ? y.geometry.coordinates[0] : y.geometry.coordinates).map(([S,
|
|
1396
|
+
const { lng: p, lat: g } = L(l.x, l.y);
|
|
1397
|
+
(function(y, C, f) {
|
|
1398
|
+
if (C === 1) return y;
|
|
1399
|
+
const m = (y.geometry.type === "Polygon" ? y.geometry.coordinates[0] : y.geometry.coordinates).map(([S, I]) => x(S, I)), P = x(f[0], f[1]), v = m.map((S) => ({ x: P.x + (S.x - P.x) * C, y: P.y + (S.y - P.y) * C })).map(({ x: S, y: I }) => [L(S, I).lng, L(S, I).lat]);
|
|
1357
1400
|
y.geometry.type === "Polygon" ? y.geometry.coordinates[0] = v : y.geometry.coordinates = v;
|
|
1358
1401
|
})(r, d, [p, g]);
|
|
1359
|
-
} else this.config.projection === "globe" && function(p, g, y,
|
|
1402
|
+
} else this.config.projection === "globe" && function(p, g, y, C = "xy") {
|
|
1360
1403
|
g === 1 || (p.geometry.type === "Polygon" ? p.geometry.coordinates[0] : p.geometry.coordinates).forEach((f) => {
|
|
1361
|
-
const m =
|
|
1362
|
-
|
|
1404
|
+
const m = pt(y, f), P = ue(y, f), v = Fe(y, m * g, P);
|
|
1405
|
+
C !== "x" && C !== "xy" || (f[0] = v[0]), C !== "y" && C !== "xy" || (f[1] = v[1]);
|
|
1363
1406
|
});
|
|
1364
|
-
}(r, d,
|
|
1365
|
-
const
|
|
1366
|
-
|
|
1367
|
-
p[0] =
|
|
1407
|
+
}(r, d, pe(r));
|
|
1408
|
+
const h = n.type === "Polygon" ? n.coordinates[0] : n.coordinates;
|
|
1409
|
+
h.forEach((p) => {
|
|
1410
|
+
p[0] = F(p[0], this.coordinatePrecision), p[1] = F(p[1], this.coordinatePrecision);
|
|
1368
1411
|
});
|
|
1369
|
-
const
|
|
1370
|
-
if (i && !i({ id: t, type: "Feature", geometry: n, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType:
|
|
1371
|
-
this.store.updateGeometry([{ id: t, geometry: n }, ...u, ...
|
|
1412
|
+
const c = this.midPoints.getUpdated(h) || [], u = this.selectionPoints.getUpdated(h) || [];
|
|
1413
|
+
if (i && !i({ id: t, type: "Feature", geometry: n, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: w.Provisional })) return !1;
|
|
1414
|
+
this.store.updateGeometry([{ id: t, geometry: n }, ...u, ...c]), this.lastDistance = a;
|
|
1372
1415
|
}
|
|
1373
1416
|
}
|
|
1374
|
-
class
|
|
1417
|
+
class Xt extends W {
|
|
1375
1418
|
constructor(e, t, i, n) {
|
|
1376
1419
|
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;
|
|
1377
1420
|
}
|
|
@@ -1430,18 +1473,18 @@ class Kt extends W {
|
|
|
1430
1473
|
centerWebMercatorDrag(e) {
|
|
1431
1474
|
const t = this.getSelectedFeatureDataWebMercator();
|
|
1432
1475
|
if (!t) return null;
|
|
1433
|
-
const { feature: i, boundingBox: n, updatedCoords: s, selectedCoordinate: r } = t, a =
|
|
1476
|
+
const { feature: i, boundingBox: n, updatedCoords: s, selectedCoordinate: r } = t, a = ge(i);
|
|
1434
1477
|
if (!a) return null;
|
|
1435
|
-
const l = x(r[0], r[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(n, l),
|
|
1436
|
-
return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: s, webMercatorCursor:
|
|
1478
|
+
const l = x(r[0], r[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(n, l), h = x(e.lng, e.lat);
|
|
1479
|
+
return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: s, webMercatorCursor: h, webMercatorSelected: l, webMercatorOrigin: a }), s;
|
|
1437
1480
|
}
|
|
1438
1481
|
centerFixedWebMercatorDrag(e) {
|
|
1439
1482
|
const t = this.getSelectedFeatureDataWebMercator();
|
|
1440
1483
|
if (!t) return null;
|
|
1441
|
-
const { feature: i, boundingBox: n, updatedCoords: s, selectedCoordinate: r } = t, a =
|
|
1484
|
+
const { feature: i, boundingBox: n, updatedCoords: s, selectedCoordinate: r } = t, a = ge(i);
|
|
1442
1485
|
if (!a) return null;
|
|
1443
|
-
const l = x(r[0], r[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(n, l),
|
|
1444
|
-
return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: s, webMercatorCursor:
|
|
1486
|
+
const l = x(r[0], r[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(n, l), h = x(e.lng, e.lat);
|
|
1487
|
+
return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: s, webMercatorCursor: h, webMercatorSelected: l, webMercatorOrigin: a }), s;
|
|
1445
1488
|
}
|
|
1446
1489
|
scaleFixedWebMercator({ closestBBoxIndex: e, webMercatorOrigin: t, webMercatorSelected: i, webMercatorCursor: n, updatedCoords: s }) {
|
|
1447
1490
|
if (!this.isValidDragWebMercator(e, t.x - n.x, t.y - n.y)) return null;
|
|
@@ -1451,14 +1494,14 @@ class Kt extends W {
|
|
|
1451
1494
|
oppositeFixedWebMercatorDrag(e) {
|
|
1452
1495
|
const t = this.getSelectedFeatureDataWebMercator();
|
|
1453
1496
|
if (!t) return null;
|
|
1454
|
-
const { boundingBox: i, updatedCoords: n, selectedCoordinate: s } = t, r = x(s[0], s[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, r), d = { x: i[a][0], y: i[a][1] },
|
|
1455
|
-
return this.scaleFixedWebMercator({ closestBBoxIndex: l, updatedCoords: n, webMercatorCursor:
|
|
1497
|
+
const { boundingBox: i, updatedCoords: n, selectedCoordinate: s } = t, r = x(s[0], s[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, r), d = { x: i[a][0], y: i[a][1] }, h = x(e.lng, e.lat);
|
|
1498
|
+
return this.scaleFixedWebMercator({ closestBBoxIndex: l, updatedCoords: n, webMercatorCursor: h, webMercatorSelected: r, webMercatorOrigin: d }), n;
|
|
1456
1499
|
}
|
|
1457
1500
|
oppositeWebMercatorDrag(e) {
|
|
1458
1501
|
const t = this.getSelectedFeatureDataWebMercator();
|
|
1459
1502
|
if (!t) return null;
|
|
1460
|
-
const { boundingBox: i, updatedCoords: n, selectedCoordinate: s } = t, r = x(s[0], s[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, r), d = { x: i[a][0], y: i[a][1] },
|
|
1461
|
-
return this.scaleWebMercator({ closestBBoxIndex: l, updatedCoords: n, webMercatorCursor:
|
|
1503
|
+
const { boundingBox: i, updatedCoords: n, selectedCoordinate: s } = t, r = x(s[0], s[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, r), d = { x: i[a][0], y: i[a][1] }, h = x(e.lng, e.lat);
|
|
1504
|
+
return this.scaleWebMercator({ closestBBoxIndex: l, updatedCoords: n, webMercatorCursor: h, webMercatorSelected: r, webMercatorOrigin: d }), n;
|
|
1462
1505
|
}
|
|
1463
1506
|
scaleWebMercator({ closestBBoxIndex: e, webMercatorOrigin: t, webMercatorSelected: i, webMercatorCursor: n, updatedCoords: s }) {
|
|
1464
1507
|
const r = t.x - n.x, a = t.y - n.y;
|
|
@@ -1482,8 +1525,8 @@ class Kt extends W {
|
|
|
1482
1525
|
}
|
|
1483
1526
|
performWebMercatorScale(e, t, i, n, s) {
|
|
1484
1527
|
e.forEach((r) => {
|
|
1485
|
-
const { x: a, y: l } = x(r[0], r[1]), d = t + (a - t) * n,
|
|
1486
|
-
r[0] =
|
|
1528
|
+
const { x: a, y: l } = x(r[0], r[1]), d = t + (a - t) * n, h = i + (l - i) * s, { lng: c, lat: u } = L(d, h);
|
|
1529
|
+
r[0] = c, r[1] = u;
|
|
1487
1530
|
});
|
|
1488
1531
|
}
|
|
1489
1532
|
getBBoxWebMercator(e) {
|
|
@@ -1526,14 +1569,14 @@ class Kt extends W {
|
|
|
1526
1569
|
let s = null;
|
|
1527
1570
|
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;
|
|
1528
1571
|
for (let d = 0; d < s.length; d++) {
|
|
1529
|
-
const
|
|
1530
|
-
if (
|
|
1572
|
+
const h = s[d];
|
|
1573
|
+
if (h[0] = F(h[0], this.coordinatePrecision), h[1] = F(h[1], this.coordinatePrecision), !ye(h, this.coordinatePrecision)) return !1;
|
|
1531
1574
|
}
|
|
1532
1575
|
const r = this.midPoints.getUpdated(s) || [], a = this.selectionPoints.getUpdated(s) || [], l = { type: n.geometry.type, coordinates: n.geometry.type === "Polygon" ? [s] : s };
|
|
1533
|
-
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:
|
|
1576
|
+
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: w.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: l }, ...a, ...r]), 0));
|
|
1534
1577
|
}
|
|
1535
1578
|
}
|
|
1536
|
-
class
|
|
1579
|
+
class Yt extends Mt {
|
|
1537
1580
|
constructor(e) {
|
|
1538
1581
|
var t;
|
|
1539
1582
|
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 : {};
|
|
@@ -1556,13 +1599,13 @@ class Xt extends xt {
|
|
|
1556
1599
|
this._state = "selecting";
|
|
1557
1600
|
}
|
|
1558
1601
|
registerBehaviors(e) {
|
|
1559
|
-
this.pixelDistance = new
|
|
1602
|
+
this.pixelDistance = new Ce(e), this.clickBoundingBox = new me(e), this.featuresAtMouseEvent = new Vt(e, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new Tt(e), this.midPoints = new Gt(e, this.selectionPoints), this.rotateFeature = new zt(e, this.selectionPoints, this.midPoints), this.scaleFeature = new Kt(e, this.selectionPoints, this.midPoints), this.dragFeature = new Ut(e, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints), this.dragCoordinate = new Rt(e, this.pixelDistance, this.selectionPoints, this.midPoints), this.dragCoordinateResizeFeature = new Xt(e, this.pixelDistance, this.selectionPoints, this.midPoints);
|
|
1560
1603
|
}
|
|
1561
1604
|
deselectFeature() {
|
|
1562
1605
|
this.deselect();
|
|
1563
1606
|
}
|
|
1564
1607
|
deselect() {
|
|
1565
|
-
const e = this.selected.filter((t) => this.store.has(t)).map((t) => ({ id: t, property:
|
|
1608
|
+
const e = this.selected.filter((t) => this.store.has(t)).map((t) => ({ id: t, property: V.SELECTED, value: !1 }));
|
|
1566
1609
|
this.store.updateProperty(e), this.onDeselect(this.selected[0]), this.selected = [], this.selectionPoints.delete(), this.midPoints.delete();
|
|
1567
1610
|
}
|
|
1568
1611
|
deleteSelected() {
|
|
@@ -1571,21 +1614,18 @@ class Xt extends xt {
|
|
|
1571
1614
|
onRightClick(e) {
|
|
1572
1615
|
if (!this.selectionPoints.ids.length) return;
|
|
1573
1616
|
let t, i = 1 / 0;
|
|
1574
|
-
if (this.selectionPoints.ids.forEach((
|
|
1575
|
-
const u = this.store.getGeometryCopy(
|
|
1576
|
-
p < this.pointerDistance && p < i && (i = p, t = this.store.getPropertiesCopy(
|
|
1617
|
+
if (this.selectionPoints.ids.forEach((c) => {
|
|
1618
|
+
const u = this.store.getGeometryCopy(c), p = this.pixelDistance.measure(e, u.coordinates);
|
|
1619
|
+
p < this.pointerDistance && p < i && (i = p, t = this.store.getPropertiesCopy(c));
|
|
1577
1620
|
}), !t) return;
|
|
1578
1621
|
const n = t.selectionPointFeatureId, s = t.index, r = this.store.getPropertiesCopy(n), a = this.flags[r.mode], l = this.validations[r.mode];
|
|
1579
1622
|
if (!(a && a.feature && a.feature.coordinates && a.feature.coordinates.deletable)) return;
|
|
1580
1623
|
const d = this.store.getGeometryCopy(n);
|
|
1581
|
-
let
|
|
1624
|
+
let h;
|
|
1582
1625
|
if (d.type === "Polygon") {
|
|
1583
|
-
if (
|
|
1584
|
-
} else if (d.type === "LineString" && (
|
|
1585
|
-
|
|
1586
|
-
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;
|
|
1587
|
-
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);
|
|
1588
|
-
}
|
|
1626
|
+
if (h = d.coordinates[0], h.length <= 4) return;
|
|
1627
|
+
} else if (d.type === "LineString" && (h = d.coordinates, h.length <= 2)) return;
|
|
1628
|
+
h && (d.type !== "Polygon" || s !== 0 && s !== h.length - 1 ? h.splice(s, 1) : (h.shift(), h.pop(), h.push([h[0][0], h[0][1]])), (!l || l({ id: n, type: "Feature", geometry: d, properties: r }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: w.Commit }).valid) && (this.store.delete([...this.midPoints.ids, ...this.selectionPoints.ids]), this.store.updateGeometry([{ id: n, geometry: d }]), this.selectionPoints.create(h, d.type, n), a && a.feature && a.feature.coordinates && a.feature.coordinates.midpoints && this.midPoints.create(h, n, this.coordinatePrecision)));
|
|
1589
1629
|
}
|
|
1590
1630
|
select(e, t = !0) {
|
|
1591
1631
|
if (this.selected[0] === e) return;
|
|
@@ -1686,7 +1726,7 @@ class Xt extends xt {
|
|
|
1686
1726
|
if (e.properties.mode === this.mode && e.geometry.type === "Point") {
|
|
1687
1727
|
if (e.properties.selectionPoint) return t.pointColor = this.getHexColorStylingValue(this.styles.selectionPointColor, t.pointColor, e), t.pointOutlineColor = this.getHexColorStylingValue(this.styles.selectionPointOutlineColor, t.pointOutlineColor, e), t.pointWidth = this.getNumericStylingValue(this.styles.selectionPointWidth, t.pointWidth, e), t.pointOutlineWidth = this.getNumericStylingValue(this.styles.selectionPointOutlineWidth, 2, e), t.zIndex = 30, t;
|
|
1688
1728
|
if (e.properties.midPoint) return t.pointColor = this.getHexColorStylingValue(this.styles.midPointColor, t.pointColor, e), t.pointOutlineColor = this.getHexColorStylingValue(this.styles.midPointOutlineColor, t.pointOutlineColor, e), t.pointWidth = this.getNumericStylingValue(this.styles.midPointWidth, 4, e), t.pointOutlineWidth = this.getNumericStylingValue(this.styles.midPointOutlineWidth, 2, e), t.zIndex = 40, t;
|
|
1689
|
-
} else if (e.properties[
|
|
1729
|
+
} else if (e.properties[V.SELECTED]) {
|
|
1690
1730
|
if (e.geometry.type === "Polygon") return t.polygonFillColor = this.getHexColorStylingValue(this.styles.selectedPolygonColor, t.polygonFillColor, e), t.polygonOutlineWidth = this.getNumericStylingValue(this.styles.selectedPolygonOutlineWidth, t.polygonOutlineWidth, e), t.polygonOutlineColor = this.getHexColorStylingValue(this.styles.selectedPolygonOutlineColor, t.polygonOutlineColor, e), t.polygonFillOpacity = this.getNumericStylingValue(this.styles.selectedPolygonFillOpacity, t.polygonFillOpacity, e), t.zIndex = 10, t;
|
|
1691
1731
|
if (e.geometry.type === "LineString") return t.lineStringColor = this.getHexColorStylingValue(this.styles.selectedLineStringColor, t.lineStringColor, e), t.lineStringWidth = this.getNumericStylingValue(this.styles.selectedLineStringWidth, t.lineStringWidth, e), t.zIndex = 10, t;
|
|
1692
1732
|
if (e.geometry.type === "Point") return t.pointWidth = this.getNumericStylingValue(this.styles.selectedPointWidth, t.pointWidth, e), t.pointColor = this.getHexColorStylingValue(this.styles.selectedPointColor, t.pointColor, e), t.pointOutlineColor = this.getHexColorStylingValue(this.styles.selectedPointOutlineColor, t.pointOutlineColor, e), t.pointOutlineWidth = this.getNumericStylingValue(this.styles.selectedPointOutlineWidth, t.pointOutlineWidth, e), t.zIndex = 10, t;
|
|
@@ -1694,9 +1734,9 @@ class Xt extends xt {
|
|
|
1694
1734
|
return t;
|
|
1695
1735
|
}
|
|
1696
1736
|
}
|
|
1697
|
-
class
|
|
1737
|
+
class Ht extends B {
|
|
1698
1738
|
constructor(...e) {
|
|
1699
|
-
super(...e), this.type =
|
|
1739
|
+
super(...e), this.type = Y.Static, this.mode = "static";
|
|
1700
1740
|
}
|
|
1701
1741
|
start() {
|
|
1702
1742
|
}
|
|
@@ -1722,85 +1762,85 @@ class Yt extends N {
|
|
|
1722
1762
|
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 });
|
|
1723
1763
|
}
|
|
1724
1764
|
}
|
|
1725
|
-
function
|
|
1765
|
+
function gt(o, e, t, i, n) {
|
|
1726
1766
|
for (; i > t; ) {
|
|
1727
1767
|
if (i - t > 600) {
|
|
1728
|
-
const l = i - t + 1, d = e - t + 1,
|
|
1729
|
-
|
|
1768
|
+
const l = i - t + 1, d = e - t + 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);
|
|
1769
|
+
gt(o, e, Math.max(t, Math.floor(e - d * c / l + u)), Math.min(i, Math.floor(e + (l - d) * c / l + u)), n);
|
|
1730
1770
|
}
|
|
1731
1771
|
const s = o[e];
|
|
1732
1772
|
let r = t, a = i;
|
|
1733
|
-
for (
|
|
1734
|
-
for (
|
|
1773
|
+
for (Q(o, t, e), n(o[i], s) > 0 && Q(o, t, i); r < a; ) {
|
|
1774
|
+
for (Q(o, r, a), r++, a--; n(o[r], s) < 0; ) r++;
|
|
1735
1775
|
for (; n(o[a], s) > 0; ) a--;
|
|
1736
1776
|
}
|
|
1737
|
-
n(o[t], s) === 0 ?
|
|
1777
|
+
n(o[t], s) === 0 ? Q(o, t, a) : (a++, Q(o, a, i)), a <= e && (t = a + 1), e <= a && (i = a - 1);
|
|
1738
1778
|
}
|
|
1739
1779
|
}
|
|
1740
|
-
function
|
|
1780
|
+
function Q(o, e, t) {
|
|
1741
1781
|
const i = o[e];
|
|
1742
1782
|
o[e] = o[t], o[t] = i;
|
|
1743
1783
|
}
|
|
1744
|
-
function
|
|
1745
|
-
|
|
1784
|
+
function H(o, e) {
|
|
1785
|
+
te(o, 0, o.children.length, e, o);
|
|
1746
1786
|
}
|
|
1747
|
-
function
|
|
1748
|
-
n || (n =
|
|
1787
|
+
function te(o, e, t, i, n) {
|
|
1788
|
+
n || (n = J([])), n.minX = 1 / 0, n.minY = 1 / 0, n.maxX = -1 / 0, n.maxY = -1 / 0;
|
|
1749
1789
|
for (let s = e; s < t; s++) {
|
|
1750
1790
|
const r = o.children[s];
|
|
1751
|
-
|
|
1791
|
+
ie(n, o.leaf ? i(r) : r);
|
|
1752
1792
|
}
|
|
1753
1793
|
return n;
|
|
1754
1794
|
}
|
|
1755
|
-
function
|
|
1795
|
+
function ie(o, e) {
|
|
1756
1796
|
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;
|
|
1757
1797
|
}
|
|
1758
|
-
function
|
|
1798
|
+
function $t(o, e) {
|
|
1759
1799
|
return o.minX - e.minX;
|
|
1760
1800
|
}
|
|
1761
|
-
function
|
|
1801
|
+
function Jt(o, e) {
|
|
1762
1802
|
return o.minY - e.minY;
|
|
1763
1803
|
}
|
|
1764
|
-
function
|
|
1804
|
+
function Se(o) {
|
|
1765
1805
|
return (o.maxX - o.minX) * (o.maxY - o.minY);
|
|
1766
1806
|
}
|
|
1767
|
-
function
|
|
1807
|
+
function le(o) {
|
|
1768
1808
|
return o.maxX - o.minX + (o.maxY - o.minY);
|
|
1769
1809
|
}
|
|
1770
|
-
function
|
|
1810
|
+
function qt(o, e) {
|
|
1771
1811
|
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);
|
|
1772
1812
|
return Math.max(0, n - t) * Math.max(0, s - i);
|
|
1773
1813
|
}
|
|
1774
|
-
function
|
|
1814
|
+
function xe(o, e) {
|
|
1775
1815
|
return o.minX <= e.minX && o.minY <= e.minY && e.maxX <= o.maxX && e.maxY <= o.maxY;
|
|
1776
1816
|
}
|
|
1777
|
-
function
|
|
1817
|
+
function de(o, e) {
|
|
1778
1818
|
return e.minX <= o.maxX && e.minY <= o.maxY && e.maxX >= o.minX && e.maxY >= o.minY;
|
|
1779
1819
|
}
|
|
1780
|
-
function
|
|
1820
|
+
function J(o) {
|
|
1781
1821
|
return { children: o, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
|
|
1782
1822
|
}
|
|
1783
|
-
function
|
|
1823
|
+
function ze(o, e, t, i, n) {
|
|
1784
1824
|
const s = [e, t];
|
|
1785
1825
|
for (; s.length; ) {
|
|
1786
1826
|
if ((t = s.pop()) - (e = s.pop()) <= i) continue;
|
|
1787
1827
|
const r = e + Math.ceil((t - e) / i / 2) * i;
|
|
1788
|
-
|
|
1828
|
+
gt(o, r, e, t, n), s.push(e, r, r, t);
|
|
1789
1829
|
}
|
|
1790
1830
|
}
|
|
1791
|
-
class
|
|
1831
|
+
class Zt {
|
|
1792
1832
|
constructor(e) {
|
|
1793
1833
|
this._maxEntries = void 0, this._minEntries = void 0, this.data = void 0, this._maxEntries = Math.max(4, e), this._minEntries = Math.max(2, Math.ceil(0.4 * this._maxEntries)), this.clear();
|
|
1794
1834
|
}
|
|
1795
1835
|
search(e) {
|
|
1796
1836
|
let t = this.data;
|
|
1797
1837
|
const i = [];
|
|
1798
|
-
if (!
|
|
1838
|
+
if (!de(e, t)) return i;
|
|
1799
1839
|
const n = this.toBBox, s = [];
|
|
1800
1840
|
for (; t; ) {
|
|
1801
1841
|
for (let r = 0; r < t.children.length; r++) {
|
|
1802
1842
|
const a = t.children[r], l = t.leaf ? n(a) : a;
|
|
1803
|
-
|
|
1843
|
+
de(e, l) && (t.leaf ? i.push(a) : xe(e, l) ? this._all(a, i) : s.push(a));
|
|
1804
1844
|
}
|
|
1805
1845
|
t = s.pop();
|
|
1806
1846
|
}
|
|
@@ -1808,13 +1848,13 @@ class qt {
|
|
|
1808
1848
|
}
|
|
1809
1849
|
collides(e) {
|
|
1810
1850
|
let t = this.data;
|
|
1811
|
-
if (
|
|
1851
|
+
if (de(e, t)) {
|
|
1812
1852
|
const i = [];
|
|
1813
1853
|
for (; t; ) {
|
|
1814
1854
|
for (let n = 0; n < t.children.length; n++) {
|
|
1815
1855
|
const s = t.children[n], r = t.leaf ? this.toBBox(s) : s;
|
|
1816
|
-
if (
|
|
1817
|
-
if (t.leaf ||
|
|
1856
|
+
if (de(e, r)) {
|
|
1857
|
+
if (t.leaf || xe(e, r)) return !0;
|
|
1818
1858
|
i.push(s);
|
|
1819
1859
|
}
|
|
1820
1860
|
}
|
|
@@ -1843,7 +1883,7 @@ class qt {
|
|
|
1843
1883
|
this._insert(e, this.data.height - 1);
|
|
1844
1884
|
}
|
|
1845
1885
|
clear() {
|
|
1846
|
-
this.data =
|
|
1886
|
+
this.data = J([]);
|
|
1847
1887
|
}
|
|
1848
1888
|
remove(e) {
|
|
1849
1889
|
let t = this.data;
|
|
@@ -1854,7 +1894,7 @@ class qt {
|
|
|
1854
1894
|
const d = t.children.indexOf(e);
|
|
1855
1895
|
d !== -1 && (t.children.splice(d, 1), n.push(t), this._condense(n));
|
|
1856
1896
|
}
|
|
1857
|
-
l || t.leaf || !
|
|
1897
|
+
l || t.leaf || !xe(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]);
|
|
1858
1898
|
}
|
|
1859
1899
|
}
|
|
1860
1900
|
toBBox(e) {
|
|
@@ -1874,26 +1914,26 @@ class qt {
|
|
|
1874
1914
|
_build(e, t, i, n) {
|
|
1875
1915
|
const s = i - t + 1;
|
|
1876
1916
|
let r, a = this._maxEntries;
|
|
1877
|
-
if (s <= a) return r =
|
|
1878
|
-
n || (n = Math.ceil(Math.log(s) / Math.log(a)), a = Math.ceil(s / Math.pow(a, n - 1))), r =
|
|
1917
|
+
if (s <= a) return r = J(e.slice(t, i + 1)), H(r, this.toBBox), r;
|
|
1918
|
+
n || (n = Math.ceil(Math.log(s) / Math.log(a)), a = Math.ceil(s / Math.pow(a, n - 1))), r = J([]), r.leaf = !1, r.height = n;
|
|
1879
1919
|
const l = Math.ceil(s / a), d = l * Math.ceil(Math.sqrt(a));
|
|
1880
|
-
|
|
1881
|
-
for (let
|
|
1882
|
-
const
|
|
1883
|
-
|
|
1884
|
-
for (let u =
|
|
1885
|
-
const p = Math.min(u + l - 1,
|
|
1920
|
+
ze(e, t, i, d, this.compareMinX);
|
|
1921
|
+
for (let h = t; h <= i; h += d) {
|
|
1922
|
+
const c = Math.min(h + d - 1, i);
|
|
1923
|
+
ze(e, h, c, l, this.compareMinY);
|
|
1924
|
+
for (let u = h; u <= c; u += l) {
|
|
1925
|
+
const p = Math.min(u + l - 1, c);
|
|
1886
1926
|
r.children.push(this._build(e, u, p, n - 1));
|
|
1887
1927
|
}
|
|
1888
1928
|
}
|
|
1889
|
-
return
|
|
1929
|
+
return H(r, this.toBBox), r;
|
|
1890
1930
|
}
|
|
1891
1931
|
_chooseSubtree(e, t, i, n) {
|
|
1892
1932
|
for (; n.push(t), !t.leaf && n.length - 1 !== i; ) {
|
|
1893
1933
|
let a, l = 1 / 0, d = 1 / 0;
|
|
1894
|
-
for (let
|
|
1895
|
-
const
|
|
1896
|
-
p < d ? (d = p, l = u < l ? u : l, a =
|
|
1934
|
+
for (let h = 0; h < t.children.length; h++) {
|
|
1935
|
+
const c = t.children[h], u = Se(c), p = (s = e, r = c, (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);
|
|
1936
|
+
p < d ? (d = p, l = u < l ? u : l, a = c) : p === d && u < l && (l = u, a = c);
|
|
1897
1937
|
}
|
|
1898
1938
|
t = a || t.children[0];
|
|
1899
1939
|
}
|
|
@@ -1902,54 +1942,54 @@ class qt {
|
|
|
1902
1942
|
}
|
|
1903
1943
|
_insert(e, t, i) {
|
|
1904
1944
|
const n = i ? e : this.toBBox(e), s = [], r = this._chooseSubtree(n, this.data, t, s);
|
|
1905
|
-
for (r.children.push(e),
|
|
1945
|
+
for (r.children.push(e), ie(r, n); t >= 0 && s[t].children.length > this._maxEntries; ) this._split(s, t), t--;
|
|
1906
1946
|
this._adjustParentBBoxes(n, s, t);
|
|
1907
1947
|
}
|
|
1908
1948
|
_split(e, t) {
|
|
1909
1949
|
const i = e[t], n = i.children.length, s = this._minEntries;
|
|
1910
1950
|
this._chooseSplitAxis(i, s, n);
|
|
1911
|
-
const r = this._chooseSplitIndex(i, s, n), a =
|
|
1912
|
-
a.height = i.height, a.leaf = i.leaf,
|
|
1951
|
+
const r = this._chooseSplitIndex(i, s, n), a = J(i.children.splice(r, i.children.length - r));
|
|
1952
|
+
a.height = i.height, a.leaf = i.leaf, H(i, this.toBBox), H(a, this.toBBox), t ? e[t - 1].children.push(a) : this._splitRoot(i, a);
|
|
1913
1953
|
}
|
|
1914
1954
|
_splitRoot(e, t) {
|
|
1915
|
-
this.data =
|
|
1955
|
+
this.data = J([e, t]), this.data.height = e.height + 1, this.data.leaf = !1, H(this.data, this.toBBox);
|
|
1916
1956
|
}
|
|
1917
1957
|
_chooseSplitIndex(e, t, i) {
|
|
1918
1958
|
let n, s = 1 / 0, r = 1 / 0;
|
|
1919
1959
|
for (let a = t; a <= i - t; a++) {
|
|
1920
|
-
const l =
|
|
1921
|
-
|
|
1960
|
+
const l = te(e, 0, a, this.toBBox), d = te(e, a, i, this.toBBox), h = qt(l, d), c = Se(l) + Se(d);
|
|
1961
|
+
h < s ? (s = h, n = a, r = c < r ? c : r) : h === s && c < r && (r = c, n = a);
|
|
1922
1962
|
}
|
|
1923
1963
|
return n || i - t;
|
|
1924
1964
|
}
|
|
1925
1965
|
_chooseSplitAxis(e, t, i) {
|
|
1926
|
-
const n = e.leaf ? this.compareMinX :
|
|
1966
|
+
const n = e.leaf ? this.compareMinX : $t, s = e.leaf ? this.compareMinY : Jt;
|
|
1927
1967
|
this._allDistMargin(e, t, i, n) < this._allDistMargin(e, t, i, s) && e.children.sort(n);
|
|
1928
1968
|
}
|
|
1929
1969
|
_allDistMargin(e, t, i, n) {
|
|
1930
1970
|
e.children.sort(n);
|
|
1931
|
-
const s = this.toBBox, r =
|
|
1932
|
-
let l =
|
|
1971
|
+
const s = this.toBBox, r = te(e, 0, t, s), a = te(e, i - t, i, s);
|
|
1972
|
+
let l = le(r) + le(a);
|
|
1933
1973
|
for (let d = t; d < i - t; d++) {
|
|
1934
|
-
const
|
|
1935
|
-
|
|
1974
|
+
const h = e.children[d];
|
|
1975
|
+
ie(r, e.leaf ? s(h) : h), l += le(r);
|
|
1936
1976
|
}
|
|
1937
1977
|
for (let d = i - t - 1; d >= t; d--) {
|
|
1938
|
-
const
|
|
1939
|
-
|
|
1978
|
+
const h = e.children[d];
|
|
1979
|
+
ie(a, e.leaf ? s(h) : h), l += le(a);
|
|
1940
1980
|
}
|
|
1941
1981
|
return l;
|
|
1942
1982
|
}
|
|
1943
1983
|
_adjustParentBBoxes(e, t, i) {
|
|
1944
|
-
for (let n = i; n >= 0; n--)
|
|
1984
|
+
for (let n = i; n >= 0; n--) ie(t[n], e);
|
|
1945
1985
|
}
|
|
1946
1986
|
_condense(e) {
|
|
1947
|
-
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() :
|
|
1987
|
+
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() : H(e[i], this.toBBox);
|
|
1948
1988
|
}
|
|
1949
1989
|
}
|
|
1950
|
-
class
|
|
1990
|
+
class Qt {
|
|
1951
1991
|
constructor(e) {
|
|
1952
|
-
this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new
|
|
1992
|
+
this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new Zt(e && e.maxEntries ? e.maxEntries : 9), this.idToNode = /* @__PURE__ */ new Map(), this.nodeToId = /* @__PURE__ */ new Map();
|
|
1953
1993
|
}
|
|
1954
1994
|
setMaps(e, t) {
|
|
1955
1995
|
this.idToNode.set(e.id, t), this.nodeToId.set(t, e.id);
|
|
@@ -2000,14 +2040,14 @@ class Zt {
|
|
|
2000
2040
|
return this.tree.collides(this.toBBox(e));
|
|
2001
2041
|
}
|
|
2002
2042
|
}
|
|
2003
|
-
const
|
|
2043
|
+
const ei = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(o) {
|
|
2004
2044
|
const e = 16 * Math.random() | 0;
|
|
2005
2045
|
return (o == "x" ? e : 3 & e | 8).toString(16);
|
|
2006
2046
|
}), isValidId: (o) => typeof o == "string" && o.length === 36 };
|
|
2007
|
-
class
|
|
2047
|
+
class ti {
|
|
2008
2048
|
constructor(e) {
|
|
2009
2049
|
this.idStrategy = void 0, this.tracked = void 0, this.spatialIndex = void 0, this.store = void 0, this._onChange = () => {
|
|
2010
|
-
}, this.store = {}, this.spatialIndex = new
|
|
2050
|
+
}, this.store = {}, this.spatialIndex = new Qt(), this.tracked = !e || e.tracked !== !1, this.idStrategy = e && e.idStrategy ? e.idStrategy : ei;
|
|
2011
2051
|
}
|
|
2012
2052
|
clone(e) {
|
|
2013
2053
|
return JSON.parse(JSON.stringify(e));
|
|
@@ -2031,10 +2071,10 @@ class ei {
|
|
|
2031
2071
|
}
|
|
2032
2072
|
if (this.tracked) {
|
|
2033
2073
|
if (r.properties.createdAt) {
|
|
2034
|
-
if (!
|
|
2074
|
+
if (!We(r.properties.createdAt)) return s.push({ id: r.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
|
|
2035
2075
|
} else r.properties.createdAt = +/* @__PURE__ */ new Date();
|
|
2036
2076
|
if (r.properties.updatedAt) {
|
|
2037
|
-
if (!
|
|
2077
|
+
if (!We(r.properties.updatedAt)) return s.push({ id: r.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
|
|
2038
2078
|
} else r.properties.updatedAt = +/* @__PURE__ */ new Date();
|
|
2039
2079
|
}
|
|
2040
2080
|
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);
|
|
@@ -2101,13 +2141,13 @@ class ei {
|
|
|
2101
2141
|
return Object.keys(this.store).length;
|
|
2102
2142
|
}
|
|
2103
2143
|
}
|
|
2104
|
-
const
|
|
2105
|
-
function
|
|
2144
|
+
const ii = "Feature is not a Polygon or LineString", ni = "Feature intersects itself", si = (o) => o.geometry.type !== "Polygon" && o.geometry.type !== "LineString" ? { valid: !1, reason: ii } : be(o) ? { valid: !1, reason: ni } : { valid: !0 };
|
|
2145
|
+
function Ke(o, e, t) {
|
|
2106
2146
|
const i = G(o, e);
|
|
2107
2147
|
let n = G(e, t) - i;
|
|
2108
2148
|
return n < 0 && (n += 360), 180 - Math.abs(n - 90 - 90);
|
|
2109
2149
|
}
|
|
2110
|
-
class
|
|
2150
|
+
class yt extends B {
|
|
2111
2151
|
constructor(e) {
|
|
2112
2152
|
super(e), this.mode = "angled-rectangle", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.cursors = void 0, this.mouseMove = !1;
|
|
2113
2153
|
const t = { start: "crosshair", close: "pointer" };
|
|
@@ -2136,13 +2176,13 @@ class gt extends N {
|
|
|
2136
2176
|
const n = 1 / Math.pow(10, this.coordinatePrecision - 1), s = Math.max(1e-6, n);
|
|
2137
2177
|
i = [t[0], [e.lng, e.lat], [e.lng, e.lat - s], t[0]];
|
|
2138
2178
|
} else if (this.currentCoordinate === 2) {
|
|
2139
|
-
const n = t[0], s = t[1], r =
|
|
2140
|
-
const O = (
|
|
2179
|
+
const n = t[0], s = t[1], r = ht(n, s, this.coordinatePrecision, this.project, this.unproject), a = x(n[0], n[1]), l = x(r[0], r[1]), d = x(s[0], s[1]), h = x(e.lng, e.lat), c = D(h, a) < D(h, d), u = Ke(a, l, h), p = c ? 90 - u : Ke(a, l, h) - 90, g = D(l, h), y = Math.cos(E(p)) * g, C = G(a, d) + (function(S, I, b) {
|
|
2180
|
+
const O = (b.x - I.x) * (S.y - I.y) - (b.y - I.y) * (S.x - I.x);
|
|
2141
2181
|
return O > 1e-10 ? "left" : O < -1e-10 ? "right" : "left";
|
|
2142
|
-
}(a, d,
|
|
2143
|
-
i = [t[0], t[1], [v.lng, v.lat], [
|
|
2182
|
+
}(a, d, h) === "right" ? -90 : 90), f = se(a, y, C), m = se(d, y, C), P = L(f.x, f.y), v = L(m.x, m.y);
|
|
2183
|
+
i = [t[0], t[1], [v.lng, v.lat], [P.lng, P.lat], t[0]];
|
|
2144
2184
|
}
|
|
2145
|
-
i && this.updatePolygonGeometry(this.currentId, i,
|
|
2185
|
+
i && this.updatePolygonGeometry(this.currentId, i, w.Provisional);
|
|
2146
2186
|
}
|
|
2147
2187
|
updatePolygonGeometry(e, t, i) {
|
|
2148
2188
|
const n = { type: "Polygon", coordinates: [t] };
|
|
@@ -2154,7 +2194,7 @@ class gt extends N {
|
|
|
2154
2194
|
this.currentId = t, this.currentCoordinate++, this.setDrawing();
|
|
2155
2195
|
} else if (this.currentCoordinate === 1 && this.currentId) {
|
|
2156
2196
|
const t = this.store.getGeometryCopy(this.currentId);
|
|
2157
|
-
if (
|
|
2197
|
+
if (Z([e.lng, e.lat], t.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [t.coordinates[0][0], [e.lng, e.lat], [e.lng, e.lat], t.coordinates[0][0]], w.Commit)) return;
|
|
2158
2198
|
this.currentCoordinate++;
|
|
2159
2199
|
} else this.currentCoordinate === 2 && this.currentId && this.close();
|
|
2160
2200
|
}
|
|
@@ -2181,13 +2221,13 @@ class gt extends N {
|
|
|
2181
2221
|
return e.properties.mode === this.mode && e.geometry.type === "Polygon" && (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;
|
|
2182
2222
|
}
|
|
2183
2223
|
validateFeature(e) {
|
|
2184
|
-
return this.validateModeFeature(e, (t) =>
|
|
2224
|
+
return this.validateModeFeature(e, (t) => oe(t, this.coordinatePrecision));
|
|
2185
2225
|
}
|
|
2186
2226
|
}
|
|
2187
|
-
function
|
|
2227
|
+
function ft(o, e, t) {
|
|
2188
2228
|
return (e.x - o.x) * (t.y - o.y) - (e.y - o.y) * (t.x - o.x) <= 0;
|
|
2189
2229
|
}
|
|
2190
|
-
class
|
|
2230
|
+
class mt extends B {
|
|
2191
2231
|
constructor(e) {
|
|
2192
2232
|
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;
|
|
2193
2233
|
const t = { start: "crosshair", close: "pointer" };
|
|
@@ -2219,21 +2259,21 @@ class ft extends N {
|
|
|
2219
2259
|
} else if (this.currentCoordinate === 2) {
|
|
2220
2260
|
const n = t[0], s = t[1], r = [e.lng, e.lat], a = x(n[0], n[1]), l = x(s[0], s[1]), d = x(r[0], r[1]);
|
|
2221
2261
|
if (this.direction === void 0) {
|
|
2222
|
-
const
|
|
2223
|
-
this.direction =
|
|
2262
|
+
const P = ft(a, l, d);
|
|
2263
|
+
this.direction = P ? "clockwise" : "anticlockwise";
|
|
2224
2264
|
}
|
|
2225
|
-
const
|
|
2265
|
+
const h = D(a, l), c = G(a, l), u = G(a, d), p = this.arcPoints, g = [n], y = X(c), C = X(u);
|
|
2226
2266
|
let f;
|
|
2227
|
-
this.direction === "anticlockwise" ? (f =
|
|
2267
|
+
this.direction === "anticlockwise" ? (f = C - y, f < 0 && (f += 360)) : (f = y - C, f < 0 && (f += 360));
|
|
2228
2268
|
const m = (this.direction === "anticlockwise" ? 1 : -1) * f / p;
|
|
2229
2269
|
g.push(s);
|
|
2230
|
-
for (let
|
|
2231
|
-
const v =
|
|
2232
|
-
|
|
2270
|
+
for (let P = 0; P <= p; P++) {
|
|
2271
|
+
const v = se(a, h, y + P * m), { lng: S, lat: I } = L(v.x, v.y), b = [F(S, this.coordinatePrecision), F(I, this.coordinatePrecision)];
|
|
2272
|
+
b[0] !== g[g.length - 1][0] && b[1] !== g[g.length - 1][1] && g.push(b);
|
|
2233
2273
|
}
|
|
2234
2274
|
g.push(n), i = [...g];
|
|
2235
2275
|
}
|
|
2236
|
-
i && this.updatePolygonGeometry(this.currentId, i,
|
|
2276
|
+
i && this.updatePolygonGeometry(this.currentId, i, w.Provisional);
|
|
2237
2277
|
}
|
|
2238
2278
|
updatePolygonGeometry(e, t, i) {
|
|
2239
2279
|
const n = { type: "Polygon", coordinates: [t] };
|
|
@@ -2245,7 +2285,7 @@ class ft extends N {
|
|
|
2245
2285
|
this.currentId = t, this.currentCoordinate++, this.setDrawing();
|
|
2246
2286
|
} else if (this.currentCoordinate === 1 && this.currentId) {
|
|
2247
2287
|
const t = this.store.getGeometryCopy(this.currentId);
|
|
2248
|
-
if (
|
|
2288
|
+
if (Z([e.lng, e.lat], t.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [t.coordinates[0][0], [e.lng, e.lat], [e.lng, e.lat], t.coordinates[0][0]], w.Commit)) return;
|
|
2249
2289
|
this.currentCoordinate++;
|
|
2250
2290
|
} else this.currentCoordinate === 2 && this.currentId && this.close();
|
|
2251
2291
|
}
|
|
@@ -2272,10 +2312,10 @@ class ft extends N {
|
|
|
2272
2312
|
return e.properties.mode === this.mode && e.geometry.type === "Polygon" && (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;
|
|
2273
2313
|
}
|
|
2274
2314
|
validateFeature(e) {
|
|
2275
|
-
return this.validateModeFeature(e, (t) =>
|
|
2315
|
+
return this.validateModeFeature(e, (t) => oe(t, this.coordinatePrecision));
|
|
2276
2316
|
}
|
|
2277
2317
|
}
|
|
2278
|
-
class
|
|
2318
|
+
class Ct extends B {
|
|
2279
2319
|
constructor(e) {
|
|
2280
2320
|
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;
|
|
2281
2321
|
const t = { start: "crosshair", close: "pointer" };
|
|
@@ -2302,29 +2342,29 @@ class mt extends N {
|
|
|
2302
2342
|
if (this.currentCoordinate === 2) {
|
|
2303
2343
|
const t = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, n = t[0], s = [e.lng, e.lat], r = x(n[0], n[1]), a = x(s[0], s[1]), l = x(i[0], i[1]), d = D(l, r);
|
|
2304
2344
|
if (this.direction === void 0) {
|
|
2305
|
-
const m =
|
|
2345
|
+
const m = ft(l, r, a);
|
|
2306
2346
|
this.direction = m ? "clockwise" : "anticlockwise";
|
|
2307
2347
|
}
|
|
2308
|
-
const
|
|
2309
|
-
let
|
|
2310
|
-
this.direction === "anticlockwise" ? (
|
|
2311
|
-
const f = (this.direction === "anticlockwise" ? 1 : -1) *
|
|
2348
|
+
const h = G(l, r), c = G(l, a), u = this.arcPoints, p = [n], g = X(h), y = X(c);
|
|
2349
|
+
let C;
|
|
2350
|
+
this.direction === "anticlockwise" ? (C = y - g, C < 0 && (C += 360)) : (C = g - y, C < 0 && (C += 360));
|
|
2351
|
+
const f = (this.direction === "anticlockwise" ? 1 : -1) * C / u;
|
|
2312
2352
|
for (let m = 0; m <= u; m++) {
|
|
2313
|
-
const
|
|
2314
|
-
|
|
2353
|
+
const P = se(l, d, g + m * f), { lng: v, lat: S } = L(P.x, P.y), I = [F(v, this.coordinatePrecision), F(S, this.coordinatePrecision)];
|
|
2354
|
+
I[0] !== p[p.length - 1][0] && I[1] !== p[p.length - 1][1] && p.push(I);
|
|
2315
2355
|
}
|
|
2316
|
-
this.updateLineStringGeometry(this.currentInitialArcId, p,
|
|
2356
|
+
this.updateLineStringGeometry(this.currentInitialArcId, p, w.Provisional);
|
|
2317
2357
|
} else if (this.currentCoordinate === 3) {
|
|
2318
2358
|
const t = this.store.getGeometryCopy(this.currentInitialArcId).coordinates;
|
|
2319
2359
|
if (t.length < 2 || !this.direction) return;
|
|
2320
|
-
const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, n = t[0], s = t[t.length - 1], r = x(e.lng, e.lat), a = x(n[0], n[1]), l = x(s[0], s[1]), d = x(i[0], i[1]),
|
|
2321
|
-
if (this.notInSector({ normalizedCursor: f, normalizedStart: y, normalizedEnd:
|
|
2322
|
-
const m = this.getDeltaBearing(this.direction, y,
|
|
2323
|
-
for (let
|
|
2324
|
-
const O =
|
|
2325
|
-
j[0] !== t[t.length - 1][0] && j[1] !== t[t.length - 1][1] &&
|
|
2360
|
+
const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, n = t[0], s = t[t.length - 1], r = x(e.lng, e.lat), a = x(n[0], n[1]), l = x(s[0], s[1]), d = x(i[0], i[1]), h = D(d, a), c = D(d, r) < h ? a : r, u = G(d, r), p = G(d, a), g = G(d, l), y = X(p), C = X(g), f = X(u);
|
|
2361
|
+
if (this.notInSector({ normalizedCursor: f, normalizedStart: y, normalizedEnd: C, direction: this.direction })) return;
|
|
2362
|
+
const m = this.getDeltaBearing(this.direction, y, C), P = this.arcPoints, v = (this.direction === "anticlockwise" ? 1 : -1) * m / P, S = D(d, c), I = [];
|
|
2363
|
+
for (let b = 0; b <= P; b++) {
|
|
2364
|
+
const O = se(d, S, y + b * v), { lng: N, lat: _ } = L(O.x, O.y), j = [F(N, this.coordinatePrecision), F(_, this.coordinatePrecision)];
|
|
2365
|
+
j[0] !== t[t.length - 1][0] && j[1] !== t[t.length - 1][1] && I.unshift(j);
|
|
2326
2366
|
}
|
|
2327
|
-
t.push(...
|
|
2367
|
+
t.push(...I), t.push(t[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, t, w.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [t] }, properties: { mode: this.mode } }]);
|
|
2328
2368
|
}
|
|
2329
2369
|
}
|
|
2330
2370
|
}
|
|
@@ -2368,7 +2408,7 @@ class mt extends N {
|
|
|
2368
2408
|
return e.properties.mode === this.mode && (e.geometry.type === "Polygon" ? (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) : e.geometry.type === "LineString" ? (t.lineStringColor = this.getHexColorStylingValue(this.styles.outlineColor, t.polygonOutlineColor, e), t.lineStringWidth = this.getNumericStylingValue(this.styles.outlineWidth, t.polygonOutlineWidth, e), t.zIndex = 10) : e.geometry.type === "Point" && (t.pointColor = this.getHexColorStylingValue(this.styles.centerPointColor, t.pointColor, e), t.pointWidth = this.getNumericStylingValue(this.styles.centerPointWidth, t.pointWidth, e), t.pointOutlineColor = this.getHexColorStylingValue(this.styles.centerPointOutlineColor, t.pointOutlineColor, e), t.pointOutlineWidth = this.getNumericStylingValue(this.styles.centerPointOutlineWidth, t.pointOutlineWidth, e), t.zIndex = 20)), t;
|
|
2369
2409
|
}
|
|
2370
2410
|
validateFeature(e) {
|
|
2371
|
-
return this.validateModeFeature(e, (t) =>
|
|
2411
|
+
return this.validateModeFeature(e, (t) => oe(t, this.coordinatePrecision));
|
|
2372
2412
|
}
|
|
2373
2413
|
getDeltaBearing(e, t, i) {
|
|
2374
2414
|
let n;
|
|
@@ -2378,51 +2418,51 @@ class mt extends N {
|
|
|
2378
2418
|
return n === "clockwise" ? t <= i ? e >= t && e <= i : e >= t || e <= i : t >= i ? e <= t && e >= i : e <= t || e >= i;
|
|
2379
2419
|
}
|
|
2380
2420
|
}
|
|
2381
|
-
class
|
|
2421
|
+
class oi {
|
|
2382
2422
|
constructor(e) {
|
|
2383
|
-
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
|
|
2384
|
-
const t = /* @__PURE__ */ new Set(), i = e.modes.reduce((
|
|
2385
|
-
if (t.has(
|
|
2386
|
-
return t.add(
|
|
2423
|
+
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 Ht();
|
|
2424
|
+
const t = /* @__PURE__ */ new Set(), i = e.modes.reduce((h, c) => {
|
|
2425
|
+
if (t.has(c.mode)) throw new Error(`There is already a ${c.mode} mode provided`);
|
|
2426
|
+
return t.add(c.mode), h[c.mode] = c, h;
|
|
2387
2427
|
}, {}), n = Object.keys(i);
|
|
2388
2428
|
if (n.length === 0) throw new Error("No modes provided");
|
|
2389
|
-
n.forEach((
|
|
2390
|
-
if (i[
|
|
2429
|
+
n.forEach((h) => {
|
|
2430
|
+
if (i[h].type === Y.Select) {
|
|
2391
2431
|
if (this._instanceSelectMode) throw new Error("only one type of select mode can be provided");
|
|
2392
|
-
this._instanceSelectMode =
|
|
2432
|
+
this._instanceSelectMode = h;
|
|
2393
2433
|
}
|
|
2394
|
-
}), this._modes = M({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new
|
|
2395
|
-
const s = (
|
|
2396
|
-
const
|
|
2397
|
-
return { changed:
|
|
2398
|
-
}, r = (
|
|
2434
|
+
}), this._modes = M({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new ti({ tracked: !!e.tracked, idStrategy: e.idStrategy ? e.idStrategy : void 0 });
|
|
2435
|
+
const s = (h) => {
|
|
2436
|
+
const c = [], u = this._store.copyAll().filter((p) => !h.includes(p.id) || (c.push(p), !1));
|
|
2437
|
+
return { changed: c, unchanged: u };
|
|
2438
|
+
}, r = (h, c) => {
|
|
2399
2439
|
this._enabled && this._eventListeners.finish.forEach((u) => {
|
|
2400
|
-
u(
|
|
2440
|
+
u(h, c);
|
|
2401
2441
|
});
|
|
2402
|
-
}, a = (
|
|
2442
|
+
}, a = (h, c) => {
|
|
2403
2443
|
if (!this._enabled) return;
|
|
2404
2444
|
this._eventListeners.change.forEach((g) => {
|
|
2405
|
-
g(
|
|
2445
|
+
g(h, c);
|
|
2406
2446
|
});
|
|
2407
|
-
const { changed: u, unchanged: p } = s(
|
|
2408
|
-
|
|
2409
|
-
}, l = (
|
|
2447
|
+
const { changed: u, unchanged: p } = s(h);
|
|
2448
|
+
c === "create" ? this._adapter.render({ created: u, deletedIds: [], unchanged: p, updated: [] }, this.getModeStyles()) : c === "update" ? this._adapter.render({ created: [], deletedIds: [], unchanged: p, updated: u }, this.getModeStyles()) : c === "delete" ? this._adapter.render({ created: [], deletedIds: h, unchanged: p, updated: [] }, this.getModeStyles()) : c === "styling" && this._adapter.render({ created: [], deletedIds: [], unchanged: p, updated: [] }, this.getModeStyles());
|
|
2449
|
+
}, l = (h) => {
|
|
2410
2450
|
if (!this._enabled) return;
|
|
2411
2451
|
this._eventListeners.select.forEach((p) => {
|
|
2412
|
-
p(
|
|
2452
|
+
p(h);
|
|
2413
2453
|
});
|
|
2414
|
-
const { changed:
|
|
2415
|
-
this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated:
|
|
2416
|
-
}, d = (
|
|
2454
|
+
const { changed: c, unchanged: u } = s([h]);
|
|
2455
|
+
this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: c }, this.getModeStyles());
|
|
2456
|
+
}, d = (h) => {
|
|
2417
2457
|
if (!this._enabled) return;
|
|
2418
2458
|
this._eventListeners.deselect.forEach((p) => {
|
|
2419
2459
|
p();
|
|
2420
2460
|
});
|
|
2421
|
-
const { changed:
|
|
2422
|
-
|
|
2461
|
+
const { changed: c, unchanged: u } = s([h]);
|
|
2462
|
+
c && this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: c }, this.getModeStyles());
|
|
2423
2463
|
};
|
|
2424
|
-
Object.keys(this._modes).forEach((
|
|
2425
|
-
this._modes[
|
|
2464
|
+
Object.keys(this._modes).forEach((h) => {
|
|
2465
|
+
this._modes[h].register({ mode: h, store: this._store, setCursor: this._adapter.setCursor.bind(this._adapter), project: this._adapter.project.bind(this._adapter), unproject: this._adapter.unproject.bind(this._adapter), setDoubleClickToZoom: this._adapter.setDoubleClickToZoom.bind(this._adapter), onChange: a, onSelect: l, onDeselect: d, onFinish: r, coordinatePrecision: this._adapter.getCoordinatePrecision() });
|
|
2426
2466
|
});
|
|
2427
2467
|
}
|
|
2428
2468
|
checkEnabled() {
|
|
@@ -2431,26 +2471,26 @@ class si {
|
|
|
2431
2471
|
getModeStyles() {
|
|
2432
2472
|
const e = {};
|
|
2433
2473
|
return Object.keys(this._modes).forEach((t) => {
|
|
2434
|
-
e[t] = (i) => this._instanceSelectMode && i.properties[
|
|
2474
|
+
e[t] = (i) => this._instanceSelectMode && i.properties[V.SELECTED] ? this._modes[this._instanceSelectMode].styleFeature.bind(this._modes[this._instanceSelectMode])(i) : this._modes[t].styleFeature.bind(this._modes[t])(i);
|
|
2435
2475
|
}), e;
|
|
2436
2476
|
}
|
|
2437
2477
|
featuresAtLocation({ lng: e, lat: t }, i) {
|
|
2438
|
-
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 =
|
|
2439
|
-
return this._store.search(d).filter((
|
|
2440
|
-
if (s && (
|
|
2441
|
-
if (
|
|
2442
|
-
const
|
|
2478
|
+
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 = nt({ unproject: r, point: l, pointerDistance: n });
|
|
2479
|
+
return this._store.search(d).filter((h) => {
|
|
2480
|
+
if (s && (h.properties[V.MID_POINT] || h.properties[V.SELECTION_POINT])) return !1;
|
|
2481
|
+
if (h.geometry.type === "Point") {
|
|
2482
|
+
const c = h.geometry.coordinates, u = a(c[0], c[1]);
|
|
2443
2483
|
return D(l, u) < n;
|
|
2444
2484
|
}
|
|
2445
|
-
if (
|
|
2446
|
-
const
|
|
2447
|
-
for (let u = 0; u <
|
|
2448
|
-
const p =
|
|
2449
|
-
if (
|
|
2485
|
+
if (h.geometry.type === "LineString") {
|
|
2486
|
+
const c = h.geometry.coordinates;
|
|
2487
|
+
for (let u = 0; u < c.length - 1; u++) {
|
|
2488
|
+
const p = c[u], g = c[u + 1];
|
|
2489
|
+
if (ut(l, a(p[0], p[1]), a(g[0], g[1])) < n) return !0;
|
|
2450
2490
|
}
|
|
2451
2491
|
return !1;
|
|
2452
2492
|
}
|
|
2453
|
-
return !!ct([e, t],
|
|
2493
|
+
return !!ct([e, t], h.geometry.coordinates) || void 0;
|
|
2454
2494
|
});
|
|
2455
2495
|
}
|
|
2456
2496
|
getSelectMode() {
|
|
@@ -2551,15 +2591,15 @@ class si {
|
|
|
2551
2591
|
i.includes(t) && i.splice(i.indexOf(t), 1);
|
|
2552
2592
|
}
|
|
2553
2593
|
}
|
|
2554
|
-
var
|
|
2555
|
-
function
|
|
2594
|
+
var Xe, Me, Ye;
|
|
2595
|
+
function He(o, e = 9) {
|
|
2556
2596
|
const t = Math.pow(10, e);
|
|
2557
2597
|
return Math.round(o * t) / t;
|
|
2558
2598
|
}
|
|
2559
|
-
(
|
|
2599
|
+
(Me = Xe || (Xe = {})).Commit = "commit", Me.Provisional = "provisional", Me.Finish = "finish", function(o) {
|
|
2560
2600
|
o.Drawing = "drawing", o.Select = "select", o.Static = "static", o.Render = "render";
|
|
2561
|
-
}(
|
|
2562
|
-
class
|
|
2601
|
+
}(Ye || (Ye = {}));
|
|
2602
|
+
class $ {
|
|
2563
2603
|
constructor({ name: e, callback: t, unregister: i, register: n }) {
|
|
2564
2604
|
this.name = void 0, this.callback = void 0, this.registered = !1, this.register = void 0, this.unregister = void 0, this.name = e, this.register = () => {
|
|
2565
2605
|
this.registered || (this.registered = !0, n(t));
|
|
@@ -2568,7 +2608,7 @@ class H {
|
|
|
2568
2608
|
}, this.callback = t;
|
|
2569
2609
|
}
|
|
2570
2610
|
}
|
|
2571
|
-
var
|
|
2611
|
+
var ri = class {
|
|
2572
2612
|
constructor(o) {
|
|
2573
2613
|
this._minPixelDragDistance = void 0, this._minPixelDragDistanceDrawing = void 0, this._minPixelDragDistanceSelecting = void 0, this._lastDrawEvent = void 0, this._coordinatePrecision = void 0, this._heldKeys = /* @__PURE__ */ new Set(), this._listeners = [], this._dragState = "not-dragging", this._currentModeCallbacks = void 0, this._minPixelDragDistance = typeof o.minPixelDragDistance == "number" ? o.minPixelDragDistance : 1, this._minPixelDragDistanceSelecting = typeof o.minPixelDragDistanceSelecting == "number" ? o.minPixelDragDistanceSelecting : 1, this._minPixelDragDistanceDrawing = typeof o.minPixelDragDistanceDrawing == "number" ? o.minPixelDragDistanceDrawing : 8, this._coordinatePrecision = typeof o.coordinatePrecision == "number" ? o.coordinatePrecision : 9;
|
|
2574
2614
|
}
|
|
@@ -2583,7 +2623,7 @@ var oi = class {
|
|
|
2583
2623
|
const e = this.getLngLatFromEvent(o);
|
|
2584
2624
|
if (!e) return null;
|
|
2585
2625
|
const { lng: t, lat: i } = e, { containerX: n, containerY: s } = this.getMapElementXYPosition(o), r = this.getButton(o), a = Array.from(this._heldKeys);
|
|
2586
|
-
return { lng:
|
|
2626
|
+
return { lng: He(t, this._coordinatePrecision), lat: He(i, this._coordinatePrecision), containerX: n, containerY: s, button: r, heldKeys: a };
|
|
2587
2627
|
}
|
|
2588
2628
|
register(o) {
|
|
2589
2629
|
this._currentModeCallbacks = o, this._listeners = this.getAdapterListeners(), this._listeners.forEach((e) => {
|
|
@@ -2594,7 +2634,7 @@ var oi = class {
|
|
|
2594
2634
|
return this._coordinatePrecision;
|
|
2595
2635
|
}
|
|
2596
2636
|
getAdapterListeners() {
|
|
2597
|
-
return [new
|
|
2637
|
+
return [new $({ name: "pointerdown", callback: (o) => {
|
|
2598
2638
|
if (!this._currentModeCallbacks || !o.isPrimary) return;
|
|
2599
2639
|
const e = this.getDrawEventFromEvent(o);
|
|
2600
2640
|
e && (this._dragState = "pre-dragging", this._lastDrawEvent = e);
|
|
@@ -2602,7 +2642,7 @@ var oi = class {
|
|
|
2602
2642
|
this.getMapEventElement().addEventListener("pointerdown", o);
|
|
2603
2643
|
}, unregister: (o) => {
|
|
2604
2644
|
this.getMapEventElement().removeEventListener("pointerdown", o);
|
|
2605
|
-
} }), new
|
|
2645
|
+
} }), new $({ name: "pointermove", callback: (o) => {
|
|
2606
2646
|
if (!this._currentModeCallbacks || !o.isPrimary) return;
|
|
2607
2647
|
o.preventDefault();
|
|
2608
2648
|
const e = this.getDrawEventFromEvent(o);
|
|
@@ -2610,7 +2650,7 @@ var oi = class {
|
|
|
2610
2650
|
else if (this._dragState === "pre-dragging") {
|
|
2611
2651
|
if (!this._lastDrawEvent) return;
|
|
2612
2652
|
const t = { x: this._lastDrawEvent.containerX, y: this._lastDrawEvent.containerY }, i = { x: e.containerX, y: e.containerY }, n = this._currentModeCallbacks.getState(), s = ((a, l) => {
|
|
2613
|
-
const { x: d, y:
|
|
2653
|
+
const { x: d, y: h } = a, { x: c, y: u } = l, p = c - d, g = u - h;
|
|
2614
2654
|
return Math.sqrt(g * g + p * p);
|
|
2615
2655
|
})(t, i);
|
|
2616
2656
|
let r = !1;
|
|
@@ -2625,13 +2665,13 @@ var oi = class {
|
|
|
2625
2665
|
this.getMapEventElement().addEventListener("pointermove", o);
|
|
2626
2666
|
}, unregister: (o) => {
|
|
2627
2667
|
this.getMapEventElement().removeEventListener("pointermove", o);
|
|
2628
|
-
} }), new
|
|
2668
|
+
} }), new $({ name: "contextmenu", callback: (o) => {
|
|
2629
2669
|
this._currentModeCallbacks && o.preventDefault();
|
|
2630
2670
|
}, register: (o) => {
|
|
2631
2671
|
this.getMapEventElement().addEventListener("contextmenu", o);
|
|
2632
2672
|
}, unregister: (o) => {
|
|
2633
2673
|
this.getMapEventElement().removeEventListener("contextmenu", o);
|
|
2634
|
-
} }), new
|
|
2674
|
+
} }), new $({ name: "pointerup", callback: (o) => {
|
|
2635
2675
|
if (!this._currentModeCallbacks || o.target !== this.getMapEventElement() || !o.isPrimary) return;
|
|
2636
2676
|
const e = this.getDrawEventFromEvent(o);
|
|
2637
2677
|
e && (this._dragState === "dragging" ? this._currentModeCallbacks.onDragEnd(e, (t) => {
|
|
@@ -2641,13 +2681,13 @@ var oi = class {
|
|
|
2641
2681
|
this.getMapEventElement().addEventListener("pointerup", o);
|
|
2642
2682
|
}, unregister: (o) => {
|
|
2643
2683
|
this.getMapEventElement().removeEventListener("pointerup", o);
|
|
2644
|
-
} }), new
|
|
2684
|
+
} }), new $({ name: "keyup", callback: (o) => {
|
|
2645
2685
|
this._currentModeCallbacks && (this._heldKeys.delete(o.key), this._currentModeCallbacks.onKeyUp({ key: o.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => o.preventDefault() }));
|
|
2646
2686
|
}, register: (o) => {
|
|
2647
2687
|
this.getMapEventElement().addEventListener("keyup", o);
|
|
2648
2688
|
}, unregister: (o) => {
|
|
2649
2689
|
this.getMapEventElement().removeEventListener("keyup", o);
|
|
2650
|
-
} }), new
|
|
2690
|
+
} }), new $({ name: "keydown", callback: (o) => {
|
|
2651
2691
|
this._currentModeCallbacks && (this._heldKeys.add(o.key), this._currentModeCallbacks.onKeyDown({ key: o.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => o.preventDefault() }));
|
|
2652
2692
|
}, register: (o) => {
|
|
2653
2693
|
this.getMapEventElement().addEventListener("keydown", o);
|
|
@@ -2661,7 +2701,7 @@ var oi = class {
|
|
|
2661
2701
|
}), this.clear();
|
|
2662
2702
|
}
|
|
2663
2703
|
};
|
|
2664
|
-
class
|
|
2704
|
+
class ai extends ri {
|
|
2665
2705
|
constructor(e) {
|
|
2666
2706
|
super(e), 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 = e.map, this._container = this._map.getContainer();
|
|
2667
2707
|
}
|
|
@@ -2731,13 +2771,13 @@ class ri extends oi {
|
|
|
2731
2771
|
this.updateChangedIds(e), this._nextRender && cancelAnimationFrame(this._nextRender), this._nextRender = requestAnimationFrame(() => {
|
|
2732
2772
|
const i = [...e.created, ...e.updated, ...e.unchanged], n = [], s = [], r = [];
|
|
2733
2773
|
for (let a = 0; a < i.length; a++) {
|
|
2734
|
-
const l = i[a], { properties: d } = l,
|
|
2735
|
-
l.geometry.type === "Point" ? (d.pointColor =
|
|
2774
|
+
const l = i[a], { properties: d } = l, h = t[d.mode](l);
|
|
2775
|
+
l.geometry.type === "Point" ? (d.pointColor = h.pointColor, d.pointOutlineColor = h.pointOutlineColor, d.pointOutlineWidth = h.pointOutlineWidth, d.pointWidth = h.pointWidth, n.push(l)) : l.geometry.type === "LineString" ? (d.lineStringColor = h.lineStringColor, d.lineStringWidth = h.lineStringWidth, s.push(l)) : l.geometry.type === "Polygon" && (d.polygonFillColor = h.polygonFillColor, d.polygonFillOpacity = h.polygonFillOpacity, d.polygonOutlineColor = h.polygonOutlineColor, d.polygonOutlineWidth = h.polygonOutlineWidth, r.push(l));
|
|
2736
2776
|
}
|
|
2737
2777
|
if (this._rendered) {
|
|
2738
2778
|
const a = this.changedIds.deletion || this.changedIds.styling, l = a || this.changedIds.linestrings, d = a || this.changedIds.polygons;
|
|
2739
|
-
let
|
|
2740
|
-
(a || this.changedIds.points) && (
|
|
2779
|
+
let h;
|
|
2780
|
+
(a || this.changedIds.points) && (h = this._setGeoJSONLayerData("Point", n)), l && this._setGeoJSONLayerData("LineString", s), d && this._setGeoJSONLayerData("Polygon", r), h && this._map.moveLayer(h);
|
|
2741
2781
|
} else {
|
|
2742
2782
|
const a = this._addGeoJSONLayer("Point", n);
|
|
2743
2783
|
this._addGeoJSONLayer("LineString", s), this._addGeoJSONLayer("Polygon", r), this._rendered = !0, a && this._map.moveLayer(a);
|
|
@@ -2759,7 +2799,7 @@ class ri extends oi {
|
|
|
2759
2799
|
super.register(e), (t = this._currentModeCallbacks) != null && t.onReady && this._currentModeCallbacks.onReady();
|
|
2760
2800
|
}
|
|
2761
2801
|
}
|
|
2762
|
-
const
|
|
2802
|
+
const Ii = [
|
|
2763
2803
|
"render",
|
|
2764
2804
|
"point",
|
|
2765
2805
|
"linestring",
|
|
@@ -2788,7 +2828,7 @@ const Mi = [
|
|
|
2788
2828
|
"delete-selection",
|
|
2789
2829
|
"delete",
|
|
2790
2830
|
"download"
|
|
2791
|
-
],
|
|
2831
|
+
], li = {
|
|
2792
2832
|
modes: [
|
|
2793
2833
|
"render",
|
|
2794
2834
|
"point",
|
|
@@ -2806,7 +2846,7 @@ const Mi = [
|
|
|
2806
2846
|
"download"
|
|
2807
2847
|
],
|
|
2808
2848
|
open: !1
|
|
2809
|
-
},
|
|
2849
|
+
}, di = {
|
|
2810
2850
|
modes: [
|
|
2811
2851
|
"render",
|
|
2812
2852
|
"linestring",
|
|
@@ -2825,7 +2865,7 @@ const Mi = [
|
|
|
2825
2865
|
open: !1,
|
|
2826
2866
|
// see styling parameters of Terra Draw at https://github.com/JamesLMilner/terra-draw/blob/main/guides/5.STYLING.md
|
|
2827
2867
|
modeOptions: {
|
|
2828
|
-
linestring: new
|
|
2868
|
+
linestring: new rt({
|
|
2829
2869
|
styles: {
|
|
2830
2870
|
lineStringColor: "#232E3D",
|
|
2831
2871
|
lineStringWidth: 2,
|
|
@@ -2835,7 +2875,7 @@ const Mi = [
|
|
|
2835
2875
|
closingPointOutlineWidth: 1
|
|
2836
2876
|
}
|
|
2837
2877
|
}),
|
|
2838
|
-
polygon: new
|
|
2878
|
+
polygon: new lt({
|
|
2839
2879
|
styles: {
|
|
2840
2880
|
fillColor: "#EDEFF0",
|
|
2841
2881
|
fillOpacity: 0.7,
|
|
@@ -2847,7 +2887,7 @@ const Mi = [
|
|
|
2847
2887
|
closingPointOutlineWidth: 1
|
|
2848
2888
|
}
|
|
2849
2889
|
}),
|
|
2850
|
-
rectangle: new
|
|
2890
|
+
rectangle: new dt({
|
|
2851
2891
|
styles: {
|
|
2852
2892
|
fillColor: "#EDEFF0",
|
|
2853
2893
|
fillOpacity: 0.7,
|
|
@@ -2855,7 +2895,7 @@ const Mi = [
|
|
|
2855
2895
|
outlineWidth: 2
|
|
2856
2896
|
}
|
|
2857
2897
|
}),
|
|
2858
|
-
"angled-rectangle": new
|
|
2898
|
+
"angled-rectangle": new yt({
|
|
2859
2899
|
styles: {
|
|
2860
2900
|
fillColor: "#EDEFF0",
|
|
2861
2901
|
fillOpacity: 0.7,
|
|
@@ -2863,7 +2903,7 @@ const Mi = [
|
|
|
2863
2903
|
outlineWidth: 2
|
|
2864
2904
|
}
|
|
2865
2905
|
}),
|
|
2866
|
-
circle: new
|
|
2906
|
+
circle: new tt({
|
|
2867
2907
|
styles: {
|
|
2868
2908
|
fillColor: "#EDEFF0",
|
|
2869
2909
|
fillOpacity: 0.7,
|
|
@@ -2871,7 +2911,7 @@ const Mi = [
|
|
|
2871
2911
|
outlineWidth: 2
|
|
2872
2912
|
}
|
|
2873
2913
|
}),
|
|
2874
|
-
freehand: new
|
|
2914
|
+
freehand: new it({
|
|
2875
2915
|
styles: {
|
|
2876
2916
|
fillColor: "#EDEFF0",
|
|
2877
2917
|
fillOpacity: 0.7,
|
|
@@ -2883,7 +2923,7 @@ const Mi = [
|
|
|
2883
2923
|
closingPointOutlineWidth: 1
|
|
2884
2924
|
}
|
|
2885
2925
|
}),
|
|
2886
|
-
sensor: new
|
|
2926
|
+
sensor: new Ct({
|
|
2887
2927
|
styles: {
|
|
2888
2928
|
fillColor: "#EDEFF0",
|
|
2889
2929
|
fillOpacity: 0.7,
|
|
@@ -2895,7 +2935,7 @@ const Mi = [
|
|
|
2895
2935
|
centerPointOutlineWidth: 1
|
|
2896
2936
|
}
|
|
2897
2937
|
}),
|
|
2898
|
-
sector: new
|
|
2938
|
+
sector: new mt({
|
|
2899
2939
|
styles: {
|
|
2900
2940
|
fillColor: "#EDEFF0",
|
|
2901
2941
|
fillOpacity: 0.7,
|
|
@@ -3008,28 +3048,28 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3008
3048
|
distancePrecision: 2,
|
|
3009
3049
|
areaUnit: "metric",
|
|
3010
3050
|
areaPrecision: 2
|
|
3011
|
-
},
|
|
3012
|
-
render: new
|
|
3051
|
+
}, hi = () => ({
|
|
3052
|
+
render: new ee({
|
|
3013
3053
|
modeName: "render",
|
|
3014
3054
|
styles: {}
|
|
3015
3055
|
}),
|
|
3016
3056
|
point: new Lt(),
|
|
3017
|
-
linestring: new
|
|
3018
|
-
polygon: new
|
|
3057
|
+
linestring: new rt(),
|
|
3058
|
+
polygon: new lt({
|
|
3019
3059
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3020
3060
|
// @ts-ignore
|
|
3021
3061
|
validation: (e, t) => {
|
|
3022
3062
|
const i = t.updateType;
|
|
3023
|
-
return i === "finish" || i === "commit" ?
|
|
3063
|
+
return i === "finish" || i === "commit" ? si(e) : { valid: !0 };
|
|
3024
3064
|
}
|
|
3025
3065
|
}),
|
|
3026
|
-
rectangle: new
|
|
3027
|
-
"angled-rectangle": new
|
|
3028
|
-
circle: new
|
|
3029
|
-
freehand: new
|
|
3030
|
-
sensor: new
|
|
3031
|
-
sector: new
|
|
3032
|
-
select: new
|
|
3066
|
+
rectangle: new dt(),
|
|
3067
|
+
"angled-rectangle": new yt(),
|
|
3068
|
+
circle: new tt(),
|
|
3069
|
+
freehand: new it(),
|
|
3070
|
+
sensor: new Ct(),
|
|
3071
|
+
sector: new mt(),
|
|
3072
|
+
select: new Yt({
|
|
3033
3073
|
flags: {
|
|
3034
3074
|
point: {
|
|
3035
3075
|
feature: {
|
|
@@ -3130,15 +3170,15 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3130
3170
|
}
|
|
3131
3171
|
}
|
|
3132
3172
|
}),
|
|
3133
|
-
delete: new
|
|
3173
|
+
delete: new ee({
|
|
3134
3174
|
modeName: "delete",
|
|
3135
3175
|
styles: {}
|
|
3136
3176
|
}),
|
|
3137
|
-
"delete-selection": new
|
|
3177
|
+
"delete-selection": new ee({
|
|
3138
3178
|
modeName: "delete-selection",
|
|
3139
3179
|
styles: {}
|
|
3140
3180
|
}),
|
|
3141
|
-
download: new
|
|
3181
|
+
download: new ee({
|
|
3142
3182
|
modeName: "download",
|
|
3143
3183
|
styles: {}
|
|
3144
3184
|
})
|
|
@@ -3152,13 +3192,35 @@ class ci {
|
|
|
3152
3192
|
A(this, "controlContainer");
|
|
3153
3193
|
A(this, "map");
|
|
3154
3194
|
A(this, "modeButtons", {});
|
|
3155
|
-
A(this, "
|
|
3195
|
+
A(this, "_isExpanded", !1);
|
|
3156
3196
|
A(this, "terradraw");
|
|
3157
|
-
A(this, "options",
|
|
3197
|
+
A(this, "options", li);
|
|
3158
3198
|
A(this, "events", {});
|
|
3159
3199
|
A(this, "defaultMode", "render");
|
|
3160
3200
|
this.modeButtons = {}, e && (this.options = Object.assign(this.options, e));
|
|
3161
3201
|
}
|
|
3202
|
+
/**
|
|
3203
|
+
* get the state of whether the control is expanded or collapsed
|
|
3204
|
+
*/
|
|
3205
|
+
get isExpanded() {
|
|
3206
|
+
return this._isExpanded;
|
|
3207
|
+
}
|
|
3208
|
+
/**
|
|
3209
|
+
* set the state of the control either expanded or collapsed.
|
|
3210
|
+
* terradraw mode will be reset if the state is changed.
|
|
3211
|
+
* either `expanded` or `collapsed` event is dispatched when changed
|
|
3212
|
+
*/
|
|
3213
|
+
set isExpanded(e) {
|
|
3214
|
+
var n, s;
|
|
3215
|
+
this._isExpanded = e;
|
|
3216
|
+
const t = document.getElementsByClassName("maplibregl-terradraw-add-control");
|
|
3217
|
+
for (let r = 0; r < t.length; r++) {
|
|
3218
|
+
const a = t.item(r);
|
|
3219
|
+
a && (this.isExpanded ? a.classList.remove("hidden") : a.classList.add("hidden"));
|
|
3220
|
+
}
|
|
3221
|
+
const i = document.getElementsByClassName("maplibregl-terradraw-render-button");
|
|
3222
|
+
i && i.length > 0 && (this.isExpanded ? (n = i.item(0)) == null || n.classList.add("enabled") : ((s = i.item(0)) == null || s.classList.remove("enabled"), this.resetActiveMode())), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.isExpanded ? this.dispatchEvent("expanded") : this.dispatchEvent("collapsed");
|
|
3223
|
+
}
|
|
3162
3224
|
/**
|
|
3163
3225
|
* Get the default control position
|
|
3164
3226
|
* @returns default control position. Default is 'top-right'
|
|
@@ -3176,36 +3238,36 @@ class ci {
|
|
|
3176
3238
|
if (this.options && this.options.modes && this.options.modes.length === 0)
|
|
3177
3239
|
throw new Error("At least a mode must be enabled.");
|
|
3178
3240
|
this.map = e;
|
|
3179
|
-
const t =
|
|
3241
|
+
const t = hi(), i = [];
|
|
3180
3242
|
return (s = (n = this.options) == null ? void 0 : n.modes) == null || s.forEach((d) => {
|
|
3181
3243
|
if (this.options.modeOptions && this.options.modeOptions[d]) {
|
|
3182
|
-
const
|
|
3244
|
+
const h = this.options.modeOptions[d];
|
|
3183
3245
|
if (d === "select") {
|
|
3184
|
-
const
|
|
3185
|
-
if (
|
|
3186
|
-
const u =
|
|
3246
|
+
const c = t[d];
|
|
3247
|
+
if (c) {
|
|
3248
|
+
const u = c.flags;
|
|
3187
3249
|
Object.keys(u).forEach((p) => {
|
|
3188
|
-
|
|
3250
|
+
h.flags[p] || (h.flags[p] = u[p]);
|
|
3189
3251
|
});
|
|
3190
3252
|
}
|
|
3191
3253
|
}
|
|
3192
|
-
i.push(
|
|
3254
|
+
i.push(h);
|
|
3193
3255
|
} else t[d] && i.push(t[d]);
|
|
3194
3256
|
}), i.forEach((d) => {
|
|
3195
3257
|
d.state !== "unregistered" && (d._state = "unregistered");
|
|
3196
3258
|
}), (a = (r = this.options) == null ? void 0 : r.modes) != null && a.includes("render") || (i.push(
|
|
3197
|
-
new
|
|
3259
|
+
new ee({
|
|
3198
3260
|
modeName: "default",
|
|
3199
3261
|
styles: {}
|
|
3200
3262
|
})
|
|
3201
|
-
), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new
|
|
3202
|
-
adapter: new
|
|
3263
|
+
), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new oi({
|
|
3264
|
+
adapter: new ai({ map: e, ...this.options.adapterOptions }),
|
|
3203
3265
|
modes: i
|
|
3204
3266
|
}), this.terradraw.start(), this.controlContainer = document.createElement("div"), this.controlContainer.classList.add("maplibregl-ctrl"), this.controlContainer.classList.add("maplibregl-ctrl-group"), i.forEach((d) => {
|
|
3205
3267
|
d.mode !== "default" && this.addTerradrawButton(d.mode);
|
|
3206
3268
|
}), Object.values(this.modeButtons).forEach((d) => {
|
|
3207
|
-
var
|
|
3208
|
-
(
|
|
3269
|
+
var h;
|
|
3270
|
+
(h = this.controlContainer) == null || h.appendChild(d);
|
|
3209
3271
|
}), (l = this.terradraw) == null || l.on("change", this.toggleButtonsWhenNoFeature.bind(this)), this.toggleButtonsWhenNoFeature(), this.controlContainer;
|
|
3210
3272
|
}
|
|
3211
3273
|
/**
|
|
@@ -3269,15 +3331,7 @@ class ci {
|
|
|
3269
3331
|
* Toggle editor control
|
|
3270
3332
|
*/
|
|
3271
3333
|
toggleEditor() {
|
|
3272
|
-
|
|
3273
|
-
if (!this.terradraw) return;
|
|
3274
|
-
const e = document.getElementsByClassName("maplibregl-terradraw-add-control");
|
|
3275
|
-
for (let s = 0; s < e.length; s++) {
|
|
3276
|
-
const r = e.item(s);
|
|
3277
|
-
r && (this.isExpanded ? r.classList.add("hidden") : r.classList.remove("hidden"));
|
|
3278
|
-
}
|
|
3279
|
-
const t = document.getElementsByClassName("maplibregl-terradraw-render-button");
|
|
3280
|
-
t && t.length > 0 && (this.isExpanded ? ((i = t.item(0)) == null || i.classList.remove("enabled"), this.resetActiveMode()) : (n = t.item(0)) == null || n.classList.add("enabled")), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.isExpanded = !this.isExpanded;
|
|
3334
|
+
this.terradraw && (this.isExpanded = !this.isExpanded);
|
|
3281
3335
|
}
|
|
3282
3336
|
/**
|
|
3283
3337
|
* Reset active mode to back to render mode
|
|
@@ -3364,14 +3418,14 @@ class ci {
|
|
|
3364
3418
|
var a, l;
|
|
3365
3419
|
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");
|
|
3366
3420
|
for (let d = 0; d < r.length; d++) {
|
|
3367
|
-
const
|
|
3368
|
-
|
|
3421
|
+
const h = r.item(d);
|
|
3422
|
+
h && (s ? h.classList.remove("hidden-delete-selection") : h.classList.add("hidden-delete-selection"));
|
|
3369
3423
|
}
|
|
3370
3424
|
if (!n) {
|
|
3371
3425
|
const d = document.getElementsByClassName("maplibregl-terradraw-add-select-button");
|
|
3372
|
-
for (let
|
|
3373
|
-
const
|
|
3374
|
-
|
|
3426
|
+
for (let h = 0; h < d.length; h++) {
|
|
3427
|
+
const c = d.item(h);
|
|
3428
|
+
c && c.classList.remove("active");
|
|
3375
3429
|
}
|
|
3376
3430
|
}
|
|
3377
3431
|
}
|
|
@@ -3384,54 +3438,54 @@ class ci {
|
|
|
3384
3438
|
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
3385
3439
|
}
|
|
3386
3440
|
}
|
|
3387
|
-
var
|
|
3388
|
-
centimeters:
|
|
3389
|
-
centimetres:
|
|
3441
|
+
var k = 63710088e-1, ui = {
|
|
3442
|
+
centimeters: k * 100,
|
|
3443
|
+
centimetres: k * 100,
|
|
3390
3444
|
degrees: 360 / (2 * Math.PI),
|
|
3391
|
-
feet:
|
|
3392
|
-
inches:
|
|
3393
|
-
kilometers:
|
|
3394
|
-
kilometres:
|
|
3395
|
-
meters:
|
|
3396
|
-
metres:
|
|
3397
|
-
miles:
|
|
3398
|
-
millimeters:
|
|
3399
|
-
millimetres:
|
|
3400
|
-
nauticalmiles:
|
|
3445
|
+
feet: k * 3.28084,
|
|
3446
|
+
inches: k * 39.37,
|
|
3447
|
+
kilometers: k / 1e3,
|
|
3448
|
+
kilometres: k / 1e3,
|
|
3449
|
+
meters: k,
|
|
3450
|
+
metres: k,
|
|
3451
|
+
miles: k / 1609.344,
|
|
3452
|
+
millimeters: k * 1e3,
|
|
3453
|
+
millimetres: k * 1e3,
|
|
3454
|
+
nauticalmiles: k / 1852,
|
|
3401
3455
|
radians: 1,
|
|
3402
|
-
yards:
|
|
3456
|
+
yards: k * 1.0936
|
|
3403
3457
|
};
|
|
3404
|
-
function
|
|
3458
|
+
function pi(o, e, t = {}) {
|
|
3405
3459
|
const i = { type: "Feature" };
|
|
3406
3460
|
return (t.id === 0 || t.id) && (i.id = t.id), t.bbox && (i.bbox = t.bbox), i.properties = e || {}, i.geometry = o, i;
|
|
3407
3461
|
}
|
|
3408
|
-
function
|
|
3462
|
+
function gi(o, e, t = {}) {
|
|
3409
3463
|
if (!o)
|
|
3410
3464
|
throw new Error("coordinates is required");
|
|
3411
3465
|
if (!Array.isArray(o))
|
|
3412
3466
|
throw new Error("coordinates must be an Array");
|
|
3413
3467
|
if (o.length < 2)
|
|
3414
3468
|
throw new Error("coordinates must be at least 2 numbers long");
|
|
3415
|
-
if (
|
|
3469
|
+
if (!$e(o[0]) || !$e(o[1]))
|
|
3416
3470
|
throw new Error("coordinates must contain numbers");
|
|
3417
|
-
return
|
|
3471
|
+
return pi({
|
|
3418
3472
|
type: "Point",
|
|
3419
3473
|
coordinates: o
|
|
3420
3474
|
}, e, t);
|
|
3421
3475
|
}
|
|
3422
|
-
function
|
|
3423
|
-
const t =
|
|
3476
|
+
function yi(o, e = "kilometers") {
|
|
3477
|
+
const t = ui[e];
|
|
3424
3478
|
if (!t)
|
|
3425
3479
|
throw new Error(e + " units is invalid");
|
|
3426
3480
|
return o * t;
|
|
3427
3481
|
}
|
|
3428
|
-
function
|
|
3482
|
+
function he(o) {
|
|
3429
3483
|
return o % 360 * Math.PI / 180;
|
|
3430
3484
|
}
|
|
3431
|
-
function
|
|
3485
|
+
function $e(o) {
|
|
3432
3486
|
return !isNaN(o) && o !== null && !Array.isArray(o);
|
|
3433
3487
|
}
|
|
3434
|
-
function
|
|
3488
|
+
function Je(o) {
|
|
3435
3489
|
if (!o)
|
|
3436
3490
|
throw new Error("coord is required");
|
|
3437
3491
|
if (!Array.isArray(o)) {
|
|
@@ -3444,91 +3498,91 @@ function $e(o) {
|
|
|
3444
3498
|
return [...o];
|
|
3445
3499
|
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
3446
3500
|
}
|
|
3447
|
-
function
|
|
3448
|
-
var i =
|
|
3449
|
-
return
|
|
3501
|
+
function fi(o, e, t = {}) {
|
|
3502
|
+
var i = Je(o), n = Je(e), s = he(n[1] - i[1]), r = he(n[0] - i[0]), a = he(i[1]), l = he(n[1]), d = Math.pow(Math.sin(s / 2), 2) + Math.pow(Math.sin(r / 2), 2) * Math.cos(a) * Math.cos(l);
|
|
3503
|
+
return yi(
|
|
3450
3504
|
2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
|
|
3451
3505
|
t.units
|
|
3452
3506
|
);
|
|
3453
3507
|
}
|
|
3454
|
-
function
|
|
3508
|
+
function Pt(o, e, t) {
|
|
3455
3509
|
if (o !== null)
|
|
3456
|
-
for (var i, n, s, r, a, l, d,
|
|
3510
|
+
for (var i, n, s, r, a, l, d, h = 0, c = 0, u, p = o.type, g = p === "FeatureCollection", y = p === "Feature", C = g ? o.features.length : 1, f = 0; f < C; f++) {
|
|
3457
3511
|
d = g ? o.features[f].geometry : y ? o.geometry : o, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
|
|
3458
3512
|
for (var m = 0; m < a; m++) {
|
|
3459
|
-
var
|
|
3513
|
+
var P = 0, v = 0;
|
|
3460
3514
|
if (r = u ? d.geometries[m] : d, r !== null) {
|
|
3461
3515
|
l = r.coordinates;
|
|
3462
3516
|
var S = r.type;
|
|
3463
|
-
switch (
|
|
3517
|
+
switch (h = S === "Polygon" || S === "MultiPolygon" ? 1 : 0, S) {
|
|
3464
3518
|
case null:
|
|
3465
3519
|
break;
|
|
3466
3520
|
case "Point":
|
|
3467
3521
|
if (e(
|
|
3468
3522
|
l,
|
|
3469
|
-
|
|
3523
|
+
c,
|
|
3470
3524
|
f,
|
|
3471
|
-
|
|
3525
|
+
P,
|
|
3472
3526
|
v
|
|
3473
3527
|
) === !1)
|
|
3474
3528
|
return !1;
|
|
3475
|
-
|
|
3529
|
+
c++, P++;
|
|
3476
3530
|
break;
|
|
3477
3531
|
case "LineString":
|
|
3478
3532
|
case "MultiPoint":
|
|
3479
3533
|
for (i = 0; i < l.length; i++) {
|
|
3480
3534
|
if (e(
|
|
3481
3535
|
l[i],
|
|
3482
|
-
|
|
3536
|
+
c,
|
|
3483
3537
|
f,
|
|
3484
|
-
|
|
3538
|
+
P,
|
|
3485
3539
|
v
|
|
3486
3540
|
) === !1)
|
|
3487
3541
|
return !1;
|
|
3488
|
-
|
|
3542
|
+
c++, S === "MultiPoint" && P++;
|
|
3489
3543
|
}
|
|
3490
|
-
S === "LineString" &&
|
|
3544
|
+
S === "LineString" && P++;
|
|
3491
3545
|
break;
|
|
3492
3546
|
case "Polygon":
|
|
3493
3547
|
case "MultiLineString":
|
|
3494
3548
|
for (i = 0; i < l.length; i++) {
|
|
3495
|
-
for (n = 0; n < l[i].length -
|
|
3549
|
+
for (n = 0; n < l[i].length - h; n++) {
|
|
3496
3550
|
if (e(
|
|
3497
3551
|
l[i][n],
|
|
3498
|
-
|
|
3552
|
+
c,
|
|
3499
3553
|
f,
|
|
3500
|
-
|
|
3554
|
+
P,
|
|
3501
3555
|
v
|
|
3502
3556
|
) === !1)
|
|
3503
3557
|
return !1;
|
|
3504
|
-
|
|
3558
|
+
c++;
|
|
3505
3559
|
}
|
|
3506
|
-
S === "MultiLineString" &&
|
|
3560
|
+
S === "MultiLineString" && P++, S === "Polygon" && v++;
|
|
3507
3561
|
}
|
|
3508
|
-
S === "Polygon" &&
|
|
3562
|
+
S === "Polygon" && P++;
|
|
3509
3563
|
break;
|
|
3510
3564
|
case "MultiPolygon":
|
|
3511
3565
|
for (i = 0; i < l.length; i++) {
|
|
3512
3566
|
for (v = 0, n = 0; n < l[i].length; n++) {
|
|
3513
|
-
for (s = 0; s < l[i][n].length -
|
|
3567
|
+
for (s = 0; s < l[i][n].length - h; s++) {
|
|
3514
3568
|
if (e(
|
|
3515
3569
|
l[i][n][s],
|
|
3516
|
-
|
|
3570
|
+
c,
|
|
3517
3571
|
f,
|
|
3518
|
-
|
|
3572
|
+
P,
|
|
3519
3573
|
v
|
|
3520
3574
|
) === !1)
|
|
3521
3575
|
return !1;
|
|
3522
|
-
|
|
3576
|
+
c++;
|
|
3523
3577
|
}
|
|
3524
3578
|
v++;
|
|
3525
3579
|
}
|
|
3526
|
-
|
|
3580
|
+
P++;
|
|
3527
3581
|
}
|
|
3528
3582
|
break;
|
|
3529
3583
|
case "GeometryCollection":
|
|
3530
3584
|
for (i = 0; i < r.geometries.length; i++)
|
|
3531
|
-
if (
|
|
3585
|
+
if (Pt(r.geometries[i], e) === !1)
|
|
3532
3586
|
return !1;
|
|
3533
3587
|
break;
|
|
3534
3588
|
default:
|
|
@@ -3538,17 +3592,17 @@ function Ct(o, e, t) {
|
|
|
3538
3592
|
}
|
|
3539
3593
|
}
|
|
3540
3594
|
}
|
|
3541
|
-
function
|
|
3542
|
-
var t, i, n, s, r, a, l, d,
|
|
3595
|
+
function mi(o, e) {
|
|
3596
|
+
var t, i, n, s, r, a, l, d, h, c, u = 0, p = o.type === "FeatureCollection", g = o.type === "Feature", y = p ? o.features.length : 1;
|
|
3543
3597
|
for (t = 0; t < y; t++) {
|
|
3544
|
-
for (a = p ? o.features[t].geometry : g ? o.geometry : o, d = p ? o.features[t].properties : g ? o.properties : {},
|
|
3598
|
+
for (a = p ? o.features[t].geometry : g ? o.geometry : o, d = p ? o.features[t].properties : g ? o.properties : {}, h = p ? o.features[t].bbox : g ? o.bbox : void 0, c = 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++) {
|
|
3545
3599
|
if (s = l ? a.geometries[n] : a, s === null) {
|
|
3546
3600
|
if (e(
|
|
3547
3601
|
null,
|
|
3548
3602
|
u,
|
|
3549
3603
|
d,
|
|
3550
|
-
|
|
3551
|
-
|
|
3604
|
+
h,
|
|
3605
|
+
c
|
|
3552
3606
|
) === !1)
|
|
3553
3607
|
return !1;
|
|
3554
3608
|
continue;
|
|
@@ -3564,8 +3618,8 @@ function fi(o, e) {
|
|
|
3564
3618
|
s,
|
|
3565
3619
|
u,
|
|
3566
3620
|
d,
|
|
3567
|
-
|
|
3568
|
-
|
|
3621
|
+
h,
|
|
3622
|
+
c
|
|
3569
3623
|
) === !1)
|
|
3570
3624
|
return !1;
|
|
3571
3625
|
break;
|
|
@@ -3576,8 +3630,8 @@ function fi(o, e) {
|
|
|
3576
3630
|
s.geometries[i],
|
|
3577
3631
|
u,
|
|
3578
3632
|
d,
|
|
3579
|
-
|
|
3580
|
-
|
|
3633
|
+
h,
|
|
3634
|
+
c
|
|
3581
3635
|
) === !1)
|
|
3582
3636
|
return !1;
|
|
3583
3637
|
break;
|
|
@@ -3589,9 +3643,9 @@ function fi(o, e) {
|
|
|
3589
3643
|
u++;
|
|
3590
3644
|
}
|
|
3591
3645
|
}
|
|
3592
|
-
function
|
|
3646
|
+
function Ci(o, e, t) {
|
|
3593
3647
|
var i = t;
|
|
3594
|
-
return
|
|
3648
|
+
return mi(
|
|
3595
3649
|
o,
|
|
3596
3650
|
function(n, s, r, a, l) {
|
|
3597
3651
|
s === 0 && t === void 0 ? i = n : i = e(
|
|
@@ -3605,21 +3659,21 @@ function mi(o, e, t) {
|
|
|
3605
3659
|
}
|
|
3606
3660
|
), i;
|
|
3607
3661
|
}
|
|
3608
|
-
function
|
|
3609
|
-
return
|
|
3662
|
+
function Pi(o) {
|
|
3663
|
+
return Ci(
|
|
3610
3664
|
o,
|
|
3611
|
-
(e, t) => e +
|
|
3665
|
+
(e, t) => e + vi(t),
|
|
3612
3666
|
0
|
|
3613
3667
|
);
|
|
3614
3668
|
}
|
|
3615
|
-
function
|
|
3669
|
+
function vi(o) {
|
|
3616
3670
|
let e = 0, t;
|
|
3617
3671
|
switch (o.type) {
|
|
3618
3672
|
case "Polygon":
|
|
3619
|
-
return
|
|
3673
|
+
return qe(o.coordinates);
|
|
3620
3674
|
case "MultiPolygon":
|
|
3621
3675
|
for (t = 0; t < o.coordinates.length; t++)
|
|
3622
|
-
e +=
|
|
3676
|
+
e += qe(o.coordinates[t]);
|
|
3623
3677
|
return e;
|
|
3624
3678
|
case "Point":
|
|
3625
3679
|
case "MultiPoint":
|
|
@@ -3629,34 +3683,34 @@ function Pi(o) {
|
|
|
3629
3683
|
}
|
|
3630
3684
|
return 0;
|
|
3631
3685
|
}
|
|
3632
|
-
function
|
|
3686
|
+
function qe(o) {
|
|
3633
3687
|
let e = 0;
|
|
3634
3688
|
if (o && o.length > 0) {
|
|
3635
|
-
e += Math.abs(
|
|
3689
|
+
e += Math.abs(Ze(o[0]));
|
|
3636
3690
|
for (let t = 1; t < o.length; t++)
|
|
3637
|
-
e -= Math.abs(
|
|
3691
|
+
e -= Math.abs(Ze(o[t]));
|
|
3638
3692
|
}
|
|
3639
3693
|
return e;
|
|
3640
3694
|
}
|
|
3641
|
-
var
|
|
3642
|
-
function
|
|
3695
|
+
var Si = k * k / 2, Ie = Math.PI / 180;
|
|
3696
|
+
function Ze(o) {
|
|
3643
3697
|
const e = o.length - 1;
|
|
3644
3698
|
if (e <= 2) return 0;
|
|
3645
3699
|
let t = 0, i = 0;
|
|
3646
3700
|
for (; i < e; ) {
|
|
3647
|
-
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] *
|
|
3701
|
+
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] * Ie, l = s[1] * Ie, d = r[0] * Ie;
|
|
3648
3702
|
t += (d - a) * Math.sin(l), i++;
|
|
3649
3703
|
}
|
|
3650
|
-
return t *
|
|
3704
|
+
return t * Si;
|
|
3651
3705
|
}
|
|
3652
|
-
function
|
|
3706
|
+
function xi(o, e = {}) {
|
|
3653
3707
|
let t = 0, i = 0, n = 0;
|
|
3654
|
-
return
|
|
3708
|
+
return Pt(
|
|
3655
3709
|
o,
|
|
3656
3710
|
function(s) {
|
|
3657
3711
|
t += s[0], i += s[1], n++;
|
|
3658
3712
|
}
|
|
3659
|
-
),
|
|
3713
|
+
), gi([t / n, i / n], e.properties);
|
|
3660
3714
|
}
|
|
3661
3715
|
class bi extends ci {
|
|
3662
3716
|
/**
|
|
@@ -3664,7 +3718,7 @@ class bi extends ci {
|
|
|
3664
3718
|
* @param options Plugin control options
|
|
3665
3719
|
*/
|
|
3666
3720
|
constructor(t) {
|
|
3667
|
-
let i =
|
|
3721
|
+
let i = di;
|
|
3668
3722
|
t && (i = Object.assign(i, t));
|
|
3669
3723
|
super({
|
|
3670
3724
|
modes: i.modes,
|
|
@@ -3874,7 +3928,7 @@ class bi extends ci {
|
|
|
3874
3928
|
*/
|
|
3875
3929
|
calcArea(t) {
|
|
3876
3930
|
if (t.geometry.type !== "Polygon") return t;
|
|
3877
|
-
const i =
|
|
3931
|
+
const i = Pi(t.geometry);
|
|
3878
3932
|
let n = i, s = "m²";
|
|
3879
3933
|
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;
|
|
3880
3934
|
}
|
|
@@ -3898,13 +3952,13 @@ class bi extends ci {
|
|
|
3898
3952
|
let n = 0;
|
|
3899
3953
|
const s = [];
|
|
3900
3954
|
for (let l = 0; l < i.length - 1; l++) {
|
|
3901
|
-
const d = i[l],
|
|
3902
|
-
n +=
|
|
3955
|
+
const d = i[l], h = i[l + 1], c = fi(d, h, { units: this.distanceUnit });
|
|
3956
|
+
n += c;
|
|
3903
3957
|
const u = JSON.parse(JSON.stringify(t));
|
|
3904
|
-
if (u.id = `${u.id}-${l}`, u.geometry.coordinates = [d,
|
|
3958
|
+
if (u.id = `${u.id}-${l}`, u.geometry.coordinates = [d, h], u.properties.originalId = t.id, u.properties.distance = parseFloat(c.toFixed(this.distancePrecision)), u.properties.total = parseFloat(n.toFixed(this.distancePrecision)), u.properties.unit = this.getDistanceUnitName(this.distanceUnit), this.measureOptions.computeElevation === !0) {
|
|
3905
3959
|
const p = (r = this.map) == null ? void 0 : r.queryTerrainElevation(d);
|
|
3906
3960
|
p && (u.properties.elevation_start = p);
|
|
3907
|
-
const g = (a = this.map) == null ? void 0 : a.queryTerrainElevation(
|
|
3961
|
+
const g = (a = this.map) == null ? void 0 : a.queryTerrainElevation(h);
|
|
3908
3962
|
g && (u.properties.elevation_end = g);
|
|
3909
3963
|
}
|
|
3910
3964
|
s.push(u);
|
|
@@ -3927,12 +3981,12 @@ class bi extends ci {
|
|
|
3927
3981
|
if (a) {
|
|
3928
3982
|
typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
|
|
3929
3983
|
(d) => {
|
|
3930
|
-
var
|
|
3931
|
-
return ((
|
|
3984
|
+
var h;
|
|
3985
|
+
return ((h = d.properties) == null ? void 0 : h.originalId) !== t;
|
|
3932
3986
|
}
|
|
3933
3987
|
));
|
|
3934
3988
|
const l = JSON.parse(JSON.stringify(s));
|
|
3935
|
-
l.id = l.id + "-area-label", l.geometry =
|
|
3989
|
+
l.id = l.id + "-area-label", l.geometry = xi(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(
|
|
3936
3990
|
this.measureOptions.polygonLayerSpec.source
|
|
3937
3991
|
)) == null || r.setData(a.data), this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && this.map.moveLayer(
|
|
3938
3992
|
this.measureOptions.lineLayerLabelSpec.id
|
|
@@ -3958,27 +4012,27 @@ class bi extends ci {
|
|
|
3958
4012
|
if (a) {
|
|
3959
4013
|
typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
|
|
3960
4014
|
(d) => {
|
|
3961
|
-
var
|
|
3962
|
-
return ((
|
|
4015
|
+
var h;
|
|
4016
|
+
return ((h = d.properties) == null ? void 0 : h.originalId) !== t;
|
|
3963
4017
|
}
|
|
3964
4018
|
)), s = this.calcDistance(s);
|
|
3965
4019
|
const l = s.properties.segments;
|
|
3966
4020
|
for (let d = 0; d < l.length; d++) {
|
|
3967
|
-
const
|
|
3968
|
-
typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(
|
|
3969
|
-
const
|
|
4021
|
+
const h = l[d];
|
|
4022
|
+
typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(h);
|
|
4023
|
+
const c = h.geometry.coordinates, u = c[0], p = c[1];
|
|
3970
4024
|
if (d === 0) {
|
|
3971
|
-
const y = JSON.parse(JSON.stringify(
|
|
3972
|
-
y.id = `${
|
|
4025
|
+
const y = JSON.parse(JSON.stringify(h));
|
|
4026
|
+
y.id = `${h.id}-node-${d}`, y.geometry = {
|
|
3973
4027
|
type: "Point",
|
|
3974
4028
|
coordinates: u
|
|
3975
|
-
}, y.properties.distance = 0, y.properties.total = 0,
|
|
4029
|
+
}, y.properties.distance = 0, y.properties.total = 0, h.properties.elevation_start && (y.properties.elevation = h.properties.elevation_start), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(y);
|
|
3976
4030
|
}
|
|
3977
|
-
const g = JSON.parse(JSON.stringify(
|
|
3978
|
-
g.id = `${
|
|
4031
|
+
const g = JSON.parse(JSON.stringify(h));
|
|
4032
|
+
g.id = `${h.id}-node-${d + 1}`, g.geometry = {
|
|
3979
4033
|
type: "Point",
|
|
3980
4034
|
coordinates: p
|
|
3981
|
-
},
|
|
4035
|
+
}, h.properties.elevation_end && (g.properties.elevation = h.properties.elevation_end), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(g);
|
|
3982
4036
|
}
|
|
3983
4037
|
(r = this.map.getSource(
|
|
3984
4038
|
this.measureOptions.lineLayerLabelSpec.source
|
|
@@ -4001,13 +4055,13 @@ class bi extends ci {
|
|
|
4001
4055
|
for (const r of s) {
|
|
4002
4056
|
const a = this.map.getStyle().sources[r];
|
|
4003
4057
|
if (a) {
|
|
4004
|
-
const l = t.getSnapshot(),
|
|
4005
|
-
(
|
|
4006
|
-
)).map((
|
|
4058
|
+
const l = t.getSnapshot(), h = (l == null ? void 0 : l.filter(
|
|
4059
|
+
(c) => ["LineString", "Polygon"].includes(c.geometry.type)
|
|
4060
|
+
)).map((c) => c.id);
|
|
4007
4061
|
typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
|
|
4008
|
-
(
|
|
4062
|
+
(c) => {
|
|
4009
4063
|
var u;
|
|
4010
|
-
return
|
|
4064
|
+
return h.includes((u = c.properties) == null ? void 0 : u.originalId);
|
|
4011
4065
|
}
|
|
4012
4066
|
)), r === this.measureOptions.lineLayerLabelSpec.source ? ((i = this.map.getSource(
|
|
4013
4067
|
this.measureOptions.lineLayerLabelSpec.source
|
|
@@ -4045,11 +4099,11 @@ class bi extends ci {
|
|
|
4045
4099
|
}
|
|
4046
4100
|
export {
|
|
4047
4101
|
wi as AvailableMeasureModes,
|
|
4048
|
-
|
|
4102
|
+
Ii as AvailableModes,
|
|
4049
4103
|
bi as MaplibreMeasureControl,
|
|
4050
4104
|
ci as MaplibreTerradrawControl,
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4105
|
+
li as defaultControlOptions,
|
|
4106
|
+
di as defaultMeasureControlOptions,
|
|
4107
|
+
hi as getDefaultModeOptions
|
|
4054
4108
|
};
|
|
4055
4109
|
//# sourceMappingURL=maplibre-gl-terradraw.es.js.map
|