@wemap/providers 4.0.0 → 4.0.1

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.
Files changed (50) hide show
  1. package/debug/src/AbsoluteAttitudeComponent.jsx +4 -1
  2. package/package.json +5 -5
  3. package/src/Providers.js +26 -82
  4. package/src/errors/AskImuOnDesktopError.js +4 -3
  5. package/src/errors/ContainsIgnoredProviderError.js +4 -3
  6. package/src/errors/GeolocationApiMissingError.js +4 -3
  7. package/src/errors/GeolocationPermissionDeniedError.js +4 -3
  8. package/src/errors/GeolocationPositionUnavailableError.js +4 -3
  9. package/src/errors/IpResolveServerError.js +4 -3
  10. package/src/errors/MissingAccelerometerError.js +3 -3
  11. package/src/errors/MissingArCoreError.js +4 -3
  12. package/src/errors/MissingGyroscopeError.js +3 -3
  13. package/src/errors/MissingNativeInterfaceError.js +4 -3
  14. package/src/errors/MissingSensorError.js +4 -3
  15. package/src/errors/NoProviderFoundError.js +4 -3
  16. package/src/events/ProvidersLoggerOld.js +35 -34
  17. package/src/mapmatching/MapMatchingHandler.js +15 -27
  18. package/src/providers/FakeProvider.spec.js +15 -15
  19. package/src/providers/Provider.js +2 -19
  20. package/src/providers/Provider.spec.js +18 -28
  21. package/src/providers/attitude/absolute/{AbsoluteAttitudeProvider.js → AbsoluteAttitude.js} +5 -6
  22. package/src/providers/attitude/absolute/{AbsoluteAttitudeFromBrowserProvider.js → AbsoluteAttitudeFromBrowser.js} +4 -4
  23. package/src/providers/attitude/absolute/{AbsoluteAttitudeFromRelAttProvider.js → AbsoluteAttitudeFromRelAtt.js} +6 -5
  24. package/src/providers/attitude/absolute/{AbsoluteAttitudeFusedProvider.js → AbsoluteAttitudeFused.js} +3 -3
  25. package/src/providers/attitude/relative/{RelativeAttitudeProvider.js → RelativeAttitude.js} +4 -5
  26. package/src/providers/attitude/relative/{RelativeAttitudeFromBrowserProvider.js → RelativeAttitudeFromBrowser.js} +4 -4
  27. package/src/providers/attitude/relative/{RelativeAttitudeFromEkfProvider.js → RelativeAttitudeFromEkf.js} +7 -7
  28. package/src/providers/attitude/relative/{RelativeAttitudeFromInertialProvider.js → RelativeAttitudeFromInertial.js} +5 -5
  29. package/src/providers/imu/{AccelerometerProvider.js → Accelerometer.js} +3 -3
  30. package/src/providers/imu/{GyroscopeProvider.js → Gyroscope.js} +3 -3
  31. package/src/providers/imu/{ImuProvider.js → Imu.js} +3 -3
  32. package/src/providers/inclination/{InclinationProvider.js → Inclination.js} +4 -5
  33. package/src/providers/inclination/{InclinationFromAccProvider.js → InclinationFromAcc.js} +4 -3
  34. package/src/providers/inclination/{InclinationFromRelativeAttitudeProvider.js → InclinationFromRelativeAttitude.js} +4 -3
  35. package/src/providers/legacy/helpers/ThugDetector.js +7 -7
  36. package/src/providers/others/{BarcodeProvider.js → Barcode.js} +3 -3
  37. package/src/providers/others/{CameraNativeProvider.js → CameraNative.js} +2 -2
  38. package/src/providers/others/{CameraProjectionMatrixProvider.js → CameraProjectionMatrix.js} +3 -3
  39. package/src/providers/position/absolute/{AbsolutePositionProvider.js → AbsolutePosition.js} +11 -13
  40. package/src/providers/position/absolute/{AbsolutePositionFromRelProvider.js → AbsolutePositionFromRel.js} +4 -5
  41. package/src/providers/position/absolute/{GnssWifiProvider.js → GnssWifi.js} +9 -8
  42. package/src/providers/position/absolute/{IpProvider.js → Ip.js} +2 -2
  43. package/src/providers/position/relative/{ArCoreProvider.js → ArCore.js} +28 -30
  44. package/src/providers/position/relative/{GeoRelativePositionProvider.js → GeoRelativePosition.js} +5 -5
  45. package/src/providers/position/relative/{GeoRelativePositionFromArCoreProvider.js → GeoRelativePositionFromArCore.js} +4 -5
  46. package/src/providers/position/relative/{PdrProvider.js → Pdr.js} +5 -5
  47. package/src/providers/steps/{StepDetectionProvider.js → StepDetection.js} +6 -5
  48. package/src/providers/steps/StepDetectionLadetto.js +12 -13
  49. package/src/providers/steps/StepDetectionMinMaxPeaks.js +19 -17
  50. package/src/providers/steps/StepDetectionMinMaxPeaks2.js +17 -18
