@wemap/providers 6.1.3 → 6.1.5

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
@@ -40,6 +40,6 @@
40
40
  "url": "git+https://github.com/wemap/wemap-modules-js.git"
41
41
  },
42
42
  "type": "module",
43
- "version": "6.1.3",
44
- "gitHead": "98aaf7ce4508834258b528bbf9dca90b0045f882"
43
+ "version": "6.1.5",
44
+ "gitHead": "ced426a15d74dddbe89fead70c632bb85286c246"
45
45
  }
@@ -136,6 +136,8 @@ class ProvidersInterface {
136
136
  throw errorFn('Itinerary');
137
137
  }
138
138
  break;
139
+ case EventType.ForceVps:
140
+ break;
139
141
  default:
140
142
  throw new Error(`Unable to deal with this event type: ${eventType}`);
141
143
  }
@@ -8,6 +8,7 @@ import MapMatchingHandler from '../../../mapmatching/MapMatchingHandler.js';
8
8
  import GnssWifi from './GnssWifi.js';
9
9
  import { default as GeoRelativePositionProvider } from '../relative/GeoRelativePosition.js';
10
10
  import ProvidersOptions from '../../../ProvidersOptions.js';
11
+ import ProviderState from '../../ProviderState.js';
11
12
  import Vps from '../../vision/Vps.js';
12
13
 
13
14
  class AbsolutePosition extends Provider {
@@ -126,7 +127,7 @@ class AbsolutePosition extends Provider {
126
127
  if (lastPosition) {
127
128
 
128
129
  // Is the new position accuracy is better enough than the last position accuracy
129
- const isBetterEnough = newPosition.accuracy * AbsolutePosition.ACCURACY_RELOC_RATIO < lastPosition.accuracy;
130
+ const isBetterEnough = newPosition.accuracy * AbsolutePosition.ACCURACY_RELOC_RATIO <= lastPosition.accuracy;
130
131
 
131
132
  // Is the new position is far from the new one (regarding accuracy)
132
133
  // This is important if the person put the current page in the background during a while
@@ -212,15 +213,16 @@ class AbsolutePosition extends Provider {
212
213
  /** @type {ProviderEvent<UserPosition>} */
213
214
  let newPositionEvent;
214
215
 
215
- if (eventType === EventType.ForceVps && !this._vpsProviderId) {
216
-
217
- this._waitUntilNextVpsPosition = true;
218
- this._vpsProviderId = Vps.addEventListener(events => {
219
- this._waitUntilNextVpsPosition = false;
220
- this._onAbsolutePosition(events.find(event => event.dataType === EventType.AbsolutePosition));
221
- Vps.removeEventListener(this._vpsProviderId);
222
- this._vpsProviderId = null;
223
- });
216
+ if (eventType === EventType.ForceVps) {
217
+ if (!this._vpsProviderId && this.state === ProviderState.STARTED) {
218
+ this._waitUntilNextVpsPosition = true;
219
+ this._vpsProviderId = Vps.addEventListener(events => {
220
+ this._waitUntilNextVpsPosition = false;
221
+ this._onAbsolutePosition(events.find(event => event.dataType === EventType.AbsolutePosition));
222
+ Vps.removeEventListener(this._vpsProviderId);
223
+ this._vpsProviderId = null;
224
+ });
225
+ }
224
226
 
225
227
  return;
226
228