@wemap/providers 3.1.2 → 3.1.4

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.
Files changed (44) hide show
  1. package/debug/Common.css +172 -0
  2. package/debug/MainComponent.jsx +64 -0
  3. package/debug/components/AbsolutePositionComponent.jsx +1 -1
  4. package/debug/components/GnssWifiComponent.jsx +1 -1
  5. package/debug/components/StartStopComponent.jsx +5 -3
  6. package/debug/components/Utils.js +4 -2
  7. package/debug/details/DetailsAttitudeComponent.jsx +121 -0
  8. package/debug/details/DetailsComponent.jsx +42 -0
  9. package/debug/details/DetailsPositionComponent.jsx +127 -0
  10. package/debug/details/ItineraryComponent.jsx +323 -0
  11. package/debug/index.js +28 -0
  12. package/debug/map/MapComponent.jsx +84 -0
  13. package/debug/map/MapHandler.js +53 -0
  14. package/debug/map/MapboxHelper.js +50 -0
  15. package/debug/map/helpers/ItineraryMapHandler.js +284 -0
  16. package/debug/map/helpers/MapClickHandler.js +119 -0
  17. package/debug/map/helpers/UserOnMapHandler.js +489 -0
  18. package/debug/stores/ItineraryStore.js +223 -0
  19. package/dist/assets/indoor-maps/bureaux-wemap-montpellier.geojson +7444 -0
  20. package/dist/{pose.html → index.html} +4 -1
  21. package/dist/js/providers-components.js +353 -209
  22. package/package.json +9 -7
  23. package/src/ProvidersInterface.js +5 -4
  24. package/src/providers/MetaProvider.js +3 -1
  25. package/src/providers/attitude/relative/RelativeAttitudeFromInertialProvider.js +1 -1
  26. package/src/providers/position/absolute/AbsolutePositionFromRelProvider.js +1 -1
  27. package/src/providers/position/absolute/AbsolutePositionProvider.js +27 -16
  28. package/src/providers/position/relative/GeoRelativePositionFromArCoreProvider.js +2 -1
  29. package/src/providers/position/relative/PdrProvider.js +2 -1
  30. package/src/smoothers/PositionSmoother.js +10 -2
  31. package/webpack/webpack.common.js +5 -5
  32. package/webpack/webpack.dev.js +7 -1
  33. package/debug/components/Common.css +0 -27
  34. package/debug/components/MapComponent.jsx +0 -366
  35. package/debug/components/PoseComponent.jsx +0 -169
  36. package/debug/components/index.js +0 -28
  37. package/src/providers/legacy/AbsolutePdrProvider.js +0 -258
  38. package/src/providers/legacy/ArCoreAbsoluteProvider.js +0 -230
  39. package/src/providers/legacy/GnssWifiPdrProvider.js +0 -217
  40. package/src/providers/legacy/MapMatchingProvider.js +0 -65
  41. package/src/providers/legacy/PdrProvider.old.js +0 -300
  42. package/src/providers/legacy/PoseProvider.js +0 -68
  43. package/src/providers/legacy/helpers/Smoother.js +0 -92
  44. package/src/providers/legacy/helpers/Smoother.spec.js +0 -426
