@wemap/geo 14.6.0-beta.3 → 14.6.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -1,99 +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
|
-
|
|
52
|
-
|
|
53
|
-
return
|
|
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];
|
|
54
57
|
} else {
|
|
55
|
-
let
|
|
56
|
-
if (
|
|
57
|
-
let
|
|
58
|
-
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];
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
|
-
throw Error(`Cannot parse following level: ${
|
|
64
|
+
throw Error(`Cannot parse following level: ${t}`);
|
|
65
|
+
}
|
|
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;
|
|
71
|
+
}
|
|
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);
|
|
76
|
+
}
|
|
77
|
+
if (typeof t == "string") return e.fromString(t);
|
|
78
|
+
throw Error(`Cannot parse level from ${typeof t}`);
|
|
62
79
|
}
|
|
63
|
-
static contains(
|
|
64
|
-
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];
|
|
65
82
|
}
|
|
66
|
-
static intersection(
|
|
67
|
-
if (e.VERIFY_TYPING && (e.checkType(
|
|
68
|
-
if (e.equals(
|
|
69
|
-
if (typeof
|
|
70
|
-
if (Array.isArray(
|
|
71
|
-
if (!Array.isArray(
|
|
72
|
-
let
|
|
73
|
-
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];
|
|
74
91
|
}
|
|
75
|
-
static intersect(
|
|
76
|
-
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;
|
|
77
94
|
}
|
|
78
|
-
static union(
|
|
79
|
-
if (e.VERIFY_TYPING && (e.checkType(
|
|
80
|
-
if (
|
|
81
|
-
let
|
|
82
|
-
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];
|
|
83
100
|
}
|
|
84
|
-
static multiplyBy(
|
|
85
|
-
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;
|
|
86
103
|
}
|
|
87
|
-
static toString(
|
|
88
|
-
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);
|
|
89
106
|
}
|
|
90
|
-
static equals(
|
|
91
|
-
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;
|
|
92
109
|
}
|
|
93
|
-
static diff(
|
|
94
|
-
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;
|
|
95
112
|
}
|
|
96
|
-
},
|
|
113
|
+
}, T = class t {
|
|
97
114
|
_lat;
|
|
98
115
|
_lng;
|
|
99
116
|
_alt = null;
|
|
@@ -102,8 +119,8 @@ var Level_default = class e {
|
|
|
102
119
|
_heightFromGround = null;
|
|
103
120
|
_ecef;
|
|
104
121
|
autoWrap = !0;
|
|
105
|
-
constructor(e,
|
|
106
|
-
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;
|
|
107
124
|
}
|
|
108
125
|
get lat() {
|
|
109
126
|
return this._lat;
|
|
@@ -141,7 +158,7 @@ var Level_default = class e {
|
|
|
141
158
|
return this._level;
|
|
142
159
|
}
|
|
143
160
|
set level(e) {
|
|
144
|
-
|
|
161
|
+
w.checkType(e), this._level = e;
|
|
145
162
|
}
|
|
146
163
|
get heightFromFloor() {
|
|
147
164
|
return this._heightFromFloor;
|
|
@@ -156,102 +173,102 @@ var Level_default = class e {
|
|
|
156
173
|
this._heightFromGround = e;
|
|
157
174
|
}
|
|
158
175
|
clone() {
|
|
159
|
-
let e = new
|
|
160
|
-
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;
|
|
161
178
|
}
|
|
162
179
|
wrap() {
|
|
163
|
-
(this._lng <= -180 || this._lng > 180) && (this._lng =
|
|
180
|
+
(this._lng <= -180 || this._lng > 180) && (this._lng = o(this._lng, -180, 180));
|
|
164
181
|
}
|
|
165
|
-
static equals(e,
|
|
166
|
-
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;
|
|
167
184
|
}
|
|
168
185
|
equals(e) {
|
|
169
|
-
return
|
|
186
|
+
return t.equals(this, e);
|
|
170
187
|
}
|
|
171
|
-
static equalsWithoutLevel(e,
|
|
172
|
-
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);
|
|
173
190
|
}
|
|
174
|
-
equalsWithoutLevel(e,
|
|
175
|
-
return
|
|
191
|
+
equalsWithoutLevel(e, n = m, r = h) {
|
|
192
|
+
return t.equalsWithoutLevel(this, e, n, r);
|
|
176
193
|
}
|
|
177
|
-
destinationPoint(e,
|
|
178
|
-
let
|
|
179
|
-
return
|
|
194
|
+
destinationPoint(e, t, n = null) {
|
|
195
|
+
let r = this.clone();
|
|
196
|
+
return r.move(e, t, n), r;
|
|
180
197
|
}
|
|
181
|
-
move(e,
|
|
182
|
-
let
|
|
183
|
-
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) {
|
|
184
201
|
if (this.alt === null) throw Error("Point altitude is not defined");
|
|
185
|
-
this.alt +=
|
|
202
|
+
this.alt += n;
|
|
186
203
|
}
|
|
187
204
|
return this;
|
|
188
205
|
}
|
|
189
206
|
distanceTo(e) {
|
|
190
|
-
let
|
|
191
|
-
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;
|
|
192
209
|
}
|
|
193
|
-
static distanceBetween(e,
|
|
194
|
-
return e.distanceTo(
|
|
210
|
+
static distanceBetween(e, t) {
|
|
211
|
+
return e.distanceTo(t);
|
|
195
212
|
}
|
|
196
213
|
bearingTo(e) {
|
|
197
|
-
let
|
|
198
|
-
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));
|
|
199
216
|
}
|
|
200
|
-
static bearingTo(e,
|
|
201
|
-
return e.bearingTo(
|
|
217
|
+
static bearingTo(e, t) {
|
|
218
|
+
return e.bearingTo(t);
|
|
202
219
|
}
|
|
203
220
|
get enuToEcefRotation() {
|
|
204
|
-
let
|
|
221
|
+
let t = e.fromAxisAngle([
|
|
205
222
|
0,
|
|
206
223
|
0,
|
|
207
224
|
1
|
|
208
|
-
], Math.PI / 2 +
|
|
225
|
+
], Math.PI / 2 + r(this.lng)), n = e.fromAxisAngle([
|
|
209
226
|
1,
|
|
210
227
|
0,
|
|
211
228
|
0
|
|
212
|
-
], Math.PI / 2 -
|
|
213
|
-
return
|
|
229
|
+
], Math.PI / 2 - r(this.lat));
|
|
230
|
+
return e.multiply(t, n);
|
|
214
231
|
}
|
|
215
232
|
get ecefToEnuRotation() {
|
|
216
|
-
let
|
|
233
|
+
let t = e.fromAxisAngle([
|
|
217
234
|
1,
|
|
218
235
|
0,
|
|
219
236
|
0
|
|
220
|
-
],
|
|
237
|
+
], r(this.lat) - Math.PI / 2), n = e.fromAxisAngle([
|
|
221
238
|
0,
|
|
222
239
|
0,
|
|
223
240
|
1
|
|
224
|
-
], -
|
|
225
|
-
return
|
|
241
|
+
], -r(this.lng) - Math.PI / 2);
|
|
242
|
+
return e.multiply(t, n);
|
|
226
243
|
}
|
|
227
244
|
get ecef() {
|
|
228
245
|
if (!this._ecef) {
|
|
229
|
-
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);
|
|
230
247
|
this._ecef = [
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
248
|
+
i,
|
|
249
|
+
a,
|
|
250
|
+
o
|
|
234
251
|
];
|
|
235
252
|
}
|
|
236
253
|
return this._ecef;
|
|
237
254
|
}
|
|
238
255
|
static fromECEF(e) {
|
|
239
|
-
let
|
|
240
|
-
|
|
241
|
-
let
|
|
242
|
-
return
|
|
243
|
-
}
|
|
244
|
-
getSegmentProjection(e,
|
|
245
|
-
let
|
|
246
|
-
if (
|
|
247
|
-
let
|
|
248
|
-
e.alt !== null &&
|
|
249
|
-
let
|
|
250
|
-
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;
|
|
251
268
|
}
|
|
252
269
|
toString() {
|
|
253
270
|
let e = "[" + this._lat.toFixed(7) + ", " + this._lng.toFixed(7);
|
|
254
|
-
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;
|
|
255
272
|
}
|
|
256
273
|
toJson() {
|
|
257
274
|
return {
|
|
@@ -262,7 +279,7 @@ var Level_default = class e {
|
|
|
262
279
|
};
|
|
263
280
|
}
|
|
264
281
|
static fromJson(e) {
|
|
265
|
-
return new
|
|
282
|
+
return new t(e.lat, e.lng, e.alt, e.level);
|
|
266
283
|
}
|
|
267
284
|
toCompressedJson() {
|
|
268
285
|
return this.level === null ? [Number(this.lat.toFixed(8)), Number(this.lng.toFixed(8))] : [
|
|
@@ -272,15 +289,15 @@ var Level_default = class e {
|
|
|
272
289
|
];
|
|
273
290
|
}
|
|
274
291
|
static fromCompressedJson(e) {
|
|
275
|
-
let
|
|
276
|
-
return e.length > 2 && (
|
|
292
|
+
let n = new t(e[0], e[1]);
|
|
293
|
+
return e.length > 2 && (n.level = e[2]), n;
|
|
277
294
|
}
|
|
278
|
-
},
|
|
295
|
+
}, E = class e extends T {
|
|
279
296
|
_time = null;
|
|
280
297
|
_accuracy = null;
|
|
281
298
|
_bearing = null;
|
|
282
|
-
constructor(e,
|
|
283
|
-
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;
|
|
284
301
|
}
|
|
285
302
|
get time() {
|
|
286
303
|
return this._time;
|
|
@@ -301,25 +318,25 @@ var Level_default = class e {
|
|
|
301
318
|
set bearing(e) {
|
|
302
319
|
this._bearing = e === null ? null : e % (2 * Math.PI);
|
|
303
320
|
}
|
|
304
|
-
move(e,
|
|
305
|
-
return super.move(e,
|
|
321
|
+
move(e, t, n = null) {
|
|
322
|
+
return super.move(e, t, n), this;
|
|
306
323
|
}
|
|
307
|
-
destinationPoint(e,
|
|
308
|
-
let
|
|
309
|
-
return
|
|
324
|
+
destinationPoint(e, t, n = null) {
|
|
325
|
+
let r = this.clone();
|
|
326
|
+
return r.move(e, t, n), r;
|
|
310
327
|
}
|
|
311
|
-
static fromCoordinates(
|
|
312
|
-
return new e(
|
|
328
|
+
static fromCoordinates(t) {
|
|
329
|
+
return new e(t.lat, t.lng, t.alt, t.level);
|
|
313
330
|
}
|
|
314
331
|
clone() {
|
|
315
|
-
let
|
|
316
|
-
return
|
|
332
|
+
let t = e.fromCoordinates(super.clone());
|
|
333
|
+
return t.time = this.time, t.accuracy = this.accuracy, t.bearing = this.bearing, t;
|
|
317
334
|
}
|
|
318
|
-
static equals(
|
|
319
|
-
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;
|
|
320
337
|
}
|
|
321
|
-
equals(
|
|
322
|
-
return e.equals(this,
|
|
338
|
+
equals(t, n = m, r = h) {
|
|
339
|
+
return e.equals(this, t, n, r);
|
|
323
340
|
}
|
|
324
341
|
toJson() {
|
|
325
342
|
return {
|
|
@@ -329,124 +346,126 @@ var Level_default = class e {
|
|
|
329
346
|
...this.bearing !== null && { bearing: this.bearing }
|
|
330
347
|
};
|
|
331
348
|
}
|
|
332
|
-
static fromJson(
|
|
333
|
-
let
|
|
334
|
-
return
|
|
335
|
-
}
|
|
336
|
-
},
|
|
337
|
-
calcDistance: () =>
|
|
338
|
-
createSegmentsAtLevel: () =>
|
|
339
|
-
geolocationPositionToUserPosition: () =>
|
|
340
|
-
sampleRoute: () =>
|
|
341
|
-
segmentIntersection: () =>
|
|
342
|
-
simplifyRoute: () =>
|
|
343
|
-
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
|
|
344
361
|
});
|
|
345
|
-
function
|
|
346
|
-
let
|
|
347
|
-
for (let
|
|
348
|
-
let
|
|
349
|
-
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;
|
|
350
367
|
else {
|
|
351
|
-
|
|
368
|
+
s += f;
|
|
352
369
|
continue;
|
|
353
370
|
}
|
|
354
|
-
for (
|
|
355
|
-
let e =
|
|
356
|
-
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;
|
|
357
374
|
}
|
|
358
|
-
if (
|
|
359
|
-
let
|
|
360
|
-
|
|
375
|
+
if (s + c > i) break;
|
|
376
|
+
let h = f - m;
|
|
377
|
+
s += h, c -= h;
|
|
361
378
|
}
|
|
362
|
-
return
|
|
379
|
+
return a;
|
|
363
380
|
}
|
|
364
|
-
function
|
|
365
|
-
let
|
|
381
|
+
function k(e, t = e[0], n = Number.MAX_VALUE) {
|
|
382
|
+
let r = [], i = null, a, o = 0;
|
|
366
383
|
if (e.length <= 1) throw Error("Route must have at least 2 points");
|
|
367
|
-
for (
|
|
368
|
-
let
|
|
369
|
-
if (
|
|
370
|
-
|
|
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;
|
|
371
388
|
break;
|
|
372
389
|
}
|
|
373
|
-
let
|
|
374
|
-
if (
|
|
375
|
-
|
|
390
|
+
let s = t.getSegmentProjection(n, o);
|
|
391
|
+
if (s && T.equals(t, s) && !s.equals(o)) {
|
|
392
|
+
r.push(s), i = s;
|
|
376
393
|
break;
|
|
377
394
|
}
|
|
378
395
|
}
|
|
379
|
-
if (!
|
|
380
|
-
for (;
|
|
381
|
-
let
|
|
382
|
-
if (
|
|
383
|
-
let e =
|
|
384
|
-
|
|
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);
|
|
385
402
|
break;
|
|
386
403
|
}
|
|
387
|
-
|
|
404
|
+
r.push(t), i = t, o += s, a++;
|
|
388
405
|
}
|
|
389
|
-
return
|
|
406
|
+
return r;
|
|
390
407
|
}
|
|
391
|
-
function
|
|
392
|
-
let
|
|
393
|
-
for (let
|
|
394
|
-
let
|
|
395
|
-
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));
|
|
396
413
|
}
|
|
397
|
-
return
|
|
414
|
+
return n && a.push(a[0]), a;
|
|
398
415
|
}
|
|
399
|
-
function
|
|
416
|
+
function j(e) {
|
|
400
417
|
if (e === null) return null;
|
|
401
|
-
let { latitude:
|
|
402
|
-
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;
|
|
403
420
|
}
|
|
404
|
-
function
|
|
405
|
-
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);
|
|
406
423
|
}
|
|
407
|
-
function
|
|
408
|
-
let
|
|
409
|
-
for (let
|
|
410
|
-
let
|
|
411
|
-
|
|
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;
|
|
412
429
|
}
|
|
413
|
-
return
|
|
430
|
+
return a;
|
|
414
431
|
}
|
|
415
|
-
function
|
|
416
|
-
let
|
|
417
|
-
x: e.lng *
|
|
418
|
-
y: e.lat *
|
|
419
|
-
}),
|
|
420
|
-
if (Math.abs(
|
|
421
|
-
let
|
|
422
|
-
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);
|
|
423
440
|
}
|
|
424
|
-
|
|
441
|
+
//#endregion
|
|
442
|
+
//#region src/coordinates/BoundingBox.ts
|
|
443
|
+
var F = class e {
|
|
425
444
|
northEast;
|
|
426
445
|
southWest;
|
|
427
|
-
constructor(e,
|
|
428
|
-
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");
|
|
429
448
|
}
|
|
430
449
|
get center() {
|
|
431
|
-
return new
|
|
450
|
+
return new T((this.southWest.lat + this.northEast.lat) / 2, (this.northEast.lng + this.southWest.lng) / 2);
|
|
432
451
|
}
|
|
433
452
|
contains(e) {
|
|
434
453
|
return e.lat <= this.northEast.lat && e.lat >= this.southWest.lat && e.lng <= this.northEast.lng && e.lng >= this.southWest.lng;
|
|
435
454
|
}
|
|
436
|
-
extend(
|
|
437
|
-
let
|
|
438
|
-
if (
|
|
439
|
-
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;
|
|
440
459
|
else throw Error("Unknown parameter");
|
|
441
|
-
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;
|
|
442
461
|
}
|
|
443
462
|
extendsWithMeasure(e) {
|
|
444
463
|
if (typeof e != "number") throw Error("measure is not a number");
|
|
445
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;
|
|
446
465
|
}
|
|
447
466
|
pad(e) {
|
|
448
|
-
let
|
|
449
|
-
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;
|
|
450
469
|
}
|
|
451
470
|
getSouthWest() {
|
|
452
471
|
return this.southWest;
|
|
@@ -455,10 +474,10 @@ var BoundingBox_default = class e {
|
|
|
455
474
|
return this.northEast;
|
|
456
475
|
}
|
|
457
476
|
getNorthWest() {
|
|
458
|
-
return new
|
|
477
|
+
return new T(this.getNorth(), this.getWest());
|
|
459
478
|
}
|
|
460
479
|
getSouthEast() {
|
|
461
|
-
return new
|
|
480
|
+
return new T(this.getSouth(), this.getEast());
|
|
462
481
|
}
|
|
463
482
|
getWest() {
|
|
464
483
|
return this.southWest.lng;
|
|
@@ -472,17 +491,17 @@ var BoundingBox_default = class e {
|
|
|
472
491
|
getNorth() {
|
|
473
492
|
return this.northEast.lat;
|
|
474
493
|
}
|
|
475
|
-
static equals(e,
|
|
476
|
-
return
|
|
494
|
+
static equals(e, t) {
|
|
495
|
+
return T.equals(e.northEast, t.northEast) && T.equals(e.southWest, t.southWest);
|
|
477
496
|
}
|
|
478
|
-
equals(
|
|
479
|
-
return e.equals(this,
|
|
497
|
+
equals(t) {
|
|
498
|
+
return e.equals(this, t);
|
|
480
499
|
}
|
|
481
|
-
static fromArray(
|
|
482
|
-
return new e(new
|
|
500
|
+
static fromArray(t) {
|
|
501
|
+
return new e(new T(t[3], t[2]), new T(t[1], t[0]));
|
|
483
502
|
}
|
|
484
|
-
static fromCoordinates(
|
|
485
|
-
return
|
|
503
|
+
static fromCoordinates(t) {
|
|
504
|
+
return t.length === 0 ? null : t.reduce((e, t) => e.extend(t), new e(t[0], t[0]));
|
|
486
505
|
}
|
|
487
506
|
toArray() {
|
|
488
507
|
return [
|
|
@@ -492,15 +511,15 @@ var BoundingBox_default = class e {
|
|
|
492
511
|
this.getNorth()
|
|
493
512
|
];
|
|
494
513
|
}
|
|
495
|
-
},
|
|
514
|
+
}, I = class e {
|
|
496
515
|
x;
|
|
497
516
|
y;
|
|
498
517
|
z;
|
|
499
518
|
time = null;
|
|
500
519
|
_accuracy = null;
|
|
501
520
|
_bearing = null;
|
|
502
|
-
constructor(e,
|
|
503
|
-
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;
|
|
504
523
|
}
|
|
505
524
|
get accuracy() {
|
|
506
525
|
return this._accuracy;
|
|
@@ -518,11 +537,11 @@ var BoundingBox_default = class e {
|
|
|
518
537
|
clone() {
|
|
519
538
|
return new e(this.x, this.y, this.z, this.time, this.accuracy, this.bearing);
|
|
520
539
|
}
|
|
521
|
-
static equals(
|
|
522
|
-
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;
|
|
523
542
|
}
|
|
524
|
-
equals(
|
|
525
|
-
return e.equals(this,
|
|
543
|
+
equals(t) {
|
|
544
|
+
return e.equals(this, t);
|
|
526
545
|
}
|
|
527
546
|
toJson() {
|
|
528
547
|
return {
|
|
@@ -534,42 +553,42 @@ var BoundingBox_default = class e {
|
|
|
534
553
|
...this.bearing !== null && { bearing: this.bearing }
|
|
535
554
|
};
|
|
536
555
|
}
|
|
537
|
-
static fromJson(
|
|
538
|
-
return new e(
|
|
556
|
+
static fromJson(t) {
|
|
557
|
+
return new e(t.x, t.y, t.z, t.time, t.accuracy, t.bearing);
|
|
539
558
|
}
|
|
540
|
-
},
|
|
559
|
+
}, L = class extends I {}, R = class t {
|
|
541
560
|
scale = 1;
|
|
542
561
|
heading = 0;
|
|
543
562
|
origin;
|
|
544
563
|
buildingLevels;
|
|
545
|
-
constructor(e,
|
|
546
|
-
this.origin = e, this.buildingLevels =
|
|
564
|
+
constructor(e, t = []) {
|
|
565
|
+
this.origin = e, this.buildingLevels = t;
|
|
547
566
|
}
|
|
548
|
-
localToWorld(
|
|
549
|
-
let
|
|
567
|
+
localToWorld(t) {
|
|
568
|
+
let r = n.multiplyScalar(t, this.scale), i = e.fromAxisAngle([
|
|
550
569
|
0,
|
|
551
570
|
0,
|
|
552
571
|
1
|
|
553
|
-
], this.heading),
|
|
554
|
-
|
|
555
|
-
let
|
|
556
|
-
|
|
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;
|
|
557
576
|
};
|
|
558
|
-
if (!this.buildingLevels.length) return
|
|
559
|
-
let
|
|
560
|
-
if (!
|
|
561
|
-
let
|
|
562
|
-
if (!
|
|
563
|
-
let
|
|
564
|
-
return
|
|
565
|
-
}
|
|
566
|
-
worldToLocal(
|
|
567
|
-
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([
|
|
568
587
|
0,
|
|
569
588
|
0,
|
|
570
589
|
1
|
|
571
|
-
], -this.heading),
|
|
572
|
-
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);
|
|
573
592
|
}
|
|
574
593
|
toJson() {
|
|
575
594
|
return {
|
|
@@ -579,10 +598,10 @@ var BoundingBox_default = class e {
|
|
|
579
598
|
};
|
|
580
599
|
}
|
|
581
600
|
static fromJson(e) {
|
|
582
|
-
let
|
|
583
|
-
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;
|
|
584
603
|
}
|
|
585
|
-
},
|
|
604
|
+
}, z = class n {
|
|
586
605
|
_quaternion = [
|
|
587
606
|
1,
|
|
588
607
|
0,
|
|
@@ -593,11 +612,11 @@ var BoundingBox_default = class e {
|
|
|
593
612
|
_eulerAngles = null;
|
|
594
613
|
_time = null;
|
|
595
614
|
_accuracy = null;
|
|
596
|
-
constructor(e,
|
|
597
|
-
this.quaternion = e, this.time =
|
|
615
|
+
constructor(e, t = null, n = null) {
|
|
616
|
+
this.quaternion = e, this.time = t, this.accuracy = n;
|
|
598
617
|
}
|
|
599
618
|
static unitary() {
|
|
600
|
-
return new
|
|
619
|
+
return new n([
|
|
601
620
|
1,
|
|
602
621
|
0,
|
|
603
622
|
0,
|
|
@@ -607,9 +626,9 @@ var BoundingBox_default = class e {
|
|
|
607
626
|
get quaternion() {
|
|
608
627
|
return this._quaternion;
|
|
609
628
|
}
|
|
610
|
-
set quaternion(
|
|
611
|
-
if (Math.abs(1 -
|
|
612
|
-
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;
|
|
613
632
|
}
|
|
614
633
|
get time() {
|
|
615
634
|
return this._time;
|
|
@@ -625,26 +644,26 @@ var BoundingBox_default = class e {
|
|
|
625
644
|
this._accuracy = e;
|
|
626
645
|
}
|
|
627
646
|
get eulerAngles() {
|
|
628
|
-
return this._eulerAngles === null && (this._eulerAngles =
|
|
647
|
+
return this._eulerAngles === null && (this._eulerAngles = t.quaternionToEulerZXY(this.quaternion)), this._eulerAngles;
|
|
629
648
|
}
|
|
630
649
|
get eulerAnglesDegrees() {
|
|
631
|
-
return this.eulerAngles.map((e) =>
|
|
650
|
+
return this.eulerAngles.map((e) => a(e));
|
|
632
651
|
}
|
|
633
652
|
get heading() {
|
|
634
653
|
if (this._heading === null) {
|
|
635
654
|
let e = 0;
|
|
636
|
-
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;
|
|
637
656
|
}
|
|
638
657
|
return this._heading;
|
|
639
658
|
}
|
|
640
659
|
get headingDegrees() {
|
|
641
|
-
return
|
|
660
|
+
return a(this.heading);
|
|
642
661
|
}
|
|
643
|
-
static equals(
|
|
644
|
-
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);
|
|
645
664
|
}
|
|
646
665
|
equals(e) {
|
|
647
|
-
return
|
|
666
|
+
return n.equals(this, e);
|
|
648
667
|
}
|
|
649
668
|
toJson() {
|
|
650
669
|
return this.time === null && this.accuracy === null ? this.quaternion : {
|
|
@@ -654,23 +673,23 @@ var BoundingBox_default = class e {
|
|
|
654
673
|
};
|
|
655
674
|
}
|
|
656
675
|
static fromJson(e) {
|
|
657
|
-
return Array.isArray(e) ? new
|
|
676
|
+
return Array.isArray(e) ? new n(e, null, null) : new n(e.q, e.time, e.accuracy);
|
|
658
677
|
}
|
|
659
678
|
clone() {
|
|
660
|
-
return new
|
|
679
|
+
return new n(this.quaternion.slice(0), this.time, this.accuracy);
|
|
661
680
|
}
|
|
662
|
-
static diff(
|
|
663
|
-
let
|
|
664
|
-
|
|
665
|
-
let
|
|
666
|
-
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);
|
|
667
686
|
}
|
|
668
|
-
},
|
|
687
|
+
}, B = class t {
|
|
669
688
|
heading;
|
|
670
689
|
time = null;
|
|
671
690
|
_accuracy = null;
|
|
672
|
-
constructor(e,
|
|
673
|
-
this.heading = e, this.time =
|
|
691
|
+
constructor(e, t = null, n = null) {
|
|
692
|
+
this.heading = e, this.time = t, this.accuracy = n;
|
|
674
693
|
}
|
|
675
694
|
get accuracy() {
|
|
676
695
|
return this._accuracy;
|
|
@@ -680,17 +699,17 @@ var BoundingBox_default = class e {
|
|
|
680
699
|
this._accuracy = e;
|
|
681
700
|
}
|
|
682
701
|
toAttitude() {
|
|
683
|
-
return new
|
|
702
|
+
return new z(e.fromAxisAngle([
|
|
684
703
|
0,
|
|
685
704
|
0,
|
|
686
705
|
1
|
|
687
706
|
], -this.heading), this.time, this.accuracy);
|
|
688
707
|
}
|
|
689
|
-
static equals(e,
|
|
690
|
-
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;
|
|
691
710
|
}
|
|
692
711
|
equals(e) {
|
|
693
|
-
return
|
|
712
|
+
return t.equals(this, e);
|
|
694
713
|
}
|
|
695
714
|
toJson() {
|
|
696
715
|
return {
|
|
@@ -700,10 +719,11 @@ var BoundingBox_default = class e {
|
|
|
700
719
|
};
|
|
701
720
|
}
|
|
702
721
|
static fromJson(e) {
|
|
703
|
-
return new
|
|
722
|
+
return new t(e.heading, e.time, e.accuracy);
|
|
704
723
|
}
|
|
705
724
|
clone() {
|
|
706
|
-
return new
|
|
725
|
+
return new t(this.heading, this.time, this.accuracy);
|
|
707
726
|
}
|
|
708
727
|
};
|
|
709
|
-
|
|
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 };
|
|
@@ -16,6 +16,11 @@ declare class Level {
|
|
|
16
16
|
* Create a level from a string (eg. 1, -2, 1;2, -2;3, 2;-1, 0.5;1 ...)
|
|
17
17
|
*/
|
|
18
18
|
static fromString(str: string | null): Level_t;
|
|
19
|
+
/**
|
|
20
|
+
* Parse a level from unknown input (GeoJSON properties, JSON APIs, etc.).
|
|
21
|
+
* Accepts: null, undefined, number (non-NaN), [min, max], non-empty string.
|
|
22
|
+
*/
|
|
23
|
+
static parse(value: unknown): Level_t;
|
|
19
24
|
/**
|
|
20
25
|
* Returns if a level is contained in another
|
|
21
26
|
* @param {null|number|[number, number]} container The container level
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Level.d.ts","sourceRoot":"","sources":["../../../src/coordinates/Level.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC;;;;GAIG;AACH,cAAM,KAAK;IAEP,MAAM,CAAC,aAAa,UAAS;IAE7B,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO;IAoB/B;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;IAOzD,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAcrC;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO;
|
|
1
|
+
{"version":3,"file":"Level.d.ts","sourceRoot":"","sources":["../../../src/coordinates/Level.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC;;;;GAIG;AACH,cAAM,KAAK;IAEP,MAAM,CAAC,aAAa,UAAS;IAE7B,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO;IAoB/B;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;IAOzD,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAcrC;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO;IA4C9C;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAyBrC;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO;IA2B/D;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO;IAyC7D;;;;;MAKE;IACF,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO;IAc1D;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO;IA2CtD;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;IAY1D,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI;IAU9C,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO;IAmBvD,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,GAAG,MAAM;CAyC9D;AAED,eAAe,KAAK,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wemap/geo",
|
|
3
|
-
"version": "14.6.0-beta.
|
|
3
|
+
"version": "14.6.0-beta.5",
|
|
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-beta.
|
|
42
|
-
"@wemap/utils": "14.6.0-beta.
|
|
41
|
+
"@wemap/maths": "14.6.0-beta.5",
|
|
42
|
+
"@wemap/utils": "14.6.0-beta.5"
|
|
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"}
|