@@ -8,7 +8,10 @@ import { TimeUtils } from '@wemap/utils';
8
8
 
9
9
  import ProvidersLoggerOld from '../../src/events/ProvidersLoggerOld.js';
10
10
  import {
11
- AbsoluteAttitudeFromBrowser, AbsoluteAttitudeFromRelAtt, AbsoluteAttitude, AbsolutePosition
11
+ AbsoluteAttitudeFromBrowser,
12
+ AbsoluteAttitudeFromRelAtt,
13
+ AbsoluteAttitude,
14
+ AbsolutePosition
12
15
  } from '../../src/Providers.js';
13
16
  import Utils from './Utils.js';
14
17
 
package/package.json CHANGED
@@ -8,10 +8,10 @@
8
8
  "Guillaume Pannetier <guillaume.pannetier@getwemap.com>"
9
9
  ],
10
10
  "dependencies": {
11
- "@wemap/geo": "^4.0.0",
11
+ "@wemap/geo": "^4.0.1",
12
12
  "@wemap/geomagnetism": "^0.1.1",
13
13
  "@wemap/logger": "^4.0.0",
14
- "@wemap/map": "^4.0.0",
14
+ "@wemap/map": "^4.0.1",
15
15
  "@wemap/maths": "^4.0.0",
16
16
  "@wemap/utils": "^4.0.0",
17
17
  "lodash.isempty": "^4.4.0",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "description": "A package using different geoloc systems",
21
21
  "devDependencies": {
22
- "@wemap/osm": "^4.0.0",
22
+ "@wemap/osm": "^4.0.1",
23
23
  "mapbox-gl": "^1.11.1"
24
24
  },
25
25
  "homepage": "https://github.com/wemap/wemap-modules-js#readme",
@@ -41,6 +41,6 @@
41
41
  "url": "git+https://github.com/wemap/wemap-modules-js.git"
42
42
  },
43
43
  "type": "module",
44
- "version": "4.0.0",
45
- "gitHead": "8b72858590fc2ff33fbea4f090de8cd353a7445f"
44
+ "version": "4.0.1",
45
+ "gitHead": "ba5cebf23d528021d4bd1a3498d51d98ac655fb9"
46
46
  }
package/src/Providers.js CHANGED
@@ -1,91 +1,35 @@
1
1
  /* eslint-disable max-len */
2
- /* eslint-disable id-length */
3
2
 
4
- import ImuProvider from './providers/imu/ImuProvider.js';
5
- import AccelerometerProvider from './providers/imu/AccelerometerProvider.js';
6
- import GyroscopeProvider from './providers/imu/GyroscopeProvider.js';
7
- const Imu = ImuProvider.instance;
8
- const Accelerometer = AccelerometerProvider.instance;
9
- const Gyroscope = GyroscopeProvider.instance;
3
+ export { default as Imu } from './providers/imu/Imu.js';
4
+ export { default as Accelerometer } from './providers/imu/Accelerometer.js';
5
+ export { default as Gyroscope } from './providers/imu/Gyroscope.js';
10
6
 
