@watergis/maplibre-gl-terradraw 1.3.1 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/maplibre-gl-terradraw.es.js +929 -846
- package/dist/maplibre-gl-terradraw.es.js.map +1 -1
- package/dist/maplibre-gl-terradraw.umd.js +2 -2
- package/dist/maplibre-gl-terradraw.umd.js.map +1 -1
- package/dist/types/constants/defaultMeasureControlOptions.d.ts.map +1 -1
- package/dist/types/constants/getDefaultModeOptions.d.ts.map +1 -1
- package/dist/types/controls/MaplibreMeasureControl.d.ts +1 -1
- package/dist/types/controls/MaplibreMeasureControl.d.ts.map +1 -1
- package/dist/types/controls/MaplibreTerradrawControl.d.ts.map +1 -1
- package/dist/types/helpers/calcArea.d.ts.map +1 -1
- package/dist/types/helpers/calcDistance.d.ts.map +1 -1
- package/dist/types/helpers/capitalize.d.ts.map +1 -1
- package/dist/types/helpers/cleanMaplibreStyle.d.ts.map +1 -1
- package/dist/types/helpers/convertAreaUnit.d.ts.map +1 -1
- package/dist/types/helpers/debounce.d.ts.map +1 -1
- package/dist/types/helpers/getDistanceUnitName.d.ts.map +1 -1
- package/dist/types/helpers/queryElevationByPoint.d.ts.map +1 -1
- package/dist/types/helpers/queryElevationFromRasterDEM.d.ts.map +1 -1
- package/package.json +27 -26
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var k = (s, t, e) =>
|
|
1
|
+
var Ue = Object.defineProperty;
|
|
2
|
+
var ze = (s, t, e) => t in s ? Ue(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
3
|
+
var k = (s, t, e) => ze(s, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import "maplibre-gl";
|
|
5
5
|
function b() {
|
|
6
6
|
return b = Object.assign ? Object.assign.bind() : function(s) {
|
|
@@ -11,24 +11,24 @@ function b() {
|
|
|
11
11
|
return s;
|
|
12
12
|
}, b.apply(null, arguments);
|
|
13
13
|
}
|
|
14
|
-
var
|
|
14
|
+
var I;
|
|
15
15
|
(function(s) {
|
|
16
16
|
s.Commit = "commit", s.Provisional = "provisional", s.Finish = "finish";
|
|
17
|
-
})(
|
|
18
|
-
const
|
|
17
|
+
})(I || (I = {}));
|
|
18
|
+
const U = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT: "selectionPoint" }, V = "edited", st = "closingPoint", Dt = "snappingPoint";
|
|
19
19
|
function bt(s) {
|
|
20
20
|
return !!(s && typeof s == "object" && s !== null && !Array.isArray(s));
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function Vt(s) {
|
|
23
23
|
return !!function(t) {
|
|
24
24
|
return typeof t == "number" && !isNaN(new Date(t).valueOf());
|
|
25
25
|
}(s);
|
|
26
26
|
}
|
|
27
|
-
const
|
|
28
|
-
var
|
|
27
|
+
const Re = "Feature mode property does not match the mode being added to";
|
|
28
|
+
var $;
|
|
29
29
|
(function(s) {
|
|
30
30
|
s.Drawing = "drawing", s.Select = "select", s.Static = "static", s.Render = "render";
|
|
31
|
-
})(
|
|
31
|
+
})($ || ($ = {}));
|
|
32
32
|
class N {
|
|
33
33
|
get state() {
|
|
34
34
|
return this._state;
|
|
@@ -41,12 +41,15 @@ class N {
|
|
|
41
41
|
}
|
|
42
42
|
set styles(t) {
|
|
43
43
|
if (typeof t != "object") throw new Error("Styling must be an object");
|
|
44
|
-
this.onStyleChange([], "styling"), this._styles = t;
|
|
44
|
+
this.onStyleChange && this.onStyleChange([], "styling"), this._styles = t;
|
|
45
45
|
}
|
|
46
46
|
registerBehaviors(t) {
|
|
47
47
|
}
|
|
48
|
-
constructor(t) {
|
|
49
|
-
this._state =
|
|
48
|
+
constructor(t, e = !1) {
|
|
49
|
+
this._state = "unregistered", this._styles = {}, this.behaviors = [], this.validate = void 0, this.pointerDistance = 40, this.coordinatePrecision = void 0, this.onStyleChange = void 0, this.store = void 0, this.projection = "web-mercator", this.setDoubleClickToZoom = void 0, this.unproject = void 0, this.project = void 0, this.setCursor = void 0, this.type = $.Drawing, this.mode = "base", e || this.updateOptions(t);
|
|
50
|
+
}
|
|
51
|
+
updateOptions(t) {
|
|
52
|
+
t != null && t.styles && (this.styles = b({}, this._styles, t.styles)), t != null && t.pointerDistance && (this.pointerDistance = t.pointerDistance), t != null && t.validation && (this.validate = t && t.validation), t != null && t.projection && (this.projection = t.projection);
|
|
50
53
|
}
|
|
51
54
|
setDrawing() {
|
|
52
55
|
if (this._state !== "started") throw new Error("Mode must be unregistered or stopped to start");
|
|
@@ -84,14 +87,14 @@ class N {
|
|
|
84
87
|
return r ? { valid: !1, reason: r } : { valid: !0 };
|
|
85
88
|
}(t, this.store.idStrategy.isValidId);
|
|
86
89
|
if (this.validate) {
|
|
87
|
-
const i = this.validate(t, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
90
|
+
const i = this.validate(t, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: I.Provisional });
|
|
88
91
|
return { valid: e.valid && i.valid, reason: i.reason };
|
|
89
92
|
}
|
|
90
93
|
return { valid: e.valid, reason: e.reason };
|
|
91
94
|
}
|
|
92
95
|
validateModeFeature(t, e) {
|
|
93
96
|
const i = this.performFeatureValidation(t);
|
|
94
|
-
return i.valid ? t.properties.mode !== this.mode ? { valid: !1, reason:
|
|
97
|
+
return i.valid ? t.properties.mode !== this.mode ? { valid: !1, reason: Re } : e(t) : { valid: !1, reason: i.reason };
|
|
95
98
|
}
|
|
96
99
|
onFinish(t, e) {
|
|
97
100
|
}
|
|
@@ -123,43 +126,43 @@ class N {
|
|
|
123
126
|
return t === void 0 ? e : typeof t == "function" ? t(i) : t;
|
|
124
127
|
}
|
|
125
128
|
}
|
|
126
|
-
class
|
|
129
|
+
class Xe extends N {
|
|
127
130
|
constructor(...t) {
|
|
128
|
-
super(...t), this.type =
|
|
131
|
+
super(...t), this.type = $.Select;
|
|
129
132
|
}
|
|
130
133
|
}
|
|
131
|
-
function
|
|
134
|
+
function A(s, t) {
|
|
132
135
|
const e = (d) => d * Math.PI / 180, i = e(s[1]), o = e(s[0]), r = e(t[1]), n = r - i, a = e(t[0]) - o, l = Math.sin(n / 2) * Math.sin(n / 2) + Math.cos(i) * Math.cos(r) * Math.sin(a / 2) * Math.sin(a / 2);
|
|
133
136
|
return 2 * Math.atan2(Math.sqrt(l), Math.sqrt(1 - l)) * 6371e3 / 1e3;
|
|
134
137
|
}
|
|
135
|
-
const
|
|
138
|
+
const ye = 63710088e-1;
|
|
136
139
|
function E(s) {
|
|
137
140
|
return s % 360 * Math.PI / 180;
|
|
138
141
|
}
|
|
139
|
-
function
|
|
142
|
+
function fe(s) {
|
|
140
143
|
return s / 6371.0088;
|
|
141
144
|
}
|
|
142
|
-
function
|
|
145
|
+
function z(s) {
|
|
143
146
|
return s % (2 * Math.PI) * 180 / Math.PI;
|
|
144
147
|
}
|
|
145
148
|
function F(s, t = 9) {
|
|
146
149
|
const e = Math.pow(10, t);
|
|
147
150
|
return Math.round(s * e) / e;
|
|
148
151
|
}
|
|
149
|
-
const
|
|
150
|
-
function
|
|
151
|
-
const i = E(s[0]), o = E(s[1]), r = E(e), n =
|
|
152
|
-
return [
|
|
152
|
+
const Ut = 57.29577951308232, zt = 0.017453292519943295, ft = 6378137, x = (s, t) => ({ x: s === 0 ? 0 : s * zt * ft, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * zt / 2)) * ft }), W = (s, t) => ({ lng: s === 0 ? 0 : Ut * (s / ft), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / ft)) - Math.PI / 2) * Ut });
|
|
153
|
+
function Ke(s, t, e) {
|
|
154
|
+
const i = E(s[0]), o = E(s[1]), r = E(e), n = fe(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(r));
|
|
155
|
+
return [z(i + Math.atan2(Math.sin(r) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), z(a)];
|
|
153
156
|
}
|
|
154
|
-
function
|
|
157
|
+
function Rt(s) {
|
|
155
158
|
const { center: t, radiusKilometers: e, coordinatePrecision: i } = s, o = s.steps ? s.steps : 64, r = [];
|
|
156
159
|
for (let n = 0; n < o; n++) {
|
|
157
|
-
const a =
|
|
160
|
+
const a = Ke(t, e, -360 * n / o);
|
|
158
161
|
r.push([F(a[0], i), F(a[1], i)]);
|
|
159
162
|
}
|
|
160
163
|
return r.push(r[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [r] }, properties: {} };
|
|
161
164
|
}
|
|
162
|
-
function
|
|
165
|
+
function _t(s) {
|
|
163
166
|
let t;
|
|
164
167
|
if (s.geometry.type === "Polygon") t = s.geometry.coordinates;
|
|
165
168
|
else {
|
|
@@ -173,55 +176,51 @@ function Dt(s) {
|
|
|
173
176
|
return r < 0 || r > 1;
|
|
174
177
|
}
|
|
175
178
|
function o(r, n, a, l) {
|
|
176
|
-
const d = t[r][n],
|
|
177
|
-
if (
|
|
178
|
-
const P = v[0], S = v[1],
|
|
179
|
-
return
|
|
180
|
-
}(d,
|
|
179
|
+
const d = t[r][n], h = t[r][n + 1], c = t[a][l], u = t[a][l + 1], p = function(v, f, m, C) {
|
|
180
|
+
if (ht(v, m) || ht(v, C) || ht(f, m) || ht(C, m)) return null;
|
|
181
|
+
const P = v[0], S = v[1], M = f[0], w = f[1], D = m[0], G = m[1], L = C[0], B = C[1], R = (P - M) * (G - B) - (S - w) * (D - L);
|
|
182
|
+
return R === 0 ? null : [((P * w - S * M) * (D - L) - (P - M) * (D * B - G * L)) / R, ((P * w - S * M) * (G - B) - (S - w) * (D * B - G * L)) / R];
|
|
183
|
+
}(d, h, c, u);
|
|
181
184
|
if (p === null) return;
|
|
182
185
|
let g, y;
|
|
183
|
-
g =
|
|
186
|
+
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(), e.push(p));
|
|
184
187
|
}
|
|
185
188
|
}
|
|
186
|
-
function
|
|
189
|
+
function ht(s, t) {
|
|
187
190
|
return s[0] === t[0] && s[1] === t[1];
|
|
188
191
|
}
|
|
189
|
-
function
|
|
190
|
-
return s.length === 2 && typeof s[0] == "number" && typeof s[1] == "number" && s[0] !== 1 / 0 && s[1] !== 1 / 0 && (i = s[0]) >= -180 && i <= 180 && (e = s[1]) >= -90 && e <= 90 &&
|
|
192
|
+
function St(s, t) {
|
|
193
|
+
return s.length === 2 && typeof s[0] == "number" && typeof s[1] == "number" && s[0] !== 1 / 0 && s[1] !== 1 / 0 && (i = s[0]) >= -180 && i <= 180 && (e = s[1]) >= -90 && e <= 90 && Xt(s[0]) <= t && Xt(s[1]) <= t;
|
|
191
194
|
var e, i;
|
|
192
195
|
}
|
|
193
|
-
function
|
|
196
|
+
function Xt(s) {
|
|
194
197
|
let t = 1, e = 0;
|
|
195
198
|
for (; Math.round(s * t) / t !== s; ) t *= 10, e++;
|
|
196
199
|
return e;
|
|
197
200
|
}
|
|
198
|
-
const
|
|
199
|
-
function
|
|
200
|
-
return s.geometry.type !== "Polygon" ? { valid: !1, reason: "Feature is not a Polygon" } : s.geometry.coordinates.length !== 1 ? { valid: !1, reason:
|
|
201
|
+
const Ye = "Feature has holes", $e = "Feature has less than 4 coordinates", He = "Feature has invalid coordinates", qe = "Feature coordinates are not closed";
|
|
202
|
+
function xt(s, t) {
|
|
203
|
+
return s.geometry.type !== "Polygon" ? { valid: !1, reason: "Feature is not a Polygon" } : s.geometry.coordinates.length !== 1 ? { valid: !1, reason: Ye } : s.geometry.coordinates[0].length < 4 ? { valid: !1, reason: $e } : s.geometry.coordinates[0].every((o) => St(o, t)) ? (e = s.geometry.coordinates[0][0])[0] !== (i = s.geometry.coordinates[0][s.geometry.coordinates[0].length - 1])[0] || e[1] !== i[1] ? { valid: !1, reason: qe } : { valid: !0 } : { valid: !1, reason: He };
|
|
201
204
|
var e, i;
|
|
202
205
|
}
|
|
203
|
-
function
|
|
204
|
-
const e =
|
|
205
|
-
return e.valid ?
|
|
206
|
+
function lt(s, t) {
|
|
207
|
+
const e = xt(s, t);
|
|
208
|
+
return e.valid ? _t(s) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
|
|
206
209
|
}
|
|
207
|
-
|
|
210
|
+
const Je = { cancel: "Escape", finish: "Enter" }, Ze = { start: "crosshair" };
|
|
211
|
+
let me = class extends N {
|
|
208
212
|
constructor(t) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
else {
|
|
214
|
-
const o = { cancel: "Escape", finish: "Enter" };
|
|
215
|
-
this.keyEvents = t && t.keyEvents ? b({}, o, t.keyEvents) : o;
|
|
216
|
-
}
|
|
217
|
-
this.startingRadiusKilometers = (e = t == null ? void 0 : t.startingRadiusKilometers) != null ? e : 1e-5, this.validate = t == null ? void 0 : t.validation;
|
|
213
|
+
super(t, !0), this.mode = "circle", this.center = void 0, this.clickCount = 0, this.currentCircleId = void 0, this.keyEvents = Je, this.cursors = Ze, this.startingRadiusKilometers = 1e-5, this.cursorMovedAfterInitialCursorDown = !1, this.updateOptions(t);
|
|
214
|
+
}
|
|
215
|
+
updateOptions(t) {
|
|
216
|
+
super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents)), t != null && t.startingRadiusKilometers && (this.startingRadiusKilometers = t.startingRadiusKilometers);
|
|
218
217
|
}
|
|
219
218
|
close() {
|
|
220
219
|
if (this.currentCircleId === void 0) return;
|
|
221
220
|
const t = this.currentCircleId;
|
|
222
221
|
if (this.validate && t) {
|
|
223
222
|
const e = this.store.getGeometryCopy(t);
|
|
224
|
-
if (!this.validate({ type: "Feature", id: t, geometry: e, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
223
|
+
if (!this.validate({ type: "Feature", id: t, geometry: e, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: I.Finish }).valid) return;
|
|
225
224
|
}
|
|
226
225
|
this.cursorMovedAfterInitialCursorDown = !1, this.center = void 0, this.currentCircleId = void 0, this.clickCount = 0, this.state === "drawing" && this.setStarted(), this.onFinish(t, { mode: this.mode, action: "draw" });
|
|
227
226
|
}
|
|
@@ -234,7 +233,7 @@ class ge extends N {
|
|
|
234
233
|
onClick(t) {
|
|
235
234
|
if (this.clickCount === 0) {
|
|
236
235
|
this.center = [t.lng, t.lat];
|
|
237
|
-
const e =
|
|
236
|
+
const e = Rt({ center: this.center, radiusKilometers: this.startingRadiusKilometers, coordinatePrecision: this.coordinatePrecision }), [i] = this.store.create([{ geometry: e.geometry, properties: { mode: this.mode, radiusKilometers: this.startingRadiusKilometers } }]);
|
|
238
237
|
this.currentCircleId = i, this.clickCount++, this.cursorMovedAfterInitialCursorDown = !1, this.setDrawing();
|
|
239
238
|
} else this.clickCount === 1 && this.center && this.currentCircleId !== void 0 && this.cursorMovedAfterInitialCursorDown && this.updateCircle(t), this.close();
|
|
240
239
|
}
|
|
@@ -265,58 +264,69 @@ class ge extends N {
|
|
|
265
264
|
return t.type === "Feature" && t.geometry.type === "Polygon" && t.properties.mode === this.mode && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
|
|
266
265
|
}
|
|
267
266
|
validateFeature(t) {
|
|
268
|
-
return this.validateModeFeature(t, (e) =>
|
|
267
|
+
return this.validateModeFeature(t, (e) => lt(e, this.coordinatePrecision));
|
|
269
268
|
}
|
|
270
269
|
updateCircle(t) {
|
|
271
270
|
if (this.clickCount === 1 && this.center && this.currentCircleId) {
|
|
272
|
-
const e =
|
|
271
|
+
const e = A(this.center, [t.lng, t.lat]);
|
|
273
272
|
let i;
|
|
274
273
|
if (this.projection === "web-mercator") {
|
|
275
274
|
const o = function(r, n) {
|
|
276
|
-
const a = 1e3 *
|
|
275
|
+
const a = 1e3 * A(r, n);
|
|
277
276
|
if (a === 0) return 1;
|
|
278
|
-
const { x: l, y: d } = x(r[0], r[1]), { x:
|
|
279
|
-
return Math.sqrt(Math.pow(
|
|
277
|
+
const { x: l, y: d } = x(r[0], r[1]), { x: h, y: c } = x(n[0], n[1]);
|
|
278
|
+
return Math.sqrt(Math.pow(h - l, 2) + Math.pow(c - d, 2)) / a;
|
|
280
279
|
}(this.center, [t.lng, t.lat]);
|
|
281
280
|
i = function(r) {
|
|
282
|
-
const { center: n, radiusKilometers: a, coordinatePrecision: l } = r, d = r.steps ? r.steps : 64,
|
|
281
|
+
const { center: n, radiusKilometers: a, coordinatePrecision: l } = r, d = r.steps ? r.steps : 64, h = 1e3 * a, [c, u] = n, { x: p, y: g } = x(c, u), y = [];
|
|
283
282
|
for (let v = 0; v < d; v++) {
|
|
284
|
-
const f = 360 * v / d * Math.PI / 180, m =
|
|
285
|
-
y.push([F(
|
|
283
|
+
const f = 360 * v / d * Math.PI / 180, m = h * Math.cos(f), C = h * Math.sin(f), [P, S] = [p + m, g + C], { lng: M, lat: w } = W(P, S);
|
|
284
|
+
y.push([F(M, l), F(w, l)]);
|
|
286
285
|
}
|
|
287
286
|
return y.push(y[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [y] }, properties: {} };
|
|
288
287
|
}({ center: this.center, radiusKilometers: e * o, coordinatePrecision: this.coordinatePrecision });
|
|
289
288
|
} else {
|
|
290
289
|
if (this.projection !== "globe") throw new Error("Invalid projection");
|
|
291
|
-
i =
|
|
290
|
+
i = Rt({ center: this.center, radiusKilometers: e, coordinatePrecision: this.coordinatePrecision });
|
|
292
291
|
}
|
|
293
|
-
if (this.validate && !this.validate({ type: "Feature", id: this.currentCircleId, geometry: i.geometry, properties: { radiusKilometers: e } }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
292
|
+
if (this.validate && !this.validate({ type: "Feature", id: this.currentCircleId, geometry: i.geometry, properties: { radiusKilometers: e } }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: I.Provisional }).valid) return;
|
|
294
293
|
this.store.updateGeometry([{ id: this.currentCircleId, geometry: i.geometry }]), this.store.updateProperty([{ id: this.currentCircleId, property: "radiusKilometers", value: e }]);
|
|
295
294
|
}
|
|
296
295
|
}
|
|
297
|
-
}
|
|
296
|
+
};
|
|
298
297
|
const O = (s, t) => {
|
|
299
298
|
const { x: e, y: i } = s, { x: o, y: r } = t, n = o - e, a = r - i;
|
|
300
299
|
return Math.sqrt(a * a + n * n);
|
|
301
300
|
};
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
const i = { cancel: "Escape", finish: "Enter" };
|
|
310
|
-
this.keyEvents = t && t.keyEvents ? b({}, i, t.keyEvents) : i;
|
|
301
|
+
function dt(s) {
|
|
302
|
+
if (!function(e) {
|
|
303
|
+
const i = e.coordinates[0];
|
|
304
|
+
let o = 0;
|
|
305
|
+
for (let r = 0; r < i.length - 1; r++) {
|
|
306
|
+
const [n, a] = i[r], [l, d] = i[r + 1];
|
|
307
|
+
o += (l - n) * (d + a);
|
|
311
308
|
}
|
|
312
|
-
|
|
309
|
+
return o < 0;
|
|
310
|
+
}(s)) return { type: "Polygon", coordinates: [s.coordinates[0].reverse()] };
|
|
311
|
+
}
|
|
312
|
+
const Qe = { cancel: "Escape", finish: "Enter" }, ti = { start: "crosshair", close: "pointer" };
|
|
313
|
+
let ve = class extends N {
|
|
314
|
+
constructor(t) {
|
|
315
|
+
super(t, !0), this.mode = "freehand", this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.minDistance = 20, this.keyEvents = Qe, this.cursors = ti, this.preventPointsNearClose = !0, this.autoClose = !1, this.autoCloseTimeout = 500, this.hasLeftStartingPoint = !1, this.preventNewFeature = !1, this.updateOptions(t);
|
|
316
|
+
}
|
|
317
|
+
updateOptions(t) {
|
|
318
|
+
super.updateOptions(t), t != null && t.minDistance && (this.minDistance = t.minDistance), (t == null ? void 0 : t.preventPointsNearClose) !== void 0 && (this.preventPointsNearClose = t.preventPointsNearClose), (t == null ? void 0 : t.autoClose) !== void 0 && (this.autoClose = t.autoClose), t != null && t.autoCloseTimeout && (this.autoCloseTimeout = t.autoCloseTimeout), (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents)), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors));
|
|
313
319
|
}
|
|
314
320
|
close() {
|
|
315
321
|
if (this.currentId === void 0) return;
|
|
322
|
+
if (this.currentId) {
|
|
323
|
+
const e = dt(this.store.getGeometryCopy(this.currentId));
|
|
324
|
+
e && this.store.updateGeometry([{ id: this.currentId, geometry: e }]);
|
|
325
|
+
}
|
|
316
326
|
const t = this.currentId;
|
|
317
327
|
if (this.validate && t) {
|
|
318
328
|
const e = this.store.getGeometryCopy(t);
|
|
319
|
-
if (!this.validate({ type: "Feature", id: t, geometry: e, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
329
|
+
if (!this.validate({ type: "Feature", id: t, geometry: e, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: I.Finish }).valid) return;
|
|
320
330
|
}
|
|
321
331
|
this.closingPointId && this.store.delete([this.closingPointId]), this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.hasLeftStartingPoint = !1, this.state === "drawing" && this.setStarted(), this.onFinish(t, { mode: this.mode, action: "draw" });
|
|
322
332
|
}
|
|
@@ -328,8 +338,8 @@ let ye = class extends N {
|
|
|
328
338
|
}
|
|
329
339
|
onMouseMove(t) {
|
|
330
340
|
if (this.currentId === void 0 || this.startingClick === !1) return;
|
|
331
|
-
const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates[0].length - 2, [o, r] = e.coordinates[0][i], { x: n, y: a } = this.project(o, r), l = O({ x: n, y: a }, { x: t.containerX, y: t.containerY }), [d,
|
|
332
|
-
if (O({ x:
|
|
341
|
+
const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates[0].length - 2, [o, r] = e.coordinates[0][i], { x: n, y: a } = this.project(o, r), l = O({ x: n, y: a }, { x: t.containerX, y: t.containerY }), [d, h] = e.coordinates[0][0], { x: c, y: u } = this.project(d, h);
|
|
342
|
+
if (O({ x: c, y: u }, { x: t.containerX, y: t.containerY }) < this.pointerDistance) {
|
|
333
343
|
if (this.autoClose && this.hasLeftStartingPoint && (this.preventNewFeature = !0, setTimeout(() => {
|
|
334
344
|
this.preventNewFeature = !1;
|
|
335
345
|
}, this.autoCloseTimeout), this.close()), this.setCursor(this.cursors.close), this.preventPointsNearClose) return;
|
|
@@ -337,7 +347,7 @@ let ye = class extends N {
|
|
|
337
347
|
if (l < this.minDistance) return;
|
|
338
348
|
e.coordinates[0].pop();
|
|
339
349
|
const p = { type: "Polygon", coordinates: [[...e.coordinates[0], [t.lng, t.lat], e.coordinates[0][0]]] };
|
|
340
|
-
this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: p, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
350
|
+
this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: p, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: I.Provisional }).valid || this.store.updateGeometry([{ id: this.currentId, geometry: p }]);
|
|
341
351
|
}
|
|
342
352
|
onClick(t) {
|
|
343
353
|
if (!this.preventNewFeature) {
|
|
@@ -351,7 +361,7 @@ let ye = class extends N {
|
|
|
351
361
|
onKeyDown() {
|
|
352
362
|
}
|
|
353
363
|
onKeyUp(t) {
|
|
354
|
-
t.key === this.keyEvents.cancel ? this.cleanUp() : t.key === this.keyEvents.finish && this.close();
|
|
364
|
+
t.key === this.keyEvents.cancel ? this.cleanUp() : t.key === this.keyEvents.finish && this.startingClick === !0 && this.close();
|
|
355
365
|
}
|
|
356
366
|
onDragStart() {
|
|
357
367
|
}
|
|
@@ -372,27 +382,28 @@ let ye = class extends N {
|
|
|
372
382
|
return t.type === "Feature" && t.geometry.type === "Polygon" && t.properties.mode === this.mode ? (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10, e) : (t.type === "Feature" && t.geometry.type === "Point" && t.properties.mode === this.mode && (e.pointWidth = this.getNumericStylingValue(this.styles.closingPointWidth, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(this.styles.closingPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.closingPointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.closingPointOutlineWidth, 2, t), e.zIndex = 40), e);
|
|
373
383
|
}
|
|
374
384
|
validateFeature(t) {
|
|
375
|
-
return this.validateModeFeature(t, (e) =>
|
|
385
|
+
return this.validateModeFeature(t, (e) => xt(e, this.coordinatePrecision));
|
|
376
386
|
}
|
|
377
|
-
}
|
|
387
|
+
};
|
|
388
|
+
class j {
|
|
378
389
|
constructor({ store: t, mode: e, project: i, unproject: o, pointerDistance: r, coordinatePrecision: n, projection: a }) {
|
|
379
390
|
this.store = void 0, this.mode = void 0, this.project = void 0, this.unproject = void 0, this.pointerDistance = void 0, this.coordinatePrecision = void 0, this.projection = void 0, this.store = t, this.mode = e, this.project = i, this.unproject = o, this.pointerDistance = r, this.coordinatePrecision = n, this.projection = a;
|
|
380
391
|
}
|
|
381
|
-
}
|
|
382
|
-
function
|
|
392
|
+
}
|
|
393
|
+
function Ce({ unproject: s, point: t, pointerDistance: e }) {
|
|
383
394
|
const i = e / 2, { x: o, y: r } = t;
|
|
384
395
|
return { type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [[s(o - i, r - i), s(o + i, r - i), s(o + i, r + i), s(o - i, r + i), s(o - i, r - i)].map((n) => [n.lng, n.lat])] } };
|
|
385
396
|
}
|
|
386
|
-
let
|
|
397
|
+
let rt = class extends j {
|
|
387
398
|
constructor(t) {
|
|
388
399
|
super(t);
|
|
389
400
|
}
|
|
390
401
|
create(t) {
|
|
391
402
|
const { containerX: e, containerY: i } = t;
|
|
392
|
-
return
|
|
403
|
+
return Ce({ unproject: this.unproject, point: { x: e, y: i }, pointerDistance: this.pointerDistance });
|
|
393
404
|
}
|
|
394
405
|
};
|
|
395
|
-
class
|
|
406
|
+
class nt extends j {
|
|
396
407
|
constructor(t) {
|
|
397
408
|
super(t);
|
|
398
409
|
}
|
|
@@ -401,7 +412,7 @@ class St extends j {
|
|
|
401
412
|
return O({ x: i, y: o }, { x: t.containerX, y: t.containerY });
|
|
402
413
|
}
|
|
403
414
|
}
|
|
404
|
-
class
|
|
415
|
+
class Lt extends j {
|
|
405
416
|
constructor(t, e, i) {
|
|
406
417
|
super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => this.getSnappable(o, (r) => !!(r.properties && r.properties.mode === this.mode)).coordinate, this.getSnappableCoordinate = (o, r) => this.getSnappable(o, (n) => !!(n.properties && n.properties.mode === this.mode && n.id !== r)).coordinate, this.config = t, this.pixelDistance = e, this.clickBoundingBox = i;
|
|
407
418
|
}
|
|
@@ -415,84 +426,84 @@ class me extends j {
|
|
|
415
426
|
a = n.geometry.coordinates;
|
|
416
427
|
}
|
|
417
428
|
a.forEach((l, d) => {
|
|
418
|
-
const
|
|
419
|
-
|
|
429
|
+
const h = this.pixelDistance.measure(t, l);
|
|
430
|
+
h < r.minDist && h < this.pointerDistance && (r.coordinate = l, r.minDist = h, r.featureId = n.id, r.featureCoordinateIndex = d);
|
|
420
431
|
});
|
|
421
432
|
}), r;
|
|
422
433
|
}
|
|
423
434
|
}
|
|
424
|
-
function
|
|
425
|
-
const i = E(s[0]), o = E(s[1]), r = E(e), n =
|
|
426
|
-
return [
|
|
435
|
+
function Kt(s, t, e) {
|
|
436
|
+
const i = E(s[0]), o = E(s[1]), r = E(e), n = fe(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(r));
|
|
437
|
+
return [z(i + Math.atan2(Math.sin(r) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), z(a)];
|
|
427
438
|
}
|
|
428
|
-
function
|
|
439
|
+
function at({ x: s, y: t }, e, i) {
|
|
429
440
|
const o = E(i);
|
|
430
441
|
return { x: s + e * Math.cos(o), y: t + e * Math.sin(o) };
|
|
431
442
|
}
|
|
432
|
-
function
|
|
443
|
+
function Yt(s, t) {
|
|
433
444
|
const e = E(s[0]), i = E(t[0]), o = E(s[1]), r = E(t[1]), n = Math.sin(i - e) * Math.cos(r), a = Math.cos(o) * Math.sin(r) - Math.sin(o) * Math.cos(r) * Math.cos(i - e);
|
|
434
|
-
return
|
|
445
|
+
return z(Math.atan2(n, a));
|
|
435
446
|
}
|
|
436
|
-
function
|
|
447
|
+
function T({ x: s, y: t }, { x: e, y: i }) {
|
|
437
448
|
let o = Math.atan2(i - t, e - s);
|
|
438
449
|
return o *= 180 / Math.PI, o > 180 ? o -= 360 : o < -180 && (o += 360), o;
|
|
439
450
|
}
|
|
440
|
-
function
|
|
451
|
+
function Y(s) {
|
|
441
452
|
return (s + 360) % 360;
|
|
442
453
|
}
|
|
443
|
-
function
|
|
454
|
+
function ei(s, t, e) {
|
|
444
455
|
const i = [], o = s.length;
|
|
445
456
|
let r, n, a, l = 0;
|
|
446
|
-
for (let
|
|
457
|
+
for (let h = 0; h < s.length && !(t >= l && h === s.length - 1); h++) {
|
|
447
458
|
if (l > t && i.length === 0) {
|
|
448
|
-
if (r = t - l, !r) return i.push(s[
|
|
449
|
-
n =
|
|
459
|
+
if (r = t - l, !r) return i.push(s[h]), i;
|
|
460
|
+
n = Yt(s[h], s[h - 1]) - 180, a = Kt(s[h], r, n), i.push(a);
|
|
450
461
|
}
|
|
451
|
-
if (l >= e) return r = e - l, r ? (n =
|
|
452
|
-
if (l >= t && i.push(s[
|
|
453
|
-
l +=
|
|
462
|
+
if (l >= e) return r = e - l, r ? (n = Yt(s[h], s[h - 1]) - 180, a = Kt(s[h], r, n), i.push(a), i) : (i.push(s[h]), i);
|
|
463
|
+
if (l >= t && i.push(s[h]), h === s.length - 1) return i;
|
|
464
|
+
l += A(s[h], s[h + 1]);
|
|
454
465
|
}
|
|
455
466
|
if (l < t && s.length === o) throw new Error("Start position is beyond line");
|
|
456
467
|
const d = s[s.length - 1];
|
|
457
468
|
return [d, d];
|
|
458
469
|
}
|
|
459
|
-
function
|
|
470
|
+
function ct(s) {
|
|
460
471
|
return s * (Math.PI / 180);
|
|
461
472
|
}
|
|
462
|
-
function
|
|
473
|
+
function $t(s) {
|
|
463
474
|
return s * (180 / Math.PI);
|
|
464
475
|
}
|
|
465
|
-
class
|
|
476
|
+
class ii extends j {
|
|
466
477
|
constructor(t) {
|
|
467
478
|
super(t), this.config = void 0, this.config = t;
|
|
468
479
|
}
|
|
469
480
|
generateInsertionCoordinates(t, e, i) {
|
|
470
481
|
const o = [t, e];
|
|
471
482
|
let r = 0;
|
|
472
|
-
for (let d = 0; d < o.length - 1; d++) r +=
|
|
483
|
+
for (let d = 0; d < o.length - 1; d++) r += A(o[0], o[1]);
|
|
473
484
|
if (r <= i) return o;
|
|
474
485
|
let n = r / i - 1;
|
|
475
486
|
Number.isInteger(n) || (n = Math.floor(n) + 1);
|
|
476
487
|
const a = [];
|
|
477
488
|
for (let d = 0; d < n; d++) {
|
|
478
|
-
const
|
|
479
|
-
a.push(
|
|
489
|
+
const h = ei(o, i * d, i * (d + 1));
|
|
490
|
+
a.push(h);
|
|
480
491
|
}
|
|
481
492
|
const l = [];
|
|
482
493
|
for (let d = 0; d < a.length; d++) l.push(a[d][1]);
|
|
483
494
|
return this.limitCoordinates(l);
|
|
484
495
|
}
|
|
485
496
|
generateInsertionGeodesicCoordinates(t, e, i) {
|
|
486
|
-
const o =
|
|
487
|
-
const d = [],
|
|
497
|
+
const o = A(t, e), r = function(n, a, l) {
|
|
498
|
+
const d = [], h = ct(n[1]), c = ct(n[0]), u = ct(a[1]), p = ct(a[0]);
|
|
488
499
|
l += 1;
|
|
489
|
-
const g = 2 * Math.asin(Math.sqrt(Math.sin((u -
|
|
500
|
+
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
501
|
if (g === 0 || isNaN(g)) return d;
|
|
491
502
|
for (let y = 0; y <= l; y++) {
|
|
492
|
-
const v = y / l, f = Math.sin((1 - v) * g) / Math.sin(g), m = Math.sin(v * g) / Math.sin(g), C = f * Math.cos(
|
|
503
|
+
const v = y / l, f = Math.sin((1 - v) * g) / Math.sin(g), m = Math.sin(v * g) / Math.sin(g), C = f * Math.cos(h) * Math.cos(c) + m * Math.cos(u) * Math.cos(p), P = f * Math.cos(h) * Math.sin(c) + m * Math.cos(u) * Math.sin(p), S = f * Math.sin(h) + m * Math.sin(u);
|
|
493
504
|
if (isNaN(C) || isNaN(P) || isNaN(S)) continue;
|
|
494
|
-
const
|
|
495
|
-
isNaN(
|
|
505
|
+
const M = Math.atan2(S, Math.sqrt(C ** 2 + P ** 2)), w = Math.atan2(P, C);
|
|
506
|
+
isNaN(M) || isNaN(w) || d.push([$t(w), $t(M)]);
|
|
496
507
|
}
|
|
497
508
|
return d.slice(1, -1);
|
|
498
509
|
}(t, e, Math.floor(o / i));
|
|
@@ -505,24 +516,97 @@ class He extends j {
|
|
|
505
516
|
function Z(s, t) {
|
|
506
517
|
return s[0] === t[0] && s[1] === t[1];
|
|
507
518
|
}
|
|
508
|
-
function
|
|
509
|
-
return s.geometry.type !== "LineString" ? { valid: !1, reason: "Feature is not a LineString" } : s.geometry.coordinates.length < 2 ? { valid: !1, reason: "Feature has less than 2 coordinates" } : s.geometry.coordinates.every((e) =>
|
|
519
|
+
function Pe(s, t) {
|
|
520
|
+
return s.geometry.type !== "LineString" ? { valid: !1, reason: "Feature is not a LineString" } : s.geometry.coordinates.length < 2 ? { valid: !1, reason: "Feature has less than 2 coordinates" } : s.geometry.coordinates.every((e) => St(e, t)) ? { valid: !0 } : { valid: !1, reason: "Feature has invalid coordinates" };
|
|
521
|
+
}
|
|
522
|
+
function Ht(s) {
|
|
523
|
+
return Math.sqrt(Math.pow(s[0], 2) + Math.pow(s[1], 2) + Math.pow(s[2], 2));
|
|
524
|
+
}
|
|
525
|
+
function X(s, t) {
|
|
526
|
+
const e = function(i, o) {
|
|
527
|
+
const [r, n, a] = i, [l, d, h] = o;
|
|
528
|
+
return r * l + n * d + a * h;
|
|
529
|
+
}(s, t) / (Ht(s) * Ht(t));
|
|
530
|
+
return Math.acos(Math.min(Math.max(e, -1), 1));
|
|
531
|
+
}
|
|
532
|
+
function Mt(s) {
|
|
533
|
+
const t = E(s[1]), e = E(s[0]);
|
|
534
|
+
return [Math.cos(t) * Math.cos(e), Math.cos(t) * Math.sin(e), Math.sin(t)];
|
|
535
|
+
}
|
|
536
|
+
function K(s) {
|
|
537
|
+
const [t, e, i] = s, o = z(Math.asin(i));
|
|
538
|
+
return [z(Math.atan2(e, t)), o];
|
|
539
|
+
}
|
|
540
|
+
function oi(s, t, e) {
|
|
541
|
+
const i = Mt(s), o = Mt(t), r = Mt(e), [n, a, l] = r, [d, h, c] = function(B, R) {
|
|
542
|
+
const [jt, Bt, Nt] = B, [Gt, Tt, At] = R;
|
|
543
|
+
return [Bt * At - Nt * Tt, Nt * Gt - jt * At, jt * Tt - Bt * Gt];
|
|
544
|
+
}(i, o), u = h * l - c * a, p = c * n - d * l, g = d * a - h * n, y = g * h - p * c, v = u * c - g * d, f = p * d - u * h, m = 1 / Math.sqrt(Math.pow(y, 2) + Math.pow(v, 2) + Math.pow(f, 2)), C = [y * m, v * m, f * m], P = [-1 * y * m, -1 * v * m, -1 * f * m], S = X(i, o), M = X(i, C), w = X(o, C), D = X(i, P), G = X(o, P);
|
|
545
|
+
let L;
|
|
546
|
+
return L = M < D && M < G || w < D && w < G ? C : P, X(i, L) > S || X(o, L) > S ? A(K(L), K(i)) <= A(K(L), K(o)) ? [K(i), !0, !1] : [K(o), !1, !0] : [K(L), !1, !1];
|
|
547
|
+
}
|
|
548
|
+
function si(s, t, e) {
|
|
549
|
+
const i = t.x - s.x, o = t.y - s.y, r = Math.max(0, Math.min(1, ((e.x - s.x) * i + (e.y - s.y) * o) / (i * i + o * o)));
|
|
550
|
+
return { x: s.x + r * i, y: s.y + r * o };
|
|
551
|
+
}
|
|
552
|
+
class Se extends j {
|
|
553
|
+
constructor(t, e, i) {
|
|
554
|
+
super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => this.getSnappable(o, (r) => !!(r.properties && r.properties.mode === this.mode)).coordinate, this.getSnappableCoordinate = (o, r) => this.getSnappable(o, (n) => !!(n.properties && n.properties.mode === this.mode && n.id !== r)).coordinate, this.config = t, this.pixelDistance = e, this.clickBoundingBox = i;
|
|
555
|
+
}
|
|
556
|
+
getSnappable(t, e) {
|
|
557
|
+
const i = this.clickBoundingBox.create(t), o = this.store.search(i, e), r = { featureId: void 0, featureCoordinateIndex: void 0, coordinate: void 0, minDistance: 1 / 0 };
|
|
558
|
+
return o.forEach((n) => {
|
|
559
|
+
let a;
|
|
560
|
+
if (n.geometry.type === "Polygon") a = n.geometry.coordinates[0];
|
|
561
|
+
else {
|
|
562
|
+
if (n.geometry.type !== "LineString") return;
|
|
563
|
+
a = n.geometry.coordinates;
|
|
564
|
+
}
|
|
565
|
+
const l = [];
|
|
566
|
+
for (let u = 0; u < a.length - 1; u++) l.push([a[u], a[u + 1]]);
|
|
567
|
+
let d;
|
|
568
|
+
const h = [t.lng, t.lat];
|
|
569
|
+
if (this.config.projection === "web-mercator" ? d = function(u, p) {
|
|
570
|
+
let g = [1 / 0, 1 / 0], y = 1 / 0, v = 0;
|
|
571
|
+
for (let f of p) {
|
|
572
|
+
const m = f[0], C = f[1];
|
|
573
|
+
let P, S = 1 / 0;
|
|
574
|
+
const M = x(m[0], m[1]), w = x(C[0], C[1]), D = x(u[0], u[1]);
|
|
575
|
+
if (m[0] === u[0] && m[1] === u[1]) P = m;
|
|
576
|
+
else if (C[0] === u[0] && C[1] === u[1]) P = C;
|
|
577
|
+
else {
|
|
578
|
+
const { x: G, y: L } = si(M, w, D), { lng: B, lat: R } = W(G, L);
|
|
579
|
+
P = [B, R];
|
|
580
|
+
}
|
|
581
|
+
P && (S = O(D, x(P[0], P[1])), S < y && (g = P, y = S, v = p.indexOf(f)));
|
|
582
|
+
}
|
|
583
|
+
return y === 1 / 0 ? void 0 : { coordinate: g, lineIndex: v, distance: y };
|
|
584
|
+
}(h, l) : this.config.projection === "globe" && (d = function(u, p) {
|
|
585
|
+
let g = [1 / 0, 1 / 0], y = 1 / 0, v = 0;
|
|
586
|
+
for (let f of p) {
|
|
587
|
+
const m = f[0], C = f[1];
|
|
588
|
+
let P, S = 1 / 0;
|
|
589
|
+
m[0] === u[0] && m[1] === u[1] ? P = m : C[0] === u[0] && C[1] === u[1] ? P = C : [P] = oi(m, C, u), P && (S = A(u, P), S < y && (g = P, y = S, v = p.indexOf(f)));
|
|
590
|
+
}
|
|
591
|
+
return y === 1 / 0 ? void 0 : { coordinate: g, distance: y, lineIndex: v };
|
|
592
|
+
}(h, l)), !d) return;
|
|
593
|
+
const c = this.pixelDistance.measure(t, d.coordinate);
|
|
594
|
+
c < r.minDistance && c < this.pointerDistance && (r.featureId = n.id, r.coordinate = d.coordinate, r.featureCoordinateIndex = d.lineIndex, r.minDistance = c);
|
|
595
|
+
}), r;
|
|
596
|
+
}
|
|
510
597
|
}
|
|
511
|
-
|
|
598
|
+
const ri = { cancel: "Escape", finish: "Enter" }, ni = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
599
|
+
class xe extends N {
|
|
512
600
|
constructor(t) {
|
|
513
|
-
super(t), this.mode = "linestring", this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.keyEvents =
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
const i = { cancel: "Escape", finish: "Enter" };
|
|
518
|
-
this.keyEvents = t && t.keyEvents ? b({}, i, t.keyEvents) : i;
|
|
519
|
-
}
|
|
520
|
-
this.validate = t == null ? void 0 : t.validation, this.insertCoordinates = t == null ? void 0 : t.insertCoordinates;
|
|
601
|
+
super(t, !0), this.mode = "linestring", this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.keyEvents = ri, this.snapping = void 0, this.cursors = ni, this.mouseMove = !1, this.insertCoordinates = void 0, this.lastCommitedCoordinates = void 0, this.snappedPointId = void 0, this.editable = !1, this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedSnapType = void 0, this.editedInsertIndex = void 0, this.editedPointId = void 0, this.coordinateSnapping = void 0, this.insertPoint = void 0, this.lineSnapping = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.updateOptions(t);
|
|
602
|
+
}
|
|
603
|
+
updateOptions(t) {
|
|
604
|
+
super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), t != null && t.snapping && (this.snapping = t.snapping), (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents)), t != null && t.insertCoordinates && (this.insertCoordinates = t.insertCoordinates), t && t.editable && (this.editable = t.editable);
|
|
521
605
|
}
|
|
522
606
|
close() {
|
|
523
607
|
if (this.currentId === void 0) return;
|
|
524
608
|
const t = this.store.getGeometryCopy(this.currentId);
|
|
525
|
-
t.coordinates.pop(), this.updateGeometries([...t.coordinates], void 0,
|
|
609
|
+
t.coordinates.pop(), this.updateGeometries([...t.coordinates], void 0, I.Commit);
|
|
526
610
|
const e = this.currentId;
|
|
527
611
|
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(e, { mode: this.mode, action: "draw" });
|
|
528
612
|
}
|
|
@@ -536,7 +620,7 @@ class Ce extends N {
|
|
|
536
620
|
generateInsertCoordinates(t, e) {
|
|
537
621
|
if (!this.insertCoordinates || !this.lastCommitedCoordinates) throw new Error("Not able to insert coordinates");
|
|
538
622
|
if (this.insertCoordinates.strategy !== "amount") throw new Error("Strategy does not exist");
|
|
539
|
-
const i =
|
|
623
|
+
const i = A(t, e) / (this.insertCoordinates.value + 1);
|
|
540
624
|
let o = [];
|
|
541
625
|
return this.projection === "globe" ? o = this.insertPoint.generateInsertionGeodesicCoordinates(t, e, i) : this.projection === "web-mercator" && (o = this.insertPoint.generateInsertionCoordinates(t, e, i)), o;
|
|
542
626
|
}
|
|
@@ -549,7 +633,7 @@ class Ce extends N {
|
|
|
549
633
|
const e = this.store.getGeometryCopy(this.currentId).coordinates, [i] = this.store.create([{ geometry: { type: "Point", coordinates: [...t] }, properties: { mode: this.mode } }]);
|
|
550
634
|
this.closingPointId = i, this.setCursor(this.cursors.close);
|
|
551
635
|
const o = [...e, t];
|
|
552
|
-
this.updateGeometries(o, void 0,
|
|
636
|
+
this.updateGeometries(o, void 0, I.Commit), this.currentCoordinate++;
|
|
553
637
|
}
|
|
554
638
|
updateToLine(t, e) {
|
|
555
639
|
if (!this.currentId) return;
|
|
@@ -557,10 +641,10 @@ class Ce extends N {
|
|
|
557
641
|
if (O({ x: n, y: a }, { x: e.x, y: e.y }) < this.pointerDistance) return void this.close();
|
|
558
642
|
this.setCursor(this.cursors.close);
|
|
559
643
|
const l = [...i, t];
|
|
560
|
-
this.updateGeometries(l, i[i.length - 1],
|
|
644
|
+
this.updateGeometries(l, i[i.length - 1], I.Commit), this.currentCoordinate++;
|
|
561
645
|
}
|
|
562
646
|
registerBehaviors(t) {
|
|
563
|
-
this.coordinateSnapping = new
|
|
647
|
+
this.coordinateSnapping = new Lt(t, new nt(t), new rt(t)), this.insertPoint = new ii(t), this.clickBoundingBox = new rt(t), this.pixelDistance = new nt(t), this.lineSnapping = new Se(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new Lt(t, this.pixelDistance, this.clickBoundingBox);
|
|
564
648
|
}
|
|
565
649
|
start() {
|
|
566
650
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -574,7 +658,7 @@ class Ce extends N {
|
|
|
574
658
|
if (e) {
|
|
575
659
|
if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: e } }]);
|
|
576
660
|
else {
|
|
577
|
-
const [n] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [
|
|
661
|
+
const [n] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [Dt]: !0 } }]);
|
|
578
662
|
this.snappedPointId = n;
|
|
579
663
|
}
|
|
580
664
|
t.lng = e[0], t.lat = e[1];
|
|
@@ -594,23 +678,58 @@ class Ce extends N {
|
|
|
594
678
|
r = [...this.lastCommitedCoordinates.slice(0, -1), ...l, i];
|
|
595
679
|
}
|
|
596
680
|
}
|
|
597
|
-
this.updateGeometries(r, void 0,
|
|
681
|
+
this.updateGeometries(r, void 0, I.Provisional);
|
|
598
682
|
}
|
|
599
|
-
|
|
600
|
-
|
|
683
|
+
onRightClick(t) {
|
|
684
|
+
if (!this.editable || this.state !== "started") return;
|
|
685
|
+
const { featureId: e, featureCoordinateIndex: i } = this.coordinateSnapping.getSnappable(t, (n) => n.geometry.type === "LineString");
|
|
686
|
+
if (!e || i === void 0) return;
|
|
687
|
+
const o = this.store.getGeometryCopy(e);
|
|
688
|
+
let r;
|
|
689
|
+
if (o.type === "LineString" && (r = o.coordinates, !(r.length <= 2))) {
|
|
690
|
+
if (r.splice(i, 1), this.validate && !this.validate({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: I.Commit }).valid) return;
|
|
691
|
+
this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: e, geometry: o }]);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
onLeftClick(t) {
|
|
695
|
+
this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0);
|
|
601
696
|
const e = this.snapCoordinate(t) || [t.lng, t.lat];
|
|
602
697
|
this.currentCoordinate === 0 ? this.createLine(e) : this.currentCoordinate === 1 && this.currentId ? this.firstUpdateToLine(e) : this.currentId && this.updateToLine(e, { x: t.containerX, y: t.containerY });
|
|
603
698
|
}
|
|
699
|
+
onClick(t) {
|
|
700
|
+
this.currentCoordinate > 0 && !this.mouseMove && this.onMouseMove(t), this.mouseMove = !1, t.button === "right" ? this.onRightClick(t) : t.button === "left" && this.onLeftClick(t);
|
|
701
|
+
}
|
|
604
702
|
onKeyDown() {
|
|
605
703
|
}
|
|
606
704
|
onKeyUp(t) {
|
|
607
705
|
t.key === this.keyEvents.cancel && this.cleanUp(), t.key === this.keyEvents.finish && this.close();
|
|
608
706
|
}
|
|
609
|
-
onDragStart() {
|
|
707
|
+
onDragStart(t, e) {
|
|
708
|
+
if (!this.editable) return;
|
|
709
|
+
let i;
|
|
710
|
+
if (this.state === "started") {
|
|
711
|
+
const o = this.lineSnapping.getSnappable(t);
|
|
712
|
+
o.coordinate && (this.editedSnapType = "line", this.editedFeatureCoordinateIndex = o.featureCoordinateIndex, this.editedFeatureId = o.featureId, i = o.coordinate);
|
|
713
|
+
const r = this.coordinateSnapping.getSnappable(t);
|
|
714
|
+
r.coordinate && (this.editedSnapType = "coordinate", this.editedFeatureCoordinateIndex = r.featureCoordinateIndex, this.editedFeatureId = r.featureId, i = r.coordinate);
|
|
715
|
+
}
|
|
716
|
+
if (this.editedFeatureId && i) {
|
|
717
|
+
if (!this.editedPointId) {
|
|
718
|
+
const [o] = this.store.create([{ geometry: { type: "Point", coordinates: i }, properties: { mode: this.mode, [V]: !0 } }]);
|
|
719
|
+
this.editedPointId = o;
|
|
720
|
+
}
|
|
721
|
+
this.setCursor(this.cursors.dragStart), e(!1);
|
|
722
|
+
}
|
|
610
723
|
}
|
|
611
|
-
onDrag() {
|
|
724
|
+
onDrag(t, e) {
|
|
725
|
+
if (this.editedFeatureId === void 0 || this.editedFeatureCoordinateIndex === void 0) return;
|
|
726
|
+
const i = this.store.getGeometryCopy(this.editedFeatureId);
|
|
727
|
+
this.editedSnapType === "coordinate" || this.editedSnapType === "line" && this.editedInsertIndex !== void 0 ? i.coordinates[this.editedFeatureCoordinateIndex] = [t.lng, t.lat] : this.editedSnapType === "line" && this.editedInsertIndex === void 0 && (this.editedInsertIndex = this.editedFeatureCoordinateIndex + 1, i.coordinates.splice(this.editedInsertIndex, 0, [t.lng, t.lat]), this.editedFeatureCoordinateIndex++);
|
|
728
|
+
const o = { type: "LineString", coordinates: i.coordinates };
|
|
729
|
+
this.validate && !this.validate({ type: "Feature", geometry: o, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: I.Provisional }).valid || (this.snapping && this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: this.editedFeatureId, geometry: o }]), this.editedPointId && this.store.updateGeometry([{ id: this.editedPointId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: V, value: !0 }]), e(!0));
|
|
612
730
|
}
|
|
613
|
-
onDragEnd() {
|
|
731
|
+
onDragEnd(t, e) {
|
|
732
|
+
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: V, value: !1 }]), this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedInsertIndex = void 0, this.editedSnapType = void 0, e(!0));
|
|
614
733
|
}
|
|
615
734
|
cleanUp() {
|
|
616
735
|
const t = this.currentId, e = this.closingPointId, i = this.snappedPointId;
|
|
@@ -630,7 +749,7 @@ class Ce extends N {
|
|
|
630
749
|
return e;
|
|
631
750
|
}
|
|
632
751
|
validateFeature(t) {
|
|
633
|
-
return this.validateModeFeature(t, (e) =>
|
|
752
|
+
return this.validateModeFeature(t, (e) => Pe(e, this.coordinatePrecision));
|
|
634
753
|
}
|
|
635
754
|
snapCoordinate(t) {
|
|
636
755
|
var e, i;
|
|
@@ -638,15 +757,17 @@ class Ce extends N {
|
|
|
638
757
|
return (e = this.snapping) != null && e.toCoordinate && (o = this.currentId ? this.coordinateSnapping.getSnappableCoordinate(t, this.currentId) : this.coordinateSnapping.getSnappableCoordinateFirstClick(t)), (i = this.snapping) != null && i.toCustom && (o = this.snapping.toCustom(t)), o;
|
|
639
758
|
}
|
|
640
759
|
}
|
|
641
|
-
const
|
|
642
|
-
function
|
|
643
|
-
return s.geometry.type !== "Point" ? { valid: !1, reason:
|
|
760
|
+
const ai = "Feature is not a Point", li = "Feature has invalid coordinates";
|
|
761
|
+
function Ie(s, t) {
|
|
762
|
+
return s.geometry.type !== "Point" ? { valid: !1, reason: ai } : St(s.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: li };
|
|
644
763
|
}
|
|
645
|
-
|
|
764
|
+
const di = { create: "crosshair", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
765
|
+
class be extends N {
|
|
646
766
|
constructor(t) {
|
|
647
|
-
super(t), this.mode = "point", this.cursors =
|
|
648
|
-
|
|
649
|
-
|
|
767
|
+
super(t, !0), this.mode = "point", this.cursors = di, this.editable = !1, this.editedFeatureId = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.updateOptions(t);
|
|
768
|
+
}
|
|
769
|
+
updateOptions(t) {
|
|
770
|
+
super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), t != null && t.editable && (this.editable = t.editable);
|
|
650
771
|
}
|
|
651
772
|
start() {
|
|
652
773
|
this.setStarted(), this.setCursor(this.cursors.create);
|
|
@@ -656,10 +777,7 @@ class Se extends N {
|
|
|
656
777
|
}
|
|
657
778
|
onClick(t) {
|
|
658
779
|
if (!this.store) throw new Error("Mode must be registered first");
|
|
659
|
-
|
|
660
|
-
if (this.validate && !this.validate({ type: "Feature", geometry: e, properties: i }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Finish }).valid) return;
|
|
661
|
-
const [o] = this.store.create([{ geometry: e, properties: i }]);
|
|
662
|
-
this.onFinish(o, { mode: this.mode, action: "draw" });
|
|
780
|
+
t.button === "right" ? this.onRightClick(t) : t.button === "left" && this.onLeftClick(t);
|
|
663
781
|
}
|
|
664
782
|
onMouseMove() {
|
|
665
783
|
}
|
|
@@ -672,26 +790,19 @@ class Se extends N {
|
|
|
672
790
|
}
|
|
673
791
|
onDragStart(t, e) {
|
|
674
792
|
if (this.editable) {
|
|
675
|
-
const i = this.
|
|
676
|
-
|
|
677
|
-
for (let a = 0; a < o.length; a++) {
|
|
678
|
-
const l = o[a];
|
|
679
|
-
if (l.geometry.type !== "Point" || l.properties.mode !== this.mode) continue;
|
|
680
|
-
const d = this.pixelDistance.measure(t, l.geometry.coordinates);
|
|
681
|
-
d > n || d > this.pointerDistance || (n = d, r = l);
|
|
682
|
-
}
|
|
683
|
-
r && (this.editedFeatureId = r.id);
|
|
793
|
+
const i = this.getNearestPointFeature(t);
|
|
794
|
+
this.editedFeatureId = i == null ? void 0 : i.id;
|
|
684
795
|
}
|
|
685
796
|
this.editedFeatureId && (this.setCursor(this.cursors.dragStart), e(!1));
|
|
686
797
|
}
|
|
687
798
|
onDrag(t, e) {
|
|
688
|
-
this.editedFeatureId !== void 0 && (this.validate && !this.validate({ type: "Feature", geometry: { type: "Point", coordinates: [t.lng, t.lat] }, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
799
|
+
this.editedFeatureId !== void 0 && (this.validate && !this.validate({ type: "Feature", geometry: { type: "Point", coordinates: [t.lng, t.lat] }, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: I.Finish }).valid || (this.store.updateGeometry([{ id: this.editedFeatureId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: V, value: !0 }]), e(!0)));
|
|
689
800
|
}
|
|
690
801
|
onDragEnd(t, e) {
|
|
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:
|
|
802
|
+
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: V, value: !1 }]), this.editedFeatureId = void 0, e(!0));
|
|
692
803
|
}
|
|
693
804
|
registerBehaviors(t) {
|
|
694
|
-
this.pixelDistance = new
|
|
805
|
+
this.pixelDistance = new nt(t), this.clickBoundingBox = new rt(t);
|
|
695
806
|
}
|
|
696
807
|
styleFeature(t) {
|
|
697
808
|
const e = b({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
@@ -702,10 +813,32 @@ class Se extends N {
|
|
|
702
813
|
return e;
|
|
703
814
|
}
|
|
704
815
|
validateFeature(t) {
|
|
705
|
-
return this.validateModeFeature(t, (e) =>
|
|
816
|
+
return this.validateModeFeature(t, (e) => Ie(e, this.coordinatePrecision));
|
|
817
|
+
}
|
|
818
|
+
onLeftClick(t) {
|
|
819
|
+
const e = { type: "Point", coordinates: [t.lng, t.lat] }, i = { mode: this.mode };
|
|
820
|
+
if (this.validate && !this.validate({ type: "Feature", geometry: e, properties: i }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: I.Finish }).valid) return;
|
|
821
|
+
const [o] = this.store.create([{ geometry: e, properties: i }]);
|
|
822
|
+
this.onFinish(o, { mode: this.mode, action: "draw" });
|
|
823
|
+
}
|
|
824
|
+
onRightClick(t) {
|
|
825
|
+
if (!this.editable) return;
|
|
826
|
+
const e = this.getNearestPointFeature(t);
|
|
827
|
+
e && this.store.delete([e.id]);
|
|
828
|
+
}
|
|
829
|
+
getNearestPointFeature(t) {
|
|
830
|
+
const e = this.clickBoundingBox.create(t), i = this.store.search(e);
|
|
831
|
+
let o, r = 1 / 0;
|
|
832
|
+
for (let n = 0; n < i.length; n++) {
|
|
833
|
+
const a = i[n];
|
|
834
|
+
if (a.geometry.type !== "Point" || a.properties.mode !== this.mode) continue;
|
|
835
|
+
const l = this.pixelDistance.measure(t, a.geometry.coordinates);
|
|
836
|
+
l > r || l > this.pointerDistance || (r = l, o = a);
|
|
837
|
+
}
|
|
838
|
+
return o;
|
|
706
839
|
}
|
|
707
840
|
}
|
|
708
|
-
class
|
|
841
|
+
class hi extends j {
|
|
709
842
|
constructor(t, e) {
|
|
710
843
|
super(t), this.config = void 0, this.pixelDistance = void 0, this._startEndPoints = [], this.config = t, this.pixelDistance = e;
|
|
711
844
|
}
|
|
@@ -731,102 +864,27 @@ class Ze extends j {
|
|
|
731
864
|
return { isClosing: o < this.pointerDistance, isPreviousClosing: r < this.pointerDistance };
|
|
732
865
|
}
|
|
733
866
|
}
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
}
|
|
737
|
-
function R(s, t) {
|
|
738
|
-
const e = function(i, o) {
|
|
739
|
-
const [r, n, a] = i, [l, d, c] = o;
|
|
740
|
-
return r * l + n * d + a * c;
|
|
741
|
-
}(s, t) / (Yt(s) * Yt(t));
|
|
742
|
-
return Math.acos(Math.min(Math.max(e, -1), 1));
|
|
743
|
-
}
|
|
744
|
-
function It(s) {
|
|
745
|
-
const t = E(s[1]), e = E(s[0]);
|
|
746
|
-
return [Math.cos(t) * Math.cos(e), Math.cos(t) * Math.sin(e), Math.sin(t)];
|
|
747
|
-
}
|
|
748
|
-
function X(s) {
|
|
749
|
-
const [t, e, i] = s, o = U(Math.asin(i));
|
|
750
|
-
return [U(Math.atan2(e, t)), o];
|
|
751
|
-
}
|
|
752
|
-
function Qe(s, t, e) {
|
|
753
|
-
const i = It(s), o = It(t), r = It(e), [n, a, l] = r, [d, c, h] = function(B, z) {
|
|
754
|
-
const [kt, Wt, jt] = B, [Bt, Nt, At] = z;
|
|
755
|
-
return [Wt * At - jt * Nt, jt * Bt - kt * At, kt * Nt - Wt * Bt];
|
|
756
|
-
}(i, o), u = c * l - h * a, p = h * n - d * l, g = d * a - c * n, y = g * c - p * h, v = u * h - g * d, f = p * d - u * c, m = 1 / Math.sqrt(Math.pow(y, 2) + Math.pow(v, 2) + Math.pow(f, 2)), C = [y * m, v * m, f * m], P = [-1 * y * m, -1 * v * m, -1 * f * m], S = R(i, o), I = R(i, C), w = R(o, C), D = R(i, P), A = R(o, P);
|
|
757
|
-
let L;
|
|
758
|
-
return L = I < D && I < A || w < D && w < A ? C : P, R(i, L) > S || R(o, L) > S ? T(X(L), X(i)) <= T(X(L), X(o)) ? [X(i), !0, !1] : [X(o), !1, !0] : [X(L), !1, !1];
|
|
759
|
-
}
|
|
760
|
-
function ti(s, t, e) {
|
|
761
|
-
const i = t.x - s.x, o = t.y - s.y, r = Math.max(0, Math.min(1, ((e.x - s.x) * i + (e.y - s.y) * o) / (i * i + o * o)));
|
|
762
|
-
return { x: s.x + r * i, y: s.y + r * o };
|
|
763
|
-
}
|
|
764
|
-
class ei extends j {
|
|
765
|
-
constructor(t, e, i) {
|
|
766
|
-
super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => this.getSnappable(o, (r) => !!(r.properties && r.properties.mode === this.mode)).coordinate, this.getSnappableCoordinate = (o, r) => this.getSnappable(o, (n) => !!(n.properties && n.properties.mode === this.mode && n.id !== r)).coordinate, this.config = t, this.pixelDistance = e, this.clickBoundingBox = i;
|
|
767
|
-
}
|
|
768
|
-
getSnappable(t, e) {
|
|
769
|
-
const i = this.clickBoundingBox.create(t), o = this.store.search(i, e), r = { featureId: void 0, featureCoordinateIndex: void 0, coordinate: void 0, minDistance: 1 / 0 };
|
|
770
|
-
return o.forEach((n) => {
|
|
771
|
-
let a;
|
|
772
|
-
if (n.geometry.type === "Polygon") a = n.geometry.coordinates[0];
|
|
773
|
-
else {
|
|
774
|
-
if (n.geometry.type !== "LineString") return;
|
|
775
|
-
a = n.geometry.coordinates;
|
|
776
|
-
}
|
|
777
|
-
const l = [];
|
|
778
|
-
for (let u = 0; u < a.length - 1; u++) l.push([a[u], a[u + 1]]);
|
|
779
|
-
let d;
|
|
780
|
-
const c = [t.lng, t.lat];
|
|
781
|
-
if (this.config.projection === "web-mercator" ? d = function(u, p) {
|
|
782
|
-
let g = [1 / 0, 1 / 0], y = 1 / 0, v = 0;
|
|
783
|
-
for (let f of p) {
|
|
784
|
-
const m = f[0], C = f[1];
|
|
785
|
-
let P, S = 1 / 0;
|
|
786
|
-
const I = x(m[0], m[1]), w = x(C[0], C[1]), D = x(u[0], u[1]);
|
|
787
|
-
if (m[0] === u[0] && m[1] === u[1]) P = m;
|
|
788
|
-
else if (C[0] === u[0] && C[1] === u[1]) P = C;
|
|
789
|
-
else {
|
|
790
|
-
const { x: A, y: L } = ti(I, w, D), { lng: B, lat: z } = W(A, L);
|
|
791
|
-
P = [B, z];
|
|
792
|
-
}
|
|
793
|
-
P && (S = O(D, x(P[0], P[1])), S < y && (g = P, y = S, v = p.indexOf(f)));
|
|
794
|
-
}
|
|
795
|
-
return y === 1 / 0 ? void 0 : { coordinate: g, lineIndex: v, distance: y };
|
|
796
|
-
}(c, l) : this.config.projection === "globe" && (d = function(u, p) {
|
|
797
|
-
let g = [1 / 0, 1 / 0], y = 1 / 0, v = 0;
|
|
798
|
-
for (let f of p) {
|
|
799
|
-
const m = f[0], C = f[1];
|
|
800
|
-
let P, S = 1 / 0;
|
|
801
|
-
m[0] === u[0] && m[1] === u[1] ? P = m : C[0] === u[0] && C[1] === u[1] ? P = C : [P] = Qe(m, C, u), P && (S = T(u, P), S < y && (g = P, y = S, v = p.indexOf(f)));
|
|
802
|
-
}
|
|
803
|
-
return y === 1 / 0 ? void 0 : { coordinate: g, distance: y, lineIndex: v };
|
|
804
|
-
}(c, l)), !d) return;
|
|
805
|
-
const h = this.pixelDistance.measure(t, d.coordinate);
|
|
806
|
-
h < r.minDistance && h < this.pointerDistance && (r.featureId = n.id, r.coordinate = d.coordinate, r.featureCoordinateIndex = d.lineIndex, r.minDistance = h);
|
|
807
|
-
}), r;
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
class xe extends N {
|
|
867
|
+
const ci = { cancel: "Escape", finish: "Enter" }, ui = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
868
|
+
class Me extends N {
|
|
811
869
|
constructor(t) {
|
|
812
|
-
super(t), this.mode = "polygon", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents =
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
const i = { cancel: "Escape", finish: "Enter" };
|
|
817
|
-
this.keyEvents = t && t.keyEvents ? b({}, i, t.keyEvents) : i;
|
|
818
|
-
}
|
|
819
|
-
this.editable = !(!t || !t.editable) && t.editable;
|
|
870
|
+
super(t, !0), this.mode = "polygon", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = ci, this.cursors = ui, this.mouseMove = !1, this.snapping = void 0, this.snappedPointId = void 0, this.editable = !1, 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.updateOptions(t);
|
|
871
|
+
}
|
|
872
|
+
updateOptions(t) {
|
|
873
|
+
super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents)), t != null && t.snapping && (this.snapping = t.snapping), t != null && t.editable && (this.editable = t.editable);
|
|
820
874
|
}
|
|
821
875
|
close() {
|
|
822
876
|
if (this.currentId === void 0) return;
|
|
823
877
|
const t = this.store.getGeometryCopy(this.currentId).coordinates[0];
|
|
824
|
-
if (t.length < 5 || !this.updatePolygonGeometry([...t.slice(0, -2), t[0]],
|
|
878
|
+
if (t.length < 5 || !this.updatePolygonGeometry([...t.slice(0, -2), t[0]], I.Finish)) return;
|
|
825
879
|
const e = this.currentId;
|
|
880
|
+
if (this.currentId) {
|
|
881
|
+
const i = dt(this.store.getGeometryCopy(this.currentId));
|
|
882
|
+
i && this.store.updateGeometry([{ id: this.currentId, geometry: i }]);
|
|
883
|
+
}
|
|
826
884
|
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(e, { mode: this.mode, action: "draw" });
|
|
827
885
|
}
|
|
828
886
|
registerBehaviors(t) {
|
|
829
|
-
this.clickBoundingBox = new
|
|
887
|
+
this.clickBoundingBox = new rt(t), this.pixelDistance = new nt(t), this.lineSnapping = new Se(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new Lt(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new hi(t, this.pixelDistance);
|
|
830
888
|
}
|
|
831
889
|
start() {
|
|
832
890
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -840,7 +898,7 @@ class xe extends N {
|
|
|
840
898
|
if (e) {
|
|
841
899
|
if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: e } }]);
|
|
842
900
|
else {
|
|
843
|
-
const [r] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [
|
|
901
|
+
const [r] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [Dt]: !0 } }]);
|
|
844
902
|
this.snappedPointId = r;
|
|
845
903
|
}
|
|
846
904
|
t.lng = e[0], t.lat = e[1];
|
|
@@ -856,7 +914,7 @@ class xe extends N {
|
|
|
856
914
|
const { isClosing: r, isPreviousClosing: n } = this.closingPoints.isClosingPoint(t);
|
|
857
915
|
n || r ? (this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.setCursor(this.cursors.close), o = [...i.slice(0, -2), i[0], i[0]]) : o = [...i.slice(0, -2), [t.lng, t.lat], i[0]];
|
|
858
916
|
}
|
|
859
|
-
this.updatePolygonGeometry(o,
|
|
917
|
+
this.updatePolygonGeometry(o, I.Provisional);
|
|
860
918
|
}
|
|
861
919
|
updatePolygonGeometry(t, e) {
|
|
862
920
|
if (!this.currentId) return !1;
|
|
@@ -876,8 +934,16 @@ class xe extends N {
|
|
|
876
934
|
}
|
|
877
935
|
return (o = this.snapping) != null && o.toCustom && (r = this.snapping.toCustom(t)), r;
|
|
878
936
|
}
|
|
879
|
-
|
|
880
|
-
if (
|
|
937
|
+
onRightClick(t) {
|
|
938
|
+
if (!this.editable) return;
|
|
939
|
+
const { featureId: e, featureCoordinateIndex: i } = this.coordinateSnapping.getSnappable(t, (n) => n.geometry.type === "Polygon");
|
|
940
|
+
if (!e || i === void 0) return;
|
|
941
|
+
const o = this.store.getGeometryCopy(e);
|
|
942
|
+
let r;
|
|
943
|
+
o.type === "Polygon" && (r = o.coordinates[0], r.length <= 4 || (o.type !== "Polygon" || i !== 0 && i !== r.length - 1 ? r.splice(i, 1) : (r.shift(), r.pop(), r.push([r[0][0], r[0][1]])), (!this.validate || this.validate({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: I.Commit }).valid) && (this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: e, geometry: o }]))));
|
|
944
|
+
}
|
|
945
|
+
onLeftClick(t) {
|
|
946
|
+
if (this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.currentCoordinate === 0) {
|
|
881
947
|
const e = this.snapCoordinate(t);
|
|
882
948
|
e && (t.lng = e[0], t.lat = e[1]);
|
|
883
949
|
const [i] = this.store.create([{ geometry: { type: "Polygon", coordinates: [[[t.lng, t.lat], [t.lng, t.lat], [t.lng, t.lat], [t.lng, t.lat]]] }, properties: { mode: this.mode } }]);
|
|
@@ -886,13 +952,13 @@ class xe extends N {
|
|
|
886
952
|
const e = this.snapCoordinate(t);
|
|
887
953
|
e && (t.lng = e[0], t.lat = e[1]);
|
|
888
954
|
const i = this.store.getGeometryCopy(this.currentId);
|
|
889
|
-
if (Z([t.lng, t.lat], i.coordinates[0][0]) || !this.updatePolygonGeometry([i.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], i.coordinates[0][0]],
|
|
955
|
+
if (Z([t.lng, t.lat], i.coordinates[0][0]) || !this.updatePolygonGeometry([i.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], i.coordinates[0][0]], I.Commit)) return;
|
|
890
956
|
this.currentCoordinate++;
|
|
891
957
|
} else if (this.currentCoordinate === 2 && this.currentId) {
|
|
892
958
|
const e = this.snapCoordinate(t);
|
|
893
959
|
e && (t.lng = e[0], t.lat = e[1]);
|
|
894
960
|
const i = this.store.getGeometryCopy(this.currentId).coordinates[0];
|
|
895
|
-
if (Z([t.lng, t.lat], i[1]) || !this.updatePolygonGeometry([i[0], i[1], [t.lng, t.lat], [t.lng, t.lat], i[0]],
|
|
961
|
+
if (Z([t.lng, t.lat], i[1]) || !this.updatePolygonGeometry([i[0], i[1], [t.lng, t.lat], [t.lng, t.lat], i[0]], I.Commit)) return;
|
|
896
962
|
this.currentCoordinate === 2 && this.closingPoints.create(i, "polygon"), this.currentCoordinate++;
|
|
897
963
|
} else if (this.currentId) {
|
|
898
964
|
const e = this.store.getGeometryCopy(this.currentId).coordinates[0], { isClosing: i, isPreviousClosing: o } = this.closingPoints.isClosingPoint(t);
|
|
@@ -903,11 +969,14 @@ class xe extends N {
|
|
|
903
969
|
const n = /* @__PURE__ */ function(a = [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]) {
|
|
904
970
|
return { type: "Feature", geometry: { type: "Polygon", coordinates: a }, properties: {} };
|
|
905
971
|
}([[...e.slice(0, -1), [t.lng, t.lat], e[0]]]);
|
|
906
|
-
if (!this.updatePolygonGeometry(n.geometry.coordinates[0],
|
|
972
|
+
if (!this.updatePolygonGeometry(n.geometry.coordinates[0], I.Commit)) return;
|
|
907
973
|
this.currentCoordinate++, this.closingPoints.ids.length && this.closingPoints.update(n.geometry.coordinates[0]);
|
|
908
974
|
}
|
|
909
975
|
}
|
|
910
976
|
}
|
|
977
|
+
onClick(t) {
|
|
978
|
+
this.currentCoordinate > 0 && !this.mouseMove && this.onMouseMove(t), this.mouseMove = !1, t.button !== "right" ? t.button !== "left" || this.onLeftClick(t) : this.onRightClick(t);
|
|
979
|
+
}
|
|
911
980
|
onKeyUp(t) {
|
|
912
981
|
t.key === this.keyEvents.cancel ? this.cleanUp() : t.key === this.keyEvents.finish && this.close();
|
|
913
982
|
}
|
|
@@ -924,7 +993,7 @@ class xe extends N {
|
|
|
924
993
|
}
|
|
925
994
|
if (this.editedFeatureId && i) {
|
|
926
995
|
if (!this.editedPointId) {
|
|
927
|
-
const [o] = this.store.create([{ geometry: { type: "Point", coordinates: i }, properties: { mode: this.mode, [
|
|
996
|
+
const [o] = this.store.create([{ geometry: { type: "Point", coordinates: i }, properties: { mode: this.mode, [V]: !0 } }]);
|
|
928
997
|
this.editedPointId = o;
|
|
929
998
|
}
|
|
930
999
|
this.setCursor(this.cursors.dragStart), e(!1);
|
|
@@ -935,10 +1004,10 @@ class xe extends N {
|
|
|
935
1004
|
const i = this.store.getGeometryCopy(this.editedFeatureId), o = i.coordinates[0];
|
|
936
1005
|
this.editedSnapType === "coordinate" || this.editedSnapType === "line" && this.editedInsertIndex !== void 0 ? this.editedFeatureCoordinateIndex === 0 || this.editedFeatureCoordinateIndex === i.coordinates[0].length - 1 ? (o[0] = [t.lng, t.lat], o[o.length - 1] = [t.lng, t.lat]) : o[this.editedFeatureCoordinateIndex] = [t.lng, t.lat] : this.editedSnapType === "line" && this.editedInsertIndex === void 0 && (this.editedInsertIndex = this.editedFeatureCoordinateIndex + 1, i.coordinates[0].splice(this.editedInsertIndex, 0, [t.lng, t.lat]), this.editedFeatureCoordinateIndex++);
|
|
937
1006
|
const r = { type: "Polygon", coordinates: i.coordinates };
|
|
938
|
-
this.validate && !this.validate({ type: "Feature", geometry: r, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
1007
|
+
this.validate && !this.validate({ type: "Feature", geometry: r, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: I.Provisional }).valid || (this.snapping && this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: this.editedFeatureId, geometry: r }]), this.editedPointId && this.store.updateGeometry([{ id: this.editedPointId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: V, value: !0 }]), e(!0));
|
|
939
1008
|
}
|
|
940
1009
|
onDragEnd(t, e) {
|
|
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:
|
|
1010
|
+
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: V, value: !1 }]), this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedInsertIndex = void 0, this.editedSnapType = void 0, e(!0));
|
|
942
1011
|
}
|
|
943
1012
|
cleanUp() {
|
|
944
1013
|
const t = this.currentId, e = this.snappedPointId, i = this.editedPointId;
|
|
@@ -953,7 +1022,7 @@ class xe extends N {
|
|
|
953
1022
|
if (t.properties.mode === this.mode) {
|
|
954
1023
|
if (t.geometry.type === "Polygon") return e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10, e;
|
|
955
1024
|
if (t.geometry.type === "Point") {
|
|
956
|
-
const i = t.properties[
|
|
1025
|
+
const i = t.properties[V], o = i ? "editedPoint" : t.properties[st] ? "closingPoint" : t.properties[Dt] ? "snappingPoint" : void 0;
|
|
957
1026
|
if (!o) return e;
|
|
958
1027
|
const r = { 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
1028
|
return e.pointWidth = this.getNumericStylingValue(r[o].width, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(r[o].color, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(r[o].outlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(r[o].outlineWidth, 2, t), e.zIndex = i ? 35 : 30, e;
|
|
@@ -962,18 +1031,16 @@ class xe extends N {
|
|
|
962
1031
|
return e;
|
|
963
1032
|
}
|
|
964
1033
|
validateFeature(t) {
|
|
965
|
-
return this.validateModeFeature(t, (e) =>
|
|
1034
|
+
return this.validateModeFeature(t, (e) => xt(e, this.coordinatePrecision));
|
|
966
1035
|
}
|
|
967
1036
|
}
|
|
968
|
-
|
|
1037
|
+
const pi = { cancel: "Escape", finish: "Enter" }, gi = { start: "crosshair" };
|
|
1038
|
+
class we extends N {
|
|
969
1039
|
constructor(t) {
|
|
970
|
-
super(t), this.mode = "rectangle", this.center = void 0, this.clickCount = 0, this.currentRectangleId = void 0, this.keyEvents =
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
const i = { cancel: "Escape", finish: "Enter" };
|
|
975
|
-
this.keyEvents = t && t.keyEvents ? b({}, i, t.keyEvents) : i;
|
|
976
|
-
}
|
|
1040
|
+
super(t, !0), this.mode = "rectangle", this.center = void 0, this.clickCount = 0, this.currentRectangleId = void 0, this.keyEvents = pi, this.cursors = gi, this.updateOptions(t);
|
|
1041
|
+
}
|
|
1042
|
+
updateOptions(t) {
|
|
1043
|
+
super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents));
|
|
977
1044
|
}
|
|
978
1045
|
updateRectangle(t, e) {
|
|
979
1046
|
if (this.clickCount === 1 && this.center && this.currentRectangleId) {
|
|
@@ -984,6 +1051,10 @@ class be extends N {
|
|
|
984
1051
|
}
|
|
985
1052
|
close() {
|
|
986
1053
|
const t = this.currentRectangleId;
|
|
1054
|
+
if (t) {
|
|
1055
|
+
const e = dt(this.store.getGeometryCopy(t));
|
|
1056
|
+
e && this.store.updateGeometry([{ id: t, geometry: e }]);
|
|
1057
|
+
}
|
|
987
1058
|
this.center = void 0, this.currentRectangleId = void 0, this.clickCount = 0, this.state === "drawing" && this.setStarted(), t !== void 0 && this.onFinish(t, { mode: this.mode, action: "draw" });
|
|
988
1059
|
}
|
|
989
1060
|
start() {
|
|
@@ -997,10 +1068,10 @@ class be extends N {
|
|
|
997
1068
|
this.center = [t.lng, t.lat];
|
|
998
1069
|
const [e] = this.store.create([{ geometry: { type: "Polygon", coordinates: [[[t.lng, t.lat], [t.lng, t.lat], [t.lng, t.lat], [t.lng, t.lat]]] }, properties: { mode: this.mode } }]);
|
|
999
1070
|
this.currentRectangleId = e, this.clickCount++, this.setDrawing();
|
|
1000
|
-
} else this.updateRectangle(t,
|
|
1071
|
+
} else this.updateRectangle(t, I.Finish), this.close();
|
|
1001
1072
|
}
|
|
1002
1073
|
onMouseMove(t) {
|
|
1003
|
-
this.updateRectangle(t,
|
|
1074
|
+
this.updateRectangle(t, I.Provisional);
|
|
1004
1075
|
}
|
|
1005
1076
|
onKeyDown() {
|
|
1006
1077
|
}
|
|
@@ -1022,12 +1093,16 @@ class be extends N {
|
|
|
1022
1093
|
return t.type === "Feature" && t.geometry.type === "Polygon" && t.properties.mode === this.mode && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
|
|
1023
1094
|
}
|
|
1024
1095
|
validateFeature(t) {
|
|
1025
|
-
return this.validateModeFeature(t, (e) =>
|
|
1096
|
+
return this.validateModeFeature(t, (e) => lt(e, this.coordinatePrecision));
|
|
1026
1097
|
}
|
|
1027
1098
|
}
|
|
1028
1099
|
class et extends N {
|
|
1029
1100
|
constructor(t) {
|
|
1030
|
-
|
|
1101
|
+
if (!t.modeName) throw new Error("Mode name is required for TerraDrawRenderMode");
|
|
1102
|
+
super(t, !0), this.type = $.Render, this.mode = "render", this.updateOptions(t);
|
|
1103
|
+
}
|
|
1104
|
+
updateOptions(t) {
|
|
1105
|
+
super.updateOptions(t), t != null && t.modeName && (this.mode = t.modeName);
|
|
1031
1106
|
}
|
|
1032
1107
|
registerBehaviors(t) {
|
|
1033
1108
|
this.mode = t.mode;
|
|
@@ -1060,50 +1135,50 @@ class et extends N {
|
|
|
1060
1135
|
validateFeature(t) {
|
|
1061
1136
|
const e = super.validateFeature(t);
|
|
1062
1137
|
if (e.valid) {
|
|
1063
|
-
const i = t, o =
|
|
1138
|
+
const i = t, o = Ie(i, this.coordinatePrecision).valid || xt(i, this.coordinatePrecision).valid || Pe(i, this.coordinatePrecision).valid;
|
|
1064
1139
|
return o ? { valid: !0 } : { valid: o, reason: "Feature is not a valid Point, Polygon or LineString feature" };
|
|
1065
1140
|
}
|
|
1066
1141
|
return e;
|
|
1067
1142
|
}
|
|
1068
1143
|
}
|
|
1069
|
-
function
|
|
1144
|
+
function mt(s, t) {
|
|
1070
1145
|
const e = s, i = t, o = E(e[1]), r = E(i[1]);
|
|
1071
1146
|
let n = E(i[0] - e[0]);
|
|
1072
1147
|
n > Math.PI && (n -= 2 * Math.PI), n < -Math.PI && (n += 2 * Math.PI);
|
|
1073
|
-
const a = Math.log(Math.tan(r / 2 + Math.PI / 4) / Math.tan(o / 2 + Math.PI / 4)), l = (
|
|
1148
|
+
const a = Math.log(Math.tan(r / 2 + Math.PI / 4) / Math.tan(o / 2 + Math.PI / 4)), l = (z(Math.atan2(n, a)) + 360) % 360;
|
|
1074
1149
|
return l > 180 ? -(360 - l) : l;
|
|
1075
1150
|
}
|
|
1076
|
-
function
|
|
1151
|
+
function kt(s, t, e) {
|
|
1077
1152
|
let i = t;
|
|
1078
1153
|
t < 0 && (i = -Math.abs(i));
|
|
1079
|
-
const o = i /
|
|
1154
|
+
const o = i / ye, r = s[0] * Math.PI / 180, n = E(s[1]), a = E(e), l = o * Math.cos(a);
|
|
1080
1155
|
let d = n + l;
|
|
1081
1156
|
Math.abs(d) > Math.PI / 2 && (d = d > 0 ? Math.PI - d : -Math.PI - d);
|
|
1082
|
-
const
|
|
1157
|
+
const h = Math.log(Math.tan(d / 2 + Math.PI / 4) / Math.tan(n / 2 + Math.PI / 4)), c = Math.abs(h) > 1e-11 ? l / h : Math.cos(n), u = [(180 * (r + o * Math.sin(a) / c) / Math.PI + 540) % 360 - 180, 180 * d / Math.PI];
|
|
1083
1158
|
return u[0] += u[0] - s[0] > 180 ? -360 : s[0] - u[0] > 180 ? 360 : 0, u;
|
|
1084
1159
|
}
|
|
1085
|
-
function
|
|
1160
|
+
function Fe(s, t, e, i, o) {
|
|
1086
1161
|
const r = i(s[0], s[1]), n = i(t[0], t[1]), { lng: a, lat: l } = o((r.x + n.x) / 2, (r.y + n.y) / 2);
|
|
1087
1162
|
return [F(a, e), F(l, e)];
|
|
1088
1163
|
}
|
|
1089
|
-
function
|
|
1090
|
-
const i =
|
|
1164
|
+
function yi(s, t, e) {
|
|
1165
|
+
const i = kt(s, 1e3 * A(s, t) / 2, mt(s, t));
|
|
1091
1166
|
return [F(i[0], e), F(i[1], e)];
|
|
1092
1167
|
}
|
|
1093
|
-
function
|
|
1168
|
+
function qt({ featureCoords: s, precision: t, unproject: e, project: i, projection: o }) {
|
|
1094
1169
|
const r = [];
|
|
1095
1170
|
for (let n = 0; n < s.length - 1; n++) {
|
|
1096
1171
|
let a;
|
|
1097
|
-
if (o === "web-mercator") a =
|
|
1172
|
+
if (o === "web-mercator") a = Fe(s[n], s[n + 1], t, i, e);
|
|
1098
1173
|
else {
|
|
1099
1174
|
if (o !== "globe") throw new Error("Invalid projection");
|
|
1100
|
-
a =
|
|
1175
|
+
a = yi(s[n], s[n + 1], t);
|
|
1101
1176
|
}
|
|
1102
1177
|
r.push(a);
|
|
1103
1178
|
}
|
|
1104
1179
|
return r;
|
|
1105
1180
|
}
|
|
1106
|
-
class
|
|
1181
|
+
class fi extends j {
|
|
1107
1182
|
constructor(t, e) {
|
|
1108
1183
|
super(t), this.config = void 0, this.selectionPointBehavior = void 0, this._midPoints = [], this.config = t, this.selectionPointBehavior = e;
|
|
1109
1184
|
}
|
|
@@ -1119,17 +1194,17 @@ class oi extends j {
|
|
|
1119
1194
|
create(t, e, i) {
|
|
1120
1195
|
if (!this.store.has(e)) throw new Error("Store does not have feature with this id");
|
|
1121
1196
|
this._midPoints = this.store.create(function(o, r, n, a, l, d) {
|
|
1122
|
-
return
|
|
1123
|
-
}(t, (o) => ({ mode: this.mode, [
|
|
1197
|
+
return qt({ featureCoords: o, precision: n, project: a, unproject: l, projection: d }).map((h, c) => ({ geometry: { type: "Point", coordinates: h }, properties: r(c) }));
|
|
1198
|
+
}(t, (o) => ({ mode: this.mode, [U.MID_POINT]: !0, midPointSegment: o, midPointFeatureId: e }), i, this.config.project, this.config.unproject, this.projection));
|
|
1124
1199
|
}
|
|
1125
1200
|
delete() {
|
|
1126
1201
|
this._midPoints.length && (this.store.delete(this._midPoints), this._midPoints = []);
|
|
1127
1202
|
}
|
|
1128
1203
|
getUpdated(t) {
|
|
1129
|
-
if (this._midPoints.length !== 0) return
|
|
1204
|
+
if (this._midPoints.length !== 0) return qt({ featureCoords: t, precision: this.coordinatePrecision, project: this.config.project, unproject: this.config.unproject, projection: this.config.projection }).map((e, i) => ({ id: this._midPoints[i], geometry: { type: "Point", coordinates: e } }));
|
|
1130
1205
|
}
|
|
1131
1206
|
}
|
|
1132
|
-
class
|
|
1207
|
+
class mi extends j {
|
|
1133
1208
|
constructor(t) {
|
|
1134
1209
|
super(t), this._selectionPoints = [];
|
|
1135
1210
|
}
|
|
@@ -1155,16 +1230,16 @@ class si extends j {
|
|
|
1155
1230
|
if (this._selectionPoints[t] !== void 0) return { id: this._selectionPoints[t], geometry: { type: "Point", coordinates: e } };
|
|
1156
1231
|
}
|
|
1157
1232
|
}
|
|
1158
|
-
function
|
|
1233
|
+
function Ee(s, t) {
|
|
1159
1234
|
let e = !1;
|
|
1160
1235
|
for (let n = 0, a = t.length; n < a; n++) {
|
|
1161
1236
|
const l = t[n];
|
|
1162
|
-
for (let d = 0,
|
|
1237
|
+
for (let d = 0, h = l.length, c = h - 1; d < h; c = d++) (o = l[d])[1] > (i = s)[1] != (r = l[c])[1] > i[1] && i[0] < (r[0] - o[0]) * (i[1] - o[1]) / (r[1] - o[1]) + o[0] && (e = !e);
|
|
1163
1238
|
}
|
|
1164
1239
|
var i, o, r;
|
|
1165
1240
|
return e;
|
|
1166
1241
|
}
|
|
1167
|
-
const
|
|
1242
|
+
const Oe = (s, t, e) => {
|
|
1168
1243
|
const i = (r) => r * r, o = (r, n) => i(r.x - n.x) + i(r.y - n.y);
|
|
1169
1244
|
return Math.sqrt(((r, n, a) => {
|
|
1170
1245
|
const l = o(n, a);
|
|
@@ -1173,34 +1248,34 @@ const we = (s, t, e) => {
|
|
|
1173
1248
|
return d = Math.max(0, Math.min(1, d)), o(r, { x: n.x + d * (a.x - n.x), y: n.y + d * (a.y - n.y) });
|
|
1174
1249
|
})(s, t, e));
|
|
1175
1250
|
};
|
|
1176
|
-
class
|
|
1251
|
+
class vi extends j {
|
|
1177
1252
|
constructor(t, e, i) {
|
|
1178
1253
|
super(t), this.config = void 0, this.createClickBoundingBox = void 0, this.pixelDistance = void 0, this.config = t, this.createClickBoundingBox = e, this.pixelDistance = i;
|
|
1179
1254
|
}
|
|
1180
1255
|
find(t, e) {
|
|
1181
1256
|
let i, o, r, n, a = 1 / 0, l = 1 / 0, d = 1 / 0;
|
|
1182
|
-
const
|
|
1183
|
-
for (let u = 0; u <
|
|
1184
|
-
const p =
|
|
1257
|
+
const h = this.createClickBoundingBox.create(t), c = this.store.search(h);
|
|
1258
|
+
for (let u = 0; u < c.length; u++) {
|
|
1259
|
+
const p = c[u], g = p.geometry;
|
|
1185
1260
|
if (g.type === "Point") {
|
|
1186
|
-
if (p.properties.selectionPoint || !e && p.properties[
|
|
1261
|
+
if (p.properties.selectionPoint || !e && p.properties[U.MID_POINT]) continue;
|
|
1187
1262
|
const y = this.pixelDistance.measure(t, g.coordinates);
|
|
1188
|
-
p.properties[
|
|
1263
|
+
p.properties[U.MID_POINT] && y < this.pointerDistance && y < d ? (d = y, r = p) : !p.properties[U.MID_POINT] && y < this.pointerDistance && y < a && (a = y, i = p);
|
|
1189
1264
|
} else if (g.type === "LineString") {
|
|
1190
1265
|
if (i) continue;
|
|
1191
1266
|
for (let y = 0; y < g.coordinates.length - 1; y++) {
|
|
1192
|
-
const v = g.coordinates[y], f = g.coordinates[y + 1], m =
|
|
1267
|
+
const v = g.coordinates[y], f = g.coordinates[y + 1], m = Oe({ x: t.containerX, y: t.containerY }, this.project(v[0], v[1]), this.project(f[0], f[1]));
|
|
1193
1268
|
m < this.pointerDistance && m < l && (l = m, o = p);
|
|
1194
1269
|
}
|
|
1195
1270
|
} else if (g.type === "Polygon") {
|
|
1196
1271
|
if (i || o) continue;
|
|
1197
|
-
|
|
1272
|
+
Ee([t.lng, t.lat], g.coordinates) && (n = p);
|
|
1198
1273
|
}
|
|
1199
1274
|
}
|
|
1200
1275
|
return { clickedFeature: i || o || n, clickedMidPoint: r };
|
|
1201
1276
|
}
|
|
1202
1277
|
}
|
|
1203
|
-
class
|
|
1278
|
+
class Ci extends j {
|
|
1204
1279
|
constructor(t, e, i, o) {
|
|
1205
1280
|
super(t), this.config = void 0, this.featuresAtCursorEvent = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.draggedFeatureId = null, this.dragPosition = void 0, this.config = t, this.featuresAtCursorEvent = e, this.selectionPoints = i, this.midPoints = o;
|
|
1206
1281
|
}
|
|
@@ -1224,26 +1299,26 @@ class ni extends j {
|
|
|
1224
1299
|
let r, n;
|
|
1225
1300
|
if (i.type === "Polygon" ? (r = i.coordinates[0], n = r.length - 1) : (r = i.coordinates, n = r.length), !this.dragPosition) return !1;
|
|
1226
1301
|
for (let d = 0; d < n; d++) {
|
|
1227
|
-
const
|
|
1228
|
-
let
|
|
1302
|
+
const h = r[d];
|
|
1303
|
+
let c, u;
|
|
1229
1304
|
if (this.config.projection === "web-mercator") {
|
|
1230
|
-
const p = x(this.dragPosition[0], this.dragPosition[1]), g = x(o[0], o[1]), y = x(
|
|
1231
|
-
|
|
1305
|
+
const p = x(this.dragPosition[0], this.dragPosition[1]), g = x(o[0], o[1]), y = x(h[0], h[1]), v = { x: p.x - g.x, y: p.y - g.y }, f = y.x - v.x, m = y.y - v.y, { lng: C, lat: P } = W(f, m);
|
|
1306
|
+
c = C, u = P;
|
|
1232
1307
|
} else {
|
|
1233
1308
|
const p = [this.dragPosition[0] - o[0], this.dragPosition[1] - o[1]];
|
|
1234
|
-
|
|
1309
|
+
c = h[0] - p[0], u = h[1] - p[1];
|
|
1235
1310
|
}
|
|
1236
|
-
if (
|
|
1237
|
-
r[d] = [
|
|
1311
|
+
if (c = F(c, this.config.coordinatePrecision), u = F(u, this.config.coordinatePrecision), c > 180 || c < -180 || u > 90 || u < -90) return !1;
|
|
1312
|
+
r[d] = [c, u];
|
|
1238
1313
|
}
|
|
1239
1314
|
i.type === "Polygon" && (r[r.length - 1] = [r[0][0], r[0][1]]);
|
|
1240
1315
|
const a = this.selectionPoints.getUpdated(r) || [], l = this.midPoints.getUpdated(r) || [];
|
|
1241
|
-
if (e && !e({ type: "Feature", id: this.draggedFeatureId, geometry: i, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType:
|
|
1316
|
+
if (e && !e({ type: "Feature", id: this.draggedFeatureId, geometry: i, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: I.Provisional }).valid) return !1;
|
|
1242
1317
|
this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: i }, ...a, ...l]), this.dragPosition = [t.lng, t.lat];
|
|
1243
1318
|
} else i.type === "Point" && (this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: { type: "Point", coordinates: o } }]), this.dragPosition = [t.lng, t.lat]);
|
|
1244
1319
|
}
|
|
1245
1320
|
}
|
|
1246
|
-
class
|
|
1321
|
+
class Pi extends j {
|
|
1247
1322
|
constructor(t, e, i, o) {
|
|
1248
1323
|
super(t), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.draggedCoordinate = { id: null, index: -1 }, this.config = t, this.pixelDistance = e, this.selectionPoints = i, this.midPoints = o;
|
|
1249
1324
|
}
|
|
@@ -1274,11 +1349,11 @@ class ai extends j {
|
|
|
1274
1349
|
if (t.lng > 180 || t.lng < -180 || t.lat > 90 || t.lat < -90) return !1;
|
|
1275
1350
|
if (r.type !== "Polygon" || o !== n.length - 1 && o !== 0) n[o] = a;
|
|
1276
1351
|
else {
|
|
1277
|
-
const
|
|
1278
|
-
n[0] = a, n[
|
|
1352
|
+
const c = n.length - 1;
|
|
1353
|
+
n[0] = a, n[c] = a;
|
|
1279
1354
|
}
|
|
1280
|
-
const l = this.selectionPoints.getOneUpdated(o, a), d = l ? [l] : [],
|
|
1281
|
-
return !(r.type !== "Point" && !e &&
|
|
1355
|
+
const l = this.selectionPoints.getOneUpdated(o, a), d = l ? [l] : [], h = this.midPoints.getUpdated(n) || [];
|
|
1356
|
+
return !(r.type !== "Point" && !e && _t({ geometry: r }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: r, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: I.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: r }, ...d, ...h]), 0));
|
|
1282
1357
|
}
|
|
1283
1358
|
isDragging() {
|
|
1284
1359
|
return this.draggedCoordinate.id !== null;
|
|
@@ -1290,21 +1365,21 @@ class ai extends j {
|
|
|
1290
1365
|
this.draggedCoordinate = { id: null, index: -1 };
|
|
1291
1366
|
}
|
|
1292
1367
|
}
|
|
1293
|
-
function
|
|
1368
|
+
function vt(s) {
|
|
1294
1369
|
let t = 0, e = 0, i = 0;
|
|
1295
1370
|
return (s.geometry.type === "Polygon" ? s.geometry.coordinates[0].slice(0, -1) : s.geometry.coordinates).forEach((o) => {
|
|
1296
1371
|
t += o[0], e += o[1], i++;
|
|
1297
1372
|
}, !0), [t / i, e / i];
|
|
1298
1373
|
}
|
|
1299
|
-
function
|
|
1374
|
+
function De(s, t) {
|
|
1300
1375
|
s[0] += s[0] - t[0] > 180 ? -360 : t[0] - s[0] > 180 ? 360 : 0;
|
|
1301
|
-
const e =
|
|
1376
|
+
const e = ye, i = t[1] * Math.PI / 180, o = s[1] * Math.PI / 180, r = o - i;
|
|
1302
1377
|
let n = Math.abs(s[0] - t[0]) * Math.PI / 180;
|
|
1303
1378
|
n > Math.PI && (n -= 2 * Math.PI);
|
|
1304
1379
|
const a = Math.log(Math.tan(o / 2 + Math.PI / 4) / Math.tan(i / 2 + Math.PI / 4)), l = Math.abs(a) > 1e-11 ? r / a : Math.cos(i);
|
|
1305
1380
|
return Math.sqrt(r * r + l * l * n * n) * e;
|
|
1306
1381
|
}
|
|
1307
|
-
function
|
|
1382
|
+
function Ct(s) {
|
|
1308
1383
|
const t = (s.geometry.type === "Polygon" ? s.geometry.coordinates[0] : s.geometry.coordinates).map((e) => {
|
|
1309
1384
|
const { x: i, y: o } = x(e[0], e[1]);
|
|
1310
1385
|
return [i, o];
|
|
@@ -1313,8 +1388,8 @@ function ft(s) {
|
|
|
1313
1388
|
let i = 0, o = 0, r = 0;
|
|
1314
1389
|
const n = e.length;
|
|
1315
1390
|
for (let a = 0; a < n - 1; a++) {
|
|
1316
|
-
const [l, d] = e[a], [
|
|
1317
|
-
i += u, o += (l +
|
|
1391
|
+
const [l, d] = e[a], [h, c] = e[a + 1], u = l * c - h * d;
|
|
1392
|
+
i += u, o += (l + h) * u, r += (d + c) * u;
|
|
1318
1393
|
}
|
|
1319
1394
|
return i /= 2, o /= 6 * i, r /= 6 * i, { x: o, y: r };
|
|
1320
1395
|
}(t) : function(e) {
|
|
@@ -1327,7 +1402,7 @@ function ft(s) {
|
|
|
1327
1402
|
return { x: o / i, y: r / i };
|
|
1328
1403
|
}(t);
|
|
1329
1404
|
}
|
|
1330
|
-
class
|
|
1405
|
+
class Si extends j {
|
|
1331
1406
|
constructor(t, e, i) {
|
|
1332
1407
|
super(t), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastBearing = void 0, this.config = t, this.selectionPoints = e, this.midPoints = i;
|
|
1333
1408
|
}
|
|
@@ -1341,36 +1416,36 @@ class li extends j {
|
|
|
1341
1416
|
let n;
|
|
1342
1417
|
const a = { type: "Feature", geometry: o, properties: {} };
|
|
1343
1418
|
if (this.config.projection === "web-mercator") {
|
|
1344
|
-
if (n =
|
|
1345
|
-
((
|
|
1346
|
-
if (u === 0 || u === 360 || u === -360) return
|
|
1347
|
-
const p = 0.017453292519943295 * u, g = (
|
|
1419
|
+
if (n = T(Ct(a), x(t.lng, t.lat)), !this.lastBearing) return void (this.lastBearing = n);
|
|
1420
|
+
((c, u) => {
|
|
1421
|
+
if (u === 0 || u === 360 || u === -360) return c;
|
|
1422
|
+
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 });
|
|
1348
1423
|
y.x /= g.length, y.y /= g.length;
|
|
1349
1424
|
const v = 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 }) => [W(f, m).lng, W(f, m).lat]);
|
|
1350
|
-
|
|
1425
|
+
c.geometry.type === "Polygon" ? c.geometry.coordinates[0] = v : c.geometry.coordinates = v;
|
|
1351
1426
|
})(a, -(this.lastBearing - n));
|
|
1352
1427
|
} else {
|
|
1353
1428
|
if (this.config.projection !== "globe") throw new Error("Unsupported projection");
|
|
1354
|
-
if (n =
|
|
1355
|
-
(function(
|
|
1356
|
-
if (u === 0 || u === 360 || u === -360) return
|
|
1357
|
-
const p =
|
|
1358
|
-
(
|
|
1359
|
-
const y =
|
|
1429
|
+
if (n = mt(vt({ geometry: o }), r), !this.lastBearing) return void (this.lastBearing = n + 180);
|
|
1430
|
+
(function(c, u) {
|
|
1431
|
+
if (u === 0 || u === 360 || u === -360) return c;
|
|
1432
|
+
const p = vt(c);
|
|
1433
|
+
(c.geometry.type === "Polygon" ? c.geometry.coordinates[0] : c.geometry.coordinates).forEach((g) => {
|
|
1434
|
+
const y = mt(p, g) + u, v = De(p, g), f = kt(p, v, y);
|
|
1360
1435
|
g[0] = f[0], g[1] = f[1];
|
|
1361
1436
|
});
|
|
1362
1437
|
})(a, -(this.lastBearing - (n + 180)));
|
|
1363
1438
|
}
|
|
1364
1439
|
const l = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
|
|
1365
|
-
l.forEach((
|
|
1366
|
-
|
|
1440
|
+
l.forEach((c) => {
|
|
1441
|
+
c[0] = F(c[0], this.coordinatePrecision), c[1] = F(c[1], this.coordinatePrecision);
|
|
1367
1442
|
});
|
|
1368
|
-
const d = this.midPoints.getUpdated(l) || [],
|
|
1369
|
-
if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType:
|
|
1370
|
-
this.store.updateGeometry([{ id: e, geometry: o }, ...
|
|
1443
|
+
const d = this.midPoints.getUpdated(l) || [], h = this.selectionPoints.getUpdated(l) || [];
|
|
1444
|
+
if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: I.Provisional })) return !1;
|
|
1445
|
+
this.store.updateGeometry([{ id: e, geometry: o }, ...h, ...d]), this.projection === "web-mercator" ? this.lastBearing = n : this.projection === "globe" && (this.lastBearing = n + 180);
|
|
1371
1446
|
}
|
|
1372
1447
|
}
|
|
1373
|
-
class
|
|
1448
|
+
class xi extends j {
|
|
1374
1449
|
constructor(t, e, i) {
|
|
1375
1450
|
super(t), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastDistance = void 0, this.config = t, this.selectionPoints = e, this.midPoints = i;
|
|
1376
1451
|
}
|
|
@@ -1382,13 +1457,13 @@ class di extends j {
|
|
|
1382
1457
|
if (o.type !== "Polygon" && o.type !== "LineString") return;
|
|
1383
1458
|
const r = [t.lng, t.lat], n = { type: "Feature", geometry: o, properties: {} };
|
|
1384
1459
|
let a;
|
|
1385
|
-
const l =
|
|
1460
|
+
const l = Ct(n);
|
|
1386
1461
|
if (this.config.projection === "web-mercator") {
|
|
1387
1462
|
const p = x(t.lng, t.lat);
|
|
1388
1463
|
a = O(l, p);
|
|
1389
1464
|
} else {
|
|
1390
1465
|
if (this.config.projection !== "globe") throw new Error("Invalid projection");
|
|
1391
|
-
a =
|
|
1466
|
+
a = A(vt({ geometry: o }), r);
|
|
1392
1467
|
}
|
|
1393
1468
|
if (!this.lastDistance) return void (this.lastDistance = a);
|
|
1394
1469
|
const d = 1 - (this.lastDistance - a) / a;
|
|
@@ -1396,25 +1471,25 @@ class di extends j {
|
|
|
1396
1471
|
const { lng: p, lat: g } = W(l.x, l.y);
|
|
1397
1472
|
(function(y, v, f) {
|
|
1398
1473
|
if (v === 1) return y;
|
|
1399
|
-
const m = (y.geometry.type === "Polygon" ? y.geometry.coordinates[0] : y.geometry.coordinates).map(([S,
|
|
1474
|
+
const m = (y.geometry.type === "Polygon" ? y.geometry.coordinates[0] : y.geometry.coordinates).map(([S, M]) => x(S, M)), C = x(f[0], f[1]), P = m.map((S) => ({ x: C.x + (S.x - C.x) * v, y: C.y + (S.y - C.y) * v })).map(({ x: S, y: M }) => [W(S, M).lng, W(S, M).lat]);
|
|
1400
1475
|
y.geometry.type === "Polygon" ? y.geometry.coordinates[0] = P : y.geometry.coordinates = P;
|
|
1401
1476
|
})(n, d, [p, g]);
|
|
1402
1477
|
} else this.config.projection === "globe" && function(p, g, y, v = "xy") {
|
|
1403
1478
|
g === 1 || (p.geometry.type === "Polygon" ? p.geometry.coordinates[0] : p.geometry.coordinates).forEach((f) => {
|
|
1404
|
-
const m =
|
|
1479
|
+
const m = De(y, f), C = mt(y, f), P = kt(y, m * g, C);
|
|
1405
1480
|
v !== "x" && v !== "xy" || (f[0] = P[0]), v !== "y" && v !== "xy" || (f[1] = P[1]);
|
|
1406
1481
|
});
|
|
1407
|
-
}(n, d,
|
|
1408
|
-
const
|
|
1409
|
-
|
|
1482
|
+
}(n, d, vt(n));
|
|
1483
|
+
const h = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
|
|
1484
|
+
h.forEach((p) => {
|
|
1410
1485
|
p[0] = F(p[0], this.coordinatePrecision), p[1] = F(p[1], this.coordinatePrecision);
|
|
1411
1486
|
});
|
|
1412
|
-
const
|
|
1413
|
-
if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType:
|
|
1414
|
-
this.store.updateGeometry([{ id: e, geometry: o }, ...u, ...
|
|
1487
|
+
const c = this.midPoints.getUpdated(h) || [], u = this.selectionPoints.getUpdated(h) || [];
|
|
1488
|
+
if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: I.Provisional })) return !1;
|
|
1489
|
+
this.store.updateGeometry([{ id: e, geometry: o }, ...u, ...c]), this.lastDistance = a;
|
|
1415
1490
|
}
|
|
1416
1491
|
}
|
|
1417
|
-
class
|
|
1492
|
+
class Ii extends j {
|
|
1418
1493
|
constructor(t, e, i, o) {
|
|
1419
1494
|
super(t), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.minimumScale = 1e-4, this.draggedCoordinate = { id: null, index: -1 }, this.boundingBoxMaps = { opposite: { 0: 4, 1: 5, 2: 6, 3: 7, 4: 0, 5: 1, 6: 2, 7: 3 } }, this.config = t, this.pixelDistance = e, this.selectionPoints = i, this.midPoints = o;
|
|
1420
1495
|
}
|
|
@@ -1473,18 +1548,18 @@ class ci extends j {
|
|
|
1473
1548
|
centerWebMercatorDrag(t) {
|
|
1474
1549
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1475
1550
|
if (!e) return null;
|
|
1476
|
-
const { feature: i, boundingBox: o, updatedCoords: r, selectedCoordinate: n } = e, a =
|
|
1551
|
+
const { feature: i, boundingBox: o, updatedCoords: r, selectedCoordinate: n } = e, a = Ct(i);
|
|
1477
1552
|
if (!a) return null;
|
|
1478
|
-
const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l),
|
|
1479
|
-
return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: r, webMercatorCursor:
|
|
1553
|
+
const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), h = x(t.lng, t.lat);
|
|
1554
|
+
return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: r, webMercatorCursor: h, webMercatorSelected: l, webMercatorOrigin: a }), r;
|
|
1480
1555
|
}
|
|
1481
1556
|
centerFixedWebMercatorDrag(t) {
|
|
1482
1557
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1483
1558
|
if (!e) return null;
|
|
1484
|
-
const { feature: i, boundingBox: o, updatedCoords: r, selectedCoordinate: n } = e, a =
|
|
1559
|
+
const { feature: i, boundingBox: o, updatedCoords: r, selectedCoordinate: n } = e, a = Ct(i);
|
|
1485
1560
|
if (!a) return null;
|
|
1486
|
-
const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l),
|
|
1487
|
-
return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: r, webMercatorCursor:
|
|
1561
|
+
const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), h = x(t.lng, t.lat);
|
|
1562
|
+
return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: r, webMercatorCursor: h, webMercatorSelected: l, webMercatorOrigin: a }), r;
|
|
1488
1563
|
}
|
|
1489
1564
|
scaleFixedWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: r }) {
|
|
1490
1565
|
if (!this.isValidDragWebMercator(t, e.x - o.x, e.y - o.y)) return null;
|
|
@@ -1494,14 +1569,14 @@ class ci extends j {
|
|
|
1494
1569
|
oppositeFixedWebMercatorDrag(t) {
|
|
1495
1570
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1496
1571
|
if (!e) return null;
|
|
1497
|
-
const { boundingBox: i, updatedCoords: o, selectedCoordinate: r } = e, n = x(r[0], r[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] },
|
|
1498
|
-
return this.scaleFixedWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor:
|
|
1572
|
+
const { boundingBox: i, updatedCoords: o, selectedCoordinate: r } = e, n = x(r[0], r[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] }, h = x(t.lng, t.lat);
|
|
1573
|
+
return this.scaleFixedWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: h, webMercatorSelected: n, webMercatorOrigin: d }), o;
|
|
1499
1574
|
}
|
|
1500
1575
|
oppositeWebMercatorDrag(t) {
|
|
1501
1576
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1502
1577
|
if (!e) return null;
|
|
1503
|
-
const { boundingBox: i, updatedCoords: o, selectedCoordinate: r } = e, n = x(r[0], r[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] },
|
|
1504
|
-
return this.scaleWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor:
|
|
1578
|
+
const { boundingBox: i, updatedCoords: o, selectedCoordinate: r } = e, n = x(r[0], r[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] }, h = x(t.lng, t.lat);
|
|
1579
|
+
return this.scaleWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: h, webMercatorSelected: n, webMercatorOrigin: d }), o;
|
|
1505
1580
|
}
|
|
1506
1581
|
scaleWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: r }) {
|
|
1507
1582
|
const n = e.x - o.x, a = e.y - o.y;
|
|
@@ -1525,8 +1600,8 @@ class ci extends j {
|
|
|
1525
1600
|
}
|
|
1526
1601
|
performWebMercatorScale(t, e, i, o, r) {
|
|
1527
1602
|
t.forEach((n) => {
|
|
1528
|
-
const { x: a, y: l } = x(n[0], n[1]), d = e + (a - e) * o,
|
|
1529
|
-
n[0] =
|
|
1603
|
+
const { x: a, y: l } = x(n[0], n[1]), d = e + (a - e) * o, h = i + (l - i) * r, { lng: c, lat: u } = W(d, h);
|
|
1604
|
+
n[0] = c, n[1] = u;
|
|
1530
1605
|
});
|
|
1531
1606
|
}
|
|
1532
1607
|
getBBoxWebMercator(t) {
|
|
@@ -1569,26 +1644,25 @@ class ci extends j {
|
|
|
1569
1644
|
let r = null;
|
|
1570
1645
|
if (e === "center" ? r = this.centerWebMercatorDrag(t) : e === "opposite" ? r = this.oppositeWebMercatorDrag(t) : e === "center-fixed" ? r = this.centerFixedWebMercatorDrag(t) : e === "opposite-fixed" && (r = this.oppositeFixedWebMercatorDrag(t)), !r) return !1;
|
|
1571
1646
|
for (let d = 0; d < r.length; d++) {
|
|
1572
|
-
const
|
|
1573
|
-
if (
|
|
1647
|
+
const h = r[d];
|
|
1648
|
+
if (h[0] = F(h[0], this.coordinatePrecision), h[1] = F(h[1], this.coordinatePrecision), !St(h, this.coordinatePrecision)) return !1;
|
|
1574
1649
|
}
|
|
1575
1650
|
const n = this.midPoints.getUpdated(r) || [], a = this.selectionPoints.getUpdated(r) || [], l = { type: o.geometry.type, coordinates: o.geometry.type === "Polygon" ? [r] : r };
|
|
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:
|
|
1651
|
+
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: I.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: l }, ...a, ...n]), 0));
|
|
1577
1652
|
}
|
|
1578
1653
|
}
|
|
1579
|
-
|
|
1654
|
+
const bi = { deselect: "Escape", delete: "Delete", rotate: ["Control", "r"], scale: ["Control", "s"] }, Jt = { pointerOver: "move", dragStart: "move", dragEnd: "move", insertMidpoint: "crosshair" };
|
|
1655
|
+
class Le extends Xe {
|
|
1580
1656
|
constructor(t) {
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
if (this.cursors = t && t.cursors ? b({},
|
|
1585
|
-
|
|
1586
|
-
const
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
const r = t.flags[o].feature;
|
|
1591
|
-
r && r.validation && (this.validations[o] = r.validation);
|
|
1657
|
+
super(t, !0), this.mode = "select", this.allowManualDeselection = !0, this.dragEventThrottle = 5, this.dragEventCount = 0, this.selected = [], this.flags = {}, this.keyEvents = bi, this.cursors = Jt, this.validations = {}, 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.updateOptions(t);
|
|
1658
|
+
}
|
|
1659
|
+
updateOptions(t) {
|
|
1660
|
+
if (super.updateOptions(t), this.cursors = t && t.cursors ? b({}, this.cursors, t.cursors) : Jt, (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { deselect: null, delete: null, rotate: null, scale: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents)), (t == null ? void 0 : t.dragEventThrottle) !== void 0 && (this.dragEventThrottle = t.dragEventThrottle), (t == null ? void 0 : t.allowManualDeselection) !== void 0 && (this.allowManualDeselection = t.allowManualDeselection), t != null && t.flags) {
|
|
1661
|
+
this.flags = b({}, this.flags, t.flags), this.validations = {};
|
|
1662
|
+
for (const e in this.flags) {
|
|
1663
|
+
const i = this.flags[e].feature;
|
|
1664
|
+
i && i.validation && (this.validations[e] = i.validation);
|
|
1665
|
+
}
|
|
1592
1666
|
}
|
|
1593
1667
|
}
|
|
1594
1668
|
selectFeature(t) {
|
|
@@ -1599,13 +1673,13 @@ class Ee extends Ue {
|
|
|
1599
1673
|
this._state = "selecting";
|
|
1600
1674
|
}
|
|
1601
1675
|
registerBehaviors(t) {
|
|
1602
|
-
this.pixelDistance = new
|
|
1676
|
+
this.pixelDistance = new nt(t), this.clickBoundingBox = new rt(t), this.featuresAtMouseEvent = new vi(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new mi(t), this.midPoints = new fi(t, this.selectionPoints), this.rotateFeature = new Si(t, this.selectionPoints, this.midPoints), this.scaleFeature = new xi(t, this.selectionPoints, this.midPoints), this.dragFeature = new Ci(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints), this.dragCoordinate = new Pi(t, this.pixelDistance, this.selectionPoints, this.midPoints), this.dragCoordinateResizeFeature = new Ii(t, this.pixelDistance, this.selectionPoints, this.midPoints);
|
|
1603
1677
|
}
|
|
1604
1678
|
deselectFeature() {
|
|
1605
1679
|
this.deselect();
|
|
1606
1680
|
}
|
|
1607
1681
|
deselect() {
|
|
1608
|
-
const t = this.selected.filter((e) => this.store.has(e)).map((e) => ({ id: e, property:
|
|
1682
|
+
const t = this.selected.filter((e) => this.store.has(e)).map((e) => ({ id: e, property: U.SELECTED, value: !1 }));
|
|
1609
1683
|
this.store.updateProperty(t), this.onDeselect(this.selected[0]), this.selected = [], this.selectionPoints.delete(), this.midPoints.delete();
|
|
1610
1684
|
}
|
|
1611
1685
|
deleteSelected() {
|
|
@@ -1614,18 +1688,18 @@ class Ee extends Ue {
|
|
|
1614
1688
|
onRightClick(t) {
|
|
1615
1689
|
if (!this.selectionPoints.ids.length) return;
|
|
1616
1690
|
let e, i = 1 / 0;
|
|
1617
|
-
if (this.selectionPoints.ids.forEach((
|
|
1618
|
-
const u = this.store.getGeometryCopy(
|
|
1619
|
-
p < this.pointerDistance && p < i && (i = p, e = this.store.getPropertiesCopy(
|
|
1691
|
+
if (this.selectionPoints.ids.forEach((c) => {
|
|
1692
|
+
const u = this.store.getGeometryCopy(c), p = this.pixelDistance.measure(t, u.coordinates);
|
|
1693
|
+
p < this.pointerDistance && p < i && (i = p, e = this.store.getPropertiesCopy(c));
|
|
1620
1694
|
}), !e) return;
|
|
1621
1695
|
const o = e.selectionPointFeatureId, r = e.index, n = this.store.getPropertiesCopy(o), a = this.flags[n.mode], l = this.validations[n.mode];
|
|
1622
1696
|
if (!(a && a.feature && a.feature.coordinates && a.feature.coordinates.deletable)) return;
|
|
1623
1697
|
const d = this.store.getGeometryCopy(o);
|
|
1624
|
-
let
|
|
1698
|
+
let h;
|
|
1625
1699
|
if (d.type === "Polygon") {
|
|
1626
|
-
if (
|
|
1627
|
-
} else if (d.type === "LineString" && (
|
|
1628
|
-
|
|
1700
|
+
if (h = d.coordinates[0], h.length <= 4) return;
|
|
1701
|
+
} else if (d.type === "LineString" && (h = d.coordinates, h.length <= 2)) return;
|
|
1702
|
+
h && (d.type !== "Polygon" || r !== 0 && r !== h.length - 1 ? h.splice(r, 1) : (h.shift(), h.pop(), h.push([h[0][0], h[0][1]])), (!l || l({ id: o, type: "Feature", geometry: d, properties: n }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: I.Commit }).valid) && (this.store.delete([...this.midPoints.ids, ...this.selectionPoints.ids]), this.store.updateGeometry([{ id: o, geometry: d }]), this.selectionPoints.create(h, d.type, o), a && a.feature && a.feature.coordinates && a.feature.coordinates.midpoints && this.midPoints.create(h, o, this.coordinatePrecision)));
|
|
1629
1703
|
}
|
|
1630
1704
|
select(t, e = !0) {
|
|
1631
1705
|
if (this.selected[0] === t) return;
|
|
@@ -1726,7 +1800,7 @@ class Ee extends Ue {
|
|
|
1726
1800
|
if (t.properties.mode === this.mode && t.geometry.type === "Point") {
|
|
1727
1801
|
if (t.properties.selectionPoint) return e.pointColor = this.getHexColorStylingValue(this.styles.selectionPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.selectionPointOutlineColor, e.pointOutlineColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.selectionPointWidth, e.pointWidth, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.selectionPointOutlineWidth, 2, t), e.zIndex = 30, e;
|
|
1728
1802
|
if (t.properties.midPoint) return e.pointColor = this.getHexColorStylingValue(this.styles.midPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.midPointOutlineColor, e.pointOutlineColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.midPointWidth, 4, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.midPointOutlineWidth, 2, t), e.zIndex = 40, e;
|
|
1729
|
-
} else if (t.properties[
|
|
1803
|
+
} else if (t.properties[U.SELECTED]) {
|
|
1730
1804
|
if (t.geometry.type === "Polygon") return e.polygonFillColor = this.getHexColorStylingValue(this.styles.selectedPolygonColor, e.polygonFillColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.selectedPolygonOutlineWidth, e.polygonOutlineWidth, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.selectedPolygonOutlineColor, e.polygonOutlineColor, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.selectedPolygonFillOpacity, e.polygonFillOpacity, t), e.zIndex = 10, e;
|
|
1731
1805
|
if (t.geometry.type === "LineString") return e.lineStringColor = this.getHexColorStylingValue(this.styles.selectedLineStringColor, e.lineStringColor, t), e.lineStringWidth = this.getNumericStylingValue(this.styles.selectedLineStringWidth, e.lineStringWidth, t), e.zIndex = 10, e;
|
|
1732
1806
|
if (t.geometry.type === "Point") return e.pointWidth = this.getNumericStylingValue(this.styles.selectedPointWidth, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(this.styles.selectedPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.selectedPointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.selectedPointOutlineWidth, e.pointOutlineWidth, t), e.zIndex = 10, e;
|
|
@@ -1734,9 +1808,9 @@ class Ee extends Ue {
|
|
|
1734
1808
|
return e;
|
|
1735
1809
|
}
|
|
1736
1810
|
}
|
|
1737
|
-
class
|
|
1811
|
+
class Mi extends N {
|
|
1738
1812
|
constructor(...t) {
|
|
1739
|
-
super(...t), this.type =
|
|
1813
|
+
super(...t), this.type = $.Static, this.mode = "static";
|
|
1740
1814
|
}
|
|
1741
1815
|
start() {
|
|
1742
1816
|
}
|
|
@@ -1762,11 +1836,11 @@ class hi extends N {
|
|
|
1762
1836
|
return b({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
1763
1837
|
}
|
|
1764
1838
|
}
|
|
1765
|
-
function
|
|
1839
|
+
function _e(s, t, e, i, o) {
|
|
1766
1840
|
for (; i > e; ) {
|
|
1767
1841
|
if (i - e > 600) {
|
|
1768
|
-
const l = i - e + 1, d = t - e + 1,
|
|
1769
|
-
|
|
1842
|
+
const l = i - e + 1, d = t - e + 1, h = Math.log(l), c = 0.5 * Math.exp(2 * h / 3), u = 0.5 * Math.sqrt(h * c * (l - c) / l) * (d - l / 2 < 0 ? -1 : 1);
|
|
1843
|
+
_e(s, t, Math.max(e, Math.floor(t - d * c / l + u)), Math.min(i, Math.floor(t + (l - d) * c / l + u)), o);
|
|
1770
1844
|
}
|
|
1771
1845
|
const r = s[t];
|
|
1772
1846
|
let n = e, a = i;
|
|
@@ -1781,11 +1855,11 @@ function Q(s, t, e) {
|
|
|
1781
1855
|
const i = s[t];
|
|
1782
1856
|
s[t] = s[e], s[e] = i;
|
|
1783
1857
|
}
|
|
1784
|
-
function
|
|
1858
|
+
function H(s, t) {
|
|
1785
1859
|
it(s, 0, s.children.length, t, s);
|
|
1786
1860
|
}
|
|
1787
1861
|
function it(s, t, e, i, o) {
|
|
1788
|
-
o || (o =
|
|
1862
|
+
o || (o = J([])), o.minX = 1 / 0, o.minY = 1 / 0, o.maxX = -1 / 0, o.maxY = -1 / 0;
|
|
1789
1863
|
for (let r = t; r < e; r++) {
|
|
1790
1864
|
const n = s.children[r];
|
|
1791
1865
|
ot(o, s.leaf ? i(n) : n);
|
|
@@ -1795,52 +1869,52 @@ function it(s, t, e, i, o) {
|
|
|
1795
1869
|
function ot(s, t) {
|
|
1796
1870
|
return s.minX = Math.min(s.minX, t.minX), s.minY = Math.min(s.minY, t.minY), s.maxX = Math.max(s.maxX, t.maxX), s.maxY = Math.max(s.maxY, t.maxY), s;
|
|
1797
1871
|
}
|
|
1798
|
-
function
|
|
1872
|
+
function wi(s, t) {
|
|
1799
1873
|
return s.minX - t.minX;
|
|
1800
1874
|
}
|
|
1801
|
-
function
|
|
1875
|
+
function Fi(s, t) {
|
|
1802
1876
|
return s.minY - t.minY;
|
|
1803
1877
|
}
|
|
1804
|
-
function
|
|
1878
|
+
function wt(s) {
|
|
1805
1879
|
return (s.maxX - s.minX) * (s.maxY - s.minY);
|
|
1806
1880
|
}
|
|
1807
|
-
function
|
|
1881
|
+
function ut(s) {
|
|
1808
1882
|
return s.maxX - s.minX + (s.maxY - s.minY);
|
|
1809
1883
|
}
|
|
1810
|
-
function
|
|
1884
|
+
function Ei(s, t) {
|
|
1811
1885
|
const e = Math.max(s.minX, t.minX), i = Math.max(s.minY, t.minY), o = Math.min(s.maxX, t.maxX), r = Math.min(s.maxY, t.maxY);
|
|
1812
1886
|
return Math.max(0, o - e) * Math.max(0, r - i);
|
|
1813
1887
|
}
|
|
1814
|
-
function
|
|
1888
|
+
function Ft(s, t) {
|
|
1815
1889
|
return s.minX <= t.minX && s.minY <= t.minY && t.maxX <= s.maxX && t.maxY <= s.maxY;
|
|
1816
1890
|
}
|
|
1817
|
-
function
|
|
1891
|
+
function pt(s, t) {
|
|
1818
1892
|
return t.minX <= s.maxX && t.minY <= s.maxY && t.maxX >= s.minX && t.maxY >= s.minY;
|
|
1819
1893
|
}
|
|
1820
|
-
function
|
|
1894
|
+
function J(s) {
|
|
1821
1895
|
return { children: s, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
|
|
1822
1896
|
}
|
|
1823
|
-
function
|
|
1897
|
+
function Zt(s, t, e, i, o) {
|
|
1824
1898
|
const r = [t, e];
|
|
1825
1899
|
for (; r.length; ) {
|
|
1826
1900
|
if ((e = r.pop()) - (t = r.pop()) <= i) continue;
|
|
1827
1901
|
const n = t + Math.ceil((e - t) / i / 2) * i;
|
|
1828
|
-
|
|
1902
|
+
_e(s, n, t, e, o), r.push(t, n, n, e);
|
|
1829
1903
|
}
|
|
1830
1904
|
}
|
|
1831
|
-
class
|
|
1905
|
+
class Oi {
|
|
1832
1906
|
constructor(t) {
|
|
1833
1907
|
this._maxEntries = void 0, this._minEntries = void 0, this.data = void 0, this._maxEntries = Math.max(4, t), this._minEntries = Math.max(2, Math.ceil(0.4 * this._maxEntries)), this.clear();
|
|
1834
1908
|
}
|
|
1835
1909
|
search(t) {
|
|
1836
1910
|
let e = this.data;
|
|
1837
1911
|
const i = [];
|
|
1838
|
-
if (!
|
|
1912
|
+
if (!pt(t, e)) return i;
|
|
1839
1913
|
const o = this.toBBox, r = [];
|
|
1840
1914
|
for (; e; ) {
|
|
1841
1915
|
for (let n = 0; n < e.children.length; n++) {
|
|
1842
1916
|
const a = e.children[n], l = e.leaf ? o(a) : a;
|
|
1843
|
-
|
|
1917
|
+
pt(t, l) && (e.leaf ? i.push(a) : Ft(t, l) ? this._all(a, i) : r.push(a));
|
|
1844
1918
|
}
|
|
1845
1919
|
e = r.pop();
|
|
1846
1920
|
}
|
|
@@ -1848,13 +1922,13 @@ class yi {
|
|
|
1848
1922
|
}
|
|
1849
1923
|
collides(t) {
|
|
1850
1924
|
let e = this.data;
|
|
1851
|
-
if (
|
|
1925
|
+
if (pt(t, e)) {
|
|
1852
1926
|
const i = [];
|
|
1853
1927
|
for (; e; ) {
|
|
1854
1928
|
for (let o = 0; o < e.children.length; o++) {
|
|
1855
1929
|
const r = e.children[o], n = e.leaf ? this.toBBox(r) : r;
|
|
1856
|
-
if (
|
|
1857
|
-
if (e.leaf ||
|
|
1930
|
+
if (pt(t, n)) {
|
|
1931
|
+
if (e.leaf || Ft(t, n)) return !0;
|
|
1858
1932
|
i.push(r);
|
|
1859
1933
|
}
|
|
1860
1934
|
}
|
|
@@ -1883,7 +1957,7 @@ class yi {
|
|
|
1883
1957
|
this._insert(t, this.data.height - 1);
|
|
1884
1958
|
}
|
|
1885
1959
|
clear() {
|
|
1886
|
-
this.data =
|
|
1960
|
+
this.data = J([]);
|
|
1887
1961
|
}
|
|
1888
1962
|
remove(t) {
|
|
1889
1963
|
let e = this.data;
|
|
@@ -1894,7 +1968,7 @@ class yi {
|
|
|
1894
1968
|
const d = e.children.indexOf(t);
|
|
1895
1969
|
d !== -1 && (e.children.splice(d, 1), o.push(e), this._condense(o));
|
|
1896
1970
|
}
|
|
1897
|
-
l || e.leaf || !
|
|
1971
|
+
l || e.leaf || !Ft(e, i) ? a ? (n++, e = a.children[n], l = !1) : e = null : (o.push(e), r.push(n), n = 0, a = e, e = e.children[0]);
|
|
1898
1972
|
}
|
|
1899
1973
|
}
|
|
1900
1974
|
toBBox(t) {
|
|
@@ -1914,26 +1988,26 @@ class yi {
|
|
|
1914
1988
|
_build(t, e, i, o) {
|
|
1915
1989
|
const r = i - e + 1;
|
|
1916
1990
|
let n, a = this._maxEntries;
|
|
1917
|
-
if (r <= a) return n =
|
|
1918
|
-
o || (o = Math.ceil(Math.log(r) / Math.log(a)), a = Math.ceil(r / Math.pow(a, o - 1))), n =
|
|
1991
|
+
if (r <= a) return n = J(t.slice(e, i + 1)), H(n, this.toBBox), n;
|
|
1992
|
+
o || (o = Math.ceil(Math.log(r) / Math.log(a)), a = Math.ceil(r / Math.pow(a, o - 1))), n = J([]), n.leaf = !1, n.height = o;
|
|
1919
1993
|
const l = Math.ceil(r / a), d = l * Math.ceil(Math.sqrt(a));
|
|
1920
|
-
|
|
1921
|
-
for (let
|
|
1922
|
-
const
|
|
1923
|
-
|
|
1924
|
-
for (let u =
|
|
1925
|
-
const p = Math.min(u + l - 1,
|
|
1994
|
+
Zt(t, e, i, d, this.compareMinX);
|
|
1995
|
+
for (let h = e; h <= i; h += d) {
|
|
1996
|
+
const c = Math.min(h + d - 1, i);
|
|
1997
|
+
Zt(t, h, c, l, this.compareMinY);
|
|
1998
|
+
for (let u = h; u <= c; u += l) {
|
|
1999
|
+
const p = Math.min(u + l - 1, c);
|
|
1926
2000
|
n.children.push(this._build(t, u, p, o - 1));
|
|
1927
2001
|
}
|
|
1928
2002
|
}
|
|
1929
|
-
return
|
|
2003
|
+
return H(n, this.toBBox), n;
|
|
1930
2004
|
}
|
|
1931
2005
|
_chooseSubtree(t, e, i, o) {
|
|
1932
2006
|
for (; o.push(e), !e.leaf && o.length - 1 !== i; ) {
|
|
1933
2007
|
let a, l = 1 / 0, d = 1 / 0;
|
|
1934
|
-
for (let
|
|
1935
|
-
const
|
|
1936
|
-
p < d ? (d = p, l = u < l ? u : l, a =
|
|
2008
|
+
for (let h = 0; h < e.children.length; h++) {
|
|
2009
|
+
const c = e.children[h], u = wt(c), p = (r = t, n = c, (Math.max(n.maxX, r.maxX) - Math.min(n.minX, r.minX)) * (Math.max(n.maxY, r.maxY) - Math.min(n.minY, r.minY)) - u);
|
|
2010
|
+
p < d ? (d = p, l = u < l ? u : l, a = c) : p === d && u < l && (l = u, a = c);
|
|
1937
2011
|
}
|
|
1938
2012
|
e = a || e.children[0];
|
|
1939
2013
|
}
|
|
@@ -1948,35 +2022,35 @@ class yi {
|
|
|
1948
2022
|
_split(t, e) {
|
|
1949
2023
|
const i = t[e], o = i.children.length, r = this._minEntries;
|
|
1950
2024
|
this._chooseSplitAxis(i, r, o);
|
|
1951
|
-
const n = this._chooseSplitIndex(i, r, o), a =
|
|
1952
|
-
a.height = i.height, a.leaf = i.leaf,
|
|
2025
|
+
const n = this._chooseSplitIndex(i, r, o), a = J(i.children.splice(n, i.children.length - n));
|
|
2026
|
+
a.height = i.height, a.leaf = i.leaf, H(i, this.toBBox), H(a, this.toBBox), e ? t[e - 1].children.push(a) : this._splitRoot(i, a);
|
|
1953
2027
|
}
|
|
1954
2028
|
_splitRoot(t, e) {
|
|
1955
|
-
this.data =
|
|
2029
|
+
this.data = J([t, e]), this.data.height = t.height + 1, this.data.leaf = !1, H(this.data, this.toBBox);
|
|
1956
2030
|
}
|
|
1957
2031
|
_chooseSplitIndex(t, e, i) {
|
|
1958
2032
|
let o, r = 1 / 0, n = 1 / 0;
|
|
1959
2033
|
for (let a = e; a <= i - e; a++) {
|
|
1960
|
-
const l = it(t, 0, a, this.toBBox), d = it(t, a, i, this.toBBox),
|
|
1961
|
-
|
|
2034
|
+
const l = it(t, 0, a, this.toBBox), d = it(t, a, i, this.toBBox), h = Ei(l, d), c = wt(l) + wt(d);
|
|
2035
|
+
h < r ? (r = h, o = a, n = c < n ? c : n) : h === r && c < n && (n = c, o = a);
|
|
1962
2036
|
}
|
|
1963
2037
|
return o || i - e;
|
|
1964
2038
|
}
|
|
1965
2039
|
_chooseSplitAxis(t, e, i) {
|
|
1966
|
-
const o = t.leaf ? this.compareMinX :
|
|
2040
|
+
const o = t.leaf ? this.compareMinX : wi, r = t.leaf ? this.compareMinY : Fi;
|
|
1967
2041
|
this._allDistMargin(t, e, i, o) < this._allDistMargin(t, e, i, r) && t.children.sort(o);
|
|
1968
2042
|
}
|
|
1969
2043
|
_allDistMargin(t, e, i, o) {
|
|
1970
2044
|
t.children.sort(o);
|
|
1971
2045
|
const r = this.toBBox, n = it(t, 0, e, r), a = it(t, i - e, i, r);
|
|
1972
|
-
let l =
|
|
2046
|
+
let l = ut(n) + ut(a);
|
|
1973
2047
|
for (let d = e; d < i - e; d++) {
|
|
1974
|
-
const
|
|
1975
|
-
ot(n, t.leaf ? r(
|
|
2048
|
+
const h = t.children[d];
|
|
2049
|
+
ot(n, t.leaf ? r(h) : h), l += ut(n);
|
|
1976
2050
|
}
|
|
1977
2051
|
for (let d = i - e - 1; d >= e; d--) {
|
|
1978
|
-
const
|
|
1979
|
-
ot(a, t.leaf ? r(
|
|
2052
|
+
const h = t.children[d];
|
|
2053
|
+
ot(a, t.leaf ? r(h) : h), l += ut(a);
|
|
1980
2054
|
}
|
|
1981
2055
|
return l;
|
|
1982
2056
|
}
|
|
@@ -1984,12 +2058,12 @@ class yi {
|
|
|
1984
2058
|
for (let o = i; o >= 0; o--) ot(e[o], t);
|
|
1985
2059
|
}
|
|
1986
2060
|
_condense(t) {
|
|
1987
|
-
for (let e, i = t.length - 1; i >= 0; i--) t[i].children.length === 0 ? i > 0 ? (e = t[i - 1].children, e.splice(e.indexOf(t[i]), 1)) : this.clear() :
|
|
2061
|
+
for (let e, i = t.length - 1; i >= 0; i--) t[i].children.length === 0 ? i > 0 ? (e = t[i - 1].children, e.splice(e.indexOf(t[i]), 1)) : this.clear() : H(t[i], this.toBBox);
|
|
1988
2062
|
}
|
|
1989
2063
|
}
|
|
1990
|
-
class
|
|
2064
|
+
class Di {
|
|
1991
2065
|
constructor(t) {
|
|
1992
|
-
this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new
|
|
2066
|
+
this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new Oi(t && t.maxEntries ? t.maxEntries : 9), this.idToNode = /* @__PURE__ */ new Map(), this.nodeToId = /* @__PURE__ */ new Map();
|
|
1993
2067
|
}
|
|
1994
2068
|
setMaps(t, e) {
|
|
1995
2069
|
this.idToNode.set(t.id, e), this.nodeToId.set(e, t.id);
|
|
@@ -2040,14 +2114,14 @@ class fi {
|
|
|
2040
2114
|
return this.tree.collides(this.toBBox(t));
|
|
2041
2115
|
}
|
|
2042
2116
|
}
|
|
2043
|
-
const
|
|
2117
|
+
const Li = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(s) {
|
|
2044
2118
|
const t = 16 * Math.random() | 0;
|
|
2045
2119
|
return (s == "x" ? t : 3 & t | 8).toString(16);
|
|
2046
2120
|
}), isValidId: (s) => typeof s == "string" && s.length === 36 };
|
|
2047
|
-
class
|
|
2121
|
+
class _i {
|
|
2048
2122
|
constructor(t) {
|
|
2049
2123
|
this.idStrategy = void 0, this.tracked = void 0, this.spatialIndex = void 0, this.store = void 0, this._onChange = () => {
|
|
2050
|
-
}, this.store = {}, this.spatialIndex = new
|
|
2124
|
+
}, this.store = {}, this.spatialIndex = new Di(), this.tracked = !t || t.tracked !== !1, this.idStrategy = t && t.idStrategy ? t.idStrategy : Li;
|
|
2051
2125
|
}
|
|
2052
2126
|
clone(t) {
|
|
2053
2127
|
return JSON.parse(JSON.stringify(t));
|
|
@@ -2071,10 +2145,10 @@ class vi {
|
|
|
2071
2145
|
}
|
|
2072
2146
|
if (this.tracked) {
|
|
2073
2147
|
if (n.properties.createdAt) {
|
|
2074
|
-
if (!
|
|
2148
|
+
if (!Vt(n.properties.createdAt)) return r.push({ id: n.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
|
|
2075
2149
|
} else n.properties.createdAt = +/* @__PURE__ */ new Date();
|
|
2076
2150
|
if (n.properties.updatedAt) {
|
|
2077
|
-
if (!
|
|
2151
|
+
if (!Vt(n.properties.updatedAt)) return r.push({ id: n.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
|
|
2078
2152
|
} else n.properties.updatedAt = +/* @__PURE__ */ new Date();
|
|
2079
2153
|
}
|
|
2080
2154
|
return this.has(a) ? (r.push({ id: a, valid: !1, reason: `Feature already exists with this id: ${a}` }), !1) : (this.store[a] = n, o.push(a), r.push({ id: a, valid: !0 }), !0);
|
|
@@ -2131,6 +2205,9 @@ class vi {
|
|
|
2131
2205
|
delete this.store[e], this.spatialIndex.remove(e);
|
|
2132
2206
|
}), this._onChange && this._onChange([...t], "delete");
|
|
2133
2207
|
}
|
|
2208
|
+
copy(t) {
|
|
2209
|
+
return this.clone(this.store[t]);
|
|
2210
|
+
}
|
|
2134
2211
|
copyAll() {
|
|
2135
2212
|
return this.clone(Object.keys(this.store).map((t) => this.store[t]));
|
|
2136
2213
|
}
|
|
@@ -2141,21 +2218,19 @@ class vi {
|
|
|
2141
2218
|
return Object.keys(this.store).length;
|
|
2142
2219
|
}
|
|
2143
2220
|
}
|
|
2144
|
-
const
|
|
2145
|
-
function
|
|
2146
|
-
const i =
|
|
2147
|
-
let o =
|
|
2221
|
+
const ki = "Feature is not a Polygon or LineString", Wi = "Feature intersects itself", ji = (s) => s.geometry.type !== "Polygon" && s.geometry.type !== "LineString" ? { valid: !1, reason: ki } : _t(s) ? { valid: !1, reason: Wi } : { valid: !0 };
|
|
2222
|
+
function Qt(s, t, e) {
|
|
2223
|
+
const i = T(s, t);
|
|
2224
|
+
let o = T(t, e) - i;
|
|
2148
2225
|
return o < 0 && (o += 360), 180 - Math.abs(o - 90 - 90);
|
|
2149
2226
|
}
|
|
2150
|
-
|
|
2227
|
+
const Bi = { cancel: "Escape", finish: "Enter" }, Ni = { start: "crosshair", close: "pointer" };
|
|
2228
|
+
class ke extends N {
|
|
2151
2229
|
constructor(t) {
|
|
2152
|
-
super(t), this.mode = "angled-rectangle", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents =
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
const i = { cancel: "Escape", finish: "Enter" };
|
|
2157
|
-
this.keyEvents = t && t.keyEvents ? b({}, i, t.keyEvents) : i;
|
|
2158
|
-
}
|
|
2230
|
+
super(t, !0), this.mode = "angled-rectangle", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = Bi, this.cursors = Ni, this.mouseMove = !1, this.updateOptions(t);
|
|
2231
|
+
}
|
|
2232
|
+
updateOptions(t) {
|
|
2233
|
+
super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents));
|
|
2159
2234
|
}
|
|
2160
2235
|
close() {
|
|
2161
2236
|
if (this.currentId === void 0) return;
|
|
@@ -2176,13 +2251,13 @@ class De extends N {
|
|
|
2176
2251
|
const o = 1 / Math.pow(10, this.coordinatePrecision - 1), r = Math.max(1e-6, o);
|
|
2177
2252
|
i = [e[0], [t.lng, t.lat], [t.lng, t.lat - r], e[0]];
|
|
2178
2253
|
} else if (this.currentCoordinate === 2) {
|
|
2179
|
-
const o = e[0], r = e[1], n =
|
|
2180
|
-
const D = (w.x -
|
|
2254
|
+
const o = e[0], r = e[1], n = Fe(o, r, this.coordinatePrecision, this.project, this.unproject), a = x(o[0], o[1]), l = x(n[0], n[1]), d = x(r[0], r[1]), h = x(t.lng, t.lat), c = O(h, a) < O(h, d), u = Qt(a, l, h), p = c ? 90 - u : Qt(a, l, h) - 90, g = O(l, h), y = Math.cos(E(p)) * g, v = T(a, d) + (function(S, M, w) {
|
|
2255
|
+
const D = (w.x - M.x) * (S.y - M.y) - (w.y - M.y) * (S.x - M.x);
|
|
2181
2256
|
return D > 1e-10 ? "left" : D < -1e-10 ? "right" : "left";
|
|
2182
|
-
}(a, d,
|
|
2257
|
+
}(a, d, h) === "right" ? -90 : 90), f = at(a, y, v), m = at(d, y, v), C = W(f.x, f.y), P = W(m.x, m.y);
|
|
2183
2258
|
i = [e[0], e[1], [P.lng, P.lat], [C.lng, C.lat], e[0]];
|
|
2184
2259
|
}
|
|
2185
|
-
i && this.updatePolygonGeometry(this.currentId, i,
|
|
2260
|
+
i && this.updatePolygonGeometry(this.currentId, i, I.Provisional);
|
|
2186
2261
|
}
|
|
2187
2262
|
updatePolygonGeometry(t, e, i) {
|
|
2188
2263
|
const o = { type: "Polygon", coordinates: [e] };
|
|
@@ -2194,12 +2269,16 @@ class De extends N {
|
|
|
2194
2269
|
this.currentId = e, this.currentCoordinate++, this.setDrawing();
|
|
2195
2270
|
} else if (this.currentCoordinate === 1 && this.currentId) {
|
|
2196
2271
|
const e = this.store.getGeometryCopy(this.currentId);
|
|
2197
|
-
if (Z([t.lng, t.lat], e.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [e.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], e.coordinates[0][0]],
|
|
2272
|
+
if (Z([t.lng, t.lat], e.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [e.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], e.coordinates[0][0]], I.Commit)) return;
|
|
2198
2273
|
this.currentCoordinate++;
|
|
2199
2274
|
} else this.currentCoordinate === 2 && this.currentId && this.close();
|
|
2200
2275
|
}
|
|
2201
2276
|
onKeyUp(t) {
|
|
2202
|
-
t.key === this.keyEvents.cancel
|
|
2277
|
+
if (t.key === this.keyEvents.cancel) this.cleanUp();
|
|
2278
|
+
else if (t.key === this.keyEvents.finish) {
|
|
2279
|
+
if (this.currentCoordinate < 2) return void this.cleanUp();
|
|
2280
|
+
this.close();
|
|
2281
|
+
}
|
|
2203
2282
|
}
|
|
2204
2283
|
onKeyDown() {
|
|
2205
2284
|
}
|
|
@@ -2221,27 +2300,26 @@ class De extends N {
|
|
|
2221
2300
|
return t.properties.mode === this.mode && t.geometry.type === "Polygon" && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
|
|
2222
2301
|
}
|
|
2223
2302
|
validateFeature(t) {
|
|
2224
|
-
return this.validateModeFeature(t, (e) =>
|
|
2303
|
+
return this.validateModeFeature(t, (e) => lt(e, this.coordinatePrecision));
|
|
2225
2304
|
}
|
|
2226
2305
|
}
|
|
2227
|
-
function
|
|
2306
|
+
function We(s, t, e) {
|
|
2228
2307
|
return (t.x - s.x) * (e.y - s.y) - (t.y - s.y) * (e.x - s.x) <= 0;
|
|
2229
2308
|
}
|
|
2230
|
-
|
|
2309
|
+
const Gi = { cancel: "Escape", finish: "Enter" }, Ti = { start: "crosshair", close: "pointer" };
|
|
2310
|
+
class je extends N {
|
|
2231
2311
|
constructor(t) {
|
|
2232
|
-
super(t), this.mode = "sector", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents =
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
const i = { cancel: "Escape", finish: "Enter" };
|
|
2237
|
-
this.keyEvents = t && t.keyEvents ? b({}, i, t.keyEvents) : i;
|
|
2238
|
-
}
|
|
2239
|
-
this.arcPoints = (t == null ? void 0 : t.arcPoints) || 64;
|
|
2312
|
+
super(t, !0), this.mode = "sector", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = Gi, this.direction = void 0, this.arcPoints = 64, this.cursors = Ti, this.mouseMove = !1, this.updateOptions(t);
|
|
2313
|
+
}
|
|
2314
|
+
updateOptions(t) {
|
|
2315
|
+
super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents)), t != null && t.arcPoints && (this.arcPoints = t.arcPoints);
|
|
2240
2316
|
}
|
|
2241
2317
|
close() {
|
|
2242
2318
|
if (this.currentId === void 0) return;
|
|
2243
|
-
const t = this.currentId;
|
|
2244
|
-
|
|
2319
|
+
const t = dt(this.store.getGeometryCopy(this.currentId));
|
|
2320
|
+
t && this.store.updateGeometry([{ id: this.currentId, geometry: t }]);
|
|
2321
|
+
const e = this.currentId;
|
|
2322
|
+
this.currentCoordinate = 0, this.currentId = void 0, this.direction = void 0, this.state === "drawing" && this.setStarted(), this.onFinish(e, { mode: this.mode, action: "draw" });
|
|
2245
2323
|
}
|
|
2246
2324
|
start() {
|
|
2247
2325
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -2259,21 +2337,21 @@ class _e extends N {
|
|
|
2259
2337
|
} else if (this.currentCoordinate === 2) {
|
|
2260
2338
|
const o = e[0], r = e[1], n = [t.lng, t.lat], a = x(o[0], o[1]), l = x(r[0], r[1]), d = x(n[0], n[1]);
|
|
2261
2339
|
if (this.direction === void 0) {
|
|
2262
|
-
const C =
|
|
2340
|
+
const C = We(a, l, d);
|
|
2263
2341
|
this.direction = C ? "clockwise" : "anticlockwise";
|
|
2264
2342
|
}
|
|
2265
|
-
const
|
|
2343
|
+
const h = O(a, l), c = T(a, l), u = T(a, d), p = this.arcPoints, g = [o], y = Y(c), v = Y(u);
|
|
2266
2344
|
let f;
|
|
2267
2345
|
this.direction === "anticlockwise" ? (f = v - y, f < 0 && (f += 360)) : (f = y - v, f < 0 && (f += 360));
|
|
2268
2346
|
const m = (this.direction === "anticlockwise" ? 1 : -1) * f / p;
|
|
2269
2347
|
g.push(r);
|
|
2270
2348
|
for (let C = 0; C <= p; C++) {
|
|
2271
|
-
const P =
|
|
2349
|
+
const P = at(a, h, y + C * m), { lng: S, lat: M } = W(P.x, P.y), w = [F(S, this.coordinatePrecision), F(M, this.coordinatePrecision)];
|
|
2272
2350
|
w[0] !== g[g.length - 1][0] && w[1] !== g[g.length - 1][1] && g.push(w);
|
|
2273
2351
|
}
|
|
2274
2352
|
g.push(o), i = [...g];
|
|
2275
2353
|
}
|
|
2276
|
-
i && this.updatePolygonGeometry(this.currentId, i,
|
|
2354
|
+
i && this.updatePolygonGeometry(this.currentId, i, I.Provisional);
|
|
2277
2355
|
}
|
|
2278
2356
|
updatePolygonGeometry(t, e, i) {
|
|
2279
2357
|
const o = { type: "Polygon", coordinates: [e] };
|
|
@@ -2285,7 +2363,7 @@ class _e extends N {
|
|
|
2285
2363
|
this.currentId = e, this.currentCoordinate++, this.setDrawing();
|
|
2286
2364
|
} else if (this.currentCoordinate === 1 && this.currentId) {
|
|
2287
2365
|
const e = this.store.getGeometryCopy(this.currentId);
|
|
2288
|
-
if (Z([t.lng, t.lat], e.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [e.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], e.coordinates[0][0]],
|
|
2366
|
+
if (Z([t.lng, t.lat], e.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [e.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], e.coordinates[0][0]], I.Commit)) return;
|
|
2289
2367
|
this.currentCoordinate++;
|
|
2290
2368
|
} else this.currentCoordinate === 2 && this.currentId && this.close();
|
|
2291
2369
|
}
|
|
@@ -2312,24 +2390,25 @@ class _e extends N {
|
|
|
2312
2390
|
return t.properties.mode === this.mode && t.geometry.type === "Polygon" && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
|
|
2313
2391
|
}
|
|
2314
2392
|
validateFeature(t) {
|
|
2315
|
-
return this.validateModeFeature(t, (e) =>
|
|
2393
|
+
return this.validateModeFeature(t, (e) => lt(e, this.coordinatePrecision));
|
|
2316
2394
|
}
|
|
2317
2395
|
}
|
|
2318
|
-
|
|
2396
|
+
const Ai = { cancel: "Escape", finish: "Enter" }, Vi = { start: "crosshair", close: "pointer" };
|
|
2397
|
+
class Be extends N {
|
|
2319
2398
|
constructor(t) {
|
|
2320
|
-
super(t), this.mode = "sensor", this.currentCoordinate = 0, this.currentId = void 0, this.currentInitialArcId = void 0, this.currentStartingPointId = void 0, this.keyEvents =
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
const i = { cancel: "Escape", finish: "Enter" };
|
|
2325
|
-
this.keyEvents = t && t.keyEvents ? b({}, i, t.keyEvents) : i;
|
|
2326
|
-
}
|
|
2327
|
-
this.arcPoints = (t == null ? void 0 : t.arcPoints) || 64;
|
|
2399
|
+
super(t, !0), this.mode = "sensor", this.currentCoordinate = 0, this.currentId = void 0, this.currentInitialArcId = void 0, this.currentStartingPointId = void 0, this.keyEvents = Ai, this.direction = void 0, this.arcPoints = 64, this.cursors = Vi, this.mouseMove = !1, this.updateOptions(t);
|
|
2400
|
+
}
|
|
2401
|
+
updateOptions(t) {
|
|
2402
|
+
super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents)), t != null && t.arcPoints && (this.arcPoints = t.arcPoints);
|
|
2328
2403
|
}
|
|
2329
2404
|
close() {
|
|
2330
2405
|
if (this.currentStartingPointId === void 0) return;
|
|
2331
2406
|
const t = this.currentStartingPointId, e = this.currentInitialArcId, i = this.currentId;
|
|
2332
|
-
t && this.store.delete([t]), e && this.store.delete([e]), this.
|
|
2407
|
+
if (t && this.store.delete([t]), e && this.store.delete([e]), this.currentId) {
|
|
2408
|
+
const o = dt(this.store.getGeometryCopy(this.currentId));
|
|
2409
|
+
o && this.store.updateGeometry([{ id: this.currentId, geometry: o }]);
|
|
2410
|
+
}
|
|
2411
|
+
this.currentCoordinate = 0, this.currentStartingPointId = void 0, this.currentInitialArcId = void 0, this.currentId = void 0, this.direction = void 0, this.state === "drawing" && this.setStarted(), i && this.onFinish(i, { mode: this.mode, action: "draw" });
|
|
2333
2412
|
}
|
|
2334
2413
|
start() {
|
|
2335
2414
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -2342,29 +2421,29 @@ class ke extends N {
|
|
|
2342
2421
|
if (this.currentCoordinate === 2) {
|
|
2343
2422
|
const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], r = [t.lng, t.lat], n = x(o[0], o[1]), a = x(r[0], r[1]), l = x(i[0], i[1]), d = O(l, n);
|
|
2344
2423
|
if (this.direction === void 0) {
|
|
2345
|
-
const m =
|
|
2424
|
+
const m = We(l, n, a);
|
|
2346
2425
|
this.direction = m ? "clockwise" : "anticlockwise";
|
|
2347
2426
|
}
|
|
2348
|
-
const
|
|
2427
|
+
const h = T(l, n), c = T(l, a), u = this.arcPoints, p = [o], g = Y(h), y = Y(c);
|
|
2349
2428
|
let v;
|
|
2350
2429
|
this.direction === "anticlockwise" ? (v = y - g, v < 0 && (v += 360)) : (v = g - y, v < 0 && (v += 360));
|
|
2351
2430
|
const f = (this.direction === "anticlockwise" ? 1 : -1) * v / u;
|
|
2352
2431
|
for (let m = 0; m <= u; m++) {
|
|
2353
|
-
const C =
|
|
2354
|
-
|
|
2432
|
+
const C = at(l, d, g + m * f), { lng: P, lat: S } = W(C.x, C.y), M = [F(P, this.coordinatePrecision), F(S, this.coordinatePrecision)];
|
|
2433
|
+
M[0] !== p[p.length - 1][0] && M[1] !== p[p.length - 1][1] && p.push(M);
|
|
2355
2434
|
}
|
|
2356
|
-
this.updateLineStringGeometry(this.currentInitialArcId, p,
|
|
2435
|
+
this.updateLineStringGeometry(this.currentInitialArcId, p, I.Provisional);
|
|
2357
2436
|
} else if (this.currentCoordinate === 3) {
|
|
2358
2437
|
const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates;
|
|
2359
2438
|
if (e.length < 2 || !this.direction) return;
|
|
2360
|
-
const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], r = e[e.length - 1], n = x(t.lng, t.lat), a = x(o[0], o[1]), l = x(r[0], r[1]), d = x(i[0], i[1]),
|
|
2439
|
+
const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], r = e[e.length - 1], n = x(t.lng, t.lat), a = x(o[0], o[1]), l = x(r[0], r[1]), d = x(i[0], i[1]), h = O(d, a), c = O(d, n) < h ? a : n, u = T(d, n), p = T(d, a), g = T(d, l), y = Y(p), v = Y(g), f = Y(u);
|
|
2361
2440
|
if (this.notInSector({ normalizedCursor: f, normalizedStart: y, normalizedEnd: v, direction: this.direction })) return;
|
|
2362
|
-
const m = this.getDeltaBearing(this.direction, y, v), C = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * m / C, S = O(d,
|
|
2441
|
+
const m = this.getDeltaBearing(this.direction, y, v), C = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * m / C, S = O(d, c), M = [];
|
|
2363
2442
|
for (let w = 0; w <= C; w++) {
|
|
2364
|
-
const D =
|
|
2365
|
-
B[0] !== e[e.length - 1][0] && B[1] !== e[e.length - 1][1] &&
|
|
2443
|
+
const D = at(d, S, y + w * P), { lng: G, lat: L } = W(D.x, D.y), B = [F(G, this.coordinatePrecision), F(L, this.coordinatePrecision)];
|
|
2444
|
+
B[0] !== e[e.length - 1][0] && B[1] !== e[e.length - 1][1] && M.unshift(B);
|
|
2366
2445
|
}
|
|
2367
|
-
e.push(...
|
|
2446
|
+
e.push(...M), e.push(e[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, e, I.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [e] }, properties: { mode: this.mode } }]);
|
|
2368
2447
|
}
|
|
2369
2448
|
}
|
|
2370
2449
|
}
|
|
@@ -2408,7 +2487,7 @@ class ke extends N {
|
|
|
2408
2487
|
return t.properties.mode === this.mode && (t.geometry.type === "Polygon" ? (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10) : t.geometry.type === "LineString" ? (e.lineStringColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.lineStringWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.zIndex = 10) : t.geometry.type === "Point" && (e.pointColor = this.getHexColorStylingValue(this.styles.centerPointColor, e.pointColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.centerPointWidth, e.pointWidth, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.centerPointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.centerPointOutlineWidth, e.pointOutlineWidth, t), e.zIndex = 20)), e;
|
|
2409
2488
|
}
|
|
2410
2489
|
validateFeature(t) {
|
|
2411
|
-
return this.validateModeFeature(t, (e) =>
|
|
2490
|
+
return this.validateModeFeature(t, (e) => lt(e, this.coordinatePrecision));
|
|
2412
2491
|
}
|
|
2413
2492
|
getDeltaBearing(t, e, i) {
|
|
2414
2493
|
let o;
|
|
@@ -2418,51 +2497,51 @@ class ke extends N {
|
|
|
2418
2497
|
return o === "clockwise" ? e <= i ? t >= e && t <= i : t >= e || t <= i : e >= i ? t <= e && t >= i : t <= e || t >= i;
|
|
2419
2498
|
}
|
|
2420
2499
|
}
|
|
2421
|
-
class
|
|
2500
|
+
class Ui {
|
|
2422
2501
|
constructor(t) {
|
|
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 = t.adapter, this._mode = new
|
|
2424
|
-
const e = /* @__PURE__ */ new Set(), i = t.modes.reduce((
|
|
2425
|
-
if (e.has(
|
|
2426
|
-
return e.add(
|
|
2502
|
+
this._modes = void 0, this._mode = void 0, this._adapter = void 0, this._enabled = !1, this._store = void 0, this._eventListeners = void 0, this._instanceSelectMode = void 0, this._adapter = t.adapter, this._mode = new Mi();
|
|
2503
|
+
const e = /* @__PURE__ */ new Set(), i = t.modes.reduce((h, c) => {
|
|
2504
|
+
if (e.has(c.mode)) throw new Error(`There is already a ${c.mode} mode provided`);
|
|
2505
|
+
return e.add(c.mode), h[c.mode] = c, h;
|
|
2427
2506
|
}, {}), o = Object.keys(i);
|
|
2428
2507
|
if (o.length === 0) throw new Error("No modes provided");
|
|
2429
|
-
o.forEach((
|
|
2430
|
-
if (i[
|
|
2508
|
+
o.forEach((h) => {
|
|
2509
|
+
if (i[h].type === $.Select) {
|
|
2431
2510
|
if (this._instanceSelectMode) throw new Error("only one type of select mode can be provided");
|
|
2432
|
-
this._instanceSelectMode =
|
|
2511
|
+
this._instanceSelectMode = h;
|
|
2433
2512
|
}
|
|
2434
|
-
}), this._modes = b({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new
|
|
2435
|
-
const r = (
|
|
2436
|
-
const
|
|
2437
|
-
return { changed:
|
|
2438
|
-
}, n = (
|
|
2513
|
+
}), this._modes = b({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new _i({ tracked: !!t.tracked, idStrategy: t.idStrategy ? t.idStrategy : void 0 });
|
|
2514
|
+
const r = (h) => {
|
|
2515
|
+
const c = [], u = this._store.copyAll().filter((p) => !h.includes(p.id) || (c.push(p), !1));
|
|
2516
|
+
return { changed: c, unchanged: u };
|
|
2517
|
+
}, n = (h, c) => {
|
|
2439
2518
|
this._enabled && this._eventListeners.finish.forEach((u) => {
|
|
2440
|
-
u(
|
|
2519
|
+
u(h, c);
|
|
2441
2520
|
});
|
|
2442
|
-
}, a = (
|
|
2521
|
+
}, a = (h, c) => {
|
|
2443
2522
|
if (!this._enabled) return;
|
|
2444
2523
|
this._eventListeners.change.forEach((g) => {
|
|
2445
|
-
g(
|
|
2524
|
+
g(h, c);
|
|
2446
2525
|
});
|
|
2447
|
-
const { changed: u, unchanged: p } = r(
|
|
2448
|
-
|
|
2449
|
-
}, l = (
|
|
2526
|
+
const { changed: u, unchanged: p } = r(h);
|
|
2527
|
+
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());
|
|
2528
|
+
}, l = (h) => {
|
|
2450
2529
|
if (!this._enabled) return;
|
|
2451
2530
|
this._eventListeners.select.forEach((p) => {
|
|
2452
|
-
p(
|
|
2531
|
+
p(h);
|
|
2453
2532
|
});
|
|
2454
|
-
const { changed:
|
|
2455
|
-
this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated:
|
|
2456
|
-
}, d = (
|
|
2533
|
+
const { changed: c, unchanged: u } = r([h]);
|
|
2534
|
+
this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: c }, this.getModeStyles());
|
|
2535
|
+
}, d = (h) => {
|
|
2457
2536
|
if (!this._enabled) return;
|
|
2458
2537
|
this._eventListeners.deselect.forEach((p) => {
|
|
2459
2538
|
p();
|
|
2460
2539
|
});
|
|
2461
|
-
const { changed:
|
|
2462
|
-
|
|
2540
|
+
const { changed: c, unchanged: u } = r([h]);
|
|
2541
|
+
c && this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: c }, this.getModeStyles());
|
|
2463
2542
|
};
|
|
2464
|
-
Object.keys(this._modes).forEach((
|
|
2465
|
-
this._modes[
|
|
2543
|
+
Object.keys(this._modes).forEach((h) => {
|
|
2544
|
+
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: n, coordinatePrecision: this._adapter.getCoordinatePrecision() });
|
|
2466
2545
|
});
|
|
2467
2546
|
}
|
|
2468
2547
|
checkEnabled() {
|
|
@@ -2471,26 +2550,26 @@ class xi {
|
|
|
2471
2550
|
getModeStyles() {
|
|
2472
2551
|
const t = {};
|
|
2473
2552
|
return Object.keys(this._modes).forEach((e) => {
|
|
2474
|
-
t[e] = (i) => this._instanceSelectMode && i.properties[
|
|
2553
|
+
t[e] = (i) => this._instanceSelectMode && i.properties[U.SELECTED] ? this._modes[this._instanceSelectMode].styleFeature.bind(this._modes[this._instanceSelectMode])(i) : this._modes[e].styleFeature.bind(this._modes[e])(i);
|
|
2475
2554
|
}), t;
|
|
2476
2555
|
}
|
|
2477
2556
|
featuresAtLocation({ lng: t, lat: e }, i) {
|
|
2478
|
-
const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, r = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, n = this._adapter.unproject.bind(this._adapter), a = this._adapter.project.bind(this._adapter), l = a(t, e), d =
|
|
2479
|
-
return this._store.search(d).filter((
|
|
2480
|
-
if (r && (
|
|
2481
|
-
if (
|
|
2482
|
-
const
|
|
2557
|
+
const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, r = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, n = this._adapter.unproject.bind(this._adapter), a = this._adapter.project.bind(this._adapter), l = a(t, e), d = Ce({ unproject: n, point: l, pointerDistance: o });
|
|
2558
|
+
return this._store.search(d).filter((h) => {
|
|
2559
|
+
if (r && (h.properties[U.MID_POINT] || h.properties[U.SELECTION_POINT])) return !1;
|
|
2560
|
+
if (h.geometry.type === "Point") {
|
|
2561
|
+
const c = h.geometry.coordinates, u = a(c[0], c[1]);
|
|
2483
2562
|
return O(l, u) < o;
|
|
2484
2563
|
}
|
|
2485
|
-
if (
|
|
2486
|
-
const
|
|
2487
|
-
for (let u = 0; u <
|
|
2488
|
-
const p =
|
|
2489
|
-
if (
|
|
2564
|
+
if (h.geometry.type === "LineString") {
|
|
2565
|
+
const c = h.geometry.coordinates;
|
|
2566
|
+
for (let u = 0; u < c.length - 1; u++) {
|
|
2567
|
+
const p = c[u], g = c[u + 1];
|
|
2568
|
+
if (Oe(l, a(p[0], p[1]), a(g[0], g[1])) < o) return !0;
|
|
2490
2569
|
}
|
|
2491
2570
|
return !1;
|
|
2492
2571
|
}
|
|
2493
|
-
return !!
|
|
2572
|
+
return !!Ee([t, e], h.geometry.coordinates) || void 0;
|
|
2494
2573
|
});
|
|
2495
2574
|
}
|
|
2496
2575
|
getSelectMode() {
|
|
@@ -2501,9 +2580,16 @@ class xi {
|
|
|
2501
2580
|
if (this.checkEnabled(), !this._modes[t]) throw new Error("No mode with this name present");
|
|
2502
2581
|
this._modes[t].styles = e;
|
|
2503
2582
|
}
|
|
2583
|
+
updateModeOptions(t, e) {
|
|
2584
|
+
if (this.checkEnabled(), !this._modes[t]) throw new Error("No mode with this name present");
|
|
2585
|
+
this._modes[t].updateOptions(e);
|
|
2586
|
+
}
|
|
2504
2587
|
getSnapshot() {
|
|
2505
2588
|
return this._store.copyAll();
|
|
2506
2589
|
}
|
|
2590
|
+
getSnapshotFeature(t) {
|
|
2591
|
+
if (this._store.has(t)) return this._store.copy(t);
|
|
2592
|
+
}
|
|
2507
2593
|
clear() {
|
|
2508
2594
|
this.checkEnabled(), this._adapter.clear();
|
|
2509
2595
|
}
|
|
@@ -2591,15 +2677,15 @@ class xi {
|
|
|
2591
2677
|
i.includes(e) && i.splice(i.indexOf(e), 1);
|
|
2592
2678
|
}
|
|
2593
2679
|
}
|
|
2594
|
-
var
|
|
2595
|
-
function
|
|
2680
|
+
var te, Et, ee;
|
|
2681
|
+
function ie(s, t = 9) {
|
|
2596
2682
|
const e = Math.pow(10, t);
|
|
2597
2683
|
return Math.round(s * e) / e;
|
|
2598
2684
|
}
|
|
2599
|
-
(
|
|
2685
|
+
(Et = te || (te = {})).Commit = "commit", Et.Provisional = "provisional", Et.Finish = "finish", function(s) {
|
|
2600
2686
|
s.Drawing = "drawing", s.Select = "select", s.Static = "static", s.Render = "render";
|
|
2601
|
-
}(
|
|
2602
|
-
class
|
|
2687
|
+
}(ee || (ee = {}));
|
|
2688
|
+
class q {
|
|
2603
2689
|
constructor({ name: t, callback: e, unregister: i, register: o }) {
|
|
2604
2690
|
this.name = void 0, this.callback = void 0, this.registered = !1, this.register = void 0, this.unregister = void 0, this.name = t, this.register = () => {
|
|
2605
2691
|
this.registered || (this.registered = !0, o(e));
|
|
@@ -2608,7 +2694,7 @@ class H {
|
|
|
2608
2694
|
}, this.callback = e;
|
|
2609
2695
|
}
|
|
2610
2696
|
}
|
|
2611
|
-
var
|
|
2697
|
+
var zi = class {
|
|
2612
2698
|
constructor(s) {
|
|
2613
2699
|
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 s.minPixelDragDistance == "number" ? s.minPixelDragDistance : 1, this._minPixelDragDistanceSelecting = typeof s.minPixelDragDistanceSelecting == "number" ? s.minPixelDragDistanceSelecting : 1, this._minPixelDragDistanceDrawing = typeof s.minPixelDragDistanceDrawing == "number" ? s.minPixelDragDistanceDrawing : 8, this._coordinatePrecision = typeof s.coordinatePrecision == "number" ? s.coordinatePrecision : 9;
|
|
2614
2700
|
}
|
|
@@ -2623,7 +2709,7 @@ var bi = class {
|
|
|
2623
2709
|
const t = this.getLngLatFromEvent(s);
|
|
2624
2710
|
if (!t) return null;
|
|
2625
2711
|
const { lng: e, lat: i } = t, { containerX: o, containerY: r } = this.getMapElementXYPosition(s), n = this.getButton(s), a = Array.from(this._heldKeys);
|
|
2626
|
-
return { lng:
|
|
2712
|
+
return { lng: ie(e, this._coordinatePrecision), lat: ie(i, this._coordinatePrecision), containerX: o, containerY: r, button: n, heldKeys: a };
|
|
2627
2713
|
}
|
|
2628
2714
|
register(s) {
|
|
2629
2715
|
this._currentModeCallbacks = s, this._listeners = this.getAdapterListeners(), this._listeners.forEach((t) => {
|
|
@@ -2634,7 +2720,7 @@ var bi = class {
|
|
|
2634
2720
|
return this._coordinatePrecision;
|
|
2635
2721
|
}
|
|
2636
2722
|
getAdapterListeners() {
|
|
2637
|
-
return [new
|
|
2723
|
+
return [new q({ name: "pointerdown", callback: (s) => {
|
|
2638
2724
|
if (!this._currentModeCallbacks || !s.isPrimary) return;
|
|
2639
2725
|
const t = this.getDrawEventFromEvent(s);
|
|
2640
2726
|
t && (this._dragState = "pre-dragging", this._lastDrawEvent = t);
|
|
@@ -2642,7 +2728,7 @@ var bi = class {
|
|
|
2642
2728
|
this.getMapEventElement().addEventListener("pointerdown", s);
|
|
2643
2729
|
}, unregister: (s) => {
|
|
2644
2730
|
this.getMapEventElement().removeEventListener("pointerdown", s);
|
|
2645
|
-
} }), new
|
|
2731
|
+
} }), new q({ name: "pointermove", callback: (s) => {
|
|
2646
2732
|
if (!this._currentModeCallbacks || !s.isPrimary) return;
|
|
2647
2733
|
s.preventDefault();
|
|
2648
2734
|
const t = this.getDrawEventFromEvent(s);
|
|
@@ -2650,7 +2736,7 @@ var bi = class {
|
|
|
2650
2736
|
else if (this._dragState === "pre-dragging") {
|
|
2651
2737
|
if (!this._lastDrawEvent) return;
|
|
2652
2738
|
const e = { x: this._lastDrawEvent.containerX, y: this._lastDrawEvent.containerY }, i = { x: t.containerX, y: t.containerY }, o = this._currentModeCallbacks.getState(), r = ((a, l) => {
|
|
2653
|
-
const { x: d, y:
|
|
2739
|
+
const { x: d, y: h } = a, { x: c, y: u } = l, p = c - d, g = u - h;
|
|
2654
2740
|
return Math.sqrt(g * g + p * p);
|
|
2655
2741
|
})(e, i);
|
|
2656
2742
|
let n = !1;
|
|
@@ -2665,13 +2751,13 @@ var bi = class {
|
|
|
2665
2751
|
this.getMapEventElement().addEventListener("pointermove", s);
|
|
2666
2752
|
}, unregister: (s) => {
|
|
2667
2753
|
this.getMapEventElement().removeEventListener("pointermove", s);
|
|
2668
|
-
} }), new
|
|
2754
|
+
} }), new q({ name: "contextmenu", callback: (s) => {
|
|
2669
2755
|
this._currentModeCallbacks && s.preventDefault();
|
|
2670
2756
|
}, register: (s) => {
|
|
2671
2757
|
this.getMapEventElement().addEventListener("contextmenu", s);
|
|
2672
2758
|
}, unregister: (s) => {
|
|
2673
2759
|
this.getMapEventElement().removeEventListener("contextmenu", s);
|
|
2674
|
-
} }), new
|
|
2760
|
+
} }), new q({ name: "pointerup", callback: (s) => {
|
|
2675
2761
|
if (!this._currentModeCallbacks || s.target !== this.getMapEventElement() || !s.isPrimary) return;
|
|
2676
2762
|
const t = this.getDrawEventFromEvent(s);
|
|
2677
2763
|
t && (this._dragState === "dragging" ? this._currentModeCallbacks.onDragEnd(t, (e) => {
|
|
@@ -2681,13 +2767,13 @@ var bi = class {
|
|
|
2681
2767
|
this.getMapEventElement().addEventListener("pointerup", s);
|
|
2682
2768
|
}, unregister: (s) => {
|
|
2683
2769
|
this.getMapEventElement().removeEventListener("pointerup", s);
|
|
2684
|
-
} }), new
|
|
2770
|
+
} }), new q({ name: "keyup", callback: (s) => {
|
|
2685
2771
|
this._currentModeCallbacks && (this._heldKeys.delete(s.key), this._currentModeCallbacks.onKeyUp({ key: s.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => s.preventDefault() }));
|
|
2686
2772
|
}, register: (s) => {
|
|
2687
2773
|
this.getMapEventElement().addEventListener("keyup", s);
|
|
2688
2774
|
}, unregister: (s) => {
|
|
2689
2775
|
this.getMapEventElement().removeEventListener("keyup", s);
|
|
2690
|
-
} }), new
|
|
2776
|
+
} }), new q({ name: "keydown", callback: (s) => {
|
|
2691
2777
|
this._currentModeCallbacks && (this._heldKeys.add(s.key), this._currentModeCallbacks.onKeyDown({ key: s.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => s.preventDefault() }));
|
|
2692
2778
|
}, register: (s) => {
|
|
2693
2779
|
this.getMapEventElement().addEventListener("keydown", s);
|
|
@@ -2701,7 +2787,7 @@ var bi = class {
|
|
|
2701
2787
|
}), this.clear();
|
|
2702
2788
|
}
|
|
2703
2789
|
};
|
|
2704
|
-
class
|
|
2790
|
+
class Ri extends zi {
|
|
2705
2791
|
constructor(t) {
|
|
2706
2792
|
super(t), this._nextRender = void 0, this._map = void 0, this._container = void 0, this._rendered = !1, this.changedIds = { deletion: !1, points: !1, linestrings: !1, polygons: !1, styling: !1 }, this._map = t.map, this._container = this._map.getContainer();
|
|
2707
2793
|
}
|
|
@@ -2771,13 +2857,13 @@ class Ii extends bi {
|
|
|
2771
2857
|
this.updateChangedIds(t), this._nextRender && cancelAnimationFrame(this._nextRender), this._nextRender = requestAnimationFrame(() => {
|
|
2772
2858
|
const i = [...t.created, ...t.updated, ...t.unchanged], o = [], r = [], n = [];
|
|
2773
2859
|
for (let a = 0; a < i.length; a++) {
|
|
2774
|
-
const l = i[a], { properties: d } = l,
|
|
2775
|
-
l.geometry.type === "Point" ? (d.pointColor =
|
|
2860
|
+
const l = i[a], { properties: d } = l, h = e[d.mode](l);
|
|
2861
|
+
l.geometry.type === "Point" ? (d.pointColor = h.pointColor, d.pointOutlineColor = h.pointOutlineColor, d.pointOutlineWidth = h.pointOutlineWidth, d.pointWidth = h.pointWidth, o.push(l)) : l.geometry.type === "LineString" ? (d.lineStringColor = h.lineStringColor, d.lineStringWidth = h.lineStringWidth, r.push(l)) : l.geometry.type === "Polygon" && (d.polygonFillColor = h.polygonFillColor, d.polygonFillOpacity = h.polygonFillOpacity, d.polygonOutlineColor = h.polygonOutlineColor, d.polygonOutlineWidth = h.polygonOutlineWidth, n.push(l));
|
|
2776
2862
|
}
|
|
2777
2863
|
if (this._rendered) {
|
|
2778
2864
|
const a = this.changedIds.deletion || this.changedIds.styling, l = a || this.changedIds.linestrings, d = a || this.changedIds.polygons;
|
|
2779
|
-
let
|
|
2780
|
-
(a || this.changedIds.points) && (
|
|
2865
|
+
let h;
|
|
2866
|
+
(a || this.changedIds.points) && (h = this._setGeoJSONLayerData("Point", o)), l && this._setGeoJSONLayerData("LineString", r), d && this._setGeoJSONLayerData("Polygon", n), h && this._map.moveLayer(h);
|
|
2781
2867
|
} else {
|
|
2782
2868
|
const a = this._addGeoJSONLayer("Point", o);
|
|
2783
2869
|
this._addGeoJSONLayer("LineString", r), this._addGeoJSONLayer("Polygon", n), this._rendered = !0, a && this._map.moveLayer(a);
|
|
@@ -2799,7 +2885,7 @@ class Ii extends bi {
|
|
|
2799
2885
|
super.register(t), (e = this._currentModeCallbacks) != null && e.onReady && this._currentModeCallbacks.onReady();
|
|
2800
2886
|
}
|
|
2801
2887
|
}
|
|
2802
|
-
const
|
|
2888
|
+
const Lo = [
|
|
2803
2889
|
"render",
|
|
2804
2890
|
"point",
|
|
2805
2891
|
"linestring",
|
|
@@ -2814,7 +2900,7 @@ const ho = [
|
|
|
2814
2900
|
"delete-selection",
|
|
2815
2901
|
"delete",
|
|
2816
2902
|
"download"
|
|
2817
|
-
],
|
|
2903
|
+
], Xi = {
|
|
2818
2904
|
modes: [
|
|
2819
2905
|
"render",
|
|
2820
2906
|
"point",
|
|
@@ -2832,7 +2918,7 @@ const ho = [
|
|
|
2832
2918
|
"download"
|
|
2833
2919
|
],
|
|
2834
2920
|
open: !1
|
|
2835
|
-
},
|
|
2921
|
+
}, yt = {
|
|
2836
2922
|
modes: [
|
|
2837
2923
|
"render",
|
|
2838
2924
|
"point",
|
|
@@ -2852,7 +2938,8 @@ const ho = [
|
|
|
2852
2938
|
open: !1,
|
|
2853
2939
|
// see styling parameters of Terra Draw at https://github.com/JamesLMilner/terra-draw/blob/main/guides/5.STYLING.md
|
|
2854
2940
|
modeOptions: {
|
|
2855
|
-
point: new
|
|
2941
|
+
point: new be({
|
|
2942
|
+
editable: !0,
|
|
2856
2943
|
styles: {
|
|
2857
2944
|
pointColor: "#FFFFFF",
|
|
2858
2945
|
pointWidth: 5,
|
|
@@ -2860,7 +2947,8 @@ const ho = [
|
|
|
2860
2947
|
pointOutlineWidth: 1
|
|
2861
2948
|
}
|
|
2862
2949
|
}),
|
|
2863
|
-
linestring: new
|
|
2950
|
+
linestring: new xe({
|
|
2951
|
+
editable: !0,
|
|
2864
2952
|
styles: {
|
|
2865
2953
|
lineStringColor: "#232E3D",
|
|
2866
2954
|
lineStringWidth: 2,
|
|
@@ -2870,7 +2958,8 @@ const ho = [
|
|
|
2870
2958
|
closingPointOutlineWidth: 1
|
|
2871
2959
|
}
|
|
2872
2960
|
}),
|
|
2873
|
-
polygon: new
|
|
2961
|
+
polygon: new Me({
|
|
2962
|
+
editable: !0,
|
|
2874
2963
|
styles: {
|
|
2875
2964
|
fillColor: "#EDEFF0",
|
|
2876
2965
|
fillOpacity: 0.7,
|
|
@@ -2882,7 +2971,7 @@ const ho = [
|
|
|
2882
2971
|
closingPointOutlineWidth: 1
|
|
2883
2972
|
}
|
|
2884
2973
|
}),
|
|
2885
|
-
rectangle: new
|
|
2974
|
+
rectangle: new we({
|
|
2886
2975
|
styles: {
|
|
2887
2976
|
fillColor: "#EDEFF0",
|
|
2888
2977
|
fillOpacity: 0.7,
|
|
@@ -2890,7 +2979,7 @@ const ho = [
|
|
|
2890
2979
|
outlineWidth: 2
|
|
2891
2980
|
}
|
|
2892
2981
|
}),
|
|
2893
|
-
"angled-rectangle": new
|
|
2982
|
+
"angled-rectangle": new ke({
|
|
2894
2983
|
styles: {
|
|
2895
2984
|
fillColor: "#EDEFF0",
|
|
2896
2985
|
fillOpacity: 0.7,
|
|
@@ -2898,7 +2987,7 @@ const ho = [
|
|
|
2898
2987
|
outlineWidth: 2
|
|
2899
2988
|
}
|
|
2900
2989
|
}),
|
|
2901
|
-
circle: new
|
|
2990
|
+
circle: new me({
|
|
2902
2991
|
styles: {
|
|
2903
2992
|
fillColor: "#EDEFF0",
|
|
2904
2993
|
fillOpacity: 0.7,
|
|
@@ -2906,7 +2995,7 @@ const ho = [
|
|
|
2906
2995
|
outlineWidth: 2
|
|
2907
2996
|
}
|
|
2908
2997
|
}),
|
|
2909
|
-
freehand: new
|
|
2998
|
+
freehand: new ve({
|
|
2910
2999
|
styles: {
|
|
2911
3000
|
fillColor: "#EDEFF0",
|
|
2912
3001
|
fillOpacity: 0.7,
|
|
@@ -2918,7 +3007,7 @@ const ho = [
|
|
|
2918
3007
|
closingPointOutlineWidth: 1
|
|
2919
3008
|
}
|
|
2920
3009
|
}),
|
|
2921
|
-
sensor: new
|
|
3010
|
+
sensor: new Be({
|
|
2922
3011
|
styles: {
|
|
2923
3012
|
fillColor: "#EDEFF0",
|
|
2924
3013
|
fillOpacity: 0.7,
|
|
@@ -2930,7 +3019,7 @@ const ho = [
|
|
|
2930
3019
|
centerPointOutlineWidth: 1
|
|
2931
3020
|
}
|
|
2932
3021
|
}),
|
|
2933
|
-
sector: new
|
|
3022
|
+
sector: new je({
|
|
2934
3023
|
styles: {
|
|
2935
3024
|
fillColor: "#EDEFF0",
|
|
2936
3025
|
fillOpacity: 0.7,
|
|
@@ -2938,7 +3027,7 @@ const ho = [
|
|
|
2938
3027
|
outlineWidth: 2
|
|
2939
3028
|
}
|
|
2940
3029
|
}),
|
|
2941
|
-
select: new
|
|
3030
|
+
select: new Le({
|
|
2942
3031
|
flags: {
|
|
2943
3032
|
point: {
|
|
2944
3033
|
feature: {
|
|
@@ -3192,28 +3281,33 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3192
3281
|
distancePrecision: 2,
|
|
3193
3282
|
areaUnit: "metric",
|
|
3194
3283
|
areaPrecision: 2
|
|
3195
|
-
},
|
|
3284
|
+
}, Ki = () => ({
|
|
3196
3285
|
render: new et({
|
|
3197
3286
|
modeName: "render",
|
|
3198
3287
|
styles: {}
|
|
3199
3288
|
}),
|
|
3200
|
-
point: new
|
|
3201
|
-
|
|
3202
|
-
|
|
3289
|
+
point: new be({
|
|
3290
|
+
editable: !0
|
|
3291
|
+
}),
|
|
3292
|
+
linestring: new xe({
|
|
3293
|
+
editable: !0
|
|
3294
|
+
}),
|
|
3295
|
+
polygon: new Me({
|
|
3296
|
+
editable: !0,
|
|
3203
3297
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3204
3298
|
// @ts-ignore
|
|
3205
3299
|
validation: (t, e) => {
|
|
3206
3300
|
const i = e.updateType;
|
|
3207
|
-
return i === "finish" || i === "commit" ?
|
|
3301
|
+
return i === "finish" || i === "commit" ? ji(t) : { valid: !0 };
|
|
3208
3302
|
}
|
|
3209
3303
|
}),
|
|
3210
|
-
rectangle: new
|
|
3211
|
-
"angled-rectangle": new
|
|
3212
|
-
circle: new
|
|
3213
|
-
freehand: new
|
|
3214
|
-
sensor: new
|
|
3215
|
-
sector: new
|
|
3216
|
-
select: new
|
|
3304
|
+
rectangle: new we(),
|
|
3305
|
+
"angled-rectangle": new ke(),
|
|
3306
|
+
circle: new me(),
|
|
3307
|
+
freehand: new ve(),
|
|
3308
|
+
sensor: new Be(),
|
|
3309
|
+
sector: new je(),
|
|
3310
|
+
select: new Le({
|
|
3217
3311
|
flags: {
|
|
3218
3312
|
point: {
|
|
3219
3313
|
feature: {
|
|
@@ -3327,7 +3421,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3327
3421
|
styles: {}
|
|
3328
3422
|
})
|
|
3329
3423
|
});
|
|
3330
|
-
var _ = 63710088e-1,
|
|
3424
|
+
var _ = 63710088e-1, Yi = {
|
|
3331
3425
|
centimeters: _ * 100,
|
|
3332
3426
|
centimetres: _ * 100,
|
|
3333
3427
|
degrees: 360 / (2 * Math.PI),
|
|
@@ -3344,87 +3438,87 @@ var _ = 63710088e-1, Fi = {
|
|
|
3344
3438
|
radians: 1,
|
|
3345
3439
|
yards: _ * 1.0936
|
|
3346
3440
|
};
|
|
3347
|
-
function
|
|
3441
|
+
function $i(s, t, e = {}) {
|
|
3348
3442
|
const i = { type: "Feature" };
|
|
3349
3443
|
return (e.id === 0 || e.id) && (i.id = e.id), e.bbox && (i.bbox = e.bbox), i.properties = t || {}, i.geometry = s, i;
|
|
3350
3444
|
}
|
|
3351
|
-
function
|
|
3445
|
+
function Hi(s, t, e = {}) {
|
|
3352
3446
|
if (!s)
|
|
3353
3447
|
throw new Error("coordinates is required");
|
|
3354
3448
|
if (!Array.isArray(s))
|
|
3355
3449
|
throw new Error("coordinates must be an Array");
|
|
3356
3450
|
if (s.length < 2)
|
|
3357
3451
|
throw new Error("coordinates must be at least 2 numbers long");
|
|
3358
|
-
if (!
|
|
3452
|
+
if (!oe(s[0]) || !oe(s[1]))
|
|
3359
3453
|
throw new Error("coordinates must contain numbers");
|
|
3360
|
-
return
|
|
3454
|
+
return $i({
|
|
3361
3455
|
type: "Point",
|
|
3362
3456
|
coordinates: s
|
|
3363
3457
|
}, t, e);
|
|
3364
3458
|
}
|
|
3365
|
-
function
|
|
3366
|
-
const e =
|
|
3459
|
+
function qi(s, t = "kilometers") {
|
|
3460
|
+
const e = Yi[t];
|
|
3367
3461
|
if (!e)
|
|
3368
3462
|
throw new Error(t + " units is invalid");
|
|
3369
3463
|
return s * e;
|
|
3370
3464
|
}
|
|
3371
|
-
function
|
|
3465
|
+
function gt(s) {
|
|
3372
3466
|
return s % 360 * Math.PI / 180;
|
|
3373
3467
|
}
|
|
3374
|
-
function
|
|
3468
|
+
function oe(s) {
|
|
3375
3469
|
return !isNaN(s) && s !== null && !Array.isArray(s);
|
|
3376
3470
|
}
|
|
3377
|
-
function
|
|
3471
|
+
function Ne(s, t, e) {
|
|
3378
3472
|
if (s !== null)
|
|
3379
|
-
for (var i, o, r, n, a, l, d,
|
|
3473
|
+
for (var i, o, r, n, a, l, d, h = 0, c = 0, u, p = s.type, g = p === "FeatureCollection", y = p === "Feature", v = g ? s.features.length : 1, f = 0; f < v; f++) {
|
|
3380
3474
|
d = g ? s.features[f].geometry : y ? s.geometry : s, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
|
|
3381
3475
|
for (var m = 0; m < a; m++) {
|
|
3382
3476
|
var C = 0, P = 0;
|
|
3383
3477
|
if (n = u ? d.geometries[m] : d, n !== null) {
|
|
3384
3478
|
l = n.coordinates;
|
|
3385
3479
|
var S = n.type;
|
|
3386
|
-
switch (
|
|
3480
|
+
switch (h = S === "Polygon" || S === "MultiPolygon" ? 1 : 0, S) {
|
|
3387
3481
|
case null:
|
|
3388
3482
|
break;
|
|
3389
3483
|
case "Point":
|
|
3390
3484
|
if (t(
|
|
3391
3485
|
l,
|
|
3392
|
-
|
|
3486
|
+
c,
|
|
3393
3487
|
f,
|
|
3394
3488
|
C,
|
|
3395
3489
|
P
|
|
3396
3490
|
) === !1)
|
|
3397
3491
|
return !1;
|
|
3398
|
-
|
|
3492
|
+
c++, C++;
|
|
3399
3493
|
break;
|
|
3400
3494
|
case "LineString":
|
|
3401
3495
|
case "MultiPoint":
|
|
3402
3496
|
for (i = 0; i < l.length; i++) {
|
|
3403
3497
|
if (t(
|
|
3404
3498
|
l[i],
|
|
3405
|
-
|
|
3499
|
+
c,
|
|
3406
3500
|
f,
|
|
3407
3501
|
C,
|
|
3408
3502
|
P
|
|
3409
3503
|
) === !1)
|
|
3410
3504
|
return !1;
|
|
3411
|
-
|
|
3505
|
+
c++, S === "MultiPoint" && C++;
|
|
3412
3506
|
}
|
|
3413
3507
|
S === "LineString" && C++;
|
|
3414
3508
|
break;
|
|
3415
3509
|
case "Polygon":
|
|
3416
3510
|
case "MultiLineString":
|
|
3417
3511
|
for (i = 0; i < l.length; i++) {
|
|
3418
|
-
for (o = 0; o < l[i].length -
|
|
3512
|
+
for (o = 0; o < l[i].length - h; o++) {
|
|
3419
3513
|
if (t(
|
|
3420
3514
|
l[i][o],
|
|
3421
|
-
|
|
3515
|
+
c,
|
|
3422
3516
|
f,
|
|
3423
3517
|
C,
|
|
3424
3518
|
P
|
|
3425
3519
|
) === !1)
|
|
3426
3520
|
return !1;
|
|
3427
|
-
|
|
3521
|
+
c++;
|
|
3428
3522
|
}
|
|
3429
3523
|
S === "MultiLineString" && C++, S === "Polygon" && P++;
|
|
3430
3524
|
}
|
|
@@ -3433,16 +3527,16 @@ function We(s, t, e) {
|
|
|
3433
3527
|
case "MultiPolygon":
|
|
3434
3528
|
for (i = 0; i < l.length; i++) {
|
|
3435
3529
|
for (P = 0, o = 0; o < l[i].length; o++) {
|
|
3436
|
-
for (r = 0; r < l[i][o].length -
|
|
3530
|
+
for (r = 0; r < l[i][o].length - h; r++) {
|
|
3437
3531
|
if (t(
|
|
3438
3532
|
l[i][o][r],
|
|
3439
|
-
|
|
3533
|
+
c,
|
|
3440
3534
|
f,
|
|
3441
3535
|
C,
|
|
3442
3536
|
P
|
|
3443
3537
|
) === !1)
|
|
3444
3538
|
return !1;
|
|
3445
|
-
|
|
3539
|
+
c++;
|
|
3446
3540
|
}
|
|
3447
3541
|
P++;
|
|
3448
3542
|
}
|
|
@@ -3451,7 +3545,7 @@ function We(s, t, e) {
|
|
|
3451
3545
|
break;
|
|
3452
3546
|
case "GeometryCollection":
|
|
3453
3547
|
for (i = 0; i < n.geometries.length; i++)
|
|
3454
|
-
if (
|
|
3548
|
+
if (Ne(n.geometries[i], t) === !1)
|
|
3455
3549
|
return !1;
|
|
3456
3550
|
break;
|
|
3457
3551
|
default:
|
|
@@ -3461,17 +3555,17 @@ function We(s, t, e) {
|
|
|
3461
3555
|
}
|
|
3462
3556
|
}
|
|
3463
3557
|
}
|
|
3464
|
-
function
|
|
3465
|
-
var e, i, o, r, n, a, l, d,
|
|
3558
|
+
function Ji(s, t) {
|
|
3559
|
+
var e, i, o, r, n, a, l, d, h, c, u = 0, p = s.type === "FeatureCollection", g = s.type === "Feature", y = p ? s.features.length : 1;
|
|
3466
3560
|
for (e = 0; e < y; e++) {
|
|
3467
|
-
for (a = p ? s.features[e].geometry : g ? s.geometry : s, d = p ? s.features[e].properties : g ? s.properties : {},
|
|
3561
|
+
for (a = p ? s.features[e].geometry : g ? s.geometry : s, d = p ? s.features[e].properties : g ? s.properties : {}, h = p ? s.features[e].bbox : g ? s.bbox : void 0, c = p ? s.features[e].id : g ? s.id : void 0, l = a ? a.type === "GeometryCollection" : !1, n = l ? a.geometries.length : 1, o = 0; o < n; o++) {
|
|
3468
3562
|
if (r = l ? a.geometries[o] : a, r === null) {
|
|
3469
3563
|
if (t(
|
|
3470
3564
|
null,
|
|
3471
3565
|
u,
|
|
3472
3566
|
d,
|
|
3473
|
-
|
|
3474
|
-
|
|
3567
|
+
h,
|
|
3568
|
+
c
|
|
3475
3569
|
) === !1)
|
|
3476
3570
|
return !1;
|
|
3477
3571
|
continue;
|
|
@@ -3487,8 +3581,8 @@ function Li(s, t) {
|
|
|
3487
3581
|
r,
|
|
3488
3582
|
u,
|
|
3489
3583
|
d,
|
|
3490
|
-
|
|
3491
|
-
|
|
3584
|
+
h,
|
|
3585
|
+
c
|
|
3492
3586
|
) === !1)
|
|
3493
3587
|
return !1;
|
|
3494
3588
|
break;
|
|
@@ -3499,8 +3593,8 @@ function Li(s, t) {
|
|
|
3499
3593
|
r.geometries[i],
|
|
3500
3594
|
u,
|
|
3501
3595
|
d,
|
|
3502
|
-
|
|
3503
|
-
|
|
3596
|
+
h,
|
|
3597
|
+
c
|
|
3504
3598
|
) === !1)
|
|
3505
3599
|
return !1;
|
|
3506
3600
|
break;
|
|
@@ -3512,9 +3606,9 @@ function Li(s, t) {
|
|
|
3512
3606
|
u++;
|
|
3513
3607
|
}
|
|
3514
3608
|
}
|
|
3515
|
-
function
|
|
3609
|
+
function Zi(s, t, e) {
|
|
3516
3610
|
var i = e;
|
|
3517
|
-
return
|
|
3611
|
+
return Ji(
|
|
3518
3612
|
s,
|
|
3519
3613
|
function(o, r, n, a, l) {
|
|
3520
3614
|
r === 0 && e === void 0 ? i = o : i = t(
|
|
@@ -3528,21 +3622,21 @@ function _i(s, t, e) {
|
|
|
3528
3622
|
}
|
|
3529
3623
|
), i;
|
|
3530
3624
|
}
|
|
3531
|
-
function
|
|
3532
|
-
return
|
|
3625
|
+
function Qi(s) {
|
|
3626
|
+
return Zi(
|
|
3533
3627
|
s,
|
|
3534
|
-
(t, e) => t +
|
|
3628
|
+
(t, e) => t + to(e),
|
|
3535
3629
|
0
|
|
3536
3630
|
);
|
|
3537
3631
|
}
|
|
3538
|
-
function
|
|
3632
|
+
function to(s) {
|
|
3539
3633
|
let t = 0, e;
|
|
3540
3634
|
switch (s.type) {
|
|
3541
3635
|
case "Polygon":
|
|
3542
|
-
return
|
|
3636
|
+
return se(s.coordinates);
|
|
3543
3637
|
case "MultiPolygon":
|
|
3544
3638
|
for (e = 0; e < s.coordinates.length; e++)
|
|
3545
|
-
t +=
|
|
3639
|
+
t += se(s.coordinates[e]);
|
|
3546
3640
|
return t;
|
|
3547
3641
|
case "Point":
|
|
3548
3642
|
case "MultiPoint":
|
|
@@ -3552,36 +3646,36 @@ function Wi(s) {
|
|
|
3552
3646
|
}
|
|
3553
3647
|
return 0;
|
|
3554
3648
|
}
|
|
3555
|
-
function
|
|
3649
|
+
function se(s) {
|
|
3556
3650
|
let t = 0;
|
|
3557
3651
|
if (s && s.length > 0) {
|
|
3558
|
-
t += Math.abs(
|
|
3652
|
+
t += Math.abs(re(s[0]));
|
|
3559
3653
|
for (let e = 1; e < s.length; e++)
|
|
3560
|
-
t -= Math.abs(
|
|
3654
|
+
t -= Math.abs(re(s[e]));
|
|
3561
3655
|
}
|
|
3562
3656
|
return t;
|
|
3563
3657
|
}
|
|
3564
|
-
var
|
|
3565
|
-
function
|
|
3658
|
+
var eo = _ * _ / 2, Ot = Math.PI / 180;
|
|
3659
|
+
function re(s) {
|
|
3566
3660
|
const t = s.length - 1;
|
|
3567
3661
|
if (t <= 2) return 0;
|
|
3568
3662
|
let e = 0, i = 0;
|
|
3569
3663
|
for (; i < t; ) {
|
|
3570
|
-
const o = s[i], r = s[i + 1 === t ? 0 : i + 1], n = s[i + 2 >= t ? (i + 2) % t : i + 2], a = o[0] *
|
|
3664
|
+
const o = s[i], r = s[i + 1 === t ? 0 : i + 1], n = s[i + 2 >= t ? (i + 2) % t : i + 2], a = o[0] * Ot, l = r[1] * Ot, d = n[0] * Ot;
|
|
3571
3665
|
e += (d - a) * Math.sin(l), i++;
|
|
3572
3666
|
}
|
|
3573
|
-
return e *
|
|
3667
|
+
return e * eo;
|
|
3574
3668
|
}
|
|
3575
|
-
var
|
|
3576
|
-
const
|
|
3669
|
+
var io = Qi;
|
|
3670
|
+
const oo = (s, t) => {
|
|
3577
3671
|
let e = s, i = "m²";
|
|
3578
3672
|
return t === "metric" ? s >= 1e6 ? (e = s / 1e6, i = "km²") : s >= 1e4 && (e = s / 1e4, i = "ha") : s >= 258998811e-2 ? (e = s / 258998811e-2, i = "mi²") : s >= 4046.856 ? (e = s / 4046.856, i = "acre") : s >= 0.83612736 && (e = s / 0.83612736, i = "yd²"), { area: e, unit: i };
|
|
3579
|
-
},
|
|
3673
|
+
}, ne = (s, t, e) => {
|
|
3580
3674
|
if (s.geometry.type !== "Polygon") return s;
|
|
3581
|
-
const i =
|
|
3675
|
+
const i = io(s.geometry), o = oo(i, t);
|
|
3582
3676
|
return o.area = parseFloat(o.area.toFixed(e)), s.properties.area = o.area, s.properties.unit = o.unit, s;
|
|
3583
3677
|
};
|
|
3584
|
-
function
|
|
3678
|
+
function ae(s) {
|
|
3585
3679
|
if (!s)
|
|
3586
3680
|
throw new Error("coord is required");
|
|
3587
3681
|
if (!Array.isArray(s)) {
|
|
@@ -3594,52 +3688,52 @@ function se(s) {
|
|
|
3594
3688
|
return [...s];
|
|
3595
3689
|
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
3596
3690
|
}
|
|
3597
|
-
function
|
|
3598
|
-
var i =
|
|
3599
|
-
return
|
|
3691
|
+
function so(s, t, e = {}) {
|
|
3692
|
+
var i = ae(s), o = ae(t), r = gt(o[1] - i[1]), n = gt(o[0] - i[0]), a = gt(i[1]), l = gt(o[1]), d = Math.pow(Math.sin(r / 2), 2) + Math.pow(Math.sin(n / 2), 2) * Math.cos(a) * Math.cos(l);
|
|
3693
|
+
return qi(
|
|
3600
3694
|
2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
|
|
3601
3695
|
e.units
|
|
3602
3696
|
);
|
|
3603
3697
|
}
|
|
3604
|
-
var
|
|
3605
|
-
const
|
|
3698
|
+
var ro = so;
|
|
3699
|
+
const no = (s) => s === "degrees" ? "°" : s === "miles" ? "mi" : s === "radians" ? "rad" : "km", le = (s, t, e, i, o, r) => {
|
|
3606
3700
|
if (s.geometry.type !== "LineString") return s;
|
|
3607
3701
|
const n = s.geometry.coordinates;
|
|
3608
3702
|
let a = 0;
|
|
3609
3703
|
const l = [];
|
|
3610
3704
|
for (let d = 0; d < n.length - 1; d++) {
|
|
3611
|
-
const
|
|
3705
|
+
const h = n[d], c = n[d + 1], u = ro(h, c, { units: t });
|
|
3612
3706
|
a += u;
|
|
3613
3707
|
const p = JSON.parse(JSON.stringify(s));
|
|
3614
|
-
if (p.id = `${p.id}-${d}`, p.geometry.coordinates = [
|
|
3615
|
-
const g = i == null ? void 0 : i.queryTerrainElevation(
|
|
3708
|
+
if (p.id = `${p.id}-${d}`, p.geometry.coordinates = [h, c], p.properties.originalId = s.id, p.properties.distance = parseFloat(u.toFixed(e)), p.properties.total = parseFloat(a.toFixed(e)), p.properties.unit = no(t), o === !0 && r === void 0) {
|
|
3709
|
+
const g = i == null ? void 0 : i.queryTerrainElevation(h);
|
|
3616
3710
|
g && (p.properties.elevation_start = g);
|
|
3617
|
-
const y = i == null ? void 0 : i.queryTerrainElevation(
|
|
3711
|
+
const y = i == null ? void 0 : i.queryTerrainElevation(c);
|
|
3618
3712
|
y && (p.properties.elevation_end = y);
|
|
3619
3713
|
}
|
|
3620
3714
|
l.push(p);
|
|
3621
3715
|
}
|
|
3622
3716
|
return s.properties.distance = l[l.length - 1].properties.total, s.properties.unit = l[l.length - 1].properties.unit, s.properties.segments = JSON.parse(JSON.stringify(l)), s;
|
|
3623
|
-
},
|
|
3624
|
-
var
|
|
3625
|
-
const
|
|
3626
|
-
...
|
|
3627
|
-
(
|
|
3628
|
-
(
|
|
3629
|
-
(
|
|
3630
|
-
],
|
|
3717
|
+
}, de = (s) => s.charAt(0).toUpperCase() + s.slice(1), It = ["td-point", "td-linestring", "td-polygon"];
|
|
3718
|
+
var ue, pe, ge;
|
|
3719
|
+
const _o = [
|
|
3720
|
+
...It,
|
|
3721
|
+
(ue = yt.polygonLayerSpec) == null ? void 0 : ue.source,
|
|
3722
|
+
(pe = yt.lineLayerLabelSpec) == null ? void 0 : pe.source,
|
|
3723
|
+
(ge = yt.pointLayerLabelSpec) == null ? void 0 : ge.source
|
|
3724
|
+
], Ge = (s, t, e = It) => {
|
|
3631
3725
|
const i = JSON.parse(JSON.stringify(s));
|
|
3632
3726
|
return t && (t.onlyTerraDrawLayers === !0 ? (i.layers = i.layers.filter((o) => "source" in o && e.includes(o.source)), Object.keys(i.sources).forEach((o) => {
|
|
3633
3727
|
e.includes(o) || delete i.sources[o];
|
|
3634
3728
|
})) : t.excludeTerraDrawLayers === !0 && (i.layers = i.layers.filter((o) => "source" in o && !e.includes(o.source)), Object.keys(i.sources).forEach((o) => {
|
|
3635
3729
|
e.includes(o) && delete i.sources[o];
|
|
3636
3730
|
}))), i;
|
|
3637
|
-
},
|
|
3731
|
+
}, ao = (s, t = 250) => {
|
|
3638
3732
|
let e;
|
|
3639
3733
|
return (...i) => {
|
|
3640
3734
|
clearTimeout(e), e = setTimeout(() => s(...i), t);
|
|
3641
3735
|
};
|
|
3642
|
-
},
|
|
3736
|
+
}, he = (s, t, e, i) => {
|
|
3643
3737
|
if (s.geometry.type !== "Point") return s;
|
|
3644
3738
|
const o = s.geometry.coordinates;
|
|
3645
3739
|
if (e === !0 && i === void 0) {
|
|
@@ -3648,58 +3742,58 @@ const uo = [
|
|
|
3648
3742
|
}
|
|
3649
3743
|
return s;
|
|
3650
3744
|
};
|
|
3651
|
-
var
|
|
3652
|
-
function
|
|
3745
|
+
var lo = Object.defineProperty, ho = (s, t, e) => t in s ? lo(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, tt = (s, t, e) => ho(s, typeof t != "symbol" ? t + "" : t, e), Pt = 2 * Math.PI * 6378137 / 2;
|
|
3746
|
+
function co(s) {
|
|
3653
3747
|
return s = s || 256, 2 * Math.PI * 6378137 / s;
|
|
3654
3748
|
}
|
|
3655
|
-
function
|
|
3656
|
-
s =
|
|
3657
|
-
var i = s[0], o = s[1], r = i *
|
|
3658
|
-
return n = n *
|
|
3749
|
+
function uo(s, t, e = { enable: !0, decimal: 1 }) {
|
|
3750
|
+
s = Wt(s);
|
|
3751
|
+
var i = s[0], o = s[1], r = i * Pt / 180, n = Math.log(Math.tan((90 + o) * Math.PI / 360)) / (Math.PI / 180);
|
|
3752
|
+
return n = n * Pt / 180, e.enable && (r = Number(r.toFixed(e.decimal)), n = Number(n.toFixed(e.decimal))), [r, n];
|
|
3659
3753
|
}
|
|
3660
|
-
function
|
|
3661
|
-
var i = s[0], o = s[1], r =
|
|
3754
|
+
function po(s, t, e) {
|
|
3755
|
+
var i = s[0], o = s[1], r = Co(t, e), n = (i + Pt) / r, a = (o + Pt) / r;
|
|
3662
3756
|
return [n, a, t];
|
|
3663
3757
|
}
|
|
3664
|
-
function
|
|
3665
|
-
s =
|
|
3666
|
-
var i =
|
|
3667
|
-
return
|
|
3758
|
+
function Te(s, t, e) {
|
|
3759
|
+
s = Wt(s);
|
|
3760
|
+
var i = uo(s), o = po(i, t);
|
|
3761
|
+
return yo(o);
|
|
3668
3762
|
}
|
|
3669
|
-
function
|
|
3670
|
-
if (s =
|
|
3763
|
+
function go(s, t, e) {
|
|
3764
|
+
if (s = Wt(s), t === 0)
|
|
3671
3765
|
return [0, 0, 0];
|
|
3672
|
-
var i =
|
|
3673
|
-
return
|
|
3766
|
+
var i = Te(s, t);
|
|
3767
|
+
return fo(i);
|
|
3674
3768
|
}
|
|
3675
|
-
function
|
|
3769
|
+
function yo(s, t, e) {
|
|
3676
3770
|
t = t || 256;
|
|
3677
3771
|
var i = s[0], o = s[1], r = s[2];
|
|
3678
3772
|
if (r === 0) return [0, 0, 0];
|
|
3679
|
-
|
|
3773
|
+
Ae(r);
|
|
3680
3774
|
var n = Math.ceil(i / t) - 1, a = Math.ceil(o / t) - 1;
|
|
3681
3775
|
return n < 0 && (n = 0), a < 0 && (a = 0), [n, a, r];
|
|
3682
3776
|
}
|
|
3683
|
-
function
|
|
3684
|
-
|
|
3777
|
+
function fo(s, t) {
|
|
3778
|
+
mo(s);
|
|
3685
3779
|
var e = s[0], i = s[1], o = s[2];
|
|
3686
3780
|
if (o === 0)
|
|
3687
3781
|
return [0, 0, 0];
|
|
3688
3782
|
var r = e, n = Math.pow(2, o) - 1 - i;
|
|
3689
3783
|
return [r, n, o];
|
|
3690
3784
|
}
|
|
3691
|
-
function
|
|
3785
|
+
function mo(s, t) {
|
|
3692
3786
|
var e = s[0], i = s[1], o = s[2];
|
|
3693
3787
|
if (o == null) throw new Error("<zoom> is required");
|
|
3694
3788
|
if (e == null) throw new Error("<x> is required");
|
|
3695
3789
|
if (i == null) throw new Error("<y> is required");
|
|
3696
|
-
return o =
|
|
3790
|
+
return o = Ae(o), s = vo(s), s;
|
|
3697
3791
|
}
|
|
3698
|
-
function
|
|
3792
|
+
function vo(s) {
|
|
3699
3793
|
var t = s[0], e = s[1], i = s[2], o = Math.pow(2, i);
|
|
3700
3794
|
return t = t % o, t < 0 && (t = t + o), [t, e, i];
|
|
3701
3795
|
}
|
|
3702
|
-
function
|
|
3796
|
+
function Ae(s) {
|
|
3703
3797
|
if (s === !1) return s;
|
|
3704
3798
|
if (s == null)
|
|
3705
3799
|
throw new Error("<zoom> is required");
|
|
@@ -3709,22 +3803,22 @@ function Ne(s) {
|
|
|
3709
3803
|
throw new Error("<zoom> cannot be greater than 32");
|
|
3710
3804
|
return s;
|
|
3711
3805
|
}
|
|
3712
|
-
function
|
|
3713
|
-
var e =
|
|
3806
|
+
function Wt(s, t) {
|
|
3807
|
+
var e = So(s[0]), i = Po(s[1]);
|
|
3714
3808
|
return i > 85 && (i = 85), i < -85 && (i = -85), [e, i];
|
|
3715
3809
|
}
|
|
3716
|
-
function
|
|
3717
|
-
return
|
|
3810
|
+
function Co(s, t) {
|
|
3811
|
+
return co(t) / Math.pow(2, s);
|
|
3718
3812
|
}
|
|
3719
|
-
function
|
|
3813
|
+
function Po(s) {
|
|
3720
3814
|
if (s == null) throw new Error("lat is required");
|
|
3721
3815
|
return (s > 90 || s < -90) && (s = s % 180, s > 90 && (s = -180 + s), s < -90 && (s = 180 + s), s === 0 && (s = 0)), s;
|
|
3722
3816
|
}
|
|
3723
|
-
function
|
|
3817
|
+
function So(s) {
|
|
3724
3818
|
if (s == null) throw new Error("lng is required");
|
|
3725
3819
|
return (s > 180 || s < -180) && (s = s % 360, s > 180 && (s = -360 + s), s < -180 && (s = 360 + s), s === 0 && (s = 0)), s;
|
|
3726
3820
|
}
|
|
3727
|
-
class
|
|
3821
|
+
class Ve {
|
|
3728
3822
|
/**
|
|
3729
3823
|
* Constructor
|
|
3730
3824
|
* @param url URL for terrain RGB raster tilesets
|
|
@@ -3749,17 +3843,17 @@ class Ae {
|
|
|
3749
3843
|
const r = t[0], n = t[1];
|
|
3750
3844
|
let a = e;
|
|
3751
3845
|
e > this.maxzoom ? a = this.maxzoom : e < this.minzoom && (a = this.minzoom);
|
|
3752
|
-
const l = this.tms ?
|
|
3753
|
-
let
|
|
3754
|
-
switch (
|
|
3846
|
+
const l = this.tms ? Te([r, n], a) : go([r, n], a), d = this.url.replace(/{x}/g, l[0].toString()).replace(/{y}/g, l[1].toString()).replace(/{z}/g, l[2].toString());
|
|
3847
|
+
let h = this.getUrlExtension(d);
|
|
3848
|
+
switch (h || (h = "png"), h) {
|
|
3755
3849
|
case "png":
|
|
3756
3850
|
case "webp":
|
|
3757
|
-
this.getValueFromRaster(d, l, r, n).then((
|
|
3758
|
-
i(
|
|
3851
|
+
this.getValueFromRaster(d, l, r, n).then((c) => {
|
|
3852
|
+
i(c);
|
|
3759
3853
|
});
|
|
3760
3854
|
break;
|
|
3761
3855
|
default:
|
|
3762
|
-
o(new Error(`Invalid file extension: ${
|
|
3856
|
+
o(new Error(`Invalid file extension: ${h}`));
|
|
3763
3857
|
break;
|
|
3764
3858
|
}
|
|
3765
3859
|
}
|
|
@@ -3784,12 +3878,12 @@ class Ae {
|
|
|
3784
3878
|
return new Promise((a, l) => {
|
|
3785
3879
|
const d = new Image();
|
|
3786
3880
|
d.onload = () => {
|
|
3787
|
-
const
|
|
3788
|
-
|
|
3789
|
-
const
|
|
3790
|
-
if (!
|
|
3791
|
-
|
|
3792
|
-
const u =
|
|
3881
|
+
const h = document.createElement("canvas");
|
|
3882
|
+
h.width = d.width, h.height = d.height;
|
|
3883
|
+
const c = h.getContext("2d");
|
|
3884
|
+
if (!c) return l(new Error("Failed to create canvas context"));
|
|
3885
|
+
c.drawImage(d, 0, 0);
|
|
3886
|
+
const u = c.getImageData(0, 0, d.width, d.height).data, p = this.pixels2rgba(new Uint8Array(u), e, i, o), g = this.calc(p[0], p[1], p[2], p[3]);
|
|
3793
3887
|
a(g);
|
|
3794
3888
|
}, d.onerror = () => a(void 0), d.src = URL.createObjectURL(n);
|
|
3795
3889
|
});
|
|
@@ -3805,7 +3899,7 @@ class Ae {
|
|
|
3805
3899
|
pixels2rgba(t, e, i, o) {
|
|
3806
3900
|
const r = [];
|
|
3807
3901
|
for (let d = 0; d < t.length; d += 4) {
|
|
3808
|
-
const
|
|
3902
|
+
const h = t[d], c = t[d + 1], u = t[d + 2], p = t[d + 3], g = [h, c, u, p];
|
|
3809
3903
|
r.push(g);
|
|
3810
3904
|
}
|
|
3811
3905
|
const n = this.tileToBBOX(e), a = this.getPixelPosition(i, o, n), l = a[0] + a[1] * this.tileSize;
|
|
@@ -3819,8 +3913,8 @@ class Ae {
|
|
|
3819
3913
|
* @returns The position in pixel
|
|
3820
3914
|
*/
|
|
3821
3915
|
getPixelPosition(t, e, i) {
|
|
3822
|
-
const o = this.tileSize, r = this.tileSize, n = i[2] - i[0], a = i[3] - i[1], l = (t - i[0]) / n, d = (e - i[1]) / a,
|
|
3823
|
-
return [
|
|
3916
|
+
const o = this.tileSize, r = this.tileSize, n = i[2] - i[0], a = i[3] - i[1], l = (t - i[0]) / n, d = (e - i[1]) / a, h = Math.floor(o * l), c = Math.floor(r * (1 - d));
|
|
3917
|
+
return [h, c];
|
|
3824
3918
|
}
|
|
3825
3919
|
/**
|
|
3826
3920
|
* Get file extenstion name from the URL
|
|
@@ -3851,7 +3945,7 @@ class Ae {
|
|
|
3851
3945
|
return i * Math.atan(0.5 * (Math.exp(o) - Math.exp(-o)));
|
|
3852
3946
|
}
|
|
3853
3947
|
}
|
|
3854
|
-
class
|
|
3948
|
+
class xo extends Ve {
|
|
3855
3949
|
/**
|
|
3856
3950
|
* Constructor
|
|
3857
3951
|
* @param url URL for terrain RGB raster tilesets
|
|
@@ -3883,7 +3977,7 @@ class eo extends Ae {
|
|
|
3883
3977
|
return -1e4 + (t * 256 * 256 + e * 256 + i) * 0.1;
|
|
3884
3978
|
}
|
|
3885
3979
|
}
|
|
3886
|
-
class
|
|
3980
|
+
class Io extends Ve {
|
|
3887
3981
|
/**
|
|
3888
3982
|
* Constructor
|
|
3889
3983
|
* @param url URL for terrarium raster tilesets
|
|
@@ -3917,15 +4011,15 @@ class io extends Ae {
|
|
|
3917
4011
|
return parseInt(o.toFixed(0));
|
|
3918
4012
|
}
|
|
3919
4013
|
}
|
|
3920
|
-
const
|
|
4014
|
+
const ce = async (s, t) => {
|
|
3921
4015
|
const e = [];
|
|
3922
4016
|
for (const i of s)
|
|
3923
4017
|
e.push(
|
|
3924
4018
|
new Promise((o) => {
|
|
3925
4019
|
if (i.geometry.type !== "Point" && o(i), t) {
|
|
3926
|
-
const r = t.url, n = t.encoding ?? "mapbox", a = t.tileSize ?? 512, l = t.minzoom ?? 5, d = t.maxzoom ?? 15,
|
|
3927
|
-
(n === "mapbox" ? new
|
|
3928
|
-
|
|
4020
|
+
const r = t.url, n = t.encoding ?? "mapbox", a = t.tileSize ?? 512, l = t.minzoom ?? 5, d = t.maxzoom ?? 15, h = t.tms ?? !1;
|
|
4021
|
+
(n === "mapbox" ? new xo(r, a, l, d, h) : new Io(r, a, l, d, h)).getElevation(i.geometry.coordinates, d).then((c) => {
|
|
4022
|
+
c && (i.properties.elevation = c), o(i);
|
|
3929
4023
|
}).catch(() => o(i));
|
|
3930
4024
|
} else
|
|
3931
4025
|
o(i);
|
|
@@ -3933,7 +4027,7 @@ const le = async (s, t) => {
|
|
|
3933
4027
|
);
|
|
3934
4028
|
return await Promise.all(e);
|
|
3935
4029
|
};
|
|
3936
|
-
class
|
|
4030
|
+
class bo {
|
|
3937
4031
|
/**
|
|
3938
4032
|
* Constructor
|
|
3939
4033
|
* @param options Plugin control options
|
|
@@ -3944,7 +4038,7 @@ class oo {
|
|
|
3944
4038
|
k(this, "modeButtons", {});
|
|
3945
4039
|
k(this, "_isExpanded", !1);
|
|
3946
4040
|
k(this, "terradraw");
|
|
3947
|
-
k(this, "options",
|
|
4041
|
+
k(this, "options", Xi);
|
|
3948
4042
|
k(this, "events", {});
|
|
3949
4043
|
k(this, "defaultMode", "render");
|
|
3950
4044
|
this.modeButtons = {}, t && (this.options = Object.assign(this.options, t));
|
|
@@ -3988,20 +4082,20 @@ class oo {
|
|
|
3988
4082
|
if (this.options && this.options.modes && this.options.modes.length === 0)
|
|
3989
4083
|
throw new Error("At least a mode must be enabled.");
|
|
3990
4084
|
this.map = t;
|
|
3991
|
-
const e =
|
|
4085
|
+
const e = Ki(), i = [];
|
|
3992
4086
|
return (r = (o = this.options) == null ? void 0 : o.modes) == null || r.forEach((d) => {
|
|
3993
4087
|
if (this.options.modeOptions && this.options.modeOptions[d]) {
|
|
3994
|
-
const
|
|
4088
|
+
const h = this.options.modeOptions[d];
|
|
3995
4089
|
if (d === "select") {
|
|
3996
|
-
const
|
|
3997
|
-
if (
|
|
3998
|
-
const u =
|
|
4090
|
+
const c = e[d];
|
|
4091
|
+
if (c) {
|
|
4092
|
+
const u = c.flags;
|
|
3999
4093
|
Object.keys(u).forEach((p) => {
|
|
4000
|
-
|
|
4094
|
+
h.flags[p] || (h.flags[p] = u[p]);
|
|
4001
4095
|
});
|
|
4002
4096
|
}
|
|
4003
4097
|
}
|
|
4004
|
-
i.push(
|
|
4098
|
+
i.push(h);
|
|
4005
4099
|
} else e[d] && i.push(e[d]);
|
|
4006
4100
|
}), i.forEach((d) => {
|
|
4007
4101
|
d.state !== "unregistered" && (d._state = "unregistered");
|
|
@@ -4010,14 +4104,14 @@ class oo {
|
|
|
4010
4104
|
modeName: "default",
|
|
4011
4105
|
styles: {}
|
|
4012
4106
|
})
|
|
4013
|
-
), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new
|
|
4014
|
-
adapter: new
|
|
4107
|
+
), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new Ui({
|
|
4108
|
+
adapter: new Ri({ map: t, ...this.options.adapterOptions }),
|
|
4015
4109
|
modes: i
|
|
4016
4110
|
}), this.terradraw.start(), this.controlContainer = document.createElement("div"), this.controlContainer.classList.add("maplibregl-ctrl"), this.controlContainer.classList.add("maplibregl-ctrl-group"), i.forEach((d) => {
|
|
4017
4111
|
d.mode !== "default" && this.addTerradrawButton(d.mode);
|
|
4018
4112
|
}), Object.values(this.modeButtons).forEach((d) => {
|
|
4019
|
-
var
|
|
4020
|
-
(
|
|
4113
|
+
var h;
|
|
4114
|
+
(h = this.controlContainer) == null || h.appendChild(d);
|
|
4021
4115
|
}), (l = this.terradraw) == null || l.on("change", this.toggleButtonsWhenNoFeature.bind(this)), this.toggleButtonsWhenNoFeature(), this.controlContainer;
|
|
4022
4116
|
}
|
|
4023
4117
|
/**
|
|
@@ -4108,7 +4202,7 @@ class oo {
|
|
|
4108
4202
|
*/
|
|
4109
4203
|
addTerradrawButton(t) {
|
|
4110
4204
|
const e = document.createElement("button");
|
|
4111
|
-
e.type = "button", this.modeButtons[t] = e, t === "render" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), this.isExpanded && e.classList.add("enabled"), e.type = "button", e.title =
|
|
4205
|
+
e.type = "button", this.modeButtons[t] = e, t === "render" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), this.isExpanded && e.classList.add("enabled"), e.type = "button", e.title = de("expand or collapse drawing tool"), e.addEventListener("click", this.toggleEditor.bind(this))) : (e.classList.add("maplibregl-terradraw-add-control"), this.isExpanded || e.classList.add("hidden"), e.title = de(t.replace(/-/g, " ")), t === "delete" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.addEventListener("click", () => {
|
|
4112
4206
|
this.terradraw && this.terradraw.enabled && (this.terradraw.clear(), this.deactivate(), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.dispatchEvent("feature-deleted"));
|
|
4113
4207
|
})) : t === "delete-selection" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.classList.add("hidden-delete-selection"), e.addEventListener("click", () => {
|
|
4114
4208
|
var r;
|
|
@@ -4158,7 +4252,7 @@ class oo {
|
|
|
4158
4252
|
* @returns
|
|
4159
4253
|
*/
|
|
4160
4254
|
cleanStyle(t, e) {
|
|
4161
|
-
return
|
|
4255
|
+
return Ge(t, e, It);
|
|
4162
4256
|
}
|
|
4163
4257
|
/**
|
|
4164
4258
|
* Download button click event handler
|
|
@@ -4192,34 +4286,34 @@ class oo {
|
|
|
4192
4286
|
var a, l;
|
|
4193
4287
|
const t = ((a = this.terradraw) == null ? void 0 : a.enabled) || !1, e = (l = this.terradraw) == null ? void 0 : l.getMode(), i = this.getFeatures(!1), o = i && i.features.length > 0, r = o && t && e === "select", n = document.getElementsByClassName("maplibregl-terradraw-delete-selection-button");
|
|
4194
4288
|
for (let d = 0; d < n.length; d++) {
|
|
4195
|
-
const
|
|
4196
|
-
|
|
4289
|
+
const h = n.item(d);
|
|
4290
|
+
h && (r ? h.classList.remove("hidden-delete-selection") : h.classList.add("hidden-delete-selection"));
|
|
4197
4291
|
}
|
|
4198
4292
|
if (!o) {
|
|
4199
4293
|
const d = document.getElementsByClassName("maplibregl-terradraw-add-select-button");
|
|
4200
|
-
for (let
|
|
4201
|
-
const
|
|
4202
|
-
|
|
4294
|
+
for (let h = 0; h < d.length; h++) {
|
|
4295
|
+
const c = d.item(h);
|
|
4296
|
+
c && c.classList.remove("active");
|
|
4203
4297
|
}
|
|
4204
4298
|
}
|
|
4205
4299
|
}
|
|
4206
4300
|
}
|
|
4207
|
-
function
|
|
4301
|
+
function Mo(s, t = {}) {
|
|
4208
4302
|
let e = 0, i = 0, o = 0;
|
|
4209
|
-
return
|
|
4303
|
+
return Ne(
|
|
4210
4304
|
s,
|
|
4211
4305
|
function(r) {
|
|
4212
4306
|
e += r[0], i += r[1], o++;
|
|
4213
4307
|
}
|
|
4214
|
-
),
|
|
4308
|
+
), Hi([e / o, i / o], t.properties);
|
|
4215
4309
|
}
|
|
4216
|
-
class
|
|
4310
|
+
class ko extends bo {
|
|
4217
4311
|
/**
|
|
4218
4312
|
* Constructor
|
|
4219
4313
|
* @param options Plugin control options
|
|
4220
4314
|
*/
|
|
4221
4315
|
constructor(e) {
|
|
4222
|
-
let i =
|
|
4316
|
+
let i = yt;
|
|
4223
4317
|
e && (i = Object.assign(i, e));
|
|
4224
4318
|
super({
|
|
4225
4319
|
modes: i.modes,
|
|
@@ -4252,7 +4346,7 @@ class po extends oo {
|
|
|
4252
4346
|
* Handle finish event of terradraw. It will be called after finishing adding a feature
|
|
4253
4347
|
* @param id Feature ID
|
|
4254
4348
|
*/
|
|
4255
|
-
k(this, "handleTerradrawFeatureReady",
|
|
4349
|
+
k(this, "handleTerradrawFeatureReady", ao((e) => {
|
|
4256
4350
|
this.map && (this.computeElevationByLineFeatureID(e), this.computeElevationByPointFeatureID(e));
|
|
4257
4351
|
}, 300));
|
|
4258
4352
|
/**
|
|
@@ -4270,7 +4364,7 @@ class po extends oo {
|
|
|
4270
4364
|
}
|
|
4271
4365
|
);
|
|
4272
4366
|
if (o && o.length > 0) {
|
|
4273
|
-
const r = await
|
|
4367
|
+
const r = await ce(
|
|
4274
4368
|
o,
|
|
4275
4369
|
this.measureOptions.terrainSource
|
|
4276
4370
|
);
|
|
@@ -4298,7 +4392,7 @@ class po extends oo {
|
|
|
4298
4392
|
}
|
|
4299
4393
|
);
|
|
4300
4394
|
if (o && o.length > 0) {
|
|
4301
|
-
const r = await
|
|
4395
|
+
const r = await ce(
|
|
4302
4396
|
o,
|
|
4303
4397
|
this.measureOptions.terrainSource
|
|
4304
4398
|
);
|
|
@@ -4427,13 +4521,13 @@ class po extends oo {
|
|
|
4427
4521
|
* @returns
|
|
4428
4522
|
*/
|
|
4429
4523
|
cleanStyle(e, i) {
|
|
4430
|
-
var l, d,
|
|
4431
|
-
const o =
|
|
4524
|
+
var l, d, h;
|
|
4525
|
+
const o = It, r = (l = this.measureOptions.polygonLayerSpec) == null ? void 0 : l.source;
|
|
4432
4526
|
r && o.push(r);
|
|
4433
4527
|
const n = (d = this.measureOptions.lineLayerLabelSpec) == null ? void 0 : d.source;
|
|
4434
4528
|
n && o.push(n);
|
|
4435
|
-
const a = (
|
|
4436
|
-
return a && o.push(a),
|
|
4529
|
+
const a = (h = this.measureOptions.pointLayerLabelSpec) == null ? void 0 : h.source;
|
|
4530
|
+
return a && o.push(a), Ge(e, i, o);
|
|
4437
4531
|
}
|
|
4438
4532
|
/**
|
|
4439
4533
|
* Register measure control related maplibre sources and layers
|
|
@@ -4487,30 +4581,28 @@ class po extends oo {
|
|
|
4487
4581
|
* Handle change event of TerraDraw
|
|
4488
4582
|
* @param ids Feature IDs
|
|
4489
4583
|
*/
|
|
4490
|
-
handleTerradrawFeatureChanged(e) {
|
|
4491
|
-
if (!this.map) return;
|
|
4492
|
-
const
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4584
|
+
handleTerradrawFeatureChanged(e, i) {
|
|
4585
|
+
if (!this.map || i === "styling") return;
|
|
4586
|
+
const r = [
|
|
4587
|
+
this.measureOptions.pointLayerLabelSpec,
|
|
4588
|
+
this.measureOptions.lineLayerLabelSpec,
|
|
4589
|
+
this.measureOptions.lineLayerNodeSpec,
|
|
4590
|
+
this.measureOptions.polygonLayerSpec
|
|
4591
|
+
].map((l) => l.source);
|
|
4592
|
+
if (i === "delete") {
|
|
4593
|
+
this.clearMeasureFeatures(r, e);
|
|
4594
|
+
return;
|
|
4595
|
+
}
|
|
4596
|
+
const n = this.getTerraDrawInstance();
|
|
4597
|
+
if (!n) return;
|
|
4598
|
+
const a = n.getSnapshot();
|
|
4599
|
+
for (const l of e) {
|
|
4600
|
+
const d = a.find((h) => h.id === l);
|
|
4601
|
+
if (d) {
|
|
4602
|
+
const h = d.geometry.type, c = d.properties.mode;
|
|
4603
|
+
c === "linestring" && h === "LineString" ? this.measureLine(l) : c === "point" && h === "Point" ? this.measurePoint(l) : !["point", "linestring", "select", "render"].includes(c) && h === "Polygon" && this.measurePolygon(l);
|
|
4500
4604
|
} else
|
|
4501
|
-
this.clearMeasureFeatures(
|
|
4502
|
-
r,
|
|
4503
|
-
this.measureOptions.lineLayerNodeSpec.source
|
|
4504
|
-
), this.clearMeasureFeatures(
|
|
4505
|
-
r,
|
|
4506
|
-
this.measureOptions.lineLayerLabelSpec.source
|
|
4507
|
-
), this.clearMeasureFeatures(
|
|
4508
|
-
r,
|
|
4509
|
-
this.measureOptions.polygonLayerSpec.source
|
|
4510
|
-
), this.clearMeasureFeatures(
|
|
4511
|
-
r,
|
|
4512
|
-
this.measureOptions.pointLayerLabelSpec.source
|
|
4513
|
-
);
|
|
4605
|
+
this.clearMeasureFeatures(r, [l]);
|
|
4514
4606
|
}
|
|
4515
4607
|
}
|
|
4516
4608
|
/**
|
|
@@ -4533,20 +4625,20 @@ class po extends oo {
|
|
|
4533
4625
|
}
|
|
4534
4626
|
/**
|
|
4535
4627
|
* Clear GeoJSON feature related to measure control by TerraDraw feature ID
|
|
4536
|
-
* @param
|
|
4537
|
-
* @param
|
|
4628
|
+
* @param sourceIds the array of source ID to delete
|
|
4629
|
+
* @param ids the array of feature ID. Optional, if undefined, delete all labels for source
|
|
4538
4630
|
* @returns void
|
|
4539
4631
|
*/
|
|
4540
|
-
clearMeasureFeatures(e, i) {
|
|
4541
|
-
var
|
|
4542
|
-
if (
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4632
|
+
clearMeasureFeatures(e, i = void 0) {
|
|
4633
|
+
var o;
|
|
4634
|
+
if (this.map)
|
|
4635
|
+
for (const r of e) {
|
|
4636
|
+
const n = this.map.getStyle().sources[r];
|
|
4637
|
+
n && typeof n.data != "string" && n.data.type === "FeatureCollection" && (i === void 0 ? n.data.features = [] : n.data.features = n.data.features.filter((a) => {
|
|
4638
|
+
var l;
|
|
4639
|
+
return (l = a.properties) != null && l.originalId ? !i.includes(a.properties.originalId) : !i.includes(a.id);
|
|
4640
|
+
}), (o = this.map.getSource(r)) == null || o.setData(n.data));
|
|
4548
4641
|
}
|
|
4549
|
-
), (r = this.map.getSource(i)) == null || r.setData(o.data));
|
|
4550
4642
|
}
|
|
4551
4643
|
/**
|
|
4552
4644
|
* Replace GeoJSON source with updated features for a given source ID
|
|
@@ -4555,32 +4647,35 @@ class po extends oo {
|
|
|
4555
4647
|
* @param type either 'linestring' or 'point'
|
|
4556
4648
|
*/
|
|
4557
4649
|
replaceGeoJSONSource(e, i, o) {
|
|
4558
|
-
var n;
|
|
4650
|
+
var n, a;
|
|
4559
4651
|
if (!this.map) return;
|
|
4560
4652
|
const r = this.map.getStyle().sources[i];
|
|
4561
4653
|
if (r && typeof r.data != "string" && r.data.type === "FeatureCollection") {
|
|
4562
|
-
const
|
|
4654
|
+
const l = [];
|
|
4655
|
+
for (const h of e)
|
|
4656
|
+
(n = this.terradraw) != null && n.getSnapshotFeature(h.id) && l.push(h);
|
|
4657
|
+
const d = l.map((h) => h.id);
|
|
4563
4658
|
if (typeof r.data != "string" && r.data.type === "FeatureCollection") {
|
|
4564
4659
|
o === "linestring" ? r.data.features = [
|
|
4565
4660
|
...r.data.features = r.data.features.filter(
|
|
4566
|
-
(
|
|
4567
|
-
var
|
|
4568
|
-
return !(
|
|
4661
|
+
(c) => {
|
|
4662
|
+
var u;
|
|
4663
|
+
return !(d.includes((u = c.properties) == null ? void 0 : u.originalId) && c.geometry.type === "Point");
|
|
4569
4664
|
}
|
|
4570
4665
|
),
|
|
4571
|
-
...
|
|
4666
|
+
...l
|
|
4572
4667
|
] : o === "point" && (r.data.features = [
|
|
4573
4668
|
...r.data.features = r.data.features.filter(
|
|
4574
|
-
(
|
|
4669
|
+
(c) => !(d.includes(c.id) && c.geometry.type === "Point")
|
|
4575
4670
|
),
|
|
4576
|
-
...
|
|
4671
|
+
...l
|
|
4577
4672
|
]);
|
|
4578
|
-
const
|
|
4579
|
-
r.data.features.forEach((
|
|
4580
|
-
var
|
|
4581
|
-
const
|
|
4582
|
-
|
|
4583
|
-
}), r.data.features = Array.from(Object.values(
|
|
4673
|
+
const h = {};
|
|
4674
|
+
r.data.features.forEach((c) => {
|
|
4675
|
+
var p;
|
|
4676
|
+
const u = c.id;
|
|
4677
|
+
h[u] ? !h[u].properties.elevation && ((p = c.properties) != null && p.elevation) && (h[u] = c) : h[u] = c;
|
|
4678
|
+
}), r.data.features = Array.from(Object.values(h)), (a = this.map.getSource(i)) == null || a.setData(r.data);
|
|
4584
4679
|
}
|
|
4585
4680
|
}
|
|
4586
4681
|
}
|
|
@@ -4600,12 +4695,12 @@ class po extends oo {
|
|
|
4600
4695
|
if (a) {
|
|
4601
4696
|
typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
|
|
4602
4697
|
(d) => {
|
|
4603
|
-
var
|
|
4604
|
-
return ((
|
|
4698
|
+
var h;
|
|
4699
|
+
return ((h = d.properties) == null ? void 0 : h.originalId) !== e;
|
|
4605
4700
|
}
|
|
4606
4701
|
));
|
|
4607
4702
|
const l = JSON.parse(JSON.stringify(r));
|
|
4608
|
-
l.id = l.id + "-area-label", l.geometry =
|
|
4703
|
+
l.id = l.id + "-area-label", l.geometry = Mo(r.geometry).geometry, l.properties.originalId = r.id, r = ne(r, this.areaUnit, this.areaPrecision), l.properties.area = r.properties.area, l.properties.unit = r.properties.unit, typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(l), (n = this.map.getSource(
|
|
4609
4704
|
this.measureOptions.polygonLayerSpec.source
|
|
4610
4705
|
)) == null || n.setData(a.data), this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && this.map.moveLayer(
|
|
4611
4706
|
this.measureOptions.lineLayerLabelSpec.id
|
|
@@ -4635,10 +4730,10 @@ class po extends oo {
|
|
|
4635
4730
|
if (a) {
|
|
4636
4731
|
typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
|
|
4637
4732
|
(d) => {
|
|
4638
|
-
var
|
|
4639
|
-
return ((
|
|
4733
|
+
var h;
|
|
4734
|
+
return ((h = d.properties) == null ? void 0 : h.originalId) !== e;
|
|
4640
4735
|
}
|
|
4641
|
-
)), r =
|
|
4736
|
+
)), r = le(
|
|
4642
4737
|
r,
|
|
4643
4738
|
this.distanceUnit,
|
|
4644
4739
|
this.distancePrecision,
|
|
@@ -4648,21 +4743,21 @@ class po extends oo {
|
|
|
4648
4743
|
);
|
|
4649
4744
|
const l = r.properties.segments;
|
|
4650
4745
|
for (let d = 0; d < l.length; d++) {
|
|
4651
|
-
const
|
|
4652
|
-
typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(
|
|
4653
|
-
const
|
|
4746
|
+
const h = l[d];
|
|
4747
|
+
typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(h);
|
|
4748
|
+
const c = h.geometry.coordinates, u = c[0], p = c[1];
|
|
4654
4749
|
if (d === 0) {
|
|
4655
|
-
const y = JSON.parse(JSON.stringify(
|
|
4656
|
-
y.id = `${
|
|
4750
|
+
const y = JSON.parse(JSON.stringify(h));
|
|
4751
|
+
y.id = `${h.id}-node-${d}`, y.geometry = {
|
|
4657
4752
|
type: "Point",
|
|
4658
4753
|
coordinates: u
|
|
4659
|
-
}, y.properties.distance = 0, y.properties.total = 0,
|
|
4754
|
+
}, 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);
|
|
4660
4755
|
}
|
|
4661
|
-
const g = JSON.parse(JSON.stringify(
|
|
4662
|
-
g.id = `${
|
|
4756
|
+
const g = JSON.parse(JSON.stringify(h));
|
|
4757
|
+
g.id = `${h.id}-node-${d + 1}`, g.geometry = {
|
|
4663
4758
|
type: "Point",
|
|
4664
4759
|
coordinates: p
|
|
4665
|
-
},
|
|
4760
|
+
}, h.properties.elevation_end && (g.properties.elevation = h.properties.elevation_end), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(g);
|
|
4666
4761
|
}
|
|
4667
4762
|
(n = this.map.getSource(
|
|
4668
4763
|
this.measureOptions.lineLayerLabelSpec.source
|
|
@@ -4687,7 +4782,7 @@ class po extends oo {
|
|
|
4687
4782
|
let r = o == null ? void 0 : o.find((a) => a.id === e && a.geometry.type === "Point");
|
|
4688
4783
|
if (r) {
|
|
4689
4784
|
const a = this.map.getStyle().sources[this.measureOptions.pointLayerLabelSpec.source];
|
|
4690
|
-
a && (typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter((l) => l.id !== e)), r =
|
|
4785
|
+
a && (typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter((l) => l.id !== e)), r = he(
|
|
4691
4786
|
r,
|
|
4692
4787
|
this.map,
|
|
4693
4788
|
this.computeElevation,
|
|
@@ -4707,29 +4802,17 @@ class po extends oo {
|
|
|
4707
4802
|
* Event definition when feature is deleted by terradraw
|
|
4708
4803
|
*/
|
|
4709
4804
|
onFeatureDeleted(e) {
|
|
4710
|
-
var o, r;
|
|
4711
4805
|
if (!this.map) return;
|
|
4712
4806
|
if (this.getTerraDrawInstance()) {
|
|
4713
|
-
let
|
|
4714
|
-
typeof e == "object" && e !== null && "deletedIds" in e && (
|
|
4715
|
-
const
|
|
4807
|
+
let o = [];
|
|
4808
|
+
typeof e == "object" && e !== null && "deletedIds" in e && (o = e.deletedIds);
|
|
4809
|
+
const n = [
|
|
4716
4810
|
this.measureOptions.pointLayerLabelSpec,
|
|
4717
4811
|
this.measureOptions.lineLayerLabelSpec,
|
|
4812
|
+
this.measureOptions.lineLayerNodeSpec,
|
|
4718
4813
|
this.measureOptions.polygonLayerSpec
|
|
4719
|
-
];
|
|
4720
|
-
|
|
4721
|
-
for (const l of a) {
|
|
4722
|
-
const d = this.map.getStyle().sources[l.source];
|
|
4723
|
-
d && (typeof d.data != "string" && d.data.type === "FeatureCollection" && (d.data.features = d.data.features.filter((c) => {
|
|
4724
|
-
var h;
|
|
4725
|
-
return (h = c.properties) != null && h.originalId ? !n.includes(c.properties.originalId) : !n.includes(c.id);
|
|
4726
|
-
})), (o = this.map.getSource(l.source)) == null || o.setData(d.data));
|
|
4727
|
-
}
|
|
4728
|
-
else
|
|
4729
|
-
for (const l of a) {
|
|
4730
|
-
const d = this.map.getStyle().sources[l.source];
|
|
4731
|
-
d && (typeof d.data != "string" && d.data.type === "FeatureCollection" && (d.data.features = []), (r = this.map.getSource(l.source)) == null || r.setData(d.data));
|
|
4732
|
-
}
|
|
4814
|
+
].map((a) => a.source);
|
|
4815
|
+
o && o.length > 0 ? this.clearMeasureFeatures(n, o) : this.clearMeasureFeatures(n, void 0);
|
|
4733
4816
|
}
|
|
4734
4817
|
}
|
|
4735
4818
|
/**
|
|
@@ -4744,14 +4827,14 @@ class po extends oo {
|
|
|
4744
4827
|
const r = i.features[o];
|
|
4745
4828
|
if (!this.map || !this.map.loaded()) continue;
|
|
4746
4829
|
const n = r.geometry.type;
|
|
4747
|
-
n === "LineString" ? i.features[o] =
|
|
4830
|
+
n === "LineString" ? i.features[o] = le(
|
|
4748
4831
|
r,
|
|
4749
4832
|
this.distanceUnit,
|
|
4750
4833
|
this.distancePrecision,
|
|
4751
4834
|
this.map,
|
|
4752
4835
|
this.computeElevation,
|
|
4753
4836
|
this.measureOptions.terrainSource
|
|
4754
|
-
) : n === "Polygon" ? i.features[o] =
|
|
4837
|
+
) : n === "Polygon" ? i.features[o] = ne(r, this.areaUnit, this.areaPrecision) : n === "Point" && (i.features[o] = he(
|
|
4755
4838
|
r,
|
|
4756
4839
|
this.map,
|
|
4757
4840
|
this.computeElevation,
|
|
@@ -4762,22 +4845,22 @@ class po extends oo {
|
|
|
4762
4845
|
}
|
|
4763
4846
|
}
|
|
4764
4847
|
export {
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4848
|
+
Lo as AvailableModes,
|
|
4849
|
+
ko as MaplibreMeasureControl,
|
|
4850
|
+
bo as MaplibreTerradrawControl,
|
|
4851
|
+
_o as TERRADRAW_MEASURE_SOURCE_IDS,
|
|
4852
|
+
It as TERRADRAW_SOURCE_IDS,
|
|
4853
|
+
ne as calcArea,
|
|
4854
|
+
le as calcDistance,
|
|
4855
|
+
de as capitalize,
|
|
4856
|
+
Ge as cleanMaplibreStyle,
|
|
4857
|
+
oo as convertAreaUnit,
|
|
4858
|
+
ao as debounce,
|
|
4859
|
+
Xi as defaultControlOptions,
|
|
4860
|
+
yt as defaultMeasureControlOptions,
|
|
4861
|
+
Ki as getDefaultModeOptions,
|
|
4862
|
+
no as getDistanceUnitName,
|
|
4863
|
+
he as queryElevationByPoint,
|
|
4864
|
+
ce as queryElevationFromRasterDEM
|
|
4782
4865
|
};
|
|
4783
4866
|
//# sourceMappingURL=maplibre-gl-terradraw.es.js.map
|