add departure.destination & arrival.origin 📝

closes #260
fixes #259

Co-Authored-By: Jannis R <mail@jannisr.de>
This commit is contained in:
Benoit Deldicque 2022-02-21 00:52:37 +01:00 committed by Jannis R
parent 4b8f7c8198
commit 57084262a2
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
7 changed files with 369 additions and 1 deletions

View file

@ -78,6 +78,27 @@ The response may look like this:
tripId: '1|31431|28|86|17122017', tripId: '1|31431|28|86|17122017',
trip: 31431, trip: 31431,
direction: 'S Spandau', direction: 'S Spandau',
// Depending on the HAFAS endpoint, the destination may be present:
destination: {
type: 'stop',
id: '900000029101',
name: 'S Spandau',
location: {
type: 'location',
id: '900029101',
latitude: 52.534794,
longitude: 13.197477
},
products: {
suburban: true,
subway: true,
tram: false,
bus: true,
ferry: false,
express: true,
regional: true,
},
},
line: { line: {
type: 'line', type: 'line',
id: '18299', id: '18299',

View file

@ -31,7 +31,17 @@ const createParseArrOrDep = (prefix) => {
direction: prefix === DEPARTURE && d.dirTxt && profile.parseStationName(ctx, d.dirTxt) || null, direction: prefix === DEPARTURE && d.dirTxt && profile.parseStationName(ctx, d.dirTxt) || null,
provenance: prefix === ARRIVAL && d.dirTxt && profile.parseStationName(ctx, d.dirTxt) || null, provenance: prefix === ARRIVAL && d.dirTxt && profile.parseStationName(ctx, d.dirTxt) || null,
line: d.line || null, line: d.line || null,
remarks: [] remarks: [],
origin: null,
destination: null
}
if (prefix === DEPARTURE && Array.isArray(d.prodL) && d.prodL[0].tLocX) {
res.destination = profile.parseLocation(ctx, ctx.res.common.locL[d.prodL[0].tLocX])
}
if (prefix === ARRIVAL && Array.isArray(d.prodL) && d.prodL[0].fLocX) {
res.origin = profile.parseLocation(ctx, ctx.res.common.locL[d.prodL[0].fLocX])
} }
if (d.pos) { if (d.pos) {

View file

@ -388,11 +388,22 @@ const createValidateArrivalOrDeparture = (type, cfg) => {
} }
val.line(val, dep.line, name + '.line') val.line(val, dep.line, name + '.line')
if (type === 'departure') { if (type === 'departure') {
const n = name + '.direction' const n = name + '.direction'
a.strictEqual(typeof dep.direction, 'string', n + ' must be a string') a.strictEqual(typeof dep.direction, 'string', n + ' must be a string')
a.ok(dep.direction, n + ' must not be empty') a.ok(dep.direction, n + ' must not be empty')
} }
if (dep.destination !== null) {
const lName = name + '.destination'
val.location(val, dep.destination, lName)
}
if (dep.origin !== null) {
const lName = name + '.origin'
val.location(val, dep.origin, lName)
}
} }
return validateArrivalOrDeparture return validateArrivalOrDeparture
} }

View file