11
- import RelativeAttitudeFromBrowserProvider from './providers/attitude/relative/RelativeAttitudeFromBrowserProvider.js';
12
- import RelativeAttitudeFromEkfProvider from './providers/attitude/relative/RelativeAttitudeFromEkfProvider.js';
13
- import RelativeAttitudeFromInertialProvider from './providers/attitude/relative/RelativeAttitudeFromInertialProvider.js';
14
- import RelativeAttitudeProvider from './providers/attitude/relative/RelativeAttitudeProvider.js';
15
- const RelativeAttitudeFromBrowser = RelativeAttitudeFromBrowserProvider.instance;
16
- const RelativeAttitudeFromEkf = RelativeAttitudeFromEkfProvider.instance;
17
- const RelativeAttitudeFromInertial = RelativeAttitudeFromInertialProvider.instance;
18
- const RelativeAttitude = RelativeAttitudeProvider.instance;
7
+ export { default as RelativeAttitudeFromBrowser } from './providers/attitude/relative/RelativeAttitudeFromBrowser.js';
8
+ export { default as RelativeAttitudeFromEkf } from './providers/attitude/relative/RelativeAttitudeFromEkf.js';
9
+ export { default as RelativeAttitudeFromInertial } from './providers/attitude/relative/RelativeAttitudeFromInertial.js';
10
+ export { default as RelativeAttitude } from './providers/attitude/relative/RelativeAttitude.js';
19
11
 
20
- import AbsoluteAttitudeFromBrowserProvider from './providers/attitude/absolute/AbsoluteAttitudeFromBrowserProvider.js';
21
- import AbsoluteAttitudeFromRelAttProvider from './providers/attitude/absolute/AbsoluteAttitudeFromRelAttProvider.js';
22
- import AbsoluteAttitudeFusedProvider from './providers/attitude/absolute/AbsoluteAttitudeFusedProvider.js';
23
- import AbsoluteAttitudeProvider from './providers/attitude/absolute/AbsoluteAttitudeProvider.js';
24
- const AbsoluteAttitudeFromBrowser = AbsoluteAttitudeFromBrowserProvider.instance;
25
- const AbsoluteAttitudeFromRelAtt = AbsoluteAttitudeFromRelAttProvider.instance;
26
- const AbsoluteAttitudeFused = AbsoluteAttitudeFusedProvider.instance;
27
- const AbsoluteAttitude = AbsoluteAttitudeProvider.instance;
12
+ export { default as AbsoluteAttitudeFromBrowser } from './providers/attitude/absolute/AbsoluteAttitudeFromBrowser.js';
13
+ export { default as AbsoluteAttitudeFromRelAtt } from './providers/attitude/absolute/AbsoluteAttitudeFromRelAtt.js';
14
+ export { default as AbsoluteAttitudeFused } from './providers/attitude/absolute/AbsoluteAttitudeFused.js';
15
+ export { default as AbsoluteAttitude } from './providers/attitude/absolute/AbsoluteAttitude.js';
28
16
 
29
- import InclinationFromAccProvider from './providers/inclination/InclinationFromAccProvider.js';
30
- import InclinationFromRelativeAttitudeProvider from './providers/inclination/InclinationFromRelativeAttitudeProvider.js';
31
- import InclinationProvider from './providers/inclination/InclinationProvider.js';
32
- const InclinationFromAcc = InclinationFromAccProvider.instance;
33
- const InclinationFromRelativeAttitude = InclinationFromRelativeAttitudeProvider.instance;
34
- const Inclination = InclinationProvider.instance;
17
+ export { default as InclinationFromAcc } from './providers/inclination/InclinationFromAcc.js';
18
+ export { default as InclinationFromRelativeAttitude } from './providers/inclination/InclinationFromRelativeAttitude.js';
19
+ export { default as Inclination } from './providers/inclination/Inclination.js';
35
20
 
36
- import StepDetectionProvider from './providers/steps/StepDetectionProvider.js';
37
- const StepDetection = StepDetectionProvider.instance;
21
+ export { default as StepDetection } from './providers/steps/StepDetection.js';
38
22
 
39
- import ArCoreProvider from './providers/position/relative/ArCoreProvider.js';
40
- import PdrProvider from './providers/position/relative/PdrProvider.js';
41
- import GeoRelativePositionFromArCoreProvider from './providers/position/relative/GeoRelativePositionFromArCoreProvider.js';
42
- import GeoRelativePositionProvider from './providers/position/relative/GeoRelativePositionProvider.js';
43
- const ArCore = ArCoreProvider.instance;
44
- const Pdr = PdrProvider.instance;
45
- const GeoRelativePositionFromArCore = GeoRelativePositionFromArCoreProvider.instance;
46
- const GeoRelativePosition = GeoRelativePositionProvider.instance;
23
+ export { default as ArCore } from './providers/position/relative/ArCore.js';
24
+ export { default as Pdr } from './providers/position/relative/Pdr.js';
25
+ export { default as GeoRelativePositionFromArCore } from './providers/position/relative/GeoRelativePositionFromArCore.js';
26
+ export { default as GeoRelativePosition } from './providers/position/relative/GeoRelativePosition.js';
47
27
 
