@wemap/positioning 2.3.11 → 2.4.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/package.json +5 -4
- package/src/components/AbsoluteAttitudeComponent.jsx +1 -4
- package/src/components/ArCoreAbsoluteComponent.jsx +52 -63
- package/src/components/GnssWifiPdrComponent.jsx +46 -61
- package/src/components/MapComponent.jsx +5 -4
- package/src/components/PdrComponent.jsx +44 -63
- package/src/components/PositioningInclinationComponent.jsx +9 -3
- package/src/components/PositioningPoseComponent.jsx +91 -106
- package/src/components/Utils.js +20 -0
- package/src/providers/ProvidersLogger.js +1 -1
- package/src/providers/others/MapMatchingProvider.js +3 -3
- package/src/providers/pose/GnssWifiPdrProvider.js +2 -2
- package/src/providers/pose/pdr/PdrProvider.js +5 -4
package/package.json
CHANGED
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
"Guillaume Pannetier <guillaume.pannetier@getwemap.com>"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@wemap/geo": "^0.1
|
|
12
|
-
"@wemap/logger": "^0.1.
|
|
13
|
-
"@wemap/maths": "^0.
|
|
11
|
+
"@wemap/geo": "^0.2.1",
|
|
12
|
+
"@wemap/logger": "^0.1.5",
|
|
13
|
+
"@wemap/maths": "^0.2.0",
|
|
14
|
+
"@wemap/osm": "^0.1.1",
|
|
14
15
|
"@wemap/utils": "^0.1.2",
|
|
15
16
|
"file-saver": "^2.0.2",
|
|
16
17
|
"geomagnetism": "^0.1.0",
|
|
@@ -81,5 +82,5 @@
|
|
|
81
82
|
"lint": "eslint --ext .js,.jsx --quiet src",
|
|
82
83
|
"test": "mocha -r esm \"src/**/*.spec.js\""
|
|
83
84
|
},
|
|
84
|
-
"version": "2.
|
|
85
|
+
"version": "2.4.0"
|
|
85
86
|
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import { WGS84 } from '@wemap/geo';
|
|
4
|
-
|
|
5
3
|
import AbsoluteAttitudeProvider from '../providers/attitude/AbsoluteAttitudeProvider';
|
|
6
4
|
import Utils from './Utils';
|
|
7
5
|
import EventType from '../events/EventType';
|
|
8
6
|
|
|
9
|
-
const userPosition = new WGS84(43.609275, 3.884236);
|
|
10
7
|
|
|
11
8
|
class AbsoluteAttitudeComponent extends React.Component {
|
|
12
9
|
|
|
@@ -20,7 +17,7 @@ class AbsoluteAttitudeComponent extends React.Component {
|
|
|
20
17
|
};
|
|
21
18
|
|
|
22
19
|
this.absoluteAttitudeProvider = new AbsoluteAttitudeProvider(this.onEvent, this.onError);
|
|
23
|
-
this.absoluteAttitudeProvider.setPosition(
|
|
20
|
+
this.absoluteAttitudeProvider.setPosition(Utils.INITIAL_POSITION);
|
|
24
21
|
}
|
|
25
22
|
|
|
26
23
|
componentDidMount() {
|
|
@@ -1,27 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import isEmpty from 'lodash.isempty';
|
|
3
3
|
|
|
4
|
+
import { deg2rad } from '@wemap/maths';
|
|
5
|
+
|
|
4
6
|
import EventType from '../events/EventType';
|
|
5
7
|
import Utils from './Utils';
|
|
6
8
|
import ArCoreAbsoluteProvider from '../providers/pose/ArCoreAbsoluteProvider';
|
|
7
|
-
import { deg2rad } from '@wemap/maths';
|
|
8
|
-
import {
|
|
9
|
-
WGS84UserPosition, Itinerary
|
|
10
|
-
} from '@wemap/geo';
|
|
11
9
|
import MapComponent from './MapComponent';
|
|
12
10
|
|
|
13
|
-
const INITIAL_POSITION = new WGS84UserPosition(43.6091955, 3.8841255);
|
|
14
|
-
const INITIAL_HEADING = 191.9;
|
|
15
|
-
const ITINERARY = Itinerary.fromPoints([
|
|
16
|
-
[INITIAL_POSITION.lat, INITIAL_POSITION.lng],
|
|
17
|
-
[43.6091883, 3.8841242],
|
|
18
|
-
[43.6091709, 3.8842382],
|
|
19
|
-
[43.6091288, 3.884226],
|
|
20
|
-
[43.6091461, 3.884112]
|
|
21
|
-
], false);
|
|
22
11
|
|
|
23
12
|
class ArCoreAbsoluteComponent extends React.Component {
|
|
24
|
-
|
|
25
13
|
constructor(props, context) {
|
|
26
14
|
super(props, context);
|
|
27
15
|
this.state = {
|
|
@@ -29,10 +17,12 @@ class ArCoreAbsoluteComponent extends React.Component {
|
|
|
29
17
|
attitude: null
|
|
30
18
|
};
|
|
31
19
|
|
|
32
|
-
this.arCoreAbsoluteProvider = new ArCoreAbsoluteProvider(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
20
|
+
this.arCoreAbsoluteProvider = new ArCoreAbsoluteProvider(
|
|
21
|
+
this.onEvent,
|
|
22
|
+
this.onError
|
|
23
|
+
);
|
|
24
|
+
this.arCoreAbsoluteProvider.setPosition(Utils.INITIAL_POSITION);
|
|
25
|
+
this.arCoreAbsoluteProvider.setHeading(deg2rad(Utils.INITIAL_HEADING));
|
|
36
26
|
}
|
|
37
27
|
|
|
38
28
|
componentDidMount() {
|
|
@@ -43,51 +33,50 @@ class ArCoreAbsoluteComponent extends React.Component {
|
|
|
43
33
|
this.arCoreAbsoluteProvider.stop();
|
|
44
34
|
}
|
|
45
35
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
36
|
+
onEvent = events => {
|
|
37
|
+
const newState = {};
|
|
38
|
+
events.forEach(event => {
|
|
39
|
+
if (event.dataType === EventType.AbsolutePosition) {
|
|
40
|
+
newState.position = event.data;
|
|
41
|
+
} else if (event.dataType === EventType.AbsoluteAttitude) {
|
|
42
|
+
newState.attitude = event.data;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
if (!isEmpty(newState)) {
|
|
46
|
+
this.setState(newState);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (this.map) {
|
|
50
|
+
this.map.parseEvents(events);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
onError = error => {
|
|
55
|
+
this.setState({
|
|
56
|
+
position: error,
|
|
57
|
+
attitude: error
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
render() {
|
|
62
|
+
const attitudeRender = Utils.renderAttitude(this.state.attitude);
|
|
63
|
+
const positionRender = Utils.renderPosition(this.state.position);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<div>
|
|
67
|
+
<h3>Position</h3>
|
|
68
|
+
{positionRender}
|
|
69
|
+
<h3>Attitude</h3>
|
|
70
|
+
{attitudeRender}
|
|
71
|
+
<h3>Map</h3>
|
|
72
|
+
<MapComponent
|
|
73
|
+
ref={map => (this.map = map)}
|
|
74
|
+
defaultZoom={21}
|
|
75
|
+
network={Utils.ITINERARY}
|
|
76
|
+
/>
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
91
80
|
}
|
|
92
81
|
|
|
93
82
|
export default ArCoreAbsoluteComponent;
|
|
@@ -1,36 +1,24 @@
|
|
|
1
1
|
import isEmpty from 'lodash.isempty';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
Itinerary, WGS84UserPosition
|
|
6
|
-
} from '@wemap/geo';
|
|
7
|
-
|
|
8
4
|
import Utils from './Utils';
|
|
9
5
|
import EventType from '../events/EventType';
|
|
10
6
|
import GnssWifiPdrProvider from '../providers/pose/GnssWifiPdrProvider';
|
|
11
7
|
import MapComponent from './MapComponent';
|
|
12
8
|
|
|
13
|
-
const INITIAL_POSITION = new WGS84UserPosition(43.6091955, 3.8841255);
|
|
14
|
-
const ITINERARY = Itinerary.fromPoints([
|
|
15
|
-
[INITIAL_POSITION.lat, INITIAL_POSITION.lng],
|
|
16
|
-
[43.6091883, 3.8841242],
|
|
17
|
-
[43.6091709, 3.8842382],
|
|
18
|
-
[43.6091288, 3.884226],
|
|
19
|
-
[43.6091461, 3.884112]
|
|
20
|
-
], false);
|
|
21
|
-
|
|
22
9
|
class GnssWifiPdrComponent extends React.Component {
|
|
23
|
-
|
|
24
10
|
constructor(props, context) {
|
|
25
11
|
super(props, context);
|
|
26
12
|
this.state = { position: null };
|
|
27
13
|
|
|
28
|
-
this.gnssWifiPdrProvider = new GnssWifiPdrProvider(
|
|
14
|
+
this.gnssWifiPdrProvider = new GnssWifiPdrProvider(
|
|
15
|
+
this.onEvent,
|
|
16
|
+
this.onError
|
|
17
|
+
);
|
|
29
18
|
}
|
|
30
19
|
|
|
31
|
-
|
|
32
20
|
componentDidMount() {
|
|
33
|
-
this.gnssWifiPdrProvider.enableMapMatching(ITINERARY);
|
|
21
|
+
this.gnssWifiPdrProvider.enableMapMatching(Utils.ITINERARY);
|
|
34
22
|
this.gnssWifiPdrProvider.start();
|
|
35
23
|
}
|
|
36
24
|
|
|
@@ -38,50 +26,47 @@ class GnssWifiPdrComponent extends React.Component {
|
|
|
38
26
|
this.gnssWifiPdrProvider.stop();
|
|
39
27
|
}
|
|
40
28
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
);
|
|
84
|
-
}
|
|
29
|
+
onEvent = events => {
|
|
30
|
+
const newState = {};
|
|
31
|
+
events.forEach(event => {
|
|
32
|
+
if (event.dataType === EventType.AbsolutePosition) {
|
|
33
|
+
newState.position = event.data;
|
|
34
|
+
} else if (event.dataType === EventType.AbsoluteAttitude) {
|
|
35
|
+
newState.attitude = event.data;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
if (!isEmpty(newState)) {
|
|
39
|
+
this.setState(newState);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (this.map) {
|
|
43
|
+
this.map.parseEvents(events);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
onError = error => {
|
|
48
|
+
this.setState({
|
|
49
|
+
position: error,
|
|
50
|
+
attitude: error
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
render() {
|
|
55
|
+
const attitudeRender = Utils.renderAttitude(this.state.attitude);
|
|
56
|
+
const positionRender = Utils.renderPosition(this.state.position);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<div>
|
|
60
|
+
<h3>Position</h3>
|
|
61
|
+
{positionRender}
|
|
62
|
+
<h3>Attitude</h3>
|
|
63
|
+
{attitudeRender}
|
|
64
|
+
<h3>Map</h3>
|
|
65
|
+
<MapComponent ref={map => (this.map = map)}
|
|
66
|
+
network={Utils.ITINERARY} />
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
85
70
|
}
|
|
86
71
|
|
|
87
72
|
export default GnssWifiPdrComponent;
|
|
@@ -4,8 +4,9 @@ import 'mapbox-gl/dist/mapbox-gl.css';
|
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
-
|
|
7
|
+
Attitude, Network, WGS84
|
|
8
8
|
} from '@wemap/geo';
|
|
9
|
+
|
|
9
10
|
import EventType from '../events/EventType';
|
|
10
11
|
|
|
11
12
|
mapboxgl.accessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
|
|
@@ -209,11 +210,11 @@ class MapComponent extends React.Component {
|
|
|
209
210
|
}
|
|
210
211
|
};
|
|
211
212
|
|
|
212
|
-
for (let i = 0; i < network.length; i++) {
|
|
213
|
+
for (let i = 0; i < network.edges.length; i++) {
|
|
213
214
|
layer.source.data.geometry.coordinates.push(
|
|
214
215
|
[
|
|
215
|
-
[network.edges[i].node1.lng, network.edges[i].node1.lat],
|
|
216
|
-
[network.edges[i].node2.lng, network.edges[i].node2.lat]
|
|
216
|
+
[network.edges[i].node1.coords.lng, network.edges[i].node1.coords.lat],
|
|
217
|
+
[network.edges[i].node2.coords.lng, network.edges[i].node2.coords.lat]
|
|
217
218
|
]
|
|
218
219
|
);
|
|
219
220
|
}
|
|
@@ -1,39 +1,23 @@
|
|
|
1
1
|
import isEmpty from 'lodash.isempty';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
Itinerary, WGS84UserPosition
|
|
6
|
-
} from '@wemap/geo';
|
|
7
|
-
|
|
8
4
|
import Utils from './Utils';
|
|
9
5
|
import PdrProvider from '../providers/pose/pdr/PdrProvider';
|
|
10
6
|
import EventType from '../events/EventType';
|
|
11
7
|
import MapComponent from './MapComponent';
|
|
12
8
|
|
|
13
|
-
const INITIAL_POSITION = new WGS84UserPosition(43.6091955, 3.8841255);
|
|
14
|
-
const INITIAL_HEADING = 191.9;
|
|
15
|
-
const ITINERARY = Itinerary.fromPoints([
|
|
16
|
-
[INITIAL_POSITION.lat, INITIAL_POSITION.lng],
|
|
17
|
-
[43.6091883, 3.8841242],
|
|
18
|
-
[43.6091709, 3.8842382],
|
|
19
|
-
[43.6091288, 3.884226],
|
|
20
|
-
[43.6091461, 3.884112]
|
|
21
|
-
], false);
|
|
22
|
-
|
|
23
9
|
class PdrComponent extends React.Component {
|
|
24
|
-
|
|
25
10
|
constructor(props, context) {
|
|
26
11
|
super(props, context);
|
|
27
12
|
this.state = { position: null };
|
|
28
13
|
|
|
29
14
|
this.pdrProvider = new PdrProvider(this.onEvent, this.onError);
|
|
30
|
-
this.pdrProvider.enableMapMatching(ITINERARY);
|
|
15
|
+
this.pdrProvider.enableMapMatching(Utils.ITINERARY);
|
|
31
16
|
}
|
|
32
17
|
|
|
33
|
-
|
|
34
18
|
componentDidMount() {
|
|
35
|
-
this.pdrProvider.setPosition(INITIAL_POSITION);
|
|
36
|
-
this.pdrProvider.setHeading(INITIAL_HEADING);
|
|
19
|
+
this.pdrProvider.setPosition(Utils.INITIAL_POSITION);
|
|
20
|
+
this.pdrProvider.setHeading(Utils.INITIAL_HEADING);
|
|
37
21
|
this.pdrProvider.start();
|
|
38
22
|
}
|
|
39
23
|
|
|
@@ -41,50 +25,47 @@ class PdrComponent extends React.Component {
|
|
|
41
25
|
this.pdrProvider.stop();
|
|
42
26
|
}
|
|
43
27
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
);
|
|
87
|
-
}
|
|
28
|
+
onEvent = events => {
|
|
29
|
+
const newState = {};
|
|
30
|
+
events.forEach(event => {
|
|
31
|
+
if (event.dataType === EventType.AbsolutePosition) {
|
|
32
|
+
newState.position = event.data;
|
|
33
|
+
} else if (event.dataType === EventType.AbsoluteAttitude) {
|
|
34
|
+
newState.attitude = event.data;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
if (!isEmpty(newState)) {
|
|
38
|
+
this.setState(newState);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (this.map) {
|
|
42
|
+
this.map.parseEvents(events);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
onError = error => {
|
|
47
|
+
this.setState({
|
|
48
|
+
position: error,
|
|
49
|
+
attitude: error
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
render() {
|
|
54
|
+
const attitudeRender = Utils.renderAttitude(this.state.attitude);
|
|
55
|
+
const positionRender = Utils.renderPosition(this.state.position);
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<div>
|
|
59
|
+
<h3>Position</h3>
|
|
60
|
+
{positionRender}
|
|
61
|
+
<h3>Attitude</h3>
|
|
62
|
+
{attitudeRender}
|
|
63
|
+
<h3>Map</h3>
|
|
64
|
+
<MapComponent ref={map => (this.map = map)}
|
|
65
|
+
network={Utils.ITINERARY} />
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
88
69
|
}
|
|
89
70
|
|
|
90
71
|
export default PdrComponent;
|
|
@@ -21,11 +21,17 @@ class PositioningInclinationComponent extends React.Component {
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
start() {
|
|
24
|
-
|
|
24
|
+
const output = this.props.positioningHandler.start(
|
|
25
25
|
[EventType.Inclination],
|
|
26
26
|
this.onEvents,
|
|
27
27
|
this.onError
|
|
28
|
-
)
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
if (!output) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
this.id = output.id;
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
|
|
@@ -51,7 +57,7 @@ class PositioningInclinationComponent extends React.Component {
|
|
|
51
57
|
|
|
52
58
|
onError = error => {
|
|
53
59
|
this.setState({
|
|
54
|
-
|
|
60
|
+
errored: true,
|
|
55
61
|
inclination: error
|
|
56
62
|
});
|
|
57
63
|
}
|
|
@@ -6,116 +6,101 @@ import EventType from '../events/EventType';
|
|
|
6
6
|
import Utils from './Utils';
|
|
7
7
|
import PositioningHandler from '../PositioningHandler';
|
|
8
8
|
import StartStopComponent from './StartStopComponent';
|
|
9
|
-
import {
|
|
10
|
-
WGS84UserPosition, Itinerary
|
|
11
|
-
} from '@wemap/geo';
|
|
12
9
|
import MapComponent from './MapComponent';
|
|
13
10
|
|
|
14
|
-
const INITIAL_POSITION = new WGS84UserPosition(43.6091955, 3.8841255);
|
|
15
|
-
const INITIAL_HEADING = 191.9;
|
|
16
|
-
const ITINERARY = Itinerary.fromPoints([
|
|
17
|
-
[INITIAL_POSITION.lat, INITIAL_POSITION.lng],
|
|
18
|
-
[43.6091883, 3.8841242],
|
|
19
|
-
[43.6091709, 3.8842382],
|
|
20
|
-
[43.6091288, 3.884226],
|
|
21
|
-
[43.6091461, 3.884112]
|
|
22
|
-
], false);
|
|
23
11
|
|
|
24
12
|
class PositioningPoseComponent extends React.Component {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
</div>
|
|
117
|
-
);
|
|
118
|
-
}
|
|
13
|
+
static propTypes = {positioningHandler: PropTypes.instanceOf(PositioningHandler).isRequired};
|
|
14
|
+
|
|
15
|
+
constructor(props, context) {
|
|
16
|
+
super(props, context);
|
|
17
|
+
this.state = {
|
|
18
|
+
position: null,
|
|
19
|
+
attitude: null,
|
|
20
|
+
errored: false
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
start() {
|
|
25
|
+
const output = this.props.positioningHandler.start(
|
|
26
|
+
[EventType.AbsolutePosition, EventType.AbsoluteAttitude],
|
|
27
|
+
this.onEvents,
|
|
28
|
+
this.onError,
|
|
29
|
+
{
|
|
30
|
+
waitInputPosition: true,
|
|
31
|
+
useMapMatching: true
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
if (!output) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
this.id = output.id;
|
|
40
|
+
|
|
41
|
+
this.props.positioningHandler.setItinerary(this.id, Utils.ITINERARY);
|
|
42
|
+
this.props.positioningHandler.setNetwork(this.id, Utils.ITINERARY);
|
|
43
|
+
this.props.positioningHandler.setPosition(this.id, Utils.INITIAL_POSITION);
|
|
44
|
+
this.props.positioningHandler.setHeading(this.id, Utils.INITIAL_HEADING);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
stop() {
|
|
48
|
+
this.props.positioningHandler.stop(this.id);
|
|
49
|
+
this.setState({
|
|
50
|
+
position: null,
|
|
51
|
+
attitude: null,
|
|
52
|
+
errored: false
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
onEvents = events => {
|
|
57
|
+
const newState = {};
|
|
58
|
+
events.forEach(event => {
|
|
59
|
+
if (event.dataType === EventType.AbsolutePosition) {
|
|
60
|
+
newState.position = event.data;
|
|
61
|
+
} else if (event.dataType === EventType.AbsoluteAttitude) {
|
|
62
|
+
newState.attitude = event.data;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
if (!isEmpty(newState)) {
|
|
66
|
+
this.setState(newState);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (this.map) {
|
|
70
|
+
this.map.parseEvents(events);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
onError = error => {
|
|
75
|
+
this.setState({
|
|
76
|
+
position: error,
|
|
77
|
+
attitude: error,
|
|
78
|
+
errored: true
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
render() {
|
|
83
|
+
const attitudeRender = Utils.renderAttitude(this.state.attitude);
|
|
84
|
+
const positionRender = Utils.renderPosition(this.state.position);
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<div>
|
|
88
|
+
<StartStopComponent
|
|
89
|
+
onStart={() => this.start()}
|
|
90
|
+
onStop={() => this.stop()}
|
|
91
|
+
errored={this.state.errored}
|
|
92
|
+
/>
|
|
93
|
+
|
|
94
|
+
<h3>Position</h3>
|
|
95
|
+
{positionRender}
|
|
96
|
+
<h3>Attitude</h3>
|
|
97
|
+
{attitudeRender}
|
|
98
|
+
<h3>Map</h3>
|
|
99
|
+
<MapComponent ref={map => (this.map = map)}
|
|
100
|
+
network={Utils.ITINERARY} />
|
|
101
|
+
</div>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
119
104
|
}
|
|
120
105
|
|
|
121
106
|
export default PositioningPoseComponent;
|
package/src/components/Utils.js
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
import React from 'react'; // eslint-disable-line no-unused-vars
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Itinerary, WGS84UserPosition
|
|
5
|
+
} from '@wemap/geo';
|
|
2
6
|
import { rad2deg } from '@wemap/maths';
|
|
3
7
|
|
|
4
8
|
const NOT_AVAILABLE_STR = 'Not available';
|
|
5
9
|
|
|
6
10
|
class Utils {
|
|
7
11
|
|
|
12
|
+
static INITIAL_POSITION = new WGS84UserPosition(43.6091955, 3.8841255);
|
|
13
|
+
static INITIAL_HEADING = 191.9;
|
|
14
|
+
static ITINERARY = Itinerary.fromOrderedPointsArray(
|
|
15
|
+
[
|
|
16
|
+
[Utils.INITIAL_POSITION.lat, Utils.INITIAL_POSITION.lng],
|
|
17
|
+
[43.6091883, 3.8841242],
|
|
18
|
+
[43.6091709, 3.8842382],
|
|
19
|
+
[43.6091288, 3.884226],
|
|
20
|
+
[43.6091461, 3.884112]
|
|
21
|
+
],
|
|
22
|
+
[Utils.INITIAL_POSITION.lat, Utils.INITIAL_POSITION.lng],
|
|
23
|
+
[43.6091461, 3.884112],
|
|
24
|
+
false
|
|
25
|
+
);
|
|
26
|
+
|
|
8
27
|
static renderAttitude(attitude) {
|
|
9
28
|
|
|
10
29
|
if (!attitude) {
|
|
@@ -87,6 +106,7 @@ class Utils {
|
|
|
87
106
|
return (<span><strong>[{error.constructor.name}]</strong> {error.message}</span>);
|
|
88
107
|
}
|
|
89
108
|
|
|
109
|
+
|
|
90
110
|
}
|
|
91
111
|
|
|
92
112
|
export default Utils;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Provider from '../Provider';
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
Edge, Itinerary, MapMatching, Network, WGS84
|
|
4
4
|
} from '@wemap/geo';
|
|
5
5
|
|
|
6
6
|
class MapMatchingProvider extends Provider {
|
|
@@ -115,7 +115,7 @@ class MapMatchingProvider extends Provider {
|
|
|
115
115
|
if (edge.node1.equalsTo(projection.nearestElement)) {
|
|
116
116
|
break;
|
|
117
117
|
}
|
|
118
|
-
traveledDistance += edge.
|
|
118
|
+
traveledDistance += edge.length;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
|
|
@@ -127,7 +127,7 @@ class MapMatchingProvider extends Provider {
|
|
|
127
127
|
traveledDistance += edge.node1.distanceTo(projection.projection);
|
|
128
128
|
break;
|
|
129
129
|
}
|
|
130
|
-
traveledDistance += edge.
|
|
130
|
+
traveledDistance += edge.length;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
} else {
|
|
@@ -193,7 +193,7 @@ class GnssWifiPdrProvider extends MapMatchingProvider {
|
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
let startEdge;
|
|
196
|
-
if (itinerary.firstEdge.
|
|
196
|
+
if (itinerary.firstEdge.length <= MM_GNSS_DIST) {
|
|
197
197
|
startEdge = itinerary.firstEdge;
|
|
198
198
|
} else {
|
|
199
199
|
startEdge = itinerary.secondEdge;
|
|
@@ -201,7 +201,7 @@ class GnssWifiPdrProvider extends MapMatchingProvider {
|
|
|
201
201
|
const startPoint = WGS84UserPosition.fromWGS84(startEdge.node1);
|
|
202
202
|
startPoint.alt = Constants.DEFAULT_ALTITUDE;
|
|
203
203
|
this.pdrProvider.setPosition(startPoint);
|
|
204
|
-
this.pdrProvider.setStepDetectionLockerOrientation(startEdge.
|
|
204
|
+
this.pdrProvider.setStepDetectionLockerOrientation(startEdge.bearing);
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import noop from 'lodash.noop';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
Constants as GeoConstants, Itinerary,
|
|
4
|
+
Constants as GeoConstants, Itinerary, WGS84, WGS84UserPosition
|
|
5
5
|
} from '@wemap/geo';
|
|
6
6
|
import {
|
|
7
7
|
rad2deg, Quaternion
|
|
@@ -314,14 +314,15 @@ class PdrProvider extends MapMatchingProvider {
|
|
|
314
314
|
throw new Error('Empty itinerary');
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
-
|
|
318
|
-
|
|
317
|
+
const edgeAt = itinerary.getEdgeAt(LO_SEGMENT_SIZE);
|
|
318
|
+
if (edgeAt) {
|
|
319
|
+
return edgeAt.bearing;
|
|
319
320
|
}
|
|
320
321
|
|
|
321
322
|
if (itinerary.length < 2) {
|
|
322
323
|
throw new Error('Itinerary is too short');
|
|
323
324
|
}
|
|
324
|
-
return itinerary.secondEdge.
|
|
325
|
+
return itinerary.secondEdge.bearing;
|
|
325
326
|
}
|
|
326
327
|
|
|
327
328
|
setStepDetectionLockerOrientation(orientation) {
|