@wemap/geo 14.6.0-beta.2 → 14.6.0-beta.4

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/index.js CHANGED
@@ -1,11 +1,12 @@
1
+ import { Quaternion, Rotations, Vector3, deg2rad, positiveMod, rad2deg, wrap } from "@wemap/maths";
1
2
  import booleanPointInPolygon from "@turf/boolean-point-in-polygon";
2
- var __defProp$1 = Object.defineProperty, __export = (e) => {
3
- let T = {};
4
- for (var E in e) __defProp$1(T, E, {
5
- get: e[E],
3
+ var __defProp = Object.defineProperty, __export = (e) => {
4
+ let y = {};
5
+ for (var b in e) __defProp(y, b, {
6
+ get: e[b],
6
7
  enumerable: !0
7
8
  });
8
- return T;
9
+ return y;
9
10
  }, Constants_exports = /* @__PURE__ */ __export({
10
11
  CIRCUMFERENCE: () => CIRCUMFERENCE,
11
12
  EARTH_GRAVITY: () => EARTH_GRAVITY,
@@ -22,428 +23,95 @@ var __defProp$1 = Object.defineProperty, __export = (e) => {
22
23
  R_MINOR_4: () => R_MINOR_4
23
24
  });
24
25
  const R_MAJOR = 6378137, R_MINOR = 6356752.3142, EARTH_GRAVITY = 9.80665, EPS_DEG_MM = 1e-8, EPS_MM = .001, ELLIPSOID_FLATNESS = (R_MAJOR - R_MINOR) / R_MAJOR, ECCENTRICITY = Math.sqrt(ELLIPSOID_FLATNESS * (2 - ELLIPSOID_FLATNESS)), ECCENTRICITY_2 = ECCENTRICITY * ECCENTRICITY, R_MAJOR_2 = R_MAJOR * R_MAJOR, R_MAJOR_4 = R_MAJOR_2 * R_MAJOR_2, R_MINOR_2 = R_MINOR * R_MINOR, R_MINOR_4 = R_MINOR_2 * R_MINOR_2, CIRCUMFERENCE = R_MAJOR * 2 * Math.PI;
25
- var __defProp = Object.defineProperty, __defNormalProp = (e, w, T) => w in e ? __defProp(e, w, {
26
- enumerable: !0,
27
- configurable: !0,
28
- writable: !0,
29
- value: T
30
- }) : e[w] = T, __publicField = (e, w, T) => (__defNormalProp(e, typeof w == "symbol" ? w : w + "", T), T), Vector = class {
31
- static concat(e, w) {
32
- return e.concat(w);
33
- }
34
- }, Vector3 = class e extends Vector {
35
- static norm(e) {
36
- return Math.sqrt(e[0] * e[0] + e[1] * e[1] + e[2] * e[2]);
37
- }
38
- static normalize(e) {
39
- let w = this.norm(e), T = [
40
- ,
41
- ,
42
- ,
43
- ];
44
- for (let E = 0; E < 3; E++) T[E] = e[E] / w;
45
- return T;
46
- }
47
- static sum(e, w) {
48
- return [
49
- e[0] + w[0],
50
- e[1] + w[1],
51
- e[2] + w[2]
52
- ];
53
- }
54
- static subtract(e, w) {
55
- return [
56
- e[0] - w[0],
57
- e[1] - w[1],
58
- e[2] - w[2]
59
- ];
60
- }
61
- static distance(w, T) {
62
- return e.norm(e.subtract(w, T));
63
- }
64
- static cross(e, w) {
65
- return [
66
- e[1] * w[2] - e[2] * w[1],
67
- e[2] * w[0] - e[0] * w[2],
68
- e[0] * w[1] - e[1] * w[0]
69
- ];
70
- }
71
- static dot(e, w) {
72
- return e[0] * w[0] + e[1] * w[1] + e[2] * w[2];
73
- }
74
- static multiplyScalar(e, w) {
75
- let T = [
76
- ,
77
- ,
78
- ,
79
- ];
80
- for (let E = 0; E < 3; E++) T[E] = e[E] * w;
81
- return T;
82
- }
83
- }, _Quaternion = class e {
84
- static get identity() {
85
- return [
86
- 1,
87
- 0,
88
- 0,
89
- 0
90
- ];
91
- }
92
- static sum(e, w) {
93
- return [
94
- e[0] + w[0],
95
- e[1] + w[1],
96
- e[2] + w[2],
97
- e[3] + w[3]
98
- ];
99
- }
100
- static rotateMatlab(e, w) {
101
- let [T, E, D, O] = e, [k, A, j] = w;
102
- return [
103
- T * (T * k - D * j + O * A) - D * (T * j - E * A + D * k) + E * (E * k + D * A + O * j) + O * (T * A + E * j - O * k),
104
- T * (T * A + E * j - O * k) + E * (T * j - E * A + D * k) + D * (E * k + D * A + O * j) - O * (T * k - D * j + O * A),
105
- T * (T * j - E * A + D * k) - E * (T * A + E * j - O * k) + D * (T * k - D * j + O * A) + O * (E * k + D * A + O * j)
106
- ];
107
- }
108
- static rotate(e, w) {
109
- let [T, E, D, O] = e, k = [
110
- E,
111
- D,
112
- O
113
- ], A = Vector3.cross(k, w);
114
- A = Vector3.sum(A, A);
115
- let j = Vector3.sum(w, Vector3.multiplyScalar(A, T));
116
- return Vector3.sum(j, Vector3.cross(k, A));
117
- }
118
- static inverse(e) {
119
- return [
120
- -e[0],
121
- e[1],
122
- e[2],
123
- e[3]
124
- ];
125
- }
126
- static multiply(...w) {
127
- if (w.length === 2) {
128
- let [e, T, E, D] = w[0], [O, k, A, j] = w[1];
129
- return [
130
- e * O - T * k - E * A - D * j,
131
- e * k + O * T + E * j - D * A,
132
- e * A + O * E + D * k - T * j,
133
- e * j + O * D + T * A - E * k
134
- ];
135
- }
136
- return w.reduce((e, w) => this.multiply(e, w), e.identity);
137
- }
138
- static fromAxisAngle(e, w) {
139
- let T = Math.sin(w / 2);
140
- return [
141
- Math.cos(w / 2),
142
- e[0] * T,
143
- e[1] * T,
144
- e[2] * T
145
- ];
146
- }
147
- static rotX(e) {
148
- return this.fromAxisAngle([
149
- 1,
150
- 0,
151
- 0
152
- ], e);
153
- }
154
- static rotY(e) {
155
- return this.fromAxisAngle([
156
- 0,
157
- 1,
158
- 0
159
- ], e);
160
- }
161
- static rotZ(e) {
162
- return this.fromAxisAngle([
163
- 0,
164
- 0,
165
- 1
166
- ], e);
167
- }
168
- static fromMatrix3(e) {
169
- let w = Math.sqrt(1 + e[0][0] + e[1][1] + e[2][2]) / 2;
170
- return [
171
- w,
172
- (e[2][1] - e[1][2]) / (4 * w),
173
- (e[0][2] - e[2][0]) / (4 * w),
174
- (e[1][0] - e[0][1]) / (4 * w)
175
- ];
176
- }
177
- static fromMatrix3Matlab(e) {
178
- let w = Math.sqrt(1 + e[0][0] + e[1][1] + e[2][2]) / 2;
179
- return [
180
- w,
181
- (e[1][2] - e[2][1]) / (4 * w),
182
- (e[2][0] - e[0][2]) / (4 * w),
183
- (e[0][1] - e[1][0]) / (4 * w)
184
- ];
185
- }
186
- static toMatrix3(e) {
187
- let [w, T, E, D] = e, O = w * T, k = w * E, A = w * D, j = T * T, M = T * E, N = T * D, P = E * E, F = E * D, I = D * D;
188
- return [
189
- [
190
- 1 - 2 * (P + I),
191
- 2 * (M - A),
192
- 2 * (N + k)
193
- ],
194
- [
195
- 2 * (M + A),
196
- 1 - 2 * (j + I),
197
- 2 * (F - O)
198
- ],
199
- [
200
- 2 * (N - k),
201
- 2 * (F + O),
202
- 1 - 2 * (j + P)
203
- ]
204
- ];
205
- }
206
- static wxyz2xyzw(e) {
207
- return [
208
- e[1],
209
- e[2],
210
- e[3],
211
- e[0]
212
- ];
213
- }
214
- static xyzw2wxyz(e) {
215
- return [
216
- e[3],
217
- e[0],
218
- e[1],
219
- e[2]
220
- ];
221
- }
222
- static distance(w, T) {
223
- return Math.acos(Math.min(2 * e.dot(w, T) ** 2 - 1, 1));
224
- }
225
- static equals(w, T) {
226
- return e.distance(w, T) < 1e-8;
227
- }
228
- static normalize(e) {
229
- let w = this.norm(e), T = [
230
- ,
231
- ,
232
- ,
233
- ,
234
- ];
235
- for (let E = 0; E < 4; E++) T[E] = e[E] / w;
236
- return T;
237
- }
238
- static norm(e) {
239
- return Math.sqrt(e[0] ** 2 + e[1] ** 2 + e[2] ** 2 + e[3] ** 2);
240
- }
241
- static dot(e, w) {
242
- return e[0] * w[0] + e[1] * w[1] + e[2] * w[2] + e[3] * w[3];
243
- }
244
- static getRotationBetweenTwoVectors(w, T) {
245
- let E = Vector3.normalize(w), D = Vector3.normalize(T), O = Vector3.dot(E, D), k;
246
- if (O < -.999999) return k = Vector3.cross([
247
- 1,
248
- 0,
249
- 0
250
- ], E), Vector3.norm(k) < 1e-6 && (k = Vector3.cross([
251
- 0,
252
- 1,
253
- 0
254
- ], E)), k = Vector3.normalize(k), e.fromAxisAngle(k, Math.PI);
255
- if (O > .999999) return e.identity;
256
- k = Vector3.cross(E, D);
257
- let A = [
258
- 1 + O,
259
- k[0],
260
- k[1],
261
- k[2]
262
- ];
263
- return e.normalize(A);
264
- }
265
- static slerp(w, T, E) {
266
- let D = w[1], O = w[2], k = w[3], A = w[0], j = T[1], M = T[2], N = T[3], P = T[0], F, I, L;
267
- F = D * j + O * M + k * N + A * P, F < 0 && (F = -F, P = -P, j = -j, M = -M, N = -N);
268
- let R = 1 - F < 1e-6;
269
- if (R) I = 1 - E, L = E;
270
- else {
271
- let e = Math.acos(F), w = Math.sin(e);
272
- I = Math.sin((1 - E) * e) / w, L = Math.sin(E * e) / w;
273
- }
274
- let z = [
275
- I * A + L * P,
276
- I * D + L * j,
277
- I * O + L * M,
278
- I * k + L * N
279
- ];
280
- return R && (z = e.normalize(z)), z;
281
- }
282
- static toString(e) {
283
- return `[${e[0].toFixed(2)}, ${e[1].toFixed(2)}, ${e[2].toFixed(2)}, ${e[3].toFixed(2)}]`;
284
- }
285
- static fromUnitVectors(w, T) {
286
- let E = Vector3.dot(w, T) + 1, D, O, k, A;
287
- E < 2 ** -52 ? (E = 0, Math.abs(w[1]) > Math.abs(w[2]) ? (D = -w[1], O = w[0], k = 0, A = E) : (D = 0, O = -w[2], k = w[1], A = E)) : (D = w[1] * T[2] - w[2] * T[1], O = w[2] * T[0] - w[0] * T[2], k = w[0] * T[1] - w[1] * T[0], A = E);
288
- let j = [
289
- A,
290
- D,
291
- O,
292
- k
293
- ];
294
- return e.normalize(j);
295
- }
296
- };
297
- __publicField(_Quaternion, "ROTX_PI2", _Quaternion.rotX(Math.PI / 2)), __publicField(_Quaternion, "ROTX_PI", _Quaternion.rotX(Math.PI)), __publicField(_Quaternion, "ROTX_MPI2", _Quaternion.rotX(-Math.PI / 2)), __publicField(_Quaternion, "ROTY_PI2", _Quaternion.rotY(Math.PI / 2)), __publicField(_Quaternion, "ROTY_PI", _Quaternion.rotY(Math.PI)), __publicField(_Quaternion, "ROTY_MPI2", _Quaternion.rotY(-Math.PI / 2)), __publicField(_Quaternion, "ROTZ_PI2", _Quaternion.rotZ(Math.PI / 2)), __publicField(_Quaternion, "ROTZ_PI", _Quaternion.rotZ(Math.PI)), __publicField(_Quaternion, "ROTZ_MPI2", _Quaternion.rotZ(-Math.PI / 2));
298
- var Quaternion = _Quaternion;
299
- function deg2rad(e) {
300
- return e * (Math.PI / 180);
301
- }
302
- function rad2deg(e) {
303
- return e * 180 / Math.PI;
304
- }
305
- function positiveMod(e, w) {
306
- return (e % w + w) % w;
307
- }
308
- function wrap(e, w, T) {
309
- let E = T - w, D = ((e - w) % E + E) % E + w;
310
- return D === w ? T : D;
311
- }
312
- var Rotations = class e {
313
- static eulerToQuaternionZXYDegrees(w) {
314
- let T = w.map((e) => deg2rad(e));
315
- return e.eulerToQuaternionZXY(T);
316
- }
317
- static eulerToQuaternionZXY(e) {
318
- let w = e[0], T = e[1], E = e[2], D = Math.cos(w / 2), O = Math.cos(T / 2), k = Math.cos(E / 2), A = Math.sin(w / 2), j = Math.sin(T / 2), M = Math.sin(E / 2), N = D * O * k - A * j * M, P = D * j * k - A * O * M, F = A * j * k + D * O * M, I = A * O * k + D * j * M;
319
- return N < 0 && (N = -N, P = -P, F = -F, I = -I), [
320
- N,
321
- P,
322
- F,
323
- I
324
- ];
325
- }
326
- static quaternionToEulerZXYDegrees(w) {
327
- return e.quaternionToEulerZXY(w).map((e) => rad2deg(e));
328
- }
329
- static quaternionToEulerZXY(e) {
330
- let w = e[0], T = e[1], E = e[2], D = e[3], O, k, A, j = E * D + T * w;
331
- return j > .499 ? (O = 2 * Math.atan2(E, w), k = Math.PI / 2, A = 0) : j < -.499 ? (O = -2 * Math.atan2(E, w), k = -Math.PI / 2, A = 0) : (O = Math.atan2(2 * D * w - 2 * E * T, 1 - 2 * D ** 2 - 2 * T ** 2), k = Math.asin(2 * j), A = Math.atan2(2 * E * w - 2 * D * T, 1 - 2 * E ** 2 - 2 * T ** 2)), O %= 2 * Math.PI, k %= Math.PI, A %= 2 * Math.PI, [
332
- O,
333
- k,
334
- A
335
- ];
336
- }
337
- static quaternionToEulerDegrees(w, T) {
338
- return e.quaternionToEuler(w, T).map((e) => rad2deg(e));
339
- }
340
- static quaternionToEuler(w, T) {
341
- let E = w[0], D = w[1], O = w[2], k = w[3];
342
- switch (T.toLowerCase()) {
343
- case "zyx": return e._threeaxisrot(2 * (D * O + E * k), E ** 2 + D ** 2 - O ** 2 - k ** 2, -2 * (D * k - E * O), 2 * (O * k + E * D), E ** 2 - D ** 2 - O ** 2 + k ** 2);
344
- case "zyz": return e._twoaxisrot(2 * (O * k - E * D), 2 * (D * k + E * O), E ** 2 - D ** 2 - O ** 2 + k ** 2, 2 * (O * k + E * D), -2 * (D * k - E * O));
345
- case "zxy": return e._threeaxisrot(-2 * (D * O - E * k), E ** 2 - D ** 2 + O ** 2 - k ** 2, 2 * (O * k + E * D), -2 * (D * k - E * O), E ** 2 - D ** 2 - O ** 2 + k ** 2);
346
- case "zxz": return e._twoaxisrot(2 * (D * k + E * O), -2 * (O * k - E * D), E ** 2 - D ** 2 - O ** 2 + k ** 2, 2 * (D * k - E * O), 2 * (O * k + E * D));
347
- case "yxz": return e._threeaxisrot(2 * (D * k + E * O), E ** 2 - D ** 2 - O ** 2 + k ** 2, -2 * (O * k - E * D), 2 * (D * O + E * k), E ** 2 - D ** 2 + O ** 2 - k ** 2);
348
- case "yxy": return e._twoaxisrot(2 * (D * O - E * k), 2 * (O * k + E * D), E ** 2 - D ** 2 + O ** 2 - k ** 2, 2 * (D * O + E * k), -2 * (O * k - E * D));
349
- case "yzx": return e._threeaxisrot(-2 * (D * k - E * O), E ** 2 + D ** 2 - O ** 2 - k ** 2, 2 * (D * O + E * k), -2 * (O * k - E * D), E ** 2 - D ** 2 + O ** 2 - k ** 2);
350
- case "yzy": return e._twoaxisrot(2 * (O * k + E * D), -2 * (D * O - E * k), E ** 2 - D ** 2 + O ** 2 - k ** 2, 2 * (O * k - E * D), 2 * (D * O + E * k));
351
- case "xyz": return e._threeaxisrot(-2 * (O * k - E * D), E ** 2 - D ** 2 - O ** 2 + k ** 2, 2 * (D * k + E * O), -2 * (D * O - E * k), E ** 2 + D ** 2 - O ** 2 - k ** 2);
352
- case "xyx": return e._twoaxisrot(2 * (D * O + E * k), -2 * (D * k - E * O), E ** 2 + D ** 2 - O ** 2 - k ** 2, 2 * (D * O - E * k), 2 * (D * k + E * O));
353
- case "xzy": return e._threeaxisrot(2 * (O * k + E * D), E ** 2 - D ** 2 + O ** 2 - k ** 2, -2 * (D * O - E * k), 2 * (D * k + E * O), E ** 2 + D ** 2 - O ** 2 - k ** 2);
354
- case "xzx": return e._twoaxisrot(2 * (D * k - E * O), 2 * (D * O + E * k), E ** 2 + D ** 2 - O ** 2 - k ** 2, 2 * (D * k + E * O), -2 * (D * O - E * k));
355
- }
356
- throw Error("unknown order");
357
- }
358
- static _threeaxisrot(e, w, T, E, D) {
359
- return [
360
- Math.atan2(e, w),
361
- Math.asin(T),
362
- Math.atan2(E, D)
363
- ];
364
- }
365
- static _twoaxisrot(e, w, T, E, D) {
366
- return [
367
- Math.atan2(e, w),
368
- Math.acos(T),
369
- Math.atan2(E, D)
370
- ];
371
- }
372
- static getHeadingFromQuaternion(e) {
373
- let [w, T, E, D] = e, O = w * T, k = E * D, A = T ** 2;
374
- return Math.asin(2 * (O + k)) < Math.PI / 4 && A + E ** 2 < .5 ? -Math.atan2(w * D - T * E, .5 - A - D ** 2) : -Math.atan2(T * D + w * E, O - k);
375
- }
376
- }, Level_default = class e {
26
+ var Level_default = class e {
377
27
  static VERIFY_TYPING = !1;
378
28
  static checkType(e) {
379
29
  if (e !== null && !(typeof e == "number" && !isNaN(e))) {
380
30
  if (Array.isArray(e) && e.length === 2) {
381
- let [w, T] = e;
382
- if (typeof w == "number" && !isNaN(w) && typeof T == "number" && !isNaN(T)) {
383
- if (w > T || w === T) throw Error(`Invalid level range: [${w}, ${T}]`);
31
+ let [y, b] = e;
32
+ if (typeof y == "number" && !isNaN(y) && typeof b == "number" && !isNaN(b)) {
33
+ if (y > b || y === b) throw Error(`Invalid level range: [${y}, ${b}]`);
384
34
  return;
385
35
  }
386
36
  }
387
37
  throw Error(`Unknown level format: ${e}`);
388
38
  }
389
39
  }
390
- static isRange(w) {
391
- return e.VERIFY_TYPING && e.checkType(w), Array.isArray(w);
392
- }
393
- static clone(w) {
394
- return e.VERIFY_TYPING && e.checkType(w), w === null ? null : typeof w == "number" ? w : [w[0], w[1]];
395
- }
396
- static fromString(w) {
397
- if (w === null) return null;
398
- if (typeof w != "string" || !w.length) throw Error(`argument must be a non empty string, got ${typeof w}`);
399
- if (!isNaN(Number(w))) return parseFloat(w);
400
- let T = w.split(";");
401
- if (T.length > 1) {
402
- let w = T.map((e) => Number(e)), E = Math.min(...w), D = Math.max(...w);
403
- return e.checkType([E, D]), [E, D];
40
+ static isRange(y) {
41
+ return e.VERIFY_TYPING && e.checkType(y), Array.isArray(y);
42
+ }
43
+ static clone(y) {
44
+ return e.VERIFY_TYPING && e.checkType(y), y === null ? null : typeof y == "number" ? y : [y[0], y[1]];
45
+ }
46
+ static fromString(y) {
47
+ if (y === null) return null;
48
+ if (typeof y != "string" || !y.length) throw Error(`argument must be a non empty string, got ${typeof y}`);
49
+ if (!isNaN(Number(y))) return parseFloat(y);
50
+ let b = (e) => {
51
+ let b = e.map((e) => Number(e));
52
+ if (b.some((e) => Number.isNaN(e)) || e.some((e) => !e.length)) throw Error(`Cannot parse following level: ${y}`);
53
+ return b;
54
+ }, x = y.split(";");
55
+ if (x.length > 1) {
56
+ let y = b(x), S = Math.min(...y), C = Math.max(...y);
57
+ return e.checkType([S, C]), [S, C];
404
58
  } else {
405
- let T = w.substring(1).indexOf("-") + 1;
406
- if (T > 0) {
407
- let E = Number(w.substring(0, T)), D = Number(w.substring(T + 1));
408
- return e.checkType([E, D]), [E, D];
59
+ let x = y.substring(1).indexOf("-") + 1;
60
+ if (x > 0) {
61
+ let [S, C] = b([y.substring(0, x), y.substring(x + 1)]);
62
+ return e.checkType([S, C]), [S, C];
409
63
  }
410
64
  }
411
- throw Error(`Cannot parse following level: ${w}`);
65
+ throw Error(`Cannot parse following level: ${y}`);
412
66
  }
413
- static contains(w, T) {
414
- return e.VERIFY_TYPING && (e.checkType(w), e.checkType(T)), w === T ? !0 : Array.isArray(w) ? Array.isArray(T) ? w[0] <= T[0] && w[1] >= T[1] : T === null ? !1 : w[0] <= T && w[1] >= T : w === null || T === null ? !1 : w <= T[0] && w >= T[1];
67
+ static parse(y) {
68
+ if (y == null) return null;
69
+ if (typeof y == "number") {
70
+ if (Number.isNaN(y)) throw Error("level number must not be NaN");
71
+ return y;
72
+ }
73
+ if (Array.isArray(y)) {
74
+ if (y.length !== 2) throw Error(`level range must have exactly 2 elements, got ${y.length}`);
75
+ let b = [y[0], y[1]];
76
+ return e.checkType(b), e.clone(b);
77
+ }
78
+ if (typeof y == "string") return e.fromString(y);
79
+ throw Error(`Cannot parse level from ${typeof y}`);
80
+ }
81
+ static contains(y, b) {
82
+ return e.VERIFY_TYPING && (e.checkType(y), e.checkType(b)), y === b ? !0 : Array.isArray(y) ? Array.isArray(b) ? y[0] <= b[0] && y[1] >= b[1] : b === null ? !1 : y[0] <= b && y[1] >= b : y === null || b === null ? !1 : y <= b[0] && y >= b[1];
415
83
  }
416
- static intersection(w, T) {
417
- if (e.VERIFY_TYPING && (e.checkType(w), e.checkType(T)), w === null || T === null) return null;
418
- if (e.equals(w, T)) return e.clone(w);
419
- if (typeof w == "number" && typeof T == "number") return w === T ? w : null;
420
- if (Array.isArray(w) && !Array.isArray(T)) return e.contains(w, T) ? T : null;
421
- if (!Array.isArray(w) && Array.isArray(T)) return e.contains(T, w) ? w : null;
422
- let E = Math.max(w[0], T[0]), D = Math.min(w[1], T[1]);
423
- return D === E ? D : D < E ? null : [E, D];
84
+ static intersection(y, b) {
85
+ if (e.VERIFY_TYPING && (e.checkType(y), e.checkType(b)), y === null || b === null) return null;
86
+ if (e.equals(y, b)) return e.clone(y);
87
+ if (typeof y == "number" && typeof b == "number") return y === b ? y : null;
88
+ if (Array.isArray(y) && !Array.isArray(b)) return e.contains(y, b) ? b : null;
89
+ if (!Array.isArray(y) && Array.isArray(b)) return e.contains(b, y) ? y : null;
90
+ let x = Math.max(y[0], b[0]), S = Math.min(y[1], b[1]);
91
+ return S === x ? S : S < x ? null : [x, S];
424
92
  }
425
- static intersect(w, T) {
426
- return e.VERIFY_TYPING && (e.checkType(w), e.checkType(T)), w === null && T === null ? !0 : e.intersection(w, T) !== null;
93
+ static intersect(y, b) {
94
+ return e.VERIFY_TYPING && (e.checkType(y), e.checkType(b)), y === null && b === null ? !0 : e.intersection(y, b) !== null;
427
95
  }
428
- static union(w, T) {
429
- if (e.VERIFY_TYPING && (e.checkType(w), e.checkType(T)), w === T) return e.clone(w);
430
- if (T === null || w === null) return null;
431
- let E, D;
432
- return !Array.isArray(w) && !Array.isArray(T) ? (E = Math.min(w, T), D = Math.max(w, T)) : Array.isArray(w) && !Array.isArray(T) ? (E = Math.min(w[0], T), D = Math.max(w[1], T)) : !Array.isArray(w) && Array.isArray(T) ? (E = Math.min(T[0], w), D = Math.max(T[1], w)) : (E = Math.min(w[0], T[0]), D = Math.max(w[1], T[1])), E === D ? E : [E, D];
96
+ static union(y, b) {
97
+ if (e.VERIFY_TYPING && (e.checkType(y), e.checkType(b)), y === b) return e.clone(y);
98
+ if (b === null || y === null) return null;
99
+ let x, S;
100
+ return !Array.isArray(y) && !Array.isArray(b) ? (x = Math.min(y, b), S = Math.max(y, b)) : Array.isArray(y) && !Array.isArray(b) ? (x = Math.min(y[0], b), S = Math.max(y[1], b)) : !Array.isArray(y) && Array.isArray(b) ? (x = Math.min(b[0], y), S = Math.max(b[1], y)) : (x = Math.min(y[0], b[0]), S = Math.max(y[1], b[1])), x === S ? x : [x, S];
433
101
  }
434
- static multiplyBy(w, T) {
435
- return e.VERIFY_TYPING && e.checkType(w), w === null ? null : Array.isArray(w) ? [w[0] * T, w[1] * T] : w * T;
102
+ static multiplyBy(y, b) {
103
+ return e.VERIFY_TYPING && e.checkType(y), y === null ? null : Array.isArray(y) ? [y[0] * b, y[1] * b] : y * b;
436
104
  }
437
- static toString(w) {
438
- return e.VERIFY_TYPING && e.checkType(w), w === null ? null : Array.isArray(w) ? w[0] + ";" + w[1] : String(w);
105
+ static toString(y) {
106
+ return e.VERIFY_TYPING && e.checkType(y), y === null ? null : Array.isArray(y) ? y[0] + ";" + y[1] : String(y);
439
107
  }
440
- static equals(w, T) {
441
- return e.VERIFY_TYPING && (e.checkType(w), e.checkType(T)), w === T ? !0 : Array.isArray(w) && Array.isArray(T) ? w[0] === T[0] && w[1] === T[1] : !1;
108
+ static equals(y, b) {
109
+ return e.VERIFY_TYPING && (e.checkType(y), e.checkType(b)), y === b ? !0 : Array.isArray(y) && Array.isArray(b) ? y[0] === b[0] && y[1] === b[1] : !1;
442
110
  }
443
- static diff(w, T) {
444
- return e.VERIFY_TYPING && (e.checkType(w), e.checkType(T)), w === null || T === null ? null : !Array.isArray(w) && !Array.isArray(T) ? T - w : Array.isArray(w) && !Array.isArray(T) ? w[0] === T ? T - w[1] : w[1] === T ? T - w[0] : null : Array.isArray(T) && !Array.isArray(w) ? w === T[0] ? T[1] - w : w === T[1] ? T[0] - w : null : e.equals(w, T) ? 0 : null;
111
+ static diff(y, b) {
112
+ return e.VERIFY_TYPING && (e.checkType(y), e.checkType(b)), y === null || b === null ? null : !Array.isArray(y) && !Array.isArray(b) ? b - y : Array.isArray(y) && !Array.isArray(b) ? y[0] === b ? b - y[1] : y[1] === b ? b - y[0] : null : Array.isArray(b) && !Array.isArray(y) ? y === b[0] ? b[1] - y : y === b[1] ? b[0] - y : null : e.equals(y, b) ? 0 : null;
445
113
  }
446
- }, Coordinates_default = class e {
114
+ }, Coordinates_default = class y {
447
115
  _lat;
448
116
  _lng;
449
117
  _alt = null;
@@ -452,8 +120,8 @@ var Rotations = class e {
452
120
  _heightFromGround = null;
453
121
  _ecef;
454
122
  autoWrap = !0;
455
- constructor(e, w, T = null, E = null) {
456
- this.lat = e, this.lng = w, this.alt = T, this.level = E, this._ecef = null;
123
+ constructor(e, y, b = null, x = null) {
124
+ this.lat = e, this.lng = y, this.alt = b, this.level = x, this._ecef = null;
457
125
  }
458
126
  get lat() {
459
127
  return this._lat;
@@ -506,98 +174,98 @@ var Rotations = class e {
506
174
  this._heightFromGround = e;
507
175
  }
508
176
  clone() {
509
- let w = new e(this.lat, this.lng, this.alt);
510
- return this.level !== null && (w.level = Level_default.clone(this.level)), w;
177
+ let e = new y(this.lat, this.lng, this.alt);
178
+ return this.level !== null && (e.level = Level_default.clone(this.level)), e;
511
179
  }
512
180
  wrap() {
513
181
  (this._lng <= -180 || this._lng > 180) && (this._lng = wrap(this._lng, -180, 180));
514
182
  }
515
- static equals(e, w, T = EPS_DEG_MM, E = EPS_MM) {
516
- return this.equalsWithoutLevel(e, w, T, E) ? e === null || w === null ? !0 : Level_default.equals(e.level, w.level) : !1;
183
+ static equals(e, y, b = EPS_DEG_MM, x = EPS_MM) {
184
+ return this.equalsWithoutLevel(e, y, b, x) ? e === null || y === null ? !0 : Level_default.equals(e.level, y.level) : !1;
517
185
  }
518
- equals(w) {
519
- return e.equals(this, w);
186
+ equals(e) {
187
+ return y.equals(this, e);
520
188
  }
521
- static equalsWithoutLevel(w, T, E = EPS_DEG_MM, D = EPS_MM) {
522
- return w === null && w === T ? !0 : !(w instanceof e) || !(T instanceof e) ? !1 : Math.abs(T.lat - w.lat) < E && Math.abs(T.lng - w.lng) < E && (w.alt === T.alt || w.alt !== null && T.alt !== null && Math.abs(T.alt - w.alt) < D);
189
+ static equalsWithoutLevel(e, b, x = EPS_DEG_MM, S = EPS_MM) {
190
+ return e === null && e === b ? !0 : !(e instanceof y) || !(b instanceof y) ? !1 : Math.abs(b.lat - e.lat) < x && Math.abs(b.lng - e.lng) < x && (e.alt === b.alt || e.alt !== null && b.alt !== null && Math.abs(b.alt - e.alt) < S);
523
191
  }
524
- equalsWithoutLevel(w, T = EPS_DEG_MM, E = EPS_MM) {
525
- return e.equalsWithoutLevel(this, w, T, E);
192
+ equalsWithoutLevel(e, b = EPS_DEG_MM, x = EPS_MM) {
193
+ return y.equalsWithoutLevel(this, e, b, x);
526
194
  }
527
- destinationPoint(e, w, T = null) {
528
- let E = this.clone();
529
- return E.move(e, w, T), E;
195
+ destinationPoint(e, y, b = null) {
196
+ let x = this.clone();
197
+ return x.move(e, y, b), x;
530
198
  }
531
- move(e, w, T = null) {
532
- let E = e / R_MAJOR, O = Math.cos(E), k = Math.sin(E), A = deg2rad(this.lat), j = deg2rad(this.lng), M = Math.asin(Math.sin(A) * O + Math.cos(A) * k * Math.cos(w)), N = j + Math.atan2(Math.sin(w) * k * Math.cos(A), O - Math.sin(A) * Math.sin(M));
533
- if (this.lat = rad2deg(M), this.lng = rad2deg(N), T !== null) {
199
+ move(e, y, b = null) {
200
+ let S = e / R_MAJOR, w = Math.cos(S), T = Math.sin(S), E = deg2rad(this.lat), D = deg2rad(this.lng), O = Math.asin(Math.sin(E) * w + Math.cos(E) * T * Math.cos(y)), A = D + Math.atan2(Math.sin(y) * T * Math.cos(E), w - Math.sin(E) * Math.sin(O));
201
+ if (this.lat = rad2deg(O), this.lng = rad2deg(A), b !== null) {
534
202
  if (this.alt === null) throw Error("Point altitude is not defined");
535
- this.alt += T;
203
+ this.alt += b;
536
204
  }
537
205
  return this;
538
206
  }
539
207
  distanceTo(e) {
540
- let w = this.lat, T = this.lng, E = e.lat, O = e.lng, k = deg2rad(E - w), A = deg2rad(O - T), j = Math.sin(A / 2), M = Math.sin(k / 2), N = deg2rad(w), P = Math.cos(N), F = deg2rad(E), I = Math.cos(F), L = M * M + P * I * j * j, R = Math.sqrt(L), z = Math.sqrt(1 - L);
541
- return R_MAJOR * (2 * Math.atan2(R, z));
208
+ let y = this.lat, b = this.lng, S = e.lat, C = e.lng, w = deg2rad(S - y), T = deg2rad(C - b), E = Math.sin(T / 2), D = Math.sin(w / 2), O = deg2rad(y), A = Math.cos(O), j = deg2rad(S), M = Math.cos(j), N = D * D + A * M * E * E, P = Math.sqrt(N), F = Math.sqrt(1 - N);
209
+ return R_MAJOR * (2 * Math.atan2(P, F));
542
210
  }
543
- static distanceBetween(e, w) {
544
- return e.distanceTo(w);
211
+ static distanceBetween(e, y) {
212
+ return e.distanceTo(y);
545
213
  }
546
214
  bearingTo(e) {
547
- let w = deg2rad(this.lat), T = deg2rad(e.lat), E = deg2rad(e.lng - this.lng);
548
- return Math.atan2(Math.sin(E) * Math.cos(T), Math.cos(w) * Math.sin(T) - Math.sin(w) * Math.cos(T) * Math.cos(E));
215
+ let y = deg2rad(this.lat), b = deg2rad(e.lat), S = deg2rad(e.lng - this.lng);
216
+ return Math.atan2(Math.sin(S) * Math.cos(b), Math.cos(y) * Math.sin(b) - Math.sin(y) * Math.cos(b) * Math.cos(S));
549
217
  }
550
- static bearingTo(e, w) {
551
- return e.bearingTo(w);
218
+ static bearingTo(e, y) {
219
+ return e.bearingTo(y);
552
220
  }
553
221
  get enuToEcefRotation() {
554
- let e = Quaternion.fromAxisAngle([
222
+ let y = Quaternion.fromAxisAngle([
555
223
  0,
556
224
  0,
557
225
  1
558
- ], Math.PI / 2 + deg2rad(this.lng)), w = Quaternion.fromAxisAngle([
226
+ ], Math.PI / 2 + deg2rad(this.lng)), b = Quaternion.fromAxisAngle([
559
227
  1,
560
228
  0,
561
229
  0
562
230
  ], Math.PI / 2 - deg2rad(this.lat));
563
- return Quaternion.multiply(e, w);
231
+ return Quaternion.multiply(y, b);
564
232
  }
565
233
  get ecefToEnuRotation() {
566
- let e = Quaternion.fromAxisAngle([
234
+ let y = Quaternion.fromAxisAngle([
567
235
  1,
568
236
  0,
569
237
  0
570
- ], deg2rad(this.lat) - Math.PI / 2), w = Quaternion.fromAxisAngle([
238
+ ], deg2rad(this.lat) - Math.PI / 2), b = Quaternion.fromAxisAngle([
571
239
  0,
572
240
  0,
573
241
  1
574
242
  ], -deg2rad(this.lng) - Math.PI / 2);
575
- return Quaternion.multiply(e, w);
243
+ return Quaternion.multiply(y, b);
576
244
  }
577
245
  get ecef() {
578
246
  if (!this._ecef) {
579
- let e = deg2rad(this.lat), w = deg2rad(this.lng), T = this.alt || 0;
247
+ let e = deg2rad(this.lat), y = deg2rad(this.lng), b = this.alt || 0;
580
248
  this._ecef = [
581
- (R_MAJOR + T) * Math.cos(e) * Math.cos(w),
582
- (R_MAJOR + T) * Math.cos(e) * Math.sin(w),
583
- (R_MAJOR + T) * Math.sin(e)
249
+ (R_MAJOR + b) * Math.cos(e) * Math.cos(y),
250
+ (R_MAJOR + b) * Math.cos(e) * Math.sin(y),
251
+ (R_MAJOR + b) * Math.sin(e)
584
252
  ];
585
253
  }
586
254
  return this._ecef;
587
255
  }
588
- static fromECEF(w) {
589
- let T = w[0], E = w[1], O = w[2], k = Math.sqrt(T ** 2 + E ** 2), A = Math.atan2(E, T), j = Math.atan2(O, k), M = k / Math.cos(j) - R_MAJOR;
590
- A %= 2 * Math.PI;
591
- let N = new e(rad2deg(j), rad2deg(A), M);
592
- return N._ecef = w, N;
256
+ static fromECEF(e) {
257
+ let b = e[0], x = e[1], S = e[2], w = Math.sqrt(b ** 2 + x ** 2), T = Math.atan2(x, b), E = Math.atan2(S, w), D = w / Math.cos(E) - R_MAJOR;
258
+ T %= 2 * Math.PI;
259
+ let O = new y(rad2deg(E), rad2deg(T), D);
260
+ return O._ecef = e, O;
593
261
  }
594
- getSegmentProjection(w, T) {
595
- let E = Vector3.normalize(w.ecef), O = Vector3.normalize(T.ecef), k = Vector3.normalize(this.ecef), A = Vector3.cross(E, O);
596
- if (Vector3.norm(A) === 0) return null;
597
- let j = Vector3.cross(k, A), M = Vector3.normalize(Vector3.cross(A, j)), N = Vector3.multiplyScalar(M, R_MAJOR), P = e.fromECEF(N), F;
598
- w.alt !== null && T.alt !== null && (F = (w.alt + T.alt) / 2);
599
- let I = new e(P.lat, P.lng, F, Level_default.union(w.level, T.level));
600
- return Math.abs(w.distanceTo(T) - w.distanceTo(I) - T.distanceTo(I)) > .001 ? null : I;
262
+ getSegmentProjection(e, x) {
263
+ let S = Vector3.normalize(e.ecef), C = Vector3.normalize(x.ecef), w = Vector3.normalize(this.ecef), T = Vector3.cross(S, C);
264
+ if (Vector3.norm(T) === 0) return null;
265
+ let E = Vector3.cross(w, T), D = Vector3.normalize(Vector3.cross(T, E)), O = Vector3.multiplyScalar(D, R_MAJOR), A = y.fromECEF(O), j;
266
+ e.alt !== null && x.alt !== null && (j = (e.alt + x.alt) / 2);
267
+ let M = new y(A.lat, A.lng, j, Level_default.union(e.level, x.level));
268
+ return Math.abs(e.distanceTo(x) - e.distanceTo(M) - x.distanceTo(M)) > .001 ? null : M;
601
269
  }
602
270
  toString() {
603
271
  let e = "[" + this._lat.toFixed(7) + ", " + this._lng.toFixed(7);
@@ -611,8 +279,8 @@ var Rotations = class e {
611
279
  ...this.level !== null && { level: this.level }
612
280
  };
613
281
  }
614
- static fromJson(w) {
615
- return new e(w.lat, w.lng, w.alt, w.level);
282
+ static fromJson(e) {
283
+ return new y(e.lat, e.lng, e.alt, e.level);
616
284
  }
617
285
  toCompressedJson() {
618
286
  return this.level === null ? [Number(this.lat.toFixed(8)), Number(this.lng.toFixed(8))] : [
@@ -621,16 +289,16 @@ var Rotations = class e {
621
289
  this.level
622
290
  ];
623
291
  }
624
- static fromCompressedJson(w) {
625
- let T = new e(w[0], w[1]);
626
- return w.length > 2 && (T.level = w[2]), T;
292
+ static fromCompressedJson(e) {
293
+ let b = new y(e[0], e[1]);
294
+ return e.length > 2 && (b.level = e[2]), b;
627
295
  }
628
296
  }, UserPosition_default = class e extends Coordinates_default {
629
297
  _time = null;
630
298
  _accuracy = null;
631
299
  _bearing = null;
632
- constructor(e, w, T = null, E = null, D = null, O = null, k = null) {
633
- super(e, w, T, E), this.time = D, this.accuracy = O, this.bearing = k;
300
+ constructor(e, y, b = null, x = null, S = null, C = null, w = null) {
301
+ super(e, y, b, x), this.time = S, this.accuracy = C, this.bearing = w;
634
302
  }
635
303
  get time() {
636
304
  return this._time;
@@ -651,25 +319,25 @@ var Rotations = class e {
651
319
  set bearing(e) {
652
320
  this._bearing = e === null ? null : e % (2 * Math.PI);
653
321
  }
654
- move(e, w, T = null) {
655
- return super.move(e, w, T), this;
322
+ move(e, y, b = null) {
323
+ return super.move(e, y, b), this;
656
324
  }
657
- destinationPoint(e, w, T = null) {
658
- let E = this.clone();
659
- return E.move(e, w, T), E;
325
+ destinationPoint(e, y, b = null) {
326
+ let x = this.clone();
327
+ return x.move(e, y, b), x;
660
328
  }
661
- static fromCoordinates(w) {
662
- return new e(w.lat, w.lng, w.alt, w.level);
329
+ static fromCoordinates(y) {
330
+ return new e(y.lat, y.lng, y.alt, y.level);
663
331
  }
664
332
  clone() {
665
- let w = e.fromCoordinates(super.clone());
666
- return w.time = this.time, w.accuracy = this.accuracy, w.bearing = this.bearing, w;
333
+ let y = e.fromCoordinates(super.clone());
334
+ return y.time = this.time, y.accuracy = this.accuracy, y.bearing = this.bearing, y;
667
335
  }
668
- static equals(w, T, E = EPS_DEG_MM, D = EPS_MM) {
669
- return w === null && w === T ? !0 : !(w instanceof e) || !(T instanceof e) || !super.equals(w, T, E, D) ? !1 : w.time === T.time && w.accuracy === T.accuracy && w.bearing === T.bearing;
336
+ static equals(y, b, x = EPS_DEG_MM, S = EPS_MM) {
337
+ return y === null && y === b ? !0 : !(y instanceof e) || !(b instanceof e) || !super.equals(y, b, x, S) ? !1 : y.time === b.time && y.accuracy === b.accuracy && y.bearing === b.bearing;
670
338
  }
671
- equals(w, T = EPS_DEG_MM, E = EPS_MM) {
672
- return e.equals(this, w, T, E);
339
+ equals(y, b = EPS_DEG_MM, x = EPS_MM) {
340
+ return e.equals(this, y, b, x);
673
341
  }
674
342
  toJson() {
675
343
  return {
@@ -679,9 +347,9 @@ var Rotations = class e {
679
347
  ...this.bearing !== null && { bearing: this.bearing }
680
348
  };
681
349
  }
682
- static fromJson(w) {
683
- let T = e.fromCoordinates(Coordinates_default.fromJson(w));
684
- return w.time !== void 0 && (T.time = w.time), w.accuracy !== void 0 && (T.accuracy = w.accuracy), w.bearing !== void 0 && (T.bearing = w.bearing), T;
350
+ static fromJson(y) {
351
+ let b = e.fromCoordinates(Coordinates_default.fromJson(y));
352
+ return y.time !== void 0 && (b.time = y.time), y.accuracy !== void 0 && (b.accuracy = y.accuracy), y.bearing !== void 0 && (b.bearing = y.bearing), b;
685
353
  }
686
354
  }, Utils_exports = /* @__PURE__ */ __export({
687
355
  calcDistance: () => calcDistance,
@@ -692,90 +360,90 @@ var Rotations = class e {
692
360
  simplifyRoute: () => simplifyRoute,
693
361
  trimRoute: () => trimRoute
694
362
  });
695
- function sampleRoute(e, w = .7, T = 0, E = Number.MAX_VALUE) {
696
- let D = T + E, O = [], k, A = 0, j = 0, M = !1;
697
- for (let E = 0; E < e.length - 1; E++) {
698
- let N = e[E], P = e[E + 1], F = N.distanceTo(P), I = N.bearingTo(P), L = 0;
699
- if (!M) if (T < A + F) M = !0, j = T - A;
363
+ function sampleRoute(e, y = .7, b = 0, x = Number.MAX_VALUE) {
364
+ let S = b + x, C = [], w, T = 0, E = 0, D = !1;
365
+ for (let x = 0; x < e.length - 1; x++) {
366
+ let O = e[x], k = e[x + 1], A = O.distanceTo(k), j = O.bearingTo(k), M = 0;
367
+ if (!D) if (b < T + A) D = !0, E = b - T;
700
368
  else {
701
- A += F;
369
+ T += A;
702
370
  continue;
703
371
  }
704
- for (k = Object.assign(N.clone(), { bearing: I }); L + j < F && A + j <= D;) {
705
- let e = k.destinationPoint(j, I);
706
- e.bearing = I, O.push(e), k = e, L += j, A += j, j = w;
372
+ for (w = Object.assign(O.clone(), { bearing: j }); M + E < A && T + E <= S;) {
373
+ let e = w.destinationPoint(E, j);
374
+ e.bearing = j, C.push(e), w = e, M += E, T += E, E = y;
707
375
  }
708
- if (A + j > D) break;
709
- let R = F - L;
710
- A += R, j -= R;
376
+ if (T + E > S) break;
377
+ let N = A - M;
378
+ T += N, E -= N;
711
379
  }
712
- return O;
380
+ return C;
713
381
  }
714
- function trimRoute(e, w = e[0], T = Number.MAX_VALUE) {
715
- let E = [], D = null, O, k = 0;
382
+ function trimRoute(e, y = e[0], b = Number.MAX_VALUE) {
383
+ let x = [], S = null, C, w = 0;
716
384
  if (e.length <= 1) throw Error("Route must have at least 2 points");
717
- for (O = 1; O < e.length; O++) {
718
- let T = e[O - 1], k = e[O];
719
- if (Coordinates_default.equals(w, T)) {
720
- E.push(T), D = T;
385
+ for (C = 1; C < e.length; C++) {
386
+ let b = e[C - 1], w = e[C];
387
+ if (Coordinates_default.equals(y, b)) {
388
+ x.push(b), S = b;
721
389
  break;
722
390
  }
723
- let A = w.getSegmentProjection(T, k);
724
- if (A && Coordinates_default.equals(w, A) && !A.equals(k)) {
725
- E.push(A), D = A;
391
+ let T = y.getSegmentProjection(b, w);
392
+ if (T && Coordinates_default.equals(y, T) && !T.equals(w)) {
393
+ x.push(T), S = T;
726
394
  break;
727
395
  }
728
396
  }
729
- if (!E.length) throw Error("startPosition is not on the route");
730
- for (; D && O < e.length;) {
731
- let w = e[O], A = D.distanceTo(w);
732
- if (k + A >= T || Math.abs(k + A - T) <= .001) {
733
- let e = D.bearingTo(w), O = T - k, A = D.destinationPoint(O, e);
734
- E.push(A);
397
+ if (!x.length) throw Error("startPosition is not on the route");
398
+ for (; S && C < e.length;) {
399
+ let y = e[C], T = S.distanceTo(y);
400
+ if (w + T >= b || Math.abs(w + T - b) <= .001) {
401
+ let e = S.bearingTo(y), C = b - w, T = S.destinationPoint(C, e);
402
+ x.push(T);
735
403
  break;
736
404
  }
737
- E.push(w), D = w, k += A, O++;
405
+ x.push(y), S = y, w += T, C++;
738
406
  }
739
- return E;
407
+ return x;
740
408
  }
741
- function simplifyRoute(e, w = deg2rad(5)) {
742
- let T = e[0].equals(e[e.length - 1]), E = e.slice(0, e.length - (T ? 1 : 0)), D = E.length;
743
- for (let O = T ? 0 : 1; O < D; O++) {
744
- let T = e[positiveMod(O - 1, D)], k = e[O], A = e[positiveMod(O + 1, D)], j = T.bearingTo(k), M = k.bearingTo(A);
745
- Math.abs(M - j) < w && (E = E.filter((e) => e !== k));
409
+ function simplifyRoute(e, y = deg2rad(5)) {
410
+ let b = e[0].equals(e[e.length - 1]), C = e.slice(0, e.length - (b ? 1 : 0)), w = C.length;
411
+ for (let x = b ? 0 : 1; x < w; x++) {
412
+ let b = e[positiveMod(x - 1, w)], T = e[x], E = e[positiveMod(x + 1, w)], D = b.bearingTo(T), O = T.bearingTo(E);
413
+ Math.abs(O - D) < y && (C = C.filter((e) => e !== T));
746
414
  }
747
- return T && E.push(E[0]), E;
415
+ return b && C.push(C[0]), C;
748
416
  }
749
417
  function geolocationPositionToUserPosition(e) {
750
418
  if (e === null) return null;
751
- let { latitude: w, longitude: T, accuracy: E, heading: D } = e.coords, O = new UserPosition_default(w, T);
752
- return O.time = e.timestamp, O.accuracy = E, O.bearing = D ? deg2rad(D) : null, O;
419
+ let { latitude: y, longitude: b, accuracy: S, heading: C } = e.coords, w = new UserPosition_default(y, b);
420
+ return w.time = e.timestamp, w.accuracy = S, w.bearing = C ? deg2rad(C) : null, w;
753
421
  }
754
422
  function calcDistance(e) {
755
- return e.reduce((e, w, T, E) => e + (T ? E[T - 1].distanceTo(w) : 0), 0);
423
+ return e.reduce((e, y, b, x) => e + (b ? x[b - 1].distanceTo(y) : 0), 0);
756
424
  }
757
- function createSegmentsAtLevel(e, w, T = !0) {
758
- let E = e.length, D = !1, O = [], k = [];
759
- for (let A = 0; A < E; A++) {
760
- let E = e[A], j = Level_default.intersect(w, E.level);
761
- T && !j && D ? k.push(E) : j && (D || (k = [], O.push(k), T && A !== 0 && k.push(e[A - 1])), k.push(E)), D = j;
425
+ function createSegmentsAtLevel(e, y, b = !0) {
426
+ let x = e.length, S = !1, C = [], w = [];
427
+ for (let T = 0; T < x; T++) {
428
+ let x = e[T], E = Level_default.intersect(y, x.level);
429
+ b && !E && S ? w.push(x) : E && (S || (w = [], C.push(w), b && T !== 0 && w.push(e[T - 1])), w.push(x)), S = E;
762
430
  }
763
- return O;
431
+ return C;
764
432
  }
765
- function segmentIntersection(e, w, T, E) {
766
- let O = (e) => e * Math.PI / 180, k = (e.lat + w.lat + T.lat + E.lat) / 4, A = R_MAJOR * 180 / Math.PI, j = R_MAJOR * 180 / Math.PI * Math.cos(O(k)), M = (e) => ({
767
- x: e.lng * j,
768
- y: e.lat * A
769
- }), N = M(e), P = M(w), F = M(T), I = M(E), L = P.x - N.x, R = P.y - N.y, z = I.x - F.x, B = I.y - F.y, V = L * B - R * z;
770
- if (Math.abs(V) < 1e-10) return null;
771
- let H = F.x - N.x, U = F.y - N.y, W = (H * B - U * z) / V, G = (H * R - U * L) / V;
772
- return W < 0 || W > 1 || G < 0 || G > 1 ? null : new Coordinates_default((N.y + W * R) / A, (N.x + W * L) / j);
433
+ function segmentIntersection(e, y, b, x) {
434
+ let S = (e) => e * Math.PI / 180, C = (e.lat + y.lat + b.lat + x.lat) / 4, w = R_MAJOR * 180 / Math.PI, T = R_MAJOR * 180 / Math.PI * Math.cos(S(C)), E = (e) => ({
435
+ x: e.lng * T,
436
+ y: e.lat * w
437
+ }), D = E(e), O = E(y), A = E(b), j = E(x), M = O.x - D.x, N = O.y - D.y, P = j.x - A.x, F = j.y - A.y, I = M * F - N * P;
438
+ if (Math.abs(I) < 1e-10) return null;
439
+ let L = A.x - D.x, R = A.y - D.y, z = (L * F - R * P) / I, B = (L * N - R * M) / I;
440
+ return z < 0 || z > 1 || B < 0 || B > 1 ? null : new Coordinates_default((D.y + z * N) / w, (D.x + z * M) / T);
773
441
  }
774
442
  var BoundingBox_default = class e {
775
443
  northEast;
776
444
  southWest;
777
- constructor(e, w) {
778
- if (this.northEast = e, this.southWest = w, this.northEast && this.southWest && this.getNorth() < this.getSouth()) throw Error("Incorrect bounding box");
445
+ constructor(e, y) {
446
+ if (this.northEast = e, this.southWest = y, this.northEast && this.southWest && this.getNorth() < this.getSouth()) throw Error("Incorrect bounding box");
779
447
  }
780
448
  get center() {
781
449
  return new Coordinates_default((this.southWest.lat + this.northEast.lat) / 2, (this.northEast.lng + this.southWest.lng) / 2);
@@ -783,20 +451,20 @@ var BoundingBox_default = class e {
783
451
  contains(e) {
784
452
  return e.lat <= this.northEast.lat && e.lat >= this.southWest.lat && e.lng <= this.northEast.lng && e.lng >= this.southWest.lng;
785
453
  }
786
- extend(w) {
787
- let T = this.southWest, E = this.northEast, D, O;
788
- if (w instanceof Coordinates_default) D = w, O = w;
789
- else if (w instanceof e) D = w.southWest, O = w.northEast;
454
+ extend(y) {
455
+ let b = this.southWest, x = this.northEast, S, C;
456
+ if (y instanceof Coordinates_default) S = y, C = y;
457
+ else if (y instanceof e) S = y.southWest, C = y.northEast;
790
458
  else throw Error("Unknown parameter");
791
- return this.southWest = new Coordinates_default(Math.min(D.lat, T.lat), Math.min(D.lng, T.lng)), this.northEast = new Coordinates_default(Math.max(O.lat, E.lat), Math.max(O.lng, E.lng)), this;
459
+ return this.southWest = new Coordinates_default(Math.min(S.lat, b.lat), Math.min(S.lng, b.lng)), this.northEast = new Coordinates_default(Math.max(C.lat, x.lat), Math.max(C.lng, x.lng)), this;
792
460
  }
793
461
  extendsWithMeasure(e) {
794
462
  if (typeof e != "number") throw Error("measure is not a number");
795
463
  return this.northEast = this.northEast.destinationPoint(e, 0).move(e, Math.PI / 2), this.southWest = this.southWest.clone().destinationPoint(e, -Math.PI / 2).destinationPoint(e, Math.PI), this;
796
464
  }
797
465
  pad(e) {
798
- let w = this.southWest, T = this.northEast, E = Math.abs(w.lat - T.lat) * e, D = Math.abs(w.lng - T.lng) * e;
799
- return this.southWest = new Coordinates_default(w.lat - E, w.lng - D), this.northEast = new Coordinates_default(T.lat + E, T.lng + D), this;
466
+ let y = this.southWest, b = this.northEast, x = Math.abs(y.lat - b.lat) * e, S = Math.abs(y.lng - b.lng) * e;
467
+ return this.southWest = new Coordinates_default(y.lat - x, y.lng - S), this.northEast = new Coordinates_default(b.lat + x, b.lng + S), this;
800
468
  }
801
469
  getSouthWest() {
802
470
  return this.southWest;
@@ -822,17 +490,17 @@ var BoundingBox_default = class e {
822
490
  getNorth() {
823
491
  return this.northEast.lat;
824
492
  }
825
- static equals(e, w) {
826
- return Coordinates_default.equals(e.northEast, w.northEast) && Coordinates_default.equals(e.southWest, w.southWest);
493
+ static equals(e, y) {
494
+ return Coordinates_default.equals(e.northEast, y.northEast) && Coordinates_default.equals(e.southWest, y.southWest);
827
495
  }
828
- equals(w) {
829
- return e.equals(this, w);
496
+ equals(y) {
497
+ return e.equals(this, y);
830
498
  }
831
- static fromArray(w) {
832
- return new e(new Coordinates_default(w[3], w[2]), new Coordinates_default(w[1], w[0]));
499
+ static fromArray(y) {
500
+ return new e(new Coordinates_default(y[3], y[2]), new Coordinates_default(y[1], y[0]));
833
501
  }
834
- static fromCoordinates(w) {
835
- return w.length === 0 ? null : w.reduce((e, w) => e.extend(w), new e(w[0], w[0]));
502
+ static fromCoordinates(y) {
503
+ return y.length === 0 ? null : y.reduce((e, y) => e.extend(y), new e(y[0], y[0]));
836
504
  }
837
505
  toArray() {
838
506
  return [
@@ -849,8 +517,8 @@ var BoundingBox_default = class e {
849
517
  time = null;
850
518
  _accuracy = null;
851
519
  _bearing = null;
852
- constructor(e, w, T, E = null, D = null, O = null) {
853
- this.x = e, this.y = w, this.z = T, this.time = E, this.accuracy = D, this.bearing = O;
520
+ constructor(e, y, b, x = null, S = null, C = null) {
521
+ this.x = e, this.y = y, this.z = b, this.time = x, this.accuracy = S, this.bearing = C;
854
522
  }
855
523
  get accuracy() {
856
524
  return this._accuracy;
@@ -868,11 +536,11 @@ var BoundingBox_default = class e {
868
536
  clone() {
869
537
  return new e(this.x, this.y, this.z, this.time, this.accuracy, this.bearing);
870
538
  }
871
- static equals(w, T, E = EPS_MM) {
872
- return w === null && w === T ? !0 : !(w instanceof e) || !(T instanceof e) ? !1 : Math.abs(T.x - w.x) < E && Math.abs(T.y - w.y) < E && Math.abs(T.z - w.z) < E && w.time === T.time && w.accuracy === T.accuracy && w.bearing === T.bearing;
539
+ static equals(y, b, x = EPS_MM) {
540
+ return y === null && y === b ? !0 : !(y instanceof e) || !(b instanceof e) ? !1 : Math.abs(b.x - y.x) < x && Math.abs(b.y - y.y) < x && Math.abs(b.z - y.z) < x && y.time === b.time && y.accuracy === b.accuracy && y.bearing === b.bearing;
873
541
  }
874
- equals(w) {
875
- return e.equals(this, w);
542
+ equals(y) {
543
+ return e.equals(this, y);
876
544
  }
877
545
  toJson() {
878
546
  return {
@@ -884,42 +552,42 @@ var BoundingBox_default = class e {
884
552
  ...this.bearing !== null && { bearing: this.bearing }
885
553
  };
886
554
  }
887
- static fromJson(w) {
888
- return new e(w.x, w.y, w.z, w.time, w.accuracy, w.bearing);
555
+ static fromJson(y) {
556
+ return new e(y.x, y.y, y.z, y.time, y.accuracy, y.bearing);
889
557
  }
890
- }, GeoRelativePosition_default = class extends RelativePosition_default {}, GeoRef_default = class w {
558
+ }, GeoRelativePosition_default = class extends RelativePosition_default {}, GeoRef_default = class y {
891
559
  scale = 1;
892
560
  heading = 0;
893
561
  origin;
894
562
  buildingLevels;
895
- constructor(e, w = []) {
896
- this.origin = e, this.buildingLevels = w;
563
+ constructor(e, y = []) {
564
+ this.origin = e, this.buildingLevels = y;
897
565
  }
898
- localToWorld(w) {
899
- let T = Vector3.multiplyScalar(w, this.scale), E = Quaternion.fromAxisAngle([
566
+ localToWorld(y) {
567
+ let x = Vector3.multiplyScalar(y, this.scale), S = Quaternion.fromAxisAngle([
900
568
  0,
901
569
  0,
902
570
  1
903
- ], this.heading), D = Quaternion.multiply(E, this.origin.enuToEcefRotation), O = Quaternion.rotate(D, T), k = Vector3.sum(this.origin.ecef, O), A = Coordinates_default.fromECEF(k), j = A.alt;
904
- A.heightFromGround = A.alt - this.origin.alt;
905
- let M = (e) => {
906
- A.level = e.id, A.heightFromFloor = j - e.floorAltitude;
571
+ ], this.heading), C = Quaternion.multiply(S, this.origin.enuToEcefRotation), w = Quaternion.rotate(C, x), E = Vector3.sum(this.origin.ecef, w), D = Coordinates_default.fromECEF(E), O = D.alt;
572
+ D.heightFromGround = D.alt - this.origin.alt;
573
+ let k = (e) => {
574
+ D.level = e.id, D.heightFromFloor = O - e.floorAltitude;
907
575
  };
908
- if (!this.buildingLevels.length) return A;
909
- let N = this.buildingLevels.filter((e) => j >= e.floorAltitude && j <= e.ceilingAltitude);
910
- if (!N.length) return A;
911
- let P = N[0], F = [A.lng, A.lat], I = N.filter((e) => e.geometries.length);
912
- if (!I.length) return M(P), A;
913
- let L = I.filter((w) => w.geometries.some((w) => booleanPointInPolygon(F, w)))[0];
914
- return L && M(L), A;
915
- }
916
- worldToLocal(e) {
917
- let w = Quaternion.fromAxisAngle([
576
+ if (!this.buildingLevels.length) return D;
577
+ let A = this.buildingLevels.filter((e) => O >= e.floorAltitude && O <= e.ceilingAltitude);
578
+ if (!A.length) return D;
579
+ let j = A[0], M = [D.lng, D.lat], N = A.filter((e) => e.geometries.length);
580
+ if (!N.length) return k(j), D;
581
+ let P = N.filter((e) => e.geometries.some((e) => booleanPointInPolygon(M, e)))[0];
582
+ return P && k(P), D;
583
+ }
584
+ worldToLocal(y) {
585
+ let x = Quaternion.fromAxisAngle([
918
586
  0,
919
587
  0,
920
588
  1
921
- ], -this.heading), T = Quaternion.multiply(this.origin.ecefToEnuRotation, w), E = Vector3.subtract(e.ecef, this.origin.ecef), D = Vector3.multiplyScalar(E, 1 / this.scale);
922
- return Quaternion.rotate(T, D);
589
+ ], -this.heading), S = Quaternion.multiply(this.origin.ecefToEnuRotation, x), C = Vector3.subtract(y.ecef, this.origin.ecef), w = Vector3.multiplyScalar(C, 1 / this.scale);
590
+ return Quaternion.rotate(S, w);
923
591
  }
924
592
  toJson() {
925
593
  return {
@@ -929,10 +597,10 @@ var BoundingBox_default = class e {
929
597
  };
930
598
  }
931
599
  static fromJson(e) {
932
- let T = new w(Coordinates_default.fromJson(e.origin));
933
- return T.scale = e.scale === void 0 ? 1 : e.scale, T.heading = e.heading === void 0 ? 0 : e.heading, T;
600
+ let b = new y(Coordinates_default.fromJson(e.origin));
601
+ return b.scale = e.scale === void 0 ? 1 : e.scale, b.heading = e.heading === void 0 ? 0 : e.heading, b;
934
602
  }
935
- }, Attitude_default = class e {
603
+ }, Attitude_default = class b {
936
604
  _quaternion = [
937
605
  1,
938
606
  0,
@@ -943,11 +611,11 @@ var BoundingBox_default = class e {
943
611
  _eulerAngles = null;
944
612
  _time = null;
945
613
  _accuracy = null;
946
- constructor(e, w = null, T = null) {
947
- this.quaternion = e, this.time = w, this.accuracy = T;
614
+ constructor(e, y = null, b = null) {
615
+ this.quaternion = e, this.time = y, this.accuracy = b;
948
616
  }
949
617
  static unitary() {
950
- return new e([
618
+ return new b([
951
619
  1,
952
620
  0,
953
621
  0,
@@ -957,9 +625,9 @@ var BoundingBox_default = class e {
957
625
  get quaternion() {
958
626
  return this._quaternion;
959
627
  }
960
- set quaternion(e) {
961
- if (Math.abs(1 - Quaternion.norm(e)) > 1e-4) throw Error("quaternion is not a unit quaternion");
962
- this._quaternion = e, this._heading = null, this._eulerAngles = null;
628
+ set quaternion(y) {
629
+ if (Math.abs(1 - Quaternion.norm(y)) > 1e-4) throw Error("quaternion is not a unit quaternion");
630
+ this._quaternion = y, this._heading = null, this._eulerAngles = null;
963
631
  }
964
632
  get time() {
965
633
  return this._time;
@@ -990,11 +658,11 @@ var BoundingBox_default = class e {
990
658
  get headingDegrees() {
991
659
  return rad2deg(this.heading);
992
660
  }
993
- static equals(w, T) {
994
- return w === null && w === T ? !0 : !(w instanceof e) || !(T instanceof e) ? !1 : w === T ? !0 : Quaternion.equals(w.quaternion, T.quaternion);
661
+ static equals(y, x) {
662
+ return y === null && y === x ? !0 : !(y instanceof b) || !(x instanceof b) ? !1 : y === x ? !0 : Quaternion.equals(y.quaternion, x.quaternion);
995
663
  }
996
- equals(w) {
997
- return e.equals(this, w);
664
+ equals(e) {
665
+ return b.equals(this, e);
998
666
  }
999
667
  toJson() {
1000
668
  return this.time === null && this.accuracy === null ? this.quaternion : {
@@ -1003,24 +671,24 @@ var BoundingBox_default = class e {
1003
671
  ...this.accuracy !== null && { accuracy: this.accuracy }
1004
672
  };
1005
673
  }
1006
- static fromJson(w) {
1007
- return Array.isArray(w) ? new e(w, null, null) : new e(w.q, w.time, w.accuracy);
674
+ static fromJson(e) {
675
+ return Array.isArray(e) ? new b(e, null, null) : new b(e.q, e.time, e.accuracy);
1008
676
  }
1009
677
  clone() {
1010
- return new e(this.quaternion.slice(0), this.time, this.accuracy);
678
+ return new b(this.quaternion.slice(0), this.time, this.accuracy);
1011
679
  }
1012
- static diff(w, T) {
1013
- let E = Quaternion.multiply(Quaternion.inverse(w.quaternion), T.quaternion), D = null;
1014
- T.time !== null && w.time !== null && (D = T.time - w.time);
1015
- let O = null;
1016
- return w.accuracy !== null && T.accuracy !== null && (O = Math.max(T.accuracy - w.accuracy)), new e(E, D, O);
680
+ static diff(y, x) {
681
+ let S = Quaternion.multiply(Quaternion.inverse(y.quaternion), x.quaternion), C = null;
682
+ x.time !== null && y.time !== null && (C = x.time - y.time);
683
+ let w = null;
684
+ return y.accuracy !== null && x.accuracy !== null && (w = Math.max(x.accuracy - y.accuracy)), new b(S, C, w);
1017
685
  }
1018
- }, AbsoluteHeading_default = class e {
686
+ }, AbsoluteHeading_default = class y {
1019
687
  heading;
1020
688
  time = null;
1021
689
  _accuracy = null;
1022
- constructor(e, w = null, T = null) {
1023
- this.heading = e, this.time = w, this.accuracy = T;
690
+ constructor(e, y = null, b = null) {
691
+ this.heading = e, this.time = y, this.accuracy = b;
1024
692
  }
1025
693
  get accuracy() {
1026
694
  return this._accuracy;
@@ -1036,11 +704,11 @@ var BoundingBox_default = class e {
1036
704
  1
1037
705
  ], -this.heading), this.time, this.accuracy);
1038
706
  }
1039
- static equals(w, T) {
1040
- return w === null && w === T ? !0 : !(w instanceof e) || !(T instanceof e) ? !1 : Math.abs(w.heading - T.heading) < 1e-8;
707
+ static equals(e, b) {
708
+ return e === null && e === b ? !0 : !(e instanceof y) || !(b instanceof y) ? !1 : Math.abs(e.heading - b.heading) < 1e-8;
1041
709
  }
1042
- equals(w) {
1043
- return e.equals(this, w);
710
+ equals(e) {
711
+ return y.equals(this, e);
1044
712
  }
1045
713
  toJson() {
1046
714
  return {
@@ -1049,11 +717,11 @@ var BoundingBox_default = class e {
1049
717
  ...this.accuracy !== null && { accuracy: this.accuracy }
1050
718
  };
1051
719
  }
1052
- static fromJson(w) {
1053
- return new e(w.heading, w.time, w.accuracy);
720
+ static fromJson(e) {
721
+ return new y(e.heading, e.time, e.accuracy);
1054
722
  }
1055
723
  clone() {
1056
- return new e(this.heading, this.time, this.accuracy);
724
+ return new y(this.heading, this.time, this.accuracy);
1057
725
  }
1058
726
  };
1059
727
  export { AbsoluteHeading_default as AbsoluteHeading, Attitude_default as Attitude, BoundingBox_default as BoundingBox, Constants_exports as Constants, Coordinates_default as Coordinates, GeoRef_default as GeoRef, GeoRelativePosition_default as GeoRelativePosition, Level_default as Level, RelativePosition_default as RelativePosition, UserPosition_default as UserPosition, Utils_exports as Utils };