@wemap/providers 3.2.1 → 3.2.3

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 (58) hide show
  1. package/debug/dist/absolute-attitude.html +19 -0
  2. package/{dist → debug/dist}/absolute-position.html +5 -2
  3. package/{dist → debug/dist}/gnss-wifi.html +5 -2
  4. package/{dist → debug/dist}/imu.html +5 -2
  5. package/debug/dist/inclination.html +19 -0
  6. package/debug/dist/index.html +20 -0
  7. package/debug/dist/positioning-legacy.html +19 -0
  8. package/debug/dist/relative-attitude.html +19 -0
  9. package/debug/dist/step-detection.html +19 -0
  10. package/debug/index.js +7 -9
  11. package/debug/{components → src}/AbsolutePositionComponent.jsx +4 -4
  12. package/debug/{components → src}/GnssWifiComponent.jsx +5 -5
  13. package/debug/{components → src}/Utils.js +2 -4
  14. package/debug/src/map/SimpleMap.jsx +47 -0
  15. package/index.js +1 -3
  16. package/package.json +12 -36
  17. package/src/ProvidersInterface.js +4 -1
  18. package/src/providers/attitude/absolute/AbsoluteAttitudeFromBrowserProvider.js +3 -3
  19. package/src/providers/attitude/relative/RelativeAttitudeFromBrowserProvider.js +2 -0
  20. package/src/providers/imu/ImuProvider.js +2 -2
  21. package/src/providers/position/absolute/AbsolutePositionProvider.js +4 -2
  22. package/src/providers/position/absolute/GnssWifiProvider.js +2 -2
  23. package/babel.config.json +0 -16
  24. package/config.json +0 -4
  25. package/debug/MainComponent.jsx +0 -51
  26. package/debug/css/App.css +0 -128
  27. package/debug/css/UserOnMapHandler.css +0 -43
  28. package/debug/details/DetailsAttitudeComponent.jsx +0 -128
  29. package/debug/details/DetailsComponent.jsx +0 -31
  30. package/debug/details/DetailsPositionComponent.jsx +0 -134
  31. package/debug/details/ItineraryComponent.jsx +0 -264
  32. package/debug/map/MapComponent.jsx +0 -85
  33. package/debug/map/MapHandler.js +0 -44
  34. package/debug/map/helpers/ItineraryMapHandler.js +0 -283
  35. package/debug/map/helpers/MapClickHandler.js +0 -121
  36. package/debug/map/helpers/UserOnMapHandler.js +0 -76
  37. package/debug/stores/ItineraryStore.js +0 -198
  38. package/dist/absolute-attitude.html +0 -16
  39. package/dist/assets/indoor-maps/bureaux-wemap-montpellier.geojson +0 -7270
  40. package/dist/inclination.html +0 -16
  41. package/dist/index.html +0 -19
  42. package/dist/js/providers-components.js +0 -2361
  43. package/dist/logger.html +0 -58
  44. package/dist/positioning-legacy.html +0 -16
  45. package/dist/relative-attitude.html +0 -16
  46. package/dist/step-detection.html +0 -16
  47. package/src/logger/NavigationLogger.js +0 -131
  48. package/src/logger/NavigationLoggerConverter.js +0 -228
  49. package/webpack/webpack.common.cjs +0 -26
  50. package/webpack/webpack.dev.cjs +0 -25
  51. package/webpack/webpack.prod.cjs +0 -15
  52. /package/debug/{components → src}/AbsoluteAttitudeComponent.jsx +0 -0
  53. /package/debug/{components → src}/ImuComponent.jsx +0 -0
  54. /package/debug/{components → src}/InclinationComponent.jsx +0 -0
  55. /package/debug/{components → src}/NavigationConfig.js +0 -0
  56. /package/debug/{components → src}/RelativeAttitudeComponent.jsx +0 -0
  57. /package/debug/{components → src}/StartStopComponent.jsx +0 -0
  58. /package/debug/{components → src}/StepDetectionComponent.jsx +0 -0