@@ -1,258 +0,0 @@
1
- /* eslint-disable max-statements */
2
- import isNumber from 'lodash.isnumber';
3
-
4
- import { UserPosition } from '@wemap/geo';
5
- import {
6
- Itinerary, MapMatching
7
- } from '@wemap/graph';
8
- import {
9
- deg2rad, Vector3
10
- } from '@wemap/maths';
11
-
12
- import Provider from '../Provider';
13
- import StepDetectionProvider from '../steps/StepDetectionProvider';
14
- import HeadingUnlocker from './helpers/HeadingUnlocker';
15
- import Availability from '../../events/Availability';
16
- import EventType from '../../events/EventType';
17
- import AbsoluteAttitudeProvider from '../attitude/absolute/AbsoluteAttitudeProvider';
18
- import PdrProvider from '../position/relative/PdrProvider';
19
- import ProviderEvent from '../../events/ProviderEvent';
20
-
21
- class AbsolutePdrProvider extends Provider {
22
-
23
- position = null;
24
-
25
- static MM_PDR_ANGLE = deg2rad(20);
26
- static MM_PDR_DIST = 15;
27
- static MM_CONV_SPEED = 0.7;
28
-
29
- static LO_SEGMENT_SIZE = 1.5;
30
-
31
- /**
32
- * @override
33
- */
34
- constructor() {
35
- super();
36
-
37
- this.relativePosition = [0, 0, 0];
38
-
39
- this.mapMatching = new MapMatching();
40
- this.mapMatching.maxAngleBearing = this.constructor.MM_PDR_ANGLE;
41
- this.mapMatching.maxDistance = this.constructor.MM_PDR_DIST;
42
-
43
- this.stepDetectionLocker = new HeadingUnlocker();
44
- }
45
-
46
- /**
47
- * @override
48
- */
49
- static get displayName() {
50
- return 'Absolute PDR';
51
- }
52
-
53
- /**
54
- * @override
55
- */
56
- static get eventsType() {
57
- return [EventType.AbsoluteAttitude, EventType.AbsolutePosition];
58
- }
59
-
60
- /**
61
- * @override
62
- */
63
- static get _availability() {
64
- return Availability.merge(
65
- StepDetectionProvider.availability,
66
- AbsoluteAttitudeProvider.availability
67
- );
68
- }
69
-
70
-
71
- /**
72
- * @override
73
- */
74
- _start() {
75
-
76
- this.pdrProviderId = this.scheduler.use(PdrProvider,
77
- events => this.onPdrEvent(events),
78
- error => this.notifyError(error),
79
- this.name);
80
-
81
- /**
82
- * Position
83
- */
84
- const lastPosition = this.dataStore.getLast(EventType.AbsolutePosition);
85
- if (lastPosition) {
86
- this.onPositionChanged(lastPosition);
87
- }
88
- this.dataStore.addEventListener(EventType.AbsolutePosition, this.onPositionChanged);
89
-
90
- /**
91
- * Network
92
- */
93
- this.mapMatching.network = this.dataStore.getLast(EventType.Network);
94
- this.dataStore.addEventListener(EventType.Network, this.onNetworkChanged);
95
-
96
- /**
97
- * Itinerary
98
- */
99
- const lastItinerary = this.dataStore.getLast(EventType.Itinerary);
100
- if (lastItinerary) {
101
- this.onItineraryChanged(lastItinerary);
102
- }
103
- this.dataStore.addEventListener(EventType.Itinerary, this.onItineraryChanged);
104
- }
105
-
106
- /**
107
- * @override
108
- */
109
- _stop() {
110
- this.dataStore.removeEventListener(EventType.AbsolutePosition, this.onPositionChanged);
111
- this.dataStore.removeEventListener(EventType.Network, this.onNetworkChanged);
112
- this.dataStore.removeEventListener(EventType.Itinerary, this.onItineraryChanged);
113
- this.scheduler.release(this.pdrProviderId, this.name);
114
- }
115
-
116
- onPositionChanged = position => {
117
- this.position = position.clone();
118
- this.notify(this.createEvent(EventType.AbsolutePosition, this.position));
119
- };
120
-
121
- onNetworkChanged = network => {
122
- this.mapMatching.network = network;
123
- }
124
-
125
- /**
126
- * @override
127
- */
128
- onPdrEvent = events => {
129
-
130
- events.forEach(event => {
131
- if (event.dataType === EventType.AbsoluteAttitude) {
132
- this.attitude = event.data;
133
- this.notify(event);
134
- } else {
135
- this.parseRelativePositionEvent(event);
136
- }
137
- });
138
- }
139
-
140
- parseRelativePositionEvent(event) {
141
-
142
- if (this.position && this.attitude
143
- && (!this.options.stepdetectionlocker
144
- || !this.stepDetectionLocker.locked
145
- || !this.stepDetectionLocker.feedHeading(this.attitude.heading))) {
146
-
147
- this.position = this.calculateNewPosition(this.position, event);
148
-
149
- this.notify(this.createEvent(EventType.AbsolutePosition, this.position, event.timestamp));
150
-
151
- } else {
152
- // this.pdrPosition has not been initialized
153
- // or
154
- // Step detection is locked by stepDetectionLocker
155
- }
156
-
157
- this.relativePosition = event.data.slice(0);
158
- }
159
-
160
- /**
161
- * Calculate AbsolutePosition from RelativePosition event
162
- * @param {UserPosition} previousPosition
163
- * @param {ProviderEvent} event
164
- */
165
- calculateNewPosition(previousPosition, event) {
166
-
167
- const offsetPosition = Vector3.subtract(event.data, this.relativePosition);
168
-
169
- const dist = Math.sqrt(offsetPosition[0] ** 2 + offsetPosition[2] ** 2);
170
- const bearing = Math.atan2(offsetPosition[0], -offsetPosition[2]);
171
-
172
- /**
173
- * First, compute new position without map-matching
174
- */
175
- const newPositionWithoutMM = previousPosition.clone();
176
- newPositionWithoutMM.move(dist, bearing, offsetPosition[1]);
177
- newPositionWithoutMM.bearing = bearing;
178
- newPositionWithoutMM.time = event.timestamp;
179
- if (isNumber(newPositionWithoutMM.accuracy) && isNumber(this.attitude.accuracy)) {
180
- // A bad accuracy from PDR is due to three things:
181
- // - Attitude accuracy
182
- // - Misalignement (device heading != walking direction)
183
- // - Step detection false positives / false negatives
184
- // Following formula only use attitude accuracy with cone formula
185
- newPositionWithoutMM.accuracy += (dist / 2) * Math.sin(this.attitude.accuracy / 2);
186
- }
187
-
188
- if (!this.options.useMapMatching || !this.mapMatching.network) {
189
- /**
190
- * If mapMatching is not used or not set, raw position is returned
191
- */
192
- return newPositionWithoutMM;
193
- }
194
-
195
- /**
196
- * Secondly, find map-matching projection
197
- */
198
- const projection = this.mapMatching.getProjection(newPositionWithoutMM, true, true);
199
- if (!projection || !projection.projection) {
200
- /**
201
- * If no projection has been found, returns the position without map-matching
202
- */
203
- return newPositionWithoutMM;
204
- }
205
-
206
- const projectedPosition = newPositionWithoutMM;
207
- projectedPosition.level = projection.projection.level;
208
-
209
- if (projection.distanceFromNearestElement < dist) {
210
- /**
211
- * If projection is not so far from network, projected position is returned
212
- */
213
- projectedPosition.lat = projection.projection.lat;
214
- projectedPosition.lng = projection.projection.lng;
215
- return projectedPosition;
216
- }
217
-
218
- /**
219
- * If projected position is far from network, we do not project calculated position directly.
220
- * This allows to adapt map-matching to not stick corridor directly.
221
- * /!\ This smoothed position is different from the one of Smoother
222
- */
223
- const smoothedPosition = projectedPosition;
224
- smoothedPosition.lat = previousPosition.lat;
225
- smoothedPosition.lng = previousPosition.lng;
226
-
227
- const smoothedDistance = projection.distanceFromNearestElement * this.constructor.MM_CONV_SPEED;
228
- const smoothedBearing = previousPosition.bearingTo(projection.projection);
229
- smoothedPosition.move(smoothedDistance, smoothedBearing);
230
-
231
- return smoothedPosition;
232
- }
233
-
234
-
235
- /**
236
- * Itinerary and PDR Locker
237
- */
238
-
239
- /**
240
- * @param {Itinerary} itinerary
241
- */
242
- onItineraryChanged = itinerary => {
243
-
244
- if (!itinerary || itinerary.edges.length === 0) {
245
- this.stepDetectionLocker.unlock();
246
- }
247
-
248
- const edgeAt = itinerary.getEdgeAt(this.constructor.LO_SEGMENT_SIZE);
249
- if (edgeAt) {
250
- this.stepDetectionLocker.lock(edgeAt.bearing);
251
- } else {
252
- this.stepDetectionLocker.lock(itinerary.edges[0].bearing);
253
- }
254
- return;
255
- }
256
- }
257
-
258
- export default AbsolutePdrProvider;
@@ -1,230 +0,0 @@
1
- /* eslint-disable max-statements */
2
- import {
3
- Attitude, UserPosition
4
- } from '@wemap/geo';
5
-
6
- import {
7
- Quaternion, Vector3
8
- } from '@wemap/maths';
9
-
10
-
11
- import Availability from '../../events/Availability';
12
- import EventType from '../../events/EventType';
13
- import ArCoreProvider from '../position/relative/ArCoreProvider';
14
- import ImuProvider from '../others/ImuProvider';
15
- import MapMatchingProvider from './MapMatchingProvider';
16
- import PdrProvider from './pdr/PdrProvider';
17
-
18
- const MM_ARCORE_DIST = 5;
19
-
20
-
21
- class ArCoreAbsoluteProvider extends MapMatchingProvider {
22
-
23
- /**
24
- * @override
25
- */
26
- constructor(onEvent, onError, options) {
27
- super(onEvent, onError, options);
28
-
29
- this.arCoreProvider = new ArCoreProvider(
30
- e => this.onArCoreEvent(e),
31
- onError,
32
- options);
33
-
34
- this.imuProvider = new ImuProvider(
35
- this.onImuEvent,
36
- onError,
37
- Object.assign({}, options || {}, { require: [EventType.AngularRate] })
38
- );
39
-
40
- if (this.options.useMapMatching) {
41
- this.enableMapMatching();
42
- }
43
- }
44
-
45
- /**
46
- * @override
47
- */
48
- static get displayName() {
49
- return 'ArCore absolute provider';
50
- }
51
-
52
- /**
53
- * @override
54
- */
55
- static get eventsType() {
56
- return [EventType.AbsoluteAttitude, EventType.AbsolutePosition];
57
- }
58
-
59
- /**
60
- * Return the list of required providers
61
- */
62
- static get _availability() {
63
- return Availability.union(
64
- ArCoreProvider.availability,
65
- ImuProvider.availability
66
- );
67
- }
68
-
69
- /**
70
- * @override
71
- */
72
- _start() {
73
- this.arCoreProvider.start();
74
- this.imuProvider.start();
75
- }
76
-
77
- /**
78
- * @override
79
- */
80
- _stop() {
81
- this.arCoreProvider.stop();
82
- this.imuProvider.stop();
83
- }
84
-
85
- onArCoreEvent = events => {
86
-
87
- const eventsForNotification = [];
88
-
89
- events.forEach(event => {
90
- if (event.dataType === EventType.RelativeAttitude) {
91
-
92
- // const previousAttitude = this.relativeAttitude;
93
- this.relativeAttitude = event.data;
94
-
95
- /**
96
- * The two following blocks cannot be called in the same call because this.waitingForceHeading
97
- * if exists, is called before the first this.relativeAttitude assigment. So, this.waitingForceHeading
98
- * and previousAttitude should not be defined in the same time.
99
- */
100
-
101
- if (typeof this.waitingForceHeading !== 'undefined') {
102
- /**
103
- * waitingForceHeading is set by setHeading() if this.relativeAttitude does not exist
104
- * At this moment, this.relativeAttitude is defined, so we can call setHeading again
105
- */
106
- this.setHeading(this.waitingForceHeading);
107
- delete this.waitingForceHeading;
108
-
109
- }
110
-
111
- // if (previousAttitude && this.absoluteAttitude) {
112
- // /**
113
- // * Sometimes ArCore has "orientation jumps" around z-axis.
114
- // * Here we try to detect and remove them.
115
- // */
116
- // const dist = Quaternion.distance(event.data.quaternion, previousAttitude.quaternion);
117
- // if (typeof this.angularRate !== 'undefined') {
118
- // const velocity = Vector3.norm(this.angularRate);
119
- // if (dist > deg2rad(10) && velocity < deg2rad(4)) {
120
- // this.setHeading(this.absoluteAttitude.heading);
121
- // }
122
- // }
123
- // }
124
-
125
- if (this.offsetQuat) {
126
- const absoluteQuaternion = Quaternion.multiply(this.offsetQuat, this.relativeAttitude.quaternion);
127
- this.absoluteAttitude = new Attitude(absoluteQuaternion);
128
- eventsForNotification.push(this.createEvent(EventType.AbsoluteAttitude, this.absoluteAttitude, event.timestamp));
129
- }
130
- }
131
-
132
- if (event.dataType === EventType.RelativePosition) {
133
-
134
- if (this.oldRelativePos && this.offsetAngle
135
- && !ArCoreAbsoluteProvider.positionEquals(this.oldRelativePos, event.data)) {
136
-
137
- const diffPos = Vector3.subtract(event.data, this.oldRelativePos);
138
- const dist = Math.sqrt(diffPos[0] ** 2 + diffPos[2] ** 2);
139
- const bearing = Math.atan2(diffPos[0], -diffPos[2]) - this.offsetAngle;
140
- this.position = this.position.destinationPoint(dist, bearing, diffPos[1]);
141
-
142
- if (this.absoluteAttitude) {
143
- this.position.bearing = this.absoluteAttitude.heading;
144
- this.updatePositionWithMapMatching();
145
- }
146
-
147
- eventsForNotification.push(this.createEvent(EventType.AbsolutePosition, this.position, event.timestamp));
148
- }
149
-
150
- this.oldRelativePos = event.data;
151
- }
152
-
153
- if (event.dataType === EventType.Barcode) {
154
- eventsForNotification.push(event);
155
- }
156
-
157
- if (eventsForNotification.length !== 0) {
158
- this.notify(...eventsForNotification);
159
- }
160
- });
161
- }
162
-
163
- static positionEquals(pos1, pos2) {
164
- return pos1[0] === pos2[0] && pos1[1] === pos2[1] && pos1[2] === pos2[2];
165
- }
166
-
167
- onImuEvent = events => {
168
- this.angularRate = events[0].data;
169
- }
170
-
171
- setHeading(heading) {
172
-
173
- if (!this.relativeAttitude) {
174
- this.waitingForceHeading = heading;
175
- return;
176
- }
177
-
178
- this.offsetAngle = this.relativeAttitude.heading - heading;
179
- this.offsetQuat = Quaternion.fromAxisAngle([0, 0, 1], this.offsetAngle);
180
- }
181
-
182
- setPosition(position) {
183
- this.position = UserPosition.fromCoordinates(position);
184
- this.notify(this.createEvent(EventType.AbsolutePosition, this.position));
185
- }
186
-
187
- /**
188
- * @override
189
- */
190
- static get useCameraNatively() {
191
- return true;
192
- }
193
-
194
-
195
- /**
196
- * MapMatching
197
- */
198
-
199
- enableMapMatching(network, maxDistance, maxAngleBearing) {
200
- super.enableMapMatching(
201
- network,
202
- maxDistance || MM_ARCORE_DIST,
203
- maxAngleBearing || PdrProvider.MM_PDR_ANGLE
204
- );
205
- }
206
-
207
- updatePositionWithMapMatching() {
208
- if (!this.mapMatching) {
209
- return;
210
- }
211
- const projection = this.mapMatching.getProjection(this.position, true, true);
212
- if (projection) {
213
- if (projection.distanceFromNearestElement > 1) {
214
- this.position.lat = projection.projection.lat;
215
- this.position.lng = projection.projection.lng;
216
- }
217
- this.position.level = projection.projection.level;
218
- }
219
- }
220
-
221
- enableBarcodeScanner() {
222
- this.arCoreProvider.enableBarcodeScanner();
223
- }
224
-
225
- disableBarcodeScanner() {
226
- this.arCoreProvider.disableBarcodeScanner();
227
- }
228
- }
229
-
230
- export default ArCoreAbsoluteProvider;
@@ -1,217 +0,0 @@
1
- /* eslint max-statements: ["error", 40]*/
2
-
3
- import { UserPosition } from '@wemap/geo';
4
- import { deg2rad } from '@wemap/maths';
5
-
6
- import MapMatchingProvider from './MapMatchingProvider';
7
- import PdrProvider from './pdr/PdrProvider';
8
- import GnssWifiProvider from '../position/GnssWifiProvider';
9
- import Availability from '../../events/Availability';
10
- import EventType from '../../events/EventType';
11
- import AbsoluteAttitudeProvider from '../attitude/absolute/AbsoluteAttitudeProvider';
12
- import Constants from '../Constants';
13
-
14
- const GPF_ACCURACY = 25;
15
- const GPF_DISTANCE = 25;
16
-
17
- const MM_GNSS_DIST = 20;
18
- const MM_GNSS_ANGLE = deg2rad(20);
19
-
20
- class GnssWifiPdrProvider extends MapMatchingProvider {
21
-
22
- /**
23
- * @override
24
- */
25
- constructor(onEvent, onError, options) {
26
- super(onEvent, onError, options);
27
-
28
- this.pdrProvider = new PdrProvider(e => this.onPdrEvent(e), onError, options);
29
- this.gnssWifiProvider = new GnssWifiProvider(e => this.onGnssWifiEvent(e), onError, options);
30
- this.absoluteAttitudeProvider = new AbsoluteAttitudeProvider(
31
- e => this.onAbsoluteAttitudeEvent(e),
32
- onError,
33
- options
34
- );
35
-
36
- this.gpsLastUpdate = 0;
37
- this.isFirstGnssUpdate = true;
38
- this.isFirstAttitudeUpdate = true;
39
-
40
- if (this.options.useMapMatching) {
41
- this.enableMapMatching();
42
- }
43
- }
44
-
45
- /**
46
- * @override
47
- */
48
- static get displayName() {
49
- return 'GnssWifiPdr';
50
- }
51
-
52
- /**
53
- * @override
54
- */
55
- static get eventsType() {
56
- return [EventType.AbsoluteAttitude, EventType.AbsolutePosition];
57
- }
58
-
59
- /**
60
- * @override
61
- */
62
- static get _availability() {
63
- return Availability.merge(
64
- PdrProvider.availability,
65
- GnssWifiProvider.availability,
66
- AbsoluteAttitudeProvider.availability
67
- );
68
- }
69
-
70
-
71
- /**
72
- * @override
73
- */
74
- _start() {
75
- this.pdrProvider.start();
76
- this.gnssWifiProvider.start();
77
- this.absoluteAttitudeProvider.start();
78
- }
79
-
80
- /**
81
- * @override
82
- */
83
- stop() {
84
- this.pdrProvider.stop();
85
- this.gnssWifiProvider.stop();
86
- this.absoluteAttitudeProvider.stop();
87
- }
88
-
89
- /**
90
- * @private
91
- */
92
- onPdrEvent(pdrEvent) {
93
- pdrEvent.forEach(event => {
94
- if (event.dataType === EventType.AbsolutePosition) {
95
- this.position = event.data;
96
- } else if (event.dataType === EventType.AbsoluteAttitude) {
97
- this.attitude = event.data;
98
- }
99
- });
100
- this.notify(...pdrEvent);
101
- }
102
-
103
- /**
104
- * @private
105
- */
106
- onGnssWifiEvent(events) {
107
-
108
- const gnssWifiEvent = events[0];
109
- const position = gnssWifiEvent.data;
110
-
111
- // This should be called to update True North / Magnetic North declination
112
- this.absoluteAttitudeProvider.setPosition(position);
113
-
114
- if (position.accuracy > GPF_ACCURACY) {
115
- return;
116
- }
117
-
118
- this.gnssPosition = position.clone();
119
- this.gnssPosition.alt = Constants.DEFAULT_ALTITUDE;
120
-
121
- if (!this.position || this.position
122
- && this.position.distanceTo(this.gnssPosition) > GPF_DISTANCE) {
123
-
124
- if (!this.mapMatching || !this.attitude) {
125
- this.pdrProvider.setPosition(this.gnssPosition);
126
- } else {
127
-
128
- this.gnssPosition.bearing = this.attitude.heading;
129
- const projection = this.mapMatching.getProjection(this.gnssPosition, true, true);
130
-
131
- if (projection && projection.projection) {
132
-
133
- // Create a new position from projection and new GNSS position.
134
- this.gnssPosition.lat = projection.projection.lat;
135
- this.gnssPosition.lng = projection.projection.lng;
136
-
137
- // // If nearest element is an edge, use its orientation to set heading
138
- // if (projection.nearestElement instanceof Edge) {
139
- // const edgeBearing = projection.nearestElement.bearing;
140
- // const diff1 = MathUtils.diffAngle(MathUtils.deg2rad(this.gnssPosition.bearing), edgeBearing);
141
- // const diff2 = MathUtils.diffAngle(MathUtils.deg2rad(this.gnssPosition.bearing), edgeBearing + Math.PI);
142
- // this.pdrProvider.setHeading(diff1 < diff2 ? edgeBearing : edgeBearing + Math.PI);
143
- // }
144
-
145
- if (this.lastAttitude) {
146
- this.pdrProvider.setHeading(this.lastAttitude.heading);
147
- }
148
-
149
- }
150
- this.pdrProvider.setPosition(this.gnssPosition);
151
- }
152
- }
153
-
154
- }
155
-
156
- onAbsoluteAttitudeEvent(events) {
157
-
158
- const attitude = events[0].data;
159
-
160
- if (this.isFirstAttitudeUpdate) {
161
- this.pdrProvider.setHeading(attitude.heading);
162
- this.isFirstAttitudeUpdate = false;
163
- }
164
-
165
- this.lastAttitude = attitude;
166
- }
167
-
168
- /**
169
- * MapMatching
170
- */
171
-
172
- enableMapMatching(network = null, maxDistance = MM_GNSS_DIST, maxAngleBearing = MM_GNSS_ANGLE) {
173
- this.pdrProvider.enableMapMatching(network, maxDistance, maxAngleBearing);
174
- super.enableMapMatching(network, maxDistance, maxAngleBearing);
175
- }
176
-
177
-
178
- setNetwork(network) {
179
- this.pdrProvider.setNetwork(network);
180
- super.setNetwork(network);
181
- }
182
-
183
- /**
184
- * Itinerary
185
- */
186
-
187
- setItinerary(itinerary) {
188
-
189
- const isFirstItinerary = !this.itinerary;
190
-
191
- super.setItinerary(itinerary);
192
-
193
- if (isFirstItinerary && itinerary.length > 0) {
194
-
195
- // When the first itinerary is received, first or second node (depending on MM_GNSS_DIST) is used as a starting point. No map-matching is needed here as router already provide the projection in the itinerary (node2 is node1 projection on OSRM network).
196
-
197
- if (!this.gnssPosition
198
- || itinerary.length < 2
199
- || !itinerary.points[0].equalsTo(this.gnssPosition)) {
200
- console.warn('Itinerary has not been calculated from GnssWifiPdrProvider and these is not recommanded');
201
- }
202
-
203
- const startEdge = itinerary.getEdgeAt(MM_GNSS_DIST);
204
- if (!startEdge) {
205
- return;
206
- }
207
- const startPoint = UserPosition.fromCoordinates(startEdge.node1.coords);
208
- startPoint.alt = Constants.DEFAULT_ALTITUDE;
209
- this.pdrProvider.setPosition(startPoint);
210
- this.pdrProvider.setStepDetectionLockerOrientation(startEdge.bearing);
211
- }
212
-
213
- }
214
-
215
- }
216
-
217
- export default GnssWifiPdrProvider;