@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEhE;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,IAAI;IACnB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,YAAY,GAAG,gBAAgB,CAAC;IAC3C,uDAAuD;IACvD,QAAQ,CAAC,EAAE,QAAQ,GAAG,gBAAgB,CAAC;IACvC,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,8EAA8E;IAC9E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gEAAgE;IAChE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB;IAC/D,2DAA2D;IAC3D,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ *
3
+ * Note: This function should be called right after a user interaction otherwise it will return false.
4
+ *
5
+ * @returns True if sensor permissions are granted, false otherwise
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { requestSensorPermissions } from '@wemap/positioning';
10
+ *
11
+ * const hasSensorPermissions = await requestSensorPermissions();
12
+ * console.log(hasSensorPermissions);
13
+ * ```
14
+ */
15
+ export declare function requestSensorPermissions(): Promise<boolean>;
16
+ /**
17
+ *
18
+ * @returns True if location permissions are granted, false otherwise
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * import { requestLocationPermissions } from '@wemap/positioning';
23
+ *
24
+ * const hasLocationPermissions = await requestLocationPermissions();
25
+ * console.log(hasLocationPermissions);
26
+ * ```
27
+ */
28
+ export declare function requestLocationPermissions(): Promise<boolean>;
29
+ //# sourceMappingURL=permissions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../../src/utils/permissions.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,OAAO,CAAC,CAkBjE;AAGD;;;;;;;;;;;GAWG;AACH,wBAAsB,0BAA0B,IAAI,OAAO,CAAC,OAAO,CAAC,CAWnE"}
@@ -0,0 +1,3 @@
1
+ declare const _default: import('vite').UserConfig;
2
+ export default _default;
3
+ //# sourceMappingURL=vitest.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":";AAMA,wBAcG"}
package/package.json CHANGED
@@ -1,66 +1,30 @@
1
1
  {
2
- "author": "Wemap",
3
- "bugs": {
4
- "url": "https://github.com/wemap/wemap-positioning-js/issues"
2
+ "name": "@wemap/positioning",
3
+ "version": "14.0.0-0",
4
+ "type": "module",
5
+ "private": false,
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "main": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/index.js",
14
+ "types": "./dist/index.d.ts"
15
+ }
5
16
  },
6
- "contributors": [
7
- "Thibaud Michel <thibaud@getwemap.com>",
8
- "Guillaume Pannetier <guillaume.pannetier@getwemap.com>"
17
+ "files": [
18
+ "dist"
9
19
  ],
10
20
  "dependencies": {
11
- "@wemap/geo": "^2.7.9",
12
- "@wemap/graph": "^2.7.9",
13
- "@wemap/logger": "^2.7.7",
14
- "@wemap/maths": "^2.7.7",
15
- "@wemap/osm": "^2.7.13",
16
- "@wemap/utils": "^2.7.7",
17
- "geomagnetism": "^0.1.0",
18
- "lodash.isempty": "^4.4.0",
19
- "lodash.isnumber": "^3.0.3",
20
- "lodash.noop": "^3.0.1"
21
+ "@wemap/core": "14.0.0-0"
21
22
  },
22
- "description": "A package using different geoloc systems",
23
23
  "devDependencies": {
24
- "@babel/core": "^7.5.5",
25
- "@babel/plugin-proposal-class-properties": "^7.5.5",
26
- "@babel/preset-env": "^7.5.5",
27
- "@babel/preset-react": "^7.0.0",
28
- "babel-loader": "^8.0.6",
29
- "css-loader": "^3.2.0",
30
- "mapbox-gl": "^1.3.0",
31
- "prop-types": "^15.7.2",
32
- "react": "^16.11.0",
33
- "react-dom": "^16.11.0",
34
- "style-loader": "^1.0.0",
35
- "webpack": "^4.39.3",
36
- "webpack-cli": "^3.3.7",
37
- "webpack-dev-server": "^3.9.0",
38
- "webpack-merge": "^4.2.1"
39
- },
40
- "homepage": "https://github.com/wemap/wemap-modules-js#readme",
41
- "keywords": [
42
- "wemap",
43
- "positioning",
44
- "pdr",
45
- "wifi",
46
- "gnss",
47
- "mapmatching",
48
- "step-detection"
49
- ],
50
- "license": "ISC",
51
- "main": "index.js",
52
- "name": "@wemap/positioning",
53
- "repository": {
54
- "type": "git",
55
- "url": "git+https://github.com/wemap/wemap-modules-js.git"
56
- },
57
- "scripts": {
58
- "build": "webpack --display-modules --config webpack/webpack.prod.js",
59
- "stats": "webpack --config webpack/webpack.prod.js --profile --json > stats.json",
60
- "start": "webpack-dev-server --config webpack/webpack.dev.js --progress --inline --hot --https",
61
- "lint": "eslint --ext .js,.jsx --quiet src",
62
- "test": "mocha -r esm \"src/**/*.spec.js\""
63
- },
64
- "version": "2.7.13",
65
- "gitHead": "bbe3d0a45f1260fcc8c50a62cda4b849ca82ca05"
24
+ "@wemap/geo-legacy": "^13.3.0",
25
+ "@wemap/maths-legacy": "^13.3.0",
26
+ "@wemap/providers-legacy": "^13.3.0",
27
+ "@wemap/routers-legacy": "^13.3.0",
28
+ "@wemap/utils-legacy": "^13.3.0"
29
+ }
66
30
  }
