@watergis/maplibre-gl-terradraw 1.7.6 → 1.8.1
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 +616 -585
- 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/constants/defaultMeasureUnitSymbols.d.ts +3 -0
- package/dist/types/constants/defaultMeasureUnitSymbols.d.ts.map +1 -0
- package/dist/types/constants/index.d.ts +1 -0
- package/dist/types/constants/index.d.ts.map +1 -1
- package/dist/types/controls/MaplibreMeasureControl.d.ts +5 -5
- package/dist/types/controls/MaplibreMeasureControl.d.ts.map +1 -1
- package/dist/types/helpers/calcArea.d.ts +2 -2
- package/dist/types/helpers/calcArea.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/convertAreaUnit.d.ts +2 -2
- package/dist/types/helpers/convertAreaUnit.d.ts.map +1 -1
- package/dist/types/helpers/convertDistance.d.ts +3 -3
- package/dist/types/helpers/convertDistance.d.ts.map +1 -1
- package/dist/types/interfaces/MeasureControlOptions.d.ts +4 -4
- package/dist/types/interfaces/MeasureControlOptions.d.ts.map +1 -1
- package/dist/types/interfaces/MeasureUnit.d.ts +9 -0
- package/dist/types/interfaces/MeasureUnit.d.ts.map +1 -0
- package/dist/types/interfaces/index.d.ts +1 -2
- package/dist/types/interfaces/index.d.ts.map +1 -1
- package/package.json +27 -27
- package/dist/types/interfaces/AreaUnit.d.ts +0 -5
- package/dist/types/interfaces/AreaUnit.d.ts.map +0 -1
- package/dist/types/interfaces/DistanceUnit.d.ts +0 -6
- package/dist/types/interfaces/DistanceUnit.d.ts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LngLat as
|
|
1
|
+
import { LngLat as Je } 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++) {
|
|
@@ -8,28 +8,28 @@ function x() {
|
|
|
8
8
|
return r;
|
|
9
9
|
}, x.apply(null, arguments);
|
|
10
10
|
}
|
|
11
|
-
var
|
|
11
|
+
var E;
|
|
12
12
|
(function(r) {
|
|
13
13
|
r.Commit = "commit", r.Provisional = "provisional", r.Finish = "finish";
|
|
14
|
-
})(
|
|
14
|
+
})(E || (E = {}));
|
|
15
15
|
const k = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT_FEATURE_ID: "selectionPointFeatureId", SELECTION_POINT: "selectionPoint" }, S = { MODE: "mode", CURRENTLY_DRAWING: "currentlyDrawing", EDITED: "edited", CLOSING_POINT: "closingPoint", SNAPPING_POINT: "snappingPoint", COORDINATE_POINT: "coordinatePoint", COORDINATE_POINT_FEATURE_ID: "coordinatePointFeatureId", COORDINATE_POINT_IDS: "coordinatePointIds", PROVISIONAL_COORDINATE_COUNT: "provisionalCoordinateCount", COMMITTED_COORDINATE_COUNT: "committedCoordinateCount" }, j = 10;
|
|
16
|
-
function
|
|
16
|
+
function wt(r) {
|
|
17
17
|
return !!(r && typeof r == "object" && r !== null && !Array.isArray(r));
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function Qt(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 te(r) {
|
|
23
23
|
return !!(function(t) {
|
|
24
24
|
return typeof t == "number" && !isNaN(new Date(t).valueOf());
|
|
25
25
|
})(r);
|
|
26
26
|
}
|
|
27
|
-
const
|
|
28
|
-
var
|
|
27
|
+
const He = "Feature mode property does not match the mode being added to";
|
|
28
|
+
var q;
|
|
29
29
|
(function(r) {
|
|
30
30
|
r.Drawing = "drawing", r.Select = "select", r.Static = "static", r.Render = "render";
|
|
31
|
-
})(
|
|
32
|
-
const
|
|
31
|
+
})(q || (q = {}));
|
|
32
|
+
const Ze = { 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 = Ze, 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 = q.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 (wt(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 (wt(i.geometry)) if (wt(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";
|
|
@@ -95,14 +95,14 @@ class A {
|
|
|
95
95
|
return s ? { valid: !1, reason: s } : { valid: !0 };
|
|
96
96
|
})(t, this.store.idStrategy.isValidId);
|
|
97
97
|
if (this.validate) {
|
|
98
|
-
const i = this.validate(t, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
98
|
+
const i = this.validate(t, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: E.Provisional });
|
|
99
99
|
return { valid: e.valid && i.valid, reason: i.reason };
|
|
100
100
|
}
|
|
101
101
|
return { valid: e.valid, reason: e.reason };
|
|
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: He } : e(t) : { valid: !1, reason: i.reason };
|
|
106
106
|
}
|
|
107
107
|
onFinish(t, e) {
|
|
108
108
|
}
|
|
@@ -134,43 +134,43 @@ class A {
|
|
|
134
134
|
return t === void 0 ? e : typeof t == "function" ? t(i) : t;
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
let
|
|
137
|
+
let Qe = class extends A {
|
|
138
138
|
constructor(...t) {
|
|
139
|
-
super(...t), this.type =
|
|
139
|
+
super(...t), this.type = q.Select;
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
142
|
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 xe = 63710088e-1;
|
|
147
147
|
function D(r) {
|
|
148
148
|
return r % 360 * Math.PI / 180;
|
|
149
149
|
}
|
|
150
|
-
function
|
|
150
|
+
function Oe(r) {
|
|
151
151
|
return r / 6371.0088;
|
|
152
152
|
}
|
|
153
153
|
function V(r) {
|
|
154
154
|
return r % (2 * Math.PI) * 180 / Math.PI;
|
|
155
155
|
}
|
|
156
|
-
function
|
|
156
|
+
function b(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 ee = 57.29577951308232, ie = 0.017453292519943295, St = 6378137, O = (r, t) => ({ x: r === 0 ? 0 : r * ie * St, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * ie / 2)) * St }), R = (r, t) => ({ lng: r === 0 ? 0 : ee * (r / St), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / St)) - Math.PI / 2) * ee });
|
|
161
|
+
function ti(r, t, e) {
|
|
162
|
+
const i = D(r[0]), o = D(r[1]), s = D(e), n = Oe(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 oe(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 =
|
|
169
|
-
s.push([
|
|
168
|
+
const a = ti(t, e, -360 * n / o);
|
|
169
|
+
s.push([b(a[0], i), b(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 jt(r) {
|
|
174
174
|
let t;
|
|
175
175
|
if (r.geometry.type === "Polygon") t = r.geometry.coordinates;
|
|
176
176
|
else {
|
|
@@ -186,8 +186,8 @@ function Bt(r) {
|
|
|
186
186
|
function o(s, n, a, l) {
|
|
187
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
|
-
const P = m[0], I = m[1],
|
|
190
|
-
return $ === 0 ? null : [((P * L - I *
|
|
189
|
+
const P = m[0], I = m[1], w = v[0], L = v[1], M = C[0], N = C[1], _ = f[0], T = f[1], $ = (P - w) * (N - T) - (I - L) * (M - _);
|
|
190
|
+
return $ === 0 ? null : [((P * L - I * w) * (M - _) - (P - w) * (M * T - N * _)) / $, ((P * L - I * w) * (N - T) - (I - L) * (M * T - N * _)) / $];
|
|
191
191
|
})(d, c, h, u);
|
|
192
192
|
if (p === null) return;
|
|
193
193
|
let g, y;
|
|
@@ -198,37 +198,37 @@ function gt(r, t) {
|
|
|
198
198
|
return r[0] === t[0] && r[1] === t[1];
|
|
199
199
|
}
|
|
200
200
|
function Ot(r, t) {
|
|
201
|
-
return
|
|
201
|
+
return se(r[0]) <= t && se(r[1]) <= t;
|
|
202
202
|
}
|
|
203
|
-
function
|
|
203
|
+
function At(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 se(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 ei = "Feature has holes", ii = "Feature has less than 4 coordinates", oi = "Feature has invalid coordinates", si = "Feature coordinates are not closed";
|
|
213
|
+
function Et(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: ei };
|
|
216
|
+
if (r.geometry.coordinates[0].length < 4) return { valid: !1, reason: ii };
|
|
217
217
|
for (let o = 0; o < r.geometry.coordinates[0].length; o++) {
|
|
218
|
-
if (!
|
|
218
|
+
if (!At(r.geometry.coordinates[0][o])) return { valid: !1, reason: oi };
|
|
219
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: si } : { 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 = Et(r, t);
|
|
226
|
+
return e.valid ? jt(r) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
|
|
227
227
|
}
|
|
228
|
-
const
|
|
229
|
-
let
|
|
228
|
+
const ri = { cancel: "Escape", finish: "Enter" }, ni = { start: "crosshair" };
|
|
229
|
+
let Ee = 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 = ri, this.cursors = ni, 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);
|
|
@@ -239,7 +239,7 @@ let Oe = class extends A {
|
|
|
239
239
|
const t = this.currentCircleId;
|
|
240
240
|
if (this.validate && t) {
|
|
241
241
|
const e = this.store.getGeometryCopy(t);
|
|
242
|
-
if (!this.validate({ type: "Feature", id: t, geometry: e, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
242
|
+
if (!this.validate({ type: "Feature", id: t, geometry: e, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: E.Finish }).valid) return;
|
|
243
243
|
}
|
|
244
244
|
this.cursorMovedAfterInitialCursorDown = !1, this.center = void 0, this.currentCircleId = void 0, this.clickCount = 0, this.state === "drawing" && this.setStarted(), this.onFinish(t, { mode: this.mode, action: "draw" });
|
|
245
245
|
}
|
|
@@ -252,7 +252,7 @@ let Oe = 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 = oe({ 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
|
}
|
|
@@ -299,16 +299,16 @@ let Oe = class extends A {
|
|
|
299
299
|
i = (function(s) {
|
|
300
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] = [p + C, g + f], { lng:
|
|
303
|
-
y.push([w
|
|
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: w, lat: L } = R(P, I);
|
|
303
|
+
y.push([b(w, l), b(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 = oe({ center: this.center, radiusKilometers: e, coordinatePrecision: this.coordinatePrecision });
|
|
310
310
|
}
|
|
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:
|
|
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: E.Provisional }).valid) return;
|
|
312
312
|
this.store.updateGeometry([{ id: this.currentCircleId, geometry: i.geometry }]), this.store.updateProperty([{ id: this.currentCircleId, property: "radiusKilometers", value: e }]);
|
|
313
313
|
}
|
|
314
314
|
}
|
|
@@ -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
|
|
334
|
+
const ai = { cancel: "Escape", finish: "Enter" }, li = { start: "crosshair", close: "pointer" };
|
|
335
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 = ai, this.cursors = li, 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));
|
|
@@ -348,7 +348,7 @@ class be extends A {
|
|
|
348
348
|
const t = this.currentId;
|
|
349
349
|
if (this.validate && t) {
|
|
350
350
|
const e = this.store.getGeometryCopy(t);
|
|
351
|
-
if (!this.validate({ type: "Feature", id: t, geometry: e, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
351
|
+
if (!this.validate({ type: "Feature", id: t, geometry: e, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: E.Finish }).valid) return;
|
|
352
352
|
}
|
|
353
353
|
this.closingPointId && this.store.delete([this.closingPointId]), this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.hasLeftStartingPoint = !1, this.state === "drawing" && this.setStarted(), this.onFinish(t, { mode: this.mode, action: "draw" });
|
|
354
354
|
}
|
|
@@ -369,7 +369,7 @@ class be extends A {
|
|
|
369
369
|
if (l < this.minDistance) return;
|
|
370
370
|
e.coordinates[0].pop();
|
|
371
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:
|
|
372
|
+
this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: p, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: E.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 be 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) => Et(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 we({ 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 we({ unproject: this.unproject, point: { x: e, y: i }, pointerDistance: this.pointerDistance });
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
432
|
class ct extends B {
|
|
@@ -458,15 +458,15 @@ let It = 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 re(r, t, e) {
|
|
462
|
+
const i = D(r[0]), o = D(r[1]), s = D(e), n = Oe(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 ne(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 di(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 = ne(r[c], r[c - 1]) - 180, a = re(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 = ne(r[c], r[c - 1]) - 180, a = re(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 li(r, t, e) {
|
|
|
498
498
|
function yt(r) {
|
|
499
499
|
return r * (Math.PI / 180);
|
|
500
500
|
}
|
|
501
|
-
function
|
|
501
|
+
function ae(r) {
|
|
502
502
|
return r * (180 / Math.PI);
|
|
503
503
|
}
|
|
504
|
-
class
|
|
504
|
+
class ci extends B {
|
|
505
505
|
constructor(t) {
|
|
506
506
|
super(t), this.config = void 0, this.config = t;
|
|
507
507
|
}
|
|
@@ -514,7 +514,7 @@ class di 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 = di(o, i * d, i * (d + 1));
|
|
518
518
|
a.push(c);
|
|
519
519
|
}
|
|
520
520
|
const l = [];
|
|
@@ -530,40 +530,40 @@ class di extends B {
|
|
|
530
530
|
for (let y = 0; y <= l; y++) {
|
|
531
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
|
-
const
|
|
534
|
-
isNaN(
|
|
533
|
+
const w = Math.atan2(I, Math.sqrt(f ** 2 + P ** 2)), L = Math.atan2(P, f);
|
|
534
|
+
isNaN(w) || isNaN(L) || d.push([ae(L), ae(w)]);
|
|
535
535
|
}
|
|
536
536
|
return d.slice(1, -1);
|
|
537
537
|
})(t, e, Math.floor(o / i));
|
|
538
538
|
return this.limitCoordinates(s);
|
|
539
539
|
}
|
|
540
540
|
limitCoordinates(t) {
|
|
541
|
-
return t.map((e) => [
|
|
541
|
+
return t.map((e) => [b(e[0], this.config.coordinatePrecision), b(e[1], this.config.coordinatePrecision)]);
|
|
542
542
|
}
|
|
543
543
|
}
|
|
544
544
|
function tt(r, t) {
|
|
545
545
|
return r[0] === t[0] && r[1] === t[1];
|
|
546
546
|
}
|
|
547
|
-
function
|
|
547
|
+
function Rt(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 (!
|
|
551
|
+
if (!At(r.geometry.coordinates[e])) return { valid: !1, reason: "Feature has invalid coordinates" };
|
|
552
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 le(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) / (le(r) * le(t));
|
|
564
564
|
return Math.acos(Math.min(Math.max(e, -1), 1));
|
|
565
565
|
}
|
|
566
|
-
function
|
|
566
|
+
function Lt(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,26 +571,26 @@ 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), 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),
|
|
574
|
+
function hi(r, t, e) {
|
|
575
|
+
const i = Lt(r), o = Lt(t), s = Lt(e), [n, a, l] = s, [d, c, h] = (function(T, $) {
|
|
576
|
+
const [Kt, Xt, qt] = T, [Jt, Ht, Zt] = $;
|
|
577
|
+
return [Xt * Zt - qt * Ht, qt * Jt - Kt * Zt, Kt * Ht - Xt * Jt];
|
|
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), w = Y(i, f), L = Y(o, f), M = Y(i, P), N = Y(o, P);
|
|
579
579
|
let _;
|
|
580
|
-
return _ =
|
|
580
|
+
return _ = w < M && w < 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 ui(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 Gt 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));
|
|
590
|
-
return s.coordinate ? [
|
|
590
|
+
return s.coordinate ? [b(s.coordinate[0], this.config.coordinatePrecision), b(s.coordinate[1], this.config.coordinatePrecision)] : void 0;
|
|
591
591
|
}, this.getSnappableCoordinate = (o, s) => {
|
|
592
592
|
const n = this.getSnappable(o, (a) => !!(a.properties && a.properties.mode === this.mode && a.id !== s));
|
|
593
|
-
return n.coordinate ? [
|
|
593
|
+
return n.coordinate ? [b(n.coordinate[0], this.config.coordinatePrecision), b(n.coordinate[1], this.config.coordinatePrecision)] : void 0;
|
|
594
594
|
}, this.config = t, this.pixelDistance = e, this.clickBoundingBox = i;
|
|
595
595
|
}
|
|
596
596
|
getSnappable(t, e) {
|
|
@@ -611,11 +611,11 @@ class Rt extends B {
|
|
|
611
611
|
for (let v of p) {
|
|
612
612
|
const C = v[0], f = v[1];
|
|
613
613
|
let P, I = 1 / 0;
|
|
614
|
-
const
|
|
614
|
+
const w = O(C[0], C[1]), L = O(f[0], f[1]), M = O(u[0], u[1]);
|
|
615
615
|
if (C[0] === u[0] && C[1] === u[1]) P = C;
|
|
616
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: _ } = ui(w, L, M), { lng: T, lat: $ } = R(N, _);
|
|
619
619
|
P = [T, $];
|
|
620
620
|
}
|
|
621
621
|
P && (I = F(M, O(P[0], P[1])), I < y && (g = P, y = I, m = p.indexOf(v)));
|
|
@@ -626,19 +626,19 @@ class Rt extends B {
|
|
|
626
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] === u[0] && C[1] === u[1] ? P = C : f[0] === u[0] && f[1] === u[1] ? P = f : [P] =
|
|
629
|
+
C[0] === u[0] && C[1] === u[1] ? P = C : f[0] === u[0] && f[1] === u[1] ? P = f : [P] = hi(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;
|
|
633
633
|
const h = this.pixelDistance.measure(t, d.coordinate);
|
|
634
|
-
h < s.minDistance && h < this.pointerDistance && (s.featureId = n.id, s.coordinate = [
|
|
634
|
+
h < s.minDistance && h < this.pointerDistance && (s.featureId = n.id, s.coordinate = [b(d.coordinate[0], this.config.coordinatePrecision), b(d.coordinate[1], this.config.coordinatePrecision)], s.featureCoordinateIndex = d.lineIndex, s.minDistance = h);
|
|
635
635
|
}), s;
|
|
636
636
|
}
|
|
637
637
|
}
|
|
638
|
-
const
|
|
639
|
-
class
|
|
638
|
+
const pi = { cancel: "Escape", finish: "Enter" }, gi = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
639
|
+
class Ut 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 = pi, this.snapping = void 0, this.cursors = gi, 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);
|
|
@@ -658,7 +658,7 @@ class Gt extends A {
|
|
|
658
658
|
close() {
|
|
659
659
|
if (this.currentId === void 0) return;
|
|
660
660
|
const t = this.store.getGeometryCopy(this.currentId);
|
|
661
|
-
t.coordinates.pop(), this.updateGeometries([...t.coordinates], void 0,
|
|
661
|
+
t.coordinates.pop(), this.updateGeometries([...t.coordinates], void 0, E.Commit), this.store.updateProperty([{ id: this.currentId, property: S.CURRENTLY_DRAWING, value: void 0 }]);
|
|
662
662
|
const e = this.currentId;
|
|
663
663
|
this.closingPointId && this.store.delete([this.closingPointId]), this.snappedPointId && this.store.delete([this.snappedPointId]), this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.snappedPointId = void 0, this.lastCommittedCoordinates = void 0, this.state === "drawing" && this.setStarted(), this.onFinish(e, { mode: this.mode, action: "draw" });
|
|
664
664
|
}
|
|
@@ -685,7 +685,7 @@ class Gt extends A {
|
|
|
685
685
|
const e = this.store.getGeometryCopy(this.currentId).coordinates, [i] = this.store.create([{ geometry: { type: "Point", coordinates: [...t] }, properties: { mode: this.mode, [S.CLOSING_POINT]: !0 } }]);
|
|
686
686
|
this.closingPointId = i, this.setCursor(this.cursors.close);
|
|
687
687
|
const o = [...e, t];
|
|
688
|
-
this.updateGeometries(o, void 0,
|
|
688
|
+
this.updateGeometries(o, void 0, E.Commit), this.currentCoordinate++;
|
|
689
689
|
}
|
|
690
690
|
updateToLine(t, e) {
|
|
691
691
|
if (!this.currentId) return;
|
|
@@ -693,10 +693,10 @@ class Gt extends A {
|
|
|
693
693
|
if (F({ x: n, y: a }, { x: e.x, y: e.y }) < this.pointerDistance) return void this.close();
|
|
694
694
|
this.setCursor(this.cursors.close);
|
|
695
695
|
const l = [...i, t];
|
|
696
|
-
this.updateGeometries(l, i[i.length - 1],
|
|
696
|
+
this.updateGeometries(l, i[i.length - 1], E.Commit), this.currentCoordinate++;
|
|
697
697
|
}
|
|
698
698
|
registerBehaviors(t) {
|
|
699
|
-
this.coordinateSnapping = new It(t, new ct(t), new dt(t)), this.insertPoint = new
|
|
699
|
+
this.coordinateSnapping = new It(t, new ct(t), new dt(t)), this.insertPoint = new ci(t), this.clickBoundingBox = new dt(t), this.pixelDistance = new ct(t), this.lineSnapping = new Gt(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);
|
|
@@ -721,7 +721,7 @@ class Gt extends A {
|
|
|
721
721
|
o = [...this.lastCommittedCoordinates.slice(0, -1), ...a, e];
|
|
722
722
|
}
|
|
723
723
|
}
|
|
724
|
-
this.updateGeometries(o, void 0,
|
|
724
|
+
this.updateGeometries(o, void 0, E.Provisional);
|
|
725
725
|
}
|
|
726
726
|
onRightClick(t) {
|
|
727
727
|
if (!this.editable || this.state !== "started") return;
|
|
@@ -730,7 +730,7 @@ class Gt extends A {
|
|
|
730
730
|
const o = this.store.getGeometryCopy(e);
|
|
731
731
|
let s;
|
|
732
732
|
if (o.type === "LineString" && (s = o.coordinates, !(s.length <= 2))) {
|
|
733
|
-
if (s.splice(i, 1), this.validate && !this.validate({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
733
|
+
if (s.splice(i, 1), this.validate && !this.validate({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: E.Commit }).valid) return;
|
|
734
734
|
this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: e, geometry: o }]), this.onFinish(e, { mode: this.mode, action: "edit" });
|
|
735
735
|
}
|
|
736
736
|
}
|
|
@@ -769,7 +769,7 @@ class Gt extends A {
|
|
|
769
769
|
const i = this.store.getGeometryCopy(this.editedFeatureId);
|
|
770
770
|
this.editedSnapType === "coordinate" || this.editedSnapType === "line" && this.editedInsertIndex !== void 0 ? i.coordinates[this.editedFeatureCoordinateIndex] = [t.lng, t.lat] : this.editedSnapType === "line" && this.editedInsertIndex === void 0 && (this.editedInsertIndex = this.editedFeatureCoordinateIndex + 1, i.coordinates.splice(this.editedInsertIndex, 0, [t.lng, t.lat]), this.editedFeatureCoordinateIndex++);
|
|
771
771
|
const o = { type: "LineString", coordinates: i.coordinates };
|
|
772
|
-
this.validate && !this.validate({ type: "Feature", geometry: o, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
772
|
+
this.validate && !this.validate({ type: "Feature", geometry: o, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: E.Provisional }).valid || (this.snapping && this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: this.editedFeatureId, geometry: o }]), this.editedPointId && this.store.updateGeometry([{ id: this.editedPointId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: S.EDITED, value: !0 }]));
|
|
773
773
|
}
|
|
774
774
|
onDragEnd(t, e) {
|
|
775
775
|
this.allowPointerEvent(this.pointerEvents.onDragEnd, t) && this.editedFeatureId !== void 0 && (this.setCursor(this.cursors.dragEnd), this.editedPointId && (this.store.delete([this.editedPointId]), this.editedPointId = void 0), this.store.updateProperty([{ id: this.editedFeatureId, property: S.EDITED, value: !1 }]), this.onFinish(this.editedFeatureId, { mode: this.mode, action: "edit" }), this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedInsertIndex = void 0, this.editedSnapType = void 0, e(!0));
|
|
@@ -792,7 +792,7 @@ class Gt extends A {
|
|
|
792
792
|
return e;
|
|
793
793
|
}
|
|
794
794
|
validateFeature(t) {
|
|
795
|
-
return this.validateModeFeature(t, (e) =>
|
|
795
|
+
return this.validateModeFeature(t, (e) => Rt(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 Gt 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 yi = "Feature is not a Point", fi = "Feature has invalid coordinates", mi = "Feature has coordinates with excessive precision";
|
|
814
|
+
function Le(r, t) {
|
|
815
|
+
return r.geometry.type !== "Point" ? { valid: !1, reason: yi } : At(r.geometry.coordinates) ? Ot(r.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: mi } : { valid: !1, reason: fi };
|
|
816
816
|
}
|
|
817
|
-
const
|
|
818
|
-
class
|
|
817
|
+
const vi = { create: "crosshair", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
818
|
+
class zt extends A {
|
|
819
819
|
constructor(t) {
|
|
820
|
-
super(t, !0), this.mode = "point", this.cursors =
|
|
820
|
+
super(t, !0), this.mode = "point", this.cursors = vi, 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);
|
|
@@ -850,7 +850,7 @@ class Ut extends A {
|
|
|
850
850
|
}
|
|
851
851
|
}
|
|
852
852
|
onDrag(t, e) {
|
|
853
|
-
this.allowPointerEvent(this.pointerEvents.onDrag, t) && this.editedFeatureId !== void 0 && (this.validate && !this.validate({ type: "Feature", geometry: { type: "Point", coordinates: [t.lng, t.lat] }, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
853
|
+
this.allowPointerEvent(this.pointerEvents.onDrag, t) && this.editedFeatureId !== void 0 && (this.validate && !this.validate({ type: "Feature", geometry: { type: "Point", coordinates: [t.lng, t.lat] }, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: E.Finish }).valid || (this.store.updateGeometry([{ id: this.editedFeatureId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: S.EDITED, value: !0 }])));
|
|
854
854
|
}
|
|
855
855
|
onDragEnd(t, e) {
|
|
856
856
|
this.allowPointerEvent(this.pointerEvents.onDragEnd, t) && this.editedFeatureId !== void 0 && (this.onFinish(this.editedFeatureId, { mode: this.mode, action: "edit" }), this.setCursor(this.cursors.dragEnd), this.store.updateProperty([{ id: this.editedFeatureId, property: S.EDITED, value: !1 }]), this.editedFeatureId = void 0, e(!0));
|
|
@@ -867,11 +867,11 @@ class Ut extends A {
|
|
|
867
867
|
return e;
|
|
868
868
|
}
|
|
869
869
|
validateFeature(t) {
|
|
870
|
-
return this.validateModeFeature(t, (e) =>
|
|
870
|
+
return this.validateModeFeature(t, (e) => Le(e, this.coordinatePrecision));
|
|
871
871
|
}
|
|
872
872
|
onLeftClick(t) {
|
|
873
873
|
const e = { type: "Point", coordinates: [t.lng, t.lat] }, i = { mode: this.mode };
|
|
874
|
-
if (this.validate && !this.validate({ type: "Feature", geometry: e, properties: i }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
874
|
+
if (this.validate && !this.validate({ type: "Feature", geometry: e, properties: i }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: E.Finish }).valid) return;
|
|
875
875
|
const [o] = this.store.create([{ geometry: e, properties: i }]);
|
|
876
876
|
this.onFinish(o, { mode: this.mode, action: "draw" });
|
|
877
877
|
}
|
|
@@ -895,7 +895,7 @@ class Ut 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 Ci 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 vi extends B {
|
|
|
921
921
|
return { isClosing: o < this.pointerDistance, isPreviousClosing: s < this.pointerDistance };
|
|
922
922
|
}
|
|
923
923
|
}
|
|
924
|
-
class
|
|
924
|
+
class Fe extends B {
|
|
925
925
|
constructor(t) {
|
|
926
926
|
super(t);
|
|
927
927
|
}
|
|
@@ -976,10 +976,10 @@ class Le extends B {
|
|
|
976
976
|
e && (this.deleteCoordinatePoints(e), this.setFeatureCoordinatePoints(t, null));
|
|
977
977
|
}
|
|
978
978
|
}
|
|
979
|
-
const
|
|
980
|
-
class
|
|
979
|
+
const Pi = { cancel: "Escape", finish: "Enter" }, Si = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
980
|
+
class Me 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 = Pi, this.cursors = Si, 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) {
|
|
@@ -995,7 +995,7 @@ class Fe extends A {
|
|
|
995
995
|
close() {
|
|
996
996
|
if (this.currentId === void 0) return;
|
|
997
997
|
const t = this.store.getGeometryCopy(this.currentId).coordinates[0];
|
|
998
|
-
if (t.length < 5 || !this.updatePolygonGeometry([...t.slice(0, -2), t[0]],
|
|
998
|
+
if (t.length < 5 || !this.updatePolygonGeometry([...t.slice(0, -2), t[0]], E.Finish)) return;
|
|
999
999
|
const e = this.currentId;
|
|
1000
1000
|
if (this.currentId) {
|
|
1001
1001
|
const i = pt(this.store.getGeometryCopy(this.currentId));
|
|
@@ -1004,7 +1004,7 @@ class Fe 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 Gt(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new It(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new Ci(t, this.pixelDistance), this.coordinatePoints = new Fe(t);
|
|
1008
1008
|
}
|
|
1009
1009
|
start() {
|
|
1010
1010
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -1035,7 +1035,7 @@ class Fe extends A {
|
|
|
1035
1035
|
const { isClosing: o, isPreviousClosing: s } = this.closingPoints.isClosingPoint(t);
|
|
1036
1036
|
s || o ? (this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.setCursor(this.cursors.close), i = [...e.slice(0, -2), e[0], e[0]]) : i = [...e.slice(0, -2), [t.lng, t.lat], e[0]];
|
|
1037
1037
|
}
|
|
1038
|
-
this.store.updateProperty([{ id: this.currentId, property: S.PROVISIONAL_COORDINATE_COUNT, value: this.currentCoordinate + 1 }]), this.updatePolygonGeometry(i,
|
|
1038
|
+
this.store.updateProperty([{ id: this.currentId, property: S.PROVISIONAL_COORDINATE_COUNT, value: this.currentCoordinate + 1 }]), this.updatePolygonGeometry(i, E.Provisional);
|
|
1039
1039
|
}
|
|
1040
1040
|
updatePolygonGeometry(t, e) {
|
|
1041
1041
|
if (!this.currentId) return !1;
|
|
@@ -1064,7 +1064,7 @@ class Fe extends A {
|
|
|
1064
1064
|
if (!e || i === void 0) return;
|
|
1065
1065
|
const o = this.store.getGeometryCopy(e);
|
|
1066
1066
|
let s;
|
|
1067
|
-
o.type === "Polygon" && (s = o.coordinates[0], s.length <= 4 || (o.type !== "Polygon" || i !== 0 && i !== s.length - 1 ? s.splice(i, 1) : (s.shift(), s.pop(), s.push([s[0][0], s[0][1]])), (!this.validate || this.validate({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
1067
|
+
o.type === "Polygon" && (s = o.coordinates[0], s.length <= 4 || (o.type !== "Polygon" || i !== 0 && i !== s.length - 1 ? s.splice(i, 1) : (s.shift(), s.pop(), s.push([s[0][0], s[0][1]])), (!this.validate || this.validate({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: E.Commit }).valid) && (this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: e, geometry: o }]), this.showCoordinatePoints && this.coordinatePoints.createOrUpdate(e), this.onFinish(e, { mode: this.mode, action: "edit" }))));
|
|
1068
1068
|
}
|
|
1069
1069
|
onLeftClick(t) {
|
|
1070
1070
|
if (this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.currentCoordinate === 0) {
|
|
@@ -1076,13 +1076,13 @@ class Fe extends A {
|
|
|
1076
1076
|
const e = this.snapCoordinate(t);
|
|
1077
1077
|
e && (t.lng = e[0], t.lat = e[1]);
|
|
1078
1078
|
const i = this.store.getGeometryCopy(this.currentId);
|
|
1079
|
-
if (tt([t.lng, t.lat], i.coordinates[0][0]) || !this.updatePolygonGeometry([i.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], i.coordinates[0][0]],
|
|
1079
|
+
if (tt([t.lng, t.lat], i.coordinates[0][0]) || !this.updatePolygonGeometry([i.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], i.coordinates[0][0]], E.Commit)) return;
|
|
1080
1080
|
this.store.updateProperty([{ id: this.currentId, property: S.COMMITTED_COORDINATE_COUNT, value: this.currentCoordinate + 1 }]), this.currentCoordinate++;
|
|
1081
1081
|
} else if (this.currentCoordinate === 2 && this.currentId) {
|
|
1082
1082
|
const e = this.snapCoordinate(t);
|
|
1083
1083
|
e && (t.lng = e[0], t.lat = e[1]);
|
|
1084
1084
|
const i = this.store.getGeometryCopy(this.currentId).coordinates[0];
|
|
1085
|
-
if (tt([t.lng, t.lat], i[1]) || !this.updatePolygonGeometry([i[0], i[1], [t.lng, t.lat], [t.lng, t.lat], i[0]],
|
|
1085
|
+
if (tt([t.lng, t.lat], i[1]) || !this.updatePolygonGeometry([i[0], i[1], [t.lng, t.lat], [t.lng, t.lat], i[0]], E.Commit)) return;
|
|
1086
1086
|
this.currentCoordinate === 2 && this.closingPoints.create(i, "polygon"), this.store.updateProperty([{ id: this.currentId, property: S.COMMITTED_COORDINATE_COUNT, value: this.currentCoordinate + 1 }]), this.currentCoordinate++;
|
|
1087
1087
|
} else if (this.currentId) {
|
|
1088
1088
|
const e = this.store.getGeometryCopy(this.currentId).coordinates[0], { isClosing: i, isPreviousClosing: o } = this.closingPoints.isClosingPoint(t);
|
|
@@ -1093,7 +1093,7 @@ class Fe extends A {
|
|
|
1093
1093
|
const n = /* @__PURE__ */ (function(a = [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]) {
|
|
1094
1094
|
return { type: "Feature", geometry: { type: "Polygon", coordinates: a }, properties: {} };
|
|
1095
1095
|
})([[...e.slice(0, -1), [t.lng, t.lat], e[0]]]);
|
|
1096
|
-
if (!this.updatePolygonGeometry(n.geometry.coordinates[0],
|
|
1096
|
+
if (!this.updatePolygonGeometry(n.geometry.coordinates[0], E.Commit)) return;
|
|
1097
1097
|
this.store.updateProperty([{ id: this.currentId, property: S.COMMITTED_COORDINATE_COUNT, value: this.currentCoordinate + 1 }]), this.currentCoordinate++, this.closingPoints.ids.length && this.closingPoints.update(n.geometry.coordinates[0]);
|
|
1098
1098
|
}
|
|
1099
1099
|
}
|
|
@@ -1128,7 +1128,7 @@ class Fe extends A {
|
|
|
1128
1128
|
const i = this.store.getGeometryCopy(this.editedFeatureId), o = i.coordinates[0];
|
|
1129
1129
|
this.editedSnapType === "coordinate" || this.editedSnapType === "line" && this.editedInsertIndex !== void 0 ? this.editedFeatureCoordinateIndex === 0 || this.editedFeatureCoordinateIndex === i.coordinates[0].length - 1 ? (o[0] = [t.lng, t.lat], o[o.length - 1] = [t.lng, t.lat]) : o[this.editedFeatureCoordinateIndex] = [t.lng, t.lat] : this.editedSnapType === "line" && this.editedInsertIndex === void 0 && (this.editedInsertIndex = this.editedFeatureCoordinateIndex + 1, i.coordinates[0].splice(this.editedInsertIndex, 0, [t.lng, t.lat]), this.editedFeatureCoordinateIndex++);
|
|
1130
1130
|
const s = { type: "Polygon", coordinates: i.coordinates };
|
|
1131
|
-
this.validate && !this.validate({ type: "Feature", geometry: s, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
1131
|
+
this.validate && !this.validate({ type: "Feature", geometry: s, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: E.Provisional }).valid || (this.snapping && this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: this.editedFeatureId, geometry: s }]), this.showCoordinatePoints && this.coordinatePoints.createOrUpdate(this.editedFeatureId), this.editedPointId && this.store.updateGeometry([{ id: this.editedPointId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: S.EDITED, value: !0 }]));
|
|
1132
1132
|
}
|
|
1133
1133
|
onDragEnd(t, e) {
|
|
1134
1134
|
this.allowPointerEvent(this.pointerEvents.onDragEnd, t) && this.editedFeatureId !== void 0 && (this.setCursor(this.cursors.dragEnd), this.editedPointId && (this.store.delete([this.editedPointId]), this.editedPointId = void 0), this.store.updateProperty([{ id: this.editedFeatureId, property: S.EDITED, value: !1 }]), this.onFinish(this.editedFeatureId, { mode: this.mode, action: "edit" }), this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedInsertIndex = void 0, this.editedSnapType = void 0, e(!0));
|
|
@@ -1161,13 +1161,13 @@ class Fe 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) => Et(e, this.coordinatePrecision));
|
|
1165
1165
|
}
|
|
1166
1166
|
}
|
|
1167
|
-
const
|
|
1168
|
-
class
|
|
1167
|
+
const Ii = { cancel: "Escape", finish: "Enter" }, xi = { start: "crosshair" };
|
|
1168
|
+
class De 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 = Ii, this.cursors = xi, 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));
|
|
@@ -1198,10 +1198,10 @@ class Me extends A {
|
|
|
1198
1198
|
this.center = [t.lng, t.lat];
|
|
1199
1199
|
const [e] = this.store.create([{ geometry: { type: "Polygon", coordinates: [[[t.lng, t.lat], [t.lng, t.lat], [t.lng, t.lat], [t.lng, t.lat]]] }, properties: { mode: this.mode, [S.CURRENTLY_DRAWING]: !0 } }]);
|
|
1200
1200
|
this.currentRectangleId = e, this.clickCount++, this.setDrawing();
|
|
1201
|
-
} else this.updateRectangle(t,
|
|
1201
|
+
} else this.updateRectangle(t, E.Finish), this.close();
|
|
1202
1202
|
}
|
|
1203
1203
|
onMouseMove(t) {
|
|
1204
|
-
this.updateRectangle(t,
|
|
1204
|
+
this.updateRectangle(t, E.Provisional);
|
|
1205
1205
|
}
|
|
1206
1206
|
onKeyDown() {
|
|
1207
1207
|
}
|
|
@@ -1232,7 +1232,7 @@ class Me extends A {
|
|
|
1232
1232
|
class Q extends A {
|
|
1233
1233
|
constructor(t) {
|
|
1234
1234
|
if (!t.modeName) throw new Error("Mode name is required for TerraDrawRenderMode");
|
|
1235
|
-
super(t, !0), this.type =
|
|
1235
|
+
super(t, !0), this.type = q.Render, this.mode = "render", this.updateOptions(t);
|
|
1236
1236
|
}
|
|
1237
1237
|
updateOptions(t) {
|
|
1238
1238
|
super.updateOptions(t), t != null && t.modeName && (this.mode = t.modeName);
|
|
@@ -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 = Le(i, this.coordinatePrecision).valid || Et(i, this.coordinatePrecision).valid || Rt(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 kt(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 _e(r, t, e) {
|
|
1285
1285
|
let i = t;
|
|
1286
1286
|
t < 0 && (i = -Math.abs(i));
|
|
1287
|
-
const o = i /
|
|
1287
|
+
const o = i / xe, 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
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
1291
|
return u[0] += u[0] - r[0] > 180 ? -360 : r[0] - u[0] > 180 ? 360 : 0, u;
|
|
1292
1292
|
}
|
|
1293
|
-
function
|
|
1293
|
+
function ke(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
|
-
return [
|
|
1295
|
+
return [b(a, e), b(l, e)];
|
|
1296
1296
|
}
|
|
1297
|
-
function
|
|
1298
|
-
const i =
|
|
1299
|
-
return [
|
|
1297
|
+
function Oi(r, t, e) {
|
|
1298
|
+
const i = _e(r, 1e3 * U(r, t) / 2, kt(r, t));
|
|
1299
|
+
return [b(i[0], e), b(i[1], e)];
|
|
1300
1300
|
}
|
|
1301
|
-
function
|
|
1301
|
+
function de({ 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 = ke(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 = Oi(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 Ei 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,14 +1327,14 @@ class Oi 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 de({ 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 de({ 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
1340
|
class bi extends B {
|
|
@@ -1363,7 +1363,7 @@ class bi 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 Ne(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 ke(r, t) {
|
|
|
1372
1372
|
var i, o, s;
|
|
1373
1373
|
return e;
|
|
1374
1374
|
}
|
|
1375
|
-
const
|
|
1375
|
+
const Nt = (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,7 +1381,7 @@ const kt = (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 wi 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
|
}
|
|
@@ -1397,18 +1397,18 @@ class Ei extends B {
|
|
|
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 =
|
|
1400
|
+
const m = g.coordinates[y], v = g.coordinates[y + 1], C = Nt({ x: t.containerX, y: t.containerY }, this.project(m[0], m[1]), this.project(v[0], v[1]));
|
|
1401
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
|
+
Ne([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 Li 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
|
}
|
|
@@ -1441,17 +1441,17 @@ class wi extends B {
|
|
|
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 (u =
|
|
1444
|
+
if (u = b(u, this.config.coordinatePrecision), p = b(p, this.config.coordinatePrecision), u > 180 || u < -180 || p > 90 || p < -90) return !1;
|
|
1445
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) || [];
|
|
1449
|
-
if (e && !e({ type: "Feature", id: this.draggedFeatureId, geometry: i, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType:
|
|
1449
|
+
if (e && !e({ type: "Feature", id: this.draggedFeatureId, geometry: i, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: E.Provisional }).valid) return !1;
|
|
1450
1450
|
this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: i }, ...a, ...l, ...d]), this.dragPosition = [t.lng, t.lat];
|
|
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 Fi 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
|
}
|
|
@@ -1503,7 +1503,7 @@ class Li extends B {
|
|
|
1503
1503
|
d[0] = u, d[v] = u;
|
|
1504
1504
|
} else d[n] = u;
|
|
1505
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 &&
|
|
1506
|
+
return !(a.type !== "Point" && !e && jt({ geometry: a }) || i && !i(h, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: E.Provisional }).valid || (this.store.updateGeometry([{ id: s, geometry: a }, ...g, ...y, ...m]), 0));
|
|
1507
1507
|
}
|
|
1508
1508
|
isDragging() {
|
|
1509
1509
|
return this.draggedCoordinate.id !== null;
|
|
@@ -1515,20 +1515,20 @@ class Li extends B {
|
|
|
1515
1515
|
this.draggedCoordinate = { id: null, index: -1 };
|
|
1516
1516
|
}
|
|
1517
1517
|
}
|
|
1518
|
-
function
|
|
1518
|
+
function ce(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 Te = (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 Tt(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];
|
|
@@ -1551,7 +1551,7 @@ function Nt(r) {
|
|
|
1551
1551
|
return { x: o / i, y: s / i };
|
|
1552
1552
|
})(t);
|
|
1553
1553
|
}
|
|
1554
|
-
class
|
|
1554
|
+
class Mi 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 Fi 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 =
|
|
1569
|
+
this.selectedGeometryWebMercatorCentroid || (this.selectedGeometryWebMercatorCentroid = Tt(a));
|
|
1570
1570
|
const u = O(t.lng, t.lat);
|
|
1571
1571
|
if (n = G(this.selectedGeometryWebMercatorCentroid, u), n === 0) return;
|
|
1572
1572
|
if (!this.lastBearing) return void (this.lastBearing = n);
|
|
1573
|
-
|
|
1573
|
+
Te(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 =
|
|
1576
|
+
if (this.selectedGeometryCentroid || (this.selectedGeometryCentroid = ce({ geometry: o })), n = kt(this.selectedGeometryCentroid, s), !this.lastBearing) return void (this.lastBearing = n + 180);
|
|
1577
1577
|
(function(u, p) {
|
|
1578
1578
|
if (p === 0 || p === 360 || p === -360) return u;
|
|
1579
|
-
const g =
|
|
1579
|
+
const g = ce(u);
|
|
1580
1580
|
(u.geometry.type === "Polygon" ? u.geometry.coordinates[0] : u.geometry.coordinates).forEach((y) => {
|
|
1581
|
-
const m =
|
|
1581
|
+
const m = kt(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 = xe, w = P[1] * Math.PI / 180, L = f[1] * Math.PI / 180, M = L - w;
|
|
1584
1584
|
let N = Math.abs(f[0] - P[0]) * Math.PI / 180;
|
|
1585
1585
|
N > Math.PI && (N -= 2 * Math.PI);
|
|
1586
|
-
const _ = Math.log(Math.tan(L / 2 + Math.PI / 4) / Math.tan(
|
|
1586
|
+
const _ = Math.log(Math.tan(L / 2 + Math.PI / 4) / Math.tan(w / 2 + Math.PI / 4)), T = Math.abs(_) > 1e-11 ? M / _ : Math.cos(w);
|
|
1587
1587
|
return Math.sqrt(M * M + T * T * N * N) * I;
|
|
1588
|
-
})(g, y), C =
|
|
1588
|
+
})(g, y), C = _e(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
1594
|
l.forEach((u) => {
|
|
1595
|
-
u[0] =
|
|
1595
|
+
u[0] = b(u[0], this.coordinatePrecision), u[1] = b(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
|
-
if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType:
|
|
1598
|
+
if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: E.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 Di 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 Mi extends B {
|
|
|
1614
1614
|
this.dragCoordinateResizeBehavior.stopDragging();
|
|
1615
1615
|
}
|
|
1616
1616
|
}
|
|
1617
|
-
function
|
|
1617
|
+
function We({ 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 _i 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 Di 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 = Tt(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 Di 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 = Tt(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 Di 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), We({ 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();
|
|
@@ -1776,19 +1776,19 @@ class Di 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] =
|
|
1779
|
+
if (h[0] = b(h[0], this.coordinatePrecision), h[1] = b(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
|
-
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:
|
|
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: E.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 ki = { deselect: "Escape", delete: "Delete", rotate: ["Control", "r"], scale: ["Control", "s"] }, he = { pointerOver: "move", dragStart: "move", dragEnd: "move", insertMidpoint: "crosshair" };
|
|
1786
|
+
class Vt extends Qe {
|
|
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 = ki, this.cursors = he, 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) : he, 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 zt extends Ze {
|
|
|
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 wi(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new bi(t), this.coordinatePoints = new Fe(t), this.midPoints = new Ei(t, this.selectionPoints, this.coordinatePoints), this.coordinateSnap = new It(t, this.pixelDistance, this.clickBoundingBox), this.lineSnap = new Gt(t, this.pixelDistance, this.clickBoundingBox), this.rotateFeature = new Mi(t, this.selectionPoints, this.midPoints, this.coordinatePoints), this.dragFeature = new Li(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints, this.coordinatePoints), this.dragCoordinate = new Fi(t, this.pixelDistance, this.selectionPoints, this.midPoints, this.coordinatePoints, this.coordinateSnap, this.lineSnap), this.dragCoordinateResizeFeature = new _i(t, this.pixelDistance, this.selectionPoints, this.midPoints, this.coordinatePoints), this.scaleFeature = new Di(t, this.dragCoordinateResizeFeature);
|
|
1808
1808
|
}
|
|
1809
1809
|
deselectFeature() {
|
|
1810
1810
|
this.deselect();
|
|
@@ -1830,7 +1830,7 @@ class zt extends Ze {
|
|
|
1830
1830
|
if (d.type === "Polygon") {
|
|
1831
1831
|
if (c = d.coordinates[0], c.length <= 4) return;
|
|
1832
1832
|
} else if (d.type === "LineString" && (c = d.coordinates, c.length <= 2)) return;
|
|
1833
|
-
if (!c || (d.type !== "Polygon" || s !== 0 && s !== c.length - 1 ? c.splice(s, 1) : (c.shift(), c.pop(), c.push([c[0][0], c[0][1]])), l && !l({ id: o, type: "Feature", geometry: d, properties: n }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
1833
|
+
if (!c || (d.type !== "Polygon" || s !== 0 && s !== c.length - 1 ? c.splice(s, 1) : (c.shift(), c.pop(), c.push([c[0][0], c[0][1]])), l && !l({ id: o, type: "Feature", geometry: d, properties: n }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: E.Commit }).valid)) return;
|
|
1834
1834
|
const h = [...this.midPoints.ids, ...this.selectionPoints.ids];
|
|
1835
1835
|
this.store.delete(h), this.store.updateGeometry([{ id: o, geometry: d }]), n.coordinatePointIds && this.coordinatePoints.createOrUpdate(o), this.selectionPoints.create(c, d.type, o), a && a.feature && a.feature.coordinates && a.feature.coordinates.midpoints && this.midPoints.create(c, o, this.coordinatePrecision);
|
|
1836
1836
|
}
|
|
@@ -1973,9 +1973,9 @@ class zt extends Ze {
|
|
|
1973
1973
|
}
|
|
1974
1974
|
}
|
|
1975
1975
|
}
|
|
1976
|
-
class
|
|
1976
|
+
class Ni extends A {
|
|
1977
1977
|
constructor(...t) {
|
|
1978
|
-
super(...t), this.type =
|
|
1978
|
+
super(...t), this.type = q.Static, this.mode = "static";
|
|
1979
1979
|
}
|
|
1980
1980
|
start() {
|
|
1981
1981
|
}
|
|
@@ -2001,11 +2001,11 @@ class ki 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 Be(r, t, e, i, o) {
|
|
2005
2005
|
for (; i > e; ) {
|
|
2006
2006
|
if (i - e > 600) {
|
|
2007
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
|
-
|
|
2008
|
+
Be(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 Ti(r, t) {
|
|
2038
2038
|
return r.minX - t.minX;
|
|
2039
2039
|
}
|
|
2040
|
-
function
|
|
2040
|
+
function Wi(r, t) {
|
|
2041
2041
|
return r.minY - t.minY;
|
|
2042
2042
|
}
|
|
2043
|
-
function
|
|
2043
|
+
function Ft(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 Bi(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 Mt(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 ue(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
|
+
Be(r, n, t, e, o), s.push(t, n, n, e);
|
|
2068
2068
|
}
|
|
2069
2069
|
}
|
|
2070
|
-
class
|
|
2070
|
+
class ji {
|
|
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 Bi {
|
|
|
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) : Mt(t, l) ? this._all(a, i) : s.push(a));
|
|
2083
2083
|
}
|
|
2084
2084
|
e = s.pop();
|
|
2085
2085
|
}
|
|
@@ -2093,7 +2093,7 @@ class Bi {
|
|
|
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 || Mt(t, n)) return !0;
|
|
2097
2097
|
i.push(s);
|
|
2098
2098
|
}
|
|
2099
2099
|
}
|
|
@@ -2133,7 +2133,7 @@ class Bi {
|
|
|
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 || !Mt(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,10 +2156,10 @@ class Bi {
|
|
|
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
|
+
ue(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
|
-
|
|
2162
|
+
ue(t, c, h, l, this.compareMinY);
|
|
2163
2163
|
for (let u = c; u <= h; u += l) {
|
|
2164
2164
|
const p = Math.min(u + l - 1, h);
|
|
2165
2165
|
n.children.push(this._build(t, u, p, o - 1));
|
|
@@ -2171,7 +2171,7 @@ class Bi {
|
|
|
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], u =
|
|
2174
|
+
const h = e.children[c], u = Ft(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
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];
|
|
@@ -2196,13 +2196,13 @@ class Bi {
|
|
|
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 = Bi(l, d), h = Ft(l) + Ft(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 : Ti, s = t.leaf ? this.compareMinY : Wi;
|
|
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 Bi {
|
|
|
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 Ai {
|
|
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 ji(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 ji {
|
|
|
2279
2279
|
return this.tree.collides(this.toBBox(t));
|
|
2280
2280
|
}
|
|
2281
2281
|
}
|
|
2282
|
-
const
|
|
2282
|
+
const Ri = { 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 Gi {
|
|
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 Ai(), this.tracked = !t || t.tracked !== !1, this.idStrategy = t && t.idStrategy ? t.idStrategy : Ri;
|
|
2290
2290
|
}
|
|
2291
2291
|
clone(t) {
|
|
2292
2292
|
return JSON.parse(JSON.stringify(t));
|
|
@@ -2310,10 +2310,10 @@ class Ri {
|
|
|
2310
2310
|
}
|
|
2311
2311
|
if (this.tracked) {
|
|
2312
2312
|
if (d.properties.createdAt) {
|
|
2313
|
-
if (!
|
|
2313
|
+
if (!te(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 (!te(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 Ri {
|
|
|
2390
2390
|
return Object.keys(this.store).length;
|
|
2391
2391
|
}
|
|
2392
2392
|
}
|
|
2393
|
-
const
|
|
2394
|
-
function
|
|
2393
|
+
const Ui = "Feature is not a Polygon or LineString", zi = "Feature intersects itself", Vi = (r) => r.geometry.type !== "Polygon" && r.geometry.type !== "LineString" ? { valid: !1, reason: Ui } : jt(r) ? { valid: !1, reason: zi } : { valid: !0 };
|
|
2394
|
+
function pe(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 $i = { cancel: "Escape", finish: "Enter" }, Yi = { start: "crosshair", close: "pointer" };
|
|
2400
|
+
class je 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 = $i, this.cursors = Yi, 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,13 +2424,13 @@ class Be 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 =
|
|
2428
|
-
const M = (L.x -
|
|
2427
|
+
const o = e[0], s = e[1], n = ke(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 = pe(a, l, c), p = h ? 90 - u : pe(a, l, c) - 90, g = F(l, c), y = Math.cos(D(p)) * g, m = G(a, d) + ((function(I, w, L) {
|
|
2428
|
+
const M = (L.x - w.x) * (I.y - w.y) - (L.y - w.y) * (I.x - w.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);
|
|
2431
|
-
i = [e[0], e[1], [P.lng, P.lat], [f.lng, f.lat], e[0]];
|
|
2431
|
+
i = [e[0], e[1], [b(P.lng, this.coordinatePrecision), b(P.lat, this.coordinatePrecision)], [b(f.lng, this.coordinatePrecision), b(f.lat, this.coordinatePrecision)], e[0]];
|
|
2432
2432
|
}
|
|
2433
|
-
i && this.updatePolygonGeometry(this.currentId, i,
|
|
2433
|
+
i && this.updatePolygonGeometry(this.currentId, i, E.Provisional);
|
|
2434
2434
|
}
|
|
2435
2435
|
updatePolygonGeometry(t, e, i) {
|
|
2436
2436
|
const o = { type: "Polygon", coordinates: [e] };
|
|
@@ -2442,7 +2442,7 @@ class Be extends A {
|
|
|
2442
2442
|
this.currentId = e, this.currentCoordinate++, this.setDrawing();
|
|
2443
2443
|
} else if (this.currentCoordinate === 1 && this.currentId) {
|
|
2444
2444
|
const e = this.store.getGeometryCopy(this.currentId);
|
|
2445
|
-
if (tt([t.lng, t.lat], e.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [e.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], e.coordinates[0][0]],
|
|
2445
|
+
if (tt([t.lng, t.lat], e.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [e.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], e.coordinates[0][0]], E.Commit)) return;
|
|
2446
2446
|
this.currentCoordinate++;
|
|
2447
2447
|
} else this.currentCoordinate === 2 && this.currentId && this.close();
|
|
2448
2448
|
}
|
|
@@ -2479,13 +2479,13 @@ class Be 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 Ae(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 Ki = { cancel: "Escape", finish: "Enter" }, Xi = { start: "crosshair", close: "pointer" };
|
|
2486
|
+
class Re 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 = Ki, this.direction = void 0, this.arcPoints = 64, this.cursors = Xi, 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,7 +2513,7 @@ class Ae 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 = Ae(a, l, d);
|
|
2517
2517
|
this.direction = f ? "clockwise" : "anticlockwise";
|
|
2518
2518
|
}
|
|
2519
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);
|
|
@@ -2522,12 +2522,12 @@ class Ae extends A {
|
|
|
2522
2522
|
const C = (this.direction === "anticlockwise" ? 1 : -1) * v / p;
|
|
2523
2523
|
g.push(s);
|
|
2524
2524
|
for (let f = 0; f <= p; f++) {
|
|
2525
|
-
const P = ht(a, c, y + f * C), { lng: I, lat:
|
|
2525
|
+
const P = ht(a, c, y + f * C), { lng: I, lat: w } = R(P.x, P.y), L = [b(I, this.coordinatePrecision), b(w, this.coordinatePrecision)];
|
|
2526
2526
|
L[0] !== g[g.length - 1][0] && L[1] !== g[g.length - 1][1] && g.push(L);
|
|
2527
2527
|
}
|
|
2528
2528
|
g.push(o), i = [...g];
|
|
2529
2529
|
}
|
|
2530
|
-
i && this.updatePolygonGeometry(this.currentId, i,
|
|
2530
|
+
i && this.updatePolygonGeometry(this.currentId, i, E.Provisional);
|
|
2531
2531
|
}
|
|
2532
2532
|
updatePolygonGeometry(t, e, i) {
|
|
2533
2533
|
const o = { type: "Polygon", coordinates: [e] };
|
|
@@ -2539,7 +2539,7 @@ class Ae extends A {
|
|
|
2539
2539
|
this.currentId = e, this.currentCoordinate++, this.setDrawing();
|
|
2540
2540
|
} else if (this.currentCoordinate === 1 && this.currentId) {
|
|
2541
2541
|
const e = this.store.getGeometryCopy(this.currentId);
|
|
2542
|
-
if (tt([t.lng, t.lat], e.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [e.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], e.coordinates[0][0]],
|
|
2542
|
+
if (tt([t.lng, t.lat], e.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [e.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], e.coordinates[0][0]], E.Commit)) return;
|
|
2543
2543
|
this.currentCoordinate++;
|
|
2544
2544
|
} else this.currentCoordinate === 2 && this.currentId && this.close();
|
|
2545
2545
|
}
|
|
@@ -2572,10 +2572,10 @@ class Ae 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 qi = { cancel: "Escape", finish: "Enter" }, Ji = { start: "crosshair", close: "pointer" };
|
|
2576
|
+
class Ge 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 = qi, this.direction = void 0, this.arcPoints = 64, this.cursors = Ji, 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,7 +2600,7 @@ class Re 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 = Ae(l, n, a);
|
|
2604
2604
|
this.direction = C ? "clockwise" : "anticlockwise";
|
|
2605
2605
|
}
|
|
2606
2606
|
const c = G(l, n), h = G(l, a), u = this.arcPoints, p = [o], g = X(c), y = X(h);
|
|
@@ -2608,21 +2608,21 @@ class Re extends A {
|
|
|
2608
2608
|
this.direction === "anticlockwise" ? (m = y - g, m < 0 && (m += 360)) : (m = g - y, m < 0 && (m += 360));
|
|
2609
2609
|
const v = (this.direction === "anticlockwise" ? 1 : -1) * m / u;
|
|
2610
2610
|
for (let C = 0; C <= u; C++) {
|
|
2611
|
-
const f = ht(l, d, g + C * v), { lng: P, lat: I } = R(f.x, f.y),
|
|
2612
|
-
|
|
2611
|
+
const f = ht(l, d, g + C * v), { lng: P, lat: I } = R(f.x, f.y), w = [b(P, this.coordinatePrecision), b(I, this.coordinatePrecision)];
|
|
2612
|
+
w[0] !== p[p.length - 1][0] && w[1] !== p[p.length - 1][1] && p.push(w);
|
|
2613
2613
|
}
|
|
2614
|
-
this.updateLineStringGeometry(this.currentInitialArcId, p,
|
|
2614
|
+
this.updateLineStringGeometry(this.currentInitialArcId, p, E.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
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
|
-
const C = this.getDeltaBearing(this.direction, y, m), f = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * C / f, I = F(d, h),
|
|
2620
|
+
const C = this.getDeltaBearing(this.direction, y, m), f = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * C / f, I = F(d, h), w = [];
|
|
2621
2621
|
for (let L = 0; L <= f; L++) {
|
|
2622
|
-
const M = ht(d, I, y + L * P), { lng: N, lat: _ } = R(M.x, M.y), T = [
|
|
2623
|
-
T[0] !== e[e.length - 1][0] && T[1] !== e[e.length - 1][1] &&
|
|
2622
|
+
const M = ht(d, I, y + L * P), { lng: N, lat: _ } = R(M.x, M.y), T = [b(N, this.coordinatePrecision), b(_, this.coordinatePrecision)];
|
|
2623
|
+
T[0] !== e[e.length - 1][0] && T[1] !== e[e.length - 1][1] && w.unshift(T);
|
|
2624
2624
|
}
|
|
2625
|
-
e.push(...
|
|
2625
|
+
e.push(...w), e.push(e[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, e, E.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [e] }, properties: { mode: this.mode, [S.CURRENTLY_DRAWING]: !0 } }]);
|
|
2626
2626
|
}
|
|
2627
2627
|
}
|
|
2628
2628
|
}
|
|
@@ -2679,7 +2679,7 @@ class Re extends A {
|
|
|
2679
2679
|
return o === "clockwise" ? e <= i ? t >= e && t <= i : t >= e || t <= i : e >= i ? t <= e && t >= i : t <= e || t >= i;
|
|
2680
2680
|
}
|
|
2681
2681
|
}
|
|
2682
|
-
class
|
|
2682
|
+
class H {
|
|
2683
2683
|
constructor({ name: t, callback: e, unregister: i, register: o }) {
|
|
2684
2684
|
this.name = void 0, this.callback = void 0, this.registered = !1, this.register = void 0, this.unregister = void 0, this.name = t, this.register = () => {
|
|
2685
2685
|
this.registered || (this.registered = !0, o(e));
|
|
@@ -2688,7 +2688,7 @@ class q {
|
|
|
2688
2688
|
}, this.callback = e;
|
|
2689
2689
|
}
|
|
2690
2690
|
}
|
|
2691
|
-
var
|
|
2691
|
+
var Hi = { __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
|
}
|
|
@@ -2703,7 +2703,7 @@ var Ji = { __proto__: null, TerraDrawBaseAdapter: class {
|
|
|
2703
2703
|
const e = this.getLngLatFromEvent(r);
|
|
2704
2704
|
if (!e) return null;
|
|
2705
2705
|
const { lng: i, lat: o } = e, { containerX: s, containerY: n } = this.getMapElementXYPosition(r), a = this.getButton(r), l = Array.from(this._heldKeys);
|
|
2706
|
-
return { lng:
|
|
2706
|
+
return { lng: b(i, this._coordinatePrecision), lat: b(o, this._coordinatePrecision), containerX: s, containerY: n, button: a, heldKeys: l, isContextMenu: t };
|
|
2707
2707
|
}
|
|
2708
2708
|
register(r) {
|
|
2709
2709
|
this._currentModeCallbacks = r, this._listeners = this.getAdapterListeners(), this._listeners.forEach((t) => {
|
|
@@ -2714,7 +2714,7 @@ var Ji = { __proto__: null, TerraDrawBaseAdapter: class {
|
|
|
2714
2714
|
return this._coordinatePrecision;
|
|
2715
2715
|
}
|
|
2716
2716
|
getAdapterListeners() {
|
|
2717
|
-
return [new
|
|
2717
|
+
return [new H({ name: "pointerdown", callback: (r) => {
|
|
2718
2718
|
if (!this._currentModeCallbacks || !r.isPrimary) return;
|
|
2719
2719
|
const t = this.getDrawEventFromEvent(r);
|
|
2720
2720
|
t && (this._dragState = "pre-dragging", this._lastDrawEvent = t);
|
|
@@ -2722,7 +2722,7 @@ var Ji = { __proto__: null, TerraDrawBaseAdapter: class {
|
|
|
2722
2722
|
this.getMapEventElement().addEventListener("pointerdown", r);
|
|
2723
2723
|
}, unregister: (r) => {
|
|
2724
2724
|
this.getMapEventElement().removeEventListener("pointerdown", r);
|
|
2725
|
-
} }), new
|
|
2725
|
+
} }), new H({ name: "pointermove", callback: (r) => {
|
|
2726
2726
|
if (!this._currentModeCallbacks || !r.isPrimary) return;
|
|
2727
2727
|
r.preventDefault();
|
|
2728
2728
|
const t = this.getDrawEventFromEvent(r);
|
|
@@ -2742,13 +2742,13 @@ var Ji = { __proto__: null, TerraDrawBaseAdapter: class {
|
|
|
2742
2742
|
this.getMapEventElement().addEventListener("pointermove", r);
|
|
2743
2743
|
}, unregister: (r) => {
|
|
2744
2744
|
this.getMapEventElement().removeEventListener("pointermove", r);
|
|
2745
|
-
} }), new
|
|
2745
|
+
} }), new H({ name: "contextmenu", callback: (r) => {
|
|
2746
2746
|
this._currentModeCallbacks && (r.preventDefault(), this._nextKeyUpIsContextMenu = !0);
|
|
2747
2747
|
}, register: (r) => {
|
|
2748
2748
|
this.getMapEventElement().addEventListener("contextmenu", r);
|
|
2749
2749
|
}, unregister: (r) => {
|
|
2750
2750
|
this.getMapEventElement().removeEventListener("contextmenu", r);
|
|
2751
|
-
} }), new
|
|
2751
|
+
} }), new H({ name: "pointerup", callback: (r) => {
|
|
2752
2752
|
if (!this._currentModeCallbacks || r.target !== this.getMapEventElement() || !r.isPrimary) return;
|
|
2753
2753
|
const t = this.getDrawEventFromEvent(r);
|
|
2754
2754
|
t && (this._dragState === "dragging" ? this._currentModeCallbacks.onDragEnd(t, (e) => {
|
|
@@ -2758,13 +2758,13 @@ var Ji = { __proto__: null, TerraDrawBaseAdapter: class {
|
|
|
2758
2758
|
this.getMapEventElement().addEventListener("pointerup", r);
|
|
2759
2759
|
}, unregister: (r) => {
|
|
2760
2760
|
this.getMapEventElement().removeEventListener("pointerup", r);
|
|
2761
|
-
} }), new
|
|
2761
|
+
} }), new H({ name: "keyup", callback: (r) => {
|
|
2762
2762
|
this._currentModeCallbacks && (this._heldKeys.delete(r.key), this._currentModeCallbacks.onKeyUp({ key: r.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => r.preventDefault() }));
|
|
2763
2763
|
}, register: (r) => {
|
|
2764
2764
|
this.getMapEventElement().addEventListener("keyup", r);
|
|
2765
2765
|
}, unregister: (r) => {
|
|
2766
2766
|
this.getMapEventElement().removeEventListener("keyup", r);
|
|
2767
|
-
} }), new
|
|
2767
|
+
} }), new H({ name: "keydown", callback: (r) => {
|
|
2768
2768
|
this._currentModeCallbacks && (this._heldKeys.add(r.key), this._currentModeCallbacks.onKeyDown({ key: r.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => r.preventDefault() }));
|
|
2769
2769
|
}, register: (r) => {
|
|
2770
2770
|
this.getMapEventElement().addEventListener("keydown", r);
|
|
@@ -2778,10 +2778,10 @@ var Ji = { __proto__: null, TerraDrawBaseAdapter: class {
|
|
|
2778
2778
|
}), this.clear(), this._currentModeCallbacks = void 0;
|
|
2779
2779
|
}
|
|
2780
2780
|
} };
|
|
2781
|
-
const
|
|
2782
|
-
class
|
|
2781
|
+
const Zi = { cancel: "Escape", finish: "Enter" }, Qi = { start: "crosshair", close: "pointer" };
|
|
2782
|
+
class Ue 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 = Zi, this.cursors = Qi, 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));
|
|
@@ -2792,7 +2792,7 @@ class Ge extends A {
|
|
|
2792
2792
|
const t = this.currentId;
|
|
2793
2793
|
if (this.validate && t) {
|
|
2794
2794
|
const e = this.store.getGeometryCopy(t);
|
|
2795
|
-
if (!this.validate({ type: "Feature", id: t, geometry: e, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
2795
|
+
if (!this.validate({ type: "Feature", id: t, geometry: e, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: E.Finish }).valid) return;
|
|
2796
2796
|
}
|
|
2797
2797
|
this.closingPointId && this.store.delete([this.closingPointId]), this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.state === "drawing" && this.setStarted(), this.onFinish(t, { mode: this.mode, action: "draw" });
|
|
2798
2798
|
}
|
|
@@ -2807,7 +2807,7 @@ class Ge extends A {
|
|
|
2807
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
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
|
-
this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: g, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
2810
|
+
this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: g, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: E.Provisional }).valid || (this.store.updateGeometry([{ id: this.currentId, geometry: g }]), this.closingPointId && this.store.updateGeometry([{ id: this.closingPointId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]));
|
|
2811
2811
|
}
|
|
2812
2812
|
onClick(t) {
|
|
2813
2813
|
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)) {
|
|
@@ -2843,13 +2843,13 @@ class Ge 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) => Rt(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 Wt(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,24 +2860,24 @@ function Tt(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 (!Wt(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" && Wt(r[t]));
|
|
2866
2866
|
}
|
|
2867
|
-
class
|
|
2867
|
+
class to {
|
|
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 Ni();
|
|
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;
|
|
2873
2873
|
}, {}), o = Object.keys(i);
|
|
2874
2874
|
if (o.length === 0) throw new Error("No modes provided");
|
|
2875
2875
|
o.forEach((c) => {
|
|
2876
|
-
if (i[c].type ===
|
|
2876
|
+
if (i[c].type === q.Select) {
|
|
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 Gi({ tracked: !!t.tracked, idStrategy: t.idStrategy ? t.idStrategy : void 0 });
|
|
2881
2881
|
const s = (c) => {
|
|
2882
2882
|
const h = [], u = this._store.copyAll().filter((p) => !c.includes(p.id) || (h.push(p), !1));
|
|
2883
2883
|
return { changed: h, unchanged: u };
|
|
@@ -2921,44 +2921,44 @@ class Qi {
|
|
|
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),
|
|
2925
|
-
return this._store.search(
|
|
2926
|
-
if (s && (
|
|
2927
|
-
if (
|
|
2928
|
-
const
|
|
2929
|
-
return F(
|
|
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 = !(!i || i.ignoreSnappingPoints === void 0) && i.ignoreSnappingPoints, c = this._adapter.unproject.bind(this._adapter), h = this._adapter.project.bind(this._adapter), u = h(t, e), p = we({ unproject: c, point: u, pointerDistance: o });
|
|
2925
|
+
return this._store.search(p).filter((g) => {
|
|
2926
|
+
if (s && (g.properties[k.MID_POINT] || g.properties[k.SELECTION_POINT]) || n && g.properties[S.COORDINATE_POINT] || l && g.properties[S.CLOSING_POINT] || a && g.properties[S.CURRENTLY_DRAWING] || d && g.properties[S.SNAPPING_POINT]) return !1;
|
|
2927
|
+
if (g.geometry.type === "Point") {
|
|
2928
|
+
const y = g.geometry.coordinates, m = h(y[0], y[1]);
|
|
2929
|
+
return F(u, m) < o;
|
|
2930
2930
|
}
|
|
2931
|
-
if (
|
|
2932
|
-
const
|
|
2933
|
-
for (let
|
|
2934
|
-
const
|
|
2935
|
-
if (
|
|
2931
|
+
if (g.geometry.type === "LineString") {
|
|
2932
|
+
const y = g.geometry.coordinates;
|
|
2933
|
+
for (let m = 0; m < y.length - 1; m++) {
|
|
2934
|
+
const v = y[m], C = y[m + 1];
|
|
2935
|
+
if (Nt(u, h(v[0], v[1]), h(C[0], C[1])) < o) return !0;
|
|
2936
2936
|
}
|
|
2937
2937
|
return !1;
|
|
2938
2938
|
}
|
|
2939
|
-
if (
|
|
2939
|
+
if (Ne([t, e], g.geometry.coordinates)) return !0;
|
|
2940
2940
|
if (i != null && i.includePolygonsWithinPointerDistance) {
|
|
2941
|
-
const
|
|
2942
|
-
for (const
|
|
2943
|
-
const
|
|
2944
|
-
if (
|
|
2941
|
+
const y = g.geometry.coordinates;
|
|
2942
|
+
for (const m of y) for (let v = 0; v < m.length - 1; v++) {
|
|
2943
|
+
const C = m[v], f = m[v + 1], P = h(C[0], C[1]), I = h(f[0], f[1]);
|
|
2944
|
+
if (Nt(u, P, I) < o) return !0;
|
|
2945
2945
|
}
|
|
2946
2946
|
}
|
|
2947
2947
|
return !1;
|
|
2948
|
-
}).map((
|
|
2949
|
-
if (i == null || !i.addClosestCoordinateInfoToProperties) return
|
|
2950
|
-
let
|
|
2951
|
-
if (
|
|
2948
|
+
}).map((g) => {
|
|
2949
|
+
if (i == null || !i.addClosestCoordinateInfoToProperties) return g;
|
|
2950
|
+
let y;
|
|
2951
|
+
if (g.geometry.type === "Polygon") y = g.geometry.coordinates[0].slice(0, -1);
|
|
2952
2952
|
else {
|
|
2953
|
-
if (
|
|
2954
|
-
|
|
2953
|
+
if (g.geometry.type !== "LineString") return g;
|
|
2954
|
+
y = g.geometry.coordinates;
|
|
2955
2955
|
}
|
|
2956
|
-
let
|
|
2957
|
-
for (let
|
|
2958
|
-
const
|
|
2959
|
-
|
|
2956
|
+
let m, v = -1, C = 1 / 0;
|
|
2957
|
+
for (let f = 0; f < y.length; f++) {
|
|
2958
|
+
const P = y[f], I = F(h(P[0], P[1]), u);
|
|
2959
|
+
I < C && (v = f, C = I, m = P);
|
|
2960
2960
|
}
|
|
2961
|
-
return
|
|
2961
|
+
return g.properties.closestCoordinateIndexToEvent = v, g.properties.closestCoordinatePixelDistanceToEvent = C, g.properties.closestCoordinateDistanceKmToEvent = U(m, [t, e]), g;
|
|
2962
2962
|
});
|
|
2963
2963
|
}
|
|
2964
2964
|
getSelectModeOrThrow() {
|
|
@@ -3040,7 +3040,7 @@ class Qi {
|
|
|
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 && !Wt(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,9 +3074,9 @@ class Qi {
|
|
|
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 =
|
|
3079
|
-
if (n = n.map((a) => [
|
|
3077
|
+
We({ coordinates: n, originX: a, originY: l, xScale: e.options.xScale || 1, yScale: e.options.yScale || 1 });
|
|
3078
|
+
} else e.type === "rotate" && (i = Te(i, e.options.angle || 0), n = i.geometry.type === "Polygon" ? i.geometry.coordinates[0] : i.geometry.coordinates);
|
|
3079
|
+
if (n = n.map((a) => [b(a[0], this._adapter.getCoordinatePrecision()), b(a[1], this._adapter.getCoordinatePrecision())]), i.geometry.coordinates = i.geometry.type === "Polygon" ? [n] : n, this._store.updateGeometry([{ id: i.id, geometry: i.geometry }], { origin: "api" }), s.afterFeatureUpdated) {
|
|
3080
3080
|
s.afterFeatureUpdated(i);
|
|
3081
3081
|
const a = i.properties[k.SELECTED], l = this.getSelectMode({ switchToSelectMode: !1 });
|
|
3082
3082
|
l && a && l.afterFeatureUpdated(i);
|
|
@@ -3084,7 +3084,7 @@ class Qi {
|
|
|
3084
3084
|
}
|
|
3085
3085
|
addFeatures(t) {
|
|
3086
3086
|
return this.checkEnabled(), t.length === 0 ? [] : this._store.load(t, (e) => {
|
|
3087
|
-
if (
|
|
3087
|
+
if (Qt(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 Qi {
|
|
|
3092
3092
|
}
|
|
3093
3093
|
return { id: e.id, valid: !1, reason: "Mode property does not exist" };
|
|
3094
3094
|
}, (e) => {
|
|
3095
|
-
if (
|
|
3095
|
+
if (Qt(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 Qi {
|
|
|
3141
3141
|
i.includes(e) && i.splice(i.indexOf(e), 1);
|
|
3142
3142
|
}
|
|
3143
3143
|
}
|
|
3144
|
-
class
|
|
3144
|
+
class eo extends Hi.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
|
}
|
|
@@ -3229,7 +3229,7 @@ class to extends Ji.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 $o = [
|
|
3233
3233
|
"render",
|
|
3234
3234
|
"point",
|
|
3235
3235
|
"linestring",
|
|
@@ -3245,7 +3245,7 @@ const Vo = [
|
|
|
3245
3245
|
"delete-selection",
|
|
3246
3246
|
"delete",
|
|
3247
3247
|
"download"
|
|
3248
|
-
],
|
|
3248
|
+
], Yo = [
|
|
3249
3249
|
"render",
|
|
3250
3250
|
"linestring",
|
|
3251
3251
|
"point",
|
|
@@ -3254,7 +3254,7 @@ const Vo = [
|
|
|
3254
3254
|
"delete",
|
|
3255
3255
|
"download",
|
|
3256
3256
|
"settings"
|
|
3257
|
-
],
|
|
3257
|
+
], io = {
|
|
3258
3258
|
modes: [
|
|
3259
3259
|
"render",
|
|
3260
3260
|
"point",
|
|
@@ -3273,6 +3273,21 @@ const Vo = [
|
|
|
3273
3273
|
"download"
|
|
3274
3274
|
],
|
|
3275
3275
|
open: !1
|
|
3276
|
+
}, bt = {
|
|
3277
|
+
kilometer: "km",
|
|
3278
|
+
meter: "m",
|
|
3279
|
+
centimeter: "cm",
|
|
3280
|
+
mile: "mi",
|
|
3281
|
+
foot: "ft",
|
|
3282
|
+
inch: "in",
|
|
3283
|
+
"square meters": "m²",
|
|
3284
|
+
"square kilometers": "km²",
|
|
3285
|
+
ares: "a",
|
|
3286
|
+
hectares: "ha",
|
|
3287
|
+
"square feet": "ft²",
|
|
3288
|
+
"square yards": "yd²",
|
|
3289
|
+
acres: "acres",
|
|
3290
|
+
"square miles": "mi²"
|
|
3276
3291
|
}, lt = {
|
|
3277
3292
|
modes: [
|
|
3278
3293
|
"render",
|
|
@@ -3294,7 +3309,7 @@ const Vo = [
|
|
|
3294
3309
|
open: !1,
|
|
3295
3310
|
// see styling parameters of Terra Draw at https://github.com/JamesLMilner/terra-draw/blob/main/guides/5.STYLING.md
|
|
3296
3311
|
modeOptions: {
|
|
3297
|
-
point: new
|
|
3312
|
+
point: new zt({
|
|
3298
3313
|
editable: !0,
|
|
3299
3314
|
styles: {
|
|
3300
3315
|
pointColor: "#FFFFFF",
|
|
@@ -3303,7 +3318,7 @@ const Vo = [
|
|
|
3303
3318
|
pointOutlineWidth: 1
|
|
3304
3319
|
}
|
|
3305
3320
|
}),
|
|
3306
|
-
linestring: new
|
|
3321
|
+
linestring: new Ut({
|
|
3307
3322
|
editable: !0,
|
|
3308
3323
|
styles: {
|
|
3309
3324
|
lineStringColor: "#666666",
|
|
@@ -3314,7 +3329,7 @@ const Vo = [
|
|
|
3314
3329
|
closingPointOutlineWidth: 1
|
|
3315
3330
|
}
|
|
3316
3331
|
}),
|
|
3317
|
-
polygon: new
|
|
3332
|
+
polygon: new Me({
|
|
3318
3333
|
editable: !0,
|
|
3319
3334
|
styles: {
|
|
3320
3335
|
fillColor: "#EDEFF0",
|
|
@@ -3327,7 +3342,7 @@ const Vo = [
|
|
|
3327
3342
|
closingPointOutlineWidth: 1
|
|
3328
3343
|
}
|
|
3329
3344
|
}),
|
|
3330
|
-
rectangle: new
|
|
3345
|
+
rectangle: new De({
|
|
3331
3346
|
styles: {
|
|
3332
3347
|
fillColor: "#EDEFF0",
|
|
3333
3348
|
fillOpacity: 0.7,
|
|
@@ -3335,7 +3350,7 @@ const Vo = [
|
|
|
3335
3350
|
outlineWidth: 2
|
|
3336
3351
|
}
|
|
3337
3352
|
}),
|
|
3338
|
-
"angled-rectangle": new
|
|
3353
|
+
"angled-rectangle": new je({
|
|
3339
3354
|
styles: {
|
|
3340
3355
|
fillColor: "#EDEFF0",
|
|
3341
3356
|
fillOpacity: 0.7,
|
|
@@ -3343,7 +3358,7 @@ const Vo = [
|
|
|
3343
3358
|
outlineWidth: 2
|
|
3344
3359
|
}
|
|
3345
3360
|
}),
|
|
3346
|
-
circle: new
|
|
3361
|
+
circle: new Ee({
|
|
3347
3362
|
styles: {
|
|
3348
3363
|
fillColor: "#EDEFF0",
|
|
3349
3364
|
fillOpacity: 0.7,
|
|
@@ -3363,7 +3378,7 @@ const Vo = [
|
|
|
3363
3378
|
closingPointOutlineWidth: 1
|
|
3364
3379
|
}
|
|
3365
3380
|
}),
|
|
3366
|
-
"freehand-linestring": new
|
|
3381
|
+
"freehand-linestring": new Ue({
|
|
3367
3382
|
styles: {
|
|
3368
3383
|
lineStringColor: "#666666",
|
|
3369
3384
|
lineStringWidth: 2,
|
|
@@ -3373,7 +3388,7 @@ const Vo = [
|
|
|
3373
3388
|
closingPointOutlineWidth: 1
|
|
3374
3389
|
}
|
|
3375
3390
|
}),
|
|
3376
|
-
sensor: new
|
|
3391
|
+
sensor: new Ge({
|
|
3377
3392
|
styles: {
|
|
3378
3393
|
fillColor: "#EDEFF0",
|
|
3379
3394
|
fillOpacity: 0.7,
|
|
@@ -3385,7 +3400,7 @@ const Vo = [
|
|
|
3385
3400
|
centerPointOutlineWidth: 1
|
|
3386
3401
|
}
|
|
3387
3402
|
}),
|
|
3388
|
-
sector: new
|
|
3403
|
+
sector: new Re({
|
|
3389
3404
|
styles: {
|
|
3390
3405
|
fillColor: "#EDEFF0",
|
|
3391
3406
|
fillOpacity: 0.7,
|
|
@@ -3393,7 +3408,7 @@ const Vo = [
|
|
|
3393
3408
|
outlineWidth: 2
|
|
3394
3409
|
}
|
|
3395
3410
|
}),
|
|
3396
|
-
select: new
|
|
3411
|
+
select: new Vt({
|
|
3397
3412
|
flags: {
|
|
3398
3413
|
point: {
|
|
3399
3414
|
feature: {
|
|
@@ -3655,12 +3670,12 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3655
3670
|
maxzoom: 15,
|
|
3656
3671
|
tms: !1
|
|
3657
3672
|
},
|
|
3658
|
-
|
|
3673
|
+
measureUnitType: "metric",
|
|
3659
3674
|
distancePrecision: 2,
|
|
3660
3675
|
forceDistanceUnit: "auto",
|
|
3661
|
-
areaUnit: "metric",
|
|
3662
3676
|
areaPrecision: 2,
|
|
3663
3677
|
forceAreaUnit: "auto",
|
|
3678
|
+
measureUnitSymbols: JSON.parse(JSON.stringify(bt)),
|
|
3664
3679
|
elevationCacheConfig: {
|
|
3665
3680
|
enabled: !0,
|
|
3666
3681
|
maxSize: 1e3,
|
|
@@ -3686,7 +3701,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3686
3701
|
open: !1,
|
|
3687
3702
|
// see styling parameters of Terra Draw at https://github.com/JamesLMilner/terra-draw/blob/main/guides/5.STYLING.md
|
|
3688
3703
|
modeOptions: {
|
|
3689
|
-
point: new
|
|
3704
|
+
point: new zt({
|
|
3690
3705
|
editable: !1,
|
|
3691
3706
|
styles: {
|
|
3692
3707
|
pointColor: "#FFFFFF",
|
|
@@ -3695,7 +3710,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3695
3710
|
pointOutlineWidth: 1
|
|
3696
3711
|
}
|
|
3697
3712
|
}),
|
|
3698
|
-
linestring: new
|
|
3713
|
+
linestring: new Ut({
|
|
3699
3714
|
editable: !1,
|
|
3700
3715
|
styles: {
|
|
3701
3716
|
lineStringColor: "#FF0000",
|
|
@@ -3706,7 +3721,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3706
3721
|
closingPointOutlineWidth: 1
|
|
3707
3722
|
}
|
|
3708
3723
|
}),
|
|
3709
|
-
select: new
|
|
3724
|
+
select: new Vt({
|
|
3710
3725
|
flags: {
|
|
3711
3726
|
point: {
|
|
3712
3727
|
feature: {
|
|
@@ -3901,34 +3916,34 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3901
3916
|
"text-halo-color": "rgb(255, 255, 255)"
|
|
3902
3917
|
}
|
|
3903
3918
|
}
|
|
3904
|
-
},
|
|
3919
|
+
}, oo = () => ({
|
|
3905
3920
|
render: new Q({
|
|
3906
3921
|
modeName: "render",
|
|
3907
3922
|
styles: {}
|
|
3908
3923
|
}),
|
|
3909
|
-
point: new
|
|
3924
|
+
point: new zt({
|
|
3910
3925
|
editable: !0
|
|
3911
3926
|
}),
|
|
3912
|
-
linestring: new
|
|
3927
|
+
linestring: new Ut({
|
|
3913
3928
|
editable: !0
|
|
3914
3929
|
}),
|
|
3915
|
-
polygon: new
|
|
3930
|
+
polygon: new Me({
|
|
3916
3931
|
editable: !0,
|
|
3917
3932
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3918
3933
|
// @ts-ignore
|
|
3919
3934
|
validation: (t, e) => {
|
|
3920
3935
|
const i = e.updateType;
|
|
3921
|
-
return i === "finish" || i === "commit" ?
|
|
3936
|
+
return i === "finish" || i === "commit" ? Vi(t) : { valid: !0 };
|
|
3922
3937
|
}
|
|
3923
3938
|
}),
|
|
3924
|
-
rectangle: new
|
|
3925
|
-
"angled-rectangle": new
|
|
3926
|
-
circle: new
|
|
3939
|
+
rectangle: new De(),
|
|
3940
|
+
"angled-rectangle": new je(),
|
|
3941
|
+
circle: new Ee(),
|
|
3927
3942
|
freehand: new be(),
|
|
3928
|
-
"freehand-linestring": new
|
|
3929
|
-
sensor: new
|
|
3930
|
-
sector: new
|
|
3931
|
-
select: new
|
|
3943
|
+
"freehand-linestring": new Ue(),
|
|
3944
|
+
sensor: new Ge(),
|
|
3945
|
+
sector: new Re(),
|
|
3946
|
+
select: new Vt({
|
|
3932
3947
|
flags: {
|
|
3933
3948
|
point: {
|
|
3934
3949
|
feature: {
|
|
@@ -4054,7 +4069,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
4054
4069
|
styles: {}
|
|
4055
4070
|
})
|
|
4056
4071
|
});
|
|
4057
|
-
var W = 63710088e-1,
|
|
4072
|
+
var W = 63710088e-1, so = {
|
|
4058
4073
|
centimeters: W * 100,
|
|
4059
4074
|
centimetres: W * 100,
|
|
4060
4075
|
degrees: 360 / (2 * Math.PI),
|
|
@@ -4071,26 +4086,26 @@ var W = 63710088e-1, oo = {
|
|
|
4071
4086
|
radians: 1,
|
|
4072
4087
|
yards: W * 1.0936
|
|
4073
4088
|
};
|
|
4074
|
-
function
|
|
4089
|
+
function ro(r, t, e = {}) {
|
|
4075
4090
|
const i = { type: "Feature" };
|
|
4076
4091
|
return (e.id === 0 || e.id) && (i.id = e.id), e.bbox && (i.bbox = e.bbox), i.properties = t || {}, i.geometry = r, i;
|
|
4077
4092
|
}
|
|
4078
|
-
function
|
|
4093
|
+
function no(r, t, e = {}) {
|
|
4079
4094
|
if (!r)
|
|
4080
4095
|
throw new Error("coordinates is required");
|
|
4081
4096
|
if (!Array.isArray(r))
|
|
4082
4097
|
throw new Error("coordinates must be an Array");
|
|
4083
4098
|
if (r.length < 2)
|
|
4084
4099
|
throw new Error("coordinates must be at least 2 numbers long");
|
|
4085
|
-
if (!
|
|
4100
|
+
if (!ge(r[0]) || !ge(r[1]))
|
|
4086
4101
|
throw new Error("coordinates must contain numbers");
|
|
4087
|
-
return
|
|
4102
|
+
return ro({
|
|
4088
4103
|
type: "Point",
|
|
4089
4104
|
coordinates: r
|
|
4090
4105
|
}, t, e);
|
|
4091
4106
|
}
|
|
4092
|
-
function
|
|
4093
|
-
const e =
|
|
4107
|
+
function ao(r, t = "kilometers") {
|
|
4108
|
+
const e = so[t];
|
|
4094
4109
|
if (!e)
|
|
4095
4110
|
throw new Error(t + " units is invalid");
|
|
4096
4111
|
return r * e;
|
|
@@ -4098,10 +4113,10 @@ function no(r, t = "kilometers") {
|
|
|
4098
4113
|
function vt(r) {
|
|
4099
4114
|
return r % 360 * Math.PI / 180;
|
|
4100
4115
|
}
|
|
4101
|
-
function
|
|
4116
|
+
function ge(r) {
|
|
4102
4117
|
return !isNaN(r) && r !== null && !Array.isArray(r);
|
|
4103
4118
|
}
|
|
4104
|
-
function
|
|
4119
|
+
function ze(r, t, e) {
|
|
4105
4120
|
if (r !== null)
|
|
4106
4121
|
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
4122
|
d = g ? r.features[v].geometry : y ? r.geometry : r, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
|
|
@@ -4178,7 +4193,7 @@ function Ue(r, t, e) {
|
|
|
4178
4193
|
break;
|
|
4179
4194
|
case "GeometryCollection":
|
|
4180
4195
|
for (i = 0; i < n.geometries.length; i++)
|
|
4181
|
-
if (
|
|
4196
|
+
if (ze(n.geometries[i], t) === !1)
|
|
4182
4197
|
return !1;
|
|
4183
4198
|
break;
|
|
4184
4199
|
default:
|
|
@@ -4188,7 +4203,7 @@ function Ue(r, t, e) {
|
|
|
4188
4203
|
}
|
|
4189
4204
|
}
|
|
4190
4205
|
}
|
|
4191
|
-
function
|
|
4206
|
+
function lo(r, t) {
|
|
4192
4207
|
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;
|
|
4193
4208
|
for (e = 0; e < y; e++) {
|
|
4194
4209
|
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++) {
|
|
@@ -4239,9 +4254,9 @@ function ao(r, t) {
|
|
|
4239
4254
|
u++;
|
|
4240
4255
|
}
|
|
4241
4256
|
}
|
|
4242
|
-
function
|
|
4257
|
+
function co(r, t, e) {
|
|
4243
4258
|
var i = e;
|
|
4244
|
-
return
|
|
4259
|
+
return lo(
|
|
4245
4260
|
r,
|
|
4246
4261
|
function(o, s, n, a, l) {
|
|
4247
4262
|
s === 0 && e === void 0 ? i = o : i = t(
|
|
@@ -4255,21 +4270,21 @@ function lo(r, t, e) {
|
|
|
4255
4270
|
}
|
|
4256
4271
|
), i;
|
|
4257
4272
|
}
|
|
4258
|
-
function
|
|
4259
|
-
return
|
|
4273
|
+
function ho(r) {
|
|
4274
|
+
return co(
|
|
4260
4275
|
r,
|
|
4261
|
-
(t, e) => t +
|
|
4276
|
+
(t, e) => t + uo(e),
|
|
4262
4277
|
0
|
|
4263
4278
|
);
|
|
4264
4279
|
}
|
|
4265
|
-
function
|
|
4280
|
+
function uo(r) {
|
|
4266
4281
|
let t = 0, e;
|
|
4267
4282
|
switch (r.type) {
|
|
4268
4283
|
case "Polygon":
|
|
4269
|
-
return
|
|
4284
|
+
return ye(r.coordinates);
|
|
4270
4285
|
case "MultiPolygon":
|
|
4271
4286
|
for (e = 0; e < r.coordinates.length; e++)
|
|
4272
|
-
t +=
|
|
4287
|
+
t += ye(r.coordinates[e]);
|
|
4273
4288
|
return t;
|
|
4274
4289
|
case "Point":
|
|
4275
4290
|
case "MultiPoint":
|
|
@@ -4279,81 +4294,81 @@ function ho(r) {
|
|
|
4279
4294
|
}
|
|
4280
4295
|
return 0;
|
|
4281
4296
|
}
|
|
4282
|
-
function
|
|
4297
|
+
function ye(r) {
|
|
4283
4298
|
let t = 0;
|
|
4284
4299
|
if (r && r.length > 0) {
|
|
4285
|
-
t += Math.abs(
|
|
4300
|
+
t += Math.abs(fe(r[0]));
|
|
4286
4301
|
for (let e = 1; e < r.length; e++)
|
|
4287
|
-
t -= Math.abs(
|
|
4302
|
+
t -= Math.abs(fe(r[e]));
|
|
4288
4303
|
}
|
|
4289
4304
|
return t;
|
|
4290
4305
|
}
|
|
4291
|
-
var
|
|
4292
|
-
function
|
|
4306
|
+
var po = W * W / 2, Dt = Math.PI / 180;
|
|
4307
|
+
function fe(r) {
|
|
4293
4308
|
const t = r.length - 1;
|
|
4294
4309
|
if (t <= 2) return 0;
|
|
4295
4310
|
let e = 0, i = 0;
|
|
4296
4311
|
for (; i < t; ) {
|
|
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] *
|
|
4312
|
+
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] * Dt, l = s[1] * Dt, d = n[0] * Dt;
|
|
4298
4313
|
e += (d - a) * Math.sin(l), i++;
|
|
4299
4314
|
}
|
|
4300
|
-
return e *
|
|
4315
|
+
return e * po;
|
|
4301
4316
|
}
|
|
4302
|
-
var
|
|
4303
|
-
const
|
|
4304
|
-
const
|
|
4305
|
-
let
|
|
4317
|
+
var go = ho;
|
|
4318
|
+
const yo = (r, t, e = "auto", i = bt) => {
|
|
4319
|
+
const o = ["square meters", "square kilometers", "ares", "hectares"], s = ["square feet", "square yards", "acres", "square miles"];
|
|
4320
|
+
let n = e;
|
|
4306
4321
|
if (e !== "auto") {
|
|
4307
|
-
const
|
|
4308
|
-
(t === "metric" && !
|
|
4322
|
+
const a = o.includes(e), l = s.includes(e);
|
|
4323
|
+
(t === "metric" && !a || t === "imperial" && !l) && (n = "auto");
|
|
4309
4324
|
}
|
|
4310
|
-
return t === "metric" ?
|
|
4311
|
-
}, ot = (r, t) => {
|
|
4312
|
-
let
|
|
4325
|
+
return t === "metric" ? n !== "auto" ? ot(r, n, i) : r >= 1e6 ? ot(r, "square kilometers", i) : r >= 1e4 ? ot(r, "hectares", i) : r >= 100 ? ot(r, "ares", i) : ot(r, "square meters", i) : n !== "auto" ? st(r, n, i) : r >= 258998811e-2 ? st(r, "square miles", i) : r >= 4046.856 ? st(r, "acres", i) : r >= 0.83612736 ? st(r, "square yards", i) : st(r, "square feet", i);
|
|
4326
|
+
}, ot = (r, t, e) => {
|
|
4327
|
+
let i = r, o = e["square meters"];
|
|
4313
4328
|
switch (t) {
|
|
4314
|
-
case "
|
|
4315
|
-
|
|
4329
|
+
case "square meters":
|
|
4330
|
+
i = r, o = e["square meters"];
|
|
4316
4331
|
break;
|
|
4317
|
-
case "
|
|
4318
|
-
|
|
4332
|
+
case "ares":
|
|
4333
|
+
i = r / 100, o = e.ares;
|
|
4319
4334
|
break;
|
|
4320
|
-
case "
|
|
4321
|
-
|
|
4335
|
+
case "hectares":
|
|
4336
|
+
i = r / 1e4, o = e.hectares;
|
|
4322
4337
|
break;
|
|
4323
|
-
case "
|
|
4324
|
-
|
|
4338
|
+
case "square kilometers":
|
|
4339
|
+
i = r / 1e6, o = e["square kilometers"];
|
|
4325
4340
|
break;
|
|
4326
4341
|
}
|
|
4327
4342
|
return {
|
|
4328
|
-
area:
|
|
4329
|
-
unit:
|
|
4343
|
+
area: i,
|
|
4344
|
+
unit: o
|
|
4330
4345
|
};
|
|
4331
|
-
}, st = (r, t) => {
|
|
4332
|
-
let
|
|
4346
|
+
}, st = (r, t, e) => {
|
|
4347
|
+
let i = r / 258998811e-2, o = e["square meters"];
|
|
4333
4348
|
switch (t) {
|
|
4334
|
-
case "
|
|
4335
|
-
|
|
4349
|
+
case "square feet":
|
|
4350
|
+
i = r / 0.09290304, o = e["square feet"];
|
|
4336
4351
|
break;
|
|
4337
|
-
case "
|
|
4338
|
-
|
|
4352
|
+
case "square yards":
|
|
4353
|
+
i = r / 0.83612736, o = e["square yards"];
|
|
4339
4354
|
break;
|
|
4340
|
-
case "
|
|
4341
|
-
|
|
4355
|
+
case "acres":
|
|
4356
|
+
i = r / 4046.856, o = e.acres;
|
|
4342
4357
|
break;
|
|
4343
|
-
case "
|
|
4344
|
-
|
|
4358
|
+
case "square miles":
|
|
4359
|
+
i = r / 258998811e-2, o = e["square miles"];
|
|
4345
4360
|
break;
|
|
4346
4361
|
}
|
|
4347
4362
|
return {
|
|
4348
|
-
area:
|
|
4349
|
-
unit:
|
|
4363
|
+
area: i,
|
|
4364
|
+
unit: o
|
|
4350
4365
|
};
|
|
4351
|
-
},
|
|
4366
|
+
}, me = (r, t, e, i, o) => {
|
|
4352
4367
|
if (r.geometry.type !== "Polygon") return r;
|
|
4353
|
-
const
|
|
4354
|
-
return
|
|
4368
|
+
const s = go(r.geometry), n = yo(s, t, i, o);
|
|
4369
|
+
return n.area = parseFloat(n.area.toFixed(e)), r.properties.area = n.area, r.properties.unit = n.unit, r;
|
|
4355
4370
|
};
|
|
4356
|
-
function
|
|
4371
|
+
function ve(r) {
|
|
4357
4372
|
if (!r)
|
|
4358
4373
|
throw new Error("coord is required");
|
|
4359
4374
|
if (!Array.isArray(r)) {
|
|
@@ -4366,140 +4381,143 @@ function me(r) {
|
|
|
4366
4381
|
return [...r];
|
|
4367
4382
|
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
4368
4383
|
}
|
|
4369
|
-
function
|
|
4370
|
-
var i =
|
|
4371
|
-
return
|
|
4384
|
+
function fo(r, t, e = {}) {
|
|
4385
|
+
var i = ve(r), o = ve(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);
|
|
4386
|
+
return ao(
|
|
4372
4387
|
2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
|
|
4373
4388
|
e.units
|
|
4374
4389
|
);
|
|
4375
4390
|
}
|
|
4376
|
-
var
|
|
4377
|
-
const
|
|
4378
|
-
const
|
|
4379
|
-
let
|
|
4391
|
+
var mo = fo;
|
|
4392
|
+
const _t = (r, t = "metric", e = "auto", i = bt) => {
|
|
4393
|
+
const o = ["centimeter", "meter", "kilometer"], s = ["inch", "foot", "mile"];
|
|
4394
|
+
let n = e;
|
|
4380
4395
|
if (e !== "auto") {
|
|
4381
|
-
const
|
|
4382
|
-
(t === "
|
|
4396
|
+
const l = o.includes(e), d = s.includes(e);
|
|
4397
|
+
(t === "metric" && !l || t === "imperial" && !d) && (n = "auto");
|
|
4383
4398
|
}
|
|
4384
|
-
let
|
|
4399
|
+
let a = {
|
|
4385
4400
|
distance: r,
|
|
4386
|
-
unit:
|
|
4401
|
+
unit: i.kilometer
|
|
4387
4402
|
};
|
|
4388
|
-
return t === "
|
|
4389
|
-
}, Ct = (r, t) => {
|
|
4390
|
-
let
|
|
4403
|
+
return t === "metric" ? a = Ct(r, n, i) : t === "imperial" && (a = Pt(r, n, i)), a;
|
|
4404
|
+
}, Ct = (r, t, e) => {
|
|
4405
|
+
let i = {
|
|
4391
4406
|
distance: r,
|
|
4392
|
-
unit:
|
|
4407
|
+
unit: e.kilometer
|
|
4393
4408
|
};
|
|
4394
4409
|
switch (t) {
|
|
4395
|
-
case "
|
|
4396
|
-
|
|
4410
|
+
case "kilometer":
|
|
4411
|
+
i.distance = r, i.unit = e[t];
|
|
4397
4412
|
break;
|
|
4398
|
-
case "
|
|
4399
|
-
|
|
4413
|
+
case "meter":
|
|
4414
|
+
i.distance = r * 1e3, i.unit = e[t];
|
|
4400
4415
|
break;
|
|
4401
|
-
case "
|
|
4402
|
-
|
|
4416
|
+
case "centimeter":
|
|
4417
|
+
i.distance = r * 1e5, i.unit = e[t];
|
|
4403
4418
|
break;
|
|
4404
4419
|
case "auto":
|
|
4405
|
-
r >= 1 ?
|
|
4420
|
+
r >= 1 ? i = Ct(r, "kilometer", e) : r * 1e3 >= 1 ? i = Ct(r, "meter", e) : i = Ct(r, "centimeter", e);
|
|
4406
4421
|
break;
|
|
4407
4422
|
default:
|
|
4408
|
-
|
|
4423
|
+
i.distance = r, i.unit = e.kilometer;
|
|
4409
4424
|
break;
|
|
4410
4425
|
}
|
|
4411
|
-
return
|
|
4412
|
-
}, Pt = (r, t) => {
|
|
4413
|
-
let
|
|
4426
|
+
return i;
|
|
4427
|
+
}, Pt = (r, t, e) => {
|
|
4428
|
+
let i = {
|
|
4414
4429
|
distance: r,
|
|
4415
|
-
unit:
|
|
4430
|
+
unit: e.mile
|
|
4416
4431
|
};
|
|
4417
4432
|
switch (t) {
|
|
4418
|
-
case "
|
|
4419
|
-
|
|
4433
|
+
case "mile":
|
|
4434
|
+
i.distance = r, i.unit = e[t];
|
|
4420
4435
|
break;
|
|
4421
|
-
case "
|
|
4422
|
-
|
|
4436
|
+
case "foot":
|
|
4437
|
+
i.distance = r * 5280, i.unit = e[t];
|
|
4423
4438
|
break;
|
|
4424
|
-
case "
|
|
4425
|
-
|
|
4439
|
+
case "inch":
|
|
4440
|
+
i.distance = r * 63360, i.unit = e[t];
|
|
4426
4441
|
break;
|
|
4427
4442
|
case "auto":
|
|
4428
|
-
r >= 1 ?
|
|
4443
|
+
r >= 1 ? i = Pt(r, "mile", e) : r * 5280 >= 1 ? i = Pt(r, "foot", e) : i = Pt(r, "inch", e);
|
|
4429
4444
|
break;
|
|
4430
4445
|
default:
|
|
4431
|
-
|
|
4446
|
+
i.distance = r, i.unit = e.mile;
|
|
4432
4447
|
break;
|
|
4433
4448
|
}
|
|
4434
|
-
return
|
|
4435
|
-
},
|
|
4449
|
+
return i;
|
|
4450
|
+
}, Ce = (r, t, e, i, o, s, n, a) => {
|
|
4436
4451
|
if (r.geometry.type !== "LineString") return r;
|
|
4437
|
-
const
|
|
4438
|
-
let
|
|
4439
|
-
const
|
|
4440
|
-
for (let
|
|
4441
|
-
const
|
|
4442
|
-
|
|
4443
|
-
const
|
|
4444
|
-
if (
|
|
4445
|
-
const
|
|
4446
|
-
|
|
4447
|
-
const
|
|
4448
|
-
|
|
4449
|
-
}
|
|
4450
|
-
|
|
4451
|
-
}
|
|
4452
|
-
r.properties.distance =
|
|
4453
|
-
const
|
|
4452
|
+
const l = r.geometry.coordinates;
|
|
4453
|
+
let d = 0;
|
|
4454
|
+
const c = [];
|
|
4455
|
+
for (let u = 0; u < l.length - 1; u++) {
|
|
4456
|
+
const p = l[u], g = l[u + 1], y = mo(p, g, { units: t === "metric" ? "kilometers" : "miles" });
|
|
4457
|
+
d += y;
|
|
4458
|
+
const m = JSON.parse(JSON.stringify(r));
|
|
4459
|
+
if (m.id = `${m.id}-${u}`, m.geometry.coordinates = [p, g], m.properties.originalId = r.id, m.properties.distance = y, m.properties.total = d, n === !0 && a === void 0) {
|
|
4460
|
+
const v = s?.queryTerrainElevation(p);
|
|
4461
|
+
v && (m.properties.elevation_start = v);
|
|
4462
|
+
const C = s?.queryTerrainElevation(g);
|
|
4463
|
+
C && (m.properties.elevation_end = C);
|
|
4464
|
+
}
|
|
4465
|
+
c.push(m);
|
|
4466
|
+
}
|
|
4467
|
+
r.properties.distance = c[c.length - 1].properties.total, r.properties.segments = JSON.parse(JSON.stringify(c));
|
|
4468
|
+
const h = _t(
|
|
4454
4469
|
r.properties.distance,
|
|
4455
4470
|
t,
|
|
4456
|
-
i
|
|
4471
|
+
i,
|
|
4472
|
+
o
|
|
4457
4473
|
);
|
|
4458
|
-
return r.properties.distance =
|
|
4459
|
-
(
|
|
4460
|
-
const
|
|
4461
|
-
|
|
4474
|
+
return r.properties.distance = h.distance, r.properties.unit = h.unit, r.properties.segments.forEach(
|
|
4475
|
+
(u) => {
|
|
4476
|
+
const p = _t(
|
|
4477
|
+
u.properties.distance,
|
|
4462
4478
|
t,
|
|
4463
|
-
i
|
|
4479
|
+
i,
|
|
4480
|
+
o
|
|
4464
4481
|
);
|
|
4465
|
-
|
|
4466
|
-
const
|
|
4467
|
-
|
|
4482
|
+
u.properties.distance = p.distance, u.properties.unit = p.unit;
|
|
4483
|
+
const g = _t(
|
|
4484
|
+
u.properties.total,
|
|
4468
4485
|
t,
|
|
4469
|
-
i
|
|
4486
|
+
i,
|
|
4487
|
+
o
|
|
4470
4488
|
);
|
|
4471
|
-
|
|
4489
|
+
u.properties.total = g.distance, u.properties.totalUnit = g.unit;
|
|
4472
4490
|
}
|
|
4473
4491
|
), r.properties.distance = parseFloat(
|
|
4474
4492
|
r.properties.distance.toFixed(e)
|
|
4475
4493
|
), r.properties.segments.forEach(
|
|
4476
|
-
(
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
),
|
|
4480
|
-
|
|
4494
|
+
(u) => {
|
|
4495
|
+
u.properties.distance = parseFloat(
|
|
4496
|
+
u.properties.distance.toFixed(e)
|
|
4497
|
+
), u.properties.total = parseFloat(
|
|
4498
|
+
u.properties.total.toFixed(e)
|
|
4481
4499
|
);
|
|
4482
4500
|
}
|
|
4483
4501
|
), r;
|
|
4484
|
-
},
|
|
4502
|
+
}, Pe = (r) => r.charAt(0).toUpperCase() + r.slice(1), et = [
|
|
4485
4503
|
"{prefix}-point",
|
|
4486
4504
|
"{prefix}-point-lower",
|
|
4487
4505
|
"{prefix}-linestring",
|
|
4488
4506
|
"{prefix}-polygon",
|
|
4489
4507
|
"{prefix}-polygon-outline"
|
|
4490
|
-
],
|
|
4508
|
+
], Ko = [
|
|
4491
4509
|
...et,
|
|
4492
4510
|
lt.polygonLayerSpec?.source,
|
|
4493
4511
|
lt.lineLayerLabelSpec?.source,
|
|
4494
4512
|
lt.pointLayerLabelSpec?.source
|
|
4495
|
-
],
|
|
4513
|
+
], Xo = [
|
|
4496
4514
|
...et,
|
|
4497
4515
|
z.routingLineLayerNodeLabelSpec?.source,
|
|
4498
4516
|
z.routingLineLayerNodeSpec?.source,
|
|
4499
4517
|
z.isochronePolygonLayerSpec?.source,
|
|
4500
4518
|
z.isochroneLineLayerSpec?.source,
|
|
4501
4519
|
z.isochroneLabelLayerSpec?.source
|
|
4502
|
-
],
|
|
4520
|
+
], $t = (r, t, e = et, i = "td") => {
|
|
4503
4521
|
e = e.map((s) => s.replace("{prefix}", i));
|
|
4504
4522
|
const o = JSON.parse(JSON.stringify(r));
|
|
4505
4523
|
return t && (t.onlyTerraDrawLayers === !0 ? (o.layers = o.layers.filter((s) => "source" in s && e.includes(s.source)), Object.keys(o.sources).forEach((s) => {
|
|
@@ -4507,13 +4525,13 @@ const Dt = (r, t = "kilometers", e = "auto") => {
|
|
|
4507
4525
|
})) : 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) => {
|
|
4508
4526
|
e.includes(s) && delete o.sources[s];
|
|
4509
4527
|
}))), o;
|
|
4510
|
-
},
|
|
4528
|
+
}, Ve = (r, t = 250) => {
|
|
4511
4529
|
let e;
|
|
4512
4530
|
return (...i) => {
|
|
4513
4531
|
clearTimeout(e), e = setTimeout(() => r(...i), t);
|
|
4514
4532
|
};
|
|
4515
4533
|
};
|
|
4516
|
-
class
|
|
4534
|
+
class $e {
|
|
4517
4535
|
cache = /* @__PURE__ */ new Map();
|
|
4518
4536
|
maxSize;
|
|
4519
4537
|
ttl;
|
|
@@ -4591,7 +4609,7 @@ class Ve {
|
|
|
4591
4609
|
};
|
|
4592
4610
|
}
|
|
4593
4611
|
}
|
|
4594
|
-
class
|
|
4612
|
+
class vo {
|
|
4595
4613
|
className;
|
|
4596
4614
|
dialog;
|
|
4597
4615
|
title;
|
|
@@ -4680,7 +4698,7 @@ class mo {
|
|
|
4680
4698
|
}), o;
|
|
4681
4699
|
}
|
|
4682
4700
|
}
|
|
4683
|
-
const
|
|
4701
|
+
const Se = (r, t, e, i) => {
|
|
4684
4702
|
if (r.geometry.type !== "Point") return r;
|
|
4685
4703
|
const o = r.geometry.coordinates;
|
|
4686
4704
|
if (e === !0 && i === void 0) {
|
|
@@ -4689,58 +4707,58 @@ const Pe = (r, t, e, i) => {
|
|
|
4689
4707
|
}
|
|
4690
4708
|
return r;
|
|
4691
4709
|
};
|
|
4692
|
-
var
|
|
4693
|
-
function
|
|
4710
|
+
var Co = Object.defineProperty, Po = (r, t, e) => t in r ? Co(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, rt = (r, t, e) => Po(r, typeof t != "symbol" ? t + "" : t, e), xt = 2 * Math.PI * 6378137 / 2;
|
|
4711
|
+
function So(r) {
|
|
4694
4712
|
return r = r || 256, 2 * Math.PI * 6378137 / r;
|
|
4695
4713
|
}
|
|
4696
|
-
function
|
|
4697
|
-
r =
|
|
4714
|
+
function Io(r, t, e = { enable: !0, decimal: 1 }) {
|
|
4715
|
+
r = Yt(r);
|
|
4698
4716
|
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
4717
|
return n = n * xt / 180, e.enable && (s = Number(s.toFixed(e.decimal)), n = Number(n.toFixed(e.decimal))), [s, n];
|
|
4700
4718
|
}
|
|
4701
|
-
function
|
|
4702
|
-
var i = r[0], o = r[1], s =
|
|
4719
|
+
function xo(r, t, e) {
|
|
4720
|
+
var i = r[0], o = r[1], s = Fo(t, e), n = (i + xt) / s, a = (o + xt) / s;
|
|
4703
4721
|
return [n, a, t];
|
|
4704
4722
|
}
|
|
4705
|
-
function
|
|
4706
|
-
r =
|
|
4707
|
-
var i =
|
|
4708
|
-
return
|
|
4723
|
+
function Ye(r, t, e) {
|
|
4724
|
+
r = Yt(r);
|
|
4725
|
+
var i = Io(r), o = xo(i, t);
|
|
4726
|
+
return Eo(o);
|
|
4709
4727
|
}
|
|
4710
|
-
function
|
|
4711
|
-
if (r =
|
|
4728
|
+
function Oo(r, t, e) {
|
|
4729
|
+
if (r = Yt(r), t === 0)
|
|
4712
4730
|
return [0, 0, 0];
|
|
4713
|
-
var i =
|
|
4731
|
+
var i = Ye(r, t);
|
|
4714
4732
|
return bo(i);
|
|
4715
4733
|
}
|
|
4716
|
-
function
|
|
4734
|
+
function Eo(r, t, e) {
|
|
4717
4735
|
t = t || 256;
|
|
4718
4736
|
var i = r[0], o = r[1], s = r[2];
|
|
4719
4737
|
if (s === 0) return [0, 0, 0];
|
|
4720
|
-
|
|
4738
|
+
Ke(s);
|
|
4721
4739
|
var n = Math.ceil(i / t) - 1, a = Math.ceil(o / t) - 1;
|
|
4722
4740
|
return n < 0 && (n = 0), a < 0 && (a = 0), [n, a, s];
|
|
4723
4741
|
}
|
|
4724
4742
|
function bo(r, t) {
|
|
4725
|
-
|
|
4743
|
+
wo(r);
|
|
4726
4744
|
var e = r[0], i = r[1], o = r[2];
|
|
4727
4745
|
if (o === 0)
|
|
4728
4746
|
return [0, 0, 0];
|
|
4729
4747
|
var s = e, n = Math.pow(2, o) - 1 - i;
|
|
4730
4748
|
return [s, n, o];
|
|
4731
4749
|
}
|
|
4732
|
-
function
|
|
4750
|
+
function wo(r, t) {
|
|
4733
4751
|
var e = r[0], i = r[1], o = r[2];
|
|
4734
4752
|
if (o == null) throw new Error("<zoom> is required");
|
|
4735
4753
|
if (e == null) throw new Error("<x> is required");
|
|
4736
4754
|
if (i == null) throw new Error("<y> is required");
|
|
4737
|
-
return o =
|
|
4755
|
+
return o = Ke(o), r = Lo(r), r;
|
|
4738
4756
|
}
|
|
4739
|
-
function
|
|
4757
|
+
function Lo(r) {
|
|
4740
4758
|
var t = r[0], e = r[1], i = r[2], o = Math.pow(2, i);
|
|
4741
4759
|
return t = t % o, t < 0 && (t = t + o), [t, e, i];
|
|
4742
4760
|
}
|
|
4743
|
-
function
|
|
4761
|
+
function Ke(r) {
|
|
4744
4762
|
if (r === !1) return r;
|
|
4745
4763
|
if (r == null)
|
|
4746
4764
|
throw new Error("<zoom> is required");
|
|
@@ -4750,22 +4768,22 @@ function Ye(r) {
|
|
|
4750
4768
|
throw new Error("<zoom> cannot be greater than 32");
|
|
4751
4769
|
return r;
|
|
4752
4770
|
}
|
|
4753
|
-
function
|
|
4754
|
-
var e =
|
|
4771
|
+
function Yt(r, t) {
|
|
4772
|
+
var e = Do(r[0]), i = Mo(r[1]);
|
|
4755
4773
|
return i > 85 && (i = 85), i < -85 && (i = -85), [e, i];
|
|
4756
4774
|
}
|
|
4757
|
-
function
|
|
4758
|
-
return
|
|
4775
|
+
function Fo(r, t) {
|
|
4776
|
+
return So(t) / Math.pow(2, r);
|
|
4759
4777
|
}
|
|
4760
|
-
function
|
|
4778
|
+
function Mo(r) {
|
|
4761
4779
|
if (r == null) throw new Error("lat is required");
|
|
4762
4780
|
return (r > 90 || r < -90) && (r = r % 180, r > 90 && (r = -180 + r), r < -90 && (r = 180 + r), r === 0 && (r = 0)), r;
|
|
4763
4781
|
}
|
|
4764
|
-
function
|
|
4782
|
+
function Do(r) {
|
|
4765
4783
|
if (r == null) throw new Error("lng is required");
|
|
4766
4784
|
return (r > 180 || r < -180) && (r = r % 360, r > 180 && (r = -360 + r), r < -180 && (r = 360 + r), r === 0 && (r = 0)), r;
|
|
4767
4785
|
}
|
|
4768
|
-
class
|
|
4786
|
+
class Xe {
|
|
4769
4787
|
/**
|
|
4770
4788
|
* Constructor
|
|
4771
4789
|
* @param url URL for terrain RGB raster tilesets
|
|
@@ -4790,7 +4808,7 @@ class Ke {
|
|
|
4790
4808
|
const s = t[0], n = t[1];
|
|
4791
4809
|
let a = e;
|
|
4792
4810
|
e > this.maxzoom ? a = this.maxzoom : e < this.minzoom && (a = this.minzoom);
|
|
4793
|
-
const l = this.tms ?
|
|
4811
|
+
const l = this.tms ? Ye([s, n], a) : Oo([s, n], a), d = this.url.replace(/{x}/g, l[0].toString()).replace(/{y}/g, l[1].toString()).replace(/{z}/g, l[2].toString());
|
|
4794
4812
|
let c = this.getUrlExtension(d);
|
|
4795
4813
|
switch (c || (c = "png"), c) {
|
|
4796
4814
|
case "png":
|
|
@@ -4892,7 +4910,7 @@ class Ke {
|
|
|
4892
4910
|
return i * Math.atan(0.5 * (Math.exp(o) - Math.exp(-o)));
|
|
4893
4911
|
}
|
|
4894
4912
|
}
|
|
4895
|
-
class
|
|
4913
|
+
class _o extends Xe {
|
|
4896
4914
|
/**
|
|
4897
4915
|
* Constructor
|
|
4898
4916
|
* @param url URL for terrain RGB raster tilesets
|
|
@@ -4924,7 +4942,7 @@ class Do extends Ke {
|
|
|
4924
4942
|
return -1e4 + (t * 256 * 256 + e * 256 + i) * 0.1;
|
|
4925
4943
|
}
|
|
4926
4944
|
}
|
|
4927
|
-
class
|
|
4945
|
+
class ko extends Xe {
|
|
4928
4946
|
/**
|
|
4929
4947
|
* Constructor
|
|
4930
4948
|
* @param url URL for terrarium raster tilesets
|
|
@@ -4958,10 +4976,10 @@ class _o extends Ke {
|
|
|
4958
4976
|
return parseInt(o.toFixed(0));
|
|
4959
4977
|
}
|
|
4960
4978
|
}
|
|
4961
|
-
const
|
|
4979
|
+
const No = (r, t = 8) => {
|
|
4962
4980
|
const [e, i] = r, o = Math.pow(10, t), s = Math.round(e * o) / o, n = Math.round(i * o) / o;
|
|
4963
4981
|
return `${s},${n}`;
|
|
4964
|
-
},
|
|
4982
|
+
}, Ie = async (r, t, e, i) => {
|
|
4965
4983
|
const o = [], s = {
|
|
4966
4984
|
enabled: !0,
|
|
4967
4985
|
maxSize: 1e3,
|
|
@@ -4971,19 +4989,19 @@ const ko = (r, t = 8) => {
|
|
|
4971
4989
|
...e
|
|
4972
4990
|
};
|
|
4973
4991
|
let n;
|
|
4974
|
-
s.enabled && (n = i || new
|
|
4992
|
+
s.enabled && (n = i || new $e(s.maxSize, s.ttl));
|
|
4975
4993
|
let a, l = 15;
|
|
4976
4994
|
if (t) {
|
|
4977
4995
|
const d = t.url, c = t.encoding ?? "mapbox", h = t.tileSize ?? 512, u = t.minzoom ?? 5;
|
|
4978
4996
|
l = t.maxzoom ?? 15;
|
|
4979
4997
|
const p = t.tms ?? !1;
|
|
4980
|
-
a = c === "mapbox" ? new
|
|
4998
|
+
a = c === "mapbox" ? new _o(d, h, u, l, p) : new ko(d, h, u, l, p);
|
|
4981
4999
|
}
|
|
4982
5000
|
for (const d of r)
|
|
4983
5001
|
o.push(
|
|
4984
5002
|
new Promise((c) => {
|
|
4985
5003
|
d.geometry.type !== "Point" && c(d);
|
|
4986
|
-
const h = d.geometry.coordinates, u =
|
|
5004
|
+
const h = d.geometry.coordinates, u = No(h, s.precision);
|
|
4987
5005
|
if (n) {
|
|
4988
5006
|
const p = n.get(u);
|
|
4989
5007
|
if (p !== void 0) {
|
|
@@ -4999,7 +5017,7 @@ const ko = (r, t = 8) => {
|
|
|
4999
5017
|
})
|
|
5000
5018
|
);
|
|
5001
5019
|
return await Promise.all(o);
|
|
5002
|
-
},
|
|
5020
|
+
}, qo = (r, t = 9) => {
|
|
5003
5021
|
function e(o) {
|
|
5004
5022
|
return [Number(o[0].toFixed(t)), Number(o[1].toFixed(t))];
|
|
5005
5023
|
}
|
|
@@ -5033,11 +5051,11 @@ const ko = (r, t = 8) => {
|
|
|
5033
5051
|
...o,
|
|
5034
5052
|
geometry: i(o.geometry)
|
|
5035
5053
|
}));
|
|
5036
|
-
},
|
|
5054
|
+
}, To = [
|
|
5037
5055
|
{ value: "time", label: "Time" },
|
|
5038
5056
|
{ value: "distance", label: "Distance" }
|
|
5039
5057
|
];
|
|
5040
|
-
class
|
|
5058
|
+
class Wo {
|
|
5041
5059
|
url;
|
|
5042
5060
|
/**
|
|
5043
5061
|
* Constructor
|
|
@@ -5069,15 +5087,15 @@ class To {
|
|
|
5069
5087
|
return await (await fetch(l)).json();
|
|
5070
5088
|
}
|
|
5071
5089
|
}
|
|
5072
|
-
const
|
|
5090
|
+
const Bt = [
|
|
5073
5091
|
{ value: "pedestrian", label: "Pedestrian" },
|
|
5074
5092
|
{ value: "bicycle", label: "Bicycle" },
|
|
5075
5093
|
{ value: "auto", label: "Car" }
|
|
5076
|
-
],
|
|
5094
|
+
], Bo = [
|
|
5077
5095
|
{ value: "kilometers", label: "km" },
|
|
5078
5096
|
{ value: "miles", label: "mile" }
|
|
5079
5097
|
];
|
|
5080
|
-
class
|
|
5098
|
+
class jo {
|
|
5081
5099
|
tripData = [];
|
|
5082
5100
|
/**
|
|
5083
5101
|
* get the raw trip data from the valhalla routing API.
|
|
@@ -5147,16 +5165,16 @@ class Bo {
|
|
|
5147
5165
|
l.trip.legs.forEach((f, P) => {
|
|
5148
5166
|
const I = this.decodeShape(f.shape);
|
|
5149
5167
|
h.push(...I), u += Number(f.summary.length.toFixed(2)), p += Number((f.summary.time / 60).toFixed()), g.push(...f.maneuvers);
|
|
5150
|
-
const
|
|
5151
|
-
|
|
5152
|
-
...
|
|
5168
|
+
const w = y.features[P + 1];
|
|
5169
|
+
w.properties = {
|
|
5170
|
+
...w.properties,
|
|
5153
5171
|
distance: u,
|
|
5154
5172
|
distance_unit: i === "kilometers" ? "km" : "mi",
|
|
5155
5173
|
time: p,
|
|
5156
5174
|
maneuvers: f.maneuvers
|
|
5157
5175
|
};
|
|
5158
5176
|
});
|
|
5159
|
-
const m =
|
|
5177
|
+
const m = Bt.find((f) => f.value === e)?.label, v = this.geoLineString(h, {
|
|
5160
5178
|
costingModel: m,
|
|
5161
5179
|
distance: u,
|
|
5162
5180
|
distance_unit: i === "kilometers" ? "km" : "mi",
|
|
@@ -5231,7 +5249,7 @@ class Bo {
|
|
|
5231
5249
|
return n;
|
|
5232
5250
|
}
|
|
5233
5251
|
}
|
|
5234
|
-
class
|
|
5252
|
+
class qe {
|
|
5235
5253
|
controlContainer;
|
|
5236
5254
|
map;
|
|
5237
5255
|
modeButtons = {};
|
|
@@ -5270,7 +5288,7 @@ class Xe {
|
|
|
5270
5288
|
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");
|
|
5271
5289
|
}
|
|
5272
5290
|
terradraw;
|
|
5273
|
-
options =
|
|
5291
|
+
options = io;
|
|
5274
5292
|
events = {};
|
|
5275
5293
|
defaultMode = "render";
|
|
5276
5294
|
/**
|
|
@@ -5298,7 +5316,7 @@ class Xe {
|
|
|
5298
5316
|
if (this.options && this.options.modes && this.options.modes.length === 0)
|
|
5299
5317
|
throw new Error("At least a mode must be enabled.");
|
|
5300
5318
|
this.map = t;
|
|
5301
|
-
const e =
|
|
5319
|
+
const e = oo(), i = [];
|
|
5302
5320
|
return this.options?.modes?.forEach((o) => {
|
|
5303
5321
|
if (this.options.modeOptions && this.options.modeOptions[o]) {
|
|
5304
5322
|
const s = this.options.modeOptions[o];
|
|
@@ -5320,8 +5338,8 @@ class Xe {
|
|
|
5320
5338
|
modeName: "default",
|
|
5321
5339
|
styles: {}
|
|
5322
5340
|
})
|
|
5323
|
-
), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new
|
|
5324
|
-
adapter: new
|
|
5341
|
+
), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new to({
|
|
5342
|
+
adapter: new eo({ map: t, ...this.options.adapterOptions }),
|
|
5325
5343
|
modes: i
|
|
5326
5344
|
}), this.map?.loaded() ? this.terradraw.start() : this.map?.once("load", () => {
|
|
5327
5345
|
this.terradraw?.start();
|
|
@@ -5419,7 +5437,7 @@ class Xe {
|
|
|
5419
5437
|
*/
|
|
5420
5438
|
addTerradrawButton(t) {
|
|
5421
5439
|
const e = document.createElement("button");
|
|
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 =
|
|
5440
|
+
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 = Pe("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 = Pe(t.replace(/-/g, " ")), t === "delete" ? (e.classList.add(`maplibregl-terradraw-${this.cssPrefix}${t}-button`), e.addEventListener("click", () => {
|
|
5423
5441
|
this.terradraw && this.terradraw.enabled && (this.terradraw.clear(), this.deactivate(), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.dispatchEvent("feature-deleted"));
|
|
5424
5442
|
})) : t === "delete-selection" ? (e.classList.add(`maplibregl-terradraw-${this.cssPrefix}${t}-button`), e.classList.add("hidden-delete-selection"), e.addEventListener("click", () => {
|
|
5425
5443
|
if (!this.terradraw || !this.terradraw.enabled) return;
|
|
@@ -5467,7 +5485,7 @@ class Xe {
|
|
|
5467
5485
|
* @returns
|
|
5468
5486
|
*/
|
|
5469
5487
|
cleanStyle(t, e) {
|
|
5470
|
-
return
|
|
5488
|
+
return $t(
|
|
5471
5489
|
t,
|
|
5472
5490
|
e,
|
|
5473
5491
|
et,
|
|
@@ -5534,35 +5552,34 @@ class Xe {
|
|
|
5534
5552
|
}
|
|
5535
5553
|
}
|
|
5536
5554
|
}
|
|
5537
|
-
function
|
|
5555
|
+
function Ao(r, t = {}) {
|
|
5538
5556
|
let e = 0, i = 0, o = 0;
|
|
5539
|
-
return
|
|
5557
|
+
return ze(
|
|
5540
5558
|
r,
|
|
5541
5559
|
function(s) {
|
|
5542
5560
|
e += s[0], i += s[1], o++;
|
|
5543
5561
|
}
|
|
5544
|
-
),
|
|
5562
|
+
), no([e / o, i / o], t.properties);
|
|
5545
5563
|
}
|
|
5546
|
-
class
|
|
5564
|
+
class Jo extends qe {
|
|
5547
5565
|
measureOptions;
|
|
5548
5566
|
elevationCache;
|
|
5549
5567
|
/**
|
|
5550
|
-
* The unit of
|
|
5568
|
+
* The unit of measurement can be metric or imperial. Default is metric.
|
|
5551
5569
|
* The measuring result will be recalculated once new value is set
|
|
5552
5570
|
*/
|
|
5553
|
-
get
|
|
5554
|
-
return this.measureOptions.
|
|
5571
|
+
get measureUnitType() {
|
|
5572
|
+
return this.measureOptions.measureUnitType ?? "metric";
|
|
5555
5573
|
}
|
|
5556
|
-
set
|
|
5557
|
-
const e = this.measureOptions.
|
|
5558
|
-
this.measureOptions.
|
|
5574
|
+
set measureUnitType(t) {
|
|
5575
|
+
const e = this.measureOptions.measureUnitType === t;
|
|
5576
|
+
this.measureOptions.measureUnitType = t, e || this.recalc();
|
|
5559
5577
|
}
|
|
5560
5578
|
/**
|
|
5561
5579
|
* 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.
|
|
5562
5580
|
*/
|
|
5563
5581
|
get distancePrecision() {
|
|
5564
|
-
|
|
5565
|
-
return this.measureOptions.distanceUnit === "degrees" && (t = 6), this.measureOptions.distancePrecision ?? t;
|
|
5582
|
+
return this.measureOptions.distancePrecision ?? 2;
|
|
5566
5583
|
}
|
|
5567
5584
|
set distancePrecision(t) {
|
|
5568
5585
|
const e = this.measureOptions.distancePrecision === t;
|
|
@@ -5582,17 +5599,6 @@ class Ho extends Xe {
|
|
|
5582
5599
|
const e = this.measureOptions.forceDistanceUnit === t;
|
|
5583
5600
|
this.measureOptions.forceDistanceUnit = t, e || this.recalc();
|
|
5584
5601
|
}
|
|
5585
|
-
/**
|
|
5586
|
-
* The unit of area can be metric (m², ha, km²) or imperial (yd², acre, mi²). Default is metric.
|
|
5587
|
-
* The measuring result will be recalculated once new value is set
|
|
5588
|
-
*/
|
|
5589
|
-
get areaUnit() {
|
|
5590
|
-
return this.measureOptions.areaUnit ?? "metric";
|
|
5591
|
-
}
|
|
5592
|
-
set areaUnit(t) {
|
|
5593
|
-
const e = this.measureOptions.areaUnit === t;
|
|
5594
|
-
this.measureOptions.areaUnit = t, e || this.recalc();
|
|
5595
|
-
}
|
|
5596
5602
|
/**
|
|
5597
5603
|
* The precision of area value. Using setter to override the value if you want.
|
|
5598
5604
|
*/
|
|
@@ -5613,6 +5619,16 @@ class Ho extends Xe {
|
|
|
5613
5619
|
const e = this.measureOptions.forceAreaUnit === t;
|
|
5614
5620
|
this.measureOptions.forceAreaUnit = t, e || this.recalc();
|
|
5615
5621
|
}
|
|
5622
|
+
/**
|
|
5623
|
+
* Measure unit symbols. If you want to change the default symbol, please overwrite the symbol by this option.
|
|
5624
|
+
*/
|
|
5625
|
+
get measureUnitSymbols() {
|
|
5626
|
+
return this.measureOptions.measureUnitSymbols ?? JSON.parse(JSON.stringify(bt));
|
|
5627
|
+
}
|
|
5628
|
+
set measureUnitSymbols(t) {
|
|
5629
|
+
const e = JSON.stringify(this.measureOptions.measureUnitSymbols) === JSON.stringify(t);
|
|
5630
|
+
this.measureOptions.measureUnitSymbols = t, e || this.recalc();
|
|
5631
|
+
}
|
|
5616
5632
|
/**
|
|
5617
5633
|
* The flag of whether computing elevation. Default is false.
|
|
5618
5634
|
* Using setter to override the value if you want.
|
|
@@ -5675,7 +5691,7 @@ class Ho extends Xe {
|
|
|
5675
5691
|
open: e.open,
|
|
5676
5692
|
modeOptions: e.modeOptions,
|
|
5677
5693
|
adapterOptions: e.adapterOptions
|
|
5678
|
-
}), this._cssPrefix = "measure-", this.measureOptions = e, this.measureOptions.elevationCacheConfig && this.measureOptions.elevationCacheConfig?.enabled && (this.elevationCache = new
|
|
5694
|
+
}), this._cssPrefix = "measure-", this.measureOptions = e, this.measureOptions.elevationCacheConfig && this.measureOptions.elevationCacheConfig?.enabled && (this.elevationCache = new $e(
|
|
5679
5695
|
this.measureOptions.elevationCacheConfig.maxSize,
|
|
5680
5696
|
this.measureOptions.elevationCacheConfig.ttl
|
|
5681
5697
|
));
|
|
@@ -5746,7 +5762,7 @@ class Ho extends Xe {
|
|
|
5746
5762
|
const s = this.measureOptions.lineLayerLabelSpec?.source;
|
|
5747
5763
|
s && i.push(s);
|
|
5748
5764
|
const n = this.measureOptions.pointLayerLabelSpec?.source;
|
|
5749
|
-
return n && i.push(n),
|
|
5765
|
+
return n && i.push(n), $t(
|
|
5750
5766
|
t,
|
|
5751
5767
|
e,
|
|
5752
5768
|
i,
|
|
@@ -5829,7 +5845,7 @@ class Ho extends Xe {
|
|
|
5829
5845
|
* Handle finish event of terradraw. It will be called after finishing adding a feature
|
|
5830
5846
|
* @param id Feature ID
|
|
5831
5847
|
*/
|
|
5832
|
-
handleTerradrawFeatureReady =
|
|
5848
|
+
handleTerradrawFeatureReady = Ve((t) => {
|
|
5833
5849
|
this.map && (this.computeElevationByLineFeatureID(t), this.computeElevationByPointFeatureID(t));
|
|
5834
5850
|
}, 300);
|
|
5835
5851
|
/**
|
|
@@ -5928,7 +5944,7 @@ class Ho extends Xe {
|
|
|
5928
5944
|
(o) => o.properties?.originalId === t && o.geometry.type === "Point"
|
|
5929
5945
|
);
|
|
5930
5946
|
if (i && i.length > 0) {
|
|
5931
|
-
const o = await
|
|
5947
|
+
const o = await Ie(
|
|
5932
5948
|
i,
|
|
5933
5949
|
this.measureOptions.terrainSource,
|
|
5934
5950
|
this.measureOptions.elevationCacheConfig,
|
|
@@ -5955,7 +5971,7 @@ class Ho extends Xe {
|
|
|
5955
5971
|
(o) => o.id === t && o.geometry.type === "Point" && o.properties?.mode === "point"
|
|
5956
5972
|
);
|
|
5957
5973
|
if (i && i.length > 0) {
|
|
5958
|
-
const o = await
|
|
5974
|
+
const o = await Ie(
|
|
5959
5975
|
i,
|
|
5960
5976
|
this.measureOptions.terrainSource,
|
|
5961
5977
|
this.measureOptions.elevationCacheConfig,
|
|
@@ -5986,7 +6002,13 @@ class Ho extends Xe {
|
|
|
5986
6002
|
(a) => a.properties?.originalId !== t
|
|
5987
6003
|
));
|
|
5988
6004
|
const n = JSON.parse(JSON.stringify(o));
|
|
5989
|
-
n.id = n.id + "-area-label", n.geometry =
|
|
6005
|
+
n.id = n.id + "-area-label", n.geometry = Ao(o.geometry).geometry, n.properties.originalId = o.id, o = me(
|
|
6006
|
+
o,
|
|
6007
|
+
this.measureUnitType,
|
|
6008
|
+
this.areaPrecision,
|
|
6009
|
+
this.forceAreaUnit,
|
|
6010
|
+
this.measureUnitSymbols
|
|
6011
|
+
), 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(
|
|
5990
6012
|
this.measureOptions.polygonLayerSpec.source
|
|
5991
6013
|
)?.setData(s.data), this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && this.map.moveLayer(
|
|
5992
6014
|
this.measureOptions.lineLayerLabelSpec.id
|
|
@@ -6016,11 +6038,12 @@ class Ho extends Xe {
|
|
|
6016
6038
|
if (s) {
|
|
6017
6039
|
typeof s.data != "string" && s.data.type === "FeatureCollection" && (s.data.features = s.data.features.filter(
|
|
6018
6040
|
(a) => a.properties?.originalId !== t
|
|
6019
|
-
)), o =
|
|
6041
|
+
)), o = Ce(
|
|
6020
6042
|
o,
|
|
6021
|
-
this.
|
|
6043
|
+
this.measureUnitType,
|
|
6022
6044
|
this.distancePrecision,
|
|
6023
6045
|
this.forceDistanceUnit,
|
|
6046
|
+
this.measureUnitSymbols,
|
|
6024
6047
|
this.map,
|
|
6025
6048
|
this.computeElevation,
|
|
6026
6049
|
this.measureOptions.terrainSource
|
|
@@ -6064,7 +6087,7 @@ class Ho extends Xe {
|
|
|
6064
6087
|
let o = e.getSnapshot()?.find((s) => s.id === t && s.geometry.type === "Point");
|
|
6065
6088
|
if (o) {
|
|
6066
6089
|
const s = this.map.getStyle().sources[this.measureOptions.pointLayerLabelSpec.source];
|
|
6067
|
-
s && (typeof s.data != "string" && s.data.type === "FeatureCollection" && (s.data.features = s.data.features.filter((n) => n.id !== t)), o =
|
|
6090
|
+
s && (typeof s.data != "string" && s.data.type === "FeatureCollection" && (s.data.features = s.data.features.filter((n) => n.id !== t)), o = Se(
|
|
6068
6091
|
o,
|
|
6069
6092
|
this.map,
|
|
6070
6093
|
this.computeElevation,
|
|
@@ -6109,15 +6132,22 @@ class Ho extends Xe {
|
|
|
6109
6132
|
const o = e.features[i];
|
|
6110
6133
|
if (!this.map || !this.map.loaded()) continue;
|
|
6111
6134
|
const s = o.geometry.type;
|
|
6112
|
-
s === "LineString" ? e.features[i] =
|
|
6135
|
+
s === "LineString" ? e.features[i] = Ce(
|
|
6113
6136
|
o,
|
|
6114
|
-
this.
|
|
6137
|
+
this.measureUnitType,
|
|
6115
6138
|
this.distancePrecision,
|
|
6116
6139
|
this.forceDistanceUnit,
|
|
6140
|
+
this.measureUnitSymbols,
|
|
6117
6141
|
this.map,
|
|
6118
6142
|
this.computeElevation,
|
|
6119
6143
|
this.measureOptions.terrainSource
|
|
6120
|
-
) : s === "Polygon" ? e.features[i] =
|
|
6144
|
+
) : s === "Polygon" ? e.features[i] = me(
|
|
6145
|
+
o,
|
|
6146
|
+
this.measureUnitType,
|
|
6147
|
+
this.areaPrecision,
|
|
6148
|
+
this.forceAreaUnit,
|
|
6149
|
+
this.measureUnitSymbols
|
|
6150
|
+
) : s === "Point" && (e.features[i] = Se(
|
|
6121
6151
|
o,
|
|
6122
6152
|
this.map,
|
|
6123
6153
|
this.computeElevation,
|
|
@@ -6127,7 +6157,7 @@ class Ho extends Xe {
|
|
|
6127
6157
|
return e;
|
|
6128
6158
|
}
|
|
6129
6159
|
}
|
|
6130
|
-
class
|
|
6160
|
+
class Ho extends qe {
|
|
6131
6161
|
controlOptions;
|
|
6132
6162
|
valhallaOptions;
|
|
6133
6163
|
_modalDialog;
|
|
@@ -6326,13 +6356,13 @@ class Jo extends Xe {
|
|
|
6326
6356
|
const i = et, o = this.controlOptions.routingLineLayerNodeSpec?.source;
|
|
6327
6357
|
o && i.push(o);
|
|
6328
6358
|
const s = this.controlOptions.isochronePolygonLayerSpec?.source;
|
|
6329
|
-
return s && i.push(s),
|
|
6359
|
+
return s && i.push(s), $t(t, e, i, this.options.adapterOptions?.prefixId);
|
|
6330
6360
|
}
|
|
6331
6361
|
/**
|
|
6332
6362
|
* Create the settings dialog for Valhalla control
|
|
6333
6363
|
*/
|
|
6334
6364
|
createSettingsDialog() {
|
|
6335
|
-
this.settingDialog = new
|
|
6365
|
+
this.settingDialog = new vo(
|
|
6336
6366
|
`maplibregl-terradraw-${this.cssPrefix}settings-dialog`,
|
|
6337
6367
|
"Settings"
|
|
6338
6368
|
), this.settingDialog.create(
|
|
@@ -6374,7 +6404,7 @@ class Jo extends Xe {
|
|
|
6374
6404
|
const i = document.createElement("label");
|
|
6375
6405
|
i.textContent = "Means of Transport", i.classList.add("setting-label"), e.appendChild(i), e.appendChild(
|
|
6376
6406
|
this.settingDialog.createSegmentButtons(
|
|
6377
|
-
|
|
6407
|
+
Bt,
|
|
6378
6408
|
this.routingCostingModel,
|
|
6379
6409
|
(n) => {
|
|
6380
6410
|
this.valhallaOptions.routingOptions || (this.valhallaOptions.routingOptions = {}), this.valhallaOptions.routingOptions.costingModel = n, this.dispatchEvent("setting-changed");
|
|
@@ -6386,7 +6416,7 @@ class Jo extends Xe {
|
|
|
6386
6416
|
const s = document.createElement("label");
|
|
6387
6417
|
return s.textContent = "Distance Unit", s.classList.add("setting-label"), o.appendChild(s), o.appendChild(
|
|
6388
6418
|
this.settingDialog.createSegmentButtons(
|
|
6389
|
-
|
|
6419
|
+
Bo,
|
|
6390
6420
|
this.routingDistanceUnit,
|
|
6391
6421
|
(n) => {
|
|
6392
6422
|
this.valhallaOptions.routingOptions || (this.valhallaOptions.routingOptions = {}), this.valhallaOptions.routingOptions.distanceUnit = n, this.dispatchEvent("setting-changed");
|
|
@@ -6403,7 +6433,7 @@ class Jo extends Xe {
|
|
|
6403
6433
|
const i = document.createElement("label");
|
|
6404
6434
|
i.textContent = "Contour Type", i.classList.add("setting-label"), e.appendChild(i), e.appendChild(
|
|
6405
6435
|
this.settingDialog.createSegmentButtons(
|
|
6406
|
-
|
|
6436
|
+
To,
|
|
6407
6437
|
this.controlOptions.valhallaOptions?.isochroneOptions?.contourType || "time",
|
|
6408
6438
|
(d) => {
|
|
6409
6439
|
this.valhallaOptions.isochroneOptions || (this.valhallaOptions.isochroneOptions = {}), this.valhallaOptions.isochroneOptions.contourType = d, this.dispatchEvent("setting-changed");
|
|
@@ -6415,7 +6445,7 @@ class Jo extends Xe {
|
|
|
6415
6445
|
const s = document.createElement("label");
|
|
6416
6446
|
s.textContent = "Means of Transport", s.classList.add("setting-label"), o.appendChild(s), o.appendChild(
|
|
6417
6447
|
this.settingDialog.createSegmentButtons(
|
|
6418
|
-
|
|
6448
|
+
Bt,
|
|
6419
6449
|
this.controlOptions.valhallaOptions?.isochroneOptions?.costingModel || "auto",
|
|
6420
6450
|
(d) => {
|
|
6421
6451
|
this.valhallaOptions.isochroneOptions || (this.valhallaOptions.isochroneOptions = {}), this.valhallaOptions.isochroneOptions.costingModel = d, this.dispatchEvent("setting-changed");
|
|
@@ -6598,14 +6628,14 @@ class Jo extends Xe {
|
|
|
6598
6628
|
* Handle finish event of terradraw. It will be called after finishing adding a feature
|
|
6599
6629
|
* @param id Feature ID
|
|
6600
6630
|
*/
|
|
6601
|
-
handleTerradrawFeatureReady =
|
|
6631
|
+
handleTerradrawFeatureReady = Ve((t) => {
|
|
6602
6632
|
this.map && (this.computeRouteByLineFeatureID(t), this.computeIsochroneByPointFeatureID(t));
|
|
6603
6633
|
}, 300);
|
|
6604
6634
|
computeIsochroneByPointFeatureID = async (t) => {
|
|
6605
6635
|
if (!this.map || !this.valhallaOptions.url) return;
|
|
6606
6636
|
const e = this.terradraw?.getSnapshotFeature(t);
|
|
6607
6637
|
if (!e || e && e.geometry.type !== "Point") return;
|
|
6608
|
-
const i = e.geometry.coordinates, n = (await new
|
|
6638
|
+
const i = e.geometry.coordinates, n = (await new Wo(this.valhallaUrl).calcIsochrone(
|
|
6609
6639
|
i[0],
|
|
6610
6640
|
i[1],
|
|
6611
6641
|
this.isochroneContourType,
|
|
@@ -6639,9 +6669,9 @@ class Jo extends Xe {
|
|
|
6639
6669
|
if (!this.map || !this.valhallaOptions.url) return;
|
|
6640
6670
|
const e = this.terradraw?.getSnapshotFeature(t);
|
|
6641
6671
|
if (!e || e && e.geometry.type !== "LineString") return;
|
|
6642
|
-
const i = new
|
|
6672
|
+
const i = new jo(this.valhallaUrl), o = e.geometry.coordinates.map((c) => {
|
|
6643
6673
|
const h = c;
|
|
6644
|
-
return new
|
|
6674
|
+
return new Je(h[0], h[1]);
|
|
6645
6675
|
});
|
|
6646
6676
|
if (!o || o && o.length < 2) return;
|
|
6647
6677
|
const s = await i.calcRoute(
|
|
@@ -6710,34 +6740,35 @@ class Jo extends Xe {
|
|
|
6710
6740
|
}
|
|
6711
6741
|
}
|
|
6712
6742
|
export {
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6743
|
+
$o as AvailableModes,
|
|
6744
|
+
Yo as AvailableValhallaModes,
|
|
6745
|
+
Jo as MaplibreMeasureControl,
|
|
6746
|
+
qe as MaplibreTerradrawControl,
|
|
6747
|
+
Ho as MaplibreValhallaControl,
|
|
6748
|
+
$e as MemoryCache,
|
|
6749
|
+
vo as ModalDialog,
|
|
6750
|
+
Ko as TERRADRAW_MEASURE_SOURCE_IDS,
|
|
6721
6751
|
et as TERRADRAW_SOURCE_IDS,
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6752
|
+
Xo as TERRADRAW_VALHALLA_SOURCE_IDS,
|
|
6753
|
+
Wo as ValhallaIsochrone,
|
|
6754
|
+
jo as ValhallaRouting,
|
|
6755
|
+
me as calcArea,
|
|
6756
|
+
Ce as calcDistance,
|
|
6757
|
+
Pe as capitalize,
|
|
6758
|
+
$t as cleanMaplibreStyle,
|
|
6759
|
+
To as contourTypeOptions,
|
|
6760
|
+
yo as convertAreaUnit,
|
|
6761
|
+
_t as convertDistance,
|
|
6762
|
+
Bt as costingModelOptions,
|
|
6763
|
+
Ve as debounce,
|
|
6764
|
+
io as defaultControlOptions,
|
|
6735
6765
|
lt as defaultMeasureControlOptions,
|
|
6766
|
+
bt as defaultMeasureUnitSymbols,
|
|
6736
6767
|
z as defaultValhallaControlOptions,
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
6768
|
+
oo as getDefaultModeOptions,
|
|
6769
|
+
Se as queryElevationByPoint,
|
|
6770
|
+
Ie as queryElevationFromRasterDEM,
|
|
6771
|
+
qo as roundFeatureCoordinates,
|
|
6772
|
+
Bo as routingDistanceUnitOptions
|
|
6742
6773
|
};
|
|
6743
6774
|
//# sourceMappingURL=maplibre-gl-terradraw.es.js.map
|