@wemap/providers 11.0.0-alpha.9 → 11.0.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
@@ -749,7 +749,7 @@ class ImuProvider extends Provider {
749
749
  } = e.accelerationIncludingGravity;
750
750
  if (typeof x === "number" && typeof y === "number" && typeof z === "number") {
751
751
  acc = [x, y, z];
752
- if (utils.BrowserUtils.name === utils.Browser.SAFARI || utils.BrowserUtils.name === utils.Browser.IOS_WEBVIEW) {
752
+ if (utils.BrowserUtils.getName() === utils.Browser.SAFARI || utils.BrowserUtils.getName() === utils.Browser.IOS_WEBVIEW) {
753
753
  acc[0] *= -1;
754
754
  acc[1] *= -1;
755
755
  acc[2] *= -1;
@@ -1313,6 +1313,25 @@ const _StepProvider = class extends Provider {
1313
1313
  __publicField(this, "_algorithm", _StepProvider.DEFAULT_ALGORITHM);
1314
1314
  __publicField(this, "_accValues", []);
1315
1315
  __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
+ });
1316
1335
  this.algorithm = this._algorithm;
1317
1336
  }
1318
1337
  availability() {
@@ -1342,25 +1361,6 @@ const _StepProvider = class extends Provider {
1342
1361
  GyroscopeProvider$1.removeEventListener(this.gyroscopeProviderId);
1343
1362
  RelativeAttitudeFromInertialProvider.removeEventListener(this.attitudeProviderId);
1344
1363
  }
1345
- onAccelerometerEvent(accelerationEvent) {
1346
- if (!this.attitudeEvent || !this.angularRateEvent) {
1347
- return;
1348
- }
1349
- const {
1350
- values: acceleration,
1351
- timestamp
1352
- } = accelerationEvent;
1353
- const linearAcc = _StepProvider.computeLinearAcceleration(
1354
- this.attitudeEvent.quaternion,
1355
- acceleration
1356
- );
1357
- const stepDetected = this.stepDetector.compute(timestamp, linearAcc, this.angularRateEvent.values);
1358
- if (stepDetected) {
1359
- const size = this.stepDetector.lastStepSize * this._stepSizeMultiplier;
1360
- this.numOfSteps++;
1361
- this.notify({ size, number: this.numOfSteps });
1362
- }
1363
- }
1364
1364
  static computeLinearAcceleration(quaternion, acc) {
1365
1365
  const linearAcc = maths.Quaternion.rotateMatlab(maths.Quaternion.inverse(quaternion), acc);
1366
1366
  linearAcc[2] -= geo.Constants.EARTH_GRAVITY;
@@ -2010,7 +2010,9 @@ const _AbsolutePositionProvider = class extends Provider {
2010
2010
  start() {
2011
2011
  GeoRelativePositionProvider$1.getAvailability().then((error) => {
2012
2012
  if (!error) {
2013
- this._relativePositionProviderId = GeoRelativePositionProvider$1.addEventListener(this._onRelativePosition);
2013
+ this._relativePositionProviderId = GeoRelativePositionProvider$1.addEventListener(
2014
+ (e) => this._onRelativePosition(e)
2015
+ );
2014
2016
  }
2015
2017
  });
2016
2018
  this._gnssWifiProviderId = GnssWifiProvider$1.addEventListener(
@@ -2233,7 +2235,7 @@ class AbsoluteAttitudeFromBrowser extends Provider {
2233
2235
  }
2234
2236
  start() {
2235
2237
  const subscribe = () => {
2236
- switch (utils.BrowserUtils.name) {
2238
+ switch (utils.BrowserUtils.getName()) {
2237
2239
  case utils.Browser.CHROME:
2238
2240
  window.addEventListener(
2239
2241
  "deviceorientationabsolute",
@@ -2274,7 +2276,7 @@ class AbsoluteAttitudeFromBrowser extends Provider {
2274
2276
  }
2275
2277
  }
2276
2278
  stop() {
2277
- switch (utils.BrowserUtils.name) {
2279
+ switch (utils.BrowserUtils.getName()) {
2278
2280
  case utils.Browser.CHROME:
2279
2281
  window.removeEventListener(
2280
2282
  "deviceorientationabsolute",
@@ -2645,7 +2647,7 @@ const _MapMatchingHandler = class extends Provider {
2645
2647
  __publicField(this, "_minStepsForOrientationMatching", _MapMatchingHandler.DEFAULT_MIN_STEPS_FOR_ORIENTATION_MATCHING);
2646
2648
  __publicField(this, "_lastProjectionsWindowSize", _MapMatchingHandler.DEFAULT_LAST_PROJECTIONS_WINDOW_SIZE);
2647
2649
  __publicField(this, "_lastProjectionsEdgeAngleThreshold", _MapMatchingHandler.DEFAULT_LAST_PROJECTIONS_EDGE_ANGLE_THRESHOLD);
2648
- __publicField(this, "_mapMatching");
2650
+ __publicField(this, "_geoGraphProjectionHandler");
2649
2651
  __publicField(this, "_internalProvidersStarted", false);
2650
2652
  __publicField(this, "_straightLineProviderId");
2651
2653
  __publicField(this, "_turnProviderId");
@@ -2657,18 +2659,18 @@ const _MapMatchingHandler = class extends Provider {
2657
2659
  __publicField(this, "getName", () => "MapMatchingHandler");
2658
2660
  __publicField(this, "availability", () => Promise.resolve());
2659
2661
  __publicField(this, "_manageStartStop", () => {
2660
- if (this.network && !this._internalProvidersStarted) {
2662
+ if (this.graph && !this._internalProvidersStarted) {
2661
2663
  this._startInternalProviders();
2662
- } else if (!this.network && this._internalProvidersStarted) {
2664
+ } else if (!this.graph && this._internalProvidersStarted) {
2663
2665
  this._stopInternalProviders();
2664
2666
  }
2665
2667
  });
2666
- this._mapMatching = new geo.MapMatching();
2667
- this._mapMatching.maxDistance = _MapMatchingHandler.DEFAULT_MM_MAX_DIST;
2668
- this._mapMatching.maxAngleBearing = _MapMatchingHandler.DEFAULT_MM_MAX_ANGLE;
2668
+ this._geoGraphProjectionHandler = new geo.GeoGraphProjectionHandler();
2669
+ this._geoGraphProjectionHandler.maxDistance = _MapMatchingHandler.DEFAULT_MM_MAX_DIST;
2670
+ this._geoGraphProjectionHandler.maxAngleBearing = _MapMatchingHandler.DEFAULT_MM_MAX_ANGLE;
2669
2671
  }
2670
2672
  start() {
2671
- if (this.network) {
2673
+ if (this.graph) {
2672
2674
  this._startInternalProviders();
2673
2675
  }
2674
2676
  }
@@ -2696,19 +2698,19 @@ const _MapMatchingHandler = class extends Provider {
2696
2698
  get enabled() {
2697
2699
  return ProvidersOptions.useMapMatching;
2698
2700
  }
2699
- get network() {
2700
- return this._mapMatching.network;
2701
+ get graph() {
2702
+ return this._geoGraphProjectionHandler.graph;
2701
2703
  }
2702
- set network(network) {
2703
- this._mapMatching.network = network;
2704
+ set graph(graph) {
2705
+ this._geoGraphProjectionHandler.graph = graph;
2704
2706
  this._itineraryInfoManager = null;
2705
- this.notify({ ...network && { network } });
2707
+ this.notify({ ...graph && { graph } });
2706
2708
  this._manageStartStop();
2707
2709
  if (this.canUseMapMatching())
2708
2710
  ;
2709
2711
  }
2710
2712
  set itinerary(itinerary) {
2711
- this._mapMatching.network = itinerary ? itinerary.toNetwork() : null;
2713
+ this._geoGraphProjectionHandler.graph = itinerary ? itinerary.toGraph() : null;
2712
2714
  this._itineraryInfoManager = new routers.ItineraryInfoManager(itinerary);
2713
2715
  this.notify({ ...itinerary && { itinerary } });
2714
2716
  this._manageStartStop();
@@ -2717,7 +2719,7 @@ const _MapMatchingHandler = class extends Provider {
2717
2719
  }
2718
2720
  }
2719
2721
  canUseMapMatching() {
2720
- return this.enabled && this.network;
2722
+ return this.enabled && this.graph;
2721
2723
  }
2722
2724
  _notifyPositionFromItineraryInput(itinerary) {
2723
2725
  if (!this._useItineraryStartAsPosition || itinerary.from) {
@@ -2854,7 +2856,7 @@ const _MapMatchingHandler = class extends Provider {
2854
2856
  }
2855
2857
  const firstProjection = this._lastProjections[0];
2856
2858
  return !this._lastProjections.some(
2857
- (projection) => !(projection.nearestElement instanceof geo.GraphEdge) || !(firstProjection.nearestElement instanceof geo.GraphEdge) || maths.diffAngleLines(projection.nearestElement.bearing, firstProjection.nearestElement.bearing) > this._lastProjectionsEdgeAngleThreshold
2859
+ (projection) => !(projection.nearestElement instanceof geo.GeoGraphEdge) || !(firstProjection.nearestElement instanceof geo.GeoGraphEdge) || maths.diffAngleLines(projection.nearestElement.bearing, firstProjection.nearestElement.bearing) > this._lastProjectionsEdgeAngleThreshold
2858
2860
  );
2859
2861
  }
2860
2862
  _nodeHasTurn(node) {
@@ -2870,12 +2872,12 @@ const _MapMatchingHandler = class extends Provider {
2870
2872
  return false;
2871
2873
  }
2872
2874
  _hasTurnInCircle(center, radius) {
2873
- const network = this._mapMatching.network;
2875
+ const network = this._geoGraphProjectionHandler.graph;
2874
2876
  if (!network) {
2875
2877
  return false;
2876
2878
  }
2877
- return network.nodes.filter(
2878
- (node) => node.coords.distanceTo(center) <= radius && geo.Level.intersect(node.coords.level, center.level)
2879
+ return network.vertices.filter(
2880
+ (vertex) => vertex.coords.distanceTo(center) <= radius && geo.Level.intersect(vertex.coords.level, center.level)
2879
2881
  ).some(this._nodeHasTurn);
2880
2882
  }
2881
2883
  tryOrientationMatching(projection) {
@@ -2886,7 +2888,7 @@ const _MapMatchingHandler = class extends Provider {
2886
2888
  return;
2887
2889
  }
2888
2890
  const { nearestElement, origin } = projection;
2889
- if (!(nearestElement instanceof geo.GraphEdge)) {
2891
+ if (!(nearestElement instanceof geo.GeoGraphEdge)) {
2890
2892
  return;
2891
2893
  }
2892
2894
  let matchingDirection;
@@ -2906,13 +2908,13 @@ const _MapMatchingHandler = class extends Provider {
2906
2908
  this._countStepsFromLastMatching = 0;
2907
2909
  }
2908
2910
  getProjection(position, useDistance, useBearing) {
2909
- return this._mapMatching.getProjection(position, useDistance, useBearing);
2911
+ return this._geoGraphProjectionHandler.getProjection(position, useDistance, useBearing);
2910
2912
  }
2911
2913
  get maxDistance() {
2912
- return this._mapMatching.maxDistance;
2914
+ return this._geoGraphProjectionHandler.maxDistance;
2913
2915
  }
2914
2916
  set maxDistance(maxDistance) {
2915
- this._mapMatching.maxDistance = maxDistance;
2917
+ this._geoGraphProjectionHandler.maxDistance = maxDistance;
2916
2918
  }
2917
2919
  get minDistance() {
2918
2920
  return this._mapMatchingMinDistance;
@@ -2921,10 +2923,10 @@ const _MapMatchingHandler = class extends Provider {
2921
2923
  this._mapMatchingMinDistance = minDistance;
2922
2924
  }
2923
2925
  get maxAngleBearing() {
2924
- return this._mapMatching.maxAngleBearing;
2926
+ return this._geoGraphProjectionHandler.maxAngleBearing;
2925
2927
  }
2926
2928
  set maxAngleBearing(maxAngleBearing) {
2927
- this._mapMatching.maxAngleBearing = maxAngleBearing;
2929
+ this._geoGraphProjectionHandler.maxAngleBearing = maxAngleBearing;
2928
2930
  }
2929
2931
  get useItineraryStartAsPosition() {
2930
2932
  return this._useItineraryStartAsPosition;
@@ -3266,6 +3268,7 @@ exports.RelativeAttitudeFromBrowserProvider = RelativeAttitudeFromBrowser$1;
3266
3268
  exports.RelativeAttitudeFromEkfProvider = RelativeAttitudeFromEkfProvider;
3267
3269
  exports.RelativeAttitudeFromInertialProvider = RelativeAttitudeFromInertialProvider;
3268
3270
  exports.RelativeAttitudeProvider = RelativeAttitudeProvider$1;
3271
+ exports.RelativeRotationCalc = RelativeRotationCalc;
3269
3272
  exports.StepDetectionMinMaxPeaks2 = StepDetectionMinMaxPeaks2;
3270
3273
  exports.StepDetectionMinMaxPeaks3 = StepDetectionMinMaxPeaks3;
3271
3274
  exports.StepProvider = StepProvider$1;