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