@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
package/package.json CHANGED
@@ -8,12 +8,12 @@
8
8
  "Guillaume Pannetier <guillaume.pannetier@getwemap.com>"
9
9
  ],
10
10
  "dependencies": {
11
- "@wemap/geo": "^3.0.0",
12
- "@wemap/graph": "^3.0.0",
11
+ "@wemap/geo": "^3.1.4",
12
+ "@wemap/graph": "^3.1.4",
13
13
  "@wemap/logger": "^3.0.0",
14
14
  "@wemap/maths": "^3.0.0",
15
- "@wemap/osm": "^3.1.0",
16
- "@wemap/utils": "^3.0.0",
15
+ "@wemap/osm": "^3.1.4",
16
+ "@wemap/utils": "^3.1.4",
17
17
  "geomagnetism": "^0.1.0",
18
18
  "lodash.isempty": "^4.4.0",
19
19
  "lodash.isnumber": "^3.0.3",
@@ -25,9 +25,10 @@
25
25
  "@babel/plugin-proposal-class-properties": "^7.5.5",
26
26
  "@babel/preset-env": "^7.5.5",
27
27
  "@babel/preset-react": "^7.0.0",
28
+ "@thibaudm/mapbox-gl-js-indoor": "^1.7.0-6",
28
29
  "babel-loader": "^8.0.6",
29
30
  "css-loader": "^3.2.0",
30
- "mapbox-gl": "^1.3.0",
31
+ "file-loader": "^5.0.2",
31
32
  "prop-types": "^15.7.2",
32
33
  "react": "^16.11.0",
33
34
  "react-dom": "^16.11.0",
@@ -60,9 +61,10 @@
60
61
  "build-debug": "webpack --display-modules --config webpack/webpack.dev.js",
61
62
  "stats": "webpack --config webpack/webpack.prod.js --profile --json > stats.json",
62
63
  "start": "webpack-dev-server --config webpack/webpack.dev.js --progress --inline --hot --https",
64
+ "start-secure": "webpack-dev-server --config webpack/webpack.dev.js --progress --inline --hot --https --cert $(grep PEM .env | cut -d '=' -f2) --key $(grep KEY .env | cut -d '=' -f2)",
63
65
  "lint": "eslint --ext .js,.jsx --quiet src",
64
66
  "test": "mocha -r esm \"src/**/*.spec.js\""
65
67
  },
66
- "version": "3.1.2",
67
- "gitHead": "d014d8da360a4d33f391eb0e86ad203f8a581582"
68
+ "version": "3.1.4",
69
+ "gitHead": "6c7ae4b3ebf1c24e46f3dccb84cfe91cc5534af4"
68
70
  }