package/babel.config.js DELETED
@@ -1,11 +0,0 @@
1
- module.exports = function(api) {
2
- api.cache(true);
3
-
4
- const presets = ['@babel/preset-env', '@babel/preset-react'];
5
- const plugins = ['@babel/plugin-proposal-class-properties'];
6
-
7
- return {
8
- presets,
9
- plugins
10
- };
11
- };
package/config.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "distFolder": "dist",
3
- "distFileName": "wemap-positioning.min.js"
4
- }
@@ -1,16 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
-
4
- <head>
5
- <meta charset="utf-8">
6
- <meta name="viewport" content="width=device-width, user-scalable=no">
7
- <title>Debug Absolute Attitude</title>
8
- <script src="/js/positioning-components.js"></script>
9
- </head>
10
-
11
- <body>
12
- <div id="app"></div>
13
- <script>createReactElement(AbsoluteAttitudeComponent, document.getElementById('app'));</script>
14
- </body>
15
-
16
- </html>
@@ -1,16 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
-
4
- <head>
5
- <meta charset="utf-8">
6
- <meta name="viewport" content="width=device-width, user-scalable=no">
7
- <title>Debug ARCore Absolute</title>
8
- <script src="/js/positioning-components.js"></script>
9
- </head>
10
-
11
- <body>
12
- <div id="app"></div>
13
- <script>createReactElement(ArCoreAbsoluteComponent, document.getElementById('app'));</script>
14
- </body>
15
-
16
- </html>
package/debug/arcore.html DELETED
@@ -1,16 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
-
4
- <head>
5
- <meta charset="utf-8">
6
- <meta name="viewport" content="width=device-width, user-scalable=no">
7
- <title>Debug ARCore</title>
8
- <script src="/js/positioning-components.js"></script>
9
- </head>
10
-
11
- <body>
12
- <div id="app"></div>
13
- <script>createReactElement(ArCoreComponent, document.getElementById('app'));</script>
14
- </body>
15
-
16
- </html>
@@ -1,100 +0,0 @@
1
- import React from 'react';
2
-
3
- import AbsoluteAttitudeProvider from '../../src/providers/attitude/AbsoluteAttitudeProvider';
4
- import NavigationConfig from './NavigationConfig';
5
- import Utils from './Utils';
6
- import EventType from '../../src/events/EventType';
7
- import ProvidersLogger from '../../src/providers/ProvidersLogger';
8
-
9
- ProvidersLogger.enabled = true;
10
-
11
- class AbsoluteAttitudeComponent extends React.Component {
12
-
13
- constructor(props, context) {
14
- super(props, context);
15
-
16
- this.state = {
17
- attitudeBrowser: null,
18
- deviceorientation: null,
19
- deviceorientationabsolute: null
20
- };
21
-
22
- this.absoluteAttitudeProvider = new AbsoluteAttitudeProvider(this.onEvent, this.onError);
23
- this.absoluteAttitudeProvider.setPosition(NavigationConfig.INITIAL_POSITION);
24
- }
25
-
26
- componentDidMount() {
27
- this.absoluteAttitudeProvider.start();
28
-
29
- this.onDeviceOrientationEventListener = (e) => this.setState({ deviceorientation: e });
30
- window.addEventListener('deviceorientation', this.onDeviceOrientationEventListener, true);
31
-
32
-
33
- this.onDeviceOrientationAbsoluteEventListener = (e) => this.setState({ deviceorientationabsolute: e });
34
- window.addEventListener('deviceorientationabsolute', this.onDeviceOrientationAbsoluteEventListener, true);
35
- }
36
-
37
- componentWillUnmount() {
38
- this.absoluteAttitudeProvider.stop();
39
-
40
- window.removeEventListener('deviceorientation', this.onDeviceOrientationEventListener, true);
41
-
42
- window.removeEventListener('deviceorientationabsolute', this.onDeviceOrientationAbsoluteEventListener, true);
43
- }
44
-
45
- onEvent = events => {
46
- events.forEach(event => {
47
- if (event.dataType === EventType.AbsoluteAttitude) {
48
- this.setState({ attitudeBrowser: event.data });
49
- }
50
- });
51
- };
52
-
53
- onError = error => {
54
- this.setState({ attitudeBrowser: error });
55
- }
56
-
57
- render() {
58
-
59
- let rawRender = <span>Not available</span>;
60
-
61
- if (this.state.deviceorientation && this.state.deviceorientation.webkitCompassHeading) {
62
- const alpha = this.state.deviceorientation.alpha;
63
- const beta = this.state.deviceorientation.beta;
64
- const gamma = this.state.deviceorientation.gamma;
65
- const webkitCompassHeading = this.state.deviceorientation.webkitCompassHeading;
66
-
67
- if (alpha && beta && gamma && webkitCompassHeading) {
68
- rawRender = <p>alpha: {alpha.toFixed(2)}, <br />
69
- beta: {beta.toFixed(2)}, <br />
70
- gamma: {gamma.toFixed(2)}, <br />
71
- webkitCompassHeading: {webkitCompassHeading.toFixed(2)}</p>;
72
- }
73
-
74
- } else if (this.state.deviceorientationabsolute) {
75
- const alpha = this.state.deviceorientationabsolute.alpha;
76
- const beta = this.state.deviceorientationabsolute.beta;
77
- const gamma = this.state.deviceorientationabsolute.gamma;
78
-
79
- if (alpha && beta && gamma) {
80
- rawRender = <p>alpha: {alpha.toFixed(2)}, <br />
81
- beta: {beta.toFixed(2)}, <br />
82
- gamma: {gamma.toFixed(2)}</p>;
83
- }
84
- }
85
-
86
- const browserRender = Utils.renderAttitude(this.state.attitudeBrowser);
87
-
88
- return (
89
- <div>
90
- <h3>Raw:</h3>
91
- {rawRender}
92
- <h3>From browser:</h3>
93
- {browserRender}
94
- </div>
95
- );
96
- }
97
- }
98
-
99
- export default AbsoluteAttitudeComponent;
100
-
@@ -1,104 +0,0 @@
1
- import React from 'react';
2
- import isEmpty from 'lodash.isempty';
3
-
4
- import { deg2rad } from '@wemap/maths';
5
-
6
- import EventType from '../../src/events/EventType';
7
- import NavigationConfig from './NavigationConfig';
8
- import Utils from './Utils';
9
- import ArCoreAbsoluteProvider from '../../src/providers/pose/ArCoreAbsoluteProvider';
10
- import MapComponent from './MapComponent';
11
- import ProvidersLogger from '../../src/providers/ProvidersLogger';
12
-
13
- ProvidersLogger.enabled = true;
14
-
15
- class ArCoreAbsoluteComponent extends React.Component {
16
-
17
- errored = false;
18
-
19
- constructor(props, context) {
20
- super(props, context);
21
- this.state = {
22
- position: null,
23
- attitude: null,
24
- barcode: null
25
- };
26
-
27
- }
28
-
29
- componentDidMount() {
30
-
31
- this.arCoreAbsoluteProvider = new ArCoreAbsoluteProvider(
32
- this.onEvent,
33
- this.onError
34
- );
35
- this.arCoreAbsoluteProvider.setPosition(NavigationConfig.INITIAL_POSITION);
36
- this.arCoreAbsoluteProvider.setHeading(deg2rad(NavigationConfig.INITIAL_HEADING));
37
-
38
- this.arCoreAbsoluteProvider.start();
39
- if (!this.errored) {
40
- this.arCoreAbsoluteProvider.enableBarcodeScanner();
41
- }
42
- }
43
-
44
- componentWillUnmount() {
45
- if (!this.errored) {
46
- this.arCoreAbsoluteProvider.stop();
47
- this.arCoreAbsoluteProvider.disableBarcodeScanner();
48
- }
49
- }
50
-
51
- onEvent = events => {
52
- const newState = {};
53
- events.forEach(event => {
54
- if (event.dataType === EventType.AbsolutePosition) {
55
- newState.position = event.data;
56
- } else if (event.dataType === EventType.AbsoluteAttitude) {
57
- newState.attitude = event.data;
58
- } else if (event.dataType === EventType.Barcode) {
59
- newState.barcode = event.data;
60
- }
61
- });
62
- if (!isEmpty(newState)) {
63
- this.setState(newState);
64
- }
65
-
66
- if (this.map) {
67
- this.map.parseEvents(events);
68
- }
69
- };
70
-
71
- onError = error => {
72
- this.errored = true;
73
- this.setState({
74
- position: error,
75
- attitude: error
76
- });
77
- };
78
-
79
- render() {
80
- const {barcode} = this.state;
81
-
82
- const attitudeRender = Utils.renderAttitude(this.state.attitude);
83
- const positionRender = Utils.renderPosition(this.state.position);
84
-
85
- return (
86
- <div>
87
- <h3>Position</h3>
88
- {positionRender}
89
- <h3>Attitude</h3>
90
- {attitudeRender}
91
- <h3>Barcode</h3>
92
- {barcode ? barcode : ''}
93
- <h3>Map</h3>
94
- <MapComponent
95
- ref={map => (this.map = map)}
96
- defaultZoom={21}
97
- network={NavigationConfig.ITINERARY}
98
- />
99
- </div>
100
- );
101
- }
102
- }
103
-
104
- export default ArCoreAbsoluteComponent;
@@ -1,69 +0,0 @@
1
- import React from 'react';
2
- import isEmpty from 'lodash.isempty';
3
-
4
- import EventType from '../../src/events/EventType';
5
- import Utils from './Utils';
6
- import ArCoreProvider from '../../src/providers/pose/ArCoreProvider';
7
- import ProvidersLogger from '../../src/providers/ProvidersLogger';
8
-
9
- ProvidersLogger.enabled = true;
10
- class ArCoreComponent extends React.Component {
11
-
12
- constructor(props, context) {
13
- super(props, context);
14
- this.state = {
15
- position: null,
16
- attitude: null
17
- };
18
-
19
- this.arCoreProvider = new ArCoreProvider(this.onEvent, this.onError);
20
- }
21
-
22
-
23
- componentDidMount() {
24
- this.arCoreProvider.start();
25
- }
26
-
27
- componentWillUnmount() {
28
- this.arCoreProvider.stop();
29
- }
30
-
31
- onEvent = events => {
32
- const newState = {};
33
- events.forEach(event => {
34
- if (event.dataType === EventType.RelativePosition) {
35
- newState.position = event.data;
36
- } else if (event.dataType === EventType.RelativeAttitude) {
37
- newState.attitude = event.data;
38
- }
39
- });
40
- if (!isEmpty(newState)) {
41
- this.setState(newState);
42
- }
43
- };
44
-
45
- onError = error => {
46
- this.setState({
47
- position: error,
48
- attitude: error
49
- });
50
- }
51
-
52
- render() {
53
-
54
- const attitudeRender = Utils.renderAttitude(this.state.attitude);
55
- const positionRender = Utils.renderRelativePosition(this.state.position);
56
-
57
- return (
58
- <div>
59
- <h3>Position</h3>
60
- {positionRender}
61
- <h3>Attitude</h3>
62
- {attitudeRender}
63
- </div>
64
-
65
- );
66
- }
67
- }
68
-
69
- export default ArCoreComponent;
@@ -1,56 +0,0 @@
1
- import React from 'react';
2
-
3
- import GnssWifiProvider from '../../src/providers/position/GnssWifiProvider';
4
- import Utils from './Utils';
5
- import EventType from '../../src/events/EventType';
6
- import MapComponent from './MapComponent';
7
- import ProvidersLogger from '../../src/providers/ProvidersLogger';
8
-
9
- ProvidersLogger.enabled = true;
10
- class GnssWifiComponent extends React.Component {
11
-
12
- constructor(props, context) {
13
- super(props, context);
14
- this.state = { position: null };
15
-
16
- this.gnssWifiProvider = new GnssWifiProvider(this.onEvent, this.onError);
17
- }
18
-
19
-
20
- componentDidMount() {
21
- this.gnssWifiProvider.start();
22
- }
23
-
24
- componentWillUnmount() {
25
- this.gnssWifiProvider.stop();
26
- }
27
-
28
- onEvent = events => {
29
- events.forEach(event => {
30
- if (event.dataType === EventType.AbsolutePosition) {
31
- this.setState({ position: event.data });
32
- }
33
- });
34
-
35
- if (this.map) {
36
- this.map.parseEvents(events);
37
- }
38
- };
39
-
40
- onError = error => {
41
- this.setState({ position: error });
42
- }
43
-
44
- render() {
45
- return (
46
- <div>
47
- <h3>Position</h3>
48
- {Utils.renderPosition(this.state.position)}
49
- <h3>Map</h3>
50
- <MapComponent ref={map => (this.map = map)} />
51
- </div>
52
- );
53
- }
54
- }
55
-
56
- export default GnssWifiComponent;
@@ -1,76 +0,0 @@
1
- import isEmpty from 'lodash.isempty';
2
- import React from 'react';
3
-
4
- import NavigationConfig from './NavigationConfig';
5
- import Utils from './Utils';
6
- import EventType from '../../src/events/EventType';
7
- import GnssWifiPdrProvider from '../../src/providers/pose/GnssWifiPdrProvider';
8
- import MapComponent from './MapComponent';
9
- import ProvidersLogger from '../../src/providers/ProvidersLogger';
10
-
11
- ProvidersLogger.enabled = true;
12
-
13
- class GnssWifiPdrComponent extends React.Component {
14
- constructor(props, context) {
15
- super(props, context);
16
- this.state = { position: null };
17
-
18
- this.gnssWifiPdrProvider = new GnssWifiPdrProvider(
19
- this.onEvent,
20
- this.onError
21
- );
22
- }
23
-
24
- componentDidMount() {
25
- this.gnssWifiPdrProvider.enableMapMatching(NavigationConfig.ITINERARY);
26
- this.gnssWifiPdrProvider.start();
27
- }
28
-
29
- componentWillUnmount() {
30
- this.gnssWifiPdrProvider.stop();
31
- }
32
-
33
- onEvent = events => {
34
- const newState = {};
35
- events.forEach(event => {
36
- if (event.dataType === EventType.AbsolutePosition) {
37
- newState.position = event.data;
38
- } else if (event.dataType === EventType.AbsoluteAttitude) {
39
- newState.attitude = event.data;
40
- }
41
- });
42
- if (!isEmpty(newState)) {
43
- this.setState(newState);
44
- }
45
-
46
- if (this.map) {
47
- this.map.parseEvents(events);
48
- }
49
- };
50
-
51
- onError = error => {
52
- this.setState({
53
- position: error,
54
- attitude: error
55
- });
56
- };
57
-
58
- render() {
59
- const attitudeRender = Utils.renderAttitude(this.state.attitude);
60
- const positionRender = Utils.renderPosition(this.state.position);
61
-
62
- return (
63
- <div>
64
- <h3>Position</h3>
65
- {positionRender}
66
- <h3>Attitude</h3>
67
- {attitudeRender}
68
- <h3>Map</h3>
69
- <MapComponent ref={map => (this.map = map)}
70
- network={NavigationConfig.ITINERARY} />
71
- </div>
72
- );
73
- }
74
- }
75
-
76
- export default GnssWifiPdrComponent;