@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 CHANGED
@@ -1,117 +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 = (e) => {
51
- let b = e.map((e) => Number(e));
52
- if (b.some((e) => Number.isNaN(e)) || e.some((e) => !e.length)) throw Error(`Cannot parse following level: ${y}`);
53
- return b;
54
- }, x = y.split(";");
55
- if (x.length > 1) {
56
- let y = b(x), S = Math.min(...y), C = Math.max(...y);
57
- return e.checkType([S, C]), [S, C];
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 x = y.substring(1).indexOf("-") + 1;
60
- if (x > 0) {
61
- let [S, C] = b([y.substring(0, x), y.substring(x + 1)]);
62
- return e.checkType([S, C]), [S, C];
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: ${y}`);
64
+ throw Error(`Cannot parse following level: ${t}`);
66
65
  }
67
- static parse(y) {
68
- if (y == null) return null;
69
- if (typeof y == "number") {
70
- if (Number.isNaN(y)) throw Error("level number must not be NaN");
71
- return y;
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(y)) {
74
- if (y.length !== 2) throw Error(`level range must have exactly 2 elements, got ${y.length}`);
75
- let b = [y[0], y[1]];
76
- return e.checkType(b), e.clone(b);
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 y == "string") return e.fromString(y);
79
- throw Error(`Cannot parse level from ${typeof y}`);
77
+ if (typeof t == "string") return e.fromString(t);
78
+ throw Error(`Cannot parse level from ${typeof t}`);
80
79
  }
81
- static contains(y, b) {
82
- 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];
83
82
  }
84
- static intersection(y, b) {
85
- if (e.VERIFY_TYPING && (e.checkType(y), e.checkType(b)), y === null || b === null) return null;
86
- if (e.equals(y, b)) return e.clone(y);
87
- if (typeof y == "number" && typeof b == "number") return y === b ? y : null;
88
- if (Array.isArray(y) && !Array.isArray(b)) return e.contains(y, b) ? b : null;
89
- if (!Array.isArray(y) && Array.isArray(b)) return e.contains(b, y) ? y : null;
90
- let x = Math.max(y[0], b[0]), S = Math.min(y[1], b[1]);
91
- 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];
92
91
  }
93
- static intersect(y, b) {
94
- 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;
95
94
  }
96
- static union(y, b) {
97
- if (e.VERIFY_TYPING && (e.checkType(y), e.checkType(b)), y === b) return e.clone(y);
98
- if (b === null || y === null) return null;
99
- let x, S;
100
- 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];
101
100
  }
102
- static multiplyBy(y, b) {
103
- 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;
104
103
  }
105
- static toString(y) {
106
- 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);
107
106
  }
108
- static equals(y, b) {
109
- 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;
110
109
  }
111
- static diff(y, b) {
112
- 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;
113
112
  }
114
- }, Coordinates_default = class y {
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, y, b = null, x = null) {
124
- 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;
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
- Level_default.checkType(e), this._level = e;
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 y(this.lat, this.lng, this.alt);
178
- 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;
179
178
  }
180
179
  wrap() {
181
- (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));
182
181
  }
183
- static equals(e, y, b = EPS_DEG_MM, x = EPS_MM) {
184
- 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;
185
184
  }
186
185
  equals(e) {
187
- return y.equals(this, e);
186
+ return t.equals(this, e);
188
187
  }
189
- static equalsWithoutLevel(e, b, x = EPS_DEG_MM, S = EPS_MM) {
190
- 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);
191
190
  }
192
- equalsWithoutLevel(e, b = EPS_DEG_MM, x = EPS_MM) {
193
- return y.equalsWithoutLevel(this, e, b, x);
191
+ equalsWithoutLevel(e, n = m, r = h) {
192
+ return t.equalsWithoutLevel(this, e, n, r);
194
193
  }
195
- destinationPoint(e, y, b = null) {
196
- let x = this.clone();
197
- 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;
198
197
  }
199
- move(e, y, b = null) {
200
- 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));
201
- 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) {
202
201
  if (this.alt === null) throw Error("Point altitude is not defined");
203
- this.alt += b;
202
+ this.alt += n;
204
203
  }
205
204
  return this;
206
205
  }
207
206
  distanceTo(e) {
208
- 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);
209
- 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;
210
209
  }
211
- static distanceBetween(e, y) {
212
- return e.distanceTo(y);
210
+ static distanceBetween(e, t) {
211
+ return e.distanceTo(t);
213
212
  }
214
213
  bearingTo(e) {
215
- let y = deg2rad(this.lat), b = deg2rad(e.lat), S = deg2rad(e.lng - this.lng);
216
- 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));
217
216
  }
218
- static bearingTo(e, y) {
219
- return e.bearingTo(y);
217
+ static bearingTo(e, t) {
218
+ return e.bearingTo(t);
220
219
  }
221
220
  get enuToEcefRotation() {
222
- let y = Quaternion.fromAxisAngle([
221
+ let t = e.fromAxisAngle([
223
222
  0,
224
223
  0,
225
224
  1
226
- ], Math.PI / 2 + deg2rad(this.lng)), b = Quaternion.fromAxisAngle([
225
+ ], Math.PI / 2 + r(this.lng)), n = e.fromAxisAngle([
227
226
  1,
228
227
  0,
229
228
  0
230
- ], Math.PI / 2 - deg2rad(this.lat));
231
- return Quaternion.multiply(y, b);
229
+ ], Math.PI / 2 - r(this.lat));
230
+ return e.multiply(t, n);
232
231
  }
233
232
  get ecefToEnuRotation() {
234
- let y = Quaternion.fromAxisAngle([
233
+ let t = e.fromAxisAngle([
235
234
  1,
236
235
  0,
237
236
  0
238
- ], deg2rad(this.lat) - Math.PI / 2), b = Quaternion.fromAxisAngle([
237
+ ], r(this.lat) - Math.PI / 2), n = e.fromAxisAngle([
239
238
  0,
240
239
  0,
241
240
  1
242
- ], -deg2rad(this.lng) - Math.PI / 2);
243
- return Quaternion.multiply(y, b);
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 = 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);
248
247
  this._ecef = [
249
- (R_MAJOR + b) * Math.cos(e) * Math.cos(y),
250
- (R_MAJOR + b) * Math.cos(e) * Math.sin(y),
251
- (R_MAJOR + b) * Math.sin(e)
248
+ i,
249
+ a,
250
+ o
252
251
  ];
253
252
  }
254
253
  return this._ecef;
255
254
  }
256
255
  static fromECEF(e) {
257
- 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;
258
- T %= 2 * Math.PI;
259
- let O = new y(rad2deg(E), rad2deg(T), D);
260
- return O._ecef = e, O;
261
- }
262
- getSegmentProjection(e, x) {
263
- let S = Vector3.normalize(e.ecef), C = Vector3.normalize(x.ecef), w = Vector3.normalize(this.ecef), T = Vector3.cross(S, C);
264
- if (Vector3.norm(T) === 0) return null;
265
- let E = Vector3.cross(w, T), D = Vector3.normalize(Vector3.cross(T, E)), O = Vector3.multiplyScalar(D, R_MAJOR), A = y.fromECEF(O), j;
266
- e.alt !== null && x.alt !== null && (j = (e.alt + x.alt) / 2);
267
- let M = new y(A.lat, A.lng, j, Level_default.union(e.level, x.level));
268
- 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;
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 += ", [" + 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;
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 y(e.lat, e.lng, e.alt, e.level);
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 b = new y(e[0], e[1]);
294
- 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;
295
294
  }
296
- }, UserPosition_default = class e extends Coordinates_default {
295
+ }, E = class e extends T {
297
296
  _time = null;
298
297
  _accuracy = null;
299
298
  _bearing = null;
300
- constructor(e, y, b = null, x = null, S = null, C = null, w = null) {
301
- 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;
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, y, b = null) {
323
- return super.move(e, y, b), this;
321
+ move(e, t, n = null) {
322
+ return super.move(e, t, n), this;
324
323
  }
325
- destinationPoint(e, y, b = null) {
326
- let x = this.clone();
327
- 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;
328
327
  }
329
- static fromCoordinates(y) {
330
- 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);
331
330
  }
332
331
  clone() {
333
- let y = e.fromCoordinates(super.clone());
334
- 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;
335
334
  }
336
- static equals(y, b, x = EPS_DEG_MM, S = EPS_MM) {
337
- 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;
338
337
  }
339
- equals(y, b = EPS_DEG_MM, x = EPS_MM) {
340
- return e.equals(this, y, b, x);
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(y) {
351
- let b = e.fromCoordinates(Coordinates_default.fromJson(y));
352
- 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;
353
- }
354
- }, Utils_exports = /* @__PURE__ */ __export({
355
- calcDistance: () => calcDistance,
356
- createSegmentsAtLevel: () => createSegmentsAtLevel,
357
- geolocationPositionToUserPosition: () => geolocationPositionToUserPosition,
358
- sampleRoute: () => sampleRoute,
359
- segmentIntersection: () => segmentIntersection,
360
- simplifyRoute: () => simplifyRoute,
361
- 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
362
361
  });
363
- function sampleRoute(e, y = .7, b = 0, x = Number.MAX_VALUE) {
364
- let S = b + x, C = [], w, T = 0, E = 0, D = !1;
365
- for (let x = 0; x < e.length - 1; x++) {
366
- let O = e[x], k = e[x + 1], A = O.distanceTo(k), j = O.bearingTo(k), M = 0;
367
- 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;
368
367
  else {
369
- T += A;
368
+ s += f;
370
369
  continue;
371
370
  }
372
- for (w = Object.assign(O.clone(), { bearing: j }); M + E < A && T + E <= S;) {
373
- let e = w.destinationPoint(E, j);
374
- 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;
375
374
  }
376
- if (T + E > S) break;
377
- let N = A - M;
378
- T += N, E -= N;
375
+ if (s + c > i) break;
376
+ let h = f - m;
377
+ s += h, c -= h;
379
378
  }
380
- return C;
379
+ return a;
381
380
  }
382
- function trimRoute(e, y = e[0], b = Number.MAX_VALUE) {
383
- 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;
384
383
  if (e.length <= 1) throw Error("Route must have at least 2 points");
385
- for (C = 1; C < e.length; C++) {
386
- let b = e[C - 1], w = e[C];
387
- if (Coordinates_default.equals(y, b)) {
388
- 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;
389
388
  break;
390
389
  }
391
- let T = y.getSegmentProjection(b, w);
392
- if (T && Coordinates_default.equals(y, T) && !T.equals(w)) {
393
- 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;
394
393
  break;
395
394
  }
396
395
  }
397
- if (!x.length) throw Error("startPosition is not on the route");
398
- for (; S && C < e.length;) {
399
- let y = e[C], T = S.distanceTo(y);
400
- if (w + T >= b || Math.abs(w + T - b) <= .001) {
401
- let e = S.bearingTo(y), C = b - w, T = S.destinationPoint(C, e);
402
- 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);
403
402
  break;
404
403
  }
405
- x.push(y), S = y, w += T, C++;
404
+ r.push(t), i = t, o += s, a++;
406
405
  }
407
- return x;
406
+ return r;
408
407
  }
409
- function simplifyRoute(e, y = deg2rad(5)) {
410
- let b = e[0].equals(e[e.length - 1]), C = e.slice(0, e.length - (b ? 1 : 0)), w = C.length;
411
- for (let x = b ? 0 : 1; x < w; x++) {
412
- let b = e[positiveMod(x - 1, w)], T = e[x], E = e[positiveMod(x + 1, w)], D = b.bearingTo(T), O = T.bearingTo(E);
413
- 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));
414
413
  }
415
- return b && C.push(C[0]), C;
414
+ return n && a.push(a[0]), a;
416
415
  }
417
- function geolocationPositionToUserPosition(e) {
416
+ function j(e) {
418
417
  if (e === null) return null;
419
- let { latitude: y, longitude: b, accuracy: S, heading: C } = e.coords, w = new UserPosition_default(y, b);
420
- 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;
421
420
  }
422
- function calcDistance(e) {
423
- 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);
424
423
  }
425
- function createSegmentsAtLevel(e, y, b = !0) {
426
- let x = e.length, S = !1, C = [], w = [];
427
- for (let T = 0; T < x; T++) {
428
- let x = e[T], E = Level_default.intersect(y, x.level);
429
- 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;
430
429
  }
431
- return C;
430
+ return a;
432
431
  }
433
- function segmentIntersection(e, y, b, x) {
434
- 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) => ({
435
- x: e.lng * T,
436
- y: e.lat * w
437
- }), 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;
438
- if (Math.abs(I) < 1e-10) return null;
439
- let L = A.x - D.x, R = A.y - D.y, z = (L * F - R * P) / I, B = (L * N - R * M) / I;
440
- 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);
441
440
  }
442
- var BoundingBox_default = class e {
441
+ //#endregion
442
+ //#region src/coordinates/BoundingBox.ts
443
+ var F = class e {
443
444
  northEast;
444
445
  southWest;
445
- constructor(e, y) {
446
- 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");
447
448
  }
448
449
  get center() {
449
- 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);
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(y) {
455
- let b = this.southWest, x = this.northEast, S, C;
456
- if (y instanceof Coordinates_default) S = y, C = y;
457
- 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;
458
459
  else throw Error("Unknown parameter");
459
- 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;
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 y = this.southWest, b = this.northEast, x = Math.abs(y.lat - b.lat) * e, S = Math.abs(y.lng - b.lng) * e;
467
- 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;
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 Coordinates_default(this.getNorth(), this.getWest());
477
+ return new T(this.getNorth(), this.getWest());
477
478
  }
478
479
  getSouthEast() {
479
- return new Coordinates_default(this.getSouth(), this.getEast());
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, y) {
494
- 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);
495
496
  }
496
- equals(y) {
497
- return e.equals(this, y);
497
+ equals(t) {
498
+ return e.equals(this, t);
498
499
  }
499
- static fromArray(y) {
500
- 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]));
501
502
  }
502
- static fromCoordinates(y) {
503
- 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]));
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
- }, RelativePosition_default = class e {
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, y, b, x = null, S = null, C = null) {
521
- 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;
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(y, b, x = EPS_MM) {
540
- 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;
541
542
  }
542
- equals(y) {
543
- return e.equals(this, y);
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(y) {
556
- 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);
557
558
  }
558
- }, GeoRelativePosition_default = class extends RelativePosition_default {}, GeoRef_default = class y {
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, y = []) {
564
- this.origin = e, this.buildingLevels = y;
564
+ constructor(e, t = []) {
565
+ this.origin = e, this.buildingLevels = t;
565
566
  }
566
- localToWorld(y) {
567
- let x = Vector3.multiplyScalar(y, this.scale), S = Quaternion.fromAxisAngle([
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), 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;
572
- D.heightFromGround = D.alt - this.origin.alt;
573
- let k = (e) => {
574
- 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;
575
576
  };
576
- if (!this.buildingLevels.length) return D;
577
- let A = this.buildingLevels.filter((e) => O >= e.floorAltitude && O <= e.ceilingAltitude);
578
- if (!A.length) return D;
579
- let j = A[0], M = [D.lng, D.lat], N = A.filter((e) => e.geometries.length);
580
- if (!N.length) return k(j), D;
581
- let P = N.filter((e) => e.geometries.some((e) => booleanPointInPolygon(M, e)))[0];
582
- return P && k(P), D;
583
- }
584
- worldToLocal(y) {
585
- 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([
586
587
  0,
587
588
  0,
588
589
  1
589
- ], -this.heading), S = Quaternion.multiply(this.origin.ecefToEnuRotation, x), C = Vector3.subtract(y.ecef, this.origin.ecef), w = Vector3.multiplyScalar(C, 1 / this.scale);
590
- 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);
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 b = new y(Coordinates_default.fromJson(e.origin));
601
- 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;
602
603
  }
603
- }, Attitude_default = class b {
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, y = null, b = null) {
615
- 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;
616
617
  }
617
618
  static unitary() {
618
- return new b([
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(y) {
629
- if (Math.abs(1 - Quaternion.norm(y)) > 1e-4) throw Error("quaternion is not a unit quaternion");
630
- 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;
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 = Rotations.quaternionToEulerZXY(this.quaternion)), 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) => rad2deg(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 = 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;
655
656
  }
656
657
  return this._heading;
657
658
  }
658
659
  get headingDegrees() {
659
- return rad2deg(this.heading);
660
+ return a(this.heading);
660
661
  }
661
- static equals(y, x) {
662
- 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);
663
664
  }
664
665
  equals(e) {
665
- return b.equals(this, e);
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 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);
676
677
  }
677
678
  clone() {
678
- return new b(this.quaternion.slice(0), this.time, this.accuracy);
679
+ return new n(this.quaternion.slice(0), this.time, this.accuracy);
679
680
  }
680
- static diff(y, x) {
681
- let S = Quaternion.multiply(Quaternion.inverse(y.quaternion), x.quaternion), C = null;
682
- x.time !== null && y.time !== null && (C = x.time - y.time);
683
- let w = null;
684
- 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);
685
686
  }
686
- }, AbsoluteHeading_default = class y {
687
+ }, B = class t {
687
688
  heading;
688
689
  time = null;
689
690
  _accuracy = null;
690
- constructor(e, y = null, b = null) {
691
- 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;
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 Attitude_default(Quaternion.fromAxisAngle([
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, b) {
708
- 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;
709
710
  }
710
711
  equals(e) {
711
- return y.equals(this, e);
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 y(e.heading, e.time, e.accuracy);
722
+ return new t(e.heading, e.time, e.accuracy);
722
723
  }
723
724
  clone() {
724
- return new y(this.heading, this.time, this.accuracy);
725
+ return new t(this.heading, this.time, this.accuracy);
725
726
  }
726
727
  };
727
- 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wemap/geo",
3
- "version": "14.6.0-beta.4",
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-beta.4",
42
- "@wemap/utils": "14.6.0-beta.4"
41
+ "@wemap/maths": "14.6.0",
42
+ "@wemap/utils": "14.6.0"
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"}