48
- import AbsolutePositionFromRelProvider from './providers/position/absolute/AbsolutePositionFromRelProvider.js';
49
- import GnssWifiProvider from './providers/position/absolute/GnssWifiProvider.js';
50
- import IpProvider from './providers/position/absolute/IpProvider.js';
51
- import AbsolutePositionProvider from './providers/position/absolute/AbsolutePositionProvider.js';
52
- const AbsolutePositionFromRel = AbsolutePositionFromRelProvider.instance;
53
- const GnssWifi = GnssWifiProvider.instance;
54
- const Ip = IpProvider.instance;
55
- const AbsolutePosition = AbsolutePositionProvider.instance;
28
+ export { default as AbsolutePositionFromRel } from './providers/position/absolute/AbsolutePositionFromRel.js';
29
+ export { default as GnssWifi } from './providers/position/absolute/GnssWifi.js';
30
+ export { default as Ip } from './providers/position/absolute/Ip.js';
31
+ export { default as AbsolutePosition } from './providers/position/absolute/AbsolutePosition.js';
56
32
 
57
- import BarcodeProvider from './providers/others/BarcodeProvider.js';
58
- import CameraNativeProvider from './providers/others/CameraNativeProvider.js';
59
- import CameraProjectionMatrixProvider from './providers/others/CameraProjectionMatrixProvider.js';
60
- const Barcode = BarcodeProvider.instance;
61
- const CameraNative = CameraNativeProvider.instance;
62
- const CameraProjectionMatrix = CameraProjectionMatrixProvider.instance;
63
-
64
- export {
65
- AbsoluteAttitude,
66
- AbsoluteAttitudeFromBrowser,
67
- AbsoluteAttitudeFromRelAtt,
68
- AbsoluteAttitudeFused,
69
- AbsolutePosition,
70
- AbsolutePositionFromRel,
71
- Accelerometer,
72
- ArCore,
73
- Barcode,
74
- CameraNative,
75
- CameraProjectionMatrix,
76
- GeoRelativePosition,
77
- GeoRelativePositionFromArCore,
78
- GnssWifi,
79
- Gyroscope,
80
- Imu,
81
- Inclination,
82
- InclinationFromAcc,
83
- InclinationFromRelativeAttitude,
84
- Ip,
85
- Pdr,
86
- RelativeAttitude,
87
- RelativeAttitudeFromBrowser,
88
- RelativeAttitudeFromEkf,
89
- RelativeAttitudeFromInertial,
90
- StepDetection
91
- };
33
+ export { default as Barcode } from './providers/others/Barcode.js';
34
+ export { default as CameraNative } from './providers/others/CameraNative.js';
35
+ export { default as CameraProjectionMatrix } from './providers/others/CameraProjectionMatrix.js';
@@ -1,8 +1,9 @@
1
- const DEFAULT_MESSAGE = 'It seems that you ask for IMU events on a desktop browser';
2
-
3
1
  class AskImuOnDesktopError extends Error {
2
+
3
+ static DEFAULT_MESSAGE = 'It seems that you ask for IMU events on a desktop browser';
4
+
4
5
  constructor(message) {
5
- super(message || DEFAULT_MESSAGE);
6
+ super(message || AskImuOnDesktopError.DEFAULT_MESSAGE);
6
7
  }
7
8
  }
8
9
 
@@ -1,8 +1,9 @@
1
- const DEFAULT_MESSAGE = 'Contains ignored provider';
2
-
3
1
  class ContainsIgnoredProviderError extends Error {
2
+
3
+ static DEFAULT_MESSAGE = 'Contains ignored provider';
4
+
4
5
  constructor(message) {
5
- super(message || DEFAULT_MESSAGE);
6
+ super(message || ContainsIgnoredProviderError.DEFAULT_MESSAGE);
6
7
  }
7
8
  }
8
9
 
