@wemap/providers 3.2.7 → 3.2.10
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/index.js +2 -3
- package/package.json +2 -3
- package/src/ProvidersInterface.js +0 -5
- package/src/providers/attitude/absolute/AbsoluteAttitudeFromBrowserProvider.js +0 -3
- package/src/providers/attitude/relative/RelativeAttitudeFromBrowserProvider.js +0 -2
- package/src/providers/imu/ImuProvider.js +0 -3
- package/src/providers/position/absolute/GnssWifiProvider.js +0 -2
- package/src/logger/ProvidersLogger.js +0 -78
- package/src/logger/ProvidersLoggerConverter.js +0 -275
package/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import EventType from './src/events/EventType.js';
|
|
2
2
|
import PositionSmoother from './src/smoothers/PositionSmoother.js';
|
|
3
|
+
import * as Providers from './src/Providers.js';
|
|
3
4
|
import ProvidersInterface from './src/ProvidersInterface.js';
|
|
4
|
-
import ProvidersLogger from './src/logger/ProvidersLogger.js';
|
|
5
5
|
import ProvidersOptions from './src/ProvidersOptions.js';
|
|
6
|
-
import Utils from './src/utils/index.js';
|
|
7
6
|
|
|
8
7
|
export {
|
|
9
|
-
EventType, PositionSmoother,
|
|
8
|
+
EventType, PositionSmoother, Providers, ProvidersInterface, ProvidersOptions
|
|
10
9
|
};
|
package/package.json
CHANGED
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
"@wemap/logger": "^3.2.3",
|
|
14
14
|
"@wemap/map": "^3.2.6",
|
|
15
15
|
"@wemap/maths": "^3.2.3",
|
|
16
|
-
"@wemap/navigation-logger": "^3.2.6",
|
|
17
16
|
"@wemap/utils": "^3.2.3",
|
|
18
17
|
"geomagnetism": "^0.1.0",
|
|
19
18
|
"lodash.isempty": "^4.4.0",
|
|
@@ -43,6 +42,6 @@
|
|
|
43
42
|
"url": "git+https://github.com/wemap/wemap-modules-js.git"
|
|
44
43
|
},
|
|
45
44
|
"type": "module",
|
|
46
|
-
"version": "3.2.
|
|
47
|
-
"gitHead": "
|
|
45
|
+
"version": "3.2.10",
|
|
46
|
+
"gitHead": "9c50dc4e1c8802c56af11593e835b55f416e4fbf"
|
|
48
47
|
}
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
AbsoluteAttitude, AbsolutePosition, Barcode, CameraNative, CameraProjectionMatrix, Inclination
|
|
11
11
|
} from './Providers.js';
|
|
12
12
|
import ProvidersLoggerOld from './events/ProvidersLoggerOld.js';
|
|
13
|
-
import ProvidersLogger from './logger/ProvidersLogger.js';
|
|
14
13
|
|
|
15
14
|
class ProvidersInterface {
|
|
16
15
|
|
|
@@ -48,7 +47,6 @@ class ProvidersInterface {
|
|
|
48
47
|
* @param {Object} data
|
|
49
48
|
*/
|
|
50
49
|
static feed(eventType, data) {
|
|
51
|
-
ProvidersLogger.feedExternalData(eventType, data, true);
|
|
52
50
|
this._checkEventTypeDataConsistency(eventType, data);
|
|
53
51
|
this._getMetaProviderFromEventType(eventType).feed(data, eventType);
|
|
54
52
|
}
|
|
@@ -136,7 +134,6 @@ class ProvidersInterface {
|
|
|
136
134
|
|
|
137
135
|
static set mapMatchingMaxDistance(maxDistance) {
|
|
138
136
|
AbsolutePosition.mapMatchingMaxDistance = maxDistance;
|
|
139
|
-
ProvidersLogger.feedProvidersMM({ mapMatchingMaxDistance: maxDistance });
|
|
140
137
|
}
|
|
141
138
|
|
|
142
139
|
static get mapMatchingMinDistance() {
|
|
@@ -145,7 +142,6 @@ class ProvidersInterface {
|
|
|
145
142
|
|
|
146
143
|
static set mapMatchingMinDistance(minDistance) {
|
|
147
144
|
AbsolutePosition.mapMatchingMinDistance = minDistance;
|
|
148
|
-
ProvidersLogger.feedProvidersMM({ mapMatchingMinDistance: minDistance });
|
|
149
145
|
}
|
|
150
146
|
|
|
151
147
|
static get mapMatchingMaxAngleBearing() {
|
|
@@ -154,7 +150,6 @@ class ProvidersInterface {
|
|
|
154
150
|
|
|
155
151
|
static set mapMatchingMaxAngleBearing(maxAngleBearing) {
|
|
156
152
|
AbsolutePosition.mapMatchingMaxAngleBearing = maxAngleBearing;
|
|
157
|
-
ProvidersLogger.feedProvidersMM({ mapMatchingMaxAngleBearing: maxAngleBearing });
|
|
158
153
|
}
|
|
159
154
|
}
|
|
160
155
|
|
|
@@ -16,7 +16,6 @@ import AskImuOnDesktopError from '../../../errors/AskImuOnDesktopError.js';
|
|
|
16
16
|
import MissingMagnetometerError from '../../../errors/MissingMagnetometerError.js';
|
|
17
17
|
import MissingSensorError from '../../../errors/MissingSensorError.js';
|
|
18
18
|
import { AbsolutePosition } from '../../../Providers.js';
|
|
19
|
-
import ProvidersLogger from '../../../logger/ProvidersLogger.js';
|
|
20
19
|
|
|
21
20
|
|
|
22
21
|
/**
|
|
@@ -136,7 +135,6 @@ class AbsoluteAttitudeFromBrowserProvider extends Provider {
|
|
|
136
135
|
|
|
137
136
|
|
|
138
137
|
onDeviceOrientationChromeEvent = e => {
|
|
139
|
-
ProvidersLogger.feedImuData(e);
|
|
140
138
|
|
|
141
139
|
this.magQuaternionTimestamp = e.timeStamp / 1e3;
|
|
142
140
|
|
|
@@ -153,7 +151,6 @@ class AbsoluteAttitudeFromBrowserProvider extends Provider {
|
|
|
153
151
|
|
|
154
152
|
|
|
155
153
|
onDeviceOrientationSafariEvent = e => {
|
|
156
|
-
ProvidersLogger.feedImuData(e);
|
|
157
154
|
|
|
158
155
|
this.magQuaternionTimestamp = e.timeStamp / 1e3;
|
|
159
156
|
|
|
@@ -7,7 +7,6 @@ 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 ProvidersLogger from '../../../logger/ProvidersLogger.js';
|
|
11
10
|
|
|
12
11
|
|
|
13
12
|
/**
|
|
@@ -80,7 +79,6 @@ class RelativeAttitudeFromBrowserProvider extends Provider {
|
|
|
80
79
|
|
|
81
80
|
|
|
82
81
|
onDeviceOrientationEvent = e => {
|
|
83
|
-
ProvidersLogger.feedImuData(e);
|
|
84
82
|
|
|
85
83
|
const timestamp = e.timeStamp / 1e3;
|
|
86
84
|
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
import Provider from '../Provider.js';
|
|
7
7
|
import EventType from '../../events/EventType';
|
|
8
8
|
import AskImuOnDesktopError from '../../errors/AskImuOnDesktopError.js';
|
|
9
|
-
import ProvidersLogger from '../../logger/ProvidersLogger.js';
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Imu (Inertial Measurement Unit) provider retrieve acceleration data
|
|
@@ -83,8 +82,6 @@ class ImuProvider extends Provider {
|
|
|
83
82
|
* @private
|
|
84
83
|
*/
|
|
85
84
|
parseDeviceMotionEvent = e => {
|
|
86
|
-
ProvidersLogger.feedImuData(e);
|
|
87
|
-
|
|
88
85
|
const events = [];
|
|
89
86
|
|
|
90
87
|
const timestamp = e.timeStamp / 1e3;
|
|
@@ -8,7 +8,6 @@ import Provider from '../../Provider.js';
|
|
|
8
8
|
import GeolocationPermissionDeniedError from '../../../errors/GeolocationPermissionDeniedError.js';
|
|
9
9
|
import GeolocationPositionUnavailableError from '../../../errors/GeolocationPositionUnavailableError.js';
|
|
10
10
|
import Constants from '../../Constants.js';
|
|
11
|
-
import ProvidersLogger from '../../../logger/ProvidersLogger.js';
|
|
12
11
|
|
|
13
12
|
const POSITION_OPTIONS = {
|
|
14
13
|
enableHighAccuracy: true,
|
|
@@ -73,7 +72,6 @@ class GnssWifiProvider extends Provider {
|
|
|
73
72
|
* @private
|
|
74
73
|
*/
|
|
75
74
|
onNewPosition = geolocation => {
|
|
76
|
-
ProvidersLogger.feedGeolocation(geolocation);
|
|
77
75
|
|
|
78
76
|
const { coords } = geolocation;
|
|
79
77
|
if (!coords) {
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import ProvidersOptions from '../ProvidersOptions';
|
|
2
|
-
import ProvidersLoggerConverter from './ProvidersLoggerConverter.js';
|
|
3
|
-
|
|
4
|
-
import { NavigationLogger } from '@wemap/navigation-logger';
|
|
5
|
-
import { TimeUtils } from '@wemap/utils';
|
|
6
|
-
|
|
7
|
-
class ProvidersLogger {
|
|
8
|
-
|
|
9
|
-
static logs = [];
|
|
10
|
-
static currentLogIndex = 0;
|
|
11
|
-
|
|
12
|
-
static Converter = ProvidersLoggerConverter;
|
|
13
|
-
|
|
14
|
-
static feedImuData(event) {
|
|
15
|
-
if (!NavigationLogger.isRecording) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
this._feed(ProvidersLoggerConverter.imuDataToLog(TimeUtils.preciseTime, event));
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
static feedGeolocation(geolocationEvent) {
|
|
22
|
-
if (!NavigationLogger.isRecording) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
this._feed(ProvidersLoggerConverter.geolocationToLog(TimeUtils.preciseTime, geolocationEvent));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
static feedExternalData(eventType, data) {
|
|
29
|
-
if (!NavigationLogger.isRecording) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
this._feed(ProvidersLoggerConverter.externalDataToLog(TimeUtils.preciseTime, eventType, data));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
static feedProvidersMM(obj) {
|
|
36
|
-
if (!NavigationLogger.isRecording) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
this._feed(ProvidersLoggerConverter.providersMMToLog(TimeUtils.preciseTime, obj));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
static _feed(line) {
|
|
43
|
-
this.logs[this.currentLogIndex++] = line;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
static _onStart() {
|
|
47
|
-
fetch(NavigationLogger.apiUrl + '/providers-config', {
|
|
48
|
-
method: 'POST',
|
|
49
|
-
headers: {
|
|
50
|
-
'Accept': 'application/json',
|
|
51
|
-
'Content-Type': 'application/json'
|
|
52
|
-
},
|
|
53
|
-
body: JSON.stringify({ ProvidersOptions })
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
static _onFlush() {
|
|
58
|
-
|
|
59
|
-
if (this.logs.length === 0) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
fetch(NavigationLogger.apiUrl + '/providers', {
|
|
64
|
-
method: 'POST',
|
|
65
|
-
headers: { 'Content-Type': 'text/plain' },
|
|
66
|
-
body: this.logs.join('\n')
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
this.logs = [];
|
|
70
|
-
this.currentLogIndex = 0;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
NavigationLogger.on('started', () => ProvidersLogger._onStart());
|
|
76
|
-
NavigationLogger.on('flush', () => ProvidersLogger._onFlush());
|
|
77
|
-
|
|
78
|
-
export default ProvidersLogger;
|
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
/* eslint-disable complexity */
|
|
2
|
-
import {
|
|
3
|
-
UserPosition, AbsoluteHeading, Attitude
|
|
4
|
-
} from '@wemap/geo';
|
|
5
|
-
import {
|
|
6
|
-
Network, Itinerary
|
|
7
|
-
} from '@wemap/graph';
|
|
8
|
-
|
|
9
|
-
import { EventType } from '@wemap/providers';
|
|
10
|
-
|
|
11
|
-
const SEPARATOR = ',';
|
|
12
|
-
|
|
13
|
-
const PRECISION = 1e-6;
|
|
14
|
-
const PRECISION_INV = 1 / PRECISION;
|
|
15
|
-
const round = num => typeof num === 'number' ? Math.round(num * PRECISION_INV) / PRECISION_INV : num;
|
|
16
|
-
|
|
17
|
-
class ProvidersLoggerConverter {
|
|
18
|
-
|
|
19
|
-
static geolocationToLog(time, event) {
|
|
20
|
-
return [
|
|
21
|
-
2,
|
|
22
|
-
round(time),
|
|
23
|
-
round(event.timestamp),
|
|
24
|
-
event.coords.latitude,
|
|
25
|
-
event.coords.longitude,
|
|
26
|
-
typeof event.coords.altitude === 'number' ? round(event.coords.altitude) : null,
|
|
27
|
-
round(event.coords.accuracy),
|
|
28
|
-
typeof event.coords.altitudeAccuracy === 'number' ? round(event.coords.altitudeAccuracy) : null,
|
|
29
|
-
typeof event.coords.heading === 'number' ? round(event.coords.heading) : null,
|
|
30
|
-
typeof event.coords.speed === 'number' ? round(event.coords.speed) : null
|
|
31
|
-
].join(SEPARATOR);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
static imuDataToLog(time, event) {
|
|
35
|
-
switch (event.type) {
|
|
36
|
-
|
|
37
|
-
case 'devicemotion':
|
|
38
|
-
const acc = event.accelerationIncludingGravity;
|
|
39
|
-
const gyr = event.rotationRate;
|
|
40
|
-
const linearAcc = event.acceleration;
|
|
41
|
-
return [
|
|
42
|
-
3,
|
|
43
|
-
event.type,
|
|
44
|
-
round(time),
|
|
45
|
-
round(event.timeStamp),
|
|
46
|
-
acc && typeof acc.x === 'number' ? round(acc.x) : null,
|
|
47
|
-
acc && typeof acc.y === 'number' ? round(acc.y) : null,
|
|
48
|
-
acc && typeof acc.z === 'number' ? round(acc.z) : null,
|
|
49
|
-
gyr && typeof gyr.alpha === 'number' ? round(gyr.alpha) : null,
|
|
50
|
-
gyr && typeof gyr.beta === 'number' ? round(gyr.beta) : null,
|
|
51
|
-
gyr && typeof gyr.gamma === 'number' ? round(gyr.gamma) : null,
|
|
52
|
-
linearAcc && typeof linearAcc.x === 'number' ? round(linearAcc.x) : null,
|
|
53
|
-
linearAcc && typeof linearAcc.y === 'number' ? round(linearAcc.y) : null,
|
|
54
|
-
linearAcc && typeof linearAcc.z === 'number' ? round(linearAcc.z) : null,
|
|
55
|
-
round(event.interval)
|
|
56
|
-
].join(SEPARATOR);
|
|
57
|
-
|
|
58
|
-
case 'deviceorientation':
|
|
59
|
-
return [
|
|
60
|
-
3,
|
|
61
|
-
event.type,
|
|
62
|
-
round(time),
|
|
63
|
-
round(event.timeStamp),
|
|
64
|
-
round(event.alpha),
|
|
65
|
-
round(event.beta),
|
|
66
|
-
round(event.gamma),
|
|
67
|
-
round(event.webkitCompassHeading),
|
|
68
|
-
event.absolute ? 1 : 0
|
|
69
|
-
].join(SEPARATOR);
|
|
70
|
-
|
|
71
|
-
case 'deviceorientationabsolute':
|
|
72
|
-
return [
|
|
73
|
-
3,
|
|
74
|
-
event.type,
|
|
75
|
-
round(time),
|
|
76
|
-
round(event.timeStamp),
|
|
77
|
-
round(event.alpha),
|
|
78
|
-
round(event.beta),
|
|
79
|
-
round(event.gamma),
|
|
80
|
-
event.absolute ? 1 : 0
|
|
81
|
-
].join(SEPARATOR);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
throw new Error(`Cannot parse event: ${event.type}`, event);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
static externalDataToLog(time, eventType, data) {
|
|
88
|
-
switch (eventType) {
|
|
89
|
-
case EventType.Network:
|
|
90
|
-
if (data instanceof Itinerary) {
|
|
91
|
-
return [4, 'itinerary', round(time), data === null ? null : JSON.stringify(data.toCompressedJson())].join(SEPARATOR);
|
|
92
|
-
}
|
|
93
|
-
return [4, 'network', round(time), data === null ? null : JSON.stringify(data.toCompressedJson())].join(SEPARATOR);
|
|
94
|
-
case EventType.AbsolutePosition:
|
|
95
|
-
return [4, 'absolute-position', round(time), JSON.stringify(data.toJson())].join(SEPARATOR);
|
|
96
|
-
case EventType.AbsoluteHeading:
|
|
97
|
-
return [4, 'absolute-heading', round(time), JSON.stringify(data.toJson())].join(SEPARATOR);
|
|
98
|
-
case EventType.AbsoluteAttitude:
|
|
99
|
-
return [4, 'absolute-attitude', round(time), JSON.stringify(data.toJson())].join(SEPARATOR);
|
|
100
|
-
}
|
|
101
|
-
return [4, 'unknown', eventType].join(SEPARATOR);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
static providersMMToLog(time, obj) {
|
|
105
|
-
return [5, time, JSON.stringify(obj)].join(SEPARATOR);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
static logToObj(str) {
|
|
110
|
-
const logType = parseInt(str[0], 10);
|
|
111
|
-
switch (logType) {
|
|
112
|
-
case 2:
|
|
113
|
-
return this.logToGeolocation(str);
|
|
114
|
-
case 3:
|
|
115
|
-
return this.logToImu(str);
|
|
116
|
-
case 4:
|
|
117
|
-
return this.logToExternalData(str);
|
|
118
|
-
case 5:
|
|
119
|
-
return this.logToProvidersMM(str);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
throw new Error(`Cannot parse log: ${str}`);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
static logToGeolocation(str) {
|
|
126
|
-
const array = str.split(SEPARATOR).map(parseFloat);
|
|
127
|
-
return {
|
|
128
|
-
type: 'geolocation',
|
|
129
|
-
time: array[1],
|
|
130
|
-
data: {
|
|
131
|
-
timestamp: array[2],
|
|
132
|
-
coords: {
|
|
133
|
-
latitude: array[3],
|
|
134
|
-
longitude: array[4],
|
|
135
|
-
altitude: array[5],
|
|
136
|
-
accuracy: array[6],
|
|
137
|
-
altitudeAccuracy: array[7],
|
|
138
|
-
heading: array[8],
|
|
139
|
-
speed: array[9]
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
static logToImu(str) {
|
|
146
|
-
|
|
147
|
-
const indexOfSecondComma = str.indexOf(SEPARATOR, 2);
|
|
148
|
-
const eventName = str.substring(2, indexOfSecondComma);
|
|
149
|
-
const data = str.substring(indexOfSecondComma + 1).split(SEPARATOR).map(parseFloat);
|
|
150
|
-
|
|
151
|
-
const event = new CustomEvent(eventName);
|
|
152
|
-
Object.defineProperties(event, { timeStamp: { writable: true } });
|
|
153
|
-
|
|
154
|
-
switch (eventName) {
|
|
155
|
-
case 'devicemotion':
|
|
156
|
-
Object.assign(event, {
|
|
157
|
-
timeStamp: data[1],
|
|
158
|
-
accelerationIncludingGravity: {
|
|
159
|
-
x: data[2],
|
|
160
|
-
y: data[3],
|
|
161
|
-
z: data[4]
|
|
162
|
-
},
|
|
163
|
-
rotationRate: {
|
|
164
|
-
alpha: data[5],
|
|
165
|
-
beta: data[6],
|
|
166
|
-
gamma: data[7]
|
|
167
|
-
},
|
|
168
|
-
acceleration: {
|
|
169
|
-
x: data[8],
|
|
170
|
-
y: data[9],
|
|
171
|
-
z: data[10]
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
break;
|
|
175
|
-
|
|
176
|
-
case 'deviceorientation':
|
|
177
|
-
Object.assign(event, {
|
|
178
|
-
timeStamp: data[1],
|
|
179
|
-
alpha: data[2],
|
|
180
|
-
beta: data[3],
|
|
181
|
-
gamma: data[4],
|
|
182
|
-
webkitCompassHeading: data[5],
|
|
183
|
-
absolute: data[6] === 1
|
|
184
|
-
});
|
|
185
|
-
break;
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
case 'deviceorientationabsolute':
|
|
189
|
-
Object.assign(event, {
|
|
190
|
-
timeStamp: data[1],
|
|
191
|
-
alpha: data[2],
|
|
192
|
-
beta: data[3],
|
|
193
|
-
gamma: data[4],
|
|
194
|
-
absolute: data[5] === 1
|
|
195
|
-
});
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
return {
|
|
200
|
-
type: 'imu',
|
|
201
|
-
time: data[0],
|
|
202
|
-
data: event
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
static logToExternalData(str) {
|
|
207
|
-
|
|
208
|
-
const indexOfSecondComma = str.indexOf(SEPARATOR, 2);
|
|
209
|
-
const eventTypeStr = str.substring(2, indexOfSecondComma);
|
|
210
|
-
|
|
211
|
-
const indexOfThirdComma = str.indexOf(SEPARATOR, indexOfSecondComma + 1);
|
|
212
|
-
const time = parseFloat(str.substring(indexOfSecondComma + 1, indexOfThirdComma));
|
|
213
|
-
|
|
214
|
-
const dataStr = str.substring(indexOfThirdComma + 1);
|
|
215
|
-
|
|
216
|
-
let data;
|
|
217
|
-
switch (eventTypeStr) {
|
|
218
|
-
|
|
219
|
-
case 'network':
|
|
220
|
-
data = {
|
|
221
|
-
eventType: EventType.Network,
|
|
222
|
-
data: dataStr === '' ? null : Network.fromCompressedJson(JSON.parse(dataStr))
|
|
223
|
-
};
|
|
224
|
-
break;
|
|
225
|
-
|
|
226
|
-
case 'itinerary':
|
|
227
|
-
data = {
|
|
228
|
-
eventType: EventType.Network,
|
|
229
|
-
data: dataStr === '' ? null : Itinerary.fromCompressedJson(JSON.parse(dataStr))
|
|
230
|
-
};
|
|
231
|
-
break;
|
|
232
|
-
|
|
233
|
-
case 'absolute-position':
|
|
234
|
-
data = {
|
|
235
|
-
eventType: EventType.AbsolutePosition,
|
|
236
|
-
data: dataStr === '' ? null : UserPosition.fromJson(JSON.parse(dataStr))
|
|
237
|
-
};
|
|
238
|
-
break;
|
|
239
|
-
|
|
240
|
-
case 'absolute-attitude':
|
|
241
|
-
data = {
|
|
242
|
-
eventType: EventType.AbsoluteAttitude,
|
|
243
|
-
data: dataStr === '' ? null : Attitude.fromJson(JSON.parse(dataStr))
|
|
244
|
-
};
|
|
245
|
-
break;
|
|
246
|
-
|
|
247
|
-
case 'absolute-heading':
|
|
248
|
-
data = {
|
|
249
|
-
eventType: EventType.AbsoluteHeading,
|
|
250
|
-
data: dataStr === '' ? null : AbsoluteHeading.fromJson(JSON.parse(dataStr))
|
|
251
|
-
};
|
|
252
|
-
break;
|
|
253
|
-
|
|
254
|
-
default:
|
|
255
|
-
throw new Error(`Cannot parse eventType: ${eventTypeStr}`);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
return {
|
|
259
|
-
type: 'external',
|
|
260
|
-
time,
|
|
261
|
-
data
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
static logToProvidersMM(str) {
|
|
266
|
-
const array = str.split(SEPARATOR);
|
|
267
|
-
return {
|
|
268
|
-
type: 'providersMM',
|
|
269
|
-
time: parseFloat(array[1]),
|
|
270
|
-
data: JSON.parse(array[2])
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
export default ProvidersLoggerConverter;
|