@wemap/providers 3.2.18 → 4.0.0
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 +8 -7
- 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 +3 -0
- package/src/ProvidersInterface.js +16 -10
- package/src/events/ProviderEvent.js +0 -2
- package/src/mapmatching/MapMatchingHandler.js +150 -0
- package/src/providers/FakeProvider.spec.js +0 -2
- package/src/providers/Provider.js +3 -8
- package/src/providers/attitude/absolute/AbsoluteAttitudeFromBrowserProvider.js +0 -1
- package/src/providers/attitude/absolute/AbsoluteAttitudeFromRelAttProvider.js +3 -3
- package/src/providers/attitude/absolute/AbsoluteAttitudeFusedProvider.js +166 -0
- package/src/providers/attitude/absolute/AbsoluteAttitudeProvider.js +45 -13
- package/src/providers/attitude/relative/RelativeAttitudeFromBrowserProvider.js +2 -4
- package/src/providers/attitude/relative/RelativeAttitudeFromEkfProvider.js +4 -4
- package/src/providers/imu/ImuProvider.js +8 -2
- package/src/providers/inclination/InclinationFromAccProvider.js +1 -2
- package/src/providers/inclination/InclinationFromRelativeAttitudeProvider.js +0 -1
- package/src/providers/position/absolute/AbsolutePositionFromRelProvider.js +2 -3
- package/src/providers/position/absolute/AbsolutePositionProvider.js +32 -138
- package/src/providers/position/absolute/GnssWifiProvider.js +1 -1
- package/src/providers/position/absolute/IpProvider.js +2 -4
- package/src/providers/position/relative/ArCoreProvider.js +1 -1
- package/src/providers/position/relative/GeoRelativePositionFromArCoreProvider.js +0 -1
- package/src/providers/position/relative/PdrProvider.js +1 -2
- package/src/providers/steps/StepDetectionProvider.js +4 -4
- package/src/smoothers/AttitudeSmoother.js +100 -0
|
@@ -80,14 +80,14 @@ class AbsoluteAttitudeComponent extends React.Component {
|
|
|
80
80
|
const heading = Number(this.inputHeading);
|
|
81
81
|
if (!isNaN(heading)) {
|
|
82
82
|
AbsoluteAttitude.feed(
|
|
83
|
-
new AbsoluteHeading(deg2rad(heading), TimeUtils.preciseTime / 1e3, 0)
|
|
83
|
+
new AbsoluteHeading(deg2rad(heading), TimeUtils.preciseTime() / 1e3, 0)
|
|
84
84
|
);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
handlePosSubmit() {
|
|
89
89
|
AbsolutePosition.feed(
|
|
90
|
-
new UserPosition(43.61, 3.8, null, null, TimeUtils.preciseTime / 1e3, 1000)
|
|
90
|
+
new UserPosition(43.61, 3.8, null, null, TimeUtils.preciseTime() / 1e3, 1000)
|
|
91
91
|
);
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -101,11 +101,12 @@ class AbsoluteAttitudeComponent extends React.Component {
|
|
|
101
101
|
const gamma = this.state.deviceorientation.gamma;
|
|
102
102
|
const webkitCompassHeading = this.state.deviceorientation.webkitCompassHeading;
|
|
103
103
|
|
|
104
|
-
if (alpha
|
|
105
|
-
|
|
104
|
+
if (typeof alpha === 'number' && typeof beta === 'number'
|
|
105
|
+
&& typeof gamma === 'number' && typeof webkitCompassHeading === 'number') {
|
|
106
|
+
rawRender = <pre>alpha: {alpha.toFixed(2)}, <br />
|
|
106
107
|
beta: {beta.toFixed(2)}, <br />
|
|
107
108
|
gamma: {gamma.toFixed(2)}, <br />
|
|
108
|
-
webkitCompassHeading: {webkitCompassHeading.toFixed(2)}</
|
|
109
|
+
webkitCompassHeading: {webkitCompassHeading.toFixed(2)}</pre>;
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
} else if (this.state.deviceorientationabsolute) {
|
|
@@ -114,9 +115,9 @@ class AbsoluteAttitudeComponent extends React.Component {
|
|
|
114
115
|
const gamma = this.state.deviceorientationabsolute.gamma;
|
|
115
116
|
|
|
116
117
|
if (typeof alpha === 'number' && typeof beta === 'number' && typeof gamma === 'number') {
|
|
117
|
-
rawRender = <
|
|
118
|
+
rawRender = <pre>alpha: {alpha.toFixed(2)}, <br />
|
|
118
119
|
beta: {beta.toFixed(2)}, <br />
|
|
119
|
-
gamma: {gamma.toFixed(2)}</
|
|
120
|
+
gamma: {gamma.toFixed(2)}</pre>;
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React from 'react'; // eslint-disable-line no-unused-vars
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
AbsoluteHeading, UserPosition, Level
|
|
4
|
+
AbsoluteHeading, UserPosition, Level, Itinerary
|
|
5
5
|
} from '@wemap/geo';
|
|
6
|
-
import { Itinerary } from '@wemap/graph';
|
|
7
6
|
import { deg2rad } from '@wemap/maths';
|
|
8
7
|
import { TimeUtils } from '@wemap/utils';
|
|
9
8
|
|
|
@@ -12,10 +11,10 @@ const datasets = {};
|
|
|
12
11
|
// Wemap Office
|
|
13
12
|
const wemapOffice = {
|
|
14
13
|
get initialPosition() {
|
|
15
|
-
return new UserPosition(43.6091955, 3.8841255, 1.5, null, TimeUtils.preciseTime / 1e3, 0);
|
|
14
|
+
return new UserPosition(43.6091955, 3.8841255, 1.5, null, TimeUtils.preciseTime() / 1e3, 0);
|
|
16
15
|
},
|
|
17
16
|
get initialHeading() {
|
|
18
|
-
return new AbsoluteHeading(deg2rad(191.9), TimeUtils.preciseTime / 1e3, 0);
|
|
17
|
+
return new AbsoluteHeading(deg2rad(191.9), TimeUtils.preciseTime() / 1e3, 0);
|
|
19
18
|
}
|
|
20
19
|
};
|
|
21
20
|
wemapOffice.itinerary = Itinerary.fromOrderedPointsArray(
|
|
@@ -33,10 +32,10 @@ wemapOffice.itinerary = Itinerary.fromOrderedPointsArray(
|
|
|
33
32
|
// Wemap Office Multi-level
|
|
34
33
|
const wemapOfficeMulti = {
|
|
35
34
|
get initialPosition() {
|
|
36
|
-
return new UserPosition(43.6091965, 3.8841285, 1.5, new Level(2), TimeUtils.preciseTime / 1e3, 0);
|
|
35
|
+
return new UserPosition(43.6091965, 3.8841285, 1.5, new Level(2), TimeUtils.preciseTime() / 1e3, 0);
|
|
37
36
|
},
|
|
38
37
|
get initialHeading() {
|
|
39
|
-
return new AbsoluteHeading(deg2rad(191.9), TimeUtils.preciseTime / 1e3, 0);
|
|
38
|
+
return new AbsoluteHeading(deg2rad(191.9), TimeUtils.preciseTime() / 1e3, 0);
|
|
40
39
|
}
|
|
41
40
|
};
|
|
42
41
|
wemapOfficeMulti.itinerary = Itinerary.fromOrderedPointsArray(
|
|
@@ -60,10 +59,10 @@ wemapOfficeMulti.itinerary = Itinerary.fromOrderedPointsArray(
|
|
|
60
59
|
// Gare de Lyon RER A
|
|
61
60
|
const gareDeLyonRerA = {
|
|
62
61
|
get initialPosition() {
|
|
63
|
-
return new UserPosition(48.8442365, 2.3728267, 1.5, new Level(-2), TimeUtils.preciseTime / 1e3, 0);
|
|
62
|
+
return new UserPosition(48.8442365, 2.3728267, 1.5, new Level(-2), TimeUtils.preciseTime() / 1e3, 0);
|
|
64
63
|
},
|
|
65
64
|
get initialHeading() {
|
|
66
|
-
return new AbsoluteHeading(deg2rad(41.6), TimeUtils.preciseTime / 1e3, 0);
|
|
65
|
+
return new AbsoluteHeading(deg2rad(41.6), TimeUtils.preciseTime() / 1e3, 0);
|
|
67
66
|
}
|
|
68
67
|
};
|
|
69
68
|
gareDeLyonRerA.itinerary = Itinerary.fromOrderedPointsArray(
|
|
@@ -59,10 +59,10 @@ class RelativeAttitudeComponent extends React.Component {
|
|
|
59
59
|
const beta = this.state.deviceorientation.beta;
|
|
60
60
|
const gamma = this.state.deviceorientation.gamma;
|
|
61
61
|
|
|
62
|
-
if (alpha && beta && gamma) {
|
|
63
|
-
rawRender = <
|
|
62
|
+
if (typeof alpha === 'number' && typeof beta === 'number' && typeof gamma === 'number') {
|
|
63
|
+
rawRender = <pre>alpha: {alpha.toFixed(2)}, <br />
|
|
64
64
|
beta: {beta.toFixed(2)}, <br />
|
|
65
|
-
gamma: {gamma.toFixed(2)}</
|
|
65
|
+
gamma: {gamma.toFixed(2)}</pre>;
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
package/debug/src/Utils.js
CHANGED
|
@@ -40,14 +40,14 @@ class Utils {
|
|
|
40
40
|
|
|
41
41
|
return (
|
|
42
42
|
<div>
|
|
43
|
-
<
|
|
43
|
+
<pre>
|
|
44
44
|
Quat: [{w}, {x}, {y}, {z}]<br />
|
|
45
45
|
Eulers: [{yaw}, {pitch}, {roll}]<br />
|
|
46
46
|
Heading: {heading}<br />
|
|
47
47
|
Time: {attitude.time.toFixed(2)}<br />
|
|
48
48
|
Accuracy: {accuracyString}
|
|
49
|
-
</
|
|
50
|
-
{(event instanceof ProviderEvent) ? Utils.
|
|
49
|
+
</pre>
|
|
50
|
+
{(event instanceof ProviderEvent) ? Utils.renderFromStack(event) : ''}
|
|
51
51
|
</div>
|
|
52
52
|
);
|
|
53
53
|
}
|
|
@@ -62,14 +62,17 @@ class Utils {
|
|
|
62
62
|
return Utils.renderError(event);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
const {
|
|
66
|
-
|
|
65
|
+
const { values } = event.data;
|
|
67
66
|
return (
|
|
68
67
|
<div>
|
|
69
|
-
<
|
|
70
|
-
[
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
<pre>
|
|
69
|
+
[
|
|
70
|
+
{values[0].toFixed(2).padStart(6, ' ')},
|
|
71
|
+
{values[1].toFixed(2).padStart(6, ' ')},
|
|
72
|
+
{values[2].toFixed(2).padStart(6, ' ')}
|
|
73
|
+
]
|
|
74
|
+
</pre>
|
|
75
|
+
{Utils.renderFromStack(event)}
|
|
73
76
|
</div>
|
|
74
77
|
);
|
|
75
78
|
}
|
|
@@ -85,7 +88,7 @@ class Utils {
|
|
|
85
88
|
const position = event instanceof ProviderEvent ? event.data : event;
|
|
86
89
|
return (
|
|
87
90
|
<div>
|
|
88
|
-
<
|
|
91
|
+
<pre>
|
|
89
92
|
Latitude: {position.lat.toFixed(7)}<br />
|
|
90
93
|
Longitude: {position.lng.toFixed(7)}<br />
|
|
91
94
|
Altitude: {position.alt ? position.alt.toFixed(2) : NOT_AVAILABLE_STR}<br />
|
|
@@ -93,8 +96,8 @@ class Utils {
|
|
|
93
96
|
Bearing: {position.bearing !== null ? rad2deg(position.bearing).toFixed(2) : NOT_AVAILABLE_STR}<br />
|
|
94
97
|
Accuracy: {position.accuracy.toFixed(2)}<br />
|
|
95
98
|
Time: {position.time.toFixed(2)}
|
|
96
|
-
</
|
|
97
|
-
{(event instanceof ProviderEvent) ? Utils.
|
|
99
|
+
</pre>
|
|
100
|
+
{(event instanceof ProviderEvent) ? Utils.renderFromStack(event) : ''}
|
|
98
101
|
</div>
|
|
99
102
|
);
|
|
100
103
|
|
|
@@ -109,11 +112,11 @@ class Utils {
|
|
|
109
112
|
return Utils.renderError(position);
|
|
110
113
|
}
|
|
111
114
|
return (
|
|
112
|
-
<
|
|
115
|
+
<pre>
|
|
113
116
|
x: {position[0].toFixed(2)}<br />
|
|
114
117
|
y: {position[1].toFixed(2)}<br />
|
|
115
118
|
z: {position[2].toFixed(2)}
|
|
116
|
-
</
|
|
119
|
+
</pre>
|
|
117
120
|
);
|
|
118
121
|
|
|
119
122
|
}
|
|
@@ -137,13 +140,13 @@ class Utils {
|
|
|
137
140
|
|
|
138
141
|
|
|
139
142
|
return (
|
|
140
|
-
<
|
|
143
|
+
<pre>
|
|
141
144
|
projection: {info.projection.nearestElement.constructor.name}<br />
|
|
142
145
|
distanceOfProjection: {info.projection.distanceFromNearestElement.toFixed(1)}m<br />
|
|
143
146
|
traveledDistance: {info.traveledDistance.toFixed(1)}m ({(info.traveledPercentage * 100).toFixed(1)}%)<br />
|
|
144
147
|
remainingDistance: {info.remainingDistance.toFixed(1)}m ({(info.remainingPercentage * 100).toFixed(1)}%)<br />
|
|
145
148
|
nextStep: {nextStepStr}
|
|
146
|
-
</
|
|
149
|
+
</pre>
|
|
147
150
|
);
|
|
148
151
|
|
|
149
152
|
}
|
|
@@ -157,10 +160,10 @@ class Utils {
|
|
|
157
160
|
}
|
|
158
161
|
return (
|
|
159
162
|
<div>
|
|
160
|
-
<
|
|
163
|
+
<pre>
|
|
161
164
|
Inclination: {rad2deg(event.data).toFixed(2)} deg
|
|
162
|
-
</
|
|
163
|
-
{Utils.
|
|
165
|
+
</pre>
|
|
166
|
+
{Utils.renderFromStack(event)}
|
|
164
167
|
</div>
|
|
165
168
|
);
|
|
166
169
|
}
|
|
@@ -177,11 +180,11 @@ class Utils {
|
|
|
177
180
|
}
|
|
178
181
|
return (
|
|
179
182
|
<div>
|
|
180
|
-
<
|
|
183
|
+
<pre style={{ margin: 0 }}>
|
|
181
184
|
Number: {event.data.number}<br />
|
|
182
185
|
Size: {event.data.size.toFixed(2)}m
|
|
183
|
-
</
|
|
184
|
-
{Utils.
|
|
186
|
+
</pre>
|
|
187
|
+
{Utils.renderFromStack(event)}
|
|
185
188
|
</div>
|
|
186
189
|
);
|
|
187
190
|
}
|
|
@@ -190,26 +193,14 @@ class Utils {
|
|
|
190
193
|
return (<div style={{ maxWidth: '180px' }}><strong>[{error.constructor.name}]</strong><br />{error.message}</div>);
|
|
191
194
|
}
|
|
192
195
|
|
|
193
|
-
static renderFromStack(providersStack) {
|
|
194
|
-
return <
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
static renderTimeAndFromStack(event) {
|
|
202
|
-
return (
|
|
203
|
-
<p style={{
|
|
204
|
-
margin: 0,
|
|
205
|
-
fontSize: 'small'
|
|
206
|
-
}}>
|
|
207
|
-
{this.renderTime(event.timestamp)}<br />
|
|
208
|
-
{this.renderFromStack(event.providersStack)}
|
|
209
|
-
</p>
|
|
210
|
-
);
|
|
196
|
+
static renderFromStack({providersStack}) {
|
|
197
|
+
return <pre style={{
|
|
198
|
+
margin: 0,
|
|
199
|
+
fontSize: 'small'
|
|
200
|
+
}}>
|
|
201
|
+
Providers Stack: {providersStack.join(', ')}
|
|
202
|
+
</pre>;
|
|
211
203
|
}
|
|
212
|
-
|
|
213
204
|
}
|
|
214
205
|
|
|
215
206
|
export default Utils;
|
package/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import ProvidersOptions from './src/ProvidersOptions.js';
|
|
1
|
+
export { default as EventType } from './src/events/EventType.js';
|
|
2
|
+
export * as Providers from './src/Providers.js';
|
|
3
|
+
export { default as ProvidersInterface } from './src/ProvidersInterface.js';
|
|
4
|
+
export { default as ProvidersOptions } from './src/ProvidersOptions.js';
|
|
6
5
|
|
|
7
|
-
export {
|
|
8
|
-
|
|
9
|
-
};
|
|
6
|
+
export { default as PositionSmoother } from './src/smoothers/PositionSmoother.js';
|
|
7
|
+
export { default as AttitudeSmoother } from './src/smoothers/AttitudeSmoother.js';
|
package/package.json
CHANGED
|
@@ -8,19 +8,18 @@
|
|
|
8
8
|
"Guillaume Pannetier <guillaume.pannetier@getwemap.com>"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@wemap/geo": "^
|
|
11
|
+
"@wemap/geo": "^4.0.0",
|
|
12
12
|
"@wemap/geomagnetism": "^0.1.1",
|
|
13
|
-
"@wemap/
|
|
14
|
-
"@wemap/
|
|
15
|
-
"@wemap/
|
|
16
|
-
"@wemap/
|
|
17
|
-
"@wemap/utils": "^3.2.16",
|
|
13
|
+
"@wemap/logger": "^4.0.0",
|
|
14
|
+
"@wemap/map": "^4.0.0",
|
|
15
|
+
"@wemap/maths": "^4.0.0",
|
|
16
|
+
"@wemap/utils": "^4.0.0",
|
|
18
17
|
"lodash.isempty": "^4.4.0",
|
|
19
18
|
"lodash.noop": "^3.0.1"
|
|
20
19
|
},
|
|
21
20
|
"description": "A package using different geoloc systems",
|
|
22
21
|
"devDependencies": {
|
|
23
|
-
"@wemap/osm": "^
|
|
22
|
+
"@wemap/osm": "^4.0.0",
|
|
24
23
|
"mapbox-gl": "^1.11.1"
|
|
25
24
|
},
|
|
26
25
|
"homepage": "https://github.com/wemap/wemap-modules-js#readme",
|
|
@@ -42,6 +41,6 @@
|
|
|
42
41
|
"url": "git+https://github.com/wemap/wemap-modules-js.git"
|
|
43
42
|
},
|
|
44
43
|
"type": "module",
|
|
45
|
-
"version": "
|
|
46
|
-
"gitHead": "
|
|
44
|
+
"version": "4.0.0",
|
|
45
|
+
"gitHead": "8b72858590fc2ff33fbea4f090de8cd353a7445f"
|
|
47
46
|
}
|
package/src/Providers.js
CHANGED
|
@@ -19,9 +19,11 @@ const RelativeAttitude = RelativeAttitudeProvider.instance;
|
|
|
19
19
|
|
|
20
20
|
import AbsoluteAttitudeFromBrowserProvider from './providers/attitude/absolute/AbsoluteAttitudeFromBrowserProvider.js';
|
|
21
21
|
import AbsoluteAttitudeFromRelAttProvider from './providers/attitude/absolute/AbsoluteAttitudeFromRelAttProvider.js';
|
|
22
|
+
import AbsoluteAttitudeFusedProvider from './providers/attitude/absolute/AbsoluteAttitudeFusedProvider.js';
|
|
22
23
|
import AbsoluteAttitudeProvider from './providers/attitude/absolute/AbsoluteAttitudeProvider.js';
|
|
23
24
|
const AbsoluteAttitudeFromBrowser = AbsoluteAttitudeFromBrowserProvider.instance;
|
|
24
25
|
const AbsoluteAttitudeFromRelAtt = AbsoluteAttitudeFromRelAttProvider.instance;
|
|
26
|
+
const AbsoluteAttitudeFused = AbsoluteAttitudeFusedProvider.instance;
|
|
25
27
|
const AbsoluteAttitude = AbsoluteAttitudeProvider.instance;
|
|
26
28
|
|
|
27
29
|
import InclinationFromAccProvider from './providers/inclination/InclinationFromAccProvider.js';
|
|
@@ -63,6 +65,7 @@ export {
|
|
|
63
65
|
AbsoluteAttitude,
|
|
64
66
|
AbsoluteAttitudeFromBrowser,
|
|
65
67
|
AbsoluteAttitudeFromRelAtt,
|
|
68
|
+
AbsoluteAttitudeFused,
|
|
66
69
|
AbsolutePosition,
|
|
67
70
|
AbsolutePositionFromRel,
|
|
68
71
|
Accelerometer,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
|
|
2
2
|
import {
|
|
3
|
-
Attitude, AbsoluteHeading, UserPosition
|
|
3
|
+
Attitude, AbsoluteHeading, UserPosition, Network
|
|
4
4
|
} from '@wemap/geo';
|
|
5
|
-
import { Network } from '@wemap/graph';
|
|
6
5
|
|
|
7
6
|
import EventType from './events/EventType.js';
|
|
8
7
|
import MetaProvider from './providers/MetaProvider.js';
|
|
9
8
|
import {
|
|
10
|
-
AbsoluteAttitude, AbsolutePosition, Barcode, CameraNative, CameraProjectionMatrix, Inclination
|
|
9
|
+
AbsoluteAttitude, AbsolutePosition, Barcode, CameraNative, CameraProjectionMatrix, Inclination, RelativeAttitude
|
|
11
10
|
} from './Providers.js';
|
|
12
11
|
import ProvidersLoggerOld from './events/ProvidersLoggerOld.js';
|
|
12
|
+
import MapMatchingHandler from './mapmatching/MapMatchingHandler.js';
|
|
13
13
|
|
|
14
14
|
class ProvidersInterface {
|
|
15
15
|
|
|
@@ -48,6 +48,10 @@ class ProvidersInterface {
|
|
|
48
48
|
*/
|
|
49
49
|
static feed(eventType, data) {
|
|
50
50
|
this._checkEventTypeDataConsistency(eventType, data);
|
|
51
|
+
if (eventType === EventType.Network) {
|
|
52
|
+
MapMatchingHandler.network = data;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
51
55
|
this._getMetaProviderFromEventType(eventType).feed(data, eventType);
|
|
52
56
|
}
|
|
53
57
|
|
|
@@ -71,9 +75,11 @@ class ProvidersInterface {
|
|
|
71
75
|
return AbsoluteAttitude;
|
|
72
76
|
|
|
73
77
|
case EventType.AbsolutePosition:
|
|
74
|
-
case EventType.Network:
|
|
75
78
|
return AbsolutePosition;
|
|
76
79
|
|
|
80
|
+
case EventType.RelativeAttitude:
|
|
81
|
+
return RelativeAttitude;
|
|
82
|
+
|
|
77
83
|
case EventType.Inclination:
|
|
78
84
|
return Inclination;
|
|
79
85
|
|
|
@@ -129,27 +135,27 @@ class ProvidersInterface {
|
|
|
129
135
|
}
|
|
130
136
|
|
|
131
137
|
static get mapMatchingMaxDistance() {
|
|
132
|
-
return
|
|
138
|
+
return MapMatchingHandler.maxDistance;
|
|
133
139
|
}
|
|
134
140
|
|
|
135
141
|
static set mapMatchingMaxDistance(maxDistance) {
|
|
136
|
-
|
|
142
|
+
MapMatchingHandler.maxDistance = maxDistance;
|
|
137
143
|
}
|
|
138
144
|
|
|
139
145
|
static get mapMatchingMinDistance() {
|
|
140
|
-
return
|
|
146
|
+
return MapMatchingHandler.minDistance;
|
|
141
147
|
}
|
|
142
148
|
|
|
143
149
|
static set mapMatchingMinDistance(minDistance) {
|
|
144
|
-
|
|
150
|
+
MapMatchingHandler.minDistance = minDistance;
|
|
145
151
|
}
|
|
146
152
|
|
|
147
153
|
static get mapMatchingMaxAngleBearing() {
|
|
148
|
-
return
|
|
154
|
+
return MapMatchingHandler.maxAngleBearing;
|
|
149
155
|
}
|
|
150
156
|
|
|
151
157
|
static set mapMatchingMaxAngleBearing(maxAngleBearing) {
|
|
152
|
-
|
|
158
|
+
MapMatchingHandler.maxAngleBearing = maxAngleBearing;
|
|
153
159
|
}
|
|
154
160
|
}
|
|
155
161
|
|
|
@@ -6,7 +6,6 @@ import EventType from './EventType.js';
|
|
|
6
6
|
*/
|
|
7
7
|
class ProviderEvent {
|
|
8
8
|
|
|
9
|
-
timestamp = -1;
|
|
10
9
|
dataType = EventType.Unknown;
|
|
11
10
|
providersStack = [];
|
|
12
11
|
data = null;
|
|
@@ -23,7 +22,6 @@ class ProviderEvent {
|
|
|
23
22
|
|
|
24
23
|
clone() {
|
|
25
24
|
const evt = new ProviderEvent(this.dataType, this.data);
|
|
26
|
-
evt.timestamp = this.timestamp;
|
|
27
25
|
evt.providersStack = this.providersStack.slice(0);
|
|
28
26
|
return evt;
|
|
29
27
|
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { UserPosition } from '@wemap/geo';
|
|
2
|
+
import {
|
|
3
|
+
MapMatching, Network
|
|
4
|
+
} from '@wemap/geo';
|
|
5
|
+
import { deg2rad } from '@wemap/maths';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
AbsolutePosition, AbsoluteAttitudeFused
|
|
9
|
+
} from '../Providers.js';
|
|
10
|
+
import ProvidersOptions from '../ProvidersOptions.js';
|
|
11
|
+
|
|
12
|
+
const MM_MAX_ANGLE = deg2rad(20);
|
|
13
|
+
const MM_MAX_DIST = 30;
|
|
14
|
+
const MM_MIN_DIST = 0;
|
|
15
|
+
|
|
16
|
+
class MapMatchingHandler {
|
|
17
|
+
|
|
18
|
+
/** @type {MapMatching} */
|
|
19
|
+
_mapMatching;
|
|
20
|
+
|
|
21
|
+
/** @type {number} */
|
|
22
|
+
_mapMatchingMinDistance;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Singleton pattern using reflection.
|
|
26
|
+
* @returns {MapMatchingHandler}
|
|
27
|
+
*/
|
|
28
|
+
static get instance() {
|
|
29
|
+
if (!this._instance) {
|
|
30
|
+
this._instance = Reflect.construct(this, []);
|
|
31
|
+
}
|
|
32
|
+
return this._instance;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
constructor() {
|
|
36
|
+
|
|
37
|
+
if (this.constructor._instance) {
|
|
38
|
+
throw new Error(`Cannot instantiate ${this.name} twice`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
this._mapMatching = new MapMatching();
|
|
42
|
+
this._mapMatching.maxDistance = MM_MAX_DIST;
|
|
43
|
+
this._mapMatching.maxAngleBearing = MM_MAX_ANGLE;
|
|
44
|
+
this._mapMatchingMinDistance = MM_MIN_DIST;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
get enabled() {
|
|
48
|
+
return ProvidersOptions.useMapMatching;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @param {Network} network
|
|
53
|
+
*/
|
|
54
|
+
set network(network) {
|
|
55
|
+
this._mapMatching.network = network;
|
|
56
|
+
|
|
57
|
+
if (!this.enabled) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const lastEvent = AbsolutePosition.lastEvent;
|
|
62
|
+
if (network !== null && lastEvent) {
|
|
63
|
+
const projectedPosition = this.calcProjection(lastEvent.data, true);
|
|
64
|
+
if (projectedPosition) {
|
|
65
|
+
const newEvent = lastEvent.clone();
|
|
66
|
+
newEvent.data = projectedPosition;
|
|
67
|
+
AbsolutePosition.notify(newEvent);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @param {UserPosition} position
|
|
74
|
+
* @param {boolean} shouldTryMmOnNodes
|
|
75
|
+
* @returns {UserPosition}
|
|
76
|
+
*/
|
|
77
|
+
calcProjection(position, shouldTryMmOnNodes = false) {
|
|
78
|
+
|
|
79
|
+
let projection = null;
|
|
80
|
+
let bearingUsedForProjection = false;
|
|
81
|
+
|
|
82
|
+
if (!this.enabled || !this._mapMatching.network) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Firstly, if new position bearing is known, try to use map-matching with bearing
|
|
87
|
+
// That is not always the case, for e.g. the first position returned by the GnssWifi provider.
|
|
88
|
+
if (position.bearing !== null) {
|
|
89
|
+
projection = this._mapMatching.getProjection(position, true, true);
|
|
90
|
+
bearingUsedForProjection = true;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Secondly, if map-matching with bearing did not work, try MM on nodes (without bearing).
|
|
94
|
+
// Note: this is not allowed for positions from AbsolutePositionFromRel to allow
|
|
95
|
+
// user to leave the network.
|
|
96
|
+
if (!projection && shouldTryMmOnNodes) {
|
|
97
|
+
projection = this._mapMatching.getProjection(position, true, false);
|
|
98
|
+
bearingUsedForProjection = false;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// No projection found
|
|
102
|
+
if (!projection) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Do not use projection if it too close from itinerary,
|
|
107
|
+
// this allows left/right movements (ie with ArCore)
|
|
108
|
+
if (projection.distanceFromNearestElement < this._mapMatchingMinDistance) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (bearingUsedForProjection) {
|
|
113
|
+
AbsoluteAttitudeFused.mapMatching(projection);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Do not use projection.projection directly, because position has some specific properties like time, bearing and altitude
|
|
117
|
+
const projectedPosition = position.clone();
|
|
118
|
+
projectedPosition.lat = projection.projection.lat;
|
|
119
|
+
projectedPosition.lng = projection.projection.lng;
|
|
120
|
+
projectedPosition.level = projection.projection.level;
|
|
121
|
+
|
|
122
|
+
return projectedPosition;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
get maxDistance() {
|
|
126
|
+
return this._mapMatching.maxDistance;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
set maxDistance(maxDistance) {
|
|
130
|
+
this._mapMatching.maxDistance = maxDistance;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
get minDistance() {
|
|
134
|
+
return this._mapMatchingMinDistance;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
set minDistance(minDistance) {
|
|
138
|
+
this._mapMatchingMinDistance = minDistance;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
get maxAngleBearing() {
|
|
142
|
+
return this._mapMatching.maxAngleBearing;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
set maxAngleBearing(maxAngleBearing) {
|
|
146
|
+
this._mapMatching.maxAngleBearing = maxAngleBearing;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export default MapMatchingHandler.instance;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { UserPosition } from '@wemap/geo';
|
|
2
|
-
import { TimeUtils } from '@wemap/utils';
|
|
3
2
|
|
|
4
3
|
import Provider from './Provider.js';
|
|
5
4
|
import EventType from '../events/EventType.js';
|
|
@@ -29,7 +28,6 @@ class FakeProvider3 extends Provider {
|
|
|
29
28
|
this.intervalId = setInterval(() => {
|
|
30
29
|
const fakePosition = new UserPosition(Math.random() * 45, Math.random() * 180);
|
|
31
30
|
this.notify(this.createEvent(EventType.AbsolutePosition, fakePosition));
|
|
32
|
-
this.notify(this.createEvent(EventType.AbsolutePosition, fakePosition, TimeUtils.preciseTime));
|
|
33
31
|
}, 1);
|
|
34
32
|
}
|
|
35
33
|
stop() {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import noop from 'lodash.noop';
|
|
2
2
|
|
|
3
|
-
import { TimeUtils } from '@wemap/utils';
|
|
4
|
-
|
|
5
3
|
import EventType from '../events/EventType.js';
|
|
6
4
|
import ProviderEvent from '../events/ProviderEvent.js';
|
|
7
5
|
import ProvidersLoggerOld from '../events/ProvidersLoggerOld.js';
|
|
@@ -96,13 +94,11 @@ class Provider {
|
|
|
96
94
|
* Create an event from current provider
|
|
97
95
|
* @param {ProviderEvent#DataType} dataType type of ProviderEvent
|
|
98
96
|
* @param {Object} data data exported to ProviderEvent
|
|
99
|
-
* @param {Number} timestamp event timestamp
|
|
100
97
|
* @returns {ProviderEvent}
|
|
101
98
|
* @protected
|
|
102
99
|
*/
|
|
103
|
-
static createEvent(dataType, data,
|
|
100
|
+
static createEvent(dataType, data, fromEvents = []) {
|
|
104
101
|
const event = new ProviderEvent(dataType, data);
|
|
105
|
-
event.timestamp = typeof timestamp === 'number' ? timestamp : TimeUtils.preciseTime / 1e3;
|
|
106
102
|
const newStack = fromEvents.reduce((acc, _event) => acc.concat(_event.providersStack), []);
|
|
107
103
|
// Remove duplicates and keep lasts
|
|
108
104
|
event.providersStack = [...new Set(newStack.reverse())].reverse();
|
|
@@ -113,13 +109,12 @@ class Provider {
|
|
|
113
109
|
* Create an event from current provider
|
|
114
110
|
* @param {EventType} dataType type of ProviderEvent
|
|
115
111
|
* @param {Object} data data exported to ProviderEvent
|
|
116
|
-
* @param {Number} timestamp event timestamp
|
|
117
112
|
* @param {ProviderEvent[]} fromEvents events used for the creation of the new one
|
|
118
113
|
* @returns {ProviderEvent}
|
|
119
114
|
* @protected
|
|
120
115
|
*/
|
|
121
|
-
createEvent(dataType, data,
|
|
122
|
-
return this.constructor.createEvent(dataType, data,
|
|
116
|
+
createEvent(dataType, data, fromEvents) {
|
|
117
|
+
return this.constructor.createEvent(dataType, data, fromEvents);
|
|
123
118
|
}
|
|
124
119
|
|
|
125
120
|
get hasNativeInterface() {
|
|
@@ -4,7 +4,7 @@ import { Attitude } from '@wemap/geo';
|
|
|
4
4
|
import Provider from '../../Provider.js';
|
|
5
5
|
import EventType from '../../../events/EventType.js';
|
|
6
6
|
import {
|
|
7
|
-
RelativeAttitude, AbsoluteAttitude, AbsoluteAttitudeFromBrowser
|
|
7
|
+
RelativeAttitude, AbsoluteAttitude, AbsoluteAttitudeFromBrowser, AbsoluteAttitudeFused
|
|
8
8
|
} from '../../../Providers.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -91,7 +91,8 @@ class AbsoluteAttitudeFromRelAttProvider extends Provider {
|
|
|
91
91
|
* Use absolute attitude events only when they are not from this provider
|
|
92
92
|
*/
|
|
93
93
|
if (absoluteAttitudeEvent.providersStack.includes(this.pname)
|
|
94
|
-
|| absoluteAttitudeEvent.providersStack.includes(AbsoluteAttitudeFromBrowser.pname)
|
|
94
|
+
|| absoluteAttitudeEvent.providersStack.includes(AbsoluteAttitudeFromBrowser.pname)
|
|
95
|
+
|| absoluteAttitudeEvent.providersStack.includes(AbsoluteAttitudeFused.pname)) {
|
|
95
96
|
return;
|
|
96
97
|
}
|
|
97
98
|
this.absoluteAttitudeEvent = absoluteAttitudeEvent;
|
|
@@ -121,7 +122,6 @@ class AbsoluteAttitudeFromRelAttProvider extends Provider {
|
|
|
121
122
|
this.notify(this.createEvent(
|
|
122
123
|
EventType.AbsoluteAttitude,
|
|
123
124
|
attitude,
|
|
124
|
-
time,
|
|
125
125
|
[this.relativeAttitudeEvent, this.absoluteAttitudeEvent]
|
|
126
126
|
));
|
|
127
127
|
|