@@ -1,8 +1,9 @@
1
- const DEFAULT_MESSAGE = 'Geolocation api is missing';
2
-
3
1
  class GeolocationApiMissingError extends Error {
2
+
3
+ static DEFAULT_MESSAGE = 'Geolocation api is missing';
4
+
4
5
  constructor(message) {
5
- super(message || DEFAULT_MESSAGE);
6
+ super(message || GeolocationApiMissingError.DEFAULT_MESSAGE);
6
7
  }
7
8
  }
8
9
 
@@ -1,8 +1,9 @@
1
- const DEFAULT_MESSAGE = 'Geolocation permission denied';
2
-
3
1
  class GeolocationPermissionDeniedError extends Error {
2
+
3
+ static DEFAULT_MESSAGE = 'Geolocation permission denied';
4
+
4
5
  constructor(message) {
5
- super(message || DEFAULT_MESSAGE);
6
+ super(message || GeolocationPermissionDeniedError.DEFAULT_MESSAGE);
6
7
  }
7
8
  }
8
9
 
@@ -1,8 +1,9 @@
1
- const DEFAULT_MESSAGE = 'Geolocation position unavailable';
2
-
3
1
  class GeolocationPositionUnavailableError extends Error {
2
+
3
+ static DEFAULT_MESSAGE = 'Geolocation position unavailable';
4
+
4
5
  constructor(message) {
5
- super(message || DEFAULT_MESSAGE);
6
+ super(message || GeolocationPositionUnavailableError.DEFAULT_MESSAGE);
6
7
  }
7
8
  }
8
9
 
@@ -1,8 +1,9 @@
1
- const DEFAULT_MESSAGE = 'IP Resolver failed';
2
-
3
1
  class IpResolveServerError extends Error {
2
+
3
+ static DEFAULT_MESSAGE = 'IP Resolver failed';
4
+
4
5
  constructor(message) {
5
- super(message || DEFAULT_MESSAGE);
6
+ super(message || IpResolveServerError.DEFAULT_MESSAGE);
6
7
  }
7
8
  }
8
9
 
@@ -1,10 +1,10 @@
1
1
  import MissingSensorError from './MissingSensorError.js';
