@watergis/maplibre-gl-terradraw 1.8.2 → 1.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/maplibre-gl-terradraw.es.js +1021 -964
- package/dist/maplibre-gl-terradraw.es.js.map +1 -1
- package/dist/maplibre-gl-terradraw.umd.js +3 -3
- package/dist/maplibre-gl-terradraw.umd.js.map +1 -1
- package/dist/types/controls/MaplibreTerradrawControl.d.ts +2 -0
- package/dist/types/controls/MaplibreTerradrawControl.d.ts.map +1 -1
- package/dist/types/controls/MaplibreValhallaControl.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { LngLat as
|
|
1
|
+
import { LngLat as Je } from "maplibre-gl";
|
|
2
2
|
function x() {
|
|
3
|
-
return x = Object.assign ? Object.assign.bind() : function(
|
|
3
|
+
return x = Object.assign ? Object.assign.bind() : function(s) {
|
|
4
4
|
for (var t = 1; t < arguments.length; t++) {
|
|
5
5
|
var e = arguments[t];
|
|
6
|
-
for (var i in e) ({}).hasOwnProperty.call(e, i) && (
|
|
6
|
+
for (var i in e) ({}).hasOwnProperty.call(e, i) && (s[i] = e[i]);
|
|
7
7
|
}
|
|
8
|
-
return
|
|
8
|
+
return s;
|
|
9
9
|
}, x.apply(null, arguments);
|
|
10
10
|
}
|
|
11
11
|
var E;
|
|
12
|
-
(function(
|
|
13
|
-
|
|
12
|
+
(function(s) {
|
|
13
|
+
s.Commit = "commit", s.Provisional = "provisional", s.Finish = "finish";
|
|
14
14
|
})(E || (E = {}));
|
|
15
15
|
const k = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT_FEATURE_ID: "selectionPointFeatureId", SELECTION_POINT: "selectionPoint" }, S = { MODE: "mode", CURRENTLY_DRAWING: "currentlyDrawing", EDITED: "edited", CLOSING_POINT: "closingPoint", SNAPPING_POINT: "snappingPoint", COORDINATE_POINT: "coordinatePoint", COORDINATE_POINT_FEATURE_ID: "coordinatePointFeatureId", COORDINATE_POINT_IDS: "coordinatePointIds", PROVISIONAL_COORDINATE_COUNT: "provisionalCoordinateCount", COMMITTED_COORDINATE_COUNT: "committedCoordinateCount" }, j = 10;
|
|
16
|
-
function Lt(
|
|
17
|
-
return !!(
|
|
16
|
+
function Lt(s) {
|
|
17
|
+
return !!(s && typeof s == "object" && s !== null && !Array.isArray(s));
|
|
18
18
|
}
|
|
19
|
-
function te(
|
|
20
|
-
return !!(
|
|
19
|
+
function te(s) {
|
|
20
|
+
return !!(s && typeof s == "object" && "properties" in s && typeof s.properties == "object" && s.properties !== null && "mode" in s.properties);
|
|
21
21
|
}
|
|
22
|
-
function ee(
|
|
22
|
+
function ee(s) {
|
|
23
23
|
return !!(function(t) {
|
|
24
24
|
return typeof t == "number" && !isNaN(new Date(t).valueOf());
|
|
25
|
-
})(
|
|
25
|
+
})(s);
|
|
26
26
|
}
|
|
27
27
|
const Ze = "Feature mode property does not match the mode being added to";
|
|
28
28
|
var q;
|
|
29
|
-
(function(
|
|
30
|
-
|
|
29
|
+
(function(s) {
|
|
30
|
+
s.Drawing = "drawing", s.Select = "select", s.Static = "static", s.Render = "render";
|
|
31
31
|
})(q || (q = {}));
|
|
32
32
|
const Qe = { rightClick: !0, contextMenu: !1, leftClick: !0, onDragStart: !0, onDrag: !0, onDragEnd: !0 };
|
|
33
33
|
class A {
|
|
@@ -81,18 +81,18 @@ class A {
|
|
|
81
81
|
performFeatureValidation(t) {
|
|
82
82
|
if (this._state === "unregistered") throw new Error("Mode must be registered");
|
|
83
83
|
const e = (function(i, o) {
|
|
84
|
-
let
|
|
85
|
-
if (Lt(i)) if (i.id == null)
|
|
86
|
-
else if (typeof i.id != "string" && typeof i.id != "number")
|
|
84
|
+
let r;
|
|
85
|
+
if (Lt(i)) if (i.id == null) r = "Feature has no id";
|
|
86
|
+
else if (typeof i.id != "string" && typeof i.id != "number") r = "Feature must be string or number as per GeoJSON spec";
|
|
87
87
|
else if (o(i.id)) if (Lt(i.geometry)) if (Lt(i.properties)) if (typeof i.geometry.type == "string" && ["Polygon", "LineString", "Point"].includes(i.geometry.type)) if (Array.isArray(i.geometry.coordinates)) {
|
|
88
88
|
if (!i.properties.mode || typeof i.properties.mode != "string") return { valid: !1, reason: "Feature does not have a valid mode property" };
|
|
89
|
-
} else
|
|
90
|
-
else
|
|
91
|
-
else
|
|
92
|
-
else
|
|
93
|
-
else
|
|
94
|
-
else
|
|
95
|
-
return
|
|
89
|
+
} else r = "Feature coordinates is not an array";
|
|
90
|
+
else r = "Feature is not Point, LineString or Polygon";
|
|
91
|
+
else r = "Feature has no properties";
|
|
92
|
+
else r = "Feature has no geometry";
|
|
93
|
+
else r = "Feature must match the id strategy (default is UUID4)";
|
|
94
|
+
else r = "Feature is not object";
|
|
95
|
+
return r ? { valid: !1, reason: r } : { valid: !0 };
|
|
96
96
|
})(t, this.store.idStrategy.isValidId);
|
|
97
97
|
if (this.validate) {
|
|
98
98
|
const i = this.validate(t, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: E.Provisional });
|
|
@@ -130,6 +130,9 @@ class A {
|
|
|
130
130
|
getNumericStylingValue(t, e, i) {
|
|
131
131
|
return this.getStylingValue(t, e, i);
|
|
132
132
|
}
|
|
133
|
+
getUrlStylingValue(t, e, i) {
|
|
134
|
+
return this.getStylingValue(t, e, i);
|
|
135
|
+
}
|
|
133
136
|
getStylingValue(t, e, i) {
|
|
134
137
|
return t === void 0 ? e : typeof t == "function" ? t(i) : t;
|
|
135
138
|
}
|
|
@@ -139,91 +142,91 @@ let ti = class extends A {
|
|
|
139
142
|
super(...t), this.type = q.Select;
|
|
140
143
|
}
|
|
141
144
|
};
|
|
142
|
-
function
|
|
143
|
-
const e = (d) => d * Math.PI / 180, i = e(
|
|
145
|
+
function G(s, t) {
|
|
146
|
+
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);
|
|
144
147
|
return 2 * Math.atan2(Math.sqrt(l), Math.sqrt(1 - l)) * 6371e3 / 1e3;
|
|
145
148
|
}
|
|
146
149
|
const Oe = 63710088e-1;
|
|
147
|
-
function D(
|
|
148
|
-
return
|
|
150
|
+
function D(s) {
|
|
151
|
+
return s % 360 * Math.PI / 180;
|
|
149
152
|
}
|
|
150
|
-
function Ee(
|
|
151
|
-
return
|
|
153
|
+
function Ee(s) {
|
|
154
|
+
return s / 6371.0088;
|
|
152
155
|
}
|
|
153
|
-
function V(
|
|
154
|
-
return
|
|
156
|
+
function V(s) {
|
|
157
|
+
return s % (2 * Math.PI) * 180 / Math.PI;
|
|
155
158
|
}
|
|
156
|
-
function b(
|
|
159
|
+
function b(s, t = 9) {
|
|
157
160
|
const e = Math.pow(10, t);
|
|
158
|
-
return Math.round(
|
|
161
|
+
return Math.round(s * e) / e;
|
|
159
162
|
}
|
|
160
|
-
const ie = 57.29577951308232, oe = 0.017453292519943295, xt = 6378137, O = (
|
|
161
|
-
function ei(
|
|
162
|
-
const i = D(
|
|
163
|
-
return [V(i + Math.atan2(Math.sin(
|
|
163
|
+
const ie = 57.29577951308232, oe = 0.017453292519943295, xt = 6378137, O = (s, t) => ({ x: s === 0 ? 0 : s * oe * xt, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * oe / 2)) * xt }), U = (s, t) => ({ lng: s === 0 ? 0 : ie * (s / xt), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / xt)) - Math.PI / 2) * ie });
|
|
164
|
+
function ei(s, t, e) {
|
|
165
|
+
const i = D(s[0]), o = D(s[1]), r = D(e), n = Ee(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(r));
|
|
166
|
+
return [V(i + Math.atan2(Math.sin(r) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), V(a)];
|
|
164
167
|
}
|
|
165
|
-
function
|
|
166
|
-
const { center: t, radiusKilometers: e, coordinatePrecision: i } =
|
|
168
|
+
function re(s) {
|
|
169
|
+
const { center: t, radiusKilometers: e, coordinatePrecision: i } = s, o = s.steps ? s.steps : 64, r = [];
|
|
167
170
|
for (let n = 0; n < o; n++) {
|
|
168
171
|
const a = ei(t, e, -360 * n / o);
|
|
169
|
-
|
|
172
|
+
r.push([b(a[0], i), b(a[1], i)]);
|
|
170
173
|
}
|
|
171
|
-
return
|
|
174
|
+
return r.push(r[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [r] }, properties: {} };
|
|
172
175
|
}
|
|
173
|
-
function At(
|
|
176
|
+
function At(s) {
|
|
174
177
|
let t;
|
|
175
|
-
if (
|
|
178
|
+
if (s.geometry.type === "Polygon") t = s.geometry.coordinates;
|
|
176
179
|
else {
|
|
177
|
-
if (
|
|
178
|
-
t = [
|
|
180
|
+
if (s.geometry.type !== "LineString") throw new Error("Self intersects only accepts Polygons and LineStrings");
|
|
181
|
+
t = [s.geometry.coordinates];
|
|
179
182
|
}
|
|
180
183
|
const e = [];
|
|
181
|
-
for (let
|
|
184
|
+
for (let r = 0; r < t.length; r++) for (let n = 0; n < t[r].length - 1; n++) for (let a = 0; a < t.length; a++) for (let l = 0; l < t[a].length - 1; l++) o(r, n, a, l);
|
|
182
185
|
return e.length > 0;
|
|
183
|
-
function i(
|
|
184
|
-
return
|
|
186
|
+
function i(r) {
|
|
187
|
+
return r < 0 || r > 1;
|
|
185
188
|
}
|
|
186
|
-
function o(
|
|
187
|
-
const d = t[
|
|
189
|
+
function o(r, n, a, l) {
|
|
190
|
+
const d = t[r][n], c = t[r][n + 1], h = t[a][l], u = t[a][l + 1], p = (function(f, v, C, m) {
|
|
188
191
|
if (ft(f, C) || ft(f, m) || ft(v, C) || ft(m, C)) return null;
|
|
189
|
-
const P = f[0], I = f[1], w = v[0], L = v[1],
|
|
190
|
-
return $ === 0 ? null : [((P * L - I * w) * (
|
|
192
|
+
const P = f[0], I = f[1], w = v[0], L = v[1], F = C[0], N = C[1], _ = m[0], T = m[1], $ = (P - w) * (N - T) - (I - L) * (F - _);
|
|
193
|
+
return $ === 0 ? null : [((P * L - I * w) * (F - _) - (P - w) * (F * T - N * _)) / $, ((P * L - I * w) * (N - T) - (I - L) * (F * T - N * _)) / $];
|
|
191
194
|
})(d, c, h, u);
|
|
192
195
|
if (p === null) return;
|
|
193
196
|
let g, y;
|
|
194
197
|
g = c[0] !== d[0] ? (p[0] - d[0]) / (c[0] - d[0]) : (p[1] - d[1]) / (c[1] - d[1]), y = u[0] !== h[0] ? (p[0] - h[0]) / (u[0] - h[0]) : (p[1] - h[1]) / (u[1] - h[1]), i(g) || i(y) || (p.toString(), e.push(p));
|
|
195
198
|
}
|
|
196
199
|
}
|
|
197
|
-
function ft(
|
|
198
|
-
return
|
|
200
|
+
function ft(s, t) {
|
|
201
|
+
return s[0] === t[0] && s[1] === t[1];
|
|
199
202
|
}
|
|
200
|
-
function bt(
|
|
201
|
-
return
|
|
203
|
+
function bt(s, t) {
|
|
204
|
+
return se(s[0]) <= t && se(s[1]) <= t;
|
|
202
205
|
}
|
|
203
|
-
function
|
|
204
|
-
return
|
|
206
|
+
function Ut(s) {
|
|
207
|
+
return s.length === 2 && typeof s[0] == "number" && typeof s[1] == "number" && s[0] !== 1 / 0 && s[1] !== 1 / 0 && (e = s[0]) >= -180 && e <= 180 && (t = s[1]) >= -90 && t <= 90;
|
|
205
208
|
var t, e;
|
|
206
209
|
}
|
|
207
|
-
function
|
|
210
|
+
function se(s) {
|
|
208
211
|
let t = 1, e = 0;
|
|
209
|
-
for (; Math.round(
|
|
212
|
+
for (; Math.round(s * t) / t !== s; ) t *= 10, e++;
|
|
210
213
|
return e;
|
|
211
214
|
}
|
|
212
|
-
const ii = "Feature has holes", oi = "Feature has less than 4 coordinates",
|
|
213
|
-
function wt(
|
|
214
|
-
if (
|
|
215
|
-
if (
|
|
216
|
-
if (
|
|
217
|
-
for (let o = 0; o <
|
|
218
|
-
if (!
|
|
219
|
-
if (!bt(
|
|
215
|
+
const ii = "Feature has holes", oi = "Feature has less than 4 coordinates", ri = "Feature has invalid coordinates", si = "Feature coordinates are not closed";
|
|
216
|
+
function wt(s, t) {
|
|
217
|
+
if (s.geometry.type !== "Polygon") return { valid: !1, reason: "Feature is not a Polygon" };
|
|
218
|
+
if (s.geometry.coordinates.length !== 1) return { valid: !1, reason: ii };
|
|
219
|
+
if (s.geometry.coordinates[0].length < 4) return { valid: !1, reason: oi };
|
|
220
|
+
for (let o = 0; o < s.geometry.coordinates[0].length; o++) {
|
|
221
|
+
if (!Ut(s.geometry.coordinates[0][o])) return { valid: !1, reason: ri };
|
|
222
|
+
if (!bt(s.geometry.coordinates[0][o], t)) return { valid: !1, reason: "Feature has coordinates with excessive precision" };
|
|
220
223
|
}
|
|
221
|
-
return (e =
|
|
224
|
+
return (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: si } : { valid: !0 };
|
|
222
225
|
var e, i;
|
|
223
226
|
}
|
|
224
|
-
function gt(
|
|
225
|
-
const e = wt(
|
|
226
|
-
return e.valid ? At(
|
|
227
|
+
function gt(s, t) {
|
|
228
|
+
const e = wt(s, t);
|
|
229
|
+
return e.valid ? At(s) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
|
|
227
230
|
}
|
|
228
231
|
const ni = { cancel: "Escape", finish: "Enter" }, ai = { start: "crosshair" };
|
|
229
232
|
let be = class extends A {
|
|
@@ -252,7 +255,7 @@ let be = class extends A {
|
|
|
252
255
|
onClick(t) {
|
|
253
256
|
if (t.button === "right" && this.allowPointerEvent(this.pointerEvents.rightClick, t) || t.button === "left" && this.allowPointerEvent(this.pointerEvents.leftClick, t) || t.isContextMenu && this.allowPointerEvent(this.pointerEvents.contextMenu, t)) if (this.clickCount === 0) {
|
|
254
257
|
this.center = [t.lng, t.lat];
|
|
255
|
-
const e =
|
|
258
|
+
const e = re({ center: this.center, radiusKilometers: this.startingRadiusKilometers, coordinatePrecision: this.coordinatePrecision }), [i] = this.store.create([{ geometry: e.geometry, properties: { mode: this.mode, radiusKilometers: this.startingRadiusKilometers, [S.CURRENTLY_DRAWING]: !0 } }]);
|
|
256
259
|
this.currentCircleId = i, this.clickCount++, this.cursorMovedAfterInitialCursorDown = !1, this.setDrawing();
|
|
257
260
|
} else this.clickCount === 1 && this.center && this.currentCircleId !== void 0 && this.cursorMovedAfterInitialCursorDown && this.updateCircle(t), this.close();
|
|
258
261
|
}
|
|
@@ -279,7 +282,7 @@ let be = class extends A {
|
|
|
279
282
|
}
|
|
280
283
|
}
|
|
281
284
|
styleFeature(t) {
|
|
282
|
-
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
285
|
+
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0, markerUrl: void 0, markerHeight: void 0, markerWidth: void 0 });
|
|
283
286
|
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 = j), e;
|
|
284
287
|
}
|
|
285
288
|
validateFeature(t) {
|
|
@@ -287,26 +290,26 @@ let be = class extends A {
|
|
|
287
290
|
}
|
|
288
291
|
updateCircle(t) {
|
|
289
292
|
if (this.clickCount === 1 && this.center && this.currentCircleId) {
|
|
290
|
-
const e =
|
|
293
|
+
const e = G(this.center, [t.lng, t.lat]);
|
|
291
294
|
let i;
|
|
292
295
|
if (this.projection === "web-mercator") {
|
|
293
|
-
const o = (function(
|
|
294
|
-
const a = 1e3 *
|
|
296
|
+
const o = (function(r, n) {
|
|
297
|
+
const a = 1e3 * G(r, n);
|
|
295
298
|
if (a === 0) return 1;
|
|
296
|
-
const { x: l, y: d } = O(
|
|
299
|
+
const { x: l, y: d } = O(r[0], r[1]), { x: c, y: h } = O(n[0], n[1]);
|
|
297
300
|
return Math.sqrt(Math.pow(c - l, 2) + Math.pow(h - d, 2)) / a;
|
|
298
301
|
})(this.center, [t.lng, t.lat]);
|
|
299
|
-
i = (function(
|
|
300
|
-
const { center: n, radiusKilometers: a, coordinatePrecision: l } =
|
|
302
|
+
i = (function(r) {
|
|
303
|
+
const { center: n, radiusKilometers: a, coordinatePrecision: l } = r, d = r.steps ? r.steps : 64, c = 1e3 * a, [h, u] = n, { x: p, y: g } = O(h, u), y = [];
|
|
301
304
|
for (let f = 0; f < d; f++) {
|
|
302
|
-
const v = 360 * f / d * Math.PI / 180, C = c * Math.cos(v), m = c * Math.sin(v), [P, I] = [p + C, g + m], { lng: w, lat: L } =
|
|
305
|
+
const v = 360 * f / d * Math.PI / 180, C = c * Math.cos(v), m = c * Math.sin(v), [P, I] = [p + C, g + m], { lng: w, lat: L } = U(P, I);
|
|
303
306
|
y.push([b(w, l), b(L, l)]);
|
|
304
307
|
}
|
|
305
308
|
return y.push(y[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [y] }, properties: {} };
|
|
306
309
|
})({ center: this.center, radiusKilometers: e * o, coordinatePrecision: this.coordinatePrecision });
|
|
307
310
|
} else {
|
|
308
311
|
if (this.projection !== "globe") throw new Error("Invalid projection");
|
|
309
|
-
i =
|
|
312
|
+
i = re({ center: this.center, radiusKilometers: e, coordinatePrecision: this.coordinatePrecision });
|
|
310
313
|
}
|
|
311
314
|
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: E.Provisional }).valid) return;
|
|
312
315
|
this.store.updateGeometry([{ id: this.currentCircleId, geometry: i.geometry }]), this.store.updateProperty([{ id: this.currentCircleId, property: "radiusKilometers", value: e }]);
|
|
@@ -316,20 +319,20 @@ let be = class extends A {
|
|
|
316
319
|
this.currentCircleId === t.id && (this.cursorMovedAfterInitialCursorDown = !1, this.center = void 0, this.currentCircleId = void 0, this.clickCount = 0, this.state === "drawing" && this.setStarted());
|
|
317
320
|
}
|
|
318
321
|
};
|
|
319
|
-
const
|
|
320
|
-
const { x: e, y: i } =
|
|
322
|
+
const M = (s, t) => {
|
|
323
|
+
const { x: e, y: i } = s, { x: o, y: r } = t, n = o - e, a = r - i;
|
|
321
324
|
return Math.sqrt(a * a + n * n);
|
|
322
325
|
};
|
|
323
|
-
function yt(
|
|
326
|
+
function yt(s) {
|
|
324
327
|
if (!(function(e) {
|
|
325
328
|
const i = e.coordinates[0];
|
|
326
329
|
let o = 0;
|
|
327
|
-
for (let
|
|
328
|
-
const [n, a] = i[
|
|
330
|
+
for (let r = 0; r < i.length - 1; r++) {
|
|
331
|
+
const [n, a] = i[r], [l, d] = i[r + 1];
|
|
329
332
|
o += (l - n) * (d + a);
|
|
330
333
|
}
|
|
331
334
|
return o < 0;
|
|
332
|
-
})(
|
|
335
|
+
})(s)) return { type: "Polygon", coordinates: [s.coordinates[0].reverse()] };
|
|
333
336
|
}
|
|
334
337
|
const li = { cancel: "Escape", finish: "Enter" }, di = { start: "crosshair", close: "pointer" };
|
|
335
338
|
class we extends A {
|
|
@@ -360,8 +363,8 @@ class we extends A {
|
|
|
360
363
|
}
|
|
361
364
|
onMouseMove(t) {
|
|
362
365
|
if (this.currentId === void 0 || this.startingClick === !1) return void this.setCursor(this.cursors.start);
|
|
363
|
-
const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates[0].length - 2, [o,
|
|
364
|
-
if (
|
|
366
|
+
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 = M({ x: n, y: a }, { x: t.containerX, y: t.containerY }), [d, c] = e.coordinates[0][0], { x: h, y: u } = this.project(d, c);
|
|
367
|
+
if (M({ x: h, y: u }, { x: t.containerX, y: t.containerY }) < this.pointerDistance) {
|
|
365
368
|
if (this.autoClose && this.hasLeftStartingPoint && (this.preventNewFeature = !0, setTimeout(() => {
|
|
366
369
|
this.preventNewFeature = !1;
|
|
367
370
|
}, this.autoCloseTimeout), this.close()), this.setCursor(this.cursors.close), this.preventPointsNearClose) return;
|
|
@@ -401,7 +404,7 @@ class we extends A {
|
|
|
401
404
|
}
|
|
402
405
|
}
|
|
403
406
|
styleFeature(t) {
|
|
404
|
-
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
407
|
+
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0, markerUrl: void 0, markerHeight: void 0, markerWidth: void 0 });
|
|
405
408
|
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 = j, 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 = 50), e);
|
|
406
409
|
}
|
|
407
410
|
validateFeature(t) {
|
|
@@ -412,13 +415,13 @@ class we extends A {
|
|
|
412
415
|
}
|
|
413
416
|
}
|
|
414
417
|
let B = class {
|
|
415
|
-
constructor({ store: t, mode: e, project: i, unproject: o, pointerDistance:
|
|
416
|
-
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 =
|
|
418
|
+
constructor({ store: t, mode: e, project: i, unproject: o, pointerDistance: r, coordinatePrecision: n, projection: a }) {
|
|
419
|
+
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;
|
|
417
420
|
}
|
|
418
421
|
};
|
|
419
|
-
function Le({ unproject:
|
|
420
|
-
const i = e / 2, { x: o, y:
|
|
421
|
-
return { type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [[
|
|
422
|
+
function Le({ unproject: s, point: t, pointerDistance: e }) {
|
|
423
|
+
const i = e / 2, { x: o, y: r } = t;
|
|
424
|
+
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])] } };
|
|
422
425
|
}
|
|
423
426
|
class ct extends B {
|
|
424
427
|
constructor(t) {
|
|
@@ -435,15 +438,15 @@ class ht extends B {
|
|
|
435
438
|
}
|
|
436
439
|
measure(t, e) {
|
|
437
440
|
const { x: i, y: o } = this.project(e[0], e[1]);
|
|
438
|
-
return
|
|
441
|
+
return M({ x: i, y: o }, { x: t.containerX, y: t.containerY });
|
|
439
442
|
}
|
|
440
443
|
}
|
|
441
444
|
let Ot = class extends B {
|
|
442
445
|
constructor(t, e, i) {
|
|
443
|
-
super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => this.getSnappable(o, (
|
|
446
|
+
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;
|
|
444
447
|
}
|
|
445
448
|
getSnappable(t, e) {
|
|
446
|
-
const i = this.clickBoundingBox.create(t), o = this.store.search(i, e),
|
|
449
|
+
const i = this.clickBoundingBox.create(t), o = this.store.search(i, e), r = { featureId: void 0, featureCoordinateIndex: void 0, coordinate: void 0, minDist: 1 / 0 };
|
|
447
450
|
return o.forEach((n) => {
|
|
448
451
|
let a;
|
|
449
452
|
if (n.geometry.type === "Polygon") a = n.geometry.coordinates[0];
|
|
@@ -453,53 +456,53 @@ let Ot = class extends B {
|
|
|
453
456
|
}
|
|
454
457
|
a.forEach((l, d) => {
|
|
455
458
|
const c = this.pixelDistance.measure(t, l);
|
|
456
|
-
c <
|
|
459
|
+
c < r.minDist && c < this.pointerDistance && (r.coordinate = l, r.minDist = c, r.featureId = n.id, r.featureCoordinateIndex = d);
|
|
457
460
|
});
|
|
458
|
-
}),
|
|
461
|
+
}), r;
|
|
459
462
|
}
|
|
460
463
|
};
|
|
461
|
-
function ne(
|
|
462
|
-
const i = D(
|
|
463
|
-
return [V(i + Math.atan2(Math.sin(
|
|
464
|
+
function ne(s, t, e) {
|
|
465
|
+
const i = D(s[0]), o = D(s[1]), r = D(e), n = Ee(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(r));
|
|
466
|
+
return [V(i + Math.atan2(Math.sin(r) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), V(a)];
|
|
464
467
|
}
|
|
465
|
-
function ut({ x:
|
|
468
|
+
function ut({ x: s, y: t }, e, i) {
|
|
466
469
|
const o = D(i);
|
|
467
|
-
return { x:
|
|
470
|
+
return { x: s + e * Math.cos(o), y: t + e * Math.sin(o) };
|
|
468
471
|
}
|
|
469
|
-
function ae(
|
|
470
|
-
const e = D(
|
|
472
|
+
function ae(s, t) {
|
|
473
|
+
const e = D(s[0]), i = D(t[0]), o = D(s[1]), r = D(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);
|
|
471
474
|
return V(Math.atan2(n, a));
|
|
472
475
|
}
|
|
473
|
-
function
|
|
474
|
-
const o = e -
|
|
475
|
-
if (o === 0 &&
|
|
476
|
-
let n = Math.atan2(
|
|
476
|
+
function R({ x: s, y: t }, { x: e, y: i }) {
|
|
477
|
+
const o = e - s, r = i - t;
|
|
478
|
+
if (o === 0 && r === 0) return 0;
|
|
479
|
+
let n = Math.atan2(r, o);
|
|
477
480
|
return n *= 180 / Math.PI, n > 180 ? n -= 360 : n < -180 && (n += 360), n;
|
|
478
481
|
}
|
|
479
|
-
function X(
|
|
480
|
-
return (
|
|
482
|
+
function X(s) {
|
|
483
|
+
return (s + 360) % 360;
|
|
481
484
|
}
|
|
482
|
-
function ci(
|
|
483
|
-
const i = [], o =
|
|
484
|
-
let
|
|
485
|
-
for (let c = 0; c <
|
|
485
|
+
function ci(s, t, e) {
|
|
486
|
+
const i = [], o = s.length;
|
|
487
|
+
let r, n, a, l = 0;
|
|
488
|
+
for (let c = 0; c < s.length && !(t >= l && c === s.length - 1); c++) {
|
|
486
489
|
if (l > t && i.length === 0) {
|
|
487
|
-
if (
|
|
488
|
-
n = ae(
|
|
490
|
+
if (r = t - l, !r) return i.push(s[c]), i;
|
|
491
|
+
n = ae(s[c], s[c - 1]) - 180, a = ne(s[c], r, n), i.push(a);
|
|
489
492
|
}
|
|
490
|
-
if (l >= e) return
|
|
491
|
-
if (l >= t && i.push(
|
|
492
|
-
l +=
|
|
493
|
+
if (l >= e) return r = e - l, r ? (n = ae(s[c], s[c - 1]) - 180, a = ne(s[c], r, n), i.push(a), i) : (i.push(s[c]), i);
|
|
494
|
+
if (l >= t && i.push(s[c]), c === s.length - 1) return i;
|
|
495
|
+
l += G(s[c], s[c + 1]);
|
|
493
496
|
}
|
|
494
|
-
if (l < t &&
|
|
495
|
-
const d =
|
|
497
|
+
if (l < t && s.length === o) throw new Error("Start position is beyond line");
|
|
498
|
+
const d = s[s.length - 1];
|
|
496
499
|
return [d, d];
|
|
497
500
|
}
|
|
498
|
-
function mt(
|
|
499
|
-
return
|
|
501
|
+
function mt(s) {
|
|
502
|
+
return s * (Math.PI / 180);
|
|
500
503
|
}
|
|
501
|
-
function le(
|
|
502
|
-
return
|
|
504
|
+
function le(s) {
|
|
505
|
+
return s * (180 / Math.PI);
|
|
503
506
|
}
|
|
504
507
|
class hi extends B {
|
|
505
508
|
constructor(t) {
|
|
@@ -507,10 +510,10 @@ class hi extends B {
|
|
|
507
510
|
}
|
|
508
511
|
generateInsertionCoordinates(t, e, i) {
|
|
509
512
|
const o = [t, e];
|
|
510
|
-
let
|
|
511
|
-
for (let d = 0; d < o.length - 1; d++)
|
|
512
|
-
if (
|
|
513
|
-
let n =
|
|
513
|
+
let r = 0;
|
|
514
|
+
for (let d = 0; d < o.length - 1; d++) r += G(o[0], o[1]);
|
|
515
|
+
if (r <= i) return o;
|
|
516
|
+
let n = r / i - 1;
|
|
514
517
|
Number.isInteger(n) || (n = Math.floor(n) + 1);
|
|
515
518
|
const a = [];
|
|
516
519
|
for (let d = 0; d < n; d++) {
|
|
@@ -522,7 +525,7 @@ class hi extends B {
|
|
|
522
525
|
return this.limitCoordinates(l);
|
|
523
526
|
}
|
|
524
527
|
generateInsertionGeodesicCoordinates(t, e, i) {
|
|
525
|
-
const o =
|
|
528
|
+
const o = G(t, e), r = (function(n, a, l) {
|
|
526
529
|
const d = [], c = mt(n[1]), h = mt(n[0]), u = mt(a[1]), p = mt(a[0]);
|
|
527
530
|
l += 1;
|
|
528
531
|
const g = 2 * Math.asin(Math.sqrt(Math.sin((u - c) / 2) ** 2 + Math.cos(c) * Math.cos(u) * Math.sin((p - h) / 2) ** 2));
|
|
@@ -535,66 +538,66 @@ class hi extends B {
|
|
|
535
538
|
}
|
|
536
539
|
return d.slice(1, -1);
|
|
537
540
|
})(t, e, Math.floor(o / i));
|
|
538
|
-
return this.limitCoordinates(
|
|
541
|
+
return this.limitCoordinates(r);
|
|
539
542
|
}
|
|
540
543
|
limitCoordinates(t) {
|
|
541
544
|
return t.map((e) => [b(e[0], this.config.coordinatePrecision), b(e[1], this.config.coordinatePrecision)]);
|
|
542
545
|
}
|
|
543
546
|
}
|
|
544
|
-
function et(
|
|
545
|
-
return
|
|
547
|
+
function et(s, t) {
|
|
548
|
+
return s[0] === t[0] && s[1] === t[1];
|
|
546
549
|
}
|
|
547
|
-
function
|
|
548
|
-
if (
|
|
549
|
-
if (
|
|
550
|
-
for (let e = 0; e <
|
|
551
|
-
if (!
|
|
552
|
-
if (!bt(
|
|
550
|
+
function Rt(s, t) {
|
|
551
|
+
if (s.geometry.type !== "LineString") return { valid: !1, reason: "Feature is not a LineString" };
|
|
552
|
+
if (s.geometry.coordinates.length < 2) return { valid: !1, reason: "Feature has less than 2 coordinates" };
|
|
553
|
+
for (let e = 0; e < s.geometry.coordinates.length; e++) {
|
|
554
|
+
if (!Ut(s.geometry.coordinates[e])) return { valid: !1, reason: "Feature has invalid coordinates" };
|
|
555
|
+
if (!bt(s.geometry.coordinates[e], t)) return { valid: !1, reason: "Feature has coordinates with excessive precision" };
|
|
553
556
|
}
|
|
554
557
|
return { valid: !0 };
|
|
555
558
|
}
|
|
556
|
-
function de(
|
|
557
|
-
return Math.sqrt(Math.pow(
|
|
559
|
+
function de(s) {
|
|
560
|
+
return Math.sqrt(Math.pow(s[0], 2) + Math.pow(s[1], 2) + Math.pow(s[2], 2));
|
|
558
561
|
}
|
|
559
|
-
function Y(
|
|
562
|
+
function Y(s, t) {
|
|
560
563
|
const e = (function(i, o) {
|
|
561
|
-
const [
|
|
562
|
-
return
|
|
563
|
-
})(
|
|
564
|
+
const [r, n, a] = i, [l, d, c] = o;
|
|
565
|
+
return r * l + n * d + a * c;
|
|
566
|
+
})(s, t) / (de(s) * de(t));
|
|
564
567
|
return Math.acos(Math.min(Math.max(e, -1), 1));
|
|
565
568
|
}
|
|
566
|
-
function
|
|
567
|
-
const t = D(
|
|
569
|
+
function Mt(s) {
|
|
570
|
+
const t = D(s[1]), e = D(s[0]);
|
|
568
571
|
return [Math.cos(t) * Math.cos(e), Math.cos(t) * Math.sin(e), Math.sin(t)];
|
|
569
572
|
}
|
|
570
|
-
function K(
|
|
571
|
-
const [t, e, i] =
|
|
573
|
+
function K(s) {
|
|
574
|
+
const [t, e, i] = s, o = V(Math.asin(i));
|
|
572
575
|
return [V(Math.atan2(e, t)), o];
|
|
573
576
|
}
|
|
574
|
-
function ui(
|
|
575
|
-
const i =
|
|
576
|
-
const [Xt, qt,
|
|
577
|
-
return [qt * Qt -
|
|
578
|
-
})(i, o), u = c * l - h * a, p = h * n - d * l, g = d * a - c * n, y = g * c - p * h, f = u * h - g * d, v = p * d - u * c, C = 1 / Math.sqrt(Math.pow(y, 2) + Math.pow(f, 2) + Math.pow(v, 2)), m = [y * C, f * C, v * C], P = [-1 * y * C, -1 * f * C, -1 * v * C], I = Y(i, o), w = Y(i, m), L = Y(o, m),
|
|
577
|
+
function ui(s, t, e) {
|
|
578
|
+
const i = Mt(s), o = Mt(t), r = Mt(e), [n, a, l] = r, [d, c, h] = (function(T, $) {
|
|
579
|
+
const [Xt, qt, Ht] = T, [Jt, Zt, Qt] = $;
|
|
580
|
+
return [qt * Qt - Ht * Zt, Ht * Jt - Xt * Qt, Xt * Zt - qt * Jt];
|
|
581
|
+
})(i, o), u = c * l - h * a, p = h * n - d * l, g = d * a - c * n, y = g * c - p * h, f = u * h - g * d, v = p * d - u * c, C = 1 / Math.sqrt(Math.pow(y, 2) + Math.pow(f, 2) + Math.pow(v, 2)), m = [y * C, f * C, v * C], P = [-1 * y * C, -1 * f * C, -1 * v * C], I = Y(i, o), w = Y(i, m), L = Y(o, m), F = Y(i, P), N = Y(o, P);
|
|
579
582
|
let _;
|
|
580
|
-
return _ = w <
|
|
583
|
+
return _ = w < F && w < N || L < F && L < N ? m : P, Y(i, _) > I || Y(o, _) > I ? G(K(_), K(i)) <= G(K(_), K(o)) ? [K(i), !0, !1] : [K(o), !1, !0] : [K(_), !1, !1];
|
|
581
584
|
}
|
|
582
|
-
function pi(
|
|
583
|
-
const i = t.x -
|
|
584
|
-
return { x:
|
|
585
|
+
function pi(s, t, e) {
|
|
586
|
+
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)));
|
|
587
|
+
return { x: s.x + r * i, y: s.y + r * o };
|
|
585
588
|
}
|
|
586
|
-
class
|
|
589
|
+
class Gt extends B {
|
|
587
590
|
constructor(t, e, i) {
|
|
588
591
|
super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => {
|
|
589
|
-
const
|
|
590
|
-
return
|
|
591
|
-
}, this.getSnappableCoordinate = (o,
|
|
592
|
-
const n = this.getSnappable(o, (a) => !!(a.properties && a.properties.mode === this.mode && a.id !==
|
|
592
|
+
const r = this.getSnappable(o, (n) => !!(n.properties && n.properties.mode === this.mode));
|
|
593
|
+
return r.coordinate ? [b(r.coordinate[0], this.config.coordinatePrecision), b(r.coordinate[1], this.config.coordinatePrecision)] : void 0;
|
|
594
|
+
}, this.getSnappableCoordinate = (o, r) => {
|
|
595
|
+
const n = this.getSnappable(o, (a) => !!(a.properties && a.properties.mode === this.mode && a.id !== r));
|
|
593
596
|
return n.coordinate ? [b(n.coordinate[0], this.config.coordinatePrecision), b(n.coordinate[1], this.config.coordinatePrecision)] : void 0;
|
|
594
597
|
}, this.config = t, this.pixelDistance = e, this.clickBoundingBox = i;
|
|
595
598
|
}
|
|
596
599
|
getSnappable(t, e) {
|
|
597
|
-
const i = this.clickBoundingBox.create(t), o = this.store.search(i, e),
|
|
600
|
+
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 };
|
|
598
601
|
return o.forEach((n) => {
|
|
599
602
|
let a;
|
|
600
603
|
if (n.geometry.type === "Polygon") a = n.geometry.coordinates[0];
|
|
@@ -611,14 +614,14 @@ class Ut extends B {
|
|
|
611
614
|
for (let v of p) {
|
|
612
615
|
const C = v[0], m = v[1];
|
|
613
616
|
let P, I = 1 / 0;
|
|
614
|
-
const w = O(C[0], C[1]), L = O(m[0], m[1]),
|
|
617
|
+
const w = O(C[0], C[1]), L = O(m[0], m[1]), F = O(u[0], u[1]);
|
|
615
618
|
if (C[0] === u[0] && C[1] === u[1]) P = C;
|
|
616
619
|
else if (m[0] === u[0] && m[1] === u[1]) P = m;
|
|
617
620
|
else {
|
|
618
|
-
const { x: N, y: _ } = pi(w, L,
|
|
621
|
+
const { x: N, y: _ } = pi(w, L, F), { lng: T, lat: $ } = U(N, _);
|
|
619
622
|
P = [T, $];
|
|
620
623
|
}
|
|
621
|
-
P && (I = F
|
|
624
|
+
P && (I = M(F, O(P[0], P[1])), I < y && (g = P, y = I, f = p.indexOf(v)));
|
|
622
625
|
}
|
|
623
626
|
return y === 1 / 0 ? void 0 : { coordinate: g, lineIndex: f, distance: y };
|
|
624
627
|
})(c, l) : this.config.projection === "globe" && (d = (function(u, p) {
|
|
@@ -626,13 +629,13 @@ class Ut extends B {
|
|
|
626
629
|
for (let v of p) {
|
|
627
630
|
const C = v[0], m = v[1];
|
|
628
631
|
let P, I = 1 / 0;
|
|
629
|
-
C[0] === u[0] && C[1] === u[1] ? P = C : m[0] === u[0] && m[1] === u[1] ? P = m : [P] = ui(C, m, u), P && (I =
|
|
632
|
+
C[0] === u[0] && C[1] === u[1] ? P = C : m[0] === u[0] && m[1] === u[1] ? P = m : [P] = ui(C, m, u), P && (I = G(u, P), I < y && (g = P, y = I, f = p.indexOf(v)));
|
|
630
633
|
}
|
|
631
634
|
return y === 1 / 0 ? void 0 : { coordinate: g, distance: y, lineIndex: f };
|
|
632
635
|
})(c, l)), !d) return;
|
|
633
636
|
const h = this.pixelDistance.measure(t, d.coordinate);
|
|
634
|
-
h <
|
|
635
|
-
}),
|
|
637
|
+
h < r.minDistance && h < this.pointerDistance && (r.featureId = n.id, r.coordinate = [b(d.coordinate[0], this.config.coordinatePrecision), b(d.coordinate[1], this.config.coordinatePrecision)], r.featureCoordinateIndex = d.lineIndex, r.minDistance = h);
|
|
638
|
+
}), r;
|
|
636
639
|
}
|
|
637
640
|
}
|
|
638
641
|
const gi = { cancel: "Escape", finish: "Enter" }, yi = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
@@ -666,13 +669,13 @@ class zt extends A {
|
|
|
666
669
|
if (!this.currentId) return;
|
|
667
670
|
const o = { type: "LineString", coordinates: t };
|
|
668
671
|
if (this.validate && !this.validate({ type: "Feature", geometry: o }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: i }).valid) return;
|
|
669
|
-
const
|
|
670
|
-
this.closingPointId && e &&
|
|
672
|
+
const r = [{ id: this.currentId, geometry: o }];
|
|
673
|
+
this.closingPointId && e && r.push({ id: this.closingPointId, geometry: { type: "Point", coordinates: e } }), i === "commit" && (this.lastCommittedCoordinates = o.coordinates), this.store.updateGeometry(r);
|
|
671
674
|
}
|
|
672
675
|
generateInsertCoordinates(t, e) {
|
|
673
676
|
if (!this.insertCoordinates || !this.lastCommittedCoordinates) throw new Error("Not able to insert coordinates");
|
|
674
677
|
if (this.insertCoordinates.strategy !== "amount") throw new Error("Strategy does not exist");
|
|
675
|
-
const i =
|
|
678
|
+
const i = G(t, e) / (this.insertCoordinates.value + 1);
|
|
676
679
|
let o = [];
|
|
677
680
|
return this.projection === "globe" ? o = this.insertPoint.generateInsertionGeodesicCoordinates(t, e, i) : this.projection === "web-mercator" && (o = this.insertPoint.generateInsertionCoordinates(t, e, i)), o;
|
|
678
681
|
}
|
|
@@ -689,14 +692,14 @@ class zt extends A {
|
|
|
689
692
|
}
|
|
690
693
|
updateToLine(t, e) {
|
|
691
694
|
if (!this.currentId) return;
|
|
692
|
-
const i = this.store.getGeometryCopy(this.currentId).coordinates, [o,
|
|
693
|
-
if (
|
|
695
|
+
const i = this.store.getGeometryCopy(this.currentId).coordinates, [o, r] = this.lastCommittedCoordinates ? this.lastCommittedCoordinates[this.lastCommittedCoordinates.length - 1] : i[i.length - 2], { x: n, y: a } = this.project(o, r);
|
|
696
|
+
if (M({ x: n, y: a }, { x: e.x, y: e.y }) < this.pointerDistance) return void this.close();
|
|
694
697
|
this.setCursor(this.cursors.close);
|
|
695
698
|
const l = [...i, t];
|
|
696
699
|
this.updateGeometries(l, i[i.length - 1], E.Commit), this.currentCoordinate++;
|
|
697
700
|
}
|
|
698
701
|
registerBehaviors(t) {
|
|
699
|
-
this.coordinateSnapping = new Ot(t, new ht(t), new ct(t)), this.insertPoint = new hi(t), this.clickBoundingBox = new ct(t), this.pixelDistance = new ht(t), this.lineSnapping = new
|
|
702
|
+
this.coordinateSnapping = new Ot(t, new ht(t), new ct(t)), this.insertPoint = new hi(t), this.clickBoundingBox = new ct(t), this.pixelDistance = new ht(t), this.lineSnapping = new Gt(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new Ot(t, this.pixelDistance, this.clickBoundingBox);
|
|
700
703
|
}
|
|
701
704
|
start() {
|
|
702
705
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -710,14 +713,14 @@ class zt extends A {
|
|
|
710
713
|
if (this.currentId === void 0 || this.currentCoordinate === 0) return;
|
|
711
714
|
const i = this.store.getGeometryCopy(this.currentId).coordinates;
|
|
712
715
|
if (i.pop(), this.closingPointId) {
|
|
713
|
-
const [
|
|
714
|
-
|
|
716
|
+
const [r, n] = i[i.length - 1], { x: a, y: l } = this.project(r, n);
|
|
717
|
+
M({ x: a, y: l }, { x: t.containerX, y: t.containerY }) < this.pointerDistance && this.setCursor(this.cursors.close);
|
|
715
718
|
}
|
|
716
719
|
let o = [...i, e];
|
|
717
720
|
if (this.insertCoordinates && this.currentId && this.lastCommittedCoordinates) {
|
|
718
|
-
const
|
|
719
|
-
if (!et(
|
|
720
|
-
const a = this.generateInsertCoordinates(
|
|
721
|
+
const r = this.lastCommittedCoordinates[this.lastCommittedCoordinates.length - 1], n = e;
|
|
722
|
+
if (!et(r, n)) {
|
|
723
|
+
const a = this.generateInsertCoordinates(r, n);
|
|
721
724
|
o = [...this.lastCommittedCoordinates.slice(0, -1), ...a, e];
|
|
722
725
|
}
|
|
723
726
|
}
|
|
@@ -728,9 +731,9 @@ class zt extends A {
|
|
|
728
731
|
const { featureId: e, featureCoordinateIndex: i } = this.coordinateSnapping.getSnappable(t, (n) => this.lineStringFilter(n));
|
|
729
732
|
if (!e || i === void 0) return;
|
|
730
733
|
const o = this.store.getGeometryCopy(e);
|
|
731
|
-
let
|
|
732
|
-
if (o.type === "LineString" && (
|
|
733
|
-
if (
|
|
734
|
+
let r;
|
|
735
|
+
if (o.type === "LineString" && (r = o.coordinates, !(r.length <= 2))) {
|
|
736
|
+
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: E.Commit }).valid) return;
|
|
734
737
|
this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: e, geometry: o }]), this.onFinish(e, { mode: this.mode, action: "edit" });
|
|
735
738
|
}
|
|
736
739
|
}
|
|
@@ -753,8 +756,8 @@ class zt extends A {
|
|
|
753
756
|
if (this.state === "started") {
|
|
754
757
|
const o = this.lineSnapping.getSnappable(t, (n) => this.lineStringFilter(n));
|
|
755
758
|
o.coordinate && (this.editedSnapType = "line", this.editedFeatureCoordinateIndex = o.featureCoordinateIndex, this.editedFeatureId = o.featureId, i = o.coordinate);
|
|
756
|
-
const
|
|
757
|
-
|
|
759
|
+
const r = this.coordinateSnapping.getSnappable(t, (n) => this.lineStringFilter(n));
|
|
760
|
+
r.coordinate && (this.editedSnapType = "coordinate", this.editedFeatureCoordinateIndex = r.featureCoordinateIndex, this.editedFeatureId = r.featureId, i = r.coordinate);
|
|
758
761
|
}
|
|
759
762
|
if (this.editedFeatureId && i) {
|
|
760
763
|
if (!this.editedPointId) {
|
|
@@ -783,7 +786,7 @@ class zt extends A {
|
|
|
783
786
|
}
|
|
784
787
|
}
|
|
785
788
|
styleFeature(t) {
|
|
786
|
-
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
789
|
+
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0, markerUrl: void 0, markerHeight: void 0, markerWidth: void 0 });
|
|
787
790
|
if (t.type === "Feature" && t.geometry.type === "LineString" && t.properties.mode === this.mode) return e.lineStringColor = this.getHexColorStylingValue(this.styles.lineStringColor, e.lineStringColor, t), e.lineStringWidth = this.getNumericStylingValue(this.styles.lineStringWidth, e.lineStringWidth, t), e.zIndex = j, e;
|
|
788
791
|
if (t.type === "Feature" && t.geometry.type === "Point" && t.properties.mode === this.mode) {
|
|
789
792
|
const i = t.properties[S.CLOSING_POINT];
|
|
@@ -792,27 +795,27 @@ class zt extends A {
|
|
|
792
795
|
return e;
|
|
793
796
|
}
|
|
794
797
|
validateFeature(t) {
|
|
795
|
-
return this.validateModeFeature(t, (e) =>
|
|
798
|
+
return this.validateModeFeature(t, (e) => Rt(e, this.coordinatePrecision));
|
|
796
799
|
}
|
|
797
800
|
lineStringFilter(t) {
|
|
798
801
|
return !!(t.geometry.type === "LineString" && t.properties && t.properties.mode === this.mode);
|
|
799
802
|
}
|
|
800
803
|
snapCoordinate(t) {
|
|
801
804
|
var e, i, o;
|
|
802
|
-
let
|
|
805
|
+
let r;
|
|
803
806
|
if ((e = this.snapping) != null && e.toLine) {
|
|
804
807
|
let n;
|
|
805
|
-
n = this.currentId ? this.lineSnapping.getSnappableCoordinate(t, this.currentId) : this.lineSnapping.getSnappableCoordinateFirstClick(t), n && (
|
|
808
|
+
n = this.currentId ? this.lineSnapping.getSnappableCoordinate(t, this.currentId) : this.lineSnapping.getSnappableCoordinateFirstClick(t), n && (r = n);
|
|
806
809
|
}
|
|
807
|
-
return (i = this.snapping) != null && i.toCoordinate && (
|
|
810
|
+
return (i = this.snapping) != null && i.toCoordinate && (r = this.currentId ? this.coordinateSnapping.getSnappableCoordinate(t, this.currentId) : this.coordinateSnapping.getSnappableCoordinateFirstClick(t)), (o = this.snapping) != null && o.toCustom && (r = this.snapping.toCustom(t, { currentCoordinate: this.currentCoordinate, currentId: this.currentId, getCurrentGeometrySnapshot: this.currentId ? () => this.store.getGeometryCopy(this.currentId) : () => null, project: this.project, unproject: this.unproject })), r;
|
|
808
811
|
}
|
|
809
812
|
afterFeatureUpdated(t) {
|
|
810
813
|
this.editedFeatureId === t.id && this.editedPointId && (this.store.delete([this.editedPointId]), this.editedPointId = void 0, this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedSnapType = void 0), this.snappedPointId && this.lastMouseMoveEvent && this.updateSnappedCoordinate(this.lastMouseMoveEvent), this.currentId === t.id && (this.closingPointId && (this.store.delete([this.closingPointId]), this.closingPointId = void 0), this.currentCoordinate = 0, this.currentId = void 0, this.state === "drawing" && this.setStarted());
|
|
811
814
|
}
|
|
812
815
|
}
|
|
813
816
|
const fi = "Feature is not a Point", mi = "Feature has invalid coordinates", vi = "Feature has coordinates with excessive precision";
|
|
814
|
-
function
|
|
815
|
-
return
|
|
817
|
+
function Me(s, t) {
|
|
818
|
+
return s.geometry.type !== "Point" ? { valid: !1, reason: fi } : Ut(s.geometry.coordinates) ? bt(s.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: vi } : { valid: !1, reason: mi };
|
|
816
819
|
}
|
|
817
820
|
const Ci = { create: "crosshair", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
818
821
|
class Vt extends A {
|
|
@@ -859,7 +862,7 @@ class Vt extends A {
|
|
|
859
862
|
this.pixelDistance = new ht(t), this.clickBoundingBox = new ct(t);
|
|
860
863
|
}
|
|
861
864
|
styleFeature(t) {
|
|
862
|
-
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
865
|
+
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0, markerUrl: void 0, markerHeight: void 0, markerWidth: void 0 });
|
|
863
866
|
if (t.type === "Feature" && t.geometry.type === "Point" && t.properties.mode === this.mode) {
|
|
864
867
|
const i = !!(t.id && this.editedFeatureId === t.id);
|
|
865
868
|
e.pointWidth = this.getNumericStylingValue(i ? this.styles.editedPointWidth : this.styles.pointWidth, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(i ? this.styles.editedPointColor : this.styles.pointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(i ? this.styles.editedPointOutlineColor : this.styles.pointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(i ? this.styles.editedPointOutlineWidth : this.styles.pointOutlineWidth, 2, t), e.zIndex = 30;
|
|
@@ -867,7 +870,7 @@ class Vt extends A {
|
|
|
867
870
|
return e;
|
|
868
871
|
}
|
|
869
872
|
validateFeature(t) {
|
|
870
|
-
return this.validateModeFeature(t, (e) =>
|
|
873
|
+
return this.validateModeFeature(t, (e) => Me(e, this.coordinatePrecision));
|
|
871
874
|
}
|
|
872
875
|
onLeftClick(t) {
|
|
873
876
|
const e = { type: "Point", coordinates: [t.lng, t.lat] }, i = { mode: this.mode };
|
|
@@ -882,12 +885,12 @@ class Vt extends A {
|
|
|
882
885
|
}
|
|
883
886
|
getNearestPointFeature(t) {
|
|
884
887
|
const e = this.clickBoundingBox.create(t), i = this.store.search(e);
|
|
885
|
-
let o,
|
|
888
|
+
let o, r = 1 / 0;
|
|
886
889
|
for (let n = 0; n < i.length; n++) {
|
|
887
890
|
const a = i[n];
|
|
888
891
|
if (a.geometry.type !== "Point" || a.properties.mode !== this.mode) continue;
|
|
889
892
|
const l = this.pixelDistance.measure(t, a.geometry.coordinates);
|
|
890
|
-
l >
|
|
893
|
+
l > r || l > this.pointerDistance || (r = l, o = a);
|
|
891
894
|
}
|
|
892
895
|
return o;
|
|
893
896
|
}
|
|
@@ -917,11 +920,11 @@ class Pi extends B {
|
|
|
917
920
|
this.store.updateGeometry([{ id: this.ids[0], geometry: { type: "Point", coordinates: t[0] } }, { id: this.ids[1], geometry: { type: "Point", coordinates: t[t.length - 3] } }]);
|
|
918
921
|
}
|
|
919
922
|
isClosingPoint(t) {
|
|
920
|
-
const e = this.store.getGeometryCopy(this.ids[0]), i = this.store.getGeometryCopy(this.ids[1]), o = this.pixelDistance.measure(t, e.coordinates),
|
|
921
|
-
return { isClosing: o < this.pointerDistance, isPreviousClosing:
|
|
923
|
+
const e = this.store.getGeometryCopy(this.ids[0]), i = this.store.getGeometryCopy(this.ids[1]), o = this.pixelDistance.measure(t, e.coordinates), r = this.pixelDistance.measure(t, i.coordinates);
|
|
924
|
+
return { isClosing: o < this.pointerDistance, isPreviousClosing: r < this.pointerDistance };
|
|
922
925
|
}
|
|
923
926
|
}
|
|
924
|
-
class
|
|
927
|
+
class Fe extends B {
|
|
925
928
|
constructor(t) {
|
|
926
929
|
super(t);
|
|
927
930
|
}
|
|
@@ -933,9 +936,9 @@ class Me extends B {
|
|
|
933
936
|
if (e.type !== "LineString") return;
|
|
934
937
|
o = e.coordinates;
|
|
935
938
|
}
|
|
936
|
-
const
|
|
939
|
+
const r = this.store.getPropertiesCopy(t), n = r.coordinatePointIds;
|
|
937
940
|
if (n) if (n && n.every((a) => this.store.has(a))) {
|
|
938
|
-
const a =
|
|
941
|
+
const a = r.coordinatePointIds, l = a.map((d) => this.store.getGeometryCopy(d).coordinates);
|
|
939
942
|
if (a.length !== o.length) {
|
|
940
943
|
this.deleteCoordinatePoints(a);
|
|
941
944
|
const d = this.createPoints(o, i.mode, t);
|
|
@@ -959,10 +962,10 @@ class Me extends B {
|
|
|
959
962
|
}
|
|
960
963
|
getUpdated(t, e) {
|
|
961
964
|
const i = this.store.getPropertiesCopy(t);
|
|
962
|
-
if (i.coordinatePointIds) return i.coordinatePointIds.map((o,
|
|
965
|
+
if (i.coordinatePointIds) return i.coordinatePointIds.map((o, r) => ({ id: o, geometry: x({}, this.store.getGeometryCopy(o), { coordinates: e[r] }) }));
|
|
963
966
|
}
|
|
964
967
|
createPoints(t, e, i) {
|
|
965
|
-
return this.store.create(t.map((o,
|
|
968
|
+
return this.store.create(t.map((o, r) => ({ geometry: { type: "Point", coordinates: o }, properties: { mode: e, [S.COORDINATE_POINT]: !0, [S.COORDINATE_POINT_FEATURE_ID]: i, index: r } })));
|
|
966
969
|
}
|
|
967
970
|
setFeatureCoordinatePoints(t, e) {
|
|
968
971
|
this.store.updateProperty([{ id: t, property: S.COORDINATE_POINT_IDS, value: e }]);
|
|
@@ -1004,7 +1007,7 @@ class De extends A {
|
|
|
1004
1007
|
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" });
|
|
1005
1008
|
}
|
|
1006
1009
|
registerBehaviors(t) {
|
|
1007
|
-
this.clickBoundingBox = new ct(t), this.pixelDistance = new ht(t), this.lineSnapping = new
|
|
1010
|
+
this.clickBoundingBox = new ct(t), this.pixelDistance = new ht(t), this.lineSnapping = new Gt(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new Ot(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new Pi(t, this.pixelDistance), this.coordinatePoints = new Fe(t);
|
|
1008
1011
|
}
|
|
1009
1012
|
start() {
|
|
1010
1013
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -1028,12 +1031,12 @@ class De extends A {
|
|
|
1028
1031
|
const e = this.store.getGeometryCopy(this.currentId).coordinates[0];
|
|
1029
1032
|
let i;
|
|
1030
1033
|
if (this.currentCoordinate === 1) {
|
|
1031
|
-
const o = 1 / Math.pow(10, this.coordinatePrecision - 1),
|
|
1032
|
-
i = [e[0], [t.lng, t.lat], [t.lng, t.lat -
|
|
1034
|
+
const o = 1 / Math.pow(10, this.coordinatePrecision - 1), r = Math.max(1e-6, o);
|
|
1035
|
+
i = [e[0], [t.lng, t.lat], [t.lng, t.lat - r], e[0]];
|
|
1033
1036
|
} else if (this.currentCoordinate === 2) i = [e[0], e[1], [t.lng, t.lat], e[0]];
|
|
1034
1037
|
else {
|
|
1035
|
-
const { isClosing: o, isPreviousClosing:
|
|
1036
|
-
|
|
1038
|
+
const { isClosing: o, isPreviousClosing: r } = this.closingPoints.isClosingPoint(t);
|
|
1039
|
+
r || o ? (this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.setCursor(this.cursors.close), i = [...e.slice(0, -2), e[0], e[0]]) : i = [...e.slice(0, -2), [t.lng, t.lat], e[0]];
|
|
1037
1040
|
}
|
|
1038
1041
|
this.store.updateProperty([{ id: this.currentId, property: S.PROVISIONAL_COORDINATE_COUNT, value: this.currentCoordinate + 1 }]), this.updatePolygonGeometry(i, E.Provisional);
|
|
1039
1042
|
}
|
|
@@ -1044,16 +1047,16 @@ class De extends A {
|
|
|
1044
1047
|
}
|
|
1045
1048
|
snapCoordinate(t) {
|
|
1046
1049
|
var e, i, o;
|
|
1047
|
-
let
|
|
1050
|
+
let r;
|
|
1048
1051
|
if ((e = this.snapping) != null && e.toLine) {
|
|
1049
1052
|
let n;
|
|
1050
|
-
n = this.currentId ? this.lineSnapping.getSnappableCoordinate(t, this.currentId) : this.lineSnapping.getSnappableCoordinateFirstClick(t), n && (
|
|
1053
|
+
n = this.currentId ? this.lineSnapping.getSnappableCoordinate(t, this.currentId) : this.lineSnapping.getSnappableCoordinateFirstClick(t), n && (r = n);
|
|
1051
1054
|
}
|
|
1052
1055
|
if ((i = this.snapping) != null && i.toCoordinate) {
|
|
1053
1056
|
let n;
|
|
1054
|
-
n = this.currentId ? this.coordinateSnapping.getSnappableCoordinate(t, this.currentId) : this.coordinateSnapping.getSnappableCoordinateFirstClick(t), n && (
|
|
1057
|
+
n = this.currentId ? this.coordinateSnapping.getSnappableCoordinate(t, this.currentId) : this.coordinateSnapping.getSnappableCoordinateFirstClick(t), n && (r = n);
|
|
1055
1058
|
}
|
|
1056
|
-
return (o = this.snapping) != null && o.toCustom && (
|
|
1059
|
+
return (o = this.snapping) != null && o.toCustom && (r = this.snapping.toCustom(t, { currentCoordinate: this.currentCoordinate, currentId: this.currentId, getCurrentGeometrySnapshot: this.currentId ? () => this.store.getGeometryCopy(this.currentId) : () => null, project: this.project, unproject: this.unproject })), r;
|
|
1057
1060
|
}
|
|
1058
1061
|
polygonFilter(t) {
|
|
1059
1062
|
return !!(t.geometry.type === "Polygon" && t.properties && t.properties.mode === this.mode);
|
|
@@ -1063,8 +1066,8 @@ class De extends A {
|
|
|
1063
1066
|
const { featureId: e, featureCoordinateIndex: i } = this.coordinateSnapping.getSnappable(t, (n) => this.polygonFilter(n));
|
|
1064
1067
|
if (!e || i === void 0) return;
|
|
1065
1068
|
const o = this.store.getGeometryCopy(e);
|
|
1066
|
-
let
|
|
1067
|
-
o.type === "Polygon" && (
|
|
1069
|
+
let r;
|
|
1070
|
+
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: E.Commit }).valid) && (this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: e, geometry: o }]), this.showCoordinatePoints && this.coordinatePoints.createOrUpdate(e), this.onFinish(e, { mode: this.mode, action: "edit" }))));
|
|
1068
1071
|
}
|
|
1069
1072
|
onLeftClick(t) {
|
|
1070
1073
|
if (this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.currentCoordinate === 0) {
|
|
@@ -1088,8 +1091,8 @@ class De extends A {
|
|
|
1088
1091
|
const e = this.store.getGeometryCopy(this.currentId).coordinates[0], { isClosing: i, isPreviousClosing: o } = this.closingPoints.isClosingPoint(t);
|
|
1089
1092
|
if (o || i) this.close();
|
|
1090
1093
|
else {
|
|
1091
|
-
const
|
|
1092
|
-
if (
|
|
1094
|
+
const r = this.snapCoordinate(t);
|
|
1095
|
+
if (r && (t.lng = r[0], t.lat = r[1]), et([t.lng, t.lat], e[this.currentCoordinate - 1])) return;
|
|
1093
1096
|
const n = /* @__PURE__ */ (function(a = [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]) {
|
|
1094
1097
|
return { type: "Feature", geometry: { type: "Polygon", coordinates: a }, properties: {} };
|
|
1095
1098
|
})([[...e.slice(0, -1), [t.lng, t.lat], e[0]]]);
|
|
@@ -1112,8 +1115,8 @@ class De extends A {
|
|
|
1112
1115
|
if (this.state === "started") {
|
|
1113
1116
|
const o = this.lineSnapping.getSnappable(t, (n) => this.polygonFilter(n));
|
|
1114
1117
|
o.coordinate && (this.editedSnapType = "line", this.editedFeatureCoordinateIndex = o.featureCoordinateIndex, this.editedFeatureId = o.featureId, i = o.coordinate);
|
|
1115
|
-
const
|
|
1116
|
-
|
|
1118
|
+
const r = this.coordinateSnapping.getSnappable(t, (n) => this.polygonFilter(n));
|
|
1119
|
+
r.coordinate && (this.editedSnapType = "coordinate", this.editedFeatureCoordinateIndex = r.featureCoordinateIndex, this.editedFeatureId = r.featureId, i = r.coordinate);
|
|
1117
1120
|
}
|
|
1118
1121
|
if (this.editedFeatureId && i) {
|
|
1119
1122
|
if (!this.editedPointId) {
|
|
@@ -1127,8 +1130,8 @@ class De extends A {
|
|
|
1127
1130
|
if (!this.allowPointerEvent(this.pointerEvents.onDrag, t) || this.editedFeatureId === void 0 || this.editedFeatureCoordinateIndex === void 0) return;
|
|
1128
1131
|
const i = this.store.getGeometryCopy(this.editedFeatureId), o = i.coordinates[0];
|
|
1129
1132
|
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++);
|
|
1130
|
-
const
|
|
1131
|
-
this.validate && !this.validate({ type: "Feature", geometry:
|
|
1133
|
+
const r = { type: "Polygon", coordinates: i.coordinates };
|
|
1134
|
+
this.validate && !this.validate({ type: "Feature", geometry: r, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: E.Provisional }).valid || (this.snapping && this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: this.editedFeatureId, geometry: r }]), this.showCoordinatePoints && this.coordinatePoints.createOrUpdate(this.editedFeatureId), this.editedPointId && this.store.updateGeometry([{ id: this.editedPointId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: S.EDITED, value: !0 }]));
|
|
1132
1135
|
}
|
|
1133
1136
|
onDragEnd(t, e) {
|
|
1134
1137
|
this.allowPointerEvent(this.pointerEvents.onDragEnd, t) && 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: S.EDITED, value: !1 }]), this.onFinish(this.editedFeatureId, { mode: this.mode, action: "edit" }), this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedInsertIndex = void 0, this.editedSnapType = void 0, e(!0));
|
|
@@ -1142,14 +1145,14 @@ class De extends A {
|
|
|
1142
1145
|
}
|
|
1143
1146
|
}
|
|
1144
1147
|
styleFeature(t) {
|
|
1145
|
-
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
1148
|
+
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0, markerUrl: void 0, markerHeight: void 0, markerWidth: void 0 });
|
|
1146
1149
|
if (t.properties.mode === this.mode) {
|
|
1147
1150
|
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 = j, e;
|
|
1148
1151
|
if (t.geometry.type === "Point") {
|
|
1149
|
-
const i = t.properties[S.EDITED], o = t.properties[S.COORDINATE_POINT],
|
|
1150
|
-
if (!
|
|
1152
|
+
const i = t.properties[S.EDITED], o = t.properties[S.COORDINATE_POINT], r = i ? "editedPoint" : t.properties[S.CLOSING_POINT] ? "closingPoint" : t.properties[S.SNAPPING_POINT] ? "snappingPoint" : o ? "coordinatePoint" : void 0;
|
|
1153
|
+
if (!r) return e;
|
|
1151
1154
|
const n = { 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 }, coordinatePoint: { width: this.styles.coordinatePointWidth, color: this.styles.coordinatePointColor, outlineColor: this.styles.coordinatePointOutlineColor, outlineWidth: this.styles.coordinatePointOutlineWidth } };
|
|
1152
|
-
return e.pointWidth = this.getNumericStylingValue(n[
|
|
1155
|
+
return e.pointWidth = this.getNumericStylingValue(n[r].width, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(n[r].color, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(n[r].outlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(n[r].outlineWidth, 2, t), e.zIndex = i ? 40 : o ? 20 : 30, e;
|
|
1153
1156
|
}
|
|
1154
1157
|
}
|
|
1155
1158
|
return e;
|
|
@@ -1219,7 +1222,7 @@ class _e extends A {
|
|
|
1219
1222
|
this.center = void 0, this.currentRectangleId = void 0, this.clickCount = 0, this.state === "drawing" && this.setStarted(), t !== void 0 && this.store.delete([t]);
|
|
1220
1223
|
}
|
|
1221
1224
|
styleFeature(t) {
|
|
1222
|
-
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
1225
|
+
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0, markerUrl: void 0, markerHeight: void 0, markerWidth: void 0 });
|
|
1223
1226
|
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 = j), e;
|
|
1224
1227
|
}
|
|
1225
1228
|
validateFeature(t) {
|
|
@@ -1268,48 +1271,48 @@ class tt extends A {
|
|
|
1268
1271
|
validateFeature(t) {
|
|
1269
1272
|
const e = super.validateFeature(t);
|
|
1270
1273
|
if (e.valid) {
|
|
1271
|
-
const i = t, o =
|
|
1274
|
+
const i = t, o = Me(i, this.coordinatePrecision).valid || wt(i, this.coordinatePrecision).valid || Rt(i, this.coordinatePrecision).valid;
|
|
1272
1275
|
return o ? { valid: !0 } : { valid: o, reason: "Feature is not a valid Point, Polygon or LineString feature" };
|
|
1273
1276
|
}
|
|
1274
1277
|
return e;
|
|
1275
1278
|
}
|
|
1276
1279
|
}
|
|
1277
|
-
function Nt(
|
|
1278
|
-
const e =
|
|
1280
|
+
function Nt(s, t) {
|
|
1281
|
+
const e = s, i = t, o = D(e[1]), r = D(i[1]);
|
|
1279
1282
|
let n = D(i[0] - e[0]);
|
|
1280
1283
|
n > Math.PI && (n -= 2 * Math.PI), n < -Math.PI && (n += 2 * Math.PI);
|
|
1281
|
-
const a = Math.log(Math.tan(
|
|
1284
|
+
const a = Math.log(Math.tan(r / 2 + Math.PI / 4) / Math.tan(o / 2 + Math.PI / 4)), l = (V(Math.atan2(n, a)) + 360) % 360;
|
|
1282
1285
|
return l > 180 ? -(360 - l) : l;
|
|
1283
1286
|
}
|
|
1284
|
-
function ke(
|
|
1287
|
+
function ke(s, t, e) {
|
|
1285
1288
|
let i = t;
|
|
1286
1289
|
t < 0 && (i = -Math.abs(i));
|
|
1287
|
-
const o = i / Oe,
|
|
1290
|
+
const o = i / Oe, r = s[0] * Math.PI / 180, n = D(s[1]), a = D(e), l = o * Math.cos(a);
|
|
1288
1291
|
let d = n + l;
|
|
1289
1292
|
Math.abs(d) > Math.PI / 2 && (d = d > 0 ? Math.PI - d : -Math.PI - d);
|
|
1290
|
-
const c = Math.log(Math.tan(d / 2 + Math.PI / 4) / Math.tan(n / 2 + Math.PI / 4)), h = Math.abs(c) > 1e-11 ? l / c : Math.cos(n), u = [(180 * (
|
|
1291
|
-
return u[0] += u[0] -
|
|
1293
|
+
const c = Math.log(Math.tan(d / 2 + Math.PI / 4) / Math.tan(n / 2 + Math.PI / 4)), h = Math.abs(c) > 1e-11 ? l / c : Math.cos(n), u = [(180 * (r + o * Math.sin(a) / h) / Math.PI + 540) % 360 - 180, 180 * d / Math.PI];
|
|
1294
|
+
return u[0] += u[0] - s[0] > 180 ? -360 : s[0] - u[0] > 180 ? 360 : 0, u;
|
|
1292
1295
|
}
|
|
1293
|
-
function Ne(
|
|
1294
|
-
const
|
|
1296
|
+
function Ne(s, t, e, i, o) {
|
|
1297
|
+
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);
|
|
1295
1298
|
return [b(a, e), b(l, e)];
|
|
1296
1299
|
}
|
|
1297
|
-
function Ei(
|
|
1298
|
-
const i = ke(
|
|
1300
|
+
function Ei(s, t, e) {
|
|
1301
|
+
const i = ke(s, 1e3 * G(s, t) / 2, Nt(s, t));
|
|
1299
1302
|
return [b(i[0], e), b(i[1], e)];
|
|
1300
1303
|
}
|
|
1301
|
-
function ce({ featureCoords:
|
|
1302
|
-
const
|
|
1303
|
-
for (let n = 0; n <
|
|
1304
|
+
function ce({ featureCoords: s, precision: t, unproject: e, project: i, projection: o }) {
|
|
1305
|
+
const r = [];
|
|
1306
|
+
for (let n = 0; n < s.length - 1; n++) {
|
|
1304
1307
|
let a;
|
|
1305
|
-
if (o === "web-mercator") a = Ne(
|
|
1308
|
+
if (o === "web-mercator") a = Ne(s[n], s[n + 1], t, i, e);
|
|
1306
1309
|
else {
|
|
1307
1310
|
if (o !== "globe") throw new Error("Invalid projection");
|
|
1308
|
-
a = Ei(
|
|
1311
|
+
a = Ei(s[n], s[n + 1], t);
|
|
1309
1312
|
}
|
|
1310
|
-
|
|
1313
|
+
r.push(a);
|
|
1311
1314
|
}
|
|
1312
|
-
return
|
|
1315
|
+
return r;
|
|
1313
1316
|
}
|
|
1314
1317
|
class bi extends B {
|
|
1315
1318
|
constructor(t, e, i) {
|
|
@@ -1321,13 +1324,13 @@ class bi extends B {
|
|
|
1321
1324
|
set ids(t) {
|
|
1322
1325
|
}
|
|
1323
1326
|
insert(t, e, i) {
|
|
1324
|
-
const o = this.store.getGeometryCopy(e), { midPointFeatureId:
|
|
1325
|
-
l.splice(n + 1, 0, o.coordinates), a.coordinates = a.type === "Polygon" ? [l] : l, this.store.updateGeometry([{ id:
|
|
1327
|
+
const o = this.store.getGeometryCopy(e), { midPointFeatureId: r, midPointSegment: n } = this.store.getPropertiesCopy(e), a = this.store.getGeometryCopy(r), l = a.type === "Polygon" ? a.coordinates[0] : a.coordinates;
|
|
1328
|
+
l.splice(n + 1, 0, o.coordinates), a.coordinates = a.type === "Polygon" ? [l] : l, this.store.updateGeometry([{ id: r, geometry: a }]), this.store.getPropertiesCopy(t)[S.COORDINATE_POINT_IDS] && this.coordinatePointBehavior.createOrUpdate(t), this.store.delete([...this._midPoints, ...this.selectionPointBehavior.ids]), this.create(l, r, i), this.selectionPointBehavior.create(l, a.type, r);
|
|
1326
1329
|
}
|
|
1327
1330
|
create(t, e, i) {
|
|
1328
1331
|
if (!this.store.has(e)) throw new Error("Store does not have feature with this id");
|
|
1329
|
-
this._midPoints = this.store.create((function(o,
|
|
1330
|
-
return ce({ featureCoords: o, precision: n, project: a, unproject: l, projection: d }).map((c, h) => ({ geometry: { type: "Point", coordinates: c }, properties:
|
|
1332
|
+
this._midPoints = this.store.create((function(o, r, n, a, l, d) {
|
|
1333
|
+
return ce({ featureCoords: o, precision: n, project: a, unproject: l, projection: d }).map((c, h) => ({ geometry: { type: "Point", coordinates: c }, properties: r(h) }));
|
|
1331
1334
|
})(t, (o) => ({ mode: this.mode, [k.MID_POINT]: !0, midPointSegment: o, midPointFeatureId: e }), i, this.config.project, this.config.unproject, this.projection));
|
|
1332
1335
|
}
|
|
1333
1336
|
delete() {
|
|
@@ -1347,8 +1350,8 @@ class wi extends B {
|
|
|
1347
1350
|
set ids(t) {
|
|
1348
1351
|
}
|
|
1349
1352
|
create(t, e, i) {
|
|
1350
|
-
this._selectionPoints = this.store.create((function(o,
|
|
1351
|
-
const a = [], l =
|
|
1353
|
+
this._selectionPoints = this.store.create((function(o, r, n) {
|
|
1354
|
+
const a = [], l = r === "Polygon" ? o.length - 1 : o.length;
|
|
1352
1355
|
for (let d = 0; d < l; d++) a.push({ geometry: { type: "Point", coordinates: o[d] }, properties: n(d) });
|
|
1353
1356
|
return a;
|
|
1354
1357
|
})(t, e, (o) => ({ mode: this.mode, index: o, [k.SELECTION_POINT]: !0, [k.SELECTION_POINT_FEATURE_ID]: i })));
|
|
@@ -1363,37 +1366,37 @@ class wi extends B {
|
|
|
1363
1366
|
if (this._selectionPoints[t] !== void 0) return { id: this._selectionPoints[t], geometry: { type: "Point", coordinates: e } };
|
|
1364
1367
|
}
|
|
1365
1368
|
}
|
|
1366
|
-
function Te(
|
|
1369
|
+
function Te(s, t) {
|
|
1367
1370
|
let e = !1;
|
|
1368
1371
|
for (let n = 0, a = t.length; n < a; n++) {
|
|
1369
1372
|
const l = t[n];
|
|
1370
|
-
for (let d = 0, c = l.length, h = c - 1; d < c; h = d++) (o = l[d])[1] > (i =
|
|
1373
|
+
for (let d = 0, c = l.length, h = c - 1; d < c; h = d++) (o = l[d])[1] > (i = s)[1] != (r = l[h])[1] > i[1] && i[0] < (r[0] - o[0]) * (i[1] - o[1]) / (r[1] - o[1]) + o[0] && (e = !e);
|
|
1371
1374
|
}
|
|
1372
|
-
var i, o,
|
|
1375
|
+
var i, o, r;
|
|
1373
1376
|
return e;
|
|
1374
1377
|
}
|
|
1375
|
-
const Tt = (
|
|
1376
|
-
const i = (
|
|
1377
|
-
return Math.sqrt(((
|
|
1378
|
+
const Tt = (s, t, e) => {
|
|
1379
|
+
const i = (r) => r * r, o = (r, n) => i(r.x - n.x) + i(r.y - n.y);
|
|
1380
|
+
return Math.sqrt(((r, n, a) => {
|
|
1378
1381
|
const l = o(n, a);
|
|
1379
|
-
if (l === 0) return o(
|
|
1380
|
-
let d = ((
|
|
1381
|
-
return d = Math.max(0, Math.min(1, d)), o(
|
|
1382
|
-
})(
|
|
1382
|
+
if (l === 0) return o(r, n);
|
|
1383
|
+
let d = ((r.x - n.x) * (a.x - n.x) + (r.y - n.y) * (a.y - n.y)) / l;
|
|
1384
|
+
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) });
|
|
1385
|
+
})(s, t, e));
|
|
1383
1386
|
};
|
|
1384
1387
|
class Li extends B {
|
|
1385
1388
|
constructor(t, e, i) {
|
|
1386
1389
|
super(t), this.config = void 0, this.createClickBoundingBox = void 0, this.pixelDistance = void 0, this.config = t, this.createClickBoundingBox = e, this.pixelDistance = i;
|
|
1387
1390
|
}
|
|
1388
1391
|
find(t, e) {
|
|
1389
|
-
let i, o,
|
|
1392
|
+
let i, o, r, n, a = 1 / 0, l = 1 / 0, d = 1 / 0;
|
|
1390
1393
|
const c = this.createClickBoundingBox.create(t), h = this.store.search(c);
|
|
1391
1394
|
for (let u = 0; u < h.length; u++) {
|
|
1392
1395
|
const p = h[u], g = p.geometry;
|
|
1393
1396
|
if (g.type === "Point") {
|
|
1394
1397
|
if (p.properties.selectionPoint || p.properties.coordinatePoint || !e && p.properties[k.MID_POINT]) continue;
|
|
1395
1398
|
const y = this.pixelDistance.measure(t, g.coordinates);
|
|
1396
|
-
p.properties[k.MID_POINT] && y < this.pointerDistance && y < d ? (d = y,
|
|
1399
|
+
p.properties[k.MID_POINT] && y < this.pointerDistance && y < d ? (d = y, r = p) : !p.properties[k.MID_POINT] && y < this.pointerDistance && y < a && (a = y, i = p);
|
|
1397
1400
|
} else if (g.type === "LineString") {
|
|
1398
1401
|
if (i) continue;
|
|
1399
1402
|
for (let y = 0; y < g.coordinates.length - 1; y++) {
|
|
@@ -1405,12 +1408,12 @@ class Li extends B {
|
|
|
1405
1408
|
Te([t.lng, t.lat], g.coordinates) && (n = p);
|
|
1406
1409
|
}
|
|
1407
1410
|
}
|
|
1408
|
-
return { clickedFeature: i || o || n, clickedMidPoint:
|
|
1411
|
+
return { clickedFeature: i || o || n, clickedMidPoint: r };
|
|
1409
1412
|
}
|
|
1410
1413
|
}
|
|
1411
|
-
class
|
|
1412
|
-
constructor(t, e, i, o,
|
|
1413
|
-
super(t), this.config = void 0, this.featuresAtCursorEvent = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.coordinatePoints = void 0, this.draggedFeatureId = null, this.dragPosition = void 0, this.config = t, this.featuresAtCursorEvent = e, this.selectionPoints = i, this.midPoints = o, this.coordinatePoints =
|
|
1414
|
+
class Mi extends B {
|
|
1415
|
+
constructor(t, e, i, o, r) {
|
|
1416
|
+
super(t), this.config = void 0, this.featuresAtCursorEvent = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.coordinatePoints = void 0, this.draggedFeatureId = null, this.dragPosition = void 0, this.config = t, this.featuresAtCursorEvent = e, this.selectionPoints = i, this.midPoints = o, this.coordinatePoints = r;
|
|
1414
1417
|
}
|
|
1415
1418
|
startDragging(t, e) {
|
|
1416
1419
|
this.draggedFeatureId = e, this.dragPosition = [t.lng, t.lat];
|
|
@@ -1429,31 +1432,31 @@ class Fi extends B {
|
|
|
1429
1432
|
if (!this.draggedFeatureId) return;
|
|
1430
1433
|
const i = this.store.getGeometryCopy(this.draggedFeatureId), o = [t.lng, t.lat];
|
|
1431
1434
|
if (i.type === "Polygon" || i.type === "LineString") {
|
|
1432
|
-
let
|
|
1433
|
-
if (i.type === "Polygon" ? (
|
|
1435
|
+
let r, n;
|
|
1436
|
+
if (i.type === "Polygon" ? (r = i.coordinates[0], n = r.length - 1) : (r = i.coordinates, n = r.length), !this.dragPosition) return !1;
|
|
1434
1437
|
for (let c = 0; c < n; c++) {
|
|
1435
|
-
const h =
|
|
1438
|
+
const h = r[c];
|
|
1436
1439
|
let u, p;
|
|
1437
1440
|
if (this.config.projection === "web-mercator") {
|
|
1438
|
-
const g = O(this.dragPosition[0], this.dragPosition[1]), y = O(o[0], o[1]), f = O(h[0], h[1]), v = { x: g.x - y.x, y: g.y - y.y }, C = f.x - v.x, m = f.y - v.y, { lng: P, lat: I } =
|
|
1441
|
+
const g = O(this.dragPosition[0], this.dragPosition[1]), y = O(o[0], o[1]), f = O(h[0], h[1]), v = { x: g.x - y.x, y: g.y - y.y }, C = f.x - v.x, m = f.y - v.y, { lng: P, lat: I } = U(C, m);
|
|
1439
1442
|
u = P, p = I;
|
|
1440
1443
|
} else {
|
|
1441
1444
|
const g = [this.dragPosition[0] - o[0], this.dragPosition[1] - o[1]];
|
|
1442
1445
|
u = h[0] - g[0], p = h[1] - g[1];
|
|
1443
1446
|
}
|
|
1444
1447
|
if (u = b(u, this.config.coordinatePrecision), p = b(p, this.config.coordinatePrecision), u > 180 || u < -180 || p > 90 || p < -90) return !1;
|
|
1445
|
-
|
|
1448
|
+
r[c] = [u, p];
|
|
1446
1449
|
}
|
|
1447
|
-
i.type === "Polygon" && (
|
|
1448
|
-
const a = this.selectionPoints.getUpdated(
|
|
1450
|
+
i.type === "Polygon" && (r[r.length - 1] = [r[0][0], r[0][1]]);
|
|
1451
|
+
const a = this.selectionPoints.getUpdated(r) || [], l = this.midPoints.getUpdated(r) || [], d = this.coordinatePoints.getUpdated(this.draggedFeatureId, r) || [];
|
|
1449
1452
|
if (e && !e({ type: "Feature", id: this.draggedFeatureId, geometry: i, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: E.Provisional }).valid) return !1;
|
|
1450
1453
|
this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: i }, ...a, ...l, ...d]), this.dragPosition = [t.lng, t.lat];
|
|
1451
1454
|
} else i.type === "Point" && (this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: { type: "Point", coordinates: o } }]), this.dragPosition = [t.lng, t.lat]);
|
|
1452
1455
|
}
|
|
1453
1456
|
}
|
|
1454
|
-
class
|
|
1455
|
-
constructor(t, e, i, o,
|
|
1456
|
-
super(t), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.coordinatePoints = void 0, this.coordinateSnapping = void 0, this.lineSnapping = void 0, this.draggedCoordinate = { id: null, index: -1 }, this.config = t, this.pixelDistance = e, this.selectionPoints = i, this.midPoints = o, this.coordinatePoints =
|
|
1457
|
+
class Fi extends B {
|
|
1458
|
+
constructor(t, e, i, o, r, n, a) {
|
|
1459
|
+
super(t), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.coordinatePoints = void 0, this.coordinateSnapping = void 0, this.lineSnapping = void 0, this.draggedCoordinate = { id: null, index: -1 }, this.config = t, this.pixelDistance = e, this.selectionPoints = i, this.midPoints = o, this.coordinatePoints = r, this.coordinateSnapping = n, this.lineSnapping = a;
|
|
1457
1460
|
}
|
|
1458
1461
|
getClosestCoordinate(t, e) {
|
|
1459
1462
|
const i = { dist: 1 / 0, index: -1, isFirstOrLastPolygonCoord: !1 };
|
|
@@ -1463,11 +1466,11 @@ class Mi extends B {
|
|
|
1463
1466
|
if (e.type !== "Polygon") return i;
|
|
1464
1467
|
o = e.coordinates[0];
|
|
1465
1468
|
}
|
|
1466
|
-
for (let
|
|
1467
|
-
const n = this.pixelDistance.measure(t, o[
|
|
1469
|
+
for (let r = 0; r < o.length; r++) {
|
|
1470
|
+
const n = this.pixelDistance.measure(t, o[r]);
|
|
1468
1471
|
if (n < this.pointerDistance && n < i.dist) {
|
|
1469
|
-
const a = e.type === "Polygon" && (
|
|
1470
|
-
i.dist = n, i.index = a ? 0 :
|
|
1472
|
+
const a = e.type === "Polygon" && (r === o.length - 1 || r === 0);
|
|
1473
|
+
i.dist = n, i.index = a ? 0 : r, i.isFirstOrLastPolygonCoord = a;
|
|
1471
1474
|
}
|
|
1472
1475
|
}
|
|
1473
1476
|
return i;
|
|
@@ -1478,14 +1481,14 @@ class Mi extends B {
|
|
|
1478
1481
|
}
|
|
1479
1482
|
snapCoordinate(t, e, i) {
|
|
1480
1483
|
let o = [t.lng, t.lat];
|
|
1481
|
-
const
|
|
1484
|
+
const r = (n) => !!(n.properties && n.properties.mode === i.properties.mode && n.id !== this.draggedCoordinate.id);
|
|
1482
1485
|
if (e != null && e.toLine) {
|
|
1483
1486
|
let n;
|
|
1484
|
-
n = this.lineSnapping.getSnappable(t,
|
|
1487
|
+
n = this.lineSnapping.getSnappable(t, r).coordinate, n && (o = n);
|
|
1485
1488
|
}
|
|
1486
1489
|
if (e.toCoordinate) {
|
|
1487
1490
|
let n;
|
|
1488
|
-
n = this.coordinateSnapping.getSnappable(t,
|
|
1491
|
+
n = this.coordinateSnapping.getSnappable(t, r).coordinate, n && (o = n);
|
|
1489
1492
|
}
|
|
1490
1493
|
if (e != null && e.toCustom) {
|
|
1491
1494
|
let n;
|
|
@@ -1494,16 +1497,16 @@ class Mi extends B {
|
|
|
1494
1497
|
return o;
|
|
1495
1498
|
}
|
|
1496
1499
|
drag(t, e, i, o) {
|
|
1497
|
-
const
|
|
1498
|
-
if (
|
|
1499
|
-
const n = this.draggedCoordinate.index, a = this.store.getGeometryCopy(
|
|
1500
|
+
const r = this.draggedCoordinate.id;
|
|
1501
|
+
if (r === null) return !1;
|
|
1502
|
+
const n = this.draggedCoordinate.index, a = this.store.getGeometryCopy(r), l = this.store.getPropertiesCopy(r), d = a.type === "LineString" ? a.coordinates : a.coordinates[0], c = a.type === "Polygon" && (n === d.length - 1 || n === 0), h = { type: "Feature", id: r, geometry: a, properties: l }, u = this.snapCoordinate(t, o, h);
|
|
1500
1503
|
if (t.lng > 180 || t.lng < -180 || t.lat > 90 || t.lat < -90) return !1;
|
|
1501
1504
|
if (c) {
|
|
1502
1505
|
const v = d.length - 1;
|
|
1503
1506
|
d[0] = u, d[v] = u;
|
|
1504
1507
|
} else d[n] = u;
|
|
1505
|
-
const p = this.selectionPoints.getOneUpdated(n, u), g = p ? [p] : [], y = this.midPoints.getUpdated(d) || [], f = this.coordinatePoints.getUpdated(
|
|
1506
|
-
return !(a.type !== "Point" && !e && At({ geometry: a }) || i && !i(h, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: E.Provisional }).valid || (this.store.updateGeometry([{ id:
|
|
1508
|
+
const p = this.selectionPoints.getOneUpdated(n, u), g = p ? [p] : [], y = this.midPoints.getUpdated(d) || [], f = this.coordinatePoints.getUpdated(r, d) || [];
|
|
1509
|
+
return !(a.type !== "Point" && !e && At({ geometry: a }) || i && !i(h, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: E.Provisional }).valid || (this.store.updateGeometry([{ id: r, geometry: a }, ...g, ...y, ...f]), 0));
|
|
1507
1510
|
}
|
|
1508
1511
|
isDragging() {
|
|
1509
1512
|
return this.draggedCoordinate.id !== null;
|
|
@@ -1515,40 +1518,40 @@ class Mi extends B {
|
|
|
1515
1518
|
this.draggedCoordinate = { id: null, index: -1 };
|
|
1516
1519
|
}
|
|
1517
1520
|
}
|
|
1518
|
-
function he(
|
|
1521
|
+
function he(s) {
|
|
1519
1522
|
let t = 0, e = 0, i = 0;
|
|
1520
|
-
return (
|
|
1523
|
+
return (s.geometry.type === "Polygon" ? s.geometry.coordinates[0].slice(0, -1) : s.geometry.coordinates).forEach((o) => {
|
|
1521
1524
|
t += o[0], e += o[1], i++;
|
|
1522
1525
|
}, !0), [t / i, e / i];
|
|
1523
1526
|
}
|
|
1524
|
-
const We = (
|
|
1525
|
-
if (t === 0 || t === 360 || t === -360) return
|
|
1526
|
-
const e = 0.017453292519943295 * t, i = (
|
|
1527
|
+
const We = (s, t) => {
|
|
1528
|
+
if (t === 0 || t === 360 || t === -360) return s;
|
|
1529
|
+
const e = 0.017453292519943295 * t, i = (s.geometry.type === "Polygon" ? s.geometry.coordinates[0] : s.geometry.coordinates).map(([n, a]) => O(n, a)), o = i.reduce((n, a) => ({ x: n.x + a.x, y: n.y + a.y }), { x: 0, y: 0 });
|
|
1527
1530
|
o.x /= i.length, o.y /= i.length;
|
|
1528
|
-
const
|
|
1529
|
-
return
|
|
1531
|
+
const r = i.map((n) => ({ x: o.x + (n.x - o.x) * Math.cos(e) - (n.y - o.y) * Math.sin(e), y: o.y + (n.x - o.x) * Math.sin(e) + (n.y - o.y) * Math.cos(e) })).map(({ x: n, y: a }) => [U(n, a).lng, U(n, a).lat]);
|
|
1532
|
+
return s.geometry.type === "Polygon" ? s.geometry.coordinates[0] = r : s.geometry.coordinates = r, s;
|
|
1530
1533
|
};
|
|
1531
|
-
function Wt(
|
|
1532
|
-
const t = (
|
|
1534
|
+
function Wt(s) {
|
|
1535
|
+
const t = (s.geometry.type === "Polygon" ? s.geometry.coordinates[0] : s.geometry.coordinates).map((e) => {
|
|
1533
1536
|
const { x: i, y: o } = O(e[0], e[1]);
|
|
1534
1537
|
return [i, o];
|
|
1535
1538
|
});
|
|
1536
|
-
return
|
|
1537
|
-
let i = 0, o = 0,
|
|
1539
|
+
return s.geometry.type === "Polygon" ? (function(e) {
|
|
1540
|
+
let i = 0, o = 0, r = 0;
|
|
1538
1541
|
const n = e.length;
|
|
1539
1542
|
for (let a = 0; a < n - 1; a++) {
|
|
1540
1543
|
const [l, d] = e[a], [c, h] = e[a + 1], u = l * h - c * d;
|
|
1541
|
-
i += u, o += (l + c) * u,
|
|
1544
|
+
i += u, o += (l + c) * u, r += (d + h) * u;
|
|
1542
1545
|
}
|
|
1543
|
-
return i /= 2, o /= 6 * i,
|
|
1546
|
+
return i /= 2, o /= 6 * i, r /= 6 * i, { x: o, y: r };
|
|
1544
1547
|
})(t) : (function(e) {
|
|
1545
1548
|
const i = e.length;
|
|
1546
|
-
let o = 0,
|
|
1549
|
+
let o = 0, r = 0;
|
|
1547
1550
|
for (let n = 0; n < i; n++) {
|
|
1548
1551
|
const [a, l] = e[n];
|
|
1549
|
-
o += a,
|
|
1552
|
+
o += a, r += l;
|
|
1550
1553
|
}
|
|
1551
|
-
return { x: o / i, y:
|
|
1554
|
+
return { x: o / i, y: r / i };
|
|
1552
1555
|
})(t);
|
|
1553
1556
|
}
|
|
1554
1557
|
class Di extends B {
|
|
@@ -1562,29 +1565,29 @@ class Di extends B {
|
|
|
1562
1565
|
this.selectedGeometry || (this.selectedGeometry = this.store.getGeometryCopy(e));
|
|
1563
1566
|
const o = this.selectedGeometry;
|
|
1564
1567
|
if (o.type !== "Polygon" && o.type !== "LineString") return;
|
|
1565
|
-
const
|
|
1568
|
+
const r = [t.lng, t.lat];
|
|
1566
1569
|
let n;
|
|
1567
1570
|
const a = { type: "Feature", geometry: o, properties: {} };
|
|
1568
1571
|
if (this.config.projection === "web-mercator") {
|
|
1569
1572
|
this.selectedGeometryWebMercatorCentroid || (this.selectedGeometryWebMercatorCentroid = Wt(a));
|
|
1570
1573
|
const u = O(t.lng, t.lat);
|
|
1571
|
-
if (n =
|
|
1574
|
+
if (n = R(this.selectedGeometryWebMercatorCentroid, u), n === 0) return;
|
|
1572
1575
|
if (!this.lastBearing) return void (this.lastBearing = n);
|
|
1573
1576
|
We(a, -(this.lastBearing - n));
|
|
1574
1577
|
} else {
|
|
1575
1578
|
if (this.config.projection !== "globe") throw new Error("Unsupported projection");
|
|
1576
|
-
if (this.selectedGeometryCentroid || (this.selectedGeometryCentroid = he({ geometry: o })), n = Nt(this.selectedGeometryCentroid,
|
|
1579
|
+
if (this.selectedGeometryCentroid || (this.selectedGeometryCentroid = he({ geometry: o })), n = Nt(this.selectedGeometryCentroid, r), !this.lastBearing) return void (this.lastBearing = n + 180);
|
|
1577
1580
|
(function(u, p) {
|
|
1578
1581
|
if (p === 0 || p === 360 || p === -360) return u;
|
|
1579
1582
|
const g = he(u);
|
|
1580
1583
|
(u.geometry.type === "Polygon" ? u.geometry.coordinates[0] : u.geometry.coordinates).forEach((y) => {
|
|
1581
1584
|
const f = Nt(g, y) + p, v = (function(m, P) {
|
|
1582
1585
|
m[0] += m[0] - P[0] > 180 ? -360 : P[0] - m[0] > 180 ? 360 : 0;
|
|
1583
|
-
const I = Oe, w = P[1] * Math.PI / 180, L = m[1] * Math.PI / 180,
|
|
1586
|
+
const I = Oe, w = P[1] * Math.PI / 180, L = m[1] * Math.PI / 180, F = L - w;
|
|
1584
1587
|
let N = Math.abs(m[0] - P[0]) * Math.PI / 180;
|
|
1585
1588
|
N > Math.PI && (N -= 2 * Math.PI);
|
|
1586
|
-
const _ = Math.log(Math.tan(L / 2 + Math.PI / 4) / Math.tan(w / 2 + Math.PI / 4)), T = Math.abs(_) > 1e-11 ?
|
|
1587
|
-
return Math.sqrt(
|
|
1589
|
+
const _ = Math.log(Math.tan(L / 2 + Math.PI / 4) / Math.tan(w / 2 + Math.PI / 4)), T = Math.abs(_) > 1e-11 ? F / _ : Math.cos(w);
|
|
1590
|
+
return Math.sqrt(F * F + T * T * N * N) * I;
|
|
1588
1591
|
})(g, y), C = ke(g, v, f);
|
|
1589
1592
|
y[0] = C[0], y[1] = C[1];
|
|
1590
1593
|
});
|
|
@@ -1614,15 +1617,15 @@ class _i extends B {
|
|
|
1614
1617
|
this.dragCoordinateResizeBehavior.stopDragging();
|
|
1615
1618
|
}
|
|
1616
1619
|
}
|
|
1617
|
-
function Be({ coordinates:
|
|
1618
|
-
i === 1 && o === 1 ||
|
|
1619
|
-
const { x: n, y: a } = O(
|
|
1620
|
-
|
|
1620
|
+
function Be({ coordinates: s, originX: t, originY: e, xScale: i, yScale: o }) {
|
|
1621
|
+
i === 1 && o === 1 || s.forEach((r) => {
|
|
1622
|
+
const { x: n, y: a } = O(r[0], r[1]), l = t + (n - t) * i, d = e + (a - e) * o, { lng: c, lat: h } = U(l, d);
|
|
1623
|
+
r[0] = c, r[1] = h;
|
|
1621
1624
|
});
|
|
1622
1625
|
}
|
|
1623
1626
|
class ki extends B {
|
|
1624
|
-
constructor(t, e, i, o,
|
|
1625
|
-
super(t), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.coordinatePoints = 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, this.coordinatePoints =
|
|
1627
|
+
constructor(t, e, i, o, r) {
|
|
1628
|
+
super(t), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.coordinatePoints = 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, this.coordinatePoints = r;
|
|
1626
1629
|
}
|
|
1627
1630
|
getClosestCoordinate(t, e) {
|
|
1628
1631
|
const i = { dist: 1 / 0, index: -1, isFirstOrLastPolygonCoord: !1 };
|
|
@@ -1632,11 +1635,11 @@ class ki extends B {
|
|
|
1632
1635
|
if (e.type !== "Polygon") return i;
|
|
1633
1636
|
o = e.coordinates[0];
|
|
1634
1637
|
}
|
|
1635
|
-
for (let
|
|
1636
|
-
const n = this.pixelDistance.measure(t, o[
|
|
1638
|
+
for (let r = 0; r < o.length; r++) {
|
|
1639
|
+
const n = this.pixelDistance.measure(t, o[r]);
|
|
1637
1640
|
if (n < this.pointerDistance && n < i.dist) {
|
|
1638
|
-
const a = e.type === "Polygon" && (
|
|
1639
|
-
i.dist = n, i.index = a ? 0 :
|
|
1641
|
+
const a = e.type === "Polygon" && (r === o.length - 1 || r === 0);
|
|
1642
|
+
i.dist = n, i.index = a ? 0 : r, i.isFirstOrLastPolygonCoord = a;
|
|
1640
1643
|
}
|
|
1641
1644
|
}
|
|
1642
1645
|
return i;
|
|
@@ -1679,43 +1682,43 @@ class ki extends B {
|
|
|
1679
1682
|
centerWebMercatorDrag(t) {
|
|
1680
1683
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1681
1684
|
if (!e) return null;
|
|
1682
|
-
const { feature: i, boundingBox: o, updatedCoords:
|
|
1685
|
+
const { feature: i, boundingBox: o, updatedCoords: r, selectedCoordinate: n } = e, a = Wt(i);
|
|
1683
1686
|
if (!a) return null;
|
|
1684
1687
|
const l = O(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), c = O(t.lng, t.lat);
|
|
1685
|
-
return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords:
|
|
1688
|
+
return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: r, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), r;
|
|
1686
1689
|
}
|
|
1687
1690
|
centerFixedWebMercatorDrag(t) {
|
|
1688
1691
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1689
1692
|
if (!e) return null;
|
|
1690
|
-
const { feature: i, boundingBox: o, updatedCoords:
|
|
1693
|
+
const { feature: i, boundingBox: o, updatedCoords: r, selectedCoordinate: n } = e, a = Wt(i);
|
|
1691
1694
|
if (!a) return null;
|
|
1692
1695
|
const l = O(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), c = O(t.lng, t.lat);
|
|
1693
|
-
return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords:
|
|
1696
|
+
return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: r, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), r;
|
|
1694
1697
|
}
|
|
1695
|
-
scaleFixedWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords:
|
|
1698
|
+
scaleFixedWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: r }) {
|
|
1696
1699
|
if (!this.isValidDragWebMercator(t, e.x - o.x, e.y - o.y)) return null;
|
|
1697
|
-
let n =
|
|
1698
|
-
return n < 0 && (n = this.minimumScale), Be({ coordinates:
|
|
1700
|
+
let n = M(e, o) / M(e, i);
|
|
1701
|
+
return n < 0 && (n = this.minimumScale), Be({ coordinates: r, originX: e.x, originY: e.y, xScale: n, yScale: n }), r;
|
|
1699
1702
|
}
|
|
1700
1703
|
oppositeFixedWebMercatorDrag(t) {
|
|
1701
1704
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1702
1705
|
if (!e) return null;
|
|
1703
|
-
const { boundingBox: i, updatedCoords: o, selectedCoordinate:
|
|
1706
|
+
const { boundingBox: i, updatedCoords: o, selectedCoordinate: r } = e, n = O(r[0], r[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] }, c = O(t.lng, t.lat);
|
|
1704
1707
|
return this.scaleFixedWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: n, webMercatorOrigin: d }), o;
|
|
1705
1708
|
}
|
|
1706
1709
|
oppositeWebMercatorDrag(t) {
|
|
1707
1710
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1708
1711
|
if (!e) return null;
|
|
1709
|
-
const { boundingBox: i, updatedCoords: o, selectedCoordinate:
|
|
1712
|
+
const { boundingBox: i, updatedCoords: o, selectedCoordinate: r } = e, n = O(r[0], r[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] }, c = O(t.lng, t.lat);
|
|
1710
1713
|
return this.scaleWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: n, webMercatorOrigin: d }), o;
|
|
1711
1714
|
}
|
|
1712
|
-
scaleWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords:
|
|
1715
|
+
scaleWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: r }) {
|
|
1713
1716
|
const n = e.x - o.x, a = e.y - o.y;
|
|
1714
1717
|
if (!this.isValidDragWebMercator(t, n, a)) return null;
|
|
1715
1718
|
let l = 1;
|
|
1716
1719
|
n !== 0 && t !== 1 && t !== 5 && (l = 1 - (e.x - i.x - n) / n);
|
|
1717
1720
|
let d = 1;
|
|
1718
|
-
return a !== 0 && t !== 3 && t !== 7 && (d = 1 - (e.y - i.y - a) / a), this.validateScale(l, d) ? (l < 0 && (l = this.minimumScale), d < 0 && (d = this.minimumScale), this.performWebMercatorScale(
|
|
1721
|
+
return a !== 0 && t !== 3 && t !== 7 && (d = 1 - (e.y - i.y - a) / a), this.validateScale(l, d) ? (l < 0 && (l = this.minimumScale), d < 0 && (d = this.minimumScale), this.performWebMercatorScale(r, e.x, e.y, l, d), r) : null;
|
|
1719
1722
|
}
|
|
1720
1723
|
getFeature(t) {
|
|
1721
1724
|
if (this.draggedCoordinate.id === null) return null;
|
|
@@ -1729,9 +1732,9 @@ class ki extends B {
|
|
|
1729
1732
|
const i = !isNaN(t) && e < Number.MAX_SAFE_INTEGER, o = !isNaN(e) && e < Number.MAX_SAFE_INTEGER;
|
|
1730
1733
|
return i && o;
|
|
1731
1734
|
}
|
|
1732
|
-
performWebMercatorScale(t, e, i, o,
|
|
1735
|
+
performWebMercatorScale(t, e, i, o, r) {
|
|
1733
1736
|
t.forEach((n) => {
|
|
1734
|
-
const { x: a, y: l } = O(n[0], n[1]), d = e + (a - e) * o, c = i + (l - i) *
|
|
1737
|
+
const { x: a, y: l } = O(n[0], n[1]), d = e + (a - e) * o, c = i + (l - i) * r, { lng: h, lat: u } = U(d, c);
|
|
1735
1738
|
n[0] = h, n[1] = u;
|
|
1736
1739
|
});
|
|
1737
1740
|
}
|
|
@@ -1743,14 +1746,14 @@ class ki extends B {
|
|
|
1743
1746
|
})).forEach(([a, l]) => {
|
|
1744
1747
|
a < e[0] && (e[0] = a), l < e[1] && (e[1] = l), a > e[2] && (e[2] = a), l > e[3] && (e[3] = l);
|
|
1745
1748
|
});
|
|
1746
|
-
const [i, o,
|
|
1747
|
-
return [[i, n], [(i +
|
|
1749
|
+
const [i, o, r, n] = e;
|
|
1750
|
+
return [[i, n], [(i + r) / 2, n], [r, n], [r, n + (o - n) / 2], [r, o], [(i + r) / 2, o], [i, o], [i, n + (o - n) / 2]];
|
|
1748
1751
|
}
|
|
1749
1752
|
getIndexesWebMercator(t, e) {
|
|
1750
1753
|
let i, o = 1 / 0;
|
|
1751
|
-
for (let
|
|
1752
|
-
const n =
|
|
1753
|
-
n < o && (i =
|
|
1754
|
+
for (let r = 0; r < t.length; r++) {
|
|
1755
|
+
const n = M({ x: e.x, y: e.y }, { x: t[r][0], y: t[r][1] });
|
|
1756
|
+
n < o && (i = r, o = n);
|
|
1754
1757
|
}
|
|
1755
1758
|
if (i === void 0) throw new Error("No closest coordinate found");
|
|
1756
1759
|
return { oppositeBboxIndex: this.boundingBoxMaps.opposite[i], closestBBoxIndex: i };
|
|
@@ -1772,13 +1775,13 @@ class ki extends B {
|
|
|
1772
1775
|
if (!this.draggedCoordinate.id) return !1;
|
|
1773
1776
|
const o = this.getFeature(this.draggedCoordinate.id);
|
|
1774
1777
|
if (!o) return !1;
|
|
1775
|
-
let
|
|
1776
|
-
if (e === "center" ?
|
|
1777
|
-
for (let c = 0; c <
|
|
1778
|
-
const h =
|
|
1778
|
+
let r = null;
|
|
1779
|
+
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;
|
|
1780
|
+
for (let c = 0; c < r.length; c++) {
|
|
1781
|
+
const h = r[c];
|
|
1779
1782
|
if (h[0] = b(h[0], this.coordinatePrecision), h[1] = b(h[1], this.coordinatePrecision), !bt(h, this.coordinatePrecision)) return !1;
|
|
1780
1783
|
}
|
|
1781
|
-
const n = this.midPoints.getUpdated(
|
|
1784
|
+
const n = this.midPoints.getUpdated(r) || [], a = this.selectionPoints.getUpdated(r) || [], l = this.coordinatePoints.getUpdated(o.id, r) || [], d = { type: o.geometry.type, coordinates: o.geometry.type === "Polygon" ? [r] : r };
|
|
1782
1785
|
return !(i && !i({ id: this.draggedCoordinate.id, type: "Feature", geometry: d, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: E.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: d }, ...a, ...n, ...l]), 0));
|
|
1783
1786
|
}
|
|
1784
1787
|
}
|
|
@@ -1804,7 +1807,7 @@ class $t extends ti {
|
|
|
1804
1807
|
this._state = "selecting";
|
|
1805
1808
|
}
|
|
1806
1809
|
registerBehaviors(t) {
|
|
1807
|
-
this.pixelDistance = new ht(t), this.clickBoundingBox = new ct(t), this.featuresAtMouseEvent = new Li(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new wi(t), this.coordinatePoints = new
|
|
1810
|
+
this.pixelDistance = new ht(t), this.clickBoundingBox = new ct(t), this.featuresAtMouseEvent = new Li(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new wi(t), this.coordinatePoints = new Fe(t), this.midPoints = new bi(t, this.selectionPoints, this.coordinatePoints), this.coordinateSnap = new Ot(t, this.pixelDistance, this.clickBoundingBox), this.lineSnap = new Gt(t, this.pixelDistance, this.clickBoundingBox), this.rotateFeature = new Di(t, this.selectionPoints, this.midPoints, this.coordinatePoints), this.dragFeature = new Mi(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints, this.coordinatePoints), this.dragCoordinate = new Fi(t, this.pixelDistance, this.selectionPoints, this.midPoints, this.coordinatePoints, this.coordinateSnap, this.lineSnap), this.dragCoordinateResizeFeature = new ki(t, this.pixelDistance, this.selectionPoints, this.midPoints, this.coordinatePoints), this.scaleFeature = new _i(t, this.dragCoordinateResizeFeature);
|
|
1808
1811
|
}
|
|
1809
1812
|
deselectFeature() {
|
|
1810
1813
|
this.deselect();
|
|
@@ -1823,14 +1826,14 @@ class $t extends ti {
|
|
|
1823
1826
|
const p = this.store.getGeometryCopy(u), g = this.pixelDistance.measure(t, p.coordinates);
|
|
1824
1827
|
g < this.pointerDistance && g < i && (i = g, e = this.store.getPropertiesCopy(u));
|
|
1825
1828
|
}), !e) return;
|
|
1826
|
-
const o = e.selectionPointFeatureId,
|
|
1829
|
+
const o = e.selectionPointFeatureId, r = e.index, n = this.store.getPropertiesCopy(o), a = this.flags[n.mode], l = this.validations[n.mode];
|
|
1827
1830
|
if (!(a && a.feature && a.feature.coordinates && a.feature.coordinates.deletable)) return;
|
|
1828
1831
|
const d = this.store.getGeometryCopy(o);
|
|
1829
1832
|
let c;
|
|
1830
1833
|
if (d.type === "Polygon") {
|
|
1831
1834
|
if (c = d.coordinates[0], c.length <= 4) return;
|
|
1832
1835
|
} else if (d.type === "LineString" && (c = d.coordinates, c.length <= 2)) return;
|
|
1833
|
-
if (!c || (d.type !== "Polygon" ||
|
|
1836
|
+
if (!c || (d.type !== "Polygon" || r !== 0 && r !== c.length - 1 ? c.splice(r, 1) : (c.shift(), c.pop(), c.push([c[0][0], c[0][1]])), l && !l({ id: o, type: "Feature", geometry: d, properties: n }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: E.Commit }).valid)) return;
|
|
1834
1837
|
const h = [...this.midPoints.ids, ...this.selectionPoints.ids];
|
|
1835
1838
|
this.store.delete(h), this.store.updateGeometry([{ id: o, geometry: d }]), n.coordinatePointIds && this.coordinatePoints.createOrUpdate(o), this.selectionPoints.create(c, d.type, o), a && a.feature && a.feature.coordinates && a.feature.coordinates.midpoints && this.midPoints.create(c, o, this.coordinatePrecision);
|
|
1836
1839
|
}
|
|
@@ -1838,9 +1841,9 @@ class $t extends ti {
|
|
|
1838
1841
|
if (this.selected[0] === t) return;
|
|
1839
1842
|
const { mode: i } = this.store.getPropertiesCopy(t), o = this.flags[i];
|
|
1840
1843
|
if (!o || !o.feature) return;
|
|
1841
|
-
const
|
|
1842
|
-
if (
|
|
1843
|
-
if (
|
|
1844
|
+
const r = this.selected[0];
|
|
1845
|
+
if (r) {
|
|
1846
|
+
if (r === t) return;
|
|
1844
1847
|
this.deselect();
|
|
1845
1848
|
}
|
|
1846
1849
|
e && this.setCursor(this.cursors.pointerOver), this.selected = [t], this.store.updateProperty([{ id: t, property: k.SELECTED, value: !0 }]), this.onSelect(t);
|
|
@@ -1892,34 +1895,34 @@ class $t extends ti {
|
|
|
1892
1895
|
const i = this.store.getPropertiesCopy(this.selected[0]), o = this.flags[i.mode];
|
|
1893
1896
|
if (!(o && o.feature && (o.feature.draggable || o.feature.coordinates && o.feature.coordinates.draggable || o.feature.coordinates && o.feature.coordinates.resizable || o.feature.coordinates && typeof o.feature.coordinates.midpoints == "object" && o.feature.coordinates.midpoints.draggable))) return;
|
|
1894
1897
|
this.dragEventCount = 0;
|
|
1895
|
-
const
|
|
1896
|
-
if (o && o.feature && o.feature.coordinates && (o.feature.coordinates.draggable || o.feature.coordinates.resizable) && n !== -1) return this.setCursor(this.cursors.dragStart), o.feature.coordinates.resizable ? this.dragCoordinateResizeFeature.startDragging(
|
|
1898
|
+
const r = this.selected[0], n = this.dragCoordinate.getDraggableIndex(t, r);
|
|
1899
|
+
if (o && o.feature && o.feature.coordinates && (o.feature.coordinates.draggable || o.feature.coordinates.resizable) && n !== -1) return this.setCursor(this.cursors.dragStart), o.feature.coordinates.resizable ? this.dragCoordinateResizeFeature.startDragging(r, n) : this.dragCoordinate.startDragging(r, n), void e(!1);
|
|
1897
1900
|
if (o && o.feature && o.feature.coordinates && typeof o.feature.coordinates.midpoints == "object" && o.feature.coordinates.midpoints.draggable) {
|
|
1898
1901
|
const { clickedMidPoint: a } = this.featuresAtMouseEvent.find(t, this.selected.length > 0);
|
|
1899
1902
|
if (this.selected.length && a) {
|
|
1900
|
-
this.midPoints.insert(
|
|
1901
|
-
const l = this.dragCoordinate.getDraggableIndex(t,
|
|
1902
|
-
return this.dragCoordinate.startDragging(
|
|
1903
|
+
this.midPoints.insert(r, a.id, this.coordinatePrecision);
|
|
1904
|
+
const l = this.dragCoordinate.getDraggableIndex(t, r);
|
|
1905
|
+
return this.dragCoordinate.startDragging(r, l), void e(!1);
|
|
1903
1906
|
}
|
|
1904
1907
|
}
|
|
1905
|
-
return o && o.feature && o.feature.draggable && this.dragFeature.canDrag(t,
|
|
1908
|
+
return o && o.feature && o.feature.draggable && this.dragFeature.canDrag(t, r) ? (this.setCursor(this.cursors.dragStart), this.dragFeature.startDragging(t, r), void e(!1)) : void 0;
|
|
1906
1909
|
}
|
|
1907
1910
|
onDrag(t, e) {
|
|
1908
1911
|
if (!this.allowPointerEvent(this.pointerEvents.onDrag, t)) return;
|
|
1909
1912
|
const i = this.selected[0];
|
|
1910
1913
|
if (!i) return;
|
|
1911
|
-
const o = this.store.getPropertiesCopy(i),
|
|
1914
|
+
const o = this.store.getPropertiesCopy(i), r = this.flags[o.mode], n = (r && r.feature && r.feature.selfIntersectable) === !0;
|
|
1912
1915
|
if (this.dragEventCount++, this.dragEventCount % this.dragEventThrottle == 0) return;
|
|
1913
1916
|
const a = this.validations[o.mode];
|
|
1914
|
-
if (
|
|
1915
|
-
if (
|
|
1916
|
-
if (this.dragCoordinateResizeFeature.isDragging() &&
|
|
1917
|
+
if (r && r.feature && r.feature.rotateable && this.canRotate(t)) return e(!1), void this.rotateFeature.rotate(t, i, a);
|
|
1918
|
+
if (r && r.feature && r.feature.scaleable && this.canScale(t)) return e(!1), void this.scaleFeature.scale(t, i, a);
|
|
1919
|
+
if (this.dragCoordinateResizeFeature.isDragging() && r.feature && r.feature.coordinates && r.feature.coordinates.resizable) {
|
|
1917
1920
|
if (this.projection === "globe") throw new Error("Globe is currently unsupported projection for resizable");
|
|
1918
|
-
return e(!1), void this.dragCoordinateResizeFeature.drag(t,
|
|
1921
|
+
return e(!1), void this.dragCoordinateResizeFeature.drag(t, r.feature.coordinates.resizable, a);
|
|
1919
1922
|
}
|
|
1920
1923
|
if (this.dragCoordinate.isDragging()) {
|
|
1921
1924
|
var l;
|
|
1922
|
-
const d = (l =
|
|
1925
|
+
const d = (l = r.feature) == null || (l = l.coordinates) == null ? void 0 : l.snappable;
|
|
1923
1926
|
let c = { toCoordinate: !1 };
|
|
1924
1927
|
return d === !0 ? c = { toCoordinate: !0 } : typeof d == "object" && (c = d), void this.dragCoordinate.drag(t, n, a, c);
|
|
1925
1928
|
}
|
|
@@ -1932,21 +1935,21 @@ class $t extends ti {
|
|
|
1932
1935
|
if (!this.selected.length) return void this.setCursor("unset");
|
|
1933
1936
|
if (this.dragFeature.isDragging()) return;
|
|
1934
1937
|
let e = !1;
|
|
1935
|
-
this.midPoints.ids.forEach((
|
|
1938
|
+
this.midPoints.ids.forEach((r) => {
|
|
1936
1939
|
if (e) return;
|
|
1937
|
-
const n = this.store.getGeometryCopy(
|
|
1940
|
+
const n = this.store.getGeometryCopy(r);
|
|
1938
1941
|
this.pixelDistance.measure(t, n.coordinates) < this.pointerDistance && (e = !0);
|
|
1939
1942
|
});
|
|
1940
1943
|
let i = !1;
|
|
1941
|
-
if (this.selectionPoints.ids.forEach((
|
|
1942
|
-
const n = this.store.getGeometryCopy(
|
|
1944
|
+
if (this.selectionPoints.ids.forEach((r) => {
|
|
1945
|
+
const n = this.store.getGeometryCopy(r);
|
|
1943
1946
|
this.pixelDistance.measure(t, n.coordinates) < this.pointerDistance && (e = !1, i = !0);
|
|
1944
1947
|
}), e) return void this.setCursor(this.cursors.insertMidpoint);
|
|
1945
1948
|
const { clickedFeature: o } = this.featuresAtMouseEvent.find(t, !0);
|
|
1946
1949
|
this.setCursor(this.selected.length > 0 && (o && o.id === this.selected[0] || i) ? this.cursors.pointerOver : "unset");
|
|
1947
1950
|
}
|
|
1948
1951
|
styleFeature(t) {
|
|
1949
|
-
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
1952
|
+
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0, markerUrl: void 0, markerHeight: void 0, markerWidth: void 0 });
|
|
1950
1953
|
if (t.properties.mode === this.mode && t.geometry.type === "Point") {
|
|
1951
1954
|
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;
|
|
1952
1955
|
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 = 50, e;
|
|
@@ -1962,14 +1965,14 @@ class $t extends ti {
|
|
|
1962
1965
|
var e, i;
|
|
1963
1966
|
const o = this.flags[t.properties.mode];
|
|
1964
1967
|
if (o == null || (e = o.feature) == null || !e.coordinates) return;
|
|
1965
|
-
const
|
|
1968
|
+
const r = t.geometry.type, n = t.id;
|
|
1966
1969
|
let a;
|
|
1967
|
-
if (this.selectionPoints.delete(), this.midPoints.delete(),
|
|
1970
|
+
if (this.selectionPoints.delete(), this.midPoints.delete(), r === "Polygon") a = t.geometry.coordinates[0];
|
|
1968
1971
|
else {
|
|
1969
|
-
if (
|
|
1972
|
+
if (r !== "LineString") return;
|
|
1970
1973
|
a = t.geometry.coordinates;
|
|
1971
1974
|
}
|
|
1972
|
-
this.selectionPoints.create(a,
|
|
1975
|
+
this.selectionPoints.create(a, r, n), o != null && (i = o.feature) != null && (i = i.coordinates) != null && i.midpoints && this.midPoints.create(r === "Polygon" ? t.geometry.coordinates[0] : t.geometry.coordinates, n, this.coordinatePrecision);
|
|
1973
1976
|
}
|
|
1974
1977
|
}
|
|
1975
1978
|
}
|
|
@@ -1998,73 +2001,73 @@ class Ti extends A {
|
|
|
1998
2001
|
cleanUp() {
|
|
1999
2002
|
}
|
|
2000
2003
|
styleFeature() {
|
|
2001
|
-
return x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
2004
|
+
return x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0, markerUrl: void 0, markerHeight: void 0, markerWidth: void 0 });
|
|
2002
2005
|
}
|
|
2003
2006
|
}
|
|
2004
|
-
function je(
|
|
2007
|
+
function je(s, t, e, i, o) {
|
|
2005
2008
|
for (; i > e; ) {
|
|
2006
2009
|
if (i - e > 600) {
|
|
2007
2010
|
const l = i - e + 1, d = t - e + 1, c = Math.log(l), h = 0.5 * Math.exp(2 * c / 3), u = 0.5 * Math.sqrt(c * h * (l - h) / l) * (d - l / 2 < 0 ? -1 : 1);
|
|
2008
|
-
je(
|
|
2011
|
+
je(s, t, Math.max(e, Math.floor(t - d * h / l + u)), Math.min(i, Math.floor(t + (l - d) * h / l + u)), o);
|
|
2009
2012
|
}
|
|
2010
|
-
const
|
|
2013
|
+
const r = s[t];
|
|
2011
2014
|
let n = e, a = i;
|
|
2012
|
-
for (ot(
|
|
2013
|
-
for (ot(
|
|
2014
|
-
for (; o(
|
|
2015
|
+
for (ot(s, e, t), o(s[i], r) > 0 && ot(s, e, i); n < a; ) {
|
|
2016
|
+
for (ot(s, n, a), n++, a--; o(s[n], r) < 0; ) n++;
|
|
2017
|
+
for (; o(s[a], r) > 0; ) a--;
|
|
2015
2018
|
}
|
|
2016
|
-
o(
|
|
2019
|
+
o(s[e], r) === 0 ? ot(s, e, a) : (a++, ot(s, a, i)), a <= t && (e = a + 1), t <= a && (i = a - 1);
|
|
2017
2020
|
}
|
|
2018
2021
|
}
|
|
2019
|
-
function ot(
|
|
2020
|
-
const i =
|
|
2021
|
-
|
|
2022
|
+
function ot(s, t, e) {
|
|
2023
|
+
const i = s[t];
|
|
2024
|
+
s[t] = s[e], s[e] = i;
|
|
2022
2025
|
}
|
|
2023
|
-
function
|
|
2024
|
-
at(
|
|
2026
|
+
function J(s, t) {
|
|
2027
|
+
at(s, 0, s.children.length, t, s);
|
|
2025
2028
|
}
|
|
2026
|
-
function at(
|
|
2029
|
+
function at(s, t, e, i, o) {
|
|
2027
2030
|
o || (o = Q([])), o.minX = 1 / 0, o.minY = 1 / 0, o.maxX = -1 / 0, o.maxY = -1 / 0;
|
|
2028
|
-
for (let
|
|
2029
|
-
const n =
|
|
2030
|
-
lt(o,
|
|
2031
|
+
for (let r = t; r < e; r++) {
|
|
2032
|
+
const n = s.children[r];
|
|
2033
|
+
lt(o, s.leaf ? i(n) : n);
|
|
2031
2034
|
}
|
|
2032
2035
|
return o;
|
|
2033
2036
|
}
|
|
2034
|
-
function lt(
|
|
2035
|
-
return
|
|
2037
|
+
function lt(s, t) {
|
|
2038
|
+
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;
|
|
2036
2039
|
}
|
|
2037
|
-
function Wi(
|
|
2038
|
-
return
|
|
2040
|
+
function Wi(s, t) {
|
|
2041
|
+
return s.minX - t.minX;
|
|
2039
2042
|
}
|
|
2040
|
-
function Bi(
|
|
2041
|
-
return
|
|
2043
|
+
function Bi(s, t) {
|
|
2044
|
+
return s.minY - t.minY;
|
|
2042
2045
|
}
|
|
2043
|
-
function
|
|
2044
|
-
return (
|
|
2046
|
+
function Ft(s) {
|
|
2047
|
+
return (s.maxX - s.minX) * (s.maxY - s.minY);
|
|
2045
2048
|
}
|
|
2046
|
-
function vt(
|
|
2047
|
-
return
|
|
2049
|
+
function vt(s) {
|
|
2050
|
+
return s.maxX - s.minX + (s.maxY - s.minY);
|
|
2048
2051
|
}
|
|
2049
|
-
function ji(
|
|
2050
|
-
const e = Math.max(
|
|
2051
|
-
return Math.max(0, o - e) * Math.max(0,
|
|
2052
|
+
function ji(s, t) {
|
|
2053
|
+
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);
|
|
2054
|
+
return Math.max(0, o - e) * Math.max(0, r - i);
|
|
2052
2055
|
}
|
|
2053
|
-
function Dt(
|
|
2054
|
-
return
|
|
2056
|
+
function Dt(s, t) {
|
|
2057
|
+
return s.minX <= t.minX && s.minY <= t.minY && t.maxX <= s.maxX && t.maxY <= s.maxY;
|
|
2055
2058
|
}
|
|
2056
|
-
function Ct(
|
|
2057
|
-
return t.minX <=
|
|
2059
|
+
function Ct(s, t) {
|
|
2060
|
+
return t.minX <= s.maxX && t.minY <= s.maxY && t.maxX >= s.minX && t.maxY >= s.minY;
|
|
2058
2061
|
}
|
|
2059
|
-
function Q(
|
|
2060
|
-
return { children:
|
|
2062
|
+
function Q(s) {
|
|
2063
|
+
return { children: s, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
|
|
2061
2064
|
}
|
|
2062
|
-
function pe(
|
|
2063
|
-
const
|
|
2064
|
-
for (;
|
|
2065
|
-
if ((e =
|
|
2065
|
+
function pe(s, t, e, i, o) {
|
|
2066
|
+
const r = [t, e];
|
|
2067
|
+
for (; r.length; ) {
|
|
2068
|
+
if ((e = r.pop()) - (t = r.pop()) <= i) continue;
|
|
2066
2069
|
const n = t + Math.ceil((e - t) / i / 2) * i;
|
|
2067
|
-
je(
|
|
2070
|
+
je(s, n, t, e, o), r.push(t, n, n, e);
|
|
2068
2071
|
}
|
|
2069
2072
|
}
|
|
2070
2073
|
class Ai {
|
|
@@ -2075,13 +2078,13 @@ class Ai {
|
|
|
2075
2078
|
let e = this.data;
|
|
2076
2079
|
const i = [];
|
|
2077
2080
|
if (!Ct(t, e)) return i;
|
|
2078
|
-
const o = this.toBBox,
|
|
2081
|
+
const o = this.toBBox, r = [];
|
|
2079
2082
|
for (; e; ) {
|
|
2080
2083
|
for (let n = 0; n < e.children.length; n++) {
|
|
2081
2084
|
const a = e.children[n], l = e.leaf ? o(a) : a;
|
|
2082
|
-
Ct(t, l) && (e.leaf ? i.push(a) : Dt(t, l) ? this._all(a, i) :
|
|
2085
|
+
Ct(t, l) && (e.leaf ? i.push(a) : Dt(t, l) ? this._all(a, i) : r.push(a));
|
|
2083
2086
|
}
|
|
2084
|
-
e =
|
|
2087
|
+
e = r.pop();
|
|
2085
2088
|
}
|
|
2086
2089
|
return i;
|
|
2087
2090
|
}
|
|
@@ -2091,10 +2094,10 @@ class Ai {
|
|
|
2091
2094
|
const i = [];
|
|
2092
2095
|
for (; e; ) {
|
|
2093
2096
|
for (let o = 0; o < e.children.length; o++) {
|
|
2094
|
-
const
|
|
2097
|
+
const r = e.children[o], n = e.leaf ? this.toBBox(r) : r;
|
|
2095
2098
|
if (Ct(t, n)) {
|
|
2096
2099
|
if (e.leaf || Dt(t, n)) return !0;
|
|
2097
|
-
i.push(
|
|
2100
|
+
i.push(r);
|
|
2098
2101
|
}
|
|
2099
2102
|
}
|
|
2100
2103
|
e = i.pop();
|
|
@@ -2126,14 +2129,14 @@ class Ai {
|
|
|
2126
2129
|
}
|
|
2127
2130
|
remove(t) {
|
|
2128
2131
|
let e = this.data;
|
|
2129
|
-
const i = this.toBBox(t), o = [],
|
|
2132
|
+
const i = this.toBBox(t), o = [], r = [];
|
|
2130
2133
|
let n, a, l = !1;
|
|
2131
2134
|
for (; e || o.length; ) {
|
|
2132
|
-
if (e || (e = o.pop(), a = o[o.length - 1], n =
|
|
2135
|
+
if (e || (e = o.pop(), a = o[o.length - 1], n = r.pop(), l = !0), e.leaf) {
|
|
2133
2136
|
const d = e.children.indexOf(t);
|
|
2134
2137
|
d !== -1 && (e.children.splice(d, 1), o.push(e), this._condense(o));
|
|
2135
2138
|
}
|
|
2136
|
-
l || e.leaf || !Dt(e, i) ? a ? (n++, e = a.children[n], l = !1) : e = null : (o.push(e),
|
|
2139
|
+
l || e.leaf || !Dt(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]);
|
|
2137
2140
|
}
|
|
2138
2141
|
}
|
|
2139
2142
|
toBBox(t) {
|
|
@@ -2151,11 +2154,11 @@ class Ai {
|
|
|
2151
2154
|
return e;
|
|
2152
2155
|
}
|
|
2153
2156
|
_build(t, e, i, o) {
|
|
2154
|
-
const
|
|
2157
|
+
const r = i - e + 1;
|
|
2155
2158
|
let n, a = this._maxEntries;
|
|
2156
|
-
if (
|
|
2157
|
-
o || (o = Math.ceil(Math.log(
|
|
2158
|
-
const l = Math.ceil(
|
|
2159
|
+
if (r <= a) return n = Q(t.slice(e, i + 1)), J(n, this.toBBox), n;
|
|
2160
|
+
o || (o = Math.ceil(Math.log(r) / Math.log(a)), a = Math.ceil(r / Math.pow(a, o - 1))), n = Q([]), n.leaf = !1, n.height = o;
|
|
2161
|
+
const l = Math.ceil(r / a), d = l * Math.ceil(Math.sqrt(a));
|
|
2159
2162
|
pe(t, e, i, d, this.compareMinX);
|
|
2160
2163
|
for (let c = e; c <= i; c += d) {
|
|
2161
2164
|
const h = Math.min(c + d - 1, i);
|
|
@@ -2165,57 +2168,57 @@ class Ai {
|
|
|
2165
2168
|
n.children.push(this._build(t, u, p, o - 1));
|
|
2166
2169
|
}
|
|
2167
2170
|
}
|
|
2168
|
-
return
|
|
2171
|
+
return J(n, this.toBBox), n;
|
|
2169
2172
|
}
|
|
2170
2173
|
_chooseSubtree(t, e, i, o) {
|
|
2171
2174
|
for (; o.push(e), !e.leaf && o.length - 1 !== i; ) {
|
|
2172
2175
|
let a, l = 1 / 0, d = 1 / 0;
|
|
2173
2176
|
for (let c = 0; c < e.children.length; c++) {
|
|
2174
|
-
const h = e.children[c], u =
|
|
2177
|
+
const h = e.children[c], u = Ft(h), p = (r = t, n = h, (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);
|
|
2175
2178
|
p < d ? (d = p, l = u < l ? u : l, a = h) : p === d && u < l && (l = u, a = h);
|
|
2176
2179
|
}
|
|
2177
2180
|
e = a || e.children[0];
|
|
2178
2181
|
}
|
|
2179
|
-
var
|
|
2182
|
+
var r, n;
|
|
2180
2183
|
return e;
|
|
2181
2184
|
}
|
|
2182
2185
|
_insert(t, e, i) {
|
|
2183
|
-
const o = i ? t : this.toBBox(t),
|
|
2184
|
-
for (n.children.push(t), lt(n, o); e >= 0 &&
|
|
2185
|
-
this._adjustParentBBoxes(o,
|
|
2186
|
+
const o = i ? t : this.toBBox(t), r = [], n = this._chooseSubtree(o, this.data, e, r);
|
|
2187
|
+
for (n.children.push(t), lt(n, o); e >= 0 && r[e].children.length > this._maxEntries; ) this._split(r, e), e--;
|
|
2188
|
+
this._adjustParentBBoxes(o, r, e);
|
|
2186
2189
|
}
|
|
2187
2190
|
_split(t, e) {
|
|
2188
|
-
const i = t[e], o = i.children.length,
|
|
2189
|
-
this._chooseSplitAxis(i,
|
|
2190
|
-
const n = this._chooseSplitIndex(i,
|
|
2191
|
-
a.height = i.height, a.leaf = i.leaf,
|
|
2191
|
+
const i = t[e], o = i.children.length, r = this._minEntries;
|
|
2192
|
+
this._chooseSplitAxis(i, r, o);
|
|
2193
|
+
const n = this._chooseSplitIndex(i, r, o), a = Q(i.children.splice(n, i.children.length - n));
|
|
2194
|
+
a.height = i.height, a.leaf = i.leaf, J(i, this.toBBox), J(a, this.toBBox), e ? t[e - 1].children.push(a) : this._splitRoot(i, a);
|
|
2192
2195
|
}
|
|
2193
2196
|
_splitRoot(t, e) {
|
|
2194
|
-
this.data = Q([t, e]), this.data.height = t.height + 1, this.data.leaf = !1,
|
|
2197
|
+
this.data = Q([t, e]), this.data.height = t.height + 1, this.data.leaf = !1, J(this.data, this.toBBox);
|
|
2195
2198
|
}
|
|
2196
2199
|
_chooseSplitIndex(t, e, i) {
|
|
2197
|
-
let o,
|
|
2200
|
+
let o, r = 1 / 0, n = 1 / 0;
|
|
2198
2201
|
for (let a = e; a <= i - e; a++) {
|
|
2199
|
-
const l = at(t, 0, a, this.toBBox), d = at(t, a, i, this.toBBox), c = ji(l, d), h =
|
|
2200
|
-
c <
|
|
2202
|
+
const l = at(t, 0, a, this.toBBox), d = at(t, a, i, this.toBBox), c = ji(l, d), h = Ft(l) + Ft(d);
|
|
2203
|
+
c < r ? (r = c, o = a, n = h < n ? h : n) : c === r && h < n && (n = h, o = a);
|
|
2201
2204
|
}
|
|
2202
2205
|
return o || i - e;
|
|
2203
2206
|
}
|
|
2204
2207
|
_chooseSplitAxis(t, e, i) {
|
|
2205
|
-
const o = t.leaf ? this.compareMinX : Wi,
|
|
2206
|
-
this._allDistMargin(t, e, i, o) < this._allDistMargin(t, e, i,
|
|
2208
|
+
const o = t.leaf ? this.compareMinX : Wi, r = t.leaf ? this.compareMinY : Bi;
|
|
2209
|
+
this._allDistMargin(t, e, i, o) < this._allDistMargin(t, e, i, r) && t.children.sort(o);
|
|
2207
2210
|
}
|
|
2208
2211
|
_allDistMargin(t, e, i, o) {
|
|
2209
2212
|
t.children.sort(o);
|
|
2210
|
-
const
|
|
2213
|
+
const r = this.toBBox, n = at(t, 0, e, r), a = at(t, i - e, i, r);
|
|
2211
2214
|
let l = vt(n) + vt(a);
|
|
2212
2215
|
for (let d = e; d < i - e; d++) {
|
|
2213
2216
|
const c = t.children[d];
|
|
2214
|
-
lt(n, t.leaf ?
|
|
2217
|
+
lt(n, t.leaf ? r(c) : c), l += vt(n);
|
|
2215
2218
|
}
|
|
2216
2219
|
for (let d = i - e - 1; d >= e; d--) {
|
|
2217
2220
|
const c = t.children[d];
|
|
2218
|
-
lt(a, t.leaf ?
|
|
2221
|
+
lt(a, t.leaf ? r(c) : c), l += vt(a);
|
|
2219
2222
|
}
|
|
2220
2223
|
return l;
|
|
2221
2224
|
}
|
|
@@ -2223,10 +2226,10 @@ class Ai {
|
|
|
2223
2226
|
for (let o = i; o >= 0; o--) lt(e[o], t);
|
|
2224
2227
|
}
|
|
2225
2228
|
_condense(t) {
|
|
2226
|
-
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() :
|
|
2229
|
+
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() : J(t[i], this.toBBox);
|
|
2227
2230
|
}
|
|
2228
2231
|
}
|
|
2229
|
-
class
|
|
2232
|
+
class Ui {
|
|
2230
2233
|
constructor(t) {
|
|
2231
2234
|
this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new Ai(t && t.maxEntries ? t.maxEntries : 9), this.idToNode = /* @__PURE__ */ new Map(), this.nodeToId = /* @__PURE__ */ new Map();
|
|
2232
2235
|
}
|
|
@@ -2243,8 +2246,8 @@ class Ri {
|
|
|
2243
2246
|
o = [t.geometry.coordinates];
|
|
2244
2247
|
}
|
|
2245
2248
|
for (let a = 0; a < o.length; a++) i.push(o[a][1]), e.push(o[a][0]);
|
|
2246
|
-
const
|
|
2247
|
-
return { minX: Math.min(...e), minY:
|
|
2249
|
+
const r = Math.min(...i), n = Math.max(...i);
|
|
2250
|
+
return { minX: Math.min(...e), minY: r, maxX: Math.max(...e), maxY: n };
|
|
2248
2251
|
}
|
|
2249
2252
|
insert(t) {
|
|
2250
2253
|
if (this.idToNode.get(String(t.id))) throw new Error("Feature already exists");
|
|
@@ -2254,9 +2257,9 @@ class Ri {
|
|
|
2254
2257
|
load(t) {
|
|
2255
2258
|
const e = [], i = /* @__PURE__ */ new Set();
|
|
2256
2259
|
t.forEach((o) => {
|
|
2257
|
-
const
|
|
2258
|
-
if (this.setMaps(o,
|
|
2259
|
-
i.add(String(o.id)), e.push(
|
|
2260
|
+
const r = this.toBBox(o);
|
|
2261
|
+
if (this.setMaps(o, r), i.has(String(o.id))) throw new Error(`Duplicate feature ID found ${o.id}`);
|
|
2262
|
+
i.add(String(o.id)), e.push(r);
|
|
2260
2263
|
}), this.tree.load(e);
|
|
2261
2264
|
}
|
|
2262
2265
|
update(t) {
|
|
@@ -2279,14 +2282,14 @@ class Ri {
|
|
|
2279
2282
|
return this.tree.collides(this.toBBox(t));
|
|
2280
2283
|
}
|
|
2281
2284
|
}
|
|
2282
|
-
const
|
|
2285
|
+
const Ri = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(s) {
|
|
2283
2286
|
const t = 16 * Math.random() | 0;
|
|
2284
|
-
return (
|
|
2285
|
-
}), isValidId: (
|
|
2286
|
-
class
|
|
2287
|
+
return (s == "x" ? t : 3 & t | 8).toString(16);
|
|
2288
|
+
}), isValidId: (s) => typeof s == "string" && s.length === 36 };
|
|
2289
|
+
class Gi {
|
|
2287
2290
|
constructor(t) {
|
|
2288
2291
|
this.idStrategy = void 0, this.tracked = void 0, this.spatialIndex = void 0, this.store = void 0, this._onChange = () => {
|
|
2289
|
-
}, this.store = {}, this.spatialIndex = new
|
|
2292
|
+
}, this.store = {}, this.spatialIndex = new Ui(), this.tracked = !t || t.tracked !== !1, this.idStrategy = t && t.idStrategy ? t.idStrategy : Ri;
|
|
2290
2293
|
}
|
|
2291
2294
|
clone(t) {
|
|
2292
2295
|
return JSON.parse(JSON.stringify(t));
|
|
@@ -2299,9 +2302,9 @@ class Ui {
|
|
|
2299
2302
|
}
|
|
2300
2303
|
load(t, e, i, o) {
|
|
2301
2304
|
if (t.length === 0) return [];
|
|
2302
|
-
let
|
|
2305
|
+
let r = this.clone(t);
|
|
2303
2306
|
const n = [], a = [];
|
|
2304
|
-
|
|
2307
|
+
r = r.filter((d) => {
|
|
2305
2308
|
d.id == null && (d.id = this.idStrategy.getId());
|
|
2306
2309
|
const c = d.id;
|
|
2307
2310
|
if (e) {
|
|
@@ -2317,7 +2320,7 @@ class Ui {
|
|
|
2317
2320
|
} else d.properties.updatedAt = +/* @__PURE__ */ new Date();
|
|
2318
2321
|
}
|
|
2319
2322
|
return this.has(c) ? (n.push({ id: c, valid: !1, reason: `Feature already exists with this id: ${c}` }), !1) : (this.store[c] = d, a.push(d), n.push({ id: c, valid: !0 }), !0);
|
|
2320
|
-
}), this.spatialIndex.load(
|
|
2323
|
+
}), this.spatialIndex.load(r);
|
|
2321
2324
|
const l = a.map(({ id: d }) => d);
|
|
2322
2325
|
return l.length > 0 && (this._onChange(l, "create", o), i && a.forEach((d) => {
|
|
2323
2326
|
i(d);
|
|
@@ -2344,26 +2347,26 @@ class Ui {
|
|
|
2344
2347
|
}
|
|
2345
2348
|
updateProperty(t, e) {
|
|
2346
2349
|
const i = [];
|
|
2347
|
-
t.forEach(({ id: o, property:
|
|
2350
|
+
t.forEach(({ id: o, property: r, value: n }) => {
|
|
2348
2351
|
const a = this.store[o];
|
|
2349
2352
|
if (!a) throw new Error(`No feature with this (${o}), can not update geometry`);
|
|
2350
|
-
i.push(o), n === void 0 ? delete a.properties[
|
|
2353
|
+
i.push(o), n === void 0 ? delete a.properties[r] : a.properties[r] = n, this.tracked && (a.properties.updatedAt = +/* @__PURE__ */ new Date());
|
|
2351
2354
|
}), this._onChange && this._onChange(i, "update", e);
|
|
2352
2355
|
}
|
|
2353
2356
|
updateGeometry(t, e) {
|
|
2354
2357
|
const i = [];
|
|
2355
|
-
t.forEach(({ id: o, geometry:
|
|
2358
|
+
t.forEach(({ id: o, geometry: r }) => {
|
|
2356
2359
|
i.push(o);
|
|
2357
2360
|
const n = this.store[o];
|
|
2358
2361
|
if (!n) throw new Error(`No feature with this (${o}), can not update geometry`);
|
|
2359
|
-
n.geometry = this.clone(
|
|
2362
|
+
n.geometry = this.clone(r), this.spatialIndex.update(n), this.tracked && (n.properties.updatedAt = +/* @__PURE__ */ new Date());
|
|
2360
2363
|
}), this._onChange && this._onChange(i, "update", e);
|
|
2361
2364
|
}
|
|
2362
2365
|
create(t, e) {
|
|
2363
2366
|
const i = [];
|
|
2364
|
-
return t.forEach(({ geometry: o, properties:
|
|
2365
|
-
let n, a = x({},
|
|
2366
|
-
this.tracked && (n = +/* @__PURE__ */ new Date(),
|
|
2367
|
+
return t.forEach(({ geometry: o, properties: r }) => {
|
|
2368
|
+
let n, a = x({}, r);
|
|
2369
|
+
this.tracked && (n = +/* @__PURE__ */ new Date(), r ? (a.createdAt = typeof r.createdAt == "number" ? r.createdAt : n, a.updatedAt = typeof r.updatedAt == "number" ? r.updatedAt : n) : a = { createdAt: n, updatedAt: n });
|
|
2367
2370
|
const l = this.getId(), d = { id: l, type: "Feature", geometry: o, properties: a };
|
|
2368
2371
|
this.store[l] = d, this.spatialIndex.insert(d), i.push(l);
|
|
2369
2372
|
}), this._onChange && this._onChange([...i], "create", e), i;
|
|
@@ -2390,10 +2393,10 @@ class Ui {
|
|
|
2390
2393
|
return Object.keys(this.store).length;
|
|
2391
2394
|
}
|
|
2392
2395
|
}
|
|
2393
|
-
const zi = "Feature is not a Polygon or LineString", Vi = "Feature intersects itself", $i = (
|
|
2394
|
-
function ge(
|
|
2395
|
-
const i =
|
|
2396
|
-
let o =
|
|
2396
|
+
const zi = "Feature is not a Polygon or LineString", Vi = "Feature intersects itself", $i = (s) => s.geometry.type !== "Polygon" && s.geometry.type !== "LineString" ? { valid: !1, reason: zi } : At(s) ? { valid: !1, reason: Vi } : { valid: !0 };
|
|
2397
|
+
function ge(s, t, e) {
|
|
2398
|
+
const i = R(s, t);
|
|
2399
|
+
let o = R(t, e) - i;
|
|
2397
2400
|
return o < 0 && (o += 360), 180 - Math.abs(o - 90 - 90);
|
|
2398
2401
|
}
|
|
2399
2402
|
const Yi = { cancel: "Escape", finish: "Enter" }, Ki = { start: "crosshair", close: "pointer" };
|
|
@@ -2421,13 +2424,13 @@ class Ae extends A {
|
|
|
2421
2424
|
const e = this.store.getGeometryCopy(this.currentId).coordinates[0];
|
|
2422
2425
|
let i;
|
|
2423
2426
|
if (this.currentCoordinate === 1) {
|
|
2424
|
-
const o = 1 / Math.pow(10, this.coordinatePrecision - 1),
|
|
2425
|
-
i = [e[0], [t.lng, t.lat], [t.lng, t.lat -
|
|
2427
|
+
const o = 1 / Math.pow(10, this.coordinatePrecision - 1), r = Math.max(1e-6, o);
|
|
2428
|
+
i = [e[0], [t.lng, t.lat], [t.lng, t.lat - r], e[0]];
|
|
2426
2429
|
} else if (this.currentCoordinate === 2) {
|
|
2427
|
-
const o = e[0],
|
|
2428
|
-
const
|
|
2429
|
-
return
|
|
2430
|
-
})(a, d, c) === "right" ? -90 : 90), v = ut(a, y, f), C = ut(d, y, f), m =
|
|
2430
|
+
const o = e[0], r = e[1], n = Ne(o, r, this.coordinatePrecision, this.project, this.unproject), a = O(o[0], o[1]), l = O(n[0], n[1]), d = O(r[0], r[1]), c = O(t.lng, t.lat), h = M(c, a) < M(c, d), u = ge(a, l, c), p = h ? 90 - u : ge(a, l, c) - 90, g = M(l, c), y = Math.cos(D(p)) * g, f = R(a, d) + ((function(I, w, L) {
|
|
2431
|
+
const F = (L.x - w.x) * (I.y - w.y) - (L.y - w.y) * (I.x - w.x);
|
|
2432
|
+
return F > 1e-10 ? "left" : F < -1e-10 ? "right" : "left";
|
|
2433
|
+
})(a, d, c) === "right" ? -90 : 90), v = ut(a, y, f), C = ut(d, y, f), m = U(v.x, v.y), P = U(C.x, C.y);
|
|
2431
2434
|
i = [e[0], e[1], [b(P.lng, this.coordinatePrecision), b(P.lat, this.coordinatePrecision)], [b(m.lng, this.coordinatePrecision), b(m.lat, this.coordinatePrecision)], e[0]];
|
|
2432
2435
|
}
|
|
2433
2436
|
i && this.updatePolygonGeometry(this.currentId, i, E.Provisional);
|
|
@@ -2469,7 +2472,7 @@ class Ae extends A {
|
|
|
2469
2472
|
this.currentId = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted();
|
|
2470
2473
|
}
|
|
2471
2474
|
styleFeature(t) {
|
|
2472
|
-
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
2475
|
+
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0, markerUrl: void 0, markerHeight: void 0, markerWidth: void 0 });
|
|
2473
2476
|
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 = j), e;
|
|
2474
2477
|
}
|
|
2475
2478
|
validateFeature(t) {
|
|
@@ -2479,11 +2482,11 @@ class Ae extends A {
|
|
|
2479
2482
|
this.currentId === t.id && (this.currentId = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted());
|
|
2480
2483
|
}
|
|
2481
2484
|
}
|
|
2482
|
-
function
|
|
2483
|
-
return (t.x -
|
|
2485
|
+
function Ue(s, t, e) {
|
|
2486
|
+
return (t.x - s.x) * (e.y - s.y) - (t.y - s.y) * (e.x - s.x) <= 0;
|
|
2484
2487
|
}
|
|
2485
2488
|
const Xi = { cancel: "Escape", finish: "Enter" }, qi = { start: "crosshair", close: "pointer" };
|
|
2486
|
-
class
|
|
2489
|
+
class Re extends A {
|
|
2487
2490
|
constructor(t) {
|
|
2488
2491
|
super(t, !0), this.mode = "sector", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = Xi, this.direction = void 0, this.arcPoints = 64, this.cursors = qi, this.mouseMove = !1, this.updateOptions(t);
|
|
2489
2492
|
}
|
|
@@ -2508,21 +2511,21 @@ class Ge extends A {
|
|
|
2508
2511
|
const e = this.store.getGeometryCopy(this.currentId).coordinates[0];
|
|
2509
2512
|
let i;
|
|
2510
2513
|
if (this.currentCoordinate === 1) {
|
|
2511
|
-
const o = 1 / Math.pow(10, this.coordinatePrecision - 1),
|
|
2512
|
-
i = [e[0], [t.lng, t.lat], [t.lng, t.lat -
|
|
2514
|
+
const o = 1 / Math.pow(10, this.coordinatePrecision - 1), r = Math.max(1e-6, o);
|
|
2515
|
+
i = [e[0], [t.lng, t.lat], [t.lng, t.lat - r], e[0]];
|
|
2513
2516
|
} else if (this.currentCoordinate === 2) {
|
|
2514
|
-
const o = e[0],
|
|
2517
|
+
const o = e[0], r = e[1], n = [t.lng, t.lat], a = O(o[0], o[1]), l = O(r[0], r[1]), d = O(n[0], n[1]);
|
|
2515
2518
|
if (this.direction === void 0) {
|
|
2516
|
-
const m =
|
|
2519
|
+
const m = Ue(a, l, d);
|
|
2517
2520
|
this.direction = m ? "clockwise" : "anticlockwise";
|
|
2518
2521
|
}
|
|
2519
|
-
const c =
|
|
2522
|
+
const c = M(a, l), h = R(a, l), u = R(a, d), p = this.arcPoints, g = [o], y = X(h), f = X(u);
|
|
2520
2523
|
let v;
|
|
2521
2524
|
this.direction === "anticlockwise" ? (v = f - y, v < 0 && (v += 360)) : (v = y - f, v < 0 && (v += 360));
|
|
2522
2525
|
const C = (this.direction === "anticlockwise" ? 1 : -1) * v / p;
|
|
2523
|
-
g.push(
|
|
2526
|
+
g.push(r);
|
|
2524
2527
|
for (let m = 0; m <= p; m++) {
|
|
2525
|
-
const P = ut(a, c, y + m * C), { lng: I, lat: w } =
|
|
2528
|
+
const P = ut(a, c, y + m * C), { lng: I, lat: w } = U(P.x, P.y), L = [b(I, this.coordinatePrecision), b(w, this.coordinatePrecision)];
|
|
2526
2529
|
L[0] !== g[g.length - 1][0] && L[1] !== g[g.length - 1][1] && g.push(L);
|
|
2527
2530
|
}
|
|
2528
2531
|
g.push(o), i = [...g];
|
|
@@ -2562,7 +2565,7 @@ class Ge extends A {
|
|
|
2562
2565
|
this.currentId = void 0, this.direction = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted();
|
|
2563
2566
|
}
|
|
2564
2567
|
styleFeature(t) {
|
|
2565
|
-
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
2568
|
+
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0, markerUrl: void 0, markerHeight: void 0, markerWidth: void 0 });
|
|
2566
2569
|
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 = j), e;
|
|
2567
2570
|
}
|
|
2568
2571
|
validateFeature(t) {
|
|
@@ -2572,10 +2575,10 @@ class Ge extends A {
|
|
|
2572
2575
|
this.currentId === t.id && (this.currentId = void 0, this.direction = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted());
|
|
2573
2576
|
}
|
|
2574
2577
|
}
|
|
2575
|
-
const
|
|
2576
|
-
class
|
|
2578
|
+
const Hi = { cancel: "Escape", finish: "Enter" }, Ji = { start: "crosshair", close: "pointer" };
|
|
2579
|
+
class Ge extends A {
|
|
2577
2580
|
constructor(t) {
|
|
2578
|
-
super(t, !0), this.mode = "sensor", this.currentCoordinate = 0, this.currentId = void 0, this.currentInitialArcId = void 0, this.currentStartingPointId = void 0, this.keyEvents =
|
|
2581
|
+
super(t, !0), this.mode = "sensor", this.currentCoordinate = 0, this.currentId = void 0, this.currentInitialArcId = void 0, this.currentStartingPointId = void 0, this.keyEvents = Hi, this.direction = void 0, this.arcPoints = 64, this.cursors = Ji, this.mouseMove = !1, this.updateOptions(t);
|
|
2579
2582
|
}
|
|
2580
2583
|
updateOptions(t) {
|
|
2581
2584
|
super.updateOptions(t), t != null && t.cursors && (this.cursors = x({}, this.cursors, t.cursors)), t?.keyEvents === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = x({}, this.keyEvents, t.keyEvents)), t != null && t.arcPoints && (this.arcPoints = t.arcPoints);
|
|
@@ -2598,28 +2601,28 @@ class Ue extends A {
|
|
|
2598
2601
|
onMouseMove(t) {
|
|
2599
2602
|
if (this.mouseMove = !0, this.setCursor(this.cursors.start), this.currentInitialArcId !== void 0 && this.currentStartingPointId !== void 0 && this.currentCoordinate !== 0) {
|
|
2600
2603
|
if (this.currentCoordinate === 2) {
|
|
2601
|
-
const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0],
|
|
2604
|
+
const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], r = [t.lng, t.lat], n = O(o[0], o[1]), a = O(r[0], r[1]), l = O(i[0], i[1]), d = M(l, n);
|
|
2602
2605
|
if (this.direction === void 0) {
|
|
2603
|
-
const C =
|
|
2606
|
+
const C = Ue(l, n, a);
|
|
2604
2607
|
this.direction = C ? "clockwise" : "anticlockwise";
|
|
2605
2608
|
}
|
|
2606
|
-
const c =
|
|
2609
|
+
const c = R(l, n), h = R(l, a), u = this.arcPoints, p = [o], g = X(c), y = X(h);
|
|
2607
2610
|
let f;
|
|
2608
2611
|
this.direction === "anticlockwise" ? (f = y - g, f < 0 && (f += 360)) : (f = g - y, f < 0 && (f += 360));
|
|
2609
2612
|
const v = (this.direction === "anticlockwise" ? 1 : -1) * f / u;
|
|
2610
2613
|
for (let C = 0; C <= u; C++) {
|
|
2611
|
-
const m = ut(l, d, g + C * v), { lng: P, lat: I } =
|
|
2614
|
+
const m = ut(l, d, g + C * v), { lng: P, lat: I } = U(m.x, m.y), w = [b(P, this.coordinatePrecision), b(I, this.coordinatePrecision)];
|
|
2612
2615
|
w[0] !== p[p.length - 1][0] && w[1] !== p[p.length - 1][1] && p.push(w);
|
|
2613
2616
|
}
|
|
2614
2617
|
this.updateLineStringGeometry(this.currentInitialArcId, p, E.Provisional);
|
|
2615
2618
|
} else if (this.currentCoordinate === 3) {
|
|
2616
2619
|
const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates;
|
|
2617
2620
|
if (e.length < 2 || !this.direction) return;
|
|
2618
|
-
const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0],
|
|
2621
|
+
const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], r = e[e.length - 1], n = O(t.lng, t.lat), a = O(o[0], o[1]), l = O(r[0], r[1]), d = O(i[0], i[1]), c = M(d, a), h = M(d, n) < c ? a : n, u = R(d, n), p = R(d, a), g = R(d, l), y = X(p), f = X(g), v = X(u);
|
|
2619
2622
|
if (this.notInSector({ normalizedCursor: v, normalizedStart: y, normalizedEnd: f, direction: this.direction })) return;
|
|
2620
|
-
const C = this.getDeltaBearing(this.direction, y, f), m = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * C / m, I =
|
|
2623
|
+
const C = this.getDeltaBearing(this.direction, y, f), m = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * C / m, I = M(d, h), w = [];
|
|
2621
2624
|
for (let L = 0; L <= m; L++) {
|
|
2622
|
-
const
|
|
2625
|
+
const F = ut(d, I, y + L * P), { lng: N, lat: _ } = U(F.x, F.y), T = [b(N, this.coordinatePrecision), b(_, this.coordinatePrecision)];
|
|
2623
2626
|
T[0] !== e[e.length - 1][0] && T[1] !== e[e.length - 1][1] && w.unshift(T);
|
|
2624
2627
|
}
|
|
2625
2628
|
e.push(...w), e.push(e[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, e, E.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [e] }, properties: { mode: this.mode, [S.CURRENTLY_DRAWING]: !0 } }]);
|
|
@@ -2662,7 +2665,7 @@ class Ue extends A {
|
|
|
2662
2665
|
this.currentStartingPointId = void 0, this.direction = void 0, this.currentId = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted();
|
|
2663
2666
|
}
|
|
2664
2667
|
styleFeature(t) {
|
|
2665
|
-
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
2668
|
+
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0, markerUrl: void 0, markerHeight: void 0, markerWidth: void 0 });
|
|
2666
2669
|
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 = j) : 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 = j) : 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;
|
|
2667
2670
|
}
|
|
2668
2671
|
validateFeature(t) {
|
|
@@ -2689,24 +2692,24 @@ class Z {
|
|
|
2689
2692
|
}
|
|
2690
2693
|
}
|
|
2691
2694
|
var Zi = { __proto__: null, TerraDrawBaseAdapter: class {
|
|
2692
|
-
constructor(
|
|
2693
|
-
this._nextKeyUpIsContextMenu = !1, 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
|
|
2695
|
+
constructor(s) {
|
|
2696
|
+
this._nextKeyUpIsContextMenu = !1, 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;
|
|
2694
2697
|
}
|
|
2695
|
-
getButton(
|
|
2696
|
-
return
|
|
2698
|
+
getButton(s) {
|
|
2699
|
+
return s.button === -1 ? "neither" : s.button === 0 ? "left" : s.button === 1 ? "middle" : s.button === 2 ? "right" : "neither";
|
|
2697
2700
|
}
|
|
2698
|
-
getMapElementXYPosition(
|
|
2701
|
+
getMapElementXYPosition(s) {
|
|
2699
2702
|
const t = this.getMapEventElement(), { left: e, top: i } = t.getBoundingClientRect();
|
|
2700
|
-
return { containerX:
|
|
2703
|
+
return { containerX: s.clientX - e, containerY: s.clientY - i };
|
|
2701
2704
|
}
|
|
2702
|
-
getDrawEventFromEvent(
|
|
2703
|
-
const e = this.getLngLatFromEvent(
|
|
2705
|
+
getDrawEventFromEvent(s, t = !1) {
|
|
2706
|
+
const e = this.getLngLatFromEvent(s);
|
|
2704
2707
|
if (!e) return null;
|
|
2705
|
-
const { lng: i, lat: o } = e, { containerX:
|
|
2706
|
-
return { lng: b(i, this._coordinatePrecision), lat: b(o, this._coordinatePrecision), containerX:
|
|
2708
|
+
const { lng: i, lat: o } = e, { containerX: r, containerY: n } = this.getMapElementXYPosition(s), a = this.getButton(s), l = Array.from(this._heldKeys);
|
|
2709
|
+
return { lng: b(i, this._coordinatePrecision), lat: b(o, this._coordinatePrecision), containerX: r, containerY: n, button: a, heldKeys: l, isContextMenu: t };
|
|
2707
2710
|
}
|
|
2708
|
-
register(
|
|
2709
|
-
this._currentModeCallbacks =
|
|
2711
|
+
register(s) {
|
|
2712
|
+
this._currentModeCallbacks = s, this._listeners = this.getAdapterListeners(), this._listeners.forEach((t) => {
|
|
2710
2713
|
t.register();
|
|
2711
2714
|
});
|
|
2712
2715
|
}
|
|
@@ -2714,67 +2717,67 @@ var Zi = { __proto__: null, TerraDrawBaseAdapter: class {
|
|
|
2714
2717
|
return this._coordinatePrecision;
|
|
2715
2718
|
}
|
|
2716
2719
|
getAdapterListeners() {
|
|
2717
|
-
return [new Z({ name: "pointerdown", callback: (
|
|
2718
|
-
if (!this._currentModeCallbacks || !
|
|
2719
|
-
const t = this.getDrawEventFromEvent(
|
|
2720
|
+
return [new Z({ name: "pointerdown", callback: (s) => {
|
|
2721
|
+
if (!this._currentModeCallbacks || !s.isPrimary) return;
|
|
2722
|
+
const t = this.getDrawEventFromEvent(s);
|
|
2720
2723
|
t && (this._dragState = "pre-dragging", this._lastDrawEvent = t);
|
|
2721
|
-
}, register: (
|
|
2722
|
-
this.getMapEventElement().addEventListener("pointerdown",
|
|
2723
|
-
}, unregister: (
|
|
2724
|
-
this.getMapEventElement().removeEventListener("pointerdown",
|
|
2725
|
-
} }), new Z({ name: "pointermove", callback: (
|
|
2726
|
-
if (!this._currentModeCallbacks || !
|
|
2727
|
-
|
|
2728
|
-
const t = this.getDrawEventFromEvent(
|
|
2724
|
+
}, register: (s) => {
|
|
2725
|
+
this.getMapEventElement().addEventListener("pointerdown", s);
|
|
2726
|
+
}, unregister: (s) => {
|
|
2727
|
+
this.getMapEventElement().removeEventListener("pointerdown", s);
|
|
2728
|
+
} }), new Z({ name: "pointermove", callback: (s) => {
|
|
2729
|
+
if (!this._currentModeCallbacks || !s.isPrimary) return;
|
|
2730
|
+
s.preventDefault();
|
|
2731
|
+
const t = this.getDrawEventFromEvent(s);
|
|
2729
2732
|
if (t) if (this._dragState === "not-dragging") this._currentModeCallbacks.onMouseMove(t), this._lastDrawEvent = t;
|
|
2730
2733
|
else if (this._dragState === "pre-dragging") {
|
|
2731
2734
|
if (!this._lastDrawEvent) return;
|
|
2732
|
-
const e = { x: this._lastDrawEvent.containerX, y: this._lastDrawEvent.containerY }, i = { x: t.containerX, y: t.containerY }, o = this._currentModeCallbacks.getState(),
|
|
2735
|
+
const e = { x: this._lastDrawEvent.containerX, y: this._lastDrawEvent.containerY }, i = { x: t.containerX, y: t.containerY }, o = this._currentModeCallbacks.getState(), r = M(e, i);
|
|
2733
2736
|
let n = !1;
|
|
2734
|
-
if (n = o === "drawing" ?
|
|
2737
|
+
if (n = o === "drawing" ? r < this._minPixelDragDistanceDrawing : o === "selecting" ? r < this._minPixelDragDistanceSelecting : r < this._minPixelDragDistance, n) return;
|
|
2735
2738
|
this._nextKeyUpIsContextMenu = !1, this._dragState = "dragging", this._currentModeCallbacks.onDragStart(t, (a) => {
|
|
2736
2739
|
this.setDraggability.bind(this)(a);
|
|
2737
2740
|
});
|
|
2738
2741
|
} else this._dragState === "dragging" && this._currentModeCallbacks.onDrag(t, (e) => {
|
|
2739
2742
|
this.setDraggability.bind(this)(e);
|
|
2740
2743
|
});
|
|
2741
|
-
}, register: (
|
|
2742
|
-
this.getMapEventElement().addEventListener("pointermove",
|
|
2743
|
-
}, unregister: (
|
|
2744
|
-
this.getMapEventElement().removeEventListener("pointermove",
|
|
2745
|
-
} }), new Z({ name: "contextmenu", callback: (
|
|
2746
|
-
this._currentModeCallbacks && (
|
|
2747
|
-
}, register: (
|
|
2748
|
-
this.getMapEventElement().addEventListener("contextmenu",
|
|
2749
|
-
}, unregister: (
|
|
2750
|
-
this.getMapEventElement().removeEventListener("contextmenu",
|
|
2751
|
-
} }), new Z({ name: "pointerup", callback: (
|
|
2752
|
-
if (!this._currentModeCallbacks ||
|
|
2753
|
-
const t = this.getDrawEventFromEvent(
|
|
2744
|
+
}, register: (s) => {
|
|
2745
|
+
this.getMapEventElement().addEventListener("pointermove", s);
|
|
2746
|
+
}, unregister: (s) => {
|
|
2747
|
+
this.getMapEventElement().removeEventListener("pointermove", s);
|
|
2748
|
+
} }), new Z({ name: "contextmenu", callback: (s) => {
|
|
2749
|
+
this._currentModeCallbacks && (s.preventDefault(), this._nextKeyUpIsContextMenu = !0);
|
|
2750
|
+
}, register: (s) => {
|
|
2751
|
+
this.getMapEventElement().addEventListener("contextmenu", s);
|
|
2752
|
+
}, unregister: (s) => {
|
|
2753
|
+
this.getMapEventElement().removeEventListener("contextmenu", s);
|
|
2754
|
+
} }), new Z({ name: "pointerup", callback: (s) => {
|
|
2755
|
+
if (!this._currentModeCallbacks || s.target !== this.getMapEventElement() || !s.isPrimary) return;
|
|
2756
|
+
const t = this.getDrawEventFromEvent(s);
|
|
2754
2757
|
t && (this._dragState === "dragging" ? this._currentModeCallbacks.onDragEnd(t, (e) => {
|
|
2755
2758
|
this.setDraggability.bind(this)(e);
|
|
2756
2759
|
}) : this._dragState !== "not-dragging" && this._dragState !== "pre-dragging" || (this._nextKeyUpIsContextMenu && (t.isContextMenu = !0, this._nextKeyUpIsContextMenu = !1), this._currentModeCallbacks.onClick(t)), this._dragState = "not-dragging", this.setDraggability(!0));
|
|
2757
|
-
}, register: (
|
|
2758
|
-
this.getMapEventElement().addEventListener("pointerup",
|
|
2759
|
-
}, unregister: (
|
|
2760
|
-
this.getMapEventElement().removeEventListener("pointerup",
|
|
2761
|
-
} }), new Z({ name: "keyup", callback: (
|
|
2762
|
-
this._currentModeCallbacks && (this._heldKeys.delete(
|
|
2763
|
-
}, register: (
|
|
2764
|
-
this.getMapEventElement().addEventListener("keyup",
|
|
2765
|
-
}, unregister: (
|
|
2766
|
-
this.getMapEventElement().removeEventListener("keyup",
|
|
2767
|
-
} }), new Z({ name: "keydown", callback: (
|
|
2768
|
-
this._currentModeCallbacks && (this._heldKeys.add(
|
|
2769
|
-
}, register: (
|
|
2770
|
-
this.getMapEventElement().addEventListener("keydown",
|
|
2771
|
-
}, unregister: (
|
|
2772
|
-
this.getMapEventElement().removeEventListener("keydown",
|
|
2760
|
+
}, register: (s) => {
|
|
2761
|
+
this.getMapEventElement().addEventListener("pointerup", s);
|
|
2762
|
+
}, unregister: (s) => {
|
|
2763
|
+
this.getMapEventElement().removeEventListener("pointerup", s);
|
|
2764
|
+
} }), new Z({ name: "keyup", callback: (s) => {
|
|
2765
|
+
this._currentModeCallbacks && (this._heldKeys.delete(s.key), this._currentModeCallbacks.onKeyUp({ key: s.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => s.preventDefault() }));
|
|
2766
|
+
}, register: (s) => {
|
|
2767
|
+
this.getMapEventElement().addEventListener("keyup", s);
|
|
2768
|
+
}, unregister: (s) => {
|
|
2769
|
+
this.getMapEventElement().removeEventListener("keyup", s);
|
|
2770
|
+
} }), new Z({ name: "keydown", callback: (s) => {
|
|
2771
|
+
this._currentModeCallbacks && (this._heldKeys.add(s.key), this._currentModeCallbacks.onKeyDown({ key: s.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => s.preventDefault() }));
|
|
2772
|
+
}, register: (s) => {
|
|
2773
|
+
this.getMapEventElement().addEventListener("keydown", s);
|
|
2774
|
+
}, unregister: (s) => {
|
|
2775
|
+
this.getMapEventElement().removeEventListener("keydown", s);
|
|
2773
2776
|
} })];
|
|
2774
2777
|
}
|
|
2775
2778
|
unregister() {
|
|
2776
|
-
this._listeners.forEach((
|
|
2777
|
-
|
|
2779
|
+
this._listeners.forEach((s) => {
|
|
2780
|
+
s.unregister();
|
|
2778
2781
|
}), this.clear(), this._currentModeCallbacks = void 0;
|
|
2779
2782
|
}
|
|
2780
2783
|
} };
|
|
@@ -2804,7 +2807,7 @@ class ze extends A {
|
|
|
2804
2807
|
}
|
|
2805
2808
|
onMouseMove(t) {
|
|
2806
2809
|
if (this.currentId === void 0 || this.startingClick === !1) return void this.setCursor(this.cursors.start);
|
|
2807
|
-
const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates.length - 2, [o,
|
|
2810
|
+
const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates.length - 2, [o, r] = e.coordinates[i], { x: n, y: a } = this.project(o, r), l = M({ x: n, y: a }, { x: t.containerX, y: t.containerY }), [d, c] = e.coordinates[e.coordinates.length - 1], { x: h, y: u } = this.project(d, c), p = M({ x: h, y: u }, { x: t.containerX, y: t.containerY });
|
|
2808
2811
|
if (this.setCursor(p < this.pointerDistance ? this.cursors.close : this.cursors.start), l < this.minDistance) return;
|
|
2809
2812
|
const g = { type: "LineString", coordinates: [...e.coordinates, [t.lng, t.lat]] };
|
|
2810
2813
|
this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: g, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: E.Provisional }).valid || (this.store.updateGeometry([{ id: this.currentId, geometry: g }]), this.closingPointId && this.store.updateGeometry([{ id: this.closingPointId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]));
|
|
@@ -2839,30 +2842,30 @@ class ze extends A {
|
|
|
2839
2842
|
}
|
|
2840
2843
|
}
|
|
2841
2844
|
styleFeature(t) {
|
|
2842
|
-
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
2845
|
+
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0, markerUrl: void 0, markerHeight: void 0, markerWidth: void 0 });
|
|
2843
2846
|
return t.type === "Feature" && t.geometry.type === "LineString" && t.properties.mode === this.mode ? (e.lineStringColor = this.getHexColorStylingValue(this.styles.lineStringColor, e.lineStringColor, t), e.lineStringWidth = this.getNumericStylingValue(this.styles.lineStringWidth, e.lineStringWidth, t), e.zIndex = j, 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 = 50), e);
|
|
2844
2847
|
}
|
|
2845
2848
|
validateFeature(t) {
|
|
2846
|
-
return this.validateModeFeature(t, (e) =>
|
|
2849
|
+
return this.validateModeFeature(t, (e) => Rt(e, this.coordinatePrecision));
|
|
2847
2850
|
}
|
|
2848
2851
|
afterFeatureUpdated(t) {
|
|
2849
2852
|
this.currentId === t.id && (this.closingPointId && this.store.delete([this.closingPointId]), this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0);
|
|
2850
2853
|
}
|
|
2851
2854
|
}
|
|
2852
|
-
function Bt(
|
|
2853
|
-
if (
|
|
2854
|
-
if (
|
|
2855
|
-
if (typeof
|
|
2856
|
-
if (typeof
|
|
2857
|
-
if (typeof
|
|
2858
|
-
const t = Object.getPrototypeOf(
|
|
2855
|
+
function Bt(s) {
|
|
2856
|
+
if (s === null || typeof s == "boolean" || typeof s == "string") return !0;
|
|
2857
|
+
if (s === void 0) return !1;
|
|
2858
|
+
if (typeof s == "number") return Number.isFinite(s);
|
|
2859
|
+
if (typeof s == "bigint" || typeof s == "symbol" || typeof s == "function" || s instanceof RegExp || s instanceof Map || s instanceof Set || s instanceof Date) return !1;
|
|
2860
|
+
if (typeof s == "object" && s !== null && !Array.isArray(s)) {
|
|
2861
|
+
const t = Object.getPrototypeOf(s);
|
|
2859
2862
|
if (t !== Object.prototype && t !== null) return !1;
|
|
2860
2863
|
}
|
|
2861
|
-
if (ArrayBuffer.isView(
|
|
2862
|
-
if (Array.isArray(
|
|
2863
|
-
for (const t of
|
|
2864
|
+
if (ArrayBuffer.isView(s) && !(s instanceof DataView)) return !1;
|
|
2865
|
+
if (Array.isArray(s)) {
|
|
2866
|
+
for (const t of s) if (!Bt(t)) return !1;
|
|
2864
2867
|
}
|
|
2865
|
-
return typeof
|
|
2868
|
+
return typeof s == "object" && Object.keys(s).every((t) => typeof t == "string" && Bt(s[t]));
|
|
2866
2869
|
}
|
|
2867
2870
|
class eo {
|
|
2868
2871
|
constructor(t) {
|
|
@@ -2877,8 +2880,8 @@ class eo {
|
|
|
2877
2880
|
if (this._instanceSelectMode) throw new Error("only one type of select mode can be provided");
|
|
2878
2881
|
this._instanceSelectMode = c;
|
|
2879
2882
|
}
|
|
2880
|
-
}), this._modes = x({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new
|
|
2881
|
-
const
|
|
2883
|
+
}), this._modes = x({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new Gi({ tracked: !!t.tracked, idStrategy: t.idStrategy ? t.idStrategy : void 0 });
|
|
2884
|
+
const r = (c) => {
|
|
2882
2885
|
const h = [], u = this._store.copyAll().filter((p) => !c.includes(p.id) || (h.push(p), !1));
|
|
2883
2886
|
return { changed: h, unchanged: u };
|
|
2884
2887
|
}, n = (c, h) => {
|
|
@@ -2890,21 +2893,21 @@ class eo {
|
|
|
2890
2893
|
this._eventListeners.change.forEach((y) => {
|
|
2891
2894
|
y(c, h, u);
|
|
2892
2895
|
});
|
|
2893
|
-
const { changed: p, unchanged: g } =
|
|
2896
|
+
const { changed: p, unchanged: g } = r(c);
|
|
2894
2897
|
h === "create" ? this._adapter.render({ created: p, deletedIds: [], unchanged: g, updated: [] }, this.getModeStyles()) : h === "update" ? this._adapter.render({ created: [], deletedIds: [], unchanged: g, updated: p }, this.getModeStyles()) : h === "delete" ? this._adapter.render({ created: [], deletedIds: c, unchanged: g, updated: [] }, this.getModeStyles()) : h === "styling" && this._adapter.render({ created: [], deletedIds: [], unchanged: g, updated: [] }, this.getModeStyles());
|
|
2895
2898
|
}, l = (c) => {
|
|
2896
2899
|
if (!this._enabled) return;
|
|
2897
2900
|
this._eventListeners.select.forEach((p) => {
|
|
2898
2901
|
p(c);
|
|
2899
2902
|
});
|
|
2900
|
-
const { changed: h, unchanged: u } =
|
|
2903
|
+
const { changed: h, unchanged: u } = r([c]);
|
|
2901
2904
|
this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: h }, this.getModeStyles());
|
|
2902
2905
|
}, d = (c) => {
|
|
2903
2906
|
if (!this._enabled) return;
|
|
2904
2907
|
this._eventListeners.deselect.forEach((p) => {
|
|
2905
2908
|
p();
|
|
2906
2909
|
});
|
|
2907
|
-
const { changed: h, unchanged: u } =
|
|
2910
|
+
const { changed: h, unchanged: u } = r([c]);
|
|
2908
2911
|
h && this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: h }, this.getModeStyles());
|
|
2909
2912
|
};
|
|
2910
2913
|
Object.keys(this._modes).forEach((c) => {
|
|
@@ -2921,12 +2924,12 @@ class eo {
|
|
|
2921
2924
|
}), t;
|
|
2922
2925
|
}
|
|
2923
2926
|
featuresAtLocation({ lng: t, lat: e }, i) {
|
|
2924
|
-
const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30,
|
|
2927
|
+
const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, r = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, n = !(!i || i.ignoreCoordinatePoints === void 0) && i.ignoreCoordinatePoints, a = !(!i || i.ignoreCurrentlyDrawing === void 0) && i.ignoreCurrentlyDrawing, l = !(!i || i.ignoreClosingPoints === void 0) && i.ignoreClosingPoints, d = !(!i || i.ignoreSnappingPoints === void 0) && i.ignoreSnappingPoints, c = this._adapter.unproject.bind(this._adapter), h = this._adapter.project.bind(this._adapter), u = h(t, e), p = Le({ unproject: c, point: u, pointerDistance: o });
|
|
2925
2928
|
return this._store.search(p).filter((g) => {
|
|
2926
|
-
if (
|
|
2929
|
+
if (r && (g.properties[k.MID_POINT] || g.properties[k.SELECTION_POINT]) || n && g.properties[S.COORDINATE_POINT] || l && g.properties[S.CLOSING_POINT] || a && g.properties[S.CURRENTLY_DRAWING] || d && g.properties[S.SNAPPING_POINT]) return !1;
|
|
2927
2930
|
if (g.geometry.type === "Point") {
|
|
2928
2931
|
const y = g.geometry.coordinates, f = h(y[0], y[1]);
|
|
2929
|
-
return
|
|
2932
|
+
return M(u, f) < o;
|
|
2930
2933
|
}
|
|
2931
2934
|
if (g.geometry.type === "LineString") {
|
|
2932
2935
|
const y = g.geometry.coordinates;
|
|
@@ -2955,10 +2958,10 @@ class eo {
|
|
|
2955
2958
|
}
|
|
2956
2959
|
let f, v = -1, C = 1 / 0;
|
|
2957
2960
|
for (let m = 0; m < y.length; m++) {
|
|
2958
|
-
const P = y[m], I =
|
|
2961
|
+
const P = y[m], I = M(h(P[0], P[1]), u);
|
|
2959
2962
|
I < C && (v = m, C = I, f = P);
|
|
2960
2963
|
}
|
|
2961
|
-
return g.properties.closestCoordinateIndexToEvent = v, g.properties.closestCoordinatePixelDistanceToEvent = C, g.properties.closestCoordinateDistanceKmToEvent =
|
|
2964
|
+
return g.properties.closestCoordinateIndexToEvent = v, g.properties.closestCoordinatePixelDistanceToEvent = C, g.properties.closestCoordinateDistanceKmToEvent = G(f, [t, e]), g;
|
|
2962
2965
|
});
|
|
2963
2966
|
}
|
|
2964
2967
|
getSelectModeOrThrow() {
|
|
@@ -3037,11 +3040,11 @@ class eo {
|
|
|
3037
3040
|
if (this.isGuidanceFeature(i)) throw new Error("Guidance features are not allowed to be updated directly.");
|
|
3038
3041
|
const o = i.properties.mode;
|
|
3039
3042
|
if (!this._modes[o]) throw new Error(`No mode with name ${o} present in instance`);
|
|
3040
|
-
const
|
|
3041
|
-
|
|
3043
|
+
const r = Object.entries(e);
|
|
3044
|
+
r.forEach(([n, a]) => {
|
|
3042
3045
|
if (!this.checkIsReservedProperty(n)) throw new Error(`You are trying to update a reserved property name: ${n}. Please choose another name.`);
|
|
3043
3046
|
if (a !== void 0 && !Bt(a)) throw new Error(`Invalid JSON value provided for property ${n}`);
|
|
3044
|
-
}), this._store.updateProperty(
|
|
3047
|
+
}), this._store.updateProperty(r.map(([n, a]) => ({ id: i.id, property: n, value: a })), { origin: "api" });
|
|
3045
3048
|
}
|
|
3046
3049
|
updateFeatureGeometry(t, e) {
|
|
3047
3050
|
if (!this._store.has(t)) throw new Error(`No feature with id ${t} present in store`);
|
|
@@ -3049,12 +3052,12 @@ class eo {
|
|
|
3049
3052
|
if (this.isGuidanceFeature(i)) throw new Error("Guidance features are not allowed to be updated directly.");
|
|
3050
3053
|
if (!(i && e && e.type && e.coordinates)) throw new Error("Invalid geometry provided");
|
|
3051
3054
|
if (e.type !== i.geometry.type) throw new Error(`Geometry type mismatch: expected ${i.geometry.type}, got ${e.type}`);
|
|
3052
|
-
const o = i.properties.mode,
|
|
3053
|
-
if (!
|
|
3054
|
-
const n = x({}, i, { geometry: e }), a =
|
|
3055
|
+
const o = i.properties.mode, r = this._modes[o];
|
|
3056
|
+
if (!r) throw new Error(`No mode with name ${o} present in instance`);
|
|
3057
|
+
const n = x({}, i, { geometry: e }), a = r.validateFeature(n);
|
|
3055
3058
|
if (!a.valid) throw new Error(`Feature validation failed: ${a.reason || "Unknown reason"}`);
|
|
3056
|
-
if (this._store.updateGeometry([{ id: i.id, geometry: e }], { origin: "api" }),
|
|
3057
|
-
|
|
3059
|
+
if (this._store.updateGeometry([{ id: i.id, geometry: e }], { origin: "api" }), r.afterFeatureUpdated) {
|
|
3060
|
+
r.afterFeatureUpdated(n);
|
|
3058
3061
|
const l = n.properties[k.SELECTED], d = this.getSelectMode({ switchToSelectMode: !1 });
|
|
3059
3062
|
d && l && d.afterFeatureUpdated(n);
|
|
3060
3063
|
}
|
|
@@ -3063,8 +3066,8 @@ class eo {
|
|
|
3063
3066
|
if (!this._store.has(t)) throw new Error(`No feature with id ${t} present in store`);
|
|
3064
3067
|
let i = this._store.copy(t);
|
|
3065
3068
|
if (this.isGuidanceFeature(i)) throw new Error("Guidance features are not allowed to be updated directly.");
|
|
3066
|
-
const o = i.properties.mode,
|
|
3067
|
-
if (!
|
|
3069
|
+
const o = i.properties.mode, r = this._modes[o];
|
|
3070
|
+
if (!r) throw new Error(`No mode with name ${o} present in instance`);
|
|
3068
3071
|
let n;
|
|
3069
3072
|
if (i.geometry.type === "Polygon") n = i.geometry.coordinates[0];
|
|
3070
3073
|
else {
|
|
@@ -3076,8 +3079,8 @@ class eo {
|
|
|
3076
3079
|
const { x: a, y: l } = O(e.origin[0], e.origin[1]);
|
|
3077
3080
|
Be({ coordinates: n, originX: a, originY: l, xScale: e.options.xScale || 1, yScale: e.options.yScale || 1 });
|
|
3078
3081
|
} else e.type === "rotate" && (i = We(i, e.options.angle || 0), n = i.geometry.type === "Polygon" ? i.geometry.coordinates[0] : i.geometry.coordinates);
|
|
3079
|
-
if (n = n.map((a) => [b(a[0], this._adapter.getCoordinatePrecision()), b(a[1], this._adapter.getCoordinatePrecision())]), i.geometry.coordinates = i.geometry.type === "Polygon" ? [n] : n, this._store.updateGeometry([{ id: i.id, geometry: i.geometry }], { origin: "api" }),
|
|
3080
|
-
|
|
3082
|
+
if (n = n.map((a) => [b(a[0], this._adapter.getCoordinatePrecision()), b(a[1], this._adapter.getCoordinatePrecision())]), i.geometry.coordinates = i.geometry.type === "Polygon" ? [n] : n, this._store.updateGeometry([{ id: i.id, geometry: i.geometry }], { origin: "api" }), r.afterFeatureUpdated) {
|
|
3083
|
+
r.afterFeatureUpdated(i);
|
|
3081
3084
|
const a = i.properties[k.SELECTED], l = this.getSelectMode({ switchToSelectMode: !1 });
|
|
3082
3085
|
l && a && l.afterFeatureUpdated(i);
|
|
3083
3086
|
}
|
|
@@ -3087,8 +3090,8 @@ class eo {
|
|
|
3087
3090
|
if (te(e)) {
|
|
3088
3091
|
const i = e.properties.mode, o = this._modes[i];
|
|
3089
3092
|
if (!o) return { id: e.id, valid: !1, reason: `${i} mode is not in the list of instantiated modes` };
|
|
3090
|
-
const
|
|
3091
|
-
return { id: e.id, valid:
|
|
3093
|
+
const r = o.validateFeature.bind(o)(e);
|
|
3094
|
+
return { id: e.id, valid: r.valid, reason: r.reason ? r.reason : r.valid ? void 0 : "Feature is invalid" };
|
|
3092
3095
|
}
|
|
3093
3096
|
return { id: e.id, valid: !1, reason: "Mode property does not exist" };
|
|
3094
3097
|
}, (e) => {
|
|
@@ -3143,7 +3146,19 @@ class eo {
|
|
|
3143
3146
|
}
|
|
3144
3147
|
class io extends Zi.TerraDrawBaseAdapter {
|
|
3145
3148
|
constructor(t) {
|
|
3146
|
-
super(t), this._renderBeforeLayerId = void 0, this._prefixId = void 0, this._initialDragPan = void 0, this._initialDragRotate = void 0, this._nextRender = void 0, this._map = void 0, this._container = void 0, this.changedIds = { deletion: !1, points: !1, linestrings: !1, polygons: !1, styling: !1 }, this._map = t.map, this._container = this._map.getContainer(), this._initialDragRotate = this._map.dragRotate.isEnabled(), this._initialDragPan = this._map.dragPan.isEnabled(), this._renderBeforeLayerId = t.renderBelowLayerId, this._prefixId = t.prefixId || "td";
|
|
3149
|
+
super(t), this._renderBeforeLayerId = void 0, this._prefixId = void 0, this._initialDragPan = void 0, this._initialDragRotate = void 0, this._nextRender = void 0, this._map = void 0, this._container = void 0, this.markerCounter = 0, this.markerMap = /* @__PURE__ */ new Map(), this.changedIds = { deletion: !1, points: !1, linestrings: !1, polygons: !1, styling: !1 }, this._map = t.map, this._container = this._map.getContainer(), this._initialDragRotate = this._map.dragRotate.isEnabled(), this._initialDragPan = this._map.dragPan.isEnabled(), this._renderBeforeLayerId = t.renderBelowLayerId, this._prefixId = t.prefixId || "td";
|
|
3150
|
+
}
|
|
3151
|
+
resizeImage(t, e, i, o) {
|
|
3152
|
+
const r = new Image();
|
|
3153
|
+
r.crossOrigin = "anonymous", r.onload = () => {
|
|
3154
|
+
const n = document.createElement("canvas");
|
|
3155
|
+
n.width = e, n.height = i;
|
|
3156
|
+
const a = n.getContext("2d");
|
|
3157
|
+
if (!a) throw new Error("Could not get canvas context");
|
|
3158
|
+
a.drawImage(r, 0, 0, e, i);
|
|
3159
|
+
const l = n.toDataURL();
|
|
3160
|
+
o(l);
|
|
3161
|
+
}, r.src = t;
|
|
3147
3162
|
}
|
|
3148
3163
|
_addGeoJSONSource(t, e) {
|
|
3149
3164
|
this._map.addSource(t, { type: "geojson", data: { type: "FeatureCollection", features: e }, tolerance: 0 });
|
|
@@ -3160,8 +3175,11 @@ class io extends Zi.TerraDrawBaseAdapter {
|
|
|
3160
3175
|
_addPointLayer(t) {
|
|
3161
3176
|
return this._map.addLayer({ id: t, source: t, type: "circle", layout: { "circle-sort-key": ["get", "zIndex"] }, paint: { "circle-stroke-color": ["get", "pointOutlineColor"], "circle-stroke-width": ["get", "pointOutlineWidth"], "circle-radius": ["get", "pointWidth"], "circle-color": ["get", "pointColor"] } });
|
|
3162
3177
|
}
|
|
3178
|
+
_addMarkerLayer(t) {
|
|
3179
|
+
return this._map.addLayer({ id: t + "-marker", source: t, type: "symbol", filter: ["has", "markerId"], layout: { "icon-image": ["get", "markerId"], "icon-anchor": "bottom", "icon-allow-overlap": !0 } });
|
|
3180
|
+
}
|
|
3163
3181
|
_addLayer(t, e) {
|
|
3164
|
-
e === "Point" && this._addPointLayer(t), e === "LineString" && this._addLineLayer(t), e === "Polygon" && (this._addFillLayer(t), this._addFillOutlineLayer(t));
|
|
3182
|
+
e === "Point" && (this._addPointLayer(t), this._addMarkerLayer(t)), e === "LineString" && this._addLineLayer(t), e === "Polygon" && (this._addFillLayer(t), this._addFillOutlineLayer(t));
|
|
3165
3183
|
}
|
|
3166
3184
|
_addGeoJSONLayer(t, e) {
|
|
3167
3185
|
const i = `${this._prefixId}-${t.toLowerCase()}`;
|
|
@@ -3204,13 +3222,23 @@ class io extends Zi.TerraDrawBaseAdapter {
|
|
|
3204
3222
|
render(t, e) {
|
|
3205
3223
|
this.updateChangedIds(t), this._nextRender && cancelAnimationFrame(this._nextRender), this._nextRender = requestAnimationFrame(() => {
|
|
3206
3224
|
if (!this._currentModeCallbacks) return;
|
|
3207
|
-
const i = [...t.created, ...t.updated, ...t.unchanged], o = [],
|
|
3225
|
+
const i = [...t.created, ...t.updated, ...t.unchanged], o = [], r = [], n = [];
|
|
3208
3226
|
for (let c = 0; c < i.length; c++) {
|
|
3209
3227
|
const h = i[c], { properties: u } = h, p = e[u.mode](h);
|
|
3210
|
-
|
|
3228
|
+
if (u.zIndex = p.zIndex, u.zIndex = p.zIndex, h.geometry.type === "Point") {
|
|
3229
|
+
if (u.pointColor = p.pointColor, u.pointOutlineColor = p.pointOutlineColor, u.pointOutlineWidth = p.pointOutlineWidth, u.pointWidth = p.pointWidth, p.markerUrl && p.markerWidth && p.markerHeight && !this.markerMap.has(p.markerUrl)) {
|
|
3230
|
+
const g = "marker-" + this.markerCounter++;
|
|
3231
|
+
this.resizeImage(p.markerUrl, p.markerWidth, p.markerHeight, (y) => {
|
|
3232
|
+
this._map.loadImage(y).then((f) => {
|
|
3233
|
+
this._map.addImage(g, f.data), this._map.setLayoutProperty(`${this._prefixId}-point-marker`, "icon-image", g);
|
|
3234
|
+
});
|
|
3235
|
+
}), this.markerMap.set(p.markerUrl, g), u.markerId = g, u.pointWidth = 0;
|
|
3236
|
+
} else p.markerUrl && this.markerMap.has(p.markerUrl) && (u.markerId = this.markerMap.get(p.markerUrl), u.pointWidth = 0);
|
|
3237
|
+
o.push(h);
|
|
3238
|
+
} else h.geometry.type === "LineString" ? (u.lineStringColor = p.lineStringColor, u.lineStringWidth = p.lineStringWidth, r.push(h)) : h.geometry.type === "Polygon" && (u.polygonFillColor = p.polygonFillColor, u.polygonFillOpacity = p.polygonFillOpacity, u.polygonOutlineColor = p.polygonOutlineColor, u.polygonOutlineWidth = p.polygonOutlineWidth, n.push(h));
|
|
3211
3239
|
}
|
|
3212
3240
|
const a = this.changedIds.deletion || this.changedIds.styling, l = a || this.changedIds.linestrings, d = a || this.changedIds.polygons;
|
|
3213
|
-
(a || this.changedIds.points) && this._setGeoJSONLayerData("Point", o), l && this._setGeoJSONLayerData("LineString",
|
|
3241
|
+
(a || this.changedIds.points) && this._setGeoJSONLayerData("Point", o), l && this._setGeoJSONLayerData("LineString", r), d && this._setGeoJSONLayerData("Polygon", n), this.changedIds = { points: !1, linestrings: !1, polygons: !1, deletion: !1, styling: !1 };
|
|
3214
3242
|
});
|
|
3215
3243
|
}
|
|
3216
3244
|
clear() {
|
|
@@ -3220,13 +3248,14 @@ class io extends Zi.TerraDrawBaseAdapter {
|
|
|
3220
3248
|
return super.getCoordinatePrecision();
|
|
3221
3249
|
}
|
|
3222
3250
|
unregister() {
|
|
3223
|
-
super.unregister(), this.changedIds = { points: !1, linestrings: !1, polygons: !1, deletion: !1, styling: !1 }, this._map.removeLayer(`${this._prefixId}-point`), this._map.removeSource(`${this._prefixId}-point`), this._map.removeLayer(`${this._prefixId}-linestring`), this._map.removeSource(`${this._prefixId}-linestring`), this._map.removeLayer(`${this._prefixId}-polygon`), this._map.removeLayer(`${this._prefixId}-polygon-outline`), this._map.removeSource(`${this._prefixId}-polygon`);
|
|
3251
|
+
super.unregister(), this.changedIds = { points: !1, linestrings: !1, polygons: !1, deletion: !1, styling: !1 }, this._map.removeLayer(`${this._prefixId}-point`), this._map.removeLayer(`${this._prefixId}-point-marker`), this._map.removeSource(`${this._prefixId}-point`), this._map.removeLayer(`${this._prefixId}-linestring`), this._map.removeSource(`${this._prefixId}-linestring`), this._map.removeLayer(`${this._prefixId}-polygon`), this._map.removeLayer(`${this._prefixId}-polygon-outline`), this._map.removeSource(`${this._prefixId}-polygon`);
|
|
3224
3252
|
}
|
|
3225
3253
|
register(t) {
|
|
3226
3254
|
var e;
|
|
3227
3255
|
super.register(t);
|
|
3228
|
-
const i = this._addGeoJSONLayer("Polygon", []), o = this._addGeoJSONLayer("LineString", []),
|
|
3229
|
-
|
|
3256
|
+
const i = this._addGeoJSONLayer("Polygon", []), o = this._addGeoJSONLayer("LineString", []), r = this._addGeoJSONLayer("Point", []);
|
|
3257
|
+
var n;
|
|
3258
|
+
this._renderBeforeLayerId && (this._map.moveLayer(r, this._renderBeforeLayerId), this._map.moveLayer(o, r), this._map.moveLayer(i + "-outline", o), this._map.moveLayer(i, o)), (e = this._currentModeCallbacks) != null && e.onReady && ((n = this._currentModeCallbacks) == null || n.onReady());
|
|
3230
3259
|
}
|
|
3231
3260
|
}
|
|
3232
3261
|
const Yo = [
|
|
@@ -3273,7 +3302,7 @@ const Yo = [
|
|
|
3273
3302
|
"download"
|
|
3274
3303
|
],
|
|
3275
3304
|
open: !1
|
|
3276
|
-
},
|
|
3305
|
+
}, H = {
|
|
3277
3306
|
kilometer: "km",
|
|
3278
3307
|
meter: "m",
|
|
3279
3308
|
centimeter: "cm",
|
|
@@ -3388,7 +3417,7 @@ const Yo = [
|
|
|
3388
3417
|
closingPointOutlineWidth: 1
|
|
3389
3418
|
}
|
|
3390
3419
|
}),
|
|
3391
|
-
sensor: new
|
|
3420
|
+
sensor: new Ge({
|
|
3392
3421
|
styles: {
|
|
3393
3422
|
fillColor: "#EDEFF0",
|
|
3394
3423
|
fillOpacity: 0.7,
|
|
@@ -3400,7 +3429,7 @@ const Yo = [
|
|
|
3400
3429
|
centerPointOutlineWidth: 1
|
|
3401
3430
|
}
|
|
3402
3431
|
}),
|
|
3403
|
-
sector: new
|
|
3432
|
+
sector: new Re({
|
|
3404
3433
|
styles: {
|
|
3405
3434
|
fillColor: "#EDEFF0",
|
|
3406
3435
|
fillOpacity: 0.7,
|
|
@@ -3687,7 +3716,7 @@ Alt. `,
|
|
|
3687
3716
|
forceDistanceUnit: "auto",
|
|
3688
3717
|
areaPrecision: 2,
|
|
3689
3718
|
forceAreaUnit: "auto",
|
|
3690
|
-
measureUnitSymbols: JSON.parse(JSON.stringify(
|
|
3719
|
+
measureUnitSymbols: JSON.parse(JSON.stringify(H)),
|
|
3691
3720
|
elevationCacheConfig: {
|
|
3692
3721
|
enabled: !0,
|
|
3693
3722
|
maxSize: 1e3,
|
|
@@ -3928,7 +3957,7 @@ Alt. `,
|
|
|
3928
3957
|
"text-halo-color": "rgb(255, 255, 255)"
|
|
3929
3958
|
}
|
|
3930
3959
|
}
|
|
3931
|
-
},
|
|
3960
|
+
}, ro = () => ({
|
|
3932
3961
|
render: new tt({
|
|
3933
3962
|
modeName: "render",
|
|
3934
3963
|
styles: {}
|
|
@@ -3953,8 +3982,8 @@ Alt. `,
|
|
|
3953
3982
|
circle: new be(),
|
|
3954
3983
|
freehand: new we(),
|
|
3955
3984
|
"freehand-linestring": new ze(),
|
|
3956
|
-
sensor: new
|
|
3957
|
-
sector: new
|
|
3985
|
+
sensor: new Ge(),
|
|
3986
|
+
sector: new Re(),
|
|
3958
3987
|
select: new $t({
|
|
3959
3988
|
flags: {
|
|
3960
3989
|
point: {
|
|
@@ -4081,7 +4110,7 @@ Alt. `,
|
|
|
4081
4110
|
styles: {}
|
|
4082
4111
|
})
|
|
4083
4112
|
});
|
|
4084
|
-
var W = 63710088e-1,
|
|
4113
|
+
var W = 63710088e-1, so = {
|
|
4085
4114
|
centimeters: W * 100,
|
|
4086
4115
|
centimetres: W * 100,
|
|
4087
4116
|
degrees: 360 / (2 * Math.PI),
|
|
@@ -4098,40 +4127,40 @@ var W = 63710088e-1, ro = {
|
|
|
4098
4127
|
radians: 1,
|
|
4099
4128
|
yards: W * 1.0936
|
|
4100
4129
|
};
|
|
4101
|
-
function no(
|
|
4130
|
+
function no(s, t, e = {}) {
|
|
4102
4131
|
const i = { type: "Feature" };
|
|
4103
|
-
return (e.id === 0 || e.id) && (i.id = e.id), e.bbox && (i.bbox = e.bbox), i.properties = t || {}, i.geometry =
|
|
4132
|
+
return (e.id === 0 || e.id) && (i.id = e.id), e.bbox && (i.bbox = e.bbox), i.properties = t || {}, i.geometry = s, i;
|
|
4104
4133
|
}
|
|
4105
|
-
function ao(
|
|
4106
|
-
if (!
|
|
4134
|
+
function ao(s, t, e = {}) {
|
|
4135
|
+
if (!s)
|
|
4107
4136
|
throw new Error("coordinates is required");
|
|
4108
|
-
if (!Array.isArray(
|
|
4137
|
+
if (!Array.isArray(s))
|
|
4109
4138
|
throw new Error("coordinates must be an Array");
|
|
4110
|
-
if (
|
|
4139
|
+
if (s.length < 2)
|
|
4111
4140
|
throw new Error("coordinates must be at least 2 numbers long");
|
|
4112
|
-
if (!ye(
|
|
4141
|
+
if (!ye(s[0]) || !ye(s[1]))
|
|
4113
4142
|
throw new Error("coordinates must contain numbers");
|
|
4114
4143
|
return no({
|
|
4115
4144
|
type: "Point",
|
|
4116
|
-
coordinates:
|
|
4145
|
+
coordinates: s
|
|
4117
4146
|
}, t, e);
|
|
4118
4147
|
}
|
|
4119
|
-
function lo(
|
|
4120
|
-
const e =
|
|
4148
|
+
function lo(s, t = "kilometers") {
|
|
4149
|
+
const e = so[t];
|
|
4121
4150
|
if (!e)
|
|
4122
4151
|
throw new Error(t + " units is invalid");
|
|
4123
|
-
return
|
|
4152
|
+
return s * e;
|
|
4124
4153
|
}
|
|
4125
|
-
function Pt(
|
|
4126
|
-
return
|
|
4154
|
+
function Pt(s) {
|
|
4155
|
+
return s % 360 * Math.PI / 180;
|
|
4127
4156
|
}
|
|
4128
|
-
function ye(
|
|
4129
|
-
return !isNaN(
|
|
4157
|
+
function ye(s) {
|
|
4158
|
+
return !isNaN(s) && s !== null && !Array.isArray(s);
|
|
4130
4159
|
}
|
|
4131
|
-
function Ve(
|
|
4132
|
-
if (
|
|
4133
|
-
for (var i, o,
|
|
4134
|
-
d = g ?
|
|
4160
|
+
function Ve(s, t, e) {
|
|
4161
|
+
if (s !== null)
|
|
4162
|
+
for (var i, o, r, n, a, l, d, c = 0, h = 0, u, p = s.type, g = p === "FeatureCollection", y = p === "Feature", f = g ? s.features.length : 1, v = 0; v < f; v++) {
|
|
4163
|
+
d = g ? s.features[v].geometry : y ? s.geometry : s, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
|
|
4135
4164
|
for (var C = 0; C < a; C++) {
|
|
4136
4165
|
var m = 0, P = 0;
|
|
4137
4166
|
if (n = u ? d.geometries[C] : d, n !== null) {
|
|
@@ -4187,9 +4216,9 @@ function Ve(r, t, e) {
|
|
|
4187
4216
|
case "MultiPolygon":
|
|
4188
4217
|
for (i = 0; i < l.length; i++) {
|
|
4189
4218
|
for (P = 0, o = 0; o < l[i].length; o++) {
|
|
4190
|
-
for (
|
|
4219
|
+
for (r = 0; r < l[i][o].length - c; r++) {
|
|
4191
4220
|
if (t(
|
|
4192
|
-
l[i][o][
|
|
4221
|
+
l[i][o][r],
|
|
4193
4222
|
h,
|
|
4194
4223
|
v,
|
|
4195
4224
|
m,
|
|
@@ -4215,11 +4244,11 @@ function Ve(r, t, e) {
|
|
|
4215
4244
|
}
|
|
4216
4245
|
}
|
|
4217
4246
|
}
|
|
4218
|
-
function co(
|
|
4219
|
-
var e, i, o,
|
|
4247
|
+
function co(s, t) {
|
|
4248
|
+
var e, i, o, r, n, a, l, d, c, h, u = 0, p = s.type === "FeatureCollection", g = s.type === "Feature", y = p ? s.features.length : 1;
|
|
4220
4249
|
for (e = 0; e < y; e++) {
|
|
4221
|
-
for (a = p ?
|
|
4222
|
-
if (
|
|
4250
|
+
for (a = p ? s.features[e].geometry : g ? s.geometry : s, d = p ? s.features[e].properties : g ? s.properties : {}, c = p ? s.features[e].bbox : g ? s.bbox : void 0, h = 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++) {
|
|
4251
|
+
if (r = l ? a.geometries[o] : a, r === null) {
|
|
4223
4252
|
if (t(
|
|
4224
4253
|
null,
|
|
4225
4254
|
u,
|
|
@@ -4230,7 +4259,7 @@ function co(r, t) {
|
|
|
4230
4259
|
return !1;
|
|
4231
4260
|
continue;
|
|
4232
4261
|
}
|
|
4233
|
-
switch (
|
|
4262
|
+
switch (r.type) {
|
|
4234
4263
|
case "Point":
|
|
4235
4264
|
case "LineString":
|
|
4236
4265
|
case "MultiPoint":
|
|
@@ -4238,7 +4267,7 @@ function co(r, t) {
|
|
|
4238
4267
|
case "MultiLineString":
|
|
4239
4268
|
case "MultiPolygon": {
|
|
4240
4269
|
if (t(
|
|
4241
|
-
|
|
4270
|
+
r,
|
|
4242
4271
|
u,
|
|
4243
4272
|
d,
|
|
4244
4273
|
c,
|
|
@@ -4248,9 +4277,9 @@ function co(r, t) {
|
|
|
4248
4277
|
break;
|
|
4249
4278
|
}
|
|
4250
4279
|
case "GeometryCollection": {
|
|
4251
|
-
for (i = 0; i <
|
|
4280
|
+
for (i = 0; i < r.geometries.length; i++)
|
|
4252
4281
|
if (t(
|
|
4253
|
-
|
|
4282
|
+
r.geometries[i],
|
|
4254
4283
|
u,
|
|
4255
4284
|
d,
|
|
4256
4285
|
c,
|
|
@@ -4266,15 +4295,15 @@ function co(r, t) {
|
|
|
4266
4295
|
u++;
|
|
4267
4296
|
}
|
|
4268
4297
|
}
|
|
4269
|
-
function ho(
|
|
4298
|
+
function ho(s, t, e) {
|
|
4270
4299
|
var i = e;
|
|
4271
4300
|
return co(
|
|
4272
|
-
|
|
4273
|
-
function(o,
|
|
4274
|
-
|
|
4301
|
+
s,
|
|
4302
|
+
function(o, r, n, a, l) {
|
|
4303
|
+
r === 0 && e === void 0 ? i = o : i = t(
|
|
4275
4304
|
i,
|
|
4276
4305
|
o,
|
|
4277
|
-
|
|
4306
|
+
r,
|
|
4278
4307
|
n,
|
|
4279
4308
|
a,
|
|
4280
4309
|
l
|
|
@@ -4282,21 +4311,21 @@ function ho(r, t, e) {
|
|
|
4282
4311
|
}
|
|
4283
4312
|
), i;
|
|
4284
4313
|
}
|
|
4285
|
-
function uo(
|
|
4314
|
+
function uo(s) {
|
|
4286
4315
|
return ho(
|
|
4287
|
-
|
|
4316
|
+
s,
|
|
4288
4317
|
(t, e) => t + po(e),
|
|
4289
4318
|
0
|
|
4290
4319
|
);
|
|
4291
4320
|
}
|
|
4292
|
-
function po(
|
|
4321
|
+
function po(s) {
|
|
4293
4322
|
let t = 0, e;
|
|
4294
|
-
switch (
|
|
4323
|
+
switch (s.type) {
|
|
4295
4324
|
case "Polygon":
|
|
4296
|
-
return fe(
|
|
4325
|
+
return fe(s.coordinates);
|
|
4297
4326
|
case "MultiPolygon":
|
|
4298
|
-
for (e = 0; e <
|
|
4299
|
-
t += fe(
|
|
4327
|
+
for (e = 0; e < s.coordinates.length; e++)
|
|
4328
|
+
t += fe(s.coordinates[e]);
|
|
4300
4329
|
return t;
|
|
4301
4330
|
case "Point":
|
|
4302
4331
|
case "MultiPoint":
|
|
@@ -4306,184 +4335,184 @@ function po(r) {
|
|
|
4306
4335
|
}
|
|
4307
4336
|
return 0;
|
|
4308
4337
|
}
|
|
4309
|
-
function fe(
|
|
4338
|
+
function fe(s) {
|
|
4310
4339
|
let t = 0;
|
|
4311
|
-
if (
|
|
4312
|
-
t += Math.abs(me(
|
|
4313
|
-
for (let e = 1; e <
|
|
4314
|
-
t -= Math.abs(me(
|
|
4340
|
+
if (s && s.length > 0) {
|
|
4341
|
+
t += Math.abs(me(s[0]));
|
|
4342
|
+
for (let e = 1; e < s.length; e++)
|
|
4343
|
+
t -= Math.abs(me(s[e]));
|
|
4315
4344
|
}
|
|
4316
4345
|
return t;
|
|
4317
4346
|
}
|
|
4318
4347
|
var go = W * W / 2, _t = Math.PI / 180;
|
|
4319
|
-
function me(
|
|
4320
|
-
const t =
|
|
4348
|
+
function me(s) {
|
|
4349
|
+
const t = s.length - 1;
|
|
4321
4350
|
if (t <= 2) return 0;
|
|
4322
4351
|
let e = 0, i = 0;
|
|
4323
4352
|
for (; i < t; ) {
|
|
4324
|
-
const o =
|
|
4353
|
+
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] * _t, l = r[1] * _t, d = n[0] * _t;
|
|
4325
4354
|
e += (d - a) * Math.sin(l), i++;
|
|
4326
4355
|
}
|
|
4327
4356
|
return e * go;
|
|
4328
4357
|
}
|
|
4329
4358
|
var yo = uo;
|
|
4330
|
-
const fo = (
|
|
4331
|
-
const o = ["square meters", "square kilometers", "ares", "hectares"],
|
|
4359
|
+
const fo = (s, t, e = "auto", i = H) => {
|
|
4360
|
+
const o = ["square meters", "square kilometers", "ares", "hectares"], r = ["square feet", "square yards", "acres", "square miles"];
|
|
4332
4361
|
let n = e;
|
|
4333
4362
|
if (e !== "auto") {
|
|
4334
|
-
const a = o.includes(e), l =
|
|
4363
|
+
const a = o.includes(e), l = r.includes(e);
|
|
4335
4364
|
(t === "metric" && !a || t === "imperial" && !l) && (n = "auto");
|
|
4336
4365
|
}
|
|
4337
|
-
return t === "metric" ? n !== "auto" ?
|
|
4338
|
-
},
|
|
4339
|
-
let i =
|
|
4366
|
+
return t === "metric" ? n !== "auto" ? rt(s, n, i) : s >= 1e6 ? rt(s, "square kilometers", i) : s >= 1e4 ? rt(s, "hectares", i) : s >= 100 ? rt(s, "ares", i) : rt(s, "square meters", i) : n !== "auto" ? st(s, n, i) : s >= 258998811e-2 ? st(s, "square miles", i) : s >= 4046.856 ? st(s, "acres", i) : s >= 0.83612736 ? st(s, "square yards", i) : st(s, "square feet", i);
|
|
4367
|
+
}, rt = (s, t, e) => {
|
|
4368
|
+
let i = s, o = e["square meters"];
|
|
4340
4369
|
switch (t) {
|
|
4341
4370
|
case "square meters":
|
|
4342
|
-
i =
|
|
4371
|
+
i = s, o = e["square meters"];
|
|
4343
4372
|
break;
|
|
4344
4373
|
case "ares":
|
|
4345
|
-
i =
|
|
4374
|
+
i = s / 100, o = e.ares;
|
|
4346
4375
|
break;
|
|
4347
4376
|
case "hectares":
|
|
4348
|
-
i =
|
|
4377
|
+
i = s / 1e4, o = e.hectares;
|
|
4349
4378
|
break;
|
|
4350
4379
|
case "square kilometers":
|
|
4351
|
-
i =
|
|
4380
|
+
i = s / 1e6, o = e["square kilometers"];
|
|
4352
4381
|
break;
|
|
4353
4382
|
}
|
|
4354
4383
|
return {
|
|
4355
4384
|
area: i,
|
|
4356
4385
|
unit: o
|
|
4357
4386
|
};
|
|
4358
|
-
},
|
|
4359
|
-
let i =
|
|
4387
|
+
}, st = (s, t, e) => {
|
|
4388
|
+
let i = s / 258998811e-2, o = e["square meters"];
|
|
4360
4389
|
switch (t) {
|
|
4361
4390
|
case "square feet":
|
|
4362
|
-
i =
|
|
4391
|
+
i = s / 0.09290304, o = e["square feet"];
|
|
4363
4392
|
break;
|
|
4364
4393
|
case "square yards":
|
|
4365
|
-
i =
|
|
4394
|
+
i = s / 0.83612736, o = e["square yards"];
|
|
4366
4395
|
break;
|
|
4367
4396
|
case "acres":
|
|
4368
|
-
i =
|
|
4397
|
+
i = s / 4046.856, o = e.acres;
|
|
4369
4398
|
break;
|
|
4370
4399
|
case "square miles":
|
|
4371
|
-
i =
|
|
4400
|
+
i = s / 258998811e-2, o = e["square miles"];
|
|
4372
4401
|
break;
|
|
4373
4402
|
}
|
|
4374
4403
|
return {
|
|
4375
4404
|
area: i,
|
|
4376
4405
|
unit: o
|
|
4377
4406
|
};
|
|
4378
|
-
}, ve = (
|
|
4379
|
-
if (
|
|
4380
|
-
const
|
|
4381
|
-
return n.area = parseFloat(n.area.toFixed(e)),
|
|
4407
|
+
}, ve = (s, t, e, i, o) => {
|
|
4408
|
+
if (s.geometry.type !== "Polygon") return s;
|
|
4409
|
+
const r = yo(s.geometry), n = fo(r, t, i, o);
|
|
4410
|
+
return n.area = parseFloat(n.area.toFixed(e)), s.properties.area = n.area, s.properties.unit = n.unit, s;
|
|
4382
4411
|
};
|
|
4383
|
-
function Ce(
|
|
4384
|
-
if (!
|
|
4412
|
+
function Ce(s) {
|
|
4413
|
+
if (!s)
|
|
4385
4414
|
throw new Error("coord is required");
|
|
4386
|
-
if (!Array.isArray(
|
|
4387
|
-
if (
|
|
4388
|
-
return [...
|
|
4389
|
-
if (
|
|
4390
|
-
return [...
|
|
4391
|
-
}
|
|
4392
|
-
if (Array.isArray(
|
|
4393
|
-
return [...
|
|
4415
|
+
if (!Array.isArray(s)) {
|
|
4416
|
+
if (s.type === "Feature" && s.geometry !== null && s.geometry.type === "Point")
|
|
4417
|
+
return [...s.geometry.coordinates];
|
|
4418
|
+
if (s.type === "Point")
|
|
4419
|
+
return [...s.coordinates];
|
|
4420
|
+
}
|
|
4421
|
+
if (Array.isArray(s) && s.length >= 2 && !Array.isArray(s[0]) && !Array.isArray(s[1]))
|
|
4422
|
+
return [...s];
|
|
4394
4423
|
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
4395
4424
|
}
|
|
4396
|
-
function mo(
|
|
4397
|
-
var i = Ce(
|
|
4425
|
+
function mo(s, t, e = {}) {
|
|
4426
|
+
var i = Ce(s), o = Ce(t), r = Pt(o[1] - i[1]), n = Pt(o[0] - i[0]), a = Pt(i[1]), l = Pt(o[1]), d = Math.pow(Math.sin(r / 2), 2) + Math.pow(Math.sin(n / 2), 2) * Math.cos(a) * Math.cos(l);
|
|
4398
4427
|
return lo(
|
|
4399
4428
|
2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
|
|
4400
4429
|
e.units
|
|
4401
4430
|
);
|
|
4402
4431
|
}
|
|
4403
4432
|
var vo = mo;
|
|
4404
|
-
const kt = (
|
|
4405
|
-
const o = ["centimeter", "meter", "kilometer"],
|
|
4433
|
+
const kt = (s, t = "metric", e = "auto", i = H) => {
|
|
4434
|
+
const o = ["centimeter", "meter", "kilometer"], r = ["inch", "foot", "mile"];
|
|
4406
4435
|
let n = e;
|
|
4407
4436
|
if (e !== "auto") {
|
|
4408
|
-
const l = o.includes(e), d =
|
|
4437
|
+
const l = o.includes(e), d = r.includes(e);
|
|
4409
4438
|
(t === "metric" && !l || t === "imperial" && !d) && (n = "auto");
|
|
4410
4439
|
}
|
|
4411
4440
|
let a = {
|
|
4412
|
-
distance:
|
|
4441
|
+
distance: s,
|
|
4413
4442
|
unit: i.kilometer
|
|
4414
4443
|
};
|
|
4415
|
-
return t === "metric" ? a = St(
|
|
4416
|
-
}, St = (
|
|
4444
|
+
return t === "metric" ? a = St(s, n, i) : t === "imperial" && (a = It(s, n, i)), a;
|
|
4445
|
+
}, St = (s, t, e) => {
|
|
4417
4446
|
let i = {
|
|
4418
|
-
distance:
|
|
4447
|
+
distance: s,
|
|
4419
4448
|
unit: e.kilometer
|
|
4420
4449
|
};
|
|
4421
4450
|
switch (t) {
|
|
4422
4451
|
case "kilometer":
|
|
4423
|
-
i.distance =
|
|
4452
|
+
i.distance = s, i.unit = e[t];
|
|
4424
4453
|
break;
|
|
4425
4454
|
case "meter":
|
|
4426
|
-
i.distance =
|
|
4455
|
+
i.distance = s * 1e3, i.unit = e[t];
|
|
4427
4456
|
break;
|
|
4428
4457
|
case "centimeter":
|
|
4429
|
-
i.distance =
|
|
4458
|
+
i.distance = s * 1e5, i.unit = e[t];
|
|
4430
4459
|
break;
|
|
4431
4460
|
case "auto":
|
|
4432
|
-
|
|
4461
|
+
s >= 1 ? i = St(s, "kilometer", e) : s * 1e3 >= 1 ? i = St(s, "meter", e) : i = St(s, "centimeter", e);
|
|
4433
4462
|
break;
|
|
4434
4463
|
default:
|
|
4435
|
-
i.distance =
|
|
4464
|
+
i.distance = s, i.unit = e.kilometer;
|
|
4436
4465
|
break;
|
|
4437
4466
|
}
|
|
4438
4467
|
return i;
|
|
4439
|
-
}, It = (
|
|
4468
|
+
}, It = (s, t, e) => {
|
|
4440
4469
|
let i = {
|
|
4441
|
-
distance:
|
|
4470
|
+
distance: s,
|
|
4442
4471
|
unit: e.mile
|
|
4443
4472
|
};
|
|
4444
4473
|
switch (t) {
|
|
4445
4474
|
case "mile":
|
|
4446
|
-
i.distance =
|
|
4475
|
+
i.distance = s, i.unit = e[t];
|
|
4447
4476
|
break;
|
|
4448
4477
|
case "foot":
|
|
4449
|
-
i.distance =
|
|
4478
|
+
i.distance = s * 5280, i.unit = e[t];
|
|
4450
4479
|
break;
|
|
4451
4480
|
case "inch":
|
|
4452
|
-
i.distance =
|
|
4481
|
+
i.distance = s * 63360, i.unit = e[t];
|
|
4453
4482
|
break;
|
|
4454
4483
|
case "auto":
|
|
4455
|
-
|
|
4484
|
+
s >= 1 ? i = It(s, "mile", e) : s * 5280 >= 1 ? i = It(s, "foot", e) : i = It(s, "inch", e);
|
|
4456
4485
|
break;
|
|
4457
4486
|
default:
|
|
4458
|
-
i.distance =
|
|
4487
|
+
i.distance = s, i.unit = e.mile;
|
|
4459
4488
|
break;
|
|
4460
4489
|
}
|
|
4461
4490
|
return i;
|
|
4462
|
-
}, Pe = (
|
|
4463
|
-
if (
|
|
4464
|
-
const l =
|
|
4491
|
+
}, Pe = (s, t, e, i, o, r, n, a) => {
|
|
4492
|
+
if (s.geometry.type !== "LineString") return s;
|
|
4493
|
+
const l = s.geometry.coordinates;
|
|
4465
4494
|
let d = 0;
|
|
4466
4495
|
const c = [];
|
|
4467
4496
|
for (let u = 0; u < l.length - 1; u++) {
|
|
4468
4497
|
const p = l[u], g = l[u + 1], y = vo(p, g, { units: t === "metric" ? "kilometers" : "miles" });
|
|
4469
4498
|
d += y;
|
|
4470
|
-
const f = JSON.parse(JSON.stringify(
|
|
4471
|
-
if (f.id = `${f.id}-${u}`, f.geometry.coordinates = [p, g], f.properties.originalId =
|
|
4472
|
-
const v =
|
|
4499
|
+
const f = JSON.parse(JSON.stringify(s));
|
|
4500
|
+
if (f.id = `${f.id}-${u}`, f.geometry.coordinates = [p, g], f.properties.originalId = s.id, f.properties.distance = y, f.properties.total = d, n === !0 && a === void 0) {
|
|
4501
|
+
const v = r?.queryTerrainElevation(p);
|
|
4473
4502
|
v && (f.properties.elevation_start = v);
|
|
4474
|
-
const C =
|
|
4503
|
+
const C = r?.queryTerrainElevation(g);
|
|
4475
4504
|
C && (f.properties.elevation_end = C);
|
|
4476
4505
|
}
|
|
4477
4506
|
c.push(f);
|
|
4478
4507
|
}
|
|
4479
|
-
|
|
4508
|
+
s.properties.distance = c[c.length - 1].properties.total, s.properties.segments = JSON.parse(JSON.stringify(c));
|
|
4480
4509
|
const h = kt(
|
|
4481
|
-
|
|
4510
|
+
s.properties.distance,
|
|
4482
4511
|
t,
|
|
4483
4512
|
i,
|
|
4484
4513
|
o
|
|
4485
4514
|
);
|
|
4486
|
-
return
|
|
4515
|
+
return s.properties.distance = h.distance, s.properties.unit = h.unit, s.properties.segments.forEach(
|
|
4487
4516
|
(u) => {
|
|
4488
4517
|
const p = kt(
|
|
4489
4518
|
u.properties.distance,
|
|
@@ -4500,9 +4529,9 @@ const kt = (r, t = "metric", e = "auto", i = J) => {
|
|
|
4500
4529
|
);
|
|
4501
4530
|
u.properties.total = g.distance, u.properties.totalUnit = g.unit;
|
|
4502
4531
|
}
|
|
4503
|
-
),
|
|
4504
|
-
|
|
4505
|
-
),
|
|
4532
|
+
), s.properties.distance = parseFloat(
|
|
4533
|
+
s.properties.distance.toFixed(e)
|
|
4534
|
+
), s.properties.segments.forEach(
|
|
4506
4535
|
(u) => {
|
|
4507
4536
|
u.properties.distance = parseFloat(
|
|
4508
4537
|
u.properties.distance.toFixed(e)
|
|
@@ -4510,14 +4539,14 @@ const kt = (r, t = "metric", e = "auto", i = J) => {
|
|
|
4510
4539
|
u.properties.total.toFixed(e)
|
|
4511
4540
|
);
|
|
4512
4541
|
}
|
|
4513
|
-
),
|
|
4514
|
-
}, pt = (
|
|
4515
|
-
elevation:
|
|
4542
|
+
), s;
|
|
4543
|
+
}, pt = (s, t = "metric", e = H) => t === "imperial" ? {
|
|
4544
|
+
elevation: s * 3.28084,
|
|
4516
4545
|
unit: e.foot
|
|
4517
4546
|
} : {
|
|
4518
|
-
elevation:
|
|
4547
|
+
elevation: s,
|
|
4519
4548
|
unit: e.meter
|
|
4520
|
-
}, Se = (
|
|
4549
|
+
}, Se = (s) => s.charAt(0).toUpperCase() + s.slice(1), it = [
|
|
4521
4550
|
"{prefix}-point",
|
|
4522
4551
|
"{prefix}-point-lower",
|
|
4523
4552
|
"{prefix}-linestring",
|
|
@@ -4535,18 +4564,18 @@ const kt = (r, t = "metric", e = "auto", i = J) => {
|
|
|
4535
4564
|
z.isochronePolygonLayerSpec?.source,
|
|
4536
4565
|
z.isochroneLineLayerSpec?.source,
|
|
4537
4566
|
z.isochroneLabelLayerSpec?.source
|
|
4538
|
-
], Yt = (
|
|
4539
|
-
e = e.map((
|
|
4540
|
-
const o = JSON.parse(JSON.stringify(
|
|
4541
|
-
return t && (t.onlyTerraDrawLayers === !0 ? (o.layers = o.layers.filter((
|
|
4542
|
-
e.includes(
|
|
4543
|
-
})) : t.excludeTerraDrawLayers === !0 && (o.layers = o.layers.filter((
|
|
4544
|
-
e.includes(
|
|
4567
|
+
], Yt = (s, t, e = it, i = "td") => {
|
|
4568
|
+
e = e.map((r) => r.replace("{prefix}", i));
|
|
4569
|
+
const o = JSON.parse(JSON.stringify(s));
|
|
4570
|
+
return t && (t.onlyTerraDrawLayers === !0 ? (o.layers = o.layers.filter((r) => "source" in r && e.includes(r.source)), Object.keys(o.sources).forEach((r) => {
|
|
4571
|
+
e.includes(r) || delete o.sources[r];
|
|
4572
|
+
})) : t.excludeTerraDrawLayers === !0 && (o.layers = o.layers.filter((r) => "source" in r && !e.includes(r.source) || r.type === "background"), Object.keys(o.sources).forEach((r) => {
|
|
4573
|
+
e.includes(r) && delete o.sources[r];
|
|
4545
4574
|
}))), o;
|
|
4546
|
-
}, $e = (
|
|
4575
|
+
}, $e = (s, t = 250) => {
|
|
4547
4576
|
let e;
|
|
4548
4577
|
return (...i) => {
|
|
4549
|
-
clearTimeout(e), e = setTimeout(() =>
|
|
4578
|
+
clearTimeout(e), e = setTimeout(() => s(...i), t);
|
|
4550
4579
|
};
|
|
4551
4580
|
};
|
|
4552
4581
|
class Ye {
|
|
@@ -4663,8 +4692,8 @@ class Co {
|
|
|
4663
4692
|
}), this.dialog = document.createElement("dialog"), this.dialog.classList.add(this.className);
|
|
4664
4693
|
const o = document.createElement("div");
|
|
4665
4694
|
o.classList.add("dialog-header");
|
|
4666
|
-
const
|
|
4667
|
-
|
|
4695
|
+
const r = document.createElement("h3");
|
|
4696
|
+
r.textContent = this.title, r.classList.add("dialog-title"), o.appendChild(r);
|
|
4668
4697
|
const n = document.createElement("button");
|
|
4669
4698
|
n.type = "button", n.classList.add("close-button"), n.innerHTML = "×", n.setAttribute("aria-label", "Close dialog"), n.addEventListener("click", () => {
|
|
4670
4699
|
this.close();
|
|
@@ -4708,17 +4737,17 @@ class Co {
|
|
|
4708
4737
|
createSegmentButtons(t, e, i = () => {
|
|
4709
4738
|
}) {
|
|
4710
4739
|
const o = document.createElement("div");
|
|
4711
|
-
return o.classList.add("segment-buttons"), t.forEach((
|
|
4740
|
+
return o.classList.add("segment-buttons"), t.forEach((r) => {
|
|
4712
4741
|
const n = document.createElement("button");
|
|
4713
|
-
n.type = "button", n.classList.add("segment-button"), n.value =
|
|
4742
|
+
n.type = "button", n.classList.add("segment-button"), n.value = r.value, n.textContent = r.label, r.value === e && n.classList.add("active"), n.addEventListener("click", () => {
|
|
4714
4743
|
o.querySelectorAll(".segment-button").forEach((a) => a.classList.remove("active")), n.classList.add("active"), i(n.value);
|
|
4715
4744
|
}), o.appendChild(n);
|
|
4716
4745
|
}), o;
|
|
4717
4746
|
}
|
|
4718
4747
|
}
|
|
4719
|
-
const Ie = (
|
|
4720
|
-
if (
|
|
4721
|
-
const n =
|
|
4748
|
+
const Ie = (s, t, e, i, o = "metric", r = H) => {
|
|
4749
|
+
if (s.geometry.type !== "Point") return s;
|
|
4750
|
+
const n = s.geometry.coordinates;
|
|
4722
4751
|
if (e === !0) {
|
|
4723
4752
|
if (i === void 0) {
|
|
4724
4753
|
const a = t?.queryTerrainElevation(n);
|
|
@@ -4726,99 +4755,99 @@ const Ie = (r, t, e, i, o = "metric", s = J) => {
|
|
|
4726
4755
|
const { elevation: l, unit: d } = pt(
|
|
4727
4756
|
a,
|
|
4728
4757
|
o,
|
|
4729
|
-
|
|
4758
|
+
r
|
|
4730
4759
|
);
|
|
4731
|
-
|
|
4760
|
+
s.properties.elevation = l, s.properties.elevationUnit = d;
|
|
4732
4761
|
}
|
|
4733
|
-
} else if (
|
|
4734
|
-
let a =
|
|
4735
|
-
const l =
|
|
4762
|
+
} else if (s.properties.elevation !== void 0 && typeof s.properties.elevation == "number") {
|
|
4763
|
+
let a = s.properties.elevation;
|
|
4764
|
+
const l = s.properties.elevationUnit;
|
|
4736
4765
|
(l === "ft" || l === "foot") && (a = a / 3.28084);
|
|
4737
4766
|
const { elevation: d, unit: c } = pt(
|
|
4738
4767
|
a,
|
|
4739
4768
|
o,
|
|
4740
|
-
|
|
4769
|
+
r
|
|
4741
4770
|
);
|
|
4742
|
-
|
|
4771
|
+
s.properties.elevation = d, s.properties.elevationUnit = c;
|
|
4743
4772
|
}
|
|
4744
4773
|
}
|
|
4745
|
-
return
|
|
4774
|
+
return s;
|
|
4746
4775
|
};
|
|
4747
|
-
var Po = Object.defineProperty, So = (
|
|
4748
|
-
function Io(
|
|
4749
|
-
return
|
|
4776
|
+
var Po = Object.defineProperty, So = (s, t, e) => t in s ? Po(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, nt = (s, t, e) => So(s, typeof t != "symbol" ? t + "" : t, e), Et = 2 * Math.PI * 6378137 / 2;
|
|
4777
|
+
function Io(s) {
|
|
4778
|
+
return s = s || 256, 2 * Math.PI * 6378137 / s;
|
|
4750
4779
|
}
|
|
4751
|
-
function xo(
|
|
4752
|
-
|
|
4753
|
-
var i =
|
|
4754
|
-
return n = n * Et / 180, e.enable && (
|
|
4780
|
+
function xo(s, t, e = { enable: !0, decimal: 1 }) {
|
|
4781
|
+
s = Kt(s);
|
|
4782
|
+
var i = s[0], o = s[1], r = i * Et / 180, n = Math.log(Math.tan((90 + o) * Math.PI / 360)) / (Math.PI / 180);
|
|
4783
|
+
return n = n * Et / 180, e.enable && (r = Number(r.toFixed(e.decimal)), n = Number(n.toFixed(e.decimal))), [r, n];
|
|
4755
4784
|
}
|
|
4756
|
-
function Oo(
|
|
4757
|
-
var i =
|
|
4785
|
+
function Oo(s, t, e) {
|
|
4786
|
+
var i = s[0], o = s[1], r = Fo(t, e), n = (i + Et) / r, a = (o + Et) / r;
|
|
4758
4787
|
return [n, a, t];
|
|
4759
4788
|
}
|
|
4760
|
-
function Ke(
|
|
4761
|
-
|
|
4762
|
-
var i = xo(
|
|
4789
|
+
function Ke(s, t, e) {
|
|
4790
|
+
s = Kt(s);
|
|
4791
|
+
var i = xo(s), o = Oo(i, t);
|
|
4763
4792
|
return bo(o);
|
|
4764
4793
|
}
|
|
4765
|
-
function Eo(
|
|
4766
|
-
if (
|
|
4794
|
+
function Eo(s, t, e) {
|
|
4795
|
+
if (s = Kt(s), t === 0)
|
|
4767
4796
|
return [0, 0, 0];
|
|
4768
|
-
var i = Ke(
|
|
4797
|
+
var i = Ke(s, t);
|
|
4769
4798
|
return wo(i);
|
|
4770
4799
|
}
|
|
4771
|
-
function bo(
|
|
4800
|
+
function bo(s, t, e) {
|
|
4772
4801
|
t = t || 256;
|
|
4773
|
-
var i =
|
|
4774
|
-
if (
|
|
4775
|
-
Xe(
|
|
4802
|
+
var i = s[0], o = s[1], r = s[2];
|
|
4803
|
+
if (r === 0) return [0, 0, 0];
|
|
4804
|
+
Xe(r);
|
|
4776
4805
|
var n = Math.ceil(i / t) - 1, a = Math.ceil(o / t) - 1;
|
|
4777
|
-
return n < 0 && (n = 0), a < 0 && (a = 0), [n, a,
|
|
4806
|
+
return n < 0 && (n = 0), a < 0 && (a = 0), [n, a, r];
|
|
4778
4807
|
}
|
|
4779
|
-
function wo(
|
|
4780
|
-
Lo(
|
|
4781
|
-
var e =
|
|
4808
|
+
function wo(s, t) {
|
|
4809
|
+
Lo(s);
|
|
4810
|
+
var e = s[0], i = s[1], o = s[2];
|
|
4782
4811
|
if (o === 0)
|
|
4783
4812
|
return [0, 0, 0];
|
|
4784
|
-
var
|
|
4785
|
-
return [
|
|
4813
|
+
var r = e, n = Math.pow(2, o) - 1 - i;
|
|
4814
|
+
return [r, n, o];
|
|
4786
4815
|
}
|
|
4787
|
-
function Lo(
|
|
4788
|
-
var e =
|
|
4816
|
+
function Lo(s, t) {
|
|
4817
|
+
var e = s[0], i = s[1], o = s[2];
|
|
4789
4818
|
if (o == null) throw new Error("<zoom> is required");
|
|
4790
4819
|
if (e == null) throw new Error("<x> is required");
|
|
4791
4820
|
if (i == null) throw new Error("<y> is required");
|
|
4792
|
-
return o = Xe(o),
|
|
4821
|
+
return o = Xe(o), s = Mo(s), s;
|
|
4793
4822
|
}
|
|
4794
|
-
function
|
|
4795
|
-
var t =
|
|
4823
|
+
function Mo(s) {
|
|
4824
|
+
var t = s[0], e = s[1], i = s[2], o = Math.pow(2, i);
|
|
4796
4825
|
return t = t % o, t < 0 && (t = t + o), [t, e, i];
|
|
4797
4826
|
}
|
|
4798
|
-
function Xe(
|
|
4799
|
-
if (
|
|
4800
|
-
if (
|
|
4827
|
+
function Xe(s) {
|
|
4828
|
+
if (s === !1) return s;
|
|
4829
|
+
if (s == null)
|
|
4801
4830
|
throw new Error("<zoom> is required");
|
|
4802
|
-
if (
|
|
4831
|
+
if (s < 0)
|
|
4803
4832
|
throw new Error("<zoom> cannot be less than 0");
|
|
4804
|
-
if (
|
|
4833
|
+
if (s > 32)
|
|
4805
4834
|
throw new Error("<zoom> cannot be greater than 32");
|
|
4806
|
-
return
|
|
4835
|
+
return s;
|
|
4807
4836
|
}
|
|
4808
|
-
function Kt(
|
|
4809
|
-
var e = _o(
|
|
4837
|
+
function Kt(s, t) {
|
|
4838
|
+
var e = _o(s[0]), i = Do(s[1]);
|
|
4810
4839
|
return i > 85 && (i = 85), i < -85 && (i = -85), [e, i];
|
|
4811
4840
|
}
|
|
4812
|
-
function
|
|
4813
|
-
return Io(t) / Math.pow(2,
|
|
4841
|
+
function Fo(s, t) {
|
|
4842
|
+
return Io(t) / Math.pow(2, s);
|
|
4814
4843
|
}
|
|
4815
|
-
function Do(
|
|
4816
|
-
if (
|
|
4817
|
-
return (
|
|
4844
|
+
function Do(s) {
|
|
4845
|
+
if (s == null) throw new Error("lat is required");
|
|
4846
|
+
return (s > 90 || s < -90) && (s = s % 180, s > 90 && (s = -180 + s), s < -90 && (s = 180 + s), s === 0 && (s = 0)), s;
|
|
4818
4847
|
}
|
|
4819
|
-
function _o(
|
|
4820
|
-
if (
|
|
4821
|
-
return (
|
|
4848
|
+
function _o(s) {
|
|
4849
|
+
if (s == null) throw new Error("lng is required");
|
|
4850
|
+
return (s > 180 || s < -180) && (s = s % 360, s > 180 && (s = -360 + s), s < -180 && (s = 360 + s), s === 0 && (s = 0)), s;
|
|
4822
4851
|
}
|
|
4823
4852
|
class qe {
|
|
4824
4853
|
/**
|
|
@@ -4830,8 +4859,8 @@ class qe {
|
|
|
4830
4859
|
* @param maxzoom maxzoom for terrain RGB raster tilesets
|
|
4831
4860
|
* @param tms whether it is Tile Map Service
|
|
4832
4861
|
*/
|
|
4833
|
-
constructor(t, e, i, o,
|
|
4834
|
-
nt(this, "url"), nt(this, "tileSize"), nt(this, "tms"), nt(this, "minzoom"), nt(this, "maxzoom"), this.url = t, this.tileSize = e, this.tms =
|
|
4862
|
+
constructor(t, e, i, o, r) {
|
|
4863
|
+
nt(this, "url"), nt(this, "tileSize"), nt(this, "tms"), nt(this, "minzoom"), nt(this, "maxzoom"), this.url = t, this.tileSize = e, this.tms = r, this.minzoom = i, this.maxzoom = o, this.tms = r;
|
|
4835
4864
|
}
|
|
4836
4865
|
/**
|
|
4837
4866
|
* Get the value from target coordinates and zoom level by using certain formula.
|
|
@@ -4842,15 +4871,15 @@ class qe {
|
|
|
4842
4871
|
getValue(t, e) {
|
|
4843
4872
|
return new Promise(
|
|
4844
4873
|
(i, o) => {
|
|
4845
|
-
const
|
|
4874
|
+
const r = t[0], n = t[1];
|
|
4846
4875
|
let a = e;
|
|
4847
4876
|
e > this.maxzoom ? a = this.maxzoom : e < this.minzoom && (a = this.minzoom);
|
|
4848
|
-
const l = this.tms ? Ke([
|
|
4877
|
+
const l = this.tms ? Ke([r, n], a) : Eo([r, n], a), d = this.url.replace(/{x}/g, l[0].toString()).replace(/{y}/g, l[1].toString()).replace(/{z}/g, l[2].toString());
|
|
4849
4878
|
let c = this.getUrlExtension(d);
|
|
4850
4879
|
switch (c || (c = "png"), c) {
|
|
4851
4880
|
case "png":
|
|
4852
4881
|
case "webp":
|
|
4853
|
-
this.getValueFromRaster(d, l,
|
|
4882
|
+
this.getValueFromRaster(d, l, r, n).then((h) => {
|
|
4854
4883
|
i(h);
|
|
4855
4884
|
});
|
|
4856
4885
|
break;
|
|
@@ -4870,13 +4899,13 @@ class qe {
|
|
|
4870
4899
|
* @returns the value calculated from coordinates. If tile does not exist returns undefined
|
|
4871
4900
|
*/
|
|
4872
4901
|
async getValueFromRaster(t, e, i, o) {
|
|
4873
|
-
const
|
|
4874
|
-
if (!
|
|
4875
|
-
if (
|
|
4902
|
+
const r = await fetch(t);
|
|
4903
|
+
if (!r.ok) {
|
|
4904
|
+
if (r.status === 404)
|
|
4876
4905
|
return;
|
|
4877
|
-
throw new Error(`Failed to fetch tile: ${
|
|
4906
|
+
throw new Error(`Failed to fetch tile: ${r.statusText}`);
|
|
4878
4907
|
}
|
|
4879
|
-
const n = await
|
|
4908
|
+
const n = await r.blob();
|
|
4880
4909
|
return new Promise((a, l) => {
|
|
4881
4910
|
const d = new Image();
|
|
4882
4911
|
d.onload = () => {
|
|
@@ -4899,13 +4928,13 @@ class qe {
|
|
|
4899
4928
|
* @returns RGBA values
|
|
4900
4929
|
*/
|
|
4901
4930
|
pixels2rgba(t, e, i, o) {
|
|
4902
|
-
const
|
|
4931
|
+
const r = [];
|
|
4903
4932
|
for (let d = 0; d < t.length; d += 4) {
|
|
4904
4933
|
const c = t[d], h = t[d + 1], u = t[d + 2], p = t[d + 3], g = [c, h, u, p];
|
|
4905
|
-
|
|
4934
|
+
r.push(g);
|
|
4906
4935
|
}
|
|
4907
4936
|
const n = this.tileToBBOX(e), a = this.getPixelPosition(i, o, n), l = a[0] + a[1] * this.tileSize;
|
|
4908
|
-
return
|
|
4937
|
+
return r[l];
|
|
4909
4938
|
}
|
|
4910
4939
|
/**
|
|
4911
4940
|
* Get the position in pixel from the coordinates
|
|
@@ -4915,7 +4944,7 @@ class qe {
|
|
|
4915
4944
|
* @returns The position in pixel
|
|
4916
4945
|
*/
|
|
4917
4946
|
getPixelPosition(t, e, i) {
|
|
4918
|
-
const o = this.tileSize,
|
|
4947
|
+
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, c = Math.floor(o * l), h = Math.floor(r * (1 - d));
|
|
4919
4948
|
return [c, h];
|
|
4920
4949
|
}
|
|
4921
4950
|
/**
|
|
@@ -4936,8 +4965,8 @@ class qe {
|
|
|
4936
4965
|
* //=bbox
|
|
4937
4966
|
*/
|
|
4938
4967
|
tileToBBOX(t) {
|
|
4939
|
-
const e = this.tile2lon(t[0] + 1, t[2]), i = this.tile2lon(t[0], t[2]), o = this.tile2lat(t[1] + 1, t[2]),
|
|
4940
|
-
return [i, o, e,
|
|
4968
|
+
const e = this.tile2lon(t[0] + 1, t[2]), i = this.tile2lon(t[0], t[2]), o = this.tile2lat(t[1] + 1, t[2]), r = this.tile2lat(t[1], t[2]);
|
|
4969
|
+
return [i, o, e, r];
|
|
4941
4970
|
}
|
|
4942
4971
|
tile2lon(t, e) {
|
|
4943
4972
|
return t / Math.pow(2, e) * 360 - 180;
|
|
@@ -4956,8 +4985,8 @@ class ko extends qe {
|
|
|
4956
4985
|
* @param minzoom minzoom for terrain RGB raster tilesets. default is 5
|
|
4957
4986
|
* @param maxzoom maxzoom for terrain RGB raster tilesets. default is 15
|
|
4958
4987
|
*/
|
|
4959
|
-
constructor(t, e, i = 5, o = 15,
|
|
4960
|
-
super(t, e, i, o,
|
|
4988
|
+
constructor(t, e, i = 5, o = 15, r = !1) {
|
|
4989
|
+
super(t, e, i, o, r);
|
|
4961
4990
|
}
|
|
4962
4991
|
/**
|
|
4963
4992
|
* Get an altitude calculated from terrain RGB information
|
|
@@ -4988,8 +5017,8 @@ class No extends qe {
|
|
|
4988
5017
|
* @param minzoom minzoom for terrain RGB raster tilesets. default is 5
|
|
4989
5018
|
* @param maxzoom maxzoom for terrain RGB raster tilesets. default is 15
|
|
4990
5019
|
*/
|
|
4991
|
-
constructor(t, e, i = 5, o = 15,
|
|
4992
|
-
super(t, e, i, o,
|
|
5020
|
+
constructor(t, e, i = 5, o = 15, r = !1) {
|
|
5021
|
+
super(t, e, i, o, r);
|
|
4993
5022
|
}
|
|
4994
5023
|
/**
|
|
4995
5024
|
* Get an altitude calculated from terrain RGB information
|
|
@@ -5013,10 +5042,10 @@ class No extends qe {
|
|
|
5013
5042
|
return parseInt(o.toFixed(0));
|
|
5014
5043
|
}
|
|
5015
5044
|
}
|
|
5016
|
-
const To = (
|
|
5017
|
-
const [e, i] =
|
|
5018
|
-
return `${
|
|
5019
|
-
}, xe = async (
|
|
5045
|
+
const To = (s, t = 8) => {
|
|
5046
|
+
const [e, i] = s, o = Math.pow(10, t), r = Math.round(e * o) / o, n = Math.round(i * o) / o;
|
|
5047
|
+
return `${r},${n}`;
|
|
5048
|
+
}, xe = async (s, t, e, i, o = "metric", r = H) => {
|
|
5020
5049
|
const n = [], a = {
|
|
5021
5050
|
enabled: !0,
|
|
5022
5051
|
maxSize: 1e3,
|
|
@@ -5034,7 +5063,7 @@ const To = (r, t = 8) => {
|
|
|
5034
5063
|
const y = t.tms ?? !1;
|
|
5035
5064
|
d = u === "mapbox" ? new ko(h, p, g, c, y) : new No(h, p, g, c, y);
|
|
5036
5065
|
}
|
|
5037
|
-
for (const h of
|
|
5066
|
+
for (const h of s)
|
|
5038
5067
|
n.push(
|
|
5039
5068
|
new Promise((u) => {
|
|
5040
5069
|
h.geometry.type !== "Point" && u(h);
|
|
@@ -5046,7 +5075,7 @@ const To = (r, t = 8) => {
|
|
|
5046
5075
|
const { elevation: f, unit: v } = pt(
|
|
5047
5076
|
y,
|
|
5048
5077
|
o,
|
|
5049
|
-
|
|
5078
|
+
r
|
|
5050
5079
|
);
|
|
5051
5080
|
h.properties.elevation = f, h.properties.elevationUnit = v;
|
|
5052
5081
|
}
|
|
@@ -5060,7 +5089,7 @@ const To = (r, t = 8) => {
|
|
|
5060
5089
|
const { elevation: f, unit: v } = pt(
|
|
5061
5090
|
y,
|
|
5062
5091
|
o,
|
|
5063
|
-
|
|
5092
|
+
r
|
|
5064
5093
|
);
|
|
5065
5094
|
h.properties.elevation = f, h.properties.elevationUnit = v;
|
|
5066
5095
|
}
|
|
@@ -5071,14 +5100,14 @@ const To = (r, t = 8) => {
|
|
|
5071
5100
|
})
|
|
5072
5101
|
);
|
|
5073
5102
|
return await Promise.all(n);
|
|
5074
|
-
},
|
|
5103
|
+
}, Ho = (s, t = 9) => {
|
|
5075
5104
|
function e(o) {
|
|
5076
5105
|
return [Number(o[0].toFixed(t)), Number(o[1].toFixed(t))];
|
|
5077
5106
|
}
|
|
5078
5107
|
function i(o) {
|
|
5079
|
-
const
|
|
5108
|
+
const r = o.type;
|
|
5080
5109
|
let n = o.coordinates;
|
|
5081
|
-
switch (
|
|
5110
|
+
switch (r) {
|
|
5082
5111
|
case "Point":
|
|
5083
5112
|
n = e(n);
|
|
5084
5113
|
break;
|
|
@@ -5101,7 +5130,7 @@ const To = (r, t = 8) => {
|
|
|
5101
5130
|
coordinates: n
|
|
5102
5131
|
};
|
|
5103
5132
|
}
|
|
5104
|
-
return
|
|
5133
|
+
return s.map((o) => ({
|
|
5105
5134
|
...o,
|
|
5106
5135
|
geometry: i(o.geometry)
|
|
5107
5136
|
}));
|
|
@@ -5127,8 +5156,8 @@ class Bo {
|
|
|
5127
5156
|
* @param contours Optional. the list of contour. If skipped, default value is used.
|
|
5128
5157
|
* @returns GeoJSON Feature Collection object
|
|
5129
5158
|
*/
|
|
5130
|
-
async calcIsochrone(t, e, i, o,
|
|
5131
|
-
const n = JSON.parse(JSON.stringify(
|
|
5159
|
+
async calcIsochrone(t, e, i, o, r) {
|
|
5160
|
+
const n = JSON.parse(JSON.stringify(r));
|
|
5132
5161
|
n.forEach((h) => {
|
|
5133
5162
|
i === "time" ? delete h.distance : delete h.time;
|
|
5134
5163
|
});
|
|
@@ -5199,13 +5228,13 @@ class Ao {
|
|
|
5199
5228
|
this.tripSummary = void 0;
|
|
5200
5229
|
return;
|
|
5201
5230
|
}
|
|
5202
|
-
const o = `${this.url}/route`,
|
|
5231
|
+
const o = `${this.url}/route`, r = {
|
|
5203
5232
|
locations: this.tripData.map((m) => ({ lon: m.lng, lat: m.lat })),
|
|
5204
5233
|
costing: e,
|
|
5205
5234
|
costing_options: { auto: { country_crossing_penalty: 2e3 } },
|
|
5206
5235
|
units: i,
|
|
5207
5236
|
id: "my_work_route"
|
|
5208
|
-
}, n = `${o}?json=${JSON.stringify(
|
|
5237
|
+
}, n = `${o}?json=${JSON.stringify(r)}`, l = await (await fetch(n)).json();
|
|
5209
5238
|
if ("error" in l)
|
|
5210
5239
|
throw this.tripData.pop(), new Error(`${l.status} (${l.status_code}): ${l.error} (${l.error_code})`);
|
|
5211
5240
|
const d = l.trip.legs.map((m) => this.decodeShape(m.shape));
|
|
@@ -5288,7 +5317,7 @@ class Ao {
|
|
|
5288
5317
|
* @returns the list of coordinates as [lng, lat] pairs
|
|
5289
5318
|
*/
|
|
5290
5319
|
decodeShape(t, e = 6) {
|
|
5291
|
-
let i = 0, o = 0,
|
|
5320
|
+
let i = 0, o = 0, r = 0, n = [], a = 0, l = 0, d = null, c, h, u = Math.pow(10, e || 6);
|
|
5292
5321
|
for (; i < t.length; ) {
|
|
5293
5322
|
d = null, a = 0, l = 0;
|
|
5294
5323
|
do
|
|
@@ -5298,12 +5327,12 @@ class Ao {
|
|
|
5298
5327
|
do
|
|
5299
5328
|
d = t.charCodeAt(i++) - 63, l |= (d & 31) << a, a += 5;
|
|
5300
5329
|
while (d >= 32);
|
|
5301
|
-
h = l & 1 ? ~(l >> 1) : l >> 1, o += c,
|
|
5330
|
+
h = l & 1 ? ~(l >> 1) : l >> 1, o += c, r += h, n.push([r / u, o / u]);
|
|
5302
5331
|
}
|
|
5303
5332
|
return n;
|
|
5304
5333
|
}
|
|
5305
5334
|
}
|
|
5306
|
-
class
|
|
5335
|
+
class He {
|
|
5307
5336
|
controlContainer;
|
|
5308
5337
|
map;
|
|
5309
5338
|
modeButtons = {};
|
|
@@ -5333,8 +5362,8 @@ class Je {
|
|
|
5333
5362
|
`maplibregl-terradraw-${this.cssPrefix}add-control`
|
|
5334
5363
|
);
|
|
5335
5364
|
for (let o = 0; o < e.length; o++) {
|
|
5336
|
-
const
|
|
5337
|
-
|
|
5365
|
+
const r = e.item(o);
|
|
5366
|
+
r && (this.isExpanded ? r.classList.remove("hidden") : r.classList.add("hidden"));
|
|
5338
5367
|
}
|
|
5339
5368
|
const i = document.getElementsByClassName(
|
|
5340
5369
|
`maplibregl-terradraw-${this.cssPrefix}render-button`
|
|
@@ -5370,20 +5399,20 @@ class Je {
|
|
|
5370
5399
|
if (this.options && this.options.modes && this.options.modes.length === 0)
|
|
5371
5400
|
throw new Error("At least a mode must be enabled.");
|
|
5372
5401
|
this.map = t;
|
|
5373
|
-
const e =
|
|
5402
|
+
const e = ro(), i = [];
|
|
5374
5403
|
return this.options?.modes?.forEach((o) => {
|
|
5375
5404
|
if (this.options.modeOptions && this.options.modeOptions[o]) {
|
|
5376
|
-
const
|
|
5405
|
+
const r = this.options.modeOptions[o];
|
|
5377
5406
|
if (o === "select") {
|
|
5378
5407
|
const n = e[o];
|
|
5379
5408
|
if (n) {
|
|
5380
5409
|
const a = n.flags;
|
|
5381
5410
|
Object.keys(a).forEach((l) => {
|
|
5382
|
-
|
|
5411
|
+
r.flags[l] || (r.flags[l] = a[l]);
|
|
5383
5412
|
});
|
|
5384
5413
|
}
|
|
5385
5414
|
}
|
|
5386
|
-
i.push(
|
|
5415
|
+
i.push(r);
|
|
5387
5416
|
} else e[o] && i.push(e[o]);
|
|
5388
5417
|
}), i.forEach((o) => {
|
|
5389
5418
|
o.state !== "unregistered" && (o._state = "unregistered");
|
|
@@ -5436,9 +5465,9 @@ class Je {
|
|
|
5436
5465
|
*/
|
|
5437
5466
|
dispatchEvent(t, e) {
|
|
5438
5467
|
this.events[t] && this.events[t].forEach((i) => {
|
|
5439
|
-
const
|
|
5468
|
+
const r = this.terradraw?.getSnapshot()?.filter((n) => n.properties.selected === !0);
|
|
5440
5469
|
i({
|
|
5441
|
-
feature:
|
|
5470
|
+
feature: r,
|
|
5442
5471
|
mode: this.terradraw?.getMode(),
|
|
5443
5472
|
...e
|
|
5444
5473
|
});
|
|
@@ -5456,13 +5485,46 @@ class Je {
|
|
|
5456
5485
|
deactivate() {
|
|
5457
5486
|
this.terradraw && this.terradraw.enabled && (this.resetActiveMode(), this.dispatchEvent("mode-changed"), this.terradraw.stop());
|
|
5458
5487
|
}
|
|
5488
|
+
/**
|
|
5489
|
+
* Handle mode change operations that should be executed after setMode is called
|
|
5490
|
+
* @param mode The active mode name
|
|
5491
|
+
* @param target The Terra Draw instance
|
|
5492
|
+
* @returns The result of the setMode operation
|
|
5493
|
+
*/
|
|
5494
|
+
handleModeChange(t, e) {
|
|
5495
|
+
const i = e.setMode(t);
|
|
5496
|
+
return this.syncButtonStates(t), t !== this.defaultMode && this.activate(), this.dispatchEvent("mode-changed"), i;
|
|
5497
|
+
}
|
|
5498
|
+
/**
|
|
5499
|
+
* Synchronize button states with the current Terra Draw mode
|
|
5500
|
+
* @param mode The active mode name
|
|
5501
|
+
*/
|
|
5502
|
+
syncButtonStates(t) {
|
|
5503
|
+
if (!this.controlContainer) return;
|
|
5504
|
+
const e = this.controlContainer.getElementsByClassName(
|
|
5505
|
+
`maplibregl-terradraw-${this.cssPrefix}add-control`
|
|
5506
|
+
);
|
|
5507
|
+
for (let i = 0; i < e.length; i++) {
|
|
5508
|
+
const o = e.item(i);
|
|
5509
|
+
o && o.classList.remove("active");
|
|
5510
|
+
}
|
|
5511
|
+
if (t !== this.defaultMode && t !== "render") {
|
|
5512
|
+
const i = this.controlContainer.getElementsByClassName(
|
|
5513
|
+
`maplibregl-terradraw-${this.cssPrefix}add-${t}-button`
|
|
5514
|
+
);
|
|
5515
|
+
i && i.length > 0 && i[0].classList.add("active");
|
|
5516
|
+
}
|
|
5517
|
+
this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature();
|
|
5518
|
+
}
|
|
5459
5519
|
/**
|
|
5460
5520
|
* Get the Terra Draw instance.
|
|
5461
5521
|
* For the Terra Draw API, please refer to https://terradraw.io/#/api
|
|
5462
|
-
* @returns Terra Draw instance
|
|
5522
|
+
* @returns Terra Draw instance with additional extensions for the plugin control
|
|
5463
5523
|
*/
|
|
5464
5524
|
getTerraDrawInstance() {
|
|
5465
|
-
return this.terradraw
|
|
5525
|
+
return this.terradraw ? new Proxy(this.terradraw, {
|
|
5526
|
+
get: (t, e, i) => e === "setMode" ? (o) => this.handleModeChange(o, t) : Reflect.get(t, e, i)
|
|
5527
|
+
}) : this.terradraw;
|
|
5466
5528
|
}
|
|
5467
5529
|
/**
|
|
5468
5530
|
* Toggle editor control
|
|
@@ -5474,16 +5536,7 @@ class Je {
|
|
|
5474
5536
|
* Reset active mode to back to render mode
|
|
5475
5537
|
*/
|
|
5476
5538
|
resetActiveMode() {
|
|
5477
|
-
|
|
5478
|
-
this.terradraw.enabled || this.terradraw.start();
|
|
5479
|
-
const t = document.getElementsByClassName(
|
|
5480
|
-
`maplibregl-terradraw-${this.cssPrefix}add-control`
|
|
5481
|
-
);
|
|
5482
|
-
for (let e = 0; e < t.length; e++) {
|
|
5483
|
-
const i = t.item(e);
|
|
5484
|
-
i && i.classList.remove("active");
|
|
5485
|
-
}
|
|
5486
|
-
this.terradraw?.setMode(this.defaultMode);
|
|
5539
|
+
this.terradraw && (this.terradraw.enabled || this.terradraw.start(), this.terradraw?.setMode(this.defaultMode), this.syncButtonStates(this.defaultMode));
|
|
5487
5540
|
}
|
|
5488
5541
|
/**
|
|
5489
5542
|
* Add Terra Draw drawing mode button
|
|
@@ -5495,19 +5548,19 @@ class Je {
|
|
|
5495
5548
|
this.terradraw && this.terradraw.enabled && (this.terradraw.clear(), this.deactivate(), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.dispatchEvent("feature-deleted"));
|
|
5496
5549
|
})) : t === "delete-selection" ? (e.classList.add(`maplibregl-terradraw-${this.cssPrefix}${t}-button`), e.classList.add("hidden-delete-selection"), e.addEventListener("click", () => {
|
|
5497
5550
|
if (!this.terradraw || !this.terradraw.enabled) return;
|
|
5498
|
-
const o = (this.terradraw?.getSnapshot()).filter((
|
|
5551
|
+
const o = (this.terradraw?.getSnapshot()).filter((r) => r.properties.selected === !0);
|
|
5499
5552
|
if (o.length > 0) {
|
|
5500
|
-
const
|
|
5501
|
-
this.terradraw.removeFeatures(
|
|
5502
|
-
for (const n of
|
|
5553
|
+
const r = o.map((n) => n.id);
|
|
5554
|
+
this.terradraw.removeFeatures(r);
|
|
5555
|
+
for (const n of r)
|
|
5503
5556
|
this.terradraw.deselectFeature(n);
|
|
5504
|
-
this.dispatchEvent("feature-deleted", { deletedIds:
|
|
5557
|
+
this.dispatchEvent("feature-deleted", { deletedIds: r });
|
|
5505
5558
|
}
|
|
5506
5559
|
this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature();
|
|
5507
5560
|
})) : t === "download" ? (e.classList.add(`maplibregl-terradraw-${this.cssPrefix}${t}-button`), e.addEventListener("click", this.handleDownload.bind(this))) : (e.classList.add(`maplibregl-terradraw-${this.cssPrefix}add-${t}-button`), e.addEventListener("click", () => {
|
|
5508
5561
|
if (!this.terradraw) return;
|
|
5509
5562
|
const i = e.classList.contains("active");
|
|
5510
|
-
this.activate(), this.resetActiveMode(), i || (this.terradraw.setMode(t),
|
|
5563
|
+
this.activate(), this.resetActiveMode(), i || (this.terradraw.setMode(t), this.syncButtonStates(t)), this.dispatchEvent("mode-changed");
|
|
5511
5564
|
})));
|
|
5512
5565
|
}
|
|
5513
5566
|
/**
|
|
@@ -5519,9 +5572,9 @@ class Je {
|
|
|
5519
5572
|
if (!this.terradraw) return;
|
|
5520
5573
|
const o = {
|
|
5521
5574
|
type: "FeatureCollection",
|
|
5522
|
-
features: (this.terradraw?.getSnapshot()).filter((
|
|
5575
|
+
features: (this.terradraw?.getSnapshot()).filter((r) => r.properties.mode !== "select")
|
|
5523
5576
|
};
|
|
5524
|
-
return t !== !0 || (o.features = o.features.filter((
|
|
5577
|
+
return t !== !0 || (o.features = o.features.filter((r) => r.properties.selected === !0)), o;
|
|
5525
5578
|
}
|
|
5526
5579
|
/**
|
|
5527
5580
|
* clean maplibre style to filter only for terradraw related layers or without them.
|
|
@@ -5564,9 +5617,9 @@ class Je {
|
|
|
5564
5617
|
`maplibregl-terradraw-${this.cssPrefix}delete-button`
|
|
5565
5618
|
];
|
|
5566
5619
|
for (const o of i) {
|
|
5567
|
-
const
|
|
5568
|
-
for (let n = 0; n <
|
|
5569
|
-
const a =
|
|
5620
|
+
const r = this.controlContainer.getElementsByClassName(o);
|
|
5621
|
+
for (let n = 0; n < r.length; n++) {
|
|
5622
|
+
const a = r.item(n);
|
|
5570
5623
|
a && (a.disabled = !e);
|
|
5571
5624
|
}
|
|
5572
5625
|
}
|
|
@@ -5575,12 +5628,12 @@ class Je {
|
|
|
5575
5628
|
* Toggle the state of delete-select button
|
|
5576
5629
|
*/
|
|
5577
5630
|
toggleDeleteSelectionButton() {
|
|
5578
|
-
const t = this.terradraw?.enabled || !1, e = this.terradraw?.getMode(), i = this.getFeatures(!1), o = i && i.features.length > 0,
|
|
5631
|
+
const t = this.terradraw?.enabled || !1, e = this.terradraw?.getMode(), i = this.getFeatures(!1), o = i && i.features.length > 0, r = o && t && e === "select", n = document.getElementsByClassName(
|
|
5579
5632
|
`maplibregl-terradraw-${this.cssPrefix}delete-selection-button`
|
|
5580
5633
|
);
|
|
5581
5634
|
for (let a = 0; a < n.length; a++) {
|
|
5582
5635
|
const l = n.item(a);
|
|
5583
|
-
l && (
|
|
5636
|
+
l && (r ? l.classList.remove("hidden-delete-selection") : l.classList.add("hidden-delete-selection"));
|
|
5584
5637
|
}
|
|
5585
5638
|
if (!o) {
|
|
5586
5639
|
const a = document.getElementsByClassName(
|
|
@@ -5602,20 +5655,20 @@ class Je {
|
|
|
5602
5655
|
if (this.map)
|
|
5603
5656
|
for (const i of t) {
|
|
5604
5657
|
const o = this.map.getStyle().sources[i];
|
|
5605
|
-
o && typeof o.data != "string" && o.data.type === "FeatureCollection" && (e === void 0 ? o.data.features = [] : o.data.features = o.data.features.filter((
|
|
5658
|
+
o && typeof o.data != "string" && o.data.type === "FeatureCollection" && (e === void 0 ? o.data.features = [] : o.data.features = o.data.features.filter((r) => r.properties?.originalId ? !e.includes(r.properties.originalId) : !e.includes(r.id)), this.map.getSource(i)?.setData(o.data));
|
|
5606
5659
|
}
|
|
5607
5660
|
}
|
|
5608
5661
|
}
|
|
5609
|
-
function
|
|
5662
|
+
function Uo(s, t = {}) {
|
|
5610
5663
|
let e = 0, i = 0, o = 0;
|
|
5611
5664
|
return Ve(
|
|
5612
|
-
|
|
5613
|
-
function(
|
|
5614
|
-
e +=
|
|
5665
|
+
s,
|
|
5666
|
+
function(r) {
|
|
5667
|
+
e += r[0], i += r[1], o++;
|
|
5615
5668
|
}
|
|
5616
5669
|
), ao([e / o, i / o], t.properties);
|
|
5617
5670
|
}
|
|
5618
|
-
class
|
|
5671
|
+
class Jo extends He {
|
|
5619
5672
|
measureOptions;
|
|
5620
5673
|
elevationCache;
|
|
5621
5674
|
/**
|
|
@@ -5677,7 +5730,7 @@ class Ho extends Je {
|
|
|
5677
5730
|
* Measure unit symbols. If you want to change the default symbol, please overwrite the symbol by this option.
|
|
5678
5731
|
*/
|
|
5679
5732
|
get measureUnitSymbols() {
|
|
5680
|
-
return this.measureOptions.measureUnitSymbols ?? JSON.parse(JSON.stringify(
|
|
5733
|
+
return this.measureOptions.measureUnitSymbols ?? JSON.parse(JSON.stringify(H));
|
|
5681
5734
|
}
|
|
5682
5735
|
set measureUnitSymbols(t) {
|
|
5683
5736
|
const e = JSON.stringify(this.measureOptions.measureUnitSymbols) === JSON.stringify(t);
|
|
@@ -5790,8 +5843,8 @@ class Ho extends Je {
|
|
|
5790
5843
|
this.registerMesureControl();
|
|
5791
5844
|
const e = t.getSnapshot();
|
|
5792
5845
|
for (const i of e) {
|
|
5793
|
-
const o = i.id,
|
|
5794
|
-
["linestring", "freehand-linestring"].includes(n) &&
|
|
5846
|
+
const o = i.id, r = i.geometry.type, n = i.properties.mode;
|
|
5847
|
+
["linestring", "freehand-linestring"].includes(n) && r === "LineString" ? (this.measureLine(o), this.computeElevationByLineFeatureID(o)) : n === "point" && r === "Point" ? (this.measurePoint(o), this.computeElevationByPointFeatureID(o)) : !["point", "linestring", "freehand-linestring", "select", "render"].includes(n) && r === "Polygon" && this.measurePolygon(o);
|
|
5795
5848
|
}
|
|
5796
5849
|
}
|
|
5797
5850
|
}
|
|
@@ -5813,8 +5866,8 @@ class Ho extends Je {
|
|
|
5813
5866
|
cleanStyle(t, e) {
|
|
5814
5867
|
const i = it, o = this.measureOptions.polygonLayerSpec?.source;
|
|
5815
5868
|
o && i.push(o);
|
|
5816
|
-
const
|
|
5817
|
-
|
|
5869
|
+
const r = this.measureOptions.lineLayerLabelSpec?.source;
|
|
5870
|
+
r && i.push(r);
|
|
5818
5871
|
const n = this.measureOptions.pointLayerLabelSpec?.source;
|
|
5819
5872
|
return n && i.push(n), Yt(
|
|
5820
5873
|
t,
|
|
@@ -5882,17 +5935,17 @@ class Ho extends Je {
|
|
|
5882
5935
|
const t = this.getTerraDrawInstance();
|
|
5883
5936
|
if (!t) return;
|
|
5884
5937
|
const e = t.getSnapshot(), i = e.filter(
|
|
5885
|
-
(
|
|
5938
|
+
(r) => r.properties.mode && ["linestring", "freehand-linestring"].includes(r.properties.mode) && r.geometry.type === "LineString"
|
|
5886
5939
|
);
|
|
5887
5940
|
if (i.length > 0)
|
|
5888
|
-
for (const
|
|
5889
|
-
this.computeElevationByLineFeatureID(
|
|
5941
|
+
for (const r of i)
|
|
5942
|
+
this.computeElevationByLineFeatureID(r.id);
|
|
5890
5943
|
const o = e.filter(
|
|
5891
|
-
(
|
|
5944
|
+
(r) => r.properties.mode === "point" && r.geometry.type === "Point"
|
|
5892
5945
|
);
|
|
5893
5946
|
if (o.length > 0)
|
|
5894
|
-
for (const
|
|
5895
|
-
this.computeElevationByPointFeatureID(
|
|
5947
|
+
for (const r of o)
|
|
5948
|
+
this.computeElevationByPointFeatureID(r.id);
|
|
5896
5949
|
}
|
|
5897
5950
|
};
|
|
5898
5951
|
/**
|
|
@@ -5918,9 +5971,9 @@ class Ho extends Je {
|
|
|
5918
5971
|
this.clearExtendedFeatures(o, t);
|
|
5919
5972
|
return;
|
|
5920
5973
|
}
|
|
5921
|
-
const
|
|
5922
|
-
if (!
|
|
5923
|
-
const n =
|
|
5974
|
+
const r = this.getTerraDrawInstance();
|
|
5975
|
+
if (!r) return;
|
|
5976
|
+
const n = r.getSnapshot();
|
|
5924
5977
|
for (const a of t) {
|
|
5925
5978
|
const l = n.find((d) => d.id === a);
|
|
5926
5979
|
if (l) {
|
|
@@ -5962,21 +6015,21 @@ class Ho extends Je {
|
|
|
5962
6015
|
if (!this.map) return;
|
|
5963
6016
|
const o = this.map.getStyle().sources[e];
|
|
5964
6017
|
if (o && typeof o.data != "string" && o.data.type === "FeatureCollection") {
|
|
5965
|
-
const
|
|
6018
|
+
const r = [];
|
|
5966
6019
|
for (const a of t)
|
|
5967
|
-
(this.terradraw?.getSnapshotFeature(a.id) || this.terradraw?.getSnapshotFeature(a.properties.originalId)) &&
|
|
5968
|
-
const n =
|
|
6020
|
+
(this.terradraw?.getSnapshotFeature(a.id) || this.terradraw?.getSnapshotFeature(a.properties.originalId)) && r.push(a);
|
|
6021
|
+
const n = r.map((a) => a.id);
|
|
5969
6022
|
if (typeof o.data != "string" && o.data.type === "FeatureCollection") {
|
|
5970
6023
|
i === "linestring" ? o.data.features = [
|
|
5971
6024
|
...o.data.features = o.data.features.filter(
|
|
5972
6025
|
(l) => !(n.includes(l.properties?.originalId) && l.geometry.type === "Point")
|
|
5973
6026
|
),
|
|
5974
|
-
...
|
|
6027
|
+
...r
|
|
5975
6028
|
] : i === "point" && (o.data.features = [
|
|
5976
6029
|
...o.data.features = o.data.features.filter(
|
|
5977
6030
|
(l) => !(n.includes(l.id) && l.geometry.type === "Point")
|
|
5978
6031
|
),
|
|
5979
|
-
...
|
|
6032
|
+
...r
|
|
5980
6033
|
]);
|
|
5981
6034
|
const a = {};
|
|
5982
6035
|
o.data.features.forEach((l) => {
|
|
@@ -6065,9 +6118,9 @@ class Ho extends Je {
|
|
|
6065
6118
|
let i = !1;
|
|
6066
6119
|
for (const o of e.data.features)
|
|
6067
6120
|
if (o.properties?.elevation !== void 0) {
|
|
6068
|
-
const
|
|
6121
|
+
const r = o.properties.elevationUnit;
|
|
6069
6122
|
let n = o.properties.elevation;
|
|
6070
|
-
(
|
|
6123
|
+
(r === "ft" || r === "foot") && (n = n / 3.28084);
|
|
6071
6124
|
const { elevation: a, unit: l } = pt(
|
|
6072
6125
|
n,
|
|
6073
6126
|
this.measureUnitType,
|
|
@@ -6086,23 +6139,23 @@ class Ho extends Je {
|
|
|
6086
6139
|
if (!this.map) return;
|
|
6087
6140
|
const e = this.getTerraDrawInstance();
|
|
6088
6141
|
if (!e) return;
|
|
6089
|
-
let o = e.getSnapshot()?.find((
|
|
6142
|
+
let o = e.getSnapshot()?.find((r) => r.id === t && r.geometry.type === "Polygon");
|
|
6090
6143
|
if (o) {
|
|
6091
|
-
const
|
|
6092
|
-
if (
|
|
6093
|
-
typeof
|
|
6144
|
+
const r = this.map.getStyle().sources[this.measureOptions.polygonLayerSpec.source];
|
|
6145
|
+
if (r) {
|
|
6146
|
+
typeof r.data != "string" && r.data.type === "FeatureCollection" && (r.data.features = r.data.features.filter(
|
|
6094
6147
|
(a) => a.properties?.originalId !== t
|
|
6095
6148
|
));
|
|
6096
6149
|
const n = JSON.parse(JSON.stringify(o));
|
|
6097
|
-
n.id = n.id + "-area-label", n.geometry =
|
|
6150
|
+
n.id = n.id + "-area-label", n.geometry = Uo(o.geometry).geometry, n.properties.originalId = o.id, o = ve(
|
|
6098
6151
|
o,
|
|
6099
6152
|
this.measureUnitType,
|
|
6100
6153
|
this.areaPrecision,
|
|
6101
6154
|
this.forceAreaUnit,
|
|
6102
6155
|
this.measureUnitSymbols
|
|
6103
|
-
), n.properties.area = o.properties.area, n.properties.unit = o.properties.unit, typeof
|
|
6156
|
+
), n.properties.area = o.properties.area, n.properties.unit = o.properties.unit, typeof r.data != "string" && r.data.type === "FeatureCollection" && r.data.features.push(n), this.map.getSource(
|
|
6104
6157
|
this.measureOptions.polygonLayerSpec.source
|
|
6105
|
-
)?.setData(
|
|
6158
|
+
)?.setData(r.data), this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && this.map.moveLayer(
|
|
6106
6159
|
this.measureOptions.lineLayerLabelSpec.id
|
|
6107
6160
|
), this.map.getLayer(
|
|
6108
6161
|
this.measureOptions.routingLineLayerNodeSpec.id
|
|
@@ -6124,11 +6177,11 @@ class Ho extends Je {
|
|
|
6124
6177
|
if (!this.map) return;
|
|
6125
6178
|
const e = this.getTerraDrawInstance();
|
|
6126
6179
|
if (!e) return;
|
|
6127
|
-
let o = e.getSnapshot()?.find((
|
|
6180
|
+
let o = e.getSnapshot()?.find((r) => r.id === t && r.geometry.type === "LineString");
|
|
6128
6181
|
if (o) {
|
|
6129
|
-
const
|
|
6130
|
-
if (
|
|
6131
|
-
typeof
|
|
6182
|
+
const r = this.map.getStyle().sources[this.measureOptions.lineLayerLabelSpec.source];
|
|
6183
|
+
if (r) {
|
|
6184
|
+
typeof r.data != "string" && r.data.type === "FeatureCollection" && (r.data.features = r.data.features.filter(
|
|
6132
6185
|
(a) => a.properties?.originalId !== t
|
|
6133
6186
|
)), o = Pe(
|
|
6134
6187
|
o,
|
|
@@ -6148,17 +6201,17 @@ class Ho extends Je {
|
|
|
6148
6201
|
p.id = `${l.id}-node-${a}`, p.geometry = {
|
|
6149
6202
|
type: "Point",
|
|
6150
6203
|
coordinates: c
|
|
6151
|
-
}, p.properties.distance = 0, p.properties.total = 0, l.properties.elevation_start && (p.properties.elevation = l.properties.elevation_start), typeof
|
|
6204
|
+
}, p.properties.distance = 0, p.properties.total = 0, l.properties.elevation_start && (p.properties.elevation = l.properties.elevation_start), typeof r.data != "string" && r.data.type === "FeatureCollection" && r.data.features.push(p);
|
|
6152
6205
|
}
|
|
6153
6206
|
const u = JSON.parse(JSON.stringify(l));
|
|
6154
6207
|
u.id = `${l.id}-node-${a + 1}`, u.geometry = {
|
|
6155
6208
|
type: "Point",
|
|
6156
6209
|
coordinates: h
|
|
6157
|
-
}, l.properties.elevation_end && (u.properties.elevation = l.properties.elevation_end), typeof
|
|
6210
|
+
}, l.properties.elevation_end && (u.properties.elevation = l.properties.elevation_end), typeof r.data != "string" && r.data.type === "FeatureCollection" && r.data.features.push(u);
|
|
6158
6211
|
}
|
|
6159
6212
|
this.map.getSource(
|
|
6160
6213
|
this.measureOptions.lineLayerLabelSpec.source
|
|
6161
|
-
)?.setData(
|
|
6214
|
+
)?.setData(r.data), this.map.getLayer(this.measureOptions.polygonLayerSpec.id) && this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.moveLayer(this.measureOptions.lineLayerLabelSpec.id), this.map.moveLayer(
|
|
6162
6215
|
this.measureOptions.routingLineLayerNodeSpec.id
|
|
6163
6216
|
), this.map.getLayer(
|
|
6164
6217
|
this.measureOptions.pointLayerLabelSpec.id
|
|
@@ -6176,19 +6229,19 @@ class Ho extends Je {
|
|
|
6176
6229
|
if (!this.map) return;
|
|
6177
6230
|
const e = this.getTerraDrawInstance();
|
|
6178
6231
|
if (!e) return;
|
|
6179
|
-
let o = e.getSnapshot()?.find((
|
|
6232
|
+
let o = e.getSnapshot()?.find((r) => r.id === t && r.geometry.type === "Point");
|
|
6180
6233
|
if (o) {
|
|
6181
|
-
const
|
|
6182
|
-
|
|
6234
|
+
const r = this.map.getStyle().sources[this.measureOptions.pointLayerLabelSpec.source];
|
|
6235
|
+
r && (typeof r.data != "string" && r.data.type === "FeatureCollection" && (r.data.features = r.data.features.filter((n) => n.id !== t)), o = Ie(
|
|
6183
6236
|
o,
|
|
6184
6237
|
this.map,
|
|
6185
6238
|
this.computeElevation,
|
|
6186
6239
|
this.measureOptions.terrainSource,
|
|
6187
6240
|
this.measureUnitType,
|
|
6188
6241
|
this.measureUnitSymbols
|
|
6189
|
-
), this.computeElevation === !0 && typeof
|
|
6242
|
+
), this.computeElevation === !0 && typeof r.data != "string" && r.data.type === "FeatureCollection" && r.data.features.push(o), this.map.getSource(
|
|
6190
6243
|
this.measureOptions.pointLayerLabelSpec.source
|
|
6191
|
-
)?.setData(
|
|
6244
|
+
)?.setData(r.data), this.map.getLayer(this.measureOptions.polygonLayerSpec.id) && this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && (this.map.moveLayer(
|
|
6192
6245
|
this.measureOptions.lineLayerLabelSpec.id
|
|
6193
6246
|
), this.map.moveLayer(
|
|
6194
6247
|
this.measureOptions.routingLineLayerNodeSpec.id
|
|
@@ -6205,13 +6258,13 @@ class Ho extends Je {
|
|
|
6205
6258
|
if (this.getTerraDrawInstance()) {
|
|
6206
6259
|
let i = [];
|
|
6207
6260
|
typeof t == "object" && t !== null && "deletedIds" in t && (i = t.deletedIds);
|
|
6208
|
-
const
|
|
6261
|
+
const r = [
|
|
6209
6262
|
this.measureOptions.pointLayerLabelSpec,
|
|
6210
6263
|
this.measureOptions.lineLayerLabelSpec,
|
|
6211
6264
|
this.measureOptions.routingLineLayerNodeSpec,
|
|
6212
6265
|
this.measureOptions.polygonLayerSpec
|
|
6213
6266
|
].map((n) => n.source);
|
|
6214
|
-
i && i.length > 0 ? this.clearExtendedFeatures(
|
|
6267
|
+
i && i.length > 0 ? this.clearExtendedFeatures(r, i) : this.clearExtendedFeatures(r, void 0);
|
|
6215
6268
|
}
|
|
6216
6269
|
}
|
|
6217
6270
|
/**
|
|
@@ -6225,8 +6278,8 @@ class Ho extends Je {
|
|
|
6225
6278
|
for (let i = 0; i < e.features.length; i++) {
|
|
6226
6279
|
const o = e.features[i];
|
|
6227
6280
|
if (!this.map || !this.map.loaded()) continue;
|
|
6228
|
-
const
|
|
6229
|
-
|
|
6281
|
+
const r = o.geometry.type;
|
|
6282
|
+
r === "LineString" ? e.features[i] = Pe(
|
|
6230
6283
|
o,
|
|
6231
6284
|
this.measureUnitType,
|
|
6232
6285
|
this.distancePrecision,
|
|
@@ -6235,13 +6288,13 @@ class Ho extends Je {
|
|
|
6235
6288
|
this.map,
|
|
6236
6289
|
this.computeElevation,
|
|
6237
6290
|
this.measureOptions.terrainSource
|
|
6238
|
-
) :
|
|
6291
|
+
) : r === "Polygon" ? e.features[i] = ve(
|
|
6239
6292
|
o,
|
|
6240
6293
|
this.measureUnitType,
|
|
6241
6294
|
this.areaPrecision,
|
|
6242
6295
|
this.forceAreaUnit,
|
|
6243
6296
|
this.measureUnitSymbols
|
|
6244
|
-
) :
|
|
6297
|
+
) : r === "Point" && (e.features[i] = Ie(
|
|
6245
6298
|
o,
|
|
6246
6299
|
this.map,
|
|
6247
6300
|
this.computeElevation,
|
|
@@ -6253,7 +6306,7 @@ class Ho extends Je {
|
|
|
6253
6306
|
return e;
|
|
6254
6307
|
}
|
|
6255
6308
|
}
|
|
6256
|
-
class Zo extends
|
|
6309
|
+
class Zo extends He {
|
|
6257
6310
|
controlOptions;
|
|
6258
6311
|
valhallaOptions;
|
|
6259
6312
|
_modalDialog;
|
|
@@ -6451,8 +6504,8 @@ class Zo extends Je {
|
|
|
6451
6504
|
cleanStyle(t, e) {
|
|
6452
6505
|
const i = it, o = this.controlOptions.routingLineLayerNodeSpec?.source;
|
|
6453
6506
|
o && i.push(o);
|
|
6454
|
-
const
|
|
6455
|
-
return
|
|
6507
|
+
const r = this.controlOptions.isochronePolygonLayerSpec?.source;
|
|
6508
|
+
return r && i.push(r), Yt(t, e, i, this.options.adapterOptions?.prefixId);
|
|
6456
6509
|
}
|
|
6457
6510
|
/**
|
|
6458
6511
|
* Create the settings dialog for Valhalla control
|
|
@@ -6472,10 +6525,10 @@ class Zo extends Je {
|
|
|
6472
6525
|
o.type = "button", o.classList.add("tab-button", "active"), o.textContent = "Routing", o.addEventListener("click", (d) => {
|
|
6473
6526
|
d.stopPropagation(), this.switchTab("routing", i, n);
|
|
6474
6527
|
}), i.appendChild(o);
|
|
6475
|
-
const
|
|
6476
|
-
|
|
6528
|
+
const r = document.createElement("button");
|
|
6529
|
+
r.type = "button", r.classList.add("tab-button"), r.textContent = "Isochrone", r.addEventListener("click", (d) => {
|
|
6477
6530
|
d.stopPropagation(), this.switchTab("isochrone", i, n);
|
|
6478
|
-
}), i.appendChild(
|
|
6531
|
+
}), i.appendChild(r), e.appendChild(i);
|
|
6479
6532
|
const n = document.createElement("div");
|
|
6480
6533
|
n.classList.add("tab-contents");
|
|
6481
6534
|
const a = this.createRoutingContent();
|
|
@@ -6509,8 +6562,8 @@ class Zo extends Je {
|
|
|
6509
6562
|
), t.appendChild(e);
|
|
6510
6563
|
const o = document.createElement("div");
|
|
6511
6564
|
o.classList.add("setting-section");
|
|
6512
|
-
const
|
|
6513
|
-
return
|
|
6565
|
+
const r = document.createElement("label");
|
|
6566
|
+
return r.textContent = "Distance Unit", r.classList.add("setting-label"), o.appendChild(r), o.appendChild(
|
|
6514
6567
|
this.settingDialog.createSegmentButtons(
|
|
6515
6568
|
jo,
|
|
6516
6569
|
this.routingDistanceUnit,
|
|
@@ -6538,8 +6591,8 @@ class Zo extends Je {
|
|
|
6538
6591
|
), t.appendChild(e);
|
|
6539
6592
|
const o = document.createElement("div");
|
|
6540
6593
|
o.classList.add("setting-section");
|
|
6541
|
-
const
|
|
6542
|
-
|
|
6594
|
+
const r = document.createElement("label");
|
|
6595
|
+
r.textContent = "Means of Transport", r.classList.add("setting-label"), o.appendChild(r), o.appendChild(
|
|
6543
6596
|
this.settingDialog.createSegmentButtons(
|
|
6544
6597
|
jt,
|
|
6545
6598
|
this.controlOptions.valhallaOptions?.isochroneOptions?.costingModel || "auto",
|
|
@@ -6563,8 +6616,8 @@ class Zo extends Je {
|
|
|
6563
6616
|
t.classList.add("contours-table");
|
|
6564
6617
|
const e = document.createElement("table");
|
|
6565
6618
|
e.classList.add("contours-table-element");
|
|
6566
|
-
const i = document.createElement("thead"), o = document.createElement("tr"),
|
|
6567
|
-
|
|
6619
|
+
const i = document.createElement("thead"), o = document.createElement("tr"), r = document.createElement("th");
|
|
6620
|
+
r.textContent = "Color", o.appendChild(r);
|
|
6568
6621
|
const n = document.createElement("th");
|
|
6569
6622
|
n.textContent = "Time (min)", o.appendChild(n);
|
|
6570
6623
|
const a = document.createElement("th");
|
|
@@ -6589,10 +6642,10 @@ class Zo extends Je {
|
|
|
6589
6642
|
createContourRow(t, e) {
|
|
6590
6643
|
const i = document.createElement("tr");
|
|
6591
6644
|
i.setAttribute("data-index", e.toString());
|
|
6592
|
-
const o = document.createElement("td"),
|
|
6593
|
-
|
|
6645
|
+
const o = document.createElement("td"), r = document.createElement("input");
|
|
6646
|
+
r.type = "color", r.value = t.color, r.classList.add("color-picker"), r.addEventListener("change", (h) => {
|
|
6594
6647
|
h.stopPropagation(), this.valhallaOptions.isochroneOptions?.contours && (this.valhallaOptions.isochroneOptions.contours[e].color = h.target.value, this.dispatchEvent("setting-changed"));
|
|
6595
|
-
}), o.appendChild(
|
|
6648
|
+
}), o.appendChild(r), i.appendChild(o);
|
|
6596
6649
|
const n = document.createElement("td"), a = document.createElement("input");
|
|
6597
6650
|
a.type = "number", a.value = t.time.toString(), a.min = "1", a.classList.add("number-input"), a.addEventListener("change", (h) => {
|
|
6598
6651
|
h.stopPropagation(), this.valhallaOptions.isochroneOptions?.contours && (this.valhallaOptions.isochroneOptions.contours[e].time = parseFloat(
|
|
@@ -6767,21 +6820,21 @@ class Zo extends Je {
|
|
|
6767
6820
|
if (!e || e && e.geometry.type !== "LineString") return;
|
|
6768
6821
|
const i = new Ao(this.valhallaUrl), o = e.geometry.coordinates.map((c) => {
|
|
6769
6822
|
const h = c;
|
|
6770
|
-
return new
|
|
6823
|
+
return new Je(h[0], h[1]);
|
|
6771
6824
|
});
|
|
6772
6825
|
if (!o || o && o.length < 2) return;
|
|
6773
|
-
const
|
|
6826
|
+
const r = await i.calcRoute(
|
|
6774
6827
|
o,
|
|
6775
6828
|
this.routingCostingModel,
|
|
6776
6829
|
this.routingDistanceUnit
|
|
6777
6830
|
);
|
|
6778
|
-
if (!
|
|
6779
|
-
const n =
|
|
6831
|
+
if (!r || !r.feature) return;
|
|
6832
|
+
const n = r?.feature.geometry;
|
|
6780
6833
|
this.terradraw?.updateFeatureGeometry(t, n), e.geometry = n, e.properties = {
|
|
6781
6834
|
...e.properties,
|
|
6782
|
-
...
|
|
6783
|
-
}, this.terradraw?.updateFeatureProperties(t,
|
|
6784
|
-
const l = (
|
|
6835
|
+
...r?.feature.properties
|
|
6836
|
+
}, this.terradraw?.updateFeatureProperties(t, r?.feature.properties);
|
|
6837
|
+
const l = (r?.pointFeatures).features.map((c) => (c.id = `${t}-${c.id}`, c.properties.originalId = t, c)), d = this.map.getStyle().sources[this.controlOptions.routingLineLayerNodeSpec.source];
|
|
6785
6838
|
d && (typeof d.data != "string" && d.data.type === "FeatureCollection" && (d.data.features = d.data.features.filter(
|
|
6786
6839
|
(c) => c.properties?.originalId !== t
|
|
6787
6840
|
)), typeof d.data != "string" && d.data.type === "FeatureCollection" && d.data.features.push(...l), this.map.getSource(
|
|
@@ -6800,11 +6853,11 @@ class Zo extends Je {
|
|
|
6800
6853
|
if (this.getTerraDrawInstance()) {
|
|
6801
6854
|
let i = [];
|
|
6802
6855
|
typeof t == "object" && t !== null && "deletedIds" in t && (i = t.deletedIds);
|
|
6803
|
-
const
|
|
6856
|
+
const r = [
|
|
6804
6857
|
this.controlOptions.routingLineLayerNodeSpec,
|
|
6805
6858
|
this.controlOptions.isochronePolygonLayerSpec
|
|
6806
6859
|
].map((n) => n.source);
|
|
6807
|
-
i && i.length > 0 ? this.clearExtendedFeatures(
|
|
6860
|
+
i && i.length > 0 ? this.clearExtendedFeatures(r, i) : this.clearExtendedFeatures(r, void 0);
|
|
6808
6861
|
}
|
|
6809
6862
|
}
|
|
6810
6863
|
/**
|
|
@@ -6815,31 +6868,35 @@ class Zo extends Je {
|
|
|
6815
6868
|
getFeatures(t = !1) {
|
|
6816
6869
|
const e = super.getFeatures(t);
|
|
6817
6870
|
if (!e || !this.terradraw || !this.map) return e;
|
|
6818
|
-
const i = this.map.getStyle()
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6871
|
+
const i = this.map.getStyle();
|
|
6872
|
+
if (!i || !i.sources) return e;
|
|
6873
|
+
const o = this.controlOptions.isochronePolygonLayerSpec.source;
|
|
6874
|
+
if (!o || !i.sources[o]) return e;
|
|
6875
|
+
const r = i.sources[o], n = [];
|
|
6876
|
+
for (let a = 0; a < e.features.length; a++) {
|
|
6877
|
+
const l = e.features[a];
|
|
6878
|
+
if (l.geometry.type === "Point") {
|
|
6879
|
+
const c = l.id;
|
|
6880
|
+
if (r && typeof r.data != "string" && r.data.type === "FeatureCollection") {
|
|
6881
|
+
const h = r.data.features.filter(
|
|
6882
|
+
(u) => u.properties?.originalId === c
|
|
6826
6883
|
);
|
|
6827
|
-
|
|
6884
|
+
n.push(l), h.length > 0 && n.push(...h);
|
|
6828
6885
|
}
|
|
6829
6886
|
} else
|
|
6830
|
-
|
|
6887
|
+
n.push(l);
|
|
6831
6888
|
}
|
|
6832
6889
|
return {
|
|
6833
6890
|
type: "FeatureCollection",
|
|
6834
|
-
features:
|
|
6891
|
+
features: n
|
|
6835
6892
|
};
|
|
6836
6893
|
}
|
|
6837
6894
|
}
|
|
6838
6895
|
export {
|
|
6839
6896
|
Yo as AvailableModes,
|
|
6840
6897
|
Ko as AvailableValhallaModes,
|
|
6841
|
-
|
|
6842
|
-
|
|
6898
|
+
Jo as MaplibreMeasureControl,
|
|
6899
|
+
He as MaplibreTerradrawControl,
|
|
6843
6900
|
Zo as MaplibreValhallaControl,
|
|
6844
6901
|
Ye as MemoryCache,
|
|
6845
6902
|
Co as ModalDialog,
|
|
@@ -6860,12 +6917,12 @@ export {
|
|
|
6860
6917
|
$e as debounce,
|
|
6861
6918
|
oo as defaultControlOptions,
|
|
6862
6919
|
dt as defaultMeasureControlOptions,
|
|
6863
|
-
|
|
6920
|
+
H as defaultMeasureUnitSymbols,
|
|
6864
6921
|
z as defaultValhallaControlOptions,
|
|
6865
|
-
|
|
6922
|
+
ro as getDefaultModeOptions,
|
|
6866
6923
|
Ie as queryElevationByPoint,
|
|
6867
6924
|
xe as queryElevationFromRasterDEM,
|
|
6868
|
-
|
|
6925
|
+
Ho as roundFeatureCoordinates,
|
|
6869
6926
|
jo as routingDistanceUnitOptions
|
|
6870
6927
|
};
|
|
6871
6928
|
//# sourceMappingURL=maplibre-gl-terradraw.es.js.map
|