@wemap/providers 10.0.0 → 10.1.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.
@@ -1,4 +1,5 @@
1
1
  import { Evented } from 'mapbox-gl';
2
+ import Logger from '@wemap/logger';
2
3
  import {
3
4
  PositionSmoother, AbsoluteAttitude, AbsolutePosition
4
5
  } from '@wemap/providers';
@@ -22,7 +23,8 @@ export default class CustomMapProvider extends Evented {
22
23
  * Attitude
23
24
  */
24
25
  this.attitudeProviderId = AbsoluteAttitude.addEventListener(
25
- events => this.fire('heading.changed', { heading: events[0].data.headingDegrees })
26
+ events => this.fire('heading.changed', { heading: events[0].data.headingDegrees }),
27
+ Logger.warn
26
28
  );
27
29
 
28
30
  // There is no sense to show the last known attitude on the map
@@ -38,7 +40,8 @@ export default class CustomMapProvider extends Evented {
38
40
  });
39
41
 
40
42
  this.positionProviderId = AbsolutePosition.addEventListener(
41
- events => this.smoother.feed(events[0].data)
43
+ events => this.smoother.feed(events[0].data),
44
+ Logger.warn
42
45
  );
43
46
 
44
47
  const lastKnownPosition = AbsolutePosition.lastEvent ? AbsolutePosition.lastEvent.data : null;
package/package.json CHANGED
@@ -8,15 +8,15 @@
8
8
  "Guillaume Pannetier <guillaume.pannetier@getwemap.com>"
9
9
  ],
10
10
  "dependencies": {
11
- "@wemap/camera": "^10.0.0",
12
- "@wemap/geo": "^10.0.0",
11
+ "@wemap/camera": "^10.1.0",
12
+ "@wemap/geo": "^10.1.0",
13
13
  "@wemap/geomagnetism": "^0.1.1",
14
14
  "@wemap/logger": "^10.0.0",
15
- "@wemap/map": "^10.0.0",
15
+ "@wemap/map": "^10.1.0",
16
16
  "@wemap/maths": "^10.0.0",
17
- "@wemap/osm": "^10.0.0",
18
- "@wemap/routers": "^10.0.0",
19
- "@wemap/utils": "^10.0.0"
17
+ "@wemap/osm": "^10.1.0",
18
+ "@wemap/routers": "^10.1.0",
19
+ "@wemap/utils": "^10.1.0"
20
20
  },
21
21
  "description": "A package using different geoloc systems",
22
22
  "devDependencies": {
@@ -42,6 +42,6 @@
42
42
  "url": "git+https://github.com/wemap/wemap-modules-js.git"
43
43
  },
44
44
  "type": "module",
45
- "version": "10.0.0",
46
- "gitHead": "dabdfdf7dbb6dcdf507ec148160ef228457b0519"
45
+ "version": "10.1.0",
46
+ "gitHead": "881fa193f9c7bd2ea6a202bb207ca97cc0bac2dd"
47
47
  }
@@ -94,7 +94,6 @@ class ProvidersInterface {
94
94
  return AbsoluteAttitude;
95
95
 
96
96
  case EventType.AbsolutePosition:
97
- case EventType.ForceVps:
98
97
  return AbsolutePosition;
99
98
 
100
99
  case EventType.RelativeAttitude:
@@ -150,8 +149,6 @@ class ProvidersInterface {
150
149
  throw errorFn('Itinerary');
151
150
  }
152
151
  break;
153
- case EventType.ForceVps:
154
- break;
155
152
  default:
156
153
  throw new Error(`Unable to deal with this event type: ${eventType}`);
157
154
  }
