@wemap/providers 11.0.0-alpha.1 → 11.0.0-alpha.12
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/index.ts +3 -3
- package/package.json +56 -51
- package/src/events/Types.ts +0 -1
- package/src/mapmatching/MapMatchingHandler.spec.ts +6 -5
- package/src/mapmatching/MapMatchingHandler.ts +16 -11
- package/src/providers/position/absolute/AbsolutePositionProvider.ts +2 -2
- package/src/providers/position/absolute/GnssWifiProvider.ts +10 -0
- package/dist/index.js +0 -29194
- package/dist/index.js.map +0 -1
package/index.ts
CHANGED
|
@@ -7,9 +7,9 @@ export { default as MapMatchingHandler } from './src/mapmatching/MapMatchingHand
|
|
|
7
7
|
export { default as PositionSmoother } from './src/smoothers/PositionSmoother.js';
|
|
8
8
|
export { default as AttitudeSmoother } from './src/smoothers/AttitudeSmoother.js';
|
|
9
9
|
|
|
10
|
-
export { default as VpsMetadata } from './src/providers/vision/vps/VpsMetadata.js';
|
|
11
|
-
export { default as VpsRequest } from './src/providers/vision/vps/VpsRequest.js';
|
|
12
|
-
export { default as VpsResponse } from './src/providers/vision/vps/VpsResponse.js';
|
|
10
|
+
export { default as VpsMetadata, type VpsMetadataJson } from './src/providers/vision/vps/VpsMetadata.js';
|
|
11
|
+
export { default as VpsRequest, type VpsRequestJson } from './src/providers/vision/vps/VpsRequest.js';
|
|
12
|
+
export { default as VpsResponse, type VpsResponseJson } from './src/providers/vision/vps/VpsResponse.js';
|
|
13
13
|
|
|
14
14
|
export { default as ProvidersLoggerOld } from './src/events/ProvidersLoggerOld.js';
|
|
15
15
|
|
package/package.json
CHANGED
|
@@ -1,53 +1,58 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
2
|
+
"author": "Wemap",
|
|
3
|
+
"contributors": [
|
|
4
|
+
"Thibaud Michel <thibaud@getwemap.com>",
|
|
5
|
+
"Guillaume Pannetier <guillaume.pannetier@getwemap.com>"
|
|
6
|
+
],
|
|
7
|
+
"description": "A package using different geoloc systems",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "index.ts",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/wemap/wemap-modules-js.git"
|
|
13
|
+
},
|
|
14
|
+
"name": "@wemap/providers",
|
|
15
|
+
"version": "11.0.0-alpha.12",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/wemap/wemap-modules-js/issues"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/wemap/wemap-modules-js#readme",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"dev": "vite build --watch",
|
|
22
|
+
"build": "vite build"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@wemap/camera": "^11.0.0-alpha.12",
|
|
26
|
+
"@wemap/geo": "^11.0.0-alpha.12",
|
|
27
|
+
"@wemap/geomagnetism": "^0.1.2",
|
|
28
|
+
"@wemap/logger": "^11.0.0-alpha.4",
|
|
29
|
+
"@wemap/map": "^11.0.0-alpha.12",
|
|
30
|
+
"@wemap/maths": "^11.0.0-alpha.12",
|
|
31
|
+
"@wemap/osm": "^11.0.0-alpha.12",
|
|
32
|
+
"@wemap/routers": "^11.0.0-alpha.12",
|
|
33
|
+
"@wemap/utils": "^11.0.0-alpha.4"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"map-gl-geolocation": "^0.3.0",
|
|
37
|
+
"mapbox-gl": "^1.11.1"
|
|
38
|
+
},
|
|
39
|
+
"keywords": [
|
|
40
|
+
"wemap",
|
|
41
|
+
"providers",
|
|
42
|
+
"positioning",
|
|
43
|
+
"pdr",
|
|
44
|
+
"wifi",
|
|
45
|
+
"gnss",
|
|
46
|
+
"mapmatching",
|
|
47
|
+
"step-detection"
|
|
48
|
+
],
|
|
49
|
+
"license": "ISC",
|
|
50
|
+
"type": "module",
|
|
51
|
+
"exports": {
|
|
52
|
+
".": {
|
|
53
|
+
"import": "./dist/index.mjs",
|
|
54
|
+
"require": "./dist/index.js"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"gitHead": "42a1aece349e6db3151938ebc9b3d85daf9bb90d"
|
|
53
58
|
}
|
package/src/events/Types.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Attitude, UserPosition } from "@wemap/geo";
|
|
2
2
|
import { Vector16_t, Vector3_t } from "@wemap/maths";
|
|
3
3
|
|
|
4
|
-
|
|
5
4
|
export type Acceleration = Readonly<{ readonly timestamp: number; readonly values: Vector3_t; }>
|
|
6
5
|
export type AngularRate = Readonly<{ readonly timestamp: number; readonly values: Vector3_t; }>
|
|
7
6
|
export type HighRotation = Readonly<{ readonly timestamp: number; }>
|
|
@@ -2,8 +2,9 @@ import chai from 'chai';
|
|
|
2
2
|
import { Coordinates, GraphNode, Network } from '@wemap/geo';
|
|
3
3
|
import { deg2rad } from '@wemap/maths';
|
|
4
4
|
import { Itinerary } from '@wemap/routers';
|
|
5
|
-
import
|
|
5
|
+
import { OsmNetwork } from '@wemap/osm';
|
|
6
6
|
|
|
7
|
+
import MMH from './MapMatchingHandler.js';
|
|
7
8
|
|
|
8
9
|
const { expect } = chai;
|
|
9
10
|
|
|
@@ -61,7 +62,7 @@ describe('MapMatchingHandler', () => {
|
|
|
61
62
|
it('_hasTurnInCircle - network', () => {
|
|
62
63
|
|
|
63
64
|
// p1 has turns
|
|
64
|
-
const network =
|
|
65
|
+
const network = OsmNetwork.fromCoordinates([[p0, p4, p1], [p1, p2], [p3, p1]]);
|
|
65
66
|
MMH.network = network;
|
|
66
67
|
|
|
67
68
|
expect(MMH._nodeHasTurn(network.getNodeByCoords(p1) as GraphNode)).is.true;
|
|
@@ -90,7 +91,7 @@ describe('MapMatchingHandler', () => {
|
|
|
90
91
|
it('_hasTurnInCircle - multi-levels', () => {
|
|
91
92
|
|
|
92
93
|
// level 1 is a straight line
|
|
93
|
-
let network =
|
|
94
|
+
let network = OsmNetwork.fromCoordinates([
|
|
94
95
|
[p0, p4, p1], [p1, p2], [p3, p1],
|
|
95
96
|
[p10, p11, p13]
|
|
96
97
|
]);
|
|
@@ -111,7 +112,7 @@ describe('MapMatchingHandler', () => {
|
|
|
111
112
|
|
|
112
113
|
// Changing level
|
|
113
114
|
// straight line
|
|
114
|
-
network =
|
|
115
|
+
network = OsmNetwork.fromCoordinates([
|
|
115
116
|
[p0, p4, p11], [p11, p13]
|
|
116
117
|
]);
|
|
117
118
|
MMH.network = network;
|
|
@@ -122,7 +123,7 @@ describe('MapMatchingHandler', () => {
|
|
|
122
123
|
|
|
123
124
|
// Changing level
|
|
124
125
|
// turn in p11
|
|
125
|
-
network =
|
|
126
|
+
network = OsmNetwork.fromCoordinates([
|
|
126
127
|
[p0, p4, p11], [p11, p12], [p11, p13]
|
|
127
128
|
]);
|
|
128
129
|
MMH.network = network;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
/* eslint-disable max-statements */
|
|
2
1
|
import {
|
|
3
2
|
AbsoluteHeading, GraphEdge, Level, MapMatching,
|
|
4
3
|
GraphProjection, UserPosition, Coordinates, GraphNode, Network
|
|
5
4
|
} from '@wemap/geo';
|
|
6
5
|
import { deg2rad, diffAngle, diffAngleLines } from '@wemap/maths';
|
|
7
|
-
import {
|
|
6
|
+
import { OsmGraphProjection, OsmMapMatching, OsmNetwork, OsmNode, OsmWay } from '@wemap/osm';
|
|
8
7
|
import { Itinerary, ItineraryInfoManager } from '@wemap/routers';
|
|
9
8
|
import { TimeUtils } from '@wemap/utils';
|
|
10
9
|
|
|
@@ -19,8 +18,14 @@ import StraightLineProvider from '../providers/steps/StraightLineProvider.js';
|
|
|
19
18
|
import ProvidersOptions from '../ProvidersOptions.js';
|
|
20
19
|
import { AbsolutePosition } from '../events/Types.js';
|
|
21
20
|
|
|
22
|
-
type
|
|
23
|
-
|
|
21
|
+
type N = OsmNode | null;
|
|
22
|
+
type E = OsmNode | OsmWay | null;
|
|
23
|
+
type NullableOsmNetwork = Network<N, E>;
|
|
24
|
+
type NullableOsmMapMatching = MapMatching<N, E>;
|
|
25
|
+
type NullableOsmGraphProjection = GraphProjection<N, E>;
|
|
26
|
+
|
|
27
|
+
type MapMatchingEvent = { network?: NullableOsmNetwork, itinerary?: Itinerary | null };
|
|
28
|
+
class MapMatchingHandler extends Provider<MapMatchingEvent> {
|
|
24
29
|
|
|
25
30
|
static DEFAULT_MM_MAX_ANGLE = deg2rad(30); // radians
|
|
26
31
|
static DEFAULT_MM_MAX_DIST = 30; // meters
|
|
@@ -44,14 +49,14 @@ class MapMatchingHandler<T> extends Provider<MapMatchingEvent<T>> {
|
|
|
44
49
|
_lastProjectionsWindowSize = MapMatchingHandler.DEFAULT_LAST_PROJECTIONS_WINDOW_SIZE;
|
|
45
50
|
_lastProjectionsEdgeAngleThreshold = MapMatchingHandler.DEFAULT_LAST_PROJECTIONS_EDGE_ANGLE_THRESHOLD;
|
|
46
51
|
|
|
47
|
-
_mapMatching:
|
|
52
|
+
_mapMatching: NullableOsmMapMatching;
|
|
48
53
|
_internalProvidersStarted = false;
|
|
49
54
|
_straightLineProviderId?: number;
|
|
50
55
|
_turnProviderId?: number;
|
|
51
56
|
_stepProviderId?: number;
|
|
52
|
-
_projectionsWithAbsAndWithoutRelAttitudeInARow:
|
|
57
|
+
_projectionsWithAbsAndWithoutRelAttitudeInARow: NullableOsmGraphProjection[] = [];
|
|
53
58
|
_countStepsFromLastMatching = 0;
|
|
54
|
-
_lastProjections:
|
|
59
|
+
_lastProjections: NullableOsmGraphProjection[] = [];
|
|
55
60
|
|
|
56
61
|
_itineraryInfoManager: ItineraryInfoManager | null = null;
|
|
57
62
|
|
|
@@ -136,7 +141,7 @@ class MapMatchingHandler<T> extends Provider<MapMatchingEvent<T>> {
|
|
|
136
141
|
|
|
137
142
|
set itinerary(itinerary: Itinerary | null) {
|
|
138
143
|
|
|
139
|
-
this._mapMatching.network = itinerary ? itinerary.toNetwork<
|
|
144
|
+
this._mapMatching.network = itinerary ? itinerary.toNetwork<N, E>() : null;
|
|
140
145
|
this._itineraryInfoManager = new ItineraryInfoManager(itinerary);
|
|
141
146
|
this.notify({ ...(itinerary && { itinerary })});
|
|
142
147
|
|
|
@@ -347,7 +352,7 @@ class MapMatchingHandler<T> extends Provider<MapMatchingEvent<T>> {
|
|
|
347
352
|
|
|
348
353
|
}
|
|
349
354
|
|
|
350
|
-
_detectWrongBigJump(projection: GraphProjection<
|
|
355
|
+
_detectWrongBigJump(projection: GraphProjection<N, E, UserPosition>) {
|
|
351
356
|
|
|
352
357
|
if (this._itineraryInfoManager && AbsolutePositionProvider.lastEvent) {
|
|
353
358
|
const infoPrevious = this._itineraryInfoManager.getInfo(AbsolutePositionProvider.lastEvent);
|
|
@@ -408,7 +413,7 @@ class MapMatchingHandler<T> extends Provider<MapMatchingEvent<T>> {
|
|
|
408
413
|
).some(this._nodeHasTurn);
|
|
409
414
|
}
|
|
410
415
|
|
|
411
|
-
tryOrientationMatching(projection: GraphProjection<
|
|
416
|
+
tryOrientationMatching(projection: GraphProjection<N, E, UserPosition>) {
|
|
412
417
|
|
|
413
418
|
if (!this._useOrientationMatching) {
|
|
414
419
|
return;
|
|
@@ -540,4 +545,4 @@ class MapMatchingHandler<T> extends Provider<MapMatchingEvent<T>> {
|
|
|
540
545
|
}
|
|
541
546
|
}
|
|
542
547
|
|
|
543
|
-
export default new MapMatchingHandler
|
|
548
|
+
export default new MapMatchingHandler();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Level, GeoRelativePosition } from '@wemap/geo';
|
|
1
|
+
import { Level, GeoRelativePosition, UserPosition } from '@wemap/geo';
|
|
2
2
|
import { TimeUtils } from '@wemap/utils';
|
|
3
3
|
|
|
4
4
|
import Provider from '../../Provider.js';
|
|
@@ -232,7 +232,7 @@ class AbsolutePositionProvider extends Provider<AbsolutePosition> {
|
|
|
232
232
|
|
|
233
233
|
let newPositionEvent: AbsolutePosition;
|
|
234
234
|
|
|
235
|
-
if (data instanceof
|
|
235
|
+
if (data instanceof UserPosition) {
|
|
236
236
|
|
|
237
237
|
if (data.time === null) {
|
|
238
238
|
throw Error('the time of the position is not defined');
|
|
@@ -25,6 +25,10 @@ class GnssWifiProvider extends Provider<AbsolutePosition> {
|
|
|
25
25
|
maximumAge: 0
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
+
static DEFAULT_DISCARD_POSITIONS_ABOVE = 50;
|
|
29
|
+
|
|
30
|
+
discardPositionsAbove = GnssWifiProvider.DEFAULT_DISCARD_POSITIONS_ABOVE;
|
|
31
|
+
|
|
28
32
|
geoLocationId?: number;
|
|
29
33
|
|
|
30
34
|
getName = () => 'GnssWifi';
|
|
@@ -77,6 +81,12 @@ class GnssWifiProvider extends Provider<AbsolutePosition> {
|
|
|
77
81
|
coords.accuracy,
|
|
78
82
|
bearing);
|
|
79
83
|
|
|
84
|
+
if (typeof this.discardPositionsAbove === 'number'
|
|
85
|
+
&& coords.accuracy > this.discardPositionsAbove
|
|
86
|
+
) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
80
90
|
this.notify(position);
|
|
81
91
|
|
|
82
92
|
};
|