@ -371,6 +371,8 @@ module.exports = [
plannedPlatform: null, plannedPlatform: null,
direction: null, direction: null,
provenance: 'Clara-Jaschke-Str.', provenance: 'Clara-Jaschke-Str.',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: 'm5', id: 'm5',
@ -410,6 +412,8 @@ module.exports = [
plannedPlatform: null, plannedPlatform: null,
direction: null, direction: null,
provenance: 'Ahrensfelde/Stadtgrenze', provenance: 'Ahrensfelde/Stadtgrenze',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: 'm8', id: 'm8',
@ -449,6 +453,8 @@ module.exports = [
plannedPlatform: null, plannedPlatform: null,
direction: null, direction: null,
provenance: 'Clara-Jaschke-Str.', provenance: 'Clara-Jaschke-Str.',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: 'm8', id: 'm8',
@ -488,6 +494,8 @@ module.exports = [
plannedPlatform: null, plannedPlatform: null,
direction: null, direction: null,
provenance: 'Riesaer Str.', provenance: 'Riesaer Str.',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: '56', id: '56',
@ -527,6 +535,8 @@ module.exports = [
plannedPlatform: '2', plannedPlatform: '2',
direction: null, direction: null,
provenance: 'S Grünau', provenance: 'S Grünau',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: 's8', id: 's8',
@ -567,6 +577,8 @@ module.exports = [
plannedPlatform: '1', plannedPlatform: '1',
direction: null, direction: null,
provenance: 'S Südkreuz', provenance: 'S Südkreuz',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: 's41', id: 's41',
@ -608,6 +620,8 @@ module.exports = [
plannedPlatform: '2', plannedPlatform: '2',
direction: null, direction: null,
provenance: 'S Südkreuz', provenance: 'S Südkreuz',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: 's42', id: 's42',
@ -649,6 +663,8 @@ module.exports = [
plannedPlatform: null, plannedPlatform: null,
direction: null, direction: null,
provenance: 'S Hackescher Markt', provenance: 'S Hackescher Markt',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: '56', id: '56',
@ -688,6 +704,8 @@ module.exports = [
plannedPlatform: '2', plannedPlatform: '2',
direction: null, direction: null,
provenance: 'S Südkreuz', provenance: 'S Südkreuz',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: 's42', id: 's42',
@ -729,6 +747,8 @@ module.exports = [
plannedPlatform: null, plannedPlatform: null,
direction: null, direction: null,
provenance: 'Scharnweberstr./Weichselstr.', provenance: 'Scharnweberstr./Weichselstr.',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: 'm5', id: 'm5',
@ -768,6 +788,8 @@ module.exports = [
plannedPlatform: '1', plannedPlatform: '1',
direction: null, direction: null,
provenance: 'S Südkreuz', provenance: 'S Südkreuz',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: 's41', id: 's41',
@ -807,6 +829,8 @@ module.exports = [
plannedPlatform: '2', plannedPlatform: '2',
direction: null, direction: null,
provenance: 'S Südkreuz', provenance: 'S Südkreuz',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: 's42', id: 's42',
@ -846,6 +870,8 @@ module.exports = [
plannedPlatform: null, plannedPlatform: null,
direction: null, direction: null,
provenance: 'Clara-Jaschke-Str.', provenance: 'Clara-Jaschke-Str.',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: 'm5', id: 'm5',
@ -887,6 +913,8 @@ module.exports = [
prognosedPlatform: null, prognosedPlatform: null,
direction: null, direction: null,
provenance: 'S Birkenwerder', provenance: 'S Birkenwerder',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: 's8', id: 's8',
@ -937,6 +965,8 @@ module.exports = [
plannedPlatform: null, plannedPlatform: null,
direction: null, direction: null,
provenance: 'Ahrensfelde/Stadtgrenze', provenance: 'Ahrensfelde/Stadtgrenze',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: 'm8', id: 'm8',
@ -976,6 +1006,8 @@ module.exports = [
plannedPlatform: null, plannedPlatform: null,
direction: null, direction: null,
provenance: 'Clara-Jaschke-Str.', provenance: 'Clara-Jaschke-Str.',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: 'm8', id: 'm8',
@ -1015,6 +1047,8 @@ module.exports = [
plannedPlatform: null, plannedPlatform: null,
direction: null, direction: null,
provenance: 'Riesaer Str.', provenance: 'Riesaer Str.',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: '56', id: '56',
@ -1056,6 +1090,8 @@ module.exports = [
prognosedPlatform: null, prognosedPlatform: null,
direction: null, direction: null,
provenance: 'S Grünau', provenance: 'S Grünau',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: 's85', id: 's85',
@ -1128,6 +1164,8 @@ module.exports = [
plannedPlatform: '1', plannedPlatform: '1',
direction: null, direction: null,
provenance: 'S Südkreuz', provenance: 'S Südkreuz',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: 's41', id: 's41',
@ -1169,6 +1207,8 @@ module.exports = [
plannedPlatform: '2', plannedPlatform: '2',
direction: null, direction: null,
provenance: 'S Südkreuz', provenance: 'S Südkreuz',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: 's42', id: 's42',
@ -1210,6 +1250,8 @@ module.exports = [
plannedPlatform: '2', plannedPlatform: '2',
direction: null, direction: null,
provenance: 'S Südkreuz', provenance: 'S Südkreuz',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: 's42', id: 's42',
@ -1251,6 +1293,8 @@ module.exports = [
plannedPlatform: '2', plannedPlatform: '2',
direction: null, direction: null,
provenance: 'S Südkreuz', provenance: 'S Südkreuz',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: 's42', id: 's42',
@ -1292,6 +1336,8 @@ module.exports = [
plannedPlatform: '2', plannedPlatform: '2',
direction: null, direction: null,
provenance: 'S Südkreuz', provenance: 'S Südkreuz',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: 's42', id: 's42',
@ -1333,6 +1379,8 @@ module.exports = [
plannedPlatform: '2', plannedPlatform: '2',
direction: null, direction: null,
provenance: 'S Südkreuz', provenance: 'S Südkreuz',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: 's42', id: 's42',

View file

@ -249,6 +249,8 @@ module.exports = [
plannedPlatform: null, plannedPlatform: null,
direction: null, direction: null,
provenance: 'Rathaus Spandau (S+U), Berlin', provenance: 'Rathaus Spandau (S+U), Berlin',
origin: null,
destination: null,
line: { line: {
type: 'line', type: 'line',
id: '7-vbbbvu-7', id: '7-vbbbvu-7',

View file

@ -196,6 +196,27 @@ module.exports = [
platform: '3', platform: '3',
plannedPlatform: '3', plannedPlatform: '3',
direction: 'S Erkner', direction: 'S Erkner',
origin: null,
destination: {
type: "stop",
id: "900000310004",
name: "S Erkner",
location: {
type: "location",
id: "900310004",
latitude: 52.428398,
longitude: 13.752246,
},
products: {
suburban: true,
subway: false,
tram: false,
bus: true,
ferry: false,
express: false,
regional: true,
},
},
provenance: null, provenance: null,
line: { line: {
type: 'line', type: 'line',
@ -496,6 +517,27 @@ module.exports = [
modified: '2021-06-12T07:43:36+02:00' modified: '2021-06-12T07:43:36+02:00'
} }
], ],
origin: null,
destination: {
type: "stop",
id: "900000005207",
name: "Philharmonie Süd",
location: {
type: "location",
id: "900005207",
latitude: 52.508761,
longitude: 13.370025,
},
products: {
suburban: false,
subway: false,
tram: false,
bus: true,
ferry: false,
express: false,
regional: false,
},
},
currentTripPosition: { currentTripPosition: {
type: 'location', type: 'location',
latitude: 52.514227, latitude: 52.514227,
@ -747,6 +789,27 @@ module.exports = [
modified: '2021-06-12T07:43:36+02:00' modified: '2021-06-12T07:43:36+02:00'
} }
], ],
origin: null,
destination: {
type: "stop",
id: "900000079221",
name: "S+U Hermannstr.",
location: {
type: "location",
id: "900079221",
latitude: 52.467339,
longitude: 13.43143,
},
products: {
suburban: true,
subway: true,
tram: false,
bus: true,
ferry: false,
express: false,
regional: false,
},
},
currentTripPosition: { currentTripPosition: {
type: 'location', type: 'location',
latitude: 52.518982, latitude: 52.518982,
@ -998,6 +1061,27 @@ module.exports = [
modified: '2021-06-12T07:43:36+02:00' modified: '2021-06-12T07:43:36+02:00'
} }
], ],
origin: null,
destination: {
type: 'stop',
id: '900000096197',
name: 'S+U Wittenau [U8]',
location: {
type: 'location',
id: '900096197',
latitude: 52.59566,
longitude: 13.334634,
},
products: {
suburban: true,
subway: true,
tram: false,
bus: true,
ferry: false,
express: false,
regional: false,
},
},
currentTripPosition: { currentTripPosition: {
type: 'location', type: 'location',
latitude: 52.51011, latitude: 52.51011,
@ -1249,6 +1333,27 @@ module.exports = [
modified: '2021-06-12T07:43:36+02:00' modified: '2021-06-12T07:43:36+02:00'
} }
], ],
origin: null,
destination: {
type: 'stop',
id: '900000024102',
name: 'S Westkreuz',
location: {
type: 'location',
id: '900024102',
latitude: 52.501148,
longitude: 13.283036,
},
products: {
suburban: true,
subway: false,
tram: false,
bus: true,
ferry: false,
express: false,
regional: false,
},
},
currentTripPosition: { currentTripPosition: {
type: 'location', type: 'location',
latitude: 52.512052, latitude: 52.512052,
@ -1500,6 +1605,27 @@ module.exports = [
modified: '2021-06-12T07:43:36+02:00' modified: '2021-06-12T07:43:36+02:00'
} }
], ],
origin: null,
destination: {
type: 'stop',
id: '900000170004',
name: 'S Ahrensfelde',
location: {
type: 'location',
id: '900170004',
latitude: 52.571335,
longitude: 13.565648,
},
products: {
suburban: true,
subway: false,
tram: false,
bus: true,
ferry: false,
express: false,
regional: true,
},
},
currentTripPosition: { currentTripPosition: {
type: 'location', type: 'location',
latitude: 52.52167, latitude: 52.52167,
@ -1751,6 +1877,27 @@ module.exports = [
modified: '2021-06-12T07:43:36+02:00' modified: '2021-06-12T07:43:36+02:00'
} }
], ],
origin: null,
destination: {
type: 'stop',
id: '900000230999',
name: 'S Potsdam Hauptbahnhof',
location: {
type: 'location',
id: '900230999',
latitude: 52.391659,
longitude: 13.066172,
},
products: {
suburban: true,
subway: false,
tram: true,
bus: true,
ferry: false,
express: true,
regional: true,
},
},
currentTripPosition: { currentTripPosition: {
type: 'location', type: 'location',
latitude: 52.507287, latitude: 52.507287,
@ -2002,6 +2149,27 @@ module.exports = [
modified: '2021-06-12T07:43:36+02:00' modified: '2021-06-12T07:43:36+02:00'
} }
], ],
origin: null,
destination: {
type: 'stop',
id: '900000320004',
name: 'S Strausberg',
location: {
type: 'location',
id: '900320004',
latitude: 52.532367,
longitude: 13.834794,
},
products: {
suburban: true,
subway: false,
tram: true,
bus: true,
ferry: false,
express: false,
regional: true,
},
},
currentTripPosition: { currentTripPosition: {
type: 'location', type: 'location',
latitude: 52.520528, latitude: 52.520528,
@ -2253,6 +2421,27 @@ module.exports = [
modified: '2021-06-12T07:43:36+02:00' modified: '2021-06-12T07:43:36+02:00'
} }
], ],
origin: null,
destination: {
type: 'stop',
id: '900000079221',
name: 'S+U Hermannstr.',
location: {
type: 'location',
id: '900079221',
latitude: 52.467339,
longitude: 13.43143,
},
products: {
suburban: true,
subway: true,
tram: false,
bus: true,
ferry: false,
express: false,
regional: false,
},
},
currentTripPosition: { currentTripPosition: {
type: 'location', type: 'location',
latitude: 52.534345, latitude: 52.534345,
@ -2504,6 +2693,27 @@ module.exports = [
modified: '2021-06-12T07:43:36+02:00' modified: '2021-06-12T07:43:36+02:00'
} }
], ],
origin: null,
destination: {
type: 'stop',
id: '900000085104',
name: 'U Paracelsus-Bad',
location: {
type: 'location',
id: '900085104',
latitude: 52.574428,
longitude: 13.3473,
},
products: {
suburban: true,
subway: true,
tram: false,
bus: true,
ferry: false,
express: false,
regional: false,
},
},
currentTripPosition: { currentTripPosition: {
type: 'location', type: 'location',
latitude: 52.493516, latitude: 52.493516,
@ -2754,6 +2964,27 @@ module.exports = [
modified: '2021-06-12T07:43:36+02:00' modified: '2021-06-12T07:43:36+02:00'
} }
], ],
origin: null,
destination: {
type: 'stop',
id: '900000120004',
name: 'S+U Warschauer Str.',
location: {
type: 'location',
id: '900120004',
latitude: 52.505768,
longitude: 13.449157,
},
products: {
suburban: true,
subway: true,
tram: true,
bus: true,
ferry: false,
express: false,
regional: false,
},
},
currentTripPosition: { currentTripPosition: {
type: 'location', type: 'location',
latitude: 52.516519, latitude: 52.516519,
@ -3005,6 +3236,27 @@ module.exports = [
modified: '2021-06-12T07:43:36+02:00' modified: '2021-06-12T07:43:36+02:00'
} }
], ],
origin: null,
destination: {
type: 'stop',
id: '900000029101',
name: 'S Spandau',
location: {
type: 'location',
id: '900029101',
latitude: 52.534794,
longitude: 13.197477,
},
products: {
suburban: true,
subway: true,
tram: false,
bus: true,
ferry: false,
express: true,
regional: true,
},
},
currentTripPosition: { currentTripPosition: {
type: 'location', type: 'location',
latitude: 52.498604, latitude: 52.498604,

View file

@ -56,6 +56,30 @@ module.exports = {
plannedPlatform: '8', plannedPlatform: '8',
direction: 'Frankfurt(Main) Hbf', direction: 'Frankfurt(Main) Hbf',
provenance: null, provenance: null,
origin: null,
destination: {
type: 'stop',
id: '8000105',
name: 'Frankfurt(Main) Hbf',
location: {
type: 'location',
id: '8000105',
latitude: 50.107149,
longitude: 8.663785,
},
products: {
nationalExpress: true,
national: true,
regionalExpress: false,
regional: true,
suburban: true,
bus: true,
ferry: false,
subway: false,
tram: false,
anrufSammelTaxi: false,
},
},
line: { line: {
type: 'line', type: 'line',
id: '80-30', id: '80-30',