@wemap/providers 4.0.0 → 4.0.3

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 (66) hide show
  1. package/debug/dist/index.html +1 -0
  2. package/debug/dist/turn-detection.html +19 -0
  3. package/debug/index.js +2 -0
  4. package/debug/src/AbsoluteAttitudeComponent.jsx +3 -10
  5. package/debug/src/StepDetectionComponent.jsx +3 -3
  6. package/debug/src/TurnDetectionComponent.jsx +47 -0
  7. package/debug/src/Utils.js +20 -0
  8. package/package.json +7 -9
  9. package/src/Providers.js +26 -81
  10. package/src/ProvidersInterface.js +5 -6
  11. package/src/errors/AskImuOnDesktopError.js +4 -3
  12. package/src/errors/ContainsIgnoredProviderError.js +4 -3
  13. package/src/errors/GeolocationApiMissingError.js +4 -3
  14. package/src/errors/GeolocationPermissionDeniedError.js +4 -3
  15. package/src/errors/GeolocationPositionUnavailableError.js +4 -3
  16. package/src/errors/IpResolveServerError.js +4 -3
  17. package/src/errors/MissingAccelerometerError.js +3 -3
  18. package/src/errors/MissingArCoreError.js +4 -3
  19. package/src/errors/MissingGyroscopeError.js +3 -3
  20. package/src/errors/MissingNativeInterfaceError.js +4 -3
  21. package/src/errors/MissingSensorError.js +4 -3
  22. package/src/errors/NoProviderFoundError.js +4 -3
  23. package/src/events/EventType.js +5 -1
  24. package/src/events/ProviderEvent.js +7 -0
  25. package/src/events/ProvidersLoggerOld.js +35 -34
  26. package/src/mapmatching/MapMatchingHandler.js +335 -69
  27. package/src/providers/FakeProvider.spec.js +15 -15
  28. package/src/providers/Provider.js +44 -27
  29. package/src/providers/Provider.spec.js +18 -29
  30. package/src/providers/attitude/TurnDectector.js +71 -0
  31. package/src/providers/attitude/absolute/AbsoluteAttitude.js +232 -0
  32. package/src/providers/attitude/absolute/{AbsoluteAttitudeFromBrowserProvider.js → AbsoluteAttitudeFromBrowser.js} +4 -4
  33. package/src/providers/attitude/relative/{RelativeAttitudeProvider.js → RelativeAttitude.js} +5 -8
  34. package/src/providers/attitude/relative/{RelativeAttitudeFromBrowserProvider.js → RelativeAttitudeFromBrowser.js} +4 -5
  35. package/src/providers/attitude/relative/{RelativeAttitudeFromEkfProvider.js → RelativeAttitudeFromEkf.js} +7 -8
  36. package/src/providers/attitude/relative/{RelativeAttitudeFromInertialProvider.js → RelativeAttitudeFromInertial.js} +24 -7
  37. package/src/providers/imu/{AccelerometerProvider.js → Accelerometer.js} +3 -3
  38. package/src/providers/imu/{GyroscopeProvider.js → Gyroscope.js} +3 -3
  39. package/src/providers/imu/HighRotationsDetector.js +62 -0
  40. package/src/providers/imu/{ImuProvider.js → Imu.js} +3 -3
  41. package/src/providers/inclination/{InclinationProvider.js → Inclination.js} +5 -6
  42. package/src/providers/inclination/{InclinationFromAccProvider.js → InclinationFromAcc.js} +4 -3
  43. package/src/providers/inclination/{InclinationFromRelativeAttitudeProvider.js → InclinationFromRelativeAttitude.js} +4 -3
  44. package/src/providers/legacy/helpers/ThugDetector.js +7 -7
  45. package/src/providers/others/{BarcodeProvider.js → Barcode.js} +3 -3
  46. package/src/providers/others/{CameraNativeProvider.js → CameraNative.js} +3 -3
  47. package/src/providers/others/{CameraProjectionMatrixProvider.js → CameraProjectionMatrix.js} +4 -4
  48. package/src/providers/position/absolute/AbsolutePosition.js +217 -0
  49. package/src/providers/position/absolute/{GnssWifiProvider.js → GnssWifi.js} +9 -8
  50. package/src/providers/position/absolute/{IpProvider.js → Ip.js} +2 -2
  51. package/src/providers/position/relative/{ArCoreProvider.js → ArCore.js} +28 -30
  52. package/src/providers/position/relative/{GeoRelativePositionProvider.js → GeoRelativePosition.js} +6 -6
  53. package/src/providers/position/relative/{GeoRelativePositionFromArCoreProvider.js → GeoRelativePositionFromArCore.js} +4 -5
  54. package/src/providers/position/relative/{PdrProvider.js → Pdr.js} +8 -8
  55. package/src/providers/steps/StepDetectionLadetto.js +12 -13
  56. package/src/providers/steps/StepDetectionMinMaxPeaks.js +19 -17
  57. package/src/providers/steps/StepDetectionMinMaxPeaks2.js +17 -18
  58. package/src/providers/steps/{StepDetectionProvider.js → StepDetector.js} +8 -7
  59. package/src/providers/steps/StraightLineDetector.js +80 -0
  60. package/src/smoothers/AttitudeSmoother.js +94 -59
  61. package/src/providers/MetaProvider.js +0 -44
  62. package/src/providers/attitude/absolute/AbsoluteAttitudeFromRelAttProvider.js +0 -132
  63. package/src/providers/attitude/absolute/AbsoluteAttitudeFusedProvider.js +0 -166
  64. package/src/providers/attitude/absolute/AbsoluteAttitudeProvider.js +0 -175
  65. package/src/providers/position/absolute/AbsolutePositionFromRelProvider.js +0 -107
  66. package/src/providers/position/absolute/AbsolutePositionProvider.js +0 -189
