@wemap/providers 9.0.8 → 9.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
@@ -42,6 +42,6 @@
42
42
  "url": "git+https://github.com/wemap/wemap-modules-js.git"
43
43
  },
44
44
  "type": "module",
45
- "version": "9.0.8",
46
- "gitHead": "68d42075fd79592fb762747c41a86d930a800625"
45
+ "version": "9.0.9",
46
+ "gitHead": "e51acbb8a7ae92d16f9c149562912cf7b0f6cf10"
47
47
  }
@@ -20,6 +20,9 @@ class AbsolutePosition extends Provider {
20
20
  /** @type {boolean} */
21
21
  static USE_MM_FOR_FEED = true;
22
22
 
23
+ /** @type {boolean} */
24
+ useAllAbsolutePositions = false;
25
+
23
26
  /** @type {number?} */
24
27
  _gnssWifiProviderId;
25
28
 
@@ -50,10 +53,18 @@ class AbsolutePosition extends Provider {
50
53
  * @override
51
54
  */
52
55
  get _availability() {
53
- return PromiseUtils.any([
56
+
57
+ const providersToCheck = [
54
58
  GeoRelativePositionProvider.availability,
55
59
  GnssWifi.availability
56
- ]);
60
+ ];
61
+ if (ProvidersOptions.hasPoleStar) {
62
+ providersToCheck.push(PoleStar.availability);
63
+ }
64
+ if (ProvidersOptions.hasVps) {
65
+ providersToCheck.push(Vps.availability);
66
+ }
67
+ return PromiseUtils.any(providersToCheck);
57
68
  }
58
69
 
59
70
 
@@ -156,7 +167,7 @@ class AbsolutePosition extends Provider {
156
167
  const newPosition = positionEvent.data.clone();
157
168
  const lastPosition = this.lastEvent ? this.lastEvent.data : null;
158
169
 
159
- if (lastPosition) {
170
+ if (lastPosition && !this.useAllAbsolutePositions) {
160
171
 
161
172
  // Is the new position accuracy is better enough than the last position accuracy
162
173
  const isBetterEnough = newPosition.accuracy * AbsolutePosition.ACCURACY_RELOC_RATIO <= lastPosition.accuracy;
@@ -165,7 +176,12 @@ class AbsolutePosition extends Provider {
165
176
  // This is important if the person put the current page in the background during a while
166
177
  const isFarEnough = lastPosition.distanceTo(newPosition) > lastPosition.accuracy + newPosition.accuracy;
167
178
 
168
- if (!isBetterEnough && !isFarEnough) {
179
+ // Added on 16/06/22
180
+ // The goal of this condition is to avoid continuous jumps between positions from two providers
181
+ // (i.e. GnssWifi and PoleStar)
182
+ const isFarEnoughAndAccuracyIsBetter = isFarEnough && newPosition.accuracy <= lastPosition.accuracy;
183
+
184
+ if (!isBetterEnough && !isFarEnoughAndAccuracyIsBetter) {
169
185
  return false;
170
186
  }
171
187
 
@@ -163,6 +163,10 @@ class Vps extends Provider {
163
163
  );
164
164
  const attitude = new Attitude(deviceQuaternion, res.attitude.time, res.attitude.accuracy);
165
165
 
166
+ // Added on 16/06/22: to provide a consistant accuracy for the VPS
167
+ const devicePosition = res.userPosition.clone();
168
+ devicePosition.accuracy = 10;
169
+
166
170
  // 5. Finally, notify the listeners if the VPS is not stopped
167
171
  if (this.state === ProviderState.STOPPED) {
168
172
  break;
@@ -170,7 +174,7 @@ class Vps extends Provider {
170
174
 
171
175
  this.notify(
172
176
  this.createEvent(EventType.AbsoluteAttitude, attitude),
173
- this.createEvent(EventType.AbsolutePosition, res.userPosition)
177
+ this.createEvent(EventType.AbsolutePosition, devicePosition)
174
178
  );
175
179
 
176
180
  }