@wemap/providers 3.1.19 → 3.1.21
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/components/Utils.js +4 -5
- package/debug/details/DetailsPositionComponent.jsx +1 -2
- package/package.json +5 -6
- package/src/providers/Provider.js +1 -2
- package/src/providers/attitude/absolute/AbsoluteAttitudeFromBrowserProvider.js +7 -6
- package/src/providers/attitude/relative/RelativeAttitudeFromBrowserProvider.js +1 -3
- package/src/providers/imu/ImuProvider.js +2 -4
- package/src/providers/legacy/helpers/HeadingUnlocker.js +4 -3
- package/src/providers/position/absolute/AbsolutePositionProvider.js +1 -1
- package/.env +0 -2
|
@@ -4,7 +4,6 @@ import { rad2deg } from '@wemap/maths';
|
|
|
4
4
|
import { OsrmUtils } from '@wemap/osm';
|
|
5
5
|
|
|
6
6
|
import ProviderEvent from '../../src/events/ProviderEvent';
|
|
7
|
-
import isNumber from 'lodash.isnumber';
|
|
8
7
|
|
|
9
8
|
const NOT_AVAILABLE_STR = 'Not available';
|
|
10
9
|
|
|
@@ -37,7 +36,7 @@ class Utils {
|
|
|
37
36
|
const roll = euler[2].toFixed(2);
|
|
38
37
|
const heading = attitude.headingDegrees.toFixed(2);
|
|
39
38
|
|
|
40
|
-
const accuracyString =
|
|
39
|
+
const accuracyString = attitude.accuracy !== null ? rad2deg(attitude.accuracy).toFixed(1) : '';
|
|
41
40
|
|
|
42
41
|
return (
|
|
43
42
|
<div>
|
|
@@ -91,9 +90,9 @@ class Utils {
|
|
|
91
90
|
Longitude: {position.lng.toFixed(7)}<br />
|
|
92
91
|
Altitude: {position.alt ? position.alt.toFixed(2) : NOT_AVAILABLE_STR}<br />
|
|
93
92
|
Level: {position.level ? position.level.toString() : NOT_AVAILABLE_STR}<br />
|
|
94
|
-
Bearing: {
|
|
95
|
-
Accuracy: {
|
|
96
|
-
Time: {
|
|
93
|
+
Bearing: {position.bearing !== null ? rad2deg(position.bearing).toFixed(2) : NOT_AVAILABLE_STR}<br />
|
|
94
|
+
Accuracy: {position.accuracy.toFixed(2)}<br />
|
|
95
|
+
Time: {position.time.toFixed(2)}
|
|
97
96
|
</p>
|
|
98
97
|
{(event instanceof ProviderEvent) ? Utils.renderTimeAndFromStack(event) : ''}
|
|
99
98
|
</div>
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import isNumber from 'lodash.isnumber';
|
|
2
1
|
import noop from 'lodash.noop';
|
|
3
2
|
import React from 'react';
|
|
4
3
|
|
|
@@ -84,7 +83,7 @@ class DetailsPositionComponent extends React.PureComponent {
|
|
|
84
83
|
this.refs.longitude.innerHTML = `${position.lng.toFixed(7)}°`;
|
|
85
84
|
this.refs.altitude.innerHTML = position.alt ? `${position.alt.toFixed(2)}m` : NOT_AVAILABLE_STR;
|
|
86
85
|
this.refs.level.innerHTML = position.level ? position.level.toString() : NOT_AVAILABLE_STR;
|
|
87
|
-
this.refs.bearing.innerHTML =
|
|
86
|
+
this.refs.bearing.innerHTML = position.bearing !== null ? `${rad2deg(position.bearing).toFixed(2)}°` : NOT_AVAILABLE_STR;
|
|
88
87
|
this.refs.accuracy.innerHTML = `${position.accuracy.toFixed(2)}m`;
|
|
89
88
|
this.refs.time.innerHTML = `${position.time.toFixed(2)}s`;
|
|
90
89
|
}
|
package/package.json
CHANGED
|
@@ -8,15 +8,14 @@
|
|
|
8
8
|
"Guillaume Pannetier <guillaume.pannetier@getwemap.com>"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@wemap/geo": "^3.1.
|
|
12
|
-
"@wemap/graph": "^3.1.
|
|
11
|
+
"@wemap/geo": "^3.1.21",
|
|
12
|
+
"@wemap/graph": "^3.1.21",
|
|
13
13
|
"@wemap/logger": "^3.0.0",
|
|
14
14
|
"@wemap/maths": "^3.1.15",
|
|
15
|
-
"@wemap/osm": "^3.1.
|
|
15
|
+
"@wemap/osm": "^3.1.21",
|
|
16
16
|
"@wemap/utils": "^3.1.5",
|
|
17
17
|
"geomagnetism": "^0.1.0",
|
|
18
18
|
"lodash.isempty": "^4.4.0",
|
|
19
|
-
"lodash.isnumber": "^3.0.3",
|
|
20
19
|
"lodash.noop": "^3.0.1"
|
|
21
20
|
},
|
|
22
21
|
"description": "A package using different geoloc systems",
|
|
@@ -65,6 +64,6 @@
|
|
|
65
64
|
"lint": "eslint --ext .js,.jsx --quiet src",
|
|
66
65
|
"test": "mocha -r esm \"src/**/*.spec.js\""
|
|
67
66
|
},
|
|
68
|
-
"version": "3.1.
|
|
69
|
-
"gitHead": "
|
|
67
|
+
"version": "3.1.21",
|
|
68
|
+
"gitHead": "17f72afdcf6098bf90d3dffc2cf0b15f9284d4d4"
|
|
70
69
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import isNumber from 'lodash.isnumber';
|
|
2
1
|
import noop from 'lodash.noop';
|
|
3
2
|
|
|
4
3
|
import { TimeUtils } from '@wemap/utils';
|
|
@@ -103,7 +102,7 @@ class Provider {
|
|
|
103
102
|
*/
|
|
104
103
|
static createEvent(dataType, data, timestamp, fromEvents = []) {
|
|
105
104
|
const event = new ProviderEvent(dataType, data);
|
|
106
|
-
event.timestamp =
|
|
105
|
+
event.timestamp = typeof timestamp === 'number' ? timestamp : TimeUtils.preciseTime / 1e3;
|
|
107
106
|
const newStack = fromEvents.reduce((acc, _event) => acc.concat(_event.providersStack), []);
|
|
108
107
|
// Remove duplicates and keep lasts
|
|
109
108
|
event.providersStack = [...new Set(newStack.reverse())].reverse();
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import geomagnetism from 'geomagnetism';
|
|
2
|
-
import isNumber from 'lodash.isnumber';
|
|
3
2
|
|
|
4
3
|
import {
|
|
5
4
|
Attitude, Coordinates
|
|
@@ -41,6 +40,8 @@ class AbsoluteAttitudeFromBrowserProvider extends Provider {
|
|
|
41
40
|
// from http://tyrex.inria.fr/mobile/benchmarks-attitude/
|
|
42
41
|
static DEFAULT_ACCURACY = deg2rad(15);
|
|
43
42
|
|
|
43
|
+
absolutePositionProviderId = null;
|
|
44
|
+
|
|
44
45
|
/**
|
|
45
46
|
* @override
|
|
46
47
|
*/
|
|
@@ -127,7 +128,7 @@ class AbsoluteAttitudeFromBrowserProvider extends Provider {
|
|
|
127
128
|
break;
|
|
128
129
|
}
|
|
129
130
|
|
|
130
|
-
if (
|
|
131
|
+
if (this.absolutePositionProviderId !== null) {
|
|
131
132
|
AbsolutePosition.removeEventListener(this.absolutePositionProviderId);
|
|
132
133
|
}
|
|
133
134
|
}
|
|
@@ -137,7 +138,7 @@ class AbsoluteAttitudeFromBrowserProvider extends Provider {
|
|
|
137
138
|
|
|
138
139
|
this.magQuaternionTimestamp = e.timeStamp / 1e3;
|
|
139
140
|
|
|
140
|
-
if (
|
|
141
|
+
if (typeof e.alpha !== 'number' || typeof e.beta !== 'number' || typeof e.gamma !== 'number') {
|
|
141
142
|
this.notifyError(new MissingSensorError().from('deviceorientationabsolute'));
|
|
142
143
|
return;
|
|
143
144
|
}
|
|
@@ -153,12 +154,12 @@ class AbsoluteAttitudeFromBrowserProvider extends Provider {
|
|
|
153
154
|
|
|
154
155
|
this.magQuaternionTimestamp = e.timeStamp / 1e3;
|
|
155
156
|
|
|
156
|
-
if (
|
|
157
|
+
if (typeof e.beta !== 'number' || typeof e.gamma !== 'number') {
|
|
157
158
|
this.notifyError(new MissingSensorError().from('deviceorientation'));
|
|
158
159
|
return;
|
|
159
160
|
}
|
|
160
161
|
|
|
161
|
-
if (
|
|
162
|
+
if (typeof e.webkitCompassHeading !== 'number') {
|
|
162
163
|
super.notifyError(new MissingMagnetometerError().from('deviceorientation'));
|
|
163
164
|
return;
|
|
164
165
|
}
|
|
@@ -217,7 +218,7 @@ class AbsoluteAttitudeFromBrowserProvider extends Provider {
|
|
|
217
218
|
this.declinationQuaternion = Quaternion.fromAxisAngle([0, 0, 1], - deg2rad(wmmResult.decl));
|
|
218
219
|
|
|
219
220
|
AbsolutePosition.removeEventListener(this.absolutePositionProviderId);
|
|
220
|
-
|
|
221
|
+
this.absolutePositionProviderId = null;
|
|
221
222
|
this.compute();
|
|
222
223
|
}
|
|
223
224
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import isnumber from 'lodash.isnumber';
|
|
2
|
-
|
|
3
1
|
import { Attitude } from '@wemap/geo';
|
|
4
2
|
import { Rotations } from '@wemap/maths';
|
|
5
3
|
import { BrowserUtils } from '@wemap/utils';
|
|
@@ -84,7 +82,7 @@ class RelativeAttitudeFromBrowserProvider extends Provider {
|
|
|
84
82
|
|
|
85
83
|
const timestamp = e.timeStamp / 1e3;
|
|
86
84
|
|
|
87
|
-
if (
|
|
85
|
+
if (typeof e.alpha !== 'number' || typeof e.beta !== 'number' || typeof e.gamma !== 'number') {
|
|
88
86
|
this.notifyError(new MissingSensorError().from('deviceorientation'));
|
|
89
87
|
return;
|
|
90
88
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import isnumber from 'lodash.isnumber';
|
|
2
|
-
|
|
3
1
|
import { deg2rad } from '@wemap/maths';
|
|
4
2
|
import {
|
|
5
3
|
Browser, BrowserUtils
|
|
@@ -95,7 +93,7 @@ class ImuProvider extends Provider {
|
|
|
95
93
|
x, y, z
|
|
96
94
|
} = e.accelerationIncludingGravity;
|
|
97
95
|
|
|
98
|
-
if (
|
|
96
|
+
if (typeof x === 'number' && typeof y === 'number' && typeof z === 'number') {
|
|
99
97
|
acc = [x, y, z];
|
|
100
98
|
|
|
101
99
|
if (BrowserUtils.name === Browser.SAFARI) {
|
|
@@ -116,7 +114,7 @@ class ImuProvider extends Provider {
|
|
|
116
114
|
alpha, beta, gamma
|
|
117
115
|
} = e.rotationRate;
|
|
118
116
|
|
|
119
|
-
if (
|
|
117
|
+
if (typeof alpha === 'number' && typeof beta === 'number' && typeof gamma === 'number') {
|
|
120
118
|
gyr = [deg2rad(alpha), deg2rad(beta), deg2rad(gamma)];
|
|
121
119
|
}
|
|
122
120
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import isnumber from 'lodash.isnumber';
|
|
2
|
-
|
|
3
1
|
import {
|
|
4
2
|
diffAngle, deg2rad
|
|
5
3
|
} from '@wemap/maths';
|
|
@@ -11,6 +9,8 @@ class HeadingUnlocker {
|
|
|
11
9
|
|
|
12
10
|
static LO_ANGLE = deg2rad(15);
|
|
13
11
|
|
|
12
|
+
waitingOrientation = null;
|
|
13
|
+
|
|
14
14
|
constructor() {
|
|
15
15
|
// HeadingUnlocker status, by default it is unlocked
|
|
16
16
|
this.locked = false;
|
|
@@ -18,6 +18,7 @@ class HeadingUnlocker {
|
|
|
18
18
|
|
|
19
19
|
unlock() {
|
|
20
20
|
this.locked = false;
|
|
21
|
+
this.waitingOrientation = null;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
lock(waitingOrientation) {
|
|
@@ -27,7 +28,7 @@ class HeadingUnlocker {
|
|
|
27
28
|
|
|
28
29
|
feedHeading(heading) {
|
|
29
30
|
|
|
30
|
-
if (
|
|
31
|
+
if (this.waitingOrientation === null) {
|
|
31
32
|
throw new Error('HeadingUnlocker has not been initialized by lock');
|
|
32
33
|
}
|
|
33
34
|
|
|
@@ -206,7 +206,7 @@ class AbsolutePositionProvider extends MetaProvider {
|
|
|
206
206
|
return null;
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
// Do not
|
|
209
|
+
// Do not use projection.projection directly, because position has some specific properties like bearing and altitude
|
|
210
210
|
const projectedPosition = position.clone();
|
|
211
211
|
projectedPosition.lat = projection.projection.lat;
|
|
212
212
|
projectedPosition.lng = projection.projection.lng;
|
package/.env
DELETED