parseJourneyLeg parseAlternative: handle missing stopL[] 🐛, add tests

This commit is contained in:
Jannis R 2020-12-07 14:16:57 +01:00 committed by Jannis Redmann
parent 7444e08819
commit 17e08acfbb
8 changed files with 10594 additions and 2 deletions

View file

@ -138,12 +138,15 @@ const parseJourneyLeg = (ctx, pt, date) => { // pt = raw leg
const parseAlternative = (a) => {
// todo: parse this just like a `leg` (breaking)
// todo: parse `a.stopL`, `a.ctxRecon`, `a.msgL`
const st0 = a.stopL[0] || {}
const st0 = Array.isArray(a.stopL) && a.stopL[0] || {}
const when = st0
? profile.parseWhen(ctx, date, st0.dTimeS, st0.dTimeR, st0.dTZOffset, st0.dCncl)
: null
return {
tripId: a.jid,
line: a.line || null,
direction: a.dirTxt || null,
...profile.parseWhen(ctx, date, st0.dTimeS, st0.dTimeR, st0.dTZOffset, st0.dCncl)
...when,
}
}
res.alternatives = freq.jnyL.map(parseAlternative)

646
test/fixtures/sbb-journeys.js vendored Normal file
View file

@ -0,0 +1,646 @@
'use strict'
const baselSBB = {
type: 'stop',
id: '8500010',
name: 'Basel SBB',
location: {
type: 'location',
id: '8500010',
latitude: 47.547408,
longitude: 7.589548
},
products: {
'express-train': true,
'international-train': true,
'interregional-train': true,
'regional-express-train': true,
watercraft: false,
'suburban-train': true,
'bus-taxi': true,
gondola: false,
'car-train': true,
tram: true,
},
}
const biel = {
type: 'stop',
id: '8504300',
name: 'Biel/Bienne',
location: {
type: 'location',
id: '8504300',
latitude: 47.132889,
longitude: 7.242906
},
products: {
'express-train': false,
'international-train': true,
'interregional-train': true,
'regional-express-train': true,
watercraft: true,
'suburban-train': true,
'bus-taxi': true,
gondola: false,
'car-train': true,
tram: false,
},
}
const bern = {
type: 'stop',
id: '8507000',
name: 'Bern',
location: {
type: 'location',
id: '8507000',
latitude: 46.948825,
longitude: 7.439122
},
products: {
'express-train': true,
'international-train': true,
'interregional-train': true,
'regional-express-train': true,
watercraft: false,
'suburban-train': true,
'bus-taxi': true,
gondola: true,
'car-train': true,
tram: true,
},
}
const lausanne = {
type: 'stop',
id: '8501120',
name: 'Lausanne',
location: {
type: 'location',
id: '8501120',
latitude: 46.516777,
longitude: 6.629095
},
products: {
'express-train': true,
'international-train': true,
'interregional-train': true,
'regional-express-train': true,
watercraft: false,
'suburban-train': true,
'bus-taxi': true,
gondola: false,
'car-train': true,
tram: true,
},
}
const yverdonLesBains = {
type: 'stop',
id: '8504200',
name: 'Yverdon-les-Bains',
location: {
type: 'location',
id: '8504200',
latitude: 46.781878,
longitude: 6.641141
},
products: {
'express-train': false,
'international-train': true,
'interregional-train': true,
'regional-express-train': true,
watercraft: true,
'suburban-train': true,
'bus-taxi': true,
gondola: false,
'car-train': false,
tram: false,
},
}
module.exports = [{
type: 'journey',
legs: [{
origin: baselSBB,
destination: biel,
departure: '2020-12-14T10:03:00+01:00',
plannedDeparture: '2020-12-14T10:03:00+01:00',
departureDelay: null,
arrival: '2020-12-14T11:10:00+01:00',
plannedArrival: '2020-12-14T11:10:00+01:00',
arrivalDelay: null,
reachable: true,
tripId: '1|33571|3|95|14122020',
line: {
type: 'line',
id: '1-000011-51',
fahrtNr: '1616',
name: 'IC 51',
public: true,
adminCode: '000011',
mode: 'train',
product: 'international-train',
operator: {
type: 'operator',
id: 'schweizerische-bundesbahnen-sbb',
name: 'Schweizerische Bundesbahnen SBB'
},
},
direction: 'Biel/Bienne',
arrivalPlatform: '4',
plannedArrivalPlatform: '4',
departurePlatform: '14',
plannedDeparturePlatform: '14',
cycle: {min: 3600, max: 3600, nr: 3},
}, {
origin: biel,
destination: yverdonLesBains,
departure: '2020-12-14T11:16:00+01:00',
plannedDeparture: '2020-12-14T11:16:00+01:00',
departureDelay: null,
arrival: '2020-12-14T11:52:00+01:00',
plannedArrival: '2020-12-14T11:52:00+01:00',
arrivalDelay: null,
reachable: true,
tripId: '1|155150|2|95|14122020',
line: {
type: 'line',
id: '1-000011-5',
fahrtNr: '516',
name: 'IC 5',
public: true,
adminCode: '000011',
mode: 'train',
product: 'international-train',
operator: {
type: 'operator',
id: 'schweizerische-bundesbahnen-sbb',
name: 'Schweizerische Bundesbahnen SBB'
},
},
direction: 'Genève-Aéroport',
arrivalPlatform: '2',
plannedArrivalPlatform: '2',
departurePlatform: '5',
plannedDeparturePlatform: '5',
cycle: {min: 1740, max: 1860, nr: 5},
}, {
origin: yverdonLesBains,
destination: lausanne,
departure: '2020-12-14T11:57:00+01:00',
plannedDeparture: '2020-12-14T11:57:00+01:00',
departureDelay: null,
arrival: '2020-12-14T12:27:00+01:00',
plannedArrival: '2020-12-14T12:27:00+01:00',
arrivalDelay: null,
reachable: true,
tripId: '1|70708|0|95|14122020',
line: {
type: 'line',
id: '5-000011-5',
fahrtNr: '24539',
name: 'S 5',
public: true,
adminCode: '000011',
mode: 'train',
product: 'suburban-train',
operator: {
type: 'operator',
id: 'schweizerische-bundesbahnen-sbb',
name: 'Schweizerische Bundesbahnen SBB'
},
},
direction: 'Aigle',
arrivalPlatform: '1',
plannedArrivalPlatform: '1',
departurePlatform: '2',
plannedDeparturePlatform: '2',
cycle: {min: 1740, max: 1860, nr: 5},
}],
refreshToken: '¶HKI¶T$A=1@O=Basel SBB@X=7589566@Y=47547408@L=8500010@a=128@$A=1@O=Biel/Bienne@X=7242906@Y=47132898@L=8504300@a=128@$202012141003$202012141110$IC 51 $$1$$$$§T$A=1@O=Biel/Bienne@X=7242906@Y=47132898@L=8504300@a=128@$A=1@O=Yverdon-les-Bains@X=6640943@Y=46781545@L=8504200@a=128@$202012141116$202012141152$IC 5 $$1$$$$§T$A=1@O=Yverdon-les-Bains@X=6640943@Y=46781545@L=8504200@a=128@$A=1@O=Lausanne@X=6629095@Y=46516795@L=8501120@a=128@$202012141157$202012141227$S 5 $$1$$$$',
cycle: {min: 3600},
remarks: [
{type: 'hint', code: 'cap1st_11', text: '1.'},
{type: 'hint', code: 'cap2nd_11', text: '2.'}]
}, {
type: 'journey',
legs: [{
origin: baselSBB,
destination: bern,
departure: '2020-12-14T10:28:00+01:00',
plannedDeparture: '2020-12-14T10:28:00+01:00',
departureDelay: null,
arrival: '2020-12-14T11:26:00+01:00',
plannedArrival: '2020-12-14T11:26:00+01:00',
arrivalDelay: null,
reachable: true,
tripId: '1|5522|0|95|14122020',
line: {
type: 'line',
id: '1-000011-6',
fahrtNr: '1067',
name: 'IC 6',
public: true,
adminCode: '000011',
mode: 'train',
product: 'international-train',
operator: {
type: 'operator',
id: 'schweizerische-bundesbahnen-sbb',
name: 'Schweizerische Bundesbahnen SBB'
},
},
direction: 'Domodossola (I)',
arrivalPlatform: '6',
plannedArrivalPlatform: '6',
departurePlatform: '10',
plannedDeparturePlatform: '10',
cycle: {min: 1800, max: 3600, nr: 4},
alternatives: [{
tripId: '1|259027|0|95|14122020',
line: {
type: 'line',
id: '1-000011-61',
fahrtNr: '967',
name: 'IC 61',
public: true,
adminCode: '000011',
mode: 'train',
product: 'international-train',
operator: {
type: 'operator',
id: 'schweizerische-bundesbahnen-sbb',
name: 'Schweizerische Bundesbahnen SBB'
},
},
direction: 'Interlaken Ost',
when: null,
plannedWhen: null,
delay: null,
}, {
tripId: '1|5612|0|95|14122020',
line: {
type: 'line',
id: '1-000011-61',
fahrtNr: '1069',
name: 'IC 61',
public: true,
adminCode: '000011',
mode: 'train',
product: 'international-train',
operator: {
type: 'operator',
id: 'schweizerische-bundesbahnen-sbb',
name: 'Schweizerische Bundesbahnen SBB'
},
},
direction: 'Interlaken Ost',
when: null,
plannedWhen: null,
delay: null,
}, {
tripId: '1|168184|0|95|14122020',
line: {
type: 'line',
id: 'ec-57',
fahrtNr: '57',
name: 'EC 57',
public: true,
adminCode: '000011',
mode: 'train',
product: 'international-train',
operator: {
type: 'operator',
id: 'schweizerische-bundesbahnen-sbb',
name: 'Schweizerische Bundesbahnen SBB'
},
},
direction: 'Brig',
when: null,
plannedWhen: null,
delay: null,
}, {
tripId: '1|259357|0|95|14122020',
line: {
type: 'line',
id: '1-000011-61',
fahrtNr: '971',
name: 'IC 61',
public: true,
adminCode: '000011',
mode: 'train',
product: 'international-train',
operator: {
type: 'operator',
id: 'schweizerische-bundesbahnen-sbb',
name: 'Schweizerische Bundesbahnen SBB'
},
},
direction: 'Interlaken Ost',
when: null,
plannedWhen: null,
delay: null,
}]
}, {
origin: bern,
destination: lausanne,
departure: '2020-12-14T11:34:00+01:00',
plannedDeparture: '2020-12-14T11:34:00+01:00',
departureDelay: null,
arrival: '2020-12-14T12:40:00+01:00',
plannedArrival: '2020-12-14T12:40:00+01:00',
arrivalDelay: null,
reachable: true,
tripId: '1|201862|0|95|14122020',
line: {
type: 'line',
id: '1-000011-1',
fahrtNr: '714',
name: 'IC 1',
public: true,
adminCode: '000011',
mode: 'train',
product: 'international-train',
operator: {
type: 'operator',
id: 'schweizerische-bundesbahnen-sbb',
name: 'Schweizerische Bundesbahnen SBB'
},
},
direction: 'Genève-Aéroport',
arrivalPlatform: '5',
plannedArrivalPlatform: '5',
departurePlatform: '5',
plannedDeparturePlatform: '5',
cycle: {min: 3600, max: 3600, nr: 3},
}],
refreshToken: '¶HKI¶T$A=1@O=Basel SBB@X=7589566@Y=47547408@L=8500010@a=128@$A=1@O=Bern@X=7439131@Y=46948834@L=8507000@a=128@$202012141028$202012141126$IC 6 $$1$$$$§T$A=1@O=Bern@X=7439131@Y=46948834@L=8507000@a=128@$A=1@O=Lausanne@X=6629095@Y=46516795@L=8501120@a=128@$202012141134$202012141240$IC 1 $$1$$$$',
cycle: {min: 3600},
remarks: [
{type: 'hint', code: 'cap1st_11', text: '1.'},
{type: 'hint', code: 'cap2nd_11', text: '2.'}]
}, {
type: 'journey',
legs: [{
origin: baselSBB,
destination: bern,
departure: '2020-12-14T10:58:00+01:00',
plannedDeparture: '2020-12-14T10:58:00+01:00',
departureDelay: null,
arrival: '2020-12-14T11:56:00+01:00',
plannedArrival: '2020-12-14T11:56:00+01:00',
arrivalDelay: null,
reachable: true,
tripId: '1|259027|0|95|14122020',
line: {
type: 'line',
id: '1-000011-61',
fahrtNr: '967',
name: 'IC 61',
public: true,
adminCode: '000011',
mode: 'train',
product: 'international-train',
operator: {
type: 'operator',
id: 'schweizerische-bundesbahnen-sbb',
name: 'Schweizerische Bundesbahnen SBB'
},
},
direction: 'Interlaken Ost',
arrivalPlatform: '4',
plannedArrivalPlatform: '4',
departurePlatform: '7',
plannedDeparturePlatform: '7',
cycle: {min: 1800, max: 3600, nr: 4},
alternatives: [{
tripId: '1|5612|0|95|14122020',
line: {
type: 'line',
id: '1-000011-61',
fahrtNr: '1069',
name: 'IC 61',
public: true,
adminCode: '000011',
mode: 'train',
product: 'international-train',
operator: {
type: 'operator',
id: 'schweizerische-bundesbahnen-sbb',
name: 'Schweizerische Bundesbahnen SBB'
},
},
direction: 'Interlaken Ost',
when: null,
plannedWhen: null,
delay: null,
}, {
tripId: '1|168184|0|95|14122020',
line: {
type: 'line',
id: 'ec-57',
fahrtNr: '57',
name: 'EC 57',
public: true,
adminCode: '000011',
mode: 'train',
product: 'international-train',
operator: {
type: 'operator',
id: 'schweizerische-bundesbahnen-sbb',
name: 'Schweizerische Bundesbahnen SBB'
},
},
direction: 'Brig',
when: null,
plannedWhen: null,
delay: null,
}, {
tripId: '1|259357|0|95|14122020',
line: {
type: 'line',
id: '1-000011-61',
fahrtNr: '971',
name: 'IC 61',
public: true,
adminCode: '000011',
mode: 'train',
product: 'international-train',
operator: {
type: 'operator',
id: 'schweizerische-bundesbahnen-sbb',
name: 'Schweizerische Bundesbahnen SBB'
},
},
direction: 'Interlaken Ost',
when: null,
plannedWhen: null,
delay: null,
}, {
tripId: '1|5887|0|95|14122020',
line: {
type: 'line',
id: '1-000011-61',
fahrtNr: '1073',
name: 'IC 61',
public: true,
adminCode: '000011',
mode: 'train',
product: 'international-train',
operator: {
type: 'operator',
id: 'schweizerische-bundesbahnen-sbb',
name: 'Schweizerische Bundesbahnen SBB'
},
},
direction: 'Interlaken Ost',
when: null,
plannedWhen: null,
delay: null,
}]
}, {
origin: bern,
destination: lausanne,
departure: '2020-12-14T12:04:00+01:00',
plannedDeparture: '2020-12-14T12:04:00+01:00',
departureDelay: null,
arrival: '2020-12-14T13:16:00+01:00',
plannedArrival: '2020-12-14T13:16:00+01:00',
arrivalDelay: null,
reachable: true,
tripId: '1|73704|0|95|14122020',
line: {
type: 'line',
id: '2-000011-15',
fahrtNr: '2518',
name: 'IR 15',
public: true,
adminCode: '000011',
mode: 'train',
product: 'interregional-train',
operator: {
type: 'operator',
id: 'schweizerische-bundesbahnen-sbb',
name: 'Schweizerische Bundesbahnen SBB'
},
},
direction: 'Genève-Aéroport',
arrivalPlatform: '6',
plannedArrivalPlatform: '6',
departurePlatform: '3',
plannedDeparturePlatform: '3',
cycle: {min: 3600, max: 3600, nr: 3},
}],
refreshToken: '¶HKI¶T$A=1@O=Basel SBB@X=7589566@Y=47547408@L=8500010@a=128@$A=1@O=Bern@X=7439131@Y=46948834@L=8507000@a=128@$202012141058$202012141156$IC 61 $$1$$$$§T$A=1@O=Bern@X=7439131@Y=46948834@L=8507000@a=128@$A=1@O=Lausanne@X=6629095@Y=46516795@L=8501120@a=128@$202012141204$202012141316$IR 15 $$1$$$$',
cycle: {min: 3600},
remarks: [
{type: 'hint', code: 'cap1st_11', text: '1.'},
{type: 'hint', code: 'cap2nd_11', text: '2.'}]
}, {
type: 'journey',
legs: [{
origin: baselSBB,
destination: biel,
departure: '2020-12-14T11:03:00+01:00',
plannedDeparture: '2020-12-14T11:03:00+01:00',
departureDelay: null,
arrival: '2020-12-14T12:10:00+01:00',
plannedArrival: '2020-12-14T12:10:00+01:00',
arrivalDelay: null,
reachable: true,
tripId: '1|33571|4|95|14122020',
line: {
type: 'line',
id: '1-000011-51',
fahrtNr: '1618',
name: 'IC 51',
public: true,
adminCode: '000011',
mode: 'train',
product: 'international-train',
operator: {
type: 'operator',
id: 'schweizerische-bundesbahnen-sbb',
name: 'Schweizerische Bundesbahnen SBB'
},
},
direction: 'Biel/Bienne',
arrivalPlatform: '4',
plannedArrivalPlatform: '4',
departurePlatform: '14',
plannedDeparturePlatform: '14',
cycle: {min: 3600, max: 3600, nr: 3},
}, {
origin: biel,
destination: yverdonLesBains,
departure: '2020-12-14T12:16:00+01:00',
plannedDeparture: '2020-12-14T12:16:00+01:00',
departureDelay: null,
arrival: '2020-12-14T12:52:00+01:00',
plannedArrival: '2020-12-14T12:52:00+01:00',
arrivalDelay: null,
reachable: true,
tripId: '1|156563|0|95|14122020',
line: {
type: 'line',
id: '1-000011-5',
fahrtNr: '518',
name: 'IC 5',
public: true,
adminCode: '000011',
mode: 'train',
product: 'international-train',
operator: {
type: 'operator',
id: 'schweizerische-bundesbahnen-sbb',
name: 'Schweizerische Bundesbahnen SBB'
},
},
direction: 'Genève-Aéroport',
arrivalPlatform: '2',
plannedArrivalPlatform: '2',
departurePlatform: '5',
plannedDeparturePlatform: '5',
cycle: {min: 1740, max: 1860, nr: 5},
}, {
origin: yverdonLesBains,
destination: lausanne,
departure: '2020-12-14T12:57:00+01:00',
plannedDeparture: '2020-12-14T12:57:00+01:00',
departureDelay: null,
arrival: '2020-12-14T13:27:00+01:00',
plannedArrival: '2020-12-14T13:27:00+01:00',
arrivalDelay: null,
reachable: true,
tripId: '1|70657|2|95|14122020',
line: {
type: 'line',
id: '5-000011-5',
fahrtNr: '24545',
name: 'S 5',
public: true,
adminCode: '000011',
mode: 'train',
product: 'suburban-train',
operator: {
type: 'operator',
id: 'schweizerische-bundesbahnen-sbb',
name: 'Schweizerische Bundesbahnen SBB'
},
},
direction: 'Aigle',
arrivalPlatform: '1',
plannedArrivalPlatform: '1',
departurePlatform: '2',
plannedDeparturePlatform: '2',
cycle: {min: 1740, max: 1860, nr: 5},
}],
refreshToken: '¶HKI¶T$A=1@O=Basel SBB@X=7589566@Y=47547408@L=8500010@a=128@$A=1@O=Biel/Bienne@X=7242906@Y=47132898@L=8504300@a=128@$202012141103$202012141210$IC 51 $$1$$$$§T$A=1@O=Biel/Bienne@X=7242906@Y=47132898@L=8504300@a=128@$A=1@O=Yverdon-les-Bains@X=6640943@Y=46781545@L=8504200@a=128@$202012141216$202012141252$IC 5 $$1$$$$§T$A=1@O=Yverdon-les-Bains@X=6640943@Y=46781545@L=8504200@a=128@$A=1@O=Lausanne@X=6629095@Y=46516795@L=8501120@a=128@$202012141257$202012141327$S 5 $$1$$$$',
cycle: {min: 3600},
remarks: [
{type: 'hint', code: 'cap1st_11', text: '1.'},
{type: 'hint', code: 'cap2nd_11', text: '2.'},
],
}]

6632
test/fixtures/sbb-journeys.json vendored Normal file

File diff suppressed because it is too large Load diff

655
test/fixtures/vbb-journeys.js vendored Normal file
View file

@ -0,0 +1,655 @@
'use strict'
module.exports = [{
type: 'journey',
legs: [{
origin: {
type: 'stop',
id: '900000042101',
name: 'U Spichernstr.',
location: {
type: 'location',
id: '900042101',
latitude: 52.496581,
longitude: 13.330616
},
products: {
suburban: false,
subway: true,
tram: false,
bus: true,
ferry: false,
express: false,
regional: false,
},
},
destination: {
type: 'stop',
id: '900000001201',
name: 'S+U Westhafen',
location: {
type: 'location',
id: '900001201',
latitude: 52.536179,
longitude: 13.343839
},
products: {
suburban: true,
subway: true,
tram: false,
bus: true,
ferry: false,
express: false,
regional: false,
},
},
departure: '2020-12-07T14:08:00+01:00',
plannedDeparture: '2020-12-07T14:08:00+01:00',
departureDelay: 0,
arrival: '2020-12-07T14:16:00+01:00',
plannedArrival: '2020-12-07T14:16:00+01:00',
arrivalDelay: 0,
reachable: true,
tripId: '1|35066|1|86|7122020',
line: {
type: 'line',
id: 'u9',
fahrtNr: '24005',
name: 'U9',
public: true,
adminCode: 'BVU',
mode: 'train',
product: 'subway',
operator: {
type: 'operator',
id: 'berliner-verkehrsbetriebe',
name: 'Berliner Verkehrsbetriebe'
},
symbol: 'U',
nr: 9,
metro: false,
express: false,
night: false,
},
direction: 'U Osloer Str.',
arrivalPlatform: null,
plannedArrivalPlatform: null,
departurePlatform: null,
plannedDeparturePlatform: null,
cycle: {min: 240, max: 300, nr: 26},
}, {
origin: {
type: 'stop',
id: '900000001201',
name: 'S+U Westhafen',
location: {
type: 'location',
id: '900001201',
latitude: 52.536179,
longitude: 13.343839
},
products: {
suburban: true,
subway: true,
tram: false,
bus: true,
ferry: false,
express: false,
regional: false,
},
},
destination: {
type: 'stop',
id: '900000007102',
name: 'S+U Gesundbrunnen',
location: {
type: 'location',
id: '900007102',
latitude: 52.548638,
longitude: 13.388372
},
products: {
suburban: true,
subway: true,
tram: false,
bus: true,
ferry: false,
express: true,
regional: true,
},
},
departure: '2020-12-07T14:20:00+01:00',
plannedDeparture: '2020-12-07T14:20:00+01:00',
departureDelay: 0,
arrival: '2020-12-07T14:25:00+01:00',
plannedArrival: '2020-12-07T14:25:00+01:00',
arrivalDelay: 0,
reachable: true,
tripId: '1|66441|25|86|7122020',
line: {
type: 'line',
id: 's41',
fahrtNr: '2568',
name: 'S41',
public: true,
adminCode: 'DBS',
mode: 'train',
product: 'suburban',
operator: {
type: 'operator',
id: 's-bahn-berlin-gmbh',
name: 'S-Bahn Berlin GmbH'
},
symbol: 'S',
nr: 41,
metro: false,
express: false,
night: false,
},
direction: 'Ringbahn S 41',
arrivalPlatform: '3',
plannedArrivalPlatform: '3',
departurePlatform: '1',
plannedDeparturePlatform: '1',
cycle: {min: 300, max: 600, nr: 24},
}, {
origin: {
type: 'stop',
id: '900000007102',
name: 'S+U Gesundbrunnen',
location: {
type: 'location',
id: '900007102',
latitude: 52.548638,
longitude: 13.388372
},
products: {
suburban: true,
subway: true,
tram: false,
bus: true,
ferry: false,
express: true,
regional: true,
},
},
destination: {
type: 'stop',
id: '900000350127',
name: 'Eberswalde, Hbf',
location: {
type: 'location',
id: '900350127',
latitude: 52.833668,
longitude: 13.797031
},
products: {
suburban: false,
subway: false,
tram: false,
bus: true,
ferry: false,
express: true,
regional: true,
},
},
departure: '2020-12-07T14:34:00+01:00',
plannedDeparture: '2020-12-07T13:52:00+01:00',
departureDelay: 2520,
arrival: '2020-12-07T14:58:00+01:00',
plannedArrival: '2020-12-07T14:17:00+01:00',
arrivalDelay: 2460,
reachable: true,
tripId: '1|43248|0|86|7122020',
line: {
type: 'line',
id: 'ice-1710',
fahrtNr: '1710',
name: 'ICE 1710',
public: true,
adminCode: 'N80',
mode: 'train',
product: 'express',
operator: {type: 'operator', id: 'db-regio-ag', name: 'DB Regio AG'},
symbol: 'ICE',
nr: 1710,
metro: false,
express: false,
night: false,
},
direction: 'Ostseebad Binz, Bhf',
arrivalPlatform: '3',
plannedArrivalPlatform: '3',
departurePlatform: '10',
plannedDeparturePlatform: '10',
cycle: {min: 7200, max: 9000, nr: 2},
alternatives: [{
tripId: '1|42763|0|86|7122020',
line: {
type: 'line',
id: 'ic-2457',
fahrtNr: '2457',
name: 'IC 2457',
public: true,
adminCode: 'N80',
mode: 'train',
product: 'express',
operator: {
type: 'operator',
id: 'db-regio-ag',
name: 'DB Regio AG'
},
symbol: 'IC',
nr: 2457,
metro: false,
express: false,
night: false,
},
direction: 'Ostseebad Binz, Bahnhof',
when: '2020-12-07T15:52:00+01:00',
plannedWhen: '2020-12-07T15:52:00+01:00',
delay: null,
}, {
tripId: '1|42768|0|86|7122020',
line: {
type: 'line',
id: 'ic-2055',
fahrtNr: '2055',
name: 'IC 2055',
public: true,
adminCode: 'N80',
mode: 'train',
product: 'express',
operator: {
type: 'operator',
id: 'db-regio-ag',
name: 'DB Regio AG'
},
symbol: 'IC',
nr: 2055,
metro: false,
express: false,
night: false,
},
direction: 'Stralsund, Hauptbahnhof',
when: '2020-12-07T18:22:00+01:00',
plannedWhen: '2020-12-07T18:22:00+01:00',
delay: null,
}]
}],
refreshToken: '¶HKI¶T$A=1@O=U Spichernstr. (Berlin)@L=900042101@a=128@$A=1@O=S+U Westhafen (Berlin)@L=900001201@a=128@$202012071408$202012071416$ U9$$1$$$$§T$A=1@O=S+U Westhafen (Berlin)@L=900001201@a=128@$A=1@O=S+U Gesundbrunnen Bhf (Berlin)@L=900007102@a=128@$202012071420$202012071425$ S41$$1$$$$§T$A=1@O=S+U Gesundbrunnen Bhf (Berlin)@L=900007102@a=128@$A=1@O=Eberswalde, Hauptbahnhof@L=900350127@a=128@$202012071352$202012071417$ICE 1710$$3$$$$',
cycle: {min: 7200},
remarks: [{
type: 'status',
code: 'text.realtime.connection.alternative.summary',
text: 'Journey suggestion according to current traffic.'
}, {
type: 'status',
code: 'text.realtime.connection.alternative.detail',
text: 'Journey suggestion according to current traffic situation. Please note the current real-time information.'
}]
},
{
type: 'journey',
legs: [{
origin: {
type: 'stop',
id: '900000042101',
name: 'U Spichernstr.',
location: {
type: 'location',
id: '900042101',
latitude: 52.496581,
longitude: 13.330616
},
products: {
suburban: false,
subway: true,
tram: false,
bus: true,
ferry: false,
express: false,
regional: false,
},
},
destination: {
type: 'stop',
id: '900000001201',
name: 'S+U Westhafen',
location: {
type: 'location',
id: '900001201',
latitude: 52.536179,
longitude: 13.343839
},
products: {
suburban: true,
subway: true,
tram: false,
bus: true,
ferry: false,
express: false,
regional: false,
},
},
departure: '2020-12-07T14:12:00+01:00',
plannedDeparture: '2020-12-07T14:12:00+01:00',
departureDelay: 0,
arrival: '2020-12-07T14:21:00+01:00',
plannedArrival: '2020-12-07T14:21:00+01:00',
arrivalDelay: 0,
reachable: true,
tripId: '1|35069|1|86|7122020',
line: {
type: 'line',
id: 'u9',
fahrtNr: '24006',
name: 'U9',
public: true,
adminCode: 'BVU',
mode: 'train',
product: 'subway',
operator: {
type: 'operator',
id: 'berliner-verkehrsbetriebe',
name: 'Berliner Verkehrsbetriebe'
},
symbol: 'U',
nr: 9,
metro: false,
express: false,
night: false,
},
direction: 'U Osloer Str.',
arrivalPlatform: null,
plannedArrivalPlatform: null,
departurePlatform: null,
plannedDeparturePlatform: null,
cycle: {min: 240, max: 300, nr: 26},
}, {
origin: {
type: 'stop',
id: '900000001201',
name: 'S+U Westhafen',
location: {
type: 'location',
id: '900001201',
latitude: 52.536179,
longitude: 13.343839
},
products: {
suburban: true,
subway: true,
tram: false,
bus: true,
ferry: false,
express: false,
regional: false,
},
},
destination: {
type: 'stop',
id: '900000007102',
name: 'S+U Gesundbrunnen',
location: {
type: 'location',
id: '900007102',
latitude: 52.548638,
longitude: 13.388372
},
products: {
suburban: true,
subway: true,
tram: false,
bus: true,
ferry: false,
express: true,
regional: true,
},
},
departure: null,
plannedDeparture: '2020-12-07T14:25:00+01:00',
departureDelay: null,
arrival: null,
plannedArrival: '2020-12-07T14:30:00+01:00',
arrivalDelay: null,
reachable: false,
tripId: '1|66451|1|86|7122020',
line: {
type: 'line',
id: 's41',
fahrtNr: '2723',
name: 'S41',
public: true,
adminCode: 'DBS',
mode: 'train',
product: 'suburban',
operator: {
type: 'operator',
id: 's-bahn-berlin-gmbh',
name: 'S-Bahn Berlin GmbH'
},
symbol: 'S',
nr: 41,
metro: false,
express: false,
night: false,
},
direction: 'Ringbahn S 41',
arrivalPlatform: null,
plannedArrivalPlatform: null,
departurePlatform: null,
plannedDeparturePlatform: null,
cycle: {min: 300, max: 300, nr: 24},
cancelled: true,
}, {
origin: {
type: 'stop',
id: '900000007102',
name: 'S+U Gesundbrunnen',
location: {
type: 'location',
id: '900007102',
latitude: 52.548638,
longitude: 13.388372
},
products: {
suburban: true,
subway: true,
tram: false,
bus: true,
ferry: false,
express: true,
regional: true,
},
},
destination: {
type: 'stop',
id: '900000350127',
name: 'Eberswalde, Hbf',
location: {
type: 'location',
id: '900350127',
latitude: 52.833668,
longitude: 13.797031
},
products: {
suburban: false,
subway: false,
tram: false,
bus: true,
ferry: false,
express: true,
regional: true,
},
},
departure: '2020-12-07T14:39:00+01:00',
plannedDeparture: '2020-12-07T14:39:00+01:00',
departureDelay: null,
arrival: '2020-12-07T15:07:00+01:00',
plannedArrival: '2020-12-07T15:07:00+01:00',
arrivalDelay: null,
reachable: true,
tripId: '1|1961|0|86|7122020',
line: {
type: 'line',
id: 're3',
fahrtNr: '22',
name: 'RE3',
public: true,
adminCode: '800158',
mode: 'train',
product: 'regional',
operator: {type: 'operator', id: 'db-regio-ag', name: 'DB Regio AG'},
symbol: 'RE',
nr: 3,
metro: false,
express: true,
night: false,
},
direction: 'Stralsund, Hbf',
arrivalPlatform: '3',
plannedArrivalPlatform: '3',
departurePlatform: '9',
plannedDeparturePlatform: '9',
cycle: {min: 840, max: 2760, nr: 5},
alternatives: [{
tripId: '1|130|0|86|7122020',
line: {
type: 'line',
id: 're66',
fahrtNr: '46',
name: 'RE66',
public: true,
adminCode: '800151',
mode: 'train',
product: 'regional',
operator: {
type: 'operator',
id: 'db-regio-ag',
name: 'DB Regio AG'
},
symbol: 'RE',
nr: 66,
metro: false,
express: true,
night: false,
},
direction: 'Tantow, Bahnhof',
when: '2020-12-07T14:53:00+01:00',
plannedWhen: '2020-12-07T14:53:00+01:00',
delay: null,
}, {
tripId: '1|1976|0|86|7122020',
line: {
type: 'line',
id: 're3',
fahrtNr: '372',
name: 'RE3',
public: true,
adminCode: '800158',
mode: 'train',
product: 'regional',
operator: {
type: 'operator',
id: 'db-regio-ag',
name: 'DB Regio AG'
},
symbol: 'RE',
nr: 3,
metro: false,
express: true,
night: false,
},
direction: 'Schwedt, Bahnhof',
when: '2020-12-07T15:39:00+01:00',
plannedWhen: '2020-12-07T15:39:00+01:00',
delay: null,
}, {
tripId: '1|1971|0|86|7122020',
line: {
type: 'line',
id: 're3',
fahrtNr: '377',
name: 'RE3',
public: true,
adminCode: '800158',
mode: 'train',
product: 'regional',
operator: {
type: 'operator',
id: 'db-regio-ag',
name: 'DB Regio AG'
},
symbol: 'RE',
nr: 3,
metro: false,
express: true,
night: false,
},
direction: 'Eberswalde, Hauptbahnhof',
when: '2020-12-07T15:59:00+01:00',
plannedWhen: '2020-12-07T15:59:00+01:00',
delay: null,
}, {
tripId: '1|1959|1|86|7122020',
line: {
type: 'line',
id: 're3',
fahrtNr: '386',
name: 'RE3',
public: true,
adminCode: '800158',
mode: 'train',
product: 'regional',
operator: {
type: 'operator',
id: 'db-regio-ag',
name: 'DB Regio AG'
},
symbol: 'RE',
nr: 3,
metro: false,
express: true,
night: false,
},
direction: 'Stralsund, Hauptbahnhof',
when: '2020-12-07T16:39:00+01:00',
plannedWhen: '2020-12-07T16:39:00+01:00',
delay: null,
}, {
tripId: '1|129|0|86|7122020',
line: {
type: 'line',
id: 're66',
fahrtNr: '47',
name: 'RE66',
public: true,
adminCode: '800151',
mode: 'train',
product: 'regional',
operator: {
type: 'operator',
id: 'db-regio-ag',
name: 'DB Regio AG'
},
symbol: 'RE',
nr: 66,
metro: false,
express: true,
night: false,
},
direction: 'Szczecin, Glowny',
when: '2020-12-07T17:19:00+01:00',
plannedWhen: '2020-12-07T17:19:00+01:00',
delay: null,
}]
}],
refreshToken: '¶HKI¶T$A=1@O=U Spichernstr. (Berlin)@L=900042101@a=128@$A=1@O=S+U Westhafen (Berlin)@L=900001201@a=128@$202012071412$202012071421$ U9$$1$$$$§T$A=1@O=S+U Westhafen (Berlin)@L=900001201@a=128@$A=1@O=S+U Gesundbrunnen Bhf (Berlin)@L=900007102@a=128@$202012071425$202012071430$ S41$$1$$$$§T$A=1@O=S+U Gesundbrunnen Bhf (Berlin)@L=900007102@a=128@$A=1@O=Eberswalde, Hauptbahnhof@L=900350127@a=128@$202012071439$202012071507$ RE3$$1$$$$',
cycle: {min: 840},
remarks: [{
type: 'status',
code: 'text.realtime.connection.cancelled',
text: 'A section of this itinerary is cancelled or unusable.'
}],
}]

2574
test/fixtures/vbb-journeys.json vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -4,6 +4,7 @@ require('./parse')
require('./format')
require('./db-stop')
require('./sbb-journeys')
require('./insa-stop')
require('./bvg-journey')
require('./db-journey')
@ -11,6 +12,7 @@ require('./db-journey-2')
require('./db-journey-polyline')
require('./db-arrivals')
require('./vbb-departures')
require('./vbb-journeys')
require('./bvg-radar')
require('./oebb-trip')
require('./rejseplanen-trip')

40
test/sbb-journeys.js Normal file
View file

@ -0,0 +1,40 @@
'use strict'
const test = require('tape')
const createClient = require('..')
const rawProfile = require('../p/sbb')
const res = require('./fixtures/sbb-journeys.json')
const expected = require('./fixtures/sbb-journeys.js')
const client = createClient(rawProfile, 'public-transport/hafas-client:test')
const {profile} = client
const opt = {
results: null,
via: null,
stopovers: false,
transfers: -1,
transferTime: 0,
accessibility: 'none',
bike: false,
walkingSpeed: 'normal',
startWithWalking: true,
tickets: false,
polylines: false,
subStops: true,
entrances: true,
remarks: true,
scheduledDays: false,
departure: '2020-12-07T13:29+01:00',
products: {},
}
test('parses a journeys() response correctly (SBB)', (t) => {
const common = profile.parseCommon({profile, opt, res})
const ctx = {profile, opt, common, res}
const journeys = res.outConL.map(j => profile.parseJourney(ctx, j))
t.deepEqual(journeys, expected)
t.end()
})

40
test/vbb-journeys.js Normal file
View file

@ -0,0 +1,40 @@
'use strict'
const test = require('tape')
const createClient = require('..')
const rawProfile = require('../p/vbb')
const res = require('./fixtures/vbb-journeys.json')
const expected = require('./fixtures/vbb-journeys.js')
const client = createClient(rawProfile, 'public-transport/hafas-client:test')
const {profile} = client
const opt = {
results: null,
via: null,
stopovers: false,
transfers: -1,
transferTime: 0,
accessibility: 'none',
bike: false,
walkingSpeed: 'normal',
startWithWalking: true,
tickets: false,
polylines: false,
subStops: true,
entrances: true,
remarks: true,
scheduledDays: false,
departure: '2020-12-07T13:29+01:00',
products: {},
}
test('parses a journeys() response correctly (VBB)', (t) => {
const common = profile.parseCommon({profile, opt, res})
const ctx = {profile, opt, common, res}
const journeys = res.outConL.map(j => profile.parseJourney(ctx, j))
t.deepEqual(journeys, expected)
t.end()
})