@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.
- package/debug/src/AbsoluteAttitudeComponent.jsx +4 -1
- package/package.json +5 -5
- package/src/Providers.js +26 -82
- package/src/errors/AskImuOnDesktopError.js +4 -3
- package/src/errors/ContainsIgnoredProviderError.js +4 -3
- package/src/errors/GeolocationApiMissingError.js +4 -3
- package/src/errors/GeolocationPermissionDeniedError.js +4 -3
- package/src/errors/GeolocationPositionUnavailableError.js +4 -3
- package/src/errors/IpResolveServerError.js +4 -3
- package/src/errors/MissingAccelerometerError.js +3 -3
- package/src/errors/MissingArCoreError.js +4 -3
- package/src/errors/MissingGyroscopeError.js +3 -3
- package/src/errors/MissingNativeInterfaceError.js +4 -3
- package/src/errors/MissingSensorError.js +4 -3
- package/src/errors/NoProviderFoundError.js +4 -3
- package/src/events/ProvidersLoggerOld.js +35 -34
- package/src/mapmatching/MapMatchingHandler.js +15 -27
- package/src/providers/FakeProvider.spec.js +15 -15
- package/src/providers/Provider.js +2 -19
- package/src/providers/Provider.spec.js +18 -28
- package/src/providers/attitude/absolute/{AbsoluteAttitudeProvider.js → AbsoluteAttitude.js} +5 -6
- package/src/providers/attitude/absolute/{AbsoluteAttitudeFromBrowserProvider.js → AbsoluteAttitudeFromBrowser.js} +4 -4
- package/src/providers/attitude/absolute/{AbsoluteAttitudeFromRelAttProvider.js → AbsoluteAttitudeFromRelAtt.js} +6 -5
- package/src/providers/attitude/absolute/{AbsoluteAttitudeFusedProvider.js → AbsoluteAttitudeFused.js} +3 -3
- package/src/providers/attitude/relative/{RelativeAttitudeProvider.js → RelativeAttitude.js} +4 -5
- package/src/providers/attitude/relative/{RelativeAttitudeFromBrowserProvider.js → RelativeAttitudeFromBrowser.js} +4 -4
- package/src/providers/attitude/relative/{RelativeAttitudeFromEkfProvider.js → RelativeAttitudeFromEkf.js} +7 -7
- package/src/providers/attitude/relative/{RelativeAttitudeFromInertialProvider.js → RelativeAttitudeFromInertial.js} +5 -5
- package/src/providers/imu/{AccelerometerProvider.js → Accelerometer.js} +3 -3
- package/src/providers/imu/{GyroscopeProvider.js → Gyroscope.js} +3 -3
- package/src/providers/imu/{ImuProvider.js → Imu.js} +3 -3
- package/src/providers/inclination/{InclinationProvider.js → Inclination.js} +4 -5
- package/src/providers/inclination/{InclinationFromAccProvider.js → InclinationFromAcc.js} +4 -3
- package/src/providers/inclination/{InclinationFromRelativeAttitudeProvider.js → InclinationFromRelativeAttitude.js} +4 -3
- package/src/providers/legacy/helpers/ThugDetector.js +7 -7
- package/src/providers/others/{BarcodeProvider.js → Barcode.js} +3 -3
- package/src/providers/others/{CameraNativeProvider.js → CameraNative.js} +2 -2
- package/src/providers/others/{CameraProjectionMatrixProvider.js → CameraProjectionMatrix.js} +3 -3
- package/src/providers/position/absolute/{AbsolutePositionProvider.js → AbsolutePosition.js} +11 -13
- package/src/providers/position/absolute/{AbsolutePositionFromRelProvider.js → AbsolutePositionFromRel.js} +4 -5
- package/src/providers/position/absolute/{GnssWifiProvider.js → GnssWifi.js} +9 -8
- package/src/providers/position/absolute/{IpProvider.js → Ip.js} +2 -2
- package/src/providers/position/relative/{ArCoreProvider.js → ArCore.js} +28 -30
- package/src/providers/position/relative/{GeoRelativePositionProvider.js → GeoRelativePosition.js} +5 -5
- package/src/providers/position/relative/{GeoRelativePositionFromArCoreProvider.js → GeoRelativePositionFromArCore.js} +4 -5
- package/src/providers/position/relative/{PdrProvider.js → Pdr.js} +5 -5
- package/src/providers/steps/{StepDetectionProvider.js → StepDetection.js} +6 -5
- package/src/providers/steps/StepDetectionLadetto.js +12 -13
- package/src/providers/steps/StepDetectionMinMaxPeaks.js +19 -17
- package/src/providers/steps/StepDetectionMinMaxPeaks2.js +17 -18
|
@@ -24,18 +24,11 @@ describe('Provider', () => {
|
|
|
24
24
|
|
|
25
25
|
it('creation/singleton', () => {
|
|
26
26
|
expect(() => new Provider()).throw(Error);
|
|
27
|
-
expect(() => Provider.instance).throw(Error);
|
|
28
|
-
expect(() => FakeProvider1.instance).not.throw(Error);
|
|
29
|
-
expect(() => FakeProvider2.instance).not.throw(Error);
|
|
30
|
-
expect(() => FakeProvider3.instance).not.throw(Error);
|
|
31
|
-
expect(() => FakeProvider4.instance).not.throw(Error);
|
|
32
|
-
expect(FakeProvider1.instance).equals(FakeProvider1.instance);
|
|
33
|
-
expect(FakeProvider4.instance).equals(FakeProvider4.instance);
|
|
34
27
|
});
|
|
35
28
|
|
|
36
29
|
|
|
37
30
|
it('default getter', () => {
|
|
38
|
-
const provider = FakeProvider1
|
|
31
|
+
const provider = FakeProvider1;
|
|
39
32
|
expect(provider.pname).equals(FakeProvider1.pname);
|
|
40
33
|
expect(provider.eventsType).is.empty;
|
|
41
34
|
expect(provider.hasNativeInterface).is.false;
|
|
@@ -45,33 +38,30 @@ describe('Provider', () => {
|
|
|
45
38
|
|
|
46
39
|
it('availability', async () => {
|
|
47
40
|
|
|
48
|
-
|
|
49
|
-
await expect(fakeProvider1.availability).to.be.fulfilled;
|
|
41
|
+
await expect(FakeProvider1.availability).to.be.fulfilled;
|
|
50
42
|
ProvidersOptions.ignoreProviders.push(FakeProvider1.pname);
|
|
51
|
-
await expect(
|
|
43
|
+
await expect(FakeProvider1.availability).to.be.rejectedWith(ContainsIgnoredProviderError);
|
|
52
44
|
ProvidersOptions.ignoreProviders = [];
|
|
53
45
|
|
|
54
|
-
await expect(FakeProvider2.
|
|
46
|
+
await expect(FakeProvider2.availability).to.be.rejectedWith(Error);
|
|
55
47
|
|
|
56
|
-
await expect(FakeProvider3.
|
|
57
|
-
await expect(FakeProvider4.
|
|
48
|
+
await expect(FakeProvider3.availability).to.be.fulfilled;
|
|
49
|
+
await expect(FakeProvider4.availability).to.be.fulfilled;
|
|
58
50
|
});
|
|
59
51
|
|
|
60
52
|
it('checkAvailability on start', async () => {
|
|
61
53
|
|
|
62
|
-
const fp2 = FakeProvider2.instance;
|
|
63
|
-
|
|
64
54
|
/**
|
|
65
55
|
* checkAvailabilityOnStart = true
|
|
66
56
|
*/
|
|
67
57
|
let errored = false;
|
|
68
|
-
|
|
58
|
+
FakeProvider2.addEventListener(noop, () => (errored = true));
|
|
69
59
|
|
|
70
60
|
await sleep(2);
|
|
71
61
|
|
|
72
62
|
expect(errored).is.true;
|
|
73
|
-
expect(
|
|
74
|
-
expect(
|
|
63
|
+
expect(FakeProvider2.state).equals(ProviderState.STOPPPED);
|
|
64
|
+
expect(FakeProvider2._eventsCallbacks.length).equals(0);
|
|
75
65
|
|
|
76
66
|
/**
|
|
77
67
|
* checkAvailabilityOnStart = false
|
|
@@ -79,16 +69,16 @@ describe('Provider', () => {
|
|
|
79
69
|
ProvidersOptions.checkAvailabilityOnStart = false;
|
|
80
70
|
|
|
81
71
|
errored = false;
|
|
82
|
-
const id =
|
|
72
|
+
const id = FakeProvider2.addEventListener(noop, () => (errored = true));
|
|
83
73
|
|
|
84
74
|
await sleep(2);
|
|
85
75
|
|
|
86
76
|
expect(errored).is.false;
|
|
87
|
-
expect(
|
|
77
|
+
expect(FakeProvider2.state).equals(ProviderState.STARTED);
|
|
88
78
|
|
|
89
|
-
|
|
90
|
-
expect(
|
|
91
|
-
expect(
|
|
79
|
+
FakeProvider2.removeEventListener(id);
|
|
80
|
+
expect(FakeProvider2.state).equals(ProviderState.STOPPPED);
|
|
81
|
+
expect(FakeProvider2._eventsCallbacks.length).equals(0);
|
|
92
82
|
|
|
93
83
|
ProvidersOptions.checkAvailabilityOnStart = true;
|
|
94
84
|
});
|
|
@@ -122,13 +112,13 @@ describe('Provider', () => {
|
|
|
122
112
|
|
|
123
113
|
it('start/stop', async () => {
|
|
124
114
|
let errored = false;
|
|
125
|
-
FakeProvider1.
|
|
115
|
+
FakeProvider1.addEventListener(noop, (errored = true));
|
|
126
116
|
await sleep(2);
|
|
127
117
|
expect(errored).is.true;
|
|
128
118
|
|
|
129
|
-
await expect(startStop(FakeProvider2
|
|
130
|
-
await expect(startStop(FakeProvider3
|
|
131
|
-
await expect(startStop(FakeProvider4
|
|
119
|
+
await expect(startStop(FakeProvider2)).to.be.fulfilled;
|
|
120
|
+
await expect(startStop(FakeProvider3)).to.be.fulfilled;
|
|
121
|
+
await expect(startStop(FakeProvider4)).to.be.fulfilled;
|
|
132
122
|
|
|
133
123
|
});
|
|
134
124
|
});
|
|
@@ -5,15 +5,14 @@ import { PromiseUtils } from '@wemap/utils';
|
|
|
5
5
|
|
|
6
6
|
import MetaProvider from '../../MetaProvider.js';
|
|
7
7
|
import EventType from '../../../events/EventType.js';
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
import AbsoluteAttitudeFromBrowser from './AbsoluteAttitudeFromBrowser.js';
|
|
9
|
+
import AbsoluteAttitudeFromRelAtt from './AbsoluteAttitudeFromRelAtt.js';
|
|
10
|
+
import AbsoluteAttitudeFused from './AbsoluteAttitudeFused.js';
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Absolute attitude provider gives the device attitude in East-North-Up (ENU) frame
|
|
15
14
|
*/
|
|
16
|
-
class
|
|
15
|
+
class AbsoluteAttitude extends MetaProvider {
|
|
17
16
|
|
|
18
17
|
constructor() {
|
|
19
18
|
super();
|
|
@@ -172,4 +171,4 @@ class AbsoluteAttitudeProvider extends MetaProvider {
|
|
|
172
171
|
}
|
|
173
172
|
}
|
|
174
173
|
|
|
175
|
-
export default
|
|
174
|
+
export default new AbsoluteAttitude();
|
|
@@ -15,7 +15,7 @@ import EventType from '../../../events/EventType.js';
|
|
|
15
15
|
import AskImuOnDesktopError from '../../../errors/AskImuOnDesktopError.js';
|
|
16
16
|
import MissingMagnetometerError from '../../../errors/MissingMagnetometerError.js';
|
|
17
17
|
import MissingSensorError from '../../../errors/MissingSensorError.js';
|
|
18
|
-
import
|
|
18
|
+
import AbsolutePosition from '../../position/absolute/AbsolutePosition.js';
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -35,7 +35,7 @@ import { AbsolutePosition } from '../../../Providers.js';
|
|
|
35
35
|
*
|
|
36
36
|
* -----------------------------------
|
|
37
37
|
*/
|
|
38
|
-
class
|
|
38
|
+
class AbsoluteAttitudeFromBrowser extends Provider {
|
|
39
39
|
|
|
40
40
|
// from http://tyrex.inria.fr/mobile/benchmarks-attitude/
|
|
41
41
|
static DEFAULT_ACCURACY = deg2rad(15);
|
|
@@ -207,7 +207,7 @@ class AbsoluteAttitudeFromBrowserProvider extends Provider {
|
|
|
207
207
|
if (isSkyMode) {
|
|
208
208
|
alpha = 180 - e.webkitCompassHeading;
|
|
209
209
|
} else {
|
|
210
|
-
alpha =
|
|
210
|
+
alpha = AbsoluteAttitudeFromBrowser.webkitCompassToHeading(
|
|
211
211
|
e.webkitCompassHeading, e.beta, e.gamma);
|
|
212
212
|
}
|
|
213
213
|
|
|
@@ -276,4 +276,4 @@ class AbsoluteAttitudeFromBrowserProvider extends Provider {
|
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
-
export default
|
|
279
|
+
export default new AbsoluteAttitudeFromBrowser();
|
|
@@ -3,14 +3,15 @@ import { Attitude } from '@wemap/geo';
|
|
|
3
3
|
|
|
4
4
|
import Provider from '../../Provider.js';
|
|
5
5
|
import EventType from '../../../events/EventType.js';
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import RelativeAttitude from '../relative/RelativeAttitude.js';
|
|
7
|
+
import AbsoluteAttitude from './AbsoluteAttitude.js';
|
|
8
|
+
import AbsoluteAttitudeFromBrowser from './AbsoluteAttitudeFromBrowser.js';
|
|
9
|
+
import AbsoluteAttitudeFused from './AbsoluteAttitudeFused.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Absolute attitude provider gives the device attitude in East-North-Up (ENU) frame
|
|
12
13
|
*/
|
|
13
|
-
class
|
|
14
|
+
class AbsoluteAttitudeFromRelAtt extends Provider {
|
|
14
15
|
|
|
15
16
|
accuracy = 0;
|
|
16
17
|
|
|
@@ -129,4 +130,4 @@ class AbsoluteAttitudeFromRelAttProvider extends Provider {
|
|
|
129
130
|
|
|
130
131
|
}
|
|
131
132
|
|
|
132
|
-
export default
|
|
133
|
+
export default new AbsoluteAttitudeFromRelAtt();
|
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
|
|
6
6
|
import Provider from '../../Provider.js';
|
|
7
7
|
import EventType from '../../../events/EventType.js';
|
|
8
|
-
import { RelativeAttitude } from '../../../Providers.js';
|
|
9
8
|
import ProviderState from '../../ProviderState.js';
|
|
9
|
+
import RelativeAttitude from '../relative/RelativeAttitude.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Absolute attitude provider gives the device attitude in East-North-Up (ENU) frame
|
|
13
13
|
*/
|
|
14
|
-
class
|
|
14
|
+
class AbsoluteAttitudeFused extends Provider {
|
|
15
15
|
|
|
16
16
|
accuracy = 0;
|
|
17
17
|
isInitialized = false;
|
|
@@ -163,4 +163,4 @@ class AbsoluteAttitudeFusedProvider extends Provider {
|
|
|
163
163
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
export default
|
|
166
|
+
export default new AbsoluteAttitudeFused();
|
|
@@ -3,17 +3,16 @@ import noop from 'lodash.noop';
|
|
|
3
3
|
import Provider from '../../Provider.js';
|
|
4
4
|
import EventType from '../../../events/EventType.js';
|
|
5
5
|
import ProviderState from '../../ProviderState.js';
|
|
6
|
-
import {
|
|
7
|
-
RelativeAttitudeFromInertial, ArCore
|
|
8
|
-
} from '../../../Providers.js';
|
|
9
6
|
|
|
7
|
+
import RelativeAttitudeFromInertial from './RelativeAttitudeFromInertial.js';
|
|
8
|
+
import ArCore from '../../position/relative/ArCore.js';
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Relative attitude provider gives the device attitude in East-North-Up (ENU) frame using
|
|
13
12
|
* browser deviceorientation
|
|
14
13
|
* The provider does not work until an offset is given.
|
|
15
14
|
*/
|
|
16
|
-
class
|
|
15
|
+
class RelativeAttitude extends Provider {
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
18
|
* @override
|
|
@@ -95,4 +94,4 @@ class RelativeAttitudeProvider extends Provider {
|
|
|
95
94
|
}
|
|
96
95
|
}
|
|
97
96
|
|
|
98
|
-
export default
|
|
97
|
+
export default new RelativeAttitude();
|
|
@@ -6,7 +6,7 @@ import Provider from '../../Provider.js';
|
|
|
6
6
|
import EventType from '../../../events/EventType.js';
|
|
7
7
|
import AskImuOnDesktopError from '../../../errors/AskImuOnDesktopError.js';
|
|
8
8
|
import MissingSensorError from '../../../errors/MissingSensorError.js';
|
|
9
|
-
import
|
|
9
|
+
import RelativeAttitudeFromInertial from './RelativeAttitudeFromInertial.js';
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -24,7 +24,7 @@ import RelativeAttitudeFromInertialProvider from './RelativeAttitudeFromInertial
|
|
|
24
24
|
*
|
|
25
25
|
* -----------------------------------
|
|
26
26
|
*/
|
|
27
|
-
class
|
|
27
|
+
class RelativeAttitudeFromBrowser extends Provider {
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* @override
|
|
@@ -88,11 +88,11 @@ class RelativeAttitudeFromBrowserProvider extends Provider {
|
|
|
88
88
|
const quaternion = Rotations.eulerToQuaternionZXYDegrees([e.alpha, e.beta, e.gamma]);
|
|
89
89
|
const attitude = new Attitude(quaternion,
|
|
90
90
|
e.timeStamp / 1e3,
|
|
91
|
-
|
|
91
|
+
RelativeAttitudeFromInertial.DEFAULT_DRIFT,
|
|
92
92
|
this.pname
|
|
93
93
|
);
|
|
94
94
|
this.notify(this.createEvent(EventType.RelativeAttitude, attitude));
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
export default
|
|
98
|
+
export default new RelativeAttitudeFromBrowser();
|
|
@@ -3,10 +3,10 @@ import { Attitude } from '@wemap/geo';
|
|
|
3
3
|
import Provider from '../../Provider.js';
|
|
4
4
|
import EventType from '../../../events/EventType.js';
|
|
5
5
|
import EkfAttitude from '../EkfAttitude.js';
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
import RelativeAttitudeFromInertial from './RelativeAttitudeFromInertial.js';
|
|
7
|
+
|
|
8
|
+
import Accelerometer from '../../imu/Accelerometer.js';
|
|
9
|
+
import Gyroscope from '../../imu/Gyroscope.js';
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
* browser deviceorientation
|
|
15
15
|
* The provider does not work until an offset is given.
|
|
16
16
|
*/
|
|
17
|
-
class
|
|
17
|
+
class RelativeAttitudeFromEkf extends Provider {
|
|
18
18
|
|
|
19
19
|
lastTimestamp = 0;
|
|
20
20
|
|
|
@@ -99,7 +99,7 @@ class RelativeAttitudeFromEkfProvider extends Provider {
|
|
|
99
99
|
if (quaternion) {
|
|
100
100
|
const attitude = new Attitude(quaternion,
|
|
101
101
|
timestamp,
|
|
102
|
-
|
|
102
|
+
RelativeAttitudeFromInertial.DEFAULT_DRIFT,
|
|
103
103
|
this.pname
|
|
104
104
|
);
|
|
105
105
|
this.notify(this.createEvent(
|
|
@@ -110,4 +110,4 @@ class RelativeAttitudeFromEkfProvider extends Provider {
|
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
export default
|
|
113
|
+
export default new RelativeAttitudeFromEkf();
|
|
@@ -3,11 +3,11 @@ import { PromiseUtils } from '@wemap/utils';
|
|
|
3
3
|
|
|
4
4
|
import Provider from '../../Provider.js';
|
|
5
5
|
import EventType from '../../../events/EventType.js';
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
} from '../../../Providers.js';
|
|
6
|
+
import RelativeAttitudeFromEkf from './RelativeAttitudeFromEkf.js';
|
|
7
|
+
import RelativeAttitudeFromBrowser from './RelativeAttitudeFromBrowser.js';
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
|
|
10
|
+
class RelativeAttitudeFromInertial extends Provider {
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* default relative attitude drift in rad.second-1
|
|
@@ -67,4 +67,4 @@ class RelativeAttitudeFromInertialProvider extends Provider {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
export default
|
|
70
|
+
export default new RelativeAttitudeFromInertial();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import Provider from '../Provider.js';
|
|
2
2
|
import EventType from '../../events/EventType.js';
|
|
3
3
|
import MissingAccelerometerError from '../../errors/MissingAccelerometerError.js';
|
|
4
|
-
import
|
|
4
|
+
import Imu from './Imu.js';
|
|
5
5
|
|
|
6
|
-
class
|
|
6
|
+
class Accelerometer extends Provider {
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @override
|
|
@@ -58,4 +58,4 @@ class AccelerometerProvider extends Provider {
|
|
|
58
58
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
export default
|
|
61
|
+
export default new Accelerometer();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import Provider from '../Provider.js';
|
|
2
2
|
import EventType from '../../events/EventType.js';
|
|
3
3
|
import MissingGyroscopeError from '../../errors/MissingGyroscopeError.js';
|
|
4
|
-
import
|
|
4
|
+
import Imu from './Imu.js';
|
|
5
5
|
|
|
6
|
-
class
|
|
6
|
+
class Gyroscope extends Provider {
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @override
|
|
@@ -58,4 +58,4 @@ class GyroscopeProvider extends Provider {
|
|
|
58
58
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
export default
|
|
61
|
+
export default new Gyroscope();
|
|
@@ -22,7 +22,7 @@ import AskImuOnDesktopError from '../../errors/AskImuOnDesktopError.js';
|
|
|
22
22
|
*
|
|
23
23
|
* -----------------------------------
|
|
24
24
|
*/
|
|
25
|
-
class
|
|
25
|
+
class Imu extends Provider {
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* @override
|
|
@@ -41,7 +41,7 @@ class ImuProvider extends Provider {
|
|
|
41
41
|
/**
|
|
42
42
|
* @override
|
|
43
43
|
*/
|
|
44
|
-
get _availability() {
|
|
44
|
+
static get _availability() {
|
|
45
45
|
return BrowserUtils.isMobile
|
|
46
46
|
? Promise.resolve()
|
|
47
47
|
: Promise.reject(new AskImuOnDesktopError());
|
|
@@ -136,4 +136,4 @@ class ImuProvider extends Provider {
|
|
|
136
136
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
export default
|
|
139
|
+
export default new Imu();
|
|
@@ -2,9 +2,8 @@ import { PromiseUtils } from '@wemap/utils';
|
|
|
2
2
|
|
|
3
3
|
import MetaProvider from '../MetaProvider.js';
|
|
4
4
|
import EventType from '../../events/EventType.js';
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
} from '../../Providers.js';
|
|
5
|
+
import InclinationFromAcc from './InclinationFromAcc.js';
|
|
6
|
+
import InclinationFromRelativeAttitude from './InclinationFromRelativeAttitude.js';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Inclination provider gives the inclination of the device using Imu Sensor
|
|
@@ -12,7 +11,7 @@ import {
|
|
|
12
11
|
* when the device is layed on a table, inclination = 0
|
|
13
12
|
* This provider use window.orientation to return a result in function of screen orientation
|
|
14
13
|
*/
|
|
15
|
-
class
|
|
14
|
+
class Inclination extends MetaProvider {
|
|
16
15
|
|
|
17
16
|
/**
|
|
18
17
|
* @override
|
|
@@ -75,4 +74,4 @@ class InclinationProvider extends MetaProvider {
|
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
76
|
|
|
78
|
-
export default
|
|
77
|
+
export default new Inclination();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Provider from '../Provider.js';
|
|
2
2
|
import EventType from '../../events/EventType.js';
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
import Accelerometer from '../imu/Accelerometer.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Inclination provider gives the inclination of the device using Imu Sensor
|
|
@@ -8,7 +9,7 @@ import { Accelerometer } from '../../Providers.js';
|
|
|
8
9
|
* when the device is layed on a table, inclination = 0
|
|
9
10
|
* This provider use window.orientation to return a result in function of screen orientation
|
|
10
11
|
*/
|
|
11
|
-
class
|
|
12
|
+
class InclinationFromAcc extends Provider {
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -83,4 +84,4 @@ class InclinationFromAccProvider extends Provider {
|
|
|
83
84
|
};
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
export default
|
|
87
|
+
export default new InclinationFromAcc();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Provider from '../Provider.js';
|
|
2
2
|
import EventType from '../../events/EventType.js';
|
|
3
|
-
import
|
|
3
|
+
import RelativeAttitudeFromInertial from '../attitude/relative/RelativeAttitudeFromInertial.js';
|
|
4
|
+
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Inclination provider gives the inclination of the device using Relative Attitude
|
|
@@ -8,7 +9,7 @@ import { RelativeAttitudeFromInertial } from '../../Providers.js';
|
|
|
8
9
|
* when the device is layed on a table, inclination = 0
|
|
9
10
|
* This provider use window.orientation to return a result in function of screen orientation
|
|
10
11
|
*/
|
|
11
|
-
class
|
|
12
|
+
class InclinationFromRelativeAttitude extends Provider {
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* @override
|
|
@@ -73,4 +74,4 @@ class InclinationFromRelativeAttitudeProvider extends Provider {
|
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
export default
|
|
77
|
+
export default new InclinationFromRelativeAttitude();
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Constants as GeoConstants } from '@wemap/geo';
|
|
2
2
|
import { Vector3 } from '@wemap/maths';
|
|
3
3
|
|
|
4
|
-
// in seconds
|
|
5
|
-
const MIN_TIME_BETWEEN_DETECTIONS = 0.5;
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
const EXT_ACC_NORM_THRESHOLD = 4;
|
|
5
|
+
class ThugDetector {
|
|
9
6
|
|
|
7
|
+
// in seconds
|
|
8
|
+
static MIN_TIME_BETWEEN_DETECTIONS = 0.5;
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
// in m.s^-2
|
|
11
|
+
static EXT_ACC_NORM_THRESHOLD = 4;
|
|
12
12
|
|
|
13
13
|
constructor() {
|
|
14
14
|
this.lastDetectionTimestamp = 0;
|
|
@@ -18,12 +18,12 @@ class ThugDetector {
|
|
|
18
18
|
|
|
19
19
|
let detection = false;
|
|
20
20
|
|
|
21
|
-
if (timestamp - this.lastDetectionTimestamp < MIN_TIME_BETWEEN_DETECTIONS) {
|
|
21
|
+
if (timestamp - this.lastDetectionTimestamp < ThugDetector.MIN_TIME_BETWEEN_DETECTIONS) {
|
|
22
22
|
return detection;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const extAccNorm = Vector3.norm(acceleration) - GeoConstants.EARTH_GRAVITY;
|
|
26
|
-
if (Math.abs(extAccNorm) > EXT_ACC_NORM_THRESHOLD) {
|
|
26
|
+
if (Math.abs(extAccNorm) > ThugDetector.EXT_ACC_NORM_THRESHOLD) {
|
|
27
27
|
detection = true;
|
|
28
28
|
this.lastDetectionTimestamp = timestamp;
|
|
29
29
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Provider from '../Provider.js';
|
|
2
2
|
import EventType from '../../events/EventType.js';
|
|
3
|
-
import
|
|
3
|
+
import ArCore from '../position/relative/ArCore.js';
|
|
4
4
|
|
|
5
|
-
class
|
|
5
|
+
class Barcode extends Provider {
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @override
|
|
@@ -51,4 +51,4 @@ class BarcodeProvider extends Provider {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export default
|
|
54
|
+
export default new Barcode();
|
|
@@ -3,7 +3,7 @@ import EventType from '../../events/EventType.js';
|
|
|
3
3
|
import { ArCore } from '../../Providers.js';
|
|
4
4
|
import ProviderState from '../ProviderState.js';
|
|
5
5
|
|
|
6
|
-
class
|
|
6
|
+
class CameraNative extends MetaProvider {
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @override
|
|
@@ -52,4 +52,4 @@ class CameraNativeProvider extends MetaProvider {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
export default
|
|
55
|
+
export default new CameraNative();
|
package/src/providers/others/{CameraProjectionMatrixProvider.js → CameraProjectionMatrix.js}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import MetaProvider from '../MetaProvider.js';
|
|
2
2
|
import EventType from '../../events/EventType.js';
|
|
3
|
-
import
|
|
3
|
+
import ArCore from '../position/relative/ArCore.js';
|
|
4
4
|
|
|
5
|
-
class
|
|
5
|
+
class CameraProjectionMatrix extends MetaProvider {
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @override
|
|
@@ -48,4 +48,4 @@ class CameraProjectionMatrixProvider extends MetaProvider {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
export default
|
|
51
|
+
export default new CameraProjectionMatrix();
|
|
@@ -6,17 +6,15 @@ import { PromiseUtils } from '@wemap/utils';
|
|
|
6
6
|
import MetaProvider from '../../MetaProvider.js';
|
|
7
7
|
import EventType from '../../../events/EventType.js';
|
|
8
8
|
import ProviderEvent from '../../../events/ProviderEvent.js';
|
|
9
|
-
import {
|
|
10
|
-
AbsolutePositionFromRel, GnssWifi
|
|
11
|
-
} from '../../../Providers.js';
|
|
12
9
|
import MapMatchingHandler from '../../../mapmatching/MapMatchingHandler.js';
|
|
10
|
+
import AbsolutePositionFromRel from './AbsolutePositionFromRel.js';
|
|
11
|
+
import GnssWifi from './GnssWifi.js';
|
|
12
|
+
class AbsolutePosition extends MetaProvider {
|
|
13
13
|
|
|
14
|
-
// Position accuracy uncertainty ratio
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class AbsolutePositionProvider extends MetaProvider {
|
|
14
|
+
// Position accuracy uncertainty ratio
|
|
15
|
+
static ACCURACY_NEW_POS_EPS_RATIO = 1.5;
|
|
16
|
+
static ACCURACY_RELOC_RATIO = 2;
|
|
17
|
+
static MM_MIN_TIME = 0.4;
|
|
20
18
|
|
|
21
19
|
/** @type {number} */
|
|
22
20
|
lastMMAttempt = -Infinity;
|
|
@@ -126,7 +124,7 @@ class AbsolutePositionProvider extends MetaProvider {
|
|
|
126
124
|
|
|
127
125
|
let position = newPositionEvent.data;
|
|
128
126
|
|
|
129
|
-
if (newPositionEvent.data.time - this.lastMMAttempt > MM_MIN_TIME) {
|
|
127
|
+
if (newPositionEvent.data.time - this.lastMMAttempt > AbsolutePosition.MM_MIN_TIME) {
|
|
130
128
|
position = MapMatchingHandler.calcProjection(position) || position;
|
|
131
129
|
this.lastMMAttempt = newPositionEvent.data.time;
|
|
132
130
|
}
|
|
@@ -150,11 +148,11 @@ class AbsolutePositionProvider extends MetaProvider {
|
|
|
150
148
|
|
|
151
149
|
const lastPosition = this.lastEvent.data;
|
|
152
150
|
|
|
153
|
-
if (newPosition.accuracy <= newPosition.distanceTo(lastPosition) / ACCURACY_NEW_POS_EPS_RATIO) {
|
|
151
|
+
if (newPosition.accuracy <= newPosition.distanceTo(lastPosition) / AbsolutePosition.ACCURACY_NEW_POS_EPS_RATIO) {
|
|
154
152
|
return true;
|
|
155
153
|
}
|
|
156
154
|
|
|
157
|
-
if (newPosition.accuracy <= lastPosition.accuracy / ACCURACY_RELOC_RATIO) {
|
|
155
|
+
if (newPosition.accuracy <= lastPosition.accuracy / AbsolutePosition.ACCURACY_RELOC_RATIO) {
|
|
158
156
|
return true;
|
|
159
157
|
}
|
|
160
158
|
|
|
@@ -186,4 +184,4 @@ class AbsolutePositionProvider extends MetaProvider {
|
|
|
186
184
|
|
|
187
185
|
}
|
|
188
186
|
|
|
189
|
-
export default
|
|
187
|
+
export default new AbsolutePosition();
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import Provider from '../../Provider.js';
|
|
2
2
|
import EventType from '../../../events/EventType.js';
|
|
3
3
|
import ProviderEvent from '../../../events/ProviderEvent.js';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
} from '../../../Providers.js';
|
|
4
|
+
import GeoRelativePosition from '../relative/GeoRelativePosition.js';
|
|
5
|
+
import AbsolutePosition from './AbsolutePosition.js';
|
|
7
6
|
|
|
8
|
-
class
|
|
7
|
+
class AbsolutePositionFromRel extends Provider {
|
|
9
8
|
|
|
10
9
|
position = null;
|
|
11
10
|
|
|
@@ -104,4 +103,4 @@ class AbsolutePositionFromRelProvider extends Provider {
|
|
|
104
103
|
|
|
105
104
|
}
|
|
106
105
|
|
|
107
|
-
export default
|
|
106
|
+
export default new AbsolutePositionFromRel();
|