@wemap/positioning 2.7.13 → 14.0.0-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 (104) hide show
  1. package/README.md +51 -0
  2. package/dist/index.d.ts +19 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +16582 -0
  5. package/dist/qr-scanner-worker.min-CdBZO1_x.js +2 -0
  6. package/dist/src/ILocationSource.d.ts +104 -0
  7. package/dist/src/ILocationSource.d.ts.map +1 -0
  8. package/dist/src/MapMatching.d.ts +83 -0
  9. package/dist/src/MapMatching.d.ts.map +1 -0
  10. package/dist/src/location-sources/GnssWifiLocationSource.d.ts +79 -0
  11. package/dist/src/location-sources/GnssWifiLocationSource.d.ts.map +1 -0
  12. package/dist/src/location-sources/LocationSource.d.ts +102 -0
  13. package/dist/src/location-sources/LocationSource.d.ts.map +1 -0
  14. package/dist/src/location-sources/VPSLocationSource.d.ts +107 -0
  15. package/dist/src/location-sources/VPSLocationSource.d.ts.map +1 -0
  16. package/dist/src/types.d.ts +65 -0
  17. package/dist/src/types.d.ts.map +1 -0
  18. package/dist/src/utils/permissions.d.ts +29 -0
  19. package/dist/src/utils/permissions.d.ts.map +1 -0
  20. package/dist/vitest.config.d.ts +3 -0
  21. package/dist/vitest.config.d.ts.map +1 -0
  22. package/package.json +23 -59
  23. package/babel.config.js +0 -11
  24. package/config.json +0 -4
  25. package/debug/absolute-attitude.html +0 -16
  26. package/debug/arcore-absolute.html +0 -16
  27. package/debug/arcore.html +0 -16
  28. package/debug/components/AbsoluteAttitudeComponent.jsx +0 -100
  29. package/debug/components/ArCoreAbsoluteComponent.jsx +0 -104
  30. package/debug/components/ArCoreComponent.jsx +0 -69
  31. package/debug/components/GnssWifiComponent.jsx +0 -56
  32. package/debug/components/GnssWifiPdrComponent.jsx +0 -76
  33. package/debug/components/ImuComponent.jsx +0 -95
  34. package/debug/components/InclinationComponent.jsx +0 -52
  35. package/debug/components/MapComponent.jsx +0 -228
  36. package/debug/components/NavigationConfig.js +0 -92
  37. package/debug/components/PdrComponent.jsx +0 -75
  38. package/debug/components/PoseComponent.jsx +0 -77
  39. package/debug/components/PositioningComponent.jsx +0 -29
  40. package/debug/components/PositioningInclinationComponent.jsx +0 -82
  41. package/debug/components/PositioningPoseComponent.jsx +0 -117
  42. package/debug/components/RelativeAttitudeComponent.jsx +0 -82
  43. package/debug/components/StartStopComponent.jsx +0 -50
  44. package/debug/components/Utils.js +0 -128
  45. package/debug/components/index.js +0 -34
  46. package/debug/gnss-wifi-pdr.html +0 -16
  47. package/debug/gnss-wifi.html +0 -16
  48. package/debug/imu.html +0 -16
  49. package/debug/inclination.html +0 -16
  50. package/debug/pdr.html +0 -16
  51. package/debug/pose.html +0 -16
  52. package/debug/positioning.html +0 -16
  53. package/debug/relative-attitude.html +0 -16
  54. package/dist/wemap-positioning.min.js +0 -1
  55. package/index.js +0 -8
  56. package/src/PositioningHandler.js +0 -237
  57. package/src/PositioningHandler.spec.js +0 -294
  58. package/src/PositioningOptions.js +0 -34
  59. package/src/errors/AskImuOnDesktopError.js +0 -9
  60. package/src/errors/ContainsIgnoredProviderError.js +0 -9
  61. package/src/errors/GeolocationApiMissingError.js +0 -9
  62. package/src/errors/GeolocationPermissionDeniedError.js +0 -9
  63. package/src/errors/GeolocationPositionUnavailableError.js +0 -9
  64. package/src/errors/IpResolveServerError.js +0 -9
  65. package/src/errors/MissingAccelerometerError.js +0 -11
  66. package/src/errors/MissingArCoreError.js +0 -9
  67. package/src/errors/MissingGyroscopeError.js +0 -11
  68. package/src/errors/MissingMagnetometerError.js +0 -9
  69. package/src/errors/MissingNativeInterfaceError.js +0 -9
  70. package/src/errors/MissingSensorError.js +0 -14
  71. package/src/errors/NoProviderFoundError.js +0 -9
  72. package/src/events/Availability.js +0 -30
  73. package/src/events/EventType.js +0 -22
  74. package/src/events/ProviderEvent.js +0 -35
  75. package/src/providers/Constants.js +0 -5
  76. package/src/providers/Provider.js +0 -247
  77. package/src/providers/ProvidersList.js +0 -44
  78. package/src/providers/ProvidersLogger.js +0 -75
  79. package/src/providers/attitude/AbsoluteAttitudeProvider.js +0 -199
  80. package/src/providers/attitude/EkfAttitude.js +0 -238
  81. package/src/providers/attitude/EkfAttitude.spec.js +0 -116
  82. package/src/providers/attitude/RelativeAttitudeProvider.js +0 -121
  83. package/src/providers/others/ImuProvider.js +0 -179
  84. package/src/providers/others/InclinationProvider.js +0 -99
  85. package/src/providers/others/MapMatchingProvider.js +0 -65
  86. package/src/providers/pose/ArCoreAbsoluteProvider.js +0 -235
  87. package/src/providers/pose/ArCoreProvider.js +0 -191
  88. package/src/providers/pose/GnssWifiPdrProvider.js +0 -219
  89. package/src/providers/pose/PoseProvider.js +0 -71
  90. package/src/providers/pose/pdr/PdrProvider.js +0 -364
  91. package/src/providers/pose/pdr/helpers/HeadingUnlocker.js +0 -41
  92. package/src/providers/pose/pdr/helpers/HeadingUnlocker.spec.js +0 -26
  93. package/src/providers/pose/pdr/helpers/Smoother.js +0 -92
  94. package/src/providers/pose/pdr/helpers/Smoother.spec.js +0 -426
  95. package/src/providers/pose/pdr/helpers/ThugDetector.js +0 -37
  96. package/src/providers/pose/pdr/steps/StepDetection.js +0 -7
  97. package/src/providers/pose/pdr/steps/StepDetectionLadetto.js +0 -67
  98. package/src/providers/pose/pdr/steps/StepDetectionMinMaxPeaks.js +0 -80
  99. package/src/providers/pose/pdr/steps/StepDetectionMinMaxPeaks2.js +0 -108
  100. package/src/providers/position/GnssWifiProvider.js +0 -130
  101. package/src/providers/position/IpProvider.js +0 -74
  102. package/webpack/webpack.common.js +0 -20
  103. package/webpack/webpack.dev.js +0 -24
  104. package/webpack/webpack.prod.js +0 -15
