diff --git a/parse/journey-leg.js b/parse/journey-leg.js index 7e6c2253..22b887cc 100644 --- a/parse/journey-leg.js +++ b/parse/journey-leg.js @@ -136,13 +136,14 @@ const parseJourneyLeg = (ctx, pt, date) => { // pt = raw leg res.stopovers = stopL.map(s => profile.parseStopover(ctx, s, date)) if (opt.remarks && Array.isArray(pt.jny.msgL)) { - // todo: apply leg-wide remarks if `opt.stopovers` is false applyRemarks(res, pt.jny.msgL) // todo: parse & use `code: EXTERNAL_ID` remarks? } // filter stations the train passes without stopping, as this doesn't comply with fptf (yet) res.stopovers = res.stopovers.filter((x) => !x.passBy) + } else if (opt.remarks && Array.isArray(pt.jny.msgL)) { + applyRemarks(res, pt.jny.msgL); } const freq = pt.jny.freq || {} diff --git a/test/db-journey-polyline.js b/test/db-journey-polyline.js index 32a0f302..db83a2f7 100644 --- a/test/db-journey-polyline.js +++ b/test/db-journey-polyline.js @@ -23,7 +23,7 @@ const opt = { bike: false, tickets: true, polylines: true, - remarks: true, + remarks: false, walkingSpeed: 'normal', startWithWalking: true, scheduledDays: false, diff --git a/test/fixtures/db-journey.js b/test/fixtures/db-journey.js index ffa002b7..b14246b8 100644 --- a/test/fixtures/db-journey.js +++ b/test/fixtures/db-journey.js @@ -183,6 +183,14 @@ const dbJourney = { plannedArrivalPlatform: '9', departurePlatform: '11', plannedDeparturePlatform: '11', + remarks: [ + { + text: 'Komfort Check-in möglich (Infos unter bahn.de/kci)', + type: 'hint', + code: 'komfort-checkin', + summary: 'Komfort-Checkin available', + } + ] } ], refreshToken: '¶HKI¶D$A=1@O=Köln Hbf@L=8000207@a=128@$A=1@O=Köln Messe/Deutz Gl.11-12@L=8073368@a=128@$202004110517$202004110520$$$1$§T$A=1@O=Köln Messe/Deutz Gl.11-12@L=8073368@a=128@$A=1@O=Nürnberg Hbf@L=8000284@a=128@$202004110520$202004110901$ICE 523$$1$', diff --git a/test/fixtures/vbb-journeys.js b/test/fixtures/vbb-journeys.js index ada4a10a..3c7905a8 100644 --- a/test/fixtures/vbb-journeys.js +++ b/test/fixtures/vbb-journeys.js @@ -73,6 +73,48 @@ const vbbJourneys = [{ departurePlatform: null, plannedDeparturePlatform: null, cycle: {min: 240, max: 300, nr: 26}, + remarks: [ + { + type: 'hint', + code: 'OPERATOR', + text: 'BVG', + }, + { + type: 'hint', + code: 'bf', + text: 'barrier-free', + }, + { + type: 'hint', + code: 'FB', + text: 'Bicycle conveyance', + }, + { + id: '96404', + type: 'warning', + summary: 'Together against corona: Keep distance, cover mouth and nose!', + text: 'In vehicles, at stops and stations. Don´t risk a fine of at least 50 euros!\nFurther information (in German language)', + icon: { + type: 'HIM0', + title: null, + }, + priority: 100, + products: { + suburban: true, + subway: true, + tram: true, + bus: true, + ferry: true, + express: true, + regional: true, + }, + company: 'VBB', + category: 0, + validFrom: '2020-08-26T00:00:00+02:00', + validUntil: '2022-12-31T00:00:00+01:00', + modified: '2020-11-04T11:22:50+01:00', + }, + ], }, { origin: { type: 'stop', @@ -146,6 +188,48 @@ const vbbJourneys = [{ departurePlatform: '1', plannedDeparturePlatform: '1', cycle: {min: 300, max: 600, nr: 24}, + remarks: [ + { + type: 'hint', + code: 'OPERATOR', + text: 'DBS', + }, + { + type: 'hint', + code: 'bf', + text: 'barrier-free', + }, + { + type: 'hint', + code: 'FB', + text: 'Bicycle conveyance', + }, + { + id: '96404', + type: 'warning', + summary: 'Together against corona: Keep distance, cover mouth and nose!', + text: 'In vehicles, at stops and stations. Don´t risk a fine of at least 50 euros!\nFurther information (in German language)', + icon: { + type: 'HIM0', + title: null, + }, + priority: 100, + products: { + suburban: true, + subway: true, + tram: true, + bus: true, + ferry: true, + express: true, + regional: true, + }, + company: 'VBB', + category: 0, + validFrom: '2020-08-26T00:00:00+02:00', + validUntil: '2022-12-31T00:00:00+01:00', + modified: '2020-11-04T11:22:50+01:00', + }, + ], }, { origin: { type: 'stop', @@ -259,7 +343,69 @@ const vbbJourneys = [{ when: '2020-12-07T18:22:00+01:00', plannedWhen: '2020-12-07T18:22:00+01:00', delay: null, - }] + }], + remarks: [ + { + type: 'hint', + code: 'OPERATOR', + text: 'DB Regio', + }, + { + type: 'hint', + code: 'VG', + text: 'VBB single, collective and season tickets are recognised (S+U Gesundbrunnen Bhf (Berlin))', + }, + { + type: 'hint', + code: 'VG', + text: 'VBB single, collective and season tickets are recognised (Eberswalde, Hauptbahnhof)', + }, + { + type: 'hint', + code: 'CK', + text: 'Komfort Check-in möglich (Infos unter bahn.de/kci)', + }, + { + type: 'hint', + code: 'FR', + text: 'Bicycles conveyed - subject to reservation', + }, + { + type: 'hint', + code: 'FB', + text: 'Bicycle conveyance', + }, + { + type: 'hint', + code: 'kh', + text: 'Bordrestaurant', + }, + { + id: '96404', + type: 'warning', + summary: 'Together against corona: Keep distance, cover mouth and nose!', + text: 'In vehicles, at stops and stations. Don´t risk a fine of at least 50 euros!\nFurther information (in German language)', + icon: { + type: 'HIM0', + title: null, + }, + priority: 100, + products: { + suburban: true, + subway: true, + tram: true, + bus: true, + ferry: true, + express: true, + regional: true, + }, + company: 'VBB', + category: 0, + validFrom: '2020-08-26T00:00:00+02:00', + validUntil: '2022-12-31T00:00:00+01:00', + modified: '2020-11-04T11:22:50+01:00', + }, + ], }], 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}, @@ -348,6 +494,48 @@ const vbbJourneys = [{ departurePlatform: null, plannedDeparturePlatform: null, cycle: {min: 240, max: 300, nr: 26}, + remarks: [ + { + type: 'hint', + code: 'OPERATOR', + text: 'BVG', + }, + { + type: 'hint', + code: 'bf', + text: 'barrier-free', + }, + { + type: 'hint', + code: 'FB', + text: 'Bicycle conveyance', + }, + { + id: '96404', + type: 'warning', + summary: 'Together against corona: Keep distance, cover mouth and nose!', + text: 'In vehicles, at stops and stations. Don´t risk a fine of at least 50 euros!\nFurther information (in German language)', + icon: { + type: 'HIM0', + title: null, + }, + priority: 100, + products: { + suburban: true, + subway: true, + tram: true, + bus: true, + ferry: true, + express: true, + regional: true, + }, + company: 'VBB', + category: 0, + validFrom: '2020-08-26T00:00:00+02:00', + validUntil: '2022-12-31T00:00:00+01:00', + modified: '2020-11-04T11:22:50+01:00', + }, + ], }, { origin: { type: 'stop', @@ -422,6 +610,53 @@ const vbbJourneys = [{ plannedDeparturePlatform: null, cycle: {min: 300, max: 300, nr: 24}, cancelled: true, + remarks: [ + { + type: 'hint', + code: 'OPERATOR', + text: 'DBS', + }, + { + type: 'hint', + code: 'bf', + text: 'barrier-free', + }, + { + type: 'hint', + code: 'FB', + text: 'Bicycle conveyance', + }, + { + id: '96404', + type: 'warning', + summary: 'Together against corona: Keep distance, cover mouth and nose!', + text: 'In vehicles, at stops and stations. Don´t risk a fine of at least 50 euros!\nFurther information (in German language)', + icon: { + type: 'HIM0', + title: null, + }, + priority: 100, + products: { + suburban: true, + subway: true, + tram: true, + bus: true, + ferry: true, + express: true, + regional: true, + }, + company: 'VBB', + category: 0, + validFrom: '2020-08-26T00:00:00+02:00', + validUntil: '2022-12-31T00:00:00+01:00', + modified: '2020-11-04T11:22:50+01:00', + }, + { + type: 'status', + code: 'text.realtime.journey.cancelled', + text: 'S41: Cancelled', + }, + ], }, { origin: { type: 'stop', @@ -601,7 +836,64 @@ const vbbJourneys = [{ when: '2020-12-07T17:19:00+01:00', plannedWhen: '2020-12-07T17:19:00+01:00', delay: null, - }] + }], + remarks: [ + { + type: 'hint', + code: 'OPERATOR', + text: 'DB Regio', + }, + { + type: 'hint', + code: 'bf', + text: 'barrier-free', + }, + { + type: 'hint', + code: 'ko', + text: 'Pflicht zur Bedeckung von Mund und Nase', + }, + { + type: 'hint', + code: 'FB', + text: 'Bicycle conveyance', + }, + { + type: 'hint', + code: 'SN', + text: 'SnackPoint/Snacks on board the train', + }, + { + type: 'hint', + code: 'km', + text: 'vehicle-mounted accessaid', + }, + { + id: '96404', + type: 'warning', + summary: 'Together against corona: Keep distance, cover mouth and nose!', + text: 'In vehicles, at stops and stations. Don´t risk a fine of at least 50 euros!\nFurther information (in German language)', + icon: { + type: 'HIM0', + title: null, + }, + priority: 100, + products: { + suburban: true, + subway: true, + tram: true, + bus: true, + ferry: true, + express: true, + regional: true, + }, + company: 'VBB', + category: 0, + validFrom: '2020-08-26T00:00:00+02:00', + validUntil: '2022-12-31T00:00:00+01:00', + modified: '2020-11-04T11:22:50+01:00', + }, + ], }], 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}, diff --git a/test/fixtures/vbb-on-demand-trip.js b/test/fixtures/vbb-on-demand-trip.js index c88fbf80..32a5dfb7 100644 --- a/test/fixtures/vbb-on-demand-trip.js +++ b/test/fixtures/vbb-on-demand-trip.js @@ -33,6 +33,66 @@ const vbbOnDemandTrip = { arrivalPlatform: null, plannedArrivalPlatform: null, arrivalPrognosisType: null, + + remarks: [ + { + type: 'hint', + code: 'OPERATOR', + text: 'VTF', + }, + { + type: 'hint', + code: 'qv', + text: 'Rufbus Bestellung unter Tel.: (03371) 62 81 81', + }, + { + type: 'hint', + code: 'qw', + text: 'Bestellannahme: täglich von 5.00 - 17.00 Uhr', + }, + { + type: 'hint', + code: 'qx', + text: 'Onlinebuchung unter: https://www.vtfonline.de/rufbusapp.html', + }, + { + type: 'hint', + code: 'qu', + text: 'VBB-Tarif zuzüglich des Komfortzuschlages 1,00 EUR je Fahrgast und Strecke', + }, + { + type: 'hint', + code: 'hx', + text: 'Linientaxi max. 8 Personen', + }, + { + id: '118634', + type: 'warning', + summary: 'Gemeinsam sicher unterwegs - mit Abstand und medizinischer Maske (in Berlin: FFP2)!', + text: 'An Haltestellen und Bahnhöfen sowie in Fahrzeugen. Maskenmuffel riskieren mindestens 50 Euro.\nWeitere Informationen', + icon: { + type: 'HIM0', + title: null, + }, + priority: 100, + products: { + suburban: true, + subway: true, + tram: true, + bus: true, + ferry: true, + express: true, + regional: true, + }, + company: 'VBB', + categories: [ + 0 + ], + validFrom: '2021-04-24T00:00:00+02:00', + validUntil: '2022-12-31T00:00:00+01:00', + modified: '2021-06-12T07:43:36+02:00', + } + ] } export { diff --git a/test/rsag-journey.js b/test/rsag-journey.js index b338abca..de9ebb47 100644 --- a/test/rsag-journey.js +++ b/test/rsag-journey.js @@ -19,7 +19,7 @@ const opt = { polylines: false, subStops: true, entrances: true, - remarks: true, + remarks: false, products: {} }