@wemap/positioning 2.0.0 → 2.2.0

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 (99) hide show
  1. package/.eslintrc.json +4 -2
  2. package/debug/absolute-attitude.html +16 -0
  3. package/debug/arcore.html +16 -0
  4. package/debug/gnss-wifi-pdr.html +16 -0
  5. package/debug/gnss-wifi.html +16 -0
  6. package/debug/imu.html +16 -0
  7. package/debug/inclination.html +16 -0
  8. package/debug/pdr.html +16 -0
  9. package/debug/pose.html +16 -0
  10. package/debug/positioning.html +16 -0
  11. package/debug/relative-attitude.html +16 -0
  12. package/package.json +7 -4
  13. package/src/PositioningHandler.js +96 -34
  14. package/src/components/AbsoluteAttitudeComponent.jsx +104 -0
  15. package/src/components/ArCoreComponent.jsx +74 -0
  16. package/src/components/GnssWifiComponent.jsx +58 -0
  17. package/src/components/GnssWifiPdrComponent.jsx +94 -0
  18. package/src/components/ImuComponent.jsx +100 -0
  19. package/src/components/InclinationComponent.jsx +53 -0
  20. package/src/components/MapComponent.jsx +226 -0
  21. package/src/components/PdrComponent.jsx +97 -0
  22. package/src/components/PoseComponent.jsx +81 -0
  23. package/src/components/PositioningComponent.jsx +26 -0
  24. package/src/components/PositioningInclinationComponent.jsx +76 -0
  25. package/src/components/PositioningPoseComponent.jsx +120 -0
  26. package/src/components/RelativeAttitudeComponent.jsx +82 -0
  27. package/src/components/StartStopComponent.jsx +50 -0
  28. package/src/components/Utils.js +92 -0
  29. package/src/components/index.js +32 -0
  30. package/src/errors/AskImuOnDesktopError.js +9 -0
  31. package/src/errors/GeolocationApiMissingError.js +9 -0
  32. package/src/errors/GeolocationPermissionDeniedError.js +9 -0
  33. package/src/errors/GeolocationPositionUnavailableError.js +9 -0
  34. package/src/errors/IpResolveServerError.js +9 -0
  35. package/src/errors/MissingAccelerometerError.js +11 -0
  36. package/src/errors/MissingArCoreError.js +9 -0
  37. package/src/errors/MissingGyroscopeError.js +11 -0
  38. package/src/errors/MissingMagnetometerError.js +9 -0
  39. package/src/errors/MissingNativeInterfaceError.js +9 -0
  40. package/src/errors/MissingSensorError.js +14 -0
  41. package/src/events/EventType.js +20 -0
  42. package/src/events/ProviderError.js +52 -0
  43. package/src/events/ProviderEvent.js +35 -0
  44. package/src/index.js +2 -2
  45. package/src/providers/Constants.js +5 -0
  46. package/src/providers/FakeAbsolutePositionProvider.js +56 -0
  47. package/src/providers/Provider.js +230 -0
  48. package/src/providers/ProviderOptions.js +28 -0
  49. package/{src.old → src}/providers/ProvidersLogger.js +2 -2
  50. package/src/providers/attitude/AbsoluteAttitudeProvider.js +207 -0
  51. package/src/providers/attitude/RelativeAttitudeProvider.js +129 -0
  52. package/src/providers/others/ImuProvider.js +186 -0
  53. package/src/providers/others/InclinationProvider.js +107 -0
  54. package/{src.old/providers/LocationSource.js → src/providers/others/MapMatchingProvider.js} +5 -148
  55. package/src/providers/pose/ArCoreProvider.js +127 -0
  56. package/src/providers/pose/GnssWifiPdrProvider.js +233 -0
  57. package/src/providers/pose/PoseProvider.js +90 -0
  58. package/{src.old/providers/PdrLocationSource.js → src/providers/pose/pdr/PdrProvider.js} +145 -113
  59. package/{src.old/providers/pdr → src/providers/pose/pdr/helpers}/Smoother.js +1 -1
  60. package/src/providers/position/GnssWifiProvider.js +129 -0
  61. package/src/providers/position/IpProvider.js +75 -0
  62. package/webpack/webpack.common.js +1 -1
  63. package/webpack/webpack.dev.js +1 -1
  64. package/debug/index.html +0 -15
  65. package/debug/index.old.html +0 -37
  66. package/scripts/release-github.js +0 -216
  67. package/src/providers/FakeLocationSource.js +0 -36
  68. package/src.old/Constants.js +0 -11
  69. package/src.old/NavigationHandler.js +0 -244
  70. package/src.old/Pose.js +0 -8
  71. package/src.old/attitude/AttitudeHandler.js +0 -342
  72. package/src.old/components/AbsoluteAttitude.jsx +0 -136
  73. package/src.old/components/Imu.jsx +0 -89
  74. package/src.old/components/LocationSource.jsx +0 -434
  75. package/src.old/components/Logger.jsx +0 -113
  76. package/src.old/components/NavigationDebugApp.jsx +0 -106
  77. package/src.old/components/Others.jsx +0 -121
  78. package/src.old/components/RelativeAttitude.jsx +0 -104
  79. package/src.old/components/Utils.js +0 -35
  80. package/src.old/components/index.js +0 -13
  81. package/src.old/index.js +0 -7
  82. package/src.old/providers/FixedLocationImuLocationSource.js +0 -66
  83. package/src.old/providers/GnssLocationSource.js +0 -118
  84. package/src.old/providers/GnssPdrLocationSource.js +0 -182
  85. package/src.old/providers/IPLocationSource.js +0 -96
  86. package/src.old/sensors/SensorsCompatibility.js +0 -486
  87. package/src.old/sensors/SensorsCompatibility.spec.js +0 -270
  88. package/src.old/sensors/SensorsLogger.js +0 -94
  89. package/src.old/sensors/SensorsLoggerUtils.js +0 -35
  90. /package/{src.old → src/providers}/attitude/EkfAttitude.js +0 -0
  91. /package/{src.old → src/providers}/attitude/EkfAttitude.spec.js +0 -0
  92. /package/{src.old/providers/pdr → src/providers/pose/pdr/helpers}/HeadingUnlocker.js +0 -0
  93. /package/{src.old/providers/pdr → src/providers/pose/pdr/helpers}/HeadingUnlocker.spec.js +0 -0
  94. /package/{src.old/providers/pdr → src/providers/pose/pdr/helpers}/Smoother.spec.js +0 -0
  95. /package/{src.old/providers/pdr → src/providers/pose/pdr/helpers}/ThugDetector.js +0 -0
  96. /package/{src.old/providers → src/providers/pose/pdr}/steps/StepDetection.js +0 -0
  97. /package/{src.old/providers → src/providers/pose/pdr}/steps/StepDetectionLadetto.js +0 -0
  98. /package/{src.old/providers → src/providers/pose/pdr}/steps/StepDetectionMinMaxPeaks.js +0 -0
  99. /package/{src.old/providers → src/providers/pose/pdr}/steps/StepDetectionMinMaxPeaks2.js +0 -0
