@wemap/routers 8.2.1 → 9.0.0-alpha.1
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/assets/rr-wemap-meta-multi-level.json +31 -25
- package/assets/rr-wemap-meta-remote-indoor-outdoor-indoor.json +17 -17
- package/package.json +5 -5
- package/src/Utils.js +12 -27
- package/src/Utils.spec.js +11 -12
- package/src/remote/deutsche-bahn/DeutscheBahnRemoteRouter.js +5 -5
- package/src/remote/deutsche-bahn/DeutscheBahnRemoteRouter.spec.js +3 -3
- package/src/remote/osrm/OsrmRemoteRouter.js +3 -3
- package/src/remote/osrm/OsrmRemoteRouter.spec.js +4 -4
- package/src/remote/wemap-meta/WemapMetaRemoteRouter.spec.js +2 -2
- package/src/wemap/WemapNetworkUtils.js +5 -2
- package/src/wemap/WemapRouter.spec.js +7 -9
- package/src/wemap/WemapStepsGeneration.js +2 -3
- package/src/wemap-meta/WemapMetaRouter.spec.js +2 -2
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
43.6091851,
|
|
8
8
|
3.8841386,
|
|
9
9
|
1.5999999999999996,
|
|
10
|
-
|
|
10
|
+
2
|
|
11
11
|
],
|
|
12
12
|
"to": [
|
|
13
13
|
43.6093145,
|
|
14
14
|
3.8842585,
|
|
15
15
|
0,
|
|
16
|
-
|
|
16
|
+
1
|
|
17
17
|
],
|
|
18
18
|
"itineraries": [
|
|
19
19
|
{
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
43.6091851,
|
|
22
22
|
3.8841386,
|
|
23
23
|
1.5999999999999996,
|
|
24
|
-
|
|
24
|
+
2
|
|
25
25
|
],
|
|
26
26
|
"to": [
|
|
27
27
|
43.6093145,
|
|
28
28
|
3.8842585,
|
|
29
29
|
0,
|
|
30
|
-
|
|
30
|
+
1
|
|
31
31
|
],
|
|
32
32
|
"distance": 42.54181917885857,
|
|
33
33
|
"duration": 30.630109808778165,
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
43.6091851,
|
|
41
41
|
3.8841386,
|
|
42
42
|
1.5999999999999996,
|
|
43
|
-
|
|
43
|
+
2
|
|
44
44
|
]
|
|
45
45
|
},
|
|
46
46
|
"to": {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
43.6093145,
|
|
49
49
|
3.8842585,
|
|
50
50
|
0,
|
|
51
|
-
|
|
51
|
+
1
|
|
52
52
|
]
|
|
53
53
|
},
|
|
54
54
|
"distance": 42.54181917885857,
|
|
@@ -58,67 +58,73 @@
|
|
|
58
58
|
43.60918687807148,
|
|
59
59
|
3.884139117496946,
|
|
60
60
|
1.5999999999999996,
|
|
61
|
-
|
|
61
|
+
2
|
|
62
62
|
],
|
|
63
63
|
[
|
|
64
64
|
43.60917494597,
|
|
65
65
|
3.88421731753,
|
|
66
66
|
null,
|
|
67
|
-
|
|
67
|
+
2
|
|
68
68
|
],
|
|
69
69
|
[
|
|
70
70
|
43.60927603206,
|
|
71
71
|
3.88424673798,
|
|
72
72
|
null,
|
|
73
|
-
|
|
73
|
+
2
|
|
74
74
|
],
|
|
75
75
|
[
|
|
76
76
|
43.60929353543,
|
|
77
77
|
3.88425183223,
|
|
78
78
|
null,
|
|
79
|
-
|
|
79
|
+
2
|
|
80
80
|
],
|
|
81
81
|
[
|
|
82
82
|
43.60930219142,
|
|
83
83
|
3.88427017086,
|
|
84
84
|
null,
|
|
85
|
-
|
|
85
|
+
2
|
|
86
86
|
],
|
|
87
87
|
[
|
|
88
88
|
43.60931231268,
|
|
89
89
|
3.8842731166,
|
|
90
90
|
null,
|
|
91
|
-
|
|
91
|
+
2
|
|
92
92
|
],
|
|
93
93
|
[
|
|
94
94
|
43.60932336323,
|
|
95
95
|
3.884200898,
|
|
96
96
|
null,
|
|
97
|
-
|
|
97
|
+
2
|
|
98
98
|
],
|
|
99
99
|
[
|
|
100
100
|
43.6093629216,
|
|
101
101
|
3.884212726,
|
|
102
102
|
null,
|
|
103
|
-
|
|
103
|
+
[
|
|
104
|
+
1,
|
|
105
|
+
2
|
|
106
|
+
]
|
|
104
107
|
],
|
|
105
108
|
[
|
|
106
109
|
43.60935965678,
|
|
107
110
|
3.8842335535,
|
|
108
111
|
null,
|
|
109
|
-
|
|
112
|
+
[
|
|
113
|
+
1,
|
|
114
|
+
2
|
|
115
|
+
]
|
|
110
116
|
],
|
|
111
117
|
[
|
|
112
118
|
43.60932022256,
|
|
113
119
|
3.88422176261,
|
|
114
120
|
null,
|
|
115
|
-
|
|
121
|
+
1
|
|
116
122
|
],
|
|
117
123
|
[
|
|
118
124
|
43.60931456597898,
|
|
119
125
|
3.884258519367876,
|
|
120
126
|
0,
|
|
121
|
-
|
|
127
|
+
1
|
|
122
128
|
]
|
|
123
129
|
],
|
|
124
130
|
"steps": [
|
|
@@ -128,7 +134,7 @@
|
|
|
128
134
|
43.60918687807148,
|
|
129
135
|
3.884139117496946,
|
|
130
136
|
1.5999999999999996,
|
|
131
|
-
|
|
137
|
+
2
|
|
132
138
|
],
|
|
133
139
|
"angle": 1.570796452892035,
|
|
134
140
|
"previousBearing": 0.20769475566724294,
|
|
@@ -144,7 +150,7 @@
|
|
|
144
150
|
43.60917494597,
|
|
145
151
|
3.88421731753,
|
|
146
152
|
null,
|
|
147
|
-
|
|
153
|
+
2
|
|
148
154
|
],
|
|
149
155
|
"angle": -1.5707958396207153,
|
|
150
156
|
"previousBearing": 1.7784909563650013,
|
|
@@ -159,7 +165,7 @@
|
|
|
159
165
|
43.60929353543,
|
|
160
166
|
3.88425183223,
|
|
161
167
|
null,
|
|
162
|
-
|
|
168
|
+
2
|
|
163
169
|
],
|
|
164
170
|
"angle": 2.3561946292270304,
|
|
165
171
|
"previousBearing": 0.20769440021825977,
|
|
@@ -174,7 +180,7 @@
|
|
|
174
180
|
43.60930219142,
|
|
175
181
|
3.88427017086,
|
|
176
182
|
null,
|
|
177
|
-
|
|
183
|
+
2
|
|
178
184
|
],
|
|
179
185
|
"angle": -2.35619514761237,
|
|
180
186
|
"previousBearing": 0.9930924245810223,
|
|
@@ -189,7 +195,7 @@
|
|
|
189
195
|
43.60931231268,
|
|
190
196
|
3.8842731166,
|
|
191
197
|
null,
|
|
192
|
-
|
|
198
|
+
2
|
|
193
199
|
],
|
|
194
200
|
"angle": -1.571367193550253,
|
|
195
201
|
"previousBearing": 0.20769491860359898,
|
|
@@ -204,7 +210,7 @@
|
|
|
204
210
|
43.60932336323,
|
|
205
211
|
3.884200898,
|
|
206
212
|
null,
|
|
207
|
-
|
|
213
|
+
2
|
|
208
214
|
],
|
|
209
215
|
"angle": 1.5658578729882155,
|
|
210
216
|
"previousBearing": -1.3625305414359412,
|
|
@@ -224,7 +230,7 @@
|
|
|
224
230
|
43.60932022256,
|
|
225
231
|
3.88422176261,
|
|
226
232
|
null,
|
|
227
|
-
|
|
233
|
+
1
|
|
228
234
|
],
|
|
229
235
|
"angle": -1.567016008190605,
|
|
230
236
|
"previousBearing": -2.928388068274625,
|
|
@@ -239,7 +245,7 @@
|
|
|
239
245
|
43.60931456597898,
|
|
240
246
|
3.884258519367876,
|
|
241
247
|
0,
|
|
242
|
-
|
|
248
|
+
1
|
|
243
249
|
],
|
|
244
250
|
"angle": 1.570792167125268,
|
|
245
251
|
"previousBearing": 1.780220593505773,
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
48.8772962,
|
|
13
13
|
2.3584458,
|
|
14
14
|
null,
|
|
15
|
-
|
|
15
|
+
0
|
|
16
16
|
],
|
|
17
17
|
"itineraries": [
|
|
18
18
|
{
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
48.8772962,
|
|
25
25
|
2.3584458,
|
|
26
26
|
null,
|
|
27
|
-
|
|
27
|
+
0
|
|
28
28
|
],
|
|
29
29
|
"distance": 1623.567209158486,
|
|
30
30
|
"duration": 1188.9963905941102,
|
|
@@ -556,7 +556,7 @@
|
|
|
556
556
|
48.8774156,
|
|
557
557
|
2.3581551,
|
|
558
558
|
null,
|
|
559
|
-
|
|
559
|
+
0
|
|
560
560
|
]
|
|
561
561
|
},
|
|
562
562
|
"to": {
|
|
@@ -564,7 +564,7 @@
|
|
|
564
564
|
48.8772962,
|
|
565
565
|
2.3584458,
|
|
566
566
|
null,
|
|
567
|
-
|
|
567
|
+
0
|
|
568
568
|
]
|
|
569
569
|
},
|
|
570
570
|
"distance": 30.909140939457533,
|
|
@@ -574,61 +574,61 @@
|
|
|
574
574
|
48.8774156,
|
|
575
575
|
2.3581551,
|
|
576
576
|
null,
|
|
577
|
-
|
|
577
|
+
0
|
|
578
578
|
],
|
|
579
579
|
[
|
|
580
580
|
48.8774031,
|
|
581
581
|
2.3582059,
|
|
582
582
|
null,
|
|
583
|
-
|
|
583
|
+
0
|
|
584
584
|
],
|
|
585
585
|
[
|
|
586
586
|
48.87739408877,
|
|
587
587
|
2.3582397815,
|
|
588
588
|
null,
|
|
589
|
-
|
|
589
|
+
0
|
|
590
590
|
],
|
|
591
591
|
[
|
|
592
592
|
48.87738003272,
|
|
593
593
|
2.35829263106,
|
|
594
594
|
null,
|
|
595
|
-
|
|
595
|
+
0
|
|
596
596
|
],
|
|
597
597
|
[
|
|
598
598
|
48.87737740687,
|
|
599
599
|
2.35830250403,
|
|
600
600
|
null,
|
|
601
|
-
|
|
601
|
+
0
|
|
602
602
|
],
|
|
603
603
|
[
|
|
604
604
|
48.87736050007,
|
|
605
605
|
2.35836607217,
|
|
606
606
|
null,
|
|
607
|
-
|
|
607
|
+
0
|
|
608
608
|
],
|
|
609
609
|
[
|
|
610
610
|
48.8773552,
|
|
611
611
|
2.358386,
|
|
612
612
|
null,
|
|
613
|
-
|
|
613
|
+
0
|
|
614
614
|
],
|
|
615
615
|
[
|
|
616
616
|
48.87734966973,
|
|
617
617
|
2.35840668389,
|
|
618
618
|
null,
|
|
619
|
-
|
|
619
|
+
0
|
|
620
620
|
],
|
|
621
621
|
[
|
|
622
622
|
48.87732716148,
|
|
623
623
|
2.35849104813,
|
|
624
624
|
null,
|
|
625
|
-
|
|
625
|
+
0
|
|
626
626
|
],
|
|
627
627
|
[
|
|
628
628
|
48.87729021362492,
|
|
629
629
|
2.3584691138693743,
|
|
630
630
|
null,
|
|
631
|
-
|
|
631
|
+
0
|
|
632
632
|
]
|
|
633
633
|
],
|
|
634
634
|
"steps": [
|
|
@@ -638,7 +638,7 @@
|
|
|
638
638
|
48.8774156,
|
|
639
639
|
2.3581551,
|
|
640
640
|
null,
|
|
641
|
-
|
|
641
|
+
0
|
|
642
642
|
],
|
|
643
643
|
"angle": 1.2127782103969411,
|
|
644
644
|
"previousBearing": 0,
|
|
@@ -653,7 +653,7 @@
|
|
|
653
653
|
48.87732716148,
|
|
654
654
|
2.35849104813,
|
|
655
655
|
null,
|
|
656
|
-
|
|
656
|
+
0
|
|
657
657
|
],
|
|
658
658
|
"angle": 1.5839505274258527,
|
|
659
659
|
"previousBearing": 1.9561807173237418,
|
|
@@ -668,7 +668,7 @@
|
|
|
668
668
|
48.87729021362492,
|
|
669
669
|
2.3584691138693743,
|
|
670
670
|
null,
|
|
671
|
-
|
|
671
|
+
0
|
|
672
672
|
],
|
|
673
673
|
"angle": 1.570800373779623,
|
|
674
674
|
"previousBearing": -2.769362463691904,
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"directory": "packages/routers"
|
|
12
12
|
},
|
|
13
13
|
"name": "@wemap/routers",
|
|
14
|
-
"version": "
|
|
14
|
+
"version": "9.0.0-alpha.1",
|
|
15
15
|
"bugs": {
|
|
16
16
|
"url": "https://github.com/wemap/wemap-modules-js/issues"
|
|
17
17
|
},
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"@turf/boolean-point-in-polygon": "^6.5.0",
|
|
30
30
|
"@turf/convex": "^6.5.0",
|
|
31
31
|
"@turf/helpers": "^6.5.0",
|
|
32
|
-
"@wemap/geo": "^
|
|
33
|
-
"@wemap/logger": "^
|
|
32
|
+
"@wemap/geo": "^9.0.0-alpha.1",
|
|
33
|
+
"@wemap/logger": "^9.0.0-alpha.1",
|
|
34
34
|
"@wemap/maths": "^8.1.0",
|
|
35
|
-
"@wemap/osm": "^
|
|
35
|
+
"@wemap/osm": "^9.0.0-alpha.1"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "ee4ec0283dbaa4c51fd01503184df3370c52628c"
|
|
38
38
|
}
|
package/src/Utils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import RouterResponse from './model/RouterResponse.js';
|
|
3
|
+
import { Level } from '@wemap/geo';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Get route duration
|
|
@@ -17,46 +18,30 @@ export function getDurationFromLength(length, speed = 5) {
|
|
|
17
18
|
* @param {Number} levelFactor
|
|
18
19
|
*/
|
|
19
20
|
export function multiplyRouterResponseLevel(routerResponse, levelFactor) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
routerResponse.to.level.multiplyBy(levelFactor);
|
|
25
|
-
}
|
|
21
|
+
|
|
22
|
+
routerResponse.from.level = Level.multiplyBy(routerResponse.from.level, levelFactor);
|
|
23
|
+
routerResponse.to.level = Level.multiplyBy(routerResponse.to.level, levelFactor);
|
|
24
|
+
|
|
26
25
|
for (const itinerary of routerResponse.itineraries) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
if (itinerary.to.level) {
|
|
31
|
-
itinerary.to.level.multiplyBy(levelFactor);
|
|
32
|
-
}
|
|
26
|
+
itinerary.from.level = Level.multiplyBy(itinerary.from.level, levelFactor);
|
|
27
|
+
itinerary.to.level = Level.multiplyBy(itinerary.to.level, levelFactor);
|
|
33
28
|
|
|
34
29
|
for (const leg of itinerary.legs) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
if (leg.to.coords.level) {
|
|
39
|
-
leg.to.coords.level.multiplyBy(levelFactor);
|
|
40
|
-
}
|
|
30
|
+
leg.from.coords.level = Level.multiplyBy(leg.from.coords.level, levelFactor);
|
|
31
|
+
leg.to.coords.level = Level.multiplyBy(leg.to.coords.level, levelFactor);
|
|
41
32
|
for (const coords of leg.coords) {
|
|
42
|
-
|
|
43
|
-
coords.level.multiplyBy(levelFactor);
|
|
44
|
-
}
|
|
33
|
+
coords.level = Level.multiplyBy(coords.level, levelFactor);
|
|
45
34
|
}
|
|
46
35
|
if (leg.steps) {
|
|
47
36
|
for (const step of leg.steps) {
|
|
48
|
-
|
|
49
|
-
step.coords.level.multiplyBy(levelFactor);
|
|
50
|
-
}
|
|
37
|
+
step.coords.level = Level.multiplyBy(step.coords.level, levelFactor);
|
|
51
38
|
}
|
|
52
39
|
}
|
|
53
40
|
}
|
|
54
41
|
|
|
55
42
|
if (itinerary._coords) {
|
|
56
43
|
for (const coords of itinerary._coords) {
|
|
57
|
-
|
|
58
|
-
coords.level.multiplyBy(levelFactor);
|
|
59
|
-
}
|
|
44
|
+
coords.level = Level.multiplyBy(coords.level, levelFactor);
|
|
60
45
|
}
|
|
61
46
|
}
|
|
62
47
|
}
|
package/src/Utils.spec.js
CHANGED
|
@@ -23,34 +23,33 @@ describe('Routers Utils', () => {
|
|
|
23
23
|
const routerResponse = RouterResponse.fromJson(json);
|
|
24
24
|
multiplyRouterResponseLevel(routerResponse, 5);
|
|
25
25
|
|
|
26
|
-
expect(routerResponse.from.level
|
|
27
|
-
expect(routerResponse.to.level
|
|
26
|
+
expect(routerResponse.from.level).equal(10);
|
|
27
|
+
expect(routerResponse.to.level).equal(5);
|
|
28
28
|
|
|
29
29
|
const itinerary = routerResponse.itineraries[0];
|
|
30
|
-
expect(itinerary.from.level
|
|
31
|
-
expect(itinerary.to.level
|
|
30
|
+
expect(itinerary.from.level).equal(10);
|
|
31
|
+
expect(itinerary.to.level).equal(5);
|
|
32
32
|
|
|
33
33
|
const leg = itinerary.legs[0];
|
|
34
|
-
expect(leg.from.coords.level
|
|
35
|
-
expect(leg.to.coords.level
|
|
34
|
+
expect(leg.from.coords.level).equal(10);
|
|
35
|
+
expect(leg.to.coords.level).equal(5);
|
|
36
36
|
|
|
37
37
|
for (let i = 0; i < leg.coords.length; i++) {
|
|
38
38
|
if (i <= 6) {
|
|
39
|
-
expect(leg.coords[i].level
|
|
39
|
+
expect(leg.coords[i].level).equal(10);
|
|
40
40
|
} else if (i <= 8) {
|
|
41
|
-
expect(leg.coords[i].level
|
|
42
|
-
expect(leg.coords[i].level.low).equal(5);
|
|
41
|
+
expect(leg.coords[i].level).deep.equal([5, 10]);
|
|
43
42
|
} else {
|
|
44
|
-
expect(leg.coords[i].level
|
|
43
|
+
expect(leg.coords[i].level).equal(5);
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
const { steps } = leg;
|
|
49
48
|
for (let i = 0; i < steps.length; i++) {
|
|
50
49
|
if (i <= 5) {
|
|
51
|
-
expect(steps[i].coords.level
|
|
50
|
+
expect(steps[i].coords.level).equal(10);
|
|
52
51
|
} else {
|
|
53
|
-
expect(steps[i].coords.level
|
|
52
|
+
expect(steps[i].coords.level).equal(5);
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
55
|
});
|
|
@@ -47,12 +47,10 @@ class DeutscheBahnRemoteRouter extends RemoteRouter {
|
|
|
47
47
|
let url = endpointUrl + '/route/v1/walking/';
|
|
48
48
|
|
|
49
49
|
url += waypoints.map(waypoint => {
|
|
50
|
-
if (waypoint.level) {
|
|
51
|
-
const altitude = waypoint.level
|
|
52
|
-
|
|
50
|
+
if (waypoint.level !== null) {
|
|
51
|
+
const altitude = Level.isRange(waypoint.level) ? waypoint.level[0] : waypoint.level;
|
|
53
52
|
return waypoint.longitude + ',' + waypoint.latitude + ',' + altitude;
|
|
54
53
|
}
|
|
55
|
-
|
|
56
54
|
return waypoint.longitude + ',' + waypoint.latitude;
|
|
57
55
|
}).join(';');
|
|
58
56
|
|
|
@@ -92,7 +90,9 @@ class DeutscheBahnRemoteRouter extends RemoteRouter {
|
|
|
92
90
|
let id = 1;
|
|
93
91
|
for (const jsonSegment of jsonSegments) {
|
|
94
92
|
|
|
95
|
-
const level =
|
|
93
|
+
const level = jsonSegment.fromLevel === jsonSegment.toLevel
|
|
94
|
+
? jsonSegment.fromLevel
|
|
95
|
+
: [jsonSegment.fromLevel, jsonSegment.toLevel];
|
|
96
96
|
const osmWay = new OsmWay(id++, null, level);
|
|
97
97
|
|
|
98
98
|
for (const jsonPoint of jsonSegment.polyline) {
|
|
@@ -5,7 +5,7 @@ import fs from 'fs';
|
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { fileURLToPath } from 'url';
|
|
7
7
|
|
|
8
|
-
import { Coordinates
|
|
8
|
+
import { Coordinates } from '@wemap/geo';
|
|
9
9
|
|
|
10
10
|
import DeutscheBahnRemoteRouter from './DeutscheBahnRemoteRouter.js';
|
|
11
11
|
|
|
@@ -26,8 +26,8 @@ describe('DeutscheBahnRemoteRouter - createRouterResponseFromJson', () => {
|
|
|
26
26
|
const fileString = fs.readFileSync(filePath, 'utf8');
|
|
27
27
|
const json = JSON.parse(fileString);
|
|
28
28
|
|
|
29
|
-
const from = new Coordinates(52.5258473, 13.3683657, null,
|
|
30
|
-
const to = new Coordinates(52.52499085853664, 13.369467296949914, null,
|
|
29
|
+
const from = new Coordinates(52.5258473, 13.3683657, null, -10);
|
|
30
|
+
const to = new Coordinates(52.52499085853664, 13.369467296949914, null, 0);
|
|
31
31
|
|
|
32
32
|
const routerResponse = DeutscheBahnRemoteRouter.createRouterResponseFromJson(json, from, to);
|
|
33
33
|
checkRouterResponseType(routerResponse);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable max-statements */
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { Coordinates } from '@wemap/geo';
|
|
4
4
|
import { rad2deg, positiveMod } from '@wemap/maths';
|
|
5
5
|
|
|
6
6
|
import Itinerary from '../../model/Itinerary.js';
|
|
@@ -85,7 +85,7 @@ class OsrmRemoteRouter extends RemoteRouter {
|
|
|
85
85
|
coordinatesToJson(coordinates) {
|
|
86
86
|
const output = [coordinates.lng, coordinates.lat];
|
|
87
87
|
if (coordinates.level) {
|
|
88
|
-
output.push(coordinates.level
|
|
88
|
+
output.push(coordinates.level);
|
|
89
89
|
}
|
|
90
90
|
return output;
|
|
91
91
|
}
|
|
@@ -97,7 +97,7 @@ class OsrmRemoteRouter extends RemoteRouter {
|
|
|
97
97
|
jsonToCoordinates(json) {
|
|
98
98
|
const output = new Coordinates(json[1], json[0]);
|
|
99
99
|
if (json.length > 2) {
|
|
100
|
-
output.level =
|
|
100
|
+
output.level = json[2];
|
|
101
101
|
}
|
|
102
102
|
return output;
|
|
103
103
|
}
|
|
@@ -44,8 +44,8 @@ const assetsPath = path.resolve(__dirname, '../../../assets');
|
|
|
44
44
|
// network, router
|
|
45
45
|
// } = load('bureaux-wemap-montpellier-network.osm');
|
|
46
46
|
|
|
47
|
-
// wemapIndoorStart = new Coordinates(43.6092754, 3.8842306, null,
|
|
48
|
-
// wemapIndoorEnd = new Coordinates(43.6092602, 3.8842669, null,
|
|
47
|
+
// wemapIndoorStart = new Coordinates(43.6092754, 3.8842306, null, 2);
|
|
48
|
+
// wemapIndoorEnd = new Coordinates(43.6092602, 3.8842669, null, 1);
|
|
49
49
|
// const itinerary = router.getShortestPath(wemapIndoorStart, wemapIndoorEnd);
|
|
50
50
|
// wemapIndoorItinerary = itinerary;
|
|
51
51
|
|
|
@@ -350,8 +350,8 @@ const assetsPath = path.resolve(__dirname, '../../../assets');
|
|
|
350
350
|
|
|
351
351
|
// const { router } = load('bureaux-wemap-montpellier-network.osm');
|
|
352
352
|
|
|
353
|
-
// const start = new Coordinates(43.6092754, 3.8842306, null,
|
|
354
|
-
// const end = new Coordinates(43.60949854, 3.88452048, null,
|
|
353
|
+
// const start = new Coordinates(43.6092754, 3.8842306, null, 2);
|
|
354
|
+
// const end = new Coordinates(43.60949854, 3.88452048, null, 0);
|
|
355
355
|
// const itinerary = router.getShortestPath(start, end);
|
|
356
356
|
|
|
357
357
|
// const osrmJson = itineraryToOsrmJson(itinerary);
|
|
@@ -3,7 +3,7 @@ import fs from 'fs';
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
|
|
6
|
-
import { Coordinates
|
|
6
|
+
import { Coordinates } from '@wemap/geo';
|
|
7
7
|
|
|
8
8
|
import Constants from '../../Constants.js';
|
|
9
9
|
import WemapMetaRemoteRouter from './WemapMetaRemoteRouter.js';
|
|
@@ -83,7 +83,7 @@ describe('WemapMetaRemoteRouter', () => {
|
|
|
83
83
|
|
|
84
84
|
it('indoor to outdoor to indoor', async () => {
|
|
85
85
|
const start = new Coordinates(48.8725992, 2.343431);
|
|
86
|
-
const end = new Coordinates(48.8772962, 2.3584458, null,
|
|
86
|
+
const end = new Coordinates(48.8772962, 2.3584458, null, 0);
|
|
87
87
|
mockFetchWithJsonAsset('rr-wemap-meta-remote-indoor-outdoor-indoor.json');
|
|
88
88
|
const routerResponse = await WemapMetaRemoteRouter.getItineraries(
|
|
89
89
|
endpointUrl, Constants.ROUTING_MODE.WALK, [start, end], options
|
|
@@ -67,7 +67,7 @@ function createNodesAndEdgesFromElevator(networkModel, node) {
|
|
|
67
67
|
|
|
68
68
|
// Create nodes from node.edges
|
|
69
69
|
node.edges.forEach(edge => {
|
|
70
|
-
if (edge.level
|
|
70
|
+
if (Level.isRange(edge.level)) {
|
|
71
71
|
throw new Error('Cannot handle this elevator edge due to ambiguity');
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -87,10 +87,13 @@ function createNodesAndEdgesFromElevator(networkModel, node) {
|
|
|
87
87
|
const createdNode1 = createdNodes[i];
|
|
88
88
|
const createdNode2 = createdNodes[j];
|
|
89
89
|
|
|
90
|
+
const minLevel = Math.min(createdNode1.coords.level, createdNode2.coords.level);
|
|
91
|
+
const maxLevel = Math.max(createdNode1.coords.level, createdNode2.coords.level);
|
|
92
|
+
|
|
90
93
|
const newEdge = new GraphEdge(
|
|
91
94
|
createdNode1,
|
|
92
95
|
createdNode2,
|
|
93
|
-
|
|
96
|
+
[minLevel, maxLevel],
|
|
94
97
|
node.builtFrom
|
|
95
98
|
);
|
|
96
99
|
networkModel.edges.push(newEdge);
|
|
@@ -5,9 +5,7 @@ import fs from 'fs';
|
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { fileURLToPath } from 'url';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
Level, Coordinates, GraphNode, Network, GraphItinerary
|
|
10
|
-
} from '@wemap/geo';
|
|
8
|
+
import { Coordinates, GraphNode, Network, GraphItinerary } from '@wemap/geo';
|
|
11
9
|
import { OsmElement, OsmParser } from '@wemap/osm';
|
|
12
10
|
|
|
13
11
|
|
|
@@ -32,8 +30,8 @@ const getNodesNames = _itinerary => {
|
|
|
32
30
|
};
|
|
33
31
|
|
|
34
32
|
|
|
35
|
-
const itineraryStart = new Coordinates(43.6092754, 3.8842306, null,
|
|
36
|
-
const itineraryEnd = new Coordinates(43.6092602, 3.8842669, null,
|
|
33
|
+
const itineraryStart = new Coordinates(43.6092754, 3.8842306, null, 2);
|
|
34
|
+
const itineraryEnd = new Coordinates(43.6092602, 3.8842669, null, 1);
|
|
37
35
|
|
|
38
36
|
|
|
39
37
|
/**
|
|
@@ -125,8 +123,8 @@ describe('WemapRouter - Multi-level itinerary', () => {
|
|
|
125
123
|
|
|
126
124
|
it('router returns shortest path 2', () => {
|
|
127
125
|
|
|
128
|
-
const start = new Coordinates(43.609219, 3.8841743, null,
|
|
129
|
-
const end = new Coordinates(43.60917216742, 3.8842355275, null,
|
|
126
|
+
const start = new Coordinates(43.609219, 3.8841743, null, 2);
|
|
127
|
+
const end = new Coordinates(43.60917216742, 3.8842355275, null, 2);
|
|
130
128
|
const itinerary2 = router.getShortestPath(start, end);
|
|
131
129
|
|
|
132
130
|
expect(getNodesNames(itinerary2)).deep.equals(['w1', 'p6', 'p5']);
|
|
@@ -184,8 +182,8 @@ describe('WemapRouter - Conveying', () => {
|
|
|
184
182
|
|
|
185
183
|
it('do not use oneway conveying', () => {
|
|
186
184
|
|
|
187
|
-
const start = new Coordinates(48.8445715, 2.3718927, null,
|
|
188
|
-
const end = new Coordinates(48.84443728652394, 2.3721685669363524, null,
|
|
185
|
+
const start = new Coordinates(48.8445715, 2.3718927, null, 0);
|
|
186
|
+
const end = new Coordinates(48.84443728652394, 2.3721685669363524, null, -1);
|
|
189
187
|
|
|
190
188
|
const itinerary = router.getShortestPath(start, end);
|
|
191
189
|
expect(itinerary).is.not.undefined;
|
|
@@ -37,9 +37,8 @@ class WemapStepsGeneration {
|
|
|
37
37
|
|
|
38
38
|
let splitByAngle = Math.abs(diffAngle(Math.PI, angle)) >= SKIP_STEP_ANGLE_MAX;
|
|
39
39
|
|
|
40
|
-
const splitByLevel = edge.level &&
|
|
41
|
-
|
|
42
|
-
splitByAngle = splitByAngle && !(node.coords.level && node.coords.level.isRange);
|
|
40
|
+
const splitByLevel = Level.isRange(edge.level) && !Level.isRange(node.coords.level);
|
|
41
|
+
splitByAngle = splitByAngle && !(node.coords.level && Level.isRange(node.coords.level));
|
|
43
42
|
|
|
44
43
|
const splitStepCondition = splitByAngle || splitByLevel;
|
|
45
44
|
|
|
@@ -4,7 +4,7 @@ import fs from 'fs';
|
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { Coordinates } from '@wemap/geo';
|
|
8
8
|
import Logger from '@wemap/logger';
|
|
9
9
|
|
|
10
10
|
import IOMap from './IOMap.js';
|
|
@@ -118,7 +118,7 @@ describe('WemapMetaRouter', () => {
|
|
|
118
118
|
|
|
119
119
|
options.targetMaps.push(garedelestMap.name);
|
|
120
120
|
const start = new Coordinates(48.8725992, 2.343431);
|
|
121
|
-
const end = new Coordinates(48.8772962, 2.3584458, null,
|
|
121
|
+
const end = new Coordinates(48.8772962, 2.3584458, null, 0);
|
|
122
122
|
mockFetchWithJsonAsset('rr-wemap-meta-indoor-outdoor-indoor.json');
|
|
123
123
|
|
|
124
124
|
const routerResponse = await router.getItineraries(mode, [start, end], options);
|