@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,121 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Map, Popup
|
|
3
|
-
} from 'mapbox-gl';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
Coordinates, Level
|
|
7
|
-
} from '@wemap/geo';
|
|
8
|
-
|
|
9
|
-
import ItineraryStore from '../../stores/ItineraryStore.js';
|
|
10
|
-
import UserOnMapHandler from './UserOnMapHandler.js';
|
|
11
|
-
|
|
12
|
-
class MapClickHandler {
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @param {Map} map
|
|
16
|
-
* @param {UserOnMapHandler} userOnMapHandler
|
|
17
|
-
*/
|
|
18
|
-
constructor(map, userOnMapHandler) {
|
|
19
|
-
if (!map) {
|
|
20
|
-
throw new TypeError('map cannot be null');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
map.on('contextmenu', e => this._onContextmenu(e));
|
|
24
|
-
|
|
25
|
-
this.map = map;
|
|
26
|
-
|
|
27
|
-
this.itineraryStore = ItineraryStore.instance;
|
|
28
|
-
this.userOnMapHandler = userOnMapHandler;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
_onContextmenu(e) {
|
|
32
|
-
|
|
33
|
-
if (this.popup) {
|
|
34
|
-
this.popup.remove();
|
|
35
|
-
this.popup = null;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (this.itineraryStore.itinerary || this.itineraryStore.itineraryComputing) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const coordinates = new Coordinates(e.lngLat.lat, e.lngLat.lng);
|
|
43
|
-
|
|
44
|
-
this.popup = new Popup()
|
|
45
|
-
.setLngLat(e.lngLat)
|
|
46
|
-
.setDOMContent(this._generatePopupHtml(coordinates))
|
|
47
|
-
.addTo(this.map);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
_updateCoordinatesWithMapLevel(coordinates) {
|
|
51
|
-
if (this.map.indoor.getLevel() !== null) {
|
|
52
|
-
coordinates.level = new Level(this.map.indoor.getLevel());
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
_generatePopupHtml(coordinates) {
|
|
57
|
-
|
|
58
|
-
const container = document.createElement('div');
|
|
59
|
-
|
|
60
|
-
const navigateButton = document.createElement('div');
|
|
61
|
-
navigateButton.id = 'navigate-to-this-point';
|
|
62
|
-
navigateButton.innerHTML = 'Navigate to this point';
|
|
63
|
-
navigateButton.classList.add('map-click-list-element');
|
|
64
|
-
navigateButton.onclick = () => {
|
|
65
|
-
this._updateCoordinatesWithMapLevel(coordinates);
|
|
66
|
-
this._navigateTo(coordinates);
|
|
67
|
-
if (this.popup) {
|
|
68
|
-
this.popup.remove();
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
container.appendChild(navigateButton);
|
|
72
|
-
|
|
73
|
-
const startButton = document.createElement('div');
|
|
74
|
-
startButton.id = 'start-from-there';
|
|
75
|
-
startButton.innerHTML = 'Start from there';
|
|
76
|
-
startButton.classList.add('map-click-list-element');
|
|
77
|
-
startButton.onclick = () => {
|
|
78
|
-
this._updateCoordinatesWithMapLevel(coordinates);
|
|
79
|
-
this.itineraryStore.start = coordinates;
|
|
80
|
-
this._eventuallyCompute();
|
|
81
|
-
if (this.popup) {
|
|
82
|
-
this.popup.remove();
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
container.appendChild(startButton);
|
|
86
|
-
|
|
87
|
-
const endButton = document.createElement('div');
|
|
88
|
-
endButton.id = 'end-to-there';
|
|
89
|
-
endButton.innerHTML = 'End to there';
|
|
90
|
-
endButton.classList.add('map-click-list-element');
|
|
91
|
-
endButton.onclick = () => {
|
|
92
|
-
this._updateCoordinatesWithMapLevel(coordinates);
|
|
93
|
-
this.itineraryStore.end = coordinates;
|
|
94
|
-
this._eventuallyCompute();
|
|
95
|
-
if (this.popup) {
|
|
96
|
-
this.popup.remove();
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
container.appendChild(endButton);
|
|
100
|
-
|
|
101
|
-
return container;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
_navigateTo(coordinates) {
|
|
105
|
-
|
|
106
|
-
this.itineraryStore.end = coordinates;
|
|
107
|
-
|
|
108
|
-
this.itineraryStore.retrieveStartFromUserLocation()
|
|
109
|
-
.then(() => {
|
|
110
|
-
this.itineraryStore.compute();
|
|
111
|
-
this.userOnMapHandler.startPositioning();
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
_eventuallyCompute() {
|
|
116
|
-
if (!this.itineraryStore.itinerary && this.itineraryStore.start && this.itineraryStore.end) {
|
|
117
|
-
this.itineraryStore.compute();
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
export default MapClickHandler;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { Map } from 'mapbox-gl';
|
|
2
|
-
import { GeolocationLayer } from '@wemap/map';
|
|
3
|
-
import { TimeUtils } from '@wemap/utils';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
PositionSmoother, ProvidersInterface, EventType
|
|
7
|
-
} from '../../../index.js';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class UserOnMapHandler {
|
|
11
|
-
|
|
12
|
-
smoother;
|
|
13
|
-
attitudeProviderId;
|
|
14
|
-
positionProviderId;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @param {Map} map
|
|
18
|
-
*/
|
|
19
|
-
constructor(map) {
|
|
20
|
-
|
|
21
|
-
this.geolocationLayer = new GeolocationLayer(map);
|
|
22
|
-
|
|
23
|
-
this.geolocationLayer.onStartButtonClicked = layer => this.start(layer);
|
|
24
|
-
this.geolocationLayer.onStopButtonClicked = layer => this.stop(layer);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
start() {
|
|
28
|
-
|
|
29
|
-
this.geolocationLayer.startRenderLoop();
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Attitude
|
|
33
|
-
*/
|
|
34
|
-
this.attitudeProviderId = ProvidersInterface.addEventListener(
|
|
35
|
-
EventType.AbsoluteAttitude,
|
|
36
|
-
attitude => this.geolocationLayer.updateHeading(attitude.headingDegrees)
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
// There is no sense to show the last known attitude on the map
|
|
40
|
-
// this.geolocationLayer.updateHeading(ProvidersInterface.getLastKnown(EventType.AbsoluteAttitude));
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Position
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
const positionTransform = input => {
|
|
48
|
-
if (input === null) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
const output = input.clone();
|
|
52
|
-
output.timestamp = TimeUtils.preciseTimeToUnixTimestamp(input.time * 1e3);
|
|
53
|
-
return output;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
this.smoother = new PositionSmoother(position => {
|
|
57
|
-
this.geolocationLayer.updatePosition(positionTransform(position));
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
this.positionProviderId = ProvidersInterface.addEventListener(
|
|
61
|
-
EventType.AbsolutePosition,
|
|
62
|
-
position => this.smoother.feed(position)
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
const lastKnownPosition = ProvidersInterface.getLastKnown(EventType.AbsolutePosition);
|
|
66
|
-
if (lastKnownPosition) {
|
|
67
|
-
this.geolocationLayer.updatePosition(positionTransform(lastKnownPosition));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
stop() {
|
|
72
|
-
|
|
73
|
-
this.geolocationLayer.stopRenderLoop();
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Attitude
|
|
77
|
-
*/
|
|
78
|
-
|
|
79
|
-
ProvidersInterface.removeEventListener(this.attitudeProviderId);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Position
|
|
84
|
-
*/
|
|
85
|
-
|
|
86
|
-
ProvidersInterface.removeEventListener(this.positionProviderId);
|
|
87
|
-
this.smoother.clear();
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
export default UserOnMapHandler;
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import { Coordinates, Level } from '@wemap/geo';
|
|
2
|
-
import { Itinerary } from '@wemap/graph';
|
|
3
|
-
import { OsrmUtils } from '@wemap/osm';
|
|
4
|
-
import { Evented } from '@wemap/utils';
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
ProvidersInterface, EventType
|
|
8
|
-
} from '../../index.js';
|
|
9
|
-
|
|
10
|
-
const Events = {
|
|
11
|
-
StartChanged: 'itinerary.start.changed',
|
|
12
|
-
EndChanged: 'itinerary.end.changed',
|
|
13
|
-
ItineraryChanged: 'itinerary.changed',
|
|
14
|
-
ItineraryNotFound: 'itinerary.not.found',
|
|
15
|
-
ItineraryComputing: 'itinerary.computing',
|
|
16
|
-
ServerError: 'itinerary.server.error',
|
|
17
|
-
UseStairsChanged: 'itinerary.use.stairs.changed'
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const SERVER_URL = 'https://routingindoor.maaap.it';
|
|
21
|
-
|
|
22
|
-
class ItineraryStore extends Evented {
|
|
23
|
-
|
|
24
|
-
_start = null;
|
|
25
|
-
_end = null;
|
|
26
|
-
_itinerary = null;
|
|
27
|
-
_useStairs = true;
|
|
28
|
-
|
|
29
|
-
static Events = Events;
|
|
30
|
-
|
|
31
|
-
static instance = new ItineraryStore();
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @param {Coordinates} start
|
|
35
|
-
*/
|
|
36
|
-
set start(start) {
|
|
37
|
-
this._start = start;
|
|
38
|
-
this.fire(Events.StartChanged, start);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @returns {Coordinates}
|
|
43
|
-
*/
|
|
44
|
-
get start() {
|
|
45
|
-
return this._start;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* @returns {Promise}
|
|
50
|
-
*/
|
|
51
|
-
retrieveStartFromUserLocation() {
|
|
52
|
-
|
|
53
|
-
const userPosition = ProvidersInterface.getLastKnown(EventType.AbsolutePosition);
|
|
54
|
-
if (userPosition) {
|
|
55
|
-
this.start = userPosition;
|
|
56
|
-
return Promise.resolve();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return new Promise((resolve, reject) => {
|
|
60
|
-
|
|
61
|
-
let providerId;
|
|
62
|
-
|
|
63
|
-
const rejectFn = () => {
|
|
64
|
-
ProvidersInterface.removeEventListener(providerId);
|
|
65
|
-
reject();
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
this.on(Events.StartChanged, rejectFn);
|
|
69
|
-
|
|
70
|
-
providerId = ProvidersInterface.addEventListener(EventType.AbsolutePosition,
|
|
71
|
-
position => {
|
|
72
|
-
this.off(Events.StartChanged, rejectFn);
|
|
73
|
-
ProvidersInterface.removeEventListener(providerId);
|
|
74
|
-
this.start = position;
|
|
75
|
-
resolve();
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* @param {Coordinates} end
|
|
82
|
-
*/
|
|
83
|
-
set end(end) {
|
|
84
|
-
this._end = end;
|
|
85
|
-
this.fire(Events.EndChanged, end);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* @returns {Coordinates}
|
|
90
|
-
*/
|
|
91
|
-
get end() {
|
|
92
|
-
return this._end;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* @returns {Itinerary}
|
|
97
|
-
*/
|
|
98
|
-
get itinerary() {
|
|
99
|
-
return this._itinerary;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* @returns {Boolean}
|
|
104
|
-
*/
|
|
105
|
-
get isComputing() {
|
|
106
|
-
return this.itineraryComputing;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* @param {Boolean}
|
|
111
|
-
*/
|
|
112
|
-
set useStairs(useStairs) {
|
|
113
|
-
this._useStairs = useStairs;
|
|
114
|
-
this.fire(Events.UseStairsChanged, useStairs);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* @return {Boolean}
|
|
119
|
-
*/
|
|
120
|
-
get useStairs() {
|
|
121
|
-
return this._useStairs;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
compute() {
|
|
125
|
-
|
|
126
|
-
const start = this.start;
|
|
127
|
-
const end = this.end;
|
|
128
|
-
|
|
129
|
-
if (!start || !end) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const computingFn = (bool) => {
|
|
134
|
-
this.itineraryComputing = bool;
|
|
135
|
-
this.fire(Events.ItineraryComputing, bool);
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
computingFn(true);
|
|
139
|
-
|
|
140
|
-
const url = SERVER_URL
|
|
141
|
-
+ '/route/v1/walking/'
|
|
142
|
-
+ start.lng + ',' + start.lat + (start.level !== null ? ',' + start.level.toString() : '')
|
|
143
|
-
+ ';'
|
|
144
|
-
+ end.lng + ',' + end.lat + (end.level !== null ? ',' + end.level.toString() : '')
|
|
145
|
-
+ '?geometries=geojson&overview=full'
|
|
146
|
-
+ '&useAltitude=false'
|
|
147
|
-
+ (!this.useStairs ? '&useStairs=false' : '');
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
fetch(url)
|
|
151
|
-
.then(response => response.json())
|
|
152
|
-
.catch(error => {
|
|
153
|
-
computingFn(false);
|
|
154
|
-
this.fire(Events.ServerError, error);
|
|
155
|
-
})
|
|
156
|
-
.then(json => {
|
|
157
|
-
if (json.code !== 'Ok') {
|
|
158
|
-
computingFn(false);
|
|
159
|
-
this.remove();
|
|
160
|
-
this.fire(Events.ItineraryNotFound);
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
const itinerary = OsrmUtils.createItineraryFromJson(json, start, end);
|
|
164
|
-
|
|
165
|
-
this.itineraryComputing = false;
|
|
166
|
-
this.fire(Events.ItineraryComputing, false);
|
|
167
|
-
|
|
168
|
-
if (itinerary.nodes.length > 0) {
|
|
169
|
-
const firstCoords = itinerary.nodes[0].coords;
|
|
170
|
-
const lastCoords = itinerary.nodes[itinerary.nodes.length - 1].coords;
|
|
171
|
-
|
|
172
|
-
if (!Level.equalsTo(firstCoords.level, start.level)) {
|
|
173
|
-
this.start.level = firstCoords.level;
|
|
174
|
-
this.fire(Events.StartChanged, start);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (!Level.equalsTo(lastCoords.level, end.level)) {
|
|
178
|
-
this.end.level = lastCoords.level;
|
|
179
|
-
this.fire(Events.EndChanged, end);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
this._itinerary = itinerary;
|
|
184
|
-
this.fire(Events.ItineraryChanged, itinerary);
|
|
185
|
-
|
|
186
|
-
ProvidersInterface.feed(EventType.Network, itinerary);
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
remove() {
|
|
191
|
-
this._itinerary = null;
|
|
192
|
-
this.fire(Events.ItineraryChanged, null);
|
|
193
|
-
ProvidersInterface.feed(EventType.Network, null);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export default ItineraryStore;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="utf-8">
|
|
6
|
-
<meta name="viewport" content="width=device-width, user-scalable=no">
|
|
7
|
-
<title>Debug Absolute Attitude</title>
|
|
8
|
-
<script src="js/providers-components.js"></script>
|
|
9
|
-
</head>
|
|
10
|
-
|
|
11
|
-
<body>
|
|
12
|
-
<div id="app"></div>
|
|
13
|
-
<script>createReactElement(AbsoluteAttitudeComponent, document.getElementById('app'));</script>
|
|
14
|
-
</body>
|
|
15
|
-
|
|
16
|
-
</html>
|