2
+ class MissingAccelerometerError extends MissingSensorError {
2
3
 
3
- const DEFAULT_MESSAGE = 'Impossible to retrieve Acceleration data';
4
+ static DEFAULT_MESSAGE = 'Impossible to retrieve Acceleration data';
4
5
 
5
- class MissingAccelerometerError extends MissingSensorError {
6
6
  constructor(message) {
7
- super(message || DEFAULT_MESSAGE);
7
+ super(message || MissingAccelerometerError.DEFAULT_MESSAGE);
8
8
  }
9
9
  }
10
10
 
@@ -1,8 +1,9 @@
1
- const DEFAULT_MESSAGE = 'ARCore is missing';
2
-
3
1
  class MissingArCoreError extends Error {
2
+
3
+ static DEFAULT_MESSAGE = 'ARCore is missing';
4
+
4
5
  constructor(message) {
5
- super(message || DEFAULT_MESSAGE);
6
+ super(message || MissingArCoreError.DEFAULT_MESSAGE);
6
7
  }
7
8
  }
8
9
 
@@ -1,10 +1,10 @@
1
1
  import MissingSensorError from './MissingSensorError.js';
2
+ class MissingGyroscopeError extends MissingSensorError {
2
3
 
3
- const DEFAULT_MESSAGE = 'Impossible to retrieve Angular Rate data';
4
+ static DEFAULT_MESSAGE = 'Impossible to retrieve Angular Rate data';
4
5
 
5
- class MissingGyroscopeError extends MissingSensorError {
6
6
  constructor(message) {
7
- super(message || DEFAULT_MESSAGE);
7
+ super(message || MissingSensorError.DEFAULT_MESSAGE);
8
8
  }
9
9
  }
10
10
 
@@ -1,8 +1,9 @@
1
- const DEFAULT_MESSAGE = 'Native interface is missing';
2
-
3
1
  class MissingNativeInterfaceError extends Error {
2
+
3
+ static DEFAULT_MESSAGE = 'Native interface is missing';
4
+
4
5
  constructor(message) {
5
- super(message || DEFAULT_MESSAGE);
6
+ super(message || MissingNativeInterfaceError.DEFAULT_MESSAGE);
6
7
  }
7
8
  }
8
9
 
@@ -1,8 +1,9 @@
1
- const DEFAULT_MESSAGE = 'Impossible to retrieve events, a sensor is missing';
2
-
3
1
  class MissingSensorError extends Error {
2
+
3
+ static DEFAULT_MESSAGE = 'Impossible to retrieve events, a sensor is missing';
4
+
4
5
  constructor(message) {
5
- super(message || DEFAULT_MESSAGE);
6
+ super(message || MissingSensorError.DEFAULT_MESSAGE);
6
7
  }
7
8
 
8
9
  from(fromMessage) {
@@ -1,8 +1,9 @@
1
- const DEFAULT_MESSAGE = 'Unable to find a provider with your given parameters';
2
-
3
1
  class NoProviderFoundError extends Error {
2
+
3
+ static DEFAULT_MESSAGE = 'Unable to find a provider with your given parameters';
4
+
4
5
  constructor(message) {
5
- super(message || DEFAULT_MESSAGE);
6
+ super(message || NoProviderFoundError.DEFAULT_MESSAGE);
6
7
  }
7
8
  }
8
9
 
@@ -1,83 +1,84 @@
1
1
  import Logger from '@wemap/logger';
2
2
 
3
- let currentId = 0;
4
- const objectsIdMap = new WeakMap();
3
+ class ProvidersLoggerOld {
5
4
 
6
- let pushEvents = {};
7
- let pushEventsRef = {};
5
+ _enabled = false;
8
6
 
9
- let interval;
10
- let initDate;
7
+ currentId = 0;
8
+ objectsIdMap = new WeakMap();
11
9
 
12
- class ProvidersLoggerOld {
10
+ pushEvents = {};
11
+ pushEventsRef = {};
12
+
13
+ interval;
14
+ initDate;
13
15
 
14
- static _enabled = false;
15
16
 
16
- static get enabled() {
17
+ get enabled() {
17
18
  return this._enabled;
18
19
  }
19
20
 
20
- static set enabled(_newVal) {
21
+ set enabled(_newVal) {
21
22
  this._enabled = _newVal;
22
23
  }
23
24
 
24
- static initializeInterval() {
25
+ initializeInterval() {
25
26
 
26
- if (interval) {
27
+ if (this.interval) {
27
28
  return;
28
29
  }
29
30
 
30
- interval = setInterval(() => {
31
+ this.interval = setInterval(() => {
31
32
 
32
- for (const [key, value] of Object.entries(pushEvents)) {
33
- Logger.debug('Received ' + value + ' notifications from ' + pushEventsRef[key].pname + ' last second');
33
+ for (const [key, value] of Object.entries(this.pushEvents)) {
34
+ Logger.debug('Received ' + value + ' notifications from ' + this.pushEventsRef[key].pname + ' last second');
34
35
  }
35
36
 
36
- pushEvents = {};
37
- pushEventsRef = {};
37
+ this.pushEvents = {};
38
+ this.pushEventsRef = {};
38
39
  }, 1000);
39
40
  }
40
41
 
41
- static getObjectId(object) {
42
- if (!objectsIdMap.has(object)) {
43
- objectsIdMap.set(object, ++currentId);
42
+ getObjectId(object) {
43
+ if (!this.objectsIdMap.has(object)) {
44
+ this.objectsIdMap.set(object, ++this.currentId);
44
45
  }
45
- return objectsIdMap.get(object);
46
+ return this.objectsIdMap.get(object);
46
47
  }
47
48
 
48
- static addEvent(object, method) {
49
+ addEvent(object, method) {
49
50
 
50
- if (!ProvidersLoggerOld.enabled) {
51
+ if (!this.enabled) {
51
52
  return;
52
53
  }
53
54
 
54
- if (!initDate) {
55
- initDate = Date.now();
55
+ if (!this.initDate) {
56
+ this.initDate = Date.now();
56
57
  }
57
58
 
58
- ProvidersLoggerOld.initializeInterval();
59
+ this.initializeInterval();
59
60
 
60
- const objectId = ProvidersLoggerOld.getObjectId(object);
61
+ const objectId = this.getObjectId(object);
61
62
  const objectClassName = object.pname;
62
63
 
63
64
  Logger.debug(objectClassName + '[' + objectId + '].' + method);
64
65
  }
65
66
 
66
- static incrementNotifications(object) {
67
+ incrementNotifications(object) {
67
68
 
68
- if (!ProvidersLoggerOld.enabled) {
69
+ if (!this.enabled) {
69
70
  return;
70
71
  }
71
72
 
72
- const objectId = ProvidersLoggerOld.getObjectId(object);
73
+ const objectId = this.getObjectId(object);
73
74
 
74
- let counter = pushEvents[objectId];
75
+ let counter = this.pushEvents[objectId];
75
76
  if (!counter) {
76
77
  counter = 0;
77
- pushEventsRef[objectId] = object;
78
+ this.pushEventsRef[objectId] = object;
78
79
  }
79
- pushEvents[objectId] = counter + 1;
80
+ this.pushEvents[objectId] = counter + 1;
80
81
  }
81
82
 
82
83
  }
83
- export default ProvidersLoggerOld;
84
+ export default new ProvidersLoggerOld();
@@ -1,36 +1,24 @@
1
- import { UserPosition } from '@wemap/geo';
2
1
  import {
3
- MapMatching, Network
2
+ MapMatching, Network, UserPosition
4
3
  } from '@wemap/geo';
5
4
  import { deg2rad } from '@wemap/maths';
6
5
 
7
- import {
8
- AbsolutePosition, AbsoluteAttitudeFused
9
- } from '../Providers.js';
6
+ import AbsoluteAttitudeFused from '../providers/attitude/absolute/AbsoluteAttitudeFused.js';
7
+ import AbsolutePosition from '../providers/position/absolute/AbsolutePosition.js';
10
8
  import ProvidersOptions from '../ProvidersOptions.js';
11
9
 
12
- const MM_MAX_ANGLE = deg2rad(20);
13
- const MM_MAX_DIST = 30;
14
- const MM_MIN_DIST = 0;
15
-
16
10
  class MapMatchingHandler {
17
11
 
12
+ static MM_MAX_ANGLE = deg2rad(20);
13
+ static MM_MAX_DIST = 30;
14
+ static MM_MIN_DIST = 0;
15
+
18
16
  /** @type {MapMatching} */
19
17
  _mapMatching;
20
18
 
21
19
  /** @type {number} */
22
20
  _mapMatchingMinDistance;
23
21
 
24
- /**
25
- * Singleton pattern using reflection.
26
- * @returns {MapMatchingHandler}
27
- */
28
- static get instance() {
29
- if (!this._instance) {
30
- this._instance = Reflect.construct(this, []);
31
- }
32
- return this._instance;
33
- }
34
22
 
35
23
  constructor() {
36
24
 
@@ -39,9 +27,9 @@ class MapMatchingHandler {
39
27
  }
40
28
 
41
29
  this._mapMatching = new MapMatching();
42
- this._mapMatching.maxDistance = MM_MAX_DIST;
43
- this._mapMatching.maxAngleBearing = MM_MAX_ANGLE;
44
- this._mapMatchingMinDistance = MM_MIN_DIST;
30
+ this._mapMatching.maxDistance = MapMatchingHandler.MM_MAX_DIST;
31
+ this._mapMatching.maxAngleBearing = MapMatchingHandler.MM_MAX_ANGLE;
32
+ this._mapMatchingMinDistance = MapMatchingHandler.MM_MIN_DIST;
45
33
  }
46
34
 
47
35
  get enabled() {
@@ -103,16 +91,16 @@ class MapMatchingHandler {
103
91
  return null;
104
92
  }
105
93
 
94
+ if (bearingUsedForProjection) {
95
+ AbsoluteAttitudeFused.mapMatching(projection);
96
+ }
97
+
106
98
  // Do not use projection if it too close from itinerary,
107
99
  // this allows left/right movements (ie with ArCore)
108
100
  if (projection.distanceFromNearestElement < this._mapMatchingMinDistance) {
109
101
  return null;
110
102
  }
111
103
 
112
- if (bearingUsedForProjection) {
113
- AbsoluteAttitudeFused.mapMatching(projection);
114
- }
115
-
116
104
  // Do not use projection.projection directly, because position has some specific properties like time, bearing and altitude
117
105
  const projectedPosition = position.clone();
118
106
  projectedPosition.lat = projection.projection.lat;
@@ -147,4 +135,4 @@ class MapMatchingHandler {
147
135
  }
148
136
  }
149
137
 
150
- export default MapMatchingHandler.instance;
138
+ export default new MapMatchingHandler();
@@ -3,13 +3,15 @@ import { UserPosition } from '@wemap/geo';
3
3
  import Provider from './Provider.js';
4
4
  import EventType from '../events/EventType.js';
5
5
 
6
- class FakeProvider1 extends Provider {
6
+ class FakeProvider1Clazz extends Provider {
7
7
  static get pname() {
8
8
  return 'FakeProvider1';
9
9
  }
10
10
  }
11
+ const FakeProvider1 = new FakeProvider1Clazz();
12
+ export { FakeProvider1 };
11
13
 
12
- class FakeProvider2 extends Provider {
14
+ class FakeProvider2Clazz extends Provider {
13
15
  static get pname() {
14
16
  return 'FakeProvider2';
15
17
  }
@@ -19,8 +21,10 @@ class FakeProvider2 extends Provider {
19
21
  start() { }
20
22
  stop() { }
21
23
  }
24
+ const FakeProvider2 = new FakeProvider2Clazz();
25
+ export { FakeProvider2 };
22
26
 
23
- class FakeProvider3 extends Provider {
27
+ class FakeProvider3Clazz extends Provider {
24
28
  static get pname() {
25
29
  return 'FakeProvider3';
26
30
  }
@@ -34,31 +38,27 @@ class FakeProvider3 extends Provider {
34
38
  clearInterval(this.intervalId);
35
39
  }
36
40
  }
41
+ const FakeProvider3 = new FakeProvider3Clazz();
42
+ export { FakeProvider3 };
37
43
 
38
- class FakeProvider4 extends Provider {
44
+ class FakeProvider4Clazz extends Provider {
39
45
 
40
46
  static get pname() {
41
47
  return 'FakeProvider4';
42
48
  }
43
49
 
44
- constructor() {
45
- super();
46
- this.fp3 = FakeProvider3.instance;
47
- }
48
50
  get _availability() {
49
- return this.fp3.availability;
51
+ return FakeProvider3.availability;
50
52
  }
51
53
  start() {
52
- this.fp3id = this.fp3.addEventListener(
54
+ this.fp3id = FakeProvider3.addEventListener(
53
55
  events => this.notify(events[0].clone()),
54
56
  this.notifyError.bind(this)
55
57
  );
56
58
  }
57
59
  stop() {
58
- this.fp3.removeEventListener(this.fp3id);
60
+ FakeProvider3.removeEventListener(this.fp3id);
59
61
  }
60
62
  }
61
-
62
- export {
63
- FakeProvider1, FakeProvider2, FakeProvider3, FakeProvider4
64
- };
63
+ const FakeProvider4 = new FakeProvider4Clazz();
64
+ export { FakeProvider4 };
@@ -7,7 +7,6 @@ import ContainsIgnoredProviderError from '../errors/ContainsIgnoredProviderError
7
7
  import ProvidersOptions from '../ProvidersOptions.js';
8
8
  import ProviderState from './ProviderState.js';
9
9
 
10
- let uniqueId = 1;
11
10
 
12
11
  /**
13
12
  * A provider is a meta class to define an entity which can be
@@ -16,25 +15,13 @@ let uniqueId = 1;
16
15
  class Provider {
17
16
 
18
17
  static _callbackUniqueId = 0;
18
+ static _uniqueId = 1;
19
19
 
20
20
  state = ProviderState.STOPPPED;
21
21
 
22
22
  _eventsCallbacks = [];
23
23
  _monitoringCallbacks = [];
24
24
 
25
-
26
- /**
27
- * Singleton pattern using reflection.
28
- * @returns {Provider}
29
- */
30
- static get instance() {
31
- if (!this._instance) {
32
- this._instance = Reflect.construct(this, []);
33
- }
34
- return this._instance;
35
- }
36
-
37
-
38
25
  /**
39
26
  * Provider constructor
40
27
  */
@@ -44,11 +31,7 @@ class Provider {
44
31
  throw new Error('Can\'t instantiate Provider directly');
45
32
  }
46
33
 
47
- if (this._instance) {
48
- throw new Error(`Cannot instantiate ${this.pname} twice`);
49
- }
50
-
51
- this.id = uniqueId++;
34
+ this.id = Provider._uniqueId++;
52
35
 
53
36
  ProvidersLoggerOld.addEvent(this, 'constructor');
54
37
  }