@wemap/providers 3.2.1 → 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/debug/map/helpers/UserOnMapHandler.js +19 -4
- package/package.json +7 -7
- package/src/logger/NavigationLogger.js +14 -7
- package/src/logger/NavigationLoggerConverter.js +207 -172
- package/src/providers/attitude/absolute/AbsoluteAttitudeFromBrowserProvider.js +2 -2
- package/src/providers/attitude/relative/RelativeAttitudeFromBrowserProvider.js +2 -0
- package/src/providers/imu/ImuProvider.js +1 -1
- package/src/providers/position/absolute/GnssWifiProvider.js +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Map } from 'mapbox-gl';
|
|
2
2
|
import { GeolocationLayer } from '@wemap/map';
|
|
3
|
+
import { TimeUtils } from '@wemap/utils';
|
|
3
4
|
|
|
4
5
|
import {
|
|
5
6
|
PositionSmoother, ProvidersInterface, EventType
|
|
@@ -32,25 +33,39 @@ class UserOnMapHandler {
|
|
|
32
33
|
*/
|
|
33
34
|
this.attitudeProviderId = ProvidersInterface.addEventListener(
|
|
34
35
|
EventType.AbsoluteAttitude,
|
|
35
|
-
attitude => this.geolocationLayer.
|
|
36
|
+
attitude => this.geolocationLayer.updateHeading(attitude.headingDegrees)
|
|
36
37
|
);
|
|
37
38
|
|
|
38
39
|
// There is no sense to show the last known attitude on the map
|
|
39
|
-
// this.
|
|
40
|
+
// this.geolocationLayer.updateHeading(ProvidersInterface.getLastKnown(EventType.AbsoluteAttitude));
|
|
40
41
|
|
|
41
42
|
|
|
42
43
|
/**
|
|
43
44
|
* Position
|
|
44
45
|
*/
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
const positionTransform = input => {
|
|
48
|
+
if (input === null) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
const output = input.clone();
|
|
52
|
+
output.timestamp = TimeUtils.preciseTimeToUnixTimestamp(input.time * 1e3);
|
|
53
|
+
return output;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
this.smoother = new PositionSmoother(position => {
|
|
57
|
+
this.geolocationLayer.updatePosition(positionTransform(position));
|
|
58
|
+
});
|
|
47
59
|
|
|
48
60
|
this.positionProviderId = ProvidersInterface.addEventListener(
|
|
49
61
|
EventType.AbsolutePosition,
|
|
50
62
|
position => this.smoother.feed(position)
|
|
51
63
|
);
|
|
52
64
|
|
|
53
|
-
|
|
65
|
+
const lastKnownPosition = ProvidersInterface.getLastKnown(EventType.AbsolutePosition);
|
|
66
|
+
if (lastKnownPosition) {
|
|
67
|
+
this.geolocationLayer.updatePosition(positionTransform(lastKnownPosition));
|
|
68
|
+
}
|
|
54
69
|
}
|
|
55
70
|
|
|
56
71
|
stop() {
|
package/package.json
CHANGED
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"Guillaume Pannetier <guillaume.pannetier@getwemap.com>"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@wemap/geo": "^3.2.
|
|
12
|
-
"@wemap/graph": "^3.2.
|
|
11
|
+
"@wemap/geo": "^3.2.2",
|
|
12
|
+
"@wemap/graph": "^3.2.2",
|
|
13
13
|
"@wemap/logger": "^3.2.1",
|
|
14
14
|
"@wemap/maths": "^3.2.1",
|
|
15
|
-
"@wemap/osm": "^3.2.
|
|
16
|
-
"@wemap/utils": "^3.2.
|
|
15
|
+
"@wemap/osm": "^3.2.2",
|
|
16
|
+
"@wemap/utils": "^3.2.2",
|
|
17
17
|
"browser-cookies": "^1.2.0",
|
|
18
18
|
"geomagnetism": "^0.1.0",
|
|
19
19
|
"lodash.isempty": "^4.4.0",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@babel/plugin-proposal-class-properties": "^7.10.4",
|
|
27
27
|
"@babel/preset-env": "^7.11.0",
|
|
28
28
|
"@babel/preset-react": "^7.10.4",
|
|
29
|
-
"@wemap/map": "^3.2.
|
|
29
|
+
"@wemap/map": "^3.2.2",
|
|
30
30
|
"babel-loader": "^8.0.6",
|
|
31
31
|
"css-loader": "^3.2.0",
|
|
32
32
|
"file-loader": "^5.0.2",
|
|
@@ -68,6 +68,6 @@
|
|
|
68
68
|
"lint": "eslint --ext .js,.jsx --quiet src"
|
|
69
69
|
},
|
|
70
70
|
"type": "module",
|
|
71
|
-
"version": "3.2.
|
|
72
|
-
"gitHead": "
|
|
71
|
+
"version": "3.2.2",
|
|
72
|
+
"gitHead": "6ff8c054aed5ccbf0f456aad752c43f46fe6b278"
|
|
73
73
|
}
|
|
@@ -44,6 +44,7 @@ class NavigationLogger {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
this._sendConfig(config);
|
|
47
|
+
this._feed(NavigationLoggerConverter.configToLog(config));
|
|
47
48
|
|
|
48
49
|
// Dispatch started event
|
|
49
50
|
if (typeof document !== 'undefined') {
|
|
@@ -66,18 +67,25 @@ class NavigationLogger {
|
|
|
66
67
|
this.isRecording = false;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
static
|
|
70
|
+
static feedImuData(event) {
|
|
70
71
|
if (!this.isRecording) {
|
|
71
72
|
return;
|
|
72
73
|
}
|
|
73
|
-
this._feed(NavigationLoggerConverter.
|
|
74
|
+
this._feed(NavigationLoggerConverter.imuDataToLog(TimeUtils.preciseTime, event));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static feedGeolocation(geolocationEvent) {
|
|
78
|
+
if (!this.isRecording) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
this._feed(NavigationLoggerConverter.geolocationToLog(TimeUtils.preciseTime, geolocationEvent));
|
|
74
82
|
}
|
|
75
83
|
|
|
76
84
|
static feedExternalData(eventType, data) {
|
|
77
85
|
if (!this.isRecording) {
|
|
78
86
|
return;
|
|
79
87
|
}
|
|
80
|
-
this._feed(NavigationLoggerConverter.
|
|
88
|
+
this._feed(NavigationLoggerConverter.externalDataToLog(TimeUtils.preciseTime, eventType, data));
|
|
81
89
|
}
|
|
82
90
|
|
|
83
91
|
|
|
@@ -107,9 +115,9 @@ class NavigationLogger {
|
|
|
107
115
|
|
|
108
116
|
static _sendLogs(logs) {
|
|
109
117
|
const xmlhttp = new XMLHttpRequest();
|
|
110
|
-
xmlhttp.open('POST', this.serverUrl + '/logs/' + this.sessionId);
|
|
111
|
-
xmlhttp.setRequestHeader('Content-Type', '
|
|
112
|
-
xmlhttp.send(
|
|
118
|
+
xmlhttp.open('POST', this.serverUrl + '/logs/' + this.sessionId, true);
|
|
119
|
+
xmlhttp.setRequestHeader('Content-Type', 'text/plain');
|
|
120
|
+
xmlhttp.send(logs.join('\n'));
|
|
113
121
|
}
|
|
114
122
|
}
|
|
115
123
|
|
|
@@ -121,7 +129,6 @@ if (typeof document !== 'undefined') {
|
|
|
121
129
|
if (!('serverUrl' in event.detail)) {
|
|
122
130
|
throw new Error('[providers.logger.start] did not find serverUrl');
|
|
123
131
|
}
|
|
124
|
-
console.log(event.detail.serverUrl, event.detail.logsSize);
|
|
125
132
|
NavigationLogger.start(event.detail.serverUrl, event.detail.logsSize);
|
|
126
133
|
});
|
|
127
134
|
document.addEventListener('providers.logger.stop', () => NavigationLogger.stop());
|
|
@@ -1,227 +1,262 @@
|
|
|
1
1
|
/* eslint-disable complexity */
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
UserPosition, AbsoluteHeading, Attitude
|
|
4
|
+
} from '@wemap/geo';
|
|
3
5
|
import { Network } from '@wemap/graph';
|
|
4
6
|
|
|
5
7
|
import EventType from '../events/EventType.js';
|
|
6
8
|
|
|
9
|
+
const SEPARATOR = ',';
|
|
10
|
+
|
|
7
11
|
const PRECISION = 1e-6;
|
|
8
12
|
const PRECISION_INV = 1 / PRECISION;
|
|
9
13
|
const round = num => typeof num === 'number' ? Math.round(num * PRECISION_INV) / PRECISION_INV : num;
|
|
10
14
|
|
|
11
15
|
class NavigationLoggerConverter {
|
|
12
16
|
|
|
13
|
-
static
|
|
14
|
-
|
|
15
|
-
case EventType.Network:
|
|
16
|
-
return [0, 'network', round(time), data === null ? null : JSON.stringify(data.toCompressedJson())];
|
|
17
|
-
case EventType.AbsolutePosition:
|
|
18
|
-
return [0, 'absolute-position', round(time), JSON.stringify(data.toJson())];
|
|
19
|
-
case EventType.AbsoluteHeading:
|
|
20
|
-
return [0, 'absolute-heading', round(time), JSON.stringify(data.toJson())];
|
|
21
|
-
case EventType.AbsoluteAttitude:
|
|
22
|
-
return [0, 'absolute-attitude', round(time), JSON.stringify(data.toJson())];
|
|
23
|
-
}
|
|
24
|
-
return [0, 'unknown', eventType];
|
|
17
|
+
static configToLog(config) {
|
|
18
|
+
return [1, JSON.stringify(config)].join(SEPARATOR);
|
|
25
19
|
}
|
|
26
20
|
|
|
27
|
-
static
|
|
28
|
-
|
|
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
|
+
}
|
|
29
35
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const gyr = data.rotationRate;
|
|
33
|
-
const linearAcc = data.acceleration;
|
|
36
|
+
static imuDataToLog(time, event) {
|
|
37
|
+
switch (event.type) {
|
|
34
38
|
|
|
39
|
+
case 'devicemotion':
|
|
40
|
+
const acc = event.accelerationIncludingGravity;
|
|
41
|
+
const gyr = event.rotationRate;
|
|
42
|
+
const linearAcc = event.acceleration;
|
|
35
43
|
return [
|
|
36
|
-
|
|
44
|
+
3,
|
|
45
|
+
event.type,
|
|
37
46
|
round(time),
|
|
38
|
-
round(
|
|
39
|
-
acc && typeof acc.x === 'number' ? round(acc.x) :
|
|
40
|
-
acc && typeof acc.y === 'number' ? round(acc.y) :
|
|
41
|
-
acc && typeof acc.z === 'number' ? round(acc.z) :
|
|
42
|
-
gyr && typeof gyr.alpha === 'number' ? round(gyr.alpha) :
|
|
43
|
-
gyr && typeof gyr.beta === 'number' ? round(gyr.beta) :
|
|
44
|
-
gyr && typeof gyr.gamma === 'number' ? round(gyr.gamma) :
|
|
45
|
-
linearAcc && typeof linearAcc.x === 'number' ? round(linearAcc.x) :
|
|
46
|
-
linearAcc && typeof linearAcc.y === 'number' ? round(linearAcc.y) :
|
|
47
|
-
linearAcc && typeof linearAcc.z === 'number' ? round(linearAcc.z) :
|
|
48
|
-
round(
|
|
49
|
-
];
|
|
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);
|
|
50
59
|
|
|
51
60
|
case 'deviceorientation':
|
|
52
61
|
return [
|
|
53
|
-
|
|
62
|
+
3,
|
|
63
|
+
event.type,
|
|
54
64
|
round(time),
|
|
55
|
-
round(
|
|
56
|
-
round(
|
|
57
|
-
round(
|
|
58
|
-
round(
|
|
59
|
-
round(
|
|
60
|
-
|
|
61
|
-
];
|
|
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);
|
|
62
72
|
|
|
63
73
|
case 'deviceorientationabsolute':
|
|
64
74
|
return [
|
|
65
75
|
3,
|
|
76
|
+
event.type,
|
|
66
77
|
round(time),
|
|
67
|
-
round(
|
|
68
|
-
round(
|
|
69
|
-
round(
|
|
70
|
-
round(
|
|
71
|
-
|
|
72
|
-
];
|
|
73
|
-
|
|
74
|
-
case 'geolocation':
|
|
75
|
-
return [
|
|
76
|
-
4,
|
|
77
|
-
round(time),
|
|
78
|
-
round(data.timestamp),
|
|
79
|
-
data.coords.latitude,
|
|
80
|
-
data.coords.longitude,
|
|
81
|
-
typeof data.coords.altitude === 'number' ? round(data.coords.altitude) : Number.MIN_VALUE,
|
|
82
|
-
round(data.coords.accuracy),
|
|
83
|
-
typeof data.coords.altitudeAccuracy === 'number' ? round(data.coords.altitudeAccuracy) : Number.MIN_VALUE,
|
|
84
|
-
typeof data.coords.heading === 'number' ? round(data.coords.heading) : Number.MIN_VALUE,
|
|
85
|
-
typeof data.coords.speed === 'number' ? round(data.coords.speed) : Number.MIN_VALUE
|
|
86
|
-
];
|
|
78
|
+
round(event.timeStamp),
|
|
79
|
+
round(event.alpha),
|
|
80
|
+
round(event.beta),
|
|
81
|
+
round(event.gamma),
|
|
82
|
+
event.absolute ? 1 : 0
|
|
83
|
+
].join(SEPARATOR);
|
|
87
84
|
}
|
|
88
85
|
|
|
89
|
-
throw new Error(`Cannot parse
|
|
86
|
+
throw new Error(`Cannot parse event: ${event.type}`, event);
|
|
90
87
|
}
|
|
91
88
|
|
|
92
|
-
static
|
|
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
|
+
}
|
|
93
102
|
|
|
94
|
-
const indexOfFirstComma = str.indexOf(',');
|
|
95
|
-
const rowType = parseInt(str.substring(0, indexOfFirstComma), 10);
|
|
96
103
|
|
|
97
|
-
|
|
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
|
+
}
|
|
98
116
|
|
|
99
|
-
|
|
117
|
+
throw new Error(`Cannot parse log: ${str}`);
|
|
118
|
+
}
|
|
100
119
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
x: array[3] === Number.MIN_VALUE ? null : array[3],
|
|
110
|
-
y: array[4] === Number.MIN_VALUE ? null : array[4],
|
|
111
|
-
z: array[5] === Number.MIN_VALUE ? null : array[5]
|
|
112
|
-
},
|
|
113
|
-
rotationRate: {
|
|
114
|
-
alpha: array[6] === Number.MIN_VALUE ? null : array[6],
|
|
115
|
-
beta: array[7] === Number.MIN_VALUE ? null : array[7],
|
|
116
|
-
gamma: array[8] === Number.MIN_VALUE ? null : array[8]
|
|
117
|
-
},
|
|
118
|
-
acceleration: {
|
|
119
|
-
x: array[9] === Number.MIN_VALUE ? null : array[9],
|
|
120
|
-
y: array[10] === Number.MIN_VALUE ? null : array[10],
|
|
121
|
-
z: array[11] === Number.MIN_VALUE ? null : array[11]
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
isExternal: false
|
|
125
|
-
};
|
|
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
|
+
}
|
|
126
128
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
+
}
|
|
142
148
|
|
|
143
|
-
|
|
144
|
-
array = str.split(',').map(parseFloat);
|
|
145
|
-
return {
|
|
146
|
-
eventName: 'deviceorientationabsolute',
|
|
147
|
-
time: array[1],
|
|
148
|
-
data: {
|
|
149
|
-
timeStamp: array[2],
|
|
150
|
-
alpha: array[3],
|
|
151
|
-
beta: array[4],
|
|
152
|
-
gamma: array[5],
|
|
153
|
-
absolute: array[6] === 1
|
|
154
|
-
},
|
|
155
|
-
isExternal: false
|
|
156
|
-
};
|
|
149
|
+
static logToImu(str) {
|
|
157
150
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
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]
|
|
174
166
|
},
|
|
175
|
-
|
|
176
|
-
|
|
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;
|
|
177
179
|
|
|
178
|
-
case
|
|
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
|
+
}
|
|
179
202
|
|
|
180
|
-
|
|
181
|
-
|
|
203
|
+
return {
|
|
204
|
+
type: 'imu',
|
|
205
|
+
time: data[0],
|
|
206
|
+
data: event
|
|
207
|
+
};
|
|
208
|
+
}
|
|
182
209
|
|
|
183
|
-
|
|
184
|
-
const time = str.substring(indexOfSecondComma + 1, indexOfThirdComma);
|
|
210
|
+
static logToExternalData(str) {
|
|
185
211
|
|
|
186
|
-
|
|
187
|
-
|
|
212
|
+
const indexOfSecondComma = str.indexOf(SEPARATOR, 2);
|
|
213
|
+
const eventTypeStr = str.substring(2, indexOfSecondComma);
|
|
188
214
|
|
|
189
|
-
|
|
190
|
-
|
|
215
|
+
const indexOfThirdComma = str.indexOf(SEPARATOR, indexOfSecondComma + 1);
|
|
216
|
+
const time = parseFloat(str.substring(indexOfSecondComma + 1, indexOfThirdComma));
|
|
191
217
|
|
|
192
|
-
|
|
193
|
-
eventType = EventType.Network;
|
|
194
|
-
data = dataStr === null ? null : Network.fromCompressedJson(dataJson);
|
|
195
|
-
break;
|
|
218
|
+
const dataStr = str.substring(indexOfThirdComma + 1);
|
|
196
219
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
data = dataStr === null ? null : UserPosition.fromJson(dataJson);
|
|
200
|
-
break;
|
|
220
|
+
let data;
|
|
221
|
+
switch (eventTypeStr) {
|
|
201
222
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
223
|
+
case 'network':
|
|
224
|
+
data = {
|
|
225
|
+
eventType: EventType.Network,
|
|
226
|
+
data: dataStr === null ? null : Network.fromCompressedJson(JSON.parse(dataStr))
|
|
227
|
+
};
|
|
228
|
+
break;
|
|
206
229
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
230
|
+
case 'absolute-position':
|
|
231
|
+
data = {
|
|
232
|
+
eventType: EventType.AbsolutePosition,
|
|
233
|
+
data: dataStr === null ? null : UserPosition.fromJson(JSON.parse(dataStr))
|
|
234
|
+
};
|
|
235
|
+
break;
|
|
211
236
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
237
|
+
case 'absolute-attitude':
|
|
238
|
+
data = {
|
|
239
|
+
eventType: EventType.AbsoluteAttitude,
|
|
240
|
+
data: dataStr === null ? null : Attitude.fromJson(JSON.parse(dataStr))
|
|
241
|
+
};
|
|
242
|
+
break;
|
|
215
243
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
isExternal: true
|
|
244
|
+
case 'absolute-heading':
|
|
245
|
+
data = {
|
|
246
|
+
eventType: EventType.AbsoluteHeading,
|
|
247
|
+
data: dataStr === null ? null : AbsoluteHeading.fromJson(JSON.parse(dataStr))
|
|
221
248
|
};
|
|
249
|
+
break;
|
|
250
|
+
|
|
251
|
+
default:
|
|
252
|
+
throw new Error(`Cannot parse eventType: ${eventTypeStr}`);
|
|
222
253
|
}
|
|
223
254
|
|
|
224
|
-
return
|
|
255
|
+
return {
|
|
256
|
+
type: 'external',
|
|
257
|
+
time,
|
|
258
|
+
data
|
|
259
|
+
};
|
|
225
260
|
}
|
|
226
261
|
}
|
|
227
262
|
|
|
@@ -136,7 +136,7 @@ class AbsoluteAttitudeFromBrowserProvider extends Provider {
|
|
|
136
136
|
|
|
137
137
|
|
|
138
138
|
onDeviceOrientationChromeEvent = e => {
|
|
139
|
-
NavigationLogger.
|
|
139
|
+
NavigationLogger.feedImuData(e);
|
|
140
140
|
|
|
141
141
|
this.magQuaternionTimestamp = e.timeStamp / 1e3;
|
|
142
142
|
|
|
@@ -153,7 +153,7 @@ class AbsoluteAttitudeFromBrowserProvider extends Provider {
|
|
|
153
153
|
|
|
154
154
|
|
|
155
155
|
onDeviceOrientationSafariEvent = e => {
|
|
156
|
-
NavigationLogger.
|
|
156
|
+
NavigationLogger.feedImuData(e);
|
|
157
157
|
|
|
158
158
|
this.magQuaternionTimestamp = e.timeStamp / 1e3;
|
|
159
159
|
|
|
@@ -7,6 +7,7 @@ import EventType from '../../../events/EventType.js';
|
|
|
7
7
|
import AskImuOnDesktopError from '../../../errors/AskImuOnDesktopError.js';
|
|
8
8
|
import MissingSensorError from '../../../errors/MissingSensorError.js';
|
|
9
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
|
|
|
@@ -73,7 +73,7 @@ class GnssWifiProvider extends Provider {
|
|
|
73
73
|
* @private
|
|
74
74
|
*/
|
|
75
75
|
onNewPosition = geolocation => {
|
|
76
|
-
NavigationLogger.
|
|
76
|
+
NavigationLogger.feedGeolocation(geolocation);
|
|
77
77
|
|
|
78
78
|
const { coords } = geolocation;
|
|
79
79
|
if (!coords) {
|