@wemap/providers 3.2.2 → 3.2.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.
- package/debug/dist/absolute-attitude.html +19 -0
- package/{dist → debug/dist}/absolute-position.html +5 -2
- package/{dist → debug/dist}/gnss-wifi.html +5 -2
- package/{dist → debug/dist}/imu.html +5 -2
- package/debug/dist/inclination.html +19 -0
- package/debug/dist/index.html +20 -0
- package/debug/dist/positioning-legacy.html +19 -0
- package/debug/dist/relative-attitude.html +19 -0
- package/debug/dist/step-detection.html +19 -0
- package/debug/index.js +7 -9
- package/debug/{components → src}/AbsolutePositionComponent.jsx +4 -4
- package/debug/{components → src}/GnssWifiComponent.jsx +5 -5
- package/debug/{components → src}/Utils.js +2 -4
- package/debug/src/map/SimpleMap.jsx +47 -0
- package/index.js +1 -3
- package/package.json +12 -36
- package/src/ProvidersInterface.js +4 -1
- package/src/providers/attitude/absolute/AbsoluteAttitudeFromBrowserProvider.js +1 -1
- package/src/providers/attitude/relative/RelativeAttitudeFromBrowserProvider.js +1 -1
- package/src/providers/imu/ImuProvider.js +1 -1
- package/src/providers/position/absolute/AbsolutePositionProvider.js +4 -2
- package/src/providers/position/absolute/GnssWifiProvider.js +1 -1
- package/babel.config.json +0 -16
- package/config.json +0 -4
- package/debug/MainComponent.jsx +0 -51
- package/debug/css/App.css +0 -128
- package/debug/css/UserOnMapHandler.css +0 -43
- package/debug/details/DetailsAttitudeComponent.jsx +0 -128
- package/debug/details/DetailsComponent.jsx +0 -31
- package/debug/details/DetailsPositionComponent.jsx +0 -134
- package/debug/details/ItineraryComponent.jsx +0 -264
- package/debug/map/MapComponent.jsx +0 -85
- package/debug/map/MapHandler.js +0 -44
- package/debug/map/helpers/ItineraryMapHandler.js +0 -283
- package/debug/map/helpers/MapClickHandler.js +0 -121
- package/debug/map/helpers/UserOnMapHandler.js +0 -91
- package/debug/stores/ItineraryStore.js +0 -198
- package/dist/absolute-attitude.html +0 -16
- package/dist/assets/indoor-maps/bureaux-wemap-montpellier.geojson +0 -7270
- package/dist/inclination.html +0 -16
- package/dist/index.html +0 -19
- package/dist/js/providers-components.js +0 -2361
- package/dist/logger.html +0 -58
- package/dist/positioning-legacy.html +0 -16
- package/dist/relative-attitude.html +0 -16
- package/dist/step-detection.html +0 -16
- package/src/logger/NavigationLogger.js +0 -138
- package/src/logger/NavigationLoggerConverter.js +0 -263
- package/webpack/webpack.common.cjs +0 -26
- package/webpack/webpack.dev.cjs +0 -25
- package/webpack/webpack.prod.cjs +0 -15
- /package/debug/{components → src}/AbsoluteAttitudeComponent.jsx +0 -0
- /package/debug/{components → src}/ImuComponent.jsx +0 -0
- /package/debug/{components → src}/InclinationComponent.jsx +0 -0
- /package/debug/{components → src}/NavigationConfig.js +0 -0
- /package/debug/{components → src}/RelativeAttitudeComponent.jsx +0 -0
- /package/debug/{components → src}/StartStopComponent.jsx +0 -0
- /package/debug/{components → src}/StepDetectionComponent.jsx +0 -0
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
import { Level } from '@wemap/geo';
|
|
5
|
-
|
|
6
|
-
import ItineraryStore from '../stores/ItineraryStore.js';
|
|
7
|
-
import MapHandler from '../map/MapHandler.js';
|
|
8
|
-
|
|
9
|
-
const Mode = {
|
|
10
|
-
Config: 'config',
|
|
11
|
-
WaitUserPositionForStart: 'wait-user-position-for-start',
|
|
12
|
-
SelectStartOnMap: 'select-start-on-map',
|
|
13
|
-
SelectEndOnMap: 'select-end-on-map',
|
|
14
|
-
ItineraryCompute: 'itinerary-compute',
|
|
15
|
-
Itinerary: 'itinerary'
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const ItineraryEvents = ItineraryStore.Events;
|
|
19
|
-
|
|
20
|
-
class ItineraryComponent extends React.PureComponent {
|
|
21
|
-
|
|
22
|
-
static propTypes = { mapHandler: PropTypes.instanceOf(MapHandler) };
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
constructor(props, context) {
|
|
26
|
-
super(props, context);
|
|
27
|
-
|
|
28
|
-
this.itineraryStore = ItineraryStore.instance;
|
|
29
|
-
|
|
30
|
-
this.state = {
|
|
31
|
-
endLevel: '',
|
|
32
|
-
error: null,
|
|
33
|
-
mode: this.itineraryStore.itinerary ? Mode.Itinerary : Mode.Config
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
componentDidMount() {
|
|
39
|
-
this.itineraryStore.on(ItineraryEvents.StartChanged, () => this.forceUpdate());
|
|
40
|
-
this.itineraryStore.on(ItineraryEvents.EndChanged, () => this.forceUpdate());
|
|
41
|
-
this.itineraryStore.on(ItineraryEvents.ItineraryChanged, it => this.onItineraryChanged(it));
|
|
42
|
-
this.itineraryStore.on(ItineraryEvents.ItineraryServerChanged, () => this.forceUpdate());
|
|
43
|
-
this.itineraryStore.on(ItineraryEvents.UseStairsChanged, () => this.forceUpdate());
|
|
44
|
-
this.itineraryStore.on(ItineraryEvents.ItineraryNotFound, () => this.setState({ error: ItineraryEvents.ItineraryNotFound }));
|
|
45
|
-
this.itineraryStore.on(ItineraryEvents.ServerError, () => this.setState({ error: ItineraryEvents.ServerError }));
|
|
46
|
-
|
|
47
|
-
if (this.props.mapHandler) {
|
|
48
|
-
this.initMapHandler();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
componentDidUpdate(prevProps, prevState) {
|
|
53
|
-
if (prevProps.mapHandler !== this.props.mapHandler && this.props.mapHandler !== null) {
|
|
54
|
-
this.initMapHandler();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (prevState.mode !== this.state.mode) {
|
|
58
|
-
if (this.state.mode === Mode.SelectStartOnMap || this.state.mode === Mode.SelectEndOnMap) {
|
|
59
|
-
this.props.mapHandler.needClick();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
initMapHandler() {
|
|
65
|
-
this.props.mapHandler.onMapClick(coords => this.onMapClick(coords));
|
|
66
|
-
|
|
67
|
-
const transformLevel = mapLevel => mapLevel === null ? '' : mapLevel.toString();
|
|
68
|
-
const map = this.props.mapHandler.mapboxInstance;
|
|
69
|
-
this.setState({ endLevel: transformLevel(map.indoor.getLevel()) });
|
|
70
|
-
map.on('indoor.level.changed', () => this.setState({ endLevel: transformLevel(map.indoor.getLevel()) }));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
onItineraryChanged(itinerary) {
|
|
74
|
-
if (itinerary) {
|
|
75
|
-
this.setState({ mode: Mode.Itinerary });
|
|
76
|
-
} else {
|
|
77
|
-
this.setState({ mode: Mode.Config });
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
onMapClick(position) {
|
|
82
|
-
if (this.state.mode === Mode.SelectStartOnMap) {
|
|
83
|
-
this.itineraryStore.start = position;
|
|
84
|
-
this.setState({ mode: Mode.Config });
|
|
85
|
-
} else if (this.state.mode === Mode.SelectEndOnMap) {
|
|
86
|
-
if (this.state.endLevel !== '') {
|
|
87
|
-
position.level = Level.fromString(this.state.endLevel);
|
|
88
|
-
}
|
|
89
|
-
this.itineraryStore.end = position;
|
|
90
|
-
this.setState({ mode: Mode.Config });
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
onUseUserPositionClick() {
|
|
95
|
-
this.setState({ mode: Mode.WaitUserPositionForStart });
|
|
96
|
-
this.itineraryStore.retrieveStartFromUserLocation().then(() => {
|
|
97
|
-
this.setState({ mode: Mode.Config });
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
render() {
|
|
102
|
-
|
|
103
|
-
const configMode = this.state.mode !== Mode.Itinerary;
|
|
104
|
-
|
|
105
|
-
return (
|
|
106
|
-
<div>
|
|
107
|
-
<div className="title">Itinerary</div>
|
|
108
|
-
{configMode ? this.renderConfig() : this.renderItinerary()}
|
|
109
|
-
</div>
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
renderItinerary() {
|
|
114
|
-
return (
|
|
115
|
-
<button
|
|
116
|
-
value=''
|
|
117
|
-
onClick={() => this.itineraryStore.remove()}>
|
|
118
|
-
Remove itinerary
|
|
119
|
-
</button>
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
renderConfig() {
|
|
124
|
-
|
|
125
|
-
const handleComputeClick = () => {
|
|
126
|
-
this.itineraryStore.compute();
|
|
127
|
-
this.setState({ itineraryNotFound: false });
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const lockedMode = this.state.mode === Mode.SelectEndOnMap
|
|
131
|
-
|| this.state.mode === Mode.SelectStartOnMap
|
|
132
|
-
|| this.state.mode === Mode.WaitUserPositionForStart
|
|
133
|
-
|| this.state.mode === Mode.ItineraryCompute;
|
|
134
|
-
|
|
135
|
-
return (
|
|
136
|
-
<div>
|
|
137
|
-
{this.state.error
|
|
138
|
-
? <div style={{
|
|
139
|
-
marginBottom: '5px',
|
|
140
|
-
color: 'red'
|
|
141
|
-
}}>
|
|
142
|
-
{this.state.error === ItineraryEvents.ItineraryNotFound
|
|
143
|
-
? 'Itinerary not found'
|
|
144
|
-
: 'Server error'
|
|
145
|
-
}
|
|
146
|
-
</div>
|
|
147
|
-
: null}
|
|
148
|
-
<div>
|
|
149
|
-
{this.renderStart(lockedMode)}
|
|
150
|
-
</div>
|
|
151
|
-
|
|
152
|
-
<div style={{ marginTop: '5px' }}>
|
|
153
|
-
{this.renderEnd(lockedMode)}
|
|
154
|
-
</div>
|
|
155
|
-
|
|
156
|
-
<div style={{ marginTop: '5px' }}>
|
|
157
|
-
<img id='wheelchair-icon'
|
|
158
|
-
className={!this.itineraryStore.useStairs ? 'selected' : null}
|
|
159
|
-
onClick={() => (this.itineraryStore.useStairs = !this.itineraryStore.useStairs)} />
|
|
160
|
-
</div>
|
|
161
|
-
|
|
162
|
-
<div style={{
|
|
163
|
-
marginTop: '10px',
|
|
164
|
-
width: '100%',
|
|
165
|
-
textAlign: 'center'
|
|
166
|
-
}}>
|
|
167
|
-
<button
|
|
168
|
-
disabled={!this.itineraryStore.start || !this.itineraryStore.end || lockedMode}
|
|
169
|
-
onClick={handleComputeClick}
|
|
170
|
-
>
|
|
171
|
-
Compute
|
|
172
|
-
</button>
|
|
173
|
-
</div>
|
|
174
|
-
|
|
175
|
-
</div>
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
renderStart(lockedMode) {
|
|
180
|
-
|
|
181
|
-
let buttons;
|
|
182
|
-
|
|
183
|
-
if (this.itineraryStore.start) {
|
|
184
|
-
buttons = (
|
|
185
|
-
<button
|
|
186
|
-
disabled={lockedMode}
|
|
187
|
-
style={{ backgroundColor: '#e57373' }}
|
|
188
|
-
onClick={() => (this.itineraryStore.start = null)}
|
|
189
|
-
>
|
|
190
|
-
Remove
|
|
191
|
-
</button>
|
|
192
|
-
);
|
|
193
|
-
} else {
|
|
194
|
-
buttons = (
|
|
195
|
-
<>
|
|
196
|
-
<button
|
|
197
|
-
disabled={lockedMode}
|
|
198
|
-
onClick={() => this.onUseUserPositionClick()}
|
|
199
|
-
>
|
|
200
|
-
{
|
|
201
|
-
this.state.mode === Mode.WaitUserPositionForStart ? (
|
|
202
|
-
<div className="loader"
|
|
203
|
-
style={{ marginRight: '5px' }}></div>
|
|
204
|
-
) : null
|
|
205
|
-
}
|
|
206
|
-
User position
|
|
207
|
-
</button>
|
|
208
|
-
|
|
209
|
-
<button
|
|
210
|
-
disabled={lockedMode}
|
|
211
|
-
style={{ marginLeft: '5px' }}
|
|
212
|
-
onClick={() => this.setState({ mode: Mode.SelectStartOnMap })}
|
|
213
|
-
>
|
|
214
|
-
Select on map
|
|
215
|
-
</button>
|
|
216
|
-
</>
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
return (
|
|
221
|
-
<>
|
|
222
|
-
Start:
|
|
223
|
-
<span style={{ marginLeft: '5px' }}>{buttons}</span>
|
|
224
|
-
</>
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
renderEnd(lockedMode) {
|
|
229
|
-
|
|
230
|
-
let buttons;
|
|
231
|
-
|
|
232
|
-
if (this.itineraryStore.end) {
|
|
233
|
-
buttons = (
|
|
234
|
-
<button
|
|
235
|
-
disabled={lockedMode}
|
|
236
|
-
style={{ backgroundColor: '#e57373' }}
|
|
237
|
-
onClick={() => (this.itineraryStore.end = null)}
|
|
238
|
-
>
|
|
239
|
-
Remove
|
|
240
|
-
</button>
|
|
241
|
-
);
|
|
242
|
-
} else {
|
|
243
|
-
buttons = (
|
|
244
|
-
<button
|
|
245
|
-
disabled={lockedMode}
|
|
246
|
-
onClick={() => this.setState({ mode: Mode.SelectEndOnMap })}
|
|
247
|
-
>
|
|
248
|
-
Select on map
|
|
249
|
-
</button>
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
return (
|
|
254
|
-
<>
|
|
255
|
-
<div>
|
|
256
|
-
End:
|
|
257
|
-
<span style={{ marginLeft: '5px' }}>{buttons}</span>
|
|
258
|
-
</div>
|
|
259
|
-
</>
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
export default ItineraryComponent;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Map } from 'mapbox-gl';
|
|
3
|
-
import {
|
|
4
|
-
Indoor, IndoorControl, IndoorMap
|
|
5
|
-
} from 'mapbox-gl-indoor';
|
|
6
|
-
import PropTypes from 'prop-types';
|
|
7
|
-
import noop from 'lodash.noop';
|
|
8
|
-
|
|
9
|
-
import MapHandler from './MapHandler.js';
|
|
10
|
-
|
|
11
|
-
import 'mapbox-gl/dist/mapbox-gl.css';
|
|
12
|
-
|
|
13
|
-
const accessToken
|
|
14
|
-
= 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
|
|
15
|
-
|
|
16
|
-
class MapComponent extends React.Component {
|
|
17
|
-
static propTypes = {
|
|
18
|
-
maxZoom: PropTypes.number,
|
|
19
|
-
onMapLoaded: PropTypes.func,
|
|
20
|
-
indoorMaps: PropTypes.array
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
static defaultProps = {
|
|
24
|
-
maxZoom: 22,
|
|
25
|
-
onMapLoaded: noop
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
componentDidMount() {
|
|
29
|
-
this.map = new Map({
|
|
30
|
-
accessToken,
|
|
31
|
-
container: this.mapContainer,
|
|
32
|
-
style: 'mapbox://styles/mapbox/streets-v10',
|
|
33
|
-
maxZoom: this.props.maxZoom
|
|
34
|
-
});
|
|
35
|
-
this.map.indoor = new Indoor(this.map);
|
|
36
|
-
|
|
37
|
-
this.mapHandler = new MapHandler(this.map);
|
|
38
|
-
|
|
39
|
-
const mapLoadedFn = () => this.props.onMapLoaded(this.mapHandler);
|
|
40
|
-
|
|
41
|
-
this.map.on('load', () => {
|
|
42
|
-
if (this.props.indoorMaps && this.props.indoorMaps.length > 0) {
|
|
43
|
-
this._loadIndoorMaps(this.props.indoorMaps)
|
|
44
|
-
.then(mapLoadedFn);
|
|
45
|
-
} else {
|
|
46
|
-
mapLoadedFn();
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
this.map.addControl(new IndoorControl(this.map.indoor));
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
componentWillUnmount() {
|
|
55
|
-
this.map.remove();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
_loadIndoorMaps(mapsPaths) {
|
|
59
|
-
const beforeLayerId = 'housenum-label';
|
|
60
|
-
const layersToHide = ['poi-scalerank4-l15', 'poi-scalerank4-l1', 'poi-scalerank3', 'road-label-small'];
|
|
61
|
-
|
|
62
|
-
return Promise.all(
|
|
63
|
-
mapsPaths.map(mapPath =>
|
|
64
|
-
fetch(mapPath)
|
|
65
|
-
.then(res => res.json())
|
|
66
|
-
.then(geojson => this.map.indoor.addMap(IndoorMap.fromGeojson(geojson, {
|
|
67
|
-
beforeLayerId,
|
|
68
|
-
layersToHide,
|
|
69
|
-
showFeaturesWithEmptyLevel: true
|
|
70
|
-
}))))
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
render() {
|
|
75
|
-
return (
|
|
76
|
-
<div ref={map => (this.mapContainer = map)}
|
|
77
|
-
style={{
|
|
78
|
-
width: '100%',
|
|
79
|
-
height: '100%'
|
|
80
|
-
}} />
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export default MapComponent;
|
package/debug/map/MapHandler.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Map } from 'mapbox-gl';
|
|
2
|
-
|
|
3
|
-
import { Coordinates } from '@wemap/geo';
|
|
4
|
-
|
|
5
|
-
import ItineraryMapHandler from './helpers/ItineraryMapHandler.js';
|
|
6
|
-
import UserOnMapHandler from './helpers/UserOnMapHandler.js';
|
|
7
|
-
import MapClickHandler from './helpers/MapClickHandler.js';
|
|
8
|
-
|
|
9
|
-
class MapHandler {
|
|
10
|
-
|
|
11
|
-
itineraryMapHandler;
|
|
12
|
-
userOnMapHandler;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @param {Map} map
|
|
17
|
-
*/
|
|
18
|
-
constructor(map) {
|
|
19
|
-
this.itineraryMapHandler = new ItineraryMapHandler(map);
|
|
20
|
-
this.userOnMapHandler = new UserOnMapHandler(map);
|
|
21
|
-
this.mapClickHandler = new MapClickHandler(map, this.userOnMapHandler);
|
|
22
|
-
this.map = map;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @param {Function} fn
|
|
27
|
-
*/
|
|
28
|
-
onMapClick(fn) {
|
|
29
|
-
this.map.on('click', e => {
|
|
30
|
-
fn(new Coordinates(e.lngLat.lat, e.lngLat.lng));
|
|
31
|
-
this.map.getCanvas().style.cursor = '';
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
needClick() {
|
|
36
|
-
this.map.getCanvas().style.cursor = 'pointer';
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
get mapboxInstance() {
|
|
40
|
-
return this.map;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export default MapHandler;
|
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
import { Map } from 'mapbox-gl';
|
|
2
|
-
|
|
3
|
-
import { Level } from '@wemap/geo';
|
|
4
|
-
import { MapboxUtils } from '@wemap/map';
|
|
5
|
-
|
|
6
|
-
import ItineraryStore from '../../stores/ItineraryStore.js';
|
|
7
|
-
|
|
8
|
-
class ItineraryMapHandler {
|
|
9
|
-
|
|
10
|
-
static SOURCE_ID = 'itinerary';
|
|
11
|
-
|
|
12
|
-
static ITINERARY_LAYER_ID = 'itinerary';
|
|
13
|
-
static ITINERARY_START_END_LAYER_ID = 'itinerary-start-end-segments';
|
|
14
|
-
static START_LAYER_ID = 'itinerary-start';
|
|
15
|
-
static END_LAYER_ID = 'itinerary-end';
|
|
16
|
-
|
|
17
|
-
mapboxSourceData = {
|
|
18
|
-
type: 'FeatureCollection',
|
|
19
|
-
features: []
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @param {Map} map
|
|
24
|
-
*/
|
|
25
|
-
constructor(map) {
|
|
26
|
-
if (!map) {
|
|
27
|
-
throw new TypeError('map cannot be null');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
map.on('load', () => this.onMapLoaded());
|
|
31
|
-
|
|
32
|
-
this.map = map;
|
|
33
|
-
this.itineraryStore = ItineraryStore.instance;
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
onMapLoaded() {
|
|
38
|
-
this.initializeMapSourceAndLayers();
|
|
39
|
-
|
|
40
|
-
this.drawItineraryStart();
|
|
41
|
-
this.itineraryStore.on(ItineraryStore.Events.StartChanged, () => this.drawItineraryStart());
|
|
42
|
-
|
|
43
|
-
this.drawItineraryEnd();
|
|
44
|
-
this.itineraryStore.on(ItineraryStore.Events.EndChanged, () => this.drawItineraryEnd());
|
|
45
|
-
|
|
46
|
-
this.drawItinerary();
|
|
47
|
-
this.itineraryStore.on(ItineraryStore.Events.ItineraryChanged, () => this.drawItinerary());
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
initializeMapSourceAndLayers() {
|
|
51
|
-
|
|
52
|
-
this.map.addSource(ItineraryMapHandler.SOURCE_ID, {
|
|
53
|
-
type: 'geojson',
|
|
54
|
-
data: this.mapboxSourceData
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
this.generateLayers(ItineraryMapHandler.SOURCE_ID).forEach(layer => {
|
|
58
|
-
this.map.indoor._addLayerForFiltering(layer);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
drawItinerary() {
|
|
63
|
-
|
|
64
|
-
this.mapboxSourceData.features = this.mapboxSourceData.features.filter(feature =>
|
|
65
|
-
!feature.properties || !feature.properties.itinerary
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
const { itinerary } = this.itineraryStore;
|
|
69
|
-
|
|
70
|
-
if (itinerary !== null) {
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Start to Network segment
|
|
74
|
-
*/
|
|
75
|
-
const startFeature = {
|
|
76
|
-
type: 'Feature',
|
|
77
|
-
properties: { 'itinerary': 'start' },
|
|
78
|
-
geometry: {
|
|
79
|
-
type: 'LineString',
|
|
80
|
-
coordinates: [
|
|
81
|
-
MapboxUtils.coordsToLngLat(itinerary.start),
|
|
82
|
-
MapboxUtils.coordsToLngLat(itinerary.nodes[0].coords)
|
|
83
|
-
]
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
if (itinerary.start.level !== null) {
|
|
87
|
-
startFeature.properties.level = itinerary.start.level.toString();
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Network to End segment
|
|
92
|
-
*/
|
|
93
|
-
const endFeature = {
|
|
94
|
-
type: 'Feature',
|
|
95
|
-
properties: { 'itinerary': 'end' },
|
|
96
|
-
geometry: {
|
|
97
|
-
type: 'LineString',
|
|
98
|
-
coordinates: [
|
|
99
|
-
MapboxUtils.coordsToLngLat(itinerary.nodes[itinerary.nodes.length - 1].coords),
|
|
100
|
-
MapboxUtils.coordsToLngLat(itinerary.end)
|
|
101
|
-
]
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
if (itinerary.end.level !== null) {
|
|
105
|
-
endFeature.properties.level = itinerary.end.level.toString();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
let previousEdgeLevel = null;
|
|
109
|
-
let currentFeatureCoordinates;
|
|
110
|
-
const itineraryFeatures = itinerary.edges.reduce((acc, edge) => {
|
|
111
|
-
|
|
112
|
-
if (!currentFeatureCoordinates || !Level.equalsTo(edge.level, previousEdgeLevel)) {
|
|
113
|
-
currentFeatureCoordinates = [MapboxUtils.coordsToLngLat(edge.node1.coords)];
|
|
114
|
-
const feature = {
|
|
115
|
-
type: 'Feature',
|
|
116
|
-
properties: { 'itinerary': 'core' },
|
|
117
|
-
geometry: {
|
|
118
|
-
type: 'LineString',
|
|
119
|
-
coordinates: currentFeatureCoordinates
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
if (edge.level !== null) {
|
|
123
|
-
feature.properties.level = edge.level.toString();
|
|
124
|
-
}
|
|
125
|
-
acc.push(feature);
|
|
126
|
-
previousEdgeLevel = edge.level;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
currentFeatureCoordinates.push(MapboxUtils.coordsToLngLat(edge.node2.coords));
|
|
130
|
-
|
|
131
|
-
return acc;
|
|
132
|
-
|
|
133
|
-
}, []);
|
|
134
|
-
|
|
135
|
-
this.mapboxSourceData.features.push(
|
|
136
|
-
...itineraryFeatures,
|
|
137
|
-
startFeature,
|
|
138
|
-
endFeature
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
this.map.getSource(ItineraryMapHandler.SOURCE_ID).setData(this.mapboxSourceData);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
drawItineraryStart() {
|
|
147
|
-
|
|
148
|
-
this.mapboxSourceData.features = this.mapboxSourceData.features.filter(feature =>
|
|
149
|
-
!feature.properties || feature.properties.start !== 'yes'
|
|
150
|
-
);
|
|
151
|
-
|
|
152
|
-
const coordinates = this.itineraryStore.start;
|
|
153
|
-
|
|
154
|
-
if (coordinates !== null) {
|
|
155
|
-
const feature = {
|
|
156
|
-
type: 'Feature',
|
|
157
|
-
properties: { 'start': 'yes' },
|
|
158
|
-
geometry: {
|
|
159
|
-
type: 'Point',
|
|
160
|
-
coordinates: MapboxUtils.coordsToLngLat(coordinates)
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
if (coordinates.level !== null) {
|
|
164
|
-
feature.properties.level = coordinates.level.toString();
|
|
165
|
-
}
|
|
166
|
-
this.mapboxSourceData.features.push(feature);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
this.map.getSource(ItineraryMapHandler.SOURCE_ID).setData(this.mapboxSourceData);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
drawItineraryEnd() {
|
|
174
|
-
|
|
175
|
-
this.mapboxSourceData.features = this.mapboxSourceData.features.filter(feature =>
|
|
176
|
-
!feature.properties || feature.properties.end !== 'yes'
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
const coordinates = this.itineraryStore.end;
|
|
180
|
-
|
|
181
|
-
if (coordinates !== null) {
|
|
182
|
-
const feature = {
|
|
183
|
-
type: 'Feature',
|
|
184
|
-
properties: { 'end': 'yes' },
|
|
185
|
-
geometry: {
|
|
186
|
-
type: 'Point',
|
|
187
|
-
coordinates: MapboxUtils.coordsToLngLat(coordinates)
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
if (coordinates.level !== null) {
|
|
191
|
-
feature.properties.level = coordinates.level.toString();
|
|
192
|
-
}
|
|
193
|
-
this.mapboxSourceData.features.push(feature);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
this.map.getSource(ItineraryMapHandler.SOURCE_ID).setData(this.mapboxSourceData);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* @returns {Layer[]}
|
|
201
|
-
*/
|
|
202
|
-
generateLayers(sourceId) {
|
|
203
|
-
return [
|
|
204
|
-
{
|
|
205
|
-
id: ItineraryMapHandler.ITINERARY_LAYER_ID,
|
|
206
|
-
type: 'line',
|
|
207
|
-
source: sourceId,
|
|
208
|
-
filter: [
|
|
209
|
-
'filter-==',
|
|
210
|
-
'itinerary',
|
|
211
|
-
'core'
|
|
212
|
-
],
|
|
213
|
-
paint: {
|
|
214
|
-
'line-color': '#039be5',
|
|
215
|
-
'line-width': 2
|
|
216
|
-
},
|
|
217
|
-
layout: {
|
|
218
|
-
'line-join': 'round',
|
|
219
|
-
'line-cap': 'round'
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
id: ItineraryMapHandler.ITINERARY_START_END_LAYER_ID,
|
|
224
|
-
type: 'line',
|
|
225
|
-
source: sourceId,
|
|
226
|
-
filter: [
|
|
227
|
-
'filter-in-small',
|
|
228
|
-
'itinerary', [
|
|
229
|
-
'literal',
|
|
230
|
-
[
|
|
231
|
-
'start',
|
|
232
|
-
'end'
|
|
233
|
-
]
|
|
234
|
-
]
|
|
235
|
-
],
|
|
236
|
-
paint: {
|
|
237
|
-
'line-color': '#039be5',
|
|
238
|
-
'line-dasharray': [
|
|
239
|
-
1,
|
|
240
|
-
3
|
|
241
|
-
],
|
|
242
|
-
'line-width': 2
|
|
243
|
-
},
|
|
244
|
-
layout: {
|
|
245
|
-
'line-join': 'round',
|
|
246
|
-
'line-cap': 'round'
|
|
247
|
-
}
|
|
248
|
-
},
|
|
249
|
-
{
|
|
250
|
-
id: ItineraryMapHandler.START_LAYER_ID,
|
|
251
|
-
type: 'symbol',
|
|
252
|
-
source: sourceId,
|
|
253
|
-
filter: [
|
|
254
|
-
'filter-==',
|
|
255
|
-
'start',
|
|
256
|
-
'yes'
|
|
257
|
-
],
|
|
258
|
-
layout: {
|
|
259
|
-
'icon-allow-overlap': true,
|
|
260
|
-
'symbol-placement': 'point',
|
|
261
|
-
'icon-image': 'hu-main-2',
|
|
262
|
-
'icon-anchor': 'bottom'
|
|
263
|
-
}
|
|
264
|
-
}, {
|
|
265
|
-
id: ItineraryMapHandler.END_LAYER_ID,
|
|
266
|
-
type: 'symbol',
|
|
267
|
-
source: sourceId,
|
|
268
|
-
filter: [
|
|
269
|
-
'filter-==',
|
|
270
|
-
'end',
|
|
271
|
-
'yes'
|
|
272
|
-
],
|
|
273
|
-
layout: {
|
|
274
|
-
'icon-allow-overlap': true,
|
|
275
|
-
'symbol-placement': 'point',
|
|
276
|
-
'icon-image': 'nz-state-2',
|
|
277
|
-
'icon-anchor': 'bottom'
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
];
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
export default ItineraryMapHandler;
|