@wemap/positioning 1.2.2 → 2.1.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.
- package/.eslintrc.json +4 -2
- package/debug/absolute-attitude.html +16 -0
- package/debug/gnss-wifi-pdr.html +16 -0
- package/debug/gnss-wifi.html +16 -0
- package/debug/imu.html +16 -0
- package/debug/inclination.html +16 -0
- package/debug/pdr.html +16 -0
- package/debug/pose.html +16 -0
- package/debug/positioning.html +16 -0
- package/debug/relative-attitude.html +16 -0
- package/package.json +6 -4
- package/src/PositioningHandler.js +124 -0
- package/src/components/AbsoluteAttitudeComponent.jsx +104 -0
- package/src/components/GnssWifiComponent.jsx +46 -0
- package/src/components/GnssWifiPdrComponent.jsx +85 -0
- package/src/components/ImuComponent.jsx +100 -0
- package/src/components/InclinationComponent.jsx +53 -0
- package/src/components/PdrComponent.jsx +88 -0
- package/src/components/PoseComponent.jsx +74 -0
- package/src/components/PositioningComponent.jsx +26 -0
- package/src/components/PositioningInclinationComponent.jsx +76 -0
- package/src/components/PositioningPoseComponent.jsx +111 -0
- package/src/components/RelativeAttitudeComponent.jsx +82 -0
- package/src/components/StartStopComponent.jsx +50 -0
- package/src/components/Utils.js +41 -2
- package/src/components/index.js +19 -2
- package/src/errors/AskImuOnDesktopError.js +9 -0
- package/src/errors/GeolocationApiMissingError.js +9 -0
- package/src/errors/GeolocationPermissionDeniedError.js +9 -0
- package/src/errors/GeolocationPositionUnavailableError.js +9 -0
- package/src/errors/IpResolveServerError.js +9 -0
- package/src/errors/MissingAccelerometerError.js +11 -0
- package/src/errors/MissingGyroscopeError.js +11 -0
- package/src/errors/MissingMagnetometerError.js +9 -0
- package/src/errors/MissingSensorError.js +14 -0
- package/src/events/EventType.js +20 -0
- package/src/events/ProviderError.js +52 -0
- package/src/events/ProviderEvent.js +35 -0
- package/src/index.js +3 -4
- package/src/providers/Constants.js +5 -0
- package/src/providers/FakeAbsolutePositionProvider.js +56 -0
- package/src/providers/Provider.js +218 -0
- package/src/providers/ProviderOptions.js +28 -0
- package/src/providers/ProvidersLogger.js +3 -3
- package/src/providers/attitude/AbsoluteAttitudeProvider.js +207 -0
- package/src/providers/attitude/EkfAttitude.js +238 -0
- package/src/providers/attitude/EkfAttitude.spec.js +116 -0
- package/src/providers/attitude/RelativeAttitudeProvider.js +129 -0
- package/src/providers/others/ImuProvider.js +186 -0
- package/src/providers/others/InclinationProvider.js +107 -0
- package/src/providers/others/MapMatchingProvider.js +147 -0
- package/src/providers/pose/GnssWifiPdrProvider.js +233 -0
- package/src/providers/pose/PoseProvider.js +90 -0
- package/src/providers/pose/pdr/PdrProvider.js +352 -0
- package/src/providers/pose/pdr/helpers/HeadingUnlocker.js +41 -0
- package/src/providers/pose/pdr/helpers/HeadingUnlocker.spec.js +26 -0
- package/src/providers/pose/pdr/helpers/Smoother.js +90 -0
- package/src/providers/pose/pdr/helpers/Smoother.spec.js +424 -0
- package/src/providers/pose/pdr/helpers/ThugDetector.js +37 -0
- package/src/providers/pose/pdr/steps/StepDetection.js +7 -0
- package/src/providers/pose/pdr/steps/StepDetectionLadetto.js +67 -0
- package/src/providers/pose/pdr/steps/StepDetectionMinMaxPeaks.js +80 -0
- package/src/providers/pose/pdr/steps/StepDetectionMinMaxPeaks2.js +108 -0
- package/src/providers/position/GnssWifiProvider.js +129 -0
- package/src/providers/position/IpProvider.js +75 -0
- package/src.old/components/Utils.js +35 -0
- package/src.old/components/index.js +13 -0
- package/src.old/index.js +7 -0
- package/{src → src.old}/providers/GnssPdrLocationSource.js +1 -1
- package/src.old/providers/ProvidersLogger.js +77 -0
- package/webpack/webpack.dev.js +1 -1
- package/debug/index.html +0 -15
- package/debug/index.old.html +0 -37
- package/scripts/release-github.js +0 -216
- package/src.new/NavigationHandler.js +0 -62
- package/src.new/index.js +0 -3
- package/src.new/providers/FakeLocationSource.js +0 -39
- /package/{src → src.old}/Constants.js +0 -0
- /package/{src → src.old}/NavigationHandler.js +0 -0
- /package/{src → src.old}/Pose.js +0 -0
- /package/{src → src.old}/attitude/AttitudeHandler.js +0 -0
- /package/{src → src.old}/attitude/EkfAttitude.js +0 -0
- /package/{src → src.old}/attitude/EkfAttitude.spec.js +0 -0
- /package/{src → src.old}/components/AbsoluteAttitude.jsx +0 -0
- /package/{src → src.old}/components/Imu.jsx +0 -0
- /package/{src → src.old}/components/LocationSource.jsx +0 -0
- /package/{src → src.old}/components/Logger.jsx +0 -0
- /package/{src → src.old}/components/NavigationDebugApp.jsx +0 -0
- /package/{src → src.old}/components/Others.jsx +0 -0
- /package/{src → src.old}/components/RelativeAttitude.jsx +0 -0
- /package/{src → src.old}/providers/FixedLocationImuLocationSource.js +0 -0
- /package/{src → src.old}/providers/GnssLocationSource.js +0 -0
- /package/{src → src.old}/providers/IPLocationSource.js +0 -0
- /package/{src → src.old}/providers/LocationSource.js +0 -0
- /package/{src → src.old}/providers/PdrLocationSource.js +0 -0
- /package/{src → src.old}/providers/pdr/HeadingUnlocker.js +0 -0
- /package/{src → src.old}/providers/pdr/HeadingUnlocker.spec.js +0 -0
- /package/{src → src.old}/providers/pdr/Smoother.js +0 -0
- /package/{src → src.old}/providers/pdr/Smoother.spec.js +0 -0
- /package/{src → src.old}/providers/pdr/ThugDetector.js +0 -0
- /package/{src → src.old}/providers/steps/StepDetection.js +0 -0
- /package/{src → src.old}/providers/steps/StepDetectionLadetto.js +0 -0
- /package/{src → src.old}/providers/steps/StepDetectionMinMaxPeaks.js +0 -0
- /package/{src → src.old}/providers/steps/StepDetectionMinMaxPeaks2.js +0 -0
- /package/{src → src.old}/sensors/SensorsCompatibility.js +0 -0
- /package/{src → src.old}/sensors/SensorsCompatibility.spec.js +0 -0
- /package/{src → src.old}/sensors/SensorsLogger.js +0 -0
- /package/{src → src.old}/sensors/SensorsLoggerUtils.js +0 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
|
|
2
|
+
// in seconds
|
|
3
|
+
const WINDOW_TIME = 0.3;
|
|
4
|
+
|
|
5
|
+
// in seconds
|
|
6
|
+
const MIN_TIME_BETWEEN_STEPS = 0.4;
|
|
7
|
+
|
|
8
|
+
// in Hz
|
|
9
|
+
const MAX_FRENQUENCY = 4;
|
|
10
|
+
const MIN_FRENQUENCY = 1;
|
|
11
|
+
|
|
12
|
+
// in m.s-2
|
|
13
|
+
const VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD = 0.75;
|
|
14
|
+
const VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD = -0.3;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class StepDetectionMinMaxPeaks2 {
|
|
18
|
+
|
|
19
|
+
constructor() {
|
|
20
|
+
this.slidingWindow = [];
|
|
21
|
+
|
|
22
|
+
this.lastStepTimestamp = -MIN_TIME_BETWEEN_STEPS;
|
|
23
|
+
this.previousVerticalAcc = 0;
|
|
24
|
+
this.influence = 0.2;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
compute(timestamp, linearAcc, angularRate) {
|
|
29
|
+
|
|
30
|
+
const verticalAcc = this.influence * (linearAcc[2] * 2) + (1 - this.influence) * this.previousVerticalAcc;
|
|
31
|
+
this.previousVerticalAcc = verticalAcc;
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
if (Math.sqrt(angularRate[0] ** 2 + angularRate[1] ** 2 + angularRate[2] ** 2) > 0.75) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (this.lastStepTimestamp && this.lastStepTimestamp + MIN_TIME_BETWEEN_STEPS > timestamp) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
let maxValue = Number.MIN_SAFE_INTEGER;
|
|
43
|
+
let minValue = Number.MAX_SAFE_INTEGER;
|
|
44
|
+
|
|
45
|
+
this.slidingWindow.forEach(function(item, index, object) {
|
|
46
|
+
if (item.timestamp < timestamp - WINDOW_TIME) {
|
|
47
|
+
object.splice(index, 1);
|
|
48
|
+
} else {
|
|
49
|
+
maxValue = Math.max(item.verticalAcc, maxValue);
|
|
50
|
+
minValue = Math.min(item.verticalAcc, minValue);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
this.slidingWindow.push({
|
|
54
|
+
timestamp: timestamp,
|
|
55
|
+
verticalAcc: verticalAcc
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
if (maxValue > VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD
|
|
60
|
+
&& minValue < VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD) {
|
|
61
|
+
|
|
62
|
+
const timeInterval = this.lastStepTimestamp ? timestamp - this.lastStepTimestamp : 1;
|
|
63
|
+
this.frequency = Math.min(Math.max((1 / timeInterval), MIN_FRENQUENCY), MAX_FRENQUENCY);
|
|
64
|
+
|
|
65
|
+
this.lastStepTimestamp = timestamp;
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
get lastStepSize() {
|
|
73
|
+
|
|
74
|
+
if (!this.frequency) {
|
|
75
|
+
return 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const kParamA = 0.45;
|
|
79
|
+
const kParamB = 0.2;
|
|
80
|
+
return kParamA + kParamB * this.frequency;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
get speed() {
|
|
84
|
+
return this.lastStepSize && this.frequency ? this.lastStepSize * this.frequency : 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
mean(data) {
|
|
88
|
+
let sum = 0.0, mean = 0.0;
|
|
89
|
+
|
|
90
|
+
for (let i = 0; i < data.length; ++i) {
|
|
91
|
+
sum += data[i].verticalAcc;
|
|
92
|
+
}
|
|
93
|
+
mean = sum / data.length;
|
|
94
|
+
return mean;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
stddev(data) {
|
|
98
|
+
const theMean = this.mean(data);
|
|
99
|
+
let standardDeviation = 0;
|
|
100
|
+
for (let i = 0; i < data.length; ++i) {
|
|
101
|
+
standardDeviation += (data[i].verticalAcc - theMean) ** 2;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return Math.sqrt(standardDeviation / data.length);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export default StepDetectionMinMaxPeaks2;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { deg2rad } from '@wemap/maths';
|
|
2
|
+
import { WGS84UserPosition } from '@wemap/geo';
|
|
3
|
+
import { DateUtils } from '@wemap/utils';
|
|
4
|
+
|
|
5
|
+
import EventType from '../../events/EventType';
|
|
6
|
+
import GeolocationApiMissingError from '../../errors/GeolocationApiMissingError';
|
|
7
|
+
import Provider from '../Provider';
|
|
8
|
+
import GeolocationPermissionDeniedError from '../../errors/GeolocationPermissionDeniedError';
|
|
9
|
+
import GeolocationPositionUnavailableError from '../../errors/GeolocationPositionUnavailableError';
|
|
10
|
+
|
|
11
|
+
const POSITION_OPTIONS = {
|
|
12
|
+
enableHighAccuracy: true,
|
|
13
|
+
timeout: Infinity,
|
|
14
|
+
maximumAge: 0
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* GnssWifiProvider is a provider based on navigator.geolocation.
|
|
19
|
+
* This API does not allow us to know if the position returned is provided
|
|
20
|
+
* by Wifi Fingerprinting algorithms or by GNSS. That is why the name is
|
|
21
|
+
* "GnssWifi".
|
|
22
|
+
*/
|
|
23
|
+
class GnssWifiProvider extends Provider {
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @override
|
|
27
|
+
*/
|
|
28
|
+
static get displayName() {
|
|
29
|
+
return 'GNSS / Wifi from Browser';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @override
|
|
34
|
+
*/
|
|
35
|
+
static get eventsType() {
|
|
36
|
+
return [EventType.AbsolutePosition];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @override
|
|
41
|
+
*/
|
|
42
|
+
static checkAvailabilityErrors() {
|
|
43
|
+
|
|
44
|
+
if (navigator && navigator.geolocation) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return [
|
|
49
|
+
GnssWifiProvider.createError(
|
|
50
|
+
EventType.AbsolutePosition,
|
|
51
|
+
new GeolocationApiMissingError()
|
|
52
|
+
)
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @override
|
|
58
|
+
*/
|
|
59
|
+
startInternal() {
|
|
60
|
+
|
|
61
|
+
this.geoLocationId = navigator.geolocation.watchPosition(
|
|
62
|
+
this.onNewPosition,
|
|
63
|
+
this.onPositionError,
|
|
64
|
+
POSITION_OPTIONS
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @override
|
|
71
|
+
*/
|
|
72
|
+
stopInternal() {
|
|
73
|
+
|
|
74
|
+
navigator.geolocation.clearWatch(this.geoLocationId);
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @private
|
|
80
|
+
*/
|
|
81
|
+
onNewPosition = position => {
|
|
82
|
+
const { coords } = position;
|
|
83
|
+
if (!coords) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
let bearing;
|
|
88
|
+
if (coords.heading) {
|
|
89
|
+
bearing = deg2rad(coords.heading);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const timestamp = DateUtils.unixTimestampToPerformanceNow(position.timestamp) / 1e3;
|
|
93
|
+
|
|
94
|
+
const location = new WGS84UserPosition(
|
|
95
|
+
coords.latitude,
|
|
96
|
+
coords.longitude,
|
|
97
|
+
coords.altitude,
|
|
98
|
+
timestamp,
|
|
99
|
+
coords.accuracy,
|
|
100
|
+
bearing,
|
|
101
|
+
GnssWifiProvider.name);
|
|
102
|
+
|
|
103
|
+
this.notify(this.createEvent(
|
|
104
|
+
EventType.AbsolutePosition, location, timestamp
|
|
105
|
+
));
|
|
106
|
+
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
onPositionError = error => {
|
|
110
|
+
|
|
111
|
+
let customError;
|
|
112
|
+
switch (error.code) {
|
|
113
|
+
case 1:
|
|
114
|
+
customError = new GeolocationPermissionDeniedError(error.message);
|
|
115
|
+
break;
|
|
116
|
+
case 2:
|
|
117
|
+
customError = new GeolocationPositionUnavailableError(error.message);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (customError) {
|
|
121
|
+
this.notifyError(this.createError(
|
|
122
|
+
EventType.AbsolutePosition,
|
|
123
|
+
customError
|
|
124
|
+
));
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export default GnssWifiProvider;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { WGS84UserPosition } from '@wemap/geo';
|
|
2
|
+
|
|
3
|
+
import EventType from '../../events/EventType';
|
|
4
|
+
import Provider from '../Provider';
|
|
5
|
+
import IpResolveServerError from '../../errors/IpResolveServerError';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* GnssWifiProvider is a provider based on navigator.geolocation.
|
|
9
|
+
* This API does not allow us to know if the position returned is provided
|
|
10
|
+
* by Wifi Fingerprinting algorithms or by GNSS. That is why the name is
|
|
11
|
+
* "GnssWifi".
|
|
12
|
+
*/
|
|
13
|
+
class GnssWifiProvider extends Provider {
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @override
|
|
17
|
+
*/
|
|
18
|
+
static get displayName() {
|
|
19
|
+
return 'IP from ipinfo.io';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @override
|
|
24
|
+
*/
|
|
25
|
+
static get eventsType() {
|
|
26
|
+
return [EventType.AbsolutePosition];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @override
|
|
31
|
+
*/
|
|
32
|
+
static checkAvailabilityErrors() {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @override
|
|
38
|
+
*/
|
|
39
|
+
startInternal() {
|
|
40
|
+
|
|
41
|
+
fetch('https://ipinfo.io/geo?token=24a7ca2f3b489d')
|
|
42
|
+
.then((response) => {
|
|
43
|
+
if (!response) {
|
|
44
|
+
this.notifyError(this.createError(
|
|
45
|
+
EventType.AbsolutePosition,
|
|
46
|
+
new IpResolveServerError()
|
|
47
|
+
));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const timestamp = performance.now() / 1e3;
|
|
52
|
+
|
|
53
|
+
const position = new WGS84UserPosition(
|
|
54
|
+
parseFloat(response.loc.split(',')[0]),
|
|
55
|
+
parseFloat(response.loc.split(',')[1]),
|
|
56
|
+
null,
|
|
57
|
+
timestamp
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
this.notify(this.createEvent(
|
|
61
|
+
EventType.AbsolutePosition, position, timestamp
|
|
62
|
+
));
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @override
|
|
68
|
+
*/
|
|
69
|
+
stopInternal() {
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export default GnssWifiProvider;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react'; // eslint-disable-line no-unused-vars
|
|
2
|
+
|
|
3
|
+
class Utils {
|
|
4
|
+
|
|
5
|
+
static renderAttitude(attitude) {
|
|
6
|
+
|
|
7
|
+
if (!attitude) {
|
|
8
|
+
return <p>Waiting</p>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (attitude === -1) {
|
|
12
|
+
return <p>Not available</p>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const quaternion = attitude.quaternion;
|
|
16
|
+
|
|
17
|
+
const w = quaternion[0].toFixed(3);
|
|
18
|
+
const x = quaternion[1].toFixed(3);
|
|
19
|
+
const y = quaternion[2].toFixed(3);
|
|
20
|
+
const z = quaternion[3].toFixed(3);
|
|
21
|
+
|
|
22
|
+
const euler = attitude.eulerAnglesDegrees;
|
|
23
|
+
const yaw = euler[0].toFixed(2);
|
|
24
|
+
const pitch = euler[1].toFixed(2);
|
|
25
|
+
const roll = euler[2].toFixed(2);
|
|
26
|
+
const heading = attitude.headingDegrees.toFixed(2);
|
|
27
|
+
|
|
28
|
+
return <p>Quaternion: [{w}, {x}, {y}, {z}]<br />
|
|
29
|
+
Eulers: [{yaw}, {pitch}, {roll}]<br />
|
|
30
|
+
Heading: {heading}</p>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default Utils;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import NavigationDebugApp from './NavigationDebugApp';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import ReactDOM from 'react-dom';
|
|
4
|
+
|
|
5
|
+
const createReactElement = (component, container) => ReactDOM.render(
|
|
6
|
+
React.createElement(component, {}, null),
|
|
7
|
+
container
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
NavigationDebugApp,
|
|
12
|
+
createReactElement
|
|
13
|
+
};
|
package/src.old/index.js
ADDED
|
@@ -132,7 +132,7 @@ class GnssPdrLocationSource extends LocationSource {
|
|
|
132
132
|
* MapMatching
|
|
133
133
|
*/
|
|
134
134
|
|
|
135
|
-
enableMapMatching(network
|
|
135
|
+
enableMapMatching(network, maxDistance = MM_GNSS_DIST, maxAngleBearing = MM_GNSS_ANGLE) {
|
|
136
136
|
this.pdrLocationSource.enableMapMatching(network, maxDistance, maxAngleBearing);
|
|
137
137
|
super.enableMapMatching(network, maxDistance, maxAngleBearing);
|
|
138
138
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import Logger from '@wemap/logger';
|
|
2
|
+
|
|
3
|
+
let currentId = 0;
|
|
4
|
+
const objectsIdMap = new WeakMap();
|
|
5
|
+
|
|
6
|
+
let pushEvents = {};
|
|
7
|
+
let pushEventsRef = {};
|
|
8
|
+
|
|
9
|
+
let interval;
|
|
10
|
+
let initDate;
|
|
11
|
+
|
|
12
|
+
class ProvidersLogger {
|
|
13
|
+
|
|
14
|
+
static initializeInterval() {
|
|
15
|
+
|
|
16
|
+
if (interval) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interval = setInterval(() => {
|
|
21
|
+
|
|
22
|
+
for (const [key, value] of Object.entries(pushEvents)) {
|
|
23
|
+
Logger.debug('Received ' + value + ' values from ' + pushEventsRef[key].constructor.name + ' last second');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
pushEvents = {};
|
|
27
|
+
pushEventsRef = {};
|
|
28
|
+
}, 1000);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static getObjectId(object) {
|
|
32
|
+
if (!objectsIdMap.has(object)) {
|
|
33
|
+
objectsIdMap.set(object, ++currentId);
|
|
34
|
+
}
|
|
35
|
+
return objectsIdMap.get(object);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static addEvent(object, method) {
|
|
39
|
+
|
|
40
|
+
if (!ProvidersLogger.enabled) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!initDate) {
|
|
45
|
+
initDate = Date.now();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
ProvidersLogger.initializeInterval();
|
|
49
|
+
|
|
50
|
+
const objectId = ProvidersLogger.getObjectId(object);
|
|
51
|
+
const objectClassName = object.constructor.name;
|
|
52
|
+
|
|
53
|
+
Logger.debug(objectClassName + '[' + objectId + '].' + method);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static addPushEvent(object) {
|
|
57
|
+
|
|
58
|
+
if (!ProvidersLogger.enabled) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const objectId = ProvidersLogger.getObjectId(object);
|
|
63
|
+
|
|
64
|
+
let counter = pushEvents[objectId];
|
|
65
|
+
if (!counter) {
|
|
66
|
+
counter = 0;
|
|
67
|
+
pushEventsRef[objectId] = object;
|
|
68
|
+
}
|
|
69
|
+
pushEvents[objectId] = counter + 1;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
static get enabled() {
|
|
73
|
+
return Logger.LOG_LEVEL === Logger.DEBUG;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
export default ProvidersLogger;
|
package/webpack/webpack.dev.js
CHANGED
|
@@ -7,7 +7,7 @@ const debugFolder = path.join(__dirname, '../debug');
|
|
|
7
7
|
|
|
8
8
|
module.exports = merge(common, {
|
|
9
9
|
mode: 'development',
|
|
10
|
-
entry: { '
|
|
10
|
+
entry: { 'positioning-components': './src/components/index.js' },
|
|
11
11
|
output: {
|
|
12
12
|
publicPath: '/js/',
|
|
13
13
|
filename: '[name].js',
|
package/debug/index.html
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="utf-8">
|
|
6
|
-
<title>Debug navigation</title>
|
|
7
|
-
<script src="/js/navigation-components.js"></script>
|
|
8
|
-
</head>
|
|
9
|
-
|
|
10
|
-
<body>
|
|
11
|
-
<div id="app"></div>
|
|
12
|
-
<script>createReactElement(NavigationDebugApp, document.getElementById('app'));</script>
|
|
13
|
-
</body>
|
|
14
|
-
|
|
15
|
-
</html>
|
package/debug/index.old.html
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="utf-8">
|
|
6
|
-
|
|
7
|
-
<title>Positioning</title>
|
|
8
|
-
|
|
9
|
-
<script src="/js/navigation.js"></script>
|
|
10
|
-
|
|
11
|
-
</head>
|
|
12
|
-
|
|
13
|
-
<body>
|
|
14
|
-
Hello world !
|
|
15
|
-
|
|
16
|
-
<script>
|
|
17
|
-
const navHandler = new NavigationHandler(pose => console.log(pose));
|
|
18
|
-
|
|
19
|
-
navHandler.startIfNecessary()
|
|
20
|
-
.then(() => {
|
|
21
|
-
console.log('Navigation started');
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
setTimeout(() => {
|
|
25
|
-
navHandler.startIfNecessary();
|
|
26
|
-
}, 3000);
|
|
27
|
-
|
|
28
|
-
setTimeout(() => {
|
|
29
|
-
navHandler.stop()
|
|
30
|
-
.then(() => {
|
|
31
|
-
console.log('Navigation stopped');
|
|
32
|
-
});
|
|
33
|
-
}, 5000);
|
|
34
|
-
</script>
|
|
35
|
-
</body>
|
|
36
|
-
|
|
37
|
-
</html>
|