@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
@@ -0,0 +1,284 @@
1
+ import mapboxgl from 'mapbox-gl';
2
+
3
+ import { Level } from '@wemap/geo';
4
+
5
+ import MapboxHelper from '../MapboxHelper';
6
+ import ItineraryStore from '../../stores/ItineraryStore';
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 {mapboxgl.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.addLayer(layer);
59
+ this.map.indoor.addLayerForFiltering(layer.id);
60
+ });
61
+ }
62
+
63
+ drawItinerary() {
64
+
65
+ this.mapboxSourceData.features = this.mapboxSourceData.features.filter(feature =>
66
+ !feature.properties || !feature.properties.itinerary
67
+ );
68
+
69
+ const { itinerary } = this.itineraryStore;
70
+
71
+ if (itinerary !== null) {
72
+
73
+ /**
74
+ * Start to Network segment
75
+ */
76
+ const startFeature = {
77
+ type: 'Feature',
78
+ properties: { 'itinerary': 'start' },
79
+ geometry: {
80
+ type: 'LineString',
81
+ coordinates: [
82
+ MapboxHelper.coordsToLngLat(itinerary.start),
83
+ MapboxHelper.coordsToLngLat(itinerary.nodes[0].coords)
84
+ ]
85
+ }
86
+ };
87
+ if (itinerary.start.level !== null) {
88
+ startFeature.properties.level = itinerary.start.level.toString();
89
+ }
90
+
91
+ /**
92
+ * Network to End segment
93
+ */
94
+ const endFeature = {
95
+ type: 'Feature',
96
+ properties: { 'itinerary': 'start' },
97
+ geometry: {
98
+ type: 'LineString',
99
+ coordinates: [
100
+ MapboxHelper.coordsToLngLat(itinerary.nodes[itinerary.nodes.length - 1].coords),
101
+ MapboxHelper.coordsToLngLat(itinerary.end)
102
+ ]
103
+ }
104
+ };
105
+ if (itinerary.end.level !== null) {
106
+ endFeature.properties.level = itinerary.end.level.toString();
107
+ }
108
+
109
+ let previousEdgeLevel = null;
110
+ let currentFeatureCoordinates;
111
+ const itineraryFeatures = itinerary.edges.reduce((acc, edge) => {
112
+
113
+ if (!currentFeatureCoordinates || !Level.equalsTo(edge.level, previousEdgeLevel)) {
114
+ currentFeatureCoordinates = [MapboxHelper.coordsToLngLat(edge.node1.coords)];
115
+ const feature = {
116
+ type: 'Feature',
117
+ properties: { 'itinerary': 'core' },
118
+ geometry: {
119
+ type: 'LineString',
120
+ coordinates: currentFeatureCoordinates
121
+ }
122
+ };
123
+ if (edge.level !== null) {
124
+ feature.properties.level = edge.level.toString();
125
+ }
126
+ acc.push(feature);
127
+ previousEdgeLevel = edge.level;
128
+ }
129
+
130
+ currentFeatureCoordinates.push(MapboxHelper.coordsToLngLat(edge.node2.coords));
131
+
132
+ return acc;
133
+
134
+ }, []);
135
+
136
+ this.mapboxSourceData.features.push(
137
+ ...itineraryFeatures,
138
+ startFeature,
139
+ endFeature
140
+ );
141
+ }
142
+
143
+ this.map.getSource(ItineraryMapHandler.SOURCE_ID).setData(this.mapboxSourceData);
144
+ }
145
+
146
+
147
+ drawItineraryStart() {
148
+
149
+ this.mapboxSourceData.features = this.mapboxSourceData.features.filter(feature =>
150
+ !feature.properties || feature.properties.start !== 'yes'
151
+ );
152
+
153
+ const coordinates = this.itineraryStore.start;
154
+
155
+ if (coordinates !== null) {
156
+ const feature = {
157
+ type: 'Feature',
158
+ properties: { 'start': 'yes' },
159
+ geometry: {
160
+ type: 'Point',
161
+ coordinates: MapboxHelper.coordsToLngLat(coordinates)
162
+ }
163
+ };
164
+ if (coordinates.level !== null) {
165
+ feature.properties.level = coordinates.level.toString();
166
+ }
167
+ this.mapboxSourceData.features.push(feature);
168
+ }
169
+
170
+ this.map.getSource(ItineraryMapHandler.SOURCE_ID).setData(this.mapboxSourceData);
171
+ }
172
+
173
+
174
+ drawItineraryEnd() {
175
+
176
+ this.mapboxSourceData.features = this.mapboxSourceData.features.filter(feature =>
177
+ !feature.properties || feature.properties.end !== 'yes'
178
+ );
179
+
180
+ const coordinates = this.itineraryStore.end;
181
+
182
+ if (coordinates !== null) {
183
+ const feature = {
184
+ type: 'Feature',
185
+ properties: { 'end': 'yes' },
186
+ geometry: {
187
+ type: 'Point',
188
+ coordinates: MapboxHelper.coordsToLngLat(coordinates)
189
+ }
190
+ };
191
+ if (coordinates.level !== null) {
192
+ feature.properties.level = coordinates.level.toString();
193
+ }
194
+ this.mapboxSourceData.features.push(feature);
195
+ }
196
+
197
+ this.map.getSource(ItineraryMapHandler.SOURCE_ID).setData(this.mapboxSourceData);
198
+ }
199
+
200
+ /**
201
+ * @returns {mapboxgl.Layer[]}
202
+ */
203
+ generateLayers(sourceId) {
204
+ return [
205
+ {
206
+ id: ItineraryMapHandler.ITINERARY_LAYER_ID,
207
+ type: 'line',
208
+ source: sourceId,
209
+ filter: [
210
+ 'filter-==',
211
+ 'itinerary',
212
+ 'core'
213
+ ],
214
+ paint: {
215
+ 'line-color': '#039be5',
216
+ 'line-width': 2
217
+ },
218
+ layout: {
219
+ 'line-join': 'round',
220
+ 'line-cap': 'round'
221
+ }
222
+ },
223
+ {
224
+ id: ItineraryMapHandler.ITINERARY_START_END_LAYER_ID,
225
+ type: 'line',
226
+ source: sourceId,
227
+ filter: [
228
+ 'filter-in-small',
229
+ 'itinerary', [
230
+ 'literal',
231
+ [
232
+ 'start',
233
+ 'end'
234
+ ]
235
+ ]
236
+ ],
237
+ paint: {
238
+ 'line-color': '#039be5',
239
+ 'line-dasharray': [
240
+ 1,
241
+ 3
242
+ ],
243
+ 'line-width': 2
244
+ },
245
+ layout: {
246
+ 'line-join': 'round',
247
+ 'line-cap': 'round'
248
+ }
249
+ },
250
+ {
251
+ id: ItineraryMapHandler.START_LAYER_ID,
252
+ type: 'symbol',
253
+ source: sourceId,
254
+ filter: [
255
+ 'filter-==',
256
+ 'start',
257
+ 'yes'
258
+ ],
259
+ layout: {
260
+ 'icon-allow-overlap': true,
261
+ 'symbol-placement': 'point',
262
+ 'icon-image': 'hu-main-2',
263
+ 'icon-anchor': 'bottom'
264
+ }
265
+ }, {
266
+ id: ItineraryMapHandler.END_LAYER_ID,
267
+ type: 'symbol',
268
+ source: sourceId,
269
+ filter: [
270
+ 'filter-==',
271
+ 'end',
272
+ 'yes'
273
+ ],
274
+ layout: {
275
+ 'icon-allow-overlap': true,
276
+ 'symbol-placement': 'point',
277
+ 'icon-image': 'nz-state-2',
278
+ 'icon-anchor': 'bottom'
279
+ }
280
+ }
281
+ ];
282
+ }
283
+ }
284
+ export default ItineraryMapHandler;
@@ -0,0 +1,119 @@
1
+ import mapboxgl from 'mapbox-gl';
2
+
3
+ import {
4
+ Coordinates, Level
5
+ } from '@wemap/geo';
6
+
7
+ import ItineraryStore from '../../stores/ItineraryStore';
8
+ import UserOnMapHandler from './UserOnMapHandler';
9
+
10
+ class MapClickHandler {
11
+
12
+ /**
13
+ * @param {mapboxgl.Map} map
14
+ * @param {UserOnMapHandler} userOnMapHandler
15
+ */
16
+ constructor(map, userOnMapHandler) {
17
+ if (!map) {
18
+ throw new TypeError('map cannot be null');
19
+ }
20
+
21
+ map.on('contextmenu', e => this._onContextmenu(e));
22
+
23
+ this.map = map;
24
+
25
+ this.itineraryStore = ItineraryStore.instance;
26
+ this.userOnMapHandler = userOnMapHandler;
27
+ }
28
+
29
+ _onContextmenu(e) {
30
+
31
+ if (this.popup) {
32
+ this.popup.remove();
33
+ this.popup = null;
34
+ }
35
+
36
+ if (this.itineraryStore.itinerary || this.itineraryStore.itineraryComputing) {
37
+ return;
38
+ }
39
+
40
+ const coordinates = new Coordinates(e.lngLat.lat, e.lngLat.lng);
41
+
42
+ this.popup = new mapboxgl.Popup()
43
+ .setLngLat(e.lngLat)
44
+ .setDOMContent(this._generatePopupHtml(coordinates))
45
+ .addTo(this.map);
46
+ }
47
+
48
+ _updateCoordinatesWithMapLevel(coordinates) {
49
+ if (this.map.getLevel() !== null) {
50
+ coordinates.level = new Level(this.map.getLevel());
51
+ }
52
+ }
53
+
54
+ _generatePopupHtml(coordinates) {
55
+
56
+ const container = document.createElement('div');
57
+
58
+ const navigateButton = document.createElement('div');
59
+ navigateButton.id = 'navigate-to-this-point';
60
+ navigateButton.innerHTML = 'Navigate to this point';
61
+ navigateButton.classList.add('map-click-list-element');
62
+ navigateButton.onclick = () => {
63
+ this._updateCoordinatesWithMapLevel(coordinates);
64
+ this._navigateTo(coordinates);
65
+ if (this.popup) {
66
+ this.popup.remove();
67
+ }
68
+ };
69
+ container.appendChild(navigateButton);
70
+
71
+ const startButton = document.createElement('div');
72
+ startButton.id = 'start-from-there';
73
+ startButton.innerHTML = 'Start from there';
74
+ startButton.classList.add('map-click-list-element');
75
+ startButton.onclick = () => {
76
+ this._updateCoordinatesWithMapLevel(coordinates);
77
+ this.itineraryStore.start = coordinates;
78
+ this._eventuallyCompute();
79
+ if (this.popup) {
80
+ this.popup.remove();
81
+ }
82
+ };
83
+ container.appendChild(startButton);
84
+
85
+ const endButton = document.createElement('div');
86
+ endButton.id = 'end-to-there';
87
+ endButton.innerHTML = 'End to there';
88
+ endButton.classList.add('map-click-list-element');
89
+ endButton.onclick = () => {
90
+ this._updateCoordinatesWithMapLevel(coordinates);
91
+ this.itineraryStore.end = coordinates;
92
+ this._eventuallyCompute();
93
+ if (this.popup) {
94
+ this.popup.remove();
95
+ }
96
+ };
97
+ container.appendChild(endButton);
98
+
99
+ return container;
100
+ }
101
+
102
+ _navigateTo(coordinates) {
103
+
104
+ this.itineraryStore.end = coordinates;
105
+
106
+ this.itineraryStore.retrieveStartFromUserLocation()
107
+ .then(() => {
108
+ this.itineraryStore.compute();
109
+ this.userOnMapHandler.startPositioning();
110
+ });
111
+ }
112
+
113
+ _eventuallyCompute() {
114
+ if (!this.itineraryStore.itinerary && this.itineraryStore.start && this.itineraryStore.end) {
115
+ this.itineraryStore.compute();
116
+ }
117
+ }
118
+ }
119
+ export default MapClickHandler;