@@ -14,6 +14,7 @@
14
14
  <a href="./absolute-attitude.html">Absolute Attitude</a><br />
15
15
  <a href="./gnss-wifi.html">GNSS-Wifi</a><br />
16
16
  <a href="./step-detection.html">Step Detection</a><br />
17
+ <a href="./turn-detection.html">Turn Detection</a><br />
17
18
  <a href="./absolute-position.html">Absolute Position</a>
18
19
  </body>
19
20
 
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <meta name="viewport" content="width=device-width, user-scalable=no">
7
+ <title>Debug Step Detection</title>
8
+ <script src="/js/providers-lib.js"></script>
9
+ </head>
10
+
11
+ <body>
12
+ <div id="app"></div>
13
+ <script>
14
+ /* global createReactElement, TurnDetectionComponent */
15
+ createReactElement(TurnDetectionComponent, document.getElementById('app'));
16
+ </script>
17
+ </body>
18
+
19
+ </html>
package/debug/index.js CHANGED
@@ -8,6 +8,7 @@ import ImuComponent from './src/ImuComponent.jsx';
8
8
  import InclinationComponent from './src/InclinationComponent.jsx';
9
9
  import RelativeAttitudeComponent from './src/RelativeAttitudeComponent.jsx';
10
10
  import StepDetectionComponent from './src/StepDetectionComponent.jsx';
11
+ import TurnDetectionComponent from './src/TurnDetectionComponent.jsx';
11
12
 
12
13
  const createReactElement = (component, container) => ReactDOM.render(
13
14
  React.createElement(component, {}, null),
@@ -22,5 +23,6 @@ export {
22
23
  GnssWifiComponent,
23
24
  RelativeAttitudeComponent,
24
25
  StepDetectionComponent,
26
+ TurnDetectionComponent,
25
27
  createReactElement
26
28
  };
@@ -8,7 +8,9 @@ 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
+ AbsoluteAttitude,
13
+ AbsolutePosition
12
14
  } from '../../src/Providers.js';
13
15
  import Utils from './Utils.js';
14
16
 
