@watergis/maplibre-gl-terradraw 1.7.4 → 1.7.6
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 +638 -567
- 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/constants/defaultMeasureControlOptions.d.ts.map +1 -1
- package/dist/types/controls/MaplibreMeasureControl.d.ts +3 -1
- package/dist/types/controls/MaplibreMeasureControl.d.ts.map +1 -1
- package/dist/types/helpers/calcDistance.d.ts +2 -2
- package/dist/types/helpers/calcDistance.d.ts.map +1 -1
- package/dist/types/helpers/convertDistance.d.ts +6 -0
- package/dist/types/helpers/convertDistance.d.ts.map +1 -0
- package/dist/types/helpers/index.d.ts +1 -2
- package/dist/types/helpers/index.d.ts.map +1 -1
- package/dist/types/interfaces/DistanceUnit.d.ts +4 -0
- package/dist/types/interfaces/DistanceUnit.d.ts.map +1 -1
- package/dist/types/interfaces/MeasureControlOptions.d.ts +2 -1
- package/dist/types/interfaces/MeasureControlOptions.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/types/helpers/convertMetricDistance.d.ts +0 -5
- package/dist/types/helpers/convertMetricDistance.d.ts.map +0 -1
- package/dist/types/helpers/getDistanceUnitName.d.ts +0 -3
- package/dist/types/helpers/getDistanceUnitName.d.ts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LngLat as
|
|
1
|
+
import { LngLat as He } from "maplibre-gl";
|
|
2
2
|
function x() {
|
|
3
3
|
return x = Object.assign ? Object.assign.bind() : function(r) {
|
|
4
4
|
for (var t = 1; t < arguments.length; t++) {
|
|
@@ -13,23 +13,23 @@ var b;
|
|
|
13
13
|
r.Commit = "commit", r.Provisional = "provisional", r.Finish = "finish";
|
|
14
14
|
})(b || (b = {}));
|
|
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
|
|
16
|
+
function Et(r) {
|
|
17
17
|
return !!(r && typeof r == "object" && r !== null && !Array.isArray(r));
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function Zt(r) {
|
|
20
20
|
return !!(r && typeof r == "object" && "properties" in r && typeof r.properties == "object" && r.properties !== null && "mode" in r.properties);
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function Qt(r) {
|
|
23
23
|
return !!(function(t) {
|
|
24
24
|
return typeof t == "number" && !isNaN(new Date(t).valueOf());
|
|
25
25
|
})(r);
|
|
26
26
|
}
|
|
27
|
-
const
|
|
27
|
+
const Je = "Feature mode property does not match the mode being added to";
|
|
28
28
|
var H;
|
|
29
29
|
(function(r) {
|
|
30
30
|
r.Drawing = "drawing", r.Select = "select", r.Static = "static", r.Render = "render";
|
|
31
31
|
})(H || (H = {}));
|
|
32
|
-
const
|
|
32
|
+
const qe = { rightClick: !0, contextMenu: !1, leftClick: !0, onDragStart: !0, onDrag: !0, onDragEnd: !0 };
|
|
33
33
|
class A {
|
|
34
34
|
get state() {
|
|
35
35
|
return this._state;
|
|
@@ -47,7 +47,7 @@ class A {
|
|
|
47
47
|
registerBehaviors(t) {
|
|
48
48
|
}
|
|
49
49
|
constructor(t, e = !1) {
|
|
50
|
-
this._state = "unregistered", this._styles = {}, this.pointerEvents =
|
|
50
|
+
this._state = "unregistered", this._styles = {}, this.pointerEvents = qe, this.behaviors = [], this.validate = void 0, this.pointerDistance = 40, this.coordinatePrecision = void 0, this.onStyleChange = void 0, this.store = void 0, this.projection = "web-mercator", this.setDoubleClickToZoom = void 0, this.unproject = void 0, this.project = void 0, this.setCursor = void 0, this.type = H.Drawing, this.mode = "base", e || this.updateOptions(t);
|
|
51
51
|
}
|
|
52
52
|
updateOptions(t) {
|
|
53
53
|
t != null && t.styles && (this.styles = x({}, this._styles, t.styles)), t != null && t.pointerDistance && (this.pointerDistance = t.pointerDistance), t != null && t.validation && (this.validate = t && t.validation), t != null && t.projection && (this.projection = t.projection), t?.pointerEvents !== void 0 && (this.pointerEvents = t.pointerEvents);
|
|
@@ -82,9 +82,9 @@ class A {
|
|
|
82
82
|
if (this._state === "unregistered") throw new Error("Mode must be registered");
|
|
83
83
|
const e = (function(i, o) {
|
|
84
84
|
let s;
|
|
85
|
-
if (
|
|
85
|
+
if (Et(i)) if (i.id == null) s = "Feature has no id";
|
|
86
86
|
else if (typeof i.id != "string" && typeof i.id != "number") s = "Feature must be string or number as per GeoJSON spec";
|
|
87
|
-
else if (o(i.id)) if (
|
|
87
|
+
else if (o(i.id)) if (Et(i.geometry)) if (Et(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
89
|
} else s = "Feature coordinates is not an array";
|
|
90
90
|
else s = "Feature is not Point, LineString or Polygon";
|
|
@@ -102,7 +102,7 @@ class A {
|
|
|
102
102
|
}
|
|
103
103
|
validateModeFeature(t, e) {
|
|
104
104
|
const i = this.performFeatureValidation(t);
|
|
105
|
-
return i.valid ? t.properties.mode !== this.mode ? { valid: !1, reason:
|
|
105
|
+
return i.valid ? t.properties.mode !== this.mode ? { valid: !1, reason: Je } : e(t) : { valid: !1, reason: i.reason };
|
|
106
106
|
}
|
|
107
107
|
onFinish(t, e) {
|
|
108
108
|
}
|
|
@@ -134,7 +134,7 @@ class A {
|
|
|
134
134
|
return t === void 0 ? e : typeof t == "function" ? t(i) : t;
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
let
|
|
137
|
+
let Ze = class extends A {
|
|
138
138
|
constructor(...t) {
|
|
139
139
|
super(...t), this.type = H.Select;
|
|
140
140
|
}
|
|
@@ -143,11 +143,11 @@ function U(r, t) {
|
|
|
143
143
|
const e = (d) => d * Math.PI / 180, i = e(r[1]), o = e(r[0]), s = e(t[1]), n = s - i, a = e(t[0]) - o, l = Math.sin(n / 2) * Math.sin(n / 2) + Math.cos(i) * Math.cos(s) * Math.sin(a / 2) * Math.sin(a / 2);
|
|
144
144
|
return 2 * Math.atan2(Math.sqrt(l), Math.sqrt(1 - l)) * 6371e3 / 1e3;
|
|
145
145
|
}
|
|
146
|
-
const
|
|
146
|
+
const Ie = 63710088e-1;
|
|
147
147
|
function D(r) {
|
|
148
148
|
return r % 360 * Math.PI / 180;
|
|
149
149
|
}
|
|
150
|
-
function
|
|
150
|
+
function xe(r) {
|
|
151
151
|
return r / 6371.0088;
|
|
152
152
|
}
|
|
153
153
|
function V(r) {
|
|
@@ -157,20 +157,20 @@ function w(r, t = 9) {
|
|
|
157
157
|
const e = Math.pow(10, t);
|
|
158
158
|
return Math.round(r * e) / e;
|
|
159
159
|
}
|
|
160
|
-
const
|
|
161
|
-
function
|
|
162
|
-
const i = D(r[0]), o = D(r[1]), s = D(e), n =
|
|
160
|
+
const te = 57.29577951308232, ee = 0.017453292519943295, St = 6378137, O = (r, t) => ({ x: r === 0 ? 0 : r * ee * St, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * ee / 2)) * St }), R = (r, t) => ({ lng: r === 0 ? 0 : te * (r / St), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / St)) - Math.PI / 2) * te });
|
|
161
|
+
function Qe(r, t, e) {
|
|
162
|
+
const i = D(r[0]), o = D(r[1]), s = D(e), n = xe(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(s));
|
|
163
163
|
return [V(i + Math.atan2(Math.sin(s) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), V(a)];
|
|
164
164
|
}
|
|
165
|
-
function
|
|
165
|
+
function ie(r) {
|
|
166
166
|
const { center: t, radiusKilometers: e, coordinatePrecision: i } = r, o = r.steps ? r.steps : 64, s = [];
|
|
167
167
|
for (let n = 0; n < o; n++) {
|
|
168
|
-
const a =
|
|
168
|
+
const a = Qe(t, e, -360 * n / o);
|
|
169
169
|
s.push([w(a[0], i), w(a[1], i)]);
|
|
170
170
|
}
|
|
171
171
|
return s.push(s[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [s] }, properties: {} };
|
|
172
172
|
}
|
|
173
|
-
function
|
|
173
|
+
function Bt(r) {
|
|
174
174
|
let t;
|
|
175
175
|
if (r.geometry.type === "Polygon") t = r.geometry.coordinates;
|
|
176
176
|
else {
|
|
@@ -184,51 +184,51 @@ function Tt(r) {
|
|
|
184
184
|
return s < 0 || s > 1;
|
|
185
185
|
}
|
|
186
186
|
function o(s, n, a, l) {
|
|
187
|
-
const d = t[s][n], c = t[s][n + 1], h = t[a][l],
|
|
187
|
+
const d = t[s][n], c = t[s][n + 1], h = t[a][l], u = t[a][l + 1], p = (function(m, v, C, f) {
|
|
188
188
|
if (gt(m, C) || gt(m, f) || gt(v, C) || gt(f, C)) return null;
|
|
189
189
|
const P = m[0], I = m[1], E = v[0], L = v[1], M = C[0], N = C[1], _ = f[0], T = f[1], $ = (P - E) * (N - T) - (I - L) * (M - _);
|
|
190
190
|
return $ === 0 ? null : [((P * L - I * E) * (M - _) - (P - E) * (M * T - N * _)) / $, ((P * L - I * E) * (N - T) - (I - L) * (M * T - N * _)) / $];
|
|
191
|
-
})(d, c, h,
|
|
192
|
-
if (
|
|
191
|
+
})(d, c, h, u);
|
|
192
|
+
if (p === null) return;
|
|
193
193
|
let g, y;
|
|
194
|
-
g = c[0] !== d[0] ? (
|
|
194
|
+
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
195
|
}
|
|
196
196
|
}
|
|
197
197
|
function gt(r, t) {
|
|
198
198
|
return r[0] === t[0] && r[1] === t[1];
|
|
199
199
|
}
|
|
200
|
-
function
|
|
201
|
-
return
|
|
200
|
+
function Ot(r, t) {
|
|
201
|
+
return oe(r[0]) <= t && oe(r[1]) <= t;
|
|
202
202
|
}
|
|
203
|
-
function
|
|
203
|
+
function jt(r) {
|
|
204
204
|
return r.length === 2 && typeof r[0] == "number" && typeof r[1] == "number" && r[0] !== 1 / 0 && r[1] !== 1 / 0 && (e = r[0]) >= -180 && e <= 180 && (t = r[1]) >= -90 && t <= 90;
|
|
205
205
|
var t, e;
|
|
206
206
|
}
|
|
207
|
-
function
|
|
207
|
+
function oe(r) {
|
|
208
208
|
let t = 1, e = 0;
|
|
209
209
|
for (; Math.round(r * t) / t !== r; ) t *= 10, e++;
|
|
210
210
|
return e;
|
|
211
211
|
}
|
|
212
|
-
const
|
|
213
|
-
function
|
|
212
|
+
const ti = "Feature has holes", ei = "Feature has less than 4 coordinates", ii = "Feature has invalid coordinates", oi = "Feature coordinates are not closed";
|
|
213
|
+
function bt(r, t) {
|
|
214
214
|
if (r.geometry.type !== "Polygon") return { valid: !1, reason: "Feature is not a Polygon" };
|
|
215
|
-
if (r.geometry.coordinates.length !== 1) return { valid: !1, reason:
|
|
216
|
-
if (r.geometry.coordinates[0].length < 4) return { valid: !1, reason:
|
|
215
|
+
if (r.geometry.coordinates.length !== 1) return { valid: !1, reason: ti };
|
|
216
|
+
if (r.geometry.coordinates[0].length < 4) return { valid: !1, reason: ei };
|
|
217
217
|
for (let o = 0; o < r.geometry.coordinates[0].length; o++) {
|
|
218
|
-
if (!
|
|
219
|
-
if (!
|
|
218
|
+
if (!jt(r.geometry.coordinates[0][o])) return { valid: !1, reason: ii };
|
|
219
|
+
if (!Ot(r.geometry.coordinates[0][o], t)) return { valid: !1, reason: "Feature has coordinates with excessive precision" };
|
|
220
220
|
}
|
|
221
|
-
return (e = r.geometry.coordinates[0][0])[0] !== (i = r.geometry.coordinates[0][r.geometry.coordinates[0].length - 1])[0] || e[1] !== i[1] ? { valid: !1, reason:
|
|
221
|
+
return (e = r.geometry.coordinates[0][0])[0] !== (i = r.geometry.coordinates[0][r.geometry.coordinates[0].length - 1])[0] || e[1] !== i[1] ? { valid: !1, reason: oi } : { valid: !0 };
|
|
222
222
|
var e, i;
|
|
223
223
|
}
|
|
224
224
|
function ut(r, t) {
|
|
225
|
-
const e =
|
|
226
|
-
return e.valid ?
|
|
225
|
+
const e = bt(r, t);
|
|
226
|
+
return e.valid ? Bt(r) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
|
|
227
227
|
}
|
|
228
|
-
const
|
|
229
|
-
let
|
|
228
|
+
const si = { cancel: "Escape", finish: "Enter" }, ri = { start: "crosshair" };
|
|
229
|
+
let Oe = class extends A {
|
|
230
230
|
constructor(t) {
|
|
231
|
-
super(t, !0), this.mode = "circle", this.center = void 0, this.clickCount = 0, this.currentCircleId = void 0, this.keyEvents =
|
|
231
|
+
super(t, !0), this.mode = "circle", this.center = void 0, this.clickCount = 0, this.currentCircleId = void 0, this.keyEvents = si, this.cursors = ri, this.startingRadiusKilometers = 1e-5, this.cursorMovedAfterInitialCursorDown = !1, this.updateOptions(t);
|
|
232
232
|
}
|
|
233
233
|
updateOptions(t) {
|
|
234
234
|
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.startingRadiusKilometers && (this.startingRadiusKilometers = t.startingRadiusKilometers);
|
|
@@ -252,7 +252,7 @@ let xe = class extends A {
|
|
|
252
252
|
onClick(t) {
|
|
253
253
|
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
254
|
this.center = [t.lng, t.lat];
|
|
255
|
-
const e =
|
|
255
|
+
const e = ie({ 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
256
|
this.currentCircleId = i, this.clickCount++, this.cursorMovedAfterInitialCursorDown = !1, this.setDrawing();
|
|
257
257
|
} else this.clickCount === 1 && this.center && this.currentCircleId !== void 0 && this.cursorMovedAfterInitialCursorDown && this.updateCircle(t), this.close();
|
|
258
258
|
}
|
|
@@ -297,16 +297,16 @@ let xe = class extends A {
|
|
|
297
297
|
return Math.sqrt(Math.pow(c - l, 2) + Math.pow(h - d, 2)) / a;
|
|
298
298
|
})(this.center, [t.lng, t.lat]);
|
|
299
299
|
i = (function(s) {
|
|
300
|
-
const { center: n, radiusKilometers: a, coordinatePrecision: l } = s, d = s.steps ? s.steps : 64, c = 1e3 * a, [h,
|
|
300
|
+
const { center: n, radiusKilometers: a, coordinatePrecision: l } = s, d = s.steps ? s.steps : 64, c = 1e3 * a, [h, u] = n, { x: p, y: g } = O(h, u), y = [];
|
|
301
301
|
for (let m = 0; m < d; m++) {
|
|
302
|
-
const v = 360 * m / d * Math.PI / 180, C = c * Math.cos(v), f = c * Math.sin(v), [P, I] = [
|
|
302
|
+
const v = 360 * m / d * Math.PI / 180, C = c * Math.cos(v), f = c * Math.sin(v), [P, I] = [p + C, g + f], { lng: E, lat: L } = R(P, I);
|
|
303
303
|
y.push([w(E, l), w(L, l)]);
|
|
304
304
|
}
|
|
305
305
|
return y.push(y[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [y] }, properties: {} };
|
|
306
306
|
})({ center: this.center, radiusKilometers: e * o, coordinatePrecision: this.coordinatePrecision });
|
|
307
307
|
} else {
|
|
308
308
|
if (this.projection !== "globe") throw new Error("Invalid projection");
|
|
309
|
-
i =
|
|
309
|
+
i = ie({ center: this.center, radiusKilometers: e, coordinatePrecision: this.coordinatePrecision });
|
|
310
310
|
}
|
|
311
311
|
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: b.Provisional }).valid) return;
|
|
312
312
|
this.store.updateGeometry([{ id: this.currentCircleId, geometry: i.geometry }]), this.store.updateProperty([{ id: this.currentCircleId, property: "radiusKilometers", value: e }]);
|
|
@@ -331,10 +331,10 @@ function pt(r) {
|
|
|
331
331
|
return o < 0;
|
|
332
332
|
})(r)) return { type: "Polygon", coordinates: [r.coordinates[0].reverse()] };
|
|
333
333
|
}
|
|
334
|
-
const
|
|
335
|
-
class
|
|
334
|
+
const ni = { cancel: "Escape", finish: "Enter" }, ai = { start: "crosshair", close: "pointer" };
|
|
335
|
+
class be extends A {
|
|
336
336
|
constructor(t) {
|
|
337
|
-
super(t, !0), this.mode = "freehand", this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.minDistance = 20, this.keyEvents =
|
|
337
|
+
super(t, !0), this.mode = "freehand", this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.minDistance = 20, this.keyEvents = ni, this.cursors = ai, this.preventPointsNearClose = !0, this.autoClose = !1, this.autoCloseTimeout = 500, this.hasLeftStartingPoint = !1, this.preventNewFeature = !1, this.updateOptions(t);
|
|
338
338
|
}
|
|
339
339
|
updateOptions(t) {
|
|
340
340
|
super.updateOptions(t), t != null && t.minDistance && (this.minDistance = t.minDistance), t?.preventPointsNearClose !== void 0 && (this.preventPointsNearClose = t.preventPointsNearClose), t?.autoClose !== void 0 && (this.autoClose = t.autoClose), t != null && t.autoCloseTimeout && (this.autoCloseTimeout = t.autoCloseTimeout), t?.keyEvents === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = x({}, this.keyEvents, t.keyEvents)), t != null && t.cursors && (this.cursors = x({}, this.cursors, t.cursors));
|
|
@@ -360,16 +360,16 @@ class Oe extends A {
|
|
|
360
360
|
}
|
|
361
361
|
onMouseMove(t) {
|
|
362
362
|
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, s] = e.coordinates[0][i], { x: n, y: a } = this.project(o, s), l = F({ x: n, y: a }, { x: t.containerX, y: t.containerY }), [d, c] = e.coordinates[0][0], { x: h, y:
|
|
364
|
-
if (F({ x: h, y:
|
|
363
|
+
const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates[0].length - 2, [o, s] = e.coordinates[0][i], { x: n, y: a } = this.project(o, s), l = F({ x: n, y: a }, { x: t.containerX, y: t.containerY }), [d, c] = e.coordinates[0][0], { x: h, y: u } = this.project(d, c);
|
|
364
|
+
if (F({ x: h, y: u }, { x: t.containerX, y: t.containerY }) < this.pointerDistance) {
|
|
365
365
|
if (this.autoClose && this.hasLeftStartingPoint && (this.preventNewFeature = !0, setTimeout(() => {
|
|
366
366
|
this.preventNewFeature = !1;
|
|
367
367
|
}, this.autoCloseTimeout), this.close()), this.setCursor(this.cursors.close), this.preventPointsNearClose) return;
|
|
368
368
|
} else this.hasLeftStartingPoint = !0, this.setCursor(this.cursors.start);
|
|
369
369
|
if (l < this.minDistance) return;
|
|
370
370
|
e.coordinates[0].pop();
|
|
371
|
-
const
|
|
372
|
-
this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry:
|
|
371
|
+
const p = { type: "Polygon", coordinates: [[...e.coordinates[0], [t.lng, t.lat], e.coordinates[0][0]]] };
|
|
372
|
+
this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: p, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Provisional }).valid || this.store.updateGeometry([{ id: this.currentId, geometry: p }]);
|
|
373
373
|
}
|
|
374
374
|
onClick(t) {
|
|
375
375
|
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)) {
|
|
@@ -405,7 +405,7 @@ class Oe extends A {
|
|
|
405
405
|
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
406
|
}
|
|
407
407
|
validateFeature(t) {
|
|
408
|
-
return this.validateModeFeature(t, (e) =>
|
|
408
|
+
return this.validateModeFeature(t, (e) => bt(e, this.coordinatePrecision));
|
|
409
409
|
}
|
|
410
410
|
afterFeatureUpdated(t) {
|
|
411
411
|
this.currentId === t.id && (this.closingPointId && this.store.delete([this.closingPointId]), this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.hasLeftStartingPoint = !1);
|
|
@@ -416,7 +416,7 @@ let B = class {
|
|
|
416
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 = s, this.coordinatePrecision = n, this.projection = a;
|
|
417
417
|
}
|
|
418
418
|
};
|
|
419
|
-
function
|
|
419
|
+
function Ee({ unproject: r, point: t, pointerDistance: e }) {
|
|
420
420
|
const i = e / 2, { x: o, y: s } = t;
|
|
421
421
|
return { type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [[r(o - i, s - i), r(o + i, s - i), r(o + i, s + i), r(o - i, s + i), r(o - i, s - i)].map((n) => [n.lng, n.lat])] } };
|
|
422
422
|
}
|
|
@@ -426,7 +426,7 @@ class dt extends B {
|
|
|
426
426
|
}
|
|
427
427
|
create(t) {
|
|
428
428
|
const { containerX: e, containerY: i } = t;
|
|
429
|
-
return
|
|
429
|
+
return Ee({ unproject: this.unproject, point: { x: e, y: i }, pointerDistance: this.pointerDistance });
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
432
|
class ct extends B {
|
|
@@ -438,7 +438,7 @@ class ct extends B {
|
|
|
438
438
|
return F({ x: i, y: o }, { x: t.containerX, y: t.containerY });
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
|
-
let
|
|
441
|
+
let It = class extends B {
|
|
442
442
|
constructor(t, e, i) {
|
|
443
443
|
super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => this.getSnappable(o, (s) => !!(s.properties && s.properties.mode === this.mode)).coordinate, this.getSnappableCoordinate = (o, s) => this.getSnappable(o, (n) => !!(n.properties && n.properties.mode === this.mode && n.id !== s)).coordinate, this.config = t, this.pixelDistance = e, this.clickBoundingBox = i;
|
|
444
444
|
}
|
|
@@ -458,15 +458,15 @@ let Pt = class extends B {
|
|
|
458
458
|
}), s;
|
|
459
459
|
}
|
|
460
460
|
};
|
|
461
|
-
function
|
|
462
|
-
const i = D(r[0]), o = D(r[1]), s = D(e), n =
|
|
461
|
+
function se(r, t, e) {
|
|
462
|
+
const i = D(r[0]), o = D(r[1]), s = D(e), n = xe(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(s));
|
|
463
463
|
return [V(i + Math.atan2(Math.sin(s) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), V(a)];
|
|
464
464
|
}
|
|
465
465
|
function ht({ x: r, y: t }, e, i) {
|
|
466
466
|
const o = D(i);
|
|
467
467
|
return { x: r + e * Math.cos(o), y: t + e * Math.sin(o) };
|
|
468
468
|
}
|
|
469
|
-
function
|
|
469
|
+
function re(r, t) {
|
|
470
470
|
const e = D(r[0]), i = D(t[0]), o = D(r[1]), s = D(t[1]), n = Math.sin(i - e) * Math.cos(s), a = Math.cos(o) * Math.sin(s) - Math.sin(o) * Math.cos(s) * Math.cos(i - e);
|
|
471
471
|
return V(Math.atan2(n, a));
|
|
472
472
|
}
|
|
@@ -479,15 +479,15 @@ function G({ x: r, y: t }, { x: e, y: i }) {
|
|
|
479
479
|
function X(r) {
|
|
480
480
|
return (r + 360) % 360;
|
|
481
481
|
}
|
|
482
|
-
function
|
|
482
|
+
function li(r, t, e) {
|
|
483
483
|
const i = [], o = r.length;
|
|
484
484
|
let s, n, a, l = 0;
|
|
485
485
|
for (let c = 0; c < r.length && !(t >= l && c === r.length - 1); c++) {
|
|
486
486
|
if (l > t && i.length === 0) {
|
|
487
487
|
if (s = t - l, !s) return i.push(r[c]), i;
|
|
488
|
-
n =
|
|
488
|
+
n = re(r[c], r[c - 1]) - 180, a = se(r[c], s, n), i.push(a);
|
|
489
489
|
}
|
|
490
|
-
if (l >= e) return s = e - l, s ? (n =
|
|
490
|
+
if (l >= e) return s = e - l, s ? (n = re(r[c], r[c - 1]) - 180, a = se(r[c], s, n), i.push(a), i) : (i.push(r[c]), i);
|
|
491
491
|
if (l >= t && i.push(r[c]), c === r.length - 1) return i;
|
|
492
492
|
l += U(r[c], r[c + 1]);
|
|
493
493
|
}
|
|
@@ -498,10 +498,10 @@ function ai(r, t, e) {
|
|
|
498
498
|
function yt(r) {
|
|
499
499
|
return r * (Math.PI / 180);
|
|
500
500
|
}
|
|
501
|
-
function
|
|
501
|
+
function ne(r) {
|
|
502
502
|
return r * (180 / Math.PI);
|
|
503
503
|
}
|
|
504
|
-
class
|
|
504
|
+
class di extends B {
|
|
505
505
|
constructor(t) {
|
|
506
506
|
super(t), this.config = void 0, this.config = t;
|
|
507
507
|
}
|
|
@@ -514,7 +514,7 @@ class li extends B {
|
|
|
514
514
|
Number.isInteger(n) || (n = Math.floor(n) + 1);
|
|
515
515
|
const a = [];
|
|
516
516
|
for (let d = 0; d < n; d++) {
|
|
517
|
-
const c =
|
|
517
|
+
const c = li(o, i * d, i * (d + 1));
|
|
518
518
|
a.push(c);
|
|
519
519
|
}
|
|
520
520
|
const l = [];
|
|
@@ -523,15 +523,15 @@ class li extends B {
|
|
|
523
523
|
}
|
|
524
524
|
generateInsertionGeodesicCoordinates(t, e, i) {
|
|
525
525
|
const o = U(t, e), s = (function(n, a, l) {
|
|
526
|
-
const d = [], c = yt(n[1]), h = yt(n[0]),
|
|
526
|
+
const d = [], c = yt(n[1]), h = yt(n[0]), u = yt(a[1]), p = yt(a[0]);
|
|
527
527
|
l += 1;
|
|
528
|
-
const g = 2 * Math.asin(Math.sqrt(Math.sin((
|
|
528
|
+
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));
|
|
529
529
|
if (g === 0 || isNaN(g)) return d;
|
|
530
530
|
for (let y = 0; y <= l; y++) {
|
|
531
|
-
const m = y / l, v = Math.sin((1 - m) * g) / Math.sin(g), C = Math.sin(m * g) / Math.sin(g), f = v * Math.cos(c) * Math.cos(h) + C * Math.cos(
|
|
531
|
+
const m = y / l, v = Math.sin((1 - m) * g) / Math.sin(g), C = Math.sin(m * g) / Math.sin(g), f = v * Math.cos(c) * Math.cos(h) + C * Math.cos(u) * Math.cos(p), P = v * Math.cos(c) * Math.sin(h) + C * Math.cos(u) * Math.sin(p), I = v * Math.sin(c) + C * Math.sin(u);
|
|
532
532
|
if (isNaN(f) || isNaN(P) || isNaN(I)) continue;
|
|
533
533
|
const E = Math.atan2(I, Math.sqrt(f ** 2 + P ** 2)), L = Math.atan2(P, f);
|
|
534
|
-
isNaN(E) || isNaN(L) || d.push([
|
|
534
|
+
isNaN(E) || isNaN(L) || d.push([ne(L), ne(E)]);
|
|
535
535
|
}
|
|
536
536
|
return d.slice(1, -1);
|
|
537
537
|
})(t, e, Math.floor(o / i));
|
|
@@ -544,26 +544,26 @@ class li extends B {
|
|
|
544
544
|
function tt(r, t) {
|
|
545
545
|
return r[0] === t[0] && r[1] === t[1];
|
|
546
546
|
}
|
|
547
|
-
function
|
|
547
|
+
function At(r, t) {
|
|
548
548
|
if (r.geometry.type !== "LineString") return { valid: !1, reason: "Feature is not a LineString" };
|
|
549
549
|
if (r.geometry.coordinates.length < 2) return { valid: !1, reason: "Feature has less than 2 coordinates" };
|
|
550
550
|
for (let e = 0; e < r.geometry.coordinates.length; e++) {
|
|
551
|
-
if (!
|
|
552
|
-
if (!
|
|
551
|
+
if (!jt(r.geometry.coordinates[e])) return { valid: !1, reason: "Feature has invalid coordinates" };
|
|
552
|
+
if (!Ot(r.geometry.coordinates[e], t)) return { valid: !1, reason: "Feature has coordinates with excessive precision" };
|
|
553
553
|
}
|
|
554
554
|
return { valid: !0 };
|
|
555
555
|
}
|
|
556
|
-
function
|
|
556
|
+
function ae(r) {
|
|
557
557
|
return Math.sqrt(Math.pow(r[0], 2) + Math.pow(r[1], 2) + Math.pow(r[2], 2));
|
|
558
558
|
}
|
|
559
559
|
function Y(r, t) {
|
|
560
560
|
const e = (function(i, o) {
|
|
561
561
|
const [s, n, a] = i, [l, d, c] = o;
|
|
562
562
|
return s * l + n * d + a * c;
|
|
563
|
-
})(r, t) / (
|
|
563
|
+
})(r, t) / (ae(r) * ae(t));
|
|
564
564
|
return Math.acos(Math.min(Math.max(e, -1), 1));
|
|
565
565
|
}
|
|
566
|
-
function
|
|
566
|
+
function wt(r) {
|
|
567
567
|
const t = D(r[1]), e = D(r[0]);
|
|
568
568
|
return [Math.cos(t) * Math.cos(e), Math.cos(t) * Math.sin(e), Math.sin(t)];
|
|
569
569
|
}
|
|
@@ -571,19 +571,19 @@ function K(r) {
|
|
|
571
571
|
const [t, e, i] = r, o = V(Math.asin(i));
|
|
572
572
|
return [V(Math.atan2(e, t)), o];
|
|
573
573
|
}
|
|
574
|
-
function
|
|
575
|
-
const i =
|
|
576
|
-
const [
|
|
577
|
-
return [
|
|
578
|
-
})(i, o),
|
|
574
|
+
function ci(r, t, e) {
|
|
575
|
+
const i = wt(r), o = wt(t), s = wt(e), [n, a, l] = s, [d, c, h] = (function(T, $) {
|
|
576
|
+
const [Yt, Kt, Xt] = T, [Ht, Jt, qt] = $;
|
|
577
|
+
return [Kt * qt - Xt * Jt, Xt * Ht - Yt * qt, Yt * Jt - Kt * Ht];
|
|
578
|
+
})(i, o), u = c * l - h * a, p = h * n - d * l, g = d * a - c * n, y = g * c - p * h, m = u * h - g * d, v = p * d - u * c, C = 1 / Math.sqrt(Math.pow(y, 2) + Math.pow(m, 2) + Math.pow(v, 2)), f = [y * C, m * C, v * C], P = [-1 * y * C, -1 * m * C, -1 * v * C], I = Y(i, o), E = Y(i, f), L = Y(o, f), M = Y(i, P), N = Y(o, P);
|
|
579
579
|
let _;
|
|
580
580
|
return _ = E < M && E < N || L < M && L < N ? f : P, Y(i, _) > I || Y(o, _) > I ? U(K(_), K(i)) <= U(K(_), K(o)) ? [K(i), !0, !1] : [K(o), !1, !0] : [K(_), !1, !1];
|
|
581
581
|
}
|
|
582
|
-
function
|
|
582
|
+
function hi(r, t, e) {
|
|
583
583
|
const i = t.x - r.x, o = t.y - r.y, s = Math.max(0, Math.min(1, ((e.x - r.x) * i + (e.y - r.y) * o) / (i * i + o * o)));
|
|
584
584
|
return { x: r.x + s * i, y: r.y + s * o };
|
|
585
585
|
}
|
|
586
|
-
class
|
|
586
|
+
class Rt extends B {
|
|
587
587
|
constructor(t, e, i) {
|
|
588
588
|
super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => {
|
|
589
589
|
const s = this.getSnappable(o, (n) => !!(n.properties && n.properties.mode === this.mode));
|
|
@@ -603,30 +603,30 @@ class jt extends B {
|
|
|
603
603
|
a = n.geometry.coordinates;
|
|
604
604
|
}
|
|
605
605
|
const l = [];
|
|
606
|
-
for (let
|
|
606
|
+
for (let u = 0; u < a.length - 1; u++) l.push([a[u], a[u + 1]]);
|
|
607
607
|
let d;
|
|
608
608
|
const c = [t.lng, t.lat];
|
|
609
|
-
if (this.config.projection === "web-mercator" ? d = (function(
|
|
609
|
+
if (this.config.projection === "web-mercator" ? d = (function(u, p) {
|
|
610
610
|
let g = [1 / 0, 1 / 0], y = 1 / 0, m = 0;
|
|
611
|
-
for (let v of
|
|
611
|
+
for (let v of p) {
|
|
612
612
|
const C = v[0], f = v[1];
|
|
613
613
|
let P, I = 1 / 0;
|
|
614
|
-
const E = O(C[0], C[1]), L = O(f[0], f[1]), M = O(
|
|
615
|
-
if (C[0] ===
|
|
616
|
-
else if (f[0] ===
|
|
614
|
+
const E = O(C[0], C[1]), L = O(f[0], f[1]), M = O(u[0], u[1]);
|
|
615
|
+
if (C[0] === u[0] && C[1] === u[1]) P = C;
|
|
616
|
+
else if (f[0] === u[0] && f[1] === u[1]) P = f;
|
|
617
617
|
else {
|
|
618
|
-
const { x: N, y: _ } =
|
|
618
|
+
const { x: N, y: _ } = hi(E, L, M), { lng: T, lat: $ } = R(N, _);
|
|
619
619
|
P = [T, $];
|
|
620
620
|
}
|
|
621
|
-
P && (I = F(M, O(P[0], P[1])), I < y && (g = P, y = I, m =
|
|
621
|
+
P && (I = F(M, O(P[0], P[1])), I < y && (g = P, y = I, m = p.indexOf(v)));
|
|
622
622
|
}
|
|
623
623
|
return y === 1 / 0 ? void 0 : { coordinate: g, lineIndex: m, distance: y };
|
|
624
|
-
})(c, l) : this.config.projection === "globe" && (d = (function(
|
|
624
|
+
})(c, l) : this.config.projection === "globe" && (d = (function(u, p) {
|
|
625
625
|
let g = [1 / 0, 1 / 0], y = 1 / 0, m = 0;
|
|
626
|
-
for (let v of
|
|
626
|
+
for (let v of p) {
|
|
627
627
|
const C = v[0], f = v[1];
|
|
628
628
|
let P, I = 1 / 0;
|
|
629
|
-
C[0] ===
|
|
629
|
+
C[0] === u[0] && C[1] === u[1] ? P = C : f[0] === u[0] && f[1] === u[1] ? P = f : [P] = ci(C, f, u), P && (I = U(u, P), I < y && (g = P, y = I, m = p.indexOf(v)));
|
|
630
630
|
}
|
|
631
631
|
return y === 1 / 0 ? void 0 : { coordinate: g, distance: y, lineIndex: m };
|
|
632
632
|
})(c, l)), !d) return;
|
|
@@ -635,10 +635,10 @@ class jt extends B {
|
|
|
635
635
|
}), s;
|
|
636
636
|
}
|
|
637
637
|
}
|
|
638
|
-
const
|
|
639
|
-
class
|
|
638
|
+
const ui = { cancel: "Escape", finish: "Enter" }, pi = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
639
|
+
class Gt extends A {
|
|
640
640
|
constructor(t) {
|
|
641
|
-
super(t, !0), this.mode = "linestring", this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.keyEvents =
|
|
641
|
+
super(t, !0), this.mode = "linestring", this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.keyEvents = ui, this.snapping = void 0, this.cursors = pi, this.mouseMove = !1, this.insertCoordinates = void 0, this.lastCommittedCoordinates = void 0, this.snappedPointId = void 0, this.lastMouseMoveEvent = void 0, this.editable = !1, this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedSnapType = void 0, this.editedInsertIndex = void 0, this.editedPointId = void 0, this.coordinateSnapping = void 0, this.insertPoint = void 0, this.lineSnapping = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.updateOptions(t);
|
|
642
642
|
}
|
|
643
643
|
updateOptions(t) {
|
|
644
644
|
super.updateOptions(t), t != null && t.cursors && (this.cursors = x({}, this.cursors, t.cursors)), t != null && t.snapping && (this.snapping = t.snapping), t?.keyEvents === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = x({}, this.keyEvents, t.keyEvents)), t != null && t.insertCoordinates && (this.insertCoordinates = t.insertCoordinates), t && t.editable && (this.editable = t.editable);
|
|
@@ -696,7 +696,7 @@ class At extends A {
|
|
|
696
696
|
this.updateGeometries(l, i[i.length - 1], b.Commit), this.currentCoordinate++;
|
|
697
697
|
}
|
|
698
698
|
registerBehaviors(t) {
|
|
699
|
-
this.coordinateSnapping = new
|
|
699
|
+
this.coordinateSnapping = new It(t, new ct(t), new dt(t)), this.insertPoint = new di(t), this.clickBoundingBox = new dt(t), this.pixelDistance = new ct(t), this.lineSnapping = new Rt(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new It(t, this.pixelDistance, this.clickBoundingBox);
|
|
700
700
|
}
|
|
701
701
|
start() {
|
|
702
702
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -792,7 +792,7 @@ class At extends A {
|
|
|
792
792
|
return e;
|
|
793
793
|
}
|
|
794
794
|
validateFeature(t) {
|
|
795
|
-
return this.validateModeFeature(t, (e) =>
|
|
795
|
+
return this.validateModeFeature(t, (e) => At(e, this.coordinatePrecision));
|
|
796
796
|
}
|
|
797
797
|
lineStringFilter(t) {
|
|
798
798
|
return !!(t.geometry.type === "LineString" && t.properties && t.properties.mode === this.mode);
|
|
@@ -810,14 +810,14 @@ class At extends A {
|
|
|
810
810
|
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
811
|
}
|
|
812
812
|
}
|
|
813
|
-
const
|
|
814
|
-
function
|
|
815
|
-
return r.geometry.type !== "Point" ? { valid: !1, reason:
|
|
813
|
+
const gi = "Feature is not a Point", yi = "Feature has invalid coordinates", fi = "Feature has coordinates with excessive precision";
|
|
814
|
+
function we(r, t) {
|
|
815
|
+
return r.geometry.type !== "Point" ? { valid: !1, reason: gi } : jt(r.geometry.coordinates) ? Ot(r.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: fi } : { valid: !1, reason: yi };
|
|
816
816
|
}
|
|
817
|
-
const
|
|
818
|
-
class
|
|
817
|
+
const mi = { create: "crosshair", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
818
|
+
class Ut extends A {
|
|
819
819
|
constructor(t) {
|
|
820
|
-
super(t, !0), this.mode = "point", this.cursors =
|
|
820
|
+
super(t, !0), this.mode = "point", this.cursors = mi, this.editable = !1, this.editedFeatureId = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.updateOptions(t);
|
|
821
821
|
}
|
|
822
822
|
updateOptions(t) {
|
|
823
823
|
super.updateOptions(t), t != null && t.cursors && (this.cursors = x({}, this.cursors, t.cursors)), t != null && t.editable && (this.editable = t.editable);
|
|
@@ -867,7 +867,7 @@ class Rt extends A {
|
|
|
867
867
|
return e;
|
|
868
868
|
}
|
|
869
869
|
validateFeature(t) {
|
|
870
|
-
return this.validateModeFeature(t, (e) =>
|
|
870
|
+
return this.validateModeFeature(t, (e) => we(e, this.coordinatePrecision));
|
|
871
871
|
}
|
|
872
872
|
onLeftClick(t) {
|
|
873
873
|
const e = { type: "Point", coordinates: [t.lng, t.lat] }, i = { mode: this.mode };
|
|
@@ -895,7 +895,7 @@ class Rt extends A {
|
|
|
895
895
|
this.editedFeatureId === t.id && (this.editedFeatureId = void 0, this.setCursor(this.cursors.create));
|
|
896
896
|
}
|
|
897
897
|
}
|
|
898
|
-
class
|
|
898
|
+
class vi extends B {
|
|
899
899
|
constructor(t, e) {
|
|
900
900
|
super(t), this.config = void 0, this.pixelDistance = void 0, this._startEndPoints = [], this.config = t, this.pixelDistance = e;
|
|
901
901
|
}
|
|
@@ -921,7 +921,7 @@ class mi extends B {
|
|
|
921
921
|
return { isClosing: o < this.pointerDistance, isPreviousClosing: s < this.pointerDistance };
|
|
922
922
|
}
|
|
923
923
|
}
|
|
924
|
-
class
|
|
924
|
+
class Le extends B {
|
|
925
925
|
constructor(t) {
|
|
926
926
|
super(t);
|
|
927
927
|
}
|
|
@@ -976,10 +976,10 @@ class we extends B {
|
|
|
976
976
|
e && (this.deleteCoordinatePoints(e), this.setFeatureCoordinatePoints(t, null));
|
|
977
977
|
}
|
|
978
978
|
}
|
|
979
|
-
const
|
|
980
|
-
class
|
|
979
|
+
const Ci = { cancel: "Escape", finish: "Enter" }, Pi = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
980
|
+
class Fe extends A {
|
|
981
981
|
constructor(t) {
|
|
982
|
-
super(t, !0), this.mode = "polygon", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents =
|
|
982
|
+
super(t, !0), this.mode = "polygon", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = Ci, this.cursors = Pi, this.mouseMove = !1, this.showCoordinatePoints = !1, this.lastMouseMoveEvent = void 0, this.snapping = void 0, this.snappedPointId = void 0, this.editable = !1, this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedSnapType = void 0, this.editedInsertIndex = void 0, this.editedPointId = void 0, this.coordinatePoints = void 0, this.lineSnapping = void 0, this.coordinateSnapping = void 0, this.pixelDistance = void 0, this.closingPoints = void 0, this.clickBoundingBox = void 0, this.updateOptions(t);
|
|
983
983
|
}
|
|
984
984
|
updateOptions(t) {
|
|
985
985
|
if (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.snapping && (this.snapping = t.snapping), t?.editable !== void 0 && (this.editable = t.editable), t?.pointerEvents !== void 0 && (this.pointerEvents = t.pointerEvents), t?.showCoordinatePoints !== void 0) {
|
|
@@ -1004,7 +1004,7 @@ class Le extends A {
|
|
|
1004
1004
|
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
1005
|
}
|
|
1006
1006
|
registerBehaviors(t) {
|
|
1007
|
-
this.clickBoundingBox = new dt(t), this.pixelDistance = new ct(t), this.lineSnapping = new
|
|
1007
|
+
this.clickBoundingBox = new dt(t), this.pixelDistance = new ct(t), this.lineSnapping = new Rt(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new It(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new vi(t, this.pixelDistance), this.coordinatePoints = new Le(t);
|
|
1008
1008
|
}
|
|
1009
1009
|
start() {
|
|
1010
1010
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -1161,13 +1161,13 @@ class Le extends A {
|
|
|
1161
1161
|
this.showCoordinatePoints && this.coordinatePoints.createOrUpdate(t.id), 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.currentCoordinate = 0, this.currentId = void 0, this.closingPoints.delete(), this.state === "drawing" && this.setStarted());
|
|
1162
1162
|
}
|
|
1163
1163
|
validateFeature(t) {
|
|
1164
|
-
return this.validateModeFeature(t, (e) =>
|
|
1164
|
+
return this.validateModeFeature(t, (e) => bt(e, this.coordinatePrecision));
|
|
1165
1165
|
}
|
|
1166
1166
|
}
|
|
1167
|
-
const
|
|
1168
|
-
class
|
|
1167
|
+
const Si = { cancel: "Escape", finish: "Enter" }, Ii = { start: "crosshair" };
|
|
1168
|
+
class Me extends A {
|
|
1169
1169
|
constructor(t) {
|
|
1170
|
-
super(t, !0), this.mode = "rectangle", this.center = void 0, this.clickCount = 0, this.currentRectangleId = void 0, this.keyEvents =
|
|
1170
|
+
super(t, !0), this.mode = "rectangle", this.center = void 0, this.clickCount = 0, this.currentRectangleId = void 0, this.keyEvents = Si, this.cursors = Ii, this.updateOptions(t);
|
|
1171
1171
|
}
|
|
1172
1172
|
updateOptions(t) {
|
|
1173
1173
|
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));
|
|
@@ -1268,50 +1268,50 @@ class Q extends A {
|
|
|
1268
1268
|
validateFeature(t) {
|
|
1269
1269
|
const e = super.validateFeature(t);
|
|
1270
1270
|
if (e.valid) {
|
|
1271
|
-
const i = t, o =
|
|
1271
|
+
const i = t, o = we(i, this.coordinatePrecision).valid || bt(i, this.coordinatePrecision).valid || At(i, this.coordinatePrecision).valid;
|
|
1272
1272
|
return o ? { valid: !0 } : { valid: o, reason: "Feature is not a valid Point, Polygon or LineString feature" };
|
|
1273
1273
|
}
|
|
1274
1274
|
return e;
|
|
1275
1275
|
}
|
|
1276
1276
|
}
|
|
1277
|
-
function
|
|
1277
|
+
function _t(r, t) {
|
|
1278
1278
|
const e = r, i = t, o = D(e[1]), s = D(i[1]);
|
|
1279
1279
|
let n = D(i[0] - e[0]);
|
|
1280
1280
|
n > Math.PI && (n -= 2 * Math.PI), n < -Math.PI && (n += 2 * Math.PI);
|
|
1281
1281
|
const a = Math.log(Math.tan(s / 2 + Math.PI / 4) / Math.tan(o / 2 + Math.PI / 4)), l = (V(Math.atan2(n, a)) + 360) % 360;
|
|
1282
1282
|
return l > 180 ? -(360 - l) : l;
|
|
1283
1283
|
}
|
|
1284
|
-
function
|
|
1284
|
+
function De(r, t, e) {
|
|
1285
1285
|
let i = t;
|
|
1286
1286
|
t < 0 && (i = -Math.abs(i));
|
|
1287
|
-
const o = i /
|
|
1287
|
+
const o = i / Ie, s = r[0] * Math.PI / 180, n = D(r[1]), a = D(e), l = o * Math.cos(a);
|
|
1288
1288
|
let d = n + l;
|
|
1289
1289
|
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),
|
|
1291
|
-
return
|
|
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 * (s + o * Math.sin(a) / h) / Math.PI + 540) % 360 - 180, 180 * d / Math.PI];
|
|
1291
|
+
return u[0] += u[0] - r[0] > 180 ? -360 : r[0] - u[0] > 180 ? 360 : 0, u;
|
|
1292
1292
|
}
|
|
1293
|
-
function
|
|
1293
|
+
function _e(r, t, e, i, o) {
|
|
1294
1294
|
const s = i(r[0], r[1]), n = i(t[0], t[1]), { lng: a, lat: l } = o((s.x + n.x) / 2, (s.y + n.y) / 2);
|
|
1295
1295
|
return [w(a, e), w(l, e)];
|
|
1296
1296
|
}
|
|
1297
|
-
function
|
|
1298
|
-
const i =
|
|
1297
|
+
function xi(r, t, e) {
|
|
1298
|
+
const i = De(r, 1e3 * U(r, t) / 2, _t(r, t));
|
|
1299
1299
|
return [w(i[0], e), w(i[1], e)];
|
|
1300
1300
|
}
|
|
1301
|
-
function
|
|
1301
|
+
function le({ featureCoords: r, precision: t, unproject: e, project: i, projection: o }) {
|
|
1302
1302
|
const s = [];
|
|
1303
1303
|
for (let n = 0; n < r.length - 1; n++) {
|
|
1304
1304
|
let a;
|
|
1305
|
-
if (o === "web-mercator") a =
|
|
1305
|
+
if (o === "web-mercator") a = _e(r[n], r[n + 1], t, i, e);
|
|
1306
1306
|
else {
|
|
1307
1307
|
if (o !== "globe") throw new Error("Invalid projection");
|
|
1308
|
-
a =
|
|
1308
|
+
a = xi(r[n], r[n + 1], t);
|
|
1309
1309
|
}
|
|
1310
1310
|
s.push(a);
|
|
1311
1311
|
}
|
|
1312
1312
|
return s;
|
|
1313
1313
|
}
|
|
1314
|
-
class
|
|
1314
|
+
class Oi extends B {
|
|
1315
1315
|
constructor(t, e, i) {
|
|
1316
1316
|
super(t), this.config = void 0, this.selectionPointBehavior = void 0, this.coordinatePointBehavior = void 0, this._midPoints = [], this.config = t, this.selectionPointBehavior = e, this.coordinatePointBehavior = i;
|
|
1317
1317
|
}
|
|
@@ -1327,17 +1327,17 @@ class xi extends B {
|
|
|
1327
1327
|
create(t, e, i) {
|
|
1328
1328
|
if (!this.store.has(e)) throw new Error("Store does not have feature with this id");
|
|
1329
1329
|
this._midPoints = this.store.create((function(o, s, n, a, l, d) {
|
|
1330
|
-
return
|
|
1330
|
+
return le({ featureCoords: o, precision: n, project: a, unproject: l, projection: d }).map((c, h) => ({ geometry: { type: "Point", coordinates: c }, properties: s(h) }));
|
|
1331
1331
|
})(t, (o) => ({ mode: this.mode, [k.MID_POINT]: !0, midPointSegment: o, midPointFeatureId: e }), i, this.config.project, this.config.unproject, this.projection));
|
|
1332
1332
|
}
|
|
1333
1333
|
delete() {
|
|
1334
1334
|
this._midPoints.length && (this.store.delete(this._midPoints), this._midPoints = []);
|
|
1335
1335
|
}
|
|
1336
1336
|
getUpdated(t) {
|
|
1337
|
-
if (this._midPoints.length !== 0) return
|
|
1337
|
+
if (this._midPoints.length !== 0) return le({ featureCoords: t, precision: this.coordinatePrecision, project: this.config.project, unproject: this.config.unproject, projection: this.config.projection }).map((e, i) => ({ id: this._midPoints[i], geometry: { type: "Point", coordinates: e } }));
|
|
1338
1338
|
}
|
|
1339
1339
|
}
|
|
1340
|
-
class
|
|
1340
|
+
class bi extends B {
|
|
1341
1341
|
constructor(t) {
|
|
1342
1342
|
super(t), this._selectionPoints = [];
|
|
1343
1343
|
}
|
|
@@ -1363,7 +1363,7 @@ class Oi extends B {
|
|
|
1363
1363
|
if (this._selectionPoints[t] !== void 0) return { id: this._selectionPoints[t], geometry: { type: "Point", coordinates: e } };
|
|
1364
1364
|
}
|
|
1365
1365
|
}
|
|
1366
|
-
function
|
|
1366
|
+
function ke(r, t) {
|
|
1367
1367
|
let e = !1;
|
|
1368
1368
|
for (let n = 0, a = t.length; n < a; n++) {
|
|
1369
1369
|
const l = t[n];
|
|
@@ -1372,7 +1372,7 @@ function _e(r, t) {
|
|
|
1372
1372
|
var i, o, s;
|
|
1373
1373
|
return e;
|
|
1374
1374
|
}
|
|
1375
|
-
const
|
|
1375
|
+
const kt = (r, t, e) => {
|
|
1376
1376
|
const i = (s) => s * s, o = (s, n) => i(s.x - n.x) + i(s.y - n.y);
|
|
1377
1377
|
return Math.sqrt(((s, n, a) => {
|
|
1378
1378
|
const l = o(n, a);
|
|
@@ -1381,34 +1381,34 @@ const Dt = (r, t, e) => {
|
|
|
1381
1381
|
return d = Math.max(0, Math.min(1, d)), o(s, { x: n.x + d * (a.x - n.x), y: n.y + d * (a.y - n.y) });
|
|
1382
1382
|
})(r, t, e));
|
|
1383
1383
|
};
|
|
1384
|
-
class
|
|
1384
|
+
class Ei extends B {
|
|
1385
1385
|
constructor(t, e, i) {
|
|
1386
1386
|
super(t), this.config = void 0, this.createClickBoundingBox = void 0, this.pixelDistance = void 0, this.config = t, this.createClickBoundingBox = e, this.pixelDistance = i;
|
|
1387
1387
|
}
|
|
1388
1388
|
find(t, e) {
|
|
1389
1389
|
let i, o, s, n, a = 1 / 0, l = 1 / 0, d = 1 / 0;
|
|
1390
1390
|
const c = this.createClickBoundingBox.create(t), h = this.store.search(c);
|
|
1391
|
-
for (let
|
|
1392
|
-
const
|
|
1391
|
+
for (let u = 0; u < h.length; u++) {
|
|
1392
|
+
const p = h[u], g = p.geometry;
|
|
1393
1393
|
if (g.type === "Point") {
|
|
1394
|
-
if (
|
|
1394
|
+
if (p.properties.selectionPoint || p.properties.coordinatePoint || !e && p.properties[k.MID_POINT]) continue;
|
|
1395
1395
|
const y = this.pixelDistance.measure(t, g.coordinates);
|
|
1396
|
-
|
|
1396
|
+
p.properties[k.MID_POINT] && y < this.pointerDistance && y < d ? (d = y, s = p) : !p.properties[k.MID_POINT] && y < this.pointerDistance && y < a && (a = y, i = p);
|
|
1397
1397
|
} else if (g.type === "LineString") {
|
|
1398
1398
|
if (i) continue;
|
|
1399
1399
|
for (let y = 0; y < g.coordinates.length - 1; y++) {
|
|
1400
|
-
const m = g.coordinates[y], v = g.coordinates[y + 1], C =
|
|
1401
|
-
C < this.pointerDistance && C < l && (l = C, o =
|
|
1400
|
+
const m = g.coordinates[y], v = g.coordinates[y + 1], C = kt({ x: t.containerX, y: t.containerY }, this.project(m[0], m[1]), this.project(v[0], v[1]));
|
|
1401
|
+
C < this.pointerDistance && C < l && (l = C, o = p);
|
|
1402
1402
|
}
|
|
1403
1403
|
} else if (g.type === "Polygon") {
|
|
1404
1404
|
if (i || o) continue;
|
|
1405
|
-
|
|
1405
|
+
ke([t.lng, t.lat], g.coordinates) && (n = p);
|
|
1406
1406
|
}
|
|
1407
1407
|
}
|
|
1408
1408
|
return { clickedFeature: i || o || n, clickedMidPoint: s };
|
|
1409
1409
|
}
|
|
1410
1410
|
}
|
|
1411
|
-
class
|
|
1411
|
+
class wi extends B {
|
|
1412
1412
|
constructor(t, e, i, o, s) {
|
|
1413
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 = s;
|
|
1414
1414
|
}
|
|
@@ -1433,16 +1433,16 @@ class Ei extends B {
|
|
|
1433
1433
|
if (i.type === "Polygon" ? (s = i.coordinates[0], n = s.length - 1) : (s = i.coordinates, n = s.length), !this.dragPosition) return !1;
|
|
1434
1434
|
for (let c = 0; c < n; c++) {
|
|
1435
1435
|
const h = s[c];
|
|
1436
|
-
let
|
|
1436
|
+
let u, p;
|
|
1437
1437
|
if (this.config.projection === "web-mercator") {
|
|
1438
1438
|
const g = O(this.dragPosition[0], this.dragPosition[1]), y = O(o[0], o[1]), m = O(h[0], h[1]), v = { x: g.x - y.x, y: g.y - y.y }, C = m.x - v.x, f = m.y - v.y, { lng: P, lat: I } = R(C, f);
|
|
1439
|
-
|
|
1439
|
+
u = P, p = I;
|
|
1440
1440
|
} else {
|
|
1441
1441
|
const g = [this.dragPosition[0] - o[0], this.dragPosition[1] - o[1]];
|
|
1442
|
-
|
|
1442
|
+
u = h[0] - g[0], p = h[1] - g[1];
|
|
1443
1443
|
}
|
|
1444
|
-
if (
|
|
1445
|
-
s[c] = [
|
|
1444
|
+
if (u = w(u, this.config.coordinatePrecision), p = w(p, this.config.coordinatePrecision), u > 180 || u < -180 || p > 90 || p < -90) return !1;
|
|
1445
|
+
s[c] = [u, p];
|
|
1446
1446
|
}
|
|
1447
1447
|
i.type === "Polygon" && (s[s.length - 1] = [s[0][0], s[0][1]]);
|
|
1448
1448
|
const a = this.selectionPoints.getUpdated(s) || [], l = this.midPoints.getUpdated(s) || [], d = this.coordinatePoints.getUpdated(this.draggedFeatureId, s) || [];
|
|
@@ -1451,7 +1451,7 @@ class Ei extends B {
|
|
|
1451
1451
|
} else i.type === "Point" && (this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: { type: "Point", coordinates: o } }]), this.dragPosition = [t.lng, t.lat]);
|
|
1452
1452
|
}
|
|
1453
1453
|
}
|
|
1454
|
-
class
|
|
1454
|
+
class Li extends B {
|
|
1455
1455
|
constructor(t, e, i, o, s, n, a) {
|
|
1456
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 = s, this.coordinateSnapping = n, this.lineSnapping = a;
|
|
1457
1457
|
}
|
|
@@ -1496,14 +1496,14 @@ class wi extends B {
|
|
|
1496
1496
|
drag(t, e, i, o) {
|
|
1497
1497
|
const s = this.draggedCoordinate.id;
|
|
1498
1498
|
if (s === null) return !1;
|
|
1499
|
-
const n = this.draggedCoordinate.index, a = this.store.getGeometryCopy(s), l = this.store.getPropertiesCopy(s), d = a.type === "LineString" ? a.coordinates : a.coordinates[0], c = a.type === "Polygon" && (n === d.length - 1 || n === 0), h = { type: "Feature", id: s, geometry: a, properties: l },
|
|
1499
|
+
const n = this.draggedCoordinate.index, a = this.store.getGeometryCopy(s), l = this.store.getPropertiesCopy(s), d = a.type === "LineString" ? a.coordinates : a.coordinates[0], c = a.type === "Polygon" && (n === d.length - 1 || n === 0), h = { type: "Feature", id: s, geometry: a, properties: l }, u = this.snapCoordinate(t, o, h);
|
|
1500
1500
|
if (t.lng > 180 || t.lng < -180 || t.lat > 90 || t.lat < -90) return !1;
|
|
1501
1501
|
if (c) {
|
|
1502
1502
|
const v = d.length - 1;
|
|
1503
|
-
d[0] =
|
|
1504
|
-
} else d[n] =
|
|
1505
|
-
const
|
|
1506
|
-
return !(a.type !== "Point" && !e &&
|
|
1503
|
+
d[0] = u, d[v] = u;
|
|
1504
|
+
} else d[n] = u;
|
|
1505
|
+
const p = this.selectionPoints.getOneUpdated(n, u), g = p ? [p] : [], y = this.midPoints.getUpdated(d) || [], m = this.coordinatePoints.getUpdated(s, d) || [];
|
|
1506
|
+
return !(a.type !== "Point" && !e && Bt({ geometry: a }) || i && !i(h, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional }).valid || (this.store.updateGeometry([{ id: s, geometry: a }, ...g, ...y, ...m]), 0));
|
|
1507
1507
|
}
|
|
1508
1508
|
isDragging() {
|
|
1509
1509
|
return this.draggedCoordinate.id !== null;
|
|
@@ -1515,20 +1515,20 @@ class wi extends B {
|
|
|
1515
1515
|
this.draggedCoordinate = { id: null, index: -1 };
|
|
1516
1516
|
}
|
|
1517
1517
|
}
|
|
1518
|
-
function
|
|
1518
|
+
function de(r) {
|
|
1519
1519
|
let t = 0, e = 0, i = 0;
|
|
1520
1520
|
return (r.geometry.type === "Polygon" ? r.geometry.coordinates[0].slice(0, -1) : r.geometry.coordinates).forEach((o) => {
|
|
1521
1521
|
t += o[0], e += o[1], i++;
|
|
1522
1522
|
}, !0), [t / i, e / i];
|
|
1523
1523
|
}
|
|
1524
|
-
const
|
|
1524
|
+
const Ne = (r, t) => {
|
|
1525
1525
|
if (t === 0 || t === 360 || t === -360) return r;
|
|
1526
1526
|
const e = 0.017453292519943295 * t, i = (r.geometry.type === "Polygon" ? r.geometry.coordinates[0] : r.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
1527
|
o.x /= i.length, o.y /= i.length;
|
|
1528
1528
|
const s = 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 }) => [R(n, a).lng, R(n, a).lat]);
|
|
1529
1529
|
return r.geometry.type === "Polygon" ? r.geometry.coordinates[0] = s : r.geometry.coordinates = s, r;
|
|
1530
1530
|
};
|
|
1531
|
-
function
|
|
1531
|
+
function Nt(r) {
|
|
1532
1532
|
const t = (r.geometry.type === "Polygon" ? r.geometry.coordinates[0] : r.geometry.coordinates).map((e) => {
|
|
1533
1533
|
const { x: i, y: o } = O(e[0], e[1]);
|
|
1534
1534
|
return [i, o];
|
|
@@ -1537,8 +1537,8 @@ function _t(r) {
|
|
|
1537
1537
|
let i = 0, o = 0, s = 0;
|
|
1538
1538
|
const n = e.length;
|
|
1539
1539
|
for (let a = 0; a < n - 1; a++) {
|
|
1540
|
-
const [l, d] = e[a], [c, h] = e[a + 1],
|
|
1541
|
-
i +=
|
|
1540
|
+
const [l, d] = e[a], [c, h] = e[a + 1], u = l * h - c * d;
|
|
1541
|
+
i += u, o += (l + c) * u, s += (d + h) * u;
|
|
1542
1542
|
}
|
|
1543
1543
|
return i /= 2, o /= 6 * i, s /= 6 * i, { x: o, y: s };
|
|
1544
1544
|
})(t) : (function(e) {
|
|
@@ -1551,7 +1551,7 @@ function _t(r) {
|
|
|
1551
1551
|
return { x: o / i, y: s / i };
|
|
1552
1552
|
})(t);
|
|
1553
1553
|
}
|
|
1554
|
-
class
|
|
1554
|
+
class Fi extends B {
|
|
1555
1555
|
constructor(t, e, i, o) {
|
|
1556
1556
|
super(t), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.coordinatePoints = void 0, this.lastBearing = void 0, this.selectedGeometry = void 0, this.selectedGeometryCentroid = void 0, this.selectedGeometryWebMercatorCentroid = void 0, this.config = t, this.selectionPoints = e, this.midPoints = i, this.coordinatePoints = o;
|
|
1557
1557
|
}
|
|
@@ -1566,40 +1566,40 @@ class Li extends B {
|
|
|
1566
1566
|
let n;
|
|
1567
1567
|
const a = { type: "Feature", geometry: o, properties: {} };
|
|
1568
1568
|
if (this.config.projection === "web-mercator") {
|
|
1569
|
-
this.selectedGeometryWebMercatorCentroid || (this.selectedGeometryWebMercatorCentroid =
|
|
1570
|
-
const
|
|
1571
|
-
if (n = G(this.selectedGeometryWebMercatorCentroid,
|
|
1569
|
+
this.selectedGeometryWebMercatorCentroid || (this.selectedGeometryWebMercatorCentroid = Nt(a));
|
|
1570
|
+
const u = O(t.lng, t.lat);
|
|
1571
|
+
if (n = G(this.selectedGeometryWebMercatorCentroid, u), n === 0) return;
|
|
1572
1572
|
if (!this.lastBearing) return void (this.lastBearing = n);
|
|
1573
|
-
|
|
1573
|
+
Ne(a, -(this.lastBearing - n));
|
|
1574
1574
|
} else {
|
|
1575
1575
|
if (this.config.projection !== "globe") throw new Error("Unsupported projection");
|
|
1576
|
-
if (this.selectedGeometryCentroid || (this.selectedGeometryCentroid =
|
|
1577
|
-
(function(
|
|
1578
|
-
if (
|
|
1579
|
-
const g =
|
|
1580
|
-
(
|
|
1581
|
-
const m =
|
|
1576
|
+
if (this.selectedGeometryCentroid || (this.selectedGeometryCentroid = de({ geometry: o })), n = _t(this.selectedGeometryCentroid, s), !this.lastBearing) return void (this.lastBearing = n + 180);
|
|
1577
|
+
(function(u, p) {
|
|
1578
|
+
if (p === 0 || p === 360 || p === -360) return u;
|
|
1579
|
+
const g = de(u);
|
|
1580
|
+
(u.geometry.type === "Polygon" ? u.geometry.coordinates[0] : u.geometry.coordinates).forEach((y) => {
|
|
1581
|
+
const m = _t(g, y) + p, v = (function(f, P) {
|
|
1582
1582
|
f[0] += f[0] - P[0] > 180 ? -360 : P[0] - f[0] > 180 ? 360 : 0;
|
|
1583
|
-
const I =
|
|
1583
|
+
const I = Ie, E = P[1] * Math.PI / 180, L = f[1] * Math.PI / 180, M = L - E;
|
|
1584
1584
|
let N = Math.abs(f[0] - P[0]) * Math.PI / 180;
|
|
1585
1585
|
N > Math.PI && (N -= 2 * Math.PI);
|
|
1586
1586
|
const _ = Math.log(Math.tan(L / 2 + Math.PI / 4) / Math.tan(E / 2 + Math.PI / 4)), T = Math.abs(_) > 1e-11 ? M / _ : Math.cos(E);
|
|
1587
1587
|
return Math.sqrt(M * M + T * T * N * N) * I;
|
|
1588
|
-
})(g, y), C =
|
|
1588
|
+
})(g, y), C = De(g, v, m);
|
|
1589
1589
|
y[0] = C[0], y[1] = C[1];
|
|
1590
1590
|
});
|
|
1591
1591
|
})(a, -(this.lastBearing - (n + 180)));
|
|
1592
1592
|
}
|
|
1593
1593
|
const l = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
|
|
1594
|
-
l.forEach((
|
|
1595
|
-
|
|
1594
|
+
l.forEach((u) => {
|
|
1595
|
+
u[0] = w(u[0], this.coordinatePrecision), u[1] = w(u[1], this.coordinatePrecision);
|
|
1596
1596
|
});
|
|
1597
1597
|
const d = this.midPoints.getUpdated(l) || [], c = this.selectionPoints.getUpdated(l) || [], h = this.coordinatePoints.getUpdated(e, l) || [];
|
|
1598
1598
|
if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional })) return !1;
|
|
1599
1599
|
this.store.updateGeometry([{ id: e, geometry: o }, ...c, ...d, ...h]), this.projection === "web-mercator" ? this.lastBearing = n : this.projection === "globe" && (this.lastBearing = n + 180);
|
|
1600
1600
|
}
|
|
1601
1601
|
}
|
|
1602
|
-
class
|
|
1602
|
+
class Mi extends B {
|
|
1603
1603
|
constructor(t, e) {
|
|
1604
1604
|
super(t), this.config = void 0, this.dragCoordinateResizeBehavior = void 0, this.config = t, this.dragCoordinateResizeBehavior = e;
|
|
1605
1605
|
}
|
|
@@ -1614,13 +1614,13 @@ class Fi extends B {
|
|
|
1614
1614
|
this.dragCoordinateResizeBehavior.stopDragging();
|
|
1615
1615
|
}
|
|
1616
1616
|
}
|
|
1617
|
-
function
|
|
1617
|
+
function Te({ coordinates: r, originX: t, originY: e, xScale: i, yScale: o }) {
|
|
1618
1618
|
i === 1 && o === 1 || r.forEach((s) => {
|
|
1619
1619
|
const { x: n, y: a } = O(s[0], s[1]), l = t + (n - t) * i, d = e + (a - e) * o, { lng: c, lat: h } = R(l, d);
|
|
1620
1620
|
s[0] = c, s[1] = h;
|
|
1621
1621
|
});
|
|
1622
1622
|
}
|
|
1623
|
-
class
|
|
1623
|
+
class Di extends B {
|
|
1624
1624
|
constructor(t, e, i, o, s) {
|
|
1625
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 = s;
|
|
1626
1626
|
}
|
|
@@ -1679,7 +1679,7 @@ class Mi extends B {
|
|
|
1679
1679
|
centerWebMercatorDrag(t) {
|
|
1680
1680
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1681
1681
|
if (!e) return null;
|
|
1682
|
-
const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a =
|
|
1682
|
+
const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a = Nt(i);
|
|
1683
1683
|
if (!a) return null;
|
|
1684
1684
|
const l = O(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), c = O(t.lng, t.lat);
|
|
1685
1685
|
return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: s, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), s;
|
|
@@ -1687,7 +1687,7 @@ class Mi extends B {
|
|
|
1687
1687
|
centerFixedWebMercatorDrag(t) {
|
|
1688
1688
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1689
1689
|
if (!e) return null;
|
|
1690
|
-
const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a =
|
|
1690
|
+
const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a = Nt(i);
|
|
1691
1691
|
if (!a) return null;
|
|
1692
1692
|
const l = O(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), c = O(t.lng, t.lat);
|
|
1693
1693
|
return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: s, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), s;
|
|
@@ -1695,7 +1695,7 @@ class Mi extends B {
|
|
|
1695
1695
|
scaleFixedWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: s }) {
|
|
1696
1696
|
if (!this.isValidDragWebMercator(t, e.x - o.x, e.y - o.y)) return null;
|
|
1697
1697
|
let n = F(e, o) / F(e, i);
|
|
1698
|
-
return n < 0 && (n = this.minimumScale),
|
|
1698
|
+
return n < 0 && (n = this.minimumScale), Te({ coordinates: s, originX: e.x, originY: e.y, xScale: n, yScale: n }), s;
|
|
1699
1699
|
}
|
|
1700
1700
|
oppositeFixedWebMercatorDrag(t) {
|
|
1701
1701
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
@@ -1731,8 +1731,8 @@ class Mi extends B {
|
|
|
1731
1731
|
}
|
|
1732
1732
|
performWebMercatorScale(t, e, i, o, s) {
|
|
1733
1733
|
t.forEach((n) => {
|
|
1734
|
-
const { x: a, y: l } = O(n[0], n[1]), d = e + (a - e) * o, c = i + (l - i) * s, { lng: h, lat:
|
|
1735
|
-
n[0] = h, n[1] =
|
|
1734
|
+
const { x: a, y: l } = O(n[0], n[1]), d = e + (a - e) * o, c = i + (l - i) * s, { lng: h, lat: u } = R(d, c);
|
|
1735
|
+
n[0] = h, n[1] = u;
|
|
1736
1736
|
});
|
|
1737
1737
|
}
|
|
1738
1738
|
getBBoxWebMercator(t) {
|
|
@@ -1776,19 +1776,19 @@ class Mi extends B {
|
|
|
1776
1776
|
if (e === "center" ? s = this.centerWebMercatorDrag(t) : e === "opposite" ? s = this.oppositeWebMercatorDrag(t) : e === "center-fixed" ? s = this.centerFixedWebMercatorDrag(t) : e === "opposite-fixed" && (s = this.oppositeFixedWebMercatorDrag(t)), !s) return !1;
|
|
1777
1777
|
for (let c = 0; c < s.length; c++) {
|
|
1778
1778
|
const h = s[c];
|
|
1779
|
-
if (h[0] = w(h[0], this.coordinatePrecision), h[1] = w(h[1], this.coordinatePrecision), !
|
|
1779
|
+
if (h[0] = w(h[0], this.coordinatePrecision), h[1] = w(h[1], this.coordinatePrecision), !Ot(h, this.coordinatePrecision)) return !1;
|
|
1780
1780
|
}
|
|
1781
1781
|
const n = this.midPoints.getUpdated(s) || [], a = this.selectionPoints.getUpdated(s) || [], l = this.coordinatePoints.getUpdated(o.id, s) || [], d = { type: o.geometry.type, coordinates: o.geometry.type === "Polygon" ? [s] : s };
|
|
1782
1782
|
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: b.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: d }, ...a, ...n, ...l]), 0));
|
|
1783
1783
|
}
|
|
1784
1784
|
}
|
|
1785
|
-
const
|
|
1786
|
-
class
|
|
1785
|
+
const _i = { deselect: "Escape", delete: "Delete", rotate: ["Control", "r"], scale: ["Control", "s"] }, ce = { pointerOver: "move", dragStart: "move", dragEnd: "move", insertMidpoint: "crosshair" };
|
|
1786
|
+
class zt extends Ze {
|
|
1787
1787
|
constructor(t) {
|
|
1788
|
-
super(t, !0), this.mode = "select", this.allowManualDeselection = !0, this.dragEventThrottle = 5, this.dragEventCount = 0, this.selected = [], this.flags = {}, this.keyEvents =
|
|
1788
|
+
super(t, !0), this.mode = "select", this.allowManualDeselection = !0, this.dragEventThrottle = 5, this.dragEventCount = 0, this.selected = [], this.flags = {}, this.keyEvents = _i, this.cursors = ce, this.validations = {}, this.selectionPoints = void 0, this.midPoints = void 0, this.coordinateSnap = void 0, this.featuresAtMouseEvent = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.dragFeature = void 0, this.dragCoordinate = void 0, this.rotateFeature = void 0, this.scaleFeature = void 0, this.dragCoordinateResizeFeature = void 0, this.coordinatePoints = void 0, this.lineSnap = void 0, this.updateOptions(t);
|
|
1789
1789
|
}
|
|
1790
1790
|
updateOptions(t) {
|
|
1791
|
-
if (super.updateOptions(t), this.cursors = t && t.cursors ? x({}, this.cursors, t.cursors) :
|
|
1791
|
+
if (super.updateOptions(t), this.cursors = t && t.cursors ? x({}, this.cursors, t.cursors) : ce, t?.keyEvents === null ? this.keyEvents = { deselect: null, delete: null, rotate: null, scale: null } : t != null && t.keyEvents && (this.keyEvents = x({}, this.keyEvents, t.keyEvents)), t?.dragEventThrottle !== void 0 && (this.dragEventThrottle = t.dragEventThrottle), t?.allowManualDeselection !== void 0 && (this.allowManualDeselection = t.allowManualDeselection), t != null && t.flags) {
|
|
1792
1792
|
this.flags = x({}, this.flags, t.flags), this.validations = {};
|
|
1793
1793
|
for (const e in this.flags) {
|
|
1794
1794
|
const i = this.flags[e].feature;
|
|
@@ -1804,7 +1804,7 @@ class Gt extends qe {
|
|
|
1804
1804
|
this._state = "selecting";
|
|
1805
1805
|
}
|
|
1806
1806
|
registerBehaviors(t) {
|
|
1807
|
-
this.pixelDistance = new ct(t), this.clickBoundingBox = new dt(t), this.featuresAtMouseEvent = new
|
|
1807
|
+
this.pixelDistance = new ct(t), this.clickBoundingBox = new dt(t), this.featuresAtMouseEvent = new Ei(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new bi(t), this.coordinatePoints = new Le(t), this.midPoints = new Oi(t, this.selectionPoints, this.coordinatePoints), this.coordinateSnap = new It(t, this.pixelDistance, this.clickBoundingBox), this.lineSnap = new Rt(t, this.pixelDistance, this.clickBoundingBox), this.rotateFeature = new Fi(t, this.selectionPoints, this.midPoints, this.coordinatePoints), this.dragFeature = new wi(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints, this.coordinatePoints), this.dragCoordinate = new Li(t, this.pixelDistance, this.selectionPoints, this.midPoints, this.coordinatePoints, this.coordinateSnap, this.lineSnap), this.dragCoordinateResizeFeature = new Di(t, this.pixelDistance, this.selectionPoints, this.midPoints, this.coordinatePoints), this.scaleFeature = new Mi(t, this.dragCoordinateResizeFeature);
|
|
1808
1808
|
}
|
|
1809
1809
|
deselectFeature() {
|
|
1810
1810
|
this.deselect();
|
|
@@ -1819,9 +1819,9 @@ class Gt extends qe {
|
|
|
1819
1819
|
onRightClick(t) {
|
|
1820
1820
|
if (!this.selectionPoints.ids.length) return;
|
|
1821
1821
|
let e, i = 1 / 0;
|
|
1822
|
-
if (this.selectionPoints.ids.forEach((
|
|
1823
|
-
const
|
|
1824
|
-
g < this.pointerDistance && g < i && (i = g, e = this.store.getPropertiesCopy(
|
|
1822
|
+
if (this.selectionPoints.ids.forEach((u) => {
|
|
1823
|
+
const p = this.store.getGeometryCopy(u), g = this.pixelDistance.measure(t, p.coordinates);
|
|
1824
|
+
g < this.pointerDistance && g < i && (i = g, e = this.store.getPropertiesCopy(u));
|
|
1825
1825
|
}), !e) return;
|
|
1826
1826
|
const o = e.selectionPointFeatureId, s = e.index, n = this.store.getPropertiesCopy(o), a = this.flags[n.mode], l = this.validations[n.mode];
|
|
1827
1827
|
if (!(a && a.feature && a.feature.coordinates && a.feature.coordinates.deletable)) return;
|
|
@@ -1973,7 +1973,7 @@ class Gt extends qe {
|
|
|
1973
1973
|
}
|
|
1974
1974
|
}
|
|
1975
1975
|
}
|
|
1976
|
-
class
|
|
1976
|
+
class ki extends A {
|
|
1977
1977
|
constructor(...t) {
|
|
1978
1978
|
super(...t), this.type = H.Static, this.mode = "static";
|
|
1979
1979
|
}
|
|
@@ -2001,11 +2001,11 @@ class _i extends A {
|
|
|
2001
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 });
|
|
2002
2002
|
}
|
|
2003
2003
|
}
|
|
2004
|
-
function
|
|
2004
|
+
function We(r, t, e, i, o) {
|
|
2005
2005
|
for (; i > e; ) {
|
|
2006
2006
|
if (i - e > 600) {
|
|
2007
|
-
const l = i - e + 1, d = t - e + 1, c = Math.log(l), h = 0.5 * Math.exp(2 * c / 3),
|
|
2008
|
-
|
|
2007
|
+
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
|
+
We(r, t, Math.max(e, Math.floor(t - d * h / l + u)), Math.min(i, Math.floor(t + (l - d) * h / l + u)), o);
|
|
2009
2009
|
}
|
|
2010
2010
|
const s = r[t];
|
|
2011
2011
|
let n = e, a = i;
|
|
@@ -2034,23 +2034,23 @@ function nt(r, t, e, i, o) {
|
|
|
2034
2034
|
function at(r, t) {
|
|
2035
2035
|
return r.minX = Math.min(r.minX, t.minX), r.minY = Math.min(r.minY, t.minY), r.maxX = Math.max(r.maxX, t.maxX), r.maxY = Math.max(r.maxY, t.maxY), r;
|
|
2036
2036
|
}
|
|
2037
|
-
function
|
|
2037
|
+
function Ni(r, t) {
|
|
2038
2038
|
return r.minX - t.minX;
|
|
2039
2039
|
}
|
|
2040
|
-
function
|
|
2040
|
+
function Ti(r, t) {
|
|
2041
2041
|
return r.minY - t.minY;
|
|
2042
2042
|
}
|
|
2043
|
-
function
|
|
2043
|
+
function Lt(r) {
|
|
2044
2044
|
return (r.maxX - r.minX) * (r.maxY - r.minY);
|
|
2045
2045
|
}
|
|
2046
2046
|
function ft(r) {
|
|
2047
2047
|
return r.maxX - r.minX + (r.maxY - r.minY);
|
|
2048
2048
|
}
|
|
2049
|
-
function
|
|
2049
|
+
function Wi(r, t) {
|
|
2050
2050
|
const e = Math.max(r.minX, t.minX), i = Math.max(r.minY, t.minY), o = Math.min(r.maxX, t.maxX), s = Math.min(r.maxY, t.maxY);
|
|
2051
2051
|
return Math.max(0, o - e) * Math.max(0, s - i);
|
|
2052
2052
|
}
|
|
2053
|
-
function
|
|
2053
|
+
function Ft(r, t) {
|
|
2054
2054
|
return r.minX <= t.minX && r.minY <= t.minY && t.maxX <= r.maxX && t.maxY <= r.maxY;
|
|
2055
2055
|
}
|
|
2056
2056
|
function mt(r, t) {
|
|
@@ -2059,15 +2059,15 @@ function mt(r, t) {
|
|
|
2059
2059
|
function Z(r) {
|
|
2060
2060
|
return { children: r, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
|
|
2061
2061
|
}
|
|
2062
|
-
function
|
|
2062
|
+
function he(r, t, e, i, o) {
|
|
2063
2063
|
const s = [t, e];
|
|
2064
2064
|
for (; s.length; ) {
|
|
2065
2065
|
if ((e = s.pop()) - (t = s.pop()) <= i) continue;
|
|
2066
2066
|
const n = t + Math.ceil((e - t) / i / 2) * i;
|
|
2067
|
-
|
|
2067
|
+
We(r, n, t, e, o), s.push(t, n, n, e);
|
|
2068
2068
|
}
|
|
2069
2069
|
}
|
|
2070
|
-
class
|
|
2070
|
+
class Bi {
|
|
2071
2071
|
constructor(t) {
|
|
2072
2072
|
this._maxEntries = void 0, this._minEntries = void 0, this.data = void 0, this._maxEntries = Math.max(4, t), this._minEntries = Math.max(2, Math.ceil(0.4 * this._maxEntries)), this.clear();
|
|
2073
2073
|
}
|
|
@@ -2079,7 +2079,7 @@ class Wi {
|
|
|
2079
2079
|
for (; e; ) {
|
|
2080
2080
|
for (let n = 0; n < e.children.length; n++) {
|
|
2081
2081
|
const a = e.children[n], l = e.leaf ? o(a) : a;
|
|
2082
|
-
mt(t, l) && (e.leaf ? i.push(a) :
|
|
2082
|
+
mt(t, l) && (e.leaf ? i.push(a) : Ft(t, l) ? this._all(a, i) : s.push(a));
|
|
2083
2083
|
}
|
|
2084
2084
|
e = s.pop();
|
|
2085
2085
|
}
|
|
@@ -2093,7 +2093,7 @@ class Wi {
|
|
|
2093
2093
|
for (let o = 0; o < e.children.length; o++) {
|
|
2094
2094
|
const s = e.children[o], n = e.leaf ? this.toBBox(s) : s;
|
|
2095
2095
|
if (mt(t, n)) {
|
|
2096
|
-
if (e.leaf ||
|
|
2096
|
+
if (e.leaf || Ft(t, n)) return !0;
|
|
2097
2097
|
i.push(s);
|
|
2098
2098
|
}
|
|
2099
2099
|
}
|
|
@@ -2133,7 +2133,7 @@ class Wi {
|
|
|
2133
2133
|
const d = e.children.indexOf(t);
|
|
2134
2134
|
d !== -1 && (e.children.splice(d, 1), o.push(e), this._condense(o));
|
|
2135
2135
|
}
|
|
2136
|
-
l || e.leaf || !
|
|
2136
|
+
l || e.leaf || !Ft(e, i) ? a ? (n++, e = a.children[n], l = !1) : e = null : (o.push(e), s.push(n), n = 0, a = e, e = e.children[0]);
|
|
2137
2137
|
}
|
|
2138
2138
|
}
|
|
2139
2139
|
toBBox(t) {
|
|
@@ -2156,13 +2156,13 @@ class Wi {
|
|
|
2156
2156
|
if (s <= a) return n = Z(t.slice(e, i + 1)), J(n, this.toBBox), n;
|
|
2157
2157
|
o || (o = Math.ceil(Math.log(s) / Math.log(a)), a = Math.ceil(s / Math.pow(a, o - 1))), n = Z([]), n.leaf = !1, n.height = o;
|
|
2158
2158
|
const l = Math.ceil(s / a), d = l * Math.ceil(Math.sqrt(a));
|
|
2159
|
-
|
|
2159
|
+
he(t, e, i, d, this.compareMinX);
|
|
2160
2160
|
for (let c = e; c <= i; c += d) {
|
|
2161
2161
|
const h = Math.min(c + d - 1, i);
|
|
2162
|
-
|
|
2163
|
-
for (let
|
|
2164
|
-
const
|
|
2165
|
-
n.children.push(this._build(t,
|
|
2162
|
+
he(t, c, h, l, this.compareMinY);
|
|
2163
|
+
for (let u = c; u <= h; u += l) {
|
|
2164
|
+
const p = Math.min(u + l - 1, h);
|
|
2165
|
+
n.children.push(this._build(t, u, p, o - 1));
|
|
2166
2166
|
}
|
|
2167
2167
|
}
|
|
2168
2168
|
return J(n, this.toBBox), n;
|
|
@@ -2171,8 +2171,8 @@ class Wi {
|
|
|
2171
2171
|
for (; o.push(e), !e.leaf && o.length - 1 !== i; ) {
|
|
2172
2172
|
let a, l = 1 / 0, d = 1 / 0;
|
|
2173
2173
|
for (let c = 0; c < e.children.length; c++) {
|
|
2174
|
-
const h = e.children[c],
|
|
2175
|
-
|
|
2174
|
+
const h = e.children[c], u = Lt(h), p = (s = t, n = h, (Math.max(n.maxX, s.maxX) - Math.min(n.minX, s.minX)) * (Math.max(n.maxY, s.maxY) - Math.min(n.minY, s.minY)) - u);
|
|
2175
|
+
p < d ? (d = p, l = u < l ? u : l, a = h) : p === d && u < l && (l = u, a = h);
|
|
2176
2176
|
}
|
|
2177
2177
|
e = a || e.children[0];
|
|
2178
2178
|
}
|
|
@@ -2196,13 +2196,13 @@ class Wi {
|
|
|
2196
2196
|
_chooseSplitIndex(t, e, i) {
|
|
2197
2197
|
let o, s = 1 / 0, n = 1 / 0;
|
|
2198
2198
|
for (let a = e; a <= i - e; a++) {
|
|
2199
|
-
const l = nt(t, 0, a, this.toBBox), d = nt(t, a, i, this.toBBox), c =
|
|
2199
|
+
const l = nt(t, 0, a, this.toBBox), d = nt(t, a, i, this.toBBox), c = Wi(l, d), h = Lt(l) + Lt(d);
|
|
2200
2200
|
c < s ? (s = c, o = a, n = h < n ? h : n) : c === s && h < n && (n = h, o = a);
|
|
2201
2201
|
}
|
|
2202
2202
|
return o || i - e;
|
|
2203
2203
|
}
|
|
2204
2204
|
_chooseSplitAxis(t, e, i) {
|
|
2205
|
-
const o = t.leaf ? this.compareMinX :
|
|
2205
|
+
const o = t.leaf ? this.compareMinX : Ni, s = t.leaf ? this.compareMinY : Ti;
|
|
2206
2206
|
this._allDistMargin(t, e, i, o) < this._allDistMargin(t, e, i, s) && t.children.sort(o);
|
|
2207
2207
|
}
|
|
2208
2208
|
_allDistMargin(t, e, i, o) {
|
|
@@ -2226,9 +2226,9 @@ class Wi {
|
|
|
2226
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() : J(t[i], this.toBBox);
|
|
2227
2227
|
}
|
|
2228
2228
|
}
|
|
2229
|
-
class
|
|
2229
|
+
class ji {
|
|
2230
2230
|
constructor(t) {
|
|
2231
|
-
this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new
|
|
2231
|
+
this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new Bi(t && t.maxEntries ? t.maxEntries : 9), this.idToNode = /* @__PURE__ */ new Map(), this.nodeToId = /* @__PURE__ */ new Map();
|
|
2232
2232
|
}
|
|
2233
2233
|
setMaps(t, e) {
|
|
2234
2234
|
this.idToNode.set(t.id, e), this.nodeToId.set(e, t.id);
|
|
@@ -2279,14 +2279,14 @@ class Bi {
|
|
|
2279
2279
|
return this.tree.collides(this.toBBox(t));
|
|
2280
2280
|
}
|
|
2281
2281
|
}
|
|
2282
|
-
const
|
|
2282
|
+
const Ai = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(r) {
|
|
2283
2283
|
const t = 16 * Math.random() | 0;
|
|
2284
2284
|
return (r == "x" ? t : 3 & t | 8).toString(16);
|
|
2285
2285
|
}), isValidId: (r) => typeof r == "string" && r.length === 36 };
|
|
2286
|
-
class
|
|
2286
|
+
class Ri {
|
|
2287
2287
|
constructor(t) {
|
|
2288
2288
|
this.idStrategy = void 0, this.tracked = void 0, this.spatialIndex = void 0, this.store = void 0, this._onChange = () => {
|
|
2289
|
-
}, this.store = {}, this.spatialIndex = new
|
|
2289
|
+
}, this.store = {}, this.spatialIndex = new ji(), this.tracked = !t || t.tracked !== !1, this.idStrategy = t && t.idStrategy ? t.idStrategy : Ai;
|
|
2290
2290
|
}
|
|
2291
2291
|
clone(t) {
|
|
2292
2292
|
return JSON.parse(JSON.stringify(t));
|
|
@@ -2310,10 +2310,10 @@ class Ai {
|
|
|
2310
2310
|
}
|
|
2311
2311
|
if (this.tracked) {
|
|
2312
2312
|
if (d.properties.createdAt) {
|
|
2313
|
-
if (!
|
|
2313
|
+
if (!Qt(d.properties.createdAt)) return n.push({ id: d.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
|
|
2314
2314
|
} else d.properties.createdAt = +/* @__PURE__ */ new Date();
|
|
2315
2315
|
if (d.properties.updatedAt) {
|
|
2316
|
-
if (!
|
|
2316
|
+
if (!Qt(d.properties.updatedAt)) return n.push({ id: d.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
|
|
2317
2317
|
} else d.properties.updatedAt = +/* @__PURE__ */ new Date();
|
|
2318
2318
|
}
|
|
2319
2319
|
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);
|
|
@@ -2390,16 +2390,16 @@ class Ai {
|
|
|
2390
2390
|
return Object.keys(this.store).length;
|
|
2391
2391
|
}
|
|
2392
2392
|
}
|
|
2393
|
-
const
|
|
2394
|
-
function
|
|
2393
|
+
const Gi = "Feature is not a Polygon or LineString", Ui = "Feature intersects itself", zi = (r) => r.geometry.type !== "Polygon" && r.geometry.type !== "LineString" ? { valid: !1, reason: Gi } : Bt(r) ? { valid: !1, reason: Ui } : { valid: !0 };
|
|
2394
|
+
function ue(r, t, e) {
|
|
2395
2395
|
const i = G(r, t);
|
|
2396
2396
|
let o = G(t, e) - i;
|
|
2397
2397
|
return o < 0 && (o += 360), 180 - Math.abs(o - 90 - 90);
|
|
2398
2398
|
}
|
|
2399
|
-
const
|
|
2400
|
-
class
|
|
2399
|
+
const Vi = { cancel: "Escape", finish: "Enter" }, $i = { start: "crosshair", close: "pointer" };
|
|
2400
|
+
class Be extends A {
|
|
2401
2401
|
constructor(t) {
|
|
2402
|
-
super(t, !0), this.mode = "angled-rectangle", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents =
|
|
2402
|
+
super(t, !0), this.mode = "angled-rectangle", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = Vi, this.cursors = $i, this.mouseMove = !1, this.updateOptions(t);
|
|
2403
2403
|
}
|
|
2404
2404
|
updateOptions(t) {
|
|
2405
2405
|
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));
|
|
@@ -2424,7 +2424,7 @@ class We extends A {
|
|
|
2424
2424
|
const o = 1 / Math.pow(10, this.coordinatePrecision - 1), s = Math.max(1e-6, o);
|
|
2425
2425
|
i = [e[0], [t.lng, t.lat], [t.lng, t.lat - s], e[0]];
|
|
2426
2426
|
} else if (this.currentCoordinate === 2) {
|
|
2427
|
-
const o = e[0], s = e[1], n =
|
|
2427
|
+
const o = e[0], s = e[1], n = _e(o, s, this.coordinatePrecision, this.project, this.unproject), a = O(o[0], o[1]), l = O(n[0], n[1]), d = O(s[0], s[1]), c = O(t.lng, t.lat), h = F(c, a) < F(c, d), u = ue(a, l, c), p = h ? 90 - u : ue(a, l, c) - 90, g = F(l, c), y = Math.cos(D(p)) * g, m = G(a, d) + ((function(I, E, L) {
|
|
2428
2428
|
const M = (L.x - E.x) * (I.y - E.y) - (L.y - E.y) * (I.x - E.x);
|
|
2429
2429
|
return M > 1e-10 ? "left" : M < -1e-10 ? "right" : "left";
|
|
2430
2430
|
})(a, d, c) === "right" ? -90 : 90), v = ht(a, y, m), C = ht(d, y, m), f = R(v.x, v.y), P = R(C.x, C.y);
|
|
@@ -2479,13 +2479,13 @@ class We extends A {
|
|
|
2479
2479
|
this.currentId === t.id && (this.currentId = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted());
|
|
2480
2480
|
}
|
|
2481
2481
|
}
|
|
2482
|
-
function
|
|
2482
|
+
function je(r, t, e) {
|
|
2483
2483
|
return (t.x - r.x) * (e.y - r.y) - (t.y - r.y) * (e.x - r.x) <= 0;
|
|
2484
2484
|
}
|
|
2485
|
-
const
|
|
2486
|
-
class
|
|
2485
|
+
const Yi = { cancel: "Escape", finish: "Enter" }, Ki = { start: "crosshair", close: "pointer" };
|
|
2486
|
+
class Ae extends A {
|
|
2487
2487
|
constructor(t) {
|
|
2488
|
-
super(t, !0), this.mode = "sector", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents =
|
|
2488
|
+
super(t, !0), this.mode = "sector", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = Yi, this.direction = void 0, this.arcPoints = 64, this.cursors = Ki, this.mouseMove = !1, this.updateOptions(t);
|
|
2489
2489
|
}
|
|
2490
2490
|
updateOptions(t) {
|
|
2491
2491
|
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);
|
|
@@ -2513,15 +2513,15 @@ class je extends A {
|
|
|
2513
2513
|
} else if (this.currentCoordinate === 2) {
|
|
2514
2514
|
const o = e[0], s = e[1], n = [t.lng, t.lat], a = O(o[0], o[1]), l = O(s[0], s[1]), d = O(n[0], n[1]);
|
|
2515
2515
|
if (this.direction === void 0) {
|
|
2516
|
-
const f =
|
|
2516
|
+
const f = je(a, l, d);
|
|
2517
2517
|
this.direction = f ? "clockwise" : "anticlockwise";
|
|
2518
2518
|
}
|
|
2519
|
-
const c = F(a, l), h = G(a, l),
|
|
2519
|
+
const c = F(a, l), h = G(a, l), u = G(a, d), p = this.arcPoints, g = [o], y = X(h), m = X(u);
|
|
2520
2520
|
let v;
|
|
2521
2521
|
this.direction === "anticlockwise" ? (v = m - y, v < 0 && (v += 360)) : (v = y - m, v < 0 && (v += 360));
|
|
2522
|
-
const C = (this.direction === "anticlockwise" ? 1 : -1) * v /
|
|
2522
|
+
const C = (this.direction === "anticlockwise" ? 1 : -1) * v / p;
|
|
2523
2523
|
g.push(s);
|
|
2524
|
-
for (let f = 0; f <=
|
|
2524
|
+
for (let f = 0; f <= p; f++) {
|
|
2525
2525
|
const P = ht(a, c, y + f * C), { lng: I, lat: E } = R(P.x, P.y), L = [w(I, this.coordinatePrecision), w(E, this.coordinatePrecision)];
|
|
2526
2526
|
L[0] !== g[g.length - 1][0] && L[1] !== g[g.length - 1][1] && g.push(L);
|
|
2527
2527
|
}
|
|
@@ -2572,10 +2572,10 @@ class je extends A {
|
|
|
2572
2572
|
this.currentId === t.id && (this.currentId = void 0, this.direction = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted());
|
|
2573
2573
|
}
|
|
2574
2574
|
}
|
|
2575
|
-
const
|
|
2576
|
-
class
|
|
2575
|
+
const Xi = { cancel: "Escape", finish: "Enter" }, Hi = { start: "crosshair", close: "pointer" };
|
|
2576
|
+
class Re extends A {
|
|
2577
2577
|
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 =
|
|
2578
|
+
super(t, !0), this.mode = "sensor", this.currentCoordinate = 0, this.currentId = void 0, this.currentInitialArcId = void 0, this.currentStartingPointId = void 0, this.keyEvents = Xi, this.direction = void 0, this.arcPoints = 64, this.cursors = Hi, this.mouseMove = !1, this.updateOptions(t);
|
|
2579
2579
|
}
|
|
2580
2580
|
updateOptions(t) {
|
|
2581
2581
|
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);
|
|
@@ -2600,22 +2600,22 @@ class Ae extends A {
|
|
|
2600
2600
|
if (this.currentCoordinate === 2) {
|
|
2601
2601
|
const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = [t.lng, t.lat], n = O(o[0], o[1]), a = O(s[0], s[1]), l = O(i[0], i[1]), d = F(l, n);
|
|
2602
2602
|
if (this.direction === void 0) {
|
|
2603
|
-
const C =
|
|
2603
|
+
const C = je(l, n, a);
|
|
2604
2604
|
this.direction = C ? "clockwise" : "anticlockwise";
|
|
2605
2605
|
}
|
|
2606
|
-
const c = G(l, n), h = G(l, a),
|
|
2606
|
+
const c = G(l, n), h = G(l, a), u = this.arcPoints, p = [o], g = X(c), y = X(h);
|
|
2607
2607
|
let m;
|
|
2608
2608
|
this.direction === "anticlockwise" ? (m = y - g, m < 0 && (m += 360)) : (m = g - y, m < 0 && (m += 360));
|
|
2609
|
-
const v = (this.direction === "anticlockwise" ? 1 : -1) * m /
|
|
2610
|
-
for (let C = 0; C <=
|
|
2609
|
+
const v = (this.direction === "anticlockwise" ? 1 : -1) * m / u;
|
|
2610
|
+
for (let C = 0; C <= u; C++) {
|
|
2611
2611
|
const f = ht(l, d, g + C * v), { lng: P, lat: I } = R(f.x, f.y), E = [w(P, this.coordinatePrecision), w(I, this.coordinatePrecision)];
|
|
2612
|
-
E[0] !==
|
|
2612
|
+
E[0] !== p[p.length - 1][0] && E[1] !== p[p.length - 1][1] && p.push(E);
|
|
2613
2613
|
}
|
|
2614
|
-
this.updateLineStringGeometry(this.currentInitialArcId,
|
|
2614
|
+
this.updateLineStringGeometry(this.currentInitialArcId, p, b.Provisional);
|
|
2615
2615
|
} else if (this.currentCoordinate === 3) {
|
|
2616
2616
|
const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates;
|
|
2617
2617
|
if (e.length < 2 || !this.direction) return;
|
|
2618
|
-
const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = e[e.length - 1], n = O(t.lng, t.lat), a = O(o[0], o[1]), l = O(s[0], s[1]), d = O(i[0], i[1]), c = F(d, a), h = F(d, n) < c ? a : n,
|
|
2618
|
+
const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = e[e.length - 1], n = O(t.lng, t.lat), a = O(o[0], o[1]), l = O(s[0], s[1]), d = O(i[0], i[1]), c = F(d, a), h = F(d, n) < c ? a : n, u = G(d, n), p = G(d, a), g = G(d, l), y = X(p), m = X(g), v = X(u);
|
|
2619
2619
|
if (this.notInSector({ normalizedCursor: v, normalizedStart: y, normalizedEnd: m, direction: this.direction })) return;
|
|
2620
2620
|
const C = this.getDeltaBearing(this.direction, y, m), f = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * C / f, I = F(d, h), E = [];
|
|
2621
2621
|
for (let L = 0; L <= f; L++) {
|
|
@@ -2688,7 +2688,7 @@ class q {
|
|
|
2688
2688
|
}, this.callback = e;
|
|
2689
2689
|
}
|
|
2690
2690
|
}
|
|
2691
|
-
var
|
|
2691
|
+
var Ji = { __proto__: null, TerraDrawBaseAdapter: class {
|
|
2692
2692
|
constructor(r) {
|
|
2693
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 r.minPixelDragDistance == "number" ? r.minPixelDragDistance : 1, this._minPixelDragDistanceSelecting = typeof r.minPixelDragDistanceSelecting == "number" ? r.minPixelDragDistanceSelecting : 1, this._minPixelDragDistanceDrawing = typeof r.minPixelDragDistanceDrawing == "number" ? r.minPixelDragDistanceDrawing : 8, this._coordinatePrecision = typeof r.coordinatePrecision == "number" ? r.coordinatePrecision : 9;
|
|
2694
2694
|
}
|
|
@@ -2778,10 +2778,10 @@ var Hi = { __proto__: null, TerraDrawBaseAdapter: class {
|
|
|
2778
2778
|
}), this.clear(), this._currentModeCallbacks = void 0;
|
|
2779
2779
|
}
|
|
2780
2780
|
} };
|
|
2781
|
-
const
|
|
2782
|
-
class
|
|
2781
|
+
const qi = { cancel: "Escape", finish: "Enter" }, Zi = { start: "crosshair", close: "pointer" };
|
|
2782
|
+
class Ge extends A {
|
|
2783
2783
|
constructor(t) {
|
|
2784
|
-
super(t, !0), this.mode = "freehand-linestring", this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.minDistance = 20, this.keyEvents =
|
|
2784
|
+
super(t, !0), this.mode = "freehand-linestring", this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.minDistance = 20, this.keyEvents = qi, this.cursors = Zi, this.preventNewFeature = !1, this.updateOptions(t);
|
|
2785
2785
|
}
|
|
2786
2786
|
updateOptions(t) {
|
|
2787
2787
|
super.updateOptions(t), t != null && t.minDistance && (this.minDistance = t.minDistance), t?.keyEvents === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = x({}, this.keyEvents, t.keyEvents)), t != null && t.cursors && (this.cursors = x({}, this.cursors, t.cursors));
|
|
@@ -2804,8 +2804,8 @@ class Re extends A {
|
|
|
2804
2804
|
}
|
|
2805
2805
|
onMouseMove(t) {
|
|
2806
2806
|
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, s] = e.coordinates[i], { x: n, y: a } = this.project(o, s), l = F({ x: n, y: a }, { x: t.containerX, y: t.containerY }), [d, c] = e.coordinates[e.coordinates.length - 1], { x: h, y:
|
|
2808
|
-
if (this.setCursor(
|
|
2807
|
+
const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates.length - 2, [o, s] = e.coordinates[i], { x: n, y: a } = this.project(o, s), l = F({ 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 = F({ x: h, y: u }, { x: t.containerX, y: t.containerY });
|
|
2808
|
+
if (this.setCursor(p < this.pointerDistance ? this.cursors.close : this.cursors.start), l < this.minDistance) return;
|
|
2809
2809
|
const g = { type: "LineString", coordinates: [...e.coordinates, [t.lng, t.lat]] };
|
|
2810
2810
|
this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: g, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.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] } }]));
|
|
2811
2811
|
}
|
|
@@ -2843,13 +2843,13 @@ class Re extends A {
|
|
|
2843
2843
|
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
2844
|
}
|
|
2845
2845
|
validateFeature(t) {
|
|
2846
|
-
return this.validateModeFeature(t, (e) =>
|
|
2846
|
+
return this.validateModeFeature(t, (e) => At(e, this.coordinatePrecision));
|
|
2847
2847
|
}
|
|
2848
2848
|
afterFeatureUpdated(t) {
|
|
2849
2849
|
this.currentId === t.id && (this.closingPointId && this.store.delete([this.closingPointId]), this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0);
|
|
2850
2850
|
}
|
|
2851
2851
|
}
|
|
2852
|
-
function
|
|
2852
|
+
function Tt(r) {
|
|
2853
2853
|
if (r === null || typeof r == "boolean" || typeof r == "string") return !0;
|
|
2854
2854
|
if (r === void 0) return !1;
|
|
2855
2855
|
if (typeof r == "number") return Number.isFinite(r);
|
|
@@ -2860,13 +2860,13 @@ function kt(r) {
|
|
|
2860
2860
|
}
|
|
2861
2861
|
if (ArrayBuffer.isView(r) && !(r instanceof DataView)) return !1;
|
|
2862
2862
|
if (Array.isArray(r)) {
|
|
2863
|
-
for (const t of r) if (!
|
|
2863
|
+
for (const t of r) if (!Tt(t)) return !1;
|
|
2864
2864
|
}
|
|
2865
|
-
return typeof r == "object" && Object.keys(r).every((t) => typeof t == "string" &&
|
|
2865
|
+
return typeof r == "object" && Object.keys(r).every((t) => typeof t == "string" && Tt(r[t]));
|
|
2866
2866
|
}
|
|
2867
|
-
class
|
|
2867
|
+
class Qi {
|
|
2868
2868
|
constructor(t) {
|
|
2869
|
-
this._modes = void 0, this._mode = void 0, this._adapter = void 0, this._enabled = !1, this._store = void 0, this._eventListeners = void 0, this._instanceSelectMode = void 0, this._adapter = t.adapter, this._mode = new
|
|
2869
|
+
this._modes = void 0, this._mode = void 0, this._adapter = void 0, this._enabled = !1, this._store = void 0, this._eventListeners = void 0, this._instanceSelectMode = void 0, this._adapter = t.adapter, this._mode = new ki();
|
|
2870
2870
|
const e = /* @__PURE__ */ new Set(), i = t.modes.reduce((c, h) => {
|
|
2871
2871
|
if (e.has(h.mode)) throw new Error(`There is already a ${h.mode} mode provided`);
|
|
2872
2872
|
return e.add(h.mode), c[h.mode] = h, c;
|
|
@@ -2877,35 +2877,35 @@ class Zi {
|
|
|
2877
2877
|
if (this._instanceSelectMode) throw new Error("only one type of select mode can be provided");
|
|
2878
2878
|
this._instanceSelectMode = c;
|
|
2879
2879
|
}
|
|
2880
|
-
}), this._modes = x({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new
|
|
2880
|
+
}), this._modes = x({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new Ri({ tracked: !!t.tracked, idStrategy: t.idStrategy ? t.idStrategy : void 0 });
|
|
2881
2881
|
const s = (c) => {
|
|
2882
|
-
const h = [],
|
|
2883
|
-
return { changed: h, unchanged:
|
|
2882
|
+
const h = [], u = this._store.copyAll().filter((p) => !c.includes(p.id) || (h.push(p), !1));
|
|
2883
|
+
return { changed: h, unchanged: u };
|
|
2884
2884
|
}, n = (c, h) => {
|
|
2885
|
-
this._enabled && this._eventListeners.finish.forEach((
|
|
2886
|
-
|
|
2885
|
+
this._enabled && this._eventListeners.finish.forEach((u) => {
|
|
2886
|
+
u(c, h);
|
|
2887
2887
|
});
|
|
2888
|
-
}, a = (c, h,
|
|
2888
|
+
}, a = (c, h, u) => {
|
|
2889
2889
|
if (!this._enabled) return;
|
|
2890
2890
|
this._eventListeners.change.forEach((y) => {
|
|
2891
|
-
y(c, h,
|
|
2891
|
+
y(c, h, u);
|
|
2892
2892
|
});
|
|
2893
|
-
const { changed:
|
|
2894
|
-
h === "create" ? this._adapter.render({ created:
|
|
2893
|
+
const { changed: p, unchanged: g } = s(c);
|
|
2894
|
+
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
2895
|
}, l = (c) => {
|
|
2896
2896
|
if (!this._enabled) return;
|
|
2897
|
-
this._eventListeners.select.forEach((
|
|
2898
|
-
|
|
2897
|
+
this._eventListeners.select.forEach((p) => {
|
|
2898
|
+
p(c);
|
|
2899
2899
|
});
|
|
2900
|
-
const { changed: h, unchanged:
|
|
2901
|
-
this._adapter.render({ created: [], deletedIds: [], unchanged:
|
|
2900
|
+
const { changed: h, unchanged: u } = s([c]);
|
|
2901
|
+
this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: h }, this.getModeStyles());
|
|
2902
2902
|
}, d = (c) => {
|
|
2903
2903
|
if (!this._enabled) return;
|
|
2904
|
-
this._eventListeners.deselect.forEach((
|
|
2905
|
-
|
|
2904
|
+
this._eventListeners.deselect.forEach((p) => {
|
|
2905
|
+
p();
|
|
2906
2906
|
});
|
|
2907
|
-
const { changed: h, unchanged:
|
|
2908
|
-
h && this._adapter.render({ created: [], deletedIds: [], unchanged:
|
|
2907
|
+
const { changed: h, unchanged: u } = s([c]);
|
|
2908
|
+
h && this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: h }, this.getModeStyles());
|
|
2909
2909
|
};
|
|
2910
2910
|
Object.keys(this._modes).forEach((c) => {
|
|
2911
2911
|
this._modes[c].register({ mode: c, store: this._store, setCursor: this._adapter.setCursor.bind(this._adapter), project: this._adapter.project.bind(this._adapter), unproject: this._adapter.unproject.bind(this._adapter), setDoubleClickToZoom: this._adapter.setDoubleClickToZoom.bind(this._adapter), onChange: a, onSelect: l, onDeselect: d, onFinish: n, coordinatePrecision: this._adapter.getCoordinatePrecision() });
|
|
@@ -2921,44 +2921,44 @@ class Zi {
|
|
|
2921
2921
|
}), t;
|
|
2922
2922
|
}
|
|
2923
2923
|
featuresAtLocation({ lng: t, lat: e }, i) {
|
|
2924
|
-
const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, s = !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 = this._adapter.unproject.bind(this._adapter), c = this._adapter.project.bind(this._adapter), h = c(t, e),
|
|
2925
|
-
return this._store.search(
|
|
2926
|
-
if (s && (
|
|
2927
|
-
if (
|
|
2928
|
-
const g =
|
|
2924
|
+
const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, s = !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 = this._adapter.unproject.bind(this._adapter), c = this._adapter.project.bind(this._adapter), h = c(t, e), u = Ee({ unproject: d, point: h, pointerDistance: o });
|
|
2925
|
+
return this._store.search(u).filter((p) => {
|
|
2926
|
+
if (s && (p.properties[k.MID_POINT] || p.properties[k.SELECTION_POINT]) || n && p.properties[S.COORDINATE_POINT] || l && p.properties[S.CLOSING_POINT] || a && p.properties[S.CURRENTLY_DRAWING]) return !1;
|
|
2927
|
+
if (p.geometry.type === "Point") {
|
|
2928
|
+
const g = p.geometry.coordinates, y = c(g[0], g[1]);
|
|
2929
2929
|
return F(h, y) < o;
|
|
2930
2930
|
}
|
|
2931
|
-
if (
|
|
2932
|
-
const g =
|
|
2931
|
+
if (p.geometry.type === "LineString") {
|
|
2932
|
+
const g = p.geometry.coordinates;
|
|
2933
2933
|
for (let y = 0; y < g.length - 1; y++) {
|
|
2934
2934
|
const m = g[y], v = g[y + 1];
|
|
2935
|
-
if (
|
|
2935
|
+
if (kt(h, c(m[0], m[1]), c(v[0], v[1])) < o) return !0;
|
|
2936
2936
|
}
|
|
2937
2937
|
return !1;
|
|
2938
2938
|
}
|
|
2939
|
-
if (
|
|
2939
|
+
if (ke([t, e], p.geometry.coordinates)) return !0;
|
|
2940
2940
|
if (i != null && i.includePolygonsWithinPointerDistance) {
|
|
2941
|
-
const g =
|
|
2941
|
+
const g = p.geometry.coordinates;
|
|
2942
2942
|
for (const y of g) for (let m = 0; m < y.length - 1; m++) {
|
|
2943
2943
|
const v = y[m], C = y[m + 1], f = c(v[0], v[1]), P = c(C[0], C[1]);
|
|
2944
|
-
if (
|
|
2944
|
+
if (kt(h, f, P) < o) return !0;
|
|
2945
2945
|
}
|
|
2946
2946
|
}
|
|
2947
2947
|
return !1;
|
|
2948
|
-
}).map((
|
|
2949
|
-
if (i == null || !i.addClosestCoordinateInfoToProperties) return
|
|
2948
|
+
}).map((p) => {
|
|
2949
|
+
if (i == null || !i.addClosestCoordinateInfoToProperties) return p;
|
|
2950
2950
|
let g;
|
|
2951
|
-
if (
|
|
2951
|
+
if (p.geometry.type === "Polygon") g = p.geometry.coordinates[0], g.pop();
|
|
2952
2952
|
else {
|
|
2953
|
-
if (
|
|
2954
|
-
g =
|
|
2953
|
+
if (p.geometry.type !== "LineString") return p;
|
|
2954
|
+
g = p.geometry.coordinates;
|
|
2955
2955
|
}
|
|
2956
2956
|
let y, m = -1, v = 1 / 0;
|
|
2957
2957
|
for (let C = 0; C < g.length; C++) {
|
|
2958
2958
|
const f = g[C], P = F(c(f[0], f[1]), h);
|
|
2959
2959
|
P < v && (m = C, v = P, y = f);
|
|
2960
2960
|
}
|
|
2961
|
-
return
|
|
2961
|
+
return p.properties.closestCoordinateIndexToEvent = m, p.properties.closestCoordinatePixelDistanceToEvent = v, p.properties.closestCoordinateDistanceKmToEvent = U(y, [t, e]), p;
|
|
2962
2962
|
});
|
|
2963
2963
|
}
|
|
2964
2964
|
getSelectModeOrThrow() {
|
|
@@ -3040,7 +3040,7 @@ class Zi {
|
|
|
3040
3040
|
const s = Object.entries(e);
|
|
3041
3041
|
s.forEach(([n, a]) => {
|
|
3042
3042
|
if (!this.checkIsReservedProperty(n)) throw new Error(`You are trying to update a reserved property name: ${n}. Please choose another name.`);
|
|
3043
|
-
if (a !== void 0 && !
|
|
3043
|
+
if (a !== void 0 && !Tt(a)) throw new Error(`Invalid JSON value provided for property ${n}`);
|
|
3044
3044
|
}), this._store.updateProperty(s.map(([n, a]) => ({ id: i.id, property: n, value: a })), { origin: "api" });
|
|
3045
3045
|
}
|
|
3046
3046
|
updateFeatureGeometry(t, e) {
|
|
@@ -3074,8 +3074,8 @@ class Zi {
|
|
|
3074
3074
|
if (e.projection != "web-mercator") throw new Error(`Projection ${e.projection} is not currently supported for transformation`);
|
|
3075
3075
|
if (e.type === "scale") {
|
|
3076
3076
|
const { x: a, y: l } = O(e.origin[0], e.origin[1]);
|
|
3077
|
-
|
|
3078
|
-
} else e.type === "rotate" && (i =
|
|
3077
|
+
Te({ coordinates: n, originX: a, originY: l, xScale: e.options.xScale || 1, yScale: e.options.yScale || 1 });
|
|
3078
|
+
} else e.type === "rotate" && (i = Ne(i, e.options.angle || 0), n = i.geometry.type === "Polygon" ? i.geometry.coordinates[0] : i.geometry.coordinates);
|
|
3079
3079
|
if (n = n.map((a) => [w(a[0], this._adapter.getCoordinatePrecision()), w(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" }), s.afterFeatureUpdated) {
|
|
3080
3080
|
s.afterFeatureUpdated(i);
|
|
3081
3081
|
const a = i.properties[k.SELECTED], l = this.getSelectMode({ switchToSelectMode: !1 });
|
|
@@ -3084,7 +3084,7 @@ class Zi {
|
|
|
3084
3084
|
}
|
|
3085
3085
|
addFeatures(t) {
|
|
3086
3086
|
return this.checkEnabled(), t.length === 0 ? [] : this._store.load(t, (e) => {
|
|
3087
|
-
if (
|
|
3087
|
+
if (Zt(e)) {
|
|
3088
3088
|
const i = e.properties.mode, o = this._modes[i];
|
|
3089
3089
|
if (!o) return { id: e.id, valid: !1, reason: `${i} mode is not in the list of instantiated modes` };
|
|
3090
3090
|
const s = o.validateFeature.bind(o)(e);
|
|
@@ -3092,7 +3092,7 @@ class Zi {
|
|
|
3092
3092
|
}
|
|
3093
3093
|
return { id: e.id, valid: !1, reason: "Mode property does not exist" };
|
|
3094
3094
|
}, (e) => {
|
|
3095
|
-
if (
|
|
3095
|
+
if (Zt(e)) {
|
|
3096
3096
|
const i = this._modes[e.properties.mode];
|
|
3097
3097
|
i && i.afterFeatureAdded && i.afterFeatureAdded(e);
|
|
3098
3098
|
}
|
|
@@ -3141,7 +3141,7 @@ class Zi {
|
|
|
3141
3141
|
i.includes(e) && i.splice(i.indexOf(e), 1);
|
|
3142
3142
|
}
|
|
3143
3143
|
}
|
|
3144
|
-
class
|
|
3144
|
+
class to extends Ji.TerraDrawBaseAdapter {
|
|
3145
3145
|
constructor(t) {
|
|
3146
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";
|
|
3147
3147
|
}
|
|
@@ -3206,8 +3206,8 @@ class Qi extends Hi.TerraDrawBaseAdapter {
|
|
|
3206
3206
|
if (!this._currentModeCallbacks) return;
|
|
3207
3207
|
const i = [...t.created, ...t.updated, ...t.unchanged], o = [], s = [], n = [];
|
|
3208
3208
|
for (let c = 0; c < i.length; c++) {
|
|
3209
|
-
const h = i[c], { properties:
|
|
3210
|
-
h.geometry.type === "Point" ? (
|
|
3209
|
+
const h = i[c], { properties: u } = h, p = e[u.mode](h);
|
|
3210
|
+
h.geometry.type === "Point" ? (u.pointColor = p.pointColor, u.pointOutlineColor = p.pointOutlineColor, u.pointOutlineWidth = p.pointOutlineWidth, u.pointWidth = p.pointWidth, u.zIndex = p.zIndex, o.push(h)) : h.geometry.type === "LineString" ? (u.lineStringColor = p.lineStringColor, u.lineStringWidth = p.lineStringWidth, s.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
3211
|
}
|
|
3212
3212
|
const a = this.changedIds.deletion || this.changedIds.styling, l = a || this.changedIds.linestrings, d = a || this.changedIds.polygons;
|
|
3213
3213
|
(a || this.changedIds.points) && this._setGeoJSONLayerData("Point", o), l && this._setGeoJSONLayerData("LineString", s), d && this._setGeoJSONLayerData("Polygon", n), this.changedIds = { points: !1, linestrings: !1, polygons: !1, deletion: !1, styling: !1 };
|
|
@@ -3229,7 +3229,7 @@ class Qi extends Hi.TerraDrawBaseAdapter {
|
|
|
3229
3229
|
this._renderBeforeLayerId && (this._map.moveLayer(s, this._renderBeforeLayerId), this._map.moveLayer(o, s), this._map.moveLayer(i + "-outline", o), this._map.moveLayer(i, o)), (e = this._currentModeCallbacks) != null && e.onReady && this._currentModeCallbacks.onReady();
|
|
3230
3230
|
}
|
|
3231
3231
|
}
|
|
3232
|
-
const
|
|
3232
|
+
const Vo = [
|
|
3233
3233
|
"render",
|
|
3234
3234
|
"point",
|
|
3235
3235
|
"linestring",
|
|
@@ -3245,7 +3245,7 @@ const zo = [
|
|
|
3245
3245
|
"delete-selection",
|
|
3246
3246
|
"delete",
|
|
3247
3247
|
"download"
|
|
3248
|
-
],
|
|
3248
|
+
], $o = [
|
|
3249
3249
|
"render",
|
|
3250
3250
|
"linestring",
|
|
3251
3251
|
"point",
|
|
@@ -3254,7 +3254,7 @@ const zo = [
|
|
|
3254
3254
|
"delete",
|
|
3255
3255
|
"download",
|
|
3256
3256
|
"settings"
|
|
3257
|
-
],
|
|
3257
|
+
], eo = {
|
|
3258
3258
|
modes: [
|
|
3259
3259
|
"render",
|
|
3260
3260
|
"point",
|
|
@@ -3294,7 +3294,7 @@ const zo = [
|
|
|
3294
3294
|
open: !1,
|
|
3295
3295
|
// see styling parameters of Terra Draw at https://github.com/JamesLMilner/terra-draw/blob/main/guides/5.STYLING.md
|
|
3296
3296
|
modeOptions: {
|
|
3297
|
-
point: new
|
|
3297
|
+
point: new Ut({
|
|
3298
3298
|
editable: !0,
|
|
3299
3299
|
styles: {
|
|
3300
3300
|
pointColor: "#FFFFFF",
|
|
@@ -3303,7 +3303,7 @@ const zo = [
|
|
|
3303
3303
|
pointOutlineWidth: 1
|
|
3304
3304
|
}
|
|
3305
3305
|
}),
|
|
3306
|
-
linestring: new
|
|
3306
|
+
linestring: new Gt({
|
|
3307
3307
|
editable: !0,
|
|
3308
3308
|
styles: {
|
|
3309
3309
|
lineStringColor: "#666666",
|
|
@@ -3314,7 +3314,7 @@ const zo = [
|
|
|
3314
3314
|
closingPointOutlineWidth: 1
|
|
3315
3315
|
}
|
|
3316
3316
|
}),
|
|
3317
|
-
polygon: new
|
|
3317
|
+
polygon: new Fe({
|
|
3318
3318
|
editable: !0,
|
|
3319
3319
|
styles: {
|
|
3320
3320
|
fillColor: "#EDEFF0",
|
|
@@ -3327,7 +3327,7 @@ const zo = [
|
|
|
3327
3327
|
closingPointOutlineWidth: 1
|
|
3328
3328
|
}
|
|
3329
3329
|
}),
|
|
3330
|
-
rectangle: new
|
|
3330
|
+
rectangle: new Me({
|
|
3331
3331
|
styles: {
|
|
3332
3332
|
fillColor: "#EDEFF0",
|
|
3333
3333
|
fillOpacity: 0.7,
|
|
@@ -3335,7 +3335,7 @@ const zo = [
|
|
|
3335
3335
|
outlineWidth: 2
|
|
3336
3336
|
}
|
|
3337
3337
|
}),
|
|
3338
|
-
"angled-rectangle": new
|
|
3338
|
+
"angled-rectangle": new Be({
|
|
3339
3339
|
styles: {
|
|
3340
3340
|
fillColor: "#EDEFF0",
|
|
3341
3341
|
fillOpacity: 0.7,
|
|
@@ -3343,7 +3343,7 @@ const zo = [
|
|
|
3343
3343
|
outlineWidth: 2
|
|
3344
3344
|
}
|
|
3345
3345
|
}),
|
|
3346
|
-
circle: new
|
|
3346
|
+
circle: new Oe({
|
|
3347
3347
|
styles: {
|
|
3348
3348
|
fillColor: "#EDEFF0",
|
|
3349
3349
|
fillOpacity: 0.7,
|
|
@@ -3351,7 +3351,7 @@ const zo = [
|
|
|
3351
3351
|
outlineWidth: 2
|
|
3352
3352
|
}
|
|
3353
3353
|
}),
|
|
3354
|
-
freehand: new
|
|
3354
|
+
freehand: new be({
|
|
3355
3355
|
styles: {
|
|
3356
3356
|
fillColor: "#EDEFF0",
|
|
3357
3357
|
fillOpacity: 0.7,
|
|
@@ -3363,7 +3363,7 @@ const zo = [
|
|
|
3363
3363
|
closingPointOutlineWidth: 1
|
|
3364
3364
|
}
|
|
3365
3365
|
}),
|
|
3366
|
-
"freehand-linestring": new
|
|
3366
|
+
"freehand-linestring": new Ge({
|
|
3367
3367
|
styles: {
|
|
3368
3368
|
lineStringColor: "#666666",
|
|
3369
3369
|
lineStringWidth: 2,
|
|
@@ -3373,7 +3373,7 @@ const zo = [
|
|
|
3373
3373
|
closingPointOutlineWidth: 1
|
|
3374
3374
|
}
|
|
3375
3375
|
}),
|
|
3376
|
-
sensor: new
|
|
3376
|
+
sensor: new Re({
|
|
3377
3377
|
styles: {
|
|
3378
3378
|
fillColor: "#EDEFF0",
|
|
3379
3379
|
fillOpacity: 0.7,
|
|
@@ -3385,7 +3385,7 @@ const zo = [
|
|
|
3385
3385
|
centerPointOutlineWidth: 1
|
|
3386
3386
|
}
|
|
3387
3387
|
}),
|
|
3388
|
-
sector: new
|
|
3388
|
+
sector: new Ae({
|
|
3389
3389
|
styles: {
|
|
3390
3390
|
fillColor: "#EDEFF0",
|
|
3391
3391
|
fillOpacity: 0.7,
|
|
@@ -3393,7 +3393,7 @@ const zo = [
|
|
|
3393
3393
|
outlineWidth: 2
|
|
3394
3394
|
}
|
|
3395
3395
|
}),
|
|
3396
|
-
select: new
|
|
3396
|
+
select: new zt({
|
|
3397
3397
|
flags: {
|
|
3398
3398
|
point: {
|
|
3399
3399
|
feature: {
|
|
@@ -3657,6 +3657,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3657
3657
|
},
|
|
3658
3658
|
distanceUnit: "kilometers",
|
|
3659
3659
|
distancePrecision: 2,
|
|
3660
|
+
forceDistanceUnit: "auto",
|
|
3660
3661
|
areaUnit: "metric",
|
|
3661
3662
|
areaPrecision: 2,
|
|
3662
3663
|
forceAreaUnit: "auto",
|
|
@@ -3685,7 +3686,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3685
3686
|
open: !1,
|
|
3686
3687
|
// see styling parameters of Terra Draw at https://github.com/JamesLMilner/terra-draw/blob/main/guides/5.STYLING.md
|
|
3687
3688
|
modeOptions: {
|
|
3688
|
-
point: new
|
|
3689
|
+
point: new Ut({
|
|
3689
3690
|
editable: !1,
|
|
3690
3691
|
styles: {
|
|
3691
3692
|
pointColor: "#FFFFFF",
|
|
@@ -3694,7 +3695,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3694
3695
|
pointOutlineWidth: 1
|
|
3695
3696
|
}
|
|
3696
3697
|
}),
|
|
3697
|
-
linestring: new
|
|
3698
|
+
linestring: new Gt({
|
|
3698
3699
|
editable: !1,
|
|
3699
3700
|
styles: {
|
|
3700
3701
|
lineStringColor: "#FF0000",
|
|
@@ -3705,7 +3706,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3705
3706
|
closingPointOutlineWidth: 1
|
|
3706
3707
|
}
|
|
3707
3708
|
}),
|
|
3708
|
-
select: new
|
|
3709
|
+
select: new zt({
|
|
3709
3710
|
flags: {
|
|
3710
3711
|
point: {
|
|
3711
3712
|
feature: {
|
|
@@ -3900,34 +3901,34 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3900
3901
|
"text-halo-color": "rgb(255, 255, 255)"
|
|
3901
3902
|
}
|
|
3902
3903
|
}
|
|
3903
|
-
},
|
|
3904
|
+
}, io = () => ({
|
|
3904
3905
|
render: new Q({
|
|
3905
3906
|
modeName: "render",
|
|
3906
3907
|
styles: {}
|
|
3907
3908
|
}),
|
|
3908
|
-
point: new
|
|
3909
|
+
point: new Ut({
|
|
3909
3910
|
editable: !0
|
|
3910
3911
|
}),
|
|
3911
|
-
linestring: new
|
|
3912
|
+
linestring: new Gt({
|
|
3912
3913
|
editable: !0
|
|
3913
3914
|
}),
|
|
3914
|
-
polygon: new
|
|
3915
|
+
polygon: new Fe({
|
|
3915
3916
|
editable: !0,
|
|
3916
3917
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3917
3918
|
// @ts-ignore
|
|
3918
3919
|
validation: (t, e) => {
|
|
3919
3920
|
const i = e.updateType;
|
|
3920
|
-
return i === "finish" || i === "commit" ?
|
|
3921
|
+
return i === "finish" || i === "commit" ? zi(t) : { valid: !0 };
|
|
3921
3922
|
}
|
|
3922
3923
|
}),
|
|
3923
|
-
rectangle: new
|
|
3924
|
-
"angled-rectangle": new
|
|
3925
|
-
circle: new
|
|
3926
|
-
freehand: new
|
|
3927
|
-
"freehand-linestring": new
|
|
3928
|
-
sensor: new
|
|
3929
|
-
sector: new
|
|
3930
|
-
select: new
|
|
3924
|
+
rectangle: new Me(),
|
|
3925
|
+
"angled-rectangle": new Be(),
|
|
3926
|
+
circle: new Oe(),
|
|
3927
|
+
freehand: new be(),
|
|
3928
|
+
"freehand-linestring": new Ge(),
|
|
3929
|
+
sensor: new Re(),
|
|
3930
|
+
sector: new Ae(),
|
|
3931
|
+
select: new zt({
|
|
3931
3932
|
flags: {
|
|
3932
3933
|
point: {
|
|
3933
3934
|
feature: {
|
|
@@ -4053,7 +4054,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
4053
4054
|
styles: {}
|
|
4054
4055
|
})
|
|
4055
4056
|
});
|
|
4056
|
-
var W = 63710088e-1,
|
|
4057
|
+
var W = 63710088e-1, oo = {
|
|
4057
4058
|
centimeters: W * 100,
|
|
4058
4059
|
centimetres: W * 100,
|
|
4059
4060
|
degrees: 360 / (2 * Math.PI),
|
|
@@ -4070,26 +4071,26 @@ var W = 63710088e-1, io = {
|
|
|
4070
4071
|
radians: 1,
|
|
4071
4072
|
yards: W * 1.0936
|
|
4072
4073
|
};
|
|
4073
|
-
function
|
|
4074
|
+
function so(r, t, e = {}) {
|
|
4074
4075
|
const i = { type: "Feature" };
|
|
4075
4076
|
return (e.id === 0 || e.id) && (i.id = e.id), e.bbox && (i.bbox = e.bbox), i.properties = t || {}, i.geometry = r, i;
|
|
4076
4077
|
}
|
|
4077
|
-
function
|
|
4078
|
+
function ro(r, t, e = {}) {
|
|
4078
4079
|
if (!r)
|
|
4079
4080
|
throw new Error("coordinates is required");
|
|
4080
4081
|
if (!Array.isArray(r))
|
|
4081
4082
|
throw new Error("coordinates must be an Array");
|
|
4082
4083
|
if (r.length < 2)
|
|
4083
4084
|
throw new Error("coordinates must be at least 2 numbers long");
|
|
4084
|
-
if (!
|
|
4085
|
+
if (!pe(r[0]) || !pe(r[1]))
|
|
4085
4086
|
throw new Error("coordinates must contain numbers");
|
|
4086
|
-
return
|
|
4087
|
+
return so({
|
|
4087
4088
|
type: "Point",
|
|
4088
4089
|
coordinates: r
|
|
4089
4090
|
}, t, e);
|
|
4090
4091
|
}
|
|
4091
|
-
function
|
|
4092
|
-
const e =
|
|
4092
|
+
function no(r, t = "kilometers") {
|
|
4093
|
+
const e = oo[t];
|
|
4093
4094
|
if (!e)
|
|
4094
4095
|
throw new Error(t + " units is invalid");
|
|
4095
4096
|
return r * e;
|
|
@@ -4097,16 +4098,16 @@ function ro(r, t = "kilometers") {
|
|
|
4097
4098
|
function vt(r) {
|
|
4098
4099
|
return r % 360 * Math.PI / 180;
|
|
4099
4100
|
}
|
|
4100
|
-
function
|
|
4101
|
+
function pe(r) {
|
|
4101
4102
|
return !isNaN(r) && r !== null && !Array.isArray(r);
|
|
4102
4103
|
}
|
|
4103
|
-
function
|
|
4104
|
+
function Ue(r, t, e) {
|
|
4104
4105
|
if (r !== null)
|
|
4105
|
-
for (var i, o, s, n, a, l, d, c = 0, h = 0,
|
|
4106
|
-
d = g ? r.features[v].geometry : y ? r.geometry : r,
|
|
4106
|
+
for (var i, o, s, n, a, l, d, c = 0, h = 0, u, p = r.type, g = p === "FeatureCollection", y = p === "Feature", m = g ? r.features.length : 1, v = 0; v < m; v++) {
|
|
4107
|
+
d = g ? r.features[v].geometry : y ? r.geometry : r, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
|
|
4107
4108
|
for (var C = 0; C < a; C++) {
|
|
4108
4109
|
var f = 0, P = 0;
|
|
4109
|
-
if (n =
|
|
4110
|
+
if (n = u ? d.geometries[C] : d, n !== null) {
|
|
4110
4111
|
l = n.coordinates;
|
|
4111
4112
|
var I = n.type;
|
|
4112
4113
|
switch (c = I === "Polygon" || I === "MultiPolygon" ? 1 : 0, I) {
|
|
@@ -4177,7 +4178,7 @@ function Ge(r, t, e) {
|
|
|
4177
4178
|
break;
|
|
4178
4179
|
case "GeometryCollection":
|
|
4179
4180
|
for (i = 0; i < n.geometries.length; i++)
|
|
4180
|
-
if (
|
|
4181
|
+
if (Ue(n.geometries[i], t) === !1)
|
|
4181
4182
|
return !1;
|
|
4182
4183
|
break;
|
|
4183
4184
|
default:
|
|
@@ -4187,14 +4188,14 @@ function Ge(r, t, e) {
|
|
|
4187
4188
|
}
|
|
4188
4189
|
}
|
|
4189
4190
|
}
|
|
4190
|
-
function
|
|
4191
|
-
var e, i, o, s, n, a, l, d, c, h,
|
|
4191
|
+
function ao(r, t) {
|
|
4192
|
+
var e, i, o, s, n, a, l, d, c, h, u = 0, p = r.type === "FeatureCollection", g = r.type === "Feature", y = p ? r.features.length : 1;
|
|
4192
4193
|
for (e = 0; e < y; e++) {
|
|
4193
|
-
for (a =
|
|
4194
|
+
for (a = p ? r.features[e].geometry : g ? r.geometry : r, d = p ? r.features[e].properties : g ? r.properties : {}, c = p ? r.features[e].bbox : g ? r.bbox : void 0, h = p ? r.features[e].id : g ? r.id : void 0, l = a ? a.type === "GeometryCollection" : !1, n = l ? a.geometries.length : 1, o = 0; o < n; o++) {
|
|
4194
4195
|
if (s = l ? a.geometries[o] : a, s === null) {
|
|
4195
4196
|
if (t(
|
|
4196
4197
|
null,
|
|
4197
|
-
|
|
4198
|
+
u,
|
|
4198
4199
|
d,
|
|
4199
4200
|
c,
|
|
4200
4201
|
h
|
|
@@ -4211,7 +4212,7 @@ function no(r, t) {
|
|
|
4211
4212
|
case "MultiPolygon": {
|
|
4212
4213
|
if (t(
|
|
4213
4214
|
s,
|
|
4214
|
-
|
|
4215
|
+
u,
|
|
4215
4216
|
d,
|
|
4216
4217
|
c,
|
|
4217
4218
|
h
|
|
@@ -4223,7 +4224,7 @@ function no(r, t) {
|
|
|
4223
4224
|
for (i = 0; i < s.geometries.length; i++)
|
|
4224
4225
|
if (t(
|
|
4225
4226
|
s.geometries[i],
|
|
4226
|
-
|
|
4227
|
+
u,
|
|
4227
4228
|
d,
|
|
4228
4229
|
c,
|
|
4229
4230
|
h
|
|
@@ -4235,12 +4236,12 @@ function no(r, t) {
|
|
|
4235
4236
|
throw new Error("Unknown Geometry Type");
|
|
4236
4237
|
}
|
|
4237
4238
|
}
|
|
4238
|
-
|
|
4239
|
+
u++;
|
|
4239
4240
|
}
|
|
4240
4241
|
}
|
|
4241
|
-
function
|
|
4242
|
+
function lo(r, t, e) {
|
|
4242
4243
|
var i = e;
|
|
4243
|
-
return
|
|
4244
|
+
return ao(
|
|
4244
4245
|
r,
|
|
4245
4246
|
function(o, s, n, a, l) {
|
|
4246
4247
|
s === 0 && e === void 0 ? i = o : i = t(
|
|
@@ -4254,21 +4255,21 @@ function ao(r, t, e) {
|
|
|
4254
4255
|
}
|
|
4255
4256
|
), i;
|
|
4256
4257
|
}
|
|
4257
|
-
function
|
|
4258
|
-
return
|
|
4258
|
+
function co(r) {
|
|
4259
|
+
return lo(
|
|
4259
4260
|
r,
|
|
4260
|
-
(t, e) => t +
|
|
4261
|
+
(t, e) => t + ho(e),
|
|
4261
4262
|
0
|
|
4262
4263
|
);
|
|
4263
4264
|
}
|
|
4264
|
-
function
|
|
4265
|
+
function ho(r) {
|
|
4265
4266
|
let t = 0, e;
|
|
4266
4267
|
switch (r.type) {
|
|
4267
4268
|
case "Polygon":
|
|
4268
|
-
return
|
|
4269
|
+
return ge(r.coordinates);
|
|
4269
4270
|
case "MultiPolygon":
|
|
4270
4271
|
for (e = 0; e < r.coordinates.length; e++)
|
|
4271
|
-
t +=
|
|
4272
|
+
t += ge(r.coordinates[e]);
|
|
4272
4273
|
return t;
|
|
4273
4274
|
case "Point":
|
|
4274
4275
|
case "MultiPoint":
|
|
@@ -4278,28 +4279,28 @@ function co(r) {
|
|
|
4278
4279
|
}
|
|
4279
4280
|
return 0;
|
|
4280
4281
|
}
|
|
4281
|
-
function
|
|
4282
|
+
function ge(r) {
|
|
4282
4283
|
let t = 0;
|
|
4283
4284
|
if (r && r.length > 0) {
|
|
4284
|
-
t += Math.abs(
|
|
4285
|
+
t += Math.abs(ye(r[0]));
|
|
4285
4286
|
for (let e = 1; e < r.length; e++)
|
|
4286
|
-
t -= Math.abs(
|
|
4287
|
+
t -= Math.abs(ye(r[e]));
|
|
4287
4288
|
}
|
|
4288
4289
|
return t;
|
|
4289
4290
|
}
|
|
4290
|
-
var
|
|
4291
|
-
function
|
|
4291
|
+
var uo = W * W / 2, Mt = Math.PI / 180;
|
|
4292
|
+
function ye(r) {
|
|
4292
4293
|
const t = r.length - 1;
|
|
4293
4294
|
if (t <= 2) return 0;
|
|
4294
4295
|
let e = 0, i = 0;
|
|
4295
4296
|
for (; i < t; ) {
|
|
4296
|
-
const o = r[i], s = r[i + 1 === t ? 0 : i + 1], n = r[i + 2 >= t ? (i + 2) % t : i + 2], a = o[0] *
|
|
4297
|
+
const o = r[i], s = r[i + 1 === t ? 0 : i + 1], n = r[i + 2 >= t ? (i + 2) % t : i + 2], a = o[0] * Mt, l = s[1] * Mt, d = n[0] * Mt;
|
|
4297
4298
|
e += (d - a) * Math.sin(l), i++;
|
|
4298
4299
|
}
|
|
4299
|
-
return e *
|
|
4300
|
+
return e * uo;
|
|
4300
4301
|
}
|
|
4301
|
-
var
|
|
4302
|
-
const
|
|
4302
|
+
var po = co;
|
|
4303
|
+
const go = (r, t, e = "auto") => {
|
|
4303
4304
|
const i = ["m2", "km2", "a", "ha"], o = ["ft2", "yd2", "acre", "mi2"];
|
|
4304
4305
|
let s = e;
|
|
4305
4306
|
if (e !== "auto") {
|
|
@@ -4347,12 +4348,12 @@ const po = (r, t, e = "auto") => {
|
|
|
4347
4348
|
area: e,
|
|
4348
4349
|
unit: i
|
|
4349
4350
|
};
|
|
4350
|
-
},
|
|
4351
|
+
}, fe = (r, t, e, i) => {
|
|
4351
4352
|
if (r.geometry.type !== "Polygon") return r;
|
|
4352
|
-
const o =
|
|
4353
|
+
const o = po(r.geometry), s = go(o, t, i);
|
|
4353
4354
|
return s.area = parseFloat(s.area.toFixed(e)), r.properties.area = s.area, r.properties.unit = s.unit, r;
|
|
4354
4355
|
};
|
|
4355
|
-
function
|
|
4356
|
+
function me(r) {
|
|
4356
4357
|
if (!r)
|
|
4357
4358
|
throw new Error("coord is required");
|
|
4358
4359
|
if (!Array.isArray(r)) {
|
|
@@ -4365,86 +4366,140 @@ function ye(r) {
|
|
|
4365
4366
|
return [...r];
|
|
4366
4367
|
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
4367
4368
|
}
|
|
4368
|
-
function
|
|
4369
|
-
var i =
|
|
4370
|
-
return
|
|
4369
|
+
function yo(r, t, e = {}) {
|
|
4370
|
+
var i = me(r), o = me(t), s = vt(o[1] - i[1]), n = vt(o[0] - i[0]), a = vt(i[1]), l = vt(o[1]), d = Math.pow(Math.sin(s / 2), 2) + Math.pow(Math.sin(n / 2), 2) * Math.cos(a) * Math.cos(l);
|
|
4371
|
+
return no(
|
|
4371
4372
|
2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
|
|
4372
4373
|
e.units
|
|
4373
4374
|
);
|
|
4374
4375
|
}
|
|
4375
|
-
var
|
|
4376
|
-
const
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
distance:
|
|
4385
|
-
unit: "
|
|
4386
|
-
} : {
|
|
4387
|
-
distance: t * 100,
|
|
4388
|
-
unit: "cm"
|
|
4376
|
+
var fo = yo;
|
|
4377
|
+
const Dt = (r, t = "kilometers", e = "auto") => {
|
|
4378
|
+
const i = ["cm", "m", "km"], o = ["in", "ft", "mi"];
|
|
4379
|
+
let s = e;
|
|
4380
|
+
if (e !== "auto") {
|
|
4381
|
+
const a = i.includes(e), l = o.includes(e);
|
|
4382
|
+
(t === "kilometers" && !a || t === "miles" && !l) && (s = "auto");
|
|
4383
|
+
}
|
|
4384
|
+
let n = {
|
|
4385
|
+
distance: r,
|
|
4386
|
+
unit: "km"
|
|
4389
4387
|
};
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4388
|
+
return t === "kilometers" ? n = Ct(r, s) : t === "degrees" ? n.unit = "°" : t === "miles" ? n = Pt(r, s) : t === "radians" && (n.unit = "rad"), n;
|
|
4389
|
+
}, Ct = (r, t) => {
|
|
4390
|
+
let e = {
|
|
4391
|
+
distance: r,
|
|
4392
|
+
unit: "km"
|
|
4393
|
+
};
|
|
4394
|
+
switch (t) {
|
|
4395
|
+
case "km":
|
|
4396
|
+
e.distance = r, e.unit = "km";
|
|
4397
|
+
break;
|
|
4398
|
+
case "m":
|
|
4399
|
+
e.distance = r * 1e3, e.unit = "m";
|
|
4400
|
+
break;
|
|
4401
|
+
case "cm":
|
|
4402
|
+
e.distance = r * 1e5, e.unit = "cm";
|
|
4403
|
+
break;
|
|
4404
|
+
case "auto":
|
|
4405
|
+
r >= 1 ? e = Ct(r, "km") : r * 1e3 >= 1 ? e = Ct(r, "m") : e = Ct(r, "cm");
|
|
4406
|
+
break;
|
|
4407
|
+
default:
|
|
4408
|
+
e.distance = r, e.unit = "km";
|
|
4409
|
+
break;
|
|
4410
|
+
}
|
|
4411
|
+
return e;
|
|
4412
|
+
}, Pt = (r, t) => {
|
|
4413
|
+
let e = {
|
|
4414
|
+
distance: r,
|
|
4415
|
+
unit: "mi"
|
|
4416
|
+
};
|
|
4417
|
+
switch (t) {
|
|
4418
|
+
case "mi":
|
|
4419
|
+
e.distance = r, e.unit = "mi";
|
|
4420
|
+
break;
|
|
4421
|
+
case "ft":
|
|
4422
|
+
e.distance = r * 5280, e.unit = "ft";
|
|
4423
|
+
break;
|
|
4424
|
+
case "in":
|
|
4425
|
+
e.distance = r * 63360, e.unit = "in";
|
|
4426
|
+
break;
|
|
4427
|
+
case "auto":
|
|
4428
|
+
r >= 1 ? e = Pt(r, "mi") : r * 5280 >= 1 ? e = Pt(r, "ft") : e = Pt(r, "in");
|
|
4429
|
+
break;
|
|
4430
|
+
default:
|
|
4431
|
+
e.distance = r, e.unit = "mi";
|
|
4432
|
+
break;
|
|
4417
4433
|
}
|
|
4418
|
-
return
|
|
4434
|
+
return e;
|
|
4435
|
+
}, ve = (r, t, e, i, o, s, n) => {
|
|
4436
|
+
if (r.geometry.type !== "LineString") return r;
|
|
4437
|
+
const a = r.geometry.coordinates;
|
|
4438
|
+
let l = 0;
|
|
4439
|
+
const d = [];
|
|
4440
|
+
for (let h = 0; h < a.length - 1; h++) {
|
|
4441
|
+
const u = a[h], p = a[h + 1], g = fo(u, p, { units: t });
|
|
4442
|
+
l += g;
|
|
4443
|
+
const y = JSON.parse(JSON.stringify(r));
|
|
4444
|
+
if (y.id = `${y.id}-${h}`, y.geometry.coordinates = [u, p], y.properties.originalId = r.id, y.properties.distance = g, y.properties.total = l, s === !0 && n === void 0) {
|
|
4445
|
+
const m = o?.queryTerrainElevation(u);
|
|
4446
|
+
m && (y.properties.elevation_start = m);
|
|
4447
|
+
const v = o?.queryTerrainElevation(p);
|
|
4448
|
+
v && (y.properties.elevation_end = v);
|
|
4449
|
+
}
|
|
4450
|
+
d.push(y);
|
|
4451
|
+
}
|
|
4452
|
+
r.properties.distance = d[d.length - 1].properties.total, r.properties.segments = JSON.parse(JSON.stringify(d));
|
|
4453
|
+
const c = Dt(
|
|
4454
|
+
r.properties.distance,
|
|
4455
|
+
t,
|
|
4456
|
+
i
|
|
4457
|
+
);
|
|
4458
|
+
return r.properties.distance = c.distance, r.properties.unit = c.unit, r.properties.segments.forEach(
|
|
4459
|
+
(h) => {
|
|
4460
|
+
const u = Dt(
|
|
4461
|
+
h.properties.distance,
|
|
4462
|
+
t,
|
|
4463
|
+
i
|
|
4464
|
+
);
|
|
4465
|
+
h.properties.distance = u.distance, h.properties.unit = u.unit;
|
|
4466
|
+
const p = Dt(
|
|
4467
|
+
h.properties.total,
|
|
4468
|
+
t,
|
|
4469
|
+
i
|
|
4470
|
+
);
|
|
4471
|
+
h.properties.total = p.distance, h.properties.totalUnit = p.unit;
|
|
4472
|
+
}
|
|
4473
|
+
), r.properties.distance = parseFloat(
|
|
4419
4474
|
r.properties.distance.toFixed(e)
|
|
4420
4475
|
), r.properties.segments.forEach(
|
|
4421
|
-
(
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
),
|
|
4425
|
-
|
|
4476
|
+
(h) => {
|
|
4477
|
+
h.properties.distance = parseFloat(
|
|
4478
|
+
h.properties.distance.toFixed(e)
|
|
4479
|
+
), h.properties.total = parseFloat(
|
|
4480
|
+
h.properties.total.toFixed(e)
|
|
4426
4481
|
);
|
|
4427
4482
|
}
|
|
4428
4483
|
), r;
|
|
4429
|
-
},
|
|
4484
|
+
}, Ce = (r) => r.charAt(0).toUpperCase() + r.slice(1), et = [
|
|
4430
4485
|
"{prefix}-point",
|
|
4431
4486
|
"{prefix}-point-lower",
|
|
4432
4487
|
"{prefix}-linestring",
|
|
4433
4488
|
"{prefix}-polygon",
|
|
4434
4489
|
"{prefix}-polygon-outline"
|
|
4435
|
-
],
|
|
4490
|
+
], Yo = [
|
|
4436
4491
|
...et,
|
|
4437
4492
|
lt.polygonLayerSpec?.source,
|
|
4438
4493
|
lt.lineLayerLabelSpec?.source,
|
|
4439
4494
|
lt.pointLayerLabelSpec?.source
|
|
4440
|
-
],
|
|
4495
|
+
], Ko = [
|
|
4441
4496
|
...et,
|
|
4442
4497
|
z.routingLineLayerNodeLabelSpec?.source,
|
|
4443
4498
|
z.routingLineLayerNodeSpec?.source,
|
|
4444
4499
|
z.isochronePolygonLayerSpec?.source,
|
|
4445
4500
|
z.isochroneLineLayerSpec?.source,
|
|
4446
4501
|
z.isochroneLabelLayerSpec?.source
|
|
4447
|
-
],
|
|
4502
|
+
], Vt = (r, t, e = et, i = "td") => {
|
|
4448
4503
|
e = e.map((s) => s.replace("{prefix}", i));
|
|
4449
4504
|
const o = JSON.parse(JSON.stringify(r));
|
|
4450
4505
|
return t && (t.onlyTerraDrawLayers === !0 ? (o.layers = o.layers.filter((s) => "source" in s && e.includes(s.source)), Object.keys(o.sources).forEach((s) => {
|
|
@@ -4452,13 +4507,13 @@ const fe = (r) => r === "degrees" ? "°" : r === "miles" ? "mi" : r === "radians
|
|
|
4452
4507
|
})) : t.excludeTerraDrawLayers === !0 && (o.layers = o.layers.filter((s) => "source" in s && !e.includes(s.source) || s.type === "background"), Object.keys(o.sources).forEach((s) => {
|
|
4453
4508
|
e.includes(s) && delete o.sources[s];
|
|
4454
4509
|
}))), o;
|
|
4455
|
-
},
|
|
4510
|
+
}, ze = (r, t = 250) => {
|
|
4456
4511
|
let e;
|
|
4457
4512
|
return (...i) => {
|
|
4458
4513
|
clearTimeout(e), e = setTimeout(() => r(...i), t);
|
|
4459
4514
|
};
|
|
4460
4515
|
};
|
|
4461
|
-
class
|
|
4516
|
+
class Ve {
|
|
4462
4517
|
cache = /* @__PURE__ */ new Map();
|
|
4463
4518
|
maxSize;
|
|
4464
4519
|
ttl;
|
|
@@ -4536,7 +4591,7 @@ class ze {
|
|
|
4536
4591
|
};
|
|
4537
4592
|
}
|
|
4538
4593
|
}
|
|
4539
|
-
class
|
|
4594
|
+
class mo {
|
|
4540
4595
|
className;
|
|
4541
4596
|
dialog;
|
|
4542
4597
|
title;
|
|
@@ -4625,7 +4680,7 @@ class fo {
|
|
|
4625
4680
|
}), o;
|
|
4626
4681
|
}
|
|
4627
4682
|
}
|
|
4628
|
-
const
|
|
4683
|
+
const Pe = (r, t, e, i) => {
|
|
4629
4684
|
if (r.geometry.type !== "Point") return r;
|
|
4630
4685
|
const o = r.geometry.coordinates;
|
|
4631
4686
|
if (e === !0 && i === void 0) {
|
|
@@ -4634,58 +4689,58 @@ const Ce = (r, t, e, i) => {
|
|
|
4634
4689
|
}
|
|
4635
4690
|
return r;
|
|
4636
4691
|
};
|
|
4637
|
-
var
|
|
4638
|
-
function
|
|
4692
|
+
var vo = Object.defineProperty, Co = (r, t, e) => t in r ? vo(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, rt = (r, t, e) => Co(r, typeof t != "symbol" ? t + "" : t, e), xt = 2 * Math.PI * 6378137 / 2;
|
|
4693
|
+
function Po(r) {
|
|
4639
4694
|
return r = r || 256, 2 * Math.PI * 6378137 / r;
|
|
4640
4695
|
}
|
|
4641
|
-
function
|
|
4642
|
-
r =
|
|
4643
|
-
var i = r[0], o = r[1], s = i *
|
|
4644
|
-
return n = n *
|
|
4696
|
+
function So(r, t, e = { enable: !0, decimal: 1 }) {
|
|
4697
|
+
r = $t(r);
|
|
4698
|
+
var i = r[0], o = r[1], s = i * xt / 180, n = Math.log(Math.tan((90 + o) * Math.PI / 360)) / (Math.PI / 180);
|
|
4699
|
+
return n = n * xt / 180, e.enable && (s = Number(s.toFixed(e.decimal)), n = Number(n.toFixed(e.decimal))), [s, n];
|
|
4645
4700
|
}
|
|
4646
|
-
function
|
|
4647
|
-
var i = r[0], o = r[1], s =
|
|
4701
|
+
function Io(r, t, e) {
|
|
4702
|
+
var i = r[0], o = r[1], s = Lo(t, e), n = (i + xt) / s, a = (o + xt) / s;
|
|
4648
4703
|
return [n, a, t];
|
|
4649
4704
|
}
|
|
4650
|
-
function
|
|
4651
|
-
r =
|
|
4652
|
-
var i =
|
|
4653
|
-
return
|
|
4705
|
+
function $e(r, t, e) {
|
|
4706
|
+
r = $t(r);
|
|
4707
|
+
var i = So(r), o = Io(i, t);
|
|
4708
|
+
return Oo(o);
|
|
4654
4709
|
}
|
|
4655
|
-
function
|
|
4656
|
-
if (r =
|
|
4710
|
+
function xo(r, t, e) {
|
|
4711
|
+
if (r = $t(r), t === 0)
|
|
4657
4712
|
return [0, 0, 0];
|
|
4658
|
-
var i =
|
|
4659
|
-
return
|
|
4713
|
+
var i = $e(r, t);
|
|
4714
|
+
return bo(i);
|
|
4660
4715
|
}
|
|
4661
|
-
function
|
|
4716
|
+
function Oo(r, t, e) {
|
|
4662
4717
|
t = t || 256;
|
|
4663
4718
|
var i = r[0], o = r[1], s = r[2];
|
|
4664
4719
|
if (s === 0) return [0, 0, 0];
|
|
4665
|
-
|
|
4720
|
+
Ye(s);
|
|
4666
4721
|
var n = Math.ceil(i / t) - 1, a = Math.ceil(o / t) - 1;
|
|
4667
4722
|
return n < 0 && (n = 0), a < 0 && (a = 0), [n, a, s];
|
|
4668
4723
|
}
|
|
4669
|
-
function
|
|
4670
|
-
|
|
4724
|
+
function bo(r, t) {
|
|
4725
|
+
Eo(r);
|
|
4671
4726
|
var e = r[0], i = r[1], o = r[2];
|
|
4672
4727
|
if (o === 0)
|
|
4673
4728
|
return [0, 0, 0];
|
|
4674
4729
|
var s = e, n = Math.pow(2, o) - 1 - i;
|
|
4675
4730
|
return [s, n, o];
|
|
4676
4731
|
}
|
|
4677
|
-
function
|
|
4732
|
+
function Eo(r, t) {
|
|
4678
4733
|
var e = r[0], i = r[1], o = r[2];
|
|
4679
4734
|
if (o == null) throw new Error("<zoom> is required");
|
|
4680
4735
|
if (e == null) throw new Error("<x> is required");
|
|
4681
4736
|
if (i == null) throw new Error("<y> is required");
|
|
4682
|
-
return o =
|
|
4737
|
+
return o = Ye(o), r = wo(r), r;
|
|
4683
4738
|
}
|
|
4684
|
-
function
|
|
4739
|
+
function wo(r) {
|
|
4685
4740
|
var t = r[0], e = r[1], i = r[2], o = Math.pow(2, i);
|
|
4686
4741
|
return t = t % o, t < 0 && (t = t + o), [t, e, i];
|
|
4687
4742
|
}
|
|
4688
|
-
function
|
|
4743
|
+
function Ye(r) {
|
|
4689
4744
|
if (r === !1) return r;
|
|
4690
4745
|
if (r == null)
|
|
4691
4746
|
throw new Error("<zoom> is required");
|
|
@@ -4695,22 +4750,22 @@ function $e(r) {
|
|
|
4695
4750
|
throw new Error("<zoom> cannot be greater than 32");
|
|
4696
4751
|
return r;
|
|
4697
4752
|
}
|
|
4698
|
-
function
|
|
4699
|
-
var e =
|
|
4753
|
+
function $t(r, t) {
|
|
4754
|
+
var e = Mo(r[0]), i = Fo(r[1]);
|
|
4700
4755
|
return i > 85 && (i = 85), i < -85 && (i = -85), [e, i];
|
|
4701
4756
|
}
|
|
4702
|
-
function
|
|
4703
|
-
return
|
|
4757
|
+
function Lo(r, t) {
|
|
4758
|
+
return Po(t) / Math.pow(2, r);
|
|
4704
4759
|
}
|
|
4705
|
-
function
|
|
4760
|
+
function Fo(r) {
|
|
4706
4761
|
if (r == null) throw new Error("lat is required");
|
|
4707
4762
|
return (r > 90 || r < -90) && (r = r % 180, r > 90 && (r = -180 + r), r < -90 && (r = 180 + r), r === 0 && (r = 0)), r;
|
|
4708
4763
|
}
|
|
4709
|
-
function
|
|
4764
|
+
function Mo(r) {
|
|
4710
4765
|
if (r == null) throw new Error("lng is required");
|
|
4711
4766
|
return (r > 180 || r < -180) && (r = r % 360, r > 180 && (r = -360 + r), r < -180 && (r = 360 + r), r === 0 && (r = 0)), r;
|
|
4712
4767
|
}
|
|
4713
|
-
class
|
|
4768
|
+
class Ke {
|
|
4714
4769
|
/**
|
|
4715
4770
|
* Constructor
|
|
4716
4771
|
* @param url URL for terrain RGB raster tilesets
|
|
@@ -4735,7 +4790,7 @@ class Ye {
|
|
|
4735
4790
|
const s = t[0], n = t[1];
|
|
4736
4791
|
let a = e;
|
|
4737
4792
|
e > this.maxzoom ? a = this.maxzoom : e < this.minzoom && (a = this.minzoom);
|
|
4738
|
-
const l = this.tms ?
|
|
4793
|
+
const l = this.tms ? $e([s, n], a) : xo([s, n], a), d = this.url.replace(/{x}/g, l[0].toString()).replace(/{y}/g, l[1].toString()).replace(/{z}/g, l[2].toString());
|
|
4739
4794
|
let c = this.getUrlExtension(d);
|
|
4740
4795
|
switch (c || (c = "png"), c) {
|
|
4741
4796
|
case "png":
|
|
@@ -4775,7 +4830,7 @@ class Ye {
|
|
|
4775
4830
|
const h = c.getContext("2d");
|
|
4776
4831
|
if (!h) return l(new Error("Failed to create canvas context"));
|
|
4777
4832
|
h.drawImage(d, 0, 0);
|
|
4778
|
-
const
|
|
4833
|
+
const u = h.getImageData(0, 0, d.width, d.height).data, p = this.pixels2rgba(new Uint8Array(u), e, i, o), g = this.calc(p[0], p[1], p[2], p[3]);
|
|
4779
4834
|
a(g);
|
|
4780
4835
|
}, d.onerror = () => a(void 0), d.src = URL.createObjectURL(n);
|
|
4781
4836
|
});
|
|
@@ -4791,7 +4846,7 @@ class Ye {
|
|
|
4791
4846
|
pixels2rgba(t, e, i, o) {
|
|
4792
4847
|
const s = [];
|
|
4793
4848
|
for (let d = 0; d < t.length; d += 4) {
|
|
4794
|
-
const c = t[d], h = t[d + 1],
|
|
4849
|
+
const c = t[d], h = t[d + 1], u = t[d + 2], p = t[d + 3], g = [c, h, u, p];
|
|
4795
4850
|
s.push(g);
|
|
4796
4851
|
}
|
|
4797
4852
|
const n = this.tileToBBOX(e), a = this.getPixelPosition(i, o, n), l = a[0] + a[1] * this.tileSize;
|
|
@@ -4837,7 +4892,7 @@ class Ye {
|
|
|
4837
4892
|
return i * Math.atan(0.5 * (Math.exp(o) - Math.exp(-o)));
|
|
4838
4893
|
}
|
|
4839
4894
|
}
|
|
4840
|
-
class
|
|
4895
|
+
class Do extends Ke {
|
|
4841
4896
|
/**
|
|
4842
4897
|
* Constructor
|
|
4843
4898
|
* @param url URL for terrain RGB raster tilesets
|
|
@@ -4869,7 +4924,7 @@ class Mo extends Ye {
|
|
|
4869
4924
|
return -1e4 + (t * 256 * 256 + e * 256 + i) * 0.1;
|
|
4870
4925
|
}
|
|
4871
4926
|
}
|
|
4872
|
-
class
|
|
4927
|
+
class _o extends Ke {
|
|
4873
4928
|
/**
|
|
4874
4929
|
* Constructor
|
|
4875
4930
|
* @param url URL for terrarium raster tilesets
|
|
@@ -4903,10 +4958,10 @@ class Do extends Ye {
|
|
|
4903
4958
|
return parseInt(o.toFixed(0));
|
|
4904
4959
|
}
|
|
4905
4960
|
}
|
|
4906
|
-
const
|
|
4961
|
+
const ko = (r, t = 8) => {
|
|
4907
4962
|
const [e, i] = r, o = Math.pow(10, t), s = Math.round(e * o) / o, n = Math.round(i * o) / o;
|
|
4908
4963
|
return `${s},${n}`;
|
|
4909
|
-
},
|
|
4964
|
+
}, Se = async (r, t, e, i) => {
|
|
4910
4965
|
const o = [], s = {
|
|
4911
4966
|
enabled: !0,
|
|
4912
4967
|
maxSize: 1e3,
|
|
@@ -4916,35 +4971,35 @@ const _o = (r, t = 8) => {
|
|
|
4916
4971
|
...e
|
|
4917
4972
|
};
|
|
4918
4973
|
let n;
|
|
4919
|
-
s.enabled && (n = i || new
|
|
4974
|
+
s.enabled && (n = i || new Ve(s.maxSize, s.ttl));
|
|
4920
4975
|
let a, l = 15;
|
|
4921
4976
|
if (t) {
|
|
4922
|
-
const d = t.url, c = t.encoding ?? "mapbox", h = t.tileSize ?? 512,
|
|
4977
|
+
const d = t.url, c = t.encoding ?? "mapbox", h = t.tileSize ?? 512, u = t.minzoom ?? 5;
|
|
4923
4978
|
l = t.maxzoom ?? 15;
|
|
4924
|
-
const
|
|
4925
|
-
a = c === "mapbox" ? new
|
|
4979
|
+
const p = t.tms ?? !1;
|
|
4980
|
+
a = c === "mapbox" ? new Do(d, h, u, l, p) : new _o(d, h, u, l, p);
|
|
4926
4981
|
}
|
|
4927
4982
|
for (const d of r)
|
|
4928
4983
|
o.push(
|
|
4929
4984
|
new Promise((c) => {
|
|
4930
4985
|
d.geometry.type !== "Point" && c(d);
|
|
4931
|
-
const h = d.geometry.coordinates,
|
|
4986
|
+
const h = d.geometry.coordinates, u = ko(h, s.precision);
|
|
4932
4987
|
if (n) {
|
|
4933
|
-
const
|
|
4934
|
-
if (
|
|
4935
|
-
isNaN(
|
|
4988
|
+
const p = n.get(u);
|
|
4989
|
+
if (p !== void 0) {
|
|
4990
|
+
isNaN(p) || (d.properties.elevation = p), c(d);
|
|
4936
4991
|
return;
|
|
4937
4992
|
}
|
|
4938
4993
|
}
|
|
4939
|
-
a ? a.getElevation(d.geometry.coordinates, l).then((
|
|
4940
|
-
|
|
4994
|
+
a ? a.getElevation(d.geometry.coordinates, l).then((p) => {
|
|
4995
|
+
p != null && typeof p == "number" && (n && n.set(u, p), d.properties.elevation = p), c(d);
|
|
4941
4996
|
}).catch(() => {
|
|
4942
|
-
n && n.has(
|
|
4997
|
+
n && n.has(u) && n.delete(u), c(d);
|
|
4943
4998
|
}) : c(d);
|
|
4944
4999
|
})
|
|
4945
5000
|
);
|
|
4946
5001
|
return await Promise.all(o);
|
|
4947
|
-
},
|
|
5002
|
+
}, Xo = (r, t = 9) => {
|
|
4948
5003
|
function e(o) {
|
|
4949
5004
|
return [Number(o[0].toFixed(t)), Number(o[1].toFixed(t))];
|
|
4950
5005
|
}
|
|
@@ -4978,11 +5033,11 @@ const _o = (r, t = 8) => {
|
|
|
4978
5033
|
...o,
|
|
4979
5034
|
geometry: i(o.geometry)
|
|
4980
5035
|
}));
|
|
4981
|
-
},
|
|
5036
|
+
}, No = [
|
|
4982
5037
|
{ value: "time", label: "Time" },
|
|
4983
5038
|
{ value: "distance", label: "Distance" }
|
|
4984
5039
|
];
|
|
4985
|
-
class
|
|
5040
|
+
class To {
|
|
4986
5041
|
url;
|
|
4987
5042
|
/**
|
|
4988
5043
|
* Constructor
|
|
@@ -5014,15 +5069,15 @@ class No {
|
|
|
5014
5069
|
return await (await fetch(l)).json();
|
|
5015
5070
|
}
|
|
5016
5071
|
}
|
|
5017
|
-
const
|
|
5072
|
+
const Wt = [
|
|
5018
5073
|
{ value: "pedestrian", label: "Pedestrian" },
|
|
5019
5074
|
{ value: "bicycle", label: "Bicycle" },
|
|
5020
5075
|
{ value: "auto", label: "Car" }
|
|
5021
|
-
],
|
|
5076
|
+
], Wo = [
|
|
5022
5077
|
{ value: "kilometers", label: "km" },
|
|
5023
5078
|
{ value: "miles", label: "mile" }
|
|
5024
5079
|
];
|
|
5025
|
-
class
|
|
5080
|
+
class Bo {
|
|
5026
5081
|
tripData = [];
|
|
5027
5082
|
/**
|
|
5028
5083
|
* get the raw trip data from the valhalla routing API.
|
|
@@ -5087,25 +5142,25 @@ class Wo {
|
|
|
5087
5142
|
c = [...c, ...f];
|
|
5088
5143
|
}), this.tripSummary = l.trip.summary, this.tripSummary.length = Number(this.tripSummary.length.toFixed(2)), this.tripSummary.time = Number((this.tripSummary.time / 60).toFixed());
|
|
5089
5144
|
const h = [];
|
|
5090
|
-
let
|
|
5145
|
+
let u = 0, p = 0;
|
|
5091
5146
|
const g = [], y = this.geoPoint(this.tripData.map((f) => [f.lng, f.lat]));
|
|
5092
5147
|
l.trip.legs.forEach((f, P) => {
|
|
5093
5148
|
const I = this.decodeShape(f.shape);
|
|
5094
|
-
h.push(...I),
|
|
5149
|
+
h.push(...I), u += Number(f.summary.length.toFixed(2)), p += Number((f.summary.time / 60).toFixed()), g.push(...f.maneuvers);
|
|
5095
5150
|
const E = y.features[P + 1];
|
|
5096
5151
|
E.properties = {
|
|
5097
5152
|
...E.properties,
|
|
5098
|
-
distance:
|
|
5153
|
+
distance: u,
|
|
5099
5154
|
distance_unit: i === "kilometers" ? "km" : "mi",
|
|
5100
|
-
time:
|
|
5155
|
+
time: p,
|
|
5101
5156
|
maneuvers: f.maneuvers
|
|
5102
5157
|
};
|
|
5103
5158
|
});
|
|
5104
|
-
const m =
|
|
5159
|
+
const m = Wt.find((f) => f.value === e)?.label, v = this.geoLineString(h, {
|
|
5105
5160
|
costingModel: m,
|
|
5106
|
-
distance:
|
|
5161
|
+
distance: u,
|
|
5107
5162
|
distance_unit: i === "kilometers" ? "km" : "mi",
|
|
5108
|
-
time:
|
|
5163
|
+
time: p,
|
|
5109
5164
|
maneuvers: g
|
|
5110
5165
|
}), C = y.features[0];
|
|
5111
5166
|
return C.properties = {
|
|
@@ -5161,7 +5216,7 @@ class Wo {
|
|
|
5161
5216
|
* @returns the list of coordinates as [lng, lat] pairs
|
|
5162
5217
|
*/
|
|
5163
5218
|
decodeShape(t, e = 6) {
|
|
5164
|
-
let i = 0, o = 0, s = 0, n = [], a = 0, l = 0, d = null, c, h,
|
|
5219
|
+
let i = 0, o = 0, s = 0, n = [], a = 0, l = 0, d = null, c, h, u = Math.pow(10, e || 6);
|
|
5165
5220
|
for (; i < t.length; ) {
|
|
5166
5221
|
d = null, a = 0, l = 0;
|
|
5167
5222
|
do
|
|
@@ -5171,12 +5226,12 @@ class Wo {
|
|
|
5171
5226
|
do
|
|
5172
5227
|
d = t.charCodeAt(i++) - 63, l |= (d & 31) << a, a += 5;
|
|
5173
5228
|
while (d >= 32);
|
|
5174
|
-
h = l & 1 ? ~(l >> 1) : l >> 1, o += c, s += h, n.push([s /
|
|
5229
|
+
h = l & 1 ? ~(l >> 1) : l >> 1, o += c, s += h, n.push([s / u, o / u]);
|
|
5175
5230
|
}
|
|
5176
5231
|
return n;
|
|
5177
5232
|
}
|
|
5178
5233
|
}
|
|
5179
|
-
class
|
|
5234
|
+
class Xe {
|
|
5180
5235
|
controlContainer;
|
|
5181
5236
|
map;
|
|
5182
5237
|
modeButtons = {};
|
|
@@ -5215,7 +5270,7 @@ class Ke {
|
|
|
5215
5270
|
i && i.length > 0 && (this.isExpanded ? i.item(0)?.classList.add("enabled") : (i.item(0)?.classList.remove("enabled"), this.resetActiveMode())), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.isExpanded ? this.dispatchEvent("expanded") : this.dispatchEvent("collapsed");
|
|
5216
5271
|
}
|
|
5217
5272
|
terradraw;
|
|
5218
|
-
options =
|
|
5273
|
+
options = eo;
|
|
5219
5274
|
events = {};
|
|
5220
5275
|
defaultMode = "render";
|
|
5221
5276
|
/**
|
|
@@ -5243,7 +5298,7 @@ class Ke {
|
|
|
5243
5298
|
if (this.options && this.options.modes && this.options.modes.length === 0)
|
|
5244
5299
|
throw new Error("At least a mode must be enabled.");
|
|
5245
5300
|
this.map = t;
|
|
5246
|
-
const e =
|
|
5301
|
+
const e = io(), i = [];
|
|
5247
5302
|
return this.options?.modes?.forEach((o) => {
|
|
5248
5303
|
if (this.options.modeOptions && this.options.modeOptions[o]) {
|
|
5249
5304
|
const s = this.options.modeOptions[o];
|
|
@@ -5265,8 +5320,8 @@ class Ke {
|
|
|
5265
5320
|
modeName: "default",
|
|
5266
5321
|
styles: {}
|
|
5267
5322
|
})
|
|
5268
|
-
), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new
|
|
5269
|
-
adapter: new
|
|
5323
|
+
), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new Qi({
|
|
5324
|
+
adapter: new to({ map: t, ...this.options.adapterOptions }),
|
|
5270
5325
|
modes: i
|
|
5271
5326
|
}), this.map?.loaded() ? this.terradraw.start() : this.map?.once("load", () => {
|
|
5272
5327
|
this.terradraw?.start();
|
|
@@ -5364,7 +5419,7 @@ class Ke {
|
|
|
5364
5419
|
*/
|
|
5365
5420
|
addTerradrawButton(t) {
|
|
5366
5421
|
const e = document.createElement("button");
|
|
5367
|
-
e.type = "button", this.modeButtons[t] = e, t === "render" ? (e.classList.add(`maplibregl-terradraw-${this.cssPrefix}${t}-button`), this.isExpanded && e.classList.add("enabled"), e.type = "button", e.title =
|
|
5422
|
+
e.type = "button", this.modeButtons[t] = e, t === "render" ? (e.classList.add(`maplibregl-terradraw-${this.cssPrefix}${t}-button`), this.isExpanded && e.classList.add("enabled"), e.type = "button", e.title = Ce("expand or collapse drawing tool"), e.addEventListener("click", this.toggleEditor.bind(this))) : (e.classList.add(`maplibregl-terradraw-${this.cssPrefix}add-control`), this.isExpanded || e.classList.add("hidden"), e.title = Ce(t.replace(/-/g, " ")), t === "delete" ? (e.classList.add(`maplibregl-terradraw-${this.cssPrefix}${t}-button`), e.addEventListener("click", () => {
|
|
5368
5423
|
this.terradraw && this.terradraw.enabled && (this.terradraw.clear(), this.deactivate(), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.dispatchEvent("feature-deleted"));
|
|
5369
5424
|
})) : t === "delete-selection" ? (e.classList.add(`maplibregl-terradraw-${this.cssPrefix}${t}-button`), e.classList.add("hidden-delete-selection"), e.addEventListener("click", () => {
|
|
5370
5425
|
if (!this.terradraw || !this.terradraw.enabled) return;
|
|
@@ -5412,7 +5467,7 @@ class Ke {
|
|
|
5412
5467
|
* @returns
|
|
5413
5468
|
*/
|
|
5414
5469
|
cleanStyle(t, e) {
|
|
5415
|
-
return
|
|
5470
|
+
return Vt(
|
|
5416
5471
|
t,
|
|
5417
5472
|
e,
|
|
5418
5473
|
et,
|
|
@@ -5479,16 +5534,16 @@ class Ke {
|
|
|
5479
5534
|
}
|
|
5480
5535
|
}
|
|
5481
5536
|
}
|
|
5482
|
-
function
|
|
5537
|
+
function jo(r, t = {}) {
|
|
5483
5538
|
let e = 0, i = 0, o = 0;
|
|
5484
|
-
return
|
|
5539
|
+
return Ue(
|
|
5485
5540
|
r,
|
|
5486
5541
|
function(s) {
|
|
5487
5542
|
e += s[0], i += s[1], o++;
|
|
5488
5543
|
}
|
|
5489
|
-
),
|
|
5544
|
+
), ro([e / o, i / o], t.properties);
|
|
5490
5545
|
}
|
|
5491
|
-
class
|
|
5546
|
+
class Ho extends Xe {
|
|
5492
5547
|
measureOptions;
|
|
5493
5548
|
elevationCache;
|
|
5494
5549
|
/**
|
|
@@ -5500,18 +5555,33 @@ class Xo extends Ke {
|
|
|
5500
5555
|
}
|
|
5501
5556
|
set distanceUnit(t) {
|
|
5502
5557
|
const e = this.measureOptions.distanceUnit === t;
|
|
5503
|
-
this.measureOptions.distanceUnit = t,
|
|
5558
|
+
this.measureOptions.distanceUnit = t, e || this.recalc();
|
|
5504
5559
|
}
|
|
5505
5560
|
/**
|
|
5506
|
-
* The precision of distance value. It will be set different value
|
|
5561
|
+
* The precision of distance value. It will be set different value when distance unit is changed. Using setter to override the value if you want.
|
|
5507
5562
|
*/
|
|
5508
5563
|
get distancePrecision() {
|
|
5509
|
-
|
|
5564
|
+
let t = 2;
|
|
5565
|
+
return this.measureOptions.distanceUnit === "degrees" && (t = 6), this.measureOptions.distancePrecision ?? t;
|
|
5510
5566
|
}
|
|
5511
5567
|
set distancePrecision(t) {
|
|
5512
5568
|
const e = this.measureOptions.distancePrecision === t;
|
|
5513
5569
|
this.measureOptions.distancePrecision = t, e || this.recalc();
|
|
5514
5570
|
}
|
|
5571
|
+
/**
|
|
5572
|
+
* Default is `auto`. If `auto` is set, the unit is converted automatically based on the value.
|
|
5573
|
+
* If a specific unit is specified (e.g., 'km', 'm', 'cm', 'mi', 'ft', 'in'), the value is always returned in that unit.
|
|
5574
|
+
* This property is only effective when `distanceUnit` is set to 'kilometers' or 'miles'.
|
|
5575
|
+
* If `distanceUnit` is set to other values (e.g., 'degrees', 'radians'), it will be ignored, and `auto` will be applied.
|
|
5576
|
+
* If you need to force other unit type, please use DistanceUnit property.
|
|
5577
|
+
*/
|
|
5578
|
+
get forceDistanceUnit() {
|
|
5579
|
+
return this.measureOptions.forceDistanceUnit ?? "auto";
|
|
5580
|
+
}
|
|
5581
|
+
set forceDistanceUnit(t) {
|
|
5582
|
+
const e = this.measureOptions.forceDistanceUnit === t;
|
|
5583
|
+
this.measureOptions.forceDistanceUnit = t, e || this.recalc();
|
|
5584
|
+
}
|
|
5515
5585
|
/**
|
|
5516
5586
|
* The unit of area can be metric (m², ha, km²) or imperial (yd², acre, mi²). Default is metric.
|
|
5517
5587
|
* The measuring result will be recalculated once new value is set
|
|
@@ -5605,7 +5675,7 @@ class Xo extends Ke {
|
|
|
5605
5675
|
open: e.open,
|
|
5606
5676
|
modeOptions: e.modeOptions,
|
|
5607
5677
|
adapterOptions: e.adapterOptions
|
|
5608
|
-
}), this._cssPrefix = "measure-", this.measureOptions = e, this.measureOptions.elevationCacheConfig && this.measureOptions.elevationCacheConfig?.enabled && (this.elevationCache = new
|
|
5678
|
+
}), this._cssPrefix = "measure-", this.measureOptions = e, this.measureOptions.elevationCacheConfig && this.measureOptions.elevationCacheConfig?.enabled && (this.elevationCache = new Ve(
|
|
5609
5679
|
this.measureOptions.elevationCacheConfig.maxSize,
|
|
5610
5680
|
this.measureOptions.elevationCacheConfig.ttl
|
|
5611
5681
|
));
|
|
@@ -5676,7 +5746,7 @@ class Xo extends Ke {
|
|
|
5676
5746
|
const s = this.measureOptions.lineLayerLabelSpec?.source;
|
|
5677
5747
|
s && i.push(s);
|
|
5678
5748
|
const n = this.measureOptions.pointLayerLabelSpec?.source;
|
|
5679
|
-
return n && i.push(n),
|
|
5749
|
+
return n && i.push(n), Vt(
|
|
5680
5750
|
t,
|
|
5681
5751
|
e,
|
|
5682
5752
|
i,
|
|
@@ -5759,7 +5829,7 @@ class Xo extends Ke {
|
|
|
5759
5829
|
* Handle finish event of terradraw. It will be called after finishing adding a feature
|
|
5760
5830
|
* @param id Feature ID
|
|
5761
5831
|
*/
|
|
5762
|
-
handleTerradrawFeatureReady =
|
|
5832
|
+
handleTerradrawFeatureReady = ze((t) => {
|
|
5763
5833
|
this.map && (this.computeElevationByLineFeatureID(t), this.computeElevationByPointFeatureID(t));
|
|
5764
5834
|
}, 300);
|
|
5765
5835
|
/**
|
|
@@ -5858,7 +5928,7 @@ class Xo extends Ke {
|
|
|
5858
5928
|
(o) => o.properties?.originalId === t && o.geometry.type === "Point"
|
|
5859
5929
|
);
|
|
5860
5930
|
if (i && i.length > 0) {
|
|
5861
|
-
const o = await
|
|
5931
|
+
const o = await Se(
|
|
5862
5932
|
i,
|
|
5863
5933
|
this.measureOptions.terrainSource,
|
|
5864
5934
|
this.measureOptions.elevationCacheConfig,
|
|
@@ -5885,7 +5955,7 @@ class Xo extends Ke {
|
|
|
5885
5955
|
(o) => o.id === t && o.geometry.type === "Point" && o.properties?.mode === "point"
|
|
5886
5956
|
);
|
|
5887
5957
|
if (i && i.length > 0) {
|
|
5888
|
-
const o = await
|
|
5958
|
+
const o = await Se(
|
|
5889
5959
|
i,
|
|
5890
5960
|
this.measureOptions.terrainSource,
|
|
5891
5961
|
this.measureOptions.elevationCacheConfig,
|
|
@@ -5916,7 +5986,7 @@ class Xo extends Ke {
|
|
|
5916
5986
|
(a) => a.properties?.originalId !== t
|
|
5917
5987
|
));
|
|
5918
5988
|
const n = JSON.parse(JSON.stringify(o));
|
|
5919
|
-
n.id = n.id + "-area-label", n.geometry =
|
|
5989
|
+
n.id = n.id + "-area-label", n.geometry = jo(o.geometry).geometry, n.properties.originalId = o.id, o = fe(o, this.areaUnit, this.areaPrecision, this.forceAreaUnit), n.properties.area = o.properties.area, n.properties.unit = o.properties.unit, typeof s.data != "string" && s.data.type === "FeatureCollection" && s.data.features.push(n), this.map.getSource(
|
|
5920
5990
|
this.measureOptions.polygonLayerSpec.source
|
|
5921
5991
|
)?.setData(s.data), this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && this.map.moveLayer(
|
|
5922
5992
|
this.measureOptions.lineLayerLabelSpec.id
|
|
@@ -5946,10 +6016,11 @@ class Xo extends Ke {
|
|
|
5946
6016
|
if (s) {
|
|
5947
6017
|
typeof s.data != "string" && s.data.type === "FeatureCollection" && (s.data.features = s.data.features.filter(
|
|
5948
6018
|
(a) => a.properties?.originalId !== t
|
|
5949
|
-
)), o =
|
|
6019
|
+
)), o = ve(
|
|
5950
6020
|
o,
|
|
5951
6021
|
this.distanceUnit,
|
|
5952
6022
|
this.distancePrecision,
|
|
6023
|
+
this.forceDistanceUnit,
|
|
5953
6024
|
this.map,
|
|
5954
6025
|
this.computeElevation,
|
|
5955
6026
|
this.measureOptions.terrainSource
|
|
@@ -5958,17 +6029,17 @@ class Xo extends Ke {
|
|
|
5958
6029
|
for (let a = 0; a < n.length; a++) {
|
|
5959
6030
|
const l = n[a], d = l.geometry.coordinates, c = d[0], h = d[1];
|
|
5960
6031
|
if (a === 0) {
|
|
5961
|
-
const
|
|
5962
|
-
|
|
6032
|
+
const p = JSON.parse(JSON.stringify(l));
|
|
6033
|
+
p.id = `${l.id}-node-${a}`, p.geometry = {
|
|
5963
6034
|
type: "Point",
|
|
5964
6035
|
coordinates: c
|
|
5965
|
-
},
|
|
6036
|
+
}, p.properties.distance = 0, p.properties.total = 0, l.properties.elevation_start && (p.properties.elevation = l.properties.elevation_start), typeof s.data != "string" && s.data.type === "FeatureCollection" && s.data.features.push(p);
|
|
5966
6037
|
}
|
|
5967
|
-
const
|
|
5968
|
-
|
|
6038
|
+
const u = JSON.parse(JSON.stringify(l));
|
|
6039
|
+
u.id = `${l.id}-node-${a + 1}`, u.geometry = {
|
|
5969
6040
|
type: "Point",
|
|
5970
6041
|
coordinates: h
|
|
5971
|
-
}, l.properties.elevation_end && (
|
|
6042
|
+
}, l.properties.elevation_end && (u.properties.elevation = l.properties.elevation_end), typeof s.data != "string" && s.data.type === "FeatureCollection" && s.data.features.push(u);
|
|
5972
6043
|
}
|
|
5973
6044
|
this.map.getSource(
|
|
5974
6045
|
this.measureOptions.lineLayerLabelSpec.source
|
|
@@ -5993,7 +6064,7 @@ class Xo extends Ke {
|
|
|
5993
6064
|
let o = e.getSnapshot()?.find((s) => s.id === t && s.geometry.type === "Point");
|
|
5994
6065
|
if (o) {
|
|
5995
6066
|
const s = this.map.getStyle().sources[this.measureOptions.pointLayerLabelSpec.source];
|
|
5996
|
-
s && (typeof s.data != "string" && s.data.type === "FeatureCollection" && (s.data.features = s.data.features.filter((n) => n.id !== t)), o =
|
|
6067
|
+
s && (typeof s.data != "string" && s.data.type === "FeatureCollection" && (s.data.features = s.data.features.filter((n) => n.id !== t)), o = Pe(
|
|
5997
6068
|
o,
|
|
5998
6069
|
this.map,
|
|
5999
6070
|
this.computeElevation,
|
|
@@ -6038,14 +6109,15 @@ class Xo extends Ke {
|
|
|
6038
6109
|
const o = e.features[i];
|
|
6039
6110
|
if (!this.map || !this.map.loaded()) continue;
|
|
6040
6111
|
const s = o.geometry.type;
|
|
6041
|
-
s === "LineString" ? e.features[i] =
|
|
6112
|
+
s === "LineString" ? e.features[i] = ve(
|
|
6042
6113
|
o,
|
|
6043
6114
|
this.distanceUnit,
|
|
6044
6115
|
this.distancePrecision,
|
|
6116
|
+
this.forceDistanceUnit,
|
|
6045
6117
|
this.map,
|
|
6046
6118
|
this.computeElevation,
|
|
6047
6119
|
this.measureOptions.terrainSource
|
|
6048
|
-
) : s === "Polygon" ? e.features[i] =
|
|
6120
|
+
) : s === "Polygon" ? e.features[i] = fe(o, this.areaUnit, this.areaPrecision, this.forceAreaUnit) : s === "Point" && (e.features[i] = Pe(
|
|
6049
6121
|
o,
|
|
6050
6122
|
this.map,
|
|
6051
6123
|
this.computeElevation,
|
|
@@ -6055,7 +6127,7 @@ class Xo extends Ke {
|
|
|
6055
6127
|
return e;
|
|
6056
6128
|
}
|
|
6057
6129
|
}
|
|
6058
|
-
class
|
|
6130
|
+
class Jo extends Xe {
|
|
6059
6131
|
controlOptions;
|
|
6060
6132
|
valhallaOptions;
|
|
6061
6133
|
_modalDialog;
|
|
@@ -6254,13 +6326,13 @@ class Ho extends Ke {
|
|
|
6254
6326
|
const i = et, o = this.controlOptions.routingLineLayerNodeSpec?.source;
|
|
6255
6327
|
o && i.push(o);
|
|
6256
6328
|
const s = this.controlOptions.isochronePolygonLayerSpec?.source;
|
|
6257
|
-
return s && i.push(s),
|
|
6329
|
+
return s && i.push(s), Vt(t, e, i, this.options.adapterOptions?.prefixId);
|
|
6258
6330
|
}
|
|
6259
6331
|
/**
|
|
6260
6332
|
* Create the settings dialog for Valhalla control
|
|
6261
6333
|
*/
|
|
6262
6334
|
createSettingsDialog() {
|
|
6263
|
-
this.settingDialog = new
|
|
6335
|
+
this.settingDialog = new mo(
|
|
6264
6336
|
`maplibregl-terradraw-${this.cssPrefix}settings-dialog`,
|
|
6265
6337
|
"Settings"
|
|
6266
6338
|
), this.settingDialog.create(
|
|
@@ -6302,7 +6374,7 @@ class Ho extends Ke {
|
|
|
6302
6374
|
const i = document.createElement("label");
|
|
6303
6375
|
i.textContent = "Means of Transport", i.classList.add("setting-label"), e.appendChild(i), e.appendChild(
|
|
6304
6376
|
this.settingDialog.createSegmentButtons(
|
|
6305
|
-
|
|
6377
|
+
Wt,
|
|
6306
6378
|
this.routingCostingModel,
|
|
6307
6379
|
(n) => {
|
|
6308
6380
|
this.valhallaOptions.routingOptions || (this.valhallaOptions.routingOptions = {}), this.valhallaOptions.routingOptions.costingModel = n, this.dispatchEvent("setting-changed");
|
|
@@ -6314,7 +6386,7 @@ class Ho extends Ke {
|
|
|
6314
6386
|
const s = document.createElement("label");
|
|
6315
6387
|
return s.textContent = "Distance Unit", s.classList.add("setting-label"), o.appendChild(s), o.appendChild(
|
|
6316
6388
|
this.settingDialog.createSegmentButtons(
|
|
6317
|
-
|
|
6389
|
+
Wo,
|
|
6318
6390
|
this.routingDistanceUnit,
|
|
6319
6391
|
(n) => {
|
|
6320
6392
|
this.valhallaOptions.routingOptions || (this.valhallaOptions.routingOptions = {}), this.valhallaOptions.routingOptions.distanceUnit = n, this.dispatchEvent("setting-changed");
|
|
@@ -6331,7 +6403,7 @@ class Ho extends Ke {
|
|
|
6331
6403
|
const i = document.createElement("label");
|
|
6332
6404
|
i.textContent = "Contour Type", i.classList.add("setting-label"), e.appendChild(i), e.appendChild(
|
|
6333
6405
|
this.settingDialog.createSegmentButtons(
|
|
6334
|
-
|
|
6406
|
+
No,
|
|
6335
6407
|
this.controlOptions.valhallaOptions?.isochroneOptions?.contourType || "time",
|
|
6336
6408
|
(d) => {
|
|
6337
6409
|
this.valhallaOptions.isochroneOptions || (this.valhallaOptions.isochroneOptions = {}), this.valhallaOptions.isochroneOptions.contourType = d, this.dispatchEvent("setting-changed");
|
|
@@ -6343,7 +6415,7 @@ class Ho extends Ke {
|
|
|
6343
6415
|
const s = document.createElement("label");
|
|
6344
6416
|
s.textContent = "Means of Transport", s.classList.add("setting-label"), o.appendChild(s), o.appendChild(
|
|
6345
6417
|
this.settingDialog.createSegmentButtons(
|
|
6346
|
-
|
|
6418
|
+
Wt,
|
|
6347
6419
|
this.controlOptions.valhallaOptions?.isochroneOptions?.costingModel || "auto",
|
|
6348
6420
|
(d) => {
|
|
6349
6421
|
this.valhallaOptions.isochroneOptions || (this.valhallaOptions.isochroneOptions = {}), this.valhallaOptions.isochroneOptions.costingModel = d, this.dispatchEvent("setting-changed");
|
|
@@ -6374,15 +6446,15 @@ class Ho extends Ke {
|
|
|
6374
6446
|
const l = document.createElement("th");
|
|
6375
6447
|
o.appendChild(l), i.appendChild(o), e.appendChild(i);
|
|
6376
6448
|
const d = document.createElement("tbody"), c = this.controlOptions.valhallaOptions?.isochroneOptions?.contours;
|
|
6377
|
-
c.forEach((
|
|
6378
|
-
const g = this.createContourRow(
|
|
6449
|
+
c.forEach((u, p) => {
|
|
6450
|
+
const g = this.createContourRow(u, p);
|
|
6379
6451
|
d.appendChild(g);
|
|
6380
6452
|
}), e.appendChild(d), t.appendChild(e);
|
|
6381
6453
|
const h = document.createElement("button");
|
|
6382
|
-
return h.type = "button", h.classList.add("add-row-button"), h.textContent = "Add Contour", h.hidden = c.length >= 4, h.addEventListener("click", (
|
|
6383
|
-
|
|
6384
|
-
const
|
|
6385
|
-
d.appendChild(m),
|
|
6454
|
+
return h.type = "button", h.classList.add("add-row-button"), h.textContent = "Add Contour", h.hidden = c.length >= 4, h.addEventListener("click", (u) => {
|
|
6455
|
+
u.stopPropagation();
|
|
6456
|
+
const p = this.valhallaOptions.isochroneOptions?.contours, g = JSON.parse(JSON.stringify(p[p.length - 1])), y = d.children.length, m = this.createContourRow(g, y);
|
|
6457
|
+
d.appendChild(m), p.push(g), this.updateAddRowButtonState(), this.dispatchEvent("setting-changed");
|
|
6386
6458
|
}), t.appendChild(h), t;
|
|
6387
6459
|
}
|
|
6388
6460
|
/**
|
|
@@ -6410,10 +6482,10 @@ class Ho extends Ke {
|
|
|
6410
6482
|
const c = document.createElement("td");
|
|
6411
6483
|
if (e > 0) {
|
|
6412
6484
|
const h = document.createElement("button");
|
|
6413
|
-
h.type = "button", h.textContent = "×", h.classList.add("delete-button"), h.addEventListener("click", (
|
|
6414
|
-
|
|
6415
|
-
const
|
|
6416
|
-
i.remove(), this.valhallaOptions.isochroneOptions?.contours && this.valhallaOptions.isochroneOptions.contours.splice(
|
|
6485
|
+
h.type = "button", h.textContent = "×", h.classList.add("delete-button"), h.addEventListener("click", (u) => {
|
|
6486
|
+
u.stopPropagation();
|
|
6487
|
+
const p = parseInt(i.getAttribute("data-index") || "0");
|
|
6488
|
+
i.remove(), this.valhallaOptions.isochroneOptions?.contours && this.valhallaOptions.isochroneOptions.contours.splice(p, 1);
|
|
6417
6489
|
const g = i.parentElement;
|
|
6418
6490
|
g && Array.from(g.children).forEach((y, m) => {
|
|
6419
6491
|
y.setAttribute("data-index", m.toString());
|
|
@@ -6526,14 +6598,14 @@ class Ho extends Ke {
|
|
|
6526
6598
|
* Handle finish event of terradraw. It will be called after finishing adding a feature
|
|
6527
6599
|
* @param id Feature ID
|
|
6528
6600
|
*/
|
|
6529
|
-
handleTerradrawFeatureReady =
|
|
6601
|
+
handleTerradrawFeatureReady = ze((t) => {
|
|
6530
6602
|
this.map && (this.computeRouteByLineFeatureID(t), this.computeIsochroneByPointFeatureID(t));
|
|
6531
6603
|
}, 300);
|
|
6532
6604
|
computeIsochroneByPointFeatureID = async (t) => {
|
|
6533
6605
|
if (!this.map || !this.valhallaOptions.url) return;
|
|
6534
6606
|
const e = this.terradraw?.getSnapshotFeature(t);
|
|
6535
6607
|
if (!e || e && e.geometry.type !== "Point") return;
|
|
6536
|
-
const i = e.geometry.coordinates, n = (await new
|
|
6608
|
+
const i = e.geometry.coordinates, n = (await new To(this.valhallaUrl).calcIsochrone(
|
|
6537
6609
|
i[0],
|
|
6538
6610
|
i[1],
|
|
6539
6611
|
this.isochroneContourType,
|
|
@@ -6567,9 +6639,9 @@ class Ho extends Ke {
|
|
|
6567
6639
|
if (!this.map || !this.valhallaOptions.url) return;
|
|
6568
6640
|
const e = this.terradraw?.getSnapshotFeature(t);
|
|
6569
6641
|
if (!e || e && e.geometry.type !== "LineString") return;
|
|
6570
|
-
const i = new
|
|
6642
|
+
const i = new Bo(this.valhallaUrl), o = e.geometry.coordinates.map((c) => {
|
|
6571
6643
|
const h = c;
|
|
6572
|
-
return new
|
|
6644
|
+
return new He(h[0], h[1]);
|
|
6573
6645
|
});
|
|
6574
6646
|
if (!o || o && o.length < 2) return;
|
|
6575
6647
|
const s = await i.calcRoute(
|
|
@@ -6638,35 +6710,34 @@ class Ho extends Ke {
|
|
|
6638
6710
|
}
|
|
6639
6711
|
}
|
|
6640
6712
|
export {
|
|
6641
|
-
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6713
|
+
Vo as AvailableModes,
|
|
6714
|
+
$o as AvailableValhallaModes,
|
|
6715
|
+
Ho as MaplibreMeasureControl,
|
|
6716
|
+
Xe as MaplibreTerradrawControl,
|
|
6717
|
+
Jo as MaplibreValhallaControl,
|
|
6718
|
+
Ve as MemoryCache,
|
|
6719
|
+
mo as ModalDialog,
|
|
6720
|
+
Yo as TERRADRAW_MEASURE_SOURCE_IDS,
|
|
6649
6721
|
et as TERRADRAW_SOURCE_IDS,
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6722
|
+
Ko as TERRADRAW_VALHALLA_SOURCE_IDS,
|
|
6723
|
+
To as ValhallaIsochrone,
|
|
6724
|
+
Bo as ValhallaRouting,
|
|
6725
|
+
fe as calcArea,
|
|
6726
|
+
ve as calcDistance,
|
|
6727
|
+
Ce as capitalize,
|
|
6728
|
+
Vt as cleanMaplibreStyle,
|
|
6729
|
+
No as contourTypeOptions,
|
|
6730
|
+
go as convertAreaUnit,
|
|
6731
|
+
Dt as convertDistance,
|
|
6732
|
+
Wt as costingModelOptions,
|
|
6733
|
+
ze as debounce,
|
|
6734
|
+
eo as defaultControlOptions,
|
|
6663
6735
|
lt as defaultMeasureControlOptions,
|
|
6664
6736
|
z as defaultValhallaControlOptions,
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
To as routingDistanceUnitOptions
|
|
6737
|
+
io as getDefaultModeOptions,
|
|
6738
|
+
Pe as queryElevationByPoint,
|
|
6739
|
+
Se as queryElevationFromRasterDEM,
|
|
6740
|
+
Xo as roundFeatureCoordinates,
|
|
6741
|
+
Wo as routingDistanceUnitOptions
|
|
6671
6742
|
};
|
|
6672
6743
|
//# sourceMappingURL=maplibre-gl-terradraw.es.js.map
|