@wemap/geo 14.6.0-beta.1 → 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/LICENSE +23 -0
- package/dist/index.js +255 -605
- package/dist/src/coordinates/Coordinates.d.ts +1 -1
- package/dist/src/coordinates/Coordinates.d.ts.map +1 -1
- package/dist/src/coordinates/GeoRef.d.ts +1 -1
- package/dist/src/coordinates/GeoRef.d.ts.map +1 -1
- package/dist/src/rotations/Attitude.d.ts +1 -1
- package/dist/src/rotations/Attitude.d.ts.map +1 -1
- package/dist/src/types.d.ts +1 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/vitest.config.d.ts.map +1 -1
- package/package.json +22 -3
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
|
|
3
|
-
let
|
|
4
|
-
for (var
|
|
5
|
-
get: 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
|
|
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
|
|
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 [
|
|
382
|
-
if (typeof
|
|
383
|
-
if (
|
|
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(
|
|
391
|
-
return e.VERIFY_TYPING && e.checkType(
|
|
40
|
+
static isRange(y) {
|
|
41
|
+
return e.VERIFY_TYPING && e.checkType(y), Array.isArray(y);
|
|
392
42
|
}
|
|
393
|
-
static clone(
|
|
394
|
-
return e.VERIFY_TYPING && e.checkType(
|
|
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(
|
|
397
|
-
if (
|
|
398
|
-
if (typeof
|
|
399
|
-
if (!isNaN(Number(
|
|
400
|
-
let
|
|
401
|
-
if (
|
|
402
|
-
let
|
|
403
|
-
return e.checkType([
|
|
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
|
|
406
|
-
if (
|
|
407
|
-
let
|
|
408
|
-
return e.checkType([
|
|
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: ${
|
|
61
|
+
throw Error(`Cannot parse following level: ${y}`);
|
|
412
62
|
}
|
|
413
|
-
static contains(
|
|
414
|
-
return e.VERIFY_TYPING && (e.checkType(
|
|
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(
|
|
417
|
-
if (e.VERIFY_TYPING && (e.checkType(
|
|
418
|
-
if (e.equals(
|
|
419
|
-
if (typeof
|
|
420
|
-
if (Array.isArray(
|
|
421
|
-
if (!Array.isArray(
|
|
422
|
-
let
|
|
423
|
-
return
|
|
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(
|
|
426
|
-
return e.VERIFY_TYPING && (e.checkType(
|
|
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(
|
|
429
|
-
if (e.VERIFY_TYPING && (e.checkType(
|
|
430
|
-
if (
|
|
431
|
-
let
|
|
432
|
-
return !Array.isArray(
|
|
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(
|
|
435
|
-
return e.VERIFY_TYPING && e.checkType(
|
|
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(
|
|
438
|
-
return e.VERIFY_TYPING && e.checkType(
|
|
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(
|
|
441
|
-
return e.VERIFY_TYPING && (e.checkType(
|
|
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(
|
|
444
|
-
return e.VERIFY_TYPING && (e.checkType(
|
|
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
|
|
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,
|
|
456
|
-
this.lat = e, this.lng =
|
|
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
|
|
510
|
-
return this.level !== null && (
|
|
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,
|
|
516
|
-
return this.equalsWithoutLevel(e,
|
|
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(
|
|
519
|
-
return
|
|
168
|
+
equals(e) {
|
|
169
|
+
return y.equals(this, e);
|
|
520
170
|
}
|
|
521
|
-
static equalsWithoutLevel(
|
|
522
|
-
return
|
|
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(
|
|
525
|
-
return
|
|
174
|
+
equalsWithoutLevel(e, b = EPS_DEG_MM, x = EPS_MM) {
|
|
175
|
+
return y.equalsWithoutLevel(this, e, b, x);
|
|
526
176
|
}
|
|
527
|
-
destinationPoint(e,
|
|
528
|
-
let
|
|
529
|
-
return
|
|
177
|
+
destinationPoint(e, y, b = null) {
|
|
178
|
+
let x = this.clone();
|
|
179
|
+
return x.move(e, y, b), x;
|
|
530
180
|
}
|
|
531
|
-
move(e,
|
|
532
|
-
let
|
|
533
|
-
if (this.lat = rad2deg(
|
|
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 +=
|
|
185
|
+
this.alt += b;
|
|
536
186
|
}
|
|
537
187
|
return this;
|
|
538
188
|
}
|
|
539
189
|
distanceTo(e) {
|
|
540
|
-
let
|
|
541
|
-
return R_MAJOR * (2 * Math.atan2(
|
|
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,
|
|
544
|
-
return e.distanceTo(
|
|
193
|
+
static distanceBetween(e, y) {
|
|
194
|
+
return e.distanceTo(y);
|
|
545
195
|
}
|
|
546
196
|
bearingTo(e) {
|
|
547
|
-
let
|
|
548
|
-
return Math.atan2(Math.sin(
|
|
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,
|
|
551
|
-
return e.bearingTo(
|
|
200
|
+
static bearingTo(e, y) {
|
|
201
|
+
return e.bearingTo(y);
|
|
552
202
|
}
|
|
553
203
|
get enuToEcefRotation() {
|
|
554
|
-
let
|
|
204
|
+
let y = Quaternion.fromAxisAngle([
|
|
555
205
|
0,
|
|
556
206
|
0,
|
|
557
207
|
1
|
|
558
|
-
], Math.PI / 2 + deg2rad(this.lng)),
|
|
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(
|
|
213
|
+
return Quaternion.multiply(y, b);
|
|
564
214
|
}
|
|
565
215
|
get ecefToEnuRotation() {
|
|
566
|
-
let
|
|
216
|
+
let y = Quaternion.fromAxisAngle([
|
|
567
217
|
1,
|
|
568
218
|
0,
|
|
569
219
|
0
|
|
570
|
-
], deg2rad(this.lat) - Math.PI / 2),
|
|
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(
|
|
225
|
+
return Quaternion.multiply(y, b);
|
|
576
226
|
}
|
|
577
227
|
get ecef() {
|
|
578
228
|
if (!this._ecef) {
|
|
579
|
-
let e = deg2rad(this.lat),
|
|
229
|
+
let e = deg2rad(this.lat), y = deg2rad(this.lng), b = this.alt || 0;
|
|
580
230
|
this._ecef = [
|
|
581
|
-
(R_MAJOR +
|
|
582
|
-
(R_MAJOR +
|
|
583
|
-
(R_MAJOR +
|
|
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(
|
|
589
|
-
let
|
|
590
|
-
|
|
591
|
-
let
|
|
592
|
-
return
|
|
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(
|
|
595
|
-
let
|
|
596
|
-
if (Vector3.norm(
|
|
597
|
-
let
|
|
598
|
-
|
|
599
|
-
let
|
|
600
|
-
return Math.abs(
|
|
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(
|
|
615
|
-
return new e
|
|
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(
|
|
625
|
-
let
|
|
626
|
-
return
|
|
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,
|
|
633
|
-
super(e,
|
|
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,
|
|
655
|
-
return super.move(e,
|
|
304
|
+
move(e, y, b = null) {
|
|
305
|
+
return super.move(e, y, b), this;
|
|
656
306
|
}
|
|
657
|
-
destinationPoint(e,
|
|
658
|
-
let
|
|
659
|
-
return
|
|
307
|
+
destinationPoint(e, y, b = null) {
|
|
308
|
+
let x = this.clone();
|
|
309
|
+
return x.move(e, y, b), x;
|
|
660
310
|
}
|
|
661
|
-
static fromCoordinates(
|
|
662
|
-
return new e(
|
|
311
|
+
static fromCoordinates(y) {
|
|
312
|
+
return new e(y.lat, y.lng, y.alt, y.level);
|
|
663
313
|
}
|
|
664
314
|
clone() {
|
|
665
|
-
let
|
|
666
|
-
return
|
|
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(
|
|
669
|
-
return
|
|
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(
|
|
672
|
-
return e.equals(this,
|
|
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(
|
|
683
|
-
let
|
|
684
|
-
return
|
|
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,
|
|
696
|
-
let
|
|
697
|
-
for (let
|
|
698
|
-
let
|
|
699
|
-
if (!
|
|
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
|
-
|
|
351
|
+
T += A;
|
|
702
352
|
continue;
|
|
703
353
|
}
|
|
704
|
-
for (
|
|
705
|
-
let e =
|
|
706
|
-
e.bearing =
|
|
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 (
|
|
709
|
-
let
|
|
710
|
-
|
|
358
|
+
if (T + E > S) break;
|
|
359
|
+
let N = A - M;
|
|
360
|
+
T += N, E -= N;
|
|
711
361
|
}
|
|
712
|
-
return
|
|
362
|
+
return C;
|
|
713
363
|
}
|
|
714
|
-
function trimRoute(e,
|
|
715
|
-
let
|
|
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 (
|
|
718
|
-
let
|
|
719
|
-
if (Coordinates_default.equals(
|
|
720
|
-
|
|
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
|
|
724
|
-
if (
|
|
725
|
-
|
|
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 (!
|
|
730
|
-
for (;
|
|
731
|
-
let
|
|
732
|
-
if (
|
|
733
|
-
let e =
|
|
734
|
-
|
|
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
|
-
|
|
387
|
+
x.push(y), S = y, w += T, C++;
|
|
738
388
|
}
|
|
739
|
-
return
|
|
389
|
+
return x;
|
|
740
390
|
}
|
|
741
|
-
function simplifyRoute(e,
|
|
742
|
-
let
|
|
743
|
-
for (let
|
|
744
|
-
let
|
|
745
|
-
Math.abs(
|
|
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
|
|
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:
|
|
752
|
-
return
|
|
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,
|
|
405
|
+
return e.reduce((e, y, b, x) => e + (b ? x[b - 1].distanceTo(y) : 0), 0);
|
|
756
406
|
}
|
|
757
|
-
function createSegmentsAtLevel(e,
|
|
758
|
-
let
|
|
759
|
-
for (let
|
|
760
|
-
let
|
|
761
|
-
|
|
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
|
|
413
|
+
return C;
|
|
764
414
|
}
|
|
765
|
-
function segmentIntersection(e,
|
|
766
|
-
let
|
|
767
|
-
x: e.lng *
|
|
768
|
-
y: e.lat *
|
|
769
|
-
}),
|
|
770
|
-
if (Math.abs(
|
|
771
|
-
let
|
|
772
|
-
return
|
|
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,
|
|
778
|
-
if (this.northEast = e, this.southWest =
|
|
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(
|
|
787
|
-
let
|
|
788
|
-
if (
|
|
789
|
-
else if (
|
|
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(
|
|
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
|
|
799
|
-
return this.southWest = new Coordinates_default(
|
|
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,
|
|
826
|
-
return Coordinates_default.equals(e.northEast,
|
|
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(
|
|
829
|
-
return e.equals(this,
|
|
478
|
+
equals(y) {
|
|
479
|
+
return e.equals(this, y);
|
|
830
480
|
}
|
|
831
|
-
static fromArray(
|
|
832
|
-
return new e(new Coordinates_default(
|
|
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(
|
|
835
|
-
return
|
|
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,
|
|
853
|
-
this.x = e, this.y =
|
|
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(
|
|
872
|
-
return
|
|
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(
|
|
875
|
-
return e.equals(this,
|
|
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(
|
|
888
|
-
return new e(
|
|
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
|
|
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,
|
|
896
|
-
this.origin = e, this.buildingLevels =
|
|
545
|
+
constructor(e, y = []) {
|
|
546
|
+
this.origin = e, this.buildingLevels = y;
|
|
897
547
|
}
|
|
898
|
-
localToWorld(
|
|
899
|
-
let
|
|
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),
|
|
904
|
-
|
|
905
|
-
let
|
|
906
|
-
|
|
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
|
|
909
|
-
let
|
|
910
|
-
if (!
|
|
911
|
-
let
|
|
912
|
-
if (!
|
|
913
|
-
let
|
|
914
|
-
return
|
|
915
|
-
}
|
|
916
|
-
worldToLocal(
|
|
917
|
-
let
|
|
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),
|
|
922
|
-
return Quaternion.rotate(
|
|
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
|
|
933
|
-
return
|
|
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
|
|
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,
|
|
947
|
-
this.quaternion = e, this.time =
|
|
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
|
|
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(
|
|
961
|
-
if (Math.abs(1 - Quaternion.norm(
|
|
962
|
-
this._quaternion =
|
|
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(
|
|
994
|
-
return
|
|
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(
|
|
997
|
-
return
|
|
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(
|
|
1007
|
-
return Array.isArray(
|
|
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
|
|
660
|
+
return new b(this.quaternion.slice(0), this.time, this.accuracy);
|
|
1011
661
|
}
|
|
1012
|
-
static diff(
|
|
1013
|
-
let
|
|
1014
|
-
|
|
1015
|
-
let
|
|
1016
|
-
return
|
|
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
|
|
668
|
+
}, AbsoluteHeading_default = class y {
|
|
1019
669
|
heading;
|
|
1020
670
|
time = null;
|
|
1021
671
|
_accuracy = null;
|
|
1022
|
-
constructor(e,
|
|
1023
|
-
this.heading = e, this.time =
|
|
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(
|
|
1040
|
-
return
|
|
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(
|
|
1043
|
-
return
|
|
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(
|
|
1053
|
-
return new e
|
|
702
|
+
static fromJson(e) {
|
|
703
|
+
return new y(e.heading, e.time, e.accuracy);
|
|
1054
704
|
}
|
|
1055
705
|
clone() {
|
|
1056
|
-
return new
|
|
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 };
|