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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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,77 @@ 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);
40
+ static isRange(y) {
41
+ return e.VERIFY_TYPING && e.checkType(y), Array.isArray(y);
392
42
  }
393
- static clone(w) {
394
- return e.VERIFY_TYPING && e.checkType(w), w === null ? null : typeof w == "number" ? w : [w[0], w[1]];
43
+ static clone(y) {
44
+ return e.VERIFY_TYPING && e.checkType(y), y === null ? null : typeof y == "number" ? y : [y[0], y[1]];
395
45
  }
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];
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 = y.split(";");
51
+ if (b.length > 1) {
52
+ let y = b.map((e) => Number(e)), x = Math.min(...y), S = Math.max(...y);
53
+ return e.checkType([x, S]), [x, S];
404
54
  } 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];
55
+ let b = y.substring(1).indexOf("-") + 1;
56
+ if (b > 0) {
57
+ let x = Number(y.substring(0, b)), S = Number(y.substring(b + 1));
58
+ return e.checkType([x, S]), [x, S];
409
59
  }
410
60
  }
411
- throw Error(`Cannot parse following level: ${w}`);
61
+ throw Error(`Cannot parse following level: ${y}`);
412
62
  }
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];
63
+ static contains(y, b) {
64
+ 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
65
  }
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];
66
+ static intersection(y, b) {
67
+ if (e.VERIFY_TYPING && (e.checkType(y), e.checkType(b)), y === null || b === null) return null;
68
+ if (e.equals(y, b)) return e.clone(y);
69
+ if (typeof y == "number" && typeof b == "number") return y === b ? y : null;
70
+ if (Array.isArray(y) && !Array.isArray(b)) return e.contains(y, b) ? b : null;
71
+ if (!Array.isArray(y) && Array.isArray(b)) return e.contains(b, y) ? y : null;
72
+ let x = Math.max(y[0], b[0]), S = Math.min(y[1], b[1]);
73
+ return S === x ? S : S < x ? null : [x, S];
424
74
  }
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;
75
+ static intersect(y, b) {
76
+ return e.VERIFY_TYPING && (e.checkType(y), e.checkType(b)), y === null && b === null ? !0 : e.intersection(y, b) !== null;
427
77
  }
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];
78
+ static union(y, b) {
79
+ if (e.VERIFY_TYPING && (e.checkType(y), e.checkType(b)), y === b) return e.clone(y);
80
+ if (b === null || y === null) return null;
81
+ let x, S;
82
+ 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
83
  }
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;
84
+ static multiplyBy(y, b) {
85
+ return e.VERIFY_TYPING && e.checkType(y), y === null ? null : Array.isArray(y) ? [y[0] * b, y[1] * b] : y * b;
436
86
  }
437
- static toString(w) {
438
- return e.VERIFY_TYPING && e.checkType(w), w === null ? null : Array.isArray(w) ? w[0] + ";" + w[1] : String(w);
87
+ static toString(y) {
88
+ return e.VERIFY_TYPING && e.checkType(y), y === null ? null : Array.isArray(y) ? y[0] + ";" + y[1] : String(y);
439
89
  }
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;
90
+ static equals(y, b) {
91
+ 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
92
  }
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;
93
+ static diff(y, b) {
94
+ 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
95
  }
446
- }, Coordinates_default = class e {
96
+ }, Coordinates_default = class y {
447
97
  _lat;
448
98
  _lng;
449
99
  _alt = null;
@@ -452,8 +102,8 @@ var Rotations = class e {
452
102
  _heightFromGround = null;
453
103
  _ecef;
454
104
  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;
105
+ constructor(e, y, b = null, x = null) {
106
+ this.lat = e, this.lng = y, this.alt = b, this.level = x, this._ecef = null;
457
107
  }
458
108
  get lat() {
459
109
  return this._lat;
@@ -506,98 +156,98 @@ var Rotations = class e {
506
156
  this._heightFromGround = e;
507
157
  }
508
158
  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;
159
+ let e = new y(this.lat, this.lng, this.alt);
160
+ return this.level !== null && (e.level = Level_default.clone(this.level)), e;
511
161
  }
512
162
  wrap() {
513
163
  (this._lng <= -180 || this._lng > 180) && (this._lng = wrap(this._lng, -180, 180));
514
164
  }
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;
165
+ static equals(e, y, b = EPS_DEG_MM, x = EPS_MM) {
166
+ return this.equalsWithoutLevel(e, y, b, x) ? e === null || y === null ? !0 : Level_default.equals(e.level, y.level) : !1;
517
167
  }
518
- equals(w) {
519
- return e.equals(this, w);
168
+ equals(e) {
169
+ return y.equals(this, e);
520
170
  }
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);
171
+ static equalsWithoutLevel(e, b, x = EPS_DEG_MM, S = EPS_MM) {
172
+ 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
173
  }
524
- equalsWithoutLevel(w, T = EPS_DEG_MM, E = EPS_MM) {
525
- return e.equalsWithoutLevel(this, w, T, E);
174
+ equalsWithoutLevel(e, b = EPS_DEG_MM, x = EPS_MM) {
175
+ return y.equalsWithoutLevel(this, e, b, x);
526
176
  }
527
- destinationPoint(e, w, T = null) {
528
- let E = this.clone();
529
- return E.move(e, w, T), E;
177
+ destinationPoint(e, y, b = null) {
178
+ let x = this.clone();
179
+ return x.move(e, y, b), x;
530
180
  }
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) {
181
+ move(e, y, b = null) {
182
+ 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));
183
+ if (this.lat = rad2deg(O), this.lng = rad2deg(A), b !== null) {
534
184
  if (this.alt === null) throw Error("Point altitude is not defined");
535
- this.alt += T;
185
+ this.alt += b;
536
186
  }
537
187
  return this;
538
188
  }
539
189
  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));
