@wemap/geo 14.6.0-beta.4 → 14.6.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 +312 -310
- package/package.json +3 -3
- package/dist/vitest.config.d.ts +0 -3
- package/dist/vitest.config.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,117 +1,116 @@
|
|
|
1
|
-
import { Quaternion, Rotations, Vector3, deg2rad, positiveMod, rad2deg, wrap } from "@wemap/maths";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { Quaternion as e, Rotations as t, Vector3 as n, deg2rad as r, positiveMod as i, rad2deg as a, wrap as o } from "@wemap/maths";
|
|
2
|
+
import s from "@turf/boolean-point-in-polygon";
|
|
3
|
+
//#region \0rolldown/runtime.js
|
|
4
|
+
var c = Object.defineProperty, l = (e, t) => {
|
|
5
|
+
let n = {};
|
|
6
|
+
for (var r in e) c(n, r, {
|
|
7
|
+
get: e[r],
|
|
7
8
|
enumerable: !0
|
|
8
9
|
});
|
|
9
|
-
return
|
|
10
|
-
},
|
|
11
|
-
CIRCUMFERENCE: () =>
|
|
12
|
-
EARTH_GRAVITY: () =>
|
|
13
|
-
ECCENTRICITY: () =>
|
|
14
|
-
ECCENTRICITY_2: () =>
|
|
15
|
-
ELLIPSOID_FLATNESS: () =>
|
|
16
|
-
EPS_DEG_MM: () =>
|
|
17
|
-
EPS_MM: () =>
|
|
18
|
-
R_MAJOR: () =>
|
|
19
|
-
R_MAJOR_2: () =>
|
|
20
|
-
R_MAJOR_4: () =>
|
|
21
|
-
R_MINOR: () =>
|
|
22
|
-
R_MINOR_2: () =>
|
|
23
|
-
R_MINOR_4: () =>
|
|
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;
|
|
26
|
-
var Level_default = class e {
|
|
10
|
+
return t || c(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
11
|
+
}, u = /* @__PURE__ */ l({
|
|
12
|
+
CIRCUMFERENCE: () => C,
|
|
13
|
+
EARTH_GRAVITY: () => p,
|
|
14
|
+
ECCENTRICITY: () => _,
|
|
15
|
+
ECCENTRICITY_2: () => v,
|
|
16
|
+
ELLIPSOID_FLATNESS: () => g,
|
|
17
|
+
EPS_DEG_MM: () => m,
|
|
18
|
+
EPS_MM: () => h,
|
|
19
|
+
R_MAJOR: () => d,
|
|
20
|
+
R_MAJOR_2: () => y,
|
|
21
|
+
R_MAJOR_4: () => b,
|
|
22
|
+
R_MINOR: () => f,
|
|
23
|
+
R_MINOR_2: () => x,
|
|
24
|
+
R_MINOR_4: () => S
|
|
25
|
+
}), d = 6378137, f = 6356752.3142, p = 9.80665, m = 1e-8, h = .001, g = (d - f) / d, _ = Math.sqrt(g * (2 - g)), v = _ * _, y = d * d, b = y * y, x = f * f, S = x * x, C = d * 2 * Math.PI, w = class e {
|
|
27
26
|
static VERIFY_TYPING = !1;
|
|
28
27
|
static checkType(e) {
|
|
29
28
|
if (e !== null && !(typeof e == "number" && !isNaN(e))) {
|
|
30
29
|
if (Array.isArray(e) && e.length === 2) {
|
|
31
|
-
let [
|
|
32
|
-
if (typeof
|
|
33
|
-
if (
|
|
30
|
+
let [t, n] = e;
|
|
31
|
+
if (typeof t == "number" && !isNaN(t) && typeof n == "number" && !isNaN(n)) {
|
|
32
|
+
if (t > n || t === n) throw Error(`Invalid level range: [${t}, ${n}]`);
|
|
34
33
|
return;
|
|
35
34
|
}
|
|
36
35
|
}
|
|
37
36
|
throw Error(`Unknown level format: ${e}`);
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
|
-
static isRange(
|
|
41
|
-
return e.VERIFY_TYPING && e.checkType(
|
|
42
|
-
}
|
|
43
|
-
static clone(
|
|
44
|
-
return e.VERIFY_TYPING && e.checkType(
|
|
45
|
-
}
|
|
46
|
-
static fromString(
|
|
47
|
-
if (
|
|
48
|
-
if (typeof
|
|
49
|
-
if (!isNaN(Number(
|
|
50
|
-
let
|
|
51
|
-
let
|
|
52
|
-
if (
|
|
53
|
-
return
|
|
54
|
-
},
|
|
55
|
-
if (
|
|
56
|
-
let
|
|
57
|
-
return e.checkType([
|
|
39
|
+
static isRange(t) {
|
|
40
|
+
return e.VERIFY_TYPING && e.checkType(t), Array.isArray(t);
|
|
41
|
+
}
|
|
42
|
+
static clone(t) {
|
|
43
|
+
return e.VERIFY_TYPING && e.checkType(t), t === null ? null : typeof t == "number" ? t : [t[0], t[1]];
|
|
44
|
+
}
|
|
45
|
+
static fromString(t) {
|
|
46
|
+
if (t === null) return null;
|
|
47
|
+
if (typeof t != "string" || !t.length) throw Error(`argument must be a non empty string, got ${typeof t}`);
|
|
48
|
+
if (!isNaN(Number(t))) return parseFloat(t);
|
|
49
|
+
let n = (e) => {
|
|
50
|
+
let n = e.map((e) => Number(e));
|
|
51
|
+
if (n.some((e) => Number.isNaN(e)) || e.some((e) => !e.length)) throw Error(`Cannot parse following level: ${t}`);
|
|
52
|
+
return n;
|
|
53
|
+
}, r = t.split(";");
|
|
54
|
+
if (r.length > 1) {
|
|
55
|
+
let t = n(r), i = Math.min(...t), a = Math.max(...t);
|
|
56
|
+
return e.checkType([i, a]), [i, a];
|
|
58
57
|
} else {
|
|
59
|
-
let
|
|
60
|
-
if (
|
|
61
|
-
let [
|
|
62
|
-
return e.checkType([
|
|
58
|
+
let r = t.substring(1).indexOf("-") + 1;
|
|
59
|
+
if (r > 0) {
|
|
60
|
+
let [i, a] = n([t.substring(0, r), t.substring(r + 1)]);
|
|
61
|
+
return e.checkType([i, a]), [i, a];
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
|
-
throw Error(`Cannot parse following level: ${
|
|
64
|
+
throw Error(`Cannot parse following level: ${t}`);
|
|
66
65
|
}
|
|
67
|
-
static parse(
|
|
68
|
-
if (
|
|
69
|
-
if (typeof
|
|
70
|
-
if (Number.isNaN(
|
|
71
|
-
return
|
|
66
|
+
static parse(t) {
|
|
67
|
+
if (t == null) return null;
|
|
68
|
+
if (typeof t == "number") {
|
|
69
|
+
if (Number.isNaN(t)) throw Error("level number must not be NaN");
|
|
70
|
+
return t;
|
|
72
71
|
}
|
|
73
|
-
if (Array.isArray(
|
|
74
|
-
if (
|
|
75
|
-
let
|
|
76
|
-
return e.checkType(
|
|
72
|
+
if (Array.isArray(t)) {
|
|
73
|
+
if (t.length !== 2) throw Error(`level range must have exactly 2 elements, got ${t.length}`);
|
|
74
|
+
let n = [t[0], t[1]];
|
|
75
|
+
return e.checkType(n), e.clone(n);
|
|
77
76
|
}
|
|
78
|
-
if (typeof
|
|
79
|
-
throw Error(`Cannot parse level from ${typeof
|
|
77
|
+
if (typeof t == "string") return e.fromString(t);
|
|
78
|
+
throw Error(`Cannot parse level from ${typeof t}`);
|
|
80
79
|
}
|
|
81
|
-
static contains(
|
|
82
|
-
return e.VERIFY_TYPING && (e.checkType(
|
|
80
|
+
static contains(t, n) {
|
|
81
|
+
return e.VERIFY_TYPING && (e.checkType(t), e.checkType(n)), t === n ? !0 : Array.isArray(t) ? Array.isArray(n) ? t[0] <= n[0] && t[1] >= n[1] : n !== null && t[0] <= n && t[1] >= n : t === null || n === null ? !1 : t <= n[0] && t >= n[1];
|
|
83
82
|
}
|
|
84
|
-
static intersection(
|
|
85
|
-
if (e.VERIFY_TYPING && (e.checkType(
|
|
86
|
-
if (e.equals(
|
|
87
|
-
if (typeof
|
|
88
|
-
if (Array.isArray(
|
|
89
|
-
if (!Array.isArray(
|
|
90
|
-
let
|
|
91
|
-
return
|
|
83
|
+
static intersection(t, n) {
|
|
84
|
+
if (e.VERIFY_TYPING && (e.checkType(t), e.checkType(n)), t === null || n === null) return null;
|
|
85
|
+
if (e.equals(t, n)) return e.clone(t);
|
|
86
|
+
if (typeof t == "number" && typeof n == "number") return t === n ? t : null;
|
|
87
|
+
if (Array.isArray(t) && !Array.isArray(n)) return e.contains(t, n) ? n : null;
|
|
88
|
+
if (!Array.isArray(t) && Array.isArray(n)) return e.contains(n, t) ? t : null;
|
|
89
|
+
let r = Math.max(t[0], n[0]), i = Math.min(t[1], n[1]);
|
|
90
|
+
return i === r ? i : i < r ? null : [r, i];
|
|
92
91
|
}
|
|
93
|
-
static intersect(
|
|
94
|
-
return e.VERIFY_TYPING && (e.checkType(
|
|
92
|
+
static intersect(t, n) {
|
|
93
|
+
return e.VERIFY_TYPING && (e.checkType(t), e.checkType(n)), t === null && n === null || e.intersection(t, n) !== null;
|
|
95
94
|
}
|
|
96
|
-
static union(
|
|
97
|
-
if (e.VERIFY_TYPING && (e.checkType(
|
|
98
|
-
if (
|
|
99
|
-
let
|
|
100
|
-
return !Array.isArray(
|
|
95
|
+
static union(t, n) {
|
|
96
|
+
if (e.VERIFY_TYPING && (e.checkType(t), e.checkType(n)), t === n) return e.clone(t);
|
|
97
|
+
if (n === null || t === null) return null;
|
|
98
|
+
let r, i;
|
|
99
|
+
return !Array.isArray(t) && !Array.isArray(n) ? (r = Math.min(t, n), i = Math.max(t, n)) : Array.isArray(t) && !Array.isArray(n) ? (r = Math.min(t[0], n), i = Math.max(t[1], n)) : !Array.isArray(t) && Array.isArray(n) ? (r = Math.min(n[0], t), i = Math.max(n[1], t)) : (r = Math.min(t[0], n[0]), i = Math.max(t[1], n[1])), r === i ? r : [r, i];
|
|
101
100
|
}
|
|
102
|
-
static multiplyBy(
|
|
103
|
-
return e.VERIFY_TYPING && e.checkType(
|
|
101
|
+
static multiplyBy(t, n) {
|
|
102
|
+
return e.VERIFY_TYPING && e.checkType(t), t === null ? null : Array.isArray(t) ? [t[0] * n, t[1] * n] : t * n;
|
|
104
103
|
}
|
|
105
|
-
static toString(
|
|
106
|
-
return e.VERIFY_TYPING && e.checkType(
|
|
104
|
+
static toString(t) {
|
|
105
|
+
return e.VERIFY_TYPING && e.checkType(t), t === null ? null : Array.isArray(t) ? t[0] + ";" + t[1] : String(t);
|
|
107
106
|
}
|
|
108
|
-
static equals(
|
|
109
|
-
return e.VERIFY_TYPING && (e.checkType(
|
|
107
|
+
static equals(t, n) {
|
|
108
|
+
return e.VERIFY_TYPING && (e.checkType(t), e.checkType(n)), t === n ? !0 : Array.isArray(t) && Array.isArray(n) ? t[0] === n[0] && t[1] === n[1] : !1;
|
|
110
109
|
}
|
|
111
|
-
static diff(
|
|
112
|
-
return e.VERIFY_TYPING && (e.checkType(
|
|
110
|
+
static diff(t, n) {
|
|
111
|
+
return e.VERIFY_TYPING && (e.checkType(t), e.checkType(n)), t === null || n === null ? null : !Array.isArray(t) && !Array.isArray(n) ? n - t : Array.isArray(t) && !Array.isArray(n) ? t[0] === n ? n - t[1] : t[1] === n ? n - t[0] : null : Array.isArray(n) && !Array.isArray(t) ? t === n[0] ? n[1] - t : t === n[1] ? n[0] - t : null : e.equals(t, n) ? 0 : null;
|
|
113
112
|
}
|
|
114
|
-
},
|
|
113
|
+
}, T = class t {
|
|
115
114
|
_lat;
|
|
116
115
|
_lng;
|
|
117
116
|
_alt = null;
|
|
@@ -120,8 +119,8 @@ var Level_default = class e {
|
|
|
120
119
|
_heightFromGround = null;
|
|
121
120
|
_ecef;
|
|
122
121
|
autoWrap = !0;
|
|
123
|
-
constructor(e,
|
|
124
|
-
this.lat = e, this.lng =
|
|
122
|
+
constructor(e, t, n = null, r = null) {
|
|
123
|
+
this.lat = e, this.lng = t, this.alt = n, this.level = r, this._ecef = null;
|
|
125
124
|
}
|
|
126
125
|
get lat() {
|
|
127
126
|
return this._lat;
|
|
@@ -159,7 +158,7 @@ var Level_default = class e {
|
|
|
159
158
|
return this._level;
|
|
160
159
|
}
|
|
161
160
|
set level(e) {
|
|
162
|
-
|
|
161
|
+
w.checkType(e), this._level = e;
|
|
163
162
|
}
|
|
164
163
|
get heightFromFloor() {
|
|
165
164
|
return this._heightFromFloor;
|
|
@@ -174,102 +173,102 @@ var Level_default = class e {
|
|
|
174
173
|
this._heightFromGround = e;
|
|
175
174
|
}
|
|
176
175
|
clone() {
|
|
177
|
-
let e = new
|
|
178
|
-
return this.level !== null && (e.level =
|
|
176
|
+
let e = new t(this.lat, this.lng, this.alt);
|
|
177
|
+
return this.level !== null && (e.level = w.clone(this.level)), e;
|
|
179
178
|
}
|
|
180
179
|
wrap() {
|
|
181
|
-
(this._lng <= -180 || this._lng > 180) && (this._lng =
|
|
180
|
+
(this._lng <= -180 || this._lng > 180) && (this._lng = o(this._lng, -180, 180));
|
|
182
181
|
}
|
|
183
|
-
static equals(e,
|
|
184
|
-
return this.equalsWithoutLevel(e,
|
|
182
|
+
static equals(e, t, n = m, r = h) {
|
|
183
|
+
return this.equalsWithoutLevel(e, t, n, r) ? e === null || t === null || w.equals(e.level, t.level) : !1;
|
|
185
184
|
}
|
|
186
185
|
equals(e) {
|
|
187
|
-
return
|
|
186
|
+
return t.equals(this, e);
|
|
188
187
|
}
|
|
189
|
-
static equalsWithoutLevel(e,
|
|
190
|
-
return e === null && e ===
|
|
188
|
+
static equalsWithoutLevel(e, n, r = m, i = h) {
|
|
189
|
+
return e === null && e === n ? !0 : !(e instanceof t) || !(n instanceof t) ? !1 : Math.abs(n.lat - e.lat) < r && Math.abs(n.lng - e.lng) < r && (e.alt === n.alt || e.alt !== null && n.alt !== null && Math.abs(n.alt - e.alt) < i);
|
|
191
190
|
}
|
|
192
|
-
equalsWithoutLevel(e,
|
|
193
|
-
return
|
|
191
|
+
equalsWithoutLevel(e, n = m, r = h) {
|
|
192
|
+
return t.equalsWithoutLevel(this, e, n, r);
|
|
194
193
|
}
|
|
195
|
-
destinationPoint(e,
|
|
196
|
-
let
|
|
197
|
-
return
|
|
194
|
+
destinationPoint(e, t, n = null) {
|
|
195
|
+
let r = this.clone();
|
|
196
|
+
return r.move(e, t, n), r;
|
|
198
197
|
}
|
|
199
|
-
move(e,
|
|
200
|
-
let
|
|
201
|
-
if (this.lat =
|
|
198
|
+
move(e, t, n = null) {
|
|
199
|
+
let i = e / d, o = Math.cos(i), s = Math.sin(i), c = r(this.lat), l = r(this.lng), u = Math.asin(Math.sin(c) * o + Math.cos(c) * s * Math.cos(t)), f = l + Math.atan2(Math.sin(t) * s * Math.cos(c), o - Math.sin(c) * Math.sin(u));
|
|
200
|
+
if (this.lat = a(u), this.lng = a(f), n !== null) {
|
|
202
201
|
if (this.alt === null) throw Error("Point altitude is not defined");
|
|
203
|
-
this.alt +=
|
|
202
|
+
this.alt += n;
|
|
204
203
|
}
|
|
205
204
|
return this;
|
|
206
205
|
}
|
|
207
206
|
distanceTo(e) {
|
|
208
|
-
let
|
|
209
|
-
return
|
|
207
|
+
let t = this.lat, n = this.lng, i = e.lat, a = e.lng, o = r(i - t), s = r(a - n), c = Math.sin(s / 2), l = Math.sin(o / 2), u = r(t), f = Math.cos(u), p = r(i), m = Math.cos(p), h = l * l + f * m * c * c, g = Math.sqrt(h), _ = Math.sqrt(1 - h);
|
|
208
|
+
return 2 * Math.atan2(g, _) * d;
|
|
210
209
|
}
|
|
211
|
-
static distanceBetween(e,
|
|
212
|
-
return e.distanceTo(
|
|
210
|
+
static distanceBetween(e, t) {
|
|
211
|
+
return e.distanceTo(t);
|
|
213
212
|
}
|
|
214
213
|
bearingTo(e) {
|
|
215
|
-
let
|
|
216
|
-
return Math.atan2(Math.sin(
|
|
214
|
+
let t = r(this.lat), n = r(e.lat), i = r(e.lng - this.lng);
|
|
215
|
+
return Math.atan2(Math.sin(i) * Math.cos(n), Math.cos(t) * Math.sin(n) - Math.sin(t) * Math.cos(n) * Math.cos(i));
|
|
217
216
|
}
|
|
218
|
-
static bearingTo(e,
|
|
219
|
-
return e.bearingTo(
|
|
217
|
+
static bearingTo(e, t) {
|
|
218
|
+
return e.bearingTo(t);
|
|
220
219
|
}
|
|
221
220
|
get enuToEcefRotation() {
|
|
222
|
-
let
|
|
221
|
+
let t = e.fromAxisAngle([
|
|
223
222
|
0,
|
|
224
223
|
0,
|
|
225
224
|
1
|
|
226
|
-
], Math.PI / 2 +
|
|
225
|
+
], Math.PI / 2 + r(this.lng)), n = e.fromAxisAngle([
|
|
227
226
|
1,
|
|
228
227
|
0,
|
|
229
228
|
0
|
|
230
|
-
], Math.PI / 2 -
|
|
231
|
-
return
|
|
229
|
+
], Math.PI / 2 - r(this.lat));
|
|
230
|
+
return e.multiply(t, n);
|
|
232
231
|
}
|
|
233
232
|
get ecefToEnuRotation() {
|
|
234
|
-
let
|
|
233
|
+
let t = e.fromAxisAngle([
|
|
235
234
|
1,
|
|
236
235
|
0,
|
|
237
236
|
0
|
|
238
|
-
],
|
|
237
|
+
], r(this.lat) - Math.PI / 2), n = e.fromAxisAngle([
|
|
239
238
|
0,
|
|
240
239
|
0,
|
|
241
240
|
1
|
|
242
|
-
], -
|
|
243
|
-
return
|
|
241
|
+
], -r(this.lng) - Math.PI / 2);
|
|
242
|
+
return e.multiply(t, n);
|
|
244
243
|
}
|
|
245
244
|
get ecef() {
|
|
246
245
|
if (!this._ecef) {
|
|
247
|
-
let e =
|
|
246
|
+
let e = r(this.lat), t = r(this.lng), n = this.alt || 0, i = (d + n) * Math.cos(e) * Math.cos(t), a = (d + n) * Math.cos(e) * Math.sin(t), o = (d + n) * Math.sin(e);
|
|
248
247
|
this._ecef = [
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
248
|
+
i,
|
|
249
|
+
a,
|
|
250
|
+
o
|
|
252
251
|
];
|
|
253
252
|
}
|
|
254
253
|
return this._ecef;
|
|
255
254
|
}
|
|
256
255
|
static fromECEF(e) {
|
|
257
|
-
let
|
|
258
|
-
|
|
259
|
-
let
|
|
260
|
-
return
|
|
261
|
-
}
|
|
262
|
-
getSegmentProjection(e,
|
|
263
|
-
let
|
|
264
|
-
if (
|
|
265
|
-
let
|
|
266
|
-
e.alt !== null &&
|
|
267
|
-
let
|
|
268
|
-
return Math.abs(e.distanceTo(
|
|
256
|
+
let n = e[0], r = e[1], i = e[2], o = Math.sqrt(n ** 2 + r ** 2), s = Math.atan2(r, n), c = Math.atan2(i, o), l = o / Math.cos(c) - d;
|
|
257
|
+
s %= 2 * Math.PI;
|
|
258
|
+
let u = new t(a(c), a(s), l);
|
|
259
|
+
return u._ecef = e, u;
|
|
260
|
+
}
|
|
261
|
+
getSegmentProjection(e, r) {
|
|
262
|
+
let i = n.normalize(e.ecef), a = n.normalize(r.ecef), o = n.normalize(this.ecef), s = n.cross(i, a);
|
|
263
|
+
if (n.norm(s) === 0) return null;
|
|
264
|
+
let c = n.cross(o, s), l = n.normalize(n.cross(s, c)), u = n.multiplyScalar(l, d), f = t.fromECEF(u), p;
|
|
265
|
+
e.alt !== null && r.alt !== null && (p = (e.alt + r.alt) / 2);
|
|
266
|
+
let m = new t(f.lat, f.lng, p, w.union(e.level, r.level));
|
|
267
|
+
return Math.abs(e.distanceTo(r) - e.distanceTo(m) - r.distanceTo(m)) > .001 ? null : m;
|
|
269
268
|
}
|
|
270
269
|
toString() {
|
|
271
270
|
let e = "[" + this._lat.toFixed(7) + ", " + this._lng.toFixed(7);
|
|
272
|
-
return this._alt !== null && (e += ", " + this._alt.toFixed(2)), this._level !== null && (e += ", [" +
|
|
271
|
+
return this._alt !== null && (e += ", " + this._alt.toFixed(2)), this._level !== null && (e += ", [" + w.toString(this._level) + "]"), e += "]", e;
|
|
273
272
|
}
|
|
274
273
|
toJson() {
|
|
275
274
|
return {
|
|
@@ -280,7 +279,7 @@ var Level_default = class e {
|
|
|
280
279
|
};
|
|
281
280
|
}
|
|
282
281
|
static fromJson(e) {
|
|
283
|
-
return new
|
|
282
|
+
return new t(e.lat, e.lng, e.alt, e.level);
|
|
284
283
|
}
|
|
285
284
|
toCompressedJson() {
|
|
286
285
|
return this.level === null ? [Number(this.lat.toFixed(8)), Number(this.lng.toFixed(8))] : [
|
|
@@ -290,15 +289,15 @@ var Level_default = class e {
|
|
|
290
289
|
];
|
|
291
290
|
}
|
|
292
291
|
static fromCompressedJson(e) {
|
|
293
|
-
let
|
|
294
|
-
return e.length > 2 && (
|
|
292
|
+
let n = new t(e[0], e[1]);
|
|
293
|
+
return e.length > 2 && (n.level = e[2]), n;
|
|
295
294
|
}
|
|
296
|
-
},
|
|
295
|
+
}, E = class e extends T {
|
|
297
296
|
_time = null;
|
|
298
297
|
_accuracy = null;
|
|
299
298
|
_bearing = null;
|
|
300
|
-
constructor(e,
|
|
301
|
-
super(e,
|
|
299
|
+
constructor(e, t, n = null, r = null, i = null, a = null, o = null) {
|
|
300
|
+
super(e, t, n, r), this.time = i, this.accuracy = a, this.bearing = o;
|
|
302
301
|
}
|
|
303
302
|
get time() {
|
|
304
303
|
return this._time;
|
|
@@ -319,25 +318,25 @@ var Level_default = class e {
|
|
|
319
318
|
set bearing(e) {
|
|
320
319
|
this._bearing = e === null ? null : e % (2 * Math.PI);
|
|
321
320
|
}
|
|
322
|
-
move(e,
|
|
323
|
-
return super.move(e,
|
|
321
|
+
move(e, t, n = null) {
|
|
322
|
+
return super.move(e, t, n), this;
|
|
324
323
|
}
|
|
325
|
-
destinationPoint(e,
|
|
326
|
-
let
|
|
327
|
-
return
|
|
324
|
+
destinationPoint(e, t, n = null) {
|
|
325
|
+
let r = this.clone();
|
|
326
|
+
return r.move(e, t, n), r;
|
|
328
327
|
}
|
|
329
|
-
static fromCoordinates(
|
|
330
|
-
return new e(
|
|
328
|
+
static fromCoordinates(t) {
|
|
329
|
+
return new e(t.lat, t.lng, t.alt, t.level);
|
|
331
330
|
}
|
|
332
331
|
clone() {
|
|
333
|
-
let
|
|
334
|
-
return
|
|
332
|
+
let t = e.fromCoordinates(super.clone());
|
|
333
|
+
return t.time = this.time, t.accuracy = this.accuracy, t.bearing = this.bearing, t;
|
|
335
334
|
}
|
|
336
|
-
static equals(
|
|
337
|
-
return
|
|
335
|
+
static equals(t, n, r = m, i = h) {
|
|
336
|
+
return t === null && t === n ? !0 : !(t instanceof e) || !(n instanceof e) || !super.equals(t, n, r, i) ? !1 : t.time === n.time && t.accuracy === n.accuracy && t.bearing === n.bearing;
|
|
338
337
|
}
|
|
339
|
-
equals(
|
|
340
|
-
return e.equals(this,
|
|
338
|
+
equals(t, n = m, r = h) {
|
|
339
|
+
return e.equals(this, t, n, r);
|
|
341
340
|
}
|
|
342
341
|
toJson() {
|
|
343
342
|
return {
|
|
@@ -347,124 +346,126 @@ var Level_default = class e {
|
|
|
347
346
|
...this.bearing !== null && { bearing: this.bearing }
|
|
348
347
|
};
|
|
349
348
|
}
|
|
350
|
-
static fromJson(
|
|
351
|
-
let
|
|
352
|
-
return
|
|
353
|
-
}
|
|
354
|
-
},
|
|
355
|
-
calcDistance: () =>
|
|
356
|
-
createSegmentsAtLevel: () =>
|
|
357
|
-
geolocationPositionToUserPosition: () =>
|
|
358
|
-
sampleRoute: () =>
|
|
359
|
-
segmentIntersection: () =>
|
|
360
|
-
simplifyRoute: () =>
|
|
361
|
-
trimRoute: () =>
|
|
349
|
+
static fromJson(t) {
|
|
350
|
+
let n = e.fromCoordinates(T.fromJson(t));
|
|
351
|
+
return t.time !== void 0 && (n.time = t.time), t.accuracy !== void 0 && (n.accuracy = t.accuracy), t.bearing !== void 0 && (n.bearing = t.bearing), n;
|
|
352
|
+
}
|
|
353
|
+
}, D = /* @__PURE__ */ l({
|
|
354
|
+
calcDistance: () => M,
|
|
355
|
+
createSegmentsAtLevel: () => N,
|
|
356
|
+
geolocationPositionToUserPosition: () => j,
|
|
357
|
+
sampleRoute: () => O,
|
|
358
|
+
segmentIntersection: () => P,
|
|
359
|
+
simplifyRoute: () => A,
|
|
360
|
+
trimRoute: () => k
|
|
362
361
|
});
|
|
363
|
-
function
|
|
364
|
-
let
|
|
365
|
-
for (let
|
|
366
|
-
let
|
|
367
|
-
if (!
|
|
362
|
+
function O(e, t = .7, n = 0, r = Number.MAX_VALUE) {
|
|
363
|
+
let i = n + r, a = [], o, s = 0, c = 0, l = !1;
|
|
364
|
+
for (let r = 0; r < e.length - 1; r++) {
|
|
365
|
+
let u = e[r], d = e[r + 1], f = u.distanceTo(d), p = u.bearingTo(d), m = 0;
|
|
366
|
+
if (!l) if (n < s + f) l = !0, c = n - s;
|
|
368
367
|
else {
|
|
369
|
-
|
|
368
|
+
s += f;
|
|
370
369
|
continue;
|
|
371
370
|
}
|
|
372
|
-
for (
|
|
373
|
-
let e =
|
|
374
|
-
e.bearing =
|
|
371
|
+
for (o = Object.assign(u.clone(), { bearing: p }); m + c < f && s + c <= i;) {
|
|
372
|
+
let e = o.destinationPoint(c, p);
|
|
373
|
+
e.bearing = p, a.push(e), o = e, m += c, s += c, c = t;
|
|
375
374
|
}
|
|
376
|
-
if (
|
|
377
|
-
let
|
|
378
|
-
|
|
375
|
+
if (s + c > i) break;
|
|
376
|
+
let h = f - m;
|
|
377
|
+
s += h, c -= h;
|
|
379
378
|
}
|
|
380
|
-
return
|
|
379
|
+
return a;
|
|
381
380
|
}
|
|
382
|
-
function
|
|
383
|
-
let
|
|
381
|
+
function k(e, t = e[0], n = Number.MAX_VALUE) {
|
|
382
|
+
let r = [], i = null, a, o = 0;
|
|
384
383
|
if (e.length <= 1) throw Error("Route must have at least 2 points");
|
|
385
|
-
for (
|
|
386
|
-
let
|
|
387
|
-
if (
|
|
388
|
-
|
|
384
|
+
for (a = 1; a < e.length; a++) {
|
|
385
|
+
let n = e[a - 1], o = e[a];
|
|
386
|
+
if (T.equals(t, n)) {
|
|
387
|
+
r.push(n), i = n;
|
|
389
388
|
break;
|
|
390
389
|
}
|
|
391
|
-
let
|
|
392
|
-
if (
|
|
393
|
-
|
|
390
|
+
let s = t.getSegmentProjection(n, o);
|
|
391
|
+
if (s && T.equals(t, s) && !s.equals(o)) {
|
|
392
|
+
r.push(s), i = s;
|
|
394
393
|
break;
|
|
395
394
|
}
|
|
396
395
|
}
|
|
397
|
-
if (!
|
|
398
|
-
for (;
|
|
399
|
-
let
|
|
400
|
-
if (
|
|
401
|
-
let e =
|
|
402
|
-
|
|
396
|
+
if (!r.length) throw Error("startPosition is not on the route");
|
|
397
|
+
for (; i && a < e.length;) {
|
|
398
|
+
let t = e[a], s = i.distanceTo(t);
|
|
399
|
+
if (o + s >= n || Math.abs(o + s - n) <= .001) {
|
|
400
|
+
let e = i.bearingTo(t), a = n - o, s = i.destinationPoint(a, e);
|
|
401
|
+
r.push(s);
|
|
403
402
|
break;
|
|
404
403
|
}
|
|
405
|
-
|
|
404
|
+
r.push(t), i = t, o += s, a++;
|
|
406
405
|
}
|
|
407
|
-
return
|
|
406
|
+
return r;
|
|
408
407
|
}
|
|
409
|
-
function
|
|
410
|
-
let
|
|
411
|
-
for (let
|
|
412
|
-
let
|
|
413
|
-
Math.abs(
|
|
408
|
+
function A(e, t = r(5)) {
|
|
409
|
+
let n = e[0].equals(e[e.length - 1]), a = e.slice(0, e.length - +!!n), o = a.length;
|
|
410
|
+
for (let r = +!n; r < o; r++) {
|
|
411
|
+
let n = e[i(r - 1, o)], s = e[r], c = e[i(r + 1, o)], l = n.bearingTo(s), u = s.bearingTo(c);
|
|
412
|
+
Math.abs(u - l) < t && (a = a.filter((e) => e !== s));
|
|
414
413
|
}
|
|
415
|
-
return
|
|
414
|
+
return n && a.push(a[0]), a;
|
|
416
415
|
}
|
|
417
|
-
function
|
|
416
|
+
function j(e) {
|
|
418
417
|
if (e === null) return null;
|
|
419
|
-
let { latitude:
|
|
420
|
-
return
|
|
418
|
+
let { latitude: t, longitude: n, accuracy: i, heading: a } = e.coords, o = new E(t, n);
|
|
419
|
+
return o.time = e.timestamp, o.accuracy = i, o.bearing = a ? r(a) : null, o;
|
|
421
420
|
}
|
|
422
|
-
function
|
|
423
|
-
return e.reduce((e,
|
|
421
|
+
function M(e) {
|
|
422
|
+
return e.reduce((e, t, n, r) => e + (n ? r[n - 1].distanceTo(t) : 0), 0);
|
|
424
423
|
}
|
|
425
|
-
function
|
|
426
|
-
let
|
|
427
|
-
for (let
|
|
428
|
-
let
|
|
429
|
-
|
|
424
|
+
function N(e, t, n = !0) {
|
|
425
|
+
let r = e.length, i = !1, a = [], o = [];
|
|
426
|
+
for (let s = 0; s < r; s++) {
|
|
427
|
+
let r = e[s], c = w.intersect(t, r.level);
|
|
428
|
+
n && !c && i ? o.push(r) : c && (i || (o = [], a.push(o), n && s !== 0 && o.push(e[s - 1])), o.push(r)), i = c;
|
|
430
429
|
}
|
|
431
|
-
return
|
|
430
|
+
return a;
|
|
432
431
|
}
|
|
433
|
-
function
|
|
434
|
-
let
|
|
435
|
-
x: e.lng *
|
|
436
|
-
y: e.lat *
|
|
437
|
-
}),
|
|
438
|
-
if (Math.abs(
|
|
439
|
-
let
|
|
440
|
-
return
|
|
432
|
+
function P(e, t, n, r) {
|
|
433
|
+
let i = (e) => e * Math.PI / 180, a = (e.lat + t.lat + n.lat + r.lat) / 4, o = d * 180 / Math.PI, s = d * 180 / Math.PI * Math.cos(i(a)), c = (e) => ({
|
|
434
|
+
x: e.lng * s,
|
|
435
|
+
y: e.lat * o
|
|
436
|
+
}), l = c(e), u = c(t), f = c(n), p = c(r), m = u.x - l.x, h = u.y - l.y, g = p.x - f.x, _ = p.y - f.y, v = m * _ - h * g;
|
|
437
|
+
if (Math.abs(v) < 1e-10) return null;
|
|
438
|
+
let y = f.x - l.x, b = f.y - l.y, x = (y * _ - b * g) / v, S = (y * h - b * m) / v;
|
|
439
|
+
return x < 0 || x > 1 || S < 0 || S > 1 ? null : new T((l.y + x * h) / o, (l.x + x * m) / s);
|
|
441
440
|
}
|
|
442
|
-
|
|
441
|
+
//#endregion
|
|
442
|
+
//#region src/coordinates/BoundingBox.ts
|
|
443
|
+
var F = class e {
|
|
443
444
|
northEast;
|
|
444
445
|
southWest;
|
|
445
|
-
constructor(e,
|
|
446
|
-
if (this.northEast = e, this.southWest =
|
|
446
|
+
constructor(e, t) {
|
|
447
|
+
if (this.northEast = e, this.southWest = t, this.northEast && this.southWest && this.getNorth() < this.getSouth()) throw Error("Incorrect bounding box");
|
|
447
448
|
}
|
|
448
449
|
get center() {
|
|
449
|
-
return new
|
|
450
|
+
return new T((this.southWest.lat + this.northEast.lat) / 2, (this.northEast.lng + this.southWest.lng) / 2);
|
|
450
451
|
}
|
|
451
452
|
contains(e) {
|
|
452
453
|
return e.lat <= this.northEast.lat && e.lat >= this.southWest.lat && e.lng <= this.northEast.lng && e.lng >= this.southWest.lng;
|
|
453
454
|
}
|
|
454
|
-
extend(
|
|
455
|
-
let
|
|
456
|
-
if (
|
|
457
|
-
else if (
|
|
455
|
+
extend(t) {
|
|
456
|
+
let n = this.southWest, r = this.northEast, i, a;
|
|
457
|
+
if (t instanceof T) i = t, a = t;
|
|
458
|
+
else if (t instanceof e) i = t.southWest, a = t.northEast;
|
|
458
459
|
else throw Error("Unknown parameter");
|
|
459
|
-
return this.southWest = new
|
|
460
|
+
return this.southWest = new T(Math.min(i.lat, n.lat), Math.min(i.lng, n.lng)), this.northEast = new T(Math.max(a.lat, r.lat), Math.max(a.lng, r.lng)), this;
|
|
460
461
|
}
|
|
461
462
|
extendsWithMeasure(e) {
|
|
462
463
|
if (typeof e != "number") throw Error("measure is not a number");
|
|
463
464
|
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;
|
|
464
465
|
}
|
|
465
466
|
pad(e) {
|
|
466
|
-
let
|
|
467
|
-
return this.southWest = new
|
|
467
|
+
let t = this.southWest, n = this.northEast, r = Math.abs(t.lat - n.lat) * e, i = Math.abs(t.lng - n.lng) * e;
|
|
468
|
+
return this.southWest = new T(t.lat - r, t.lng - i), this.northEast = new T(n.lat + r, n.lng + i), this;
|
|
468
469
|
}
|
|
469
470
|
getSouthWest() {
|
|
470
471
|
return this.southWest;
|
|
@@ -473,10 +474,10 @@ var BoundingBox_default = class e {
|
|
|
473
474
|
return this.northEast;
|
|
474
475
|
}
|
|
475
476
|
getNorthWest() {
|
|
476
|
-
return new
|
|
477
|
+
return new T(this.getNorth(), this.getWest());
|
|
477
478
|
}
|
|
478
479
|
getSouthEast() {
|
|
479
|
-
return new
|
|
480
|
+
return new T(this.getSouth(), this.getEast());
|
|
480
481
|
}
|
|
481
482
|
getWest() {
|
|
482
483
|
return this.southWest.lng;
|
|
@@ -490,17 +491,17 @@ var BoundingBox_default = class e {
|
|
|
490
491
|
getNorth() {
|
|
491
492
|
return this.northEast.lat;
|
|
492
493
|
}
|
|
493
|
-
static equals(e,
|
|
494
|
-
return
|
|
494
|
+
static equals(e, t) {
|
|
495
|
+
return T.equals(e.northEast, t.northEast) && T.equals(e.southWest, t.southWest);
|
|
495
496
|
}
|
|
496
|
-
equals(
|
|
497
|
-
return e.equals(this,
|
|
497
|
+
equals(t) {
|
|
498
|
+
return e.equals(this, t);
|
|
498
499
|
}
|
|
499
|
-
static fromArray(
|
|
500
|
-
return new e(new
|
|
500
|
+
static fromArray(t) {
|
|
501
|
+
return new e(new T(t[3], t[2]), new T(t[1], t[0]));
|
|
501
502
|
}
|
|
502
|
-
static fromCoordinates(
|
|
503
|
-
return
|
|
503
|
+
static fromCoordinates(t) {
|
|
504
|
+
return t.length === 0 ? null : t.reduce((e, t) => e.extend(t), new e(t[0], t[0]));
|
|
504
505
|
}
|
|
505
506
|
toArray() {
|
|
506
507
|
return [
|
|
@@ -510,15 +511,15 @@ var BoundingBox_default = class e {
|
|
|
510
511
|
this.getNorth()
|
|
511
512
|
];
|
|
512
513
|
}
|
|
513
|
-
},
|
|
514
|
+
}, I = class e {
|
|
514
515
|
x;
|
|
515
516
|
y;
|
|
516
517
|
z;
|
|
517
518
|
time = null;
|
|
518
519
|
_accuracy = null;
|
|
519
520
|
_bearing = null;
|
|
520
|
-
constructor(e,
|
|
521
|
-
this.x = e, this.y =
|
|
521
|
+
constructor(e, t, n, r = null, i = null, a = null) {
|
|
522
|
+
this.x = e, this.y = t, this.z = n, this.time = r, this.accuracy = i, this.bearing = a;
|
|
522
523
|
}
|
|
523
524
|
get accuracy() {
|
|
524
525
|
return this._accuracy;
|
|
@@ -536,11 +537,11 @@ var BoundingBox_default = class e {
|
|
|
536
537
|
clone() {
|
|
537
538
|
return new e(this.x, this.y, this.z, this.time, this.accuracy, this.bearing);
|
|
538
539
|
}
|
|
539
|
-
static equals(
|
|
540
|
-
return
|
|
540
|
+
static equals(t, n, r = h) {
|
|
541
|
+
return t === null && t === n ? !0 : !(t instanceof e) || !(n instanceof e) ? !1 : Math.abs(n.x - t.x) < r && Math.abs(n.y - t.y) < r && Math.abs(n.z - t.z) < r && t.time === n.time && t.accuracy === n.accuracy && t.bearing === n.bearing;
|
|
541
542
|
}
|
|
542
|
-
equals(
|
|
543
|
-
return e.equals(this,
|
|
543
|
+
equals(t) {
|
|
544
|
+
return e.equals(this, t);
|
|
544
545
|
}
|
|
545
546
|
toJson() {
|
|
546
547
|
return {
|
|
@@ -552,42 +553,42 @@ var BoundingBox_default = class e {
|
|
|
552
553
|
...this.bearing !== null && { bearing: this.bearing }
|
|
553
554
|
};
|
|
554
555
|
}
|
|
555
|
-
static fromJson(
|
|
556
|
-
return new e(
|
|
556
|
+
static fromJson(t) {
|
|
557
|
+
return new e(t.x, t.y, t.z, t.time, t.accuracy, t.bearing);
|
|
557
558
|
}
|
|
558
|
-
},
|
|
559
|
+
}, L = class extends I {}, R = class t {
|
|
559
560
|
scale = 1;
|
|
560
561
|
heading = 0;
|
|
561
562
|
origin;
|
|
562
563
|
buildingLevels;
|
|
563
|
-
constructor(e,
|
|
564
|
-
this.origin = e, this.buildingLevels =
|
|
564
|
+
constructor(e, t = []) {
|
|
565
|
+
this.origin = e, this.buildingLevels = t;
|
|
565
566
|
}
|
|
566
|
-
localToWorld(
|
|
567
|
-
let
|
|
567
|
+
localToWorld(t) {
|
|
568
|
+
let r = n.multiplyScalar(t, this.scale), i = e.fromAxisAngle([
|
|
568
569
|
0,
|
|
569
570
|
0,
|
|
570
571
|
1
|
|
571
|
-
], this.heading),
|
|
572
|
-
|
|
573
|
-
let
|
|
574
|
-
|
|
572
|
+
], this.heading), a = e.multiply(i, this.origin.enuToEcefRotation), o = e.rotate(a, r), c = n.sum(this.origin.ecef, o), l = T.fromECEF(c), u = l.alt;
|
|
573
|
+
l.heightFromGround = l.alt - this.origin.alt;
|
|
574
|
+
let d = (e) => {
|
|
575
|
+
l.level = e.id, l.heightFromFloor = u - e.floorAltitude;
|
|
575
576
|
};
|
|
576
|
-
if (!this.buildingLevels.length) return
|
|
577
|
-
let
|
|
578
|
-
if (!
|
|
579
|
-
let
|
|
580
|
-
if (!
|
|
581
|
-
let
|
|
582
|
-
return
|
|
583
|
-
}
|
|
584
|
-
worldToLocal(
|
|
585
|
-
let
|
|
577
|
+
if (!this.buildingLevels.length) return l;
|
|
578
|
+
let f = this.buildingLevels.filter((e) => u >= e.floorAltitude && u <= e.ceilingAltitude);
|
|
579
|
+
if (!f.length) return l;
|
|
580
|
+
let p = f[0], m = [l.lng, l.lat], h = f.filter((e) => e.geometries.length);
|
|
581
|
+
if (!h.length) return d(p), l;
|
|
582
|
+
let g = h.filter((e) => e.geometries.some((e) => s(m, e)))[0];
|
|
583
|
+
return g && d(g), l;
|
|
584
|
+
}
|
|
585
|
+
worldToLocal(t) {
|
|
586
|
+
let r = e.fromAxisAngle([
|
|
586
587
|
0,
|
|
587
588
|
0,
|
|
588
589
|
1
|
|
589
|
-
], -this.heading),
|
|
590
|
-
return
|
|
590
|
+
], -this.heading), i = e.multiply(this.origin.ecefToEnuRotation, r), a = n.subtract(t.ecef, this.origin.ecef), o = n.multiplyScalar(a, 1 / this.scale);
|
|
591
|
+
return e.rotate(i, o);
|
|
591
592
|
}
|
|
592
593
|
toJson() {
|
|
593
594
|
return {
|
|
@@ -597,10 +598,10 @@ var BoundingBox_default = class e {
|
|
|
597
598
|
};
|
|
598
599
|
}
|
|
599
600
|
static fromJson(e) {
|
|
600
|
-
let
|
|
601
|
-
return
|
|
601
|
+
let n = new t(T.fromJson(e.origin));
|
|
602
|
+
return n.scale = e.scale === void 0 ? 1 : e.scale, n.heading = e.heading === void 0 ? 0 : e.heading, n;
|
|
602
603
|
}
|
|
603
|
-
},
|
|
604
|
+
}, z = class n {
|
|
604
605
|
_quaternion = [
|
|
605
606
|
1,
|
|
606
607
|
0,
|
|
@@ -611,11 +612,11 @@ var BoundingBox_default = class e {
|
|
|
611
612
|
_eulerAngles = null;
|
|
612
613
|
_time = null;
|
|
613
614
|
_accuracy = null;
|
|
614
|
-
constructor(e,
|
|
615
|
-
this.quaternion = e, this.time =
|
|
615
|
+
constructor(e, t = null, n = null) {
|
|
616
|
+
this.quaternion = e, this.time = t, this.accuracy = n;
|
|
616
617
|
}
|
|
617
618
|
static unitary() {
|
|
618
|
-
return new
|
|
619
|
+
return new n([
|
|
619
620
|
1,
|
|
620
621
|
0,
|
|
621
622
|
0,
|
|
@@ -625,9 +626,9 @@ var BoundingBox_default = class e {
|
|
|
625
626
|
get quaternion() {
|
|
626
627
|
return this._quaternion;
|
|
627
628
|
}
|
|
628
|
-
set quaternion(
|
|
629
|
-
if (Math.abs(1 -
|
|
630
|
-
this._quaternion =
|
|
629
|
+
set quaternion(t) {
|
|
630
|
+
if (Math.abs(1 - e.norm(t)) > 1e-4) throw Error("quaternion is not a unit quaternion");
|
|
631
|
+
this._quaternion = t, this._heading = null, this._eulerAngles = null;
|
|
631
632
|
}
|
|
632
633
|
get time() {
|
|
633
634
|
return this._time;
|
|
@@ -643,26 +644,26 @@ var BoundingBox_default = class e {
|
|
|
643
644
|
this._accuracy = e;
|
|
644
645
|
}
|
|
645
646
|
get eulerAngles() {
|
|
646
|
-
return this._eulerAngles === null && (this._eulerAngles =
|
|
647
|
+
return this._eulerAngles === null && (this._eulerAngles = t.quaternionToEulerZXY(this.quaternion)), this._eulerAngles;
|
|
647
648
|
}
|
|
648
649
|
get eulerAnglesDegrees() {
|
|
649
|
-
return this.eulerAngles.map((e) =>
|
|
650
|
+
return this.eulerAngles.map((e) => a(e));
|
|
650
651
|
}
|
|
651
652
|
get heading() {
|
|
652
653
|
if (this._heading === null) {
|
|
653
654
|
let e = 0;
|
|
654
|
-
typeof window < "u" && window && window.orientation && (e =
|
|
655
|
+
typeof window < "u" && window && window.orientation && (e = r(window.orientation)), this._heading = t.getHeadingFromQuaternion(this.quaternion) + e;
|
|
655
656
|
}
|
|
656
657
|
return this._heading;
|
|
657
658
|
}
|
|
658
659
|
get headingDegrees() {
|
|
659
|
-
return
|
|
660
|
+
return a(this.heading);
|
|
660
661
|
}
|
|
661
|
-
static equals(
|
|
662
|
-
return
|
|
662
|
+
static equals(t, r) {
|
|
663
|
+
return t === null && t === r ? !0 : !(t instanceof n) || !(r instanceof n) ? !1 : t === r || e.equals(t.quaternion, r.quaternion);
|
|
663
664
|
}
|
|
664
665
|
equals(e) {
|
|
665
|
-
return
|
|
666
|
+
return n.equals(this, e);
|
|
666
667
|
}
|
|
667
668
|
toJson() {
|
|
668
669
|
return this.time === null && this.accuracy === null ? this.quaternion : {
|
|
@@ -672,23 +673,23 @@ var BoundingBox_default = class e {
|
|
|
672
673
|
};
|
|
673
674
|
}
|
|
674
675
|
static fromJson(e) {
|
|
675
|
-
return Array.isArray(e) ? new
|
|
676
|
+
return Array.isArray(e) ? new n(e, null, null) : new n(e.q, e.time, e.accuracy);
|
|
676
677
|
}
|
|
677
678
|
clone() {
|
|
678
|
-
return new
|
|
679
|
+
return new n(this.quaternion.slice(0), this.time, this.accuracy);
|
|
679
680
|
}
|
|
680
|
-
static diff(
|
|
681
|
-
let
|
|
682
|
-
|
|
683
|
-
let
|
|
684
|
-
return
|
|
681
|
+
static diff(t, r) {
|
|
682
|
+
let i = e.multiply(e.inverse(t.quaternion), r.quaternion), a = null;
|
|
683
|
+
r.time !== null && t.time !== null && (a = r.time - t.time);
|
|
684
|
+
let o = null;
|
|
685
|
+
return t.accuracy !== null && r.accuracy !== null && (o = Math.max(r.accuracy - t.accuracy)), new n(i, a, o);
|
|
685
686
|
}
|
|
686
|
-
},
|
|
687
|
+
}, B = class t {
|
|
687
688
|
heading;
|
|
688
689
|
time = null;
|
|
689
690
|
_accuracy = null;
|
|
690
|
-
constructor(e,
|
|
691
|
-
this.heading = e, this.time =
|
|
691
|
+
constructor(e, t = null, n = null) {
|
|
692
|
+
this.heading = e, this.time = t, this.accuracy = n;
|
|
692
693
|
}
|
|
693
694
|
get accuracy() {
|
|
694
695
|
return this._accuracy;
|
|
@@ -698,17 +699,17 @@ var BoundingBox_default = class e {
|
|
|
698
699
|
this._accuracy = e;
|
|
699
700
|
}
|
|
700
701
|
toAttitude() {
|
|
701
|
-
return new
|
|
702
|
+
return new z(e.fromAxisAngle([
|
|
702
703
|
0,
|
|
703
704
|
0,
|
|
704
705
|
1
|
|
705
706
|
], -this.heading), this.time, this.accuracy);
|
|
706
707
|
}
|
|
707
|
-
static equals(e,
|
|
708
|
-
return e === null && e ===
|
|
708
|
+
static equals(e, n) {
|
|
709
|
+
return e === null && e === n ? !0 : !(e instanceof t) || !(n instanceof t) ? !1 : Math.abs(e.heading - n.heading) < 1e-8;
|
|
709
710
|
}
|
|
710
711
|
equals(e) {
|
|
711
|
-
return
|
|
712
|
+
return t.equals(this, e);
|
|
712
713
|
}
|
|
713
714
|
toJson() {
|
|
714
715
|
return {
|
|
@@ -718,10 +719,11 @@ var BoundingBox_default = class e {
|
|
|
718
719
|
};
|
|
719
720
|
}
|
|
720
721
|
static fromJson(e) {
|
|
721
|
-
return new
|
|
722
|
+
return new t(e.heading, e.time, e.accuracy);
|
|
722
723
|
}
|
|
723
724
|
clone() {
|
|
724
|
-
return new
|
|
725
|
+
return new t(this.heading, this.time, this.accuracy);
|
|
725
726
|
}
|
|
726
727
|
};
|
|
727
|
-
|
|
728
|
+
//#endregion
|
|
729
|
+
export { B as AbsoluteHeading, z as Attitude, F as BoundingBox, u as Constants, T as Coordinates, R as GeoRef, L as GeoRelativePosition, w as Level, I as RelativePosition, E as UserPosition, D as Utils };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wemap/geo",
|
|
3
|
-
"version": "14.6.0
|
|
3
|
+
"version": "14.6.0",
|
|
4
4
|
"description": "Geospatial primitives (coordinates, levels, bounding boxes) for the Wemap SDK.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Wemap SAS",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@turf/boolean-point-in-polygon": "^7.3.4",
|
|
41
|
-
"@wemap/maths": "14.6.0
|
|
42
|
-
"@wemap/utils": "14.6.0
|
|
41
|
+
"@wemap/maths": "14.6.0",
|
|
42
|
+
"@wemap/utils": "14.6.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/geojson": "^7946.0.14",
|
package/dist/vitest.config.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":";AAMA,wBAeG"}
|