@wemap/geo 10.1.0 → 10.3.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/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { Quaternion_t, Vector3_t } from '@wemap/maths';
|
|
2
2
|
declare module '@wemap/geo' {
|
|
3
3
|
|
|
4
|
+
/*************
|
|
5
|
+
* Coordinates
|
|
6
|
+
*************/
|
|
7
|
+
|
|
4
8
|
export type Level_t = null | number | [number, number];
|
|
5
9
|
|
|
6
10
|
export class Level {
|
|
@@ -64,29 +68,6 @@ declare module '@wemap/geo' {
|
|
|
64
68
|
static fromCompressedJson(json: CoordinatesCompressedJson): Coordinates;
|
|
65
69
|
}
|
|
66
70
|
|
|
67
|
-
export type AttitudeJson = Quaternion_t
|
|
68
|
-
| { q: Quaternion_t, time?: number, accuracy?: number };
|
|
69
|
-
|
|
70
|
-
export class Attitude {
|
|
71
|
-
constructor(quaternion: Quaternion_t, time?: number, accuracy?: number);
|
|
72
|
-
get quaternion(): Quaternion_t;
|
|
73
|
-
set quaternion(quaternion: Quaternion_t);
|
|
74
|
-
get time(): number;
|
|
75
|
-
set time(time: number);
|
|
76
|
-
get accuracy(): number;
|
|
77
|
-
set accuracy(accuracy: number);
|
|
78
|
-
get eulerAngles(): [number, number, number];
|
|
79
|
-
get eulerAnglesDegrees(): [number, number, number];
|
|
80
|
-
get heading(): number;
|
|
81
|
-
get headingDegrees(): number;
|
|
82
|
-
equals(other: Attitude): boolean;
|
|
83
|
-
toJson(): AttitudeJson;
|
|
84
|
-
clone(): Attitude;
|
|
85
|
-
static unitary(): Attitude;
|
|
86
|
-
static equals(attitude1: Attitude, attitude2: Attitude): boolean;
|
|
87
|
-
static fromJson(json: AttitudeJson): Attitude;
|
|
88
|
-
static diff(attitudeStart: Attitude, attitudeEnd: Attitude): Attitude;
|
|
89
|
-
}
|
|
90
71
|
|
|
91
72
|
export class GeoRef {
|
|
92
73
|
origin: Coordinates;
|
|
@@ -96,6 +77,7 @@ declare module '@wemap/geo' {
|
|
|
96
77
|
localToWorld(localPosition: [number, number, number]): Coordinates;
|
|
97
78
|
worldToLocal(coords: Coordinates): [number, number, number];
|
|
98
79
|
toJson(): object;
|
|
80
|
+
|
|
99
81
|
static fromJson(json: object): GeoRef;
|
|
100
82
|
}
|
|
101
83
|
|
|
@@ -107,22 +89,22 @@ declare module '@wemap/geo' {
|
|
|
107
89
|
|
|
108
90
|
export class UserPosition extends Coordinates {
|
|
109
91
|
|
|
110
|
-
constructor(lat: number, lng: number, alt?: number, level?: Level_t,
|
|
111
|
-
time?: number, accuracy?: number, bearing?: number);
|
|
92
|
+
constructor(lat: number, lng: number, alt?: number | null, level?: Level_t,
|
|
93
|
+
time?: number | null, accuracy?: number | null, bearing?: number | null);
|
|
112
94
|
|
|
113
|
-
get time(): number;
|
|
114
|
-
set time(time: number);
|
|
115
|
-
get accuracy(): number;
|
|
116
|
-
set accuracy(accuracy: number);
|
|
117
|
-
get bearing(): number;
|
|
118
|
-
set bearing(bearing: number);
|
|
95
|
+
get time(): number | null;
|
|
96
|
+
set time(time: number | null);
|
|
97
|
+
get accuracy(): number | null;
|
|
98
|
+
set accuracy(accuracy: number | null);
|
|
99
|
+
get bearing(): number | null;
|
|
100
|
+
set bearing(bearing: number | null);
|
|
119
101
|
|
|
120
102
|
fromCoordinates(coords: Coordinates): UserPosition;
|
|
121
103
|
clone(): UserPosition;
|
|
122
|
-
static equals(pos1: Coordinates, pos2: Coordinates, eps?: number, epsAlt?: number): boolean;
|
|
123
104
|
equals(other: Coordinates, eps?: number, epsAlt?: number): boolean;
|
|
124
|
-
|
|
125
105
|
toJson(): UserPositionJson;
|
|
106
|
+
|
|
107
|
+
static equals(pos1: Coordinates, pos2: Coordinates, eps?: number, epsAlt?: number): boolean;
|
|
126
108
|
static fromJson(json: UserPositionJson): UserPosition;
|
|
127
109
|
}
|
|
128
110
|
|
|
@@ -136,4 +118,273 @@ declare module '@wemap/geo' {
|
|
|
136
118
|
position: UserPosition,
|
|
137
119
|
};
|
|
138
120
|
|
|
121
|
+
export class RelativePosition {
|
|
122
|
+
constructor(x: number, y: number, z: number,
|
|
123
|
+
time?: number | null, accuracy?: number | null, bearing?: number | null);
|
|
124
|
+
|
|
125
|
+
get x(): number;
|
|
126
|
+
set x(x: number);
|
|
127
|
+
get y(): number;
|
|
128
|
+
set y(y: number);
|
|
129
|
+
get z(): number;
|
|
130
|
+
set z(z: number);
|
|
131
|
+
get time(): number | null;
|
|
132
|
+
set time(time: number | null);
|
|
133
|
+
get accuracy(): number | null;
|
|
134
|
+
set accuracy(accuracy: number | null);
|
|
135
|
+
get bearing(): number | null;
|
|
136
|
+
set bearing(bearing: number | null);
|
|
137
|
+
|
|
138
|
+
clone(): RelativePosition;
|
|
139
|
+
equals(other: RelativePosition, eps?: number): boolean;
|
|
140
|
+
toJson(): object;
|
|
141
|
+
|
|
142
|
+
static equals(pos1: RelativePosition, pos2: RelativePosition, eps?: number): boolean;
|
|
143
|
+
static fromJson(json: object): RelativePosition;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export class GeoRelativePosition extends RelativePosition { }
|
|
147
|
+
|
|
148
|
+
export class BoundingBox {
|
|
149
|
+
northEast: Coordinates;
|
|
150
|
+
southWest: Coordinates;
|
|
151
|
+
|
|
152
|
+
constructor(northEast: Coordinates, southWest: Coordinates);
|
|
153
|
+
|
|
154
|
+
get center(): Coordinates;
|
|
155
|
+
getSouthWest(): Coordinates;
|
|
156
|
+
getNorthEast(): Coordinates;
|
|
157
|
+
getNorthWest(): Coordinates;
|
|
158
|
+
getSouthEast(): Coordinates;
|
|
159
|
+
getWest(): number;
|
|
160
|
+
getSouth(): number;
|
|
161
|
+
getEast(): number;
|
|
162
|
+
getNorth(): number;
|
|
163
|
+
|
|
164
|
+
contains(point: Coordinates): boolean;
|
|
165
|
+
extend(obj: Coordinates | BoundingBox): BoundingBox;
|
|
166
|
+
extendsWithMeasure(measure: number): BoundingBox;
|
|
167
|
+
pad(bufferRatio: number): BoundingBox;
|
|
168
|
+
equals(other: BoundingBox): boolean;
|
|
169
|
+
toArray(): [number, number, number, number];
|
|
170
|
+
|
|
171
|
+
static equals(bb1: BoundingBox, bb2: BoundingBox): boolean;
|
|
172
|
+
static fromArray(wsenBounds: [number, number, number, number]): BoundingBox;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/*********
|
|
176
|
+
* Graph
|
|
177
|
+
*********/
|
|
178
|
+
|
|
179
|
+
export class GraphNode<T> {
|
|
180
|
+
edges: GraphEdge<T>[];
|
|
181
|
+
builtFrom: T | null;
|
|
182
|
+
io: boolean;
|
|
183
|
+
|
|
184
|
+
constructor(coords: Coordinates, builtFrom: T | null);
|
|
185
|
+
|
|
186
|
+
get coords(): Coordinates;
|
|
187
|
+
set coords(coords: Coordinates);
|
|
188
|
+
|
|
189
|
+
distanceTo(other: GraphNode<T>): number;
|
|
190
|
+
bearingTo(other: GraphNode<T>): number;
|
|
191
|
+
equals(other: GraphNode<T>): boolean;
|
|
192
|
+
clone(): GraphNode<T>;
|
|
193
|
+
toJson(): object;
|
|
194
|
+
|
|
195
|
+
static fromJson<T>(json: object): GraphNode<T>;
|
|
196
|
+
static generateNodesLevels<T>(nodes: GraphNode<T>[]): void;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export class GraphEdge<T> {
|
|
200
|
+
builtFrom: T | null;
|
|
201
|
+
isOneway: boolean;
|
|
202
|
+
|
|
203
|
+
constructor(node1: GraphNode<T>, node2: GraphNode<T>, level?: Level_t | null, builtFrom?: T | null);
|
|
204
|
+
|
|
205
|
+
get node1(): GraphNode<T>;
|
|
206
|
+
set node1(node: GraphNode<T>);
|
|
207
|
+
get node2(): GraphNode<T>;
|
|
208
|
+
set node2(node: GraphNode<T>);
|
|
209
|
+
get level(): Level_t;
|
|
210
|
+
set level(level: Level_t);
|
|
211
|
+
get bearing(): number;
|
|
212
|
+
get length(): number;
|
|
213
|
+
|
|
214
|
+
equals(other: GraphEdge<T>): boolean;
|
|
215
|
+
clone(): GraphEdge<T>;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export class GraphProjection<T> {
|
|
219
|
+
origin: Coordinates;
|
|
220
|
+
distanceFromNearestElement: number;
|
|
221
|
+
projection: Coordinates;
|
|
222
|
+
nearestElement: GraphNode<T> | GraphEdge<T>;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export class Network<T> {
|
|
226
|
+
|
|
227
|
+
nodes: GraphNode<T>[];
|
|
228
|
+
edges: GraphEdge<T>[];
|
|
229
|
+
|
|
230
|
+
constructor(nodes: GraphNode<T>[], edges: GraphEdge<T>[]);
|
|
231
|
+
|
|
232
|
+
getNodeByCoords(coords: Coordinates): GraphNode<T> | undefined;
|
|
233
|
+
getEdgeByNodes(node1: GraphNode<T>, node2: GraphNode<T>): GraphEdge<T> | undefined;
|
|
234
|
+
getBoundingBox(extendedMeasure: number | undefined): BoundingBox;
|
|
235
|
+
getEdgesAtLevel(targetLevel: Level, useMultiLevelEdges: boolean): GraphEdge<T>;
|
|
236
|
+
toDetailedString(
|
|
237
|
+
_nodeToStringFn: (node: GraphNode<T>) => string,
|
|
238
|
+
_edgeToStringFn: (node: GraphEdge<T>) => string
|
|
239
|
+
): string;
|
|
240
|
+
toCompressedJson(): object;
|
|
241
|
+
|
|
242
|
+
static fromCompressedJson<T>(json: object): Network<T>;
|
|
243
|
+
static fromCoordinates<T>(segments: Coordinates[][]): Network<T>;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export function getEdgeByNodes<T>(
|
|
247
|
+
edges: GraphEdge<T>[], node1: GraphNode<T>, node2: GraphNode<T>
|
|
248
|
+
): GraphNode<T> | undefined;
|
|
249
|
+
|
|
250
|
+
export class MapMatching<T> {
|
|
251
|
+
constructor(network?: Network<T>);
|
|
252
|
+
|
|
253
|
+
set maxAngleBearing(maxAngleBearing: number);
|
|
254
|
+
get maxAngleBearing(): number;
|
|
255
|
+
set maxDistance(maxDistance: number);
|
|
256
|
+
get maxDistance(): number;
|
|
257
|
+
set network(network: Network<T> | null);
|
|
258
|
+
get network(): Network<T>;
|
|
259
|
+
|
|
260
|
+
getProjection(
|
|
261
|
+
location: Coordinates,
|
|
262
|
+
useDistance?: boolean,
|
|
263
|
+
useBearing?: boolean,
|
|
264
|
+
useMultiLevelSegments?: boolean,
|
|
265
|
+
acceptEdgeFn?: (edge: GraphEdge<T>) => boolean
|
|
266
|
+
): GraphProjection<T> | null;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/*************
|
|
270
|
+
* Rotations
|
|
271
|
+
*************/
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
export type AttitudeJson = Quaternion_t
|
|
275
|
+
| { q: Quaternion_t, time?: number, accuracy?: number };
|
|
276
|
+
|
|
277
|
+
export class Attitude {
|
|
278
|
+
|
|
279
|
+
constructor(quaternion: Quaternion_t, time?: number, accuracy?: number);
|
|
280
|
+
|
|
281
|
+
get quaternion(): Quaternion_t;
|
|
282
|
+
set quaternion(quaternion: Quaternion_t);
|
|
283
|
+
get time(): number;
|
|
284
|
+
set time(time: number);
|
|
285
|
+
get accuracy(): number;
|
|
286
|
+
set accuracy(accuracy: number);
|
|
287
|
+
get eulerAngles(): [number, number, number];
|
|
288
|
+
get eulerAnglesDegrees(): [number, number, number];
|
|
289
|
+
get heading(): number;
|
|
290
|
+
get headingDegrees(): number;
|
|
291
|
+
|
|
292
|
+
equals(other: Attitude): boolean;
|
|
293
|
+
toJson(): AttitudeJson;
|
|
294
|
+
clone(): Attitude;
|
|
295
|
+
|
|
296
|
+
static unitary(): Attitude;
|
|
297
|
+
static equals(attitude1: Attitude, attitude2: Attitude): boolean;
|
|
298
|
+
static fromJson(json: AttitudeJson): Attitude;
|
|
299
|
+
static diff(attitudeStart: Attitude, attitudeEnd: Attitude): Attitude;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export class AbsoluteHeading {
|
|
303
|
+
constructor(heading: number, time?: number | null, accuracy?: number | null);
|
|
304
|
+
|
|
305
|
+
get heading(): number;
|
|
306
|
+
set heading(heading: number);
|
|
307
|
+
get time(): number | null;
|
|
308
|
+
set time(heading: number | null);
|
|
309
|
+
get accuracy(): number | null;
|
|
310
|
+
set accuracy(heading: number | null);
|
|
311
|
+
|
|
312
|
+
toAttitude(): Attitude;
|
|
313
|
+
equals(other: AbsoluteHeading | null): boolean;
|
|
314
|
+
toJson(): object;
|
|
315
|
+
clone(): AbsoluteHeading;
|
|
316
|
+
|
|
317
|
+
static equals(heading1: AbsoluteHeading | null, heading2: AbsoluteHeading | null): boolean;
|
|
318
|
+
static fromJson(json: object): AbsoluteHeading;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/***********
|
|
322
|
+
* Router
|
|
323
|
+
***********/
|
|
324
|
+
|
|
325
|
+
export class GraphItinerary<T> {
|
|
326
|
+
start: Coordinates;
|
|
327
|
+
end: Coordinates;
|
|
328
|
+
nodes: GraphNode<T>[];
|
|
329
|
+
edges: GraphEdge<T>[];
|
|
330
|
+
edgesWeights: number[];
|
|
331
|
+
|
|
332
|
+
static fromNetworkNodes<T>(
|
|
333
|
+
networkNodes: GraphNode<T>[],
|
|
334
|
+
edgesWeight: number[]
|
|
335
|
+
): GraphItinerary<T>;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export class GraphRouter<T> {
|
|
339
|
+
constructor(network: Network<T>);
|
|
340
|
+
getShortestPath(
|
|
341
|
+
start: GraphNode<T> | Coordinates,
|
|
342
|
+
end: GraphNode<T> | Coordinates,
|
|
343
|
+
options?: GraphRouterOptions<T>
|
|
344
|
+
): GraphItinerary<T>;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export class GraphRouterOptions<T> {
|
|
348
|
+
projectionMaxDistance: number;
|
|
349
|
+
weightEdgeFn: (edge: GraphEdge<T>) => number;
|
|
350
|
+
acceptEdgeFn: (edge: GraphEdge<T>) => boolean;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export class NoRouteFoundError<T> {
|
|
354
|
+
constructor(
|
|
355
|
+
start: GraphNode<T> | Coordinates,
|
|
356
|
+
end: GraphNode<T> | Coordinates,
|
|
357
|
+
details?: string
|
|
358
|
+
);
|
|
359
|
+
get startStr(): string;
|
|
360
|
+
get endStr(): string;
|
|
361
|
+
get message(): string;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
/***********
|
|
366
|
+
* Utils
|
|
367
|
+
***********/
|
|
368
|
+
|
|
369
|
+
export function sampleRoute(
|
|
370
|
+
route: Coordinates[],
|
|
371
|
+
stepSize?: number,
|
|
372
|
+
startSampling?: number,
|
|
373
|
+
length?: number
|
|
374
|
+
): Coordinates[];
|
|
375
|
+
|
|
376
|
+
export function trimRoute(
|
|
377
|
+
route: Coordinates[],
|
|
378
|
+
startPosition?: Coordinates,
|
|
379
|
+
length?: number
|
|
380
|
+
): Coordinates[];
|
|
381
|
+
|
|
382
|
+
export function simplifyRoute(
|
|
383
|
+
coords: Coordinates[],
|
|
384
|
+
precisionAngle?: number
|
|
385
|
+
): Coordinates;
|
|
386
|
+
|
|
387
|
+
export function geolocationPositionToUserPosition(
|
|
388
|
+
geolocationPosition: GeolocationPosition | null
|
|
389
|
+
): UserPosition | null;
|
|
139
390
|
}
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"directory": "packages/geo"
|
|
14
14
|
},
|
|
15
15
|
"name": "@wemap/geo",
|
|
16
|
-
"version": "10.
|
|
16
|
+
"version": "10.3.0",
|
|
17
17
|
"bugs": {
|
|
18
18
|
"url": "https://github.com/wemap/wemap-modules-js/issues"
|
|
19
19
|
},
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"license": "ISC",
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@wemap/logger": "^10.0.0",
|
|
32
|
-
"@wemap/maths": "^10.
|
|
32
|
+
"@wemap/maths": "^10.3.0"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "2435b4a1c0218f56a87ff1768e197f8cb738aa4d"
|
|
35
35
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Coordinates from '../coordinates/Coordinates.js';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import GraphEdge from './GraphEdge.js';
|
|
3
|
+
import GraphNode from './GraphNode.js';
|
|
4
4
|
|
|
5
5
|
class GraphProjection {
|
|
6
6
|
|
|
@@ -13,7 +13,7 @@ class GraphProjection {
|
|
|
13
13
|
/** @type {Coordinates} */
|
|
14
14
|
projection;
|
|
15
15
|
|
|
16
|
-
/** @type {
|
|
16
|
+
/** @type {GraphNode|GraphEdge} */
|
|
17
17
|
nearestElement;
|
|
18
18
|
|
|
19
19
|
}
|
package/src/graph/Network.js
CHANGED
|
@@ -195,9 +195,9 @@ class Network {
|
|
|
195
195
|
|
|
196
196
|
/**
|
|
197
197
|
* Create edges From MultiLevel Itinerary for a given level
|
|
198
|
-
* @param {
|
|
198
|
+
* @param {null|number|[number, number]} targetLevel level for selection.
|
|
199
199
|
* @param {Boolean} useMultiLevelEdges use segments which intersect both levels (stairs, elevators...)
|
|
200
|
-
* @returns {GraphEdge[]} Ordered edges
|
|
200
|
+
* @returns {GraphEdge<T>[]} Ordered edges
|
|
201
201
|
*/
|
|
202
202
|
getEdgesAtLevel(targetLevel, useMultiLevelEdges = true) {
|
|
203
203
|
return this.edges.filter(
|
|
@@ -8,7 +8,7 @@ class GraphRouterOptions {
|
|
|
8
8
|
/** @type {number} in meters */
|
|
9
9
|
projectionMaxDistance = 50;
|
|
10
10
|
|
|
11
|
-
/** @type {function(GraphEdge<T>):
|
|
11
|
+
/** @type {function(GraphEdge<T>):number} */
|
|
12
12
|
weightEdgeFn = edge => edge.length;
|
|
13
13
|
|
|
14
14
|
/** @type {function(GraphEdge<T>):boolean} */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import GraphNode from '../graph/GraphNode.js';
|
|
2
2
|
|
|
3
3
|
class NoRouteFoundError extends Error {
|
|
4
4
|
|
|
@@ -10,8 +10,8 @@ class NoRouteFoundError extends Error {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
get startStr() {
|
|
13
|
-
if (this.start instanceof
|
|
14
|
-
return `
|
|
13
|
+
if (this.start instanceof GraphNode) {
|
|
14
|
+
return `GraphNode ${this.start.coords.toString()}`;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
// if (this.start instanceof Coordinates) {
|
|
@@ -19,8 +19,8 @@ class NoRouteFoundError extends Error {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
get endStr() {
|
|
22
|
-
if (this.end instanceof
|
|
23
|
-
return `
|
|
22
|
+
if (this.end instanceof GraphNode) {
|
|
23
|
+
return `GraphNode ${this.end.coords.toString()}`;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// if (this.end instanceof Coordinates) {
|