@@ -19,11 +19,12 @@ class ProvidersInterface {
19
19
  * @param {EventType} eventType
20
20
  * @param {Function} onEvent
21
21
  * @param {Function} onError
22
+ * @param {Boolean} watchOnly if true, addEventListener does not start any provider, it just watches for events
22
23
  * @returns {Number}
23
24
  */
24
- static addEventListener(eventType, onEvent, onError) {
25
+ static addEventListener(eventType, onEvent, onError, watchOnly = false) {
25
26
  const provider = this._getMetaProviderFromEventType(eventType);
26
- const id = provider.addEventListener(events => onEvent(events[0].data), onError, this.name);
27
+ const id = provider.addEventListener(events => onEvent(events[0].data), onError, this.name, !watchOnly);
27
28
  this.idListeners.set(id, provider);
28
29
  return id;
29
30
  }
@@ -47,7 +48,7 @@ class ProvidersInterface {
47
48
  */
48
49
  static feed(eventType, data) {
49
50
  this._checkEventTypeDataConsistency(eventType, data);
50
- this._getMetaProviderFromEventType(eventType).feed(data);
51
+ this._getMetaProviderFromEventType(eventType).feed(data, eventType);
51
52
  }
52
53
 
53
54
  /**
@@ -111,7 +112,7 @@ class ProvidersInterface {
111
112
  }
112
113
  break;
113
114
  case EventType.Network:
114
- if (!(data instanceof Network)) {
115
+ if (!(data instanceof Network || data === null)) {
115
116
  throw errorFn('Network');
116
117
  }
117
118
  break;
@@ -1,3 +1,4 @@
1
+ import EventType from '../events/EventType';
1
2
  import Provider from './Provider';
2
3
  import ProviderEvent from '../events/ProviderEvent';
3
4
 
@@ -32,9 +33,10 @@ class MetaProvider extends Provider {
32
33
  /**
33
34
  * Input data from external interface
34
35
  * @param {ProviderEvent} event
36
+ * @param {EventType} eventType
35
37
  */
36
38
  // eslint-disable-next-line no-unused-vars
37
- feed(event) {
39
+ feed(event, eventType) {
38
40
  throw new Error('Not implemented');
39
41
  }
40
42
  }
@@ -12,7 +12,7 @@ class RelativeAttitudeFromInertialProvider extends Provider {
12
12
  /**
13
13
  * default relative attitude drift in rad.second-1
14
14
  */
15
- static DEFAULT_DRIFT = deg2rad(15) / 60;
15
+ static DEFAULT_DRIFT = deg2rad(5) / 60;
16
16
 
17
17
 
18
18
  /**
@@ -91,7 +91,7 @@ class AbsolutePositionFromRelProvider extends Provider {
91
91
  const bearing = Math.atan2(offsetPos.x, offsetPos.y);
92
92
 
93
93
  this.position = this.position.destinationPoint(dist, bearing, offsetPos.z);
94
- this.position.bearing = bearing;
94
+ this.position.bearing = offsetPos.bearing;
95
95
  this.position.time = event.timestamp;
96
96
  this.position.accuracy += offsetPos.accuracy;
97
97
 
@@ -15,19 +15,23 @@ import {
15
15
  } from '../../../Providers';
16
16
  import ProvidersOptions from '../../../ProvidersOptions';
17
17
 
18
- class AbsolutePositionProvider extends MetaProvider {
18
+ // Position accuracy uncertainty ratio
19
+ const ACCURACY_NEW_POS_EPS_RATIO = 1.5;
20
+ const ACCURACY_RELOC_RATIO = 2;
21
+ const MM_MAX_ANGLE = deg2rad(20);
22
+ const MM_MAX_DIST = 15;
23
+ const MM_MIN_DIST = 1;
24
+ const MM_MIN_TIME = 0.4;
19
25
 
20
- static ACCURACY_RELOC_RATIO = 2;
21
- static MM_MAX_ANGLE = deg2rad(20);
22
- static MM_MAX_DIST = 15;
23
- static MM_MIN_DIST = 1;
26
+ class AbsolutePositionProvider extends MetaProvider {
24
27
 
28
+ lastMMAttempt = -Infinity;
25
29
 
26
30
  constructor() {
27
31
  super();
28
32
  this.mapMatching = new MapMatching();
29
- this.mapMatching.maxDistance = AbsolutePositionProvider.MM_MAX_DIST;
30
- this.mapMatching.maxAngleBearing = AbsolutePositionProvider.MM_MAX_ANGLE;
33
+ this.mapMatching.maxDistance = MM_MAX_DIST;
34
+ this.mapMatching.maxAngleBearing = MM_MAX_ANGLE;
31
35
  }
32
36
 
33
37
  /**
@@ -68,7 +72,7 @@ class AbsolutePositionProvider extends MetaProvider {
68
72
  }
69
73
 
70
74
  this.gnssWifiProviderId = GnssWifi.addEventListener(
71
- events => this.onAbsolutePosition(events[0]),
75
+ events => this.onAbsolutePosition(events[0], false),
72
76
  noop,
73
77
  this.name
74
78
  );
@@ -86,16 +90,20 @@ class AbsolutePositionProvider extends MetaProvider {
86
90
  GnssWifi.removeEventListener(this.gnssWifiProviderId);
87
91
  }
88
92
 
89
- onAbsolutePosition(newPositionEvent) {
93
+ onAbsolutePosition(newPositionEvent, canContainLevel = true) {
90
94
  if (this.lastEvent) {
91
95
 
92
96
  const newPosition = newPositionEvent.data;
93
97
  const lastPosition = this.lastEvent.data;
94
98
 
95
- if (newPosition.distanceTo(lastPosition) < newPosition.accuracy
96
- && newPosition.accuracy > lastPosition.accuracy / AbsolutePositionProvider.ACCURACY_RELOC_RATIO) {
99
+ if (newPosition.distanceTo(lastPosition) < newPosition.accuracy * ACCURACY_NEW_POS_EPS_RATIO
100
+ && newPosition.accuracy > lastPosition.accuracy / ACCURACY_RELOC_RATIO) {
97
101
  return;
98
102
  }
103
+
104
+ if (!canContainLevel) {
105
+ newPosition.level = lastPosition.level;
106
+ }
99
107
  }
100
108
 
101
109
  this.notify(newPositionEvent.clone());
@@ -110,10 +118,12 @@ class AbsolutePositionProvider extends MetaProvider {
110
118
  * If map matching is not used or not set, raw position is returned
111
119
  */
112
120
  if (!ProvidersOptions.useMapMatching
113
- || !this.mapMatching.network) {
121
+ || !this.mapMatching.network
122
+ || newPositionEvent.data.time - this.lastMMAttempt < MM_MIN_TIME) {
114
123
  this.notify(newPositionEvent.clone());
115
124
  return;
116
125
  }
126
+ this.lastMMAttempt = newPositionEvent.data.time;
117
127
 
118
128
  const newPosition = newPositionEvent.data;
119
129
  const projection = this.mapMatching.getProjection(newPosition, true, true);
@@ -130,7 +140,7 @@ class AbsolutePositionProvider extends MetaProvider {
130
140
 
131
141
  // Do not use projection if it too close from itinerary,
132
142
  // this allows left/right movements (ie with ArCore)
133
- if (projection.distanceFromNearestElement > AbsolutePositionProvider.MM_MIN_DIST) {
143
+ if (projection.distanceFromNearestElement > MM_MIN_DIST) {
134
144
  projectedPosition.lat = projection.projection.lat;
135
145
  projectedPosition.lng = projection.projection.lng;
136
146
  }
@@ -145,9 +155,10 @@ class AbsolutePositionProvider extends MetaProvider {
145
155
 
146
156
  /**
147
157
  * @override
148
- * @param {UserPosition} position
158
+ * @param {UserPosition | Network} data
159
+ * @param {EventType} eventType
149
160
  */
150
- feed(data) {
161
+ feed(data, eventType) {
151
162
  if (data instanceof UserPosition) {
152
163
  const position = data;
153
164
  if (position.time === null) {
@@ -159,7 +170,7 @@ class AbsolutePositionProvider extends MetaProvider {
159
170
  this.onAbsolutePosition(this.createEvent(
160
171
  EventType.AbsolutePosition, position, position.time
161
172
  ));
162
- } else if (data instanceof Network) {
173
+ } else if (data instanceof Network || eventType === EventType.Network) {
163
174
  this.mapMatching.network = data;
164
175
  } else {
165
176
  throw new Error('Unknown feed object');
@@ -70,7 +70,8 @@ class GeoRelativePositionFromArCoreProvider extends Provider {
70
70
  north,
71
71
  up,
72
72
  relativePosition.time,
73
- 0
73
+ 0,
74
+ absoluteAttitude.heading
74
75
  );
75
76
 
76
77
  this.notify(this.createEvent(
@@ -116,7 +116,8 @@ class PdrProvider extends Provider {
116
116
  stepSize * Math.cos(deviceDirection),
117
117
  0,
118
118
  timestamp,
119
- accuracy
119
+ accuracy,
120
+ deviceDirection
120
121
  );
121
122
 
122
123
  this.notify(this.createEvent(
@@ -18,7 +18,6 @@ class PositionSmoother {
18
18
  constructor(callback, frequency = this.constructor.DEFAULT_FREQUENCY) {
19
19
  this.callback = callback;
20
20
  this.positionsQueue = [];
21
- this.timeoutPositions = null;
22
21
  this.frequency = frequency;
23
22
  }
24
23
 
@@ -63,7 +62,10 @@ class PositionSmoother {
63
62
  smoothedPosition.time = refTimestamp + (i - 1) / this.frequency;
64
63
  smoothedPosition.level = newPositionLevel;
65
64
  smoothedPosition.bearing = newPosition.bearing;
66
- smoothedPosition.accuracy += Math.max((newPosition.accuracy - smoothedPosition.accuracy) * i / nSamples, 0);
65
+ smoothedPosition.accuracy = Math.max(
66
+ smoothedPosition.accuracy + (newPosition.accuracy - smoothedPosition.accuracy) * i / nSamples,
67
+ 0
68
+ );
67
69
  this.positionsQueue.push(smoothedPosition);
68
70
  i++;
69
71
  }
@@ -87,6 +89,12 @@ class PositionSmoother {
87
89
  delete this.timeoutNotify;
88
90
  }
89
91
  }
92
+
93
+ clear() {
94
+ clearTimeout(this.timeoutNotify);
95
+ delete this.timeoutNotify;
96
+ this.positionsQueue = [];
97
+ }
90
98
  }
91
99
 
92
100
  export default PositionSmoother;
@@ -3,16 +3,16 @@ module.exports = {
3
3
  rules: [
4
4
  {
5
5
  test: /\.jsx?$/,
6
- include: [
7
- /src/,
8
- /wemap-(.*)/
9
- ],
10
- exclude: /(\/mapbox-gl\/|.test.js|.spec.js|.mock.js)/,
6
+ exclude: /(node_modules|.test.js|.spec.js|.mock.js)/,
11
7
  use: { loader: 'babel-loader' }
12
8
  },
13
9
  {
14
10
  test: /\.css$/,
15
11
  use: ['style-loader', 'css-loader']
12
+ },
13
+ {
14
+ test: /\.(png|jpe?g|gif|svg)$/i,
15
+ use: ['file-loader']
16
16
  }
17
17
  ]
18
18
  },
@@ -8,7 +8,7 @@ const distFolder = path.join(__dirname, '../', config.distFolder);
8
8
 
9
9
  module.exports = merge(common, {
10
10
  mode: 'development',
11
- entry: { 'providers-components': './debug/components/index.js' },
11
+ entry: { 'providers-components': './debug/index.js' },
12
12
  output: {
13
13
  publicPath: '/js/',
14
14
  filename: '[name].js',
@@ -21,5 +21,11 @@ module.exports = merge(common, {
21
21
  hot: true,
22
22
  host: '0.0.0.0',
23
23
  port: 9000
24
+ },
25
+ resolve: {
26
+ alias: {
27
+ 'mapbox-gl': '@thibaudm/mapbox-gl-js-indoor/dist/mapbox-gl.js',
28
+ 'mapbox-gl-css': '@thibaudm/mapbox-gl-js-indoor/dist/mapbox-gl.css'
29
+ }
24
30
  }
25
31
  });
@@ -1,27 +0,0 @@
1
- html,
2
- body {
3
- margin: 0;
4
- font-size: 12px;
5
- height: 100%;
6
- }
7
-
8
- @media screen and (min-width: 400px) {
9
- body {
10
- font-size: 14px;
11
- }
12
- }
13
-
14
- #app {
15
- height: 100%
16
- }
17
-
18
- p {
19
- margin-top: 0;
20
- }
21
-
22
- .title {
23
- font-size: 18px;
24
- font-weight: bold;
25
- margin-top: 10px;
26
- margin-bottom: 5px;
27
- }