@@ -12,7 +12,7 @@ const ProvidersOptions = {
12
12
  ignoreProviders: [],
13
13
 
14
14
  /**
15
- * Some providers are not used by default (VPS, QRCodeScanner) because they
15
+ * Some providers are not used by default (i.e. PoleStar) because they
16
16
  * require data from an optional external service or because they drain more
17
17
  * battery. They can be added to this list to be used
18
18
  * List of {@link Provider#pname}
@@ -34,10 +34,6 @@ const ProvidersOptions = {
34
34
 
35
35
  smoother: true,
36
36
 
37
- get hasVps() {
38
- return this.optionalProviders.includes('Vps');
39
- },
40
-
41
37
  get hasPoleStar() {
42
38
  return this.optionalProviders.includes('PoleStar');
43
39
  }
@@ -34,7 +34,5 @@ export default {
34
34
  CameraNative: 'CAMERA_NATIVE',
35
35
 
36
36
  Itinerary: 'ITINERARY',
37
- Network: 'NETWORK',
38
-
39
- ForceVps: 'FORCE_VPS'
37
+ Network: 'NETWORK'
40
38
  };
@@ -623,14 +623,6 @@ class MapMatchingHandler extends Provider {
623
623
  this._disableMMCloseToATurnDistance = disableMMCloseToATurnDistance;
624
624
  }
625
625
 
626
- get useOrientationMatching() {
627
- return this._useOrientationMatching;
628
- }
629
-
630
- set useOrientationMatching(useOrientationMatching) {
631
- this._useOrientationMatching = useOrientationMatching;
632
- }
633
-
634
626
  get minStepsBetweenOrientationMatching() {
635
627
  return this._minStepsBetweenOrientationMatching;
636
628
  }
@@ -144,12 +144,12 @@ class Provider {
144
144
 
145
145
  /**
146
146
  *
147
- * @param {onEventsFunction} onEvents
148
- * @param {Function} onError
147
+ * @param {onEventsFunction|null|undefined} onEvents
148
+ * @param {Function|null|undefined} onError
149
149
  * @param {Boolean} startIfNecessary
150
150
  * @returns {Number}
151
151
  */
152
- addEventListener(onEvents = () => { }, onError = () => { }, startIfNecessary = true) {
152
+ addEventListener(onEvents = null, onError = null, startIfNecessary = true) {
153
153
  const id = ++Provider._callbackUniqueId;
154
154
 
155
155
  /**
@@ -157,8 +157,8 @@ class Provider {
157
157
  */
158
158
  this._eventsCallbacks.push({
159
159
  id,
160
- onEvents,
161
- onError,
160
+ onEvents: onEvents || (() => {}),
161
+ onError: onError || (() => {}),
162
162
  optional: !startIfNecessary
163
163
  });
164
164
 
@@ -9,7 +9,6 @@ import RelativeAttitude from '../relative/RelativeAttitude.js';
9
9
  import Inclination from '../../inclination/Inclination.js';
10
10
  import ProviderEvent from '../../../events/ProviderEvent.js';
11
11
  import HighRotationsDetector from '../../imu/HighRotationsDetector.js';
12
- import ProvidersOptions from '../../../ProvidersOptions.js';
13
12
  import Vps from '../../vision/vps/Vps.js';
14
13
  import AvailabilityHelper from '../../../events/AvailabilityHelper.js';
15
14
 
@@ -101,13 +100,11 @@ class AbsoluteAttitude extends Provider {
101
100
  );
102
101
 
103
102
  // Vps
104
- if (ProvidersOptions.hasVps) {
105
- this._vpsProviderId = Vps.addEventListener(
106
- events => this._onAttitudeFromVps(events.find(event => event.dataType === EventType.AbsoluteAttitude)),
107
- error => this.notifyError(error),
108
- false
109
- );
110
- }
103
+ this._vpsProviderId = Vps.addEventListener(
104
+ events => this._onAttitudeFromVps(events.find(event => event.dataType === EventType.AbsoluteAttitude)),
105
+ error => this.notifyError(error),
106
+ false
107
+ );
111
108
 
112
109
  this.relativeAttitudeProviderId = RelativeAttitude.addEventListener(
113
110
  events => this._onRelativeAttitudeEvent(events[0]),
@@ -8,7 +8,6 @@ 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';
12
11
  import Vps from '../../vision/vps/Vps.js';
13
12
  import PoleStar from './PoleStar.js';
14
13
  import AvailabilityHelper from '../../../events/AvailabilityHelper.js';
@@ -62,9 +61,7 @@ class AbsolutePosition extends Provider {
62
61
  if (ProvidersOptions.hasPoleStar) {
63
62
  providersToCheck.push(PoleStar.availability);
64
63
  }
65
- if (ProvidersOptions.hasVps) {
66
- providersToCheck.push(Vps.availability);
67
- }
64
+ providersToCheck.push(Vps.availability);
68
65
  return AvailabilityHelper.some(providersToCheck);
69
66
  }
70
67
 
@@ -94,13 +91,11 @@ class AbsolutePosition extends Provider {
94
91
  );
95
92
 
96
93
  // Vps
97
- if (ProvidersOptions.hasVps) {
98
- this._vpsProviderId = Vps.addEventListener(
99
- events => this._onAbsolutePosition(events.find(event => event.dataType === EventType.AbsolutePosition)),
100
- error => this.notifyError(error),
101
- false
102
- );
103
- }
94
+ this._vpsProviderId = Vps.addEventListener(
95
+ events => this._onAbsolutePosition(events.find(event => event.dataType === EventType.AbsolutePosition)),
96
+ error => this.notifyError(error),
97
+ false
98
+ );
104
99
 
105
100
  // PoleStar
106
101
  if (ProvidersOptions.hasPoleStar) {
@@ -292,28 +287,12 @@ class AbsolutePosition extends Provider {
292
287
  /**
293
288
  * @override
294
289
  * @param {UserPosition|ProviderEvent} data
295
- * @param {EventType} eventType
296
290
  */
297
- feed(data, eventType) {
291
+ feed(data) {
298
292
 
299
293
  /** @type {ProviderEvent<UserPosition>} */
300
294
  let newPositionEvent;
301
295
 
302
- if (eventType === EventType.ForceVps) {
303
- if (!this._vpsProviderId && this.state === ProviderState.STARTED) {
304
- this._waitUntilNextVpsPosition = true;
305
- this._vpsProviderId = Vps.addEventListener(events => {
306
- this._waitUntilNextVpsPosition = false;
307
- this._onAbsolutePosition(events.find(event => event.dataType === EventType.AbsolutePosition));
308
- Vps.removeEventListener(this._vpsProviderId);
309
- this._vpsProviderId = null;
310
- });
311
- }
312
-
313
- return;
314
-
315
- }
316
-
317
296
  if (data instanceof UserPosition) {
318
297
 
319
298
  if (data.time === null) {
@@ -147,6 +147,10 @@ class StepDetector extends Provider {
147
147
  }
148
148
  this._algorithm = algorithm;
149
149
  }
150
+
151
+ get algorithm() {
152
+ return this._algorithm;
153
+ }
150
154
  }
151
155
 
152
156
  export default new StepDetector();
@@ -87,7 +87,7 @@ class StraightLineDetector extends Provider {
87
87
  * @returns {boolean}
88
88
  */
89
89
  isStraight() {
90
- return this._countSteps >= StraightLineDetector.STEPS_CONSIDERED_FOR_STRAIGHT_LINE;
90
+ return this._countSteps >= this._stepsConsideredForStraightLine;
91
91
  }
92
92
 
93
93
  get numStepsDetectedFromLastTurn() {