@wemap/routers 9.0.0 → 9.0.2
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.
|
@@ -71,9 +71,15 @@
|
|
|
71
71
|
<node id='-441210' action='modify' visible='true' lat='43.60932786111' lon='3.8842776591'>
|
|
72
72
|
<tag k='name' v='p17' />
|
|
73
73
|
</node>
|
|
74
|
-
<node id='-
|
|
74
|
+
<node id='-441270' action='modify' visible='true' lat='43.6093032' lon='3.8844388'>
|
|
75
75
|
<tag k='name' v='p21' />
|
|
76
76
|
</node>
|
|
77
|
+
<node id='-441273' action='modify' visible='true' lat='43.6095297' lon='3.8845039'>
|
|
78
|
+
<tag k='name' v='p22' />
|
|
79
|
+
</node>
|
|
80
|
+
<node id='-441286' action='modify' visible='true' lat='43.6095624' lon='3.8845134'>
|
|
81
|
+
<tag k='name' v='p23' />
|
|
82
|
+
</node>
|
|
77
83
|
<way id='-440499' action='modify' visible='true'>
|
|
78
84
|
<nd ref='-440476' />
|
|
79
85
|
<nd ref='-440460' />
|
|
@@ -154,9 +160,15 @@
|
|
|
154
160
|
</way>
|
|
155
161
|
<way id='-441263' action='modify' visible='true'>
|
|
156
162
|
<nd ref='-441187' />
|
|
157
|
-
<nd ref='-
|
|
163
|
+
<nd ref='-441270' />
|
|
164
|
+
<nd ref='-441273' />
|
|
158
165
|
<tag k='highway' v='footway' />
|
|
159
166
|
<tag k='level' v='0' />
|
|
160
167
|
<tag k='name' v='w10' />
|
|
161
168
|
</way>
|
|
169
|
+
<way id='-441268' action='modify' visible='true'>
|
|
170
|
+
<nd ref='-441273' />
|
|
171
|
+
<nd ref='-441286' />
|
|
172
|
+
<tag k='highway' v='footway' />
|
|
173
|
+
</way>
|
|
162
174
|
</osm>
|
package/dist/wemap-routers.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Coordinates, Network, GraphRouterOptions, GraphRouter, GraphUtils,
|
|
1
|
+
import { Coordinates, Network, Level, GraphRouterOptions, GraphRouter, GraphUtils, GraphEdge, GraphNode, NoRouteFoundError, GraphItinerary, Utils, MapMatching } from '@wemap/geo';
|
|
2
2
|
import { OsmParser, OsmWay, OsmNode } from '@wemap/osm';
|
|
3
3
|
import { deg2rad, diffAngle, positiveMod, rad2deg } from '@wemap/maths';
|
|
4
4
|
import Logger from '@wemap/logger';
|
|
@@ -23,7 +23,7 @@ class LevelChange {
|
|
|
23
23
|
* @param {LevelChange} obj2
|
|
24
24
|
* @returns {Boolean}
|
|
25
25
|
*/
|
|
26
|
-
static
|
|
26
|
+
static equals(obj1, obj2) {
|
|
27
27
|
return obj1.difference === obj2.difference
|
|
28
28
|
&& obj1.direction === obj2.direction
|
|
29
29
|
&& obj1.type === obj2.type;
|
|
@@ -33,8 +33,8 @@ class LevelChange {
|
|
|
33
33
|
* @param {LevelChange} obj
|
|
34
34
|
* @returns {Boolean}
|
|
35
35
|
*/
|
|
36
|
-
|
|
37
|
-
return LevelChange.
|
|
36
|
+
equals(obj) {
|
|
37
|
+
return LevelChange.equals(this, obj);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/**
|
|
@@ -110,11 +110,11 @@ class Step {
|
|
|
110
110
|
* @param {Step} obj2
|
|
111
111
|
* @returns {Boolean}
|
|
112
112
|
*/
|
|
113
|
-
static
|
|
113
|
+
static equals(obj1, obj2) {
|
|
114
114
|
return obj1.firstStep === obj2.firstStep
|
|
115
115
|
&& obj1.lastStep === obj2.lastStep
|
|
116
116
|
&& obj1.number === obj2.number
|
|
117
|
-
&& obj1.coords.
|
|
117
|
+
&& obj1.coords.equals(obj2.coords)
|
|
118
118
|
&& obj1.angle === obj2.angle
|
|
119
119
|
&& obj1.previousBearing === obj2.previousBearing
|
|
120
120
|
&& obj1.nextBearing === obj2.nextBearing
|
|
@@ -123,7 +123,7 @@ class Step {
|
|
|
123
123
|
&& obj1.name === obj2.name
|
|
124
124
|
&& (
|
|
125
125
|
obj1.levelChange === obj2.levelChange
|
|
126
|
-
|| obj1.levelChange !== null && obj1.levelChange.
|
|
126
|
+
|| obj1.levelChange !== null && obj1.levelChange.equals(obj2.levelChange)
|
|
127
127
|
)
|
|
128
128
|
&& (
|
|
129
129
|
obj1.extras === obj2.extras
|
|
@@ -140,8 +140,8 @@ class Step {
|
|
|
140
140
|
* @param {Step} obj
|
|
141
141
|
* @returns {Boolean}
|
|
142
142
|
*/
|
|
143
|
-
|
|
144
|
-
return Step.
|
|
143
|
+
equals(obj) {
|
|
144
|
+
return Step.equals(this, obj);
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
/**
|
|
@@ -294,16 +294,16 @@ class Leg {
|
|
|
294
294
|
* @returns {Boolean}
|
|
295
295
|
*/
|
|
296
296
|
// eslint-disable-next-line complexity
|
|
297
|
-
static
|
|
297
|
+
static equals(obj1, obj2) {
|
|
298
298
|
const intermediate = obj1.mode === obj2.mode
|
|
299
299
|
&& obj1.distance === obj2.distance
|
|
300
300
|
&& obj1.duration === obj2.duration
|
|
301
301
|
&& obj1.startTime === obj2.startTime
|
|
302
302
|
&& obj1.endTime === obj2.endTime
|
|
303
303
|
&& obj1.from.name === obj2.from.name
|
|
304
|
-
&& obj1.from.coords.
|
|
304
|
+
&& obj1.from.coords.equals(obj2.from.coords)
|
|
305
305
|
&& obj1.to.name === obj2.to.name
|
|
306
|
-
&& obj1.to.coords.
|
|
306
|
+
&& obj1.to.coords.equals(obj2.to.coords)
|
|
307
307
|
&& obj1.coords.length === obj2.coords.length
|
|
308
308
|
&& (
|
|
309
309
|
obj1.steps === obj2.steps
|
|
@@ -316,13 +316,13 @@ class Leg {
|
|
|
316
316
|
|
|
317
317
|
let i;
|
|
318
318
|
for (i = 0; i < obj1.coords.length; i++) {
|
|
319
|
-
if (!obj1.coords[i].
|
|
319
|
+
if (!obj1.coords[i].equals(obj2.coords[i])) {
|
|
320
320
|
return false;
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
323
|
if (obj1.steps) {
|
|
324
324
|
for (i = 0; i < obj1.steps.length; i++) {
|
|
325
|
-
if (!obj1.steps[i].
|
|
325
|
+
if (!obj1.steps[i].equals(obj2.steps[i])) {
|
|
326
326
|
return false;
|
|
327
327
|
}
|
|
328
328
|
}
|
|
@@ -349,8 +349,8 @@ class Leg {
|
|
|
349
349
|
* @param {Leg} obj
|
|
350
350
|
* @returns {Boolean}
|
|
351
351
|
*/
|
|
352
|
-
|
|
353
|
-
return Leg.
|
|
352
|
+
equals(obj) {
|
|
353
|
+
return Leg.equals(this, obj);
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
/**
|
|
@@ -435,58 +435,60 @@ function getDurationFromLength(length, speed = 5) {
|
|
|
435
435
|
return length / (speed * 1000 / 3600);
|
|
436
436
|
}
|
|
437
437
|
|
|
438
|
-
|
|
439
|
-
/* eslint-disable max-depth */
|
|
438
|
+
|
|
440
439
|
/**
|
|
441
|
-
* @param {
|
|
442
|
-
* @param {
|
|
440
|
+
* @param {Leg} leg
|
|
441
|
+
* @param {number} levelFactor
|
|
443
442
|
*/
|
|
444
|
-
function
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
443
|
+
function multiplyLegLevel(leg, levelFactor) {
|
|
444
|
+
|
|
445
|
+
leg.from.coords.level = Level.multiplyBy(leg.from.coords.level, levelFactor);
|
|
446
|
+
leg.to.coords.level = Level.multiplyBy(leg.to.coords.level, levelFactor);
|
|
447
|
+
for (const coords of leg.coords) {
|
|
448
|
+
coords.level = Level.multiplyBy(coords.level, levelFactor);
|
|
450
449
|
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
}
|
|
455
|
-
if (itinerary.to.level) {
|
|
456
|
-
itinerary.to.level.multiplyBy(levelFactor);
|
|
450
|
+
if (leg.steps) {
|
|
451
|
+
for (const step of leg.steps) {
|
|
452
|
+
step.coords.level = Level.multiplyBy(step.coords.level, levelFactor);
|
|
457
453
|
}
|
|
454
|
+
}
|
|
458
455
|
|
|
459
|
-
|
|
460
|
-
if (leg.from.coords.level) {
|
|
461
|
-
leg.from.coords.level.multiplyBy(levelFactor);
|
|
462
|
-
}
|
|
463
|
-
if (leg.to.coords.level) {
|
|
464
|
-
leg.to.coords.level.multiplyBy(levelFactor);
|
|
465
|
-
}
|
|
466
|
-
for (const coords of leg.coords) {
|
|
467
|
-
if (coords.level) {
|
|
468
|
-
coords.level.multiplyBy(levelFactor);
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
if (leg.steps) {
|
|
472
|
-
for (const step of leg.steps) {
|
|
473
|
-
if (step.coords.level) {
|
|
474
|
-
step.coords.level.multiplyBy(levelFactor);
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
}
|
|
456
|
+
}
|
|
479
457
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
458
|
+
/**
|
|
459
|
+
* @param {Itinerary} itinerary
|
|
460
|
+
* @param {number} levelFactor
|
|
461
|
+
*/
|
|
462
|
+
function multiplyItineraryLevel(itinerary, levelFactor) {
|
|
463
|
+
|
|
464
|
+
itinerary.from.level = Level.multiplyBy(itinerary.from.level, levelFactor);
|
|
465
|
+
itinerary.to.level = Level.multiplyBy(itinerary.to.level, levelFactor);
|
|
466
|
+
|
|
467
|
+
for (const leg of itinerary.legs) {
|
|
468
|
+
multiplyLegLevel(leg, levelFactor);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
if (itinerary._coords) {
|
|
472
|
+
for (const coords of itinerary._coords) {
|
|
473
|
+
coords.level = Level.multiplyBy(coords.level, levelFactor);
|
|
486
474
|
}
|
|
487
475
|
}
|
|
488
476
|
}
|
|
489
477
|
|
|
478
|
+
/**
|
|
479
|
+
* @param {RouterResponse} routerResponse
|
|
480
|
+
* @param {number} levelFactor
|
|
481
|
+
*/
|
|
482
|
+
function multiplyRouterResponseLevel(routerResponse, levelFactor) {
|
|
483
|
+
|
|
484
|
+
routerResponse.from.level = Level.multiplyBy(routerResponse.from.level, levelFactor);
|
|
485
|
+
routerResponse.to.level = Level.multiplyBy(routerResponse.to.level, levelFactor);
|
|
486
|
+
|
|
487
|
+
for (const itinerary of routerResponse.itineraries) {
|
|
488
|
+
multiplyItineraryLevel(itinerary, levelFactor);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
490
492
|
/* eslint-disable max-statements */
|
|
491
493
|
|
|
492
494
|
/**
|
|
@@ -535,7 +537,7 @@ class Itinerary {
|
|
|
535
537
|
if (!this._coords) {
|
|
536
538
|
// Returns the coordinates contained in all legs and remove duplicates between array
|
|
537
539
|
this._coords = this.legs.reduce((acc, val) => {
|
|
538
|
-
const isDuplicate = acc.length && val.coords.length && acc[acc.length - 1].
|
|
540
|
+
const isDuplicate = acc.length && val.coords.length && acc[acc.length - 1].equals(val.coords[0]);
|
|
539
541
|
acc.push(...val.coords.slice(isDuplicate ? 1 : 0));
|
|
540
542
|
return acc;
|
|
541
543
|
}, []);
|
|
@@ -679,9 +681,9 @@ class Itinerary {
|
|
|
679
681
|
* @param {Itinerary} obj2
|
|
680
682
|
* @returns {Boolean}
|
|
681
683
|
*/
|
|
682
|
-
static
|
|
683
|
-
const intermediate = obj1.from.
|
|
684
|
-
&& obj1.to.
|
|
684
|
+
static equals(obj1, obj2) {
|
|
685
|
+
const intermediate = obj1.from.equals(obj2.from)
|
|
686
|
+
&& obj1.to.equals(obj2.to)
|
|
685
687
|
&& obj1.distance === obj2.distance
|
|
686
688
|
&& obj1.duration === obj2.duration
|
|
687
689
|
&& obj1.startTime === obj2.startTime
|
|
@@ -693,7 +695,7 @@ class Itinerary {
|
|
|
693
695
|
}
|
|
694
696
|
|
|
695
697
|
for (let i = 0; i < obj1.legs.length; i++) {
|
|
696
|
-
if (!obj1.legs[i].
|
|
698
|
+
if (!obj1.legs[i].equals(obj2.legs[i])) {
|
|
697
699
|
return false;
|
|
698
700
|
}
|
|
699
701
|
}
|
|
@@ -705,8 +707,8 @@ class Itinerary {
|
|
|
705
707
|
* @param {Itinerary} obj
|
|
706
708
|
* @returns {Boolean}
|
|
707
709
|
*/
|
|
708
|
-
|
|
709
|
-
return Itinerary.
|
|
710
|
+
equals(obj) {
|
|
711
|
+
return Itinerary.equals(this, obj);
|
|
710
712
|
}
|
|
711
713
|
|
|
712
714
|
/**
|
|
@@ -773,10 +775,10 @@ class RouterResponse {
|
|
|
773
775
|
* @param {RouterResponse} obj2
|
|
774
776
|
* @returns {Boolean}
|
|
775
777
|
*/
|
|
776
|
-
static
|
|
778
|
+
static equals(obj1, obj2) {
|
|
777
779
|
const intermediate = obj1.routerName === obj2.routerName
|
|
778
|
-
&& obj1.from.
|
|
779
|
-
&& obj1.to.
|
|
780
|
+
&& obj1.from.equals(obj2.from)
|
|
781
|
+
&& obj1.to.equals(obj2.to)
|
|
780
782
|
&& obj1.itineraries.length === obj2.itineraries.length;
|
|
781
783
|
|
|
782
784
|
if (!intermediate) {
|
|
@@ -784,7 +786,7 @@ class RouterResponse {
|
|
|
784
786
|
}
|
|
785
787
|
|
|
786
788
|
for (let i = 0; i < obj1.itineraries.length; i++) {
|
|
787
|
-
if (!obj1.itineraries[i].
|
|
789
|
+
if (!obj1.itineraries[i].equals(obj2.itineraries[i])) {
|
|
788
790
|
return false;
|
|
789
791
|
}
|
|
790
792
|
}
|
|
@@ -796,8 +798,8 @@ class RouterResponse {
|
|
|
796
798
|
* @param {RouterResponse} obj
|
|
797
799
|
* @returns {Boolean}
|
|
798
800
|
*/
|
|
799
|
-
|
|
800
|
-
return RouterResponse.
|
|
801
|
+
equals(obj) {
|
|
802
|
+
return RouterResponse.equals(this, obj);
|
|
801
803
|
}
|
|
802
804
|
|
|
803
805
|
|
|
@@ -949,9 +951,8 @@ class WemapStepsGeneration {
|
|
|
949
951
|
|
|
950
952
|
let splitByAngle = Math.abs(diffAngle(Math.PI, angle)) >= SKIP_STEP_ANGLE_MAX;
|
|
951
953
|
|
|
952
|
-
const splitByLevel = edge.level &&
|
|
953
|
-
|
|
954
|
-
splitByAngle = splitByAngle && !(node.coords.level && node.coords.level.isRange);
|
|
954
|
+
const splitByLevel = Level.isRange(edge.level) && !Level.isRange(node.coords.level);
|
|
955
|
+
splitByAngle = splitByAngle && !(node.coords.level && Level.isRange(node.coords.level));
|
|
955
956
|
|
|
956
957
|
const splitStepCondition = splitByAngle || splitByLevel;
|
|
957
958
|
|
|
@@ -999,7 +1000,7 @@ class WemapStepsGeneration {
|
|
|
999
1000
|
const lastNode = nodes[nodes.length - 1];
|
|
1000
1001
|
|
|
1001
1002
|
// Create a last step if end is not on the network
|
|
1002
|
-
if (!Coordinates.
|
|
1003
|
+
if (!Coordinates.equals(lastNode.coords, end)) {
|
|
1003
1004
|
const lastStep = new Step();
|
|
1004
1005
|
lastStep.coords = lastNode.coords;
|
|
1005
1006
|
lastStep.number = steps.length + 1;
|
|
@@ -1145,7 +1146,7 @@ function createNodesAndEdgesFromElevator(networkModel, node) {
|
|
|
1145
1146
|
/** @type {GraphNode[]} */
|
|
1146
1147
|
const createdNodes = [];
|
|
1147
1148
|
const getOrCreateLevelNode = (level, builtFrom) => {
|
|
1148
|
-
let levelNode = createdNodes.find(({ coords }) => Level.
|
|
1149
|
+
let levelNode = createdNodes.find(({ coords }) => Level.equals(level, coords.level));
|
|
1149
1150
|
if (!levelNode) {
|
|
1150
1151
|
levelNode = new GraphNode(node.coords.clone(), builtFrom);
|
|
1151
1152
|
levelNode.coords.level = level;
|
|
@@ -1157,7 +1158,7 @@ function createNodesAndEdgesFromElevator(networkModel, node) {
|
|
|
1157
1158
|
|
|
1158
1159
|
// Create nodes from node.edges
|
|
1159
1160
|
node.edges.forEach(edge => {
|
|
1160
|
-
if (edge.level
|
|
1161
|
+
if (Level.isRange(edge.level)) {
|
|
1161
1162
|
throw new Error('Cannot handle this elevator edge due to ambiguity');
|
|
1162
1163
|
}
|
|
1163
1164
|
|
|
@@ -1177,10 +1178,13 @@ function createNodesAndEdgesFromElevator(networkModel, node) {
|
|
|
1177
1178
|
const createdNode1 = createdNodes[i];
|
|
1178
1179
|
const createdNode2 = createdNodes[j];
|
|
1179
1180
|
|
|
1181
|
+
const minLevel = Math.min(createdNode1.coords.level, createdNode2.coords.level);
|
|
1182
|
+
const maxLevel = Math.max(createdNode1.coords.level, createdNode2.coords.level);
|
|
1183
|
+
|
|
1180
1184
|
const newEdge = new GraphEdge(
|
|
1181
1185
|
createdNode1,
|
|
1182
1186
|
createdNode2,
|
|
1183
|
-
|
|
1187
|
+
[minLevel, maxLevel],
|
|
1184
1188
|
node.builtFrom
|
|
1185
1189
|
);
|
|
1186
1190
|
networkModel.edges.push(newEdge);
|
|
@@ -1858,7 +1862,9 @@ class CitywayRemoteRouter extends RemoteRouter {
|
|
|
1858
1862
|
for (const jsonPathLink of jsonLeg.pathLinks.PathLink) {
|
|
1859
1863
|
const step = new Step();
|
|
1860
1864
|
let stepCoords;
|
|
1861
|
-
|
|
1865
|
+
// jsonPathLink.Geometry is either a POINT or a LINESTRING
|
|
1866
|
+
// or it can also be 'Null' as string
|
|
1867
|
+
if (jsonPathLink.Geometry && jsonPathLink.Geometry !== 'Null') {
|
|
1862
1868
|
stepCoords = this.parseWKTGeometry(jsonPathLink.Geometry);
|
|
1863
1869
|
} else {
|
|
1864
1870
|
stepCoords = [leg.from.coords, leg.to.coords];
|
|
@@ -1869,7 +1875,7 @@ class CitywayRemoteRouter extends RemoteRouter {
|
|
|
1869
1875
|
if (
|
|
1870
1876
|
idx !== 0
|
|
1871
1877
|
|| leg.coords.length === 0
|
|
1872
|
-
|| !leg.coords[leg.coords.length - 1].
|
|
1878
|
+
|| !leg.coords[leg.coords.length - 1].equals(coords)
|
|
1873
1879
|
) {
|
|
1874
1880
|
leg.coords.push(coords);
|
|
1875
1881
|
}
|
|
@@ -1914,7 +1920,7 @@ class CitywayRemoteRouter extends RemoteRouter {
|
|
|
1914
1920
|
if (
|
|
1915
1921
|
idx !== 0
|
|
1916
1922
|
|| leg.coords.length === 0
|
|
1917
|
-
|| !leg.coords[leg.coords.length - 1].
|
|
1923
|
+
|| !leg.coords[leg.coords.length - 1].equals(coords)
|
|
1918
1924
|
) {
|
|
1919
1925
|
leg.coords.push(coords);
|
|
1920
1926
|
}
|
|
@@ -1991,8 +1997,8 @@ class CitywayRemoteRouter extends RemoteRouter {
|
|
|
1991
1997
|
* @returns {Coordinates[]}
|
|
1992
1998
|
*/
|
|
1993
1999
|
parseWKTGeometry(wktGeometry) {
|
|
1994
|
-
const tmpCoordsStr = wktGeometry.match(/LINESTRING
|
|
1995
|
-
const tmpCoordsPt = wktGeometry.match(/POINT
|
|
2000
|
+
const tmpCoordsStr = wktGeometry.match(/LINESTRING ?\((.*)\)/i);
|
|
2001
|
+
const tmpCoordsPt = wktGeometry.match(/POINT ?\((.*)\)/i);
|
|
1996
2002
|
if (!tmpCoordsStr && !tmpCoordsPt) {
|
|
1997
2003
|
return null;
|
|
1998
2004
|
}
|
|
@@ -2077,12 +2083,10 @@ class DeutscheBahnRemoteRouter extends RemoteRouter {
|
|
|
2077
2083
|
let url = endpointUrl + '/route/v1/walking/';
|
|
2078
2084
|
|
|
2079
2085
|
url += waypoints.map(waypoint => {
|
|
2080
|
-
if (waypoint.level) {
|
|
2081
|
-
const altitude = waypoint.level
|
|
2082
|
-
|
|
2086
|
+
if (waypoint.level !== null) {
|
|
2087
|
+
const altitude = Level.isRange(waypoint.level) ? waypoint.level[0] : waypoint.level;
|
|
2083
2088
|
return waypoint.longitude + ',' + waypoint.latitude + ',' + altitude;
|
|
2084
2089
|
}
|
|
2085
|
-
|
|
2086
2090
|
return waypoint.longitude + ',' + waypoint.latitude;
|
|
2087
2091
|
}).join(';');
|
|
2088
2092
|
|
|
@@ -2122,14 +2126,16 @@ class DeutscheBahnRemoteRouter extends RemoteRouter {
|
|
|
2122
2126
|
let id = 1;
|
|
2123
2127
|
for (const jsonSegment of jsonSegments) {
|
|
2124
2128
|
|
|
2125
|
-
const level =
|
|
2129
|
+
const level = jsonSegment.fromLevel === jsonSegment.toLevel
|
|
2130
|
+
? jsonSegment.fromLevel
|
|
2131
|
+
: [jsonSegment.fromLevel, jsonSegment.toLevel];
|
|
2126
2132
|
const osmWay = new OsmWay(id++, null, level);
|
|
2127
2133
|
|
|
2128
2134
|
for (const jsonPoint of jsonSegment.polyline) {
|
|
2129
2135
|
const coord = new Coordinates(jsonPoint.lat, jsonPoint.lon, null, level);
|
|
2130
2136
|
|
|
2131
2137
|
if (nodes.length !== 0
|
|
2132
|
-
&& nodes[nodes.length - 1].coords.
|
|
2138
|
+
&& nodes[nodes.length - 1].coords.equals(coord)) {
|
|
2133
2139
|
continue;
|
|
2134
2140
|
}
|
|
2135
2141
|
|
|
@@ -2680,7 +2686,7 @@ class OsrmRemoteRouter extends RemoteRouter {
|
|
|
2680
2686
|
coordinatesToJson(coordinates) {
|
|
2681
2687
|
const output = [coordinates.lng, coordinates.lat];
|
|
2682
2688
|
if (coordinates.level) {
|
|
2683
|
-
output.push(coordinates.level
|
|
2689
|
+
output.push(coordinates.level);
|
|
2684
2690
|
}
|
|
2685
2691
|
return output;
|
|
2686
2692
|
}
|
|
@@ -2690,11 +2696,16 @@ class OsrmRemoteRouter extends RemoteRouter {
|
|
|
2690
2696
|
* @returns {Coordinates}
|
|
2691
2697
|
*/
|
|
2692
2698
|
jsonToCoordinates(json) {
|
|
2693
|
-
const
|
|
2699
|
+
const coords = new Coordinates(json[1], json[0]);
|
|
2694
2700
|
if (json.length > 2) {
|
|
2695
|
-
|
|
2701
|
+
if (typeof json[2] === 'string') {
|
|
2702
|
+
Logger.warn('Still using legacy level format. Please update your project.');
|
|
2703
|
+
coords.level = Level.fromString(json[2]);
|
|
2704
|
+
} else {
|
|
2705
|
+
coords.level = json[2];
|
|
2706
|
+
}
|
|
2696
2707
|
}
|
|
2697
|
-
return
|
|
2708
|
+
return coords;
|
|
2698
2709
|
}
|
|
2699
2710
|
|
|
2700
2711
|
nodesToJsonCoords(nodes) {
|
|
@@ -2758,10 +2769,10 @@ class OsrmRemoteRouter extends RemoteRouter {
|
|
|
2758
2769
|
let type = idStep === 0 && idLeg === 0 ? 'depart' : 'turn';
|
|
2759
2770
|
type = idStep === lastStepId && idLeg === lastLegId ? 'arrive' : type;
|
|
2760
2771
|
|
|
2761
|
-
const stepCoordsIdx = coords.findIndex(p => p.
|
|
2772
|
+
const stepCoordsIdx = coords.findIndex(p => p.equals(step.coords));
|
|
2762
2773
|
const nextStepCoordsIdx = idStep === lastStepId
|
|
2763
2774
|
? stepCoordsIdx
|
|
2764
|
-
: coords.findIndex(p => p.
|
|
2775
|
+
: coords.findIndex(p => p.equals(arr[idStep + 1].coords));
|
|
2765
2776
|
|
|
2766
2777
|
const jsonStep = {
|
|
2767
2778
|
geometry: {
|
|
@@ -2903,7 +2914,7 @@ class OsrmRemoteRouter extends RemoteRouter {
|
|
|
2903
2914
|
.map(step => step.geometry.coordinates.map(this.jsonToCoordinates))
|
|
2904
2915
|
.flat()
|
|
2905
2916
|
// Remove duplicates
|
|
2906
|
-
.filter((coords, idx, arr) => idx === 0 || !arr[idx - 1].
|
|
2917
|
+
.filter((coords, idx, arr) => idx === 0 || !arr[idx - 1].equals(coords));
|
|
2907
2918
|
|
|
2908
2919
|
leg.from = {
|
|
2909
2920
|
name: null,
|
|
@@ -3743,7 +3754,7 @@ class ItineraryInfoManager {
|
|
|
3743
3754
|
let distanceTraveled = 0;
|
|
3744
3755
|
|
|
3745
3756
|
itinerary.coords.forEach((coords, idx, arr) => {
|
|
3746
|
-
if (stepId < this._steps.length && this._steps[stepId].coords.
|
|
3757
|
+
if (stepId < this._steps.length && this._steps[stepId].coords.equals(coords)) {
|
|
3747
3758
|
previousStep = this._steps[stepId];
|
|
3748
3759
|
nextStep = stepId === this._steps.length - 1 ? null : this._steps[stepId + 1];
|
|
3749
3760
|
stepId++;
|
|
@@ -3832,5 +3843,5 @@ class ItineraryInfoManager {
|
|
|
3832
3843
|
|
|
3833
3844
|
}
|
|
3834
3845
|
|
|
3835
|
-
export { CitywayRemoteRouter$1 as CitywayRemoteRouter, Constants, DeutscheBahnRemoteRouter$1 as DeutscheBahnRemoteRouter, IdfmRemoteRouter$1 as IdfmRemoteRouter, Itinerary, ItineraryInfo, ItineraryInfoManager, Leg, LevelChange, OsrmRemoteRouter$1 as OsrmRemoteRouter, OtpRemoteRouter$1 as OtpRemoteRouter, RemoteRouterManager$1 as RemoteRouterManager, RouterResponse, Step, WemapMetaRemoteRouter$1 as WemapMetaRemoteRouter, WemapMetaRemoteRouterOptions, WemapMetaRemoteRouterPayload, WemapMetaRouter, IOMap as WemapMetaRouterIOMap, WemapMetaRouterOptions, WemapNetworkUtils, WemapRouter, WemapRouterOptions, WemapRouterUtils, getDurationFromLength, multiplyRouterResponseLevel };
|
|
3846
|
+
export { CitywayRemoteRouter$1 as CitywayRemoteRouter, Constants, DeutscheBahnRemoteRouter$1 as DeutscheBahnRemoteRouter, IdfmRemoteRouter$1 as IdfmRemoteRouter, Itinerary, ItineraryInfo, ItineraryInfoManager, Leg, LevelChange, OsrmRemoteRouter$1 as OsrmRemoteRouter, OtpRemoteRouter$1 as OtpRemoteRouter, RemoteRouterManager$1 as RemoteRouterManager, RemoteRouterOptions, RemoteRouterServerUnreachable, RouterResponse, Step, WemapMetaRemoteRouter$1 as WemapMetaRemoteRouter, WemapMetaRemoteRouterOptions, WemapMetaRemoteRouterPayload, WemapMetaRouter, IOMap as WemapMetaRouterIOMap, WemapMetaRouterOptions, WemapNetworkUtils, WemapRouter, WemapRouterOptions, WemapRouterUtils, getDurationFromLength, multiplyItineraryLevel, multiplyLegLevel, multiplyRouterResponseLevel };
|
|
3836
3847
|
//# sourceMappingURL=wemap-routers.es.js.map
|