@wemap/osm 5.4.1 → 5.4.6
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/itinerary-lehavre-cityway-2.json +2133 -0
- package/assets/itinerary-lehavre-cityway-3.json +12577 -0
- package/index.js +1 -0
- package/package.json +2 -2
- package/src/routers/Leg.js +1 -1
- package/src/routers/cityway/CitywayUtils.js +8 -5
- package/src/routers/cityway/CitywayUtils.spec.js +33 -1
- /package/assets/{itinerary-lehavre-cityway.json → itinerary-lehavre-cityway-1.json} +0 -0
package/index.js
CHANGED
|
@@ -14,6 +14,7 @@ export * as OsmNetworkUtils from './src/routers/custom/OsmNetworkUtils.js';
|
|
|
14
14
|
/* OSRM/OTP Router */
|
|
15
15
|
export * as OsrmUtils from './src/routers/osrm/OsrmUtils.js';
|
|
16
16
|
export * as OtpUtils from './src/routers/otp/OtpUtils.js';
|
|
17
|
+
export * as CitywayUtils from './src/routers/cityway/CitywayUtils.js';
|
|
17
18
|
|
|
18
19
|
/* Router model */
|
|
19
20
|
export { default as RouterResponse } from './src/routers/RouterResponse.js';
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"directory": "packages/osm"
|
|
12
12
|
},
|
|
13
13
|
"name": "@wemap/osm",
|
|
14
|
-
"version": "5.4.
|
|
14
|
+
"version": "5.4.6",
|
|
15
15
|
"bugs": {
|
|
16
16
|
"url": "https://github.com/wemap/wemap-modules-js/issues"
|
|
17
17
|
},
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"@wemap/maths": "^5.1.1",
|
|
32
32
|
"saxes": "^5.0.1"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "3e1281575d667fcf2e911258a449695022a61910"
|
|
35
35
|
}
|
package/src/routers/Leg.js
CHANGED
|
@@ -89,10 +89,13 @@ export function createRouterResponseFromJson(json) {
|
|
|
89
89
|
routerResponse.routerName = 'cityway';
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
//
|
|
93
|
-
const
|
|
92
|
+
// Do not know if it the best approach, but it works...
|
|
93
|
+
const allJsonTrips = json.Data.reduce((acc, dataObj) => {
|
|
94
|
+
acc.push(...dataObj.response.trips.Trip);
|
|
95
|
+
return acc;
|
|
96
|
+
}, []);
|
|
94
97
|
|
|
95
|
-
for (const trip of
|
|
98
|
+
for (const trip of allJsonTrips) {
|
|
96
99
|
|
|
97
100
|
const itinerary = new Itinerary();
|
|
98
101
|
|
|
@@ -115,7 +118,7 @@ export function createRouterResponseFromJson(json) {
|
|
|
115
118
|
leg.endTime = jsonDateToTimestamp(jsonLeg.Arrival.Time);
|
|
116
119
|
leg.coords = [];
|
|
117
120
|
|
|
118
|
-
if (leg.mode === 'WALK') {
|
|
121
|
+
if (leg.mode === 'WALK' || leg.mode === 'BICYCLE') {
|
|
119
122
|
|
|
120
123
|
leg.from = {
|
|
121
124
|
name: jsonLeg.Departure.Site.Name,
|
|
@@ -156,7 +159,7 @@ export function createRouterResponseFromJson(json) {
|
|
|
156
159
|
leg.steps.push(step);
|
|
157
160
|
}
|
|
158
161
|
|
|
159
|
-
} else if (leg.mode === 'BUS' || leg.mode === 'TRAM') {
|
|
162
|
+
} else if (leg.mode === 'BUS' || leg.mode === 'TRAM' || leg.mode === 'FUNICULAR') {
|
|
160
163
|
|
|
161
164
|
leg.from = {
|
|
162
165
|
name: jsonLeg.Departure.StopPlace.Name,
|
|
@@ -19,7 +19,7 @@ describe('CitywayUtils - createRouterResponseFromJson', () => {
|
|
|
19
19
|
|
|
20
20
|
it('RouterResponse - 1', () => {
|
|
21
21
|
|
|
22
|
-
const filePath = path.resolve(__dirname, '../../../assets/itinerary-lehavre-cityway.json');
|
|
22
|
+
const filePath = path.resolve(__dirname, '../../../assets/itinerary-lehavre-cityway-1.json');
|
|
23
23
|
const fileString = fs.readFileSync(filePath, 'utf8');
|
|
24
24
|
const json = JSON.parse(fileString);
|
|
25
25
|
|
|
@@ -60,6 +60,38 @@ describe('CitywayUtils - createRouterResponseFromJson', () => {
|
|
|
60
60
|
expect(itinerary1leg2.transportInfo.directionName).equal('Graville');
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
+
it('RouterResponse - 2', () => {
|
|
64
|
+
const filePath = path.resolve(__dirname, '../../../assets/itinerary-lehavre-cityway-2.json');
|
|
65
|
+
const fileString = fs.readFileSync(filePath, 'utf8');
|
|
66
|
+
const json = JSON.parse(fileString);
|
|
67
|
+
|
|
68
|
+
const routerResponse = createRouterResponseFromJson(json);
|
|
69
|
+
verifyRouterResponseData(routerResponse);
|
|
70
|
+
|
|
71
|
+
expect(routerResponse.itineraries.length).equal(1);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('RouterResponse - 3', () => {
|
|
75
|
+
const filePath = path.resolve(__dirname, '../../../assets/itinerary-lehavre-cityway-3.json');
|
|
76
|
+
const fileString = fs.readFileSync(filePath, 'utf8');
|
|
77
|
+
const json = JSON.parse(fileString);
|
|
78
|
+
|
|
79
|
+
const routerResponse = createRouterResponseFromJson(json);
|
|
80
|
+
verifyRouterResponseData(routerResponse);
|
|
81
|
+
|
|
82
|
+
expect(routerResponse.itineraries[0].legs[1].mode).equal('FUNICULAR');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('RouterResponse - 4', () => {
|
|
86
|
+
const filePath = path.resolve(__dirname, '../../../assets/itinerary-lehavre-cityway-4.json');
|
|
87
|
+
const fileString = fs.readFileSync(filePath, 'utf8');
|
|
88
|
+
const json = JSON.parse(fileString);
|
|
89
|
+
|
|
90
|
+
const routerResponse = createRouterResponseFromJson(json);
|
|
91
|
+
verifyRouterResponseData(routerResponse);
|
|
92
|
+
|
|
93
|
+
expect(routerResponse.itineraries[0].legs[0].mode).equal('BICYCLE');
|
|
94
|
+
});
|
|
63
95
|
|
|
64
96
|
});
|
|
65
97
|
|
|
File without changes
|