@wemap/positioning 14.1.0 → 14.2.0-beta.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.d.ts CHANGED
@@ -14,6 +14,6 @@ export { requestSensorPermissions, requestLocationPermissions } from './src/util
14
14
  /**
15
15
  * @internal
16
16
  */
17
- export { Coordinates, UserPosition } from '@wemap/geo-legacy';
17
+ export { Coordinates, UserPosition } from '../geo';
18
18
  export type { Pose, PartialPose } from './src/types';
19
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG7D,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAGvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,YAAY,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AAExF,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AACvF,YAAY,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAGlG,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAG/F;;GAEG;AACH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG9D,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG7D,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAGvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,YAAY,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AAExF,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AACvF,YAAY,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAGlG,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAG/F;;GAEG;AACH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGvD,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { AbsoluteAttitudeProvider, AbsolutePositionProvider, GnssWifiProvider, MapMatchingHandler, PositionSmoother, ProvidersOptions, VpsProvider } from "@wemap/providers";
2
2
  import { CoreConfig } from "@wemap/core";
3
+ import { Coordinates, UserPosition } from "@wemap/geo";
3
4
  var LocationSource = class {
4
5
  currentPose = {};
5
6
  updateCallbacks = /* @__PURE__ */ new Set();
@@ -28,18 +29,18 @@ var LocationSource = class {
28
29
  e.position !== void 0 && (this.currentPose.position = e.position), e.attitude !== void 0 && (this.currentPose.attitude = e.attitude), e.inclination !== void 0 && (this.currentPose.inclination = e.inclination), e.time !== void 0 && (this.currentPose.time = e.time), e.accuracy !== void 0 && (this.currentPose.accuracy = e.accuracy), this.emitUpdate({ ...this.currentPose });
29
30
  }
30
31
  emitUpdate(e) {
31
- this.updateCallbacks.forEach((C) => {
32
+ this.updateCallbacks.forEach((u) => {
32
33
  try {
33
- C(e);
34
+ u(e);
34
35
  } catch (e) {
35
36
  console.error(`Error in ${this.constructor.name} callback:`, e);
36
37
  }
37
38
  });
38
39
  }
39
40
  emitError(e) {
40
- this.errorCallbacks.forEach((C) => {
41
+ this.errorCallbacks.forEach((u) => {
41
42
  try {
42
- C(e);
43
+ u(e);
43
44
  } catch (e) {
44
45
  console.error(`Error in ${this.constructor.name} error callback:`, e);
45
46
  }
@@ -63,16 +64,16 @@ var LocationSource = class {
63
64
  })), ProvidersOptions.ignoreProviders = ["GnssWifi"];
64
65
  }
65
66
  configureVpsProvider(e) {
66
- let C = CoreConfig.getConfig()?.arNavigationData?.providers?.vps, w = e?.endpoint ?? C?.endpoint;
67
- if (!w) throw Error("VPSLocationSource requires an endpoint URL. Provide it in config or ensure CoreConfig is initialized with arNavigationData.providers.vps.endpoint");
68
- let T = new URL(w);
69
- T.href += "geopose", VpsProvider.endpoint = T.toString();
70
- let E = e?.minInclinationForRequest ?? (C?.minInclinationForRequest ? C.minInclinationForRequest * Math.PI / 180 : void 0);
71
- E !== void 0 && (VpsProvider.minInclinationForRequest = E);
72
- let D = e?.waitTimeMinInclinationForRequest ?? C?.waitTimeMinInclinationForRequest;
73
- D !== void 0 && (VpsProvider.waitTimeMinInclinationForRequest = D);
74
- let A = e?.useCoarsePose ?? C?.useCoarsePose;
75
- A !== void 0 && (VpsProvider.useCoarsePose = A), e?.requestCaller !== void 0 && (VpsProvider.requestCaller = e.requestCaller);
67
+ let u = CoreConfig.getConfig()?.arNavigationData?.providers?.vps, d = e?.endpoint ?? u?.endpoint;
68
+ if (!d) throw Error("VPSLocationSource requires an endpoint URL. Provide it in config or ensure CoreConfig is initialized with arNavigationData.providers.vps.endpoint");
69
+ let f = new URL(d);
70
+ f.href += "geopose", VpsProvider.endpoint = f.toString();
71
+ let p = e?.minInclinationForRequest ?? (u?.minInclinationForRequest ? u.minInclinationForRequest * Math.PI / 180 : void 0);
72
+ p !== void 0 && (VpsProvider.minInclinationForRequest = p);
73
+ let m = e?.waitTimeMinInclinationForRequest ?? u?.waitTimeMinInclinationForRequest;
74
+ m !== void 0 && (VpsProvider.waitTimeMinInclinationForRequest = m);
75
+ let h = e?.useCoarsePose ?? u?.useCoarsePose;
76
+ h !== void 0 && (VpsProvider.useCoarsePose = h), e?.requestCaller !== void 0 && (VpsProvider.requestCaller = e.requestCaller);
76
77
  }
77
78
  async start() {
78
79
  this.isStarted ||= (this.setupListeners(), !0);
@@ -85,17 +86,17 @@ var LocationSource = class {
85
86
  let e = await VpsProvider.getAvailability();
86
87
  if (e instanceof Error) throw e;
87
88
  return this.scanStatus = "scanning", this.scanPromise = new Promise((e) => {
88
- this.vpsProviderListenerId = VpsProvider.addEventListener((C) => {
89
+ this.vpsProviderListenerId = VpsProvider.addEventListener((u) => {
89
90
  this.stopScan();
90
- let w = {};
91
- if (C.absolutePosition) {
92
- w.position = C.absolutePosition;
93
- let e = "time" in C.absolutePosition ? C.absolutePosition.time : Date.now(), T = "accuracy" in C.absolutePosition ? C.absolutePosition.accuracy : void 0;
94
- w.time = e, T !== void 0 && (w.accuracy = T);
91
+ let d = {};
92
+ if (u.absolutePosition) {
93
+ d.position = u.absolutePosition;
94
+ let e = "time" in u.absolutePosition ? u.absolutePosition.time : Date.now(), f = "accuracy" in u.absolutePosition ? u.absolutePosition.accuracy : void 0;
95
+ d.time = e, f !== void 0 && (d.accuracy = f);
95
96
  }
96
- C.absoluteAttitude && (w.attitude = C.absoluteAttitude), this.mergeAndEmitUpdate(w), e(!0);
97
- }, (C) => {
98
- this.emitError(C), e(!1);
97
+ u.absoluteAttitude && (d.attitude = u.absoluteAttitude), this.mergeAndEmitUpdate(d), e(!0);
98
+ }, (u) => {
99
+ this.emitError(u), e(!1);
99
100
  });
100
101
  }), this.scanPromise;
101
102
  }
@@ -108,8 +109,8 @@ var LocationSource = class {
108
109
  }, (e) => {
109
110
  this.emitError(e);
110
111
  }))), !this.absoluteAttitudeProviderId && this.firstScan) {
111
- let C = await AbsoluteAttitudeProvider.getAvailability();
112
- C instanceof Error ? console.warn("AbsoluteAttitudeProvider not available:", C) : this.absoluteAttitudeProviderId = AbsoluteAttitudeProvider.addEventListener((e) => {
112
+ let u = await AbsoluteAttitudeProvider.getAvailability();
113
+ u instanceof Error ? console.warn("AbsoluteAttitudeProvider not available:", u) : this.absoluteAttitudeProviderId = AbsoluteAttitudeProvider.addEventListener((e) => {
113
114
  this.mergeAndEmitUpdate({
114
115
  attitude: e,
115
116
  time: "time" in e ? e.time : Date.now()
@@ -143,8 +144,8 @@ var LocationSource = class {
143
144
  }, !1);
144
145
  }
145
146
  configureGnssWifi(e) {
146
- let C = CoreConfig.getConfig()?.arNavigationData?.providers, T = e ?? C?.gnssWifi;
147
- T && (T.discardPositionsAbove !== void 0 && (GnssWifiProvider.discardPositionsAbove = T.discardPositionsAbove), T.enableHighAccuracy !== void 0 && (GnssWifiProvider.enableHighAccuracy = T.enableHighAccuracy));
147
+ let u = CoreConfig.getConfig()?.arNavigationData?.providers, f = e ?? u?.gnssWifi;
148
+ f && (f.discardPositionsAbove !== void 0 && (GnssWifiProvider.discardPositionsAbove = f.discardPositionsAbove), f.enableHighAccuracy !== void 0 && (GnssWifiProvider.enableHighAccuracy = f.enableHighAccuracy));
148
149
  }
149
150
  async start() {
150
151
  if (!this.isStarted) try {
@@ -169,8 +170,8 @@ var LocationSource = class {
169
170
  }
170
171
  }
171
172
  async startAttitude() {
172
- let C = await AbsoluteAttitudeProvider.getAvailability();
173
- C instanceof Error ? console.warn("AbsoluteAttitudeProvider not available:", C) : this.absoluteAttitudeProviderId = AbsoluteAttitudeProvider.addEventListener((e) => {
173
+ let u = await AbsoluteAttitudeProvider.getAvailability();
174
+ u instanceof Error ? console.warn("AbsoluteAttitudeProvider not available:", u) : this.absoluteAttitudeProviderId = AbsoluteAttitudeProvider.addEventListener((e) => {
174
175
  this.mergeAndEmitUpdate({
175
176
  attitude: e,
176
177
  time: "time" in e ? e.time : Date.now()
@@ -214,600 +215,4 @@ async function requestLocationPermissions() {
214
215
  });
215
216
  });
216
217
  }
217
- var __defProp$1 = Object.defineProperty, __defNormalProp$1 = (e, C, w) => C in e ? __defProp$1(e, C, {
218
- enumerable: !0,
219
- configurable: !0,
220
- writable: !0,
221
- value: w
222
- }) : e[C] = w, __publicField$1 = (e, C, w) => (__defNormalProp$1(e, typeof C == "symbol" ? C : C + "", w), w), Vector = class {
223
- static concat(e, C) {
224
- return e.concat(C);
225
- }
226
- }, Vector3 = class e extends Vector {
227
- static norm(e) {
228
- return Math.sqrt(e[0] * e[0] + e[1] * e[1] + e[2] * e[2]);
229
- }
230
- static normalize(e) {
231
- let C = this.norm(e), w = [
232
- ,
233
- ,
234
- ,
235
- ];
236
- for (let T = 0; T < 3; T++) w[T] = e[T] / C;
237
- return w;
238
- }
239
- static sum(e, C) {
240
- return [
241
- e[0] + C[0],
242
- e[1] + C[1],
243
- e[2] + C[2]
244
- ];
245
- }
246
- static subtract(e, C) {
247
- return [
248
- e[0] - C[0],
249
- e[1] - C[1],
250
- e[2] - C[2]
251
- ];
252
- }
253
- static distance(C, w) {
254
- return e.norm(e.subtract(C, w));
255
- }
256
- static cross(e, C) {
257
- return [
258
- e[1] * C[2] - e[2] * C[1],
259
- e[2] * C[0] - e[0] * C[2],
260
- e[0] * C[1] - e[1] * C[0]
261
- ];
262
- }
263
- static dot(e, C) {
264
- return e[0] * C[0] + e[1] * C[1] + e[2] * C[2];
265
- }
266
- static multiplyScalar(e, C) {
267
- let w = [
268
- ,
269
- ,
270
- ,
271
- ];
272
- for (let T = 0; T < 3; T++) w[T] = e[T] * C;
273
- return w;
274
- }
275
- }, _Quaternion = class e {
276
- static get identity() {
277
- return [
278
- 1,
279
- 0,
280
- 0,
281
- 0
282
- ];
283
- }
284
- static sum(e, C) {
285
- return [
286
- e[0] + C[0],
287
- e[1] + C[1],
288
- e[2] + C[2],
289
- e[3] + C[3]
290
- ];
291
- }
292
- static rotateMatlab(e, C) {
293
- let [w, T, E, D] = e, [O, k, A] = C;
294
- return [
295
- w * (w * O - E * A + D * k) - E * (w * A - T * k + E * O) + T * (T * O + E * k + D * A) + D * (w * k + T * A - D * O),
296
- w * (w * k + T * A - D * O) + T * (w * A - T * k + E * O) + E * (T * O + E * k + D * A) - D * (w * O - E * A + D * k),
297
- w * (w * A - T * k + E * O) - T * (w * k + T * A - D * O) + E * (w * O - E * A + D * k) + D * (T * O + E * k + D * A)
298
- ];
299
- }
300
- static rotate(e, C) {
301
- let [w, T, E, D] = e, O = [
302
- T,
303
- E,
304
- D
305
- ], k = Vector3.cross(O, C);
306
- k = Vector3.sum(k, k);
307
- let A = Vector3.sum(C, Vector3.multiplyScalar(k, w));
308
- return Vector3.sum(A, Vector3.cross(O, k));
309
- }
310
- static inverse(e) {
311
- return [
312
- -e[0],
313
- e[1],
314
- e[2],
315
- e[3]
316
- ];
317
- }
318
- static multiply(...C) {
319
- if (C.length === 2) {
320
- let [e, w, T, E] = C[0], [D, O, k, A] = C[1];
321
- return [
322
- e * D - w * O - T * k - E * A,
323
- e * O + D * w + T * A - E * k,
324
- e * k + D * T + E * O - w * A,
325
- e * A + D * E + w * k - T * O
326
- ];
327
- }
328
- return C.reduce((e, C) => this.multiply(e, C), e.identity);
329
- }
330
- static fromAxisAngle(e, C) {
331
- let w = Math.sin(C / 2);
332
- return [
333
- Math.cos(C / 2),
334
- e[0] * w,
335
- e[1] * w,
336
- e[2] * w
337
- ];
338
- }
339
- static rotX(e) {
340
- return this.fromAxisAngle([
341
- 1,
342
- 0,
343
- 0
344
- ], e);
345
- }
346
- static rotY(e) {
347
- return this.fromAxisAngle([
348
- 0,
349
- 1,
350
- 0
351
- ], e);
352
- }
353
- static rotZ(e) {
354
- return this.fromAxisAngle([
355
- 0,
356
- 0,
357
- 1
358
- ], e);
359
- }
360
- static fromMatrix3(e) {
361
- let C = Math.sqrt(1 + e[0][0] + e[1][1] + e[2][2]) / 2;
362
- return [
363
- C,
364
- (e[2][1] - e[1][2]) / (4 * C),
365
- (e[0][2] - e[2][0]) / (4 * C),
366
- (e[1][0] - e[0][1]) / (4 * C)
367
- ];
368
- }
369
- static fromMatrix3Matlab(e) {
370
- let C = Math.sqrt(1 + e[0][0] + e[1][1] + e[2][2]) / 2;
371
- return [
372
- C,
373
- (e[1][2] - e[2][1]) / (4 * C),
374
- (e[2][0] - e[0][2]) / (4 * C),
375
- (e[0][1] - e[1][0]) / (4 * C)
376
- ];
377
- }
378
- static toMatrix3(e) {
379
- let [C, w, T, E] = e, D = C * w, O = C * T, k = C * E, A = w * w, j = w * T, M = w * E, N = T * T, P = T * E, F = E * E;
380
- return [
381
- [
382
- 1 - 2 * (N + F),
383
- 2 * (j - k),
384
- 2 * (M + O)
385
- ],
386
- [
387
- 2 * (j + k),
388
- 1 - 2 * (A + F),
389
- 2 * (P - D)
390
- ],
391
- [
392
- 2 * (M - O),
393
- 2 * (P + D),
394
- 1 - 2 * (A + N)
395
- ]
396
- ];
397
- }
398
- static wxyz2xyzw(e) {
399
- return [
400
- e[1],
401
- e[2],
402
- e[3],
403
- e[0]
404
- ];
405
- }
406
- static xyzw2wxyz(e) {
407
- return [
408
- e[3],
409
- e[0],
410
- e[1],
411
- e[2]
412
- ];
413
- }
414
- static distance(C, w) {
415
- return Math.acos(Math.min(2 * e.dot(C, w) ** 2 - 1, 1));
416
- }
417
- static equals(C, w) {
418
- return e.distance(C, w) < 1e-8;
419
- }
420
- static normalize(e) {
421
- let C = this.norm(e), w = [
422
- ,
423
- ,
424
- ,
425
- ,
426
- ];
427
- for (let T = 0; T < 4; T++) w[T] = e[T] / C;
428
- return w;
429
- }
430
- static norm(e) {
431
- return Math.sqrt(e[0] ** 2 + e[1] ** 2 + e[2] ** 2 + e[3] ** 2);
432
- }
433
- static dot(e, C) {
434
- return e[0] * C[0] + e[1] * C[1] + e[2] * C[2] + e[3] * C[3];
435
- }
436
- static getRotationBetweenTwoVectors(C, w) {
437
- let T = Vector3.normalize(C), E = Vector3.normalize(w), D = Vector3.dot(T, E), O;
438
- if (D < -.999999) return O = Vector3.cross([
439
- 1,
440
- 0,
441
- 0
442
- ], T), Vector3.norm(O) < 1e-6 && (O = Vector3.cross([
443
- 0,
444
- 1,
445
- 0
446
- ], T)), O = Vector3.normalize(O), e.fromAxisAngle(O, Math.PI);
447
- if (D > .999999) return e.identity;
448
- O = Vector3.cross(T, E);
449
- let k = [
450
- 1 + D,
451
- O[0],
452
- O[1],
453
- O[2]
454
- ];
455
- return e.normalize(k);
456
- }
457
- static slerp(C, w, T) {
458
- let E = C[1], D = C[2], O = C[3], k = C[0], A = w[1], j = w[2], M = w[3], N = w[0], P, F, I;
459
- P = E * A + D * j + O * M + k * N, P < 0 && (P = -P, N = -N, A = -A, j = -j, M = -M);
460
- let L = 1 - P < 1e-6;
461
- if (L) F = 1 - T, I = T;
462
- else {
463
- let e = Math.acos(P), C = Math.sin(e);
464
- F = Math.sin((1 - T) * e) / C, I = Math.sin(T * e) / C;
465
- }
466
- let R = [
467
- F * k + I * N,
468
- F * E + I * A,
469
- F * D + I * j,
470
- F * O + I * M
471
- ];
472
- return L && (R = e.normalize(R)), R;
473
- }
474
- static toString(e) {
475
- return `[${e[0].toFixed(2)}, ${e[1].toFixed(2)}, ${e[2].toFixed(2)}, ${e[3].toFixed(2)}]`;
476
- }
477
- static fromUnitVectors(C, w) {
478
- let T = Vector3.dot(C, w) + 1, E, D, O, k;
479
- T < 2 ** -52 ? (T = 0, Math.abs(C[1]) > Math.abs(C[2]) ? (E = -C[1], D = C[0], O = 0, k = T) : (E = 0, D = -C[2], O = C[1], k = T)) : (E = C[1] * w[2] - C[2] * w[1], D = C[2] * w[0] - C[0] * w[2], O = C[0] * w[1] - C[1] * w[0], k = T);
480
- let A = [
481
- k,
482
- E,
483
- D,
484
- O
485
- ];
486
- return e.normalize(A);
487
- }
488
- };
489
- __publicField$1(_Quaternion, "ROTX_PI2", _Quaternion.rotX(Math.PI / 2)), __publicField$1(_Quaternion, "ROTX_PI", _Quaternion.rotX(Math.PI)), __publicField$1(_Quaternion, "ROTX_MPI2", _Quaternion.rotX(-Math.PI / 2)), __publicField$1(_Quaternion, "ROTY_PI2", _Quaternion.rotY(Math.PI / 2)), __publicField$1(_Quaternion, "ROTY_PI", _Quaternion.rotY(Math.PI)), __publicField$1(_Quaternion, "ROTY_MPI2", _Quaternion.rotY(-Math.PI / 2)), __publicField$1(_Quaternion, "ROTZ_PI2", _Quaternion.rotZ(Math.PI / 2)), __publicField$1(_Quaternion, "ROTZ_PI", _Quaternion.rotZ(Math.PI)), __publicField$1(_Quaternion, "ROTZ_MPI2", _Quaternion.rotZ(-Math.PI / 2));
490
- var Quaternion = _Quaternion;
491
- function deg2rad(e) {
492
- return e * (Math.PI / 180);
493
- }
494
- function rad2deg(e) {
495
- return e * 180 / Math.PI;
496
- }
497
- function wrap(e, C, w) {
498
- let T = w - C, E = ((e - C) % T + T) % T + C;
499
- return E === C ? w : E;
500
- }
501
- var __defProp = Object.defineProperty, __defNormalProp = (e, C, w) => C in e ? __defProp(e, C, {
502
- enumerable: !0,
503
- configurable: !0,
504
- writable: !0,
505
- value: w
506
- }) : e[C] = w, __publicField = (e, C, w) => (__defNormalProp(e, typeof C == "symbol" ? C : C + "", w), w), R_MAJOR = 6378137, R_MINOR = 6356752.3142, EPS_DEG_MM = 1e-8, EPS_MM = .001, ELLIPSOID_FLATNESS = (R_MAJOR - R_MINOR) / R_MAJOR, ECCENTRICITY = Math.sqrt(ELLIPSOID_FLATNESS * (2 - ELLIPSOID_FLATNESS));
507
- ECCENTRICITY * ECCENTRICITY;
508
- var R_MAJOR_2 = R_MAJOR * R_MAJOR;
509
- R_MAJOR_2 * R_MAJOR_2;
510
- var R_MINOR_2 = R_MINOR * R_MINOR;
511
- R_MINOR_2 * R_MINOR_2, R_MAJOR * 2 * Math.PI;
512
- var _Level = class e {
513
- static checkType(e) {
514
- if (e !== null && !(typeof e == "number" && !isNaN(e))) {
515
- if (Array.isArray(e) && e.length === 2) {
516
- let [C, w] = e;
517
- if (typeof C == "number" && !isNaN(C) && typeof w == "number" && !isNaN(w)) {
518
- if (C > w || C === w) throw Error(`Invalid level range: [${C}, ${w}]`);
519
- return;
520
- }
521
- }
522
- throw Error(`Unknown level format: ${e}`);
523
- }
524
- }
525
- static isRange(C) {
526
- return e.VERIFY_TYPING && e.checkType(C), Array.isArray(C);
527
- }
528
- static clone(C) {
529
- return e.VERIFY_TYPING && e.checkType(C), C === null ? null : typeof C == "number" ? C : [C[0], C[1]];
530
- }
531
- static fromString(C) {
532
- if (C === null) return null;
533
- if (typeof C != "string" || !C.length) throw Error(`argument must be a non empty string, got ${typeof C}`);
534
- if (!isNaN(Number(C))) return parseFloat(C);
535
- let w = C.split(";");
536
- if (w.length > 1) {
537
- let C = w.map((e) => Number(e)), T = Math.min(...C), E = Math.max(...C);
538
- return e.checkType([T, E]), [T, E];
539
- } else {
540
- let w = C.substring(1).indexOf("-") + 1;
541
- if (w > 0) {
542
- let T = Number(C.substring(0, w)), E = Number(C.substring(w + 1));
543
- return e.checkType([T, E]), [T, E];
544
- }
545
- }
546
- throw Error(`Cannot parse following level: ${C}`);
547
- }
548
- static contains(C, w) {
549
- return e.VERIFY_TYPING && (e.checkType(C), e.checkType(w)), C === w ? !0 : Array.isArray(C) ? Array.isArray(w) ? C[0] <= w[0] && C[1] >= w[1] : w === null ? !1 : C[0] <= w && C[1] >= w : C === null || w === null ? !1 : C <= w[0] && C >= w[1];
550
- }
551
- static intersection(C, w) {
552
- if (e.VERIFY_TYPING && (e.checkType(C), e.checkType(w)), C === null || w === null) return null;
553
- if (e.equals(C, w)) return e.clone(C);
554
- if (typeof C == "number" && typeof w == "number") return C === w ? C : null;
555
- if (Array.isArray(C) && !Array.isArray(w)) return e.contains(C, w) ? w : null;
556
- if (!Array.isArray(C) && Array.isArray(w)) return e.contains(w, C) ? C : null;
557
- let T = Math.max(C[0], w[0]), E = Math.min(C[1], w[1]);
558
- return E === T ? E : E < T ? null : [T, E];
559
- }
560
- static intersect(C, w) {
561
- return e.VERIFY_TYPING && (e.checkType(C), e.checkType(w)), C === null && w === null ? !0 : e.intersection(C, w) !== null;
562
- }
563
- static union(C, w) {
564
- if (e.VERIFY_TYPING && (e.checkType(C), e.checkType(w)), C === w) return e.clone(C);
565
- if (w === null || C === null) return null;
566
- let T, E;
567
- return !Array.isArray(C) && !Array.isArray(w) ? (T = Math.min(C, w), E = Math.max(C, w)) : Array.isArray(C) && !Array.isArray(w) ? (T = Math.min(C[0], w), E = Math.max(C[1], w)) : !Array.isArray(C) && Array.isArray(w) ? (T = Math.min(w[0], C), E = Math.max(w[1], C)) : (T = Math.min(C[0], w[0]), E = Math.max(C[1], w[1])), T === E ? T : [T, E];
568
- }
569
- static multiplyBy(C, w) {
570
- return e.VERIFY_TYPING && e.checkType(C), C === null ? null : Array.isArray(C) ? [C[0] * w, C[1] * w] : C * w;
571
- }
572
- static toString(C) {
573
- return e.VERIFY_TYPING && e.checkType(C), C === null ? null : Array.isArray(C) ? C[0] + ";" + C[1] : String(C);
574
- }
575
- static equals(C, w) {
576
- return e.VERIFY_TYPING && (e.checkType(C), e.checkType(w)), C === w ? !0 : Array.isArray(C) && Array.isArray(w) ? C[0] === w[0] && C[1] === w[1] : !1;
577
- }
578
- static diff(C, w) {
579
- return e.VERIFY_TYPING && (e.checkType(C), e.checkType(w)), C === null || w === null ? null : !Array.isArray(C) && !Array.isArray(w) ? w - C : Array.isArray(C) && !Array.isArray(w) ? C[0] === w ? w - C[1] : C[1] === w ? w - C[0] : null : Array.isArray(w) && !Array.isArray(C) ? C === w[0] ? w[1] - C : C === w[1] ? w[0] - C : null : e.equals(C, w) ? 0 : null;
580
- }
581
- };
582
- __publicField(_Level, "VERIFY_TYPING", !1);
583
- var Level = _Level, Coordinates = class e {
584
- constructor(e, C, w = null, T = null) {
585
- __publicField(this, "_lat"), __publicField(this, "_lng"), __publicField(this, "_alt", null), __publicField(this, "_level", null), __publicField(this, "_heightFromFloor", null), __publicField(this, "_heightFromGround", null), __publicField(this, "_ecef"), __publicField(this, "autoWrap", !0), this.lat = e, this.lng = C, this.alt = w, this.level = T, this._ecef = null;
586
- }
587
- get lat() {
588
- return this._lat;
589
- }
590
- set lat(e) {
591
- if (Math.abs(e) <= 90) this._lat = e;
592
- else throw Error(`lat argument is not in [-90; 90], value is ${e}`);
593
- this._ecef = null;
594
- }
595
- get latitude() {
596
- return this._lat;
597
- }
598
- set latitude(e) {
599
- throw Error("Please use Coordinates#lat setter instead of Coordinate#latitude");
600
- }
601
- get lng() {
602
- return this._lng;
603
- }
604
- set lng(e) {
605
- this._lng = e, this.autoWrap && this.wrap(), this._ecef = null;
606
- }
607
- get longitude() {
608
- return this._lng;
609
- }
610
- set longitude(e) {
611
- throw Error("Please use Coordinates#lng setter instead of Coordinate#longitude");
612
- }
613
- get alt() {
614
- return this._alt;
615
- }
616
- set alt(e) {
617
- this._alt = e, this._ecef = null;
618
- }
619
- get level() {
620
- return this._level;
621
- }
622
- set level(e) {
623
- Level.checkType(e), this._level = e;
624
- }
625
- get heightFromFloor() {
626
- return this._heightFromFloor;
627
- }
628
- set heightFromFloor(e) {
629
- this._heightFromFloor = e;
630
- }
631
- get heightFromGround() {
632
- return this._heightFromGround;
633
- }
634
- set heightFromGround(e) {
635
- this._heightFromGround = e;
636
- }
637
- clone() {
638
- let C = new e(this.lat, this.lng, this.alt);
639
- return this.level !== null && (C.level = Level.clone(this.level)), C;
640
- }
641
- wrap() {
642
- (this._lng <= -180 || this._lng > 180) && (this._lng = wrap(this._lng, -180, 180));
643
- }
644
- static equals(e, C, w = EPS_DEG_MM, T = EPS_MM) {
645
- return this.equalsWithoutLevel(e, C, w, T) ? e === null || C === null ? !0 : Level.equals(e.level, C.level) : !1;
646
- }
647
- equals(C) {
648
- return e.equals(this, C);
649
- }
650
- static equalsWithoutLevel(C, w, T = EPS_DEG_MM, E = EPS_MM) {
651
- return C === null && C === w ? !0 : !(C instanceof e) || !(w instanceof e) ? !1 : Math.abs(w.lat - C.lat) < T && Math.abs(w.lng - C.lng) < T && (C.alt === w.alt || C.alt !== null && w.alt !== null && Math.abs(w.alt - C.alt) < E);
652
- }
653
- equalsWithoutLevel(C, w = EPS_DEG_MM, T = EPS_MM) {
654
- return e.equalsWithoutLevel(this, C, w, T);
655
- }
656
- destinationPoint(e, C, w = null) {
657
- let T = this.clone();
658
- return T.move(e, C, w), T;
659
- }
660
- move(e, C, w = null) {
661
- let T = e / R_MAJOR, E = Math.cos(T), D = Math.sin(T), O = deg2rad(this.lat), k = deg2rad(this.lng), A = Math.asin(Math.sin(O) * E + Math.cos(O) * D * Math.cos(C)), j = k + Math.atan2(Math.sin(C) * D * Math.cos(O), E - Math.sin(O) * Math.sin(A));
662
- if (this.lat = rad2deg(A), this.lng = rad2deg(j), w !== null) {
663
- if (this.alt === null) throw Error("Point altitude is not defined");
664
- this.alt += w;
665
- }
666
- return this;
667
- }
668
- distanceTo(e) {
669
- let C = this.lat, w = this.lng, T = e.lat, E = e.lng, D = deg2rad(T - C), O = deg2rad(E - w), k = Math.sin(O / 2), A = Math.sin(D / 2), j = deg2rad(C), M = Math.cos(j), N = deg2rad(T), P = Math.cos(N), F = A * A + M * P * k * k, I = Math.sqrt(F), L = Math.sqrt(1 - F);
670
- return R_MAJOR * (2 * Math.atan2(I, L));
671
- }
672
- static distanceBetween(e, C) {
673
- return e.distanceTo(C);
674
- }
675
- bearingTo(e) {
676
- let C = deg2rad(this.lat), w = deg2rad(e.lat), T = deg2rad(e.lng - this.lng);
677
- return Math.atan2(Math.sin(T) * Math.cos(w), Math.cos(C) * Math.sin(w) - Math.sin(C) * Math.cos(w) * Math.cos(T));
678
- }
679
- static bearingTo(e, C) {
680
- return e.bearingTo(C);
681
- }
682
- get enuToEcefRotation() {
683
- let e = Quaternion.fromAxisAngle([
684
- 0,
685
- 0,
686
- 1
687
- ], Math.PI / 2 + deg2rad(this.lng)), C = Quaternion.fromAxisAngle([
688
- 1,
689
- 0,
690
- 0
691
- ], Math.PI / 2 - deg2rad(this.lat));
692
- return Quaternion.multiply(e, C);
693
- }
694
- get ecefToEnuRotation() {
695
- let e = Quaternion.fromAxisAngle([
696
- 1,
697
- 0,
698
- 0
699
- ], deg2rad(this.lat) - Math.PI / 2), C = Quaternion.fromAxisAngle([
700
- 0,
701
- 0,
702
- 1
703
- ], -deg2rad(this.lng) - Math.PI / 2);
704
- return Quaternion.multiply(e, C);
705
- }
706
- get ecef() {
707
- if (!this._ecef) {
708
- let e = deg2rad(this.lat), C = deg2rad(this.lng), w = this.alt || 0;
709
- this._ecef = [
710
- (R_MAJOR + w) * Math.cos(e) * Math.cos(C),
711
- (R_MAJOR + w) * Math.cos(e) * Math.sin(C),
712
- (R_MAJOR + w) * Math.sin(e)
713
- ];
714
- }
715
- return this._ecef;
716
- }
717
- static fromECEF(C) {
718
- let w = C[0], T = C[1], E = C[2], D = Math.sqrt(w ** 2 + T ** 2), O = Math.atan2(T, w), k = Math.atan2(E, D), A = D / Math.cos(k) - R_MAJOR;
719
- O %= 2 * Math.PI;
720
- let j = new e(rad2deg(k), rad2deg(O), A);
721
- return j._ecef = C, j;
722
- }
723
- getSegmentProjection(C, w) {
724
- let T = Vector3.normalize(C.ecef), E = Vector3.normalize(w.ecef), D = Vector3.normalize(this.ecef), O = Vector3.cross(T, E);
725
- if (Vector3.norm(O) === 0) return null;
726
- let k = Vector3.cross(D, O), A = Vector3.normalize(Vector3.cross(O, k)), j = Vector3.multiplyScalar(A, R_MAJOR), M = e.fromECEF(j), N;
727
- C.alt !== null && w.alt !== null && (N = (C.alt + w.alt) / 2);
728
- let P = new e(M.lat, M.lng, N, Level.union(C.level, w.level));
729
- return Math.abs(C.distanceTo(w) - C.distanceTo(P) - w.distanceTo(P)) > EPS_MM ? null : P;
730
- }
731
- toString() {
732
- let e = "[" + this._lat.toFixed(7) + ", " + this._lng.toFixed(7);
733
- return this._alt !== null && (e += ", " + this._alt.toFixed(2)), this._level !== null && (e += ", [" + Level.toString(this._level) + "]"), e += "]", e;
734
- }
735
- toJson() {
736
- return {
737
- lat: Number(this.lat.toFixed(8)),
738
- lng: Number(this.lng.toFixed(8)),
739
- ...this.alt !== null && { alt: Number(this.alt.toFixed(3)) },
740
- ...this.level !== null && { level: this.level }
741
- };
742
- }
743
- static fromJson(C) {
744
- return new e(C.lat, C.lng, C.alt, C.level);
745
- }
746
- toCompressedJson() {
747
- return this.level === null ? [Number(this.lat.toFixed(8)), Number(this.lng.toFixed(8))] : [
748
- Number(this.lat.toFixed(8)),
749
- Number(this.lng.toFixed(8)),
750
- this.level
751
- ];
752
- }
753
- static fromCompressedJson(C) {
754
- let w = new e(C[0], C[1]);
755
- return C.length > 2 && (w.level = C[2]), w;
756
- }
757
- }, UserPosition = class e extends Coordinates {
758
- constructor(e, C, w = null, T = null, E = null, D = null, O = null) {
759
- super(e, C, w, T), __publicField(this, "_time", null), __publicField(this, "_accuracy", null), __publicField(this, "_bearing", null), this.time = E, this.accuracy = D, this.bearing = O;
760
- }
761
- get time() {
762
- return this._time;
763
- }
764
- set time(e) {
765
- this._time = e;
766
- }
767
- get accuracy() {
768
- return this._accuracy;
769
- }
770
- set accuracy(e) {
771
- if (e !== null && e < 0) throw Error("accuracy argument is not a positive number");
772
- this._accuracy = e;
773
- }
774
- get bearing() {
775
- return this._bearing;
776
- }
777
- set bearing(e) {
778
- this._bearing = e === null ? null : e % (2 * Math.PI);
779
- }
780
- move(e, C, w = null) {
781
- return super.move(e, C, w), this;
782
- }
783
- destinationPoint(e, C, w = null) {
784
- let T = this.clone();
785
- return T.move(e, C, w), T;
786
- }
787
- static fromCoordinates(C) {
788
- return new e(C.lat, C.lng, C.alt, C.level);
789
- }
790
- clone() {
791
- let C = e.fromCoordinates(super.clone());
792
- return C.time = this.time, C.accuracy = this.accuracy, C.bearing = this.bearing, C;
793
- }
794
- static equals(C, w, T = EPS_DEG_MM, E = EPS_MM) {
795
- return C === null && C === w ? !0 : !(C instanceof e) || !(w instanceof e) || !super.equals(C, w, T, E) ? !1 : C.time === w.time && C.accuracy === w.accuracy && C.bearing === w.bearing;
796
- }
797
- equals(C, w = EPS_DEG_MM, T = EPS_MM) {
798
- return e.equals(this, C, w, T);
799
- }
800
- toJson() {
801
- return {
802
- ...super.toJson(),
803
- ...this.time !== null && { time: this.time },
804
- ...this.accuracy !== null && { accuracy: this.accuracy },
805
- ...this.bearing !== null && { bearing: this.bearing }
806
- };
807
- }
808
- static fromJson(C) {
809
- let w = e.fromCoordinates(Coordinates.fromJson(C));
810
- return C.time !== void 0 && (w.time = C.time), C.accuracy !== void 0 && (w.accuracy = C.accuracy), C.bearing !== void 0 && (w.bearing = C.bearing), w;
811
- }
812
- };
813
218
  export { Coordinates, GnssWifiLocationSource, LocationSource, MapMatching, UserPosition, VPSLocationSource, requestLocationPermissions, requestSensorPermissions };
@@ -1,4 +1,4 @@
1
- import { Itinerary } from '@wemap/routers-legacy';
1
+ import { Itinerary } from '../../routers';
2
2
  /**
3
3
  * Map Matching utility for projecting user position onto an itinerary
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"MapMatching.d.ts","sourceRoot":"","sources":["../../src/MapMatching.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,WAAW;IAEtB,OAAO,CAAC,MAAM,CAAC,SAAS,CAA0B;IAClD;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI;IAMtD;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,YAAY,IAAI,SAAS,GAAG,IAAI;IAIvC;;;;;;;OAOG;IACH,MAAM,CAAC,cAAc,IAAI,IAAI;CAI9B"}
1
+ {"version":3,"file":"MapMatching.d.ts","sourceRoot":"","sources":["../../src/MapMatching.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,WAAW;IAEtB,OAAO,CAAC,MAAM,CAAC,SAAS,CAA0B;IAClD;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI;IAMtD;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,YAAY,IAAI,SAAS,GAAG,IAAI;IAIvC;;;;;;;OAOG;IACH,MAAM,CAAC,cAAc,IAAI,IAAI;CAI9B"}
@@ -1,5 +1,5 @@
1
1
  import { AbsolutePosition, AbsoluteAttitude } from '../../providers';
2
- import { UserPosition, Attitude } from '@wemap/geo-legacy';
2
+ import { UserPosition, Attitude } from '../../geo';
3
3
  /**
4
4
  * Complete pose data combining position, attitude, and other sensor data
5
5
  *
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEhE;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,IAAI;IACnB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,YAAY,GAAG,gBAAgB,CAAC;IAC3C,uDAAuD;IACvD,QAAQ,CAAC,EAAE,QAAQ,GAAG,gBAAgB,CAAC;IACvC,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,8EAA8E;IAC9E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gEAAgE;IAChE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB;IAC/D,2DAA2D;IAC3D,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEzD;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,IAAI;IACnB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,YAAY,GAAG,gBAAgB,CAAC;IAC3C,uDAAuD;IACvD,QAAQ,CAAC,EAAE,QAAQ,GAAG,gBAAgB,CAAC;IACvC,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,8EAA8E;IAC9E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gEAAgE;IAChE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB;IAC/D,2DAA2D;IAC3D,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B"}
@@ -1 +1 @@
1
- {"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":";AAMA,wBAeG"}
1
+ {"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":";AAMA,wBAkBG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wemap/positioning",
3
- "version": "14.1.0",
3
+ "version": "14.2.0-beta.0",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -18,13 +18,13 @@
18
18
  "dist"
19
19
  ],
20
20
  "dependencies": {
21
- "@wemap/core": "14.1.0",
22
- "@wemap/providers": "14.1.0"
21
+ "@wemap/core": "14.2.0-beta.0",
22
+ "@wemap/geo": "14.2.0-beta.0",
23
+ "@wemap/providers": "14.2.0-beta.0",
24
+ "@wemap/routers": "14.2.0-beta.0",
25
+ "@wemap/utils": "14.2.0-beta.0"
23
26
  },
24
27
  "devDependencies": {
25
- "@wemap/geo-legacy": "^13.3.0",
26
- "@wemap/maths-legacy": "^13.3.0",
27
- "@wemap/routers-legacy": "^13.3.0",
28
- "@wemap/utils-legacy": "^13.3.0"
28
+ "@wemap/maths-legacy": "^13.3.0"
29
29
  }
30
30
  }