@wemap/routers 8.2.1 → 9.0.0-alpha.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/assets/rr-wemap-meta-multi-level.json +31 -25
- package/assets/rr-wemap-meta-remote-indoor-outdoor-indoor.json +17 -17
- package/package.json +4 -4
- package/src/ItineraryInfoManager.spec.js +1 -3
- package/src/Utils.js +12 -27
- package/src/Utils.spec.js +11 -12
- package/src/remote/cityway/CitywayRemoteRouter.js +10 -10
- package/src/remote/cityway/CitywayRemoteRouter.spec.js +5 -9
- package/src/remote/deutsche-bahn/DeutscheBahnRemoteRouter.js +15 -13
- package/src/remote/deutsche-bahn/DeutscheBahnRemoteRouter.spec.js +3 -3
- package/src/remote/idfm/IdfmRemoteRouter.js +14 -15
- package/src/remote/idfm/IdfmRemoteRouter.spec.js +3 -5
- package/src/remote/osrm/OsrmRemoteRouter.js +12 -13
- package/src/remote/osrm/OsrmRemoteRouter.spec.js +4 -4
- package/src/remote/otp/OtpRemoteRouter.js +12 -15
- package/src/remote/otp/OtpRemoteRouter.spec.js +6 -10
- 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.0",
|
|
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": "^
|
|
32
|
+
"@wemap/geo": "^9.0.0-alpha.0",
|
|
33
33
|
"@wemap/logger": "^8.0.1",
|
|
34
34
|
"@wemap/maths": "^8.1.0",
|
|
35
|
-
"@wemap/osm": "^
|
|
35
|
+
"@wemap/osm": "^9.0.0-alpha.0"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "fc17cf617195c987813ede500bf67dd0f135cf34"
|
|
38
38
|
}
|
|
@@ -19,9 +19,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
19
19
|
const filePath = path.resolve(__dirname, '../assets/itinerary-grenoble-otp-1.json');
|
|
20
20
|
const fileString = fs.readFileSync(filePath, 'utf8');
|
|
21
21
|
const json = JSON.parse(fileString);
|
|
22
|
-
const
|
|
23
|
-
const to = new Coordinates(45.163729, 5.74085);
|
|
24
|
-
const routerResponse = OtpRemoteRouter.createRouterResponseFromJson(json, from, to);
|
|
22
|
+
const routerResponse = OtpRemoteRouter.createRouterResponseFromJson(json);
|
|
25
23
|
|
|
26
24
|
let position, itineraryInfo;
|
|
27
25
|
|
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
|
});
|
|
@@ -100,7 +100,7 @@ class CitywayRemoteRouter extends RemoteRouter {
|
|
|
100
100
|
const jsonResponse = await res.json().catch(() => {
|
|
101
101
|
throw new RemoteRouterServerUnreachable(this.rname, url);
|
|
102
102
|
});
|
|
103
|
-
return this.createRouterResponseFromJson(jsonResponse
|
|
103
|
+
return this.createRouterResponseFromJson(jsonResponse);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
|
|
@@ -132,21 +132,18 @@ class CitywayRemoteRouter extends RemoteRouter {
|
|
|
132
132
|
/**
|
|
133
133
|
* Generate multi itineraries from Cityway JSON
|
|
134
134
|
* @param {object} json JSON file provided by Cityway.
|
|
135
|
-
* @
|
|
136
|
-
* @param {Coordinates} to
|
|
137
|
-
* @returns {!RouterResponse}
|
|
135
|
+
* @returns {?RouterResponse}
|
|
138
136
|
* @example https://preprod.api.lia2.cityway.fr/journeyplanner/api/opt/PlanTrips/json?DepartureLatitude=49.51509388236216&DepartureLongitude=0.09341749619366316&ArrivalLatitude=49.5067090188444&ArrivalLongitude=0.1694842115417831&DepartureType=COORDINATES&ArrivalType=COORDINATES
|
|
139
137
|
*/
|
|
140
|
-
createRouterResponseFromJson(json
|
|
138
|
+
createRouterResponseFromJson(json) {
|
|
139
|
+
|
|
140
|
+
if (json.StatusCode !== 200 || !json.Data || !json.Data.length) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
141
143
|
|
|
142
144
|
const routerResponse = new RouterResponse();
|
|
143
145
|
routerResponse.routerName = this.rname;
|
|
144
|
-
routerResponse.from = from;
|
|
145
|
-
routerResponse.to = to;
|
|
146
146
|
|
|
147
|
-
if (json.StatusCode !== 200 || !json.Data || !json.Data.length) {
|
|
148
|
-
return routerResponse;
|
|
149
|
-
}
|
|
150
147
|
|
|
151
148
|
// Do not know if it the best approach, but it works...
|
|
152
149
|
const allJsonTrips = json.Data.reduce((acc, dataObj) => {
|
|
@@ -305,6 +302,9 @@ class CitywayRemoteRouter extends RemoteRouter {
|
|
|
305
302
|
generateStepsMetadata(itinerary);
|
|
306
303
|
}
|
|
307
304
|
|
|
305
|
+
routerResponse.from = routerResponse.itineraries[0].from;
|
|
306
|
+
routerResponse.to = routerResponse.itineraries[routerResponse.itineraries.length - 1].to;
|
|
307
|
+
|
|
308
308
|
return routerResponse;
|
|
309
309
|
}
|
|
310
310
|
|
|
@@ -24,9 +24,7 @@ describe('CitywayRemoteRouter - createRouterResponseFromJson', () => {
|
|
|
24
24
|
const fileString = fs.readFileSync(filePath, 'utf8');
|
|
25
25
|
const json = JSON.parse(fileString);
|
|
26
26
|
|
|
27
|
-
const
|
|
28
|
-
const to = new Coordinates(49.5067090188444, 0.16948421154178309);
|
|
29
|
-
const routerResponse = CitywayRemoteRouter.createRouterResponseFromJson(json, from, to);
|
|
27
|
+
const routerResponse = CitywayRemoteRouter.createRouterResponseFromJson(json);
|
|
30
28
|
checkRouterResponseType(routerResponse);
|
|
31
29
|
|
|
32
30
|
expect(routerResponse.routerName).equal('cityway');
|
|
@@ -64,14 +62,12 @@ describe('CitywayRemoteRouter - createRouterResponseFromJson', () => {
|
|
|
64
62
|
expect(itinerary1leg2.transportInfo.directionName).equal('Graville');
|
|
65
63
|
});
|
|
66
64
|
|
|
67
|
-
const fakeCoords = new Coordinates(0, 0);
|
|
68
|
-
|
|
69
65
|
it('RouterResponse - 2', () => {
|
|
70
66
|
const filePath = path.resolve(assetsPath, 'itinerary-lehavre-cityway-2.json');
|
|
71
67
|
const fileString = fs.readFileSync(filePath, 'utf8');
|
|
72
68
|
const json = JSON.parse(fileString);
|
|
73
69
|
|
|
74
|
-
const routerResponse = CitywayRemoteRouter.createRouterResponseFromJson(json
|
|
70
|
+
const routerResponse = CitywayRemoteRouter.createRouterResponseFromJson(json);
|
|
75
71
|
checkRouterResponseType(routerResponse);
|
|
76
72
|
|
|
77
73
|
expect(routerResponse.itineraries.length).equal(1);
|
|
@@ -83,7 +79,7 @@ describe('CitywayRemoteRouter - createRouterResponseFromJson', () => {
|
|
|
83
79
|
const fileString = fs.readFileSync(filePath, 'utf8');
|
|
84
80
|
const json = JSON.parse(fileString);
|
|
85
81
|
|
|
86
|
-
const routerResponse = CitywayRemoteRouter.createRouterResponseFromJson(json
|
|
82
|
+
const routerResponse = CitywayRemoteRouter.createRouterResponseFromJson(json);
|
|
87
83
|
checkRouterResponseType(routerResponse);
|
|
88
84
|
|
|
89
85
|
expect(routerResponse.itineraries[0].mode).equal('PT');
|
|
@@ -95,7 +91,7 @@ describe('CitywayRemoteRouter - createRouterResponseFromJson', () => {
|
|
|
95
91
|
const fileString = fs.readFileSync(filePath, 'utf8');
|
|
96
92
|
const json = JSON.parse(fileString);
|
|
97
93
|
|
|
98
|
-
const routerResponse = CitywayRemoteRouter.createRouterResponseFromJson(json
|
|
94
|
+
const routerResponse = CitywayRemoteRouter.createRouterResponseFromJson(json);
|
|
99
95
|
checkRouterResponseType(routerResponse);
|
|
100
96
|
|
|
101
97
|
expect(routerResponse.itineraries[0].mode).equal('BIKE');
|
|
@@ -107,7 +103,7 @@ describe('CitywayRemoteRouter - createRouterResponseFromJson', () => {
|
|
|
107
103
|
const fileString = fs.readFileSync(filePath, 'utf8');
|
|
108
104
|
const json = JSON.parse(fileString);
|
|
109
105
|
|
|
110
|
-
const routerResponse = CitywayRemoteRouter.createRouterResponseFromJson(json
|
|
106
|
+
const routerResponse = CitywayRemoteRouter.createRouterResponseFromJson(json);
|
|
111
107
|
checkRouterResponseType(routerResponse);
|
|
112
108
|
|
|
113
109
|
expect(routerResponse.itineraries[1].mode).equal('PT');
|
|
@@ -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
|
|
|
@@ -64,22 +62,24 @@ class DeutscheBahnRemoteRouter extends RemoteRouter {
|
|
|
64
62
|
/**
|
|
65
63
|
* Generate multi itineraries from the DB JSON
|
|
66
64
|
* @param {object} json JSON file provided by the DB.
|
|
67
|
-
* @param {Coordinates} from
|
|
68
|
-
* @param {Coordinates} to
|
|
69
|
-
* @returns {
|
|
65
|
+
* @param {Coordinates} from itinerary start
|
|
66
|
+
* @param {Coordinates} to itinerary end
|
|
67
|
+
* @returns {?RouterResponse}
|
|
70
68
|
*/
|
|
71
69
|
createRouterResponseFromJson(json, from, to) {
|
|
72
70
|
|
|
71
|
+
const { segments: jsonSegments } = json;
|
|
72
|
+
|
|
73
|
+
if (!jsonSegments) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
73
77
|
const routerResponse = new RouterResponse();
|
|
74
78
|
routerResponse.routerName = this.rname;
|
|
79
|
+
|
|
75
80
|
routerResponse.from = from;
|
|
76
81
|
routerResponse.to = to;
|
|
77
82
|
|
|
78
|
-
const { segments: jsonSegments } = json;
|
|
79
|
-
if (!jsonSegments) {
|
|
80
|
-
return routerResponse;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
83
|
/** @type {GraphEdge<OsmElement>[]} */
|
|
84
84
|
const edges = [];
|
|
85
85
|
|
|
@@ -92,7 +92,9 @@ class DeutscheBahnRemoteRouter extends RemoteRouter {
|
|
|
92
92
|
let id = 1;
|
|
93
93
|
for (const jsonSegment of jsonSegments) {
|
|
94
94
|
|
|
95
|
-
const level =
|
|
95
|
+
const level = jsonSegment.fromLevel === jsonSegment.toLevel
|
|
96
|
+
? jsonSegment.fromLevel
|
|
97
|
+
: [jsonSegment.fromLevel, jsonSegment.toLevel];
|
|
96
98
|
const osmWay = new OsmWay(id++, null, level);
|
|
97
99
|
|
|
98
100
|
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);
|
|
@@ -127,7 +127,7 @@ class IdfmRemoteRouter extends RemoteRouter {
|
|
|
127
127
|
return routerResponse;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
return this.createRouterResponseFromJson(jsonResponse
|
|
130
|
+
return this.createRouterResponseFromJson(jsonResponse);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
/**
|
|
@@ -327,20 +327,19 @@ class IdfmRemoteRouter extends RemoteRouter {
|
|
|
327
327
|
/**
|
|
328
328
|
* Generate multi itineraries from OTP JSON
|
|
329
329
|
* @param {object} json JSON file provided by OTP.
|
|
330
|
-
* @
|
|
331
|
-
* @param {Coordinates} to
|
|
332
|
-
* @returns {!RouterResponse}
|
|
330
|
+
* @returns {?RouterResponse}
|
|
333
331
|
*/
|
|
334
|
-
createRouterResponseFromJson(json
|
|
332
|
+
createRouterResponseFromJson(json) {
|
|
333
|
+
|
|
334
|
+
if (!json || !json.journeys) {
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
335
337
|
|
|
336
338
|
const routerResponse = new RouterResponse();
|
|
337
339
|
routerResponse.routerName = this.rname;
|
|
338
|
-
routerResponse.from = from;
|
|
339
|
-
routerResponse.to = to;
|
|
340
340
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
}
|
|
341
|
+
routerResponse.from = this.getSectionCoords(json.journeys[0].sections[0]).from;
|
|
342
|
+
routerResponse.to = this.getSectionCoords(last(json.journeys[0].sections)).to;
|
|
344
343
|
|
|
345
344
|
const timeZone = json.context.timezone;
|
|
346
345
|
|
|
@@ -351,8 +350,8 @@ class IdfmRemoteRouter extends RemoteRouter {
|
|
|
351
350
|
itinerary.duration = jsonItinerary.duration;
|
|
352
351
|
itinerary.startTime = this.dateStringToTimestamp(jsonItinerary.departure_date_time, timeZone);
|
|
353
352
|
itinerary.endTime = this.dateStringToTimestamp(jsonItinerary.arrival_date_time, timeZone);
|
|
354
|
-
itinerary.from =
|
|
355
|
-
itinerary.to =
|
|
353
|
+
itinerary.from = routerResponse.from;
|
|
354
|
+
itinerary.to = routerResponse.to;
|
|
356
355
|
itinerary.distance = 0;
|
|
357
356
|
|
|
358
357
|
routerResponse.itineraries.push(itinerary);
|
|
@@ -365,7 +364,7 @@ class IdfmRemoteRouter extends RemoteRouter {
|
|
|
365
364
|
|
|
366
365
|
const leg = new Leg();
|
|
367
366
|
let existingCoords = [];
|
|
368
|
-
const { from
|
|
367
|
+
const { from, to } = this.getSectionCoords(jsonSection);
|
|
369
368
|
|
|
370
369
|
leg.distance = 0;
|
|
371
370
|
leg.mode = routingModeCorrespondance.get(jsonSection.mode);
|
|
@@ -375,12 +374,12 @@ class IdfmRemoteRouter extends RemoteRouter {
|
|
|
375
374
|
|
|
376
375
|
leg.from = {
|
|
377
376
|
name: jsonSection.from.name,
|
|
378
|
-
coords:
|
|
377
|
+
coords: from
|
|
379
378
|
};
|
|
380
379
|
|
|
381
380
|
leg.to = {
|
|
382
381
|
name: jsonSection.to.name,
|
|
383
|
-
coords:
|
|
382
|
+
coords: to
|
|
384
383
|
};
|
|
385
384
|
|
|
386
385
|
// A section can have multiple same coordinates, we need to remove them
|
|
@@ -24,17 +24,15 @@ describe('IdfmRouter - createRouterResponseFromJson', () => {
|
|
|
24
24
|
const fileString = fs.readFileSync(filePath, 'utf8');
|
|
25
25
|
const json = JSON.parse(fileString);
|
|
26
26
|
|
|
27
|
-
const
|
|
28
|
-
const to = new Coordinates(48.877877, 2.351929);
|
|
29
|
-
const routerResponse = IdfmRemoteRouter.createRouterResponseFromJson(json, from, to);
|
|
27
|
+
const routerResponse = IdfmRemoteRouter.createRouterResponseFromJson(json);
|
|
30
28
|
checkRouterResponseType(routerResponse);
|
|
31
29
|
|
|
32
30
|
expect(routerResponse.routerName).equal('idfm');
|
|
33
31
|
expect(routerResponse.itineraries.length).equal(5);
|
|
32
|
+
expect(routerResponse.from.equalsTo(new Coordinates(48.875877, 2.301357))).true;
|
|
33
|
+
expect(routerResponse.to.equalsTo(new Coordinates(48.877877, 2.351929))).true;
|
|
34
34
|
|
|
35
35
|
const itinerary1 = routerResponse.itineraries[0];
|
|
36
|
-
expect(itinerary1.from.equalsTo(new Coordinates(48.875877, 2.301357))).true;
|
|
37
|
-
expect(itinerary1.to.equalsTo(new Coordinates(48.877877, 2.351929))).true;
|
|
38
36
|
expect(itinerary1.distance).to.be.closeTo(1242, 1);
|
|
39
37
|
expect(itinerary1.duration).equal(1842);
|
|
40
38
|
expect(itinerary1.mode).equal('PT');
|
|
@@ -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';
|
|
@@ -53,9 +53,7 @@ class OsrmRemoteRouter extends RemoteRouter {
|
|
|
53
53
|
throw new RemoteRouterServerUnreachable(this.rname, url);
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
const to = waypoints[waypoints.length - 1];
|
|
58
|
-
return this.createRouterResponseFromJson(jsonResponse, from, to);
|
|
56
|
+
return this.createRouterResponseFromJson(jsonResponse, waypoints[0], waypoints[1]);
|
|
59
57
|
}
|
|
60
58
|
|
|
61
59
|
/**
|
|
@@ -85,7 +83,7 @@ class OsrmRemoteRouter extends RemoteRouter {
|
|
|
85
83
|
coordinatesToJson(coordinates) {
|
|
86
84
|
const output = [coordinates.lng, coordinates.lat];
|
|
87
85
|
if (coordinates.level) {
|
|
88
|
-
output.push(coordinates.level
|
|
86
|
+
output.push(coordinates.level);
|
|
89
87
|
}
|
|
90
88
|
return output;
|
|
91
89
|
}
|
|
@@ -97,7 +95,7 @@ class OsrmRemoteRouter extends RemoteRouter {
|
|
|
97
95
|
jsonToCoordinates(json) {
|
|
98
96
|
const output = new Coordinates(json[1], json[0]);
|
|
99
97
|
if (json.length > 2) {
|
|
100
|
-
output.level =
|
|
98
|
+
output.level = json[2];
|
|
101
99
|
}
|
|
102
100
|
return output;
|
|
103
101
|
}
|
|
@@ -267,15 +265,10 @@ class OsrmRemoteRouter extends RemoteRouter {
|
|
|
267
265
|
* @returns {?RouterResponse}
|
|
268
266
|
*/
|
|
269
267
|
createRouterResponseFromJson(json, from, to, routingMode = 'walking') {
|
|
270
|
-
|
|
271
|
-
const routerResponse = new RouterResponse();
|
|
272
|
-
routerResponse.routerName = this.rname;
|
|
273
|
-
routerResponse.from = from;
|
|
274
|
-
routerResponse.to = to;
|
|
275
|
-
|
|
276
268
|
const { routes: jsonRoutes } = json;
|
|
269
|
+
|
|
277
270
|
if (!jsonRoutes) {
|
|
278
|
-
return
|
|
271
|
+
return null;
|
|
279
272
|
}
|
|
280
273
|
|
|
281
274
|
const routingModeCorrespondance = new Map();
|
|
@@ -284,6 +277,12 @@ class OsrmRemoteRouter extends RemoteRouter {
|
|
|
284
277
|
routingModeCorrespondance.set('bicycle', 'BIKE');
|
|
285
278
|
const mode = routingModeCorrespondance.get(routingMode) || null;
|
|
286
279
|
|
|
280
|
+
const routerResponse = new RouterResponse();
|
|
281
|
+
routerResponse.routerName = this.rname;
|
|
282
|
+
|
|
283
|
+
routerResponse.from = from;
|
|
284
|
+
routerResponse.to = to;
|
|
285
|
+
|
|
287
286
|
for (const jsonItinerary of jsonRoutes) {
|
|
288
287
|
|
|
289
288
|
const itinerary = new Itinerary();
|
|
@@ -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);
|
|
@@ -50,7 +50,7 @@ class OtpRemoteRouter extends RemoteRouter {
|
|
|
50
50
|
const jsonResponse = await res.json().catch(() => {
|
|
51
51
|
throw new RemoteRouterServerUnreachable(this.rname, url);
|
|
52
52
|
});
|
|
53
|
-
return this.createRouterResponseFromJson(jsonResponse
|
|
53
|
+
return this.createRouterResponseFromJson(jsonResponse);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
/**
|
|
@@ -127,24 +127,21 @@ class OtpRemoteRouter extends RemoteRouter {
|
|
|
127
127
|
/**
|
|
128
128
|
* Generate multi itineraries from OTP JSON
|
|
129
129
|
* @param {object} json JSON file provided by OTP.
|
|
130
|
-
* @
|
|
131
|
-
* @param {Coordinates} to
|
|
132
|
-
* @returns {!RouterResponse}
|
|
130
|
+
* @returns {?RouterResponse}
|
|
133
131
|
*/
|
|
134
|
-
createRouterResponseFromJson(json
|
|
135
|
-
|
|
136
|
-
const routerResponse = new RouterResponse();
|
|
137
|
-
routerResponse.routerName = this.rname;
|
|
138
|
-
routerResponse.from = from;
|
|
139
|
-
routerResponse.to = to;
|
|
132
|
+
createRouterResponseFromJson(json) {
|
|
140
133
|
|
|
141
134
|
const { plan: jsonPlan } = json;
|
|
135
|
+
|
|
142
136
|
if (!jsonPlan) {
|
|
143
|
-
return
|
|
137
|
+
return null;
|
|
144
138
|
}
|
|
145
139
|
|
|
146
|
-
const
|
|
147
|
-
|
|
140
|
+
const routerResponse = new RouterResponse();
|
|
141
|
+
routerResponse.routerName = this.rname;
|
|
142
|
+
|
|
143
|
+
routerResponse.from = this.jsonToCoordinates(jsonPlan.from);
|
|
144
|
+
routerResponse.to = this.jsonToCoordinates(jsonPlan.to);
|
|
148
145
|
|
|
149
146
|
for (const jsonItinerary of jsonPlan.itineraries) {
|
|
150
147
|
|
|
@@ -153,8 +150,8 @@ class OtpRemoteRouter extends RemoteRouter {
|
|
|
153
150
|
itinerary.duration = jsonItinerary.duration;
|
|
154
151
|
itinerary.startTime = jsonItinerary.startTime;
|
|
155
152
|
itinerary.endTime = jsonItinerary.endTime;
|
|
156
|
-
itinerary.from =
|
|
157
|
-
itinerary.to =
|
|
153
|
+
itinerary.from = routerResponse.from;
|
|
154
|
+
itinerary.to = routerResponse.to;
|
|
158
155
|
|
|
159
156
|
routerResponse.itineraries.push(itinerary);
|
|
160
157
|
|
|
@@ -26,17 +26,15 @@ describe('OtpRouter - createRouterResponseFromJson', () => {
|
|
|
26
26
|
const fileString = fs.readFileSync(filePath, 'utf8');
|
|
27
27
|
const json = JSON.parse(fileString);
|
|
28
28
|
|
|
29
|
-
const
|
|
30
|
-
const to = new Coordinates(45.163729, 5.74085);
|
|
31
|
-
const routerResponse = OtpRemoteRouter.createRouterResponseFromJson(json, from, to);
|
|
29
|
+
const routerResponse = OtpRemoteRouter.createRouterResponseFromJson(json);
|
|
32
30
|
checkRouterResponseType(routerResponse);
|
|
33
31
|
|
|
34
32
|
expect(routerResponse.routerName).equal('otp');
|
|
35
33
|
expect(routerResponse.itineraries.length).equal(2);
|
|
34
|
+
expect(routerResponse.from.equalsTo(new Coordinates(45.187291, 5.723455))).true;
|
|
35
|
+
expect(routerResponse.to.equalsTo(new Coordinates(45.163729, 5.74085))).true;
|
|
36
36
|
|
|
37
37
|
const itinerary1 = routerResponse.itineraries[0];
|
|
38
|
-
expect(itinerary1.from.equalsTo(new Coordinates(45.187291, 5.723455))).true;
|
|
39
|
-
expect(itinerary1.to.equalsTo(new Coordinates(45.163729, 5.74085))).true;
|
|
40
38
|
expect(itinerary1.coords.length).equal(162);
|
|
41
39
|
expect(itinerary1.duration).equal(1206);
|
|
42
40
|
expect(itinerary1.startTime).equal(1614607210000);
|
|
@@ -72,16 +70,14 @@ describe('OtpRouter - createRouterResponseFromJson', () => {
|
|
|
72
70
|
const fileString = fs.readFileSync(filePath, 'utf8');
|
|
73
71
|
const json = JSON.parse(fileString);
|
|
74
72
|
|
|
75
|
-
const
|
|
76
|
-
const to = new Coordinates(45.18544, 5.73123);
|
|
77
|
-
const routerResponse = OtpRemoteRouter.createRouterResponseFromJson(json, from, to);
|
|
73
|
+
const routerResponse = OtpRemoteRouter.createRouterResponseFromJson(json);
|
|
78
74
|
checkRouterResponseType(routerResponse);
|
|
79
75
|
|
|
80
76
|
expect(routerResponse.itineraries.length).equal(2);
|
|
77
|
+
expect(routerResponse.from.equalsTo(new Coordinates(45.192514856662456, 5.731452541397871))).true;
|
|
78
|
+
expect(routerResponse.to.equalsTo(new Coordinates(45.18544, 5.73123))).true;
|
|
81
79
|
|
|
82
80
|
const itinerary1 = routerResponse.itineraries[0];
|
|
83
|
-
expect(itinerary1.from.equalsTo(new Coordinates(45.192514856662456, 5.731452541397871))).true;
|
|
84
|
-
expect(itinerary1.to.equalsTo(new Coordinates(45.18544, 5.73123))).true;
|
|
85
81
|
expect(itinerary1.legs.length).equal(5);
|
|
86
82
|
|
|
87
83
|
expect(itinerary1.mode).equal('PT');
|
|
@@ -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);
|