@wemap/providers 3.0.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.
- package/babel.config.js +11 -0
- package/config.json +4 -0
- package/debug/absolute-attitude.html +16 -0
- package/debug/absolute-position.html +16 -0
- package/debug/attitude.html +16 -0
- package/debug/components/AbsoluteAttitudeComponent.jsx +142 -0
- package/debug/components/AbsolutePositionComponent.jsx +79 -0
- package/debug/components/AttitudeComponent.jsx +40 -0
- package/debug/components/Common.css +27 -0
- package/debug/components/GnssWifiComponent.jsx +53 -0
- package/debug/components/ImuComponent.jsx +53 -0
- package/debug/components/InclinationComponent.jsx +68 -0
- package/debug/components/MapComponent.jsx +366 -0
- package/debug/components/NavigationConfig.js +112 -0
- package/debug/components/PoseComponent.jsx +168 -0
- package/debug/components/RelativeAttitudeComponent.jsx +85 -0
- package/debug/components/StartStopComponent.jsx +45 -0
- package/debug/components/StepDetectionComponent.jsx +39 -0
- package/debug/components/Utils.js +216 -0
- package/debug/components/index.js +30 -0
- package/debug/components/old/PositioningComponent.jsx +29 -0
- package/debug/components/old/PositioningInclinationComponent.jsx +82 -0
- package/debug/components/old/PositioningPoseComponent.jsx +117 -0
- package/debug/gnss-wifi.html +16 -0
- package/debug/imu.html +16 -0
- package/debug/inclination.html +16 -0
- package/debug/pose.html +16 -0
- package/debug/positioning-legacy.html +16 -0
- package/debug/relative-attitude.html +16 -0
- package/debug/step-detection.html +16 -0
- package/index.js +7 -0
- package/package.json +67 -0
- package/src/Providers.js +80 -0
- package/src/ProvidersInterface.js +125 -0
- package/src/ProvidersOptions.js +29 -0
- package/src/errors/AskImuOnDesktopError.js +9 -0
- package/src/errors/ContainsIgnoredProviderError.js +9 -0
- package/src/errors/GeolocationApiMissingError.js +9 -0
- package/src/errors/GeolocationPermissionDeniedError.js +9 -0
- package/src/errors/GeolocationPositionUnavailableError.js +9 -0
- package/src/errors/IpResolveServerError.js +9 -0
- package/src/errors/MissingAccelerometerError.js +11 -0
- package/src/errors/MissingArCoreError.js +9 -0
- package/src/errors/MissingGyroscopeError.js +11 -0
- package/src/errors/MissingMagnetometerError.js +9 -0
- package/src/errors/MissingNativeInterfaceError.js +9 -0
- package/src/errors/MissingSensorError.js +14 -0
- package/src/errors/NoProviderFoundError.js +9 -0
- package/src/events/Availability.js +44 -0
- package/src/events/EventType.js +33 -0
- package/src/events/ProviderEvent.js +32 -0
- package/src/events/ProvidersLogger.js +83 -0
- package/src/providers/Constants.js +5 -0
- package/src/providers/FakeProvider.spec.js +57 -0
- package/src/providers/MetaProvider.js +42 -0
- package/src/providers/Provider.js +314 -0
- package/src/providers/Provider.spec.js +136 -0
- package/src/providers/ProviderState.js +5 -0
- package/src/providers/attitude/AttitudeProvider.js +63 -0
- package/src/providers/attitude/EkfAttitude.js +224 -0
- package/src/providers/attitude/EkfAttitude.spec.js +114 -0
- package/src/providers/attitude/absolute/AbsoluteAttitudeFromBrowserProvider.js +224 -0
- package/src/providers/attitude/absolute/AbsoluteAttitudeFromRelAttProvider.js +134 -0
- package/src/providers/attitude/absolute/AbsoluteAttitudeProvider.js +143 -0
- package/src/providers/attitude/relative/RelativeAttitudeFromBrowserProvider.js +89 -0
- package/src/providers/attitude/relative/RelativeAttitudeFromEkfProvider.js +114 -0
- package/src/providers/attitude/relative/RelativeAttitudeProvider.js +103 -0
- package/src/providers/imu/AccelerometerProvider.js +61 -0
- package/src/providers/imu/GyroscopeProvider.js +61 -0
- package/src/providers/imu/ImuProvider.js +122 -0
- package/src/providers/inclination/InclinationFromAccProvider.js +87 -0
- package/src/providers/inclination/InclinationFromAttitudeProvider.js +77 -0
- package/src/providers/inclination/InclinationProvider.js +69 -0
- package/src/providers/legacy/AbsolutePdrProvider.js +258 -0
- package/src/providers/legacy/ArCoreAbsoluteProvider.js +230 -0
- package/src/providers/legacy/GnssWifiPdrProvider.js +217 -0
- package/src/providers/legacy/MapMatchingProvider.js +65 -0
- package/src/providers/legacy/PdrProvider.old.js +300 -0
- package/src/providers/legacy/PoseProvider.js +68 -0
- package/src/providers/legacy/helpers/HeadingUnlocker.js +47 -0
- package/src/providers/legacy/helpers/HeadingUnlocker.spec.js +53 -0
- package/src/providers/legacy/helpers/Smoother.js +92 -0
- package/src/providers/legacy/helpers/Smoother.spec.js +426 -0
- package/src/providers/legacy/helpers/ThugDetector.js +37 -0
- package/src/providers/others/CameraNativeProvider.js +44 -0
- package/src/providers/position/absolute/AbsolutePositionFromRelProvider.js +109 -0
- package/src/providers/position/absolute/AbsolutePositionProvider.js +172 -0
- package/src/providers/position/absolute/GnssWifiProvider.js +122 -0
- package/src/providers/position/absolute/IpProvider.js +68 -0
- package/src/providers/position/relative/ArCoreProvider.js +197 -0
- package/src/providers/position/relative/GeoRelativePositionFromArCoreProvider.js +85 -0
- package/src/providers/position/relative/GeoRelativePositionProvider.js +66 -0
- package/src/providers/position/relative/PdrProvider.js +132 -0
- package/src/providers/steps/StepDetectionLadetto.js +67 -0
- package/src/providers/steps/StepDetectionMinMaxPeaks.js +80 -0
- package/src/providers/steps/StepDetectionMinMaxPeaks2.js +108 -0
- package/src/providers/steps/StepDetectionProvider.js +100 -0
- package/src/smoothers/PositionSmoother.js +86 -0
- package/src/smoothers/PositionSmoother.spec.js +55 -0
- package/webpack/webpack.common.js +20 -0
- package/webpack/webpack.dev.js +24 -0
- package/webpack/webpack.prod.js +15 -0
package/debug/pose.html
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
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 Pose</title>
|
|
8
|
+
<script src="/js/providers-components.js"></script>
|
|
9
|
+
</head>
|
|
10
|
+
|
|
11
|
+
<body>
|
|
12
|
+
<div id="app"></div>
|
|
13
|
+
<script>createReactElement(PoseComponent, document.getElementById('app'));</script>
|
|
14
|
+
</body>
|
|
15
|
+
|
|
16
|
+
</html>
|
|
@@ -0,0 +1,16 @@
|
|
|
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 Positioning</title>
|
|
8
|
+
<script src="/js/providers-components.js"></script>
|
|
9
|
+
</head>
|
|
10
|
+
|
|
11
|
+
<body>
|
|
12
|
+
<div id="app"></div>
|
|
13
|
+
<script>createReactElement(PositioningComponent, document.getElementById('app'));</script>
|
|
14
|
+
</body>
|
|
15
|
+
|
|
16
|
+
</html>
|
|
@@ -0,0 +1,16 @@
|
|
|
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 Relative Attitude</title>
|
|
8
|
+
<script src="/js/providers-components.js"></script>
|
|
9
|
+
</head>
|
|
10
|
+
|
|
11
|
+
<body>
|
|
12
|
+
<div id="app"></div>
|
|
13
|
+
<script>createReactElement(RelativeAttitudeComponent, document.getElementById('app'));</script>
|
|
14
|
+
</body>
|
|
15
|
+
|
|
16
|
+
</html>
|
|
@@ -0,0 +1,16 @@
|
|
|
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-components.js"></script>
|
|
9
|
+
</head>
|
|
10
|
+
|
|
11
|
+
<body>
|
|
12
|
+
<div id="app"></div>
|
|
13
|
+
<script>createReactElement(StepDetectionComponent, document.getElementById('app'));</script>
|
|
14
|
+
</body>
|
|
15
|
+
|
|
16
|
+
</html>
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"author": "Wemap",
|
|
3
|
+
"bugs": {
|
|
4
|
+
"url": "https://github.com/wemap/wemap-modules-js/issues"
|
|
5
|
+
},
|
|
6
|
+
"contributors": [
|
|
7
|
+
"Thibaud Michel <thibaud@getwemap.com>",
|
|
8
|
+
"Guillaume Pannetier <guillaume.pannetier@getwemap.com>"
|
|
9
|
+
],
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@wemap/geo": "^3.0.0",
|
|
12
|
+
"@wemap/graph": "^3.0.0",
|
|
13
|
+
"@wemap/logger": "^3.0.0",
|
|
14
|
+
"@wemap/maths": "^3.0.0",
|
|
15
|
+
"@wemap/osm": "^3.0.0",
|
|
16
|
+
"@wemap/utils": "^3.0.0",
|
|
17
|
+
"geomagnetism": "^0.1.0",
|
|
18
|
+
"lodash.isempty": "^4.4.0",
|
|
19
|
+
"lodash.isnumber": "^3.0.3",
|
|
20
|
+
"lodash.noop": "^3.0.1"
|
|
21
|
+
},
|
|
22
|
+
"description": "A package using different geoloc systems",
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@babel/core": "^7.5.5",
|
|
25
|
+
"@babel/plugin-proposal-class-properties": "^7.5.5",
|
|
26
|
+
"@babel/preset-env": "^7.5.5",
|
|
27
|
+
"@babel/preset-react": "^7.0.0",
|
|
28
|
+
"babel-loader": "^8.0.6",
|
|
29
|
+
"css-loader": "^3.2.0",
|
|
30
|
+
"mapbox-gl": "^1.3.0",
|
|
31
|
+
"prop-types": "^15.7.2",
|
|
32
|
+
"react": "^16.11.0",
|
|
33
|
+
"react-dom": "^16.11.0",
|
|
34
|
+
"style-loader": "^1.0.0",
|
|
35
|
+
"webpack": "^4.39.3",
|
|
36
|
+
"webpack-cli": "^3.3.7",
|
|
37
|
+
"webpack-dev-server": "^3.9.0",
|
|
38
|
+
"webpack-merge": "^4.2.1"
|
|
39
|
+
},
|
|
40
|
+
"homepage": "https://github.com/wemap/wemap-modules-js#readme",
|
|
41
|
+
"keywords": [
|
|
42
|
+
"wemap",
|
|
43
|
+
"providers",
|
|
44
|
+
"positioning",
|
|
45
|
+
"pdr",
|
|
46
|
+
"wifi",
|
|
47
|
+
"gnss",
|
|
48
|
+
"mapmatching",
|
|
49
|
+
"step-detection"
|
|
50
|
+
],
|
|
51
|
+
"license": "ISC",
|
|
52
|
+
"main": "index.js",
|
|
53
|
+
"name": "@wemap/providers",
|
|
54
|
+
"repository": {
|
|
55
|
+
"type": "git",
|
|
56
|
+
"url": "git+https://github.com/wemap/wemap-modules-js.git"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "webpack --display-modules --config webpack/webpack.prod.js",
|
|
60
|
+
"stats": "webpack --config webpack/webpack.prod.js --profile --json > stats.json",
|
|
61
|
+
"start": "webpack-dev-server --config webpack/webpack.dev.js --progress --inline --hot --https",
|
|
62
|
+
"lint": "eslint --ext .js,.jsx --quiet src",
|
|
63
|
+
"test": "mocha -r esm \"src/**/*.spec.js\""
|
|
64
|
+
},
|
|
65
|
+
"version": "3.0.0",
|
|
66
|
+
"gitHead": "2bbb4840a99b90eaae989291cb728ac87cebade8"
|
|
67
|
+
}
|
package/src/Providers.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import ImuProvider from './providers/imu/ImuProvider';
|
|
2
|
+
import AccelerometerProvider from './providers/imu/AccelerometerProvider';
|
|
3
|
+
import GyroscopeProvider from './providers/imu/GyroscopeProvider';
|
|
4
|
+
const Imu = ImuProvider.instance;
|
|
5
|
+
const Accelerometer = AccelerometerProvider.instance;
|
|
6
|
+
const Gyroscope = GyroscopeProvider.instance;
|
|
7
|
+
|
|
8
|
+
import RelativeAttitudeFromBrowserProvider from './providers/attitude/relative/RelativeAttitudeFromBrowserProvider';
|
|
9
|
+
import RelativeAttitudeFromEkfProvider from './providers/attitude/relative/RelativeAttitudeFromEkfProvider';
|
|
10
|
+
import RelativeAttitudeProvider from './providers/attitude/relative/RelativeAttitudeProvider';
|
|
11
|
+
const RelativeAttitudeFromBrowser = RelativeAttitudeFromBrowserProvider.instance;
|
|
12
|
+
const RelativeAttitudeFromEkf = RelativeAttitudeFromEkfProvider.instance;
|
|
13
|
+
const RelativeAttitude = RelativeAttitudeProvider.instance;
|
|
14
|
+
|
|
15
|
+
import AbsoluteAttitudeFromBrowserProvider from './providers/attitude/absolute/AbsoluteAttitudeFromBrowserProvider';
|
|
16
|
+
import AbsoluteAttitudeFromRelAttProvider from './providers/attitude/absolute/AbsoluteAttitudeFromRelAttProvider';
|
|
17
|
+
import AbsoluteAttitudeProvider from './providers/attitude/absolute/AbsoluteAttitudeProvider';
|
|
18
|
+
const AbsoluteAttitudeFromBrowser = AbsoluteAttitudeFromBrowserProvider.instance;
|
|
19
|
+
const AbsoluteAttitudeFromRelAtt = AbsoluteAttitudeFromRelAttProvider.instance;
|
|
20
|
+
const AbsoluteAttitude = AbsoluteAttitudeProvider.instance;
|
|
21
|
+
|
|
22
|
+
import AttitudeProvider from './providers/attitude/AttitudeProvider';
|
|
23
|
+
const Attitude = AttitudeProvider.instance;
|
|
24
|
+
|
|
25
|
+
import InclinationFromAccProvider from './providers/inclination/InclinationFromAccProvider';
|
|
26
|
+
import InclinationFromAttitudeProvider from './providers/inclination/InclinationFromAttitudeProvider';
|
|
27
|
+
import InclinationProvider from './providers/inclination/InclinationProvider';
|
|
28
|
+
const InclinationFromAcc = InclinationFromAccProvider.instance;
|
|
29
|
+
const InclinationFromAttitude = InclinationFromAttitudeProvider.instance;
|
|
30
|
+
const Inclination = InclinationProvider.instance;
|
|
31
|
+
|
|
32
|
+
import StepDetectionProvider from './providers/steps/StepDetectionProvider';
|
|
33
|
+
const StepDetection = StepDetectionProvider.instance;
|
|
34
|
+
|
|
35
|
+
import ArCoreProvider from './providers/position/relative/ArCoreProvider';
|
|
36
|
+
import PdrProvider from './providers/position/relative/PdrProvider';
|
|
37
|
+
import GeoRelativePositionFromArCoreProvider from './providers/position/relative/GeoRelativePositionFromArCoreProvider';
|
|
38
|
+
import GeoRelativePositionProvider from './providers/position/relative/GeoRelativePositionProvider';
|
|
39
|
+
const ArCore = ArCoreProvider.instance;
|
|
40
|
+
const Pdr = PdrProvider.instance;
|
|
41
|
+
const GeoRelativePositionFromArCore = GeoRelativePositionFromArCoreProvider.instance;
|
|
42
|
+
const GeoRelativePosition = GeoRelativePositionProvider.instance;
|
|
43
|
+
|
|
44
|
+
import AbsolutePositionFromRelProvider from './providers/position/absolute/AbsolutePositionFromRelProvider';
|
|
45
|
+
import GnssWifiProvider from './providers/position/absolute/GnssWifiProvider';
|
|
46
|
+
import IpProvider from './providers/position/absolute/IpProvider';
|
|
47
|
+
import AbsolutePositionProvider from './providers/position/absolute/AbsolutePositionProvider';
|
|
48
|
+
const AbsolutePositionFromRel = AbsolutePositionFromRelProvider.instance;
|
|
49
|
+
const GnssWifi = GnssWifiProvider.instance;
|
|
50
|
+
const Ip = IpProvider.instance;
|
|
51
|
+
const AbsolutePosition = AbsolutePositionProvider.instance;
|
|
52
|
+
|
|
53
|
+
import CameraNativeProvider from './providers/others/CameraNativeProvider';
|
|
54
|
+
const CameraNative = CameraNativeProvider.instance;
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
AbsoluteAttitude,
|
|
58
|
+
AbsoluteAttitudeFromBrowser,
|
|
59
|
+
AbsoluteAttitudeFromRelAtt,
|
|
60
|
+
AbsolutePosition,
|
|
61
|
+
AbsolutePositionFromRel,
|
|
62
|
+
Accelerometer,
|
|
63
|
+
ArCore,
|
|
64
|
+
Attitude,
|
|
65
|
+
CameraNative,
|
|
66
|
+
GeoRelativePosition,
|
|
67
|
+
GeoRelativePositionFromArCore,
|
|
68
|
+
GnssWifi,
|
|
69
|
+
Gyroscope,
|
|
70
|
+
Imu,
|
|
71
|
+
Inclination,
|
|
72
|
+
InclinationFromAcc,
|
|
73
|
+
InclinationFromAttitude,
|
|
74
|
+
Ip,
|
|
75
|
+
Pdr,
|
|
76
|
+
RelativeAttitude,
|
|
77
|
+
RelativeAttitudeFromBrowser,
|
|
78
|
+
RelativeAttitudeFromEkf,
|
|
79
|
+
StepDetection
|
|
80
|
+
};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
|
|
2
|
+
import {
|
|
3
|
+
Attitude, AbsoluteHeading, UserPosition
|
|
4
|
+
} from '@wemap/geo';
|
|
5
|
+
import { Network } from '@wemap/graph';
|
|
6
|
+
|
|
7
|
+
import EventType from './events/EventType';
|
|
8
|
+
import MetaProvider from './providers/MetaProvider';
|
|
9
|
+
import {
|
|
10
|
+
AbsoluteAttitude, AbsolutePosition, CameraNative, Inclination
|
|
11
|
+
} from './Providers';
|
|
12
|
+
import ProvidersLogger from './events/ProvidersLogger';
|
|
13
|
+
|
|
14
|
+
class ProvidersInterface {
|
|
15
|
+
|
|
16
|
+
static idListeners = new Map();
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {EventType} eventType
|
|
20
|
+
* @param {Function} onEvent
|
|
21
|
+
* @param {Function} onError
|
|
22
|
+
* @returns {Number}
|
|
23
|
+
*/
|
|
24
|
+
static addEventListener(eventType, onEvent, onError) {
|
|
25
|
+
const provider = this._getMetaProviderFromEventType(eventType);
|
|
26
|
+
const id = provider.addEventListener(events => onEvent(events[0].data), onError, this.name);
|
|
27
|
+
this.idListeners.set(id, provider);
|
|
28
|
+
return id;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @see addEventListener
|
|
33
|
+
* @param {Number} id
|
|
34
|
+
*/
|
|
35
|
+
static removeEventListener(id) {
|
|
36
|
+
const provider = this.idListeners.get(id);
|
|
37
|
+
if (provider) {
|
|
38
|
+
return provider.removeEventListener(id);
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @param {EventType} eventType
|
|
46
|
+
* @param {Object} data
|
|
47
|
+
*/
|
|
48
|
+
static feed(eventType, data) {
|
|
49
|
+
this._checkEventTypeDataConsistency(eventType, data);
|
|
50
|
+
this._getMetaProviderFromEventType(eventType).feed(data);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @param {EventType} eventType
|
|
55
|
+
*/
|
|
56
|
+
static getLastKnown(eventType) {
|
|
57
|
+
const { lastEvent } = this._getMetaProviderFromEventType(eventType);
|
|
58
|
+
return lastEvent ? lastEvent.data : null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param {EventType} eventType
|
|
63
|
+
* @returns {MetaProvider}
|
|
64
|
+
*/
|
|
65
|
+
static _getMetaProviderFromEventType(eventType) {
|
|
66
|
+
|
|
67
|
+
switch (eventType) {
|
|
68
|
+
case EventType.AbsoluteAttitude:
|
|
69
|
+
case EventType.AbsoluteHeading:
|
|
70
|
+
return AbsoluteAttitude;
|
|
71
|
+
|
|
72
|
+
case EventType.AbsolutePosition:
|
|
73
|
+
case EventType.Network:
|
|
74
|
+
return AbsolutePosition;
|
|
75
|
+
|
|
76
|
+
case EventType.Inclination:
|
|
77
|
+
return Inclination;
|
|
78
|
+
|
|
79
|
+
case EventType.CameraNative:
|
|
80
|
+
return CameraNative;
|
|
81
|
+
|
|
82
|
+
default:
|
|
83
|
+
throw new Error(`Unable to deal with this event type: ${eventType}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static _checkEventTypeDataConsistency(eventType, data) {
|
|
88
|
+
const errorFn = expectedType =>
|
|
89
|
+
new Error(`Event type (${eventType}) is not an instance of ${expectedType}`);
|
|
90
|
+
|
|
91
|
+
switch (eventType) {
|
|
92
|
+
case EventType.AbsoluteAttitude:
|
|
93
|
+
if (!(data instanceof Attitude)) {
|
|
94
|
+
throw errorFn('Attitude');
|
|
95
|
+
}
|
|
96
|
+
break;
|
|
97
|
+
case EventType.AbsoluteHeading:
|
|
98
|
+
if (!(data instanceof AbsoluteHeading)) {
|
|
99
|
+
throw errorFn('AbsoluteHeading');
|
|
100
|
+
}
|
|
101
|
+
break;
|
|
102
|
+
case EventType.AbsolutePosition:
|
|
103
|
+
if (!(data instanceof UserPosition)) {
|
|
104
|
+
throw errorFn('UserPosition');
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
case EventType.Network:
|
|
108
|
+
if (!(data instanceof Network)) {
|
|
109
|
+
throw errorFn('Network');
|
|
110
|
+
}
|
|
111
|
+
break;
|
|
112
|
+
default:
|
|
113
|
+
throw new Error(`Unable to deal with this event type: ${eventType}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* @param {Boolean} enabled
|
|
119
|
+
*/
|
|
120
|
+
static set logger(enabled) {
|
|
121
|
+
ProvidersLogger.enabled = enabled;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export default ProvidersInterface;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const ProvidersOptions = {
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Does provider will use map to
|
|
5
|
+
*/
|
|
6
|
+
useMapMatching: true,
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Providers listed here will not be used by the system
|
|
10
|
+
* List of {@link Provider#name}
|
|
11
|
+
*/
|
|
12
|
+
ignoreProviders: [],
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Define the list of EventType that are optionals
|
|
16
|
+
* List of {@link EventType}
|
|
17
|
+
*/
|
|
18
|
+
optionalEvents: [],
|
|
19
|
+
|
|
20
|
+
stopOnError: true,
|
|
21
|
+
|
|
22
|
+
checkAvailabilityOnStart: true,
|
|
23
|
+
|
|
24
|
+
stepdetectionlocker: true,
|
|
25
|
+
|
|
26
|
+
smoother: true
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default ProvidersOptions;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const DEFAULT_MESSAGE = 'Impossible to retrieve Acceleration data';
|
|
2
|
+
|
|
3
|
+
import MissingSensorError from './MissingSensorError';
|
|
4
|
+
|
|
5
|
+
class MissingAccelerometerError extends MissingSensorError {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message || DEFAULT_MESSAGE);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default MissingAccelerometerError;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const DEFAULT_MESSAGE = 'Impossible to retrieve Angular Rate data';
|
|
2
|
+
|
|
3
|
+
import MissingSensorError from './MissingSensorError';
|
|
4
|
+
|
|
5
|
+
class MissingGyroscopeError extends MissingSensorError {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message || DEFAULT_MESSAGE);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default MissingGyroscopeError;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const DEFAULT_MESSAGE = 'Impossible to retrieve events, a sensor is missing';
|
|
2
|
+
|
|
3
|
+
class MissingSensorError extends Error {
|
|
4
|
+
constructor(message) {
|
|
5
|
+
super(message || DEFAULT_MESSAGE);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
from(fromMessage) {
|
|
9
|
+
this.message += ' from ' + fromMessage;
|
|
10
|
+
return this;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default MissingSensorError;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
class Availability {
|
|
2
|
+
|
|
3
|
+
isSupported = false;
|
|
4
|
+
reason = null;
|
|
5
|
+
|
|
6
|
+
static no(reason) {
|
|
7
|
+
const availability = new Availability();
|
|
8
|
+
availability.reason = reason;
|
|
9
|
+
availability.isSupported = false;
|
|
10
|
+
return availability;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static yes() {
|
|
14
|
+
const availability = new Availability();
|
|
15
|
+
availability.isSupported = true;
|
|
16
|
+
return availability;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static merge(...availabilities) {
|
|
20
|
+
for (let i = 0; i < availabilities.length; i++) {
|
|
21
|
+
const availability = availabilities[i];
|
|
22
|
+
if (!availability.isSupported) {
|
|
23
|
+
return availability;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return Availability.yes();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static union(...availabilities) {
|
|
30
|
+
if (availabilities.length === 0) {
|
|
31
|
+
return Availability.yes();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
for (let i = 0; i < availabilities.length; i++) {
|
|
35
|
+
const availability = availabilities[i];
|
|
36
|
+
if (availability.isSupported) {
|
|
37
|
+
return availability;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return availabilities[0];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default Availability;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event data types handled by {@link ProviderEvent}
|
|
3
|
+
*/
|
|
4
|
+
export default {
|
|
5
|
+
Unknown: 'UNKNOWN',
|
|
6
|
+
|
|
7
|
+
MagneticField: 'MAGNETIC_FIELD',
|
|
8
|
+
AngularRate: 'ANGULAR_RATE',
|
|
9
|
+
Acceleration: 'ACCELERATION',
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
RelativeAttitude: 'RELATIVE_ATTITUDE',
|
|
13
|
+
AbsoluteAttitude: 'ABSOLUTE_ATTITUDE',
|
|
14
|
+
Attitude: 'ATTITUDE',
|
|
15
|
+
|
|
16
|
+
Inclination: 'INCLINATION',
|
|
17
|
+
AbsoluteHeading: 'ABSOLUTE_HEADING',
|
|
18
|
+
|
|
19
|
+
RelativePosition: 'RELATIVE_POSITION',
|
|
20
|
+
GeoRelativePosition: 'GEO_RELATIVE_POSITION',
|
|
21
|
+
AbsolutePosition: 'ABSOLUTE_POSITION',
|
|
22
|
+
|
|
23
|
+
Pressure: 'PRESSURE',
|
|
24
|
+
BluetoothSignals: 'BLUETOOTH_SIGNALS',
|
|
25
|
+
WifiSignals: 'WIFI_SIGNALS',
|
|
26
|
+
ScanId: 'SCAN_ID',
|
|
27
|
+
Barcode: 'BARCODE',
|
|
28
|
+
ProjectionMatrix: 'PROJECTION_MATRIX',
|
|
29
|
+
CameraNative: 'CAMERA_NATIVE',
|
|
30
|
+
|
|
31
|
+
Itinerary: 'ITINERARY',
|
|
32
|
+
Network: 'NETWORK'
|
|
33
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import EventType from './EventType';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A provider event is an event which can be triggered by device sensors
|
|
5
|
+
* or can be computed from raw providers.
|
|
6
|
+
*/
|
|
7
|
+
class ProviderEvent {
|
|
8
|
+
|
|
9
|
+
timestamp = -1;
|
|
10
|
+
dataType = EventType.Unknown;
|
|
11
|
+
providersStack = [];
|
|
12
|
+
data = null;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Create a Provider Event with the minimum information
|
|
16
|
+
* @param {EventType} dataType the type of event
|
|
17
|
+
* @param {Object} data the event data
|
|
18
|
+
*/
|
|
19
|
+
constructor(dataType, data) {
|
|
20
|
+
this.dataType = dataType;
|
|
21
|
+
this.data = data;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
clone() {
|
|
25
|
+
const evt = new ProviderEvent(this.dataType, this.data);
|
|
26
|
+
evt.timestamp = this.timestamp;
|
|
27
|
+
evt.providersStack = this.providersStack.slice(0);
|
|
28
|
+
return evt;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default ProviderEvent;
|