@wemap/providers 3.3.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 +12 -8
- package/debug/src/NavigationConfig.js +7 -8
- package/debug/src/RelativeAttitudeComponent.jsx +3 -3
- package/debug/src/Utils.js +32 -41
- package/index.js +6 -8
- package/package.json +8 -9
- package/src/Providers.js +26 -79
- package/src/ProvidersInterface.js +12 -9
- 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/ProviderEvent.js +0 -2
- package/src/events/ProvidersLoggerOld.js +35 -34
- package/src/mapmatching/MapMatchingHandler.js +138 -0
- package/src/providers/FakeProvider.spec.js +15 -17
- package/src/providers/Provider.js +5 -27
- package/src/providers/Provider.spec.js +18 -28
- package/src/providers/attitude/absolute/{AbsoluteAttitudeProvider.js → AbsoluteAttitude.js} +49 -18
- package/src/providers/attitude/absolute/{AbsoluteAttitudeFromBrowserProvider.js → AbsoluteAttitudeFromBrowser.js} +4 -5
- package/src/providers/attitude/absolute/{AbsoluteAttitudeFromRelAttProvider.js → AbsoluteAttitudeFromRelAtt.js} +8 -7
- package/src/providers/attitude/absolute/AbsoluteAttitudeFused.js +166 -0
- package/src/providers/attitude/relative/{RelativeAttitudeProvider.js → RelativeAttitude.js} +4 -5
- package/src/providers/attitude/relative/{RelativeAttitudeFromBrowserProvider.js → RelativeAttitudeFromBrowser.js} +6 -8
- package/src/providers/attitude/relative/{RelativeAttitudeFromEkfProvider.js → RelativeAttitudeFromEkf.js} +11 -11
- 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} +11 -5
- package/src/providers/inclination/{InclinationProvider.js → Inclination.js} +4 -5
- package/src/providers/inclination/{InclinationFromAccProvider.js → InclinationFromAcc.js} +5 -5
- package/src/providers/inclination/{InclinationFromRelativeAttitudeProvider.js → InclinationFromRelativeAttitude.js} +4 -4
- 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/AbsolutePosition.js +187 -0
- package/src/providers/position/absolute/{AbsolutePositionFromRelProvider.js → AbsolutePositionFromRel.js} +6 -8
- package/src/providers/position/absolute/{GnssWifiProvider.js → GnssWifi.js} +10 -9
- package/src/providers/position/absolute/{IpProvider.js → Ip.js} +4 -6
- package/src/providers/position/relative/{ArCoreProvider.js → ArCore.js} +29 -31
- package/src/providers/position/relative/{GeoRelativePositionProvider.js → GeoRelativePosition.js} +5 -5
- package/src/providers/position/relative/{GeoRelativePositionFromArCoreProvider.js → GeoRelativePositionFromArCore.js} +4 -6
- package/src/providers/position/relative/{PdrProvider.js → Pdr.js} +6 -7
- package/src/providers/steps/{StepDetectionProvider.js → StepDetection.js} +10 -9
- package/src/providers/steps/StepDetectionLadetto.js +12 -13
- package/src/providers/steps/StepDetectionMinMaxPeaks.js +19 -17
- package/src/providers/steps/StepDetectionMinMaxPeaks2.js +17 -18
- package/src/smoothers/AttitudeSmoother.js +100 -0
- package/src/providers/position/absolute/AbsolutePositionProvider.js +0 -295
|
@@ -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
|
/**
|
|
@@ -53,7 +54,7 @@ class InclinationFromAccProvider extends Provider {
|
|
|
53
54
|
* @private
|
|
54
55
|
*/
|
|
55
56
|
onAccelerometerEvent = accelerometerEvent => {
|
|
56
|
-
const acc = accelerometerEvent.data;
|
|
57
|
+
const acc = accelerometerEvent.data.values;
|
|
57
58
|
|
|
58
59
|
const screenOrientation = window.orientation || 0;
|
|
59
60
|
|
|
@@ -78,10 +79,9 @@ class InclinationFromAccProvider extends Provider {
|
|
|
78
79
|
this.notify(this.createEvent(
|
|
79
80
|
EventType.Inclination,
|
|
80
81
|
inclination,
|
|
81
|
-
accelerometerEvent.timestamp,
|
|
82
82
|
[accelerometerEvent]
|
|
83
83
|
));
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
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
|
|
@@ -44,7 +45,6 @@ class InclinationFromRelativeAttitudeProvider extends Provider {
|
|
|
44
45
|
this.notify(this.createEvent(
|
|
45
46
|
EventType.Inclination,
|
|
46
47
|
inclination,
|
|
47
|
-
attitudeEvent.timestamp,
|
|
48
48
|
[attitudeEvent]
|
|
49
49
|
));
|
|
50
50
|
},
|
|
@@ -74,4 +74,4 @@ class InclinationFromRelativeAttitudeProvider extends Provider {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
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();
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import noop from 'lodash.noop';
|
|
2
|
+
|
|
3
|
+
import { UserPosition } from '@wemap/geo';
|
|
4
|
+
import { PromiseUtils } from '@wemap/utils';
|
|
5
|
+
|
|
6
|
+
import MetaProvider from '../../MetaProvider.js';
|
|
7
|
+
import EventType from '../../../events/EventType.js';
|
|
8
|
+
import ProviderEvent from '../../../events/ProviderEvent.js';
|
|
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
|
+
|
|
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;
|
|
18
|
+
|
|
19
|
+
/** @type {number} */
|
|
20
|
+
lastMMAttempt = -Infinity;
|
|
21
|
+
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @override
|
|
28
|
+
*/
|
|
29
|
+
static get pname() {
|
|
30
|
+
return 'AbsolutePosition';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @override
|
|
35
|
+
*/
|
|
36
|
+
static get eventsType() {
|
|
37
|
+
return [EventType.AbsolutePosition];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @override
|
|
42
|
+
*/
|
|
43
|
+
get _availability() {
|
|
44
|
+
return PromiseUtils.any([
|
|
45
|
+
AbsolutePositionFromRel.availability,
|
|
46
|
+
GnssWifi.availability
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @override
|
|
53
|
+
*/
|
|
54
|
+
start() {
|
|
55
|
+
AbsolutePositionFromRel.availability
|
|
56
|
+
.then(() => {
|
|
57
|
+
this.fromRelPosProviderId = AbsolutePositionFromRel.addEventListener(
|
|
58
|
+
events => this.onAbsolutePositionFromRel(events[0]),
|
|
59
|
+
noop
|
|
60
|
+
);
|
|
61
|
+
})
|
|
62
|
+
.catch(() => {
|
|
63
|
+
// do nothing
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
this.gnssWifiProviderId = GnssWifi.addEventListener(
|
|
67
|
+
events => {
|
|
68
|
+
// bearing from GnssWifi is not reliable for our usecase
|
|
69
|
+
events[0].data.bearing = null;
|
|
70
|
+
this.onAbsolutePosition(events[0], false);
|
|
71
|
+
},
|
|
72
|
+
noop
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @override
|
|
80
|
+
*/
|
|
81
|
+
stop() {
|
|
82
|
+
if (this.fromRelPosProviderId) {
|
|
83
|
+
AbsolutePositionFromRel.removeEventListener(this.fromRelPosProviderId);
|
|
84
|
+
}
|
|
85
|
+
GnssWifi.removeEventListener(this.gnssWifiProviderId);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @param {ProviderEvent} newPositionEvent
|
|
90
|
+
* @param {boolean} canContainLevel
|
|
91
|
+
*/
|
|
92
|
+
onAbsolutePosition(newPositionEvent, canContainLevel = true) {
|
|
93
|
+
|
|
94
|
+
if (!this._useNewAbsolutePosition(newPositionEvent.data)) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const newPosition = newPositionEvent.data.clone();
|
|
99
|
+
|
|
100
|
+
if (this.lastEvent && !canContainLevel) {
|
|
101
|
+
newPosition.level = this.lastEvent.data.level;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// If the new position does not have a bearing, retrieve the bearing from the last position
|
|
105
|
+
if (newPosition.bearing === null && this.lastEvent !== null) {
|
|
106
|
+
newPosition.bearing = this.lastEvent.data.bearing;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const shouldTryMmOnNodes = !newPositionEvent.providersStack.includes(AbsolutePositionFromRel.pname);
|
|
110
|
+
const position = MapMatchingHandler.calcProjection(newPosition, shouldTryMmOnNodes) || newPosition;
|
|
111
|
+
|
|
112
|
+
this.notify(this.createEvent(
|
|
113
|
+
EventType.AbsolutePosition,
|
|
114
|
+
position,
|
|
115
|
+
[newPositionEvent]
|
|
116
|
+
));
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @param {ProviderEvent} newPositionEvent
|
|
122
|
+
*/
|
|
123
|
+
onAbsolutePositionFromRel(newPositionEvent) {
|
|
124
|
+
|
|
125
|
+
let position = newPositionEvent.data;
|
|
126
|
+
|
|
127
|
+
if (newPositionEvent.data.time - this.lastMMAttempt > AbsolutePosition.MM_MIN_TIME) {
|
|
128
|
+
position = MapMatchingHandler.calcProjection(position) || position;
|
|
129
|
+
this.lastMMAttempt = newPositionEvent.data.time;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (position === newPositionEvent.data) {
|
|
133
|
+
position = position.clone();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
this.notify(this.createEvent(
|
|
137
|
+
EventType.AbsolutePosition,
|
|
138
|
+
position,
|
|
139
|
+
[newPositionEvent]
|
|
140
|
+
));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
_useNewAbsolutePosition(newPosition) {
|
|
144
|
+
|
|
145
|
+
if (!this.lastEvent) {
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const lastPosition = this.lastEvent.data;
|
|
150
|
+
|
|
151
|
+
if (newPosition.accuracy <= newPosition.distanceTo(lastPosition) / AbsolutePosition.ACCURACY_NEW_POS_EPS_RATIO) {
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (newPosition.accuracy <= lastPosition.accuracy / AbsolutePosition.ACCURACY_RELOC_RATIO) {
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return false;
|
|
160
|
+
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* @override
|
|
165
|
+
* @param {UserPosition} data
|
|
166
|
+
*/
|
|
167
|
+
feed(data) {
|
|
168
|
+
if (data instanceof UserPosition) {
|
|
169
|
+
const position = data;
|
|
170
|
+
if (position.time === null) {
|
|
171
|
+
throw Error('the time of the position is not defined');
|
|
172
|
+
}
|
|
173
|
+
if (position.accuracy === null) {
|
|
174
|
+
throw Error('the accuracy of the position is not defined');
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
this.onAbsolutePosition(this.createEvent(
|
|
178
|
+
EventType.AbsolutePosition, position
|
|
179
|
+
));
|
|
180
|
+
} else {
|
|
181
|
+
throw new Error('Unknown feed object');
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
|
|
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
|
|
|
@@ -68,7 +67,7 @@ class AbsolutePositionFromRelProvider extends Provider {
|
|
|
68
67
|
/**
|
|
69
68
|
* Use absolute position events only when they are not from this provider
|
|
70
69
|
*/
|
|
71
|
-
if (absolutePositionEvent.
|
|
70
|
+
if (absolutePositionEvent.data === this.position) {
|
|
72
71
|
return;
|
|
73
72
|
}
|
|
74
73
|
|
|
@@ -91,13 +90,12 @@ class AbsolutePositionFromRelProvider extends Provider {
|
|
|
91
90
|
|
|
92
91
|
this.position = this.position.destinationPoint(dist, bearing, alt);
|
|
93
92
|
this.position.bearing = offsetPos.bearing;
|
|
94
|
-
this.position.time =
|
|
93
|
+
this.position.time = offsetPos.time;
|
|
95
94
|
this.position.accuracy += offsetPos.accuracy;
|
|
96
95
|
|
|
97
96
|
this.notify(this.createEvent(
|
|
98
97
|
EventType.AbsolutePosition,
|
|
99
98
|
this.position,
|
|
100
|
-
event.timestamp,
|
|
101
99
|
[event]
|
|
102
100
|
));
|
|
103
101
|
}
|
|
@@ -105,4 +103,4 @@ class AbsolutePositionFromRelProvider extends Provider {
|
|
|
105
103
|
|
|
106
104
|
}
|
|
107
105
|
|
|
108
|
-
export default
|
|
106
|
+
export default new AbsolutePositionFromRel();
|
|
@@ -10,11 +10,6 @@ import GeolocationPermissionDeniedError from '../../../errors/GeolocationPermiss
|
|
|
10
10
|
import GeolocationPositionUnavailableError from '../../../errors/GeolocationPositionUnavailableError.js';
|
|
11
11
|
import Constants from '../../Constants.js';
|
|
12
12
|
|
|
13
|
-
const POSITION_OPTIONS = {
|
|
14
|
-
enableHighAccuracy: true,
|
|
15
|
-
timeout: Infinity,
|
|
16
|
-
maximumAge: 0
|
|
17
|
-
};
|
|
18
13
|
|
|
19
14
|
/**
|
|
20
15
|
* GnssWifiProvider is a provider based on navigator.geolocation.
|
|
@@ -22,7 +17,13 @@ const POSITION_OPTIONS = {
|
|
|
22
17
|
* by Wifi Fingerprinting algorithms or by GNSS. That is why the name is
|
|
23
18
|
* "GnssWifi".
|
|
24
19
|
*/
|
|
25
|
-
class
|
|
20
|
+
class GnssWifi extends Provider {
|
|
21
|
+
|
|
22
|
+
static POSITION_OPTIONS = {
|
|
23
|
+
enableHighAccuracy: true,
|
|
24
|
+
timeout: Infinity,
|
|
25
|
+
maximumAge: 0
|
|
26
|
+
};
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* @override
|
|
@@ -55,7 +56,7 @@ class GnssWifiProvider extends Provider {
|
|
|
55
56
|
this.geoLocationId = navigator.geolocation.watchPosition(
|
|
56
57
|
this.onNewPosition,
|
|
57
58
|
this.onPositionError,
|
|
58
|
-
POSITION_OPTIONS
|
|
59
|
+
GnssWifi.POSITION_OPTIONS
|
|
59
60
|
);
|
|
60
61
|
|
|
61
62
|
}
|
|
@@ -97,7 +98,7 @@ class GnssWifiProvider extends Provider {
|
|
|
97
98
|
this.pname);
|
|
98
99
|
|
|
99
100
|
this.notify(this.createEvent(
|
|
100
|
-
EventType.AbsolutePosition, position
|
|
101
|
+
EventType.AbsolutePosition, position
|
|
101
102
|
));
|
|
102
103
|
|
|
103
104
|
};
|
|
@@ -122,4 +123,4 @@ class GnssWifiProvider extends Provider {
|
|
|
122
123
|
};
|
|
123
124
|
}
|
|
124
125
|
|
|
125
|
-
export default
|
|
126
|
+
export default new GnssWifi();
|
|
@@ -11,7 +11,7 @@ import IpResolveServerError from '../../../errors/IpResolveServerError.js';
|
|
|
11
11
|
* by Wifi Fingerprinting algorithms or by GNSS. That is why the name is
|
|
12
12
|
* "GnssWifi".
|
|
13
13
|
*/
|
|
14
|
-
class
|
|
14
|
+
class Ip extends Provider {
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* @override
|
|
@@ -39,7 +39,7 @@ class IpProvider extends Provider {
|
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
const timestamp = TimeUtils.preciseTime / 1e3;
|
|
42
|
+
const timestamp = TimeUtils.preciseTime() / 1e3;
|
|
43
43
|
|
|
44
44
|
const latLngStr = response.loc.split(',');
|
|
45
45
|
const position = new UserPosition(
|
|
@@ -50,9 +50,7 @@ class IpProvider extends Provider {
|
|
|
50
50
|
timestamp
|
|
51
51
|
);
|
|
52
52
|
|
|
53
|
-
this.notify(this.createEvent(
|
|
54
|
-
EventType.AbsolutePosition, position, timestamp
|
|
55
|
-
));
|
|
53
|
+
this.notify(this.createEvent(EventType.AbsolutePosition, position));
|
|
56
54
|
});
|
|
57
55
|
}
|
|
58
56
|
|
|
@@ -65,4 +63,4 @@ class IpProvider extends Provider {
|
|
|
65
63
|
|
|
66
64
|
}
|
|
67
65
|
|
|
68
|
-
export default
|
|
66
|
+
export default new Ip();
|
|
@@ -10,28 +10,26 @@ import EventType from '../../../events/EventType.js';
|
|
|
10
10
|
import MissingArCoreError from '../../../errors/MissingArCoreError.js';
|
|
11
11
|
import MissingNativeInterfaceError from '../../../errors/MissingNativeInterfaceError.js';
|
|
12
12
|
import ProviderState from '../../ProviderState.js';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
class ArCoreProvider extends Provider {
|
|
13
|
+
class ArCore extends Provider {
|
|
14
|
+
|
|
15
|
+
static Payload = {
|
|
16
|
+
Pose: {
|
|
17
|
+
ref: 2 ** 0,
|
|
18
|
+
size: 7
|
|
19
|
+
},
|
|
20
|
+
Barcode: {
|
|
21
|
+
ref: 2 ** 1,
|
|
22
|
+
size: 1
|
|
23
|
+
},
|
|
24
|
+
ProjMat: {
|
|
25
|
+
ref: 2 ** 2,
|
|
26
|
+
size: 16
|
|
27
|
+
},
|
|
28
|
+
ImageRef: {
|
|
29
|
+
ref: 2 ** 3,
|
|
30
|
+
size: 1
|
|
31
|
+
}
|
|
32
|
+
};
|
|
35
33
|
|
|
36
34
|
/**
|
|
37
35
|
* default relative attitude drift in rad.second-1
|
|
@@ -95,9 +93,9 @@ class ArCoreProvider extends Provider {
|
|
|
95
93
|
|
|
96
94
|
const events = [];
|
|
97
95
|
|
|
98
|
-
const time = TimeUtils.preciseTime / 1e3;
|
|
96
|
+
const time = TimeUtils.preciseTime() / 1e3;
|
|
99
97
|
|
|
100
|
-
if (ref & Payload.Pose.ref) {
|
|
98
|
+
if (ref & ArCore.Payload.Pose.ref) {
|
|
101
99
|
|
|
102
100
|
const attitude = new Attitude(
|
|
103
101
|
payload.slice(bufferIndex, bufferIndex + 4),
|
|
@@ -117,18 +115,18 @@ class ArCoreProvider extends Provider {
|
|
|
117
115
|
this.previousPosition = newPosition;
|
|
118
116
|
events.push(this.createEvent(EventType.RelativePosition, position));
|
|
119
117
|
|
|
120
|
-
bufferIndex += Payload.Pose.size;
|
|
118
|
+
bufferIndex += ArCore.Payload.Pose.size;
|
|
121
119
|
}
|
|
122
120
|
|
|
123
|
-
if (ref & Payload.Barcode.ref) {
|
|
121
|
+
if (ref & ArCore.Payload.Barcode.ref) {
|
|
124
122
|
events.push(this.createEvent(EventType.Barcode, payload[bufferIndex]));
|
|
125
|
-
bufferIndex += Payload.Barcode.size;
|
|
123
|
+
bufferIndex += ArCore.Payload.Barcode.size;
|
|
126
124
|
}
|
|
127
125
|
|
|
128
|
-
if (ref & Payload.ProjMat.ref) {
|
|
129
|
-
const projMatrix = payload.slice(bufferIndex, bufferIndex + Payload.ProjMat.size);
|
|
126
|
+
if (ref & ArCore.Payload.ProjMat.ref) {
|
|
127
|
+
const projMatrix = payload.slice(bufferIndex, bufferIndex + ArCore.Payload.ProjMat.size);
|
|
130
128
|
events.push(this.createEvent(EventType.CameraProjectionMatrix, projMatrix));
|
|
131
|
-
bufferIndex += Payload.ProjMat.size;
|
|
129
|
+
bufferIndex += ArCore.Payload.ProjMat.size;
|
|
132
130
|
}
|
|
133
131
|
|
|
134
132
|
if (events.length !== 0) {
|
|
@@ -197,4 +195,4 @@ class ArCoreProvider extends Provider {
|
|
|
197
195
|
}
|
|
198
196
|
}
|
|
199
197
|
|
|
200
|
-
export default
|
|
198
|
+
export default new ArCore();
|
package/src/providers/position/relative/{GeoRelativePositionProvider.js → GeoRelativePosition.js}
RENAMED
|
@@ -2,11 +2,11 @@ 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 GeoRelativePositionFromArCore from './GeoRelativePositionFromArCore.js';
|
|
6
|
+
import Pdr from './Pdr.js';
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
|
|
9
|
+
class GeoRelativePosition extends MetaProvider {
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @override
|
|
@@ -65,4 +65,4 @@ class GeoRelativePositionProvider extends MetaProvider {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
export default
|
|
68
|
+
export default new GeoRelativePosition();
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { GeoRelativePosition } from '@wemap/geo';
|
|
2
2
|
|
|
3
3
|
import EventType from '../../../events/EventType.js';
|
|
4
|
+
import AbsoluteAttitude from '../../attitude/absolute/AbsoluteAttitude.js';
|
|
4
5
|
import Provider from '../../Provider.js';
|
|
5
|
-
import
|
|
6
|
-
ArCore, AbsoluteAttitude
|
|
7
|
-
} from '../../../Providers.js';
|
|
6
|
+
import ArCore from './ArCore.js';
|
|
8
7
|
|
|
9
|
-
class
|
|
8
|
+
class GeoRelativePositionFromArCore extends Provider {
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* @override
|
|
@@ -84,10 +83,9 @@ class GeoRelativePositionFromArCoreProvider extends Provider {
|
|
|
84
83
|
this.notify(this.createEvent(
|
|
85
84
|
EventType.GeoRelativePosition,
|
|
86
85
|
position,
|
|
87
|
-
relativePosition.time,
|
|
88
86
|
[relativePositionEvent, relativeAttitudeEvent, absoluteAttitudeEvent]
|
|
89
87
|
));
|
|
90
88
|
}
|
|
91
89
|
}
|
|
92
90
|
|
|
93
|
-
export default
|
|
91
|
+
export default new GeoRelativePositionFromArCore();
|
|
@@ -3,11 +3,11 @@ import { deg2rad } from '@wemap/maths';
|
|
|
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 StepDetection from '../../steps/StepDetection.js';
|
|
7
|
+
import AbsoluteAttitude from '../../attitude/absolute/AbsoluteAttitude.js';
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
|
|
10
|
+
class Pdr extends Provider {
|
|
11
11
|
|
|
12
12
|
// https://ieeexplore.ieee.org/document/7346766
|
|
13
13
|
misalignment = [1, 0, 0, 0];
|
|
@@ -72,7 +72,6 @@ class PdrProvider extends Provider {
|
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
const timestamp = stepEvent.timestamp;
|
|
76
75
|
const stepSize = stepEvent.data.size;
|
|
77
76
|
|
|
78
77
|
/**
|
|
@@ -106,6 +105,7 @@ class PdrProvider extends Provider {
|
|
|
106
105
|
*/
|
|
107
106
|
const deviceDirectionAccuracy = deviceAttitude.accuracy + this.misalignmentError;
|
|
108
107
|
const accuracy = (stepSize / 2) * Math.sin(deviceDirectionAccuracy / 2);
|
|
108
|
+
const timestamp = deviceAttitude.time;
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
111
|
* Relative position is defined in ENU frame
|
|
@@ -122,11 +122,10 @@ class PdrProvider extends Provider {
|
|
|
122
122
|
this.notify(this.createEvent(
|
|
123
123
|
EventType.GeoRelativePosition,
|
|
124
124
|
position,
|
|
125
|
-
timestamp,
|
|
126
125
|
[stepEvent, this.attitudeEvent]
|
|
127
126
|
));
|
|
128
127
|
}
|
|
129
128
|
|
|
130
129
|
}
|
|
131
130
|
|
|
132
|
-
export default
|
|
131
|
+
export default new Pdr();
|