package/dist/logger.html DELETED
@@ -1,58 +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 Pose</title>
8
- <script src="js/providers-components.js"></script>
9
-
10
- <style>
11
- #logger {
12
- background: #ffffffaa;
13
- position: absolute;
14
- bottom: 0;
15
- left: 0;
16
- z-index: 2;
17
- margin: 5px;
18
- padding-left: 10px;
19
- padding-right: 10px;
20
- min-width: 100px;
21
- }
22
- </style>
23
- </head>
24
-
25
- <body>
26
- <div id="app"></div>
27
- <div id="logger">
28
- <div class="title">Logger</div>
29
- <button id="start">Start</button>
30
- <button id="stop" disabled>Stop</button>
31
- </div>
32
- <script>
33
- const app = createReactElement(MainComponent, document.getElementById('app'));
34
-
35
- const SERVER_URL = 'https://localhost:9002'
36
-
37
- const startButton = document.getElementById('start');
38
- const stopButton = document.getElementById('stop');
39
-
40
- startButton.addEventListener('click', () => {
41
- document.dispatchEvent(new CustomEvent('providers.logger.start', { detail : {
42
- serverUrl: SERVER_URL,
43
- logsSize: 300
44
- }}));
45
- startButton.disabled = true;
46
- stopButton.disabled = false;
47
- });
48
-
49
- stopButton.addEventListener('click', () => {
50
- document.dispatchEvent(new Event('providers.logger.stop'));
51
- startButton.disabled = false;
52
- stopButton.disabled = true;
53
- });
54
-
55
- </script>
56
- </body>
57
-
58
- </html>
@@ -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 Positioning</title>
8
- <script src="js/providers-components.js"></script>
9
- </head>
10
-
11
- <body>
12
- <div id="app"></div>
13
- <script>createReactElement(PositioningComponent, document.getElementById('app'));</script>
14
- </body>
15
-
16
- </html>
@@ -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 Relative Attitude</title>
8
- <script src="js/providers-components.js"></script>
9
- </head>
10
-
11
- <body>
12
- <div id="app"></div>
13
- <script>createReactElement(RelativeAttitudeComponent, document.getElementById('app'));</script>
14
- </body>
15
-
16
- </html>
@@ -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 Step Detection</title>
8
- <script src="js/providers-components.js"></script>
9
- </head>
10
-
11
- <body>
12
- <div id="app"></div>
13
- <script>createReactElement(StepDetectionComponent, document.getElementById('app'));</script>
14
- </body>
15
-
16
- </html>
@@ -1,131 +0,0 @@
1
- import { v4 as uuidv4 } from 'uuid';
2
- import cookies from 'browser-cookies';
3
-
4
- import { TimeUtils } from '@wemap/utils';
5
-
6
- import ProvidersOptions from '../ProvidersOptions.js';
7
- import NavigationLoggerConverter from './NavigationLoggerConverter.js';
8
-
9
-
10
- class NavigationLogger {
11
-
12
- static serverUrl;
13
- static logsSize;
14
-
15
- static logs;
16
- static sessionsId;
17
-
18
- static isRecording = false;
19
-
20
- static start(serverUrl, logsSize = 200) {
21
- if (this.isRecording) {
22
- return;
23
- }
24
- this.isRecording = true;
25
-
26
- this.serverUrl = serverUrl;
27
- this.logsSize = logsSize;
28
-
29
- // Initialize
30
- this.logs = new Array(this.logsSize);
31
- this.currentLogIndex = 0;
32
-
33
- // Fill and send the config object
34
- const config = {};
35
- config.startTime = TimeUtils.preciseTime;
36
- config.options = ProvidersOptions;
37
- config.sessionId = this.sessionId = uuidv4();
38
- config.userAgent = typeof navigator !== 'undefined' ? navigator.userAgent : '';
39
- if (typeof document !== 'undefined') {
40
- config.cookieId = cookies.get('providers.logger.uuid');
41
- if (!config.cookieId) {
42
- config.cookieId = uuidv4();
43
- cookies.set('providers.logger.uuid', config.cookieId);
44
- }
45
- }
46
- this._sendConfig(config);
47
-
48
- // Dispatch started event
49
- if (typeof document !== 'undefined') {
50
- document.dispatchEvent(new CustomEvent('providers.logger.started', { detail: { config: this.config } }));
51
- }
52
- }
53
-
54
- static stop() {
55
- if (!this.isRecording) {
56
- return;
57
- }
58
-
59
- this._sendLogs(this.logs.filter(el => el !== null));
60
- // this.config.endTime = TimeUtils.preciseTime;
61
-
62
- if (typeof document !== 'undefined') {
63
- document.dispatchEvent(new CustomEvent('providers.logger.stopped', { detail: { logs: this.logs } }));
64
- }
65
-
66
- this.isRecording = false;
67
- }
68
-
69
- static feedRawData(eventName, data) {
70
- if (!this.isRecording) {
71
- return;
72
- }
73
- this._feed(NavigationLoggerConverter.rawDataToArray(eventName, TimeUtils.preciseTime, data));
74
- }
75
-
76
- static feedExternalData(eventType, data) {
77
- if (!this.isRecording) {
78
- return;
79
- }
80
- this._feed(NavigationLoggerConverter.externalDataToArray(eventType, TimeUtils.preciseTime, data));
81
- }
82
-
83
-
84
- static _feed(line) {
85
- this.logs[this.currentLogIndex++] = line;
86
- if (this.logsSize && this.logs[this.logsSize - 1]) {
87
- this._flush();
88
- }
89
- }
90
-
91
- static _flush() {
92
- this._sendLogs(this.logs);
93
- if (typeof document !== 'undefined') {
94
- document.dispatchEvent(new CustomEvent('providers.logger.flush', { detail: { logs: this.logs } }));
95
- }
96
- this.currentLogIndex = 0;
97
- this.logs = new Array(this.logsSize);
98
- }
99
-
100
-
101
- static _sendConfig(config) {
102
- const xmlhttp = new XMLHttpRequest();
103
- xmlhttp.open('POST', this.serverUrl + '/config');
104
- xmlhttp.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
105
- xmlhttp.send(JSON.stringify(config));
106
- }
107
-
108
- static _sendLogs(logs) {
109
- const xmlhttp = new XMLHttpRequest();
110
- xmlhttp.open('POST', this.serverUrl + '/logs/' + this.sessionId);
111
- xmlhttp.setRequestHeader('Content-Type', 'application/json');
112
- xmlhttp.send(JSON.stringify(logs));
113
- }
114
- }
115
-
116
- if (typeof document !== 'undefined') {
117
- document.addEventListener('providers.logger.start', event => {
118
- if (!('detail' in event)) {
119
- throw new Error('[providers.logger.start] did not find event detail');
120
- }
121
- if (!('serverUrl' in event.detail)) {
122
- throw new Error('[providers.logger.start] did not find serverUrl');
123
- }
124
- console.log(event.detail.serverUrl, event.detail.logsSize);
125
- NavigationLogger.start(event.detail.serverUrl, event.detail.logsSize);
126
- });
127
- document.addEventListener('providers.logger.stop', () => NavigationLogger.stop());
128
- }
129
-
130
-
131
- export default NavigationLogger;
@@ -1,228 +0,0 @@
1
- /* eslint-disable complexity */
2
- import { UserPosition } from '@wemap/geo';
3
- import { Network } from '@wemap/graph';
4
-
5
- import EventType from '../events/EventType.js';
6
-
7
- const PRECISION = 1e-6;
8
- const PRECISION_INV = 1 / PRECISION;
9
- const round = num => typeof num === 'number' ? Math.round(num * PRECISION_INV) / PRECISION_INV : num;
10
-
11
- class NavigationLoggerConverter {
12
-
13
- static externalDataToArray(eventType, time, data) {
14
- switch (eventType) {
15
- case EventType.Network:
16
- return [0, 'network', round(time), data === null ? null : JSON.stringify(data.toCompressedJson())];
17
- case EventType.AbsolutePosition:
18
- return [0, 'absolute-position', round(time), JSON.stringify(data.toJson())];
19
- case EventType.AbsoluteHeading:
20
- return [0, 'absolute-heading', round(time), JSON.stringify(data.toJson())];
21
- case EventType.AbsoluteAttitude:
22
- return [0, 'absolute-attitude', round(time), JSON.stringify(data.toJson())];
23
- }
24
- return [0, 'unknown', eventType];
25
- }
26
-
27
- static rawDataToArray(eventName, time, data) {
28
- switch (eventName) {
29
-
30
- case 'devicemotion':
31
- const acc = data.accelerationIncludingGravity;
32
- const gyr = data.rotationRate;
33
- const linearAcc = data.acceleration;
34
-
35
- return [
36
- 1,
37
- round(time),
38
- round(data.timeStamp),
39
- acc && typeof acc.x === 'number' ? round(acc.x) : Number.MIN_VALUE,
40
- acc && typeof acc.y === 'number' ? round(acc.y) : Number.MIN_VALUE,
41
- acc && typeof acc.z === 'number' ? round(acc.z) : Number.MIN_VALUE,
42
- gyr && typeof gyr.alpha === 'number' ? round(gyr.alpha) : Number.MIN_VALUE,
43
- gyr && typeof gyr.beta === 'number' ? round(gyr.beta) : Number.MIN_VALUE,
44
- gyr && typeof gyr.gamma === 'number' ? round(gyr.gamma) : Number.MIN_VALUE,
45
- linearAcc && typeof linearAcc.x === 'number' ? round(linearAcc.x) : Number.MIN_VALUE,
46
- linearAcc && typeof linearAcc.y === 'number' ? round(linearAcc.y) : Number.MIN_VALUE,
47
- linearAcc && typeof linearAcc.z === 'number' ? round(linearAcc.z) : Number.MIN_VALUE,
48
- round(data.interval)
49
- ];
50
-
51
- case 'deviceorientation':
52
- return [
53
- 2,
54
- round(time),
55
- round(data.timeStamp),
56
- round(data.alpha),
57
- round(data.beta),
58
- round(data.gamma),
59
- round(data.webkitCompassHeading),
60
- data.absolute ? 1 : 0
61
- ];
62
-
63
- case 'deviceorientationabsolute':
64
- return [
65
- 3,
66
- round(time),
67
- round(data.timeStamp),
68
- round(data.alpha),
69
- round(data.beta),
70
- round(data.gamma),
71
- data.absolute ? 1 : 0
72
- ];
73
-
74
- case 'geolocation':
75
- return [
76
- 4,
77
- round(time),
78
- round(data.timestamp),
79
- data.coords.latitude,
80
- data.coords.longitude,
81
- typeof data.coords.altitude === 'number' ? round(data.coords.altitude) : Number.MIN_VALUE,
82
- round(data.coords.accuracy),
83
- typeof data.coords.altitudeAccuracy === 'number' ? round(data.coords.altitudeAccuracy) : Number.MIN_VALUE,
84
- typeof data.coords.heading === 'number' ? round(data.coords.heading) : Number.MIN_VALUE,
85
- typeof data.coords.speed === 'number' ? round(data.coords.speed) : Number.MIN_VALUE
86
- ];
87
- }
88
-
89
- throw new Error(`Cannot parse eventName: ${eventName}`);
90
- }
91
-
92
- static _strToObj(str) {
93
-
94
- const indexOfFirstComma = str.indexOf(',');
95
- const rowType = parseInt(str.substring(0, indexOfFirstComma), 10);
96
-
97
- let array;
98
-
99
- switch (rowType) {
100
-
101
- case 1:
102
- array = str.split(',').map(parseFloat);
103
- return {
104
- eventName: 'devicemotion',
105
- time: array[1],
106
- data: {
107
- timeStamp: array[2],
108
- accelerationIncludingGravity: {
109
- x: array[3] === Number.MIN_VALUE ? null : array[3],
110
- y: array[4] === Number.MIN_VALUE ? null : array[4],
111
- z: array[5] === Number.MIN_VALUE ? null : array[5]
112
- },
113
- rotationRate: {
114
- alpha: array[6] === Number.MIN_VALUE ? null : array[6],
115
- beta: array[7] === Number.MIN_VALUE ? null : array[7],
116
- gamma: array[8] === Number.MIN_VALUE ? null : array[8]
117
- },
118
- acceleration: {
119
- x: array[9] === Number.MIN_VALUE ? null : array[9],
120
- y: array[10] === Number.MIN_VALUE ? null : array[10],
121
- z: array[11] === Number.MIN_VALUE ? null : array[11]
122
- }
123
- },
124
- isExternal: false
125
- };
126
-
127
- case 2:
128
- array = str.split(',').map(parseFloat);
129
- return {
130
- eventName: 'deviceorientation',
131
- time: array[1],
132
- data: {
133
- timeStamp: array[2],
134
- alpha: array[3],
135
- beta: array[4],
136
- gamma: array[5],
137
- webkitCompassHeading: array[6],
138
- absolute: array[7] === 1
139
- },
140
- isExternal: false
141
- };
142
-
143
- case 3:
144
- array = str.split(',').map(parseFloat);
145
- return {
146
- eventName: 'deviceorientationabsolute',
147
- time: array[1],
148
- data: {
149
- timeStamp: array[2],
150
- alpha: array[3],
151
- beta: array[4],
152
- gamma: array[5],
153
- absolute: array[6] === 1
154
- },
155
- isExternal: false
156
- };
157
-
158
- case 4:
159
- array = str.split(',').map(parseFloat);
160
- return {
161
- eventName: 'geolocation',
162
- time: array[1],
163
- data: {
164
- timestamp: array[2],
165
- coords: {
166
- latitude: array[3],
167
- longitude: array[4],
168
- altitude: array[5] === Number.MIN_VALUE ? null : array[5],
169
- accuracy: array[6],
170
- altitudeAccuracy: array[7] === Number.MIN_VALUE ? null : array[7],
171
- heading: array[8] === Number.MIN_VALUE ? null : array[8],
172
- speed: array[9] === Number.MIN_VALUE ? null : array[9]
173
- }
174
- },
175
- isExternal: false
176
- };
177
-
178
- case 0:
179
-
180
- const indexOfSecondComma = str.indexOf(',', indexOfFirstComma + 1);
181
- const eventTypeStr = str.substring(indexOfFirstComma + 1, indexOfSecondComma);
182
-
183
- const indexOfThirdComma = str.indexOf(',', indexOfSecondComma + 1);
184
- const time = str.substring(indexOfSecondComma + 1, indexOfThirdComma);
185
-
186
- const dataStr = str.substring(indexOfThirdComma + 1);
187
- const dataJson = JSON.parse(dataStr);
188
-
189
- let eventType, data;
190
- switch (eventTypeStr) {
191
-
192
- case 'network':
193
- eventType = EventType.Network;
194
- data = dataStr === null ? null : Network.fromCompressedJson(dataJson);
195
- break;
196
-
197
- case 'absolute-position':
198
- eventType = EventType.AbsolutePosition;
199
- data = dataStr === null ? null : UserPosition.fromJson(dataJson);
200
- break;
201
-
202
- case 'absolute-attitude':
203
- eventType = EventType.AbsoluteAttitude;
204
- data = dataStr === null ? null : UserPosition.fromJson(dataJson);
205
- break;
206
-
207
- case 'absolute-heading':
208
- eventType = EventType.AbsoluteHeading;
209
- data = dataStr === null ? null : UserPosition.fromJson(dataJson);
210
- break;
211
-
212
- default:
213
- throw new Error(`Cannot parse eventType: ${array[1]}`);
214
- }
215
-
216
- return {
217
- eventType,
218
- data,
219
- time: round(time),
220
- isExternal: true
221
- };
222
- }
223
-
224
- return null;
225
- }
226
- }
227
-
228
- export default NavigationLoggerConverter;
@@ -1,26 +0,0 @@
1
- const path = require('path');
2
-
3
- module.exports = {
4
- module: {
5
- rules: [
6
- {
7
- test: /\.jsx?$/,
8
- exclude: /(node_modules|.test.js|.spec.js|.mock.js)/,
9
- use: { loader: 'babel-loader' }
10
- },
11
- {
12
- test: /\.css$/,
13
- use: ['style-loader', 'css-loader']
14
- },
15
- {
16
- test: /\.(png|jpe?g|gif|svg)$/i,
17
- use: ['file-loader']
18
- }
19
- ]
20
- },
21
- resolve: {
22
- extensions: ['.js', '.jsx'],
23
- alias: { 'mapbox-gl': path.resolve('node_modules', 'mapbox-gl') }
24
- }
25
-
26
- };
@@ -1,25 +0,0 @@
1
- const merge = require('webpack-merge');
2
- const path = require('path');
3
-
4
- const common = require('./webpack.common.cjs');
5
- const config = require('../config.json');
6
-
7
- const distFolder = path.join(__dirname, '../', config.distFolder);
8
-
9
- module.exports = merge(common, {
10
- mode: 'development',
11
- entry: { 'providers-components': './debug/index.js' },
12
- output: {
13
- publicPath: '/js/',
14
- filename: '[name].js',
15
- path: path.join(distFolder, 'js'),
16
- libraryTarget: 'global'
17
- },
18
- devServer: {
19
- contentBase: distFolder,
20
- inline: true,
21
- hot: true,
22
- host: '0.0.0.0',
23
- port: 9000
24
- }
25
- });
@@ -1,15 +0,0 @@
1
- const merge = require('webpack-merge');
2
- const path = require('path');
3
-
4
- const common = require('./webpack.common.cjs');
5
- const config = require('../config.json');
6
-
7
- module.exports = merge(common, {
8
- mode: 'production',
9
- entry: './index.js',
10
- output: {
11
- filename: config.distFileName,
12
- path: path.join(__dirname, '../', config.distFolder),
13
- libraryTarget: 'commonjs2'
14
- }
15
- });
File without changes
File without changes