@wemap/providers 11.0.0-alpha.26 → 11.0.0-alpha.4

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
@@ -307,7 +307,6 @@ const Constants = {
307
307
  const _GnssWifiProvider = class extends Provider {
308
308
  constructor() {
309
309
  super(...arguments);
310
- __publicField(this, "discardPositionsAbove", _GnssWifiProvider.DEFAULT_DISCARD_POSITIONS_ABOVE);
311
310
  __publicField(this, "geoLocationId");
312
311
  __publicField(this, "getName", () => "GnssWifi");
313
312
  __publicField(this, "onNewPosition", (geolocation) => {
@@ -329,9 +328,6 @@ const _GnssWifiProvider = class extends Provider {
329
328
  coords.accuracy,
330
329
  bearing
331
330
  );
332
- if (typeof this.discardPositionsAbove === "number" && coords.accuracy > this.discardPositionsAbove) {
333
- return;
334
- }
335
331
  this.notify(position);
336
332
  });
337
333
  __publicField(this, "onPositionError", (error) => {
@@ -374,7 +370,6 @@ __publicField(GnssWifiProvider, "POSITION_OPTIONS", {
374
370
  timeout: Infinity,
375
371
  maximumAge: 0
376
372
  });
377
- __publicField(GnssWifiProvider, "DEFAULT_DISCARD_POSITIONS_ABOVE", 50);
378
373
  const GnssWifiProvider$1 = new GnssWifiProvider();
379
374
  const _MissingArCoreError = class extends Error {
380
375
  constructor(message) {
@@ -749,7 +744,7 @@ class ImuProvider extends Provider {
749
744
  } = e.accelerationIncludingGravity;
750
745
  if (typeof x === "number" && typeof y === "number" && typeof z === "number") {
751
746
  acc = [x, y, z];
752
- if (utils.BrowserUtils.getName() === utils.Browser.SAFARI || utils.BrowserUtils.getName() === utils.Browser.IOS_WEBVIEW) {
747
+ if (utils.BrowserUtils.name === utils.Browser.SAFARI || utils.BrowserUtils.name === utils.Browser.IOS_WEBVIEW) {
753
748
  acc[0] *= -1;
754
749
  acc[1] *= -1;
755
750
  acc[2] *= -1;
@@ -1313,25 +1308,6 @@ const _StepProvider = class extends Provider {
1313
1308
  __publicField(this, "_algorithm", _StepProvider.DEFAULT_ALGORITHM);
1314
1309
  __publicField(this, "_accValues", []);
1315
1310
  __publicField(this, "getName", () => "StepDetector");
1316
- __publicField(this, "onAccelerometerEvent", (accelerationEvent) => {
1317
- if (!this.attitudeEvent || !this.angularRateEvent) {
1318
- return;
1319
- }
1320
- const {
1321
- values: acceleration,
1322
- timestamp
1323
- } = accelerationEvent;
1324
- const linearAcc = _StepProvider.computeLinearAcceleration(
1325
- this.attitudeEvent.quaternion,
1326
- acceleration
1327
- );
1328
- const stepDetected = this.stepDetector.compute(timestamp, linearAcc, this.angularRateEvent.values);
1329
- if (stepDetected) {
1330
- const size = this.stepDetector.lastStepSize * this._stepSizeMultiplier;
1331
- this.numOfSteps++;
1332
- this.notify({ size, number: this.numOfSteps });
1333
- }
1334
- });
1335
1311
  this.algorithm = this._algorithm;
1336
1312
  }
1337
1313
  availability() {
@@ -1361,6 +1337,25 @@ const _StepProvider = class extends Provider {
1361
1337
  GyroscopeProvider$1.removeEventListener(this.gyroscopeProviderId);
1362
1338
  RelativeAttitudeFromInertialProvider.removeEventListener(this.attitudeProviderId);
1363
1339
  }
1340
+ onAccelerometerEvent(accelerationEvent) {
1341
+ if (!this.attitudeEvent || !this.angularRateEvent) {
1342
+ return;
1343
+ }
1344
+ const {
1345
+ values: acceleration,
1346
+ timestamp
1347
+ } = accelerationEvent;
1348
+ const linearAcc = _StepProvider.computeLinearAcceleration(
1349
+ this.attitudeEvent.quaternion,
1350
+ acceleration
1351
+ );
1352
+ const stepDetected = this.stepDetector.compute(timestamp, linearAcc, this.angularRateEvent.values);
1353
+ if (stepDetected) {
1354
+ const size = this.stepDetector.lastStepSize * this._stepSizeMultiplier;
1355
+ this.numOfSteps++;
1356
+ this.notify({ size, number: this.numOfSteps });
1357
+ }
1358
+ }
1364
1359
  static computeLinearAcceleration(quaternion, acc) {
1365
1360
  const linearAcc = maths.Quaternion.rotateMatlab(maths.Quaternion.inverse(quaternion), acc);
1366
1361
  linearAcc[2] -= geo.Constants.EARTH_GRAVITY;
@@ -2010,9 +2005,7 @@ const _AbsolutePositionProvider = class extends Provider {
2010
2005
  start() {
2011
2006
  GeoRelativePositionProvider$1.getAvailability().then((error) => {
2012
2007
  if (!error) {
2013
- this._relativePositionProviderId = GeoRelativePositionProvider$1.addEventListener(
2014
- (e) => this._onRelativePosition(e)
2015
- );
2008
+ this._relativePositionProviderId = GeoRelativePositionProvider$1.addEventListener(this._onRelativePosition);
2016
2009
  }
2017
2010
  });
2018
2011
  this._gnssWifiProviderId = GnssWifiProvider$1.addEventListener(
@@ -2235,7 +2228,7 @@ class AbsoluteAttitudeFromBrowser extends Provider {
2235
2228
  }
2236
2229
  start() {
2237
2230
  const subscribe = () => {
2238
- switch (utils.BrowserUtils.getName()) {
2231
+ switch (utils.BrowserUtils.name) {
2239
2232
  case utils.Browser.CHROME:
2240
2233
  window.addEventListener(
2241
2234
  "deviceorientationabsolute",
@@ -2276,7 +2269,7 @@ class AbsoluteAttitudeFromBrowser extends Provider {
2276
2269
  }
2277
2270
  }
2278
2271
  stop() {
2279
- switch (utils.BrowserUtils.getName()) {
2272
+ switch (utils.BrowserUtils.name) {
2280
2273
  case utils.Browser.CHROME:
2281
2274
  window.removeEventListener(
2282
2275
  "deviceorientationabsolute",
@@ -2647,7 +2640,7 @@ const _MapMatchingHandler = class extends Provider {
2647
2640
  __publicField(this, "_minStepsForOrientationMatching", _MapMatchingHandler.DEFAULT_MIN_STEPS_FOR_ORIENTATION_MATCHING);
2648
2641
  __publicField(this, "_lastProjectionsWindowSize", _MapMatchingHandler.DEFAULT_LAST_PROJECTIONS_WINDOW_SIZE);
2649
2642
  __publicField(this, "_lastProjectionsEdgeAngleThreshold", _MapMatchingHandler.DEFAULT_LAST_PROJECTIONS_EDGE_ANGLE_THRESHOLD);
2650
- __publicField(this, "_geoGraphProjectionHandler");
2643
+ __publicField(this, "_mapMatching");
2651
2644
  __publicField(this, "_internalProvidersStarted", false);
2652
2645
  __publicField(this, "_straightLineProviderId");
2653
2646
  __publicField(this, "_turnProviderId");
@@ -2659,18 +2652,18 @@ const _MapMatchingHandler = class extends Provider {
2659
2652
  __publicField(this, "getName", () => "MapMatchingHandler");
2660
2653
  __publicField(this, "availability", () => Promise.resolve());
2661
2654
  __publicField(this, "_manageStartStop", () => {
2662
- if (this.graph && !this._internalProvidersStarted) {
2655
+ if (this.network && !this._internalProvidersStarted) {
2663
2656
  this._startInternalProviders();
2664
- } else if (!this.graph && this._internalProvidersStarted) {
2657
+ } else if (!this.network && this._internalProvidersStarted) {
2665
2658
  this._stopInternalProviders();
2666
2659
  }
2667
2660
  });
2668
- this._geoGraphProjectionHandler = new geo.GeoGraphProjectionHandler();
2669
- this._geoGraphProjectionHandler.maxDistance = _MapMatchingHandler.DEFAULT_MM_MAX_DIST;
2670
- this._geoGraphProjectionHandler.maxAngleBearing = _MapMatchingHandler.DEFAULT_MM_MAX_ANGLE;
2661
+ this._mapMatching = new geo.MapMatching();
2662
+ this._mapMatching.maxDistance = _MapMatchingHandler.DEFAULT_MM_MAX_DIST;
2663
+ this._mapMatching.maxAngleBearing = _MapMatchingHandler.DEFAULT_MM_MAX_ANGLE;
2671
2664
  }
2672
2665
  start() {
2673
- if (this.graph) {
2666
+ if (this.network) {
2674
2667
  this._startInternalProviders();
2675
2668
  }
2676
2669
  }
@@ -2698,19 +2691,19 @@ const _MapMatchingHandler = class extends Provider {
2698
2691
  get enabled() {
2699
2692
  return ProvidersOptions.useMapMatching;
2700
2693
  }
2701
- get graph() {
2702
- return this._geoGraphProjectionHandler.graph;
2694
+ get network() {
2695
+ return this._mapMatching.network;
2703
2696
  }
2704
- set graph(graph) {
2705
- this._geoGraphProjectionHandler.graph = graph;
2697
+ set network(network) {
2698
+ this._mapMatching.network = network;
2706
2699
  this._itineraryInfoManager = null;
2707
- this.notify({ ...graph && { graph } });
2700
+ this.notify({ ...network && { network } });
2708
2701
  this._manageStartStop();
2709
2702
  if (this.canUseMapMatching())
2710
2703
  ;
2711
2704
  }
2712
2705
  set itinerary(itinerary) {
2713
- this._geoGraphProjectionHandler.graph = itinerary ? itinerary.toGraph() : null;
2706
+ this._mapMatching.network = itinerary ? itinerary.toNetwork() : null;
2714
2707
  this._itineraryInfoManager = new routers.ItineraryInfoManager(itinerary);
2715
2708
  this.notify({ ...itinerary && { itinerary } });
2716
2709
  this._manageStartStop();
@@ -2719,7 +2712,7 @@ const _MapMatchingHandler = class extends Provider {
2719
2712
  }
2720
2713
  }
2721
2714
  canUseMapMatching() {
2722
- return this.enabled && this.graph;
2715
+ return this.enabled && this.network;
2723
2716
  }
2724
2717
  _notifyPositionFromItineraryInput(itinerary) {
2725
2718
  if (!this._useItineraryStartAsPosition || itinerary.from) {
@@ -2856,7 +2849,7 @@ const _MapMatchingHandler = class extends Provider {
2856
2849
  }
2857
2850
  const firstProjection = this._lastProjections[0];
2858
2851
  return !this._lastProjections.some(
2859
- (projection) => !(projection.nearestElement instanceof geo.GeoGraphEdge) || !(firstProjection.nearestElement instanceof geo.GeoGraphEdge) || maths.diffAngleLines(projection.nearestElement.bearing, firstProjection.nearestElement.bearing) > this._lastProjectionsEdgeAngleThreshold
2852
+ (projection) => !(projection.nearestElement instanceof geo.GraphEdge) || !(firstProjection.nearestElement instanceof geo.GraphEdge) || maths.diffAngleLines(projection.nearestElement.bearing, firstProjection.nearestElement.bearing) > this._lastProjectionsEdgeAngleThreshold
2860
2853
  );
2861
2854
  }
2862
2855
  _nodeHasTurn(node) {
@@ -2872,12 +2865,12 @@ const _MapMatchingHandler = class extends Provider {
2872
2865
  return false;
2873
2866
  }
2874
2867
  _hasTurnInCircle(center, radius) {
2875
- const network = this._geoGraphProjectionHandler.graph;
2868
+ const network = this._mapMatching.network;
2876
2869
  if (!network) {
2877
2870
  return false;
2878
2871
  }
2879
- return network.vertices.filter(
2880
- (vertex) => vertex.coords.distanceTo(center) <= radius && geo.Level.intersect(vertex.coords.level, center.level)
2872
+ return network.nodes.filter(
2873
+ (node) => node.coords.distanceTo(center) <= radius && geo.Level.intersect(node.coords.level, center.level)
2881
2874
  ).some(this._nodeHasTurn);
2882
2875
  }
2883
2876
  tryOrientationMatching(projection) {
@@ -2888,7 +2881,7 @@ const _MapMatchingHandler = class extends Provider {
2888
2881
  return;
2889
2882
  }
2890
2883
  const { nearestElement, origin } = projection;
2891
- if (!(nearestElement instanceof geo.GeoGraphEdge)) {
2884
+ if (!(nearestElement instanceof geo.GraphEdge)) {
2892
2885
  return;
2893
2886
  }
2894
2887
  let matchingDirection;
@@ -2908,13 +2901,13 @@ const _MapMatchingHandler = class extends Provider {
2908
2901
  this._countStepsFromLastMatching = 0;
2909
2902
  }
2910
2903
  getProjection(position, useDistance, useBearing) {
2911
- return this._geoGraphProjectionHandler.getProjection(position, useDistance, useBearing);
2904
+ return this._mapMatching.getProjection(position, useDistance, useBearing);
2912
2905
  }
2913
2906
  get maxDistance() {
2914
- return this._geoGraphProjectionHandler.maxDistance;
2907
+ return this._mapMatching.maxDistance;
2915
2908
  }
2916
2909
  set maxDistance(maxDistance) {
2917
- this._geoGraphProjectionHandler.maxDistance = maxDistance;
2910
+ this._mapMatching.maxDistance = maxDistance;
2918
2911
  }
2919
2912
  get minDistance() {
2920
2913
  return this._mapMatchingMinDistance;
@@ -2923,10 +2916,10 @@ const _MapMatchingHandler = class extends Provider {
2923
2916
  this._mapMatchingMinDistance = minDistance;
2924
2917
  }
2925
2918
  get maxAngleBearing() {
2926
- return this._geoGraphProjectionHandler.maxAngleBearing;
2919
+ return this._mapMatching.maxAngleBearing;
2927
2920
  }
2928
2921
  set maxAngleBearing(maxAngleBearing) {
2929
- this._geoGraphProjectionHandler.maxAngleBearing = maxAngleBearing;
2922
+ this._mapMatching.maxAngleBearing = maxAngleBearing;
2930
2923
  }
2931
2924
  get useItineraryStartAsPosition() {
2932
2925
  return this._useItineraryStartAsPosition;
@@ -3268,7 +3261,6 @@ exports.RelativeAttitudeFromBrowserProvider = RelativeAttitudeFromBrowser$1;
3268
3261
  exports.RelativeAttitudeFromEkfProvider = RelativeAttitudeFromEkfProvider;
3269
3262
  exports.RelativeAttitudeFromInertialProvider = RelativeAttitudeFromInertialProvider;
3270
3263
  exports.RelativeAttitudeProvider = RelativeAttitudeProvider$1;
3271
- exports.RelativeRotationCalc = RelativeRotationCalc;
3272
3264
  exports.StepDetectionMinMaxPeaks2 = StepDetectionMinMaxPeaks2;
3273
3265
  exports.StepDetectionMinMaxPeaks3 = StepDetectionMinMaxPeaks3;
3274
3266
  exports.StepProvider = StepProvider$1;