@@ -23,7 +25,6 @@ class AbsoluteAttitudeComponent extends React.Component {
23
25
 
24
26
  this.state = {
25
27
  attitude: null,
26
- attitudeFromRelAtt: null,
27
28
  attitudeFromBrowser: null,
28
29
  deviceorientation: null,
29
30
  deviceorientationabsolute: null
@@ -43,11 +44,6 @@ class AbsoluteAttitudeComponent extends React.Component {
43
44
  error => this.setState({ attitudeFromBrowser: error })
44
45
  );
45
46
 
46
- this.providerFromRelAttId = AbsoluteAttitudeFromRelAtt.addEventListener(
47
- events => this.setState({ attitudeFromRelAtt: events[0] }),
48
- error => this.setState({ attitudeFromRelAtt: error })
49
- );
50
-
51
47
  this.providerId = AbsoluteAttitude.addEventListener(
52
48
  events => this.setState({ attitude: events[0] }),
53
49
  error => this.setState({ attitude: error })
@@ -64,7 +60,6 @@ class AbsoluteAttitudeComponent extends React.Component {
64
60
  stop() {
65
61
  this.isStarted = false;
66
62
  AbsoluteAttitudeFromBrowser.removeEventListener(this.providerFromBrowserId);
67
- AbsoluteAttitudeFromRelAtt.removeEventListener(this.providerFromRelAttId);
68
63
  AbsoluteAttitude.removeEventListener(this.providerId);
69
64
  window.removeEventListener('deviceorientation', this.onDeviceOrientationEventListener, true);
70
65
  window.removeEventListener('deviceorientationabsolute', this.onDeviceOrientationAbsoluteEventListener, true);
@@ -155,8 +150,6 @@ class AbsoluteAttitudeComponent extends React.Component {
155
150
  {rawRender}
156
151
  <h3>Absolute attitude:</h3>
157
152
  {Utils.renderAttitudeEvent(this.state.attitude)}
158
- <h3>Absolute attitude From relative + offset:</h3>
159
- {Utils.renderAttitudeEvent(this.state.attitudeFromRelAtt)}
160
153
  <h3>Absolute attitude From browser:</h3>
161
154
  {Utils.renderAttitudeEvent(this.state.attitudeFromBrowser)}
162
155
  </div>
@@ -2,7 +2,7 @@ import React from 'react';
2
2
 
3
3
  import Utils from './Utils.js';
4
4
  import ProvidersLoggerOld from '../../src/events/ProvidersLoggerOld.js';
5
- import { StepDetection } from '../../src/Providers.js';
5
+ import { StepDetector } from '../../src/Providers.js';
6
6
 
7
7
  ProvidersLoggerOld.enabled = true;
8
8
 
@@ -15,14 +15,14 @@ class StepDetectionComponent extends React.Component {
15
15
  }
16
16
 
17
17
  componentDidMount() {
18
- this.providerId = StepDetection.addEventListener(
18
+ this.providerId = StepDetector.addEventListener(
19
19
  events => this.setState({ stepDetected: events[0] }),
20
20
  error => this.setState({ stepDetected: error })
21
21
  );
22
22
  }
23
23
 
24
24
  componentWillUnmount() {
25
- StepDetection.removeEventListener(this.providerId);
25
+ StepDetector.removeEventListener(this.providerId);
26
26
  }
27
27
 
28
28
  render() {
@@ -0,0 +1,47 @@
1
+ import React from 'react';
2
+
3
+ import Utils from './Utils.js';
4
+ import ProvidersLoggerOld from '../../src/events/ProvidersLoggerOld.js';
5
+ import { TurnDetector, HighRotationsDetector } from '../../src/Providers.js';
6
+
7
+ ProvidersLoggerOld.enabled = true;
8
+
9
+ class TurnDetectionComponent extends React.Component {
10
+
11
+ constructor(props) {
12
+ super(props);
13
+
14
+ this.state = { turnDetected: 0, highRotationsDetected: 0 };
15
+ }
16
+
17
+ componentDidMount() {
18
+ this.turnDetectorId = TurnDetector.addEventListener(
19
+ () => this.setState(({ turnDetected }) => ({ turnDetected: turnDetected + 1 })),
20
+ error => this.setState({ turnDetected: error })
21
+ );
22
+
23
+ this.highRotationsDetectorId = HighRotationsDetector.addEventListener(
24
+ () => this.setState(({ highRotationsDetected }) => ({ highRotationsDetected: highRotationsDetected + 1 })),
25
+ error => this.setState({ highRotationsDetected: error })
26
+ );
27
+ }
28
+
29
+ componentWillUnmount() {
30
+ TurnDetector.removeEventListener(this.turnDetectorId);
31
+ HighRotationsDetector.removeEventListener(this.highRotationsDetectorId);
32
+ }
33
+
34
+ render() {
35
+ return (
36
+ <div>
37
+ <h3>Turn detected</h3>
38
+ {Utils.renderTurnEvent(this.state.turnDetected)}
39
+ <h3>High rotation detected</h3>
40
+ {Utils.renderTurnEvent(this.state.highRotationsDetected)}
41
+ </div>
42
+ );
43
+
44
+ }
45
+ }
46
+
47
+ export default TurnDetectionComponent;
@@ -189,6 +189,26 @@ class Utils {
189
189
  );
190
190
  }
191
191
 
192
+ /**
193
+ * @param {number|Error} event
194
+ */
195
+ static renderTurnEvent(event) {
196
+ if (event === null) {
197
+ return 'Waiting';
198
+ }
199
+ if (event instanceof Error) {
200
+ return Utils.renderError(event);
201
+ }
202
+ return (
203
+ <div>
204
+ <pre style={{ margin: 0 }}>
205
+ Number: {event}
206
+ </pre>
207
+ {/* {Utils.renderFromStack(event)} */}
208
+ </div>
209
+ );
210
+ }
211
+
192
212
  static renderError(error) {
193
213
  return (<div style={{ maxWidth: '180px' }}><strong>[{error.constructor.name}]</strong><br />{error.message}</div>);
194
214
  }
package/package.json CHANGED
@@ -8,18 +8,16 @@
8
8
  "Guillaume Pannetier <guillaume.pannetier@getwemap.com>"
9
9
  ],
10
10
  "dependencies": {
11
- "@wemap/geo": "^4.0.0",
11
+ "@wemap/geo": "^4.0.3",
12
12
  "@wemap/geomagnetism": "^0.1.1",
13
13
  "@wemap/logger": "^4.0.0",
14
- "@wemap/map": "^4.0.0",
15
- "@wemap/maths": "^4.0.0",
16
- "@wemap/utils": "^4.0.0",
17
- "lodash.isempty": "^4.4.0",
18
- "lodash.noop": "^3.0.1"
14
+ "@wemap/map": "^4.0.3",
15
+ "@wemap/maths": "^4.0.3",
16
+ "@wemap/utils": "^4.0.0"
19
17
  },
20
18
  "description": "A package using different geoloc systems",
21
19
  "devDependencies": {
22
- "@wemap/osm": "^4.0.0",
20
+ "@wemap/osm": "^4.0.3",
23
21
  "mapbox-gl": "^1.11.1"
24
22
  },
25
23
  "homepage": "https://github.com/wemap/wemap-modules-js#readme",
@@ -41,6 +39,6 @@
41
39
  "url": "git+https://github.com/wemap/wemap-modules-js.git"
42
40
  },
43
41
  "type": "module",
44
- "version": "4.0.0",
45
- "gitHead": "8b72858590fc2ff33fbea4f090de8cd353a7445f"
42
+ "version": "4.0.3",
43
+ "gitHead": "91a82028ddda32038999582da381d1d0d8acd091"
46
44
  }
package/src/Providers.js CHANGED
@@ -1,91 +1,36 @@
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';
6
+ export { default as HighRotationsDetector } from './providers/imu/HighRotationsDetector.js';
10
7
 
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;
8
+ export { default as RelativeAttitudeFromBrowser } from './providers/attitude/relative/RelativeAttitudeFromBrowser.js';
9
+ export { default as RelativeAttitudeFromEkf } from './providers/attitude/relative/RelativeAttitudeFromEkf.js';
10
+ export { default as RelativeAttitudeFromInertial } from './providers/attitude/relative/RelativeAttitudeFromInertial.js';
11
+ export { default as RelativeAttitude } from './providers/attitude/relative/RelativeAttitude.js';
19
12
 
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;
13
+ export { default as AbsoluteAttitudeFromBrowser } from './providers/attitude/absolute/AbsoluteAttitudeFromBrowser.js';
14
+ export { default as AbsoluteAttitude } from './providers/attitude/absolute/AbsoluteAttitude.js';
28
15
 
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;
16
+ export { default as TurnDetector } from './providers/attitude/TurnDectector.js';
35
17
 
36
- import StepDetectionProvider from './providers/steps/StepDetectionProvider.js';
37
- const StepDetection = StepDetectionProvider.instance;
18
+ export { default as InclinationFromAcc } from './providers/inclination/InclinationFromAcc.js';
19
+ export { default as InclinationFromRelativeAttitude } from './providers/inclination/InclinationFromRelativeAttitude.js';
20
+ export { default as Inclination } from './providers/inclination/Inclination.js';
38
21
 
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;
22
+ export { default as StepDetector } from './providers/steps/StepDetector.js';
23
+ export { default as StraightLineDetector } from './providers/steps/StraightLineDetector.js';
47
24
 
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;
25
+ export { default as ArCore } from './providers/position/relative/ArCore.js';
26
+ export { default as Pdr } from './providers/position/relative/Pdr.js';
27
+ export { default as GeoRelativePositionFromArCore } from './providers/position/relative/GeoRelativePositionFromArCore.js';
28
+ export { default as GeoRelativePosition } from './providers/position/relative/GeoRelativePosition.js';
56
29
 
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;
30
+ export { default as GnssWifi } from './providers/position/absolute/GnssWifi.js';
31
+ export { default as Ip } from './providers/position/absolute/Ip.js';
32
+ export { default as AbsolutePosition } from './providers/position/absolute/AbsolutePosition.js';
63
33
 
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
- };
34
+ export { default as Barcode } from './providers/others/Barcode.js';
35
+ export { default as CameraNative } from './providers/others/CameraNative.js';
36
+ export { default as CameraProjectionMatrix } from './providers/others/CameraProjectionMatrix.js';
@@ -4,7 +4,6 @@ import {
4
4
  } from '@wemap/geo';
5
5
 
6
6
  import EventType from './events/EventType.js';
7
- import MetaProvider from './providers/MetaProvider.js';
8
7
  import {
9
8
  AbsoluteAttitude, AbsolutePosition, Barcode, CameraNative, CameraProjectionMatrix, Inclination, RelativeAttitude
10
9
  } from './Providers.js';
@@ -23,7 +22,7 @@ class ProvidersInterface {
23
22
  * @returns {Number}
24
23
  */
25
24
  static addEventListener(eventType, onEvent, onError, watchOnly = false) {
26
- const provider = this._getMetaProviderFromEventType(eventType);
25
+ const provider = this._getProviderFromEventType(eventType);
27
26
  const id = provider.addEventListener(events => onEvent(events[0].data), onError, !watchOnly);
28
27
  this.idListeners.set(id, provider);
29
28
  return id;
@@ -52,22 +51,22 @@ class ProvidersInterface {
52
51
  MapMatchingHandler.network = data;
53
52
  return;
54
53
  }
55
- this._getMetaProviderFromEventType(eventType).feed(data, eventType);
54
+ this._getProviderFromEventType(eventType).feed(data, eventType);
56
55
  }
57
56
 
58
57
  /**
59
58
  * @param {EventType} eventType
60
59
  */
61
60
  static getLastKnown(eventType) {
62
- const { lastEvent } = this._getMetaProviderFromEventType(eventType);
61
+ const { lastEvent } = this._getProviderFromEventType(eventType);
63
62
  return lastEvent ? lastEvent.data : null;
64
63
  }
65
64
 
66
65
  /**
67
66
  * @param {EventType} eventType
68
- * @returns {MetaProvider}
67
+ * @returns {Provider}
69
68
  */
70
- static _getMetaProviderFromEventType(eventType) {
69
+ static _getProviderFromEventType(eventType) {
71
70
 
72
71
  switch (eventType) {
73
72
  case EventType.AbsoluteAttitude:
@@ -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
 
@@ -8,18 +8,22 @@ export default {
8
8
  AngularRate: 'ANGULAR_RATE',
9
9
  Acceleration: 'ACCELERATION',
10
10
 
11
-
12
11
  RelativeAttitude: 'RELATIVE_ATTITUDE',
13
12
  AbsoluteAttitude: 'ABSOLUTE_ATTITUDE',
14
13
  Attitude: 'ATTITUDE',
15
14
 
16
15
  Inclination: 'INCLINATION',
17
16
  AbsoluteHeading: 'ABSOLUTE_HEADING',
17
+ Turn: 'TURN',
18
+ HighRotation: 'HIGH_ROTATION',
18
19
 
19
20
  RelativePosition: 'RELATIVE_POSITION',
20
21
  GeoRelativePosition: 'GEO_RELATIVE_POSITION',
21
22
  AbsolutePosition: 'ABSOLUTE_POSITION',
22
23
 
24
+ Step: 'STEP',
25
+ StraightLine: 'STRAIGHT_LINE',
26
+
23
27
  Pressure: 'PRESSURE',
24
28
  BluetoothSignals: 'BLUETOOTH_SIGNALS',
25
29
  WifiSignals: 'WIFI_SIGNALS',
@@ -3,11 +3,15 @@ import EventType from './EventType.js';
3
3
  /**
4
4
  * A provider event is an event which can be triggered by device sensors
5
5
  * or can be computed from raw providers.
6
+ *
7
+ * @template T
6
8
  */
7
9
  class ProviderEvent {
8
10
 
9
11
  dataType = EventType.Unknown;
10
12
  providersStack = [];
13
+
14
+ /** @type {T} */
11
15
  data = null;
12
16
 
13
17
  /**
@@ -20,6 +24,9 @@ class ProviderEvent {
20
24
  this.data = data;
21
25
  }
22
26
 
27
+ /**
28
+ * @return {ProviderEvent<T>}
29
+ */
23
30
  clone() {
24
31
  const evt = new ProviderEvent(this.dataType, this.data);
25
32
  evt.providersStack = this.providersStack.slice(0);