@watergis/maplibre-gl-terradraw 1.7.2 → 1.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/maplibre-gl-terradraw.es.js +709 -679
- package/dist/maplibre-gl-terradraw.es.js.map +1 -1
- package/dist/maplibre-gl-terradraw.umd.js +3 -3
- package/dist/maplibre-gl-terradraw.umd.js.map +1 -1
- package/dist/types/controls/MaplibreMeasureControl.d.ts.map +1 -1
- package/dist/types/controls/MaplibreValhallaControl.d.ts.map +1 -1
- package/dist/types/helpers/roundFeatureCoordinates.d.ts +1 -1
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LngLat as
|
|
1
|
+
import { LngLat as Xe } 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++) {
|
|
@@ -12,25 +12,25 @@ var b;
|
|
|
12
12
|
(function(r) {
|
|
13
13
|
r.Commit = "commit", r.Provisional = "provisional", r.Finish = "finish";
|
|
14
14
|
})(b || (b = {}));
|
|
15
|
-
const k = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT_FEATURE_ID: "selectionPointFeatureId", SELECTION_POINT: "selectionPoint" },
|
|
16
|
-
function
|
|
15
|
+
const k = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT_FEATURE_ID: "selectionPointFeatureId", SELECTION_POINT: "selectionPoint" }, P = { 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 Ot(r) {
|
|
17
17
|
return !!(r && typeof r == "object" && r !== null && !Array.isArray(r));
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function Jt(r) {
|
|
20
20
|
return !!(r && typeof r == "object" && "properties" in r && typeof r.properties == "object" && r.properties !== null && "mode" in r.properties);
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function qt(r) {
|
|
23
23
|
return !!(function(t) {
|
|
24
24
|
return typeof t == "number" && !isNaN(new Date(t).valueOf());
|
|
25
25
|
})(r);
|
|
26
26
|
}
|
|
27
|
-
const
|
|
28
|
-
var
|
|
27
|
+
const He = "Feature mode property does not match the mode being added to";
|
|
28
|
+
var H;
|
|
29
29
|
(function(r) {
|
|
30
30
|
r.Drawing = "drawing", r.Select = "select", r.Static = "static", r.Render = "render";
|
|
31
|
-
})(
|
|
32
|
-
const
|
|
33
|
-
|
|
31
|
+
})(H || (H = {}));
|
|
32
|
+
const Je = { rightClick: !0, contextMenu: !1, leftClick: !0, onDragStart: !0, onDrag: !0, onDragEnd: !0 };
|
|
33
|
+
class A {
|
|
34
34
|
get state() {
|
|
35
35
|
return this._state;
|
|
36
36
|
}
|
|
@@ -47,7 +47,7 @@ let G = class {
|
|
|
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 = Je, this.behaviors = [], this.validate = void 0, this.pointerDistance = 40, this.coordinatePrecision = void 0, this.onStyleChange = void 0, this.store = void 0, this.projection = "web-mercator", this.setDoubleClickToZoom = void 0, this.unproject = void 0, this.project = void 0, this.setCursor = void 0, this.type = H.Drawing, this.mode = "base", e || this.updateOptions(t);
|
|
51
51
|
}
|
|
52
52
|
updateOptions(t) {
|
|
53
53
|
t != null && t.styles && (this.styles = x({}, this._styles, t.styles)), t != null && t.pointerDistance && (this.pointerDistance = t.pointerDistance), t != null && t.validation && (this.validate = t && t.validation), t != null && t.projection && (this.projection = t.projection), t?.pointerEvents !== void 0 && (this.pointerEvents = t.pointerEvents);
|
|
@@ -82,9 +82,9 @@ let G = class {
|
|
|
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 (Ot(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 (Ot(i.geometry)) if (Ot(i.properties)) if (typeof i.geometry.type == "string" && ["Polygon", "LineString", "Point"].includes(i.geometry.type)) if (Array.isArray(i.geometry.coordinates)) {
|
|
88
88
|
if (!i.properties.mode || typeof i.properties.mode != "string") return { valid: !1, reason: "Feature does not have a valid mode property" };
|
|
89
89
|
} else s = "Feature coordinates is not an array";
|
|
90
90
|
else s = "Feature is not Point, LineString or Polygon";
|
|
@@ -102,7 +102,7 @@ let G = class {
|
|
|
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
|
}
|
|
@@ -133,44 +133,44 @@ let G = class {
|
|
|
133
133
|
getStylingValue(t, e, i) {
|
|
134
134
|
return t === void 0 ? e : typeof t == "function" ? t(i) : t;
|
|
135
135
|
}
|
|
136
|
-
}
|
|
137
|
-
class
|
|
136
|
+
}
|
|
137
|
+
let qe = class extends A {
|
|
138
138
|
constructor(...t) {
|
|
139
|
-
super(...t), this.type =
|
|
139
|
+
super(...t), this.type = H.Select;
|
|
140
140
|
}
|
|
141
|
-
}
|
|
142
|
-
function
|
|
141
|
+
};
|
|
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
|
|
147
|
-
function
|
|
146
|
+
const Se = 63710088e-1;
|
|
147
|
+
function D(r) {
|
|
148
148
|
return r % 360 * Math.PI / 180;
|
|
149
149
|
}
|
|
150
|
-
function
|
|
150
|
+
function Ie(r) {
|
|
151
151
|
return r / 6371.0088;
|
|
152
152
|
}
|
|
153
|
-
function
|
|
153
|
+
function V(r) {
|
|
154
154
|
return r % (2 * Math.PI) * 180 / Math.PI;
|
|
155
155
|
}
|
|
156
156
|
function w(r, t = 9) {
|
|
157
157
|
const e = Math.pow(10, t);
|
|
158
158
|
return Math.round(r * e) / e;
|
|
159
159
|
}
|
|
160
|
-
const
|
|
161
|
-
function
|
|
162
|
-
const i =
|
|
163
|
-
return [
|
|
160
|
+
const Zt = 57.29577951308232, Qt = 0.017453292519943295, Ct = 6378137, O = (r, t) => ({ x: r === 0 ? 0 : r * Qt * Ct, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * Qt / 2)) * Ct }), R = (r, t) => ({ lng: r === 0 ? 0 : Zt * (r / Ct), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / Ct)) - Math.PI / 2) * Zt });
|
|
161
|
+
function Ze(r, t, e) {
|
|
162
|
+
const i = D(r[0]), o = D(r[1]), s = D(e), n = Ie(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(s));
|
|
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 te(r) {
|
|
166
166
|
const { center: t, radiusKilometers: e, coordinatePrecision: i } = r, o = r.steps ? r.steps : 64, s = [];
|
|
167
167
|
for (let n = 0; n < o; n++) {
|
|
168
|
-
const a =
|
|
168
|
+
const a = Ze(t, e, -360 * n / o);
|
|
169
169
|
s.push([w(a[0], i), w(a[1], i)]);
|
|
170
170
|
}
|
|
171
171
|
return s.push(s[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [s] }, properties: {} };
|
|
172
172
|
}
|
|
173
|
-
function
|
|
173
|
+
function Tt(r) {
|
|
174
174
|
let t;
|
|
175
175
|
if (r.geometry.type === "Polygon") t = r.geometry.coordinates;
|
|
176
176
|
else {
|
|
@@ -185,57 +185,57 @@ function Gt(r) {
|
|
|
185
185
|
}
|
|
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
|
-
if (
|
|
189
|
-
const
|
|
190
|
-
return
|
|
188
|
+
if (gt(m, C) || gt(m, f) || gt(v, C) || gt(f, C)) return null;
|
|
189
|
+
const S = m[0], I = m[1], E = v[0], L = v[1], M = C[0], N = C[1], _ = f[0], T = f[1], $ = (S - E) * (N - T) - (I - L) * (M - _);
|
|
190
|
+
return $ === 0 ? null : [((S * L - I * E) * (M - _) - (S - E) * (M * T - N * _)) / $, ((S * L - I * E) * (N - T) - (I - L) * (M * T - N * _)) / $];
|
|
191
191
|
})(d, c, h, u);
|
|
192
192
|
if (p === null) return;
|
|
193
193
|
let g, y;
|
|
194
194
|
g = c[0] !== d[0] ? (p[0] - d[0]) / (c[0] - d[0]) : (p[1] - d[1]) / (c[1] - d[1]), y = u[0] !== h[0] ? (p[0] - h[0]) / (u[0] - h[0]) : (p[1] - h[1]) / (u[1] - h[1]), i(g) || i(y) || (p.toString(), e.push(p));
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
|
-
function
|
|
197
|
+
function gt(r, t) {
|
|
198
198
|
return r[0] === t[0] && r[1] === t[1];
|
|
199
199
|
}
|
|
200
|
-
function
|
|
201
|
-
return
|
|
200
|
+
function It(r, t) {
|
|
201
|
+
return ee(r[0]) <= t && ee(r[1]) <= t;
|
|
202
202
|
}
|
|
203
|
-
function
|
|
203
|
+
function Wt(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 ee(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 Qe = "Feature has holes", ti = "Feature has less than 4 coordinates", ei = "Feature has invalid coordinates", ii = "Feature coordinates are not closed";
|
|
213
|
+
function xt(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: Qe };
|
|
216
|
+
if (r.geometry.coordinates[0].length < 4) return { valid: !1, reason: ti };
|
|
217
217
|
for (let o = 0; o < r.geometry.coordinates[0].length; o++) {
|
|
218
|
-
if (!
|
|
219
|
-
if (!
|
|
218
|
+
if (!Wt(r.geometry.coordinates[0][o])) return { valid: !1, reason: ei };
|
|
219
|
+
if (!It(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: ii } : { valid: !0 };
|
|
222
222
|
var e, i;
|
|
223
223
|
}
|
|
224
|
-
function
|
|
225
|
-
const e =
|
|
226
|
-
return e.valid ?
|
|
224
|
+
function ut(r, t) {
|
|
225
|
+
const e = xt(r, t);
|
|
226
|
+
return e.valid ? Tt(r) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
|
|
227
227
|
}
|
|
228
|
-
const
|
|
229
|
-
class
|
|
228
|
+
const oi = { cancel: "Escape", finish: "Enter" }, si = { start: "crosshair" };
|
|
229
|
+
let xe = 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 = oi, this.cursors = si, 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);
|
|
235
235
|
}
|
|
236
236
|
close() {
|
|
237
237
|
if (this.currentCircleId === void 0) return;
|
|
238
|
-
this.store.updateProperty([{ id: this.currentCircleId, property:
|
|
238
|
+
this.store.updateProperty([{ id: this.currentCircleId, property: P.CURRENTLY_DRAWING, value: void 0 }]);
|
|
239
239
|
const t = this.currentCircleId;
|
|
240
240
|
if (this.validate && t) {
|
|
241
241
|
const e = this.store.getGeometryCopy(t);
|
|
@@ -252,7 +252,7 @@ class Oe extends G {
|
|
|
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 = te({ center: this.center, radiusKilometers: this.startingRadiusKilometers, coordinatePrecision: this.coordinatePrecision }), [i] = this.store.create([{ geometry: e.geometry, properties: { mode: this.mode, radiusKilometers: this.startingRadiusKilometers, [P.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
|
}
|
|
@@ -280,33 +280,33 @@ class Oe extends G {
|
|
|
280
280
|
}
|
|
281
281
|
styleFeature(t) {
|
|
282
282
|
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
283
|
-
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 =
|
|
283
|
+
return t.type === "Feature" && t.geometry.type === "Polygon" && t.properties.mode === this.mode && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = j), e;
|
|
284
284
|
}
|
|
285
285
|
validateFeature(t) {
|
|
286
|
-
return this.validateModeFeature(t, (e) =>
|
|
286
|
+
return this.validateModeFeature(t, (e) => ut(e, this.coordinatePrecision));
|
|
287
287
|
}
|
|
288
288
|
updateCircle(t) {
|
|
289
289
|
if (this.clickCount === 1 && this.center && this.currentCircleId) {
|
|
290
|
-
const e =
|
|
290
|
+
const e = U(this.center, [t.lng, t.lat]);
|
|
291
291
|
let i;
|
|
292
292
|
if (this.projection === "web-mercator") {
|
|
293
293
|
const o = (function(s, n) {
|
|
294
|
-
const a = 1e3 *
|
|
294
|
+
const a = 1e3 * U(s, n);
|
|
295
295
|
if (a === 0) return 1;
|
|
296
|
-
const { x: l, y: d } =
|
|
296
|
+
const { x: l, y: d } = O(s[0], s[1]), { x: c, y: h } = O(n[0], n[1]);
|
|
297
297
|
return Math.sqrt(Math.pow(c - l, 2) + Math.pow(h - d, 2)) / a;
|
|
298
298
|
})(this.center, [t.lng, t.lat]);
|
|
299
299
|
i = (function(s) {
|
|
300
|
-
const { center: n, radiusKilometers: a, coordinatePrecision: l } = s, d = s.steps ? s.steps : 64, c = 1e3 * a, [h, u] = n, { x: p, y: g } =
|
|
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), [
|
|
303
|
-
y.push([w(E, l), w(
|
|
302
|
+
const v = 360 * m / d * Math.PI / 180, C = c * Math.cos(v), f = c * Math.sin(v), [S, I] = [p + C, g + f], { lng: E, lat: L } = R(S, I);
|
|
303
|
+
y.push([w(E, l), w(L, l)]);
|
|
304
304
|
}
|
|
305
305
|
return y.push(y[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [y] }, properties: {} };
|
|
306
306
|
})({ center: this.center, radiusKilometers: e * o, coordinatePrecision: this.coordinatePrecision });
|
|
307
307
|
} else {
|
|
308
308
|
if (this.projection !== "globe") throw new Error("Invalid projection");
|
|
309
|
-
i =
|
|
309
|
+
i = te({ center: this.center, radiusKilometers: e, coordinatePrecision: this.coordinatePrecision });
|
|
310
310
|
}
|
|
311
311
|
if (this.validate && !this.validate({ type: "Feature", id: this.currentCircleId, geometry: i.geometry, properties: { radiusKilometers: e } }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Provisional }).valid) return;
|
|
312
312
|
this.store.updateGeometry([{ id: this.currentCircleId, geometry: i.geometry }]), this.store.updateProperty([{ id: this.currentCircleId, property: "radiusKilometers", value: e }]);
|
|
@@ -315,12 +315,12 @@ class Oe extends G {
|
|
|
315
315
|
afterFeatureUpdated(t) {
|
|
316
316
|
this.currentCircleId === t.id && (this.cursorMovedAfterInitialCursorDown = !1, this.center = void 0, this.currentCircleId = void 0, this.clickCount = 0, this.state === "drawing" && this.setStarted());
|
|
317
317
|
}
|
|
318
|
-
}
|
|
319
|
-
const
|
|
318
|
+
};
|
|
319
|
+
const F = (r, t) => {
|
|
320
320
|
const { x: e, y: i } = r, { x: o, y: s } = t, n = o - e, a = s - i;
|
|
321
321
|
return Math.sqrt(a * a + n * n);
|
|
322
322
|
};
|
|
323
|
-
function
|
|
323
|
+
function pt(r) {
|
|
324
324
|
if (!(function(e) {
|
|
325
325
|
const i = e.coordinates[0];
|
|
326
326
|
let o = 0;
|
|
@@ -331,10 +331,10 @@ function ft(r) {
|
|
|
331
331
|
return o < 0;
|
|
332
332
|
})(r)) return { type: "Polygon", coordinates: [r.coordinates[0].reverse()] };
|
|
333
333
|
}
|
|
334
|
-
const
|
|
335
|
-
class
|
|
334
|
+
const ri = { cancel: "Escape", finish: "Enter" }, ni = { start: "crosshair", close: "pointer" };
|
|
335
|
+
class Oe 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 = ri, this.cursors = ni, 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));
|
|
@@ -342,8 +342,8 @@ class Le extends G {
|
|
|
342
342
|
close() {
|
|
343
343
|
if (this.currentId === void 0) return;
|
|
344
344
|
if (this.currentId) {
|
|
345
|
-
const e =
|
|
346
|
-
e && this.store.updateGeometry([{ id: this.currentId, geometry: e }]), this.store.updateProperty([{ id: this.currentId, property:
|
|
345
|
+
const e = pt(this.store.getGeometryCopy(this.currentId));
|
|
346
|
+
e && this.store.updateGeometry([{ id: this.currentId, geometry: e }]), this.store.updateProperty([{ id: this.currentId, property: P.CURRENTLY_DRAWING, value: void 0 }]);
|
|
347
347
|
}
|
|
348
348
|
const t = this.currentId;
|
|
349
349
|
if (this.validate && t) {
|
|
@@ -360,8 +360,8 @@ class Le extends G {
|
|
|
360
360
|
}
|
|
361
361
|
onMouseMove(t) {
|
|
362
362
|
if (this.currentId === void 0 || this.startingClick === !1) return void this.setCursor(this.cursors.start);
|
|
363
|
-
const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates[0].length - 2, [o, s] = e.coordinates[0][i], { x: n, y: a } = this.project(o, s), l =
|
|
364
|
-
if (
|
|
363
|
+
const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates[0].length - 2, [o, s] = e.coordinates[0][i], { x: n, y: a } = this.project(o, s), l = F({ x: n, y: a }, { x: t.containerX, y: t.containerY }), [d, c] = e.coordinates[0][0], { x: h, y: u } = this.project(d, c);
|
|
364
|
+
if (F({ x: h, y: u }, { x: t.containerX, y: t.containerY }) < this.pointerDistance) {
|
|
365
365
|
if (this.autoClose && this.hasLeftStartingPoint && (this.preventNewFeature = !0, setTimeout(() => {
|
|
366
366
|
this.preventNewFeature = !1;
|
|
367
367
|
}, this.autoCloseTimeout), this.close()), this.setCursor(this.cursors.close), this.preventPointsNearClose) return;
|
|
@@ -375,7 +375,7 @@ class Le extends G {
|
|
|
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)) {
|
|
376
376
|
if (this.preventNewFeature) return;
|
|
377
377
|
if (this.startingClick === !1) {
|
|
378
|
-
const [e, i] = this.store.create([{ geometry: { type: "Polygon", coordinates: [[[t.lng, t.lat], [t.lng, t.lat], [t.lng, t.lat], [t.lng, t.lat]]] }, properties: { mode: this.mode, [
|
|
378
|
+
const [e, i] = this.store.create([{ geometry: { type: "Polygon", coordinates: [[[t.lng, t.lat], [t.lng, t.lat], [t.lng, t.lat], [t.lng, t.lat]]] }, properties: { mode: this.mode, [P.CURRENTLY_DRAWING]: !0 } }, { geometry: { type: "Point", coordinates: [t.lng, t.lat] }, properties: { mode: this.mode, [P.CLOSING_POINT]: !0 } }]);
|
|
379
379
|
return this.currentId = e, this.closingPointId = i, this.startingClick = !0, void (this.state !== "drawing" && this.setDrawing());
|
|
380
380
|
}
|
|
381
381
|
this.close();
|
|
@@ -402,43 +402,43 @@ class Le extends G {
|
|
|
402
402
|
}
|
|
403
403
|
styleFeature(t) {
|
|
404
404
|
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
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 =
|
|
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) => xt(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);
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
|
-
class
|
|
414
|
+
let B = class {
|
|
415
415
|
constructor({ store: t, mode: e, project: i, unproject: o, pointerDistance: s, coordinatePrecision: n, projection: a }) {
|
|
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
|
-
}
|
|
419
|
-
function
|
|
418
|
+
};
|
|
419
|
+
function be({ 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
|
}
|
|
423
|
-
class
|
|
423
|
+
class dt extends B {
|
|
424
424
|
constructor(t) {
|
|
425
425
|
super(t);
|
|
426
426
|
}
|
|
427
427
|
create(t) {
|
|
428
428
|
const { containerX: e, containerY: i } = t;
|
|
429
|
-
return
|
|
429
|
+
return be({ unproject: this.unproject, point: { x: e, y: i }, pointerDistance: this.pointerDistance });
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
|
-
class
|
|
432
|
+
class ct extends B {
|
|
433
433
|
constructor(t) {
|
|
434
434
|
super(t);
|
|
435
435
|
}
|
|
436
436
|
measure(t, e) {
|
|
437
437
|
const { x: i, y: o } = this.project(e[0], e[1]);
|
|
438
|
-
return
|
|
438
|
+
return F({ x: i, y: o }, { x: t.containerX, y: t.containerY });
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
|
-
class
|
|
441
|
+
let Pt = class extends B {
|
|
442
442
|
constructor(t, e, i) {
|
|
443
443
|
super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => this.getSnappable(o, (s) => !!(s.properties && s.properties.mode === this.mode)).coordinate, this.getSnappableCoordinate = (o, s) => this.getSnappable(o, (n) => !!(n.properties && n.properties.mode === this.mode && n.id !== s)).coordinate, this.config = t, this.pixelDistance = e, this.clickBoundingBox = i;
|
|
444
444
|
}
|
|
@@ -457,64 +457,64 @@ class Et extends W {
|
|
|
457
457
|
});
|
|
458
458
|
}), s;
|
|
459
459
|
}
|
|
460
|
+
};
|
|
461
|
+
function ie(r, t, e) {
|
|
462
|
+
const i = D(r[0]), o = D(r[1]), s = D(e), n = Ie(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(s));
|
|
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)];
|
|
460
464
|
}
|
|
461
|
-
function
|
|
462
|
-
const
|
|
463
|
-
return [$(i + Math.atan2(Math.sin(s) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), $(a)];
|
|
464
|
-
}
|
|
465
|
-
function gt({ x: r, y: t }, e, i) {
|
|
466
|
-
const o = M(i);
|
|
465
|
+
function ht({ x: r, y: t }, e, i) {
|
|
466
|
+
const o = D(i);
|
|
467
467
|
return { x: r + e * Math.cos(o), y: t + e * Math.sin(o) };
|
|
468
468
|
}
|
|
469
|
-
function
|
|
470
|
-
const e =
|
|
471
|
-
return
|
|
469
|
+
function oe(r, t) {
|
|
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
|
+
return V(Math.atan2(n, a));
|
|
472
472
|
}
|
|
473
|
-
function
|
|
473
|
+
function G({ x: r, y: t }, { x: e, y: i }) {
|
|
474
474
|
const o = e - r, s = i - t;
|
|
475
475
|
if (o === 0 && s === 0) return 0;
|
|
476
476
|
let n = Math.atan2(s, o);
|
|
477
477
|
return n *= 180 / Math.PI, n > 180 ? n -= 360 : n < -180 && (n += 360), n;
|
|
478
478
|
}
|
|
479
|
-
function
|
|
479
|
+
function X(r) {
|
|
480
480
|
return (r + 360) % 360;
|
|
481
481
|
}
|
|
482
|
-
function
|
|
482
|
+
function ai(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 = oe(r[c], r[c - 1]) - 180, a = ie(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 = oe(r[c], r[c - 1]) - 180, a = ie(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
|
-
l +=
|
|
492
|
+
l += U(r[c], r[c + 1]);
|
|
493
493
|
}
|
|
494
494
|
if (l < t && r.length === o) throw new Error("Start position is beyond line");
|
|
495
495
|
const d = r[r.length - 1];
|
|
496
496
|
return [d, d];
|
|
497
497
|
}
|
|
498
|
-
function
|
|
498
|
+
function yt(r) {
|
|
499
499
|
return r * (Math.PI / 180);
|
|
500
500
|
}
|
|
501
|
-
function
|
|
501
|
+
function se(r) {
|
|
502
502
|
return r * (180 / Math.PI);
|
|
503
503
|
}
|
|
504
|
-
class
|
|
504
|
+
class li extends B {
|
|
505
505
|
constructor(t) {
|
|
506
506
|
super(t), this.config = void 0, this.config = t;
|
|
507
507
|
}
|
|
508
508
|
generateInsertionCoordinates(t, e, i) {
|
|
509
509
|
const o = [t, e];
|
|
510
510
|
let s = 0;
|
|
511
|
-
for (let d = 0; d < o.length - 1; d++) s +=
|
|
511
|
+
for (let d = 0; d < o.length - 1; d++) s += U(o[0], o[1]);
|
|
512
512
|
if (s <= i) return o;
|
|
513
513
|
let n = s / i - 1;
|
|
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 = ai(o, i * d, i * (d + 1));
|
|
518
518
|
a.push(c);
|
|
519
519
|
}
|
|
520
520
|
const l = [];
|
|
@@ -522,16 +522,16 @@ class pi extends W {
|
|
|
522
522
|
return this.limitCoordinates(l);
|
|
523
523
|
}
|
|
524
524
|
generateInsertionGeodesicCoordinates(t, e, i) {
|
|
525
|
-
const o =
|
|
526
|
-
const d = [], c =
|
|
525
|
+
const o = U(t, e), s = (function(n, a, l) {
|
|
526
|
+
const d = [], c = yt(n[1]), h = yt(n[0]), u = yt(a[1]), p = yt(a[0]);
|
|
527
527
|
l += 1;
|
|
528
528
|
const g = 2 * Math.asin(Math.sqrt(Math.sin((u - c) / 2) ** 2 + Math.cos(c) * Math.cos(u) * Math.sin((p - h) / 2) ** 2));
|
|
529
529
|
if (g === 0 || isNaN(g)) return d;
|
|
530
530
|
for (let y = 0; y <= l; y++) {
|
|
531
|
-
const m = y / l, v = Math.sin((1 - m) * g) / Math.sin(g), C = Math.sin(m * g) / Math.sin(g), f = v * Math.cos(c) * Math.cos(h) + C * Math.cos(u) * Math.cos(p),
|
|
532
|
-
if (isNaN(f) || isNaN(
|
|
533
|
-
const E = Math.atan2(
|
|
534
|
-
isNaN(E) || isNaN(
|
|
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), S = v * Math.cos(c) * Math.sin(h) + C * Math.cos(u) * Math.sin(p), I = v * Math.sin(c) + C * Math.sin(u);
|
|
532
|
+
if (isNaN(f) || isNaN(S) || isNaN(I)) continue;
|
|
533
|
+
const E = Math.atan2(I, Math.sqrt(f ** 2 + S ** 2)), L = Math.atan2(S, f);
|
|
534
|
+
isNaN(E) || isNaN(L) || d.push([se(L), se(E)]);
|
|
535
535
|
}
|
|
536
536
|
return d.slice(1, -1);
|
|
537
537
|
})(t, e, Math.floor(o / i));
|
|
@@ -541,49 +541,49 @@ class pi extends W {
|
|
|
541
541
|
return t.map((e) => [w(e[0], this.config.coordinatePrecision), w(e[1], this.config.coordinatePrecision)]);
|
|
542
542
|
}
|
|
543
543
|
}
|
|
544
|
-
function
|
|
544
|
+
function tt(r, t) {
|
|
545
545
|
return r[0] === t[0] && r[1] === t[1];
|
|
546
546
|
}
|
|
547
|
-
function
|
|
547
|
+
function Bt(r, t) {
|
|
548
548
|
if (r.geometry.type !== "LineString") return { valid: !1, reason: "Feature is not a LineString" };
|
|
549
549
|
if (r.geometry.coordinates.length < 2) return { valid: !1, reason: "Feature has less than 2 coordinates" };
|
|
550
550
|
for (let e = 0; e < r.geometry.coordinates.length; e++) {
|
|
551
|
-
if (!
|
|
552
|
-
if (!
|
|
551
|
+
if (!Wt(r.geometry.coordinates[e])) return { valid: !1, reason: "Feature has invalid coordinates" };
|
|
552
|
+
if (!It(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 re(r) {
|
|
557
557
|
return Math.sqrt(Math.pow(r[0], 2) + Math.pow(r[1], 2) + Math.pow(r[2], 2));
|
|
558
558
|
}
|
|
559
|
-
function
|
|
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) / (re(r) * re(t));
|
|
564
564
|
return Math.acos(Math.min(Math.max(e, -1), 1));
|
|
565
565
|
}
|
|
566
|
-
function
|
|
567
|
-
const t =
|
|
566
|
+
function bt(r) {
|
|
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
|
}
|
|
570
|
-
function
|
|
571
|
-
const [t, e, i] = r, o =
|
|
572
|
-
return [
|
|
570
|
+
function K(r) {
|
|
571
|
+
const [t, e, i] = r, o = V(Math.asin(i));
|
|
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],
|
|
574
|
+
function di(r, t, e) {
|
|
575
|
+
const i = bt(r), o = bt(t), s = bt(e), [n, a, l] = s, [d, c, h] = (function(T, $) {
|
|
576
|
+
const [Vt, $t, Yt] = T, [Kt, Xt, Ht] = $;
|
|
577
|
+
return [$t * Ht - Yt * Xt, Yt * Kt - Vt * Ht, Vt * Xt - $t * Kt];
|
|
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], S = [-1 * y * C, -1 * m * C, -1 * v * C], I = Y(i, o), E = Y(i, f), L = Y(o, f), M = Y(i, S), N = Y(o, S);
|
|
579
579
|
let _;
|
|
580
|
-
return _ = E <
|
|
580
|
+
return _ = E < M && E < N || L < M && L < N ? f : S, 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 ci(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 jt 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));
|
|
@@ -610,23 +610,23 @@ class Rt extends W {
|
|
|
610
610
|
let g = [1 / 0, 1 / 0], y = 1 / 0, m = 0;
|
|
611
611
|
for (let v of p) {
|
|
612
612
|
const C = v[0], f = v[1];
|
|
613
|
-
let
|
|
614
|
-
const E =
|
|
615
|
-
if (C[0] === u[0] && C[1] === u[1])
|
|
616
|
-
else if (f[0] === u[0] && f[1] === u[1])
|
|
613
|
+
let S, I = 1 / 0;
|
|
614
|
+
const E = O(C[0], C[1]), L = O(f[0], f[1]), M = O(u[0], u[1]);
|
|
615
|
+
if (C[0] === u[0] && C[1] === u[1]) S = C;
|
|
616
|
+
else if (f[0] === u[0] && f[1] === u[1]) S = f;
|
|
617
617
|
else {
|
|
618
|
-
const { x: N, y: _ } =
|
|
619
|
-
|
|
618
|
+
const { x: N, y: _ } = ci(E, L, M), { lng: T, lat: $ } = R(N, _);
|
|
619
|
+
S = [T, $];
|
|
620
620
|
}
|
|
621
|
-
|
|
621
|
+
S && (I = F(M, O(S[0], S[1])), I < y && (g = S, y = I, m = p.indexOf(v)));
|
|
622
622
|
}
|
|
623
623
|
return y === 1 / 0 ? void 0 : { coordinate: g, lineIndex: m, distance: y };
|
|
624
624
|
})(c, l) : this.config.projection === "globe" && (d = (function(u, p) {
|
|
625
625
|
let g = [1 / 0, 1 / 0], y = 1 / 0, m = 0;
|
|
626
626
|
for (let v of p) {
|
|
627
627
|
const C = v[0], f = v[1];
|
|
628
|
-
let
|
|
629
|
-
C[0] === u[0] && C[1] === u[1] ?
|
|
628
|
+
let S, I = 1 / 0;
|
|
629
|
+
C[0] === u[0] && C[1] === u[1] ? S = C : f[0] === u[0] && f[1] === u[1] ? S = f : [S] = di(C, f, u), S && (I = U(u, S), I < y && (g = S, y = I, m = p.indexOf(v)));
|
|
630
630
|
}
|
|
631
631
|
return y === 1 / 0 ? void 0 : { coordinate: g, distance: y, lineIndex: m };
|
|
632
632
|
})(c, l)), !d) return;
|
|
@@ -635,10 +635,10 @@ class Rt extends W {
|
|
|
635
635
|
}), s;
|
|
636
636
|
}
|
|
637
637
|
}
|
|
638
|
-
const
|
|
639
|
-
class
|
|
638
|
+
const hi = { cancel: "Escape", finish: "Enter" }, ui = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
639
|
+
class At 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 = hi, this.snapping = void 0, this.cursors = ui, 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);
|
|
@@ -648,7 +648,7 @@ class zt extends G {
|
|
|
648
648
|
if (e) {
|
|
649
649
|
if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: e } }]);
|
|
650
650
|
else {
|
|
651
|
-
const [i] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [
|
|
651
|
+
const [i] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [P.SNAPPING_POINT]: !0 } }]);
|
|
652
652
|
this.snappedPointId = i;
|
|
653
653
|
}
|
|
654
654
|
t.lng = e[0], t.lat = e[1];
|
|
@@ -658,7 +658,7 @@ class zt extends G {
|
|
|
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, b.Commit), this.store.updateProperty([{ id: this.currentId, property:
|
|
661
|
+
t.coordinates.pop(), this.updateGeometries([...t.coordinates], void 0, b.Commit), this.store.updateProperty([{ id: this.currentId, property: P.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
|
}
|
|
@@ -672,17 +672,17 @@ class zt extends G {
|
|
|
672
672
|
generateInsertCoordinates(t, e) {
|
|
673
673
|
if (!this.insertCoordinates || !this.lastCommittedCoordinates) throw new Error("Not able to insert coordinates");
|
|
674
674
|
if (this.insertCoordinates.strategy !== "amount") throw new Error("Strategy does not exist");
|
|
675
|
-
const i =
|
|
675
|
+
const i = U(t, e) / (this.insertCoordinates.value + 1);
|
|
676
676
|
let o = [];
|
|
677
677
|
return this.projection === "globe" ? o = this.insertPoint.generateInsertionGeodesicCoordinates(t, e, i) : this.projection === "web-mercator" && (o = this.insertPoint.generateInsertionCoordinates(t, e, i)), o;
|
|
678
678
|
}
|
|
679
679
|
createLine(t) {
|
|
680
|
-
const [e] = this.store.create([{ geometry: { type: "LineString", coordinates: [t, t] }, properties: { mode: this.mode, [
|
|
680
|
+
const [e] = this.store.create([{ geometry: { type: "LineString", coordinates: [t, t] }, properties: { mode: this.mode, [P.CURRENTLY_DRAWING]: !0 } }]);
|
|
681
681
|
this.lastCommittedCoordinates = [t, t], this.currentId = e, this.currentCoordinate++, this.setDrawing();
|
|
682
682
|
}
|
|
683
683
|
firstUpdateToLine(t) {
|
|
684
684
|
if (!this.currentId) return;
|
|
685
|
-
const e = this.store.getGeometryCopy(this.currentId).coordinates, [i] = this.store.create([{ geometry: { type: "Point", coordinates: [...t] }, properties: { mode: this.mode } }]);
|
|
685
|
+
const e = this.store.getGeometryCopy(this.currentId).coordinates, [i] = this.store.create([{ geometry: { type: "Point", coordinates: [...t] }, properties: { mode: this.mode, [P.CLOSING_POINT]: !0 } }]);
|
|
686
686
|
this.closingPointId = i, this.setCursor(this.cursors.close);
|
|
687
687
|
const o = [...e, t];
|
|
688
688
|
this.updateGeometries(o, void 0, b.Commit), this.currentCoordinate++;
|
|
@@ -690,13 +690,13 @@ class zt extends G {
|
|
|
690
690
|
updateToLine(t, e) {
|
|
691
691
|
if (!this.currentId) return;
|
|
692
692
|
const i = this.store.getGeometryCopy(this.currentId).coordinates, [o, s] = this.lastCommittedCoordinates ? this.lastCommittedCoordinates[this.lastCommittedCoordinates.length - 1] : i[i.length - 2], { x: n, y: a } = this.project(o, s);
|
|
693
|
-
if (
|
|
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
696
|
this.updateGeometries(l, i[i.length - 1], b.Commit), this.currentCoordinate++;
|
|
697
697
|
}
|
|
698
698
|
registerBehaviors(t) {
|
|
699
|
-
this.coordinateSnapping = new
|
|
699
|
+
this.coordinateSnapping = new Pt(t, new ct(t), new dt(t)), this.insertPoint = new li(t), this.clickBoundingBox = new dt(t), this.pixelDistance = new ct(t), this.lineSnapping = new jt(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new Pt(t, this.pixelDistance, this.clickBoundingBox);
|
|
700
700
|
}
|
|
701
701
|
start() {
|
|
702
702
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -711,12 +711,12 @@ class zt extends G {
|
|
|
711
711
|
const i = this.store.getGeometryCopy(this.currentId).coordinates;
|
|
712
712
|
if (i.pop(), this.closingPointId) {
|
|
713
713
|
const [s, n] = i[i.length - 1], { x: a, y: l } = this.project(s, n);
|
|
714
|
-
|
|
714
|
+
F({ x: a, y: l }, { x: t.containerX, y: t.containerY }) < this.pointerDistance && this.setCursor(this.cursors.close);
|
|
715
715
|
}
|
|
716
716
|
let o = [...i, e];
|
|
717
717
|
if (this.insertCoordinates && this.currentId && this.lastCommittedCoordinates) {
|
|
718
718
|
const s = this.lastCommittedCoordinates[this.lastCommittedCoordinates.length - 1], n = e;
|
|
719
|
-
if (!
|
|
719
|
+
if (!tt(s, n)) {
|
|
720
720
|
const a = this.generateInsertCoordinates(s, n);
|
|
721
721
|
o = [...this.lastCommittedCoordinates.slice(0, -1), ...a, e];
|
|
722
722
|
}
|
|
@@ -758,7 +758,7 @@ class zt extends G {
|
|
|
758
758
|
}
|
|
759
759
|
if (this.editedFeatureId && i) {
|
|
760
760
|
if (!this.editedPointId) {
|
|
761
|
-
const [o] = this.store.create([{ geometry: { type: "Point", coordinates: i }, properties: { mode: this.mode, [
|
|
761
|
+
const [o] = this.store.create([{ geometry: { type: "Point", coordinates: i }, properties: { mode: this.mode, [P.EDITED]: !0 } }]);
|
|
762
762
|
this.editedPointId = o;
|
|
763
763
|
}
|
|
764
764
|
this.setCursor(this.cursors.dragStart), e(!1);
|
|
@@ -769,10 +769,10 @@ class zt extends G {
|
|
|
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: b.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:
|
|
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: b.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: P.EDITED, value: !0 }]));
|
|
773
773
|
}
|
|
774
774
|
onDragEnd(t, e) {
|
|
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:
|
|
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: P.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));
|
|
776
776
|
}
|
|
777
777
|
cleanUp() {
|
|
778
778
|
const t = this.currentId, e = this.closingPointId, i = this.snappedPointId;
|
|
@@ -784,15 +784,15 @@ class zt extends G {
|
|
|
784
784
|
}
|
|
785
785
|
styleFeature(t) {
|
|
786
786
|
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
787
|
-
if (t.type === "Feature" && t.geometry.type === "LineString" && t.properties.mode === this.mode) return e.lineStringColor = this.getHexColorStylingValue(this.styles.lineStringColor, e.lineStringColor, t), e.lineStringWidth = this.getNumericStylingValue(this.styles.lineStringWidth, e.lineStringWidth, t), e.zIndex =
|
|
787
|
+
if (t.type === "Feature" && t.geometry.type === "LineString" && t.properties.mode === this.mode) return e.lineStringColor = this.getHexColorStylingValue(this.styles.lineStringColor, e.lineStringColor, t), e.lineStringWidth = this.getNumericStylingValue(this.styles.lineStringWidth, e.lineStringWidth, t), e.zIndex = j, e;
|
|
788
788
|
if (t.type === "Feature" && t.geometry.type === "Point" && t.properties.mode === this.mode) {
|
|
789
|
-
const i = t.properties[
|
|
789
|
+
const i = t.properties[P.CLOSING_POINT];
|
|
790
790
|
return e.pointColor = this.getHexColorStylingValue(i ? this.styles.closingPointColor : this.styles.snappingPointColor, e.pointColor, t), e.pointWidth = this.getNumericStylingValue(i ? this.styles.closingPointWidth : this.styles.snappingPointWidth, e.pointWidth, t), e.pointOutlineColor = this.getHexColorStylingValue(i ? this.styles.closingPointOutlineColor : this.styles.snappingPointOutlineColor, "#ffffff", t), e.pointOutlineWidth = this.getNumericStylingValue(i ? this.styles.closingPointOutlineWidth : this.styles.snappingPointOutlineWidth, 2, t), e.zIndex = 50, e;
|
|
791
791
|
}
|
|
792
792
|
return e;
|
|
793
793
|
}
|
|
794
794
|
validateFeature(t) {
|
|
795
|
-
return this.validateModeFeature(t, (e) =>
|
|
795
|
+
return this.validateModeFeature(t, (e) => Bt(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 zt extends G {
|
|
|
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 pi = "Feature is not a Point", gi = "Feature has invalid coordinates", yi = "Feature has coordinates with excessive precision";
|
|
814
|
+
function Ee(r, t) {
|
|
815
|
+
return r.geometry.type !== "Point" ? { valid: !1, reason: pi } : Wt(r.geometry.coordinates) ? It(r.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: yi } : { valid: !1, reason: gi };
|
|
816
816
|
}
|
|
817
|
-
const
|
|
818
|
-
class
|
|
817
|
+
const fi = { create: "crosshair", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
818
|
+
class Rt extends A {
|
|
819
819
|
constructor(t) {
|
|
820
|
-
super(t, !0), this.mode = "point", this.cursors =
|
|
820
|
+
super(t, !0), this.mode = "point", this.cursors = fi, 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,13 +850,13 @@ class Vt extends G {
|
|
|
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: b.Finish }).valid || (this.store.updateGeometry([{ id: this.editedFeatureId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property:
|
|
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: b.Finish }).valid || (this.store.updateGeometry([{ id: this.editedFeatureId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: P.EDITED, value: !0 }])));
|
|
854
854
|
}
|
|
855
855
|
onDragEnd(t, e) {
|
|
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:
|
|
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: P.EDITED, value: !1 }]), this.editedFeatureId = void 0, e(!0));
|
|
857
857
|
}
|
|
858
858
|
registerBehaviors(t) {
|
|
859
|
-
this.pixelDistance = new
|
|
859
|
+
this.pixelDistance = new ct(t), this.clickBoundingBox = new dt(t);
|
|
860
860
|
}
|
|
861
861
|
styleFeature(t) {
|
|
862
862
|
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
@@ -867,7 +867,7 @@ class Vt extends G {
|
|
|
867
867
|
return e;
|
|
868
868
|
}
|
|
869
869
|
validateFeature(t) {
|
|
870
|
-
return this.validateModeFeature(t, (e) =>
|
|
870
|
+
return this.validateModeFeature(t, (e) => Ee(e, this.coordinatePrecision));
|
|
871
871
|
}
|
|
872
872
|
onLeftClick(t) {
|
|
873
873
|
const e = { type: "Point", coordinates: [t.lng, t.lat] }, i = { mode: this.mode };
|
|
@@ -895,7 +895,7 @@ class Vt extends G {
|
|
|
895
895
|
this.editedFeatureId === t.id && (this.editedFeatureId = void 0, this.setCursor(this.cursors.create));
|
|
896
896
|
}
|
|
897
897
|
}
|
|
898
|
-
class
|
|
898
|
+
class mi 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
|
}
|
|
@@ -907,7 +907,7 @@ class xi extends W {
|
|
|
907
907
|
create(t, e) {
|
|
908
908
|
if (this.ids.length) throw new Error("Opening and closing points already created");
|
|
909
909
|
if (t.length <= 3) throw new Error("Requires at least 4 coordinates");
|
|
910
|
-
this._startEndPoints = this.store.create([{ geometry: { type: "Point", coordinates: t[0] }, properties: { mode: e, [
|
|
910
|
+
this._startEndPoints = this.store.create([{ geometry: { type: "Point", coordinates: t[0] }, properties: { mode: e, [P.CLOSING_POINT]: !0 } }, { geometry: { type: "Point", coordinates: t[t.length - 2] }, properties: { mode: e, [P.CLOSING_POINT]: !0 } }]);
|
|
911
911
|
}
|
|
912
912
|
delete() {
|
|
913
913
|
this.ids.length && (this.store.delete(this.ids), this._startEndPoints = []);
|
|
@@ -921,7 +921,7 @@ class xi extends W {
|
|
|
921
921
|
return { isClosing: o < this.pointerDistance, isPreviousClosing: s < this.pointerDistance };
|
|
922
922
|
}
|
|
923
923
|
}
|
|
924
|
-
class
|
|
924
|
+
class we extends B {
|
|
925
925
|
constructor(t) {
|
|
926
926
|
super(t);
|
|
927
927
|
}
|
|
@@ -962,10 +962,10 @@ class De extends W {
|
|
|
962
962
|
if (i.coordinatePointIds) return i.coordinatePointIds.map((o, s) => ({ id: o, geometry: x({}, this.store.getGeometryCopy(o), { coordinates: e[s] }) }));
|
|
963
963
|
}
|
|
964
964
|
createPoints(t, e, i) {
|
|
965
|
-
return this.store.create(t.map((o, s) => ({ geometry: { type: "Point", coordinates: o }, properties: { mode: e, [
|
|
965
|
+
return this.store.create(t.map((o, s) => ({ geometry: { type: "Point", coordinates: o }, properties: { mode: e, [P.COORDINATE_POINT]: !0, [P.COORDINATE_POINT_FEATURE_ID]: i, index: s } })));
|
|
966
966
|
}
|
|
967
967
|
setFeatureCoordinatePoints(t, e) {
|
|
968
|
-
this.store.updateProperty([{ id: t, property:
|
|
968
|
+
this.store.updateProperty([{ id: t, property: P.COORDINATE_POINT_IDS, value: e }]);
|
|
969
969
|
}
|
|
970
970
|
deleteCoordinatePoints(t) {
|
|
971
971
|
const e = t.filter((i) => this.store.has(i));
|
|
@@ -976,10 +976,10 @@ class De extends W {
|
|
|
976
976
|
e && (this.deleteCoordinatePoints(e), this.setFeatureCoordinatePoints(t, null));
|
|
977
977
|
}
|
|
978
978
|
}
|
|
979
|
-
const
|
|
980
|
-
class
|
|
979
|
+
const vi = { cancel: "Escape", finish: "Enter" }, Ci = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
980
|
+
class Le 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 = vi, this.cursors = Ci, 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) {
|
|
@@ -987,7 +987,7 @@ class _e extends G {
|
|
|
987
987
|
this.coordinatePoints.createOrUpdate(e);
|
|
988
988
|
});
|
|
989
989
|
else if (this.coordinatePoints && this.showCoordinatePoints === !1) {
|
|
990
|
-
const e = this.store.copyAllWhere((i) => i.mode === this.mode && !!i[
|
|
990
|
+
const e = this.store.copyAllWhere((i) => i.mode === this.mode && !!i[P.COORDINATE_POINT_IDS]);
|
|
991
991
|
this.coordinatePoints.deletePointsByFeatureIds(e.map((i) => i.id));
|
|
992
992
|
}
|
|
993
993
|
}
|
|
@@ -998,13 +998,13 @@ class _e extends G {
|
|
|
998
998
|
if (t.length < 5 || !this.updatePolygonGeometry([...t.slice(0, -2), t[0]], b.Finish)) return;
|
|
999
999
|
const e = this.currentId;
|
|
1000
1000
|
if (this.currentId) {
|
|
1001
|
-
const i =
|
|
1002
|
-
i && this.store.updateGeometry([{ id: this.currentId, geometry: i }]), this.store.updateProperty([{ id: this.currentId, property:
|
|
1001
|
+
const i = pt(this.store.getGeometryCopy(this.currentId));
|
|
1002
|
+
i && (this.store.updateGeometry([{ id: this.currentId, geometry: i }]), this.showCoordinatePoints && this.coordinatePoints.createOrUpdate(this.currentId)), this.store.updateProperty([{ id: this.currentId, property: P.CURRENTLY_DRAWING, value: void 0 }, { id: this.currentId, property: P.COMMITTED_COORDINATE_COUNT, value: void 0 }, { id: this.currentId, property: P.PROVISIONAL_COORDINATE_COUNT, value: void 0 }]);
|
|
1003
1003
|
}
|
|
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
|
|
1007
|
+
this.clickBoundingBox = new dt(t), this.pixelDistance = new ct(t), this.lineSnapping = new jt(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new Pt(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new mi(t, this.pixelDistance), this.coordinatePoints = new we(t);
|
|
1008
1008
|
}
|
|
1009
1009
|
start() {
|
|
1010
1010
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -1017,7 +1017,7 @@ class _e extends G {
|
|
|
1017
1017
|
if (e) {
|
|
1018
1018
|
if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: e } }]);
|
|
1019
1019
|
else {
|
|
1020
|
-
const [i] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [
|
|
1020
|
+
const [i] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [P.SNAPPING_POINT]: !0 } }]);
|
|
1021
1021
|
this.snappedPointId = i;
|
|
1022
1022
|
}
|
|
1023
1023
|
t.lng = e[0], t.lat = e[1];
|
|
@@ -1035,7 +1035,7 @@ class _e extends G {
|
|
|
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.updatePolygonGeometry(i, b.Provisional);
|
|
1038
|
+
this.store.updateProperty([{ id: this.currentId, property: P.PROVISIONAL_COORDINATE_COUNT, value: this.currentCoordinate + 1 }]), this.updatePolygonGeometry(i, b.Provisional);
|
|
1039
1039
|
}
|
|
1040
1040
|
updatePolygonGeometry(t, e) {
|
|
1041
1041
|
if (!this.currentId) return !1;
|
|
@@ -1070,31 +1070,31 @@ class _e extends G {
|
|
|
1070
1070
|
if (this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.currentCoordinate === 0) {
|
|
1071
1071
|
const e = this.snapCoordinate(t);
|
|
1072
1072
|
e && (t.lng = e[0], t.lat = e[1]);
|
|
1073
|
-
const [i] = this.store.create([{ geometry: { type: "Polygon", coordinates: [[[t.lng, t.lat], [t.lng, t.lat], [t.lng, t.lat], [t.lng, t.lat]]] }, properties: { mode: this.mode, [
|
|
1073
|
+
const [i] = this.store.create([{ geometry: { type: "Polygon", coordinates: [[[t.lng, t.lat], [t.lng, t.lat], [t.lng, t.lat], [t.lng, t.lat]]] }, properties: { mode: this.mode, [P.CURRENTLY_DRAWING]: !0, [P.COMMITTED_COORDINATE_COUNT]: this.currentCoordinate + 1, [P.PROVISIONAL_COORDINATE_COUNT]: this.currentCoordinate + 1 } }]);
|
|
1074
1074
|
this.currentId = i, this.currentCoordinate++, this.showCoordinatePoints && this.coordinatePoints.createOrUpdate(i), this.setDrawing();
|
|
1075
1075
|
} else if (this.currentCoordinate === 1 && this.currentId) {
|
|
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 (
|
|
1080
|
-
this.currentCoordinate++;
|
|
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]], b.Commit)) return;
|
|
1080
|
+
this.store.updateProperty([{ id: this.currentId, property: P.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 (
|
|
1086
|
-
this.currentCoordinate === 2 && this.closingPoints.create(i, "polygon"), this.currentCoordinate++;
|
|
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]], b.Commit)) return;
|
|
1086
|
+
this.currentCoordinate === 2 && this.closingPoints.create(i, "polygon"), this.store.updateProperty([{ id: this.currentId, property: P.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);
|
|
1089
1089
|
if (o || i) this.close();
|
|
1090
1090
|
else {
|
|
1091
1091
|
const s = this.snapCoordinate(t);
|
|
1092
|
-
if (s && (t.lng = s[0], t.lat = s[1]),
|
|
1092
|
+
if (s && (t.lng = s[0], t.lat = s[1]), tt([t.lng, t.lat], e[this.currentCoordinate - 1])) return;
|
|
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
1096
|
if (!this.updatePolygonGeometry(n.geometry.coordinates[0], b.Commit)) return;
|
|
1097
|
-
this.currentCoordinate++, this.closingPoints.ids.length && this.closingPoints.update(n.geometry.coordinates[0]);
|
|
1097
|
+
this.store.updateProperty([{ id: this.currentId, property: P.COMMITTED_COORDINATE_COUNT, value: this.currentCoordinate + 1 }]), this.currentCoordinate++, this.closingPoints.ids.length && this.closingPoints.update(n.geometry.coordinates[0]);
|
|
1098
1098
|
}
|
|
1099
1099
|
}
|
|
1100
1100
|
}
|
|
@@ -1117,7 +1117,7 @@ class _e extends G {
|
|
|
1117
1117
|
}
|
|
1118
1118
|
if (this.editedFeatureId && i) {
|
|
1119
1119
|
if (!this.editedPointId) {
|
|
1120
|
-
const [o] = this.store.create([{ geometry: { type: "Point", coordinates: i }, properties: { mode: this.mode, [
|
|
1120
|
+
const [o] = this.store.create([{ geometry: { type: "Point", coordinates: i }, properties: { mode: this.mode, [P.EDITED]: !0 } }]);
|
|
1121
1121
|
this.editedPointId = o;
|
|
1122
1122
|
}
|
|
1123
1123
|
this.setCursor(this.cursors.dragStart), e(!1);
|
|
@@ -1128,10 +1128,10 @@ class _e extends G {
|
|
|
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: b.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:
|
|
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: b.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: P.EDITED, value: !0 }]));
|
|
1132
1132
|
}
|
|
1133
1133
|
onDragEnd(t, e) {
|
|
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:
|
|
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: P.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));
|
|
1135
1135
|
}
|
|
1136
1136
|
cleanUp() {
|
|
1137
1137
|
const t = this.currentId, e = this.snappedPointId, i = this.editedPointId;
|
|
@@ -1144,9 +1144,9 @@ class _e extends G {
|
|
|
1144
1144
|
styleFeature(t) {
|
|
1145
1145
|
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
1146
1146
|
if (t.properties.mode === this.mode) {
|
|
1147
|
-
if (t.geometry.type === "Polygon") return e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex =
|
|
1147
|
+
if (t.geometry.type === "Polygon") return e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = j, e;
|
|
1148
1148
|
if (t.geometry.type === "Point") {
|
|
1149
|
-
const i = t.properties[
|
|
1149
|
+
const i = t.properties[P.EDITED], o = t.properties[P.COORDINATE_POINT], s = i ? "editedPoint" : t.properties[P.CLOSING_POINT] ? "closingPoint" : t.properties[P.SNAPPING_POINT] ? "snappingPoint" : o ? "coordinatePoint" : void 0;
|
|
1150
1150
|
if (!s) return e;
|
|
1151
1151
|
const n = { editedPoint: { width: this.styles.editedPointOutlineWidth, color: this.styles.editedPointColor, outlineColor: this.styles.editedPointOutlineColor, outlineWidth: this.styles.editedPointOutlineWidth }, closingPoint: { width: this.styles.closingPointWidth, color: this.styles.closingPointColor, outlineColor: this.styles.closingPointOutlineColor, outlineWidth: this.styles.closingPointOutlineWidth }, snappingPoint: { width: this.styles.snappingPointWidth, color: this.styles.snappingPointColor, outlineColor: this.styles.snappingPointOutlineColor, outlineWidth: this.styles.snappingPointOutlineWidth }, coordinatePoint: { width: this.styles.coordinatePointWidth, color: this.styles.coordinatePointColor, outlineColor: this.styles.coordinatePointOutlineColor, outlineWidth: this.styles.coordinatePointOutlineWidth } };
|
|
1152
1152
|
return e.pointWidth = this.getNumericStylingValue(n[s].width, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(n[s].color, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(n[s].outlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(n[s].outlineWidth, 2, t), e.zIndex = i ? 40 : o ? 20 : 30, e;
|
|
@@ -1161,13 +1161,13 @@ class _e extends G {
|
|
|
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) => xt(e, this.coordinatePrecision));
|
|
1165
1165
|
}
|
|
1166
1166
|
}
|
|
1167
|
-
const
|
|
1168
|
-
class
|
|
1167
|
+
const Pi = { cancel: "Escape", finish: "Enter" }, Si = { start: "crosshair" };
|
|
1168
|
+
class Fe 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 = Pi, this.cursors = Si, 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));
|
|
@@ -1182,8 +1182,8 @@ class ke extends G {
|
|
|
1182
1182
|
close() {
|
|
1183
1183
|
const t = this.currentRectangleId;
|
|
1184
1184
|
if (t) {
|
|
1185
|
-
const e =
|
|
1186
|
-
e && this.store.updateGeometry([{ id: t, geometry: e }]), this.store.updateProperty([{ id: t, property:
|
|
1185
|
+
const e = pt(this.store.getGeometryCopy(t));
|
|
1186
|
+
e && this.store.updateGeometry([{ id: t, geometry: e }]), this.store.updateProperty([{ id: t, property: P.CURRENTLY_DRAWING, value: void 0 }]);
|
|
1187
1187
|
}
|
|
1188
1188
|
this.center = void 0, this.currentRectangleId = void 0, this.clickCount = 0, this.state === "drawing" && this.setStarted(), t !== void 0 && this.onFinish(t, { mode: this.mode, action: "draw" });
|
|
1189
1189
|
}
|
|
@@ -1196,7 +1196,7 @@ class ke extends G {
|
|
|
1196
1196
|
onClick(t) {
|
|
1197
1197
|
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) {
|
|
1198
1198
|
this.center = [t.lng, t.lat];
|
|
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, [
|
|
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, [P.CURRENTLY_DRAWING]: !0 } }]);
|
|
1200
1200
|
this.currentRectangleId = e, this.clickCount++, this.setDrawing();
|
|
1201
1201
|
} else this.updateRectangle(t, b.Finish), this.close();
|
|
1202
1202
|
}
|
|
@@ -1220,19 +1220,19 @@ class ke extends G {
|
|
|
1220
1220
|
}
|
|
1221
1221
|
styleFeature(t) {
|
|
1222
1222
|
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
1223
|
-
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 =
|
|
1223
|
+
return t.type === "Feature" && t.geometry.type === "Polygon" && t.properties.mode === this.mode && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = j), e;
|
|
1224
1224
|
}
|
|
1225
1225
|
validateFeature(t) {
|
|
1226
|
-
return this.validateModeFeature(t, (e) =>
|
|
1226
|
+
return this.validateModeFeature(t, (e) => ut(e, this.coordinatePrecision));
|
|
1227
1227
|
}
|
|
1228
1228
|
afterFeatureUpdated(t) {
|
|
1229
1229
|
this.currentRectangleId === t.id && (this.center = void 0, this.currentRectangleId = void 0, this.clickCount = 0, this.state === "drawing" && this.setStarted());
|
|
1230
1230
|
}
|
|
1231
1231
|
}
|
|
1232
|
-
class
|
|
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 = H.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 et extends G {
|
|
|
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 = Ee(i, this.coordinatePrecision).valid || xt(i, this.coordinatePrecision).valid || Bt(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
|
|
1278
|
-
const e = r, i = t, o =
|
|
1279
|
-
let n =
|
|
1277
|
+
function Mt(r, t) {
|
|
1278
|
+
const e = r, i = t, o = D(e[1]), s = D(i[1]);
|
|
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
|
-
const a = Math.log(Math.tan(s / 2 + Math.PI / 4) / Math.tan(o / 2 + Math.PI / 4)), l = (
|
|
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 Me(r, t, e) {
|
|
1285
1285
|
let i = t;
|
|
1286
1286
|
t < 0 && (i = -Math.abs(i));
|
|
1287
|
-
const o = i /
|
|
1287
|
+
const o = i / Se, 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 De(r, t, e, i, o) {
|
|
1294
1294
|
const s = i(r[0], r[1]), n = i(t[0], t[1]), { lng: a, lat: l } = o((s.x + n.x) / 2, (s.y + n.y) / 2);
|
|
1295
1295
|
return [w(a, e), w(l, e)];
|
|
1296
1296
|
}
|
|
1297
|
-
function
|
|
1298
|
-
const i =
|
|
1297
|
+
function Ii(r, t, e) {
|
|
1298
|
+
const i = Me(r, 1e3 * U(r, t) / 2, Mt(r, t));
|
|
1299
1299
|
return [w(i[0], e), w(i[1], e)];
|
|
1300
1300
|
}
|
|
1301
|
-
function
|
|
1301
|
+
function ne({ 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 = De(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 = Ii(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 xi 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
|
}
|
|
@@ -1322,22 +1322,22 @@ class Li extends W {
|
|
|
1322
1322
|
}
|
|
1323
1323
|
insert(t, e, i) {
|
|
1324
1324
|
const o = this.store.getGeometryCopy(e), { midPointFeatureId: s, midPointSegment: n } = this.store.getPropertiesCopy(e), a = this.store.getGeometryCopy(s), l = a.type === "Polygon" ? a.coordinates[0] : a.coordinates;
|
|
1325
|
-
l.splice(n + 1, 0, o.coordinates), a.coordinates = a.type === "Polygon" ? [l] : l, this.store.updateGeometry([{ id: s, geometry: a }]), this.store.getPropertiesCopy(t)[
|
|
1325
|
+
l.splice(n + 1, 0, o.coordinates), a.coordinates = a.type === "Polygon" ? [l] : l, this.store.updateGeometry([{ id: s, geometry: a }]), this.store.getPropertiesCopy(t)[P.COORDINATE_POINT_IDS] && this.coordinatePointBehavior.createOrUpdate(t), this.store.delete([...this._midPoints, ...this.selectionPointBehavior.ids]), this.create(l, s, i), this.selectionPointBehavior.create(l, a.type, s);
|
|
1326
1326
|
}
|
|
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 ne({ 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 ne({ featureCoords: t, precision: this.coordinatePrecision, project: this.config.project, unproject: this.config.unproject, projection: this.config.projection }).map((e, i) => ({ id: this._midPoints[i], geometry: { type: "Point", coordinates: e } }));
|
|
1338
1338
|
}
|
|
1339
1339
|
}
|
|
1340
|
-
class
|
|
1340
|
+
class Oi extends B {
|
|
1341
1341
|
constructor(t) {
|
|
1342
1342
|
super(t), this._selectionPoints = [];
|
|
1343
1343
|
}
|
|
@@ -1363,7 +1363,7 @@ class Fi extends W {
|
|
|
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 _e(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 je(r, t) {
|
|
|
1372
1372
|
var i, o, s;
|
|
1373
1373
|
return e;
|
|
1374
1374
|
}
|
|
1375
|
-
const
|
|
1375
|
+
const Dt = (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 jt = (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 bi 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 Mi extends W {
|
|
|
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 = Dt({ 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
|
+
_e([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 Ei 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
|
}
|
|
@@ -1435,8 +1435,8 @@ class Di extends W {
|
|
|
1435
1435
|
const h = s[c];
|
|
1436
1436
|
let u, p;
|
|
1437
1437
|
if (this.config.projection === "web-mercator") {
|
|
1438
|
-
const g =
|
|
1439
|
-
u =
|
|
1438
|
+
const g = O(this.dragPosition[0], this.dragPosition[1]), y = O(o[0], o[1]), m = O(h[0], h[1]), v = { x: g.x - y.x, y: g.y - y.y }, C = m.x - v.x, f = m.y - v.y, { lng: S, lat: I } = R(C, f);
|
|
1439
|
+
u = S, p = I;
|
|
1440
1440
|
} else {
|
|
1441
1441
|
const g = [this.dragPosition[0] - o[0], this.dragPosition[1] - o[1]];
|
|
1442
1442
|
u = h[0] - g[0], p = h[1] - g[1];
|
|
@@ -1451,7 +1451,7 @@ class Di extends W {
|
|
|
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 wi 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 _i extends W {
|
|
|
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 && Tt({ geometry: a }) || i && !i(h, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional }).valid || (this.store.updateGeometry([{ id: s, geometry: a }, ...g, ...y, ...m]), 0));
|
|
1507
1507
|
}
|
|
1508
1508
|
isDragging() {
|
|
1509
1509
|
return this.draggedCoordinate.id !== null;
|
|
@@ -1515,22 +1515,22 @@ class _i extends W {
|
|
|
1515
1515
|
this.draggedCoordinate = { id: null, index: -1 };
|
|
1516
1516
|
}
|
|
1517
1517
|
}
|
|
1518
|
-
function
|
|
1518
|
+
function ae(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 ke = (r, t) => {
|
|
1525
1525
|
if (t === 0 || t === 360 || t === -360) return r;
|
|
1526
|
-
const e = 0.017453292519943295 * t, i = (r.geometry.type === "Polygon" ? r.geometry.coordinates[0] : r.geometry.coordinates).map(([n, a]) =>
|
|
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
|
-
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 }) => [
|
|
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 _t(r) {
|
|
1532
1532
|
const t = (r.geometry.type === "Polygon" ? r.geometry.coordinates[0] : r.geometry.coordinates).map((e) => {
|
|
1533
|
-
const { x: i, y: o } =
|
|
1533
|
+
const { x: i, y: o } = O(e[0], e[1]);
|
|
1534
1534
|
return [i, o];
|
|
1535
1535
|
});
|
|
1536
1536
|
return r.geometry.type === "Polygon" ? (function(e) {
|
|
@@ -1551,7 +1551,7 @@ function Wt(r) {
|
|
|
1551
1551
|
return { x: o / i, y: s / i };
|
|
1552
1552
|
})(t);
|
|
1553
1553
|
}
|
|
1554
|
-
class
|
|
1554
|
+
class Li 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,26 +1566,26 @@ class ki extends W {
|
|
|
1566
1566
|
let n;
|
|
1567
1567
|
const a = { type: "Feature", geometry: o, properties: {} };
|
|
1568
1568
|
if (this.config.projection === "web-mercator") {
|
|
1569
|
-
this.selectedGeometryWebMercatorCentroid || (this.selectedGeometryWebMercatorCentroid =
|
|
1570
|
-
const u =
|
|
1571
|
-
if (n =
|
|
1569
|
+
this.selectedGeometryWebMercatorCentroid || (this.selectedGeometryWebMercatorCentroid = _t(a));
|
|
1570
|
+
const u = O(t.lng, t.lat);
|
|
1571
|
+
if (n = G(this.selectedGeometryWebMercatorCentroid, u), n === 0) return;
|
|
1572
1572
|
if (!this.lastBearing) return void (this.lastBearing = n);
|
|
1573
|
-
|
|
1573
|
+
ke(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 = ae({ geometry: o })), n = Mt(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 = ae(u);
|
|
1580
1580
|
(u.geometry.type === "Polygon" ? u.geometry.coordinates[0] : u.geometry.coordinates).forEach((y) => {
|
|
1581
|
-
const m =
|
|
1582
|
-
f[0] += f[0] -
|
|
1583
|
-
const
|
|
1584
|
-
let N = Math.abs(f[0] -
|
|
1581
|
+
const m = Mt(g, y) + p, v = (function(f, S) {
|
|
1582
|
+
f[0] += f[0] - S[0] > 180 ? -360 : S[0] - f[0] > 180 ? 360 : 0;
|
|
1583
|
+
const I = Se, E = S[1] * Math.PI / 180, L = f[1] * Math.PI / 180, M = L - E;
|
|
1584
|
+
let N = Math.abs(f[0] - S[0]) * Math.PI / 180;
|
|
1585
1585
|
N > Math.PI && (N -= 2 * Math.PI);
|
|
1586
|
-
const _ = Math.log(Math.tan(
|
|
1587
|
-
return Math.sqrt(
|
|
1588
|
-
})(g, y), C =
|
|
1586
|
+
const _ = Math.log(Math.tan(L / 2 + Math.PI / 4) / Math.tan(E / 2 + Math.PI / 4)), T = Math.abs(_) > 1e-11 ? M / _ : Math.cos(E);
|
|
1587
|
+
return Math.sqrt(M * M + T * T * N * N) * I;
|
|
1588
|
+
})(g, y), C = Me(g, v, m);
|
|
1589
1589
|
y[0] = C[0], y[1] = C[1];
|
|
1590
1590
|
});
|
|
1591
1591
|
})(a, -(this.lastBearing - (n + 180)));
|
|
@@ -1599,7 +1599,7 @@ class ki extends W {
|
|
|
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 Fi 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 Ni extends W {
|
|
|
1614
1614
|
this.dragCoordinateResizeBehavior.stopDragging();
|
|
1615
1615
|
}
|
|
1616
1616
|
}
|
|
1617
|
-
function
|
|
1617
|
+
function Ne({ coordinates: r, originX: t, originY: e, xScale: i, yScale: o }) {
|
|
1618
1618
|
i === 1 && o === 1 || r.forEach((s) => {
|
|
1619
|
-
const { x: n, y: a } =
|
|
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 Mi 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,34 +1679,34 @@ class Bi extends W {
|
|
|
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 = _t(i);
|
|
1683
1683
|
if (!a) return null;
|
|
1684
|
-
const l =
|
|
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;
|
|
1686
1686
|
}
|
|
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 = _t(i);
|
|
1691
1691
|
if (!a) return null;
|
|
1692
|
-
const l =
|
|
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;
|
|
1694
1694
|
}
|
|
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
|
-
let n =
|
|
1698
|
-
return n < 0 && (n = this.minimumScale),
|
|
1697
|
+
let n = F(e, o) / F(e, i);
|
|
1698
|
+
return n < 0 && (n = this.minimumScale), Ne({ 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();
|
|
1702
1702
|
if (!e) return null;
|
|
1703
|
-
const { boundingBox: i, updatedCoords: o, selectedCoordinate: s } = e, n =
|
|
1703
|
+
const { boundingBox: i, updatedCoords: o, selectedCoordinate: s } = e, n = O(s[0], s[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] }, c = O(t.lng, t.lat);
|
|
1704
1704
|
return this.scaleFixedWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: n, webMercatorOrigin: d }), o;
|
|
1705
1705
|
}
|
|
1706
1706
|
oppositeWebMercatorDrag(t) {
|
|
1707
1707
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1708
1708
|
if (!e) return null;
|
|
1709
|
-
const { boundingBox: i, updatedCoords: o, selectedCoordinate: s } = e, n =
|
|
1709
|
+
const { boundingBox: i, updatedCoords: o, selectedCoordinate: s } = e, n = O(s[0], s[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] }, c = O(t.lng, t.lat);
|
|
1710
1710
|
return this.scaleWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: n, webMercatorOrigin: d }), o;
|
|
1711
1711
|
}
|
|
1712
1712
|
scaleWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: s }) {
|
|
@@ -1731,14 +1731,14 @@ class Bi extends W {
|
|
|
1731
1731
|
}
|
|
1732
1732
|
performWebMercatorScale(t, e, i, o, s) {
|
|
1733
1733
|
t.forEach((n) => {
|
|
1734
|
-
const { x: a, y: l } =
|
|
1734
|
+
const { x: a, y: l } = O(n[0], n[1]), d = e + (a - e) * o, c = i + (l - i) * s, { lng: h, lat: u } = R(d, c);
|
|
1735
1735
|
n[0] = h, n[1] = u;
|
|
1736
1736
|
});
|
|
1737
1737
|
}
|
|
1738
1738
|
getBBoxWebMercator(t) {
|
|
1739
1739
|
const e = [1 / 0, 1 / 0, -1 / 0, -1 / 0];
|
|
1740
1740
|
(t = t.map((a) => {
|
|
1741
|
-
const { x: l, y: d } =
|
|
1741
|
+
const { x: l, y: d } = O(a[0], a[1]);
|
|
1742
1742
|
return [l, d];
|
|
1743
1743
|
})).forEach(([a, l]) => {
|
|
1744
1744
|
a < e[0] && (e[0] = a), l < e[1] && (e[1] = l), a > e[2] && (e[2] = a), l > e[3] && (e[3] = l);
|
|
@@ -1749,7 +1749,7 @@ class Bi extends W {
|
|
|
1749
1749
|
getIndexesWebMercator(t, e) {
|
|
1750
1750
|
let i, o = 1 / 0;
|
|
1751
1751
|
for (let s = 0; s < t.length; s++) {
|
|
1752
|
-
const n =
|
|
1752
|
+
const n = F({ x: e.x, y: e.y }, { x: t[s][0], y: t[s][1] });
|
|
1753
1753
|
n < o && (i = s, o = n);
|
|
1754
1754
|
}
|
|
1755
1755
|
if (i === void 0) throw new Error("No closest coordinate found");
|
|
@@ -1776,19 +1776,19 @@ class Bi extends W {
|
|
|
1776
1776
|
if (e === "center" ? s = this.centerWebMercatorDrag(t) : e === "opposite" ? s = this.oppositeWebMercatorDrag(t) : e === "center-fixed" ? s = this.centerFixedWebMercatorDrag(t) : e === "opposite-fixed" && (s = this.oppositeFixedWebMercatorDrag(t)), !s) return !1;
|
|
1777
1777
|
for (let c = 0; c < s.length; c++) {
|
|
1778
1778
|
const h = s[c];
|
|
1779
|
-
if (h[0] = w(h[0], this.coordinatePrecision), h[1] = w(h[1], this.coordinatePrecision), !
|
|
1779
|
+
if (h[0] = w(h[0], this.coordinatePrecision), h[1] = w(h[1], this.coordinatePrecision), !It(h, this.coordinatePrecision)) return !1;
|
|
1780
1780
|
}
|
|
1781
1781
|
const n = this.midPoints.getUpdated(s) || [], a = this.selectionPoints.getUpdated(s) || [], l = this.coordinatePoints.getUpdated(o.id, s) || [], d = { type: o.geometry.type, coordinates: o.geometry.type === "Polygon" ? [s] : s };
|
|
1782
1782
|
return !(i && !i({ id: this.draggedCoordinate.id, type: "Feature", geometry: d, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: d }, ...a, ...n, ...l]), 0));
|
|
1783
1783
|
}
|
|
1784
1784
|
}
|
|
1785
|
-
const
|
|
1786
|
-
class
|
|
1785
|
+
const Di = { deselect: "Escape", delete: "Delete", rotate: ["Control", "r"], scale: ["Control", "s"] }, le = { pointerOver: "move", dragStart: "move", dragEnd: "move", insertMidpoint: "crosshair" };
|
|
1786
|
+
class Gt 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 = Di, this.cursors = le, 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) : le, 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 $t extends ii {
|
|
|
1804
1804
|
this._state = "selecting";
|
|
1805
1805
|
}
|
|
1806
1806
|
registerBehaviors(t) {
|
|
1807
|
-
this.pixelDistance = new
|
|
1807
|
+
this.pixelDistance = new ct(t), this.clickBoundingBox = new dt(t), this.featuresAtMouseEvent = new bi(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new Oi(t), this.coordinatePoints = new we(t), this.midPoints = new xi(t, this.selectionPoints, this.coordinatePoints), this.coordinateSnap = new Pt(t, this.pixelDistance, this.clickBoundingBox), this.lineSnap = new jt(t, this.pixelDistance, this.clickBoundingBox), this.rotateFeature = new Li(t, this.selectionPoints, this.midPoints, this.coordinatePoints), this.dragFeature = new Ei(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints, this.coordinatePoints), this.dragCoordinate = new wi(t, this.pixelDistance, this.selectionPoints, this.midPoints, this.coordinatePoints, this.coordinateSnap, this.lineSnap), this.dragCoordinateResizeFeature = new Mi(t, this.pixelDistance, this.selectionPoints, this.midPoints, this.coordinatePoints), this.scaleFeature = new Fi(t, this.dragCoordinateResizeFeature);
|
|
1808
1808
|
}
|
|
1809
1809
|
deselectFeature() {
|
|
1810
1810
|
this.deselect();
|
|
@@ -1951,9 +1951,9 @@ class $t extends ii {
|
|
|
1951
1951
|
if (t.properties.selectionPoint) return e.pointColor = this.getHexColorStylingValue(this.styles.selectionPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.selectionPointOutlineColor, e.pointOutlineColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.selectionPointWidth, e.pointWidth, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.selectionPointOutlineWidth, 2, t), e.zIndex = 30, e;
|
|
1952
1952
|
if (t.properties.midPoint) return e.pointColor = this.getHexColorStylingValue(this.styles.midPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.midPointOutlineColor, e.pointOutlineColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.midPointWidth, 4, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.midPointOutlineWidth, 2, t), e.zIndex = 50, e;
|
|
1953
1953
|
} else if (t.properties[k.SELECTED]) {
|
|
1954
|
-
if (t.geometry.type === "Polygon") return e.polygonFillColor = this.getHexColorStylingValue(this.styles.selectedPolygonColor, e.polygonFillColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.selectedPolygonOutlineWidth, e.polygonOutlineWidth, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.selectedPolygonOutlineColor, e.polygonOutlineColor, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.selectedPolygonFillOpacity, e.polygonFillOpacity, t), e.zIndex =
|
|
1955
|
-
if (t.geometry.type === "LineString") return e.lineStringColor = this.getHexColorStylingValue(this.styles.selectedLineStringColor, e.lineStringColor, t), e.lineStringWidth = this.getNumericStylingValue(this.styles.selectedLineStringWidth, e.lineStringWidth, t), e.zIndex =
|
|
1956
|
-
if (t.geometry.type === "Point") return e.pointWidth = this.getNumericStylingValue(this.styles.selectedPointWidth, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(this.styles.selectedPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.selectedPointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.selectedPointOutlineWidth, e.pointOutlineWidth, t), e.zIndex =
|
|
1954
|
+
if (t.geometry.type === "Polygon") return e.polygonFillColor = this.getHexColorStylingValue(this.styles.selectedPolygonColor, e.polygonFillColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.selectedPolygonOutlineWidth, e.polygonOutlineWidth, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.selectedPolygonOutlineColor, e.polygonOutlineColor, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.selectedPolygonFillOpacity, e.polygonFillOpacity, t), e.zIndex = j, e;
|
|
1955
|
+
if (t.geometry.type === "LineString") return e.lineStringColor = this.getHexColorStylingValue(this.styles.selectedLineStringColor, e.lineStringColor, t), e.lineStringWidth = this.getNumericStylingValue(this.styles.selectedLineStringWidth, e.lineStringWidth, t), e.zIndex = j, e;
|
|
1956
|
+
if (t.geometry.type === "Point") return e.pointWidth = this.getNumericStylingValue(this.styles.selectedPointWidth, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(this.styles.selectedPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.selectedPointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.selectedPointOutlineWidth, e.pointOutlineWidth, t), e.zIndex = j, e;
|
|
1957
1957
|
}
|
|
1958
1958
|
return e;
|
|
1959
1959
|
}
|
|
@@ -1973,9 +1973,9 @@ class $t extends ii {
|
|
|
1973
1973
|
}
|
|
1974
1974
|
}
|
|
1975
1975
|
}
|
|
1976
|
-
class
|
|
1976
|
+
class _i extends A {
|
|
1977
1977
|
constructor(...t) {
|
|
1978
|
-
super(...t), this.type =
|
|
1978
|
+
super(...t), this.type = H.Static, this.mode = "static";
|
|
1979
1979
|
}
|
|
1980
1980
|
start() {
|
|
1981
1981
|
}
|
|
@@ -2001,85 +2001,85 @@ class Wi extends G {
|
|
|
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 Te(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
|
+
Te(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;
|
|
2012
|
-
for (
|
|
2013
|
-
for (
|
|
2012
|
+
for (it(r, e, t), o(r[i], s) > 0 && it(r, e, i); n < a; ) {
|
|
2013
|
+
for (it(r, n, a), n++, a--; o(r[n], s) < 0; ) n++;
|
|
2014
2014
|
for (; o(r[a], s) > 0; ) a--;
|
|
2015
2015
|
}
|
|
2016
|
-
o(r[e], s) === 0 ?
|
|
2016
|
+
o(r[e], s) === 0 ? it(r, e, a) : (a++, it(r, a, i)), a <= t && (e = a + 1), t <= a && (i = a - 1);
|
|
2017
2017
|
}
|
|
2018
2018
|
}
|
|
2019
|
-
function
|
|
2019
|
+
function it(r, t, e) {
|
|
2020
2020
|
const i = r[t];
|
|
2021
2021
|
r[t] = r[e], r[e] = i;
|
|
2022
2022
|
}
|
|
2023
|
-
function
|
|
2024
|
-
|
|
2023
|
+
function J(r, t) {
|
|
2024
|
+
nt(r, 0, r.children.length, t, r);
|
|
2025
2025
|
}
|
|
2026
|
-
function
|
|
2027
|
-
o || (o =
|
|
2026
|
+
function nt(r, t, e, i, o) {
|
|
2027
|
+
o || (o = Z([])), o.minX = 1 / 0, o.minY = 1 / 0, o.maxX = -1 / 0, o.maxY = -1 / 0;
|
|
2028
2028
|
for (let s = t; s < e; s++) {
|
|
2029
2029
|
const n = r.children[s];
|
|
2030
|
-
|
|
2030
|
+
at(o, r.leaf ? i(n) : n);
|
|
2031
2031
|
}
|
|
2032
2032
|
return o;
|
|
2033
2033
|
}
|
|
2034
|
-
function
|
|
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 ki(r, t) {
|
|
2038
2038
|
return r.minX - t.minX;
|
|
2039
2039
|
}
|
|
2040
|
-
function
|
|
2040
|
+
function Ni(r, t) {
|
|
2041
2041
|
return r.minY - t.minY;
|
|
2042
2042
|
}
|
|
2043
|
-
function
|
|
2043
|
+
function Et(r) {
|
|
2044
2044
|
return (r.maxX - r.minX) * (r.maxY - r.minY);
|
|
2045
2045
|
}
|
|
2046
|
-
function
|
|
2046
|
+
function ft(r) {
|
|
2047
2047
|
return r.maxX - r.minX + (r.maxY - r.minY);
|
|
2048
2048
|
}
|
|
2049
|
-
function
|
|
2049
|
+
function Ti(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 wt(r, t) {
|
|
2054
2054
|
return r.minX <= t.minX && r.minY <= t.minY && t.maxX <= r.maxX && t.maxY <= r.maxY;
|
|
2055
2055
|
}
|
|
2056
|
-
function
|
|
2056
|
+
function mt(r, t) {
|
|
2057
2057
|
return t.minX <= r.maxX && t.minY <= r.maxY && t.maxX >= r.minX && t.maxY >= r.minY;
|
|
2058
2058
|
}
|
|
2059
|
-
function
|
|
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 de(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
|
+
Te(r, n, t, e, o), s.push(t, n, n, e);
|
|
2068
2068
|
}
|
|
2069
2069
|
}
|
|
2070
|
-
class
|
|
2070
|
+
class Wi {
|
|
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
|
}
|
|
2074
2074
|
search(t) {
|
|
2075
2075
|
let e = this.data;
|
|
2076
2076
|
const i = [];
|
|
2077
|
-
if (!
|
|
2077
|
+
if (!mt(t, e)) return i;
|
|
2078
2078
|
const o = this.toBBox, s = [];
|
|
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
|
-
|
|
2082
|
+
mt(t, l) && (e.leaf ? i.push(a) : wt(t, l) ? this._all(a, i) : s.push(a));
|
|
2083
2083
|
}
|
|
2084
2084
|
e = s.pop();
|
|
2085
2085
|
}
|
|
@@ -2087,13 +2087,13 @@ class Ui {
|
|
|
2087
2087
|
}
|
|
2088
2088
|
collides(t) {
|
|
2089
2089
|
let e = this.data;
|
|
2090
|
-
if (
|
|
2090
|
+
if (mt(t, e)) {
|
|
2091
2091
|
const i = [];
|
|
2092
2092
|
for (; e; ) {
|
|
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
|
-
if (
|
|
2096
|
-
if (e.leaf ||
|
|
2095
|
+
if (mt(t, n)) {
|
|
2096
|
+
if (e.leaf || wt(t, n)) return !0;
|
|
2097
2097
|
i.push(s);
|
|
2098
2098
|
}
|
|
2099
2099
|
}
|
|
@@ -2122,7 +2122,7 @@ class Ui {
|
|
|
2122
2122
|
this._insert(t, this.data.height - 1);
|
|
2123
2123
|
}
|
|
2124
2124
|
clear() {
|
|
2125
|
-
this.data =
|
|
2125
|
+
this.data = Z([]);
|
|
2126
2126
|
}
|
|
2127
2127
|
remove(t) {
|
|
2128
2128
|
let e = this.data;
|
|
@@ -2133,7 +2133,7 @@ class Ui {
|
|
|
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 || !wt(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) {
|
|
@@ -2153,25 +2153,25 @@ class Ui {
|
|
|
2153
2153
|
_build(t, e, i, o) {
|
|
2154
2154
|
const s = i - e + 1;
|
|
2155
2155
|
let n, a = this._maxEntries;
|
|
2156
|
-
if (s <= a) return n =
|
|
2157
|
-
o || (o = Math.ceil(Math.log(s) / Math.log(a)), a = Math.ceil(s / Math.pow(a, o - 1))), n =
|
|
2156
|
+
if (s <= a) return n = Z(t.slice(e, i + 1)), J(n, this.toBBox), n;
|
|
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
|
+
de(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
|
+
de(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));
|
|
2166
2166
|
}
|
|
2167
2167
|
}
|
|
2168
|
-
return
|
|
2168
|
+
return J(n, this.toBBox), n;
|
|
2169
2169
|
}
|
|
2170
2170
|
_chooseSubtree(t, e, i, o) {
|
|
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 = Et(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];
|
|
@@ -2181,54 +2181,54 @@ class Ui {
|
|
|
2181
2181
|
}
|
|
2182
2182
|
_insert(t, e, i) {
|
|
2183
2183
|
const o = i ? t : this.toBBox(t), s = [], n = this._chooseSubtree(o, this.data, e, s);
|
|
2184
|
-
for (n.children.push(t),
|
|
2184
|
+
for (n.children.push(t), at(n, o); e >= 0 && s[e].children.length > this._maxEntries; ) this._split(s, e), e--;
|
|
2185
2185
|
this._adjustParentBBoxes(o, s, e);
|
|
2186
2186
|
}
|
|
2187
2187
|
_split(t, e) {
|
|
2188
2188
|
const i = t[e], o = i.children.length, s = this._minEntries;
|
|
2189
2189
|
this._chooseSplitAxis(i, s, o);
|
|
2190
|
-
const n = this._chooseSplitIndex(i, s, o), a =
|
|
2191
|
-
a.height = i.height, a.leaf = i.leaf,
|
|
2190
|
+
const n = this._chooseSplitIndex(i, s, o), a = Z(i.children.splice(n, i.children.length - n));
|
|
2191
|
+
a.height = i.height, a.leaf = i.leaf, J(i, this.toBBox), J(a, this.toBBox), e ? t[e - 1].children.push(a) : this._splitRoot(i, a);
|
|
2192
2192
|
}
|
|
2193
2193
|
_splitRoot(t, e) {
|
|
2194
|
-
this.data =
|
|
2194
|
+
this.data = Z([t, e]), this.data.height = t.height + 1, this.data.leaf = !1, J(this.data, this.toBBox);
|
|
2195
2195
|
}
|
|
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 =
|
|
2199
|
+
const l = nt(t, 0, a, this.toBBox), d = nt(t, a, i, this.toBBox), c = Ti(l, d), h = Et(l) + Et(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 : ki, s = t.leaf ? this.compareMinY : Ni;
|
|
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) {
|
|
2209
2209
|
t.children.sort(o);
|
|
2210
|
-
const s = this.toBBox, n =
|
|
2211
|
-
let l =
|
|
2210
|
+
const s = this.toBBox, n = nt(t, 0, e, s), a = nt(t, i - e, i, s);
|
|
2211
|
+
let l = ft(n) + ft(a);
|
|
2212
2212
|
for (let d = e; d < i - e; d++) {
|
|
2213
2213
|
const c = t.children[d];
|
|
2214
|
-
|
|
2214
|
+
at(n, t.leaf ? s(c) : c), l += ft(n);
|
|
2215
2215
|
}
|
|
2216
2216
|
for (let d = i - e - 1; d >= e; d--) {
|
|
2217
2217
|
const c = t.children[d];
|
|
2218
|
-
|
|
2218
|
+
at(a, t.leaf ? s(c) : c), l += ft(a);
|
|
2219
2219
|
}
|
|
2220
2220
|
return l;
|
|
2221
2221
|
}
|
|
2222
2222
|
_adjustParentBBoxes(t, e, i) {
|
|
2223
|
-
for (let o = i; o >= 0; o--)
|
|
2223
|
+
for (let o = i; o >= 0; o--) at(e[o], t);
|
|
2224
2224
|
}
|
|
2225
2225
|
_condense(t) {
|
|
2226
|
-
for (let e, i = t.length - 1; i >= 0; i--) t[i].children.length === 0 ? i > 0 ? (e = t[i - 1].children, e.splice(e.indexOf(t[i]), 1)) : this.clear() :
|
|
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 Bi {
|
|
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 Wi(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 Ri {
|
|
|
2279
2279
|
return this.tree.collides(this.toBBox(t));
|
|
2280
2280
|
}
|
|
2281
2281
|
}
|
|
2282
|
-
const
|
|
2282
|
+
const ji = { 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 Ai {
|
|
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 Bi(), this.tracked = !t || t.tracked !== !1, this.idStrategy = t && t.idStrategy ? t.idStrategy : ji;
|
|
2290
2290
|
}
|
|
2291
2291
|
clone(t) {
|
|
2292
2292
|
return JSON.parse(JSON.stringify(t));
|
|
@@ -2310,10 +2310,10 @@ class Vi {
|
|
|
2310
2310
|
}
|
|
2311
2311
|
if (this.tracked) {
|
|
2312
2312
|
if (l.properties.createdAt) {
|
|
2313
|
-
if (!
|
|
2313
|
+
if (!qt(l.properties.createdAt)) return a.push({ id: l.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
|
|
2314
2314
|
} else l.properties.createdAt = +/* @__PURE__ */ new Date();
|
|
2315
2315
|
if (l.properties.updatedAt) {
|
|
2316
|
-
if (!
|
|
2316
|
+
if (!qt(l.properties.updatedAt)) return a.push({ id: l.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
|
|
2317
2317
|
} else l.properties.updatedAt = +/* @__PURE__ */ new Date();
|
|
2318
2318
|
}
|
|
2319
2319
|
return this.has(d) ? (a.push({ id: d, valid: !1, reason: `Feature already exists with this id: ${d}` }), !1) : (this.store[d] = l, n.push(d), i && i(l), a.push({ id: d, valid: !0 }), !0);
|
|
@@ -2386,23 +2386,23 @@ class Vi {
|
|
|
2386
2386
|
return Object.keys(this.store).length;
|
|
2387
2387
|
}
|
|
2388
2388
|
}
|
|
2389
|
-
const
|
|
2390
|
-
function
|
|
2391
|
-
const i =
|
|
2392
|
-
let o =
|
|
2389
|
+
const Ri = "Feature is not a Polygon or LineString", Gi = "Feature intersects itself", Ui = (r) => r.geometry.type !== "Polygon" && r.geometry.type !== "LineString" ? { valid: !1, reason: Ri } : Tt(r) ? { valid: !1, reason: Gi } : { valid: !0 };
|
|
2390
|
+
function ce(r, t, e) {
|
|
2391
|
+
const i = G(r, t);
|
|
2392
|
+
let o = G(t, e) - i;
|
|
2393
2393
|
return o < 0 && (o += 360), 180 - Math.abs(o - 90 - 90);
|
|
2394
2394
|
}
|
|
2395
|
-
const
|
|
2396
|
-
class
|
|
2395
|
+
const zi = { cancel: "Escape", finish: "Enter" }, Vi = { start: "crosshair", close: "pointer" };
|
|
2396
|
+
class We extends A {
|
|
2397
2397
|
constructor(t) {
|
|
2398
|
-
super(t, !0), this.mode = "angled-rectangle", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents =
|
|
2398
|
+
super(t, !0), this.mode = "angled-rectangle", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = zi, this.cursors = Vi, this.mouseMove = !1, this.updateOptions(t);
|
|
2399
2399
|
}
|
|
2400
2400
|
updateOptions(t) {
|
|
2401
2401
|
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));
|
|
2402
2402
|
}
|
|
2403
2403
|
close() {
|
|
2404
2404
|
if (this.currentId === void 0) return;
|
|
2405
|
-
this.store.updateProperty([{ id: this.currentId, property:
|
|
2405
|
+
this.store.updateProperty([{ id: this.currentId, property: P.CURRENTLY_DRAWING, value: void 0 }]);
|
|
2406
2406
|
const t = this.currentId;
|
|
2407
2407
|
this.currentCoordinate = 0, this.currentId = void 0, this.state === "drawing" && this.setStarted(), this.onFinish(t, { mode: this.mode, action: "draw" });
|
|
2408
2408
|
}
|
|
@@ -2420,11 +2420,11 @@ class Ae extends G {
|
|
|
2420
2420
|
const o = 1 / Math.pow(10, this.coordinatePrecision - 1), s = Math.max(1e-6, o);
|
|
2421
2421
|
i = [e[0], [t.lng, t.lat], [t.lng, t.lat - s], e[0]];
|
|
2422
2422
|
} else if (this.currentCoordinate === 2) {
|
|
2423
|
-
const o = e[0], s = e[1], n =
|
|
2424
|
-
const
|
|
2425
|
-
return
|
|
2426
|
-
})(a, d, c) === "right" ? -90 : 90), v =
|
|
2427
|
-
i = [e[0], e[1], [
|
|
2423
|
+
const o = e[0], s = e[1], n = De(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 = ce(a, l, c), p = h ? 90 - u : ce(a, l, c) - 90, g = F(l, c), y = Math.cos(D(p)) * g, m = G(a, d) + ((function(I, E, L) {
|
|
2424
|
+
const M = (L.x - E.x) * (I.y - E.y) - (L.y - E.y) * (I.x - E.x);
|
|
2425
|
+
return M > 1e-10 ? "left" : M < -1e-10 ? "right" : "left";
|
|
2426
|
+
})(a, d, c) === "right" ? -90 : 90), v = ht(a, y, m), C = ht(d, y, m), f = R(v.x, v.y), S = R(C.x, C.y);
|
|
2427
|
+
i = [e[0], e[1], [S.lng, S.lat], [f.lng, f.lat], e[0]];
|
|
2428
2428
|
}
|
|
2429
2429
|
i && this.updatePolygonGeometry(this.currentId, i, b.Provisional);
|
|
2430
2430
|
}
|
|
@@ -2434,11 +2434,11 @@ class Ae extends G {
|
|
|
2434
2434
|
}
|
|
2435
2435
|
onClick(t) {
|
|
2436
2436
|
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.currentCoordinate > 0 && !this.mouseMove && this.onMouseMove(t), this.mouseMove = !1, this.currentCoordinate === 0) {
|
|
2437
|
-
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, [
|
|
2437
|
+
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, [P.CURRENTLY_DRAWING]: !0 } }]);
|
|
2438
2438
|
this.currentId = e, this.currentCoordinate++, this.setDrawing();
|
|
2439
2439
|
} else if (this.currentCoordinate === 1 && this.currentId) {
|
|
2440
2440
|
const e = this.store.getGeometryCopy(this.currentId);
|
|
2441
|
-
if (
|
|
2441
|
+
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]], b.Commit)) return;
|
|
2442
2442
|
this.currentCoordinate++;
|
|
2443
2443
|
} else this.currentCoordinate === 2 && this.currentId && this.close();
|
|
2444
2444
|
}
|
|
@@ -2466,30 +2466,30 @@ class Ae extends G {
|
|
|
2466
2466
|
}
|
|
2467
2467
|
styleFeature(t) {
|
|
2468
2468
|
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
2469
|
-
return t.properties.mode === this.mode && t.geometry.type === "Polygon" && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex =
|
|
2469
|
+
return t.properties.mode === this.mode && t.geometry.type === "Polygon" && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = j), e;
|
|
2470
2470
|
}
|
|
2471
2471
|
validateFeature(t) {
|
|
2472
|
-
return this.validateModeFeature(t, (e) =>
|
|
2472
|
+
return this.validateModeFeature(t, (e) => ut(e, this.coordinatePrecision));
|
|
2473
2473
|
}
|
|
2474
2474
|
afterFeatureUpdated(t) {
|
|
2475
2475
|
this.currentId === t.id && (this.currentId = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted());
|
|
2476
2476
|
}
|
|
2477
2477
|
}
|
|
2478
|
-
function
|
|
2478
|
+
function Be(r, t, e) {
|
|
2479
2479
|
return (t.x - r.x) * (e.y - r.y) - (t.y - r.y) * (e.x - r.x) <= 0;
|
|
2480
2480
|
}
|
|
2481
|
-
const
|
|
2482
|
-
class
|
|
2481
|
+
const $i = { cancel: "Escape", finish: "Enter" }, Yi = { start: "crosshair", close: "pointer" };
|
|
2482
|
+
class je extends A {
|
|
2483
2483
|
constructor(t) {
|
|
2484
|
-
super(t, !0), this.mode = "sector", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents =
|
|
2484
|
+
super(t, !0), this.mode = "sector", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = $i, this.direction = void 0, this.arcPoints = 64, this.cursors = Yi, this.mouseMove = !1, this.updateOptions(t);
|
|
2485
2485
|
}
|
|
2486
2486
|
updateOptions(t) {
|
|
2487
2487
|
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);
|
|
2488
2488
|
}
|
|
2489
2489
|
close() {
|
|
2490
2490
|
if (this.currentId === void 0) return;
|
|
2491
|
-
const t =
|
|
2492
|
-
t && this.store.updateGeometry([{ id: this.currentId, geometry: t }]), this.store.updateProperty([{ id: this.currentId, property:
|
|
2491
|
+
const t = pt(this.store.getGeometryCopy(this.currentId));
|
|
2492
|
+
t && this.store.updateGeometry([{ id: this.currentId, geometry: t }]), this.store.updateProperty([{ id: this.currentId, property: P.CURRENTLY_DRAWING, value: void 0 }]);
|
|
2493
2493
|
const e = this.currentId;
|
|
2494
2494
|
this.currentCoordinate = 0, this.currentId = void 0, this.direction = void 0, this.state === "drawing" && this.setStarted(), this.onFinish(e, { mode: this.mode, action: "draw" });
|
|
2495
2495
|
}
|
|
@@ -2507,19 +2507,19 @@ class Re extends G {
|
|
|
2507
2507
|
const o = 1 / Math.pow(10, this.coordinatePrecision - 1), s = Math.max(1e-6, o);
|
|
2508
2508
|
i = [e[0], [t.lng, t.lat], [t.lng, t.lat - s], e[0]];
|
|
2509
2509
|
} else if (this.currentCoordinate === 2) {
|
|
2510
|
-
const o = e[0], s = e[1], n = [t.lng, t.lat], a =
|
|
2510
|
+
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]);
|
|
2511
2511
|
if (this.direction === void 0) {
|
|
2512
|
-
const f =
|
|
2512
|
+
const f = Be(a, l, d);
|
|
2513
2513
|
this.direction = f ? "clockwise" : "anticlockwise";
|
|
2514
2514
|
}
|
|
2515
|
-
const c =
|
|
2515
|
+
const c = F(a, l), h = G(a, l), u = G(a, d), p = this.arcPoints, g = [o], y = X(h), m = X(u);
|
|
2516
2516
|
let v;
|
|
2517
2517
|
this.direction === "anticlockwise" ? (v = m - y, v < 0 && (v += 360)) : (v = y - m, v < 0 && (v += 360));
|
|
2518
2518
|
const C = (this.direction === "anticlockwise" ? 1 : -1) * v / p;
|
|
2519
2519
|
g.push(s);
|
|
2520
2520
|
for (let f = 0; f <= p; f++) {
|
|
2521
|
-
const
|
|
2522
|
-
|
|
2521
|
+
const S = ht(a, c, y + f * C), { lng: I, lat: E } = R(S.x, S.y), L = [w(I, this.coordinatePrecision), w(E, this.coordinatePrecision)];
|
|
2522
|
+
L[0] !== g[g.length - 1][0] && L[1] !== g[g.length - 1][1] && g.push(L);
|
|
2523
2523
|
}
|
|
2524
2524
|
g.push(o), i = [...g];
|
|
2525
2525
|
}
|
|
@@ -2531,11 +2531,11 @@ class Re extends G {
|
|
|
2531
2531
|
}
|
|
2532
2532
|
onClick(t) {
|
|
2533
2533
|
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.currentCoordinate > 0 && !this.mouseMove && this.onMouseMove(t), this.mouseMove = !1, this.currentCoordinate === 0) {
|
|
2534
|
-
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, [
|
|
2534
|
+
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, [P.CURRENTLY_DRAWING]: !0 } }]);
|
|
2535
2535
|
this.currentId = e, this.currentCoordinate++, this.setDrawing();
|
|
2536
2536
|
} else if (this.currentCoordinate === 1 && this.currentId) {
|
|
2537
2537
|
const e = this.store.getGeometryCopy(this.currentId);
|
|
2538
|
-
if (
|
|
2538
|
+
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]], b.Commit)) return;
|
|
2539
2539
|
this.currentCoordinate++;
|
|
2540
2540
|
} else this.currentCoordinate === 2 && this.currentId && this.close();
|
|
2541
2541
|
}
|
|
@@ -2559,19 +2559,19 @@ class Re extends G {
|
|
|
2559
2559
|
}
|
|
2560
2560
|
styleFeature(t) {
|
|
2561
2561
|
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
2562
|
-
return t.properties.mode === this.mode && t.geometry.type === "Polygon" && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex =
|
|
2562
|
+
return t.properties.mode === this.mode && t.geometry.type === "Polygon" && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = j), e;
|
|
2563
2563
|
}
|
|
2564
2564
|
validateFeature(t) {
|
|
2565
|
-
return this.validateModeFeature(t, (e) =>
|
|
2565
|
+
return this.validateModeFeature(t, (e) => ut(e, this.coordinatePrecision));
|
|
2566
2566
|
}
|
|
2567
2567
|
afterFeatureUpdated(t) {
|
|
2568
2568
|
this.currentId === t.id && (this.currentId = void 0, this.direction = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted());
|
|
2569
2569
|
}
|
|
2570
2570
|
}
|
|
2571
|
-
const
|
|
2572
|
-
class
|
|
2571
|
+
const Ki = { cancel: "Escape", finish: "Enter" }, Xi = { start: "crosshair", close: "pointer" };
|
|
2572
|
+
class Ae extends A {
|
|
2573
2573
|
constructor(t) {
|
|
2574
|
-
super(t, !0), this.mode = "sensor", this.currentCoordinate = 0, this.currentId = void 0, this.currentInitialArcId = void 0, this.currentStartingPointId = void 0, this.keyEvents =
|
|
2574
|
+
super(t, !0), this.mode = "sensor", this.currentCoordinate = 0, this.currentId = void 0, this.currentInitialArcId = void 0, this.currentStartingPointId = void 0, this.keyEvents = Ki, this.direction = void 0, this.arcPoints = 64, this.cursors = Xi, this.mouseMove = !1, this.updateOptions(t);
|
|
2575
2575
|
}
|
|
2576
2576
|
updateOptions(t) {
|
|
2577
2577
|
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);
|
|
@@ -2580,8 +2580,8 @@ class ze extends G {
|
|
|
2580
2580
|
if (this.currentStartingPointId === void 0) return;
|
|
2581
2581
|
const t = this.currentStartingPointId, e = this.currentInitialArcId, i = this.currentId;
|
|
2582
2582
|
if (t && this.store.delete([t]), e && this.store.delete([e]), this.currentId) {
|
|
2583
|
-
const o =
|
|
2584
|
-
o && this.store.updateGeometry([{ id: this.currentId, geometry: o }]), this.store.updateProperty([{ id: this.currentId, property:
|
|
2583
|
+
const o = pt(this.store.getGeometryCopy(this.currentId));
|
|
2584
|
+
o && this.store.updateGeometry([{ id: this.currentId, geometry: o }]), this.store.updateProperty([{ id: this.currentId, property: P.CURRENTLY_DRAWING, value: void 0 }]);
|
|
2585
2585
|
}
|
|
2586
2586
|
this.currentCoordinate = 0, this.currentStartingPointId = void 0, this.currentInitialArcId = void 0, this.currentId = void 0, this.direction = void 0, this.state === "drawing" && this.setStarted(), i && this.onFinish(i, { mode: this.mode, action: "draw" });
|
|
2587
2587
|
}
|
|
@@ -2594,31 +2594,31 @@ class ze extends G {
|
|
|
2594
2594
|
onMouseMove(t) {
|
|
2595
2595
|
if (this.mouseMove = !0, this.setCursor(this.cursors.start), this.currentInitialArcId !== void 0 && this.currentStartingPointId !== void 0 && this.currentCoordinate !== 0) {
|
|
2596
2596
|
if (this.currentCoordinate === 2) {
|
|
2597
|
-
const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = [t.lng, t.lat], n =
|
|
2597
|
+
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);
|
|
2598
2598
|
if (this.direction === void 0) {
|
|
2599
|
-
const C =
|
|
2599
|
+
const C = Be(l, n, a);
|
|
2600
2600
|
this.direction = C ? "clockwise" : "anticlockwise";
|
|
2601
2601
|
}
|
|
2602
|
-
const c =
|
|
2602
|
+
const c = G(l, n), h = G(l, a), u = this.arcPoints, p = [o], g = X(c), y = X(h);
|
|
2603
2603
|
let m;
|
|
2604
2604
|
this.direction === "anticlockwise" ? (m = y - g, m < 0 && (m += 360)) : (m = g - y, m < 0 && (m += 360));
|
|
2605
2605
|
const v = (this.direction === "anticlockwise" ? 1 : -1) * m / u;
|
|
2606
2606
|
for (let C = 0; C <= u; C++) {
|
|
2607
|
-
const f =
|
|
2607
|
+
const f = ht(l, d, g + C * v), { lng: S, lat: I } = R(f.x, f.y), E = [w(S, this.coordinatePrecision), w(I, this.coordinatePrecision)];
|
|
2608
2608
|
E[0] !== p[p.length - 1][0] && E[1] !== p[p.length - 1][1] && p.push(E);
|
|
2609
2609
|
}
|
|
2610
2610
|
this.updateLineStringGeometry(this.currentInitialArcId, p, b.Provisional);
|
|
2611
2611
|
} else if (this.currentCoordinate === 3) {
|
|
2612
2612
|
const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates;
|
|
2613
2613
|
if (e.length < 2 || !this.direction) return;
|
|
2614
|
-
const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = e[e.length - 1], n =
|
|
2614
|
+
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);
|
|
2615
2615
|
if (this.notInSector({ normalizedCursor: v, normalizedStart: y, normalizedEnd: m, direction: this.direction })) return;
|
|
2616
|
-
const C = this.getDeltaBearing(this.direction, y, m), f = this.arcPoints,
|
|
2617
|
-
for (let
|
|
2618
|
-
const
|
|
2619
|
-
|
|
2616
|
+
const C = this.getDeltaBearing(this.direction, y, m), f = this.arcPoints, S = (this.direction === "anticlockwise" ? 1 : -1) * C / f, I = F(d, h), E = [];
|
|
2617
|
+
for (let L = 0; L <= f; L++) {
|
|
2618
|
+
const M = ht(d, I, y + L * S), { lng: N, lat: _ } = R(M.x, M.y), T = [w(N, this.coordinatePrecision), w(_, this.coordinatePrecision)];
|
|
2619
|
+
T[0] !== e[e.length - 1][0] && T[1] !== e[e.length - 1][1] && E.unshift(T);
|
|
2620
2620
|
}
|
|
2621
|
-
e.push(...E), e.push(e[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, e, b.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [e] }, properties: { mode: this.mode, [
|
|
2621
|
+
e.push(...E), e.push(e[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, e, b.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [e] }, properties: { mode: this.mode, [P.CURRENTLY_DRAWING]: !0 } }]);
|
|
2622
2622
|
}
|
|
2623
2623
|
}
|
|
2624
2624
|
}
|
|
@@ -2659,10 +2659,10 @@ class ze extends G {
|
|
|
2659
2659
|
}
|
|
2660
2660
|
styleFeature(t) {
|
|
2661
2661
|
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
2662
|
-
return t.properties.mode === this.mode && (t.geometry.type === "Polygon" ? (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex =
|
|
2662
|
+
return t.properties.mode === this.mode && (t.geometry.type === "Polygon" ? (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = j) : t.geometry.type === "LineString" ? (e.lineStringColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.lineStringWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.zIndex = j) : t.geometry.type === "Point" && (e.pointColor = this.getHexColorStylingValue(this.styles.centerPointColor, e.pointColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.centerPointWidth, e.pointWidth, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.centerPointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.centerPointOutlineWidth, e.pointOutlineWidth, t), e.zIndex = 20)), e;
|
|
2663
2663
|
}
|
|
2664
2664
|
validateFeature(t) {
|
|
2665
|
-
return this.validateModeFeature(t, (e) =>
|
|
2665
|
+
return this.validateModeFeature(t, (e) => ut(e, this.coordinatePrecision));
|
|
2666
2666
|
}
|
|
2667
2667
|
afterFeatureUpdated(t) {
|
|
2668
2668
|
this.currentId === t.id && (this.currentStartingPointId && this.store.delete([this.currentStartingPointId]), this.currentInitialArcId && this.store.delete([this.currentInitialArcId]), this.currentStartingPointId = void 0, this.direction = void 0, this.currentId = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted());
|
|
@@ -2675,7 +2675,7 @@ class ze extends G {
|
|
|
2675
2675
|
return o === "clockwise" ? e <= i ? t >= e && t <= i : t >= e || t <= i : e >= i ? t <= e && t >= i : t <= e || t >= i;
|
|
2676
2676
|
}
|
|
2677
2677
|
}
|
|
2678
|
-
class
|
|
2678
|
+
class q {
|
|
2679
2679
|
constructor({ name: t, callback: e, unregister: i, register: o }) {
|
|
2680
2680
|
this.name = void 0, this.callback = void 0, this.registered = !1, this.register = void 0, this.unregister = void 0, this.name = t, this.register = () => {
|
|
2681
2681
|
this.registered || (this.registered = !0, o(e));
|
|
@@ -2684,7 +2684,7 @@ class Q {
|
|
|
2684
2684
|
}, this.callback = e;
|
|
2685
2685
|
}
|
|
2686
2686
|
}
|
|
2687
|
-
var
|
|
2687
|
+
var Hi = { __proto__: null, TerraDrawBaseAdapter: class {
|
|
2688
2688
|
constructor(r) {
|
|
2689
2689
|
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;
|
|
2690
2690
|
}
|
|
@@ -2710,7 +2710,7 @@ var to = { __proto__: null, TerraDrawBaseAdapter: class {
|
|
|
2710
2710
|
return this._coordinatePrecision;
|
|
2711
2711
|
}
|
|
2712
2712
|
getAdapterListeners() {
|
|
2713
|
-
return [new
|
|
2713
|
+
return [new q({ name: "pointerdown", callback: (r) => {
|
|
2714
2714
|
if (!this._currentModeCallbacks || !r.isPrimary) return;
|
|
2715
2715
|
const t = this.getDrawEventFromEvent(r);
|
|
2716
2716
|
t && (this._dragState = "pre-dragging", this._lastDrawEvent = t);
|
|
@@ -2718,14 +2718,14 @@ var to = { __proto__: null, TerraDrawBaseAdapter: class {
|
|
|
2718
2718
|
this.getMapEventElement().addEventListener("pointerdown", r);
|
|
2719
2719
|
}, unregister: (r) => {
|
|
2720
2720
|
this.getMapEventElement().removeEventListener("pointerdown", r);
|
|
2721
|
-
} }), new
|
|
2721
|
+
} }), new q({ name: "pointermove", callback: (r) => {
|
|
2722
2722
|
if (!this._currentModeCallbacks || !r.isPrimary) return;
|
|
2723
2723
|
r.preventDefault();
|
|
2724
2724
|
const t = this.getDrawEventFromEvent(r);
|
|
2725
2725
|
if (t) if (this._dragState === "not-dragging") this._currentModeCallbacks.onMouseMove(t), this._lastDrawEvent = t;
|
|
2726
2726
|
else if (this._dragState === "pre-dragging") {
|
|
2727
2727
|
if (!this._lastDrawEvent) return;
|
|
2728
|
-
const e = { x: this._lastDrawEvent.containerX, y: this._lastDrawEvent.containerY }, i = { x: t.containerX, y: t.containerY }, o = this._currentModeCallbacks.getState(), s =
|
|
2728
|
+
const e = { x: this._lastDrawEvent.containerX, y: this._lastDrawEvent.containerY }, i = { x: t.containerX, y: t.containerY }, o = this._currentModeCallbacks.getState(), s = F(e, i);
|
|
2729
2729
|
let n = !1;
|
|
2730
2730
|
if (n = o === "drawing" ? s < this._minPixelDragDistanceDrawing : o === "selecting" ? s < this._minPixelDragDistanceSelecting : s < this._minPixelDragDistance, n) return;
|
|
2731
2731
|
this._nextKeyUpIsContextMenu = !1, this._dragState = "dragging", this._currentModeCallbacks.onDragStart(t, (a) => {
|
|
@@ -2738,13 +2738,13 @@ var to = { __proto__: null, TerraDrawBaseAdapter: class {
|
|
|
2738
2738
|
this.getMapEventElement().addEventListener("pointermove", r);
|
|
2739
2739
|
}, unregister: (r) => {
|
|
2740
2740
|
this.getMapEventElement().removeEventListener("pointermove", r);
|
|
2741
|
-
} }), new
|
|
2741
|
+
} }), new q({ name: "contextmenu", callback: (r) => {
|
|
2742
2742
|
this._currentModeCallbacks && (r.preventDefault(), this._nextKeyUpIsContextMenu = !0);
|
|
2743
2743
|
}, register: (r) => {
|
|
2744
2744
|
this.getMapEventElement().addEventListener("contextmenu", r);
|
|
2745
2745
|
}, unregister: (r) => {
|
|
2746
2746
|
this.getMapEventElement().removeEventListener("contextmenu", r);
|
|
2747
|
-
} }), new
|
|
2747
|
+
} }), new q({ name: "pointerup", callback: (r) => {
|
|
2748
2748
|
if (!this._currentModeCallbacks || r.target !== this.getMapEventElement() || !r.isPrimary) return;
|
|
2749
2749
|
const t = this.getDrawEventFromEvent(r);
|
|
2750
2750
|
t && (this._dragState === "dragging" ? this._currentModeCallbacks.onDragEnd(t, (e) => {
|
|
@@ -2754,13 +2754,13 @@ var to = { __proto__: null, TerraDrawBaseAdapter: class {
|
|
|
2754
2754
|
this.getMapEventElement().addEventListener("pointerup", r);
|
|
2755
2755
|
}, unregister: (r) => {
|
|
2756
2756
|
this.getMapEventElement().removeEventListener("pointerup", r);
|
|
2757
|
-
} }), new
|
|
2757
|
+
} }), new q({ name: "keyup", callback: (r) => {
|
|
2758
2758
|
this._currentModeCallbacks && (this._heldKeys.delete(r.key), this._currentModeCallbacks.onKeyUp({ key: r.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => r.preventDefault() }));
|
|
2759
2759
|
}, register: (r) => {
|
|
2760
2760
|
this.getMapEventElement().addEventListener("keyup", r);
|
|
2761
2761
|
}, unregister: (r) => {
|
|
2762
2762
|
this.getMapEventElement().removeEventListener("keyup", r);
|
|
2763
|
-
} }), new
|
|
2763
|
+
} }), new q({ name: "keydown", callback: (r) => {
|
|
2764
2764
|
this._currentModeCallbacks && (this._heldKeys.add(r.key), this._currentModeCallbacks.onKeyDown({ key: r.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => r.preventDefault() }));
|
|
2765
2765
|
}, register: (r) => {
|
|
2766
2766
|
this.getMapEventElement().addEventListener("keydown", r);
|
|
@@ -2774,17 +2774,17 @@ var to = { __proto__: null, TerraDrawBaseAdapter: class {
|
|
|
2774
2774
|
}), this.clear(), this._currentModeCallbacks = void 0;
|
|
2775
2775
|
}
|
|
2776
2776
|
} };
|
|
2777
|
-
const
|
|
2778
|
-
class
|
|
2777
|
+
const Ji = { cancel: "Escape", finish: "Enter" }, qi = { start: "crosshair", close: "pointer" };
|
|
2778
|
+
class Re extends A {
|
|
2779
2779
|
constructor(t) {
|
|
2780
|
-
super(t, !0), this.mode = "freehand-linestring", this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.minDistance = 20, this.keyEvents =
|
|
2780
|
+
super(t, !0), this.mode = "freehand-linestring", this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.minDistance = 20, this.keyEvents = Ji, this.cursors = qi, this.preventNewFeature = !1, this.updateOptions(t);
|
|
2781
2781
|
}
|
|
2782
2782
|
updateOptions(t) {
|
|
2783
2783
|
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));
|
|
2784
2784
|
}
|
|
2785
2785
|
close() {
|
|
2786
2786
|
if (this.currentId === void 0) return;
|
|
2787
|
-
this.currentId && this.store.updateProperty([{ id: this.currentId, property:
|
|
2787
|
+
this.currentId && this.store.updateProperty([{ id: this.currentId, property: P.CURRENTLY_DRAWING, value: void 0 }]);
|
|
2788
2788
|
const t = this.currentId;
|
|
2789
2789
|
if (this.validate && t) {
|
|
2790
2790
|
const e = this.store.getGeometryCopy(t);
|
|
@@ -2800,7 +2800,7 @@ class Ve extends G {
|
|
|
2800
2800
|
}
|
|
2801
2801
|
onMouseMove(t) {
|
|
2802
2802
|
if (this.currentId === void 0 || this.startingClick === !1) return void this.setCursor(this.cursors.start);
|
|
2803
|
-
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 =
|
|
2803
|
+
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 });
|
|
2804
2804
|
if (this.setCursor(p < this.pointerDistance ? this.cursors.close : this.cursors.start), l < this.minDistance) return;
|
|
2805
2805
|
const g = { type: "LineString", coordinates: [...e.coordinates, [t.lng, t.lat]] };
|
|
2806
2806
|
this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: g, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Provisional }).valid || (this.store.updateGeometry([{ id: this.currentId, geometry: g }]), this.closingPointId && this.store.updateGeometry([{ id: this.closingPointId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]));
|
|
@@ -2809,7 +2809,7 @@ class Ve extends G {
|
|
|
2809
2809
|
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)) {
|
|
2810
2810
|
if (this.preventNewFeature) return;
|
|
2811
2811
|
if (this.startingClick === !1) {
|
|
2812
|
-
const [e, i] = this.store.create([{ geometry: { type: "LineString", coordinates: [[t.lng, t.lat], [t.lng, t.lat]] }, properties: { mode: this.mode, [
|
|
2812
|
+
const [e, i] = this.store.create([{ geometry: { type: "LineString", coordinates: [[t.lng, t.lat], [t.lng, t.lat]] }, properties: { mode: this.mode, [P.CURRENTLY_DRAWING]: !0 } }, { geometry: { type: "Point", coordinates: [t.lng, t.lat] }, properties: { mode: this.mode, [P.CLOSING_POINT]: !0 } }]);
|
|
2813
2813
|
return this.currentId = e, this.closingPointId = i, this.startingClick = !0, void (this.state !== "drawing" && this.setDrawing());
|
|
2814
2814
|
}
|
|
2815
2815
|
this.close();
|
|
@@ -2836,29 +2836,44 @@ class Ve extends G {
|
|
|
2836
2836
|
}
|
|
2837
2837
|
styleFeature(t) {
|
|
2838
2838
|
const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
2839
|
-
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 =
|
|
2839
|
+
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);
|
|
2840
2840
|
}
|
|
2841
2841
|
validateFeature(t) {
|
|
2842
|
-
return this.validateModeFeature(t, (e) =>
|
|
2842
|
+
return this.validateModeFeature(t, (e) => Bt(e, this.coordinatePrecision));
|
|
2843
2843
|
}
|
|
2844
2844
|
afterFeatureUpdated(t) {
|
|
2845
2845
|
this.currentId === t.id && (this.closingPointId && this.store.delete([this.closingPointId]), this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0);
|
|
2846
2846
|
}
|
|
2847
2847
|
}
|
|
2848
|
-
|
|
2848
|
+
function kt(r) {
|
|
2849
|
+
if (r === null || typeof r == "boolean" || typeof r == "string") return !0;
|
|
2850
|
+
if (r === void 0) return !1;
|
|
2851
|
+
if (typeof r == "number") return Number.isFinite(r);
|
|
2852
|
+
if (typeof r == "bigint" || typeof r == "symbol" || typeof r == "function" || r instanceof RegExp || r instanceof Map || r instanceof Set || r instanceof Date) return !1;
|
|
2853
|
+
if (typeof r == "object" && r !== null && !Array.isArray(r)) {
|
|
2854
|
+
const t = Object.getPrototypeOf(r);
|
|
2855
|
+
if (t !== Object.prototype && t !== null) return !1;
|
|
2856
|
+
}
|
|
2857
|
+
if (ArrayBuffer.isView(r) && !(r instanceof DataView)) return !1;
|
|
2858
|
+
if (Array.isArray(r)) {
|
|
2859
|
+
for (const t of r) if (!kt(t)) return !1;
|
|
2860
|
+
}
|
|
2861
|
+
return typeof r == "object" && Object.keys(r).every((t) => typeof t == "string" && kt(r[t]));
|
|
2862
|
+
}
|
|
2863
|
+
class Zi {
|
|
2849
2864
|
constructor(t) {
|
|
2850
|
-
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
|
|
2865
|
+
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 _i();
|
|
2851
2866
|
const e = /* @__PURE__ */ new Set(), i = t.modes.reduce((c, h) => {
|
|
2852
2867
|
if (e.has(h.mode)) throw new Error(`There is already a ${h.mode} mode provided`);
|
|
2853
2868
|
return e.add(h.mode), c[h.mode] = h, c;
|
|
2854
2869
|
}, {}), o = Object.keys(i);
|
|
2855
2870
|
if (o.length === 0) throw new Error("No modes provided");
|
|
2856
2871
|
o.forEach((c) => {
|
|
2857
|
-
if (i[c].type ===
|
|
2872
|
+
if (i[c].type === H.Select) {
|
|
2858
2873
|
if (this._instanceSelectMode) throw new Error("only one type of select mode can be provided");
|
|
2859
2874
|
this._instanceSelectMode = c;
|
|
2860
2875
|
}
|
|
2861
|
-
}), this._modes = x({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new
|
|
2876
|
+
}), this._modes = x({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new Ai({ tracked: !!t.tracked, idStrategy: t.idStrategy ? t.idStrategy : void 0 });
|
|
2862
2877
|
const s = (c) => {
|
|
2863
2878
|
const h = [], u = this._store.copyAll().filter((p) => !c.includes(p.id) || (h.push(p), !1));
|
|
2864
2879
|
return { changed: h, unchanged: u };
|
|
@@ -2902,27 +2917,27 @@ class oo {
|
|
|
2902
2917
|
}), t;
|
|
2903
2918
|
}
|
|
2904
2919
|
featuresAtLocation({ lng: t, lat: e }, i) {
|
|
2905
|
-
const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, s = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, n = !(!i || i.ignoreCoordinatePoints === void 0) && i.ignoreCoordinatePoints, a = !(!i || i.ignoreCurrentlyDrawing === void 0) && i.ignoreCurrentlyDrawing, l = !(!i || i.ignoreClosingPoints === void 0) && i.ignoreClosingPoints, d = this._adapter.unproject.bind(this._adapter), c = this._adapter.project.bind(this._adapter), h = c(t, e), u =
|
|
2920
|
+
const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, s = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, n = !(!i || i.ignoreCoordinatePoints === void 0) && i.ignoreCoordinatePoints, a = !(!i || i.ignoreCurrentlyDrawing === void 0) && i.ignoreCurrentlyDrawing, l = !(!i || i.ignoreClosingPoints === void 0) && i.ignoreClosingPoints, d = this._adapter.unproject.bind(this._adapter), c = this._adapter.project.bind(this._adapter), h = c(t, e), u = be({ unproject: d, point: h, pointerDistance: o });
|
|
2906
2921
|
return this._store.search(u).filter((p) => {
|
|
2907
|
-
if (s && (p.properties[k.MID_POINT] || p.properties[k.SELECTION_POINT]) || n && p.properties[
|
|
2922
|
+
if (s && (p.properties[k.MID_POINT] || p.properties[k.SELECTION_POINT]) || n && p.properties[P.COORDINATE_POINT] || l && p.properties[P.CLOSING_POINT] || a && p.properties[P.CURRENTLY_DRAWING]) return !1;
|
|
2908
2923
|
if (p.geometry.type === "Point") {
|
|
2909
2924
|
const g = p.geometry.coordinates, y = c(g[0], g[1]);
|
|
2910
|
-
return
|
|
2925
|
+
return F(h, y) < o;
|
|
2911
2926
|
}
|
|
2912
2927
|
if (p.geometry.type === "LineString") {
|
|
2913
2928
|
const g = p.geometry.coordinates;
|
|
2914
2929
|
for (let y = 0; y < g.length - 1; y++) {
|
|
2915
2930
|
const m = g[y], v = g[y + 1];
|
|
2916
|
-
if (
|
|
2931
|
+
if (Dt(h, c(m[0], m[1]), c(v[0], v[1])) < o) return !0;
|
|
2917
2932
|
}
|
|
2918
2933
|
return !1;
|
|
2919
2934
|
}
|
|
2920
|
-
if (
|
|
2935
|
+
if (_e([t, e], p.geometry.coordinates)) return !0;
|
|
2921
2936
|
if (i != null && i.includePolygonsWithinPointerDistance) {
|
|
2922
2937
|
const g = p.geometry.coordinates;
|
|
2923
2938
|
for (const y of g) for (let m = 0; m < y.length - 1; m++) {
|
|
2924
|
-
const v = y[m], C = y[m + 1], f = c(v[0], v[1]),
|
|
2925
|
-
if (
|
|
2939
|
+
const v = y[m], C = y[m + 1], f = c(v[0], v[1]), S = c(C[0], C[1]);
|
|
2940
|
+
if (Dt(h, f, S) < o) return !0;
|
|
2926
2941
|
}
|
|
2927
2942
|
}
|
|
2928
2943
|
return !1;
|
|
@@ -2939,7 +2954,7 @@ class oo {
|
|
|
2939
2954
|
return t && e !== this._instanceSelectMode && this.setMode(this._instanceSelectMode), this._modes[this._instanceSelectMode];
|
|
2940
2955
|
}
|
|
2941
2956
|
isGuidanceFeature(t) {
|
|
2942
|
-
return !!(t.properties[k.MID_POINT] || t.properties[k.SELECTION_POINT] || t.properties[
|
|
2957
|
+
return !!(t.properties[k.MID_POINT] || t.properties[k.SELECTION_POINT] || t.properties[P.COORDINATE_POINT] || t.properties[P.SNAPPING_POINT]);
|
|
2943
2958
|
}
|
|
2944
2959
|
setModeStyles(t, e) {
|
|
2945
2960
|
if (this.checkEnabled(), !this._modes[t]) throw new Error("No mode with this name present");
|
|
@@ -2980,7 +2995,7 @@ class oo {
|
|
|
2980
2995
|
t.forEach((i) => {
|
|
2981
2996
|
if (!this._store.has(i)) throw new Error(`No feature with id ${i}, can not delete`);
|
|
2982
2997
|
const o = this._store.copy(i);
|
|
2983
|
-
o.properties[k.SELECTED] && this.deselectFeature(i), o.properties[
|
|
2998
|
+
o.properties[k.SELECTED] && this.deselectFeature(i), o.properties[P.COORDINATE_POINT_IDS] && e.push(...o.properties[P.COORDINATE_POINT_IDS]);
|
|
2984
2999
|
}), this._store.delete([...t, ...e], { origin: "api" });
|
|
2985
3000
|
}
|
|
2986
3001
|
selectFeature(t) {
|
|
@@ -2995,6 +3010,21 @@ class oo {
|
|
|
2995
3010
|
hasFeature(t) {
|
|
2996
3011
|
return this._store.has(t);
|
|
2997
3012
|
}
|
|
3013
|
+
checkIsReservedProperty(t) {
|
|
3014
|
+
return ![...Object.values(k), ...Object.values(P)].includes(t);
|
|
3015
|
+
}
|
|
3016
|
+
updateFeatureProperties(t, e) {
|
|
3017
|
+
if (!this._store.has(t)) throw new Error(`No feature with id ${t} present in store`);
|
|
3018
|
+
const i = this._store.copy(t);
|
|
3019
|
+
if (this.isGuidanceFeature(i)) throw new Error("Guidance features are not allowed to be updated directly.");
|
|
3020
|
+
const o = i.properties.mode;
|
|
3021
|
+
if (!this._modes[o]) throw new Error(`No mode with name ${o} present in instance`);
|
|
3022
|
+
const s = Object.entries(e);
|
|
3023
|
+
s.forEach(([n, a]) => {
|
|
3024
|
+
if (!this.checkIsReservedProperty(n)) throw new Error(`You are trying to update a reserved property name: ${n}. Please choose another name.`);
|
|
3025
|
+
if (a !== void 0 && !kt(a)) throw new Error(`Invalid JSON value provided for property ${n}`);
|
|
3026
|
+
}), this._store.updateProperty(s.map(([n, a]) => ({ id: i.id, property: n, value: a })), { origin: "api" });
|
|
3027
|
+
}
|
|
2998
3028
|
updateFeatureGeometry(t, e) {
|
|
2999
3029
|
if (!this._store.has(t)) throw new Error(`No feature with id ${t} present in store`);
|
|
3000
3030
|
const i = this._store.copy(t);
|
|
@@ -3025,9 +3055,9 @@ class oo {
|
|
|
3025
3055
|
}
|
|
3026
3056
|
if (e.projection != "web-mercator") throw new Error(`Projection ${e.projection} is not currently supported for transformation`);
|
|
3027
3057
|
if (e.type === "scale") {
|
|
3028
|
-
const { x: a, y: l } =
|
|
3029
|
-
|
|
3030
|
-
} else e.type === "rotate" && (i =
|
|
3058
|
+
const { x: a, y: l } = O(e.origin[0], e.origin[1]);
|
|
3059
|
+
Ne({ coordinates: n, originX: a, originY: l, xScale: e.options.xScale || 1, yScale: e.options.yScale || 1 });
|
|
3060
|
+
} else e.type === "rotate" && (i = ke(i, e.options.angle || 0), n = i.geometry.type === "Polygon" ? i.geometry.coordinates[0] : i.geometry.coordinates);
|
|
3031
3061
|
if (n = n.map((a) => [w(a[0], this._adapter.getCoordinatePrecision()), w(a[1], this._adapter.getCoordinatePrecision())]), i.geometry.coordinates = i.geometry.type === "Polygon" ? [n] : n, this._store.updateGeometry([{ id: i.id, geometry: i.geometry }], { origin: "api" }), s.afterFeatureUpdated) {
|
|
3032
3062
|
s.afterFeatureUpdated(i);
|
|
3033
3063
|
const a = i.properties[k.SELECTED], l = this.getSelectMode({ switchToSelectMode: !1 });
|
|
@@ -3036,7 +3066,7 @@ class oo {
|
|
|
3036
3066
|
}
|
|
3037
3067
|
addFeatures(t) {
|
|
3038
3068
|
return this.checkEnabled(), t.length === 0 ? [] : this._store.load(t, (e) => {
|
|
3039
|
-
if (
|
|
3069
|
+
if (Jt(e)) {
|
|
3040
3070
|
const i = e.properties.mode, o = this._modes[i];
|
|
3041
3071
|
if (!o) return { id: e.id, valid: !1, reason: `${i} mode is not in the list of instantiated modes` };
|
|
3042
3072
|
const s = o.validateFeature.bind(o)(e);
|
|
@@ -3044,7 +3074,7 @@ class oo {
|
|
|
3044
3074
|
}
|
|
3045
3075
|
return { id: e.id, valid: !1, reason: "Mode property does not exist" };
|
|
3046
3076
|
}, (e) => {
|
|
3047
|
-
if (
|
|
3077
|
+
if (Jt(e)) {
|
|
3048
3078
|
const i = this._modes[e.properties.mode];
|
|
3049
3079
|
i && i.afterFeatureAdded && i.afterFeatureAdded(e);
|
|
3050
3080
|
}
|
|
@@ -3093,7 +3123,7 @@ class oo {
|
|
|
3093
3123
|
i.includes(e) && i.splice(i.indexOf(e), 1);
|
|
3094
3124
|
}
|
|
3095
3125
|
}
|
|
3096
|
-
class
|
|
3126
|
+
class Qi extends Hi.TerraDrawBaseAdapter {
|
|
3097
3127
|
constructor(t) {
|
|
3098
3128
|
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";
|
|
3099
3129
|
}
|
|
@@ -3181,7 +3211,7 @@ class so extends to.TerraDrawBaseAdapter {
|
|
|
3181
3211
|
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();
|
|
3182
3212
|
}
|
|
3183
3213
|
}
|
|
3184
|
-
const
|
|
3214
|
+
const zo = [
|
|
3185
3215
|
"render",
|
|
3186
3216
|
"point",
|
|
3187
3217
|
"linestring",
|
|
@@ -3197,7 +3227,7 @@ const $o = [
|
|
|
3197
3227
|
"delete-selection",
|
|
3198
3228
|
"delete",
|
|
3199
3229
|
"download"
|
|
3200
|
-
],
|
|
3230
|
+
], Vo = [
|
|
3201
3231
|
"render",
|
|
3202
3232
|
"linestring",
|
|
3203
3233
|
"point",
|
|
@@ -3206,7 +3236,7 @@ const $o = [
|
|
|
3206
3236
|
"delete",
|
|
3207
3237
|
"download",
|
|
3208
3238
|
"settings"
|
|
3209
|
-
],
|
|
3239
|
+
], to = {
|
|
3210
3240
|
modes: [
|
|
3211
3241
|
"render",
|
|
3212
3242
|
"point",
|
|
@@ -3225,7 +3255,7 @@ const $o = [
|
|
|
3225
3255
|
"download"
|
|
3226
3256
|
],
|
|
3227
3257
|
open: !1
|
|
3228
|
-
},
|
|
3258
|
+
}, lt = {
|
|
3229
3259
|
modes: [
|
|
3230
3260
|
"render",
|
|
3231
3261
|
"point",
|
|
@@ -3246,7 +3276,7 @@ const $o = [
|
|
|
3246
3276
|
open: !1,
|
|
3247
3277
|
// see styling parameters of Terra Draw at https://github.com/JamesLMilner/terra-draw/blob/main/guides/5.STYLING.md
|
|
3248
3278
|
modeOptions: {
|
|
3249
|
-
point: new
|
|
3279
|
+
point: new Rt({
|
|
3250
3280
|
editable: !0,
|
|
3251
3281
|
styles: {
|
|
3252
3282
|
pointColor: "#FFFFFF",
|
|
@@ -3255,7 +3285,7 @@ const $o = [
|
|
|
3255
3285
|
pointOutlineWidth: 1
|
|
3256
3286
|
}
|
|
3257
3287
|
}),
|
|
3258
|
-
linestring: new
|
|
3288
|
+
linestring: new At({
|
|
3259
3289
|
editable: !0,
|
|
3260
3290
|
styles: {
|
|
3261
3291
|
lineStringColor: "#666666",
|
|
@@ -3266,7 +3296,7 @@ const $o = [
|
|
|
3266
3296
|
closingPointOutlineWidth: 1
|
|
3267
3297
|
}
|
|
3268
3298
|
}),
|
|
3269
|
-
polygon: new
|
|
3299
|
+
polygon: new Le({
|
|
3270
3300
|
editable: !0,
|
|
3271
3301
|
styles: {
|
|
3272
3302
|
fillColor: "#EDEFF0",
|
|
@@ -3279,7 +3309,7 @@ const $o = [
|
|
|
3279
3309
|
closingPointOutlineWidth: 1
|
|
3280
3310
|
}
|
|
3281
3311
|
}),
|
|
3282
|
-
rectangle: new
|
|
3312
|
+
rectangle: new Fe({
|
|
3283
3313
|
styles: {
|
|
3284
3314
|
fillColor: "#EDEFF0",
|
|
3285
3315
|
fillOpacity: 0.7,
|
|
@@ -3287,7 +3317,7 @@ const $o = [
|
|
|
3287
3317
|
outlineWidth: 2
|
|
3288
3318
|
}
|
|
3289
3319
|
}),
|
|
3290
|
-
"angled-rectangle": new
|
|
3320
|
+
"angled-rectangle": new We({
|
|
3291
3321
|
styles: {
|
|
3292
3322
|
fillColor: "#EDEFF0",
|
|
3293
3323
|
fillOpacity: 0.7,
|
|
@@ -3295,7 +3325,7 @@ const $o = [
|
|
|
3295
3325
|
outlineWidth: 2
|
|
3296
3326
|
}
|
|
3297
3327
|
}),
|
|
3298
|
-
circle: new
|
|
3328
|
+
circle: new xe({
|
|
3299
3329
|
styles: {
|
|
3300
3330
|
fillColor: "#EDEFF0",
|
|
3301
3331
|
fillOpacity: 0.7,
|
|
@@ -3303,7 +3333,7 @@ const $o = [
|
|
|
3303
3333
|
outlineWidth: 2
|
|
3304
3334
|
}
|
|
3305
3335
|
}),
|
|
3306
|
-
freehand: new
|
|
3336
|
+
freehand: new Oe({
|
|
3307
3337
|
styles: {
|
|
3308
3338
|
fillColor: "#EDEFF0",
|
|
3309
3339
|
fillOpacity: 0.7,
|
|
@@ -3315,7 +3345,7 @@ const $o = [
|
|
|
3315
3345
|
closingPointOutlineWidth: 1
|
|
3316
3346
|
}
|
|
3317
3347
|
}),
|
|
3318
|
-
"freehand-linestring": new
|
|
3348
|
+
"freehand-linestring": new Re({
|
|
3319
3349
|
styles: {
|
|
3320
3350
|
lineStringColor: "#666666",
|
|
3321
3351
|
lineStringWidth: 2,
|
|
@@ -3325,7 +3355,7 @@ const $o = [
|
|
|
3325
3355
|
closingPointOutlineWidth: 1
|
|
3326
3356
|
}
|
|
3327
3357
|
}),
|
|
3328
|
-
sensor: new
|
|
3358
|
+
sensor: new Ae({
|
|
3329
3359
|
styles: {
|
|
3330
3360
|
fillColor: "#EDEFF0",
|
|
3331
3361
|
fillOpacity: 0.7,
|
|
@@ -3337,7 +3367,7 @@ const $o = [
|
|
|
3337
3367
|
centerPointOutlineWidth: 1
|
|
3338
3368
|
}
|
|
3339
3369
|
}),
|
|
3340
|
-
sector: new
|
|
3370
|
+
sector: new je({
|
|
3341
3371
|
styles: {
|
|
3342
3372
|
fillColor: "#EDEFF0",
|
|
3343
3373
|
fillOpacity: 0.7,
|
|
@@ -3345,7 +3375,7 @@ const $o = [
|
|
|
3345
3375
|
outlineWidth: 2
|
|
3346
3376
|
}
|
|
3347
3377
|
}),
|
|
3348
|
-
select: new
|
|
3378
|
+
select: new Gt({
|
|
3349
3379
|
flags: {
|
|
3350
3380
|
point: {
|
|
3351
3381
|
feature: {
|
|
@@ -3623,7 +3653,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3623
3653
|
adapterOptions: {
|
|
3624
3654
|
prefixId: "td-measure"
|
|
3625
3655
|
}
|
|
3626
|
-
},
|
|
3656
|
+
}, z = {
|
|
3627
3657
|
modes: [
|
|
3628
3658
|
"render",
|
|
3629
3659
|
"linestring",
|
|
@@ -3637,7 +3667,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3637
3667
|
open: !1,
|
|
3638
3668
|
// see styling parameters of Terra Draw at https://github.com/JamesLMilner/terra-draw/blob/main/guides/5.STYLING.md
|
|
3639
3669
|
modeOptions: {
|
|
3640
|
-
point: new
|
|
3670
|
+
point: new Rt({
|
|
3641
3671
|
editable: !1,
|
|
3642
3672
|
styles: {
|
|
3643
3673
|
pointColor: "#FFFFFF",
|
|
@@ -3646,7 +3676,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3646
3676
|
pointOutlineWidth: 1
|
|
3647
3677
|
}
|
|
3648
3678
|
}),
|
|
3649
|
-
linestring: new
|
|
3679
|
+
linestring: new At({
|
|
3650
3680
|
editable: !1,
|
|
3651
3681
|
styles: {
|
|
3652
3682
|
lineStringColor: "#FF0000",
|
|
@@ -3657,7 +3687,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3657
3687
|
closingPointOutlineWidth: 1
|
|
3658
3688
|
}
|
|
3659
3689
|
}),
|
|
3660
|
-
select: new
|
|
3690
|
+
select: new Gt({
|
|
3661
3691
|
flags: {
|
|
3662
3692
|
point: {
|
|
3663
3693
|
feature: {
|
|
@@ -3678,7 +3708,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3678
3708
|
}
|
|
3679
3709
|
}
|
|
3680
3710
|
}),
|
|
3681
|
-
settings: new
|
|
3711
|
+
settings: new Q({
|
|
3682
3712
|
modeName: "settings",
|
|
3683
3713
|
styles: {}
|
|
3684
3714
|
})
|
|
@@ -3852,34 +3882,34 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3852
3882
|
"text-halo-color": "rgb(255, 255, 255)"
|
|
3853
3883
|
}
|
|
3854
3884
|
}
|
|
3855
|
-
},
|
|
3856
|
-
render: new
|
|
3885
|
+
}, eo = () => ({
|
|
3886
|
+
render: new Q({
|
|
3857
3887
|
modeName: "render",
|
|
3858
3888
|
styles: {}
|
|
3859
3889
|
}),
|
|
3860
|
-
point: new
|
|
3890
|
+
point: new Rt({
|
|
3861
3891
|
editable: !0
|
|
3862
3892
|
}),
|
|
3863
|
-
linestring: new
|
|
3893
|
+
linestring: new At({
|
|
3864
3894
|
editable: !0
|
|
3865
3895
|
}),
|
|
3866
|
-
polygon: new
|
|
3896
|
+
polygon: new Le({
|
|
3867
3897
|
editable: !0,
|
|
3868
3898
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3869
3899
|
// @ts-ignore
|
|
3870
3900
|
validation: (t, e) => {
|
|
3871
3901
|
const i = e.updateType;
|
|
3872
|
-
return i === "finish" || i === "commit" ?
|
|
3902
|
+
return i === "finish" || i === "commit" ? Ui(t) : { valid: !0 };
|
|
3873
3903
|
}
|
|
3874
3904
|
}),
|
|
3875
|
-
rectangle: new
|
|
3876
|
-
"angled-rectangle": new
|
|
3877
|
-
circle: new
|
|
3878
|
-
freehand: new
|
|
3879
|
-
"freehand-linestring": new
|
|
3880
|
-
sensor: new
|
|
3881
|
-
sector: new
|
|
3882
|
-
select: new
|
|
3905
|
+
rectangle: new Fe(),
|
|
3906
|
+
"angled-rectangle": new We(),
|
|
3907
|
+
circle: new xe(),
|
|
3908
|
+
freehand: new Oe(),
|
|
3909
|
+
"freehand-linestring": new Re(),
|
|
3910
|
+
sensor: new Ae(),
|
|
3911
|
+
sector: new je(),
|
|
3912
|
+
select: new Gt({
|
|
3883
3913
|
flags: {
|
|
3884
3914
|
point: {
|
|
3885
3915
|
feature: {
|
|
@@ -3992,76 +4022,76 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3992
4022
|
}
|
|
3993
4023
|
}
|
|
3994
4024
|
}),
|
|
3995
|
-
delete: new
|
|
4025
|
+
delete: new Q({
|
|
3996
4026
|
modeName: "delete",
|
|
3997
4027
|
styles: {}
|
|
3998
4028
|
}),
|
|
3999
|
-
"delete-selection": new
|
|
4029
|
+
"delete-selection": new Q({
|
|
4000
4030
|
modeName: "delete-selection",
|
|
4001
4031
|
styles: {}
|
|
4002
4032
|
}),
|
|
4003
|
-
download: new
|
|
4033
|
+
download: new Q({
|
|
4004
4034
|
modeName: "download",
|
|
4005
4035
|
styles: {}
|
|
4006
4036
|
})
|
|
4007
4037
|
});
|
|
4008
|
-
var
|
|
4009
|
-
centimeters:
|
|
4010
|
-
centimetres:
|
|
4038
|
+
var W = 63710088e-1, io = {
|
|
4039
|
+
centimeters: W * 100,
|
|
4040
|
+
centimetres: W * 100,
|
|
4011
4041
|
degrees: 360 / (2 * Math.PI),
|
|
4012
|
-
feet:
|
|
4013
|
-
inches:
|
|
4014
|
-
kilometers:
|
|
4015
|
-
kilometres:
|
|
4016
|
-
meters:
|
|
4017
|
-
metres:
|
|
4018
|
-
miles:
|
|
4019
|
-
millimeters:
|
|
4020
|
-
millimetres:
|
|
4021
|
-
nauticalmiles:
|
|
4042
|
+
feet: W * 3.28084,
|
|
4043
|
+
inches: W * 39.37,
|
|
4044
|
+
kilometers: W / 1e3,
|
|
4045
|
+
kilometres: W / 1e3,
|
|
4046
|
+
meters: W,
|
|
4047
|
+
metres: W,
|
|
4048
|
+
miles: W / 1609.344,
|
|
4049
|
+
millimeters: W * 1e3,
|
|
4050
|
+
millimetres: W * 1e3,
|
|
4051
|
+
nauticalmiles: W / 1852,
|
|
4022
4052
|
radians: 1,
|
|
4023
|
-
yards:
|
|
4053
|
+
yards: W * 1.0936
|
|
4024
4054
|
};
|
|
4025
|
-
function
|
|
4055
|
+
function oo(r, t, e = {}) {
|
|
4026
4056
|
const i = { type: "Feature" };
|
|
4027
4057
|
return (e.id === 0 || e.id) && (i.id = e.id), e.bbox && (i.bbox = e.bbox), i.properties = t || {}, i.geometry = r, i;
|
|
4028
4058
|
}
|
|
4029
|
-
function
|
|
4059
|
+
function so(r, t, e = {}) {
|
|
4030
4060
|
if (!r)
|
|
4031
4061
|
throw new Error("coordinates is required");
|
|
4032
4062
|
if (!Array.isArray(r))
|
|
4033
4063
|
throw new Error("coordinates must be an Array");
|
|
4034
4064
|
if (r.length < 2)
|
|
4035
4065
|
throw new Error("coordinates must be at least 2 numbers long");
|
|
4036
|
-
if (!
|
|
4066
|
+
if (!he(r[0]) || !he(r[1]))
|
|
4037
4067
|
throw new Error("coordinates must contain numbers");
|
|
4038
|
-
return
|
|
4068
|
+
return oo({
|
|
4039
4069
|
type: "Point",
|
|
4040
4070
|
coordinates: r
|
|
4041
4071
|
}, t, e);
|
|
4042
4072
|
}
|
|
4043
|
-
function
|
|
4044
|
-
const e =
|
|
4073
|
+
function ro(r, t = "kilometers") {
|
|
4074
|
+
const e = io[t];
|
|
4045
4075
|
if (!e)
|
|
4046
4076
|
throw new Error(t + " units is invalid");
|
|
4047
4077
|
return r * e;
|
|
4048
4078
|
}
|
|
4049
|
-
function
|
|
4079
|
+
function vt(r) {
|
|
4050
4080
|
return r % 360 * Math.PI / 180;
|
|
4051
4081
|
}
|
|
4052
|
-
function
|
|
4082
|
+
function he(r) {
|
|
4053
4083
|
return !isNaN(r) && r !== null && !Array.isArray(r);
|
|
4054
4084
|
}
|
|
4055
|
-
function
|
|
4085
|
+
function Ge(r, t, e) {
|
|
4056
4086
|
if (r !== null)
|
|
4057
4087
|
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++) {
|
|
4058
4088
|
d = g ? r.features[v].geometry : y ? r.geometry : r, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
|
|
4059
4089
|
for (var C = 0; C < a; C++) {
|
|
4060
|
-
var f = 0,
|
|
4090
|
+
var f = 0, S = 0;
|
|
4061
4091
|
if (n = u ? d.geometries[C] : d, n !== null) {
|
|
4062
4092
|
l = n.coordinates;
|
|
4063
|
-
var
|
|
4064
|
-
switch (c =
|
|
4093
|
+
var I = n.type;
|
|
4094
|
+
switch (c = I === "Polygon" || I === "MultiPolygon" ? 1 : 0, I) {
|
|
4065
4095
|
case null:
|
|
4066
4096
|
break;
|
|
4067
4097
|
case "Point":
|
|
@@ -4070,7 +4100,7 @@ function $e(r, t, e) {
|
|
|
4070
4100
|
h,
|
|
4071
4101
|
v,
|
|
4072
4102
|
f,
|
|
4073
|
-
|
|
4103
|
+
S
|
|
4074
4104
|
) === !1)
|
|
4075
4105
|
return !1;
|
|
4076
4106
|
h++, f++;
|
|
@@ -4083,12 +4113,12 @@ function $e(r, t, e) {
|
|
|
4083
4113
|
h,
|
|
4084
4114
|
v,
|
|
4085
4115
|
f,
|
|
4086
|
-
|
|
4116
|
+
S
|
|
4087
4117
|
) === !1)
|
|
4088
4118
|
return !1;
|
|
4089
|
-
h++,
|
|
4119
|
+
h++, I === "MultiPoint" && f++;
|
|
4090
4120
|
}
|
|
4091
|
-
|
|
4121
|
+
I === "LineString" && f++;
|
|
4092
4122
|
break;
|
|
4093
4123
|
case "Polygon":
|
|
4094
4124
|
case "MultiLineString":
|
|
@@ -4099,37 +4129,37 @@ function $e(r, t, e) {
|
|
|
4099
4129
|
h,
|
|
4100
4130
|
v,
|
|
4101
4131
|
f,
|
|
4102
|
-
|
|
4132
|
+
S
|
|
4103
4133
|
) === !1)
|
|
4104
4134
|
return !1;
|
|
4105
4135
|
h++;
|
|
4106
4136
|
}
|
|
4107
|
-
|
|
4137
|
+
I === "MultiLineString" && f++, I === "Polygon" && S++;
|
|
4108
4138
|
}
|
|
4109
|
-
|
|
4139
|
+
I === "Polygon" && f++;
|
|
4110
4140
|
break;
|
|
4111
4141
|
case "MultiPolygon":
|
|
4112
4142
|
for (i = 0; i < l.length; i++) {
|
|
4113
|
-
for (
|
|
4143
|
+
for (S = 0, o = 0; o < l[i].length; o++) {
|
|
4114
4144
|
for (s = 0; s < l[i][o].length - c; s++) {
|
|
4115
4145
|
if (t(
|
|
4116
4146
|
l[i][o][s],
|
|
4117
4147
|
h,
|
|
4118
4148
|
v,
|
|
4119
4149
|
f,
|
|
4120
|
-
|
|
4150
|
+
S
|
|
4121
4151
|
) === !1)
|
|
4122
4152
|
return !1;
|
|
4123
4153
|
h++;
|
|
4124
4154
|
}
|
|
4125
|
-
|
|
4155
|
+
S++;
|
|
4126
4156
|
}
|
|
4127
4157
|
f++;
|
|
4128
4158
|
}
|
|
4129
4159
|
break;
|
|
4130
4160
|
case "GeometryCollection":
|
|
4131
4161
|
for (i = 0; i < n.geometries.length; i++)
|
|
4132
|
-
if (
|
|
4162
|
+
if (Ge(n.geometries[i], t) === !1)
|
|
4133
4163
|
return !1;
|
|
4134
4164
|
break;
|
|
4135
4165
|
default:
|
|
@@ -4139,7 +4169,7 @@ function $e(r, t, e) {
|
|
|
4139
4169
|
}
|
|
4140
4170
|
}
|
|
4141
4171
|
}
|
|
4142
|
-
function
|
|
4172
|
+
function no(r, t) {
|
|
4143
4173
|
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;
|
|
4144
4174
|
for (e = 0; e < y; e++) {
|
|
4145
4175
|
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++) {
|
|
@@ -4190,9 +4220,9 @@ function uo(r, t) {
|
|
|
4190
4220
|
u++;
|
|
4191
4221
|
}
|
|
4192
4222
|
}
|
|
4193
|
-
function
|
|
4223
|
+
function ao(r, t, e) {
|
|
4194
4224
|
var i = e;
|
|
4195
|
-
return
|
|
4225
|
+
return no(
|
|
4196
4226
|
r,
|
|
4197
4227
|
function(o, s, n, a, l) {
|
|
4198
4228
|
s === 0 && e === void 0 ? i = o : i = t(
|
|
@@ -4206,21 +4236,21 @@ function po(r, t, e) {
|
|
|
4206
4236
|
}
|
|
4207
4237
|
), i;
|
|
4208
4238
|
}
|
|
4209
|
-
function
|
|
4210
|
-
return
|
|
4239
|
+
function lo(r) {
|
|
4240
|
+
return ao(
|
|
4211
4241
|
r,
|
|
4212
|
-
(t, e) => t +
|
|
4242
|
+
(t, e) => t + co(e),
|
|
4213
4243
|
0
|
|
4214
4244
|
);
|
|
4215
4245
|
}
|
|
4216
|
-
function
|
|
4246
|
+
function co(r) {
|
|
4217
4247
|
let t = 0, e;
|
|
4218
4248
|
switch (r.type) {
|
|
4219
4249
|
case "Polygon":
|
|
4220
|
-
return
|
|
4250
|
+
return ue(r.coordinates);
|
|
4221
4251
|
case "MultiPolygon":
|
|
4222
4252
|
for (e = 0; e < r.coordinates.length; e++)
|
|
4223
|
-
t +=
|
|
4253
|
+
t += ue(r.coordinates[e]);
|
|
4224
4254
|
return t;
|
|
4225
4255
|
case "Point":
|
|
4226
4256
|
case "MultiPoint":
|
|
@@ -4230,36 +4260,36 @@ function yo(r) {
|
|
|
4230
4260
|
}
|
|
4231
4261
|
return 0;
|
|
4232
4262
|
}
|
|
4233
|
-
function
|
|
4263
|
+
function ue(r) {
|
|
4234
4264
|
let t = 0;
|
|
4235
4265
|
if (r && r.length > 0) {
|
|
4236
|
-
t += Math.abs(
|
|
4266
|
+
t += Math.abs(pe(r[0]));
|
|
4237
4267
|
for (let e = 1; e < r.length; e++)
|
|
4238
|
-
t -= Math.abs(
|
|
4268
|
+
t -= Math.abs(pe(r[e]));
|
|
4239
4269
|
}
|
|
4240
4270
|
return t;
|
|
4241
4271
|
}
|
|
4242
|
-
var
|
|
4243
|
-
function
|
|
4272
|
+
var ho = W * W / 2, Lt = Math.PI / 180;
|
|
4273
|
+
function pe(r) {
|
|
4244
4274
|
const t = r.length - 1;
|
|
4245
4275
|
if (t <= 2) return 0;
|
|
4246
4276
|
let e = 0, i = 0;
|
|
4247
4277
|
for (; i < t; ) {
|
|
4248
|
-
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] *
|
|
4278
|
+
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] * Lt, l = s[1] * Lt, d = n[0] * Lt;
|
|
4249
4279
|
e += (d - a) * Math.sin(l), i++;
|
|
4250
4280
|
}
|
|
4251
|
-
return e *
|
|
4281
|
+
return e * ho;
|
|
4252
4282
|
}
|
|
4253
|
-
var
|
|
4254
|
-
const
|
|
4283
|
+
var uo = lo;
|
|
4284
|
+
const po = (r, t, e = "auto") => {
|
|
4255
4285
|
const i = ["m2", "km2", "a", "ha"], o = ["ft2", "yd2", "acre", "mi2"];
|
|
4256
4286
|
let s = e;
|
|
4257
4287
|
if (e !== "auto") {
|
|
4258
4288
|
const n = i.includes(e), a = o.includes(e);
|
|
4259
4289
|
(t === "metric" && !n || t === "imperial" && !a) && (s = "auto");
|
|
4260
4290
|
}
|
|
4261
|
-
return t === "metric" ? s !== "auto" ?
|
|
4262
|
-
},
|
|
4291
|
+
return t === "metric" ? s !== "auto" ? ot(r, s) : r >= 1e6 ? ot(r, "km2") : r >= 1e4 ? ot(r, "ha") : r >= 100 ? ot(r, "a") : ot(r, "m2") : s !== "auto" ? st(r, s) : r >= 258998811e-2 ? st(r, "mi2") : r >= 4046.856 ? st(r, "acre") : r >= 0.83612736 ? st(r, "yd2") : st(r, "ft2");
|
|
4292
|
+
}, ot = (r, t) => {
|
|
4263
4293
|
let e = r, i = "m²";
|
|
4264
4294
|
switch (t) {
|
|
4265
4295
|
case "m2":
|
|
@@ -4279,7 +4309,7 @@ const vo = (r, t, e = "auto") => {
|
|
|
4279
4309
|
area: e,
|
|
4280
4310
|
unit: i
|
|
4281
4311
|
};
|
|
4282
|
-
},
|
|
4312
|
+
}, st = (r, t) => {
|
|
4283
4313
|
let e = r / 258998811e-2, i = "m²";
|
|
4284
4314
|
switch (t) {
|
|
4285
4315
|
case "ft2":
|
|
@@ -4299,12 +4329,12 @@ const vo = (r, t, e = "auto") => {
|
|
|
4299
4329
|
area: e,
|
|
4300
4330
|
unit: i
|
|
4301
4331
|
};
|
|
4302
|
-
},
|
|
4332
|
+
}, ge = (r, t, e, i) => {
|
|
4303
4333
|
if (r.geometry.type !== "Polygon") return r;
|
|
4304
|
-
const o =
|
|
4334
|
+
const o = uo(r.geometry), s = po(o, t, i);
|
|
4305
4335
|
return s.area = parseFloat(s.area.toFixed(e)), r.properties.area = s.area, r.properties.unit = s.unit, r;
|
|
4306
4336
|
};
|
|
4307
|
-
function
|
|
4337
|
+
function ye(r) {
|
|
4308
4338
|
if (!r)
|
|
4309
4339
|
throw new Error("coord is required");
|
|
4310
4340
|
if (!Array.isArray(r)) {
|
|
@@ -4317,15 +4347,15 @@ function Ce(r) {
|
|
|
4317
4347
|
return [...r];
|
|
4318
4348
|
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
4319
4349
|
}
|
|
4320
|
-
function
|
|
4321
|
-
var i =
|
|
4322
|
-
return
|
|
4350
|
+
function go(r, t, e = {}) {
|
|
4351
|
+
var i = ye(r), o = ye(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);
|
|
4352
|
+
return ro(
|
|
4323
4353
|
2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
|
|
4324
4354
|
e.units
|
|
4325
4355
|
);
|
|
4326
4356
|
}
|
|
4327
|
-
var
|
|
4328
|
-
const
|
|
4357
|
+
var yo = go;
|
|
4358
|
+
const fe = (r) => r === "degrees" ? "°" : r === "miles" ? "mi" : r === "radians" ? "rad" : "km", Ft = (r) => {
|
|
4329
4359
|
if (r >= 1)
|
|
4330
4360
|
return {
|
|
4331
4361
|
distance: r,
|
|
@@ -4339,16 +4369,16 @@ const Pe = (r) => r === "degrees" ? "°" : r === "miles" ? "mi" : r === "radians
|
|
|
4339
4369
|
distance: t * 100,
|
|
4340
4370
|
unit: "cm"
|
|
4341
4371
|
};
|
|
4342
|
-
},
|
|
4372
|
+
}, me = (r, t, e, i, o, s) => {
|
|
4343
4373
|
if (r.geometry.type !== "LineString") return r;
|
|
4344
4374
|
const n = r.geometry.coordinates;
|
|
4345
4375
|
let a = 0;
|
|
4346
4376
|
const l = [];
|
|
4347
4377
|
for (let d = 0; d < n.length - 1; d++) {
|
|
4348
|
-
const c = n[d], h = n[d + 1], u =
|
|
4378
|
+
const c = n[d], h = n[d + 1], u = yo(c, h, { units: t });
|
|
4349
4379
|
a += u;
|
|
4350
4380
|
const p = JSON.parse(JSON.stringify(r));
|
|
4351
|
-
if (p.id = `${p.id}-${d}`, p.geometry.coordinates = [c, h], p.properties.originalId = r.id, p.properties.distance = u, p.properties.total = a, p.properties.unit =
|
|
4381
|
+
if (p.id = `${p.id}-${d}`, p.geometry.coordinates = [c, h], p.properties.originalId = r.id, p.properties.distance = u, p.properties.total = a, p.properties.unit = fe(t), p.properties.totalUnit = fe(t), o === !0 && s === void 0) {
|
|
4352
4382
|
const g = i?.queryTerrainElevation(c);
|
|
4353
4383
|
g && (p.properties.elevation_start = g);
|
|
4354
4384
|
const y = i?.queryTerrainElevation(h);
|
|
@@ -4357,12 +4387,12 @@ const Pe = (r) => r === "degrees" ? "°" : r === "miles" ? "mi" : r === "radians
|
|
|
4357
4387
|
l.push(p);
|
|
4358
4388
|
}
|
|
4359
4389
|
if (r.properties.distance = l[l.length - 1].properties.total, r.properties.unit = l[l.length - 1].properties.unit, r.properties.segments = JSON.parse(JSON.stringify(l)), t === "kilometers") {
|
|
4360
|
-
const d =
|
|
4390
|
+
const d = Ft(r.properties.distance);
|
|
4361
4391
|
r.properties.distance = d.distance, r.properties.unit = d.unit, r.properties.segments.forEach(
|
|
4362
4392
|
(c) => {
|
|
4363
|
-
const h =
|
|
4393
|
+
const h = Ft(c.properties.distance);
|
|
4364
4394
|
c.properties.distance = h.distance, c.properties.unit = h.unit;
|
|
4365
|
-
const u =
|
|
4395
|
+
const u = Ft(c.properties.total);
|
|
4366
4396
|
c.properties.total = u.distance, c.properties.totalUnit = u.unit;
|
|
4367
4397
|
}
|
|
4368
4398
|
);
|
|
@@ -4378,25 +4408,25 @@ const Pe = (r) => r === "degrees" ? "°" : r === "miles" ? "mi" : r === "radians
|
|
|
4378
4408
|
);
|
|
4379
4409
|
}
|
|
4380
4410
|
), r;
|
|
4381
|
-
},
|
|
4411
|
+
}, ve = (r) => r.charAt(0).toUpperCase() + r.slice(1), et = [
|
|
4382
4412
|
"{prefix}-point",
|
|
4383
4413
|
"{prefix}-point-lower",
|
|
4384
4414
|
"{prefix}-linestring",
|
|
4385
4415
|
"{prefix}-polygon",
|
|
4386
4416
|
"{prefix}-polygon-outline"
|
|
4387
|
-
],
|
|
4388
|
-
...
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4417
|
+
], $o = [
|
|
4418
|
+
...et,
|
|
4419
|
+
lt.polygonLayerSpec?.source,
|
|
4420
|
+
lt.lineLayerLabelSpec?.source,
|
|
4421
|
+
lt.pointLayerLabelSpec?.source
|
|
4392
4422
|
], Yo = [
|
|
4393
|
-
...
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
],
|
|
4423
|
+
...et,
|
|
4424
|
+
z.routingLineLayerNodeLabelSpec?.source,
|
|
4425
|
+
z.routingLineLayerNodeSpec?.source,
|
|
4426
|
+
z.isochronePolygonLayerSpec?.source,
|
|
4427
|
+
z.isochroneLineLayerSpec?.source,
|
|
4428
|
+
z.isochroneLabelLayerSpec?.source
|
|
4429
|
+
], Ut = (r, t, e = et, i = "td") => {
|
|
4400
4430
|
e = e.map((s) => s.replace("{prefix}", i));
|
|
4401
4431
|
const o = JSON.parse(JSON.stringify(r));
|
|
4402
4432
|
return t && (t.onlyTerraDrawLayers === !0 ? (o.layers = o.layers.filter((s) => "source" in s && e.includes(s.source)), Object.keys(o.sources).forEach((s) => {
|
|
@@ -4404,13 +4434,13 @@ const Pe = (r) => r === "degrees" ? "°" : r === "miles" ? "mi" : r === "radians
|
|
|
4404
4434
|
})) : 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) => {
|
|
4405
4435
|
e.includes(s) && delete o.sources[s];
|
|
4406
4436
|
}))), o;
|
|
4407
|
-
},
|
|
4437
|
+
}, Ue = (r, t = 250) => {
|
|
4408
4438
|
let e;
|
|
4409
4439
|
return (...i) => {
|
|
4410
4440
|
clearTimeout(e), e = setTimeout(() => r(...i), t);
|
|
4411
4441
|
};
|
|
4412
4442
|
};
|
|
4413
|
-
class
|
|
4443
|
+
class ze {
|
|
4414
4444
|
cache = /* @__PURE__ */ new Map();
|
|
4415
4445
|
maxSize;
|
|
4416
4446
|
ttl;
|
|
@@ -4488,7 +4518,7 @@ class Xe {
|
|
|
4488
4518
|
};
|
|
4489
4519
|
}
|
|
4490
4520
|
}
|
|
4491
|
-
class
|
|
4521
|
+
class fo {
|
|
4492
4522
|
className;
|
|
4493
4523
|
dialog;
|
|
4494
4524
|
title;
|
|
@@ -4577,7 +4607,7 @@ class So {
|
|
|
4577
4607
|
}), o;
|
|
4578
4608
|
}
|
|
4579
4609
|
}
|
|
4580
|
-
const
|
|
4610
|
+
const Ce = (r, t, e, i) => {
|
|
4581
4611
|
if (r.geometry.type !== "Point") return r;
|
|
4582
4612
|
const o = r.geometry.coordinates;
|
|
4583
4613
|
if (e === !0 && i === void 0) {
|
|
@@ -4586,58 +4616,58 @@ const Ie = (r, t, e, i) => {
|
|
|
4586
4616
|
}
|
|
4587
4617
|
return r;
|
|
4588
4618
|
};
|
|
4589
|
-
var
|
|
4590
|
-
function
|
|
4619
|
+
var mo = Object.defineProperty, vo = (r, t, e) => t in r ? mo(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, rt = (r, t, e) => vo(r, typeof t != "symbol" ? t + "" : t, e), St = 2 * Math.PI * 6378137 / 2;
|
|
4620
|
+
function Co(r) {
|
|
4591
4621
|
return r = r || 256, 2 * Math.PI * 6378137 / r;
|
|
4592
4622
|
}
|
|
4593
|
-
function
|
|
4594
|
-
r =
|
|
4595
|
-
var i = r[0], o = r[1], s = i *
|
|
4596
|
-
return n = n *
|
|
4623
|
+
function Po(r, t, e = { enable: !0, decimal: 1 }) {
|
|
4624
|
+
r = zt(r);
|
|
4625
|
+
var i = r[0], o = r[1], s = i * St / 180, n = Math.log(Math.tan((90 + o) * Math.PI / 360)) / (Math.PI / 180);
|
|
4626
|
+
return n = n * St / 180, e.enable && (s = Number(s.toFixed(e.decimal)), n = Number(n.toFixed(e.decimal))), [s, n];
|
|
4597
4627
|
}
|
|
4598
|
-
function
|
|
4599
|
-
var i = r[0], o = r[1], s =
|
|
4628
|
+
function So(r, t, e) {
|
|
4629
|
+
var i = r[0], o = r[1], s = wo(t, e), n = (i + St) / s, a = (o + St) / s;
|
|
4600
4630
|
return [n, a, t];
|
|
4601
4631
|
}
|
|
4602
|
-
function
|
|
4603
|
-
r =
|
|
4604
|
-
var i =
|
|
4605
|
-
return
|
|
4632
|
+
function Ve(r, t, e) {
|
|
4633
|
+
r = zt(r);
|
|
4634
|
+
var i = Po(r), o = So(i, t);
|
|
4635
|
+
return xo(o);
|
|
4606
4636
|
}
|
|
4607
|
-
function
|
|
4608
|
-
if (r =
|
|
4637
|
+
function Io(r, t, e) {
|
|
4638
|
+
if (r = zt(r), t === 0)
|
|
4609
4639
|
return [0, 0, 0];
|
|
4610
|
-
var i =
|
|
4611
|
-
return
|
|
4640
|
+
var i = Ve(r, t);
|
|
4641
|
+
return Oo(i);
|
|
4612
4642
|
}
|
|
4613
|
-
function
|
|
4643
|
+
function xo(r, t, e) {
|
|
4614
4644
|
t = t || 256;
|
|
4615
4645
|
var i = r[0], o = r[1], s = r[2];
|
|
4616
4646
|
if (s === 0) return [0, 0, 0];
|
|
4617
|
-
|
|
4647
|
+
$e(s);
|
|
4618
4648
|
var n = Math.ceil(i / t) - 1, a = Math.ceil(o / t) - 1;
|
|
4619
4649
|
return n < 0 && (n = 0), a < 0 && (a = 0), [n, a, s];
|
|
4620
4650
|
}
|
|
4621
|
-
function
|
|
4622
|
-
|
|
4651
|
+
function Oo(r, t) {
|
|
4652
|
+
bo(r);
|
|
4623
4653
|
var e = r[0], i = r[1], o = r[2];
|
|
4624
4654
|
if (o === 0)
|
|
4625
4655
|
return [0, 0, 0];
|
|
4626
4656
|
var s = e, n = Math.pow(2, o) - 1 - i;
|
|
4627
4657
|
return [s, n, o];
|
|
4628
4658
|
}
|
|
4629
|
-
function
|
|
4659
|
+
function bo(r, t) {
|
|
4630
4660
|
var e = r[0], i = r[1], o = r[2];
|
|
4631
4661
|
if (o == null) throw new Error("<zoom> is required");
|
|
4632
4662
|
if (e == null) throw new Error("<x> is required");
|
|
4633
4663
|
if (i == null) throw new Error("<y> is required");
|
|
4634
|
-
return o =
|
|
4664
|
+
return o = $e(o), r = Eo(r), r;
|
|
4635
4665
|
}
|
|
4636
|
-
function
|
|
4666
|
+
function Eo(r) {
|
|
4637
4667
|
var t = r[0], e = r[1], i = r[2], o = Math.pow(2, i);
|
|
4638
4668
|
return t = t % o, t < 0 && (t = t + o), [t, e, i];
|
|
4639
4669
|
}
|
|
4640
|
-
function
|
|
4670
|
+
function $e(r) {
|
|
4641
4671
|
if (r === !1) return r;
|
|
4642
4672
|
if (r == null)
|
|
4643
4673
|
throw new Error("<zoom> is required");
|
|
@@ -4647,22 +4677,22 @@ function He(r) {
|
|
|
4647
4677
|
throw new Error("<zoom> cannot be greater than 32");
|
|
4648
4678
|
return r;
|
|
4649
4679
|
}
|
|
4650
|
-
function
|
|
4651
|
-
var e =
|
|
4680
|
+
function zt(r, t) {
|
|
4681
|
+
var e = Fo(r[0]), i = Lo(r[1]);
|
|
4652
4682
|
return i > 85 && (i = 85), i < -85 && (i = -85), [e, i];
|
|
4653
4683
|
}
|
|
4654
|
-
function
|
|
4655
|
-
return
|
|
4684
|
+
function wo(r, t) {
|
|
4685
|
+
return Co(t) / Math.pow(2, r);
|
|
4656
4686
|
}
|
|
4657
|
-
function
|
|
4687
|
+
function Lo(r) {
|
|
4658
4688
|
if (r == null) throw new Error("lat is required");
|
|
4659
4689
|
return (r > 90 || r < -90) && (r = r % 180, r > 90 && (r = -180 + r), r < -90 && (r = 180 + r), r === 0 && (r = 0)), r;
|
|
4660
4690
|
}
|
|
4661
|
-
function
|
|
4691
|
+
function Fo(r) {
|
|
4662
4692
|
if (r == null) throw new Error("lng is required");
|
|
4663
4693
|
return (r > 180 || r < -180) && (r = r % 360, r > 180 && (r = -360 + r), r < -180 && (r = 360 + r), r === 0 && (r = 0)), r;
|
|
4664
4694
|
}
|
|
4665
|
-
class
|
|
4695
|
+
class Ye {
|
|
4666
4696
|
/**
|
|
4667
4697
|
* Constructor
|
|
4668
4698
|
* @param url URL for terrain RGB raster tilesets
|
|
@@ -4673,7 +4703,7 @@ class Je {
|
|
|
4673
4703
|
* @param tms whether it is Tile Map Service
|
|
4674
4704
|
*/
|
|
4675
4705
|
constructor(t, e, i, o, s) {
|
|
4676
|
-
|
|
4706
|
+
rt(this, "url"), rt(this, "tileSize"), rt(this, "tms"), rt(this, "minzoom"), rt(this, "maxzoom"), this.url = t, this.tileSize = e, this.tms = s, this.minzoom = i, this.maxzoom = o, this.tms = s;
|
|
4677
4707
|
}
|
|
4678
4708
|
/**
|
|
4679
4709
|
* Get the value from target coordinates and zoom level by using certain formula.
|
|
@@ -4687,7 +4717,7 @@ class Je {
|
|
|
4687
4717
|
const s = t[0], n = t[1];
|
|
4688
4718
|
let a = e;
|
|
4689
4719
|
e > this.maxzoom ? a = this.maxzoom : e < this.minzoom && (a = this.minzoom);
|
|
4690
|
-
const l = this.tms ?
|
|
4720
|
+
const l = this.tms ? Ve([s, n], a) : Io([s, n], a), d = this.url.replace(/{x}/g, l[0].toString()).replace(/{y}/g, l[1].toString()).replace(/{z}/g, l[2].toString());
|
|
4691
4721
|
let c = this.getUrlExtension(d);
|
|
4692
4722
|
switch (c || (c = "png"), c) {
|
|
4693
4723
|
case "png":
|
|
@@ -4789,7 +4819,7 @@ class Je {
|
|
|
4789
4819
|
return i * Math.atan(0.5 * (Math.exp(o) - Math.exp(-o)));
|
|
4790
4820
|
}
|
|
4791
4821
|
}
|
|
4792
|
-
class
|
|
4822
|
+
class Mo extends Ye {
|
|
4793
4823
|
/**
|
|
4794
4824
|
* Constructor
|
|
4795
4825
|
* @param url URL for terrain RGB raster tilesets
|
|
@@ -4821,7 +4851,7 @@ class Bo extends Je {
|
|
|
4821
4851
|
return -1e4 + (t * 256 * 256 + e * 256 + i) * 0.1;
|
|
4822
4852
|
}
|
|
4823
4853
|
}
|
|
4824
|
-
class
|
|
4854
|
+
class Do extends Ye {
|
|
4825
4855
|
/**
|
|
4826
4856
|
* Constructor
|
|
4827
4857
|
* @param url URL for terrarium raster tilesets
|
|
@@ -4855,10 +4885,10 @@ class jo extends Je {
|
|
|
4855
4885
|
return parseInt(o.toFixed(0));
|
|
4856
4886
|
}
|
|
4857
4887
|
}
|
|
4858
|
-
const
|
|
4888
|
+
const _o = (r, t = 8) => {
|
|
4859
4889
|
const [e, i] = r, o = Math.pow(10, t), s = Math.round(e * o) / o, n = Math.round(i * o) / o;
|
|
4860
4890
|
return `${s},${n}`;
|
|
4861
|
-
},
|
|
4891
|
+
}, Pe = async (r, t, e, i) => {
|
|
4862
4892
|
const o = [], s = {
|
|
4863
4893
|
enabled: !0,
|
|
4864
4894
|
maxSize: 1e3,
|
|
@@ -4868,19 +4898,19 @@ const Wo = (r, t = 8) => {
|
|
|
4868
4898
|
...e
|
|
4869
4899
|
};
|
|
4870
4900
|
let n;
|
|
4871
|
-
s.enabled && (n = i || new
|
|
4901
|
+
s.enabled && (n = i || new ze(s.maxSize, s.ttl));
|
|
4872
4902
|
let a, l = 15;
|
|
4873
4903
|
if (t) {
|
|
4874
4904
|
const d = t.url, c = t.encoding ?? "mapbox", h = t.tileSize ?? 512, u = t.minzoom ?? 5;
|
|
4875
4905
|
l = t.maxzoom ?? 15;
|
|
4876
4906
|
const p = t.tms ?? !1;
|
|
4877
|
-
a = c === "mapbox" ? new
|
|
4907
|
+
a = c === "mapbox" ? new Mo(d, h, u, l, p) : new Do(d, h, u, l, p);
|
|
4878
4908
|
}
|
|
4879
4909
|
for (const d of r)
|
|
4880
4910
|
o.push(
|
|
4881
4911
|
new Promise((c) => {
|
|
4882
4912
|
d.geometry.type !== "Point" && c(d);
|
|
4883
|
-
const h = d.geometry.coordinates, u =
|
|
4913
|
+
const h = d.geometry.coordinates, u = _o(h, s.precision);
|
|
4884
4914
|
if (n) {
|
|
4885
4915
|
const p = n.get(u);
|
|
4886
4916
|
if (p !== void 0) {
|
|
@@ -4896,7 +4926,7 @@ const Wo = (r, t = 8) => {
|
|
|
4896
4926
|
})
|
|
4897
4927
|
);
|
|
4898
4928
|
return await Promise.all(o);
|
|
4899
|
-
},
|
|
4929
|
+
}, Ko = (r, t = 9) => {
|
|
4900
4930
|
function e(o) {
|
|
4901
4931
|
return [Number(o[0].toFixed(t)), Number(o[1].toFixed(t))];
|
|
4902
4932
|
}
|
|
@@ -4930,11 +4960,11 @@ const Wo = (r, t = 8) => {
|
|
|
4930
4960
|
...o,
|
|
4931
4961
|
geometry: i(o.geometry)
|
|
4932
4962
|
}));
|
|
4933
|
-
},
|
|
4963
|
+
}, ko = [
|
|
4934
4964
|
{ value: "time", label: "Time" },
|
|
4935
4965
|
{ value: "distance", label: "Distance" }
|
|
4936
4966
|
];
|
|
4937
|
-
class
|
|
4967
|
+
class No {
|
|
4938
4968
|
url;
|
|
4939
4969
|
/**
|
|
4940
4970
|
* Constructor
|
|
@@ -4966,15 +4996,15 @@ class Go {
|
|
|
4966
4996
|
return await (await fetch(l)).json();
|
|
4967
4997
|
}
|
|
4968
4998
|
}
|
|
4969
|
-
const
|
|
4999
|
+
const Nt = [
|
|
4970
5000
|
{ value: "pedestrian", label: "Pedestrian" },
|
|
4971
5001
|
{ value: "bicycle", label: "Bicycle" },
|
|
4972
5002
|
{ value: "auto", label: "Car" }
|
|
4973
|
-
],
|
|
5003
|
+
], To = [
|
|
4974
5004
|
{ value: "kilometers", label: "km" },
|
|
4975
5005
|
{ value: "miles", label: "mile" }
|
|
4976
5006
|
];
|
|
4977
|
-
class
|
|
5007
|
+
class Wo {
|
|
4978
5008
|
tripData = [];
|
|
4979
5009
|
/**
|
|
4980
5010
|
* get the raw trip data from the valhalla routing API.
|
|
@@ -5041,10 +5071,10 @@ class Uo {
|
|
|
5041
5071
|
const h = [];
|
|
5042
5072
|
let u = 0, p = 0;
|
|
5043
5073
|
const g = [], y = this.geoPoint(this.tripData.map((f) => [f.lng, f.lat]));
|
|
5044
|
-
l.trip.legs.forEach((f,
|
|
5045
|
-
const
|
|
5046
|
-
h.push(...
|
|
5047
|
-
const E = y.features[
|
|
5074
|
+
l.trip.legs.forEach((f, S) => {
|
|
5075
|
+
const I = this.decodeShape(f.shape);
|
|
5076
|
+
h.push(...I), u += Number(f.summary.length.toFixed(2)), p += Number((f.summary.time / 60).toFixed()), g.push(...f.maneuvers);
|
|
5077
|
+
const E = y.features[S + 1];
|
|
5048
5078
|
E.properties = {
|
|
5049
5079
|
...E.properties,
|
|
5050
5080
|
distance: u,
|
|
@@ -5053,7 +5083,7 @@ class Uo {
|
|
|
5053
5083
|
maneuvers: f.maneuvers
|
|
5054
5084
|
};
|
|
5055
5085
|
});
|
|
5056
|
-
const m =
|
|
5086
|
+
const m = Nt.find((f) => f.value === e)?.label, v = this.geoLineString(h, {
|
|
5057
5087
|
costingModel: m,
|
|
5058
5088
|
distance: u,
|
|
5059
5089
|
distance_unit: i === "kilometers" ? "km" : "mi",
|
|
@@ -5128,7 +5158,7 @@ class Uo {
|
|
|
5128
5158
|
return n;
|
|
5129
5159
|
}
|
|
5130
5160
|
}
|
|
5131
|
-
class
|
|
5161
|
+
class Ke {
|
|
5132
5162
|
controlContainer;
|
|
5133
5163
|
map;
|
|
5134
5164
|
modeButtons = {};
|
|
@@ -5167,7 +5197,7 @@ class qe {
|
|
|
5167
5197
|
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");
|
|
5168
5198
|
}
|
|
5169
5199
|
terradraw;
|
|
5170
|
-
options =
|
|
5200
|
+
options = to;
|
|
5171
5201
|
events = {};
|
|
5172
5202
|
defaultMode = "render";
|
|
5173
5203
|
/**
|
|
@@ -5195,7 +5225,7 @@ class qe {
|
|
|
5195
5225
|
if (this.options && this.options.modes && this.options.modes.length === 0)
|
|
5196
5226
|
throw new Error("At least a mode must be enabled.");
|
|
5197
5227
|
this.map = t;
|
|
5198
|
-
const e =
|
|
5228
|
+
const e = eo(), i = [];
|
|
5199
5229
|
return this.options?.modes?.forEach((o) => {
|
|
5200
5230
|
if (this.options.modeOptions && this.options.modeOptions[o]) {
|
|
5201
5231
|
const s = this.options.modeOptions[o];
|
|
@@ -5213,12 +5243,12 @@ class qe {
|
|
|
5213
5243
|
}), i.forEach((o) => {
|
|
5214
5244
|
o.state !== "unregistered" && (o._state = "unregistered");
|
|
5215
5245
|
}), this.options?.modes?.includes("render") || (i.push(
|
|
5216
|
-
new
|
|
5246
|
+
new Q({
|
|
5217
5247
|
modeName: "default",
|
|
5218
5248
|
styles: {}
|
|
5219
5249
|
})
|
|
5220
|
-
), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new
|
|
5221
|
-
adapter: new
|
|
5250
|
+
), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new Zi({
|
|
5251
|
+
adapter: new Qi({ map: t, ...this.options.adapterOptions }),
|
|
5222
5252
|
modes: i
|
|
5223
5253
|
}), this.map?.loaded() ? this.terradraw.start() : this.map?.once("load", () => {
|
|
5224
5254
|
this.terradraw?.start();
|
|
@@ -5316,7 +5346,7 @@ class qe {
|
|
|
5316
5346
|
*/
|
|
5317
5347
|
addTerradrawButton(t) {
|
|
5318
5348
|
const e = document.createElement("button");
|
|
5319
|
-
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 =
|
|
5349
|
+
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 = ve("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 = ve(t.replace(/-/g, " ")), t === "delete" ? (e.classList.add(`maplibregl-terradraw-${this.cssPrefix}${t}-button`), e.addEventListener("click", () => {
|
|
5320
5350
|
this.terradraw && this.terradraw.enabled && (this.terradraw.clear(), this.deactivate(), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.dispatchEvent("feature-deleted"));
|
|
5321
5351
|
})) : t === "delete-selection" ? (e.classList.add(`maplibregl-terradraw-${this.cssPrefix}${t}-button`), e.classList.add("hidden-delete-selection"), e.addEventListener("click", () => {
|
|
5322
5352
|
if (!this.terradraw || !this.terradraw.enabled) return;
|
|
@@ -5364,10 +5394,10 @@ class qe {
|
|
|
5364
5394
|
* @returns
|
|
5365
5395
|
*/
|
|
5366
5396
|
cleanStyle(t, e) {
|
|
5367
|
-
return
|
|
5397
|
+
return Ut(
|
|
5368
5398
|
t,
|
|
5369
5399
|
e,
|
|
5370
|
-
|
|
5400
|
+
et,
|
|
5371
5401
|
this.options.adapterOptions?.prefixId
|
|
5372
5402
|
);
|
|
5373
5403
|
}
|
|
@@ -5431,16 +5461,16 @@ class qe {
|
|
|
5431
5461
|
}
|
|
5432
5462
|
}
|
|
5433
5463
|
}
|
|
5434
|
-
function
|
|
5464
|
+
function Bo(r, t = {}) {
|
|
5435
5465
|
let e = 0, i = 0, o = 0;
|
|
5436
|
-
return
|
|
5466
|
+
return Ge(
|
|
5437
5467
|
r,
|
|
5438
5468
|
function(s) {
|
|
5439
5469
|
e += s[0], i += s[1], o++;
|
|
5440
5470
|
}
|
|
5441
|
-
),
|
|
5471
|
+
), so([e / o, i / o], t.properties);
|
|
5442
5472
|
}
|
|
5443
|
-
class
|
|
5473
|
+
class Xo extends Ke {
|
|
5444
5474
|
measureOptions;
|
|
5445
5475
|
elevationCache;
|
|
5446
5476
|
/**
|
|
@@ -5547,8 +5577,8 @@ class Jo extends qe {
|
|
|
5547
5577
|
*/
|
|
5548
5578
|
constructor(t) {
|
|
5549
5579
|
let e = {
|
|
5550
|
-
...JSON.parse(JSON.stringify(
|
|
5551
|
-
modeOptions: { ...
|
|
5580
|
+
...JSON.parse(JSON.stringify(lt)),
|
|
5581
|
+
modeOptions: { ...lt.modeOptions }
|
|
5552
5582
|
};
|
|
5553
5583
|
t && (e = Object.assign(e, t));
|
|
5554
5584
|
const i = e.adapterOptions?.prefixId ?? "td-measure";
|
|
@@ -5557,7 +5587,7 @@ class Jo extends qe {
|
|
|
5557
5587
|
open: e.open,
|
|
5558
5588
|
modeOptions: e.modeOptions,
|
|
5559
5589
|
adapterOptions: e.adapterOptions
|
|
5560
|
-
}), this._cssPrefix = "measure-", this.measureOptions = e, this.measureOptions.elevationCacheConfig && this.measureOptions.elevationCacheConfig?.enabled && (this.elevationCache = new
|
|
5590
|
+
}), this._cssPrefix = "measure-", this.measureOptions = e, this.measureOptions.elevationCacheConfig && this.measureOptions.elevationCacheConfig?.enabled && (this.elevationCache = new ze(
|
|
5561
5591
|
this.measureOptions.elevationCacheConfig.maxSize,
|
|
5562
5592
|
this.measureOptions.elevationCacheConfig.ttl
|
|
5563
5593
|
));
|
|
@@ -5623,12 +5653,12 @@ class Jo extends qe {
|
|
|
5623
5653
|
* @returns
|
|
5624
5654
|
*/
|
|
5625
5655
|
cleanStyle(t, e) {
|
|
5626
|
-
const i =
|
|
5656
|
+
const i = et, o = this.measureOptions.polygonLayerSpec?.source;
|
|
5627
5657
|
o && i.push(o);
|
|
5628
5658
|
const s = this.measureOptions.lineLayerLabelSpec?.source;
|
|
5629
5659
|
s && i.push(s);
|
|
5630
5660
|
const n = this.measureOptions.pointLayerLabelSpec?.source;
|
|
5631
|
-
return n && i.push(n),
|
|
5661
|
+
return n && i.push(n), Ut(
|
|
5632
5662
|
t,
|
|
5633
5663
|
e,
|
|
5634
5664
|
i,
|
|
@@ -5711,7 +5741,7 @@ class Jo extends qe {
|
|
|
5711
5741
|
* Handle finish event of terradraw. It will be called after finishing adding a feature
|
|
5712
5742
|
* @param id Feature ID
|
|
5713
5743
|
*/
|
|
5714
|
-
handleTerradrawFeatureReady =
|
|
5744
|
+
handleTerradrawFeatureReady = Ue((t) => {
|
|
5715
5745
|
this.map && (this.computeElevationByLineFeatureID(t), this.computeElevationByPointFeatureID(t));
|
|
5716
5746
|
}, 300);
|
|
5717
5747
|
/**
|
|
@@ -5776,7 +5806,7 @@ class Jo extends qe {
|
|
|
5776
5806
|
if (o && typeof o.data != "string" && o.data.type === "FeatureCollection") {
|
|
5777
5807
|
const s = [];
|
|
5778
5808
|
for (const a of t)
|
|
5779
|
-
this.terradraw?.getSnapshotFeature(a.id) && s.push(a);
|
|
5809
|
+
(this.terradraw?.getSnapshotFeature(a.id) || this.terradraw?.getSnapshotFeature(a.properties.originalId)) && s.push(a);
|
|
5780
5810
|
const n = s.map((a) => a.id);
|
|
5781
5811
|
if (typeof o.data != "string" && o.data.type === "FeatureCollection") {
|
|
5782
5812
|
i === "linestring" ? o.data.features = [
|
|
@@ -5810,7 +5840,7 @@ class Jo extends qe {
|
|
|
5810
5840
|
(o) => o.properties?.originalId === t && o.geometry.type === "Point"
|
|
5811
5841
|
);
|
|
5812
5842
|
if (i && i.length > 0) {
|
|
5813
|
-
const o = await
|
|
5843
|
+
const o = await Pe(
|
|
5814
5844
|
i,
|
|
5815
5845
|
this.measureOptions.terrainSource,
|
|
5816
5846
|
this.measureOptions.elevationCacheConfig,
|
|
@@ -5837,7 +5867,7 @@ class Jo extends qe {
|
|
|
5837
5867
|
(o) => o.id === t && o.geometry.type === "Point" && o.properties?.mode === "point"
|
|
5838
5868
|
);
|
|
5839
5869
|
if (i && i.length > 0) {
|
|
5840
|
-
const o = await
|
|
5870
|
+
const o = await Pe(
|
|
5841
5871
|
i,
|
|
5842
5872
|
this.measureOptions.terrainSource,
|
|
5843
5873
|
this.measureOptions.elevationCacheConfig,
|
|
@@ -5868,7 +5898,7 @@ class Jo extends qe {
|
|
|
5868
5898
|
(a) => a.properties?.originalId !== t
|
|
5869
5899
|
));
|
|
5870
5900
|
const n = JSON.parse(JSON.stringify(o));
|
|
5871
|
-
n.id = n.id + "-area-label", n.geometry =
|
|
5901
|
+
n.id = n.id + "-area-label", n.geometry = Bo(o.geometry).geometry, n.properties.originalId = o.id, o = ge(o, this.areaUnit, this.areaPrecision, this.forceAreaUnit), n.properties.area = o.properties.area, n.properties.unit = o.properties.unit, typeof s.data != "string" && s.data.type === "FeatureCollection" && s.data.features.push(n), this.map.getSource(
|
|
5872
5902
|
this.measureOptions.polygonLayerSpec.source
|
|
5873
5903
|
)?.setData(s.data), this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && this.map.moveLayer(
|
|
5874
5904
|
this.measureOptions.lineLayerLabelSpec.id
|
|
@@ -5898,7 +5928,7 @@ class Jo extends qe {
|
|
|
5898
5928
|
if (s) {
|
|
5899
5929
|
typeof s.data != "string" && s.data.type === "FeatureCollection" && (s.data.features = s.data.features.filter(
|
|
5900
5930
|
(a) => a.properties?.originalId !== t
|
|
5901
|
-
)), o =
|
|
5931
|
+
)), o = me(
|
|
5902
5932
|
o,
|
|
5903
5933
|
this.distanceUnit,
|
|
5904
5934
|
this.distancePrecision,
|
|
@@ -5908,9 +5938,7 @@ class Jo extends qe {
|
|
|
5908
5938
|
);
|
|
5909
5939
|
const n = o.properties.segments;
|
|
5910
5940
|
for (let a = 0; a < n.length; a++) {
|
|
5911
|
-
const l = n[a];
|
|
5912
|
-
typeof s.data != "string" && s.data.type === "FeatureCollection" && s.data.features.push(l);
|
|
5913
|
-
const d = l.geometry.coordinates, c = d[0], h = d[1];
|
|
5941
|
+
const l = n[a], d = l.geometry.coordinates, c = d[0], h = d[1];
|
|
5914
5942
|
if (a === 0) {
|
|
5915
5943
|
const p = JSON.parse(JSON.stringify(l));
|
|
5916
5944
|
p.id = `${l.id}-node-${a}`, p.geometry = {
|
|
@@ -5947,7 +5975,7 @@ class Jo extends qe {
|
|
|
5947
5975
|
let o = e.getSnapshot()?.find((s) => s.id === t && s.geometry.type === "Point");
|
|
5948
5976
|
if (o) {
|
|
5949
5977
|
const s = this.map.getStyle().sources[this.measureOptions.pointLayerLabelSpec.source];
|
|
5950
|
-
s && (typeof s.data != "string" && s.data.type === "FeatureCollection" && (s.data.features = s.data.features.filter((n) => n.id !== t)), o =
|
|
5978
|
+
s && (typeof s.data != "string" && s.data.type === "FeatureCollection" && (s.data.features = s.data.features.filter((n) => n.id !== t)), o = Ce(
|
|
5951
5979
|
o,
|
|
5952
5980
|
this.map,
|
|
5953
5981
|
this.computeElevation,
|
|
@@ -5992,14 +6020,14 @@ class Jo extends qe {
|
|
|
5992
6020
|
const o = e.features[i];
|
|
5993
6021
|
if (!this.map || !this.map.loaded()) continue;
|
|
5994
6022
|
const s = o.geometry.type;
|
|
5995
|
-
s === "LineString" ? e.features[i] =
|
|
6023
|
+
s === "LineString" ? e.features[i] = me(
|
|
5996
6024
|
o,
|
|
5997
6025
|
this.distanceUnit,
|
|
5998
6026
|
this.distancePrecision,
|
|
5999
6027
|
this.map,
|
|
6000
6028
|
this.computeElevation,
|
|
6001
6029
|
this.measureOptions.terrainSource
|
|
6002
|
-
) : s === "Polygon" ? e.features[i] =
|
|
6030
|
+
) : s === "Polygon" ? e.features[i] = ge(o, this.areaUnit, this.areaPrecision, this.forceAreaUnit) : s === "Point" && (e.features[i] = Ce(
|
|
6003
6031
|
o,
|
|
6004
6032
|
this.map,
|
|
6005
6033
|
this.computeElevation,
|
|
@@ -6009,7 +6037,7 @@ class Jo extends qe {
|
|
|
6009
6037
|
return e;
|
|
6010
6038
|
}
|
|
6011
6039
|
}
|
|
6012
|
-
class
|
|
6040
|
+
class Ho extends Ke {
|
|
6013
6041
|
controlOptions;
|
|
6014
6042
|
valhallaOptions;
|
|
6015
6043
|
_modalDialog;
|
|
@@ -6149,11 +6177,11 @@ class qo extends qe {
|
|
|
6149
6177
|
*/
|
|
6150
6178
|
constructor(t) {
|
|
6151
6179
|
let e = {
|
|
6152
|
-
...JSON.parse(JSON.stringify(
|
|
6153
|
-
modeOptions: { ...
|
|
6180
|
+
...JSON.parse(JSON.stringify(z)),
|
|
6181
|
+
modeOptions: { ...z.modeOptions }
|
|
6154
6182
|
};
|
|
6155
6183
|
t && (e = Object.assign(e, t), e.valhallaOptions = Object.assign(
|
|
6156
|
-
JSON.parse(JSON.stringify(
|
|
6184
|
+
JSON.parse(JSON.stringify(z.valhallaOptions)),
|
|
6157
6185
|
e.valhallaOptions
|
|
6158
6186
|
)), e.adapterOptions || (e.adapterOptions = {}), e.adapterOptions.prefixId = e.adapterOptions?.prefixId ?? "td-valhalla";
|
|
6159
6187
|
const i = e.adapterOptions?.prefixId ?? "td-valhalla";
|
|
@@ -6205,16 +6233,16 @@ class qo extends qe {
|
|
|
6205
6233
|
* @returns
|
|
6206
6234
|
*/
|
|
6207
6235
|
cleanStyle(t, e) {
|
|
6208
|
-
const i =
|
|
6236
|
+
const i = et, o = this.controlOptions.routingLineLayerNodeSpec?.source;
|
|
6209
6237
|
o && i.push(o);
|
|
6210
6238
|
const s = this.controlOptions.isochronePolygonLayerSpec?.source;
|
|
6211
|
-
return s && i.push(s),
|
|
6239
|
+
return s && i.push(s), Ut(t, e, i, this.options.adapterOptions?.prefixId);
|
|
6212
6240
|
}
|
|
6213
6241
|
/**
|
|
6214
6242
|
* Create the settings dialog for Valhalla control
|
|
6215
6243
|
*/
|
|
6216
6244
|
createSettingsDialog() {
|
|
6217
|
-
this.settingDialog = new
|
|
6245
|
+
this.settingDialog = new fo(
|
|
6218
6246
|
`maplibregl-terradraw-${this.cssPrefix}settings-dialog`,
|
|
6219
6247
|
"Settings"
|
|
6220
6248
|
), this.settingDialog.create(
|
|
@@ -6256,7 +6284,7 @@ class qo extends qe {
|
|
|
6256
6284
|
const i = document.createElement("label");
|
|
6257
6285
|
i.textContent = "Means of Transport", i.classList.add("setting-label"), e.appendChild(i), e.appendChild(
|
|
6258
6286
|
this.settingDialog.createSegmentButtons(
|
|
6259
|
-
|
|
6287
|
+
Nt,
|
|
6260
6288
|
this.routingCostingModel,
|
|
6261
6289
|
(n) => {
|
|
6262
6290
|
this.valhallaOptions.routingOptions || (this.valhallaOptions.routingOptions = {}), this.valhallaOptions.routingOptions.costingModel = n, this.dispatchEvent("setting-changed");
|
|
@@ -6268,7 +6296,7 @@ class qo extends qe {
|
|
|
6268
6296
|
const s = document.createElement("label");
|
|
6269
6297
|
return s.textContent = "Distance Unit", s.classList.add("setting-label"), o.appendChild(s), o.appendChild(
|
|
6270
6298
|
this.settingDialog.createSegmentButtons(
|
|
6271
|
-
|
|
6299
|
+
To,
|
|
6272
6300
|
this.routingDistanceUnit,
|
|
6273
6301
|
(n) => {
|
|
6274
6302
|
this.valhallaOptions.routingOptions || (this.valhallaOptions.routingOptions = {}), this.valhallaOptions.routingOptions.distanceUnit = n, this.dispatchEvent("setting-changed");
|
|
@@ -6285,7 +6313,7 @@ class qo extends qe {
|
|
|
6285
6313
|
const i = document.createElement("label");
|
|
6286
6314
|
i.textContent = "Contour Type", i.classList.add("setting-label"), e.appendChild(i), e.appendChild(
|
|
6287
6315
|
this.settingDialog.createSegmentButtons(
|
|
6288
|
-
|
|
6316
|
+
ko,
|
|
6289
6317
|
this.controlOptions.valhallaOptions?.isochroneOptions?.contourType || "time",
|
|
6290
6318
|
(d) => {
|
|
6291
6319
|
this.valhallaOptions.isochroneOptions || (this.valhallaOptions.isochroneOptions = {}), this.valhallaOptions.isochroneOptions.contourType = d, this.dispatchEvent("setting-changed");
|
|
@@ -6297,7 +6325,7 @@ class qo extends qe {
|
|
|
6297
6325
|
const s = document.createElement("label");
|
|
6298
6326
|
s.textContent = "Means of Transport", s.classList.add("setting-label"), o.appendChild(s), o.appendChild(
|
|
6299
6327
|
this.settingDialog.createSegmentButtons(
|
|
6300
|
-
|
|
6328
|
+
Nt,
|
|
6301
6329
|
this.controlOptions.valhallaOptions?.isochroneOptions?.costingModel || "auto",
|
|
6302
6330
|
(d) => {
|
|
6303
6331
|
this.valhallaOptions.isochroneOptions || (this.valhallaOptions.isochroneOptions = {}), this.valhallaOptions.isochroneOptions.costingModel = d, this.dispatchEvent("setting-changed");
|
|
@@ -6480,32 +6508,34 @@ class qo extends qe {
|
|
|
6480
6508
|
* Handle finish event of terradraw. It will be called after finishing adding a feature
|
|
6481
6509
|
* @param id Feature ID
|
|
6482
6510
|
*/
|
|
6483
|
-
handleTerradrawFeatureReady =
|
|
6511
|
+
handleTerradrawFeatureReady = Ue((t) => {
|
|
6484
6512
|
this.map && (this.computeRouteByLineFeatureID(t), this.computeIsochroneByPointFeatureID(t));
|
|
6485
6513
|
}, 300);
|
|
6486
6514
|
computeIsochroneByPointFeatureID = async (t) => {
|
|
6487
6515
|
if (!this.map || !this.valhallaOptions.url) return;
|
|
6488
6516
|
const e = this.terradraw?.getSnapshotFeature(t);
|
|
6489
6517
|
if (!e || e && e.geometry.type !== "Point") return;
|
|
6490
|
-
const i = e.geometry.coordinates, n = (await new
|
|
6518
|
+
const i = e.geometry.coordinates, n = (await new No(this.valhallaUrl).calcIsochrone(
|
|
6491
6519
|
i[0],
|
|
6492
6520
|
i[1],
|
|
6493
6521
|
this.isochroneContourType,
|
|
6494
6522
|
this.isochroneCostingModel,
|
|
6495
6523
|
this.isochroneContours
|
|
6496
|
-
)).features.map((
|
|
6497
|
-
e.properties = {
|
|
6498
|
-
...e.properties,
|
|
6524
|
+
)).features.map((d) => (d.id = `${t}-${d.properties.contour}`, d.properties.originalId = t, d)), a = {
|
|
6499
6525
|
contourType: this.isochroneContourType,
|
|
6500
6526
|
costingModel: this.isochroneCostingModel,
|
|
6501
6527
|
result: n
|
|
6502
|
-
}
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6528
|
+
};
|
|
6529
|
+
e.properties = {
|
|
6530
|
+
...e.properties,
|
|
6531
|
+
...a
|
|
6532
|
+
}, this.terradraw?.updateFeatureProperties(t, a);
|
|
6533
|
+
const l = this.map.getStyle().sources[this.controlOptions.isochronePolygonLayerSpec.source];
|
|
6534
|
+
l && (typeof l.data != "string" && l.data.type === "FeatureCollection" && (l.data.features = l.data.features.filter(
|
|
6535
|
+
(d) => d.properties?.originalId !== t
|
|
6536
|
+
)), typeof l.data != "string" && l.data.type === "FeatureCollection" && l.data.features.push(...n), this.map.getSource(
|
|
6507
6537
|
this.controlOptions.isochronePolygonLayerSpec.source
|
|
6508
|
-
)?.setData(
|
|
6538
|
+
)?.setData(l.data), this.map.moveLayer(
|
|
6509
6539
|
this.controlOptions.isochronePolygonLayerSpec.id
|
|
6510
6540
|
), this.map.moveLayer(this.controlOptions.isochroneLineLayerSpec.id), this.map.moveLayer(
|
|
6511
6541
|
this.controlOptions.isochroneLabelLayerSpec.id
|
|
@@ -6519,9 +6549,9 @@ class qo extends qe {
|
|
|
6519
6549
|
if (!this.map || !this.valhallaOptions.url) return;
|
|
6520
6550
|
const e = this.terradraw?.getSnapshotFeature(t);
|
|
6521
6551
|
if (!e || e && e.geometry.type !== "LineString") return;
|
|
6522
|
-
const i = new
|
|
6552
|
+
const i = new Wo(this.valhallaUrl), o = e.geometry.coordinates.map((c) => {
|
|
6523
6553
|
const h = c;
|
|
6524
|
-
return new
|
|
6554
|
+
return new Xe(h[0], h[1]);
|
|
6525
6555
|
});
|
|
6526
6556
|
if (!o || o && o.length < 2) return;
|
|
6527
6557
|
const s = await i.calcRoute(
|
|
@@ -6531,10 +6561,10 @@ class qo extends qe {
|
|
|
6531
6561
|
);
|
|
6532
6562
|
if (!s || !s.feature) return;
|
|
6533
6563
|
const n = s?.feature.geometry;
|
|
6534
|
-
e.geometry = n, e.properties = {
|
|
6564
|
+
this.terradraw?.updateFeatureGeometry(t, n), e.geometry = n, e.properties = {
|
|
6535
6565
|
...e.properties,
|
|
6536
6566
|
...s?.feature.properties
|
|
6537
|
-
}, this.terradraw?.
|
|
6567
|
+
}, this.terradraw?.updateFeatureProperties(t, s?.feature.properties);
|
|
6538
6568
|
const l = (s?.pointFeatures).features.map((c) => (c.id = `${t}-${c.id}`, c.properties.originalId = t, c)), d = this.map.getStyle().sources[this.controlOptions.routingLineLayerNodeSpec.source];
|
|
6539
6569
|
d && (typeof d.data != "string" && d.data.type === "FeatureCollection" && (d.data.features = d.data.features.filter(
|
|
6540
6570
|
(c) => c.properties?.originalId !== t
|
|
@@ -6590,35 +6620,35 @@ class qo extends qe {
|
|
|
6590
6620
|
}
|
|
6591
6621
|
}
|
|
6592
6622
|
export {
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
6598
|
-
|
|
6599
|
-
|
|
6600
|
-
|
|
6601
|
-
|
|
6623
|
+
zo as AvailableModes,
|
|
6624
|
+
Vo as AvailableValhallaModes,
|
|
6625
|
+
Xo as MaplibreMeasureControl,
|
|
6626
|
+
Ke as MaplibreTerradrawControl,
|
|
6627
|
+
Ho as MaplibreValhallaControl,
|
|
6628
|
+
ze as MemoryCache,
|
|
6629
|
+
fo as ModalDialog,
|
|
6630
|
+
$o as TERRADRAW_MEASURE_SOURCE_IDS,
|
|
6631
|
+
et as TERRADRAW_SOURCE_IDS,
|
|
6602
6632
|
Yo as TERRADRAW_VALHALLA_SOURCE_IDS,
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
|
|
6608
|
-
|
|
6609
|
-
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
|
|
6616
|
-
|
|
6617
|
-
|
|
6618
|
-
|
|
6619
|
-
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
|
|
6633
|
+
No as ValhallaIsochrone,
|
|
6634
|
+
Wo as ValhallaRouting,
|
|
6635
|
+
ge as calcArea,
|
|
6636
|
+
me as calcDistance,
|
|
6637
|
+
ve as capitalize,
|
|
6638
|
+
Ut as cleanMaplibreStyle,
|
|
6639
|
+
ko as contourTypeOptions,
|
|
6640
|
+
po as convertAreaUnit,
|
|
6641
|
+
Ft as convertMetricDistance,
|
|
6642
|
+
Nt as costingModelOptions,
|
|
6643
|
+
Ue as debounce,
|
|
6644
|
+
to as defaultControlOptions,
|
|
6645
|
+
lt as defaultMeasureControlOptions,
|
|
6646
|
+
z as defaultValhallaControlOptions,
|
|
6647
|
+
eo as getDefaultModeOptions,
|
|
6648
|
+
fe as getDistanceUnitName,
|
|
6649
|
+
Ce as queryElevationByPoint,
|
|
6650
|
+
Pe as queryElevationFromRasterDEM,
|
|
6651
|
+
Ko as roundFeatureCoordinates,
|
|
6652
|
+
To as routingDistanceUnitOptions
|
|
6623
6653
|
};
|
|
6624
6654
|
//# sourceMappingURL=maplibre-gl-terradraw.es.js.map
|