@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 booleanPointInPolygon from "@turf/boolean-point-in-polygon";
3
- var __defProp = Object.defineProperty, __export = (e) => {
4
- let y = {};
5
- for (var b in e) __defProp(y, b, {
6
- get: e[b],
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 y;
10
- }, Constants_exports = /* @__PURE__ */ __export({
11
- CIRCUMFERENCE: () => CIRCUMFERENCE,
12
- EARTH_GRAVITY: () => EARTH_GRAVITY,
13
- ECCENTRICITY: () => ECCENTRICITY,
14
- ECCENTRICITY_2: () => ECCENTRICITY_2,
15
- ELLIPSOID_FLATNESS: () => ELLIPSOID_FLATNESS,
16
- EPS_DEG_MM: () => EPS_DEG_MM,
17
- EPS_MM: () => EPS_MM,
18
- R_MAJOR: () => R_MAJOR,
19
- R_MAJOR_2: () => R_MAJOR_2,
20
- R_MAJOR_4: () => R_MAJOR_4,
21
- R_MINOR: () => R_MINOR,
22
- R_MINOR_2: () => R_MINOR_2,
23
- R_MINOR_4: () => 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 [y, b] = e;
32
- if (typeof y == "number" && !isNaN(y) && typeof b == "number" && !isNaN(b)) {
33
- if (y > b || y === b) throw Error(`Invalid level range: [${y}, ${b}]`);
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(y) {
41
- return e.VERIFY_TYPING && e.checkType(y), Array.isArray(y);
42
- }
43
- static clone(y) {
44
- return e.VERIFY_TYPING && e.checkType(y), y === null ? null : typeof y == "number" ? y : [y[0], y[1]];
45
- }
46
- static fromString(y) {
47
- if (y === null) return null;
48
- if (typeof y != "string" || !y.length) throw Error(`argument must be a non empty string, got ${typeof y}`);
49
- if (!isNaN(Number(y))) return parseFloat(y);
50
- let b = y.split(";");
51
- if (b.length > 1) {
52
- let y = b.map((e) => Number(e)), x = Math.min(...y), S = Math.max(...y);
53
- return e.checkType([x, S]), [x, S];
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 b = y.substring(1).indexOf("-") + 1;
56
- if (b > 0) {
57
- let x = Number(y.substring(0, b)), S = Number(y.substring(b + 1));
58
- return e.checkType([x, S]), [x, S];
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: ${y}`);
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(y, b) {
64
- return e.VERIFY_TYPING && (e.checkType(y), e.checkType(b)), y === b ? !0 : Array.isArray(y) ? Array.isArray(b) ? y[0] <= b[0] && y[1] >= b[1] : b === null ? !1 : y[0] <= b && y[1] >= b : y === null || b === null ? !1 : y <= b[0] && y >= b[1];
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(y, b) {
67
- if (e.VERIFY_TYPING && (e.checkType(y), e.checkType(b)), y === null || b === null) return null;
68
- if (e.equals(y, b)) return e.clone(y);
69
- if (typeof y == "number" && typeof b == "number") return y === b ? y : null;
70
- if (Array.isArray(y) && !Array.isArray(b)) return e.contains(y, b) ? b : null;
71
- if (!Array.isArray(y) && Array.isArray(b)) return e.contains(b, y) ? y : null;
72
- let x = Math.max(y[0], b[0]), S = Math.min(y[1], b[1]);
73
- return S === x ? S : S < x ? null : [x, S];
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(y, b) {
76
- return e.VERIFY_TYPING && (e.checkType(y), e.checkType(b)), y === null && b === null ? !0 : e.intersection(y, b) !== null;
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(y, b) {
79
- if (e.VERIFY_TYPING && (e.checkType(y), e.checkType(b)), y === b) return e.clone(y);
80
- if (b === null || y === null) return null;
81
- let x, S;
82
- return !Array.isArray(y) && !Array.isArray(b) ? (x = Math.min(y, b), S = Math.max(y, b)) : Array.isArray(y) && !Array.isArray(b) ? (x = Math.min(y[0], b), S = Math.max(y[1], b)) : !Array.isArray(y) && Array.isArray(b) ? (x = Math.min(b[0], y), S = Math.max(b[1], y)) : (x = Math.min(y[0], b[0]), S = Math.max(y[1], b[1])), x === S ? x : [x, S];
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(y, b) {
85
- return e.VERIFY_TYPING && e.checkType(y), y === null ? null : Array.isArray(y) ? [y[0] * b, y[1] * b] : y * b;
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(y) {
88
- return e.VERIFY_TYPING && e.checkType(y), y === null ? null : Array.isArray(y) ? y[0] + ";" + y[1] : String(y);
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(y, b) {
91
- return e.VERIFY_TYPING && (e.checkType(y), e.checkType(b)), y === b ? !0 : Array.isArray(y) && Array.isArray(b) ? y[0] === b[0] && y[1] === b[1] : !1;
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(y, b) {
94
- return e.VERIFY_TYPING && (e.checkType(y), e.checkType(b)), y === null || b === null ? null : !Array.isArray(y) && !Array.isArray(b) ? b - y : Array.isArray(y) && !Array.isArray(b) ? y[0] === b ? b - y[1] : y[1] === b ? b - y[0] : null : Array.isArray(b) && !Array.isArray(y) ? y === b[0] ? b[1] - y : y === b[1] ? b[0] - y : null : e.equals(y, b) ? 0 : null;
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
- }, Coordinates_default = class y {
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, y, b = null, x = null) {
106
- this.lat = e, this.lng = y, this.alt = b, this.level = x, this._ecef = null;
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
- Level_default.checkType(e), this._level = e;
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 y(this.lat, this.lng, this.alt);
160
- return this.level !== null && (e.level = Level_default.clone(this.level)), e;
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 = wrap(this._lng, -180, 180));
180
+ (this._lng <= -180 || this._lng > 180) && (this._lng = o(this._lng, -180, 180));
164
181
  }
165
- static equals(e, y, b = EPS_DEG_MM, x = EPS_MM) {
166
- return this.equalsWithoutLevel(e, y, b, x) ? e === null || y === null ? !0 : Level_default.equals(e.level, y.level) : !1;
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 y.equals(this, e);
186
+ return t.equals(this, e);
170
187
  }
171
- static equalsWithoutLevel(e, b, x = EPS_DEG_MM, S = EPS_MM) {
172
- return e === null && e === b ? !0 : !(e instanceof y) || !(b instanceof y) ? !1 : Math.abs(b.lat - e.lat) < x && Math.abs(b.lng - e.lng) < x && (e.alt === b.alt || e.alt !== null && b.alt !== null && Math.abs(b.alt - e.alt) < S);
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, b = EPS_DEG_MM, x = EPS_MM) {
175
- return y.equalsWithoutLevel(this, e, b, x);
191
+ equalsWithoutLevel(e, n = m, r = h) {
192
+ return t.equalsWithoutLevel(this, e, n, r);
176
193
  }
177
- destinationPoint(e, y, b = null) {
178
- let x = this.clone();
179
- return x.move(e, y, b), x;
194
+ destinationPoint(e, t, n = null) {
195
+ let r = this.clone();
196
+ return r.move(e, t, n), r;
180
197
  }
181
- move(e, y, b = null) {
182
- let S = e / R_MAJOR, w = Math.cos(S), T = Math.sin(S), E = deg2rad(this.lat), D = deg2rad(this.lng), O = Math.asin(Math.sin(E) * w + Math.cos(E) * T * Math.cos(y)), A = D + Math.atan2(Math.sin(y) * T * Math.cos(E), w - Math.sin(E) * Math.sin(O));
183
- if (this.lat = rad2deg(O), this.lng = rad2deg(A), b !== null) {
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 += b;
202
+ this.alt += n;
186
203
  }
187
204
  return this;
188
205
  }
189
206
  distanceTo(e) {
190
- let y = this.lat, b = this.lng, S = e.lat, C = e.lng, w = deg2rad(S - y), T = deg2rad(C - b), E = Math.sin(T / 2), D = Math.sin(w / 2), O = deg2rad(y), A = Math.cos(O), j = deg2rad(S), M = Math.cos(j), N = D * D + A * M * E * E, P = Math.sqrt(N), F = Math.sqrt(1 - N);
191
- return R_MAJOR * (2 * Math.atan2(P, F));
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, y) {
194
- return e.distanceTo(y);
210
+ static distanceBetween(e, t) {
211
+ return e.distanceTo(t);
195
212
  }
196
213
  bearingTo(e) {
197
- let y = deg2rad(this.lat), b = deg2rad(e.lat), S = deg2rad(e.lng - this.lng);
198
- return Math.atan2(Math.sin(S) * Math.cos(b), Math.cos(y) * Math.sin(b) - Math.sin(y) * Math.cos(b) * Math.cos(S));
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, y) {
201
- return e.bearingTo(y);
217
+ static bearingTo(e, t) {
218
+ return e.bearingTo(t);
202
219
  }
203
220
  get enuToEcefRotation() {
204
- let y = Quaternion.fromAxisAngle([
221
+ let t = e.fromAxisAngle([
205
222
  0,
206
223
  0,
207
224
  1
208
- ], Math.PI / 2 + deg2rad(this.lng)), b = Quaternion.fromAxisAngle([
225
+ ], Math.PI / 2 + r(this.lng)), n = e.fromAxisAngle([
209
226
  1,
210
227
  0,
211
228
  0
212
- ], Math.PI / 2 - deg2rad(this.lat));
213
- return Quaternion.multiply(y, b);
229
+ ], Math.PI / 2 - r(this.lat));
230
+ return e.multiply(t, n);
214
231
  }
215
232
  get ecefToEnuRotation() {
216
- let y = Quaternion.fromAxisAngle([
233
+ let t = e.fromAxisAngle([
217
234
  1,
218
235
  0,
219
236
  0
220
- ], deg2rad(this.lat) - Math.PI / 2), b = Quaternion.fromAxisAngle([
237
+ ], r(this.lat) - Math.PI / 2), n = e.fromAxisAngle([
221
238
  0,
222
239
  0,
223
240
  1
224
- ], -deg2rad(this.lng) - Math.PI / 2);
225
- return Quaternion.multiply(y, b);
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 = deg2rad(this.lat), y = deg2rad(this.lng), b = this.alt || 0;
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
- (R_MAJOR + b) * Math.cos(e) * Math.cos(y),
232
- (R_MAJOR + b) * Math.cos(e) * Math.sin(y),
233
- (R_MAJOR + b) * Math.sin(e)
248
+ i,
249
+ a,
250
+ o
234
251
  ];
235
252
  }
236
253
  return this._ecef;
237
254
  }
238
255
  static fromECEF(e) {
239
- let b = e[0], x = e[1], S = e[2], w = Math.sqrt(b ** 2 + x ** 2), T = Math.atan2(x, b), E = Math.atan2(S, w), D = w / Math.cos(E) - R_MAJOR;
240
- T %= 2 * Math.PI;
241
- let O = new y(rad2deg(E), rad2deg(T), D);
242
- return O._ecef = e, O;
243
- }
244
- getSegmentProjection(e, x) {
245
- let S = Vector3.normalize(e.ecef), C = Vector3.normalize(x.ecef), w = Vector3.normalize(this.ecef), T = Vector3.cross(S, C);
246
- if (Vector3.norm(T) === 0) return null;
247
- let E = Vector3.cross(w, T), D = Vector3.normalize(Vector3.cross(T, E)), O = Vector3.multiplyScalar(D, R_MAJOR), A = y.fromECEF(O), j;
248
- e.alt !== null && x.alt !== null && (j = (e.alt + x.alt) / 2);
249
- let M = new y(A.lat, A.lng, j, Level_default.union(e.level, x.level));
250
- return Math.abs(e.distanceTo(x) - e.distanceTo(M) - x.distanceTo(M)) > .001 ? null : M;
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 += ", [" + Level_default.toString(this._level) + "]"), e += "]", 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 y(e.lat, e.lng, e.alt, e.level);
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 b = new y(e[0], e[1]);
276
- return e.length > 2 && (b.level = e[2]), b;
292
+ let n = new t(e[0], e[1]);
293
+ return e.length > 2 && (n.level = e[2]), n;
277
294
  }
278
- }, UserPosition_default = class e extends Coordinates_default {
295
+ }, E = class e extends T {
279
296
  _time = null;
280
297
  _accuracy = null;
281
298
  _bearing = null;
282
- constructor(e, y, b = null, x = null, S = null, C = null, w = null) {
283
- super(e, y, b, x), this.time = S, this.accuracy = C, this.bearing = w;
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, y, b = null) {
305
- return super.move(e, y, b), this;
321
+ move(e, t, n = null) {
322
+ return super.move(e, t, n), this;
306
323
  }
307
- destinationPoint(e, y, b = null) {
308
- let x = this.clone();
309
- return x.move(e, y, b), x;
324
+ destinationPoint(e, t, n = null) {
325
+ let r = this.clone();
326
+ return r.move(e, t, n), r;
310
327
  }
311
- static fromCoordinates(y) {
312
- return new e(y.lat, y.lng, y.alt, y.level);
328
+ static fromCoordinates(t) {
329
+ return new e(t.lat, t.lng, t.alt, t.level);
313
330
  }
314
331
  clone() {
315
- let y = e.fromCoordinates(super.clone());
316
- return y.time = this.time, y.accuracy = this.accuracy, y.bearing = this.bearing, y;
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(y, b, x = EPS_DEG_MM, S = EPS_MM) {
319
- return y === null && y === b ? !0 : !(y instanceof e) || !(b instanceof e) || !super.equals(y, b, x, S) ? !1 : y.time === b.time && y.accuracy === b.accuracy && y.bearing === b.bearing;
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(y, b = EPS_DEG_MM, x = EPS_MM) {
322
- return e.equals(this, y, b, x);
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(y) {
333
- let b = e.fromCoordinates(Coordinates_default.fromJson(y));
334
- return y.time !== void 0 && (b.time = y.time), y.accuracy !== void 0 && (b.accuracy = y.accuracy), y.bearing !== void 0 && (b.bearing = y.bearing), b;
335
- }
336
- }, Utils_exports = /* @__PURE__ */ __export({
337
- calcDistance: () => calcDistance,
338
- createSegmentsAtLevel: () => createSegmentsAtLevel,
339
- geolocationPositionToUserPosition: () => geolocationPositionToUserPosition,
340
- sampleRoute: () => sampleRoute,
341
- segmentIntersection: () => segmentIntersection,
342
- simplifyRoute: () => simplifyRoute,
343
- trimRoute: () => 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 sampleRoute(e, y = .7, b = 0, x = Number.MAX_VALUE) {
346
- let S = b + x, C = [], w, T = 0, E = 0, D = !1;
347
- for (let x = 0; x < e.length - 1; x++) {
348
- let O = e[x], k = e[x + 1], A = O.distanceTo(k), j = O.bearingTo(k), M = 0;
349
- if (!D) if (b < T + A) D = !0, E = b - T;
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
- T += A;
368
+ s += f;
352
369
  continue;
353
370
  }
354
- for (w = Object.assign(O.clone(), { bearing: j }); M + E < A && T + E <= S;) {
355
- let e = w.destinationPoint(E, j);
356
- e.bearing = j, C.push(e), w = e, M += E, T += E, E = y;
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 (T + E > S) break;
359
- let N = A - M;
360
- T += N, E -= N;
375
+ if (s + c > i) break;
376
+ let h = f - m;
377
+ s += h, c -= h;
361
378
  }
362
- return C;
379
+ return a;
363
380
  }
364
- function trimRoute(e, y = e[0], b = Number.MAX_VALUE) {
365
- let x = [], S = null, C, w = 0;
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 (C = 1; C < e.length; C++) {
368
- let b = e[C - 1], w = e[C];
369
- if (Coordinates_default.equals(y, b)) {
370
- x.push(b), S = b;
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 T = y.getSegmentProjection(b, w);
374
- if (T && Coordinates_default.equals(y, T) && !T.equals(w)) {
375
- x.push(T), S = T;
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 (!x.length) throw Error("startPosition is not on the route");
380
- for (; S && C < e.length;) {
381
- let y = e[C], T = S.distanceTo(y);
382
- if (w + T >= b || Math.abs(w + T - b) <= .001) {
383
- let e = S.bearingTo(y), C = b - w, T = S.destinationPoint(C, e);
384
- x.push(T);
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
- x.push(y), S = y, w += T, C++;
404
+ r.push(t), i = t, o += s, a++;
388
405
  }
389
- return x;
406
+ return r;
390
407
  }
391
- function simplifyRoute(e, y = deg2rad(5)) {
392
- let b = e[0].equals(e[e.length - 1]), C = e.slice(0, e.length - (b ? 1 : 0)), w = C.length;
393
- for (let x = b ? 0 : 1; x < w; x++) {
394
- let b = e[positiveMod(x - 1, w)], T = e[x], E = e[positiveMod(x + 1, w)], D = b.bearingTo(T), O = T.bearingTo(E);
395
- Math.abs(O - D) < y && (C = C.filter((e) => e !== T));
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 b && C.push(C[0]), C;
414
+ return n && a.push(a[0]), a;
398
415
  }
399
- function geolocationPositionToUserPosition(e) {
416
+ function j(e) {
400
417
  if (e === null) return null;
401
- let { latitude: y, longitude: b, accuracy: S, heading: C } = e.coords, w = new UserPosition_default(y, b);
402
- return w.time = e.timestamp, w.accuracy = S, w.bearing = C ? deg2rad(C) : null, w;
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 calcDistance(e) {
405
- return e.reduce((e, y, b, x) => e + (b ? x[b - 1].distanceTo(y) : 0), 0);
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 createSegmentsAtLevel(e, y, b = !0) {
408
- let x = e.length, S = !1, C = [], w = [];
409
- for (let T = 0; T < x; T++) {
410
- let x = e[T], E = Level_default.intersect(y, x.level);
411
- b && !E && S ? w.push(x) : E && (S || (w = [], C.push(w), b && T !== 0 && w.push(e[T - 1])), w.push(x)), S = E;
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 C;
430
+ return a;
414
431
  }
415
- function segmentIntersection(e, y, b, x) {
416
- let S = (e) => e * Math.PI / 180, C = (e.lat + y.lat + b.lat + x.lat) / 4, w = R_MAJOR * 180 / Math.PI, T = R_MAJOR * 180 / Math.PI * Math.cos(S(C)), E = (e) => ({
417
- x: e.lng * T,
418
- y: e.lat * w
419
- }), D = E(e), O = E(y), A = E(b), j = E(x), M = O.x - D.x, N = O.y - D.y, P = j.x - A.x, F = j.y - A.y, I = M * F - N * P;
420
- if (Math.abs(I) < 1e-10) return null;
421
- let L = A.x - D.x, R = A.y - D.y, z = (L * F - R * P) / I, B = (L * N - R * M) / I;
422
- return z < 0 || z > 1 || B < 0 || B > 1 ? null : new Coordinates_default((D.y + z * N) / w, (D.x + z * M) / T);
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
- var BoundingBox_default = class e {
441
+ //#endregion
442
+ //#region src/coordinates/BoundingBox.ts
443
+ var F = class e {
425
444
  northEast;
426
445
  southWest;
427
- constructor(e, y) {
428
- if (this.northEast = e, this.southWest = y, this.northEast && this.southWest && this.getNorth() < this.getSouth()) throw Error("Incorrect bounding box");
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 Coordinates_default((this.southWest.lat + this.northEast.lat) / 2, (this.northEast.lng + this.southWest.lng) / 2);
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(y) {
437
- let b = this.southWest, x = this.northEast, S, C;
438
- if (y instanceof Coordinates_default) S = y, C = y;
439
- else if (y instanceof e) S = y.southWest, C = y.northEast;
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 Coordinates_default(Math.min(S.lat, b.lat), Math.min(S.lng, b.lng)), this.northEast = new Coordinates_default(Math.max(C.lat, x.lat), Math.max(C.lng, x.lng)), this;
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 y = this.southWest, b = this.northEast, x = Math.abs(y.lat - b.lat) * e, S = Math.abs(y.lng - b.lng) * e;
449
- return this.southWest = new Coordinates_default(y.lat - x, y.lng - S), this.northEast = new Coordinates_default(b.lat + x, b.lng + S), this;
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 Coordinates_default(this.getNorth(), this.getWest());
477
+ return new T(this.getNorth(), this.getWest());
459
478
  }
460
479
  getSouthEast() {
461
- return new Coordinates_default(this.getSouth(), this.getEast());
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, y) {
476
- return Coordinates_default.equals(e.northEast, y.northEast) && Coordinates_default.equals(e.southWest, y.southWest);
494
+ static equals(e, t) {
495
+ return T.equals(e.northEast, t.northEast) && T.equals(e.southWest, t.southWest);
477
496
  }
478
- equals(y) {
479
- return e.equals(this, y);
497
+ equals(t) {
498
+ return e.equals(this, t);
480
499
  }
481
- static fromArray(y) {
482
- return new e(new Coordinates_default(y[3], y[2]), new Coordinates_default(y[1], y[0]));
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(y) {
485
- return y.length === 0 ? null : y.reduce((e, y) => e.extend(y), new e(y[0], y[0]));
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
- }, RelativePosition_default = class e {
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, y, b, x = null, S = null, C = null) {
503
- this.x = e, this.y = y, this.z = b, this.time = x, this.accuracy = S, this.bearing = C;
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(y, b, x = EPS_MM) {
522
- return y === null && y === b ? !0 : !(y instanceof e) || !(b instanceof e) ? !1 : Math.abs(b.x - y.x) < x && Math.abs(b.y - y.y) < x && Math.abs(b.z - y.z) < x && y.time === b.time && y.accuracy === b.accuracy && y.bearing === b.bearing;
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(y) {
525
- return e.equals(this, y);
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(y) {
538
- return new e(y.x, y.y, y.z, y.time, y.accuracy, y.bearing);
556
+ static fromJson(t) {
557
+ return new e(t.x, t.y, t.z, t.time, t.accuracy, t.bearing);
539
558
  }
540
- }, GeoRelativePosition_default = class extends RelativePosition_default {}, GeoRef_default = class y {
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, y = []) {
546
- this.origin = e, this.buildingLevels = y;
564
+ constructor(e, t = []) {
565
+ this.origin = e, this.buildingLevels = t;
547
566
  }
548
- localToWorld(y) {
549
- let x = Vector3.multiplyScalar(y, this.scale), S = Quaternion.fromAxisAngle([
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), C = Quaternion.multiply(S, this.origin.enuToEcefRotation), w = Quaternion.rotate(C, x), E = Vector3.sum(this.origin.ecef, w), D = Coordinates_default.fromECEF(E), O = D.alt;
554
- D.heightFromGround = D.alt - this.origin.alt;
555
- let k = (e) => {
556
- D.level = e.id, D.heightFromFloor = O - e.floorAltitude;
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 D;
559
- let A = this.buildingLevels.filter((e) => O >= e.floorAltitude && O <= e.ceilingAltitude);
560
- if (!A.length) return D;
561
- let j = A[0], M = [D.lng, D.lat], N = A.filter((e) => e.geometries.length);
562
- if (!N.length) return k(j), D;
563
- let P = N.filter((e) => e.geometries.some((e) => booleanPointInPolygon(M, e)))[0];
564
- return P && k(P), D;
565
- }
566
- worldToLocal(y) {
567
- let x = Quaternion.fromAxisAngle([
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), S = Quaternion.multiply(this.origin.ecefToEnuRotation, x), C = Vector3.subtract(y.ecef, this.origin.ecef), w = Vector3.multiplyScalar(C, 1 / this.scale);
572
- return Quaternion.rotate(S, w);
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 b = new y(Coordinates_default.fromJson(e.origin));
583
- return b.scale = e.scale === void 0 ? 1 : e.scale, b.heading = e.heading === void 0 ? 0 : e.heading, b;
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
- }, Attitude_default = class b {
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, y = null, b = null) {
597
- this.quaternion = e, this.time = y, this.accuracy = b;
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 b([
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(y) {
611
- if (Math.abs(1 - Quaternion.norm(y)) > 1e-4) throw Error("quaternion is not a unit quaternion");
612
- this._quaternion = y, this._heading = null, this._eulerAngles = null;
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 = Rotations.quaternionToEulerZXY(this.quaternion)), 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) => rad2deg(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 = deg2rad(window.orientation)), this._heading = Rotations.getHeadingFromQuaternion(this.quaternion) + 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 rad2deg(this.heading);
660
+ return a(this.heading);
642
661
  }
643
- static equals(y, x) {
644
- return y === null && y === x ? !0 : !(y instanceof b) || !(x instanceof b) ? !1 : y === x ? !0 : Quaternion.equals(y.quaternion, x.quaternion);
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 b.equals(this, e);
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 b(e, null, null) : new b(e.q, e.time, e.accuracy);
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 b(this.quaternion.slice(0), this.time, this.accuracy);
679
+ return new n(this.quaternion.slice(0), this.time, this.accuracy);
661
680
  }
662
- static diff(y, x) {
663
- let S = Quaternion.multiply(Quaternion.inverse(y.quaternion), x.quaternion), C = null;
664
- x.time !== null && y.time !== null && (C = x.time - y.time);
665
- let w = null;
666
- return y.accuracy !== null && x.accuracy !== null && (w = Math.max(x.accuracy - y.accuracy)), new b(S, C, w);
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
- }, AbsoluteHeading_default = class y {
687
+ }, B = class t {
669
688
  heading;
670
689
  time = null;
671
690
  _accuracy = null;
672
- constructor(e, y = null, b = null) {
673
- this.heading = e, this.time = y, this.accuracy = b;
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 Attitude_default(Quaternion.fromAxisAngle([
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, b) {
690
- return e === null && e === b ? !0 : !(e instanceof y) || !(b instanceof y) ? !1 : Math.abs(e.heading - b.heading) < 1e-8;
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 y.equals(this, e);
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 y(e.heading, e.time, e.accuracy);
722
+ return new t(e.heading, e.time, e.accuracy);
704
723
  }
705
724
  clone() {
706
- return new y(this.heading, this.time, this.accuracy);
725
+ return new t(this.heading, this.time, this.accuracy);
707
726
  }
708
727
  };
709
- export { AbsoluteHeading_default as AbsoluteHeading, Attitude_default as Attitude, BoundingBox_default as BoundingBox, Constants_exports as Constants, Coordinates_default as Coordinates, GeoRef_default as GeoRef, GeoRelativePosition_default as GeoRelativePosition, Level_default as Level, RelativePosition_default as RelativePosition, UserPosition_default as UserPosition, Utils_exports as Utils };
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;IAmC9C;;;;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"}
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",
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.3",
42
- "@wemap/utils": "14.6.0-beta.3"
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",
@@ -1,3 +0,0 @@
1
- declare const _default: import('vite').UserConfig;
2
- export default _default;
3
- //# sourceMappingURL=vitest.config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":";AAMA,wBAeG"}