@wemap/providers 3.1.3 → 3.1.5
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/Common.css +172 -0
- package/debug/MainComponent.jsx +51 -0
- package/debug/components/AbsolutePositionComponent.jsx +1 -1
- package/debug/components/GnssWifiComponent.jsx +1 -1
- package/debug/components/StartStopComponent.jsx +5 -3
- package/debug/components/Utils.js +4 -2
- package/debug/details/DetailsAttitudeComponent.jsx +128 -0
- package/debug/details/DetailsComponent.jsx +32 -0
- package/debug/details/DetailsPositionComponent.jsx +135 -0
- package/debug/details/ItineraryComponent.jsx +323 -0
- package/debug/index.js +28 -0
- package/debug/map/MapComponent.jsx +77 -0
- package/debug/map/MapHandler.js +53 -0
- package/debug/map/MapboxHelper.js +50 -0
- package/debug/map/helpers/ItineraryMapHandler.js +284 -0
- package/debug/map/helpers/MapClickHandler.js +119 -0
- package/debug/map/helpers/UserOnMapHandler.js +470 -0
- package/debug/stores/ItineraryStore.js +223 -0
- package/dist/assets/indoor-maps/bureaux-wemap-montpellier.geojson +7444 -0
- package/dist/{pose.html → index.html} +4 -1
- package/dist/js/providers-components.js +353 -209
- package/package.json +9 -7
- package/src/ProvidersInterface.js +5 -4
- package/src/providers/FakeProvider.spec.js +2 -7
- package/src/providers/MetaProvider.js +3 -1
- package/src/providers/Provider.js +19 -14
- package/src/providers/Provider.spec.js +21 -20
- package/src/providers/attitude/absolute/AbsoluteAttitudeFromBrowserProvider.js +2 -3
- package/src/providers/attitude/absolute/AbsoluteAttitudeProvider.js +3 -3
- package/src/providers/attitude/relative/RelativeAttitudeFromBrowserProvider.js +2 -3
- package/src/providers/attitude/relative/RelativeAttitudeFromEkfProvider.js +3 -4
- package/src/providers/attitude/relative/RelativeAttitudeFromInertialProvider.js +18 -12
- package/src/providers/imu/ImuProvider.js +2 -3
- package/src/providers/inclination/InclinationProvider.js +4 -3
- package/src/providers/position/absolute/AbsolutePositionFromRelProvider.js +1 -1
- package/src/providers/position/absolute/AbsolutePositionProvider.js +41 -26
- package/src/providers/position/absolute/GnssWifiProvider.js +2 -3
- package/src/providers/position/relative/ArCoreProvider.js +3 -4
- package/src/providers/position/relative/GeoRelativePositionFromArCoreProvider.js +2 -1
- package/src/providers/position/relative/GeoRelativePositionProvider.js +23 -20
- package/src/providers/position/relative/PdrProvider.js +4 -4
- package/src/providers/steps/StepDetectionProvider.js +2 -3
- package/src/smoothers/PositionSmoother.js +10 -2
- package/webpack/webpack.common.js +5 -5
- package/webpack/webpack.dev.js +7 -1
- package/debug/components/Common.css +0 -27
- package/debug/components/MapComponent.jsx +0 -366
- package/debug/components/PoseComponent.jsx +0 -169
- package/debug/components/index.js +0 -28
- package/src/events/Availability.js +0 -44
- package/src/providers/legacy/AbsolutePdrProvider.js +0 -258
- package/src/providers/legacy/ArCoreAbsoluteProvider.js +0 -230
- package/src/providers/legacy/GnssWifiPdrProvider.js +0 -217
- package/src/providers/legacy/MapMatchingProvider.js +0 -65
- package/src/providers/legacy/PdrProvider.old.js +0 -300
- package/src/providers/legacy/PoseProvider.js +0 -68
- package/src/providers/legacy/helpers/Smoother.js +0 -92
- package/src/providers/legacy/helpers/Smoother.spec.js +0 -426
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
PositionSmoother, ProvidersInterface, EventType
|
|
5
|
-
} from '../..';
|
|
6
|
-
|
|
7
|
-
import Utils from './Utils';
|
|
8
|
-
import MapComponent from './MapComponent';
|
|
9
|
-
import NavigationConfig from './NavigationConfig';
|
|
10
|
-
|
|
11
|
-
import './Common.css';
|
|
12
|
-
import StartStopComponent from './StartStopComponent';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class PoseComponent extends React.Component {
|
|
16
|
-
|
|
17
|
-
started = false;
|
|
18
|
-
|
|
19
|
-
constructor(props, context) {
|
|
20
|
-
super(props, context);
|
|
21
|
-
this.state = {
|
|
22
|
-
position: null,
|
|
23
|
-
attitude: null
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
this.smoother = new PositionSmoother(position => {
|
|
27
|
-
if (this.map && this.started) {
|
|
28
|
-
this.map.updatePosition(position);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
ProvidersInterface.logger = true;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
componentWillUnmount() {
|
|
36
|
-
this.onStop();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
onStart = () => {
|
|
40
|
-
this.started = true;
|
|
41
|
-
this.onAttitudeEvent(ProvidersInterface.getLastKnown(EventType.AbsoluteAttitude));
|
|
42
|
-
this.attitudeProviderId = ProvidersInterface.addEventListener(
|
|
43
|
-
EventType.AbsoluteAttitude,
|
|
44
|
-
this.onAttitudeEvent,
|
|
45
|
-
this.onAttitudeError
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
this.onPositionEvent(ProvidersInterface.getLastKnown(EventType.AbsolutePosition));
|
|
49
|
-
this.positionProviderId = ProvidersInterface.addEventListener(
|
|
50
|
-
EventType.AbsolutePosition,
|
|
51
|
-
this.onPositionEvent,
|
|
52
|
-
this.onPositionError
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
onStop = () => {
|
|
57
|
-
this.started = false;
|
|
58
|
-
ProvidersInterface.removeEventListener(this.attitudeProviderId);
|
|
59
|
-
ProvidersInterface.removeEventListener(this.positionProviderId);
|
|
60
|
-
this.map.updatePosition(null);
|
|
61
|
-
this.map.updateAttitude(null);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
onPositionEvent = position => {
|
|
65
|
-
if (!position) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
this.setState({ position });
|
|
69
|
-
this.smoother.feed(position);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
onPositionError = error => {
|
|
73
|
-
this.setState({ position: error });
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
onAttitudeEvent = attitude => {
|
|
77
|
-
if (!attitude) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
this.setState({ attitude });
|
|
81
|
-
if (this.map && this.started) {
|
|
82
|
-
this.map.updateAttitude(attitude);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
onAttitudeError = error => {
|
|
87
|
-
this.setState({ attitude: error });
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
handleHeadingButton() {
|
|
91
|
-
ProvidersInterface.feed(EventType.AbsoluteHeading, NavigationConfig.INITIAL_HEADING);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
handlePosButton() {
|
|
95
|
-
ProvidersInterface.feed(EventType.AbsolutePosition, NavigationConfig.INITIAL_POSITION);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
handleItinerary() {
|
|
99
|
-
const itinerary = NavigationConfig.ITINERARY;
|
|
100
|
-
ProvidersInterface.feed(EventType.Network, itinerary);
|
|
101
|
-
this.setState({ itinerary });
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
render() {
|
|
106
|
-
|
|
107
|
-
const errored = this.state.attitude instanceof Error
|
|
108
|
-
&& this.state.position instanceof Error;
|
|
109
|
-
|
|
110
|
-
return (
|
|
111
|
-
<div style={{
|
|
112
|
-
display: 'flex',
|
|
113
|
-
flexFlow: 'column',
|
|
114
|
-
height: 'calc(100% - 16px)',
|
|
115
|
-
padding: '8px'
|
|
116
|
-
}}>
|
|
117
|
-
|
|
118
|
-
<StartStopComponent
|
|
119
|
-
onStart={this.onStart}
|
|
120
|
-
onStop={this.onStop}
|
|
121
|
-
errored={errored}
|
|
122
|
-
/>
|
|
123
|
-
|
|
124
|
-
<div style={{ marginTop: '10px' }}>
|
|
125
|
-
<input type="button"
|
|
126
|
-
onClick={() => this.handlePosButton()}
|
|
127
|
-
value="Send Wemap position" />
|
|
128
|
-
<input type="button"
|
|
129
|
-
style={{ marginLeft: '10px' }}
|
|
130
|
-
onClick={() => this.handleHeadingButton()}
|
|
131
|
-
value="Send heading" />
|
|
132
|
-
<input type="button"
|
|
133
|
-
value="Add itinerary"
|
|
134
|
-
style={{ marginLeft: '10px' }}
|
|
135
|
-
onClick={() => this.handleItinerary()} />
|
|
136
|
-
</div>
|
|
137
|
-
|
|
138
|
-
<div style={{
|
|
139
|
-
display: 'flex',
|
|
140
|
-
flexFlow: 'row'
|
|
141
|
-
}}>
|
|
142
|
-
<div style={{ width: '50%' }}>
|
|
143
|
-
<div className="title">Position</div>
|
|
144
|
-
{Utils.renderPositionEvent(this.state.position)}
|
|
145
|
-
</div>
|
|
146
|
-
<div style={{ width: '50%' }}>
|
|
147
|
-
<div className="title">Attitude</div>
|
|
148
|
-
{Utils.renderAttitudeEvent(this.state.attitude)}
|
|
149
|
-
</div>
|
|
150
|
-
</div>
|
|
151
|
-
|
|
152
|
-
<div className="title">Map</div>
|
|
153
|
-
<div style={{
|
|
154
|
-
flexGrow: 1,
|
|
155
|
-
height: '0px',
|
|
156
|
-
minHeight: '300px'
|
|
157
|
-
}}>
|
|
158
|
-
<MapComponent
|
|
159
|
-
ref={map => (this.map = map)}
|
|
160
|
-
network={this.state.itinerary}
|
|
161
|
-
/>
|
|
162
|
-
</div>
|
|
163
|
-
</div >
|
|
164
|
-
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export default PoseComponent;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom';
|
|
3
|
-
|
|
4
|
-
import AbsoluteAttitudeComponent from './AbsoluteAttitudeComponent';
|
|
5
|
-
import AbsolutePositionComponent from './AbsolutePositionComponent';
|
|
6
|
-
import GnssWifiComponent from './GnssWifiComponent';
|
|
7
|
-
import ImuComponent from './ImuComponent';
|
|
8
|
-
import InclinationComponent from './InclinationComponent';
|
|
9
|
-
import PoseComponent from './PoseComponent';
|
|
10
|
-
import RelativeAttitudeComponent from './RelativeAttitudeComponent';
|
|
11
|
-
import StepDetectionComponent from './StepDetectionComponent';
|
|
12
|
-
|
|
13
|
-
const createReactElement = (component, container) => ReactDOM.render(
|
|
14
|
-
React.createElement(component, {}, null),
|
|
15
|
-
container
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
export {
|
|
19
|
-
AbsoluteAttitudeComponent,
|
|
20
|
-
AbsolutePositionComponent,
|
|
21
|
-
ImuComponent,
|
|
22
|
-
InclinationComponent,
|
|
23
|
-
GnssWifiComponent,
|
|
24
|
-
PoseComponent,
|
|
25
|
-
RelativeAttitudeComponent,
|
|
26
|
-
StepDetectionComponent,
|
|
27
|
-
createReactElement
|
|
28
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
class Availability {
|
|
2
|
-
|
|
3
|
-
isSupported = false;
|
|
4
|
-
reason = null;
|
|
5
|
-
|
|
6
|
-
static no(reason) {
|
|
7
|
-
const availability = new Availability();
|
|
8
|
-
availability.reason = reason;
|
|
9
|
-
availability.isSupported = false;
|
|
10
|
-
return availability;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
static yes() {
|
|
14
|
-
const availability = new Availability();
|
|
15
|
-
availability.isSupported = true;
|
|
16
|
-
return availability;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
static merge(...availabilities) {
|
|
20
|
-
for (let i = 0; i < availabilities.length; i++) {
|
|
21
|
-
const availability = availabilities[i];
|
|
22
|
-
if (!availability.isSupported) {
|
|
23
|
-
return availability;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return Availability.yes();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
static union(...availabilities) {
|
|
30
|
-
if (availabilities.length === 0) {
|
|
31
|
-
return Availability.yes();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
for (let i = 0; i < availabilities.length; i++) {
|
|
35
|
-
const availability = availabilities[i];
|
|
36
|
-
if (availability.isSupported) {
|
|
37
|
-
return availability;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return availabilities[0];
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export default Availability;
|
|
@@ -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;
|