190
+ 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);
191
+ return R_MAJOR * (2 * Math.atan2(P, F));
542
192
  }
543
- static distanceBetween(e, w) {
544
- return e.distanceTo(w);
193
+ static distanceBetween(e, y) {
194
+ return e.distanceTo(y);
545
195
  }
546
196
  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));
197
+ let y = deg2rad(this.lat), b = deg2rad(e.lat), S = deg2rad(e.lng - this.lng);
198
+ 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
199
  }
550
- static bearingTo(e, w) {
551
- return e.bearingTo(w);
200
+ static bearingTo(e, y) {
201
+ return e.bearingTo(y);
552
202
  }
553
203
  get enuToEcefRotation() {
554
- let e = Quaternion.fromAxisAngle([
204
+ let y = Quaternion.fromAxisAngle([
555
205
  0,
556
206
  0,
557
207
  1
558
- ], Math.PI / 2 + deg2rad(this.lng)), w = Quaternion.fromAxisAngle([
208
+ ], Math.PI / 2 + deg2rad(this.lng)), b = Quaternion.fromAxisAngle([
559
209
  1,
560
210
  0,
561
211
  0
562
212
  ], Math.PI / 2 - deg2rad(this.lat));
563
- return Quaternion.multiply(e, w);
213
+ return Quaternion.multiply(y, b);
564
214
  }
565
215
  get ecefToEnuRotation() {
566
- let e = Quaternion.fromAxisAngle([
216
+ let y = Quaternion.fromAxisAngle([
567
217
  1,
568
218
  0,
569
219
  0
570
- ], deg2rad(this.lat) - Math.PI / 2), w = Quaternion.fromAxisAngle([
220
+ ], deg2rad(this.lat) - Math.PI / 2), b = Quaternion.fromAxisAngle([
571
221
  0,
572
222
  0,
573
223
  1
574
224
  ], -deg2rad(this.lng) - Math.PI / 2);
575
- return Quaternion.multiply(e, w);
225
+ return Quaternion.multiply(y, b);
576
226
  }
577
227
  get ecef() {
578
228
  if (!this._ecef) {
579
- let e = deg2rad(this.lat), w = deg2rad(this.lng), T = this.alt || 0;
229
+ let e = deg2rad(this.lat), y = deg2rad(this.lng), b = this.alt || 0;
580
230
  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)
231
+ (R_MAJOR + b) * Math.cos(e) * Math.cos(y),
232
+ (R_MAJOR + b) * Math.cos(e) * Math.sin(y),
233
+ (R_MAJOR + b) * Math.sin(e)
584
234
  ];
585
235
  }
586
236
  return this._ecef;
587
237
  }
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;
238
+ static fromECEF(e) {
239
+ 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;
240
+ T %= 2 * Math.PI;
241
+ let O = new y(rad2deg(E), rad2deg(T), D);
242
+ return O._ecef = e, O;
593
243
  }
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;
244
+ getSegmentProjection(e, x) {
245
+ let S = Vector3.normalize(e.ecef), C = Vector3.normalize(x.ecef), w = Vector3.normalize(this.ecef), T = Vector3.cross(S, C);
246
+ if (Vector3.norm(T) === 0) return null;
247
+ let E = Vector3.cross(w, T), D = Vector3.normalize(Vector3.cross(T, E)), O = Vector3.multiplyScalar(D, R_MAJOR), A = y.fromECEF(O), j;
248
+ e.alt !== null && x.alt !== null && (j = (e.alt + x.alt) / 2);
249
+ let M = new y(A.lat, A.lng, j, Level_default.union(e.level, x.level));
250
+ return Math.abs(e.distanceTo(x) - e.distanceTo(M) - x.distanceTo(M)) > .001 ? null : M;
601
251
  }
602
252
  toString() {
603
253
  let e = "[" + this._lat.toFixed(7) + ", " + this._lng.toFixed(7);
@@ -611,8 +261,8 @@ var Rotations = class e {
611
261
  ...this.level !== null && { level: this.level }
612
262
  };
613
263
  }
614
- static fromJson(w) {
615
- return new e(w.lat, w.lng, w.alt, w.level);
264
+ static fromJson(e) {
265
+ return new y(e.lat, e.lng, e.alt, e.level);
616
266
  }
617
267
  toCompressedJson() {
618
268
  return this.level === null ? [Number(this.lat.toFixed(8)), Number(this.lng.toFixed(8))] : [
@@ -621,16 +271,16 @@ var Rotations = class e {
621
271
  this.level
622
272
  ];
623
273
  }
624
- static fromCompressedJson(w) {
625
- let T = new e(w[0], w[1]);
626
- return w.length > 2 && (T.level = w[2]), T;
274
+ static fromCompressedJson(e) {
275
+ let b = new y(e[0], e[1]);
276
+ return e.length > 2 && (b.level = e[2]), b;
627
277
  }
628
278
  }, UserPosition_default = class e extends Coordinates_default {
629
279
  _time = null;
630
280
  _accuracy = null;
631
281
  _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;
282
+ constructor(e, y, b = null, x = null, S = null, C = null, w = null) {
283
+ super(e, y, b, x), this.time = S, this.accuracy = C, this.bearing = w;
634
284
  }
635
285
  get time() {
636
286
  return this._time;
@@ -651,25 +301,25 @@ var Rotations = class e {
651
301
  set bearing(e) {
652
302
  this._bearing = e === null ? null : e % (2 * Math.PI);
653
303
  }
654
- move(e, w, T = null) {
655
- return super.move(e, w, T), this;
304
+ move(e, y, b = null) {
305
+ return super.move(e, y, b), this;
656
306
  }
657
- destinationPoint(e, w, T = null) {
658
- let E = this.clone();
659
- return E.move(e, w, T), E;
307
+ destinationPoint(e, y, b = null) {
308
+ let x = this.clone();
309
+ return x.move(e, y, b), x;
660
310
  }
661
- static fromCoordinates(w) {
662
- return new e(w.lat, w.lng, w.alt, w.level);
311
+ static fromCoordinates(y) {
312
+ return new e(y.lat, y.lng, y.alt, y.level);
663
313
  }
664
314
  clone() {
665
- let w = e.fromCoordinates(super.clone());
666
- return w.time = this.time, w.accuracy = this.accuracy, w.bearing = this.bearing, w;
315
+ let y = e.fromCoordinates(super.clone());
316
+ return y.time = this.time, y.accuracy = this.accuracy, y.bearing = this.bearing, y;
667
317
  }
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;
318
+ static equals(y, b, x = EPS_DEG_MM, S = EPS_MM) {
319
+ 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
320
  }
671
- equals(w, T = EPS_DEG_MM, E = EPS_MM) {
672
- return e.equals(this, w, T, E);
321
+ equals(y, b = EPS_DEG_MM, x = EPS_MM) {
322
+ return e.equals(this, y, b, x);
673
323
  }
674
324
  toJson() {
675
325
  return {
@@ -679,9 +329,9 @@ var Rotations = class e {
679
329
  ...this.bearing !== null && { bearing: this.bearing }
680
330
  };
681
331
  }
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;
332
+ static fromJson(y) {
333
+ let b = e.fromCoordinates(Coordinates_default.fromJson(y));
334
+ 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
335
  }
686
336
  }, Utils_exports = /* @__PURE__ */ __export({
687
337
  calcDistance: () => calcDistance,
@@ -692,90 +342,90 @@ var Rotations = class e {
692
342
  simplifyRoute: () => simplifyRoute,
693
343
  trimRoute: () => trimRoute
694
344
  });
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;
345
+ function sampleRoute(e, y = .7, b = 0, x = Number.MAX_VALUE) {
346
+ let S = b + x, C = [], w, T = 0, E = 0, D = !1;
347
+ for (let x = 0; x < e.length - 1; x++) {
348
+ let O = e[x], k = e[x + 1], A = O.distanceTo(k), j = O.bearingTo(k), M = 0;
349
+ if (!D) if (b < T + A) D = !0, E = b - T;
700
350
  else {
701
- A += F;
351
+ T += A;
702
352
  continue;
703
353
  }
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;
354
+ for (w = Object.assign(O.clone(), { bearing: j }); M + E < A && T + E <= S;) {
355
+ let e = w.destinationPoint(E, j);
356
+ e.bearing = j, C.push(e), w = e, M += E, T += E, E = y;
707
357
  }
708
- if (A + j > D) break;
709
- let R = F - L;
710
- A += R, j -= R;
358
+ if (T + E > S) break;
359
+ let N = A - M;
360
+ T += N, E -= N;
711
361
  }
712
- return O;
362
+ return C;
713
363
  }
714
- function trimRoute(e, w = e[0], T = Number.MAX_VALUE) {
715
- let E = [], D = null, O, k = 0;
364
+ function trimRoute(e, y = e[0], b = Number.MAX_VALUE) {
365
+ let x = [], S = null, C, w = 0;
716
366
  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;
367
+ for (C = 1; C < e.length; C++) {
368
+ let b = e[C - 1], w = e[C];
369
+ if (Coordinates_default.equals(y, b)) {
370
+ x.push(b), S = b;
721
371
  break;
722
372
  }
723
- let A = w.getSegmentProjection(T, k);
724
- if (A && Coordinates_default.equals(w, A) && !A.equals(k)) {
725
- E.push(A), D = A;
373
+ let T = y.getSegmentProjection(b, w);
374
+ if (T && Coordinates_default.equals(y, T) && !T.equals(w)) {
375
+ x.push(T), S = T;
726
376
  break;
727
377
  }
728
378
  }
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);
379
+ if (!x.length) throw Error("startPosition is not on the route");
380
+ for (; S && C < e.length;) {
381
+ let y = e[C], T = S.distanceTo(y);
382
+ if (w + T >= b || Math.abs(w + T - b) <= .001) {
383
+ let e = S.bearingTo(y), C = b - w, T = S.destinationPoint(C, e);
384
+ x.push(T);
735
385
  break;
736
386
  }
737
- E.push(w), D = w, k += A, O++;
387
+ x.push(y), S = y, w += T, C++;
738
388
  }
739
- return E;
389
+ return x;
740
390
  }
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));
391
+ function simplifyRoute(e, y = deg2rad(5)) {
392
+ let b = e[0].equals(e[e.length - 1]), C = e.slice(0, e.length - (b ? 1 : 0)), w = C.length;
393
+ for (let x = b ? 0 : 1; x < w; x++) {
394
+ let b = e[positiveMod(x - 1, w)], T = e[x], E = e[positiveMod(x + 1, w)], D = b.bearingTo(T), O = T.bearingTo(E);
395
+ Math.abs(O - D) < y && (C = C.filter((e) => e !== T));
746
396
  }
747
- return T && E.push(E[0]), E;
397
+ return b && C.push(C[0]), C;
748
398
  }
749
399
  function geolocationPositionToUserPosition(e) {
750
400
  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;
401
+ let { latitude: y, longitude: b, accuracy: S, heading: C } = e.coords, w = new UserPosition_default(y, b);
402
+ return w.time = e.timestamp, w.accuracy = S, w.bearing = C ? deg2rad(C) : null, w;
753
403
  }
754
404
  function calcDistance(e) {
755
- return e.reduce((e, w, T, E) => e + (T ? E[T - 1].distanceTo(w) : 0), 0);
405
+ return e.reduce((e, y, b, x) => e + (b ? x[b - 1].distanceTo(y) : 0), 0);
756
406
  }
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;
407
+ function createSegmentsAtLevel(e, y, b = !0) {
408
+ let x = e.length, S = !1, C = [], w = [];
409
+ for (let T = 0; T < x; T++) {
410
+ let x = e[T], E = Level_default.intersect(y, x.level);
411
+ 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
412
  }
763
- return O;
413
+ return C;
764
414
  }
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);
415
+ function segmentIntersection(e, y, b, x) {
416
+ 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) => ({
417
+ x: e.lng * T,
418
+ y: e.lat * w
419
+ }), 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;
420
+ if (Math.abs(I) < 1e-10) return null;
421
+ let L = A.x - D.x, R = A.y - D.y, z = (L * F - R * P) / I, B = (L * N - R * M) / I;
422
+ return z < 0 || z > 1 || B < 0 || B > 1 ? null : new Coordinates_default((D.y + z * N) / w, (D.x + z * M) / T);
773
423
  }
774
424
  var BoundingBox_default = class e {
775
425
  northEast;
776
426
  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");
427
+ constructor(e, y) {
428
+ if (this.northEast = e, this.southWest = y, this.northEast && this.southWest && this.getNorth() < this.getSouth()) throw Error("Incorrect bounding box");
779
429
  }
780
430
  get center() {
781
431
  return new Coordinates_default((this.southWest.lat + this.northEast.lat) / 2, (this.northEast.lng + this.southWest.lng) / 2);
@@ -783,20 +433,20 @@ var BoundingBox_default = class e {
783
433
  contains(e) {
784
434
  return e.lat <= this.northEast.lat && e.lat >= this.southWest.lat && e.lng <= this.northEast.lng && e.lng >= this.southWest.lng;
785
435
  }
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;
436
+ extend(y) {
437
+ let b = this.southWest, x = this.northEast, S, C;
438
+ if (y instanceof Coordinates_default) S = y, C = y;
439
+ else if (y instanceof e) S = y.southWest, C = y.northEast;
790
440
  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;
441
+ 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
442
  }
793
443
  extendsWithMeasure(e) {
794
444
  if (typeof e != "number") throw Error("measure is not a number");
795
445
  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
446
  }
797
447
  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;
448
+ let y = this.southWest, b = this.northEast, x = Math.abs(y.lat - b.lat) * e, S = Math.abs(y.lng - b.lng) * e;
449
+ 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
450
  }
801
451
  getSouthWest() {
802
452
  return this.southWest;
@@ -822,17 +472,17 @@ var BoundingBox_default = class e {
822
472
  getNorth() {
823
473
  return this.northEast.lat;
824
474
  }
825
- static equals(e, w) {
826
- return Coordinates_default.equals(e.northEast, w.northEast) && Coordinates_default.equals(e.southWest, w.southWest);
475
+ static equals(e, y) {
476
+ return Coordinates_default.equals(e.northEast, y.northEast) && Coordinates_default.equals(e.southWest, y.southWest);
827
477
  }
828
- equals(w) {
829
- return e.equals(this, w);
478
+ equals(y) {
479
+ return e.equals(this, y);
830
480
  }
831
- static fromArray(w) {
832
- return new e(new Coordinates_default(w[3], w[2]), new Coordinates_default(w[1], w[0]));
481
+ static fromArray(y) {
482
+ return new e(new Coordinates_default(y[3], y[2]), new Coordinates_default(y[1], y[0]));
833
483
  }
834
- static fromCoordinates(w) {
835
- return w.length === 0 ? null : w.reduce((e, w) => e.extend(w), new e(w[0], w[0]));
484
+ static fromCoordinates(y) {
485
+ return y.length === 0 ? null : y.reduce((e, y) => e.extend(y), new e(y[0], y[0]));
836
486
  }
837
487
  toArray() {
838
488
  return [
@@ -849,8 +499,8 @@ var BoundingBox_default = class e {
849
499
  time = null;
850
500
  _accuracy = null;
851
501
  _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;
502
+ constructor(e, y, b, x = null, S = null, C = null) {
503
+ this.x = e, this.y = y, this.z = b, this.time = x, this.accuracy = S, this.bearing = C;
854
504
  }
855
505
  get accuracy() {
856
506
  return this._accuracy;
@@ -868,11 +518,11 @@ var BoundingBox_default = class e {
868
518
  clone() {
869
519
  return new e(this.x, this.y, this.z, this.time, this.accuracy, this.bearing);
870
520
  }
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;
521
+ static equals(y, b, x = EPS_MM) {
522
+ 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
523
  }
874
- equals(w) {
875
- return e.equals(this, w);
524
+ equals(y) {
525
+ return e.equals(this, y);
876
526
  }
877
527
  toJson() {
878
528
  return {
@@ -884,42 +534,42 @@ var BoundingBox_default = class e {
884
534
  ...this.bearing !== null && { bearing: this.bearing }
885
535
  };
886
536
  }
887
- static fromJson(w) {
888
- return new e(w.x, w.y, w.z, w.time, w.accuracy, w.bearing);
537
+ static fromJson(y) {
538
+ return new e(y.x, y.y, y.z, y.time, y.accuracy, y.bearing);
889
539
  }
890
- }, GeoRelativePosition_default = class extends RelativePosition_default {}, GeoRef_default = class w {
540
+ }, GeoRelativePosition_default = class extends RelativePosition_default {}, GeoRef_default = class y {
891
541
  scale = 1;
892
542
  heading = 0;
893
543
  origin;
894
544
  buildingLevels;
895
- constructor(e, w = []) {
896
- this.origin = e, this.buildingLevels = w;
545
+ constructor(e, y = []) {
546
+ this.origin = e, this.buildingLevels = y;
897
547
  }
898
- localToWorld(w) {
899
- let T = Vector3.multiplyScalar(w, this.scale), E = Quaternion.fromAxisAngle([
548
+ localToWorld(y) {
549
+ let x = Vector3.multiplyScalar(y, this.scale), S = Quaternion.fromAxisAngle([
900
550
  0,
901
551
  0,
902
552
  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;
553
+ ], 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;
554
+ D.heightFromGround = D.alt - this.origin.alt;
555
+ let k = (e) => {
556
+ D.level = e.id, D.heightFromFloor = O - e.floorAltitude;
907
557
  };
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([
558
+ if (!this.buildingLevels.length) return D;
559
+ let A = this.buildingLevels.filter((e) => O >= e.floorAltitude && O <= e.ceilingAltitude);
560
+ if (!A.length) return D;
561
+ let j = A[0], M = [D.lng, D.lat], N = A.filter((e) => e.geometries.length);
562
+ if (!N.length) return k(j), D;
563
+ let P = N.filter((e) => e.geometries.some((e) => booleanPointInPolygon(M, e)))[0];
564
+ return P && k(P), D;
565
+ }
566
+ worldToLocal(y) {
567
+ let x = Quaternion.fromAxisAngle([
918
568
  0,
919
569
  0,
920
570
  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);
571
+ ], -this.heading), S = Quaternion.multiply(this.origin.ecefToEnuRotation, x), C = Vector3.subtract(y.ecef, this.origin.ecef), w = Vector3.multiplyScalar(C, 1 / this.scale);
572
+ return Quaternion.rotate(S, w);
923
573
  }
924
574
  toJson() {
925
575
  return {
@@ -929,10 +579,10 @@ var BoundingBox_default = class e {
929
579
  };
930
580
  }
931
581
  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;
582
+ let b = new y(Coordinates_default.fromJson(e.origin));
583
+ return b.scale = e.scale === void 0 ? 1 : e.scale, b.heading = e.heading === void 0 ? 0 : e.heading, b;
934
584
  }
935
- }, Attitude_default = class e {
585
+ }, Attitude_default = class b {
936
586
  _quaternion = [
937
587
  1,
938
588
  0,
@@ -943,11 +593,11 @@ var BoundingBox_default = class e {
943
593
  _eulerAngles = null;
944
594
  _time = null;
945
595
  _accuracy = null;
946
- constructor(e, w = null, T = null) {
947
- this.quaternion = e, this.time = w, this.accuracy = T;
596
+ constructor(e, y = null, b = null) {
597
+ this.quaternion = e, this.time = y, this.accuracy = b;
948
598
  }
949
599
  static unitary() {
950
- return new e([
600
+ return new b([
951
601
  1,
952
602
  0,
953
603
  0,
@@ -957,9 +607,9 @@ var BoundingBox_default = class e {
957
607
  get quaternion() {
958
608
  return this._quaternion;
959
609
  }
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;
610
+ set quaternion(y) {
611
+ if (Math.abs(1 - Quaternion.norm(y)) > 1e-4) throw Error("quaternion is not a unit quaternion");
612
+ this._quaternion = y, this._heading = null, this._eulerAngles = null;
963
613
  }
964
614
  get time() {
965
615
  return this._time;
@@ -990,11 +640,11 @@ var BoundingBox_default = class e {
990
640
  get headingDegrees() {
991
641
  return rad2deg(this.heading);
992
642
  }
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);
643
+ static equals(y, x) {
644
+ return y === null && y === x ? !0 : !(y instanceof b) || !(x instanceof b) ? !1 : y === x ? !0 : Quaternion.equals(y.quaternion, x.quaternion);
995
645
  }
996
- equals(w) {
997
- return e.equals(this, w);
646
+ equals(e) {
647
+ return b.equals(this, e);
998
648
  }
999
649
  toJson() {
1000
650
  return this.time === null && this.accuracy === null ? this.quaternion : {
@@ -1003,24 +653,24 @@ var BoundingBox_default = class e {
1003
653
  ...this.accuracy !== null && { accuracy: this.accuracy }
1004
654
  };
1005
655
  }
1006
- static fromJson(w) {
1007
- return Array.isArray(w) ? new e(w, null, null) : new e(w.q, w.time, w.accuracy);
656
+ static fromJson(e) {
657
+ return Array.isArray(e) ? new b(e, null, null) : new b(e.q, e.time, e.accuracy);
1008
658
  }
1009
659
  clone() {
1010
- return new e(this.quaternion.slice(0), this.time, this.accuracy);
660
+ return new b(this.quaternion.slice(0), this.time, this.accuracy);
1011
661
  }
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);
662
+ static diff(y, x) {
663
+ let S = Quaternion.multiply(Quaternion.inverse(y.quaternion), x.quaternion), C = null;
664
+ x.time !== null && y.time !== null && (C = x.time - y.time);
665
+ let w = null;
666
+ return y.accuracy !== null && x.accuracy !== null && (w = Math.max(x.accuracy - y.accuracy)), new b(S, C, w);
1017
667
  }
1018
- }, AbsoluteHeading_default = class e {
668
+ }, AbsoluteHeading_default = class y {
1019
669
  heading;
1020
670
  time = null;
1021
671
  _accuracy = null;
1022
- constructor(e, w = null, T = null) {
1023
- this.heading = e, this.time = w, this.accuracy = T;
672
+ constructor(e, y = null, b = null) {
673
+ this.heading = e, this.time = y, this.accuracy = b;
1024
674
  }
1025
675
  get accuracy() {
1026
676
  return this._accuracy;
@@ -1036,11 +686,11 @@ var BoundingBox_default = class e {
1036
686
  1
1037
687
  ], -this.heading), this.time, this.accuracy);
1038
688
  }
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;
689
+ static equals(e, b) {
690
+ return e === null && e === b ? !0 : !(e instanceof y) || !(b instanceof y) ? !1 : Math.abs(e.heading - b.heading) < 1e-8;
1041
691
  }
1042
- equals(w) {
1043
- return e.equals(this, w);
692
+ equals(e) {
693
+ return y.equals(this, e);
1044
694
  }
1045
695
  toJson() {
1046
696
  return {
@@ -1049,11 +699,11 @@ var BoundingBox_default = class e {
1049
699
  ...this.accuracy !== null && { accuracy: this.accuracy }
1050
700
  };
1051
701
  }
1052
- static fromJson(w) {
1053
- return new e(w.heading, w.time, w.accuracy);
702
+ static fromJson(e) {
703
+ return new y(e.heading, e.time, e.accuracy);
1054
704
  }
1055
705
  clone() {
1056
- return new e(this.heading, this.time, this.accuracy);
706
+ return new y(this.heading, this.time, this.accuracy);
1057
707
  }
1058
708
  };
1059
709
  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 };