@watergis/maplibre-gl-terradraw 1.2.2 → 1.3.0
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 +1071 -773
- package/dist/maplibre-gl-terradraw.es.js.map +1 -1
- package/dist/maplibre-gl-terradraw.umd.js +2 -2
- package/dist/maplibre-gl-terradraw.umd.js.map +1 -1
- package/dist/types/constants/defaultMeasureControlOptions.d.ts.map +1 -1
- package/dist/types/constants/index.d.ts +0 -1
- package/dist/types/constants/index.d.ts.map +1 -1
- package/dist/types/controls/MaplibreMeasureControl.d.ts +12 -2
- package/dist/types/controls/MaplibreMeasureControl.d.ts.map +1 -1
- package/dist/types/controls/MaplibreTerradrawControl.d.ts +8 -4
- package/dist/types/controls/MaplibreTerradrawControl.d.ts.map +1 -1
- package/dist/types/helpers/capitalize.d.ts +2 -0
- package/dist/types/helpers/capitalize.d.ts.map +1 -0
- package/dist/types/helpers/cleanMaplibreStyle.d.ts +8 -0
- package/dist/types/helpers/cleanMaplibreStyle.d.ts.map +1 -0
- package/dist/types/helpers/debounce.d.ts +2 -0
- package/dist/types/helpers/debounce.d.ts.map +1 -0
- package/dist/types/helpers/index.d.ts +4 -0
- package/dist/types/helpers/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/interfaces/MeasureControlOptions.d.ts +3 -2
- package/dist/types/interfaces/MeasureControlOptions.d.ts.map +1 -1
- package/dist/types/interfaces/index.d.ts +0 -1
- package/dist/types/interfaces/index.d.ts.map +1 -1
- package/package.json +18 -6
- package/dist/types/constants/AvailableMeasureModes.d.ts +0 -2
- package/dist/types/constants/AvailableMeasureModes.d.ts.map +0 -1
- package/dist/types/interfaces/MeasureControlMode.d.ts +0 -3
- package/dist/types/interfaces/MeasureControlMode.d.ts.map +0 -1
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var Be = Object.defineProperty;
|
|
2
|
+
var je = (r, t, e) => t in r ? Be(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
+
var _ = (r, t, e) => je(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import "maplibre-gl";
|
|
5
|
-
function
|
|
6
|
-
return
|
|
5
|
+
function I() {
|
|
6
|
+
return I = Object.assign ? Object.assign.bind() : function(r) {
|
|
7
7
|
for (var t = 1; t < arguments.length; t++) {
|
|
8
8
|
var e = arguments[t];
|
|
9
9
|
for (var i in e) ({}).hasOwnProperty.call(e, i) && (r[i] = e[i]);
|
|
10
10
|
}
|
|
11
11
|
return r;
|
|
12
|
-
},
|
|
12
|
+
}, I.apply(null, arguments);
|
|
13
13
|
}
|
|
14
|
-
var
|
|
14
|
+
var M;
|
|
15
15
|
(function(r) {
|
|
16
16
|
r.Commit = "commit", r.Provisional = "provisional", r.Finish = "finish";
|
|
17
|
-
})(
|
|
18
|
-
const V = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT: "selectionPoint" }, J = "edited", st = "closingPoint",
|
|
19
|
-
function
|
|
17
|
+
})(M || (M = {}));
|
|
18
|
+
const V = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT: "selectionPoint" }, J = "edited", st = "closingPoint", Ot = "snappingPoint";
|
|
19
|
+
function It(r) {
|
|
20
20
|
return !!(r && typeof r == "object" && r !== null && !Array.isArray(r));
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function Tt(r) {
|
|
23
23
|
return !!function(t) {
|
|
24
24
|
return typeof t == "number" && !isNaN(new Date(t).valueOf());
|
|
25
25
|
}(r);
|
|
26
26
|
}
|
|
27
|
-
const
|
|
27
|
+
const Ne = "Feature mode property does not match the mode being added to";
|
|
28
28
|
var Y;
|
|
29
29
|
(function(r) {
|
|
30
30
|
r.Drawing = "drawing", r.Select = "select", r.Static = "static", r.Render = "render";
|
|
@@ -46,7 +46,7 @@ class N {
|
|
|
46
46
|
registerBehaviors(t) {
|
|
47
47
|
}
|
|
48
48
|
constructor(t) {
|
|
49
|
-
this._state = void 0, this._styles = void 0, this.behaviors = [], this.validate = void 0, this.pointerDistance = void 0, this.coordinatePrecision = void 0, this.onStyleChange = void 0, this.store = void 0, this.setDoubleClickToZoom = void 0, this.unproject = void 0, this.project = void 0, this.setCursor = void 0, this.projection = void 0, this.type = Y.Drawing, this.mode = "base", this._state = "unregistered", this._styles = t && t.styles ?
|
|
49
|
+
this._state = void 0, this._styles = void 0, this.behaviors = [], this.validate = void 0, this.pointerDistance = void 0, this.coordinatePrecision = void 0, this.onStyleChange = void 0, this.store = void 0, this.setDoubleClickToZoom = void 0, this.unproject = void 0, this.project = void 0, this.setCursor = void 0, this.projection = void 0, this.type = Y.Drawing, this.mode = "base", this._state = "unregistered", this._styles = t && t.styles ? I({}, t.styles) : {}, this.pointerDistance = t && t.pointerDistance || 40, this.validate = t && t.validation, this.projection = t && t.projection || "web-mercator";
|
|
50
50
|
}
|
|
51
51
|
setDrawing() {
|
|
52
52
|
if (this._state !== "started") throw new Error("Mode must be unregistered or stopped to start");
|
|
@@ -71,9 +71,9 @@ class N {
|
|
|
71
71
|
if (this._state === "unregistered") throw new Error("Mode must be registered");
|
|
72
72
|
const e = function(i, o) {
|
|
73
73
|
let s;
|
|
74
|
-
if (
|
|
74
|
+
if (It(i)) if (i.id == null) s = "Feature has no id";
|
|
75
75
|
else if (typeof i.id != "string" && typeof i.id != "number") s = "Feature must be string or number as per GeoJSON spec";
|
|
76
|
-
else if (o(i.id)) if (
|
|
76
|
+
else if (o(i.id)) if (It(i.geometry)) if (It(i.properties)) if (typeof i.geometry.type == "string" && ["Polygon", "LineString", "Point"].includes(i.geometry.type)) if (Array.isArray(i.geometry.coordinates)) {
|
|
77
77
|
if (!i.properties.mode || typeof i.properties.mode != "string") return { valid: !1, reason: "Feature does not have a valid mode property" };
|
|
78
78
|
} else s = "Feature coordinates is not an array";
|
|
79
79
|
else s = "Feature is not Point, LineString or Polygon";
|
|
@@ -84,14 +84,14 @@ class N {
|
|
|
84
84
|
return s ? { valid: !1, reason: s } : { valid: !0 };
|
|
85
85
|
}(t, this.store.idStrategy.isValidId);
|
|
86
86
|
if (this.validate) {
|
|
87
|
-
const i = this.validate(t, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
87
|
+
const i = this.validate(t, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Provisional });
|
|
88
88
|
return { valid: e.valid && i.valid, reason: i.reason };
|
|
89
89
|
}
|
|
90
90
|
return { valid: e.valid, reason: e.reason };
|
|
91
91
|
}
|
|
92
92
|
validateModeFeature(t, e) {
|
|
93
93
|
const i = this.performFeatureValidation(t);
|
|
94
|
-
return i.valid ? t.properties.mode !== this.mode ? { valid: !1, reason:
|
|
94
|
+
return i.valid ? t.properties.mode !== this.mode ? { valid: !1, reason: Ne } : e(t) : { valid: !1, reason: i.reason };
|
|
95
95
|
}
|
|
96
96
|
onFinish(t, e) {
|
|
97
97
|
}
|
|
@@ -123,20 +123,20 @@ class N {
|
|
|
123
123
|
return t === void 0 ? e : typeof t == "function" ? t(i) : t;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
class
|
|
126
|
+
class Ae extends N {
|
|
127
127
|
constructor(...t) {
|
|
128
128
|
super(...t), this.type = Y.Select;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
function
|
|
132
|
-
const e = (
|
|
133
|
-
return 2 * Math.atan2(Math.sqrt(
|
|
131
|
+
function G(r, t) {
|
|
132
|
+
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);
|
|
133
|
+
return 2 * Math.atan2(Math.sqrt(l), Math.sqrt(1 - l)) * 6371e3 / 1e3;
|
|
134
134
|
}
|
|
135
|
-
const
|
|
135
|
+
const le = 63710088e-1;
|
|
136
136
|
function E(r) {
|
|
137
137
|
return r % 360 * Math.PI / 180;
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function de(r) {
|
|
140
140
|
return r / 6371.0088;
|
|
141
141
|
}
|
|
142
142
|
function U(r) {
|
|
@@ -146,20 +146,20 @@ function F(r, t = 9) {
|
|
|
146
146
|
const e = Math.pow(10, t);
|
|
147
147
|
return Math.round(r * e) / e;
|
|
148
148
|
}
|
|
149
|
-
const
|
|
150
|
-
function
|
|
151
|
-
const i = E(r[0]), o = E(r[1]), s = E(e), n =
|
|
149
|
+
const Gt = 57.29577951308232, Vt = 0.017453292519943295, pt = 6378137, x = (r, t) => ({ x: r === 0 ? 0 : r * Vt * pt, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * Vt / 2)) * pt }), W = (r, t) => ({ lng: r === 0 ? 0 : Gt * (r / pt), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / pt)) - Math.PI / 2) * Gt });
|
|
150
|
+
function Te(r, t, e) {
|
|
151
|
+
const i = E(r[0]), o = E(r[1]), s = E(e), n = de(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(s));
|
|
152
152
|
return [U(i + Math.atan2(Math.sin(s) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), U(a)];
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function Ut(r) {
|
|
155
155
|
const { center: t, radiusKilometers: e, coordinatePrecision: i } = r, o = r.steps ? r.steps : 64, s = [];
|
|
156
156
|
for (let n = 0; n < o; n++) {
|
|
157
|
-
const a =
|
|
157
|
+
const a = Te(t, e, -360 * n / o);
|
|
158
158
|
s.push([F(a[0], i), F(a[1], i)]);
|
|
159
159
|
}
|
|
160
160
|
return s.push(s[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [s] }, properties: {} };
|
|
161
161
|
}
|
|
162
|
-
function
|
|
162
|
+
function Dt(r) {
|
|
163
163
|
let t;
|
|
164
164
|
if (r.geometry.type === "Polygon") t = r.geometry.coordinates;
|
|
165
165
|
else {
|
|
@@ -167,52 +167,52 @@ function Et(r) {
|
|
|
167
167
|
t = [r.geometry.coordinates];
|
|
168
168
|
}
|
|
169
169
|
const e = [];
|
|
170
|
-
for (let s = 0; s < t.length; s++) for (let n = 0; n < t[s].length - 1; n++) for (let a = 0; a < t.length; a++) for (let
|
|
170
|
+
for (let s = 0; s < t.length; s++) for (let n = 0; n < t[s].length - 1; n++) for (let a = 0; a < t.length; a++) for (let l = 0; l < t[a].length - 1; l++) o(s, n, a, l);
|
|
171
171
|
return e.length > 0;
|
|
172
172
|
function i(s) {
|
|
173
173
|
return s < 0 || s > 1;
|
|
174
174
|
}
|
|
175
|
-
function o(s, n, a,
|
|
176
|
-
const
|
|
175
|
+
function o(s, n, a, l) {
|
|
176
|
+
const d = t[s][n], c = t[s][n + 1], h = t[a][l], u = t[a][l + 1], p = function(v, f, m, C) {
|
|
177
177
|
if (at(v, m) || at(v, C) || at(f, m) || at(C, m)) return null;
|
|
178
|
-
const P = v[0],
|
|
179
|
-
return z === 0 ? null : [((P *
|
|
180
|
-
}(
|
|
178
|
+
const P = v[0], S = v[1], b = f[0], w = f[1], D = m[0], A = m[1], L = C[0], j = C[1], z = (P - b) * (A - j) - (S - w) * (D - L);
|
|
179
|
+
return z === 0 ? null : [((P * w - S * b) * (D - L) - (P - b) * (D * j - A * L)) / z, ((P * w - S * b) * (A - j) - (S - w) * (D * j - A * L)) / z];
|
|
180
|
+
}(d, c, h, u);
|
|
181
181
|
if (p === null) return;
|
|
182
182
|
let g, y;
|
|
183
|
-
g = c[0] !==
|
|
183
|
+
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));
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
function at(r, t) {
|
|
187
187
|
return r[0] === t[0] && r[1] === t[1];
|
|
188
188
|
}
|
|
189
|
-
function
|
|
190
|
-
return r.length === 2 && typeof r[0] == "number" && typeof r[1] == "number" && r[0] !== 1 / 0 && r[1] !== 1 / 0 && (i = r[0]) >= -180 && i <= 180 && (e = r[1]) >= -90 && e <= 90 &&
|
|
189
|
+
function vt(r, t) {
|
|
190
|
+
return r.length === 2 && typeof r[0] == "number" && typeof r[1] == "number" && r[0] !== 1 / 0 && r[1] !== 1 / 0 && (i = r[0]) >= -180 && i <= 180 && (e = r[1]) >= -90 && e <= 90 && zt(r[0]) <= t && zt(r[1]) <= t;
|
|
191
191
|
var e, i;
|
|
192
192
|
}
|
|
193
|
-
function
|
|
193
|
+
function zt(r) {
|
|
194
194
|
let t = 1, e = 0;
|
|
195
195
|
for (; Math.round(r * t) / t !== r; ) t *= 10, e++;
|
|
196
196
|
return e;
|
|
197
197
|
}
|
|
198
|
-
const
|
|
199
|
-
function
|
|
200
|
-
return r.geometry.type !== "Polygon" ? { valid: !1, reason: "Feature is not a Polygon" } : r.geometry.coordinates.length !== 1 ? { valid: !1, reason:
|
|
198
|
+
const Ge = "Feature has holes", Ve = "Feature has less than 4 coordinates", Ue = "Feature has invalid coordinates", ze = "Feature coordinates are not closed";
|
|
199
|
+
function Ct(r, t) {
|
|
200
|
+
return r.geometry.type !== "Polygon" ? { valid: !1, reason: "Feature is not a Polygon" } : r.geometry.coordinates.length !== 1 ? { valid: !1, reason: Ge } : r.geometry.coordinates[0].length < 4 ? { valid: !1, reason: Ve } : r.geometry.coordinates[0].every((o) => vt(o, t)) ? (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: ze } : { valid: !0 } : { valid: !1, reason: Ue };
|
|
201
201
|
var e, i;
|
|
202
202
|
}
|
|
203
203
|
function nt(r, t) {
|
|
204
|
-
const e =
|
|
205
|
-
return e.valid ?
|
|
204
|
+
const e = Ct(r, t);
|
|
205
|
+
return e.valid ? Dt(r) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
|
|
206
206
|
}
|
|
207
|
-
class
|
|
207
|
+
class ce extends N {
|
|
208
208
|
constructor(t) {
|
|
209
209
|
var e;
|
|
210
210
|
super(t), this.mode = "circle", this.center = void 0, this.clickCount = 0, this.currentCircleId = void 0, this.keyEvents = void 0, this.cursors = void 0, this.startingRadiusKilometers = 1e-5, this.cursorMovedAfterInitialCursorDown = !1;
|
|
211
211
|
const i = { start: "crosshair" };
|
|
212
|
-
if (this.cursors = t && t.cursors ?
|
|
212
|
+
if (this.cursors = t && t.cursors ? I({}, i, t.cursors) : i, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
|
|
213
213
|
else {
|
|
214
214
|
const o = { cancel: "Escape", finish: "Enter" };
|
|
215
|
-
this.keyEvents = t && t.keyEvents ?
|
|
215
|
+
this.keyEvents = t && t.keyEvents ? I({}, o, t.keyEvents) : o;
|
|
216
216
|
}
|
|
217
217
|
this.startingRadiusKilometers = (e = t == null ? void 0 : t.startingRadiusKilometers) != null ? e : 1e-5, this.validate = t == null ? void 0 : t.validation;
|
|
218
218
|
}
|
|
@@ -221,7 +221,7 @@ class se extends N {
|
|
|
221
221
|
const t = this.currentCircleId;
|
|
222
222
|
if (this.validate && t) {
|
|
223
223
|
const e = this.store.getGeometryCopy(t);
|
|
224
|
-
if (!this.validate({ type: "Feature", id: t, geometry: e, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
224
|
+
if (!this.validate({ type: "Feature", id: t, geometry: e, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Finish }).valid) return;
|
|
225
225
|
}
|
|
226
226
|
this.cursorMovedAfterInitialCursorDown = !1, this.center = void 0, this.currentCircleId = void 0, this.clickCount = 0, this.state === "drawing" && this.setStarted(), this.onFinish(t, { mode: this.mode, action: "draw" });
|
|
227
227
|
}
|
|
@@ -234,7 +234,7 @@ class se extends N {
|
|
|
234
234
|
onClick(t) {
|
|
235
235
|
if (this.clickCount === 0) {
|
|
236
236
|
this.center = [t.lng, t.lat];
|
|
237
|
-
const e =
|
|
237
|
+
const e = Ut({ center: this.center, radiusKilometers: this.startingRadiusKilometers, coordinatePrecision: this.coordinatePrecision }), [i] = this.store.create([{ geometry: e.geometry, properties: { mode: this.mode, radiusKilometers: this.startingRadiusKilometers } }]);
|
|
238
238
|
this.currentCircleId = i, this.clickCount++, this.cursorMovedAfterInitialCursorDown = !1, this.setDrawing();
|
|
239
239
|
} else this.clickCount === 1 && this.center && this.currentCircleId !== void 0 && this.cursorMovedAfterInitialCursorDown && this.updateCircle(t), this.close();
|
|
240
240
|
}
|
|
@@ -261,7 +261,7 @@ class se extends N {
|
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
styleFeature(t) {
|
|
264
|
-
const e =
|
|
264
|
+
const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
265
265
|
return t.type === "Feature" && t.geometry.type === "Polygon" && t.properties.mode === this.mode && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
|
|
266
266
|
}
|
|
267
267
|
validateFeature(t) {
|
|
@@ -269,45 +269,45 @@ class se extends N {
|
|
|
269
269
|
}
|
|
270
270
|
updateCircle(t) {
|
|
271
271
|
if (this.clickCount === 1 && this.center && this.currentCircleId) {
|
|
272
|
-
const e =
|
|
272
|
+
const e = G(this.center, [t.lng, t.lat]);
|
|
273
273
|
let i;
|
|
274
274
|
if (this.projection === "web-mercator") {
|
|
275
275
|
const o = function(s, n) {
|
|
276
|
-
const a = 1e3 *
|
|
276
|
+
const a = 1e3 * G(s, n);
|
|
277
277
|
if (a === 0) return 1;
|
|
278
|
-
const { x:
|
|
279
|
-
return Math.sqrt(Math.pow(c -
|
|
278
|
+
const { x: l, y: d } = x(s[0], s[1]), { x: c, y: h } = x(n[0], n[1]);
|
|
279
|
+
return Math.sqrt(Math.pow(c - l, 2) + Math.pow(h - d, 2)) / a;
|
|
280
280
|
}(this.center, [t.lng, t.lat]);
|
|
281
281
|
i = function(s) {
|
|
282
|
-
const { center: n, radiusKilometers: a, coordinatePrecision:
|
|
283
|
-
for (let v = 0; v <
|
|
284
|
-
const f = 360 * v /
|
|
285
|
-
y.push([F(
|
|
282
|
+
const { center: n, radiusKilometers: a, coordinatePrecision: l } = s, d = s.steps ? s.steps : 64, c = 1e3 * a, [h, u] = n, { x: p, y: g } = x(h, u), y = [];
|
|
283
|
+
for (let v = 0; v < d; v++) {
|
|
284
|
+
const f = 360 * v / d * Math.PI / 180, m = c * Math.cos(f), C = c * Math.sin(f), [P, S] = [p + m, g + C], { lng: b, lat: w } = W(P, S);
|
|
285
|
+
y.push([F(b, l), F(w, l)]);
|
|
286
286
|
}
|
|
287
287
|
return y.push(y[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [y] }, properties: {} };
|
|
288
288
|
}({ center: this.center, radiusKilometers: e * o, coordinatePrecision: this.coordinatePrecision });
|
|
289
289
|
} else {
|
|
290
290
|
if (this.projection !== "globe") throw new Error("Invalid projection");
|
|
291
|
-
i =
|
|
291
|
+
i = Ut({ center: this.center, radiusKilometers: e, coordinatePrecision: this.coordinatePrecision });
|
|
292
292
|
}
|
|
293
|
-
if (this.validate && !this.validate({ type: "Feature", id: this.currentCircleId, geometry: i.geometry, properties: { radiusKilometers: e } }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
293
|
+
if (this.validate && !this.validate({ type: "Feature", id: this.currentCircleId, geometry: i.geometry, properties: { radiusKilometers: e } }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Provisional }).valid) return;
|
|
294
294
|
this.store.updateGeometry([{ id: this.currentCircleId, geometry: i.geometry }]), this.store.updateProperty([{ id: this.currentCircleId, property: "radiusKilometers", value: e }]);
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
-
const
|
|
298
|
+
const O = (r, t) => {
|
|
299
299
|
const { x: e, y: i } = r, { x: o, y: s } = t, n = o - e, a = s - i;
|
|
300
300
|
return Math.sqrt(a * a + n * n);
|
|
301
301
|
};
|
|
302
|
-
let
|
|
302
|
+
let he = class extends N {
|
|
303
303
|
constructor(t) {
|
|
304
304
|
super(t), this.mode = "freehand", this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.minDistance = void 0, this.keyEvents = void 0, this.cursors = void 0, this.preventPointsNearClose = void 0, this.autoClose = void 0, this.autoCloseTimeout = 500, this.hasLeftStartingPoint = !1, this.preventNewFeature = !1;
|
|
305
305
|
const e = { start: "crosshair", close: "pointer" };
|
|
306
|
-
if (this.cursors = t && t.cursors ?
|
|
306
|
+
if (this.cursors = t && t.cursors ? I({}, e, t.cursors) : e, this.preventPointsNearClose = t && t.preventPointsNearClose || !0, t && t.autoCloseTimeout && !t.autoClose) throw new Error("autoCloseTimeout is set, but autoClose is not enabled");
|
|
307
307
|
if (this.autoClose = t && t.autoClose || !1, this.autoCloseTimeout = t && t.autoCloseTimeout || 500, this.minDistance = t && t.minDistance || 20, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
|
|
308
308
|
else {
|
|
309
309
|
const i = { cancel: "Escape", finish: "Enter" };
|
|
310
|
-
this.keyEvents = t && t.keyEvents ?
|
|
310
|
+
this.keyEvents = t && t.keyEvents ? I({}, i, t.keyEvents) : i;
|
|
311
311
|
}
|
|
312
312
|
this.validate = t == null ? void 0 : t.validation;
|
|
313
313
|
}
|
|
@@ -316,7 +316,7 @@ let re = class extends N {
|
|
|
316
316
|
const t = this.currentId;
|
|
317
317
|
if (this.validate && t) {
|
|
318
318
|
const e = this.store.getGeometryCopy(t);
|
|
319
|
-
if (!this.validate({ type: "Feature", id: t, geometry: e, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
319
|
+
if (!this.validate({ type: "Feature", id: t, geometry: e, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Finish }).valid) return;
|
|
320
320
|
}
|
|
321
321
|
this.closingPointId && this.store.delete([this.closingPointId]), this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.hasLeftStartingPoint = !1, this.state === "drawing" && this.setStarted(), this.onFinish(t, { mode: this.mode, action: "draw" });
|
|
322
322
|
}
|
|
@@ -328,16 +328,16 @@ let re = class extends N {
|
|
|
328
328
|
}
|
|
329
329
|
onMouseMove(t) {
|
|
330
330
|
if (this.currentId === void 0 || this.startingClick === !1) return;
|
|
331
|
-
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),
|
|
332
|
-
if (
|
|
331
|
+
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 = O({ x: n, y: a }, { x: t.containerX, y: t.containerY }), [d, c] = e.coordinates[0][0], { x: h, y: u } = this.project(d, c);
|
|
332
|
+
if (O({ x: h, y: u }, { x: t.containerX, y: t.containerY }) < this.pointerDistance) {
|
|
333
333
|
if (this.autoClose && this.hasLeftStartingPoint && (this.preventNewFeature = !0, setTimeout(() => {
|
|
334
334
|
this.preventNewFeature = !1;
|
|
335
335
|
}, this.autoCloseTimeout), this.close()), this.setCursor(this.cursors.close), this.preventPointsNearClose) return;
|
|
336
336
|
} else this.hasLeftStartingPoint = !0, this.setCursor(this.cursors.start);
|
|
337
|
-
if (
|
|
337
|
+
if (l < this.minDistance) return;
|
|
338
338
|
e.coordinates[0].pop();
|
|
339
339
|
const p = { type: "Polygon", coordinates: [[...e.coordinates[0], [t.lng, t.lat], e.coordinates[0][0]]] };
|
|
340
|
-
this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: p, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
340
|
+
this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: p, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Provisional }).valid || this.store.updateGeometry([{ id: this.currentId, geometry: p }]);
|
|
341
341
|
}
|
|
342
342
|
onClick(t) {
|
|
343
343
|
if (!this.preventNewFeature) {
|
|
@@ -368,40 +368,40 @@ let re = class extends N {
|
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
370
|
styleFeature(t) {
|
|
371
|
-
const e =
|
|
371
|
+
const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
372
372
|
return t.type === "Feature" && t.geometry.type === "Polygon" && t.properties.mode === this.mode ? (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10, e) : (t.type === "Feature" && t.geometry.type === "Point" && t.properties.mode === this.mode && (e.pointWidth = this.getNumericStylingValue(this.styles.closingPointWidth, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(this.styles.closingPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.closingPointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.closingPointOutlineWidth, 2, t), e.zIndex = 40), e);
|
|
373
373
|
}
|
|
374
374
|
validateFeature(t) {
|
|
375
|
-
return this.validateModeFeature(t, (e) =>
|
|
375
|
+
return this.validateModeFeature(t, (e) => Ct(e, this.coordinatePrecision));
|
|
376
376
|
}
|
|
377
377
|
}, B = class {
|
|
378
378
|
constructor({ store: t, mode: e, project: i, unproject: o, pointerDistance: s, coordinatePrecision: n, projection: a }) {
|
|
379
379
|
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;
|
|
380
380
|
}
|
|
381
381
|
};
|
|
382
|
-
function
|
|
382
|
+
function ue({ unproject: r, point: t, pointerDistance: e }) {
|
|
383
383
|
const i = e / 2, { x: o, y: s } = t;
|
|
384
384
|
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])] } };
|
|
385
385
|
}
|
|
386
|
-
let
|
|
386
|
+
let Pt = class extends B {
|
|
387
387
|
constructor(t) {
|
|
388
388
|
super(t);
|
|
389
389
|
}
|
|
390
390
|
create(t) {
|
|
391
391
|
const { containerX: e, containerY: i } = t;
|
|
392
|
-
return
|
|
392
|
+
return ue({ unproject: this.unproject, point: { x: e, y: i }, pointerDistance: this.pointerDistance });
|
|
393
393
|
}
|
|
394
394
|
};
|
|
395
|
-
class
|
|
395
|
+
class St extends B {
|
|
396
396
|
constructor(t) {
|
|
397
397
|
super(t);
|
|
398
398
|
}
|
|
399
399
|
measure(t, e) {
|
|
400
400
|
const { x: i, y: o } = this.project(e[0], e[1]);
|
|
401
|
-
return
|
|
401
|
+
return O({ x: i, y: o }, { x: t.containerX, y: t.containerY });
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
|
-
class
|
|
404
|
+
class pe extends B {
|
|
405
405
|
constructor(t, e, i) {
|
|
406
406
|
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;
|
|
407
407
|
}
|
|
@@ -414,87 +414,87 @@ class ae extends B {
|
|
|
414
414
|
if (n.geometry.type !== "LineString") return;
|
|
415
415
|
a = n.geometry.coordinates;
|
|
416
416
|
}
|
|
417
|
-
a.forEach((
|
|
418
|
-
const c = this.pixelDistance.measure(t,
|
|
419
|
-
c < s.minDist && c < this.pointerDistance && (s.coordinate =
|
|
417
|
+
a.forEach((l, d) => {
|
|
418
|
+
const c = this.pixelDistance.measure(t, l);
|
|
419
|
+
c < s.minDist && c < this.pointerDistance && (s.coordinate = l, s.minDist = c, s.featureId = n.id, s.featureCoordinateIndex = d);
|
|
420
420
|
});
|
|
421
421
|
}), s;
|
|
422
422
|
}
|
|
423
423
|
}
|
|
424
|
-
function
|
|
425
|
-
const i = E(r[0]), o = E(r[1]), s = E(e), n =
|
|
424
|
+
function Rt(r, t, e) {
|
|
425
|
+
const i = E(r[0]), o = E(r[1]), s = E(e), n = de(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(s));
|
|
426
426
|
return [U(i + Math.atan2(Math.sin(s) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), U(a)];
|
|
427
427
|
}
|
|
428
428
|
function rt({ x: r, y: t }, e, i) {
|
|
429
429
|
const o = E(i);
|
|
430
430
|
return { x: r + e * Math.cos(o), y: t + e * Math.sin(o) };
|
|
431
431
|
}
|
|
432
|
-
function
|
|
432
|
+
function Xt(r, t) {
|
|
433
433
|
const e = E(r[0]), i = E(t[0]), o = E(r[1]), s = E(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);
|
|
434
434
|
return U(Math.atan2(n, a));
|
|
435
435
|
}
|
|
436
|
-
function
|
|
436
|
+
function T({ x: r, y: t }, { x: e, y: i }) {
|
|
437
437
|
let o = Math.atan2(i - t, e - r);
|
|
438
438
|
return o *= 180 / Math.PI, o > 180 ? o -= 360 : o < -180 && (o += 360), o;
|
|
439
439
|
}
|
|
440
440
|
function K(r) {
|
|
441
441
|
return (r + 360) % 360;
|
|
442
442
|
}
|
|
443
|
-
function
|
|
443
|
+
function Re(r, t, e) {
|
|
444
444
|
const i = [], o = r.length;
|
|
445
|
-
let s, n, a,
|
|
446
|
-
for (let c = 0; c < r.length && !(t >=
|
|
447
|
-
if (
|
|
448
|
-
if (s = t -
|
|
449
|
-
n =
|
|
445
|
+
let s, n, a, l = 0;
|
|
446
|
+
for (let c = 0; c < r.length && !(t >= l && c === r.length - 1); c++) {
|
|
447
|
+
if (l > t && i.length === 0) {
|
|
448
|
+
if (s = t - l, !s) return i.push(r[c]), i;
|
|
449
|
+
n = Xt(r[c], r[c - 1]) - 180, a = Rt(r[c], s, n), i.push(a);
|
|
450
450
|
}
|
|
451
|
-
if (
|
|
452
|
-
if (
|
|
453
|
-
|
|
451
|
+
if (l >= e) return s = e - l, s ? (n = Xt(r[c], r[c - 1]) - 180, a = Rt(r[c], s, n), i.push(a), i) : (i.push(r[c]), i);
|
|
452
|
+
if (l >= t && i.push(r[c]), c === r.length - 1) return i;
|
|
453
|
+
l += G(r[c], r[c + 1]);
|
|
454
454
|
}
|
|
455
|
-
if (
|
|
456
|
-
const
|
|
457
|
-
return [
|
|
455
|
+
if (l < t && r.length === o) throw new Error("Start position is beyond line");
|
|
456
|
+
const d = r[r.length - 1];
|
|
457
|
+
return [d, d];
|
|
458
458
|
}
|
|
459
459
|
function lt(r) {
|
|
460
460
|
return r * (Math.PI / 180);
|
|
461
461
|
}
|
|
462
|
-
function
|
|
462
|
+
function Kt(r) {
|
|
463
463
|
return r * (180 / Math.PI);
|
|
464
464
|
}
|
|
465
|
-
class
|
|
465
|
+
class Xe extends B {
|
|
466
466
|
constructor(t) {
|
|
467
467
|
super(t), this.config = void 0, this.config = t;
|
|
468
468
|
}
|
|
469
469
|
generateInsertionCoordinates(t, e, i) {
|
|
470
470
|
const o = [t, e];
|
|
471
471
|
let s = 0;
|
|
472
|
-
for (let
|
|
472
|
+
for (let d = 0; d < o.length - 1; d++) s += G(o[0], o[1]);
|
|
473
473
|
if (s <= i) return o;
|
|
474
474
|
let n = s / i - 1;
|
|
475
475
|
Number.isInteger(n) || (n = Math.floor(n) + 1);
|
|
476
476
|
const a = [];
|
|
477
|
-
for (let
|
|
478
|
-
const c =
|
|
477
|
+
for (let d = 0; d < n; d++) {
|
|
478
|
+
const c = Re(o, i * d, i * (d + 1));
|
|
479
479
|
a.push(c);
|
|
480
480
|
}
|
|
481
|
-
const
|
|
482
|
-
for (let
|
|
483
|
-
return this.limitCoordinates(
|
|
481
|
+
const l = [];
|
|
482
|
+
for (let d = 0; d < a.length; d++) l.push(a[d][1]);
|
|
483
|
+
return this.limitCoordinates(l);
|
|
484
484
|
}
|
|
485
485
|
generateInsertionGeodesicCoordinates(t, e, i) {
|
|
486
|
-
const o =
|
|
487
|
-
const
|
|
488
|
-
|
|
486
|
+
const o = G(t, e), s = function(n, a, l) {
|
|
487
|
+
const d = [], c = lt(n[1]), h = lt(n[0]), u = lt(a[1]), p = lt(a[0]);
|
|
488
|
+
l += 1;
|
|
489
489
|
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));
|
|
490
|
-
if (g === 0 || isNaN(g)) return
|
|
491
|
-
for (let y = 0; y <=
|
|
492
|
-
const v = y /
|
|
493
|
-
if (isNaN(C) || isNaN(P) || isNaN(
|
|
494
|
-
const
|
|
495
|
-
isNaN(
|
|
490
|
+
if (g === 0 || isNaN(g)) return d;
|
|
491
|
+
for (let y = 0; y <= l; y++) {
|
|
492
|
+
const v = y / l, f = Math.sin((1 - v) * g) / Math.sin(g), m = Math.sin(v * g) / Math.sin(g), C = f * Math.cos(c) * Math.cos(h) + m * Math.cos(u) * Math.cos(p), P = f * Math.cos(c) * Math.sin(h) + m * Math.cos(u) * Math.sin(p), S = f * Math.sin(c) + m * Math.sin(u);
|
|
493
|
+
if (isNaN(C) || isNaN(P) || isNaN(S)) continue;
|
|
494
|
+
const b = Math.atan2(S, Math.sqrt(C ** 2 + P ** 2)), w = Math.atan2(P, C);
|
|
495
|
+
isNaN(b) || isNaN(w) || d.push([Kt(w), Kt(b)]);
|
|
496
496
|
}
|
|
497
|
-
return
|
|
497
|
+
return d.slice(1, -1);
|
|
498
498
|
}(t, e, Math.floor(o / i));
|
|
499
499
|
return this.limitCoordinates(s);
|
|
500
500
|
}
|
|
@@ -505,24 +505,24 @@ class je extends B {
|
|
|
505
505
|
function Z(r, t) {
|
|
506
506
|
return r[0] === t[0] && r[1] === t[1];
|
|
507
507
|
}
|
|
508
|
-
function
|
|
509
|
-
return r.geometry.type !== "LineString" ? { valid: !1, reason: "Feature is not a LineString" } : r.geometry.coordinates.length < 2 ? { valid: !1, reason: "Feature has less than 2 coordinates" } : r.geometry.coordinates.every((e) =>
|
|
508
|
+
function ge(r, t) {
|
|
509
|
+
return r.geometry.type !== "LineString" ? { valid: !1, reason: "Feature is not a LineString" } : r.geometry.coordinates.length < 2 ? { valid: !1, reason: "Feature has less than 2 coordinates" } : r.geometry.coordinates.every((e) => vt(e, t)) ? { valid: !0 } : { valid: !1, reason: "Feature has invalid coordinates" };
|
|
510
510
|
}
|
|
511
|
-
class
|
|
511
|
+
class ye extends N {
|
|
512
512
|
constructor(t) {
|
|
513
513
|
super(t), this.mode = "linestring", this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.keyEvents = void 0, this.snapping = void 0, this.cursors = void 0, this.mouseMove = !1, this.insertCoordinates = void 0, this.lastCommitedCoordinates = void 0, this.snappedPointId = void 0, this.coordinateSnapping = void 0, this.insertPoint = void 0;
|
|
514
514
|
const e = { start: "crosshair", close: "pointer" };
|
|
515
|
-
if (this.cursors = t && t.cursors ?
|
|
515
|
+
if (this.cursors = t && t.cursors ? I({}, e, t.cursors) : e, this.snapping = t && t.snapping ? t.snapping : void 0, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
|
|
516
516
|
else {
|
|
517
517
|
const i = { cancel: "Escape", finish: "Enter" };
|
|
518
|
-
this.keyEvents = t && t.keyEvents ?
|
|
518
|
+
this.keyEvents = t && t.keyEvents ? I({}, i, t.keyEvents) : i;
|
|
519
519
|
}
|
|
520
520
|
this.validate = t == null ? void 0 : t.validation, this.insertCoordinates = t == null ? void 0 : t.insertCoordinates;
|
|
521
521
|
}
|
|
522
522
|
close() {
|
|
523
523
|
if (this.currentId === void 0) return;
|
|
524
524
|
const t = this.store.getGeometryCopy(this.currentId);
|
|
525
|
-
t.coordinates.pop(), this.updateGeometries([...t.coordinates], void 0,
|
|
525
|
+
t.coordinates.pop(), this.updateGeometries([...t.coordinates], void 0, M.Commit);
|
|
526
526
|
const e = this.currentId;
|
|
527
527
|
this.closingPointId && this.store.delete([this.closingPointId]), this.snappedPointId && this.store.delete([this.snappedPointId]), this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.snappedPointId = void 0, this.lastCommitedCoordinates = void 0, this.state === "drawing" && this.setStarted(), this.onFinish(e, { mode: this.mode, action: "draw" });
|
|
528
528
|
}
|
|
@@ -536,7 +536,7 @@ class de extends N {
|
|
|
536
536
|
generateInsertCoordinates(t, e) {
|
|
537
537
|
if (!this.insertCoordinates || !this.lastCommitedCoordinates) throw new Error("Not able to insert coordinates");
|
|
538
538
|
if (this.insertCoordinates.strategy !== "amount") throw new Error("Strategy does not exist");
|
|
539
|
-
const i =
|
|
539
|
+
const i = G(t, e) / (this.insertCoordinates.value + 1);
|
|
540
540
|
let o = [];
|
|
541
541
|
return this.projection === "globe" ? o = this.insertPoint.generateInsertionGeodesicCoordinates(t, e, i) : this.projection === "web-mercator" && (o = this.insertPoint.generateInsertionCoordinates(t, e, i)), o;
|
|
542
542
|
}
|
|
@@ -549,18 +549,18 @@ class de extends N {
|
|
|
549
549
|
const e = this.store.getGeometryCopy(this.currentId).coordinates, [i] = this.store.create([{ geometry: { type: "Point", coordinates: [...t] }, properties: { mode: this.mode } }]);
|
|
550
550
|
this.closingPointId = i, this.setCursor(this.cursors.close);
|
|
551
551
|
const o = [...e, t];
|
|
552
|
-
this.updateGeometries(o, void 0,
|
|
552
|
+
this.updateGeometries(o, void 0, M.Commit), this.currentCoordinate++;
|
|
553
553
|
}
|
|
554
554
|
updateToLine(t, e) {
|
|
555
555
|
if (!this.currentId) return;
|
|
556
556
|
const i = this.store.getGeometryCopy(this.currentId).coordinates, [o, s] = this.lastCommitedCoordinates ? this.lastCommitedCoordinates[this.lastCommitedCoordinates.length - 1] : i[i.length - 2], { x: n, y: a } = this.project(o, s);
|
|
557
|
-
if (
|
|
557
|
+
if (O({ x: n, y: a }, { x: e.x, y: e.y }) < this.pointerDistance) return void this.close();
|
|
558
558
|
this.setCursor(this.cursors.close);
|
|
559
|
-
const
|
|
560
|
-
this.updateGeometries(
|
|
559
|
+
const l = [...i, t];
|
|
560
|
+
this.updateGeometries(l, i[i.length - 1], M.Commit), this.currentCoordinate++;
|
|
561
561
|
}
|
|
562
562
|
registerBehaviors(t) {
|
|
563
|
-
this.coordinateSnapping = new
|
|
563
|
+
this.coordinateSnapping = new pe(t, new St(t), new Pt(t)), this.insertPoint = new Xe(t);
|
|
564
564
|
}
|
|
565
565
|
start() {
|
|
566
566
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -574,7 +574,7 @@ class de extends N {
|
|
|
574
574
|
if (e) {
|
|
575
575
|
if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: e } }]);
|
|
576
576
|
else {
|
|
577
|
-
const [n] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [
|
|
577
|
+
const [n] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [Ot]: !0 } }]);
|
|
578
578
|
this.snappedPointId = n;
|
|
579
579
|
}
|
|
580
580
|
t.lng = e[0], t.lat = e[1];
|
|
@@ -583,18 +583,18 @@ class de extends N {
|
|
|
583
583
|
if (this.currentId === void 0 || this.currentCoordinate === 0) return;
|
|
584
584
|
const o = this.store.getGeometryCopy(this.currentId).coordinates;
|
|
585
585
|
if (o.pop(), this.closingPointId) {
|
|
586
|
-
const [n, a] = o[o.length - 1], { x:
|
|
587
|
-
|
|
586
|
+
const [n, a] = o[o.length - 1], { x: l, y: d } = this.project(n, a);
|
|
587
|
+
O({ x: l, y: d }, { x: t.containerX, y: t.containerY }) < this.pointerDistance && this.setCursor(this.cursors.close);
|
|
588
588
|
}
|
|
589
589
|
let s = [...o, i];
|
|
590
590
|
if (this.insertCoordinates && this.currentId && this.lastCommitedCoordinates) {
|
|
591
591
|
const n = this.lastCommitedCoordinates[this.lastCommitedCoordinates.length - 1], a = i;
|
|
592
592
|
if (!Z(n, a)) {
|
|
593
|
-
const
|
|
594
|
-
s = [...this.lastCommitedCoordinates.slice(0, -1), ...
|
|
593
|
+
const l = this.generateInsertCoordinates(n, a);
|
|
594
|
+
s = [...this.lastCommitedCoordinates.slice(0, -1), ...l, i];
|
|
595
595
|
}
|
|
596
596
|
}
|
|
597
|
-
this.updateGeometries(s, void 0,
|
|
597
|
+
this.updateGeometries(s, void 0, M.Provisional);
|
|
598
598
|
}
|
|
599
599
|
onClick(t) {
|
|
600
600
|
this.currentCoordinate > 0 && !this.mouseMove && this.onMouseMove(t), this.mouseMove = !1, this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0);
|
|
@@ -621,7 +621,7 @@ class de extends N {
|
|
|
621
621
|
}
|
|
622
622
|
}
|
|
623
623
|
styleFeature(t) {
|
|
624
|
-
const e =
|
|
624
|
+
const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
625
625
|
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 = 10, e;
|
|
626
626
|
if (t.type === "Feature" && t.geometry.type === "Point" && t.properties.mode === this.mode) {
|
|
627
627
|
const i = t.properties[st];
|
|
@@ -630,7 +630,7 @@ class de extends N {
|
|
|
630
630
|
return e;
|
|
631
631
|
}
|
|
632
632
|
validateFeature(t) {
|
|
633
|
-
return this.validateModeFeature(t, (e) =>
|
|
633
|
+
return this.validateModeFeature(t, (e) => ge(e, this.coordinatePrecision));
|
|
634
634
|
}
|
|
635
635
|
snapCoordinate(t) {
|
|
636
636
|
var e, i;
|
|
@@ -638,15 +638,15 @@ class de extends N {
|
|
|
638
638
|
return (e = this.snapping) != null && e.toCoordinate && (o = this.currentId ? this.coordinateSnapping.getSnappableCoordinate(t, this.currentId) : this.coordinateSnapping.getSnappableCoordinateFirstClick(t)), (i = this.snapping) != null && i.toCustom && (o = this.snapping.toCustom(t)), o;
|
|
639
639
|
}
|
|
640
640
|
}
|
|
641
|
-
const
|
|
642
|
-
function
|
|
643
|
-
return r.geometry.type !== "Point" ? { valid: !1, reason:
|
|
641
|
+
const Ke = "Feature is not a Point", Ye = "Feature has invalid coordinates";
|
|
642
|
+
function fe(r, t) {
|
|
643
|
+
return r.geometry.type !== "Point" ? { valid: !1, reason: Ke } : vt(r.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: Ye };
|
|
644
644
|
}
|
|
645
|
-
class
|
|
645
|
+
class me extends N {
|
|
646
646
|
constructor(t) {
|
|
647
647
|
super(t), this.mode = "point", this.cursors = void 0, this.editable = void 0, this.editedFeatureId = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0;
|
|
648
648
|
const e = { create: "crosshair", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
649
|
-
this.cursors = t && t.cursors ?
|
|
649
|
+
this.cursors = t && t.cursors ? I({}, e, t.cursors) : e, this.editable = !(!t || !t.editable) && t.editable;
|
|
650
650
|
}
|
|
651
651
|
start() {
|
|
652
652
|
this.setStarted(), this.setCursor(this.cursors.create);
|
|
@@ -657,7 +657,7 @@ class Ge extends N {
|
|
|
657
657
|
onClick(t) {
|
|
658
658
|
if (!this.store) throw new Error("Mode must be registered first");
|
|
659
659
|
const e = { type: "Point", coordinates: [t.lng, t.lat] }, i = { mode: this.mode };
|
|
660
|
-
if (this.validate && !this.validate({ type: "Feature", geometry: e, properties: i }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
660
|
+
if (this.validate && !this.validate({ type: "Feature", geometry: e, properties: i }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Finish }).valid) return;
|
|
661
661
|
const [o] = this.store.create([{ geometry: e, properties: i }]);
|
|
662
662
|
this.onFinish(o, { mode: this.mode, action: "draw" });
|
|
663
663
|
}
|
|
@@ -675,26 +675,26 @@ class Ge extends N {
|
|
|
675
675
|
const i = this.clickBoundingBox.create(t), o = this.store.search(i);
|
|
676
676
|
let s, n = 1 / 0;
|
|
677
677
|
for (let a = 0; a < o.length; a++) {
|
|
678
|
-
const
|
|
679
|
-
if (
|
|
680
|
-
const
|
|
681
|
-
|
|
678
|
+
const l = o[a];
|
|
679
|
+
if (l.geometry.type !== "Point" || l.properties.mode !== this.mode) continue;
|
|
680
|
+
const d = this.pixelDistance.measure(t, l.geometry.coordinates);
|
|
681
|
+
d > n || d > this.pointerDistance || (n = d, s = l);
|
|
682
682
|
}
|
|
683
683
|
s && (this.editedFeatureId = s.id);
|
|
684
684
|
}
|
|
685
685
|
this.editedFeatureId && (this.setCursor(this.cursors.dragStart), e(!1));
|
|
686
686
|
}
|
|
687
687
|
onDrag(t, e) {
|
|
688
|
-
this.editedFeatureId !== void 0 && (this.validate && !this.validate({ type: "Feature", geometry: { type: "Point", coordinates: [t.lng, t.lat] }, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
688
|
+
this.editedFeatureId !== void 0 && (this.validate && !this.validate({ type: "Feature", geometry: { type: "Point", coordinates: [t.lng, t.lat] }, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Finish }).valid || (this.store.updateGeometry([{ id: this.editedFeatureId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: J, value: !0 }]), e(!0)));
|
|
689
689
|
}
|
|
690
690
|
onDragEnd(t, e) {
|
|
691
691
|
this.editedFeatureId !== void 0 && (this.onFinish(this.editedFeatureId, { mode: this.mode, action: "edit" }), this.setCursor(this.cursors.dragEnd), this.store.updateProperty([{ id: this.editedFeatureId, property: J, value: !1 }]), this.editedFeatureId = void 0, e(!0));
|
|
692
692
|
}
|
|
693
693
|
registerBehaviors(t) {
|
|
694
|
-
this.pixelDistance = new
|
|
694
|
+
this.pixelDistance = new St(t), this.clickBoundingBox = new Pt(t);
|
|
695
695
|
}
|
|
696
696
|
styleFeature(t) {
|
|
697
|
-
const e =
|
|
697
|
+
const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
698
698
|
if (t.type === "Feature" && t.geometry.type === "Point" && t.properties.mode === this.mode) {
|
|
699
699
|
const i = !!(t.id && this.editedFeatureId === t.id);
|
|
700
700
|
e.pointWidth = this.getNumericStylingValue(i ? this.styles.editedPointWidth : this.styles.pointWidth, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(i ? this.styles.editedPointColor : this.styles.pointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(i ? this.styles.editedPointOutlineColor : this.styles.pointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(i ? this.styles.editedPointOutlineWidth : this.styles.pointOutlineWidth, 2, t), e.zIndex = 30;
|
|
@@ -702,10 +702,10 @@ class Ge extends N {
|
|
|
702
702
|
return e;
|
|
703
703
|
}
|
|
704
704
|
validateFeature(t) {
|
|
705
|
-
return this.validateModeFeature(t, (e) =>
|
|
705
|
+
return this.validateModeFeature(t, (e) => fe(e, this.coordinatePrecision));
|
|
706
706
|
}
|
|
707
707
|
}
|
|
708
|
-
class
|
|
708
|
+
class $e extends B {
|
|
709
709
|
constructor(t, e) {
|
|
710
710
|
super(t), this.config = void 0, this.pixelDistance = void 0, this._startEndPoints = [], this.config = t, this.pixelDistance = e;
|
|
711
711
|
}
|
|
@@ -731,17 +731,17 @@ class Te extends B {
|
|
|
731
731
|
return { isClosing: o < this.pointerDistance, isPreviousClosing: s < this.pointerDistance };
|
|
732
732
|
}
|
|
733
733
|
}
|
|
734
|
-
function
|
|
734
|
+
function Yt(r) {
|
|
735
735
|
return Math.sqrt(Math.pow(r[0], 2) + Math.pow(r[1], 2) + Math.pow(r[2], 2));
|
|
736
736
|
}
|
|
737
737
|
function R(r, t) {
|
|
738
738
|
const e = function(i, o) {
|
|
739
|
-
const [s, n, a] = i, [
|
|
740
|
-
return s *
|
|
741
|
-
}(r, t) / (
|
|
739
|
+
const [s, n, a] = i, [l, d, c] = o;
|
|
740
|
+
return s * l + n * d + a * c;
|
|
741
|
+
}(r, t) / (Yt(r) * Yt(t));
|
|
742
742
|
return Math.acos(Math.min(Math.max(e, -1), 1));
|
|
743
743
|
}
|
|
744
|
-
function
|
|
744
|
+
function bt(r) {
|
|
745
745
|
const t = E(r[1]), e = E(r[0]);
|
|
746
746
|
return [Math.cos(t) * Math.cos(e), Math.cos(t) * Math.sin(e), Math.sin(t)];
|
|
747
747
|
}
|
|
@@ -749,19 +749,19 @@ function X(r) {
|
|
|
749
749
|
const [t, e, i] = r, o = U(Math.asin(i));
|
|
750
750
|
return [U(Math.atan2(e, t)), o];
|
|
751
751
|
}
|
|
752
|
-
function
|
|
753
|
-
const i =
|
|
754
|
-
const [
|
|
755
|
-
return [
|
|
756
|
-
}(i, o), u = c *
|
|
757
|
-
let
|
|
758
|
-
return
|
|
752
|
+
function He(r, t, e) {
|
|
753
|
+
const i = bt(r), o = bt(t), s = bt(e), [n, a, l] = s, [d, c, h] = function(j, z) {
|
|
754
|
+
const [kt, Wt, Bt] = j, [jt, Nt, At] = z;
|
|
755
|
+
return [Wt * At - Bt * Nt, Bt * jt - kt * At, kt * Nt - Wt * jt];
|
|
756
|
+
}(i, o), u = c * l - h * a, p = h * n - d * l, g = d * a - c * n, y = g * c - p * h, v = u * h - g * d, f = p * d - u * c, m = 1 / Math.sqrt(Math.pow(y, 2) + Math.pow(v, 2) + Math.pow(f, 2)), C = [y * m, v * m, f * m], P = [-1 * y * m, -1 * v * m, -1 * f * m], S = R(i, o), b = R(i, C), w = R(o, C), D = R(i, P), A = R(o, P);
|
|
757
|
+
let L;
|
|
758
|
+
return L = b < D && b < A || w < D && w < A ? C : P, R(i, L) > S || R(o, L) > S ? G(X(L), X(i)) <= G(X(L), X(o)) ? [X(i), !0, !1] : [X(o), !1, !0] : [X(L), !1, !1];
|
|
759
759
|
}
|
|
760
|
-
function
|
|
760
|
+
function qe(r, t, e) {
|
|
761
761
|
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)));
|
|
762
762
|
return { x: r.x + s * i, y: r.y + s * o };
|
|
763
763
|
}
|
|
764
|
-
class
|
|
764
|
+
class Je extends B {
|
|
765
765
|
constructor(t, e, i) {
|
|
766
766
|
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;
|
|
767
767
|
}
|
|
@@ -774,59 +774,59 @@ class ze extends B {
|
|
|
774
774
|
if (n.geometry.type !== "LineString") return;
|
|
775
775
|
a = n.geometry.coordinates;
|
|
776
776
|
}
|
|
777
|
-
const
|
|
778
|
-
for (let u = 0; u < a.length - 1; u++)
|
|
779
|
-
let
|
|
777
|
+
const l = [];
|
|
778
|
+
for (let u = 0; u < a.length - 1; u++) l.push([a[u], a[u + 1]]);
|
|
779
|
+
let d;
|
|
780
780
|
const c = [t.lng, t.lat];
|
|
781
|
-
if (this.config.projection === "web-mercator" ?
|
|
781
|
+
if (this.config.projection === "web-mercator" ? d = function(u, p) {
|
|
782
782
|
let g = [1 / 0, 1 / 0], y = 1 / 0, v = 0;
|
|
783
783
|
for (let f of p) {
|
|
784
784
|
const m = f[0], C = f[1];
|
|
785
|
-
let P,
|
|
786
|
-
const
|
|
785
|
+
let P, S = 1 / 0;
|
|
786
|
+
const b = x(m[0], m[1]), w = x(C[0], C[1]), D = x(u[0], u[1]);
|
|
787
787
|
if (m[0] === u[0] && m[1] === u[1]) P = m;
|
|
788
788
|
else if (C[0] === u[0] && C[1] === u[1]) P = C;
|
|
789
789
|
else {
|
|
790
|
-
const { x: A, y:
|
|
790
|
+
const { x: A, y: L } = qe(b, w, D), { lng: j, lat: z } = W(A, L);
|
|
791
791
|
P = [j, z];
|
|
792
792
|
}
|
|
793
|
-
P && (
|
|
793
|
+
P && (S = O(D, x(P[0], P[1])), S < y && (g = P, y = S, v = p.indexOf(f)));
|
|
794
794
|
}
|
|
795
795
|
return y === 1 / 0 ? void 0 : { coordinate: g, lineIndex: v, distance: y };
|
|
796
|
-
}(c,
|
|
796
|
+
}(c, l) : this.config.projection === "globe" && (d = function(u, p) {
|
|
797
797
|
let g = [1 / 0, 1 / 0], y = 1 / 0, v = 0;
|
|
798
798
|
for (let f of p) {
|
|
799
799
|
const m = f[0], C = f[1];
|
|
800
|
-
let P,
|
|
801
|
-
m[0] === u[0] && m[1] === u[1] ? P = m : C[0] === u[0] && C[1] === u[1] ? P = C : [P] =
|
|
800
|
+
let P, S = 1 / 0;
|
|
801
|
+
m[0] === u[0] && m[1] === u[1] ? P = m : C[0] === u[0] && C[1] === u[1] ? P = C : [P] = He(m, C, u), P && (S = G(u, P), S < y && (g = P, y = S, v = p.indexOf(f)));
|
|
802
802
|
}
|
|
803
803
|
return y === 1 / 0 ? void 0 : { coordinate: g, distance: y, lineIndex: v };
|
|
804
|
-
}(c,
|
|
805
|
-
const h = this.pixelDistance.measure(t,
|
|
806
|
-
h < s.minDistance && h < this.pointerDistance && (s.featureId = n.id, s.coordinate =
|
|
804
|
+
}(c, l)), !d) return;
|
|
805
|
+
const h = this.pixelDistance.measure(t, d.coordinate);
|
|
806
|
+
h < s.minDistance && h < this.pointerDistance && (s.featureId = n.id, s.coordinate = d.coordinate, s.featureCoordinateIndex = d.lineIndex, s.minDistance = h);
|
|
807
807
|
}), s;
|
|
808
808
|
}
|
|
809
809
|
}
|
|
810
|
-
class
|
|
810
|
+
class ve extends N {
|
|
811
811
|
constructor(t) {
|
|
812
812
|
super(t), this.mode = "polygon", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.snapping = void 0, this.editable = void 0, this.snappedPointId = void 0, this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedSnapType = void 0, this.editedInsertIndex = void 0, this.editedPointId = void 0, this.lineSnapping = void 0, this.coordinateSnapping = void 0, this.pixelDistance = void 0, this.closingPoints = void 0, this.clickBoundingBox = void 0, this.cursors = void 0, this.mouseMove = !1;
|
|
813
813
|
const e = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
|
|
814
|
-
if (this.cursors = t && t.cursors ?
|
|
814
|
+
if (this.cursors = t && t.cursors ? I({}, e, t.cursors) : e, this.snapping = t && t.snapping ? t.snapping : void 0, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
|
|
815
815
|
else {
|
|
816
816
|
const i = { cancel: "Escape", finish: "Enter" };
|
|
817
|
-
this.keyEvents = t && t.keyEvents ?
|
|
817
|
+
this.keyEvents = t && t.keyEvents ? I({}, i, t.keyEvents) : i;
|
|
818
818
|
}
|
|
819
819
|
this.editable = !(!t || !t.editable) && t.editable;
|
|
820
820
|
}
|
|
821
821
|
close() {
|
|
822
822
|
if (this.currentId === void 0) return;
|
|
823
823
|
const t = this.store.getGeometryCopy(this.currentId).coordinates[0];
|
|
824
|
-
if (t.length < 5 || !this.updatePolygonGeometry([...t.slice(0, -2), t[0]],
|
|
824
|
+
if (t.length < 5 || !this.updatePolygonGeometry([...t.slice(0, -2), t[0]], M.Finish)) return;
|
|
825
825
|
const e = this.currentId;
|
|
826
826
|
this.snappedPointId && this.store.delete([this.snappedPointId]), this.currentCoordinate = 0, this.currentId = void 0, this.snappedPointId = void 0, this.closingPoints.delete(), this.state === "drawing" && this.setStarted(), this.onFinish(e, { mode: this.mode, action: "draw" });
|
|
827
827
|
}
|
|
828
828
|
registerBehaviors(t) {
|
|
829
|
-
this.clickBoundingBox = new
|
|
829
|
+
this.clickBoundingBox = new Pt(t), this.pixelDistance = new St(t), this.lineSnapping = new Je(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new pe(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new $e(t, this.pixelDistance);
|
|
830
830
|
}
|
|
831
831
|
start() {
|
|
832
832
|
this.setStarted(), this.setCursor(this.cursors.start);
|
|
@@ -840,7 +840,7 @@ class he extends N {
|
|
|
840
840
|
if (e) {
|
|
841
841
|
if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: e } }]);
|
|
842
842
|
else {
|
|
843
|
-
const [s] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [
|
|
843
|
+
const [s] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [Ot]: !0 } }]);
|
|
844
844
|
this.snappedPointId = s;
|
|
845
845
|
}
|
|
846
846
|
t.lng = e[0], t.lat = e[1];
|
|
@@ -856,7 +856,7 @@ class he extends N {
|
|
|
856
856
|
const { isClosing: s, isPreviousClosing: n } = this.closingPoints.isClosingPoint(t);
|
|
857
857
|
n || s ? (this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.setCursor(this.cursors.close), o = [...i.slice(0, -2), i[0], i[0]]) : o = [...i.slice(0, -2), [t.lng, t.lat], i[0]];
|
|
858
858
|
}
|
|
859
|
-
this.updatePolygonGeometry(o,
|
|
859
|
+
this.updatePolygonGeometry(o, M.Provisional);
|
|
860
860
|
}
|
|
861
861
|
updatePolygonGeometry(t, e) {
|
|
862
862
|
if (!this.currentId) return !1;
|
|
@@ -886,13 +886,13 @@ class he extends N {
|
|
|
886
886
|
const e = this.snapCoordinate(t);
|
|
887
887
|
e && (t.lng = e[0], t.lat = e[1]);
|
|
888
888
|
const i = this.store.getGeometryCopy(this.currentId);
|
|
889
|
-
if (Z([t.lng, t.lat], i.coordinates[0][0]) || !this.updatePolygonGeometry([i.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], i.coordinates[0][0]],
|
|
889
|
+
if (Z([t.lng, t.lat], i.coordinates[0][0]) || !this.updatePolygonGeometry([i.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], i.coordinates[0][0]], M.Commit)) return;
|
|
890
890
|
this.currentCoordinate++;
|
|
891
891
|
} else if (this.currentCoordinate === 2 && this.currentId) {
|
|
892
892
|
const e = this.snapCoordinate(t);
|
|
893
893
|
e && (t.lng = e[0], t.lat = e[1]);
|
|
894
894
|
const i = this.store.getGeometryCopy(this.currentId).coordinates[0];
|
|
895
|
-
if (Z([t.lng, t.lat], i[1]) || !this.updatePolygonGeometry([i[0], i[1], [t.lng, t.lat], [t.lng, t.lat], i[0]],
|
|
895
|
+
if (Z([t.lng, t.lat], i[1]) || !this.updatePolygonGeometry([i[0], i[1], [t.lng, t.lat], [t.lng, t.lat], i[0]], M.Commit)) return;
|
|
896
896
|
this.currentCoordinate === 2 && this.closingPoints.create(i, "polygon"), this.currentCoordinate++;
|
|
897
897
|
} else if (this.currentId) {
|
|
898
898
|
const e = this.store.getGeometryCopy(this.currentId).coordinates[0], { isClosing: i, isPreviousClosing: o } = this.closingPoints.isClosingPoint(t);
|
|
@@ -903,7 +903,7 @@ class he extends N {
|
|
|
903
903
|
const n = /* @__PURE__ */ function(a = [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]) {
|
|
904
904
|
return { type: "Feature", geometry: { type: "Polygon", coordinates: a }, properties: {} };
|
|
905
905
|
}([[...e.slice(0, -1), [t.lng, t.lat], e[0]]]);
|
|
906
|
-
if (!this.updatePolygonGeometry(n.geometry.coordinates[0],
|
|
906
|
+
if (!this.updatePolygonGeometry(n.geometry.coordinates[0], M.Commit)) return;
|
|
907
907
|
this.currentCoordinate++, this.closingPoints.ids.length && this.closingPoints.update(n.geometry.coordinates[0]);
|
|
908
908
|
}
|
|
909
909
|
}
|
|
@@ -935,7 +935,7 @@ class he extends N {
|
|
|
935
935
|
const i = this.store.getGeometryCopy(this.editedFeatureId), o = i.coordinates[0];
|
|
936
936
|
this.editedSnapType === "coordinate" || this.editedSnapType === "line" && this.editedInsertIndex !== void 0 ? this.editedFeatureCoordinateIndex === 0 || this.editedFeatureCoordinateIndex === i.coordinates[0].length - 1 ? (o[0] = [t.lng, t.lat], o[o.length - 1] = [t.lng, t.lat]) : o[this.editedFeatureCoordinateIndex] = [t.lng, t.lat] : this.editedSnapType === "line" && this.editedInsertIndex === void 0 && (this.editedInsertIndex = this.editedFeatureCoordinateIndex + 1, i.coordinates[0].splice(this.editedInsertIndex, 0, [t.lng, t.lat]), this.editedFeatureCoordinateIndex++);
|
|
937
937
|
const s = { type: "Polygon", coordinates: i.coordinates };
|
|
938
|
-
this.validate && !this.validate({ type: "Feature", geometry: s, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType:
|
|
938
|
+
this.validate && !this.validate({ type: "Feature", geometry: s, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Provisional }).valid || (this.snapping && this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: this.editedFeatureId, geometry: s }]), this.editedPointId && this.store.updateGeometry([{ id: this.editedPointId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: J, value: !0 }]), e(!0));
|
|
939
939
|
}
|
|
940
940
|
onDragEnd(t, e) {
|
|
941
941
|
this.editedFeatureId !== void 0 && (this.setCursor(this.cursors.dragEnd), this.editedPointId && (this.store.delete([this.editedPointId]), this.editedPointId = void 0), this.store.updateProperty([{ id: this.editedFeatureId, property: J, value: !1 }]), this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedInsertIndex = void 0, this.editedSnapType = void 0, e(!0));
|
|
@@ -949,11 +949,11 @@ class he extends N {
|
|
|
949
949
|
}
|
|
950
950
|
}
|
|
951
951
|
styleFeature(t) {
|
|
952
|
-
const e =
|
|
952
|
+
const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
953
953
|
if (t.properties.mode === this.mode) {
|
|
954
954
|
if (t.geometry.type === "Polygon") return e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10, e;
|
|
955
955
|
if (t.geometry.type === "Point") {
|
|
956
|
-
const i = t.properties[J], o = i ? "editedPoint" : t.properties[st] ? "closingPoint" : t.properties[
|
|
956
|
+
const i = t.properties[J], o = i ? "editedPoint" : t.properties[st] ? "closingPoint" : t.properties[Ot] ? "snappingPoint" : void 0;
|
|
957
957
|
if (!o) return e;
|
|
958
958
|
const s = { editedPoint: { width: this.styles.editedPointOutlineWidth, color: this.styles.editedPointColor, outlineColor: this.styles.editedPointOutlineColor, outlineWidth: this.styles.editedPointOutlineWidth }, closingPoint: { width: this.styles.closingPointWidth, color: this.styles.closingPointColor, outlineColor: this.styles.closingPointOutlineColor, outlineWidth: this.styles.closingPointOutlineWidth }, snappingPoint: { width: this.styles.snappingPointWidth, color: this.styles.snappingPointColor, outlineColor: this.styles.snappingPointOutlineColor, outlineWidth: this.styles.snappingPointOutlineWidth } };
|
|
959
959
|
return e.pointWidth = this.getNumericStylingValue(s[o].width, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(s[o].color, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(s[o].outlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(s[o].outlineWidth, 2, t), e.zIndex = i ? 35 : 30, e;
|
|
@@ -962,17 +962,17 @@ class he extends N {
|
|
|
962
962
|
return e;
|
|
963
963
|
}
|
|
964
964
|
validateFeature(t) {
|
|
965
|
-
return this.validateModeFeature(t, (e) =>
|
|
965
|
+
return this.validateModeFeature(t, (e) => Ct(e, this.coordinatePrecision));
|
|
966
966
|
}
|
|
967
967
|
}
|
|
968
|
-
class
|
|
968
|
+
class Ce extends N {
|
|
969
969
|
constructor(t) {
|
|
970
970
|
super(t), this.mode = "rectangle", this.center = void 0, this.clickCount = 0, this.currentRectangleId = void 0, this.keyEvents = void 0, this.cursors = void 0;
|
|
971
971
|
const e = { start: "crosshair" };
|
|
972
|
-
if (this.cursors = t && t.cursors ?
|
|
972
|
+
if (this.cursors = t && t.cursors ? I({}, e, t.cursors) : e, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
|
|
973
973
|
else {
|
|
974
974
|
const i = { cancel: "Escape", finish: "Enter" };
|
|
975
|
-
this.keyEvents = t && t.keyEvents ?
|
|
975
|
+
this.keyEvents = t && t.keyEvents ? I({}, i, t.keyEvents) : i;
|
|
976
976
|
}
|
|
977
977
|
}
|
|
978
978
|
updateRectangle(t, e) {
|
|
@@ -997,10 +997,10 @@ class ue extends N {
|
|
|
997
997
|
this.center = [t.lng, t.lat];
|
|
998
998
|
const [e] = this.store.create([{ geometry: { type: "Polygon", coordinates: [[[t.lng, t.lat], [t.lng, t.lat], [t.lng, t.lat], [t.lng, t.lat]]] }, properties: { mode: this.mode } }]);
|
|
999
999
|
this.currentRectangleId = e, this.clickCount++, this.setDrawing();
|
|
1000
|
-
} else this.updateRectangle(t,
|
|
1000
|
+
} else this.updateRectangle(t, M.Finish), this.close();
|
|
1001
1001
|
}
|
|
1002
1002
|
onMouseMove(t) {
|
|
1003
|
-
this.updateRectangle(t,
|
|
1003
|
+
this.updateRectangle(t, M.Provisional);
|
|
1004
1004
|
}
|
|
1005
1005
|
onKeyDown() {
|
|
1006
1006
|
}
|
|
@@ -1018,7 +1018,7 @@ class ue extends N {
|
|
|
1018
1018
|
this.center = void 0, this.currentRectangleId = void 0, this.clickCount = 0, this.state === "drawing" && this.setStarted(), t !== void 0 && this.store.delete([t]);
|
|
1019
1019
|
}
|
|
1020
1020
|
styleFeature(t) {
|
|
1021
|
-
const e =
|
|
1021
|
+
const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
1022
1022
|
return t.type === "Feature" && t.geometry.type === "Polygon" && t.properties.mode === this.mode && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
|
|
1023
1023
|
}
|
|
1024
1024
|
validateFeature(t) {
|
|
@@ -1060,50 +1060,50 @@ class et extends N {
|
|
|
1060
1060
|
validateFeature(t) {
|
|
1061
1061
|
const e = super.validateFeature(t);
|
|
1062
1062
|
if (e.valid) {
|
|
1063
|
-
const i = t, o =
|
|
1063
|
+
const i = t, o = fe(i, this.coordinatePrecision).valid || Ct(i, this.coordinatePrecision).valid || ge(i, this.coordinatePrecision).valid;
|
|
1064
1064
|
return o ? { valid: !0 } : { valid: o, reason: "Feature is not a valid Point, Polygon or LineString feature" };
|
|
1065
1065
|
}
|
|
1066
1066
|
return e;
|
|
1067
1067
|
}
|
|
1068
1068
|
}
|
|
1069
|
-
function
|
|
1069
|
+
function gt(r, t) {
|
|
1070
1070
|
const e = r, i = t, o = E(e[1]), s = E(i[1]);
|
|
1071
1071
|
let n = E(i[0] - e[0]);
|
|
1072
1072
|
n > Math.PI && (n -= 2 * Math.PI), n < -Math.PI && (n += 2 * Math.PI);
|
|
1073
|
-
const a = Math.log(Math.tan(s / 2 + Math.PI / 4) / Math.tan(o / 2 + Math.PI / 4)),
|
|
1074
|
-
return
|
|
1073
|
+
const a = Math.log(Math.tan(s / 2 + Math.PI / 4) / Math.tan(o / 2 + Math.PI / 4)), l = (U(Math.atan2(n, a)) + 360) % 360;
|
|
1074
|
+
return l > 180 ? -(360 - l) : l;
|
|
1075
1075
|
}
|
|
1076
|
-
function
|
|
1076
|
+
function Lt(r, t, e) {
|
|
1077
1077
|
let i = t;
|
|
1078
1078
|
t < 0 && (i = -Math.abs(i));
|
|
1079
|
-
const o = i /
|
|
1080
|
-
let
|
|
1081
|
-
Math.abs(
|
|
1082
|
-
const c = Math.log(Math.tan(
|
|
1079
|
+
const o = i / le, s = r[0] * Math.PI / 180, n = E(r[1]), a = E(e), l = o * Math.cos(a);
|
|
1080
|
+
let d = n + l;
|
|
1081
|
+
Math.abs(d) > Math.PI / 2 && (d = d > 0 ? Math.PI - d : -Math.PI - d);
|
|
1082
|
+
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];
|
|
1083
1083
|
return u[0] += u[0] - r[0] > 180 ? -360 : r[0] - u[0] > 180 ? 360 : 0, u;
|
|
1084
1084
|
}
|
|
1085
|
-
function
|
|
1086
|
-
const s = i(r[0], r[1]), n = i(t[0], t[1]), { lng: a, lat:
|
|
1087
|
-
return [F(a, e), F(
|
|
1085
|
+
function Pe(r, t, e, i, o) {
|
|
1086
|
+
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);
|
|
1087
|
+
return [F(a, e), F(l, e)];
|
|
1088
1088
|
}
|
|
1089
|
-
function
|
|
1090
|
-
const i =
|
|
1089
|
+
function Ze(r, t, e) {
|
|
1090
|
+
const i = Lt(r, 1e3 * G(r, t) / 2, gt(r, t));
|
|
1091
1091
|
return [F(i[0], e), F(i[1], e)];
|
|
1092
1092
|
}
|
|
1093
|
-
function
|
|
1093
|
+
function $t({ featureCoords: r, precision: t, unproject: e, project: i, projection: o }) {
|
|
1094
1094
|
const s = [];
|
|
1095
1095
|
for (let n = 0; n < r.length - 1; n++) {
|
|
1096
1096
|
let a;
|
|
1097
|
-
if (o === "web-mercator") a =
|
|
1097
|
+
if (o === "web-mercator") a = Pe(r[n], r[n + 1], t, i, e);
|
|
1098
1098
|
else {
|
|
1099
1099
|
if (o !== "globe") throw new Error("Invalid projection");
|
|
1100
|
-
a =
|
|
1100
|
+
a = Ze(r[n], r[n + 1], t);
|
|
1101
1101
|
}
|
|
1102
1102
|
s.push(a);
|
|
1103
1103
|
}
|
|
1104
1104
|
return s;
|
|
1105
1105
|
}
|
|
1106
|
-
class
|
|
1106
|
+
class Qe extends B {
|
|
1107
1107
|
constructor(t, e) {
|
|
1108
1108
|
super(t), this.config = void 0, this.selectionPointBehavior = void 0, this._midPoints = [], this.config = t, this.selectionPointBehavior = e;
|
|
1109
1109
|
}
|
|
@@ -1118,18 +1118,18 @@ class Xe extends B {
|
|
|
1118
1118
|
}
|
|
1119
1119
|
create(t, e, i) {
|
|
1120
1120
|
if (!this.store.has(e)) throw new Error("Store does not have feature with this id");
|
|
1121
|
-
this._midPoints = this.store.create(function(o, s, n, a,
|
|
1122
|
-
return
|
|
1121
|
+
this._midPoints = this.store.create(function(o, s, n, a, l, d) {
|
|
1122
|
+
return $t({ featureCoords: o, precision: n, project: a, unproject: l, projection: d }).map((c, h) => ({ geometry: { type: "Point", coordinates: c }, properties: s(h) }));
|
|
1123
1123
|
}(t, (o) => ({ mode: this.mode, [V.MID_POINT]: !0, midPointSegment: o, midPointFeatureId: e }), i, this.config.project, this.config.unproject, this.projection));
|
|
1124
1124
|
}
|
|
1125
1125
|
delete() {
|
|
1126
1126
|
this._midPoints.length && (this.store.delete(this._midPoints), this._midPoints = []);
|
|
1127
1127
|
}
|
|
1128
1128
|
getUpdated(t) {
|
|
1129
|
-
if (this._midPoints.length !== 0) return
|
|
1129
|
+
if (this._midPoints.length !== 0) return $t({ featureCoords: t, precision: this.coordinatePrecision, project: this.config.project, unproject: this.config.unproject, projection: this.config.projection }).map((e, i) => ({ id: this._midPoints[i], geometry: { type: "Point", coordinates: e } }));
|
|
1130
1130
|
}
|
|
1131
1131
|
}
|
|
1132
|
-
class
|
|
1132
|
+
class ti extends B {
|
|
1133
1133
|
constructor(t) {
|
|
1134
1134
|
super(t), this._selectionPoints = [];
|
|
1135
1135
|
}
|
|
@@ -1140,8 +1140,8 @@ class Ke extends B {
|
|
|
1140
1140
|
}
|
|
1141
1141
|
create(t, e, i) {
|
|
1142
1142
|
this._selectionPoints = this.store.create(function(o, s, n) {
|
|
1143
|
-
const a = [],
|
|
1144
|
-
for (let
|
|
1143
|
+
const a = [], l = s === "Polygon" ? o.length - 1 : o.length;
|
|
1144
|
+
for (let d = 0; d < l; d++) a.push({ geometry: { type: "Point", coordinates: o[d] }, properties: n(d) });
|
|
1145
1145
|
return a;
|
|
1146
1146
|
}(t, e, (o) => ({ mode: this.mode, selectionPoint: !0, selectionPointFeatureId: i, index: o })));
|
|
1147
1147
|
}
|
|
@@ -1155,52 +1155,52 @@ class Ke extends B {
|
|
|
1155
1155
|
if (this._selectionPoints[t] !== void 0) return { id: this._selectionPoints[t], geometry: { type: "Point", coordinates: e } };
|
|
1156
1156
|
}
|
|
1157
1157
|
}
|
|
1158
|
-
function
|
|
1158
|
+
function Se(r, t) {
|
|
1159
1159
|
let e = !1;
|
|
1160
1160
|
for (let n = 0, a = t.length; n < a; n++) {
|
|
1161
|
-
const
|
|
1162
|
-
for (let
|
|
1161
|
+
const l = t[n];
|
|
1162
|
+
for (let d = 0, c = l.length, h = c - 1; d < c; h = d++) (o = l[d])[1] > (i = r)[1] != (s = l[h])[1] > i[1] && i[0] < (s[0] - o[0]) * (i[1] - o[1]) / (s[1] - o[1]) + o[0] && (e = !e);
|
|
1163
1163
|
}
|
|
1164
1164
|
var i, o, s;
|
|
1165
1165
|
return e;
|
|
1166
1166
|
}
|
|
1167
|
-
const
|
|
1167
|
+
const xe = (r, t, e) => {
|
|
1168
1168
|
const i = (s) => s * s, o = (s, n) => i(s.x - n.x) + i(s.y - n.y);
|
|
1169
1169
|
return Math.sqrt(((s, n, a) => {
|
|
1170
|
-
const
|
|
1171
|
-
if (
|
|
1172
|
-
let
|
|
1173
|
-
return
|
|
1170
|
+
const l = o(n, a);
|
|
1171
|
+
if (l === 0) return o(s, n);
|
|
1172
|
+
let d = ((s.x - n.x) * (a.x - n.x) + (s.y - n.y) * (a.y - n.y)) / l;
|
|
1173
|
+
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) });
|
|
1174
1174
|
})(r, t, e));
|
|
1175
1175
|
};
|
|
1176
|
-
class
|
|
1176
|
+
class ei extends B {
|
|
1177
1177
|
constructor(t, e, i) {
|
|
1178
1178
|
super(t), this.config = void 0, this.createClickBoundingBox = void 0, this.pixelDistance = void 0, this.config = t, this.createClickBoundingBox = e, this.pixelDistance = i;
|
|
1179
1179
|
}
|
|
1180
1180
|
find(t, e) {
|
|
1181
|
-
let i, o, s, n, a = 1 / 0,
|
|
1181
|
+
let i, o, s, n, a = 1 / 0, l = 1 / 0, d = 1 / 0;
|
|
1182
1182
|
const c = this.createClickBoundingBox.create(t), h = this.store.search(c);
|
|
1183
1183
|
for (let u = 0; u < h.length; u++) {
|
|
1184
1184
|
const p = h[u], g = p.geometry;
|
|
1185
1185
|
if (g.type === "Point") {
|
|
1186
1186
|
if (p.properties.selectionPoint || !e && p.properties[V.MID_POINT]) continue;
|
|
1187
1187
|
const y = this.pixelDistance.measure(t, g.coordinates);
|
|
1188
|
-
p.properties[V.MID_POINT] && y < this.pointerDistance && y <
|
|
1188
|
+
p.properties[V.MID_POINT] && y < this.pointerDistance && y < d ? (d = y, s = p) : !p.properties[V.MID_POINT] && y < this.pointerDistance && y < a && (a = y, i = p);
|
|
1189
1189
|
} else if (g.type === "LineString") {
|
|
1190
1190
|
if (i) continue;
|
|
1191
1191
|
for (let y = 0; y < g.coordinates.length - 1; y++) {
|
|
1192
|
-
const v = g.coordinates[y], f = g.coordinates[y + 1], m =
|
|
1193
|
-
m < this.pointerDistance && m <
|
|
1192
|
+
const v = g.coordinates[y], f = g.coordinates[y + 1], m = xe({ x: t.containerX, y: t.containerY }, this.project(v[0], v[1]), this.project(f[0], f[1]));
|
|
1193
|
+
m < this.pointerDistance && m < l && (l = m, o = p);
|
|
1194
1194
|
}
|
|
1195
1195
|
} else if (g.type === "Polygon") {
|
|
1196
1196
|
if (i || o) continue;
|
|
1197
|
-
|
|
1197
|
+
Se([t.lng, t.lat], g.coordinates) && (n = p);
|
|
1198
1198
|
}
|
|
1199
1199
|
}
|
|
1200
1200
|
return { clickedFeature: i || o || n, clickedMidPoint: s };
|
|
1201
1201
|
}
|
|
1202
1202
|
}
|
|
1203
|
-
class
|
|
1203
|
+
class ii extends B {
|
|
1204
1204
|
constructor(t, e, i, o) {
|
|
1205
1205
|
super(t), this.config = void 0, this.featuresAtCursorEvent = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.draggedFeatureId = null, this.dragPosition = void 0, this.config = t, this.featuresAtCursorEvent = e, this.selectionPoints = i, this.midPoints = o;
|
|
1206
1206
|
}
|
|
@@ -1223,27 +1223,27 @@ class $e extends B {
|
|
|
1223
1223
|
if (i.type === "Polygon" || i.type === "LineString") {
|
|
1224
1224
|
let s, n;
|
|
1225
1225
|
if (i.type === "Polygon" ? (s = i.coordinates[0], n = s.length - 1) : (s = i.coordinates, n = s.length), !this.dragPosition) return !1;
|
|
1226
|
-
for (let
|
|
1227
|
-
const c = s[
|
|
1226
|
+
for (let d = 0; d < n; d++) {
|
|
1227
|
+
const c = s[d];
|
|
1228
1228
|
let h, u;
|
|
1229
1229
|
if (this.config.projection === "web-mercator") {
|
|
1230
|
-
const p =
|
|
1230
|
+
const p = x(this.dragPosition[0], this.dragPosition[1]), g = x(o[0], o[1]), y = x(c[0], c[1]), v = { x: p.x - g.x, y: p.y - g.y }, f = y.x - v.x, m = y.y - v.y, { lng: C, lat: P } = W(f, m);
|
|
1231
1231
|
h = C, u = P;
|
|
1232
1232
|
} else {
|
|
1233
1233
|
const p = [this.dragPosition[0] - o[0], this.dragPosition[1] - o[1]];
|
|
1234
1234
|
h = c[0] - p[0], u = c[1] - p[1];
|
|
1235
1235
|
}
|
|
1236
1236
|
if (h = F(h, this.config.coordinatePrecision), u = F(u, this.config.coordinatePrecision), h > 180 || h < -180 || u > 90 || u < -90) return !1;
|
|
1237
|
-
s[
|
|
1237
|
+
s[d] = [h, u];
|
|
1238
1238
|
}
|
|
1239
1239
|
i.type === "Polygon" && (s[s.length - 1] = [s[0][0], s[0][1]]);
|
|
1240
|
-
const a = this.selectionPoints.getUpdated(s) || [],
|
|
1241
|
-
if (e && !e({ type: "Feature", id: this.draggedFeatureId, geometry: i, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType:
|
|
1242
|
-
this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: i }, ...a, ...
|
|
1240
|
+
const a = this.selectionPoints.getUpdated(s) || [], l = this.midPoints.getUpdated(s) || [];
|
|
1241
|
+
if (e && !e({ type: "Feature", id: this.draggedFeatureId, geometry: i, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: M.Provisional }).valid) return !1;
|
|
1242
|
+
this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: i }, ...a, ...l]), this.dragPosition = [t.lng, t.lat];
|
|
1243
1243
|
} else i.type === "Point" && (this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: { type: "Point", coordinates: o } }]), this.dragPosition = [t.lng, t.lat]);
|
|
1244
1244
|
}
|
|
1245
1245
|
}
|
|
1246
|
-
class
|
|
1246
|
+
class oi extends B {
|
|
1247
1247
|
constructor(t, e, i, o) {
|
|
1248
1248
|
super(t), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.draggedCoordinate = { id: null, index: -1 }, this.config = t, this.pixelDistance = e, this.selectionPoints = i, this.midPoints = o;
|
|
1249
1249
|
}
|
|
@@ -1277,8 +1277,8 @@ class He extends B {
|
|
|
1277
1277
|
const h = n.length - 1;
|
|
1278
1278
|
n[0] = a, n[h] = a;
|
|
1279
1279
|
}
|
|
1280
|
-
const
|
|
1281
|
-
return !(s.type !== "Point" && !e &&
|
|
1280
|
+
const l = this.selectionPoints.getOneUpdated(o, a), d = l ? [l] : [], c = this.midPoints.getUpdated(n) || [];
|
|
1281
|
+
return !(s.type !== "Point" && !e && Dt({ geometry: s }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: s, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: M.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: s }, ...d, ...c]), 0));
|
|
1282
1282
|
}
|
|
1283
1283
|
isDragging() {
|
|
1284
1284
|
return this.draggedCoordinate.id !== null;
|
|
@@ -1290,44 +1290,44 @@ class He extends B {
|
|
|
1290
1290
|
this.draggedCoordinate = { id: null, index: -1 };
|
|
1291
1291
|
}
|
|
1292
1292
|
}
|
|
1293
|
-
function
|
|
1293
|
+
function yt(r) {
|
|
1294
1294
|
let t = 0, e = 0, i = 0;
|
|
1295
1295
|
return (r.geometry.type === "Polygon" ? r.geometry.coordinates[0].slice(0, -1) : r.geometry.coordinates).forEach((o) => {
|
|
1296
1296
|
t += o[0], e += o[1], i++;
|
|
1297
1297
|
}, !0), [t / i, e / i];
|
|
1298
1298
|
}
|
|
1299
|
-
function
|
|
1299
|
+
function Ie(r, t) {
|
|
1300
1300
|
r[0] += r[0] - t[0] > 180 ? -360 : t[0] - r[0] > 180 ? 360 : 0;
|
|
1301
|
-
const e =
|
|
1301
|
+
const e = le, i = t[1] * Math.PI / 180, o = r[1] * Math.PI / 180, s = o - i;
|
|
1302
1302
|
let n = Math.abs(r[0] - t[0]) * Math.PI / 180;
|
|
1303
1303
|
n > Math.PI && (n -= 2 * Math.PI);
|
|
1304
|
-
const a = Math.log(Math.tan(o / 2 + Math.PI / 4) / Math.tan(i / 2 + Math.PI / 4)),
|
|
1305
|
-
return Math.sqrt(s * s +
|
|
1304
|
+
const a = Math.log(Math.tan(o / 2 + Math.PI / 4) / Math.tan(i / 2 + Math.PI / 4)), l = Math.abs(a) > 1e-11 ? s / a : Math.cos(i);
|
|
1305
|
+
return Math.sqrt(s * s + l * l * n * n) * e;
|
|
1306
1306
|
}
|
|
1307
|
-
function
|
|
1307
|
+
function ft(r) {
|
|
1308
1308
|
const t = (r.geometry.type === "Polygon" ? r.geometry.coordinates[0] : r.geometry.coordinates).map((e) => {
|
|
1309
|
-
const { x: i, y: o } =
|
|
1309
|
+
const { x: i, y: o } = x(e[0], e[1]);
|
|
1310
1310
|
return [i, o];
|
|
1311
1311
|
});
|
|
1312
1312
|
return r.geometry.type === "Polygon" ? function(e) {
|
|
1313
1313
|
let i = 0, o = 0, s = 0;
|
|
1314
1314
|
const n = e.length;
|
|
1315
1315
|
for (let a = 0; a < n - 1; a++) {
|
|
1316
|
-
const [
|
|
1317
|
-
i += u, o += (
|
|
1316
|
+
const [l, d] = e[a], [c, h] = e[a + 1], u = l * h - c * d;
|
|
1317
|
+
i += u, o += (l + c) * u, s += (d + h) * u;
|
|
1318
1318
|
}
|
|
1319
1319
|
return i /= 2, o /= 6 * i, s /= 6 * i, { x: o, y: s };
|
|
1320
1320
|
}(t) : function(e) {
|
|
1321
1321
|
const i = e.length;
|
|
1322
1322
|
let o = 0, s = 0;
|
|
1323
1323
|
for (let n = 0; n < i; n++) {
|
|
1324
|
-
const [a,
|
|
1325
|
-
o += a, s +=
|
|
1324
|
+
const [a, l] = e[n];
|
|
1325
|
+
o += a, s += l;
|
|
1326
1326
|
}
|
|
1327
1327
|
return { x: o / i, y: s / i };
|
|
1328
1328
|
}(t);
|
|
1329
1329
|
}
|
|
1330
|
-
class
|
|
1330
|
+
class si extends B {
|
|
1331
1331
|
constructor(t, e, i) {
|
|
1332
1332
|
super(t), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastBearing = void 0, this.config = t, this.selectionPoints = e, this.midPoints = i;
|
|
1333
1333
|
}
|
|
@@ -1341,36 +1341,36 @@ class qe extends B {
|
|
|
1341
1341
|
let n;
|
|
1342
1342
|
const a = { type: "Feature", geometry: o, properties: {} };
|
|
1343
1343
|
if (this.config.projection === "web-mercator") {
|
|
1344
|
-
if (n =
|
|
1344
|
+
if (n = T(ft(a), x(t.lng, t.lat)), !this.lastBearing) return void (this.lastBearing = n);
|
|
1345
1345
|
((h, u) => {
|
|
1346
1346
|
if (u === 0 || u === 360 || u === -360) return h;
|
|
1347
|
-
const p = 0.017453292519943295 * u, g = (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).map(([f, m]) =>
|
|
1347
|
+
const p = 0.017453292519943295 * u, g = (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).map(([f, m]) => x(f, m)), y = g.reduce((f, m) => ({ x: f.x + m.x, y: f.y + m.y }), { x: 0, y: 0 });
|
|
1348
1348
|
y.x /= g.length, y.y /= g.length;
|
|
1349
1349
|
const v = g.map((f) => ({ x: y.x + (f.x - y.x) * Math.cos(p) - (f.y - y.y) * Math.sin(p), y: y.y + (f.x - y.x) * Math.sin(p) + (f.y - y.y) * Math.cos(p) })).map(({ x: f, y: m }) => [W(f, m).lng, W(f, m).lat]);
|
|
1350
1350
|
h.geometry.type === "Polygon" ? h.geometry.coordinates[0] = v : h.geometry.coordinates = v;
|
|
1351
1351
|
})(a, -(this.lastBearing - n));
|
|
1352
1352
|
} else {
|
|
1353
1353
|
if (this.config.projection !== "globe") throw new Error("Unsupported projection");
|
|
1354
|
-
if (n =
|
|
1354
|
+
if (n = gt(yt({ geometry: o }), s), !this.lastBearing) return void (this.lastBearing = n + 180);
|
|
1355
1355
|
(function(h, u) {
|
|
1356
1356
|
if (u === 0 || u === 360 || u === -360) return h;
|
|
1357
|
-
const p =
|
|
1357
|
+
const p = yt(h);
|
|
1358
1358
|
(h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).forEach((g) => {
|
|
1359
|
-
const y =
|
|
1359
|
+
const y = gt(p, g) + u, v = Ie(p, g), f = Lt(p, v, y);
|
|
1360
1360
|
g[0] = f[0], g[1] = f[1];
|
|
1361
1361
|
});
|
|
1362
1362
|
})(a, -(this.lastBearing - (n + 180)));
|
|
1363
1363
|
}
|
|
1364
|
-
const
|
|
1365
|
-
|
|
1364
|
+
const l = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
|
|
1365
|
+
l.forEach((h) => {
|
|
1366
1366
|
h[0] = F(h[0], this.coordinatePrecision), h[1] = F(h[1], this.coordinatePrecision);
|
|
1367
1367
|
});
|
|
1368
|
-
const
|
|
1369
|
-
if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType:
|
|
1370
|
-
this.store.updateGeometry([{ id: e, geometry: o }, ...c, ...
|
|
1368
|
+
const d = this.midPoints.getUpdated(l) || [], c = this.selectionPoints.getUpdated(l) || [];
|
|
1369
|
+
if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: M.Provisional })) return !1;
|
|
1370
|
+
this.store.updateGeometry([{ id: e, geometry: o }, ...c, ...d]), this.projection === "web-mercator" ? this.lastBearing = n : this.projection === "globe" && (this.lastBearing = n + 180);
|
|
1371
1371
|
}
|
|
1372
1372
|
}
|
|
1373
|
-
class
|
|
1373
|
+
class ri extends B {
|
|
1374
1374
|
constructor(t, e, i) {
|
|
1375
1375
|
super(t), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastDistance = void 0, this.config = t, this.selectionPoints = e, this.midPoints = i;
|
|
1376
1376
|
}
|
|
@@ -1382,39 +1382,39 @@ class Je extends B {
|
|
|
1382
1382
|
if (o.type !== "Polygon" && o.type !== "LineString") return;
|
|
1383
1383
|
const s = [t.lng, t.lat], n = { type: "Feature", geometry: o, properties: {} };
|
|
1384
1384
|
let a;
|
|
1385
|
-
const
|
|
1385
|
+
const l = ft(n);
|
|
1386
1386
|
if (this.config.projection === "web-mercator") {
|
|
1387
|
-
const p =
|
|
1388
|
-
a =
|
|
1387
|
+
const p = x(t.lng, t.lat);
|
|
1388
|
+
a = O(l, p);
|
|
1389
1389
|
} else {
|
|
1390
1390
|
if (this.config.projection !== "globe") throw new Error("Invalid projection");
|
|
1391
|
-
a =
|
|
1391
|
+
a = G(yt({ geometry: o }), s);
|
|
1392
1392
|
}
|
|
1393
1393
|
if (!this.lastDistance) return void (this.lastDistance = a);
|
|
1394
|
-
const
|
|
1394
|
+
const d = 1 - (this.lastDistance - a) / a;
|
|
1395
1395
|
if (this.config.projection === "web-mercator") {
|
|
1396
|
-
const { lng: p, lat: g } = W(
|
|
1396
|
+
const { lng: p, lat: g } = W(l.x, l.y);
|
|
1397
1397
|
(function(y, v, f) {
|
|
1398
1398
|
if (v === 1) return y;
|
|
1399
|
-
const m = (y.geometry.type === "Polygon" ? y.geometry.coordinates[0] : y.geometry.coordinates).map(([
|
|
1399
|
+
const m = (y.geometry.type === "Polygon" ? y.geometry.coordinates[0] : y.geometry.coordinates).map(([S, b]) => x(S, b)), C = x(f[0], f[1]), P = m.map((S) => ({ x: C.x + (S.x - C.x) * v, y: C.y + (S.y - C.y) * v })).map(({ x: S, y: b }) => [W(S, b).lng, W(S, b).lat]);
|
|
1400
1400
|
y.geometry.type === "Polygon" ? y.geometry.coordinates[0] = P : y.geometry.coordinates = P;
|
|
1401
|
-
})(n,
|
|
1401
|
+
})(n, d, [p, g]);
|
|
1402
1402
|
} else this.config.projection === "globe" && function(p, g, y, v = "xy") {
|
|
1403
1403
|
g === 1 || (p.geometry.type === "Polygon" ? p.geometry.coordinates[0] : p.geometry.coordinates).forEach((f) => {
|
|
1404
|
-
const m =
|
|
1404
|
+
const m = Ie(y, f), C = gt(y, f), P = Lt(y, m * g, C);
|
|
1405
1405
|
v !== "x" && v !== "xy" || (f[0] = P[0]), v !== "y" && v !== "xy" || (f[1] = P[1]);
|
|
1406
1406
|
});
|
|
1407
|
-
}(n,
|
|
1407
|
+
}(n, d, yt(n));
|
|
1408
1408
|
const c = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
|
|
1409
1409
|
c.forEach((p) => {
|
|
1410
1410
|
p[0] = F(p[0], this.coordinatePrecision), p[1] = F(p[1], this.coordinatePrecision);
|
|
1411
1411
|
});
|
|
1412
1412
|
const h = this.midPoints.getUpdated(c) || [], u = this.selectionPoints.getUpdated(c) || [];
|
|
1413
|
-
if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType:
|
|
1413
|
+
if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: M.Provisional })) return !1;
|
|
1414
1414
|
this.store.updateGeometry([{ id: e, geometry: o }, ...u, ...h]), this.lastDistance = a;
|
|
1415
1415
|
}
|
|
1416
1416
|
}
|
|
1417
|
-
class
|
|
1417
|
+
class ni extends B {
|
|
1418
1418
|
constructor(t, e, i, o) {
|
|
1419
1419
|
super(t), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.minimumScale = 1e-4, this.draggedCoordinate = { id: null, index: -1 }, this.boundingBoxMaps = { opposite: { 0: 4, 1: 5, 2: 6, 3: 7, 4: 0, 5: 1, 6: 2, 7: 3 } }, this.config = t, this.pixelDistance = e, this.selectionPoints = i, this.midPoints = o;
|
|
1420
1420
|
}
|
|
@@ -1473,43 +1473,43 @@ class Ze extends B {
|
|
|
1473
1473
|
centerWebMercatorDrag(t) {
|
|
1474
1474
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1475
1475
|
if (!e) return null;
|
|
1476
|
-
const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a =
|
|
1476
|
+
const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a = ft(i);
|
|
1477
1477
|
if (!a) return null;
|
|
1478
|
-
const
|
|
1479
|
-
return this.scaleWebMercator({ closestBBoxIndex:
|
|
1478
|
+
const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), c = x(t.lng, t.lat);
|
|
1479
|
+
return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: s, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), s;
|
|
1480
1480
|
}
|
|
1481
1481
|
centerFixedWebMercatorDrag(t) {
|
|
1482
1482
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1483
1483
|
if (!e) return null;
|
|
1484
|
-
const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a =
|
|
1484
|
+
const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a = ft(i);
|
|
1485
1485
|
if (!a) return null;
|
|
1486
|
-
const
|
|
1487
|
-
return this.scaleFixedWebMercator({ closestBBoxIndex:
|
|
1486
|
+
const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), c = x(t.lng, t.lat);
|
|
1487
|
+
return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: s, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), s;
|
|
1488
1488
|
}
|
|
1489
1489
|
scaleFixedWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: s }) {
|
|
1490
1490
|
if (!this.isValidDragWebMercator(t, e.x - o.x, e.y - o.y)) return null;
|
|
1491
|
-
let n =
|
|
1491
|
+
let n = O(e, o) / O(e, i);
|
|
1492
1492
|
return n < 0 && (n = this.minimumScale), this.performWebMercatorScale(s, e.x, e.y, n, n), s;
|
|
1493
1493
|
}
|
|
1494
1494
|
oppositeFixedWebMercatorDrag(t) {
|
|
1495
1495
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1496
1496
|
if (!e) return null;
|
|
1497
|
-
const { boundingBox: i, updatedCoords: o, selectedCoordinate: s } = e, n =
|
|
1498
|
-
return this.scaleFixedWebMercator({ closestBBoxIndex:
|
|
1497
|
+
const { boundingBox: i, updatedCoords: o, selectedCoordinate: s } = e, n = x(s[0], s[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] }, c = x(t.lng, t.lat);
|
|
1498
|
+
return this.scaleFixedWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: n, webMercatorOrigin: d }), o;
|
|
1499
1499
|
}
|
|
1500
1500
|
oppositeWebMercatorDrag(t) {
|
|
1501
1501
|
const e = this.getSelectedFeatureDataWebMercator();
|
|
1502
1502
|
if (!e) return null;
|
|
1503
|
-
const { boundingBox: i, updatedCoords: o, selectedCoordinate: s } = e, n =
|
|
1504
|
-
return this.scaleWebMercator({ closestBBoxIndex:
|
|
1503
|
+
const { boundingBox: i, updatedCoords: o, selectedCoordinate: s } = e, n = x(s[0], s[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] }, c = x(t.lng, t.lat);
|
|
1504
|
+
return this.scaleWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: n, webMercatorOrigin: d }), o;
|
|
1505
1505
|
}
|
|
1506
1506
|
scaleWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: s }) {
|
|
1507
1507
|
const n = e.x - o.x, a = e.y - o.y;
|
|
1508
1508
|
if (!this.isValidDragWebMercator(t, n, a)) return null;
|
|
1509
|
-
let d = 1;
|
|
1510
|
-
n !== 0 && t !== 1 && t !== 5 && (d = 1 - (e.x - i.x - n) / n);
|
|
1511
1509
|
let l = 1;
|
|
1512
|
-
|
|
1510
|
+
n !== 0 && t !== 1 && t !== 5 && (l = 1 - (e.x - i.x - n) / n);
|
|
1511
|
+
let d = 1;
|
|
1512
|
+
return a !== 0 && t !== 3 && t !== 7 && (d = 1 - (e.y - i.y - a) / a), this.validateScale(l, d) ? (l < 0 && (l = this.minimumScale), d < 0 && (d = this.minimumScale), this.performWebMercatorScale(s, e.x, e.y, l, d), s) : null;
|
|
1513
1513
|
}
|
|
1514
1514
|
getFeature(t) {
|
|
1515
1515
|
if (this.draggedCoordinate.id === null) return null;
|
|
@@ -1525,17 +1525,17 @@ class Ze extends B {
|
|
|
1525
1525
|
}
|
|
1526
1526
|
performWebMercatorScale(t, e, i, o, s) {
|
|
1527
1527
|
t.forEach((n) => {
|
|
1528
|
-
const { x: a, y:
|
|
1528
|
+
const { x: a, y: l } = x(n[0], n[1]), d = e + (a - e) * o, c = i + (l - i) * s, { lng: h, lat: u } = W(d, c);
|
|
1529
1529
|
n[0] = h, n[1] = u;
|
|
1530
1530
|
});
|
|
1531
1531
|
}
|
|
1532
1532
|
getBBoxWebMercator(t) {
|
|
1533
1533
|
const e = [1 / 0, 1 / 0, -1 / 0, -1 / 0];
|
|
1534
1534
|
(t = t.map((a) => {
|
|
1535
|
-
const { x:
|
|
1536
|
-
return [
|
|
1537
|
-
})).forEach(([a,
|
|
1538
|
-
a < e[0] && (e[0] = a),
|
|
1535
|
+
const { x: l, y: d } = x(a[0], a[1]);
|
|
1536
|
+
return [l, d];
|
|
1537
|
+
})).forEach(([a, l]) => {
|
|
1538
|
+
a < e[0] && (e[0] = a), l < e[1] && (e[1] = l), a > e[2] && (e[2] = a), l > e[3] && (e[3] = l);
|
|
1539
1539
|
});
|
|
1540
1540
|
const [i, o, s, n] = e;
|
|
1541
1541
|
return [[i, n], [(i + s) / 2, n], [s, n], [s, n + (o - n) / 2], [s, o], [(i + s) / 2, o], [i, o], [i, n + (o - n) / 2]];
|
|
@@ -1543,7 +1543,7 @@ class Ze extends B {
|
|
|
1543
1543
|
getIndexesWebMercator(t, e) {
|
|
1544
1544
|
let i, o = 1 / 0;
|
|
1545
1545
|
for (let s = 0; s < t.length; s++) {
|
|
1546
|
-
const n =
|
|
1546
|
+
const n = O({ x: e.x, y: e.y }, { x: t[s][0], y: t[s][1] });
|
|
1547
1547
|
n < o && (i = s, o = n);
|
|
1548
1548
|
}
|
|
1549
1549
|
if (i === void 0) throw new Error("No closest coordinate found");
|
|
@@ -1568,23 +1568,23 @@ class Ze extends B {
|
|
|
1568
1568
|
if (!o) return !1;
|
|
1569
1569
|
let s = null;
|
|
1570
1570
|
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;
|
|
1571
|
-
for (let
|
|
1572
|
-
const c = s[
|
|
1573
|
-
if (c[0] = F(c[0], this.coordinatePrecision), c[1] = F(c[1], this.coordinatePrecision), !
|
|
1571
|
+
for (let d = 0; d < s.length; d++) {
|
|
1572
|
+
const c = s[d];
|
|
1573
|
+
if (c[0] = F(c[0], this.coordinatePrecision), c[1] = F(c[1], this.coordinatePrecision), !vt(c, this.coordinatePrecision)) return !1;
|
|
1574
1574
|
}
|
|
1575
|
-
const n = this.midPoints.getUpdated(s) || [], a = this.selectionPoints.getUpdated(s) || [],
|
|
1576
|
-
return !(i && !i({ id: this.draggedCoordinate.id, type: "Feature", geometry:
|
|
1575
|
+
const n = this.midPoints.getUpdated(s) || [], a = this.selectionPoints.getUpdated(s) || [], l = { type: o.geometry.type, coordinates: o.geometry.type === "Polygon" ? [s] : s };
|
|
1576
|
+
return !(i && !i({ id: this.draggedCoordinate.id, type: "Feature", geometry: l, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: M.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: l }, ...a, ...n]), 0));
|
|
1577
1577
|
}
|
|
1578
1578
|
}
|
|
1579
|
-
class
|
|
1579
|
+
class be extends Ae {
|
|
1580
1580
|
constructor(t) {
|
|
1581
1581
|
var e;
|
|
1582
1582
|
super(t), this.mode = "select", this.allowManualDeselection = !0, this.dragEventThrottle = 5, this.dragEventCount = 0, this.selected = [], this.flags = void 0, this.keyEvents = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.featuresAtMouseEvent = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.dragFeature = void 0, this.dragCoordinate = void 0, this.rotateFeature = void 0, this.scaleFeature = void 0, this.dragCoordinateResizeFeature = void 0, this.cursors = void 0, this.validations = {}, this.flags = t && t.flags ? t.flags : {};
|
|
1583
1583
|
const i = { pointerOver: "move", dragStart: "move", dragEnd: "move", insertMidpoint: "crosshair" };
|
|
1584
|
-
if (this.cursors = t && t.cursors ?
|
|
1584
|
+
if (this.cursors = t && t.cursors ? I({}, i, t.cursors) : i, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { deselect: null, delete: null, rotate: null, scale: null };
|
|
1585
1585
|
else {
|
|
1586
1586
|
const o = { deselect: "Escape", delete: "Delete", rotate: ["Control", "r"], scale: ["Control", "s"] };
|
|
1587
|
-
this.keyEvents = t && t.keyEvents ?
|
|
1587
|
+
this.keyEvents = t && t.keyEvents ? I({}, o, t.keyEvents) : o;
|
|
1588
1588
|
}
|
|
1589
1589
|
if (this.dragEventThrottle = t && t.dragEventThrottle !== void 0 && t.dragEventThrottle || 5, this.allowManualDeselection = (e = t == null ? void 0 : t.allowManualDeselection) == null || e, t && t.flags && t.flags) for (const o in t.flags) {
|
|
1590
1590
|
const s = t.flags[o].feature;
|
|
@@ -1599,7 +1599,7 @@ class Qe extends De {
|
|
|
1599
1599
|
this._state = "selecting";
|
|
1600
1600
|
}
|
|
1601
1601
|
registerBehaviors(t) {
|
|
1602
|
-
this.pixelDistance = new
|
|
1602
|
+
this.pixelDistance = new St(t), this.clickBoundingBox = new Pt(t), this.featuresAtMouseEvent = new ei(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new ti(t), this.midPoints = new Qe(t, this.selectionPoints), this.rotateFeature = new si(t, this.selectionPoints, this.midPoints), this.scaleFeature = new ri(t, this.selectionPoints, this.midPoints), this.dragFeature = new ii(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints), this.dragCoordinate = new oi(t, this.pixelDistance, this.selectionPoints, this.midPoints), this.dragCoordinateResizeFeature = new ni(t, this.pixelDistance, this.selectionPoints, this.midPoints);
|
|
1603
1603
|
}
|
|
1604
1604
|
deselectFeature() {
|
|
1605
1605
|
this.deselect();
|
|
@@ -1618,14 +1618,14 @@ class Qe extends De {
|
|
|
1618
1618
|
const u = this.store.getGeometryCopy(h), p = this.pixelDistance.measure(t, u.coordinates);
|
|
1619
1619
|
p < this.pointerDistance && p < i && (i = p, e = this.store.getPropertiesCopy(h));
|
|
1620
1620
|
}), !e) return;
|
|
1621
|
-
const o = e.selectionPointFeatureId, s = e.index, n = this.store.getPropertiesCopy(o), a = this.flags[n.mode],
|
|
1621
|
+
const o = e.selectionPointFeatureId, s = e.index, n = this.store.getPropertiesCopy(o), a = this.flags[n.mode], l = this.validations[n.mode];
|
|
1622
1622
|
if (!(a && a.feature && a.feature.coordinates && a.feature.coordinates.deletable)) return;
|
|
1623
|
-
const
|
|
1623
|
+
const d = this.store.getGeometryCopy(o);
|
|
1624
1624
|
let c;
|
|
1625
|
-
if (
|
|
1626
|
-
if (c =
|
|
1627
|
-
} else if (
|
|
1628
|
-
c && (
|
|
1625
|
+
if (d.type === "Polygon") {
|
|
1626
|
+
if (c = d.coordinates[0], c.length <= 4) return;
|
|
1627
|
+
} else if (d.type === "LineString" && (c = d.coordinates, c.length <= 2)) return;
|
|
1628
|
+
c && (d.type !== "Polygon" || s !== 0 && s !== c.length - 1 ? c.splice(s, 1) : (c.shift(), c.pop(), c.push([c[0][0], c[0][1]])), (!l || l({ id: o, type: "Feature", geometry: d, properties: n }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Commit }).valid) && (this.store.delete([...this.midPoints.ids, ...this.selectionPoints.ids]), this.store.updateGeometry([{ id: o, geometry: d }]), this.selectionPoints.create(c, d.type, o), a && a.feature && a.feature.coordinates && a.feature.coordinates.midpoints && this.midPoints.create(c, o, this.coordinatePrecision)));
|
|
1629
1629
|
}
|
|
1630
1630
|
select(t, e = !0) {
|
|
1631
1631
|
if (this.selected[0] === t) return;
|
|
@@ -1639,8 +1639,8 @@ class Qe extends De {
|
|
|
1639
1639
|
e && this.setCursor(this.cursors.pointerOver), this.selected = [t], this.store.updateProperty([{ id: t, property: "selected", value: !0 }]), this.onSelect(t);
|
|
1640
1640
|
const { type: n, coordinates: a } = this.store.getGeometryCopy(t);
|
|
1641
1641
|
if (n !== "LineString" && n !== "Polygon") return;
|
|
1642
|
-
const
|
|
1643
|
-
|
|
1642
|
+
const l = n === "LineString" ? a : a[0];
|
|
1643
|
+
l && o && o.feature.coordinates && (this.selectionPoints.create(l, n, t), o.feature.coordinates.midpoints && this.midPoints.create(l, t, this.coordinatePrecision));
|
|
1644
1644
|
}
|
|
1645
1645
|
onLeftClick(t) {
|
|
1646
1646
|
const { clickedFeature: e, clickedMidPoint: i } = this.featuresAtMouseEvent.find(t, this.selected.length > 0);
|
|
@@ -1722,7 +1722,7 @@ class Qe extends De {
|
|
|
1722
1722
|
this.setCursor(this.selected.length > 0 && (o && o.id === this.selected[0] || i) ? this.cursors.pointerOver : "unset");
|
|
1723
1723
|
}
|
|
1724
1724
|
styleFeature(t) {
|
|
1725
|
-
const e =
|
|
1725
|
+
const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
1726
1726
|
if (t.properties.mode === this.mode && t.geometry.type === "Point") {
|
|
1727
1727
|
if (t.properties.selectionPoint) return e.pointColor = this.getHexColorStylingValue(this.styles.selectionPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.selectionPointOutlineColor, e.pointOutlineColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.selectionPointWidth, e.pointWidth, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.selectionPointOutlineWidth, 2, t), e.zIndex = 30, e;
|
|
1728
1728
|
if (t.properties.midPoint) return e.pointColor = this.getHexColorStylingValue(this.styles.midPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.midPointOutlineColor, e.pointOutlineColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.midPointWidth, 4, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.midPointOutlineWidth, 2, t), e.zIndex = 40, e;
|
|
@@ -1734,7 +1734,7 @@ class Qe extends De {
|
|
|
1734
1734
|
return e;
|
|
1735
1735
|
}
|
|
1736
1736
|
}
|
|
1737
|
-
class
|
|
1737
|
+
class ai extends N {
|
|
1738
1738
|
constructor(...t) {
|
|
1739
1739
|
super(...t), this.type = Y.Static, this.mode = "static";
|
|
1740
1740
|
}
|
|
@@ -1759,14 +1759,14 @@ class ti extends N {
|
|
|
1759
1759
|
cleanUp() {
|
|
1760
1760
|
}
|
|
1761
1761
|
styleFeature() {
|
|
1762
|
-
return
|
|
1762
|
+
return I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
1763
1763
|
}
|
|
1764
1764
|
}
|
|
1765
|
-
function
|
|
1765
|
+
function Me(r, t, e, i, o) {
|
|
1766
1766
|
for (; i > e; ) {
|
|
1767
1767
|
if (i - e > 600) {
|
|
1768
|
-
const
|
|
1769
|
-
|
|
1768
|
+
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);
|
|
1769
|
+
Me(r, t, Math.max(e, Math.floor(t - d * h / l + u)), Math.min(i, Math.floor(t + (l - d) * h / l + u)), o);
|
|
1770
1770
|
}
|
|
1771
1771
|
const s = r[t];
|
|
1772
1772
|
let n = e, a = i;
|
|
@@ -1795,10 +1795,10 @@ function it(r, t, e, i, o) {
|
|
|
1795
1795
|
function ot(r, t) {
|
|
1796
1796
|
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;
|
|
1797
1797
|
}
|
|
1798
|
-
function
|
|
1798
|
+
function li(r, t) {
|
|
1799
1799
|
return r.minX - t.minX;
|
|
1800
1800
|
}
|
|
1801
|
-
function
|
|
1801
|
+
function di(r, t) {
|
|
1802
1802
|
return r.minY - t.minY;
|
|
1803
1803
|
}
|
|
1804
1804
|
function Mt(r) {
|
|
@@ -1807,11 +1807,11 @@ function Mt(r) {
|
|
|
1807
1807
|
function dt(r) {
|
|
1808
1808
|
return r.maxX - r.minX + (r.maxY - r.minY);
|
|
1809
1809
|
}
|
|
1810
|
-
function
|
|
1810
|
+
function ci(r, t) {
|
|
1811
1811
|
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);
|
|
1812
1812
|
return Math.max(0, o - e) * Math.max(0, s - i);
|
|
1813
1813
|
}
|
|
1814
|
-
function
|
|
1814
|
+
function wt(r, t) {
|
|
1815
1815
|
return r.minX <= t.minX && r.minY <= t.minY && t.maxX <= r.maxX && t.maxY <= r.maxY;
|
|
1816
1816
|
}
|
|
1817
1817
|
function ct(r, t) {
|
|
@@ -1820,15 +1820,15 @@ function ct(r, t) {
|
|
|
1820
1820
|
function q(r) {
|
|
1821
1821
|
return { children: r, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
|
|
1822
1822
|
}
|
|
1823
|
-
function
|
|
1823
|
+
function Ht(r, t, e, i, o) {
|
|
1824
1824
|
const s = [t, e];
|
|
1825
1825
|
for (; s.length; ) {
|
|
1826
1826
|
if ((e = s.pop()) - (t = s.pop()) <= i) continue;
|
|
1827
1827
|
const n = t + Math.ceil((e - t) / i / 2) * i;
|
|
1828
|
-
|
|
1828
|
+
Me(r, n, t, e, o), s.push(t, n, n, e);
|
|
1829
1829
|
}
|
|
1830
1830
|
}
|
|
1831
|
-
class
|
|
1831
|
+
class hi {
|
|
1832
1832
|
constructor(t) {
|
|
1833
1833
|
this._maxEntries = void 0, this._minEntries = void 0, this.data = void 0, this._maxEntries = Math.max(4, t), this._minEntries = Math.max(2, Math.ceil(0.4 * this._maxEntries)), this.clear();
|
|
1834
1834
|
}
|
|
@@ -1839,8 +1839,8 @@ class si {
|
|
|
1839
1839
|
const o = this.toBBox, s = [];
|
|
1840
1840
|
for (; e; ) {
|
|
1841
1841
|
for (let n = 0; n < e.children.length; n++) {
|
|
1842
|
-
const a = e.children[n],
|
|
1843
|
-
ct(t,
|
|
1842
|
+
const a = e.children[n], l = e.leaf ? o(a) : a;
|
|
1843
|
+
ct(t, l) && (e.leaf ? i.push(a) : wt(t, l) ? this._all(a, i) : s.push(a));
|
|
1844
1844
|
}
|
|
1845
1845
|
e = s.pop();
|
|
1846
1846
|
}
|
|
@@ -1854,7 +1854,7 @@ class si {
|
|
|
1854
1854
|
for (let o = 0; o < e.children.length; o++) {
|
|
1855
1855
|
const s = e.children[o], n = e.leaf ? this.toBBox(s) : s;
|
|
1856
1856
|
if (ct(t, n)) {
|
|
1857
|
-
if (e.leaf ||
|
|
1857
|
+
if (e.leaf || wt(t, n)) return !0;
|
|
1858
1858
|
i.push(s);
|
|
1859
1859
|
}
|
|
1860
1860
|
}
|
|
@@ -1888,13 +1888,13 @@ class si {
|
|
|
1888
1888
|
remove(t) {
|
|
1889
1889
|
let e = this.data;
|
|
1890
1890
|
const i = this.toBBox(t), o = [], s = [];
|
|
1891
|
-
let n, a,
|
|
1891
|
+
let n, a, l = !1;
|
|
1892
1892
|
for (; e || o.length; ) {
|
|
1893
|
-
if (e || (e = o.pop(), a = o[o.length - 1], n = s.pop(),
|
|
1894
|
-
const
|
|
1895
|
-
|
|
1893
|
+
if (e || (e = o.pop(), a = o[o.length - 1], n = s.pop(), l = !0), e.leaf) {
|
|
1894
|
+
const d = e.children.indexOf(t);
|
|
1895
|
+
d !== -1 && (e.children.splice(d, 1), o.push(e), this._condense(o));
|
|
1896
1896
|
}
|
|
1897
|
-
|
|
1897
|
+
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]);
|
|
1898
1898
|
}
|
|
1899
1899
|
}
|
|
1900
1900
|
toBBox(t) {
|
|
@@ -1916,13 +1916,13 @@ class si {
|
|
|
1916
1916
|
let n, a = this._maxEntries;
|
|
1917
1917
|
if (s <= a) return n = q(t.slice(e, i + 1)), $(n, this.toBBox), n;
|
|
1918
1918
|
o || (o = Math.ceil(Math.log(s) / Math.log(a)), a = Math.ceil(s / Math.pow(a, o - 1))), n = q([]), n.leaf = !1, n.height = o;
|
|
1919
|
-
const
|
|
1920
|
-
|
|
1921
|
-
for (let c = e; c <= i; c +=
|
|
1922
|
-
const h = Math.min(c +
|
|
1923
|
-
|
|
1924
|
-
for (let u = c; u <= h; u +=
|
|
1925
|
-
const p = Math.min(u +
|
|
1919
|
+
const l = Math.ceil(s / a), d = l * Math.ceil(Math.sqrt(a));
|
|
1920
|
+
Ht(t, e, i, d, this.compareMinX);
|
|
1921
|
+
for (let c = e; c <= i; c += d) {
|
|
1922
|
+
const h = Math.min(c + d - 1, i);
|
|
1923
|
+
Ht(t, c, h, l, this.compareMinY);
|
|
1924
|
+
for (let u = c; u <= h; u += l) {
|
|
1925
|
+
const p = Math.min(u + l - 1, h);
|
|
1926
1926
|
n.children.push(this._build(t, u, p, o - 1));
|
|
1927
1927
|
}
|
|
1928
1928
|
}
|
|
@@ -1930,10 +1930,10 @@ class si {
|
|
|
1930
1930
|
}
|
|
1931
1931
|
_chooseSubtree(t, e, i, o) {
|
|
1932
1932
|
for (; o.push(e), !e.leaf && o.length - 1 !== i; ) {
|
|
1933
|
-
let a,
|
|
1933
|
+
let a, l = 1 / 0, d = 1 / 0;
|
|
1934
1934
|
for (let c = 0; c < e.children.length; c++) {
|
|
1935
1935
|
const h = e.children[c], u = Mt(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);
|
|
1936
|
-
p <
|
|
1936
|
+
p < d ? (d = p, l = u < l ? u : l, a = h) : p === d && u < l && (l = u, a = h);
|
|
1937
1937
|
}
|
|
1938
1938
|
e = a || e.children[0];
|
|
1939
1939
|
}
|
|
@@ -1957,28 +1957,28 @@ class si {
|
|
|
1957
1957
|
_chooseSplitIndex(t, e, i) {
|
|
1958
1958
|
let o, s = 1 / 0, n = 1 / 0;
|
|
1959
1959
|
for (let a = e; a <= i - e; a++) {
|
|
1960
|
-
const
|
|
1960
|
+
const l = it(t, 0, a, this.toBBox), d = it(t, a, i, this.toBBox), c = ci(l, d), h = Mt(l) + Mt(d);
|
|
1961
1961
|
c < s ? (s = c, o = a, n = h < n ? h : n) : c === s && h < n && (n = h, o = a);
|
|
1962
1962
|
}
|
|
1963
1963
|
return o || i - e;
|
|
1964
1964
|
}
|
|
1965
1965
|
_chooseSplitAxis(t, e, i) {
|
|
1966
|
-
const o = t.leaf ? this.compareMinX :
|
|
1966
|
+
const o = t.leaf ? this.compareMinX : li, s = t.leaf ? this.compareMinY : di;
|
|
1967
1967
|
this._allDistMargin(t, e, i, o) < this._allDistMargin(t, e, i, s) && t.children.sort(o);
|
|
1968
1968
|
}
|
|
1969
1969
|
_allDistMargin(t, e, i, o) {
|
|
1970
1970
|
t.children.sort(o);
|
|
1971
1971
|
const s = this.toBBox, n = it(t, 0, e, s), a = it(t, i - e, i, s);
|
|
1972
|
-
let
|
|
1973
|
-
for (let
|
|
1974
|
-
const c = t.children[
|
|
1975
|
-
ot(n, t.leaf ? s(c) : c),
|
|
1972
|
+
let l = dt(n) + dt(a);
|
|
1973
|
+
for (let d = e; d < i - e; d++) {
|
|
1974
|
+
const c = t.children[d];
|
|
1975
|
+
ot(n, t.leaf ? s(c) : c), l += dt(n);
|
|
1976
1976
|
}
|
|
1977
|
-
for (let
|
|
1978
|
-
const c = t.children[
|
|
1979
|
-
ot(a, t.leaf ? s(c) : c),
|
|
1977
|
+
for (let d = i - e - 1; d >= e; d--) {
|
|
1978
|
+
const c = t.children[d];
|
|
1979
|
+
ot(a, t.leaf ? s(c) : c), l += dt(a);
|
|
1980
1980
|
}
|
|
1981
|
-
return
|
|
1981
|
+
return l;
|
|
1982
1982
|
}
|
|
1983
1983
|
_adjustParentBBoxes(t, e, i) {
|
|
1984
1984
|
for (let o = i; o >= 0; o--) ot(e[o], t);
|
|
@@ -1987,9 +1987,9 @@ class si {
|
|
|
1987
1987
|
for (let e, i = t.length - 1; i >= 0; i--) t[i].children.length === 0 ? i > 0 ? (e = t[i - 1].children, e.splice(e.indexOf(t[i]), 1)) : this.clear() : $(t[i], this.toBBox);
|
|
1988
1988
|
}
|
|
1989
1989
|
}
|
|
1990
|
-
class
|
|
1990
|
+
class ui {
|
|
1991
1991
|
constructor(t) {
|
|
1992
|
-
this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new
|
|
1992
|
+
this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new hi(t && t.maxEntries ? t.maxEntries : 9), this.idToNode = /* @__PURE__ */ new Map(), this.nodeToId = /* @__PURE__ */ new Map();
|
|
1993
1993
|
}
|
|
1994
1994
|
setMaps(t, e) {
|
|
1995
1995
|
this.idToNode.set(t.id, e), this.nodeToId.set(e, t.id);
|
|
@@ -2040,14 +2040,14 @@ class ri {
|
|
|
2040
2040
|
return this.tree.collides(this.toBBox(t));
|
|
2041
2041
|
}
|
|
2042
2042
|
}
|
|
2043
|
-
const
|
|
2043
|
+
const pi = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(r) {
|
|
2044
2044
|
const t = 16 * Math.random() | 0;
|
|
2045
2045
|
return (r == "x" ? t : 3 & t | 8).toString(16);
|
|
2046
2046
|
}), isValidId: (r) => typeof r == "string" && r.length === 36 };
|
|
2047
|
-
class
|
|
2047
|
+
class gi {
|
|
2048
2048
|
constructor(t) {
|
|
2049
2049
|
this.idStrategy = void 0, this.tracked = void 0, this.spatialIndex = void 0, this.store = void 0, this._onChange = () => {
|
|
2050
|
-
}, this.store = {}, this.spatialIndex = new
|
|
2050
|
+
}, this.store = {}, this.spatialIndex = new ui(), this.tracked = !t || t.tracked !== !1, this.idStrategy = t && t.idStrategy ? t.idStrategy : pi;
|
|
2051
2051
|
}
|
|
2052
2052
|
clone(t) {
|
|
2053
2053
|
return JSON.parse(JSON.stringify(t));
|
|
@@ -2066,15 +2066,15 @@ class ai {
|
|
|
2066
2066
|
n.id == null && (n.id = this.idStrategy.getId());
|
|
2067
2067
|
const a = n.id;
|
|
2068
2068
|
if (e) {
|
|
2069
|
-
const
|
|
2070
|
-
if (!
|
|
2069
|
+
const l = e(n);
|
|
2070
|
+
if (!l.valid) return s.push({ id: a, valid: !1, reason: l.reason }), !1;
|
|
2071
2071
|
}
|
|
2072
2072
|
if (this.tracked) {
|
|
2073
2073
|
if (n.properties.createdAt) {
|
|
2074
|
-
if (!
|
|
2074
|
+
if (!Tt(n.properties.createdAt)) return s.push({ id: n.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
|
|
2075
2075
|
} else n.properties.createdAt = +/* @__PURE__ */ new Date();
|
|
2076
2076
|
if (n.properties.updatedAt) {
|
|
2077
|
-
if (!
|
|
2077
|
+
if (!Tt(n.properties.updatedAt)) return s.push({ id: n.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
|
|
2078
2078
|
} else n.properties.updatedAt = +/* @__PURE__ */ new Date();
|
|
2079
2079
|
}
|
|
2080
2080
|
return this.has(a) ? (s.push({ id: a, valid: !1, reason: `Feature already exists with this id: ${a}` }), !1) : (this.store[a] = n, o.push(a), s.push({ id: a, valid: !0 }), !0);
|
|
@@ -2119,10 +2119,10 @@ class ai {
|
|
|
2119
2119
|
create(t) {
|
|
2120
2120
|
const e = [];
|
|
2121
2121
|
return t.forEach(({ geometry: i, properties: o }) => {
|
|
2122
|
-
let s, n =
|
|
2122
|
+
let s, n = I({}, o);
|
|
2123
2123
|
this.tracked && (s = +/* @__PURE__ */ new Date(), o ? (n.createdAt = typeof o.createdAt == "number" ? o.createdAt : s, n.updatedAt = typeof o.updatedAt == "number" ? o.updatedAt : s) : n = { createdAt: s, updatedAt: s });
|
|
2124
|
-
const a = this.getId(),
|
|
2125
|
-
this.store[a] =
|
|
2124
|
+
const a = this.getId(), l = { id: a, type: "Feature", geometry: i, properties: n };
|
|
2125
|
+
this.store[a] = l, this.spatialIndex.insert(l), e.push(a);
|
|
2126
2126
|
}), this._onChange && this._onChange([...e], "create"), e;
|
|
2127
2127
|
}
|
|
2128
2128
|
delete(t) {
|
|
@@ -2141,20 +2141,20 @@ class ai {
|
|
|
2141
2141
|
return Object.keys(this.store).length;
|
|
2142
2142
|
}
|
|
2143
2143
|
}
|
|
2144
|
-
const
|
|
2145
|
-
function
|
|
2146
|
-
const i =
|
|
2147
|
-
let o =
|
|
2144
|
+
const yi = "Feature is not a Polygon or LineString", fi = "Feature intersects itself", mi = (r) => r.geometry.type !== "Polygon" && r.geometry.type !== "LineString" ? { valid: !1, reason: yi } : Dt(r) ? { valid: !1, reason: fi } : { valid: !0 };
|
|
2145
|
+
function qt(r, t, e) {
|
|
2146
|
+
const i = T(r, t);
|
|
2147
|
+
let o = T(t, e) - i;
|
|
2148
2148
|
return o < 0 && (o += 360), 180 - Math.abs(o - 90 - 90);
|
|
2149
2149
|
}
|
|
2150
|
-
class
|
|
2150
|
+
class we extends N {
|
|
2151
2151
|
constructor(t) {
|
|
2152
2152
|
super(t), this.mode = "angled-rectangle", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.cursors = void 0, this.mouseMove = !1;
|
|
2153
2153
|
const e = { start: "crosshair", close: "pointer" };
|
|
2154
|
-
if (this.cursors = t && t.cursors ?
|
|
2154
|
+
if (this.cursors = t && t.cursors ? I({}, e, t.cursors) : e, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
|
|
2155
2155
|
else {
|
|
2156
2156
|
const i = { cancel: "Escape", finish: "Enter" };
|
|
2157
|
-
this.keyEvents = t && t.keyEvents ?
|
|
2157
|
+
this.keyEvents = t && t.keyEvents ? I({}, i, t.keyEvents) : i;
|
|
2158
2158
|
}
|
|
2159
2159
|
}
|
|
2160
2160
|
close() {
|
|
@@ -2176,13 +2176,13 @@ class ve extends N {
|
|
|
2176
2176
|
const o = 1 / Math.pow(10, this.coordinatePrecision - 1), s = Math.max(1e-6, o);
|
|
2177
2177
|
i = [e[0], [t.lng, t.lat], [t.lng, t.lat - s], e[0]];
|
|
2178
2178
|
} else if (this.currentCoordinate === 2) {
|
|
2179
|
-
const o = e[0], s = e[1], n =
|
|
2180
|
-
const
|
|
2181
|
-
return
|
|
2182
|
-
}(a,
|
|
2179
|
+
const o = e[0], s = e[1], n = Pe(o, s, this.coordinatePrecision, this.project, this.unproject), a = x(o[0], o[1]), l = x(n[0], n[1]), d = x(s[0], s[1]), c = x(t.lng, t.lat), h = O(c, a) < O(c, d), u = qt(a, l, c), p = h ? 90 - u : qt(a, l, c) - 90, g = O(l, c), y = Math.cos(E(p)) * g, v = T(a, d) + (function(S, b, w) {
|
|
2180
|
+
const D = (w.x - b.x) * (S.y - b.y) - (w.y - b.y) * (S.x - b.x);
|
|
2181
|
+
return D > 1e-10 ? "left" : D < -1e-10 ? "right" : "left";
|
|
2182
|
+
}(a, d, c) === "right" ? -90 : 90), f = rt(a, y, v), m = rt(d, y, v), C = W(f.x, f.y), P = W(m.x, m.y);
|
|
2183
2183
|
i = [e[0], e[1], [P.lng, P.lat], [C.lng, C.lat], e[0]];
|
|
2184
2184
|
}
|
|
2185
|
-
i && this.updatePolygonGeometry(this.currentId, i,
|
|
2185
|
+
i && this.updatePolygonGeometry(this.currentId, i, M.Provisional);
|
|
2186
2186
|
}
|
|
2187
2187
|
updatePolygonGeometry(t, e, i) {
|
|
2188
2188
|
const o = { type: "Polygon", coordinates: [e] };
|
|
@@ -2194,7 +2194,7 @@ class ve extends N {
|
|
|
2194
2194
|
this.currentId = e, this.currentCoordinate++, this.setDrawing();
|
|
2195
2195
|
} else if (this.currentCoordinate === 1 && this.currentId) {
|
|
2196
2196
|
const e = this.store.getGeometryCopy(this.currentId);
|
|
2197
|
-
if (Z([t.lng, t.lat], e.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [e.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], e.coordinates[0][0]],
|
|
2197
|
+
if (Z([t.lng, t.lat], e.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [e.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], e.coordinates[0][0]], M.Commit)) return;
|
|
2198
2198
|
this.currentCoordinate++;
|
|
2199
2199
|
} else this.currentCoordinate === 2 && this.currentId && this.close();
|
|
2200
2200
|
}
|
|
@@ -2217,24 +2217,24 @@ class ve extends N {
|
|
|
2217
2217
|
this.currentId = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted();
|
|
2218
2218
|
}
|
|
2219
2219
|
styleFeature(t) {
|
|
2220
|
-
const e =
|
|
2220
|
+
const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
2221
2221
|
return t.properties.mode === this.mode && t.geometry.type === "Polygon" && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
|
|
2222
2222
|
}
|
|
2223
2223
|
validateFeature(t) {
|
|
2224
2224
|
return this.validateModeFeature(t, (e) => nt(e, this.coordinatePrecision));
|
|
2225
2225
|
}
|
|
2226
2226
|
}
|
|
2227
|
-
function
|
|
2227
|
+
function Fe(r, t, e) {
|
|
2228
2228
|
return (t.x - r.x) * (e.y - r.y) - (t.y - r.y) * (e.x - r.x) <= 0;
|
|
2229
2229
|
}
|
|
2230
|
-
class
|
|
2230
|
+
class Ee extends N {
|
|
2231
2231
|
constructor(t) {
|
|
2232
2232
|
super(t), this.mode = "sector", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.direction = void 0, this.arcPoints = void 0, this.cursors = void 0, this.mouseMove = !1;
|
|
2233
2233
|
const e = { start: "crosshair", close: "pointer" };
|
|
2234
|
-
if (this.cursors = t && t.cursors ?
|
|
2234
|
+
if (this.cursors = t && t.cursors ? I({}, e, t.cursors) : e, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
|
|
2235
2235
|
else {
|
|
2236
2236
|
const i = { cancel: "Escape", finish: "Enter" };
|
|
2237
|
-
this.keyEvents = t && t.keyEvents ?
|
|
2237
|
+
this.keyEvents = t && t.keyEvents ? I({}, i, t.keyEvents) : i;
|
|
2238
2238
|
}
|
|
2239
2239
|
this.arcPoints = (t == null ? void 0 : t.arcPoints) || 64;
|
|
2240
2240
|
}
|
|
@@ -2257,23 +2257,23 @@ class Pe extends N {
|
|
|
2257
2257
|
const o = 1 / Math.pow(10, this.coordinatePrecision - 1), s = Math.max(1e-6, o);
|
|
2258
2258
|
i = [e[0], [t.lng, t.lat], [t.lng, t.lat - s], e[0]];
|
|
2259
2259
|
} else if (this.currentCoordinate === 2) {
|
|
2260
|
-
const o = e[0], s = e[1], n = [t.lng, t.lat], a =
|
|
2260
|
+
const o = e[0], s = e[1], n = [t.lng, t.lat], a = x(o[0], o[1]), l = x(s[0], s[1]), d = x(n[0], n[1]);
|
|
2261
2261
|
if (this.direction === void 0) {
|
|
2262
|
-
const C =
|
|
2262
|
+
const C = Fe(a, l, d);
|
|
2263
2263
|
this.direction = C ? "clockwise" : "anticlockwise";
|
|
2264
2264
|
}
|
|
2265
|
-
const c =
|
|
2265
|
+
const c = O(a, l), h = T(a, l), u = T(a, d), p = this.arcPoints, g = [o], y = K(h), v = K(u);
|
|
2266
2266
|
let f;
|
|
2267
2267
|
this.direction === "anticlockwise" ? (f = v - y, f < 0 && (f += 360)) : (f = y - v, f < 0 && (f += 360));
|
|
2268
2268
|
const m = (this.direction === "anticlockwise" ? 1 : -1) * f / p;
|
|
2269
2269
|
g.push(s);
|
|
2270
2270
|
for (let C = 0; C <= p; C++) {
|
|
2271
|
-
const P = rt(a, c, y + C * m), { lng:
|
|
2272
|
-
|
|
2271
|
+
const P = rt(a, c, y + C * m), { lng: S, lat: b } = W(P.x, P.y), w = [F(S, this.coordinatePrecision), F(b, this.coordinatePrecision)];
|
|
2272
|
+
w[0] !== g[g.length - 1][0] && w[1] !== g[g.length - 1][1] && g.push(w);
|
|
2273
2273
|
}
|
|
2274
2274
|
g.push(o), i = [...g];
|
|
2275
2275
|
}
|
|
2276
|
-
i && this.updatePolygonGeometry(this.currentId, i,
|
|
2276
|
+
i && this.updatePolygonGeometry(this.currentId, i, M.Provisional);
|
|
2277
2277
|
}
|
|
2278
2278
|
updatePolygonGeometry(t, e, i) {
|
|
2279
2279
|
const o = { type: "Polygon", coordinates: [e] };
|
|
@@ -2285,7 +2285,7 @@ class Pe extends N {
|
|
|
2285
2285
|
this.currentId = e, this.currentCoordinate++, this.setDrawing();
|
|
2286
2286
|
} else if (this.currentCoordinate === 1 && this.currentId) {
|
|
2287
2287
|
const e = this.store.getGeometryCopy(this.currentId);
|
|
2288
|
-
if (Z([t.lng, t.lat], e.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [e.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], e.coordinates[0][0]],
|
|
2288
|
+
if (Z([t.lng, t.lat], e.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [e.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], e.coordinates[0][0]], M.Commit)) return;
|
|
2289
2289
|
this.currentCoordinate++;
|
|
2290
2290
|
} else this.currentCoordinate === 2 && this.currentId && this.close();
|
|
2291
2291
|
}
|
|
@@ -2308,21 +2308,21 @@ class Pe extends N {
|
|
|
2308
2308
|
this.currentId = void 0, this.direction = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted();
|
|
2309
2309
|
}
|
|
2310
2310
|
styleFeature(t) {
|
|
2311
|
-
const e =
|
|
2311
|
+
const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
2312
2312
|
return t.properties.mode === this.mode && t.geometry.type === "Polygon" && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
|
|
2313
2313
|
}
|
|
2314
2314
|
validateFeature(t) {
|
|
2315
2315
|
return this.validateModeFeature(t, (e) => nt(e, this.coordinatePrecision));
|
|
2316
2316
|
}
|
|
2317
2317
|
}
|
|
2318
|
-
class
|
|
2318
|
+
class Oe extends N {
|
|
2319
2319
|
constructor(t) {
|
|
2320
2320
|
super(t), this.mode = "sensor", this.currentCoordinate = 0, this.currentId = void 0, this.currentInitialArcId = void 0, this.currentStartingPointId = void 0, this.keyEvents = void 0, this.direction = void 0, this.arcPoints = void 0, this.cursors = void 0, this.mouseMove = !1;
|
|
2321
2321
|
const e = { start: "crosshair", close: "pointer" };
|
|
2322
|
-
if (this.cursors = t && t.cursors ?
|
|
2322
|
+
if (this.cursors = t && t.cursors ? I({}, e, t.cursors) : e, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
|
|
2323
2323
|
else {
|
|
2324
2324
|
const i = { cancel: "Escape", finish: "Enter" };
|
|
2325
|
-
this.keyEvents = t && t.keyEvents ?
|
|
2325
|
+
this.keyEvents = t && t.keyEvents ? I({}, i, t.keyEvents) : i;
|
|
2326
2326
|
}
|
|
2327
2327
|
this.arcPoints = (t == null ? void 0 : t.arcPoints) || 64;
|
|
2328
2328
|
}
|
|
@@ -2340,31 +2340,31 @@ class xe extends N {
|
|
|
2340
2340
|
onMouseMove(t) {
|
|
2341
2341
|
if (this.mouseMove = !0, this.setCursor(this.cursors.start), this.currentInitialArcId !== void 0 && this.currentStartingPointId !== void 0 && this.currentCoordinate !== 0) {
|
|
2342
2342
|
if (this.currentCoordinate === 2) {
|
|
2343
|
-
const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = [t.lng, t.lat], n =
|
|
2343
|
+
const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = [t.lng, t.lat], n = x(o[0], o[1]), a = x(s[0], s[1]), l = x(i[0], i[1]), d = O(l, n);
|
|
2344
2344
|
if (this.direction === void 0) {
|
|
2345
|
-
const m =
|
|
2345
|
+
const m = Fe(l, n, a);
|
|
2346
2346
|
this.direction = m ? "clockwise" : "anticlockwise";
|
|
2347
2347
|
}
|
|
2348
|
-
const c =
|
|
2348
|
+
const c = T(l, n), h = T(l, a), u = this.arcPoints, p = [o], g = K(c), y = K(h);
|
|
2349
2349
|
let v;
|
|
2350
2350
|
this.direction === "anticlockwise" ? (v = y - g, v < 0 && (v += 360)) : (v = g - y, v < 0 && (v += 360));
|
|
2351
2351
|
const f = (this.direction === "anticlockwise" ? 1 : -1) * v / u;
|
|
2352
2352
|
for (let m = 0; m <= u; m++) {
|
|
2353
|
-
const C = rt(
|
|
2354
|
-
|
|
2353
|
+
const C = rt(l, d, g + m * f), { lng: P, lat: S } = W(C.x, C.y), b = [F(P, this.coordinatePrecision), F(S, this.coordinatePrecision)];
|
|
2354
|
+
b[0] !== p[p.length - 1][0] && b[1] !== p[p.length - 1][1] && p.push(b);
|
|
2355
2355
|
}
|
|
2356
|
-
this.updateLineStringGeometry(this.currentInitialArcId, p,
|
|
2356
|
+
this.updateLineStringGeometry(this.currentInitialArcId, p, M.Provisional);
|
|
2357
2357
|
} else if (this.currentCoordinate === 3) {
|
|
2358
2358
|
const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates;
|
|
2359
2359
|
if (e.length < 2 || !this.direction) return;
|
|
2360
|
-
const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = e[e.length - 1], n =
|
|
2360
|
+
const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = e[e.length - 1], n = x(t.lng, t.lat), a = x(o[0], o[1]), l = x(s[0], s[1]), d = x(i[0], i[1]), c = O(d, a), h = O(d, n) < c ? a : n, u = T(d, n), p = T(d, a), g = T(d, l), y = K(p), v = K(g), f = K(u);
|
|
2361
2361
|
if (this.notInSector({ normalizedCursor: f, normalizedStart: y, normalizedEnd: v, direction: this.direction })) return;
|
|
2362
|
-
const m = this.getDeltaBearing(this.direction, y, v), C = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * m / C,
|
|
2363
|
-
for (let
|
|
2364
|
-
const
|
|
2365
|
-
j[0] !== e[e.length - 1][0] && j[1] !== e[e.length - 1][1] &&
|
|
2362
|
+
const m = this.getDeltaBearing(this.direction, y, v), C = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * m / C, S = O(d, h), b = [];
|
|
2363
|
+
for (let w = 0; w <= C; w++) {
|
|
2364
|
+
const D = rt(d, S, y + w * P), { lng: A, lat: L } = W(D.x, D.y), j = [F(A, this.coordinatePrecision), F(L, this.coordinatePrecision)];
|
|
2365
|
+
j[0] !== e[e.length - 1][0] && j[1] !== e[e.length - 1][1] && b.unshift(j);
|
|
2366
2366
|
}
|
|
2367
|
-
e.push(...
|
|
2367
|
+
e.push(...b), e.push(e[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, e, M.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [e] }, properties: { mode: this.mode } }]);
|
|
2368
2368
|
}
|
|
2369
2369
|
}
|
|
2370
2370
|
}
|
|
@@ -2404,7 +2404,7 @@ class xe extends N {
|
|
|
2404
2404
|
this.currentStartingPointId = void 0, this.direction = void 0, this.currentId = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted();
|
|
2405
2405
|
}
|
|
2406
2406
|
styleFeature(t) {
|
|
2407
|
-
const e =
|
|
2407
|
+
const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
|
|
2408
2408
|
return t.properties.mode === this.mode && (t.geometry.type === "Polygon" ? (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10) : t.geometry.type === "LineString" ? (e.lineStringColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.lineStringWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.zIndex = 10) : t.geometry.type === "Point" && (e.pointColor = this.getHexColorStylingValue(this.styles.centerPointColor, e.pointColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.centerPointWidth, e.pointWidth, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.centerPointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.centerPointOutlineWidth, e.pointOutlineWidth, t), e.zIndex = 20)), e;
|
|
2409
2409
|
}
|
|
2410
2410
|
validateFeature(t) {
|
|
@@ -2418,9 +2418,9 @@ class xe extends N {
|
|
|
2418
2418
|
return o === "clockwise" ? e <= i ? t >= e && t <= i : t >= e || t <= i : e >= i ? t <= e && t >= i : t <= e || t >= i;
|
|
2419
2419
|
}
|
|
2420
2420
|
}
|
|
2421
|
-
class
|
|
2421
|
+
class vi {
|
|
2422
2422
|
constructor(t) {
|
|
2423
|
-
this._modes = void 0, this._mode = void 0, this._adapter = void 0, this._enabled = !1, this._store = void 0, this._eventListeners = void 0, this._instanceSelectMode = void 0, this._adapter = t.adapter, this._mode = new
|
|
2423
|
+
this._modes = void 0, this._mode = void 0, this._adapter = void 0, this._enabled = !1, this._store = void 0, this._eventListeners = void 0, this._instanceSelectMode = void 0, this._adapter = t.adapter, this._mode = new ai();
|
|
2424
2424
|
const e = /* @__PURE__ */ new Set(), i = t.modes.reduce((c, h) => {
|
|
2425
2425
|
if (e.has(h.mode)) throw new Error(`There is already a ${h.mode} mode provided`);
|
|
2426
2426
|
return e.add(h.mode), c[h.mode] = h, c;
|
|
@@ -2431,7 +2431,7 @@ class hi {
|
|
|
2431
2431
|
if (this._instanceSelectMode) throw new Error("only one type of select mode can be provided");
|
|
2432
2432
|
this._instanceSelectMode = c;
|
|
2433
2433
|
}
|
|
2434
|
-
}), this._modes =
|
|
2434
|
+
}), this._modes = I({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new gi({ tracked: !!t.tracked, idStrategy: t.idStrategy ? t.idStrategy : void 0 });
|
|
2435
2435
|
const s = (c) => {
|
|
2436
2436
|
const h = [], u = this._store.copyAll().filter((p) => !c.includes(p.id) || (h.push(p), !1));
|
|
2437
2437
|
return { changed: h, unchanged: u };
|
|
@@ -2446,14 +2446,14 @@ class hi {
|
|
|
2446
2446
|
});
|
|
2447
2447
|
const { changed: u, unchanged: p } = s(c);
|
|
2448
2448
|
h === "create" ? this._adapter.render({ created: u, deletedIds: [], unchanged: p, updated: [] }, this.getModeStyles()) : h === "update" ? this._adapter.render({ created: [], deletedIds: [], unchanged: p, updated: u }, this.getModeStyles()) : h === "delete" ? this._adapter.render({ created: [], deletedIds: c, unchanged: p, updated: [] }, this.getModeStyles()) : h === "styling" && this._adapter.render({ created: [], deletedIds: [], unchanged: p, updated: [] }, this.getModeStyles());
|
|
2449
|
-
},
|
|
2449
|
+
}, l = (c) => {
|
|
2450
2450
|
if (!this._enabled) return;
|
|
2451
2451
|
this._eventListeners.select.forEach((p) => {
|
|
2452
2452
|
p(c);
|
|
2453
2453
|
});
|
|
2454
2454
|
const { changed: h, unchanged: u } = s([c]);
|
|
2455
2455
|
this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: h }, this.getModeStyles());
|
|
2456
|
-
},
|
|
2456
|
+
}, d = (c) => {
|
|
2457
2457
|
if (!this._enabled) return;
|
|
2458
2458
|
this._eventListeners.deselect.forEach((p) => {
|
|
2459
2459
|
p();
|
|
@@ -2462,7 +2462,7 @@ class hi {
|
|
|
2462
2462
|
h && this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: h }, this.getModeStyles());
|
|
2463
2463
|
};
|
|
2464
2464
|
Object.keys(this._modes).forEach((c) => {
|
|
2465
|
-
this._modes[c].register({ mode: c, store: this._store, setCursor: this._adapter.setCursor.bind(this._adapter), project: this._adapter.project.bind(this._adapter), unproject: this._adapter.unproject.bind(this._adapter), setDoubleClickToZoom: this._adapter.setDoubleClickToZoom.bind(this._adapter), onChange: a, onSelect:
|
|
2465
|
+
this._modes[c].register({ mode: c, store: this._store, setCursor: this._adapter.setCursor.bind(this._adapter), project: this._adapter.project.bind(this._adapter), unproject: this._adapter.unproject.bind(this._adapter), setDoubleClickToZoom: this._adapter.setDoubleClickToZoom.bind(this._adapter), onChange: a, onSelect: l, onDeselect: d, onFinish: n, coordinatePrecision: this._adapter.getCoordinatePrecision() });
|
|
2466
2466
|
});
|
|
2467
2467
|
}
|
|
2468
2468
|
checkEnabled() {
|
|
@@ -2475,22 +2475,22 @@ class hi {
|
|
|
2475
2475
|
}), t;
|
|
2476
2476
|
}
|
|
2477
2477
|
featuresAtLocation({ lng: t, lat: e }, i) {
|
|
2478
|
-
const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, s = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, n = this._adapter.unproject.bind(this._adapter), a = this._adapter.project.bind(this._adapter),
|
|
2479
|
-
return this._store.search(
|
|
2478
|
+
const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, s = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, n = this._adapter.unproject.bind(this._adapter), a = this._adapter.project.bind(this._adapter), l = a(t, e), d = ue({ unproject: n, point: l, pointerDistance: o });
|
|
2479
|
+
return this._store.search(d).filter((c) => {
|
|
2480
2480
|
if (s && (c.properties[V.MID_POINT] || c.properties[V.SELECTION_POINT])) return !1;
|
|
2481
2481
|
if (c.geometry.type === "Point") {
|
|
2482
2482
|
const h = c.geometry.coordinates, u = a(h[0], h[1]);
|
|
2483
|
-
return
|
|
2483
|
+
return O(l, u) < o;
|
|
2484
2484
|
}
|
|
2485
2485
|
if (c.geometry.type === "LineString") {
|
|
2486
2486
|
const h = c.geometry.coordinates;
|
|
2487
2487
|
for (let u = 0; u < h.length - 1; u++) {
|
|
2488
2488
|
const p = h[u], g = h[u + 1];
|
|
2489
|
-
if (
|
|
2489
|
+
if (xe(l, a(p[0], p[1]), a(g[0], g[1])) < o) return !0;
|
|
2490
2490
|
}
|
|
2491
2491
|
return !1;
|
|
2492
2492
|
}
|
|
2493
|
-
return !!
|
|
2493
|
+
return !!Se([t, e], c.geometry.coordinates) || void 0;
|
|
2494
2494
|
});
|
|
2495
2495
|
}
|
|
2496
2496
|
getSelectMode() {
|
|
@@ -2591,14 +2591,14 @@ class hi {
|
|
|
2591
2591
|
i.includes(e) && i.splice(i.indexOf(e), 1);
|
|
2592
2592
|
}
|
|
2593
2593
|
}
|
|
2594
|
-
var
|
|
2595
|
-
function
|
|
2594
|
+
var Jt, Ft, Zt;
|
|
2595
|
+
function Qt(r, t = 9) {
|
|
2596
2596
|
const e = Math.pow(10, t);
|
|
2597
2597
|
return Math.round(r * e) / e;
|
|
2598
2598
|
}
|
|
2599
|
-
(
|
|
2599
|
+
(Ft = Jt || (Jt = {})).Commit = "commit", Ft.Provisional = "provisional", Ft.Finish = "finish", function(r) {
|
|
2600
2600
|
r.Drawing = "drawing", r.Select = "select", r.Static = "static", r.Render = "render";
|
|
2601
|
-
}(
|
|
2601
|
+
}(Zt || (Zt = {}));
|
|
2602
2602
|
class H {
|
|
2603
2603
|
constructor({ name: t, callback: e, unregister: i, register: o }) {
|
|
2604
2604
|
this.name = void 0, this.callback = void 0, this.registered = !1, this.register = void 0, this.unregister = void 0, this.name = t, this.register = () => {
|
|
@@ -2608,7 +2608,7 @@ class H {
|
|
|
2608
2608
|
}, this.callback = e;
|
|
2609
2609
|
}
|
|
2610
2610
|
}
|
|
2611
|
-
var
|
|
2611
|
+
var Ci = class {
|
|
2612
2612
|
constructor(r) {
|
|
2613
2613
|
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;
|
|
2614
2614
|
}
|
|
@@ -2623,7 +2623,7 @@ var ui = class {
|
|
|
2623
2623
|
const t = this.getLngLatFromEvent(r);
|
|
2624
2624
|
if (!t) return null;
|
|
2625
2625
|
const { lng: e, lat: i } = t, { containerX: o, containerY: s } = this.getMapElementXYPosition(r), n = this.getButton(r), a = Array.from(this._heldKeys);
|
|
2626
|
-
return { lng:
|
|
2626
|
+
return { lng: Qt(e, this._coordinatePrecision), lat: Qt(i, this._coordinatePrecision), containerX: o, containerY: s, button: n, heldKeys: a };
|
|
2627
2627
|
}
|
|
2628
2628
|
register(r) {
|
|
2629
2629
|
this._currentModeCallbacks = r, this._listeners = this.getAdapterListeners(), this._listeners.forEach((t) => {
|
|
@@ -2649,8 +2649,8 @@ var ui = class {
|
|
|
2649
2649
|
if (t) if (this._dragState === "not-dragging") this._currentModeCallbacks.onMouseMove(t), this._lastDrawEvent = t;
|
|
2650
2650
|
else if (this._dragState === "pre-dragging") {
|
|
2651
2651
|
if (!this._lastDrawEvent) return;
|
|
2652
|
-
const e = { x: this._lastDrawEvent.containerX, y: this._lastDrawEvent.containerY }, i = { x: t.containerX, y: t.containerY }, o = this._currentModeCallbacks.getState(), s = ((a,
|
|
2653
|
-
const { x:
|
|
2652
|
+
const e = { x: this._lastDrawEvent.containerX, y: this._lastDrawEvent.containerY }, i = { x: t.containerX, y: t.containerY }, o = this._currentModeCallbacks.getState(), s = ((a, l) => {
|
|
2653
|
+
const { x: d, y: c } = a, { x: h, y: u } = l, p = h - d, g = u - c;
|
|
2654
2654
|
return Math.sqrt(g * g + p * p);
|
|
2655
2655
|
})(e, i);
|
|
2656
2656
|
let n = !1;
|
|
@@ -2701,7 +2701,7 @@ var ui = class {
|
|
|
2701
2701
|
}), this.clear();
|
|
2702
2702
|
}
|
|
2703
2703
|
};
|
|
2704
|
-
class
|
|
2704
|
+
class Pi extends Ci {
|
|
2705
2705
|
constructor(t) {
|
|
2706
2706
|
super(t), this._nextRender = void 0, this._map = void 0, this._container = void 0, this._rendered = !1, this.changedIds = { deletion: !1, points: !1, linestrings: !1, polygons: !1, styling: !1 }, this._map = t.map, this._container = this._map.getContainer();
|
|
2707
2707
|
}
|
|
@@ -2771,13 +2771,13 @@ class pi extends ui {
|
|
|
2771
2771
|
this.updateChangedIds(t), this._nextRender && cancelAnimationFrame(this._nextRender), this._nextRender = requestAnimationFrame(() => {
|
|
2772
2772
|
const i = [...t.created, ...t.updated, ...t.unchanged], o = [], s = [], n = [];
|
|
2773
2773
|
for (let a = 0; a < i.length; a++) {
|
|
2774
|
-
const
|
|
2775
|
-
|
|
2774
|
+
const l = i[a], { properties: d } = l, c = e[d.mode](l);
|
|
2775
|
+
l.geometry.type === "Point" ? (d.pointColor = c.pointColor, d.pointOutlineColor = c.pointOutlineColor, d.pointOutlineWidth = c.pointOutlineWidth, d.pointWidth = c.pointWidth, o.push(l)) : l.geometry.type === "LineString" ? (d.lineStringColor = c.lineStringColor, d.lineStringWidth = c.lineStringWidth, s.push(l)) : l.geometry.type === "Polygon" && (d.polygonFillColor = c.polygonFillColor, d.polygonFillOpacity = c.polygonFillOpacity, d.polygonOutlineColor = c.polygonOutlineColor, d.polygonOutlineWidth = c.polygonOutlineWidth, n.push(l));
|
|
2776
2776
|
}
|
|
2777
2777
|
if (this._rendered) {
|
|
2778
|
-
const a = this.changedIds.deletion || this.changedIds.styling,
|
|
2778
|
+
const a = this.changedIds.deletion || this.changedIds.styling, l = a || this.changedIds.linestrings, d = a || this.changedIds.polygons;
|
|
2779
2779
|
let c;
|
|
2780
|
-
(a || this.changedIds.points) && (c = this._setGeoJSONLayerData("Point", o)),
|
|
2780
|
+
(a || this.changedIds.points) && (c = this._setGeoJSONLayerData("Point", o)), l && this._setGeoJSONLayerData("LineString", s), d && this._setGeoJSONLayerData("Polygon", n), c && this._map.moveLayer(c);
|
|
2781
2781
|
} else {
|
|
2782
2782
|
const a = this._addGeoJSONLayer("Point", o);
|
|
2783
2783
|
this._addGeoJSONLayer("LineString", s), this._addGeoJSONLayer("Polygon", n), this._rendered = !0, a && this._map.moveLayer(a);
|
|
@@ -2799,7 +2799,7 @@ class pi extends ui {
|
|
|
2799
2799
|
super.register(t), (e = this._currentModeCallbacks) != null && e.onReady && this._currentModeCallbacks.onReady();
|
|
2800
2800
|
}
|
|
2801
2801
|
}
|
|
2802
|
-
const
|
|
2802
|
+
const io = [
|
|
2803
2803
|
"render",
|
|
2804
2804
|
"point",
|
|
2805
2805
|
"linestring",
|
|
@@ -2814,21 +2814,7 @@ const Hi = [
|
|
|
2814
2814
|
"delete-selection",
|
|
2815
2815
|
"delete",
|
|
2816
2816
|
"download"
|
|
2817
|
-
],
|
|
2818
|
-
"render",
|
|
2819
|
-
"linestring",
|
|
2820
|
-
"polygon",
|
|
2821
|
-
"rectangle",
|
|
2822
|
-
"circle",
|
|
2823
|
-
"freehand",
|
|
2824
|
-
"angled-rectangle",
|
|
2825
|
-
"sensor",
|
|
2826
|
-
"sector",
|
|
2827
|
-
"select",
|
|
2828
|
-
"delete-selection",
|
|
2829
|
-
"delete",
|
|
2830
|
-
"download"
|
|
2831
|
-
], gi = {
|
|
2817
|
+
], Si = {
|
|
2832
2818
|
modes: [
|
|
2833
2819
|
"render",
|
|
2834
2820
|
"point",
|
|
@@ -2846,9 +2832,10 @@ const Hi = [
|
|
|
2846
2832
|
"download"
|
|
2847
2833
|
],
|
|
2848
2834
|
open: !1
|
|
2849
|
-
},
|
|
2835
|
+
}, ut = {
|
|
2850
2836
|
modes: [
|
|
2851
2837
|
"render",
|
|
2838
|
+
"point",
|
|
2852
2839
|
"linestring",
|
|
2853
2840
|
"polygon",
|
|
2854
2841
|
"rectangle",
|
|
@@ -2865,7 +2852,15 @@ const Hi = [
|
|
|
2865
2852
|
open: !1,
|
|
2866
2853
|
// see styling parameters of Terra Draw at https://github.com/JamesLMilner/terra-draw/blob/main/guides/5.STYLING.md
|
|
2867
2854
|
modeOptions: {
|
|
2868
|
-
|
|
2855
|
+
point: new me({
|
|
2856
|
+
styles: {
|
|
2857
|
+
pointColor: "#FFFFFF",
|
|
2858
|
+
pointWidth: 5,
|
|
2859
|
+
pointOutlineColor: "#232E3D",
|
|
2860
|
+
pointOutlineWidth: 1
|
|
2861
|
+
}
|
|
2862
|
+
}),
|
|
2863
|
+
linestring: new ye({
|
|
2869
2864
|
styles: {
|
|
2870
2865
|
lineStringColor: "#232E3D",
|
|
2871
2866
|
lineStringWidth: 2,
|
|
@@ -2875,7 +2870,7 @@ const Hi = [
|
|
|
2875
2870
|
closingPointOutlineWidth: 1
|
|
2876
2871
|
}
|
|
2877
2872
|
}),
|
|
2878
|
-
polygon: new
|
|
2873
|
+
polygon: new ve({
|
|
2879
2874
|
styles: {
|
|
2880
2875
|
fillColor: "#EDEFF0",
|
|
2881
2876
|
fillOpacity: 0.7,
|
|
@@ -2887,7 +2882,7 @@ const Hi = [
|
|
|
2887
2882
|
closingPointOutlineWidth: 1
|
|
2888
2883
|
}
|
|
2889
2884
|
}),
|
|
2890
|
-
rectangle: new
|
|
2885
|
+
rectangle: new Ce({
|
|
2891
2886
|
styles: {
|
|
2892
2887
|
fillColor: "#EDEFF0",
|
|
2893
2888
|
fillOpacity: 0.7,
|
|
@@ -2895,7 +2890,7 @@ const Hi = [
|
|
|
2895
2890
|
outlineWidth: 2
|
|
2896
2891
|
}
|
|
2897
2892
|
}),
|
|
2898
|
-
"angled-rectangle": new
|
|
2893
|
+
"angled-rectangle": new we({
|
|
2899
2894
|
styles: {
|
|
2900
2895
|
fillColor: "#EDEFF0",
|
|
2901
2896
|
fillOpacity: 0.7,
|
|
@@ -2903,7 +2898,7 @@ const Hi = [
|
|
|
2903
2898
|
outlineWidth: 2
|
|
2904
2899
|
}
|
|
2905
2900
|
}),
|
|
2906
|
-
circle: new
|
|
2901
|
+
circle: new ce({
|
|
2907
2902
|
styles: {
|
|
2908
2903
|
fillColor: "#EDEFF0",
|
|
2909
2904
|
fillOpacity: 0.7,
|
|
@@ -2911,7 +2906,7 @@ const Hi = [
|
|
|
2911
2906
|
outlineWidth: 2
|
|
2912
2907
|
}
|
|
2913
2908
|
}),
|
|
2914
|
-
freehand: new
|
|
2909
|
+
freehand: new he({
|
|
2915
2910
|
styles: {
|
|
2916
2911
|
fillColor: "#EDEFF0",
|
|
2917
2912
|
fillOpacity: 0.7,
|
|
@@ -2923,7 +2918,7 @@ const Hi = [
|
|
|
2923
2918
|
closingPointOutlineWidth: 1
|
|
2924
2919
|
}
|
|
2925
2920
|
}),
|
|
2926
|
-
sensor: new
|
|
2921
|
+
sensor: new Oe({
|
|
2927
2922
|
styles: {
|
|
2928
2923
|
fillColor: "#EDEFF0",
|
|
2929
2924
|
fillOpacity: 0.7,
|
|
@@ -2935,15 +2930,156 @@ const Hi = [
|
|
|
2935
2930
|
centerPointOutlineWidth: 1
|
|
2936
2931
|
}
|
|
2937
2932
|
}),
|
|
2938
|
-
sector: new
|
|
2933
|
+
sector: new Ee({
|
|
2939
2934
|
styles: {
|
|
2940
2935
|
fillColor: "#EDEFF0",
|
|
2941
2936
|
fillOpacity: 0.7,
|
|
2942
2937
|
outlineColor: "#232E3D",
|
|
2943
2938
|
outlineWidth: 2
|
|
2944
2939
|
}
|
|
2940
|
+
}),
|
|
2941
|
+
select: new be({
|
|
2942
|
+
flags: {
|
|
2943
|
+
point: {
|
|
2944
|
+
feature: {
|
|
2945
|
+
draggable: !1
|
|
2946
|
+
}
|
|
2947
|
+
},
|
|
2948
|
+
polygon: {
|
|
2949
|
+
feature: {
|
|
2950
|
+
draggable: !0,
|
|
2951
|
+
rotateable: !0,
|
|
2952
|
+
scaleable: !0,
|
|
2953
|
+
coordinates: {
|
|
2954
|
+
midpoints: !0,
|
|
2955
|
+
draggable: !0,
|
|
2956
|
+
deletable: !0
|
|
2957
|
+
}
|
|
2958
|
+
}
|
|
2959
|
+
},
|
|
2960
|
+
linestring: {
|
|
2961
|
+
feature: {
|
|
2962
|
+
draggable: !0,
|
|
2963
|
+
rotateable: !0,
|
|
2964
|
+
scaleable: !0,
|
|
2965
|
+
coordinates: {
|
|
2966
|
+
midpoints: !0,
|
|
2967
|
+
draggable: !0,
|
|
2968
|
+
deletable: !0
|
|
2969
|
+
}
|
|
2970
|
+
}
|
|
2971
|
+
},
|
|
2972
|
+
freehand: {
|
|
2973
|
+
feature: {
|
|
2974
|
+
draggable: !0,
|
|
2975
|
+
coordinates: {
|
|
2976
|
+
midpoints: !0,
|
|
2977
|
+
draggable: !0,
|
|
2978
|
+
deletable: !0
|
|
2979
|
+
}
|
|
2980
|
+
}
|
|
2981
|
+
},
|
|
2982
|
+
circle: {
|
|
2983
|
+
feature: {
|
|
2984
|
+
draggable: !0,
|
|
2985
|
+
coordinates: {
|
|
2986
|
+
midpoints: !0,
|
|
2987
|
+
draggable: !0,
|
|
2988
|
+
deletable: !0
|
|
2989
|
+
}
|
|
2990
|
+
}
|
|
2991
|
+
},
|
|
2992
|
+
rectangle: {
|
|
2993
|
+
feature: {
|
|
2994
|
+
draggable: !0,
|
|
2995
|
+
rotateable: !0,
|
|
2996
|
+
scaleable: !0,
|
|
2997
|
+
coordinates: {
|
|
2998
|
+
midpoints: !0,
|
|
2999
|
+
draggable: !0,
|
|
3000
|
+
deletable: !0
|
|
3001
|
+
}
|
|
3002
|
+
}
|
|
3003
|
+
},
|
|
3004
|
+
"angled-rectangle": {
|
|
3005
|
+
feature: {
|
|
3006
|
+
draggable: !0,
|
|
3007
|
+
rotateable: !0,
|
|
3008
|
+
scaleable: !0,
|
|
3009
|
+
coordinates: {
|
|
3010
|
+
midpoints: !0,
|
|
3011
|
+
draggable: !0,
|
|
3012
|
+
deletable: !0
|
|
3013
|
+
}
|
|
3014
|
+
}
|
|
3015
|
+
},
|
|
3016
|
+
sensor: {
|
|
3017
|
+
feature: {
|
|
3018
|
+
draggable: !0,
|
|
3019
|
+
rotateable: !0,
|
|
3020
|
+
scaleable: !0,
|
|
3021
|
+
coordinates: {
|
|
3022
|
+
midpoints: !0,
|
|
3023
|
+
draggable: !0,
|
|
3024
|
+
deletable: !0
|
|
3025
|
+
}
|
|
3026
|
+
}
|
|
3027
|
+
},
|
|
3028
|
+
sector: {
|
|
3029
|
+
feature: {
|
|
3030
|
+
draggable: !0,
|
|
3031
|
+
rotateable: !0,
|
|
3032
|
+
scaleable: !0,
|
|
3033
|
+
coordinates: {
|
|
3034
|
+
midpoints: !0,
|
|
3035
|
+
draggable: !0,
|
|
3036
|
+
deletable: !0
|
|
3037
|
+
}
|
|
3038
|
+
}
|
|
3039
|
+
}
|
|
3040
|
+
}
|
|
2945
3041
|
})
|
|
2946
3042
|
},
|
|
3043
|
+
pointLayerLabelSpec: {
|
|
3044
|
+
id: "terradraw-measure-point-label",
|
|
3045
|
+
type: "symbol",
|
|
3046
|
+
source: "terradraw-measure-point-source",
|
|
3047
|
+
filter: ["all", ["==", "$type", "Point"], ["==", "mode", "point"]],
|
|
3048
|
+
layout: {
|
|
3049
|
+
"text-field": [
|
|
3050
|
+
"case",
|
|
3051
|
+
["all", ["has", "elevation"], [">", ["get", "elevation"], 0]],
|
|
3052
|
+
["concat", "Alt. ", ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
3053
|
+
""
|
|
3054
|
+
],
|
|
3055
|
+
"symbol-placement": "point",
|
|
3056
|
+
"text-size": [
|
|
3057
|
+
"interpolate",
|
|
3058
|
+
["linear"],
|
|
3059
|
+
["zoom"],
|
|
3060
|
+
5,
|
|
3061
|
+
10,
|
|
3062
|
+
10,
|
|
3063
|
+
12,
|
|
3064
|
+
13,
|
|
3065
|
+
14,
|
|
3066
|
+
14,
|
|
3067
|
+
16,
|
|
3068
|
+
18,
|
|
3069
|
+
18
|
|
3070
|
+
],
|
|
3071
|
+
"text-overlap": "always",
|
|
3072
|
+
"text-variable-anchor": ["left", "right", "top", "bottom"],
|
|
3073
|
+
"text-radial-offset": 0.5,
|
|
3074
|
+
"text-justify": "center",
|
|
3075
|
+
"text-letter-spacing": 0.05
|
|
3076
|
+
},
|
|
3077
|
+
paint: {
|
|
3078
|
+
"text-halo-color": "#F7F7F7",
|
|
3079
|
+
"text-halo-width": 2,
|
|
3080
|
+
"text-color": "#232E3D"
|
|
3081
|
+
}
|
|
3082
|
+
},
|
|
2947
3083
|
lineLayerLabelSpec: {
|
|
2948
3084
|
id: "terradraw-measure-line-label",
|
|
2949
3085
|
type: "symbol",
|
|
@@ -3056,28 +3192,28 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3056
3192
|
distancePrecision: 2,
|
|
3057
3193
|
areaUnit: "metric",
|
|
3058
3194
|
areaPrecision: 2
|
|
3059
|
-
},
|
|
3195
|
+
}, xi = () => ({
|
|
3060
3196
|
render: new et({
|
|
3061
3197
|
modeName: "render",
|
|
3062
3198
|
styles: {}
|
|
3063
3199
|
}),
|
|
3064
|
-
point: new
|
|
3065
|
-
linestring: new
|
|
3066
|
-
polygon: new
|
|
3200
|
+
point: new me(),
|
|
3201
|
+
linestring: new ye(),
|
|
3202
|
+
polygon: new ve({
|
|
3067
3203
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3068
3204
|
// @ts-ignore
|
|
3069
3205
|
validation: (t, e) => {
|
|
3070
3206
|
const i = e.updateType;
|
|
3071
|
-
return i === "finish" || i === "commit" ?
|
|
3207
|
+
return i === "finish" || i === "commit" ? mi(t) : { valid: !0 };
|
|
3072
3208
|
}
|
|
3073
3209
|
}),
|
|
3074
|
-
rectangle: new
|
|
3075
|
-
"angled-rectangle": new
|
|
3076
|
-
circle: new
|
|
3077
|
-
freehand: new
|
|
3078
|
-
sensor: new
|
|
3079
|
-
sector: new
|
|
3080
|
-
select: new
|
|
3210
|
+
rectangle: new Ce(),
|
|
3211
|
+
"angled-rectangle": new we(),
|
|
3212
|
+
circle: new ce(),
|
|
3213
|
+
freehand: new he(),
|
|
3214
|
+
sensor: new Oe(),
|
|
3215
|
+
sector: new Ee(),
|
|
3216
|
+
select: new be({
|
|
3081
3217
|
flags: {
|
|
3082
3218
|
point: {
|
|
3083
3219
|
feature: {
|
|
@@ -3190,32 +3326,40 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
|
|
|
3190
3326
|
modeName: "download",
|
|
3191
3327
|
styles: {}
|
|
3192
3328
|
})
|
|
3193
|
-
});
|
|
3194
|
-
|
|
3329
|
+
}), te = (r) => r.charAt(0).toUpperCase() + r.slice(1), xt = ["td-point", "td-linestring", "td-polygon"];
|
|
3330
|
+
var re, ne, ae;
|
|
3331
|
+
const oo = [
|
|
3332
|
+
...xt,
|
|
3333
|
+
(re = ut.polygonLayerSpec) == null ? void 0 : re.source,
|
|
3334
|
+
(ne = ut.lineLayerLabelSpec) == null ? void 0 : ne.source,
|
|
3335
|
+
(ae = ut.pointLayerLabelSpec) == null ? void 0 : ae.source
|
|
3336
|
+
], De = (r, t, e = xt) => {
|
|
3337
|
+
const i = JSON.parse(JSON.stringify(r));
|
|
3338
|
+
return t && (t.onlyTerraDrawLayers === !0 ? (i.layers = i.layers.filter((o) => "source" in o && e.includes(o.source)), Object.keys(i.sources).forEach((o) => {
|
|
3339
|
+
e.includes(o) || delete i.sources[o];
|
|
3340
|
+
})) : t.excludeTerraDrawLayers === !0 && (i.layers = i.layers.filter((o) => "source" in o && !e.includes(o.source)), Object.keys(i.sources).forEach((o) => {
|
|
3341
|
+
e.includes(o) && delete i.sources[o];
|
|
3342
|
+
}))), i;
|
|
3343
|
+
}, Ii = (r, t = 250) => {
|
|
3344
|
+
let e;
|
|
3345
|
+
return (...i) => {
|
|
3346
|
+
clearTimeout(e), e = setTimeout(() => r(...i), t);
|
|
3347
|
+
};
|
|
3348
|
+
};
|
|
3349
|
+
class bi {
|
|
3195
3350
|
/**
|
|
3196
3351
|
* Constructor
|
|
3197
3352
|
* @param options Plugin control options
|
|
3198
3353
|
*/
|
|
3199
3354
|
constructor(t) {
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
/**
|
|
3209
|
-
* debounce
|
|
3210
|
-
* @param callback callback function
|
|
3211
|
-
* @param delay millisecond to delay
|
|
3212
|
-
*/
|
|
3213
|
-
L(this, "debounce", (t, e = 250) => {
|
|
3214
|
-
let i;
|
|
3215
|
-
return (...o) => {
|
|
3216
|
-
clearTimeout(i), i = setTimeout(() => t(...o), e);
|
|
3217
|
-
};
|
|
3218
|
-
});
|
|
3355
|
+
_(this, "controlContainer");
|
|
3356
|
+
_(this, "map");
|
|
3357
|
+
_(this, "modeButtons", {});
|
|
3358
|
+
_(this, "_isExpanded", !1);
|
|
3359
|
+
_(this, "terradraw");
|
|
3360
|
+
_(this, "options", Si);
|
|
3361
|
+
_(this, "events", {});
|
|
3362
|
+
_(this, "defaultMode", "render");
|
|
3219
3363
|
this.modeButtons = {}, t && (this.options = Object.assign(this.options, t));
|
|
3220
3364
|
}
|
|
3221
3365
|
/**
|
|
@@ -3253,16 +3397,16 @@ class mi {
|
|
|
3253
3397
|
* @returns HTML Element
|
|
3254
3398
|
*/
|
|
3255
3399
|
onAdd(t) {
|
|
3256
|
-
var o, s, n, a,
|
|
3400
|
+
var o, s, n, a, l;
|
|
3257
3401
|
if (this.options && this.options.modes && this.options.modes.length === 0)
|
|
3258
3402
|
throw new Error("At least a mode must be enabled.");
|
|
3259
3403
|
this.map = t;
|
|
3260
|
-
const e =
|
|
3261
|
-
return (s = (o = this.options) == null ? void 0 : o.modes) == null || s.forEach((
|
|
3262
|
-
if (this.options.modeOptions && this.options.modeOptions[
|
|
3263
|
-
const c = this.options.modeOptions[
|
|
3264
|
-
if (
|
|
3265
|
-
const h = e[
|
|
3404
|
+
const e = xi(), i = [];
|
|
3405
|
+
return (s = (o = this.options) == null ? void 0 : o.modes) == null || s.forEach((d) => {
|
|
3406
|
+
if (this.options.modeOptions && this.options.modeOptions[d]) {
|
|
3407
|
+
const c = this.options.modeOptions[d];
|
|
3408
|
+
if (d === "select") {
|
|
3409
|
+
const h = e[d];
|
|
3266
3410
|
if (h) {
|
|
3267
3411
|
const u = h.flags;
|
|
3268
3412
|
Object.keys(u).forEach((p) => {
|
|
@@ -3271,23 +3415,23 @@ class mi {
|
|
|
3271
3415
|
}
|
|
3272
3416
|
}
|
|
3273
3417
|
i.push(c);
|
|
3274
|
-
} else e[
|
|
3275
|
-
}), i.forEach((
|
|
3276
|
-
|
|
3418
|
+
} else e[d] && i.push(e[d]);
|
|
3419
|
+
}), i.forEach((d) => {
|
|
3420
|
+
d.state !== "unregistered" && (d._state = "unregistered");
|
|
3277
3421
|
}), (a = (n = this.options) == null ? void 0 : n.modes) != null && a.includes("render") || (i.push(
|
|
3278
3422
|
new et({
|
|
3279
3423
|
modeName: "default",
|
|
3280
3424
|
styles: {}
|
|
3281
3425
|
})
|
|
3282
|
-
), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new
|
|
3283
|
-
adapter: new
|
|
3426
|
+
), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new vi({
|
|
3427
|
+
adapter: new Pi({ map: t, ...this.options.adapterOptions }),
|
|
3284
3428
|
modes: i
|
|
3285
|
-
}), this.terradraw.start(), this.controlContainer = document.createElement("div"), this.controlContainer.classList.add("maplibregl-ctrl"), this.controlContainer.classList.add("maplibregl-ctrl-group"), i.forEach((
|
|
3286
|
-
|
|
3287
|
-
}), Object.values(this.modeButtons).forEach((
|
|
3429
|
+
}), this.terradraw.start(), this.controlContainer = document.createElement("div"), this.controlContainer.classList.add("maplibregl-ctrl"), this.controlContainer.classList.add("maplibregl-ctrl-group"), i.forEach((d) => {
|
|
3430
|
+
d.mode !== "default" && this.addTerradrawButton(d.mode);
|
|
3431
|
+
}), Object.values(this.modeButtons).forEach((d) => {
|
|
3288
3432
|
var c;
|
|
3289
|
-
(c = this.controlContainer) == null || c.appendChild(
|
|
3290
|
-
}), (
|
|
3433
|
+
(c = this.controlContainer) == null || c.appendChild(d);
|
|
3434
|
+
}), (l = this.terradraw) == null || l.on("change", this.toggleButtonsWhenNoFeature.bind(this)), this.toggleButtonsWhenNoFeature(), this.controlContainer;
|
|
3291
3435
|
}
|
|
3292
3436
|
/**
|
|
3293
3437
|
* Remove the plugin control from maplibre
|
|
@@ -3318,12 +3462,17 @@ class mi {
|
|
|
3318
3462
|
/**
|
|
3319
3463
|
* Dispatch an event. Pass the current snapshot of features and mode
|
|
3320
3464
|
* @param event event type
|
|
3465
|
+
* @param args additional arguments
|
|
3321
3466
|
*/
|
|
3322
|
-
dispatchEvent(t) {
|
|
3323
|
-
this.events[t] && this.events[t].forEach((
|
|
3324
|
-
var
|
|
3325
|
-
const
|
|
3326
|
-
|
|
3467
|
+
dispatchEvent(t, e) {
|
|
3468
|
+
this.events[t] && this.events[t].forEach((i) => {
|
|
3469
|
+
var n, a;
|
|
3470
|
+
const o = (n = this.terradraw) == null ? void 0 : n.getSnapshot(), s = o == null ? void 0 : o.filter((l) => l.properties.selected === !0);
|
|
3471
|
+
i({
|
|
3472
|
+
feature: s,
|
|
3473
|
+
mode: (a = this.terradraw) == null ? void 0 : a.getMode(),
|
|
3474
|
+
...e
|
|
3475
|
+
});
|
|
3327
3476
|
});
|
|
3328
3477
|
}
|
|
3329
3478
|
/**
|
|
@@ -3372,17 +3521,18 @@ class mi {
|
|
|
3372
3521
|
*/
|
|
3373
3522
|
addTerradrawButton(t) {
|
|
3374
3523
|
const e = document.createElement("button");
|
|
3375
|
-
e.type = "button", this.modeButtons[t] = e, t === "render" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), this.isExpanded && e.classList.add("enabled"), e.type = "button", e.title =
|
|
3524
|
+
e.type = "button", this.modeButtons[t] = e, t === "render" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), this.isExpanded && e.classList.add("enabled"), e.type = "button", e.title = te("expand or collapse drawing tool"), e.addEventListener("click", this.toggleEditor.bind(this))) : (e.classList.add("maplibregl-terradraw-add-control"), this.isExpanded || e.classList.add("hidden"), e.title = te(t.replace(/-/g, " ")), t === "delete" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.addEventListener("click", () => {
|
|
3376
3525
|
this.terradraw && this.terradraw.enabled && (this.terradraw.clear(), this.deactivate(), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.dispatchEvent("feature-deleted"));
|
|
3377
3526
|
})) : t === "delete-selection" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.classList.add("hidden-delete-selection"), e.addEventListener("click", () => {
|
|
3378
3527
|
var s;
|
|
3379
3528
|
if (!this.terradraw || !this.terradraw.enabled) return;
|
|
3380
3529
|
const o = ((s = this.terradraw) == null ? void 0 : s.getSnapshot()).filter((n) => n.properties.selected === !0);
|
|
3381
3530
|
if (o.length > 0) {
|
|
3382
|
-
const n =
|
|
3383
|
-
this.terradraw.
|
|
3384
|
-
const a
|
|
3385
|
-
|
|
3531
|
+
const n = o.map((a) => a.id);
|
|
3532
|
+
this.terradraw.removeFeatures(n);
|
|
3533
|
+
for (const a of n)
|
|
3534
|
+
this.terradraw.deselectFeature(a);
|
|
3535
|
+
this.dispatchEvent("feature-deleted", { deletedIds: n });
|
|
3386
3536
|
}
|
|
3387
3537
|
this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature();
|
|
3388
3538
|
})) : t === "download" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.addEventListener("click", this.handleDownload.bind(this))) : (e.classList.add(`maplibregl-terradraw-add-${t}-button`), e.addEventListener("click", () => {
|
|
@@ -3405,6 +3555,24 @@ class mi {
|
|
|
3405
3555
|
};
|
|
3406
3556
|
return t !== !0 || (o.features = o.features.filter((n) => n.properties.selected === !0)), o;
|
|
3407
3557
|
}
|
|
3558
|
+
/**
|
|
3559
|
+
* clean maplibre style to filter only for terradraw related layers or without them.
|
|
3560
|
+
* If options are not set, returns original style given to the function.
|
|
3561
|
+
*
|
|
3562
|
+
* This can be useful incase users only want to get terradraw related layers or without it.
|
|
3563
|
+
*
|
|
3564
|
+
* Usage:
|
|
3565
|
+
* `cleanStyle(map.getStyle, { excludeTerraDrawLayers: true})`
|
|
3566
|
+
* `cleanStyle(map.getStyle, { onlyTerraDrawLayers: true})`
|
|
3567
|
+
*
|
|
3568
|
+
* @param style maplibre style spec
|
|
3569
|
+
* @param options.excludeTerraDrawLayers return maplibre style without terradraw layers and sources
|
|
3570
|
+
* @param options.onlyTerraDrawLayers return maplibre style with only terradraw layers and sources
|
|
3571
|
+
* @returns
|
|
3572
|
+
*/
|
|
3573
|
+
cleanStyle(t, e) {
|
|
3574
|
+
return De(t, e, xt);
|
|
3575
|
+
}
|
|
3408
3576
|
/**
|
|
3409
3577
|
* Download button click event handler
|
|
3410
3578
|
*/
|
|
@@ -3434,30 +3602,22 @@ class mi {
|
|
|
3434
3602
|
* Toggle the state of delete-select button
|
|
3435
3603
|
*/
|
|
3436
3604
|
toggleDeleteSelectionButton() {
|
|
3437
|
-
var a,
|
|
3438
|
-
const t = ((a = this.terradraw) == null ? void 0 : a.enabled) || !1, e = (
|
|
3439
|
-
for (let
|
|
3440
|
-
const c = n.item(
|
|
3605
|
+
var a, l;
|
|
3606
|
+
const t = ((a = this.terradraw) == null ? void 0 : a.enabled) || !1, e = (l = this.terradraw) == null ? void 0 : l.getMode(), i = this.getFeatures(!1), o = i && i.features.length > 0, s = o && t && e === "select", n = document.getElementsByClassName("maplibregl-terradraw-delete-selection-button");
|
|
3607
|
+
for (let d = 0; d < n.length; d++) {
|
|
3608
|
+
const c = n.item(d);
|
|
3441
3609
|
c && (s ? c.classList.remove("hidden-delete-selection") : c.classList.add("hidden-delete-selection"));
|
|
3442
3610
|
}
|
|
3443
3611
|
if (!o) {
|
|
3444
|
-
const
|
|
3445
|
-
for (let c = 0; c <
|
|
3446
|
-
const h =
|
|
3612
|
+
const d = document.getElementsByClassName("maplibregl-terradraw-add-select-button");
|
|
3613
|
+
for (let c = 0; c < d.length; c++) {
|
|
3614
|
+
const h = d.item(c);
|
|
3447
3615
|
h && h.classList.remove("active");
|
|
3448
3616
|
}
|
|
3449
3617
|
}
|
|
3450
3618
|
}
|
|
3451
|
-
/**
|
|
3452
|
-
* Capitalzie string value
|
|
3453
|
-
* @param value string value
|
|
3454
|
-
* @returns string
|
|
3455
|
-
*/
|
|
3456
|
-
capitalize(t) {
|
|
3457
|
-
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
3458
|
-
}
|
|
3459
3619
|
}
|
|
3460
|
-
var k = 63710088e-1,
|
|
3620
|
+
var k = 63710088e-1, Mi = {
|
|
3461
3621
|
centimeters: k * 100,
|
|
3462
3622
|
centimetres: k * 100,
|
|
3463
3623
|
degrees: 360 / (2 * Math.PI),
|
|
@@ -3474,26 +3634,26 @@ var k = 63710088e-1, vi = {
|
|
|
3474
3634
|
radians: 1,
|
|
3475
3635
|
yards: k * 1.0936
|
|
3476
3636
|
};
|
|
3477
|
-
function
|
|
3637
|
+
function wi(r, t, e = {}) {
|
|
3478
3638
|
const i = { type: "Feature" };
|
|
3479
3639
|
return (e.id === 0 || e.id) && (i.id = e.id), e.bbox && (i.bbox = e.bbox), i.properties = t || {}, i.geometry = r, i;
|
|
3480
3640
|
}
|
|
3481
|
-
function
|
|
3641
|
+
function Fi(r, t, e = {}) {
|
|
3482
3642
|
if (!r)
|
|
3483
3643
|
throw new Error("coordinates is required");
|
|
3484
3644
|
if (!Array.isArray(r))
|
|
3485
3645
|
throw new Error("coordinates must be an Array");
|
|
3486
3646
|
if (r.length < 2)
|
|
3487
3647
|
throw new Error("coordinates must be at least 2 numbers long");
|
|
3488
|
-
if (!
|
|
3648
|
+
if (!ee(r[0]) || !ee(r[1]))
|
|
3489
3649
|
throw new Error("coordinates must contain numbers");
|
|
3490
|
-
return
|
|
3650
|
+
return wi({
|
|
3491
3651
|
type: "Point",
|
|
3492
3652
|
coordinates: r
|
|
3493
3653
|
}, t, e);
|
|
3494
3654
|
}
|
|
3495
|
-
function
|
|
3496
|
-
const e =
|
|
3655
|
+
function Ei(r, t = "kilometers") {
|
|
3656
|
+
const e = Mi[t];
|
|
3497
3657
|
if (!e)
|
|
3498
3658
|
throw new Error(t + " units is invalid");
|
|
3499
3659
|
return r * e;
|
|
@@ -3501,10 +3661,10 @@ function xi(r, t = "kilometers") {
|
|
|
3501
3661
|
function ht(r) {
|
|
3502
3662
|
return r % 360 * Math.PI / 180;
|
|
3503
3663
|
}
|
|
3504
|
-
function
|
|
3664
|
+
function ee(r) {
|
|
3505
3665
|
return !isNaN(r) && r !== null && !Array.isArray(r);
|
|
3506
3666
|
}
|
|
3507
|
-
function
|
|
3667
|
+
function ie(r) {
|
|
3508
3668
|
if (!r)
|
|
3509
3669
|
throw new Error("coord is required");
|
|
3510
3670
|
if (!Array.isArray(r)) {
|
|
@@ -3517,28 +3677,28 @@ function Qt(r) {
|
|
|
3517
3677
|
return [...r];
|
|
3518
3678
|
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
3519
3679
|
}
|
|
3520
|
-
function
|
|
3521
|
-
var i =
|
|
3522
|
-
return
|
|
3523
|
-
2 * Math.atan2(Math.sqrt(
|
|
3680
|
+
function Oi(r, t, e = {}) {
|
|
3681
|
+
var i = ie(r), o = ie(t), s = ht(o[1] - i[1]), n = ht(o[0] - i[0]), a = ht(i[1]), l = ht(o[1]), d = Math.pow(Math.sin(s / 2), 2) + Math.pow(Math.sin(n / 2), 2) * Math.cos(a) * Math.cos(l);
|
|
3682
|
+
return Ei(
|
|
3683
|
+
2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
|
|
3524
3684
|
e.units
|
|
3525
3685
|
);
|
|
3526
3686
|
}
|
|
3527
|
-
function
|
|
3687
|
+
function Le(r, t, e) {
|
|
3528
3688
|
if (r !== null)
|
|
3529
|
-
for (var i, o, s, n, a,
|
|
3530
|
-
|
|
3689
|
+
for (var i, o, s, n, a, l, d, c = 0, h = 0, u, p = r.type, g = p === "FeatureCollection", y = p === "Feature", v = g ? r.features.length : 1, f = 0; f < v; f++) {
|
|
3690
|
+
d = g ? r.features[f].geometry : y ? r.geometry : r, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
|
|
3531
3691
|
for (var m = 0; m < a; m++) {
|
|
3532
3692
|
var C = 0, P = 0;
|
|
3533
|
-
if (n = u ?
|
|
3534
|
-
|
|
3535
|
-
var
|
|
3536
|
-
switch (c =
|
|
3693
|
+
if (n = u ? d.geometries[m] : d, n !== null) {
|
|
3694
|
+
l = n.coordinates;
|
|
3695
|
+
var S = n.type;
|
|
3696
|
+
switch (c = S === "Polygon" || S === "MultiPolygon" ? 1 : 0, S) {
|
|
3537
3697
|
case null:
|
|
3538
3698
|
break;
|
|
3539
3699
|
case "Point":
|
|
3540
3700
|
if (t(
|
|
3541
|
-
|
|
3701
|
+
l,
|
|
3542
3702
|
h,
|
|
3543
3703
|
f,
|
|
3544
3704
|
C,
|
|
@@ -3549,25 +3709,25 @@ function Se(r, t, e) {
|
|
|
3549
3709
|
break;
|
|
3550
3710
|
case "LineString":
|
|
3551
3711
|
case "MultiPoint":
|
|
3552
|
-
for (i = 0; i <
|
|
3712
|
+
for (i = 0; i < l.length; i++) {
|
|
3553
3713
|
if (t(
|
|
3554
|
-
|
|
3714
|
+
l[i],
|
|
3555
3715
|
h,
|
|
3556
3716
|
f,
|
|
3557
3717
|
C,
|
|
3558
3718
|
P
|
|
3559
3719
|
) === !1)
|
|
3560
3720
|
return !1;
|
|
3561
|
-
h++,
|
|
3721
|
+
h++, S === "MultiPoint" && C++;
|
|
3562
3722
|
}
|
|
3563
|
-
|
|
3723
|
+
S === "LineString" && C++;
|
|
3564
3724
|
break;
|
|
3565
3725
|
case "Polygon":
|
|
3566
3726
|
case "MultiLineString":
|
|
3567
|
-
for (i = 0; i <
|
|
3568
|
-
for (o = 0; o <
|
|
3727
|
+
for (i = 0; i < l.length; i++) {
|
|
3728
|
+
for (o = 0; o < l[i].length - c; o++) {
|
|
3569
3729
|
if (t(
|
|
3570
|
-
|
|
3730
|
+
l[i][o],
|
|
3571
3731
|
h,
|
|
3572
3732
|
f,
|
|
3573
3733
|
C,
|
|
@@ -3576,16 +3736,16 @@ function Se(r, t, e) {
|
|
|
3576
3736
|
return !1;
|
|
3577
3737
|
h++;
|
|
3578
3738
|
}
|
|
3579
|
-
|
|
3739
|
+
S === "MultiLineString" && C++, S === "Polygon" && P++;
|
|
3580
3740
|
}
|
|
3581
|
-
|
|
3741
|
+
S === "Polygon" && C++;
|
|
3582
3742
|
break;
|
|
3583
3743
|
case "MultiPolygon":
|
|
3584
|
-
for (i = 0; i <
|
|
3585
|
-
for (P = 0, o = 0; o <
|
|
3586
|
-
for (s = 0; s <
|
|
3744
|
+
for (i = 0; i < l.length; i++) {
|
|
3745
|
+
for (P = 0, o = 0; o < l[i].length; o++) {
|
|
3746
|
+
for (s = 0; s < l[i][o].length - c; s++) {
|
|
3587
3747
|
if (t(
|
|
3588
|
-
|
|
3748
|
+
l[i][o][s],
|
|
3589
3749
|
h,
|
|
3590
3750
|
f,
|
|
3591
3751
|
C,
|
|
@@ -3601,7 +3761,7 @@ function Se(r, t, e) {
|
|
|
3601
3761
|
break;
|
|
3602
3762
|
case "GeometryCollection":
|
|
3603
3763
|
for (i = 0; i < n.geometries.length; i++)
|
|
3604
|
-
if (
|
|
3764
|
+
if (Le(n.geometries[i], t) === !1)
|
|
3605
3765
|
return !1;
|
|
3606
3766
|
break;
|
|
3607
3767
|
default:
|
|
@@ -3611,15 +3771,15 @@ function Se(r, t, e) {
|
|
|
3611
3771
|
}
|
|
3612
3772
|
}
|
|
3613
3773
|
}
|
|
3614
|
-
function
|
|
3615
|
-
var e, i, o, s, n, a,
|
|
3774
|
+
function Di(r, t) {
|
|
3775
|
+
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;
|
|
3616
3776
|
for (e = 0; e < y; e++) {
|
|
3617
|
-
for (a = p ? r.features[e].geometry : g ? r.geometry : r,
|
|
3618
|
-
if (s =
|
|
3777
|
+
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++) {
|
|
3778
|
+
if (s = l ? a.geometries[o] : a, s === null) {
|
|
3619
3779
|
if (t(
|
|
3620
3780
|
null,
|
|
3621
3781
|
u,
|
|
3622
|
-
|
|
3782
|
+
d,
|
|
3623
3783
|
c,
|
|
3624
3784
|
h
|
|
3625
3785
|
) === !1)
|
|
@@ -3636,7 +3796,7 @@ function Mi(r, t) {
|
|
|
3636
3796
|
if (t(
|
|
3637
3797
|
s,
|
|
3638
3798
|
u,
|
|
3639
|
-
|
|
3799
|
+
d,
|
|
3640
3800
|
c,
|
|
3641
3801
|
h
|
|
3642
3802
|
) === !1)
|
|
@@ -3648,7 +3808,7 @@ function Mi(r, t) {
|
|
|
3648
3808
|
if (t(
|
|
3649
3809
|
s.geometries[i],
|
|
3650
3810
|
u,
|
|
3651
|
-
|
|
3811
|
+
d,
|
|
3652
3812
|
c,
|
|
3653
3813
|
h
|
|
3654
3814
|
) === !1)
|
|
@@ -3662,37 +3822,37 @@ function Mi(r, t) {
|
|
|
3662
3822
|
u++;
|
|
3663
3823
|
}
|
|
3664
3824
|
}
|
|
3665
|
-
function
|
|
3825
|
+
function Li(r, t, e) {
|
|
3666
3826
|
var i = e;
|
|
3667
|
-
return
|
|
3827
|
+
return Di(
|
|
3668
3828
|
r,
|
|
3669
|
-
function(o, s, n, a,
|
|
3829
|
+
function(o, s, n, a, l) {
|
|
3670
3830
|
s === 0 && e === void 0 ? i = o : i = t(
|
|
3671
3831
|
i,
|
|
3672
3832
|
o,
|
|
3673
3833
|
s,
|
|
3674
3834
|
n,
|
|
3675
3835
|
a,
|
|
3676
|
-
|
|
3836
|
+
l
|
|
3677
3837
|
);
|
|
3678
3838
|
}
|
|
3679
3839
|
), i;
|
|
3680
3840
|
}
|
|
3681
|
-
function
|
|
3682
|
-
return
|
|
3841
|
+
function _i(r) {
|
|
3842
|
+
return Li(
|
|
3683
3843
|
r,
|
|
3684
|
-
(t, e) => t +
|
|
3844
|
+
(t, e) => t + ki(e),
|
|
3685
3845
|
0
|
|
3686
3846
|
);
|
|
3687
3847
|
}
|
|
3688
|
-
function
|
|
3848
|
+
function ki(r) {
|
|
3689
3849
|
let t = 0, e;
|
|
3690
3850
|
switch (r.type) {
|
|
3691
3851
|
case "Polygon":
|
|
3692
|
-
return
|
|
3852
|
+
return oe(r.coordinates);
|
|
3693
3853
|
case "MultiPolygon":
|
|
3694
3854
|
for (e = 0; e < r.coordinates.length; e++)
|
|
3695
|
-
t +=
|
|
3855
|
+
t += oe(r.coordinates[e]);
|
|
3696
3856
|
return t;
|
|
3697
3857
|
case "Point":
|
|
3698
3858
|
case "MultiPoint":
|
|
@@ -3702,87 +3862,87 @@ function bi(r) {
|
|
|
3702
3862
|
}
|
|
3703
3863
|
return 0;
|
|
3704
3864
|
}
|
|
3705
|
-
function
|
|
3865
|
+
function oe(r) {
|
|
3706
3866
|
let t = 0;
|
|
3707
3867
|
if (r && r.length > 0) {
|
|
3708
|
-
t += Math.abs(
|
|
3868
|
+
t += Math.abs(se(r[0]));
|
|
3709
3869
|
for (let e = 1; e < r.length; e++)
|
|
3710
|
-
t -= Math.abs(
|
|
3870
|
+
t -= Math.abs(se(r[e]));
|
|
3711
3871
|
}
|
|
3712
3872
|
return t;
|
|
3713
3873
|
}
|
|
3714
|
-
var
|
|
3715
|
-
function
|
|
3874
|
+
var Wi = k * k / 2, Et = Math.PI / 180;
|
|
3875
|
+
function se(r) {
|
|
3716
3876
|
const t = r.length - 1;
|
|
3717
3877
|
if (t <= 2) return 0;
|
|
3718
3878
|
let e = 0, i = 0;
|
|
3719
3879
|
for (; i < t; ) {
|
|
3720
|
-
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] *
|
|
3721
|
-
e += (
|
|
3880
|
+
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] * Et, l = s[1] * Et, d = n[0] * Et;
|
|
3881
|
+
e += (d - a) * Math.sin(l), i++;
|
|
3722
3882
|
}
|
|
3723
|
-
return e *
|
|
3883
|
+
return e * Wi;
|
|
3724
3884
|
}
|
|
3725
|
-
function
|
|
3885
|
+
function Bi(r, t = {}) {
|
|
3726
3886
|
let e = 0, i = 0, o = 0;
|
|
3727
|
-
return
|
|
3887
|
+
return Le(
|
|
3728
3888
|
r,
|
|
3729
3889
|
function(s) {
|
|
3730
3890
|
e += s[0], i += s[1], o++;
|
|
3731
3891
|
}
|
|
3732
|
-
),
|
|
3892
|
+
), Fi([e / o, i / o], t.properties);
|
|
3733
3893
|
}
|
|
3734
|
-
var
|
|
3735
|
-
function
|
|
3894
|
+
var ji = Object.defineProperty, Ni = (r, t, e) => t in r ? ji(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, tt = (r, t, e) => Ni(r, typeof t != "symbol" ? t + "" : t, e), mt = 2 * Math.PI * 6378137 / 2;
|
|
3895
|
+
function Ai(r) {
|
|
3736
3896
|
return r = r || 256, 2 * Math.PI * 6378137 / r;
|
|
3737
3897
|
}
|
|
3738
|
-
function
|
|
3739
|
-
r =
|
|
3740
|
-
var i = r[0], o = r[1], s = i *
|
|
3741
|
-
return n = n *
|
|
3898
|
+
function Ti(r, t, e = { enable: !0, decimal: 1 }) {
|
|
3899
|
+
r = _t(r);
|
|
3900
|
+
var i = r[0], o = r[1], s = i * mt / 180, n = Math.log(Math.tan((90 + o) * Math.PI / 360)) / (Math.PI / 180);
|
|
3901
|
+
return n = n * mt / 180, e.enable && (s = Number(s.toFixed(e.decimal)), n = Number(n.toFixed(e.decimal))), [s, n];
|
|
3742
3902
|
}
|
|
3743
|
-
function
|
|
3744
|
-
var i = r[0], o = r[1], s =
|
|
3903
|
+
function Gi(r, t, e) {
|
|
3904
|
+
var i = r[0], o = r[1], s = Ki(t, e), n = (i + mt) / s, a = (o + mt) / s;
|
|
3745
3905
|
return [n, a, t];
|
|
3746
3906
|
}
|
|
3747
|
-
function
|
|
3748
|
-
r =
|
|
3749
|
-
var i =
|
|
3750
|
-
return
|
|
3907
|
+
function _e(r, t, e) {
|
|
3908
|
+
r = _t(r);
|
|
3909
|
+
var i = Ti(r), o = Gi(i, t);
|
|
3910
|
+
return Ui(o);
|
|
3751
3911
|
}
|
|
3752
|
-
function
|
|
3753
|
-
if (r =
|
|
3912
|
+
function Vi(r, t, e) {
|
|
3913
|
+
if (r = _t(r), t === 0)
|
|
3754
3914
|
return [0, 0, 0];
|
|
3755
|
-
var i =
|
|
3756
|
-
return
|
|
3915
|
+
var i = _e(r, t);
|
|
3916
|
+
return zi(i);
|
|
3757
3917
|
}
|
|
3758
|
-
function
|
|
3918
|
+
function Ui(r, t, e) {
|
|
3759
3919
|
t = t || 256;
|
|
3760
3920
|
var i = r[0], o = r[1], s = r[2];
|
|
3761
3921
|
if (s === 0) return [0, 0, 0];
|
|
3762
|
-
|
|
3922
|
+
ke(s);
|
|
3763
3923
|
var n = Math.ceil(i / t) - 1, a = Math.ceil(o / t) - 1;
|
|
3764
3924
|
return n < 0 && (n = 0), a < 0 && (a = 0), [n, a, s];
|
|
3765
3925
|
}
|
|
3766
|
-
function
|
|
3767
|
-
|
|
3926
|
+
function zi(r, t) {
|
|
3927
|
+
Ri(r);
|
|
3768
3928
|
var e = r[0], i = r[1], o = r[2];
|
|
3769
3929
|
if (o === 0)
|
|
3770
3930
|
return [0, 0, 0];
|
|
3771
3931
|
var s = e, n = Math.pow(2, o) - 1 - i;
|
|
3772
3932
|
return [s, n, o];
|
|
3773
3933
|
}
|
|
3774
|
-
function
|
|
3934
|
+
function Ri(r, t) {
|
|
3775
3935
|
var e = r[0], i = r[1], o = r[2];
|
|
3776
3936
|
if (o == null) throw new Error("<zoom> is required");
|
|
3777
3937
|
if (e == null) throw new Error("<x> is required");
|
|
3778
3938
|
if (i == null) throw new Error("<y> is required");
|
|
3779
|
-
return o =
|
|
3939
|
+
return o = ke(o), r = Xi(r), r;
|
|
3780
3940
|
}
|
|
3781
|
-
function
|
|
3941
|
+
function Xi(r) {
|
|
3782
3942
|
var t = r[0], e = r[1], i = r[2], o = Math.pow(2, i);
|
|
3783
3943
|
return t = t % o, t < 0 && (t = t + o), [t, e, i];
|
|
3784
3944
|
}
|
|
3785
|
-
function
|
|
3945
|
+
function ke(r) {
|
|
3786
3946
|
if (r === !1) return r;
|
|
3787
3947
|
if (r == null)
|
|
3788
3948
|
throw new Error("<zoom> is required");
|
|
@@ -3792,22 +3952,22 @@ function Ie(r) {
|
|
|
3792
3952
|
throw new Error("<zoom> cannot be greater than 32");
|
|
3793
3953
|
return r;
|
|
3794
3954
|
}
|
|
3795
|
-
function
|
|
3796
|
-
var e =
|
|
3955
|
+
function _t(r, t) {
|
|
3956
|
+
var e = $i(r[0]), i = Yi(r[1]);
|
|
3797
3957
|
return i > 85 && (i = 85), i < -85 && (i = -85), [e, i];
|
|
3798
3958
|
}
|
|
3799
|
-
function
|
|
3800
|
-
return
|
|
3959
|
+
function Ki(r, t) {
|
|
3960
|
+
return Ai(t) / Math.pow(2, r);
|
|
3801
3961
|
}
|
|
3802
|
-
function
|
|
3962
|
+
function Yi(r) {
|
|
3803
3963
|
if (r == null) throw new Error("lat is required");
|
|
3804
3964
|
return (r > 90 || r < -90) && (r = r % 180, r > 90 && (r = -180 + r), r < -90 && (r = 180 + r), r === 0 && (r = 0)), r;
|
|
3805
3965
|
}
|
|
3806
|
-
function
|
|
3966
|
+
function $i(r) {
|
|
3807
3967
|
if (r == null) throw new Error("lng is required");
|
|
3808
3968
|
return (r > 180 || r < -180) && (r = r % 360, r > 180 && (r = -360 + r), r < -180 && (r = 360 + r), r === 0 && (r = 0)), r;
|
|
3809
3969
|
}
|
|
3810
|
-
class
|
|
3970
|
+
class We {
|
|
3811
3971
|
/**
|
|
3812
3972
|
* Constructor
|
|
3813
3973
|
* @param url URL for terrain RGB raster tilesets
|
|
@@ -3832,12 +3992,12 @@ class we {
|
|
|
3832
3992
|
const s = t[0], n = t[1];
|
|
3833
3993
|
let a = e;
|
|
3834
3994
|
e > this.maxzoom ? a = this.maxzoom : e < this.minzoom && (a = this.minzoom);
|
|
3835
|
-
const
|
|
3836
|
-
let c = this.getUrlExtension(
|
|
3995
|
+
const l = this.tms ? _e([s, n], a) : Vi([s, n], a), d = this.url.replace(/{x}/g, l[0].toString()).replace(/{y}/g, l[1].toString()).replace(/{z}/g, l[2].toString());
|
|
3996
|
+
let c = this.getUrlExtension(d);
|
|
3837
3997
|
switch (c || (c = "png"), c) {
|
|
3838
3998
|
case "png":
|
|
3839
3999
|
case "webp":
|
|
3840
|
-
this.getValueFromRaster(
|
|
4000
|
+
this.getValueFromRaster(d, l, s, n).then((h) => {
|
|
3841
4001
|
i(h);
|
|
3842
4002
|
});
|
|
3843
4003
|
break;
|
|
@@ -3864,17 +4024,17 @@ class we {
|
|
|
3864
4024
|
throw new Error(`Failed to fetch tile: ${s.statusText}`);
|
|
3865
4025
|
}
|
|
3866
4026
|
const n = await s.blob();
|
|
3867
|
-
return new Promise((a,
|
|
3868
|
-
const
|
|
3869
|
-
|
|
4027
|
+
return new Promise((a, l) => {
|
|
4028
|
+
const d = new Image();
|
|
4029
|
+
d.onload = () => {
|
|
3870
4030
|
const c = document.createElement("canvas");
|
|
3871
|
-
c.width =
|
|
4031
|
+
c.width = d.width, c.height = d.height;
|
|
3872
4032
|
const h = c.getContext("2d");
|
|
3873
|
-
if (!h) return
|
|
3874
|
-
h.drawImage(
|
|
3875
|
-
const u = h.getImageData(0, 0,
|
|
4033
|
+
if (!h) return l(new Error("Failed to create canvas context"));
|
|
4034
|
+
h.drawImage(d, 0, 0);
|
|
4035
|
+
const u = h.getImageData(0, 0, d.width, d.height).data, p = this.pixels2rgba(new Uint8Array(u), e, i, o), g = this.calc(p[0], p[1], p[2], p[3]);
|
|
3876
4036
|
a(g);
|
|
3877
|
-
},
|
|
4037
|
+
}, d.onerror = () => a(void 0), d.src = URL.createObjectURL(n);
|
|
3878
4038
|
});
|
|
3879
4039
|
}
|
|
3880
4040
|
/**
|
|
@@ -3887,12 +4047,12 @@ class we {
|
|
|
3887
4047
|
*/
|
|
3888
4048
|
pixels2rgba(t, e, i, o) {
|
|
3889
4049
|
const s = [];
|
|
3890
|
-
for (let
|
|
3891
|
-
const c = t[
|
|
4050
|
+
for (let d = 0; d < t.length; d += 4) {
|
|
4051
|
+
const c = t[d], h = t[d + 1], u = t[d + 2], p = t[d + 3], g = [c, h, u, p];
|
|
3892
4052
|
s.push(g);
|
|
3893
4053
|
}
|
|
3894
|
-
const n = this.tileToBBOX(e), a = this.getPixelPosition(i, o, n),
|
|
3895
|
-
return s[
|
|
4054
|
+
const n = this.tileToBBOX(e), a = this.getPixelPosition(i, o, n), l = a[0] + a[1] * this.tileSize;
|
|
4055
|
+
return s[l];
|
|
3896
4056
|
}
|
|
3897
4057
|
/**
|
|
3898
4058
|
* Get the position in pixel from the coordinates
|
|
@@ -3902,7 +4062,7 @@ class we {
|
|
|
3902
4062
|
* @returns The position in pixel
|
|
3903
4063
|
*/
|
|
3904
4064
|
getPixelPosition(t, e, i) {
|
|
3905
|
-
const o = this.tileSize, s = this.tileSize, n = i[2] - i[0], a = i[3] - i[1],
|
|
4065
|
+
const o = this.tileSize, s = this.tileSize, n = i[2] - i[0], a = i[3] - i[1], l = (t - i[0]) / n, d = (e - i[1]) / a, c = Math.floor(o * l), h = Math.floor(s * (1 - d));
|
|
3906
4066
|
return [c, h];
|
|
3907
4067
|
}
|
|
3908
4068
|
/**
|
|
@@ -3934,7 +4094,7 @@ class we {
|
|
|
3934
4094
|
return i * Math.atan(0.5 * (Math.exp(o) - Math.exp(-o)));
|
|
3935
4095
|
}
|
|
3936
4096
|
}
|
|
3937
|
-
class
|
|
4097
|
+
class Hi extends We {
|
|
3938
4098
|
/**
|
|
3939
4099
|
* Constructor
|
|
3940
4100
|
* @param url URL for terrain RGB raster tilesets
|
|
@@ -3966,7 +4126,7 @@ class Ui extends we {
|
|
|
3966
4126
|
return -1e4 + (t * 256 * 256 + e * 256 + i) * 0.1;
|
|
3967
4127
|
}
|
|
3968
4128
|
}
|
|
3969
|
-
class
|
|
4129
|
+
class qi extends We {
|
|
3970
4130
|
/**
|
|
3971
4131
|
* Constructor
|
|
3972
4132
|
* @param url URL for terrarium raster tilesets
|
|
@@ -4000,84 +4160,98 @@ class zi extends we {
|
|
|
4000
4160
|
return parseInt(o.toFixed(0));
|
|
4001
4161
|
}
|
|
4002
4162
|
}
|
|
4003
|
-
class
|
|
4163
|
+
class so extends bi {
|
|
4004
4164
|
/**
|
|
4005
4165
|
* Constructor
|
|
4006
4166
|
* @param options Plugin control options
|
|
4007
4167
|
*/
|
|
4008
4168
|
constructor(e) {
|
|
4009
|
-
let i =
|
|
4169
|
+
let i = ut;
|
|
4010
4170
|
e && (i = Object.assign(i, e));
|
|
4011
4171
|
super({
|
|
4012
4172
|
modes: i.modes,
|
|
4013
4173
|
open: i.open,
|
|
4014
4174
|
modeOptions: i.modeOptions
|
|
4015
4175
|
});
|
|
4016
|
-
|
|
4176
|
+
_(this, "measureOptions");
|
|
4017
4177
|
/**
|
|
4018
4178
|
* Handle deselect event of terradraw
|
|
4019
|
-
* @param id Feature ID
|
|
4020
4179
|
*/
|
|
4021
|
-
|
|
4022
|
-
if (this.map && this.
|
|
4180
|
+
_(this, "handleTerradrawDeselect", () => {
|
|
4181
|
+
if (this.map && this.computeElevation === !0 && this.measureOptions.terrainSource !== void 0) {
|
|
4023
4182
|
const e = this.getTerraDrawInstance();
|
|
4024
4183
|
if (!e) return;
|
|
4025
|
-
const
|
|
4026
|
-
(
|
|
4184
|
+
const i = e.getSnapshot(), o = i.filter(
|
|
4185
|
+
(n) => n.properties.mode === "linestring" && n.geometry.type === "LineString"
|
|
4027
4186
|
);
|
|
4028
4187
|
if (o.length > 0)
|
|
4029
|
-
for (const
|
|
4030
|
-
this.
|
|
4188
|
+
for (const n of o)
|
|
4189
|
+
this.computeElevationByLineFeatureID(n.id);
|
|
4190
|
+
const s = i.filter(
|
|
4191
|
+
(n) => n.properties.mode === "point" && n.geometry.type === "Point"
|
|
4192
|
+
);
|
|
4193
|
+
if (s.length > 0)
|
|
4194
|
+
for (const n of s)
|
|
4195
|
+
this.computeElevationByPointFeatureID(n.id);
|
|
4031
4196
|
}
|
|
4032
4197
|
});
|
|
4033
4198
|
/**
|
|
4034
4199
|
* Handle finish event of terradraw. It will be called after finishing adding a feature
|
|
4035
4200
|
* @param id Feature ID
|
|
4036
4201
|
*/
|
|
4037
|
-
|
|
4038
|
-
this.map && this.
|
|
4202
|
+
_(this, "handleTerradrawFeatureReady", Ii((e) => {
|
|
4203
|
+
this.map && (this.computeElevationByLineFeatureID(e), this.computeElevationByPointFeatureID(e));
|
|
4039
4204
|
}, 300));
|
|
4040
4205
|
/**
|
|
4041
4206
|
* Compute elevation by a LineString feature ID
|
|
4042
4207
|
* @param id FeatureID
|
|
4043
4208
|
*/
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
return ((a = n.properties) == null ? void 0 : a.originalId) === e && n.geometry.type === "Point";
|
|
4209
|
+
_(this, "computeElevationByLineFeatureID", async (e) => {
|
|
4210
|
+
if (this.map && this.computeElevation === !0) {
|
|
4211
|
+
const i = this.map.getStyle().sources[this.measureOptions.lineLayerLabelSpec.source];
|
|
4212
|
+
if (i && typeof i.data != "string" && i.data.type === "FeatureCollection") {
|
|
4213
|
+
const o = i.data.features.filter(
|
|
4214
|
+
(s) => {
|
|
4215
|
+
var n;
|
|
4216
|
+
return ((n = s.properties) == null ? void 0 : n.originalId) === e && s.geometry.type === "Point";
|
|
4053
4217
|
}
|
|
4054
4218
|
);
|
|
4055
|
-
if (
|
|
4056
|
-
const
|
|
4057
|
-
|
|
4058
|
-
)
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4219
|
+
if (o && o.length > 0) {
|
|
4220
|
+
const s = await this.queryTerrainElevation(
|
|
4221
|
+
o
|
|
4222
|
+
);
|
|
4223
|
+
this.replaceGeoJSONSource(
|
|
4224
|
+
s,
|
|
4225
|
+
this.measureOptions.lineLayerLabelSpec.source,
|
|
4226
|
+
"linestring"
|
|
4227
|
+
);
|
|
4228
|
+
}
|
|
4229
|
+
}
|
|
4230
|
+
}
|
|
4231
|
+
});
|
|
4232
|
+
/**
|
|
4233
|
+
* Compute elevation by a Point feature ID
|
|
4234
|
+
* @param id FeatureID
|
|
4235
|
+
*/
|
|
4236
|
+
_(this, "computeElevationByPointFeatureID", async (e) => {
|
|
4237
|
+
if (this.map && this.computeElevation === !0) {
|
|
4238
|
+
const i = this.map.getStyle().sources[this.measureOptions.pointLayerLabelSpec.source];
|
|
4239
|
+
if (i && typeof i.data != "string" && i.data.type === "FeatureCollection") {
|
|
4240
|
+
const o = i.data.features.filter(
|
|
4241
|
+
(s) => {
|
|
4242
|
+
var n;
|
|
4243
|
+
return s.id === e && s.geometry.type === "Point" && ((n = s.properties) == null ? void 0 : n.mode) === "point";
|
|
4080
4244
|
}
|
|
4245
|
+
);
|
|
4246
|
+
if (o && o.length > 0) {
|
|
4247
|
+
const s = await this.queryTerrainElevation(
|
|
4248
|
+
o
|
|
4249
|
+
);
|
|
4250
|
+
this.replaceGeoJSONSource(
|
|
4251
|
+
s,
|
|
4252
|
+
this.measureOptions.pointLayerLabelSpec.source,
|
|
4253
|
+
"point"
|
|
4254
|
+
);
|
|
4081
4255
|
}
|
|
4082
4256
|
}
|
|
4083
4257
|
}
|
|
@@ -4087,10 +4261,10 @@ class Ji extends mi {
|
|
|
4087
4261
|
* @param feature GeoJSON feature
|
|
4088
4262
|
* @returns updated GeoJSON feature
|
|
4089
4263
|
*/
|
|
4090
|
-
|
|
4264
|
+
_(this, "updateFeatureProperties", (e) => {
|
|
4091
4265
|
if (!this.map || !this.map.loaded()) return e;
|
|
4092
4266
|
const i = e.geometry.type;
|
|
4093
|
-
return i === "LineString" ? e = this.calcDistance(e) : i === "Polygon" && (e = this.
|
|
4267
|
+
return i === "LineString" ? e = this.calcDistance(e) : i === "Polygon" ? e = this.calcArea(e) : i === "Point" && (e = this.queryElevationByPoint(e)), e;
|
|
4094
4268
|
});
|
|
4095
4269
|
this.measureOptions = i;
|
|
4096
4270
|
}
|
|
@@ -4136,6 +4310,17 @@ class Ji extends mi {
|
|
|
4136
4310
|
const i = this.measureOptions.areaPrecision === e;
|
|
4137
4311
|
this.measureOptions.areaPrecision = e, i || this.recalc();
|
|
4138
4312
|
}
|
|
4313
|
+
/**
|
|
4314
|
+
* The flag of whether computing elevation. Default is false.
|
|
4315
|
+
* Using setter to override the value if you want.
|
|
4316
|
+
*/
|
|
4317
|
+
get computeElevation() {
|
|
4318
|
+
return this.measureOptions.computeElevation ?? !1;
|
|
4319
|
+
}
|
|
4320
|
+
set computeElevation(e) {
|
|
4321
|
+
const i = this.measureOptions.computeElevation === e;
|
|
4322
|
+
this.measureOptions.computeElevation = e, i || this.recalc();
|
|
4323
|
+
}
|
|
4139
4324
|
/**
|
|
4140
4325
|
* add the plugin control to maplibre
|
|
4141
4326
|
* @param map Maplibre Map object
|
|
@@ -4177,18 +4362,50 @@ class Ji extends mi {
|
|
|
4177
4362
|
const i = e.getSnapshot();
|
|
4178
4363
|
for (const o of i) {
|
|
4179
4364
|
const s = o.id, n = o.geometry.type, a = o.properties.mode;
|
|
4180
|
-
a === "linestring" && n === "LineString" ? (this.measureLine(s), this.
|
|
4365
|
+
a === "linestring" && n === "LineString" ? (this.measureLine(s), this.computeElevationByLineFeatureID(s)) : a === "point" && n === "Point" ? (this.measurePoint(s), this.computeElevationByPointFeatureID(s)) : !["point", "linestring", "select", "render"].includes(a) && n === "Polygon" && this.measurePolygon(s);
|
|
4181
4366
|
}
|
|
4182
4367
|
}
|
|
4183
4368
|
}
|
|
4369
|
+
/**
|
|
4370
|
+
* clean maplibre style to filter only for terradraw related layers or without them.
|
|
4371
|
+
* If options are not set, returns original style given to the function.
|
|
4372
|
+
*
|
|
4373
|
+
* This can be useful incase users only want to get terradraw related layers or without it.
|
|
4374
|
+
*
|
|
4375
|
+
* Usage:
|
|
4376
|
+
* `cleanStyle(map.getStyle, { excludeTerraDrawLayers: true})`
|
|
4377
|
+
* `cleanStyle(map.getStyle, { onlyTerraDrawLayers: true})`
|
|
4378
|
+
*
|
|
4379
|
+
* @param style maplibre style spec
|
|
4380
|
+
* @param options.excludeTerraDrawLayers return maplibre style without terradraw layers and sources
|
|
4381
|
+
* @param options.onlyTerraDrawLayers return maplibre style with only terradraw layers and sources
|
|
4382
|
+
* @returns
|
|
4383
|
+
*/
|
|
4384
|
+
cleanStyle(e, i) {
|
|
4385
|
+
var l, d, c;
|
|
4386
|
+
const o = xt, s = (l = this.measureOptions.polygonLayerSpec) == null ? void 0 : l.source;
|
|
4387
|
+
s && o.push(s);
|
|
4388
|
+
const n = (d = this.measureOptions.lineLayerLabelSpec) == null ? void 0 : d.source;
|
|
4389
|
+
n && o.push(n);
|
|
4390
|
+
const a = (c = this.measureOptions.pointLayerLabelSpec) == null ? void 0 : c.source;
|
|
4391
|
+
return a && o.push(a), De(e, i, o);
|
|
4392
|
+
}
|
|
4184
4393
|
/**
|
|
4185
4394
|
* Register measure control related maplibre sources and layers
|
|
4186
4395
|
*/
|
|
4187
4396
|
registerMesureControl() {
|
|
4188
|
-
var
|
|
4397
|
+
var s, n, a;
|
|
4189
4398
|
if (!this.map) return;
|
|
4190
|
-
const e = (
|
|
4191
|
-
|
|
4399
|
+
const e = (s = this.options.modes) == null ? void 0 : s.filter((l) => ["linestring"].includes(l));
|
|
4400
|
+
((n = this.options.modes) == null ? void 0 : n.find((l) => l === "point")) && (this.map.getSource(
|
|
4401
|
+
this.measureOptions.pointLayerLabelSpec.source
|
|
4402
|
+
) || this.map.addSource(
|
|
4403
|
+
this.measureOptions.pointLayerLabelSpec.source,
|
|
4404
|
+
{
|
|
4405
|
+
type: "geojson",
|
|
4406
|
+
data: { type: "FeatureCollection", features: [] }
|
|
4407
|
+
}
|
|
4408
|
+
), this.map.getLayer(this.measureOptions.pointLayerLabelSpec.id) || this.map.addLayer(this.measureOptions.pointLayerLabelSpec)), e && e.length > 0 && (this.map.getSource(
|
|
4192
4409
|
this.measureOptions.lineLayerLabelSpec.source
|
|
4193
4410
|
) || this.map.addSource(
|
|
4194
4411
|
this.measureOptions.lineLayerLabelSpec.source,
|
|
@@ -4197,8 +4414,8 @@ class Ji extends mi {
|
|
|
4197
4414
|
data: { type: "FeatureCollection", features: [] }
|
|
4198
4415
|
}
|
|
4199
4416
|
), this.map.getLayer(this.measureOptions.lineLayerNodeSpec.id) || this.map.addLayer(this.measureOptions.lineLayerNodeSpec), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) || this.map.addLayer(this.measureOptions.lineLayerLabelSpec));
|
|
4200
|
-
const
|
|
4201
|
-
(
|
|
4417
|
+
const o = (a = this.options.modes) == null ? void 0 : a.filter(
|
|
4418
|
+
(l) => [
|
|
4202
4419
|
"polygon",
|
|
4203
4420
|
"rectangle",
|
|
4204
4421
|
"angled-rectangle",
|
|
@@ -4206,9 +4423,9 @@ class Ji extends mi {
|
|
|
4206
4423
|
"sector",
|
|
4207
4424
|
"sensor",
|
|
4208
4425
|
"freehand"
|
|
4209
|
-
].includes(
|
|
4426
|
+
].includes(l)
|
|
4210
4427
|
);
|
|
4211
|
-
if (
|
|
4428
|
+
if (o && o.length > 0 && (this.map.getSource(
|
|
4212
4429
|
this.measureOptions.polygonLayerSpec.source
|
|
4213
4430
|
) || this.map.addSource(
|
|
4214
4431
|
this.measureOptions.polygonLayerSpec.source,
|
|
@@ -4216,9 +4433,9 @@ class Ji extends mi {
|
|
|
4216
4433
|
type: "geojson",
|
|
4217
4434
|
data: { type: "FeatureCollection", features: [] }
|
|
4218
4435
|
}
|
|
4219
|
-
), this.map.getLayer(this.measureOptions.polygonLayerSpec.id) || this.map.addLayer(this.measureOptions.polygonLayerSpec)), e && e.length > 0 ||
|
|
4220
|
-
const
|
|
4221
|
-
|
|
4436
|
+
), this.map.getLayer(this.measureOptions.polygonLayerSpec.id) || this.map.addLayer(this.measureOptions.polygonLayerSpec)), e && e.length > 0 || o && o.length > 0) {
|
|
4437
|
+
const l = this.getTerraDrawInstance();
|
|
4438
|
+
l && (l.on("change", this.handleTerradrawFeatureChanged.bind(this)), l.on("finish", this.handleTerradrawFeatureReady.bind(this)), l.on("deselect", this.handleTerradrawDeselect.bind(this)), this.on("feature-deleted", this.onFeatureDeleted.bind(this)));
|
|
4222
4439
|
}
|
|
4223
4440
|
}
|
|
4224
4441
|
/**
|
|
@@ -4233,8 +4450,8 @@ class Ji extends mi {
|
|
|
4233
4450
|
for (const s of e) {
|
|
4234
4451
|
const n = o.find((a) => a.id === s);
|
|
4235
4452
|
if (n) {
|
|
4236
|
-
const a = n.geometry.type,
|
|
4237
|
-
|
|
4453
|
+
const a = n.geometry.type, l = n.properties.mode;
|
|
4454
|
+
l === "linestring" && a === "LineString" ? this.measureLine(s) : l === "point" && a === "Point" ? this.measurePoint(s) : !["point", "linestring", "select", "render"].includes(l) && a === "Polygon" && this.measurePolygon(s);
|
|
4238
4455
|
} else
|
|
4239
4456
|
this.clearMeasureFeatures(
|
|
4240
4457
|
s,
|
|
@@ -4245,6 +4462,9 @@ class Ji extends mi {
|
|
|
4245
4462
|
), this.clearMeasureFeatures(
|
|
4246
4463
|
s,
|
|
4247
4464
|
this.measureOptions.polygonLayerSpec.source
|
|
4465
|
+
), this.clearMeasureFeatures(
|
|
4466
|
+
s,
|
|
4467
|
+
this.measureOptions.pointLayerLabelSpec.source
|
|
4248
4468
|
);
|
|
4249
4469
|
}
|
|
4250
4470
|
}
|
|
@@ -4252,7 +4472,13 @@ class Ji extends mi {
|
|
|
4252
4472
|
* Unregister measure control related maplibre sources and layers
|
|
4253
4473
|
*/
|
|
4254
4474
|
unregisterMesureControl() {
|
|
4255
|
-
this.off("feature-deleted", this.onFeatureDeleted.bind(this)), this.map && (this.map.getLayer(this.measureOptions.
|
|
4475
|
+
this.off("feature-deleted", this.onFeatureDeleted.bind(this)), this.map && (this.map.getLayer(this.measureOptions.pointLayerLabelSpec.id) && this.map.removeLayer(
|
|
4476
|
+
this.measureOptions.pointLayerLabelSpec.id
|
|
4477
|
+
), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && this.map.removeLayer(this.measureOptions.lineLayerLabelSpec.id), this.map.getLayer(this.measureOptions.lineLayerNodeSpec.id) && this.map.removeLayer(this.measureOptions.lineLayerNodeSpec.id), this.map.getLayer(this.measureOptions.polygonLayerSpec.id) && this.map.removeLayer(this.measureOptions.polygonLayerSpec.id), this.map.getSource(
|
|
4478
|
+
this.measureOptions.pointLayerLabelSpec.source
|
|
4479
|
+
) && this.map.removeSource(
|
|
4480
|
+
this.measureOptions.pointLayerLabelSpec.source
|
|
4481
|
+
), this.map.getSource(
|
|
4256
4482
|
this.measureOptions.lineLayerLabelSpec.source
|
|
4257
4483
|
) && this.map.removeSource(
|
|
4258
4484
|
this.measureOptions.lineLayerLabelSpec.source
|
|
@@ -4284,7 +4510,7 @@ class Ji extends mi {
|
|
|
4284
4510
|
*/
|
|
4285
4511
|
calcArea(e) {
|
|
4286
4512
|
if (e.geometry.type !== "Polygon") return e;
|
|
4287
|
-
const i =
|
|
4513
|
+
const i = _i(e.geometry);
|
|
4288
4514
|
let o = i, s = "m²";
|
|
4289
4515
|
return this.areaUnit === "metric" ? i >= 1e6 ? (o = i / 1e6, s = "km²") : i >= 1e4 && (o = i / 1e4, s = "ha") : i >= 258998811e-2 ? (o = i / 258998811e-2, s = "mi²") : i >= 4046.856 ? (o = i / 4046.856, s = "acre") : i >= 0.83612736 && (o = i / 0.83612736, s = "yd²"), o = parseFloat(o.toFixed(this.areaPrecision)), e.properties.area = o, e.properties.unit = s, e;
|
|
4290
4516
|
}
|
|
@@ -4296,6 +4522,42 @@ class Ji extends mi {
|
|
|
4296
4522
|
getDistanceUnitName(e) {
|
|
4297
4523
|
return e === "degrees" ? "°" : e === "miles" ? "mi" : e === "radians" ? "rad" : "km";
|
|
4298
4524
|
}
|
|
4525
|
+
/**
|
|
4526
|
+
* Replace GeoJSON source with updated features for a given source ID
|
|
4527
|
+
* @param updatedFeatures Updated GeoJSON features
|
|
4528
|
+
* @param sourceId Source ID to update
|
|
4529
|
+
* @param type either 'linestring' or 'point'
|
|
4530
|
+
*/
|
|
4531
|
+
replaceGeoJSONSource(e, i, o) {
|
|
4532
|
+
var n;
|
|
4533
|
+
if (!this.map) return;
|
|
4534
|
+
const s = this.map.getStyle().sources[i];
|
|
4535
|
+
if (s && typeof s.data != "string" && s.data.type === "FeatureCollection") {
|
|
4536
|
+
const a = e.map((l) => l.id);
|
|
4537
|
+
if (typeof s.data != "string" && s.data.type === "FeatureCollection") {
|
|
4538
|
+
o === "linestring" ? s.data.features = [
|
|
4539
|
+
...s.data.features = s.data.features.filter(
|
|
4540
|
+
(d) => {
|
|
4541
|
+
var c;
|
|
4542
|
+
return !(a.includes((c = d.properties) == null ? void 0 : c.originalId) && d.geometry.type === "Point");
|
|
4543
|
+
}
|
|
4544
|
+
),
|
|
4545
|
+
...e
|
|
4546
|
+
] : o === "point" && (s.data.features = [
|
|
4547
|
+
...s.data.features = s.data.features.filter(
|
|
4548
|
+
(d) => !(a.includes(d.id) && d.geometry.type === "Point")
|
|
4549
|
+
),
|
|
4550
|
+
...e
|
|
4551
|
+
]);
|
|
4552
|
+
const l = {};
|
|
4553
|
+
s.data.features.forEach((d) => {
|
|
4554
|
+
var h;
|
|
4555
|
+
const c = d.id;
|
|
4556
|
+
l[c] ? !l[c].properties.elevation && ((h = d.properties) != null && h.elevation) && (l[c] = d) : l[c] = d;
|
|
4557
|
+
}), s.data.features = Array.from(Object.values(l)), (n = this.map.getSource(i)) == null || n.setData(s.data);
|
|
4558
|
+
}
|
|
4559
|
+
}
|
|
4560
|
+
}
|
|
4299
4561
|
/**
|
|
4300
4562
|
* Query terrain elvation for point features
|
|
4301
4563
|
* @param point Point GeoJSON features
|
|
@@ -4310,8 +4572,8 @@ class Ji extends mi {
|
|
|
4310
4572
|
o.geometry.type !== "Point" && s(o);
|
|
4311
4573
|
const n = this.measureOptions.terrainSource;
|
|
4312
4574
|
if (n) {
|
|
4313
|
-
const a = n.url,
|
|
4314
|
-
(
|
|
4575
|
+
const a = n.url, l = n.encoding ?? "mapbox", d = n.tileSize ?? 512, c = n.minzoom ?? 5, h = n.maxzoom ?? 15, u = n.tms ?? !1;
|
|
4576
|
+
(l === "mapbox" ? new Hi(a, d, c, h, u) : new qi(a, d, c, h, u)).getElevation(o.geometry.coordinates, h).then((p) => {
|
|
4315
4577
|
p && (o.properties.elevation = p), s(o);
|
|
4316
4578
|
}).catch(() => s(o));
|
|
4317
4579
|
} else
|
|
@@ -4320,6 +4582,16 @@ class Ji extends mi {
|
|
|
4320
4582
|
);
|
|
4321
4583
|
return await Promise.all(i);
|
|
4322
4584
|
}
|
|
4585
|
+
queryElevationByPoint(e) {
|
|
4586
|
+
var o;
|
|
4587
|
+
if (e.geometry.type !== "Point") return e;
|
|
4588
|
+
const i = e.geometry.coordinates;
|
|
4589
|
+
if (this.computeElevation === !0 && this.measureOptions.terrainSource === void 0) {
|
|
4590
|
+
const s = (o = this.map) == null ? void 0 : o.queryTerrainElevation(i);
|
|
4591
|
+
s && (e.properties.elevation = s);
|
|
4592
|
+
}
|
|
4593
|
+
return e;
|
|
4594
|
+
}
|
|
4323
4595
|
/**
|
|
4324
4596
|
* Caclulate distance for each segment on a given feature
|
|
4325
4597
|
* @param feature LineString GeoJSON feature
|
|
@@ -4331,12 +4603,12 @@ class Ji extends mi {
|
|
|
4331
4603
|
const i = e.geometry.coordinates;
|
|
4332
4604
|
let o = 0;
|
|
4333
4605
|
const s = [];
|
|
4334
|
-
for (let
|
|
4335
|
-
const
|
|
4606
|
+
for (let l = 0; l < i.length - 1; l++) {
|
|
4607
|
+
const d = i[l], c = i[l + 1], h = Oi(d, c, { units: this.distanceUnit });
|
|
4336
4608
|
o += h;
|
|
4337
4609
|
const u = JSON.parse(JSON.stringify(e));
|
|
4338
|
-
if (u.id = `${u.id}-${
|
|
4339
|
-
const p = (n = this.map) == null ? void 0 : n.queryTerrainElevation(
|
|
4610
|
+
if (u.id = `${u.id}-${l}`, u.geometry.coordinates = [d, c], u.properties.originalId = e.id, u.properties.distance = parseFloat(h.toFixed(this.distancePrecision)), u.properties.total = parseFloat(o.toFixed(this.distancePrecision)), u.properties.unit = this.getDistanceUnitName(this.distanceUnit), this.computeElevation === !0 && this.measureOptions.terrainSource === void 0) {
|
|
4611
|
+
const p = (n = this.map) == null ? void 0 : n.queryTerrainElevation(d);
|
|
4340
4612
|
p && (u.properties.elevation_start = p);
|
|
4341
4613
|
const g = (a = this.map) == null ? void 0 : a.queryTerrainElevation(c);
|
|
4342
4614
|
g && (u.properties.elevation_end = g);
|
|
@@ -4360,18 +4632,22 @@ class Ji extends mi {
|
|
|
4360
4632
|
const a = this.map.getStyle().sources[this.measureOptions.polygonLayerSpec.source];
|
|
4361
4633
|
if (a) {
|
|
4362
4634
|
typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
|
|
4363
|
-
(
|
|
4635
|
+
(d) => {
|
|
4364
4636
|
var c;
|
|
4365
|
-
return ((c =
|
|
4637
|
+
return ((c = d.properties) == null ? void 0 : c.originalId) !== e;
|
|
4366
4638
|
}
|
|
4367
4639
|
));
|
|
4368
|
-
const
|
|
4369
|
-
|
|
4640
|
+
const l = JSON.parse(JSON.stringify(s));
|
|
4641
|
+
l.id = l.id + "-area-label", l.geometry = Bi(s.geometry).geometry, l.properties.originalId = s.id, s = this.calcArea(s), l.properties.area = s.properties.area, l.properties.unit = s.properties.unit, typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(l), (n = this.map.getSource(
|
|
4370
4642
|
this.measureOptions.polygonLayerSpec.source
|
|
4371
4643
|
)) == null || n.setData(a.data), this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && this.map.moveLayer(
|
|
4372
4644
|
this.measureOptions.lineLayerLabelSpec.id
|
|
4373
4645
|
), this.map.getLayer(this.measureOptions.lineLayerNodeSpec.id) && this.map.moveLayer(
|
|
4374
4646
|
this.measureOptions.lineLayerNodeSpec.id
|
|
4647
|
+
), this.map.getLayer(
|
|
4648
|
+
this.measureOptions.pointLayerLabelSpec.id
|
|
4649
|
+
) && this.map.moveLayer(
|
|
4650
|
+
this.measureOptions.pointLayerLabelSpec.id
|
|
4375
4651
|
);
|
|
4376
4652
|
}
|
|
4377
4653
|
}
|
|
@@ -4391,77 +4667,95 @@ class Ji extends mi {
|
|
|
4391
4667
|
const a = this.map.getStyle().sources[this.measureOptions.lineLayerLabelSpec.source];
|
|
4392
4668
|
if (a) {
|
|
4393
4669
|
typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
|
|
4394
|
-
(
|
|
4670
|
+
(d) => {
|
|
4395
4671
|
var c;
|
|
4396
|
-
return ((c =
|
|
4672
|
+
return ((c = d.properties) == null ? void 0 : c.originalId) !== e;
|
|
4397
4673
|
}
|
|
4398
4674
|
)), s = this.calcDistance(s);
|
|
4399
|
-
const
|
|
4400
|
-
for (let
|
|
4401
|
-
const c = d
|
|
4675
|
+
const l = s.properties.segments;
|
|
4676
|
+
for (let d = 0; d < l.length; d++) {
|
|
4677
|
+
const c = l[d];
|
|
4402
4678
|
typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(c);
|
|
4403
4679
|
const h = c.geometry.coordinates, u = h[0], p = h[1];
|
|
4404
|
-
if (
|
|
4680
|
+
if (d === 0) {
|
|
4405
4681
|
const y = JSON.parse(JSON.stringify(c));
|
|
4406
|
-
y.id = `${c.id}-node-${
|
|
4682
|
+
y.id = `${c.id}-node-${d}`, y.geometry = {
|
|
4407
4683
|
type: "Point",
|
|
4408
4684
|
coordinates: u
|
|
4409
4685
|
}, y.properties.distance = 0, y.properties.total = 0, c.properties.elevation_start && (y.properties.elevation = c.properties.elevation_start), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(y);
|
|
4410
4686
|
}
|
|
4411
4687
|
const g = JSON.parse(JSON.stringify(c));
|
|
4412
|
-
g.id = `${c.id}-node-${
|
|
4688
|
+
g.id = `${c.id}-node-${d + 1}`, g.geometry = {
|
|
4413
4689
|
type: "Point",
|
|
4414
4690
|
coordinates: p
|
|
4415
4691
|
}, c.properties.elevation_end && (g.properties.elevation = c.properties.elevation_end), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(g);
|
|
4416
4692
|
}
|
|
4417
4693
|
(n = this.map.getSource(
|
|
4418
4694
|
this.measureOptions.lineLayerLabelSpec.source
|
|
4419
|
-
)) == null || n.setData(a.data), this.map.getLayer(this.measureOptions.polygonLayerSpec.id) && this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.moveLayer(this.measureOptions.lineLayerLabelSpec.id), this.map.moveLayer(this.measureOptions.lineLayerNodeSpec.id)
|
|
4695
|
+
)) == null || n.setData(a.data), this.map.getLayer(this.measureOptions.polygonLayerSpec.id) && this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.moveLayer(this.measureOptions.lineLayerLabelSpec.id), this.map.moveLayer(this.measureOptions.lineLayerNodeSpec.id), this.map.getLayer(
|
|
4696
|
+
this.measureOptions.pointLayerLabelSpec.id
|
|
4697
|
+
) && this.map.moveLayer(
|
|
4698
|
+
this.measureOptions.pointLayerLabelSpec.id
|
|
4699
|
+
);
|
|
4420
4700
|
}
|
|
4421
4701
|
}
|
|
4422
4702
|
}
|
|
4703
|
+
/**
|
|
4704
|
+
* measure point elevation for given feature ID
|
|
4705
|
+
* @param id terradraw feature id
|
|
4706
|
+
*/
|
|
4707
|
+
measurePoint(e) {
|
|
4708
|
+
var n;
|
|
4709
|
+
if (!this.map) return;
|
|
4710
|
+
const i = this.getTerraDrawInstance();
|
|
4711
|
+
if (!i) return;
|
|
4712
|
+
const o = i.getSnapshot();
|
|
4713
|
+
let s = o == null ? void 0 : o.find((a) => a.id === e && a.geometry.type === "Point");
|
|
4714
|
+
if (s) {
|
|
4715
|
+
const a = this.map.getStyle().sources[this.measureOptions.pointLayerLabelSpec.source];
|
|
4716
|
+
a && (typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
|
|
4717
|
+
(l) => {
|
|
4718
|
+
var d;
|
|
4719
|
+
return ((d = l.properties) == null ? void 0 : d.originalId) !== e;
|
|
4720
|
+
}
|
|
4721
|
+
)), s = this.queryElevationByPoint(s), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(s), (n = this.map.getSource(
|
|
4722
|
+
this.measureOptions.pointLayerLabelSpec.source
|
|
4723
|
+
)) == null || n.setData(a.data), this.map.getLayer(this.measureOptions.polygonLayerSpec.id) && this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && (this.map.moveLayer(
|
|
4724
|
+
this.measureOptions.lineLayerLabelSpec.id
|
|
4725
|
+
), this.map.moveLayer(
|
|
4726
|
+
this.measureOptions.lineLayerNodeSpec.id
|
|
4727
|
+
)), this.map.moveLayer(
|
|
4728
|
+
this.measureOptions.pointLayerLabelSpec.id
|
|
4729
|
+
));
|
|
4730
|
+
}
|
|
4731
|
+
}
|
|
4423
4732
|
/**
|
|
4424
4733
|
* Event definition when feature is deleted by terradraw
|
|
4425
4734
|
*/
|
|
4426
|
-
onFeatureDeleted() {
|
|
4427
|
-
var
|
|
4735
|
+
onFeatureDeleted(e) {
|
|
4736
|
+
var o, s;
|
|
4428
4737
|
if (!this.map) return;
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
this.measureOptions.
|
|
4738
|
+
if (this.getTerraDrawInstance()) {
|
|
4739
|
+
let n = [];
|
|
4740
|
+
typeof e == "object" && e !== null && "deletedIds" in e && (n = e.deletedIds);
|
|
4741
|
+
const a = [
|
|
4742
|
+
this.measureOptions.pointLayerLabelSpec,
|
|
4743
|
+
this.measureOptions.lineLayerLabelSpec,
|
|
4744
|
+
this.measureOptions.polygonLayerSpec
|
|
4434
4745
|
];
|
|
4435
|
-
|
|
4436
|
-
const
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
this.measureOptions.lineLayerLabelSpec.source
|
|
4448
|
-
)) == null || i.setData(a.data), this.map.getLayer(
|
|
4449
|
-
this.measureOptions.lineLayerNodeSpec.id
|
|
4450
|
-
) && this.map.moveLayer(
|
|
4451
|
-
this.measureOptions.lineLayerNodeSpec.id
|
|
4452
|
-
), this.map.getLayer(
|
|
4453
|
-
this.measureOptions.lineLayerLabelSpec.id
|
|
4454
|
-
) && this.map.moveLayer(
|
|
4455
|
-
this.measureOptions.lineLayerLabelSpec.id
|
|
4456
|
-
)) : n === this.measureOptions.polygonLayerSpec.source && ((o = this.map.getSource(
|
|
4457
|
-
this.measureOptions.polygonLayerSpec.source
|
|
4458
|
-
)) == null || o.setData(a.data), this.map.getLayer(
|
|
4459
|
-
this.measureOptions.polygonLayerSpec.id
|
|
4460
|
-
) && this.map.moveLayer(
|
|
4461
|
-
this.measureOptions.polygonLayerSpec.id
|
|
4462
|
-
));
|
|
4746
|
+
if (n && n.length > 0)
|
|
4747
|
+
for (const l of a) {
|
|
4748
|
+
const d = this.map.getStyle().sources[l.source];
|
|
4749
|
+
d && (typeof d.data != "string" && d.data.type === "FeatureCollection" && (d.data.features = d.data.features.filter((c) => {
|
|
4750
|
+
var h;
|
|
4751
|
+
return (h = c.properties) != null && h.originalId ? !n.includes(c.properties.originalId) : !n.includes(c.id);
|
|
4752
|
+
})), (o = this.map.getSource(l.source)) == null || o.setData(d.data));
|
|
4753
|
+
}
|
|
4754
|
+
else
|
|
4755
|
+
for (const l of a) {
|
|
4756
|
+
const d = this.map.getStyle().sources[l.source];
|
|
4757
|
+
d && (typeof d.data != "string" && d.data.type === "FeatureCollection" && (d.data.features = []), (s = this.map.getSource(l.source)) == null || s.setData(d.data));
|
|
4463
4758
|
}
|
|
4464
|
-
}
|
|
4465
4759
|
}
|
|
4466
4760
|
}
|
|
4467
4761
|
/**
|
|
@@ -4478,12 +4772,16 @@ class Ji extends mi {
|
|
|
4478
4772
|
}
|
|
4479
4773
|
}
|
|
4480
4774
|
export {
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4775
|
+
io as AvailableModes,
|
|
4776
|
+
so as MaplibreMeasureControl,
|
|
4777
|
+
bi as MaplibreTerradrawControl,
|
|
4778
|
+
oo as TERRADRAW_MEASURE_SOURCE_IDS,
|
|
4779
|
+
xt as TERRADRAW_SOURCE_IDS,
|
|
4780
|
+
te as capitalize,
|
|
4781
|
+
De as cleanMaplibreStyle,
|
|
4782
|
+
Ii as debounce,
|
|
4783
|
+
Si as defaultControlOptions,
|
|
4784
|
+
ut as defaultMeasureControlOptions,
|
|
4785
|
+
xi as getDefaultModeOptions
|
|
4488
4786
|
};
|
|
4489
4787
|
//# sourceMappingURL=maplibre-gl-terradraw.es.js.map
|