@wemap/providers 3.1.23 → 3.2.2
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.json +16 -0
- package/debug/MainComponent.jsx +5 -5
- package/debug/components/AbsoluteAttitudeComponent.jsx +5 -5
- package/debug/components/AbsolutePositionComponent.jsx +7 -9
- package/debug/components/GnssWifiComponent.jsx +5 -5
- package/debug/components/ImuComponent.jsx +4 -4
- package/debug/components/InclinationComponent.jsx +4 -4
- package/debug/components/RelativeAttitudeComponent.jsx +4 -4
- package/debug/components/StepDetectionComponent.jsx +4 -4
- package/debug/components/Utils.js +1 -1
- package/debug/{Common.css → css/App.css} +0 -44
- package/debug/css/UserOnMapHandler.css +43 -0
- package/debug/details/DetailsAttitudeComponent.jsx +1 -1
- package/debug/details/DetailsComponent.jsx +4 -5
- package/debug/details/DetailsPositionComponent.jsx +2 -2
- package/debug/details/ItineraryComponent.jsx +10 -69
- package/debug/index.js +8 -8
- package/debug/map/MapComponent.jsx +23 -15
- package/debug/map/MapHandler.js +7 -16
- package/debug/map/helpers/ItineraryMapHandler.js +15 -16
- package/debug/map/helpers/MapClickHandler.js +9 -7
- package/debug/map/helpers/UserOnMapHandler.js +38 -417
- package/debug/stores/ItineraryStore.js +23 -48
- package/dist/assets/indoor-maps/bureaux-wemap-montpellier.geojson +339 -513
- package/dist/js/providers-components.js +2361 -0
- package/dist/logger.html +58 -0
- package/index.js +7 -5
- package/package.json +25 -21
- package/src/Providers.js +15 -15
- package/src/ProvidersInterface.js +7 -5
- package/src/errors/MissingAccelerometerError.js +2 -2
- package/src/errors/MissingGyroscopeError.js +2 -2
- package/src/errors/MissingMagnetometerError.js +1 -1
- package/src/events/ProviderEvent.js +1 -1
- package/src/events/{ProvidersLogger.js → ProvidersLoggerOld.js} +7 -7
- package/src/logger/NavigationLogger.js +138 -0
- package/src/logger/NavigationLoggerConverter.js +263 -0
- package/src/providers/FakeProvider.spec.js +3 -4
- package/src/providers/MetaProvider.js +3 -3
- package/src/providers/Provider.js +12 -11
- package/src/providers/Provider.spec.js +5 -7
- package/src/providers/attitude/EkfAttitude.spec.js +1 -1
- package/src/providers/attitude/absolute/AbsoluteAttitudeFromBrowserProvider.js +9 -8
- package/src/providers/attitude/absolute/AbsoluteAttitudeFromRelAttProvider.js +5 -6
- package/src/providers/attitude/absolute/AbsoluteAttitudeProvider.js +3 -3
- package/src/providers/attitude/relative/RelativeAttitudeFromBrowserProvider.js +7 -5
- package/src/providers/attitude/relative/RelativeAttitudeFromEkfProvider.js +5 -5
- package/src/providers/attitude/relative/RelativeAttitudeFromInertialProvider.js +3 -3
- package/src/providers/attitude/relative/RelativeAttitudeProvider.js +5 -4
- package/src/providers/imu/AccelerometerProvider.js +4 -4
- package/src/providers/imu/GyroscopeProvider.js +4 -4
- package/src/providers/imu/ImuProvider.js +5 -4
- package/src/providers/inclination/InclinationFromAccProvider.js +3 -3
- package/src/providers/inclination/InclinationFromRelativeAttitudeProvider.js +3 -3
- package/src/providers/inclination/InclinationProvider.js +3 -3
- package/src/providers/legacy/helpers/HeadingUnlocker.spec.js +1 -1
- package/src/providers/others/BarcodeProvider.js +3 -3
- package/src/providers/others/CameraNativeProvider.js +4 -4
- package/src/providers/others/CameraProjectionMatrixProvider.js +3 -3
- package/src/providers/position/absolute/AbsolutePositionFromRelProvider.js +4 -4
- package/src/providers/position/absolute/AbsolutePositionProvider.js +5 -5
- package/src/providers/position/absolute/GnssWifiProvider.js +9 -6
- package/src/providers/position/absolute/IpProvider.js +3 -3
- package/src/providers/position/relative/ArCoreProvider.js +5 -5
- package/src/providers/position/relative/GeoRelativePositionFromArCoreProvider.js +3 -3
- package/src/providers/position/relative/GeoRelativePositionProvider.js +3 -3
- package/src/providers/position/relative/PdrProvider.js +3 -3
- package/src/providers/steps/StepDetectionProvider.js +11 -4
- package/src/smoothers/PositionSmoother.spec.js +1 -1
- package/webpack/{webpack.common.js → webpack.common.cjs} +7 -1
- package/webpack/{webpack.dev.js → webpack.dev.cjs} +1 -7
- package/webpack/{webpack.prod.js → webpack.prod.cjs} +1 -1
- package/babel.config.js +0 -11
- package/debug/map/MapboxHelper.js +0 -50
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/* eslint-disable complexity */
|
|
2
|
+
import {
|
|
3
|
+
UserPosition, AbsoluteHeading, Attitude
|
|
4
|
+
} from '@wemap/geo';
|
|
5
|
+
import { Network } from '@wemap/graph';
|
|
6
|
+
|
|
7
|
+
import EventType from '../events/EventType.js';
|
|
8
|
+
|
|
9
|
+
const SEPARATOR = ',';
|
|
10
|
+
|
|
11
|
+
const PRECISION = 1e-6;
|
|
12
|
+
const PRECISION_INV = 1 / PRECISION;
|
|
13
|
+
const round = num => typeof num === 'number' ? Math.round(num * PRECISION_INV) / PRECISION_INV : num;
|
|
14
|
+
|
|
15
|
+
class NavigationLoggerConverter {
|
|
16
|
+
|
|
17
|
+
static configToLog(config) {
|
|
18
|
+
return [1, JSON.stringify(config)].join(SEPARATOR);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static geolocationToLog(time, event) {
|
|
22
|
+
return [
|
|
23
|
+
2,
|
|
24
|
+
round(time),
|
|
25
|
+
round(event.timestamp),
|
|
26
|
+
event.coords.latitude,
|
|
27
|
+
event.coords.longitude,
|
|
28
|
+
typeof event.coords.altitude === 'number' ? round(event.coords.altitude) : null,
|
|
29
|
+
round(event.coords.accuracy),
|
|
30
|
+
typeof event.coords.altitudeAccuracy === 'number' ? round(event.coords.altitudeAccuracy) : null,
|
|
31
|
+
typeof event.coords.heading === 'number' ? round(event.coords.heading) : null,
|
|
32
|
+
typeof event.coords.speed === 'number' ? round(event.coords.speed) : null
|
|
33
|
+
].join(SEPARATOR);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static imuDataToLog(time, event) {
|
|
37
|
+
switch (event.type) {
|
|
38
|
+
|
|
39
|
+
case 'devicemotion':
|
|
40
|
+
const acc = event.accelerationIncludingGravity;
|
|
41
|
+
const gyr = event.rotationRate;
|
|
42
|
+
const linearAcc = event.acceleration;
|
|
43
|
+
return [
|
|
44
|
+
3,
|
|
45
|
+
event.type,
|
|
46
|
+
round(time),
|
|
47
|
+
round(event.timeStamp),
|
|
48
|
+
acc && typeof acc.x === 'number' ? round(acc.x) : null,
|
|
49
|
+
acc && typeof acc.y === 'number' ? round(acc.y) : null,
|
|
50
|
+
acc && typeof acc.z === 'number' ? round(acc.z) : null,
|
|
51
|
+
gyr && typeof gyr.alpha === 'number' ? round(gyr.alpha) : null,
|
|
52
|
+
gyr && typeof gyr.beta === 'number' ? round(gyr.beta) : null,
|
|
53
|
+
gyr && typeof gyr.gamma === 'number' ? round(gyr.gamma) : null,
|
|
54
|
+
linearAcc && typeof linearAcc.x === 'number' ? round(linearAcc.x) : null,
|
|
55
|
+
linearAcc && typeof linearAcc.y === 'number' ? round(linearAcc.y) : null,
|
|
56
|
+
linearAcc && typeof linearAcc.z === 'number' ? round(linearAcc.z) : null,
|
|
57
|
+
round(event.interval)
|
|
58
|
+
].join(SEPARATOR);
|
|
59
|
+
|
|
60
|
+
case 'deviceorientation':
|
|
61
|
+
return [
|
|
62
|
+
3,
|
|
63
|
+
event.type,
|
|
64
|
+
round(time),
|
|
65
|
+
round(event.timeStamp),
|
|
66
|
+
round(event.alpha),
|
|
67
|
+
round(event.beta),
|
|
68
|
+
round(event.gamma),
|
|
69
|
+
round(event.webkitCompassHeading),
|
|
70
|
+
event.absolute ? 1 : 0
|
|
71
|
+
].join(SEPARATOR);
|
|
72
|
+
|
|
73
|
+
case 'deviceorientationabsolute':
|
|
74
|
+
return [
|
|
75
|
+
3,
|
|
76
|
+
event.type,
|
|
77
|
+
round(time),
|
|
78
|
+
round(event.timeStamp),
|
|
79
|
+
round(event.alpha),
|
|
80
|
+
round(event.beta),
|
|
81
|
+
round(event.gamma),
|
|
82
|
+
event.absolute ? 1 : 0
|
|
83
|
+
].join(SEPARATOR);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
throw new Error(`Cannot parse event: ${event.type}`, event);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
static externalDataToLog(time, eventType, data) {
|
|
90
|
+
switch (eventType) {
|
|
91
|
+
case EventType.Network:
|
|
92
|
+
return [4, 'network', round(time), data === null ? null : JSON.stringify(data.toCompressedJson())].join(SEPARATOR);
|
|
93
|
+
case EventType.AbsolutePosition:
|
|
94
|
+
return [4, 'absolute-position', round(time), JSON.stringify(data.toJson())].join(SEPARATOR);
|
|
95
|
+
case EventType.AbsoluteHeading:
|
|
96
|
+
return [4, 'absolute-heading', round(time), JSON.stringify(data.toJson())].join(SEPARATOR);
|
|
97
|
+
case EventType.AbsoluteAttitude:
|
|
98
|
+
return [4, 'absolute-attitude', round(time), JSON.stringify(data.toJson())].join(SEPARATOR);
|
|
99
|
+
}
|
|
100
|
+
return [4, 'unknown', eventType].join(SEPARATOR);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
static logToObj(str) {
|
|
105
|
+
const logType = parseInt(str[0], 10);
|
|
106
|
+
switch (logType) {
|
|
107
|
+
case 1:
|
|
108
|
+
return this.logToConfig(str);
|
|
109
|
+
case 2:
|
|
110
|
+
return this.logToGeolocation(str);
|
|
111
|
+
case 3:
|
|
112
|
+
return this.logToImu(str);
|
|
113
|
+
case 4:
|
|
114
|
+
return this.logToExternalData(str);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
throw new Error(`Cannot parse log: ${str}`);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
static logToConfig(str) {
|
|
121
|
+
const config = JSON.parse(str.substring(2));
|
|
122
|
+
return {
|
|
123
|
+
type: 'config',
|
|
124
|
+
time: config.startTime,
|
|
125
|
+
data: config
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
static logToGeolocation(str) {
|
|
130
|
+
const array = str.split(SEPARATOR).map(parseFloat);
|
|
131
|
+
return {
|
|
132
|
+
type: 'geolocation',
|
|
133
|
+
time: array[1],
|
|
134
|
+
data: {
|
|
135
|
+
timestamp: array[2],
|
|
136
|
+
coords: {
|
|
137
|
+
latitude: array[3],
|
|
138
|
+
longitude: array[4],
|
|
139
|
+
altitude: array[5],
|
|
140
|
+
accuracy: array[6],
|
|
141
|
+
altitudeAccuracy: array[7],
|
|
142
|
+
heading: array[8],
|
|
143
|
+
speed: array[9]
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
static logToImu(str) {
|
|
150
|
+
|
|
151
|
+
const indexOfSecondComma = str.indexOf(SEPARATOR, 2);
|
|
152
|
+
const eventName = str.substring(2, indexOfSecondComma);
|
|
153
|
+
const data = str.substring(indexOfSecondComma + 1).split(SEPARATOR).map(parseFloat);
|
|
154
|
+
|
|
155
|
+
const event = new CustomEvent(eventName);
|
|
156
|
+
Object.defineProperties(event, { timeStamp: { writable: true } });
|
|
157
|
+
|
|
158
|
+
switch (eventName) {
|
|
159
|
+
case 'devicemotion':
|
|
160
|
+
Object.assign(event, {
|
|
161
|
+
timeStamp: data[1],
|
|
162
|
+
accelerationIncludingGravity: {
|
|
163
|
+
x: data[2],
|
|
164
|
+
y: data[3],
|
|
165
|
+
z: data[4]
|
|
166
|
+
},
|
|
167
|
+
rotationRate: {
|
|
168
|
+
alpha: data[5],
|
|
169
|
+
beta: data[6],
|
|
170
|
+
gamma: data[7]
|
|
171
|
+
},
|
|
172
|
+
acceleration: {
|
|
173
|
+
x: data[8],
|
|
174
|
+
y: data[9],
|
|
175
|
+
z: data[10]
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
break;
|
|
179
|
+
|
|
180
|
+
case 'deviceorientation':
|
|
181
|
+
Object.assign(event, {
|
|
182
|
+
timeStamp: data[1],
|
|
183
|
+
alpha: data[2],
|
|
184
|
+
beta: data[3],
|
|
185
|
+
gamma: data[4],
|
|
186
|
+
webkitCompassHeading: data[5],
|
|
187
|
+
absolute: data[6] === 1
|
|
188
|
+
});
|
|
189
|
+
break;
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
case 'deviceorientationabsolute':
|
|
193
|
+
Object.assign(event, {
|
|
194
|
+
timeStamp: data[1],
|
|
195
|
+
alpha: data[2],
|
|
196
|
+
beta: data[3],
|
|
197
|
+
gamma: data[4],
|
|
198
|
+
absolute: data[5] === 1
|
|
199
|
+
});
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return {
|
|
204
|
+
type: 'imu',
|
|
205
|
+
time: data[0],
|
|
206
|
+
data: event
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
static logToExternalData(str) {
|
|
211
|
+
|
|
212
|
+
const indexOfSecondComma = str.indexOf(SEPARATOR, 2);
|
|
213
|
+
const eventTypeStr = str.substring(2, indexOfSecondComma);
|
|
214
|
+
|
|
215
|
+
const indexOfThirdComma = str.indexOf(SEPARATOR, indexOfSecondComma + 1);
|
|
216
|
+
const time = parseFloat(str.substring(indexOfSecondComma + 1, indexOfThirdComma));
|
|
217
|
+
|
|
218
|
+
const dataStr = str.substring(indexOfThirdComma + 1);
|
|
219
|
+
|
|
220
|
+
let data;
|
|
221
|
+
switch (eventTypeStr) {
|
|
222
|
+
|
|
223
|
+
case 'network':
|
|
224
|
+
data = {
|
|
225
|
+
eventType: EventType.Network,
|
|
226
|
+
data: dataStr === null ? null : Network.fromCompressedJson(JSON.parse(dataStr))
|
|
227
|
+
};
|
|
228
|
+
break;
|
|
229
|
+
|
|
230
|
+
case 'absolute-position':
|
|
231
|
+
data = {
|
|
232
|
+
eventType: EventType.AbsolutePosition,
|
|
233
|
+
data: dataStr === null ? null : UserPosition.fromJson(JSON.parse(dataStr))
|
|
234
|
+
};
|
|
235
|
+
break;
|
|
236
|
+
|
|
237
|
+
case 'absolute-attitude':
|
|
238
|
+
data = {
|
|
239
|
+
eventType: EventType.AbsoluteAttitude,
|
|
240
|
+
data: dataStr === null ? null : Attitude.fromJson(JSON.parse(dataStr))
|
|
241
|
+
};
|
|
242
|
+
break;
|
|
243
|
+
|
|
244
|
+
case 'absolute-heading':
|
|
245
|
+
data = {
|
|
246
|
+
eventType: EventType.AbsoluteHeading,
|
|
247
|
+
data: dataStr === null ? null : AbsoluteHeading.fromJson(JSON.parse(dataStr))
|
|
248
|
+
};
|
|
249
|
+
break;
|
|
250
|
+
|
|
251
|
+
default:
|
|
252
|
+
throw new Error(`Cannot parse eventType: ${eventTypeStr}`);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return {
|
|
256
|
+
type: 'external',
|
|
257
|
+
time,
|
|
258
|
+
data
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export default NavigationLoggerConverter;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { UserPosition } from '@wemap/geo';
|
|
2
|
-
|
|
3
|
-
import Provider from './Provider';
|
|
4
|
-
|
|
5
|
-
import EventType from '../events/EventType';
|
|
6
2
|
import { TimeUtils } from '@wemap/utils';
|
|
7
3
|
|
|
4
|
+
import Provider from './Provider.js';
|
|
5
|
+
import EventType from '../events/EventType.js';
|
|
6
|
+
|
|
8
7
|
class FakeProvider1 extends Provider {
|
|
9
8
|
static get pname() {
|
|
10
9
|
return 'FakeProvider1';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import EventType from '../events/EventType';
|
|
2
|
-
import Provider from './Provider';
|
|
3
|
-
import ProviderEvent from '../events/ProviderEvent';
|
|
1
|
+
import EventType from '../events/EventType.js';
|
|
2
|
+
import Provider from './Provider.js';
|
|
3
|
+
import ProviderEvent from '../events/ProviderEvent.js';
|
|
4
4
|
|
|
5
5
|
class MetaProvider extends Provider {
|
|
6
6
|
|
|
@@ -2,12 +2,12 @@ import noop from 'lodash.noop';
|
|
|
2
2
|
|
|
3
3
|
import { TimeUtils } from '@wemap/utils';
|
|
4
4
|
|
|
5
|
-
import EventType from '../events/EventType';
|
|
6
|
-
import ProviderEvent from '../events/ProviderEvent';
|
|
7
|
-
import
|
|
8
|
-
import ContainsIgnoredProviderError from '../errors/ContainsIgnoredProviderError';
|
|
9
|
-
import ProvidersOptions from '../ProvidersOptions';
|
|
10
|
-
import ProviderState from './ProviderState';
|
|
5
|
+
import EventType from '../events/EventType.js';
|
|
6
|
+
import ProviderEvent from '../events/ProviderEvent.js';
|
|
7
|
+
import ProvidersLoggerOld from '../events/ProvidersLoggerOld.js';
|
|
8
|
+
import ContainsIgnoredProviderError from '../errors/ContainsIgnoredProviderError.js';
|
|
9
|
+
import ProvidersOptions from '../ProvidersOptions.js';
|
|
10
|
+
import ProviderState from './ProviderState.js';
|
|
11
11
|
|
|
12
12
|
let uniqueId = 1;
|
|
13
13
|
|
|
@@ -52,7 +52,7 @@ class Provider {
|
|
|
52
52
|
|
|
53
53
|
this.id = uniqueId++;
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
ProvidersLoggerOld.addEvent(this, 'constructor');
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/**
|
|
@@ -166,6 +166,7 @@ class Provider {
|
|
|
166
166
|
if (this.state !== ProviderState.STOPPPED) {
|
|
167
167
|
return id;
|
|
168
168
|
}
|
|
169
|
+
this.state = ProviderState.STARTING;
|
|
169
170
|
|
|
170
171
|
// Check availability on start if defined in options
|
|
171
172
|
let availabilityPromise = Promise.resolve();
|
|
@@ -175,9 +176,8 @@ class Provider {
|
|
|
175
176
|
|
|
176
177
|
availabilityPromise
|
|
177
178
|
.then(() => {
|
|
178
|
-
this.state = ProviderState.STARTING;
|
|
179
179
|
|
|
180
|
-
|
|
180
|
+
ProvidersLoggerOld.addEvent(this, 'start');
|
|
181
181
|
// Call the child start function
|
|
182
182
|
this.start();
|
|
183
183
|
|
|
@@ -186,6 +186,7 @@ class Provider {
|
|
|
186
186
|
this._monitoringCallbacks.forEach(({ onStarted }) => onStarted());
|
|
187
187
|
})
|
|
188
188
|
.catch(e => {
|
|
189
|
+
this.state = ProviderState.STOPPPED;
|
|
189
190
|
this.notifyError(e);
|
|
190
191
|
})
|
|
191
192
|
// notifyError can throw an error if onStop is not defined
|
|
@@ -226,7 +227,7 @@ class Provider {
|
|
|
226
227
|
return;
|
|
227
228
|
}
|
|
228
229
|
|
|
229
|
-
|
|
230
|
+
ProvidersLoggerOld.addEvent(this, 'stop');
|
|
230
231
|
// Call the child stop function
|
|
231
232
|
this.stop();
|
|
232
233
|
|
|
@@ -283,7 +284,7 @@ class Provider {
|
|
|
283
284
|
*/
|
|
284
285
|
notify(...events) {
|
|
285
286
|
// Logging
|
|
286
|
-
|
|
287
|
+
ProvidersLoggerOld.incrementNotifications(this);
|
|
287
288
|
|
|
288
289
|
// Add current provider to the list of providers for this event.
|
|
289
290
|
events.forEach(event => event.providersStack.unshift(this.pname));
|
|
@@ -5,15 +5,13 @@ import noop from 'lodash.noop';
|
|
|
5
5
|
|
|
6
6
|
import Logger from '@wemap/logger';
|
|
7
7
|
|
|
8
|
-
import Provider from './Provider';
|
|
9
|
-
|
|
10
|
-
import ContainsIgnoredProviderError from '../errors/ContainsIgnoredProviderError';
|
|
11
|
-
|
|
8
|
+
import Provider from './Provider.js';
|
|
9
|
+
import ContainsIgnoredProviderError from '../errors/ContainsIgnoredProviderError.js';
|
|
12
10
|
import {
|
|
13
11
|
FakeProvider1, FakeProvider2, FakeProvider3, FakeProvider4
|
|
14
|
-
} from './FakeProvider.spec';
|
|
15
|
-
import ProvidersOptions from '../ProvidersOptions';
|
|
16
|
-
import ProviderState from './ProviderState';
|
|
12
|
+
} from './FakeProvider.spec.js';
|
|
13
|
+
import ProvidersOptions from '../ProvidersOptions.js';
|
|
14
|
+
import ProviderState from './ProviderState.js';
|
|
17
15
|
|
|
18
16
|
chai.use(chaiAsPromised);
|
|
19
17
|
Logger.enable(false);
|
|
@@ -10,12 +10,13 @@ import {
|
|
|
10
10
|
Browser, BrowserUtils
|
|
11
11
|
} from '@wemap/utils';
|
|
12
12
|
|
|
13
|
-
import Provider from '../../Provider';
|
|
14
|
-
import EventType from '../../../events/EventType';
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
13
|
+
import Provider from '../../Provider.js';
|
|
14
|
+
import EventType from '../../../events/EventType.js';
|
|
15
|
+
import NavigationLogger from '../../../logger/NavigationLogger.js';
|
|
16
|
+
import AskImuOnDesktopError from '../../../errors/AskImuOnDesktopError.js';
|
|
17
|
+
import MissingMagnetometerError from '../../../errors/MissingMagnetometerError.js';
|
|
18
|
+
import MissingSensorError from '../../../errors/MissingSensorError.js';
|
|
19
|
+
import { AbsolutePosition } from '../../../Providers.js';
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
/**
|
|
@@ -78,7 +79,6 @@ class AbsoluteAttitudeFromBrowserProvider extends Provider {
|
|
|
78
79
|
break;
|
|
79
80
|
|
|
80
81
|
case Browser.SAFARI:
|
|
81
|
-
case Browser.IOS_WEBVIEW:
|
|
82
82
|
window.addEventListener('deviceorientation',
|
|
83
83
|
this.onDeviceOrientationSafariEvent, true);
|
|
84
84
|
break;
|
|
@@ -124,7 +124,6 @@ class AbsoluteAttitudeFromBrowserProvider extends Provider {
|
|
|
124
124
|
break;
|
|
125
125
|
|
|
126
126
|
case Browser.SAFARI:
|
|
127
|
-
case Browser.IOS_WEBVIEW:
|
|
128
127
|
window.removeEventListener('deviceorientation',
|
|
129
128
|
this.onDeviceOrientationSafariEvent, true);
|
|
130
129
|
break;
|
|
@@ -137,6 +136,7 @@ class AbsoluteAttitudeFromBrowserProvider extends Provider {
|
|
|
137
136
|
|
|
138
137
|
|
|
139
138
|
onDeviceOrientationChromeEvent = e => {
|
|
139
|
+
NavigationLogger.feedImuData(e);
|
|
140
140
|
|
|
141
141
|
this.magQuaternionTimestamp = e.timeStamp / 1e3;
|
|
142
142
|
|
|
@@ -153,6 +153,7 @@ class AbsoluteAttitudeFromBrowserProvider extends Provider {
|
|
|
153
153
|
|
|
154
154
|
|
|
155
155
|
onDeviceOrientationSafariEvent = e => {
|
|
156
|
+
NavigationLogger.feedImuData(e);
|
|
156
157
|
|
|
157
158
|
this.magQuaternionTimestamp = e.timeStamp / 1e3;
|
|
158
159
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Quaternion } from '@wemap/maths';
|
|
2
2
|
import { Attitude } from '@wemap/geo';
|
|
3
3
|
|
|
4
|
-
import Provider from '../../Provider';
|
|
5
|
-
import EventType from '../../../events/EventType';
|
|
4
|
+
import Provider from '../../Provider.js';
|
|
5
|
+
import EventType from '../../../events/EventType.js';
|
|
6
6
|
import {
|
|
7
|
-
RelativeAttitude, AbsoluteAttitude
|
|
7
|
+
RelativeAttitude, AbsoluteAttitude
|
|
8
8
|
} from '../../../Providers.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -90,8 +90,7 @@ class AbsoluteAttitudeFromRelAttProvider extends Provider {
|
|
|
90
90
|
/**
|
|
91
91
|
* Use absolute attitude events only when they are not from this provider
|
|
92
92
|
*/
|
|
93
|
-
if (absoluteAttitudeEvent.providersStack.includes(this.pname)
|
|
94
|
-
|| absoluteAttitudeEvent.providersStack.includes(AbsoluteAttitudeFromBrowser.pname)) {
|
|
93
|
+
if (absoluteAttitudeEvent.providersStack.includes(this.pname)) {
|
|
95
94
|
return;
|
|
96
95
|
}
|
|
97
96
|
this.absoluteAttitudeEvent = absoluteAttitudeEvent;
|
|
@@ -115,7 +114,7 @@ class AbsoluteAttitudeFromRelAttProvider extends Provider {
|
|
|
115
114
|
const absoluteAttitudeAccuracy = this.absoluteAttitudeEvent.data.accuracy;
|
|
116
115
|
|
|
117
116
|
const absoluteQuat = Quaternion.multiply(this.zOffset, quaternion);
|
|
118
|
-
const newAccuracy = absoluteAttitudeAccuracy + this.accuracy;
|
|
117
|
+
const newAccuracy = Math.min(absoluteAttitudeAccuracy + this.accuracy, Math.PI);
|
|
119
118
|
const attitude = new Attitude(absoluteQuat, time, newAccuracy, this.pname);
|
|
120
119
|
|
|
121
120
|
this.notify(this.createEvent(
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
} from '@wemap/geo';
|
|
4
4
|
import { PromiseUtils } from '@wemap/utils';
|
|
5
5
|
|
|
6
|
-
import MetaProvider from '../../MetaProvider';
|
|
7
|
-
import EventType from '../../../events/EventType';
|
|
6
|
+
import MetaProvider from '../../MetaProvider.js';
|
|
7
|
+
import EventType from '../../../events/EventType.js';
|
|
8
8
|
import {
|
|
9
9
|
AbsoluteAttitudeFromBrowser, AbsoluteAttitudeFromRelAtt
|
|
10
|
-
} from '../../../Providers';
|
|
10
|
+
} from '../../../Providers.js';
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -2,11 +2,12 @@ import { Attitude } from '@wemap/geo';
|
|
|
2
2
|
import { Rotations } from '@wemap/maths';
|
|
3
3
|
import { BrowserUtils } from '@wemap/utils';
|
|
4
4
|
|
|
5
|
-
import Provider from '../../Provider';
|
|
6
|
-
import EventType from '../../../events/EventType';
|
|
7
|
-
import AskImuOnDesktopError from '../../../errors/AskImuOnDesktopError';
|
|
8
|
-
import MissingSensorError from '../../../errors/MissingSensorError';
|
|
9
|
-
import RelativeAttitudeFromInertialProvider from './RelativeAttitudeFromInertialProvider';
|
|
5
|
+
import Provider from '../../Provider.js';
|
|
6
|
+
import EventType from '../../../events/EventType.js';
|
|
7
|
+
import AskImuOnDesktopError from '../../../errors/AskImuOnDesktopError.js';
|
|
8
|
+
import MissingSensorError from '../../../errors/MissingSensorError.js';
|
|
9
|
+
import RelativeAttitudeFromInertialProvider from './RelativeAttitudeFromInertialProvider.js';
|
|
10
|
+
import NavigationLogger from '../../../logger/NavigationLogger.js';
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -79,6 +80,7 @@ class RelativeAttitudeFromBrowserProvider extends Provider {
|
|
|
79
80
|
|
|
80
81
|
|
|
81
82
|
onDeviceOrientationEvent = e => {
|
|
83
|
+
NavigationLogger.feedImuData(e);
|
|
82
84
|
|
|
83
85
|
const timestamp = e.timeStamp / 1e3;
|
|
84
86
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Attitude } from '@wemap/geo';
|
|
2
2
|
|
|
3
|
-
import Provider from '../../Provider';
|
|
4
|
-
import EventType from '../../../events/EventType';
|
|
5
|
-
import EkfAttitude from '../EkfAttitude';
|
|
6
|
-
import RelativeAttitudeFromInertialProvider from './RelativeAttitudeFromInertialProvider';
|
|
3
|
+
import Provider from '../../Provider.js';
|
|
4
|
+
import EventType from '../../../events/EventType.js';
|
|
5
|
+
import EkfAttitude from '../EkfAttitude.js';
|
|
6
|
+
import RelativeAttitudeFromInertialProvider from './RelativeAttitudeFromInertialProvider.js';
|
|
7
7
|
import {
|
|
8
8
|
Accelerometer, Gyroscope
|
|
9
|
-
} from '../../../Providers';
|
|
9
|
+
} from '../../../Providers.js';
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { deg2rad } from '@wemap/maths';
|
|
2
2
|
import { PromiseUtils } from '@wemap/utils';
|
|
3
3
|
|
|
4
|
-
import Provider from '../../Provider';
|
|
5
|
-
import EventType from '../../../events/EventType';
|
|
4
|
+
import Provider from '../../Provider.js';
|
|
5
|
+
import EventType from '../../../events/EventType.js';
|
|
6
6
|
import {
|
|
7
7
|
RelativeAttitudeFromEkf, RelativeAttitudeFromBrowser
|
|
8
|
-
} from '../../../Providers';
|
|
8
|
+
} from '../../../Providers.js';
|
|
9
9
|
|
|
10
10
|
class RelativeAttitudeFromInertialProvider extends Provider {
|
|
11
11
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import Provider from '../../Provider';
|
|
2
|
-
import EventType from '../../../events/EventType';
|
|
3
1
|
import noop from 'lodash.noop';
|
|
4
|
-
|
|
2
|
+
|
|
3
|
+
import Provider from '../../Provider.js';
|
|
4
|
+
import EventType from '../../../events/EventType.js';
|
|
5
|
+
import ProviderState from '../../ProviderState.js';
|
|
5
6
|
import {
|
|
6
7
|
RelativeAttitudeFromInertial, ArCore
|
|
7
|
-
} from '../../../Providers';
|
|
8
|
+
} from '../../../Providers.js';
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Provider from '../Provider';
|
|
2
|
-
import EventType from '../../events/EventType';
|
|
3
|
-
import MissingAccelerometerError from '../../errors/MissingAccelerometerError';
|
|
4
|
-
import { Imu } from '../../Providers';
|
|
1
|
+
import Provider from '../Provider.js';
|
|
2
|
+
import EventType from '../../events/EventType.js';
|
|
3
|
+
import MissingAccelerometerError from '../../errors/MissingAccelerometerError.js';
|
|
4
|
+
import { Imu } from '../../Providers.js';
|
|
5
5
|
|
|
6
6
|
class AccelerometerProvider extends Provider {
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Provider from '../Provider';
|
|
2
|
-
import EventType from '../../events/EventType';
|
|
3
|
-
import MissingGyroscopeError from '../../errors/MissingGyroscopeError';
|
|
4
|
-
import { Imu } from '../../Providers';
|
|
1
|
+
import Provider from '../Provider.js';
|
|
2
|
+
import EventType from '../../events/EventType.js';
|
|
3
|
+
import MissingGyroscopeError from '../../errors/MissingGyroscopeError.js';
|
|
4
|
+
import { Imu } from '../../Providers.js';
|
|
5
5
|
|
|
6
6
|
class GyroscopeProvider extends Provider {
|
|
7
7
|
|
|
@@ -3,9 +3,10 @@ import {
|
|
|
3
3
|
Browser, BrowserUtils
|
|
4
4
|
} from '@wemap/utils';
|
|
5
5
|
|
|
6
|
-
import Provider from '../Provider';
|
|
6
|
+
import Provider from '../Provider.js';
|
|
7
7
|
import EventType from '../../events/EventType';
|
|
8
|
-
import AskImuOnDesktopError from '../../errors/AskImuOnDesktopError';
|
|
8
|
+
import AskImuOnDesktopError from '../../errors/AskImuOnDesktopError.js';
|
|
9
|
+
import NavigationLogger from '../../logger/NavigationLogger.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Imu (Inertial Measurement Unit) provider retrieve acceleration data
|
|
@@ -82,6 +83,7 @@ class ImuProvider extends Provider {
|
|
|
82
83
|
* @private
|
|
83
84
|
*/
|
|
84
85
|
parseDeviceMotionEvent = e => {
|
|
86
|
+
NavigationLogger.feedImuData(e);
|
|
85
87
|
|
|
86
88
|
const events = [];
|
|
87
89
|
|
|
@@ -96,8 +98,7 @@ class ImuProvider extends Provider {
|
|
|
96
98
|
if (typeof x === 'number' && typeof y === 'number' && typeof z === 'number') {
|
|
97
99
|
acc = [x, y, z];
|
|
98
100
|
|
|
99
|
-
if (BrowserUtils.name === Browser.SAFARI
|
|
100
|
-
|| BrowserUtils.name === Browser.IOS_WEBVIEW) {
|
|
101
|
+
if (BrowserUtils.name === Browser.SAFARI) {
|
|
101
102
|
acc[0] *= -1;
|
|
102
103
|
acc[1] *= -1;
|
|
103
104
|
acc[2] *= -1;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Provider from '../Provider';
|
|
2
|
-
import EventType from '../../events/EventType';
|
|
3
|
-
import { Accelerometer } from '../../Providers';
|
|
1
|
+
import Provider from '../Provider.js';
|
|
2
|
+
import EventType from '../../events/EventType.js';
|
|
3
|
+
import { Accelerometer } from '../../Providers.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Inclination provider gives the inclination of the device using Imu Sensor
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Provider from '../Provider';
|
|
2
|
-
import EventType from '../../events/EventType';
|
|
3
|
-
import { RelativeAttitudeFromInertial } from '../../Providers';
|
|
1
|
+
import Provider from '../Provider.js';
|
|
2
|
+
import EventType from '../../events/EventType.js';
|
|
3
|
+
import { RelativeAttitudeFromInertial } from '../../Providers.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Inclination provider gives the inclination of the device using Relative Attitude
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PromiseUtils } from '@wemap/utils';
|
|
2
2
|
|
|
3
|
-
import MetaProvider from '../MetaProvider';
|
|
4
|
-
import EventType from '../../events/EventType';
|
|
3
|
+
import MetaProvider from '../MetaProvider.js';
|
|
4
|
+
import EventType from '../../events/EventType.js';
|
|
5
5
|
import {
|
|
6
6
|
InclinationFromRelativeAttitude, InclinationFromAcc
|
|
7
|
-
} from '../../Providers';
|
|
7
|
+
} from '../../Providers.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Inclination provider gives the inclination of the device using Imu Sensor
|