@@ -1,80 +0,0 @@
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 = 1.5;
14
- const VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD = -1;
15
-
16
-
17
- class StepDetectionMinMaxPeaks {
18
-
19
- constructor() {
20
- this.slidingWindow = [];
21
-
22
- this.lastStepTimestamp = -MIN_TIME_BETWEEN_STEPS;
23
- }
24
-
25
-
26
- compute(timestamp, linearAcc) {
27
-
28
- if (this.lastStepTimestamp && this.lastStepTimestamp + MIN_TIME_BETWEEN_STEPS > timestamp) {
29
- return false;
30
- }
31
-
32
- let maxValue = Number.MIN_SAFE_INTEGER;
33
- let minValue = Number.MAX_SAFE_INTEGER;
34
-
35
- const windowTime = WINDOW_TIME;
36
- this.slidingWindow.forEach(function(item, index, object) {
37
- if (item.timestamp < timestamp - windowTime) {
38
- object.splice(index, 1);
39
- } else {
40
- maxValue = Math.max(item.verticalAcc, maxValue);
41
- minValue = Math.min(item.verticalAcc, minValue);
42
- }
43
- });
44
- this.slidingWindow.push({
45
- timestamp: timestamp,
46
- verticalAcc: linearAcc[2]
47
- });
48
-
49
-
50
- if (maxValue > VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD
51
- && minValue < VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD) {
52
-
53
- const timeInterval = this.lastStepTimestamp ? timestamp - this.lastStepTimestamp : 1;
54
- this.frequency = Math.min(Math.max((1 / timeInterval), MIN_FRENQUENCY), MAX_FRENQUENCY);
55
-
56
- this.lastStepTimestamp = timestamp;
57
- return true;
58
- }
59
-
60
- return false;
61
- }
62
-
63
- get lastStepSize() {
64
-
65
- if (!this.frequency) {
66
- return 0;
67
- }
68
-
69
- const kParamA = 0.45;
70
- const kParamB = 0.2;
71
- return kParamA + kParamB * this.frequency;
72
- }
73
-
74
- get speed() {
75
- return this.lastStepTimestamp ? this.lastStepSize * this.frequency : 0;
76
- }
77
-
78
- }
79
-
80
- export default StepDetectionMinMaxPeaks;
@@ -1,108 +0,0 @@
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;
@@ -1,130 +0,0 @@
1
- import { deg2rad } from '@wemap/maths';
2
- import { WGS84UserPosition } from '@wemap/geo';
3
- import { TimeUtils } 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
- import Availability from '../../events/Availability';
11
-
12
- const POSITION_OPTIONS = {
13
- enableHighAccuracy: true,
14
- timeout: Infinity,
15
- maximumAge: 0
16
- };
17
-
18
- /**
19
- * GnssWifiProvider is a provider based on navigator.geolocation.
20
- * This API does not allow us to know if the position returned is provided
21
- * by Wifi Fingerprinting algorithms or by GNSS. That is why the name is
22
- * "GnssWifi".
23
- */
24
- class GnssWifiProvider extends Provider {
25
-
26
- /**
27
- * @override
28
- */
29
- static get name() {
30
- return 'GnssWifi';
31
- }
32
-
33
- /**
34
- * @override
35
- */
36
- static get displayName() {
37
- return 'GNSS / Wifi from Browser';
38
- }
39
-
40
- /**
41
- * @override
42
- */
43
- static get eventsType() {
44
- return [EventType.AbsolutePosition];
45
- }
46
-
47
- /**
48
- * @override
49
- */
50
- static checkAvailability(options) {
51
- return Availability.merge(
52
- super.checkAvailability(options),
53
- navigator && navigator.geolocation
54
- ? Availability.yes()
55
- : Availability.no(new GeolocationApiMissingError())
56
- );
57
- }
58
-
59
- /**
60
- * @override
61
- */
62
- startInternal() {
63
-
64
- this.geoLocationId = navigator.geolocation.watchPosition(
65
- this.onNewPosition,
66
- this.onPositionError,
67
- POSITION_OPTIONS
68
- );
69
-
70
- }
71
-
72
- /**
73
- * @override
74
- */
75
- stopInternal() {
76
-
77
- navigator.geolocation.clearWatch(this.geoLocationId);
78
-
79
- }
80
-
81
- /**
82
- * @private
83
- */
84
- onNewPosition = geolocation => {
85
- const { coords } = geolocation;
86
- if (!coords) {
87
- return;
88
- }
89
-
90
- let bearing;
91
- if (coords.heading) {
92
- bearing = deg2rad(coords.heading);
93
- }
94
-
95
- const timestamp = TimeUtils.unixTimestampToPreciseTime(geolocation.timestamp) / 1e3;
96
-
97
- const position = new WGS84UserPosition(
98
- coords.latitude,
99
- coords.longitude,
100
- null,
101
- null,
102
- timestamp,
103
- coords.accuracy,
104
- bearing,
105
- GnssWifiProvider.name);
106
-
107
- this.notify(this.createEvent(
108
- EventType.AbsolutePosition, position, timestamp
109
- ));
110
-
111
- };
112
-
113
- onPositionError = error => {
114
-
115
- let customError;
116
- switch (error.code) {
117
- case 1:
118
- customError = new GeolocationPermissionDeniedError(error.message);
119
- break;
120
- case 2:
121
- customError = new GeolocationPositionUnavailableError(error.message);
122
- }
123
-
124
- if (customError) {
125
- this.notifyError(customError);
126
- }
127
- };
128
- }
129
-
130
- export default GnssWifiProvider;
@@ -1,74 +0,0 @@
1
- import { WGS84UserPosition } from '@wemap/geo';
2
- import { TimeUtils } from '@wemap/utils';
3
-
4
- import EventType from '../../events/EventType';
5
- import Provider from '../Provider';
6
- import IpResolveServerError from '../../errors/IpResolveServerError';
7
-
8
- /**
9
- * GnssWifiProvider is a provider based on navigator.geolocation.
10
- * This API does not allow us to know if the position returned is provided
11
- * by Wifi Fingerprinting algorithms or by GNSS. That is why the name is
12
- * "GnssWifi".
13
- */
14
- class IpProvider extends Provider {
15
-
16
- /**
17
- * @override
18
- */
19
- static get name() {
20
- return 'IP';
21
- }
22
-
23
- /**
24
- * @override
25
- */
26
- static get displayName() {
27
- return 'IP from ipinfo.io';
28
- }
29
-
30
- /**
31
- * @override
32
- */
33
- static get eventsType() {
34
- return [EventType.AbsolutePosition];
35
- }
36
-
37
- /**
38
- * @override
39
- */
40
- startInternal() {
41
-
42
- fetch('https://ipinfo.io/geo?token=24a7ca2f3b489d')
43
- .then((response) => {
44
- if (!response) {
45
- this.notifyError(new IpResolveServerError());
46
- return;
47
- }
48
-
49
- const timestamp = TimeUtils.preciseTime / 1e3;
50
-
51
- const position = new WGS84UserPosition(
52
- parseFloat(response.loc.split(',')[0]),
53
- parseFloat(response.loc.split(',')[1]),
54
- null,
55
- null,
56
- timestamp
57
- );
58
-
59
- this.notify(this.createEvent(
60
- EventType.AbsolutePosition, position, timestamp
61
- ));
62
- });
63
- }
64
-
65
- /**
66
- * @override
67
- */
68
- stopInternal() {
69
-
70
- }
71
-
72
- }
73
-
74
- export default IpProvider;
@@ -1,20 +0,0 @@
1
- module.exports = {
2
- module: {
3
- rules: [
4
- {
5
- test: /\.jsx?$/,
6
- include: [
7
- /src/,
8
- /wemap-(.*)/
9
- ],
10
- exclude: /(\/mapbox-gl\/|.test.js|.spec.js|.mock.js)/,
11
- use: { loader: 'babel-loader' }
12
- },
13
- {
14
- test: /\.css$/,
15
- use: ['style-loader', 'css-loader']
16
- }
17
- ]
18
- },
19
- resolve: { extensions: ['.js', '.jsx'] }
20
- };
@@ -1,24 +0,0 @@
1
- const merge = require('webpack-merge');
2
- const path = require('path');
3
-
4
- const common = require('./webpack.common.js');
5
-
6
- const debugFolder = path.join(__dirname, '../debug');
7
-
8
- module.exports = merge(common, {
9
- mode: 'development',
10
- entry: { 'positioning-components': './debug/components/index.js' },
11
- output: {
12
- publicPath: '/js/',
13
- filename: '[name].js',
14
- path: path.join(debugFolder, 'js'),
15
- libraryTarget: 'global'
16
- },
17
- devServer: {
18
- contentBase: debugFolder,
19
- inline: true,
20
- hot: true,
21
- host: '0.0.0.0',
22
- port: 9000
23
- }
24
- });
@@ -1,15 +0,0 @@
1
- const merge = require('webpack-merge');
2
- const path = require('path');
3
-
4
- const common = require('./webpack.common.js');
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
- });