@wemap/providers 4.0.6 → 4.0.9

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/package.json CHANGED
@@ -39,6 +39,6 @@
39
39
  "url": "git+https://github.com/wemap/wemap-modules-js.git"
40
40
  },
41
41
  "type": "module",
42
- "version": "4.0.6",
43
- "gitHead": "e6f232b824b7c2caabf0aefd719855a75f94b702"
42
+ "version": "4.0.9",
43
+ "gitHead": "8c9f26f91219a445be8f98be753d7c88bbde01c9"
44
44
  }
@@ -24,6 +24,20 @@ class TurnDetector extends Provider {
24
24
  return 'TurnDetector';
25
25
  }
26
26
 
27
+ /**
28
+ * @override
29
+ */
30
+ static get eventsType() {
31
+ return [EventType.Turn];
32
+ }
33
+
34
+ /**
35
+ * @override
36
+ */
37
+ get _availability() {
38
+ return RelativeAttitude.availability;
39
+ }
40
+
27
41
  /**
28
42
  * @override
29
43
  */
@@ -84,7 +84,7 @@ class AbsoluteAttitude extends Provider {
84
84
  events => this._onRelativeAttitudeEvent(events[0]),
85
85
  error => {
86
86
  this._attitudeFromRelativeErrored = true;
87
- this.notifyError(error);
87
+ this.onError(error);
88
88
  }
89
89
  );
90
90
 
@@ -38,7 +38,8 @@ class RelativeAttitudeFromInertial extends Provider {
38
38
  get _availability() {
39
39
  return PromiseUtils.any([
40
40
  RelativeAttitudeFromEkf.availability,
41
- RelativeAttitudeFromBrowser.availability
41
+ RelativeAttitudeFromBrowser.availability,
42
+ HighRotationsDetector.availability
42
43
  ]);
43
44
  }
44
45
 
@@ -55,7 +56,10 @@ class RelativeAttitudeFromInertial extends Provider {
55
56
  events => this._parseEvent(events[0]),
56
57
  error => this.notifyError(error)
57
58
  );
58
- this._highRotationsDetector = HighRotationsDetector.addEventListener();
59
+ this._highRotationsDetector = HighRotationsDetector.addEventListener(
60
+ () => {},
61
+ error => this.notifyError(error)
62
+ );
59
63
  });
60
64
  }
61
65
 
@@ -19,6 +19,21 @@ class HighRotationsDetector extends Provider {
19
19
  return 'HighRotationsDetector';
20
20
  }
21
21
 
22
+
23
+ /**
24
+ * @override
25
+ */
26
+ static get eventsType() {
27
+ return [EventType.HighRotation];
28
+ }
29
+
30
+ /**
31
+ * @override
32
+ */
33
+ get _availability() {
34
+ return Gyroscope.availability;
35
+ }
36
+
22
37
  /**
23
38
  * @override
24
39
  */
@@ -100,8 +100,14 @@ class AbsolutePosition extends Provider {
100
100
 
101
101
  if (lastPosition) {
102
102
 
103
- // Reject if the new position accuracy is not twice better than the last position accuracy
104
- if (newPosition.accuracy * AbsolutePosition.ACCURACY_RELOC_RATIO > lastPosition.accuracy) {
103
+ // Is the new position accuracy is better enough than the last position accuracy
104
+ const isBetterEnough = newPosition.accuracy * AbsolutePosition.ACCURACY_RELOC_RATIO < lastPosition.accuracy;
105
+
106
+ // Is the new position is far from the new one (regarding accuracy)
107
+ // This is important if the person put the current page in the background during a while
108
+ const isFarEnough = lastPosition.distanceTo(newPosition) > lastPosition.accuracy + newPosition.accuracy;
109
+
110
+ if (!isBetterEnough && !isFarEnough) {
105
111
  return;
106
112
  }
107
113