@@ -1,182 +0,0 @@
1
- /* eslint max-statements: ["error", 40]*/
2
-
3
- import { WGS84UserPosition } from '@wemap/geo';
4
-
5
- import LocationSource from './LocationSource';
6
- import AttitudeHandler from '../attitude/AttitudeHandler';
7
- import Constants from '../Constants';
8
- import GnssLocationSource from './GnssLocationSource';
9
- import PdrLocationSource from './PdrLocationSource';
10
- import NavigationHandler from '../NavigationHandler';
11
-
12
- const GPF_ACCURACY = 25;
13
- const GPF_DISTANCE = 25;
14
-
15
- const MM_GNSS_DIST = 20;
16
- const MM_GNSS_ANGLE = 20;
17
-
18
- class GnssPdrLocationSource extends LocationSource {
19
-
20
- constructor(callback, options) {
21
- super(callback);
22
-
23
- // Create a PdrLocationSource. Updates from Pdr will automatically set pose of GnssPdrLocationSource
24
- this.pdrLocationSource = new PdrLocationSource(pose => {
25
- this.pose = pose;
26
- this.notify();
27
- }, options);
28
-
29
- // Create a GNSSLocationSource without IMU for attitude
30
- this.gnssLocationSource = new GnssLocationSource(e => this.callbackGnss(e), false);
31
-
32
- this.attitudeHandler = new AttitudeHandler();
33
-
34
- this.gpsLastUpdate = 0;
35
- this.isFirstGnssUpdate = true;
36
- this.isFirstAttitudeUpdate = true;
37
- }
38
-
39
- /**
40
- * Get provider name
41
- * @override
42
- */
43
- static get providerName() {
44
- return Constants.LOCATION_SOURCE_PROVIDERS.GNSS_PDR;
45
- }
46
-
47
- start() {
48
- super.start();
49
-
50
- return Promise.all([
51
- this.pdrLocationSource.start(),
52
- this.gnssLocationSource.start(),
53
- this.attitudeHandler.startAbsolute(attitude => this.callbackAttitude(attitude))]);
54
- }
55
-
56
- stop() {
57
- super.stop();
58
-
59
- this.pdrLocationSource.stop();
60
- this.gnssLocationSource.stop();
61
- this.attitudeHandler.stopAbsolute();
62
- }
63
-
64
- setLogger(logger) {
65
- super.setLogger(logger);
66
- this.pdrLocationSource.setLogger(logger);
67
- this.gnssLocationSource.setLogger(logger);
68
- this.attitudeHandler.setLogger(logger);
69
- }
70
-
71
-
72
- callbackGnss(pose) {
73
-
74
- // This should be called to update True North / Magnetic North declination
75
- this.attitudeHandler.setUserLocationForAbsolute(pose.location);
76
-
77
- if (pose.location.accuracy > GPF_ACCURACY) {
78
- return;
79
- }
80
-
81
- this.gnssLocation = pose.location.clone();
82
- this.gnssLocation.alt = NavigationHandler.DEFAULT_ALTITUDE;
83
-
84
- if (!this.pose.location || this.pose.location
85
- && this.pose.location.distanceTo(this.gnssLocation) > GPF_DISTANCE) {
86
-
87
- if (!this.mapMatching || !this.pose.attitude) {
88
- this.pdrLocationSource.setLocation(this.gnssLocation);
89
- } else {
90
-
91
- this.gnssLocation.bearing = this.pose.attitude.headingDegrees;
92
- const projection = this.mapMatching.getProjection(this.gnssLocation);
93
-
94
- if (projection && projection.projection) {
95
-
96
- // Create a new location from projection and new GNSS location.
97
- const projectedLocation = WGS84UserPosition.fromWGS84(projection.projection, this.gnssLocation);
98
- this.pdrLocationSource.setLocation(projectedLocation);
99
-
100
- // // If nearest element is an edge, use its orientation to set heading
101
- // if (projection.nearestElement instanceof Edge) {
102
- // const edgeBearing = projection.nearestElement.bearing;
103
- // const diff1 = MathUtils.diffAngle(MathUtils.deg2rad(this.gnssLocation.bearing), edgeBearing);
104
- // const diff2 = MathUtils.diffAngle(MathUtils.deg2rad(this.gnssLocation.bearing), edgeBearing + Math.PI);
105
- // this.pdrLocationSource.setHeading(diff1 < diff2 ? edgeBearing : edgeBearing + Math.PI);
106
- // }
107
-
108
- if (this.lastAttitude) {
109
- this.pdrLocationSource.setHeading(this.lastAttitude.heading);
110
- }
111
-
112
- } else {
113
- this.pdrLocationSource.setLocation(this.gnssLocation);
114
- }
115
- }
116
- }
117
-
118
- }
119
-
120
- callbackAttitude(attitude) {
121
-
122
- if (this.isFirstAttitudeUpdate) {
123
- this.pdrLocationSource.setHeading(attitude.heading);
124
- this.isFirstAttitudeUpdate = false;
125
- }
126
-
127
- this.lastAttitude = attitude;
128
- }
129
-
130
-
131
- /**
132
- * MapMatching
133
- */
134
-
135
- enableMapMatching(network = null, maxDistance = MM_GNSS_DIST, maxAngleBearing = MM_GNSS_ANGLE) {
136
- this.pdrLocationSource.enableMapMatching(network, maxDistance, maxAngleBearing);
137
- super.enableMapMatching(network, maxDistance, maxAngleBearing);
138
- }
139
-
140
-
141
- setNetwork(network) {
142
- this.pdrLocationSource.setNetwork(network);
143
- super.setNetwork(network);
144
- }
145
-
146
- /**
147
- * Itinerary
148
- */
149
-
150
- setItinerary(itinerary) {
151
-
152
- const isFirstItinerary = !this.itinerary;
153
-
154
- super.setItinerary(itinerary);
155
-
156
- if (isFirstItinerary && itinerary.length > 0) {
157
-
158
- // When the first itinerary is received, first or second node (depending on MM_GNSS_DIST) is used as a starting point. No map-matching is needed here as router already provide the projection in the itinerary (node2 is node1 projection on OSRM network).
159
-
160
- if (!this.gnssLocation
161
- || itinerary.length < 2
162
- || !itinerary.points[0].equalsTo(this.gnssLocation)) {
163
- console.warn('Itinerary has not been calculated from GnssPdrLocationSource and these is not recommanded');
164
- }
165
-
166
- let startEdge;
167
- if (itinerary.firstEdge.getLength() <= MM_GNSS_DIST) {
168
- startEdge = itinerary.firstEdge;
169
- } else {
170
- startEdge = itinerary.secondEdge;
171
- }
172
- const startPoint = WGS84UserPosition.fromWGS84(startEdge.node1);
173
- startPoint.alt = NavigationHandler.DEFAULT_ALTITUDE;
174
- this.pdrLocationSource.setLocation(startPoint);
175
- this.pdrLocationSource.setStepDetectionLockerOrientation(startEdge.getBearing());
176
- }
177
-
178
- }
179
-
180
- }
181
-
182
- export default GnssPdrLocationSource;
@@ -1,96 +0,0 @@
1
- import { WGS84UserPosition } from '@wemap/geo';
2
-
3
- import LocationSource from './LocationSource';
4
- import AttitudeHandler from '../attitude/AttitudeHandler';
5
- import Constants from '../Constants';
6
- import SensorsLogger from '../sensors/SensorsLogger';
7
-
8
-
9
- class IPLocationSource extends LocationSource {
10
-
11
- constructor(callback, imuEnabled = true) {
12
- super(callback);
13
-
14
- if (imuEnabled) {
15
- this.attitudeHandler = new AttitudeHandler();
16
- }
17
- }
18
-
19
- /**
20
- * Start the location source algorithm
21
- * @override
22
- */
23
- start() {
24
- super.start();
25
-
26
- if (this.attitudeHandler) {
27
- this.attitudeHandler.startAbsolute(
28
- attitude => {
29
- this.pose.attitude = attitude;
30
- this.notify();
31
- })
32
- // Attitude is optionnal here, do not throw an error if it not works.
33
- .catch(() => { });
34
- }
35
-
36
- return new Promise((resolve, reject) => {
37
- this.geolocate()
38
- .then(location => {
39
- this.pose.location = location;
40
- if (this.attitudeHandler) {
41
- this.attitudeHandler.setUserLocationForAbsolute(location);
42
- }
43
- resolve();
44
- this.notify();
45
- })
46
- .catch(reject);
47
- });
48
- }
49
-
50
- /**
51
- * Stop the location source algorithm
52
- * @override
53
- */
54
- stop() {
55
- super.stop();
56
-
57
- if (this.attitudeHandler) {
58
- this.attitudeHandler.stopAbsolute();
59
- this.attitudeHandler = null;
60
- }
61
- }
62
-
63
- geolocate() {
64
- return new Promise((resolve, reject) => {
65
- fetch('https://ipinfo.io/geo?token=24a7ca2f3b489d')
66
- .then((response) => {
67
- if (!response) {
68
- reject();
69
- }
70
-
71
- const position = new WGS84UserPosition(
72
- parseFloat(response.loc.split(',')[0]),
73
- parseFloat(response.loc.split(',')[1]),
74
- null,
75
- performance.now() / 1e3
76
- );
77
-
78
- resolve(position);
79
-
80
- if (this.logger) {
81
- this.logger.feedWithCurrentTime(SensorsLogger.DataType.IP_POSITION, [position.lat, position.lng]);
82
- }
83
- });
84
- });
85
- }
86
-
87
- /**
88
- * Get provider name
89
- * @override
90
- */
91
- static get providerName() {
92
- return Constants.LOCATION_SOURCE_PROVIDERS.IP;
93
- }
94
- }
95
-
96
- export default IPLocationSource;