From 5ecf03f34901ecc90a1b8bbd9b45e335fa859928 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Wed, 29 Dec 2021 18:12:33 +0100 Subject: [PATCH] =?UTF-8?q?VBB:=20don't=20convert=207/9=20<->=2012=20digit?= =?UTF-8?q?=20IDs=20=F0=9F=92=A5=E2=9C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- p/vbb/index.js | 26 ------------------ package.json | 4 +-- test/e2e/vbb.js | 18 ++++++------- test/fixtures/vbb-departures.js | 48 ++++++++++++++++----------------- test/fixtures/vbb-journeys.js | 24 ++++++++--------- 5 files changed, 46 insertions(+), 74 deletions(-) diff --git a/p/vbb/index.js b/p/vbb/index.js index 201b2f55..f9c77853 100644 --- a/p/vbb/index.js +++ b/p/vbb/index.js @@ -1,10 +1,8 @@ 'use strict' const shorten = require('vbb-short-station-name') -const {to12Digit, to9Digit} = require('vbb-translate-ids') const parseLineName = require('vbb-parse-line') const parseTicket = require('vbb-parse-ticket') -const getStations = require('vbb-stations') const {parseHook} = require('../../lib/profile-hooks') const parseAndAddLocationDHID = require('./parse-loc-dhid') @@ -12,7 +10,6 @@ const _parseLine = require('../../parse/line') const _parseLocation = require('../../parse/location') const _parseJourney = require('../../parse/journey') const _parseDeparture = require('../../parse/departure') -const _formatStation = require('../../format/station') const baseProfile = require('./base.json') const products = require('./products') @@ -31,15 +28,6 @@ const parseLineWithMoreDetails = ({parsed}, p) => { } const parseLocation = ({parsed}, l) => { - if ((parsed.type === 'stop' || parsed.type === 'station') && parsed.id[0] === '9') { - parsed.name = shorten(parsed.name) - parsed.id = to12Digit(parsed.id) - if (!parsed.location.latitude || !parsed.location.longitude) { - const [s] = getStations(parsed.id) - if (s) Object.assign(parsed.location, s.location) - } - } - parseAndAddLocationDHID(parsed, l) return parsed } @@ -80,18 +68,6 @@ const parseDepartureRenameRingbahn = ({parsed}) => { return parsed } -const validIBNR = /^\d+$/ -const formatStation = (id) => { - if ('string' !== typeof id) throw new TypeError('station ID must be a string.') - if (!validIBNR.test(id)) { - throw new Error('station ID must be a valid IBNR.') - } - // The VBB has some 7-digit stations. We don't convert them to 12 digits, - // because it only recognizes in the 7-digit format. see derhuerst/vbb-hafas#22 - if (id.length !== 7) id = to9Digit(id) - return _formatStation(id) -} - const vbbProfile = { ...baseProfile, locale: 'de-DE', @@ -105,8 +81,6 @@ const vbbProfile = { parseJourney: parseHook(_parseJourney, parseJourneyWithTickets), parseDeparture: parseHook(_parseDeparture, parseDepartureRenameRingbahn), - formatStation, - journeysWalkingSpeed: true, refreshJourneyUseOutReconL: true, trip: true, diff --git a/package.json b/package.json index 34f20826..9b2d99e0 100644 --- a/package.json +++ b/package.json @@ -63,9 +63,7 @@ "slugg": "^1.2.0", "vbb-parse-line": "^1.0.0", "vbb-parse-ticket": "^0.2.1", - "vbb-short-station-name": "^1.0.1", - "vbb-stations": "^7.1.0", - "vbb-translate-ids": "^4.0.0" + "vbb-short-station-name": "^1.0.1" }, "devDependencies": { "eslint": "^7.0.0", diff --git a/test/e2e/vbb.js b/test/e2e/vbb.js index 83751120..df3b7897 100644 --- a/test/e2e/vbb.js +++ b/test/e2e/vbb.js @@ -37,12 +37,12 @@ const validate = createValidate(cfg, { const client = createClient(vbbProfile, 'public-transport/hafas-client:test') -const amrumerStr = '900000009101' -const spichernstr = '900000042101' -const bismarckstr = '900000024201' -const westhafen = '900000001201' -const wedding = '900000009104' -const württembergallee = '900000026153' +const amrumerStr = '900009101' +const spichernstr = '900042101' +const bismarckstr = '900024201' +const westhafen = '900001201' +const wedding = '900009104' +const württembergallee = '900026153' tap.test('journeys – Spichernstr. to Bismarckstr.', async (t) => { const res = await client.journeys({ @@ -123,7 +123,7 @@ tap.test('journeys: walkingSpeed', async (t) => { latitude: 52.443576, longitude: 13.198973 } - const wannsee = '900000053301' + const wannsee = '900053301' await testJourneysWalkingSpeed({ test: t, @@ -343,8 +343,8 @@ tap.test('arrivals', async (t) => { }) tap.test('nearby', async (t) => { - const berlinerStr = '900000044201' - const landhausstr = '900000043252' + const berlinerStr = '900044201' + const landhausstr = '900043252' // Berliner Str./Bundesallee const nearby = await client.nearby({ diff --git a/test/fixtures/vbb-departures.js b/test/fixtures/vbb-departures.js index 9ac380c7..bd353010 100644 --- a/test/fixtures/vbb-departures.js +++ b/test/fixtures/vbb-departures.js @@ -5,7 +5,7 @@ module.exports = [ tripId: '1|24934|5|86|12102021', stop: { type: 'stop', - id: '900000100004', + id: '900100004', stationDHID: 'de:11000:900100004', name: 'S+U Jannowitzbrücke', location: { @@ -201,7 +201,7 @@ module.exports = [ origin: null, destination: { type: "stop", - id: "900000310004", + id: "900310004", stationDHID: 'de:12067:900310004', name: "S Erkner", location: { @@ -280,7 +280,7 @@ module.exports = [ tripId: '1|12106|15|86|12102021', stop: { type: 'stop', - id: '900000100004', + id: '900100004', stationDHID: 'de:11000:900100004', name: 'S+U Jannowitzbrücke', location: { @@ -525,7 +525,7 @@ module.exports = [ origin: null, destination: { type: "stop", - id: "900000005207", + id: "900005207", stationDHID: 'de:11000:900005207', name: "Philharmonie Süd", location: { @@ -554,7 +554,7 @@ module.exports = [ tripId: '1|23076|26|86|12102021', stop: { type: 'stop', - id: '900000100004', + id: '900100004', stationDHID: 'de:11000:900100004', name: 'S+U Jannowitzbrücke', location: { @@ -800,7 +800,7 @@ module.exports = [ origin: null, destination: { type: "stop", - id: "900000079221", + id: "900079221", stationDHID: 'de:11000:900079221', name: "S+U Hermannstr.", location: { @@ -829,7 +829,7 @@ module.exports = [ tripId: '1|23117|2|86|12102021', stop: { type: 'stop', - id: '900000100004', + id: '900100004', stationDHID: 'de:11000:900100004', name: 'S+U Jannowitzbrücke', location: { @@ -1075,7 +1075,7 @@ module.exports = [ origin: null, destination: { type: 'stop', - id: '900000096197', + id: '900096197', stationDHID: 'de:11000:900096197', name: 'S+U Wittenau [U8]', location: { @@ -1104,7 +1104,7 @@ module.exports = [ tripId: '1|25978|5|86|12102021', stop: { type: 'stop', - id: '900000100004', + id: '900100004', stationDHID: 'de:11000:900100004', name: 'S+U Jannowitzbrücke', location: { @@ -1350,7 +1350,7 @@ module.exports = [ origin: null, destination: { type: 'stop', - id: '900000024102', + id: '900024102', stationDHID: 'de:11000:900024102', name: 'S Westkreuz', location: { @@ -1379,7 +1379,7 @@ module.exports = [ tripId: '1|26593|10|86|12102021', stop: { type: 'stop', - id: '900000100004', + id: '900100004', stationDHID: 'de:11000:900100004', name: 'S+U Jannowitzbrücke', location: { @@ -1625,7 +1625,7 @@ module.exports = [ origin: null, destination: { type: 'stop', - id: '900000170004', + id: '900170004', stationDHID: 'de:11000:900170004', name: 'S Ahrensfelde', location: { @@ -1654,7 +1654,7 @@ module.exports = [ tripId: '1|26662|10|86|12102021', stop: { type: 'stop', - id: '900000100004', + id: '900100004', stationDHID: 'de:11000:900100004', name: 'S+U Jannowitzbrücke', location: { @@ -1900,7 +1900,7 @@ module.exports = [ origin: null, destination: { type: 'stop', - id: '900000230999', + id: '900230999', stationDHID: 'de:12054:900230999', name: 'S Potsdam Hauptbahnhof', location: { @@ -1929,7 +1929,7 @@ module.exports = [ tripId: '1|26077|2|86|12102021', stop: { type: 'stop', - id: '900000100004', + id: '900100004', stationDHID: 'de:11000:900100004', name: 'S+U Jannowitzbrücke', location: { @@ -2175,7 +2175,7 @@ module.exports = [ origin: null, destination: { type: 'stop', - id: '900000320004', + id: '900320004', stationDHID: 'de:12064:900320004', name: 'S Strausberg', location: { @@ -2204,7 +2204,7 @@ module.exports = [ tripId: '1|23049|34|86|12102021', stop: { type: 'stop', - id: '900000100004', + id: '900100004', stationDHID: 'de:11000:900100004', name: 'S+U Jannowitzbrücke', location: { @@ -2450,7 +2450,7 @@ module.exports = [ origin: null, destination: { type: 'stop', - id: '900000079221', + id: '900079221', stationDHID: 'de:11000:900079221', name: 'S+U Hermannstr.', location: { @@ -2479,7 +2479,7 @@ module.exports = [ tripId: '1|23111|31|86|12102021', stop: { type: 'stop', - id: '900000100004', + id: '900100004', stationDHID: 'de:11000:900100004', name: 'S+U Jannowitzbrücke', location: { @@ -2725,7 +2725,7 @@ module.exports = [ origin: null, destination: { type: 'stop', - id: '900000085104', + id: '900085104', stationDHID: 'de:11000:900085104', name: 'U Paracelsus-Bad', location: { @@ -2754,7 +2754,7 @@ module.exports = [ tripId: '1|12062|15|86|12102021', stop: { type: 'stop', - id: '900000100004', + id: '900100004', stationDHID: 'de:11000:900100004', name: 'S+U Jannowitzbrücke', location: { @@ -2999,7 +2999,7 @@ module.exports = [ origin: null, destination: { type: 'stop', - id: '900000120004', + id: '900120004', stationDHID: 'de:11000:900120004', name: 'S+U Warschauer Str.', location: { @@ -3028,7 +3028,7 @@ module.exports = [ tripId: '1|27181|9|86|12102021', stop: { type: 'stop', - id: '900000100004', + id: '900100004', stationDHID: 'de:11000:900100004', name: 'S+U Jannowitzbrücke', location: { @@ -3274,7 +3274,7 @@ module.exports = [ origin: null, destination: { type: 'stop', - id: '900000029101', + id: '900029101', stationDHID: 'de:11000:900029101', name: 'S Spandau', location: { diff --git a/test/fixtures/vbb-journeys.js b/test/fixtures/vbb-journeys.js index 607e67e7..524e355f 100644 --- a/test/fixtures/vbb-journeys.js +++ b/test/fixtures/vbb-journeys.js @@ -5,7 +5,7 @@ module.exports = [{ legs: [{ origin: { type: 'stop', - id: '900000042101', + id: '900042101', name: 'U Spichernstr.', location: { type: 'location', @@ -25,7 +25,7 @@ module.exports = [{ }, destination: { type: 'stop', - id: '900000001201', + id: '900001201', name: 'S+U Westhafen', location: { type: 'location', @@ -83,7 +83,7 @@ module.exports = [{ }, { origin: { type: 'stop', - id: '900000001201', + id: '900001201', name: 'S+U Westhafen', location: { type: 'location', @@ -103,7 +103,7 @@ module.exports = [{ }, destination: { type: 'stop', - id: '900000007102', + id: '900007102', name: 'S+U Gesundbrunnen', location: { type: 'location', @@ -161,7 +161,7 @@ module.exports = [{ }, { origin: { type: 'stop', - id: '900000007102', + id: '900007102', name: 'S+U Gesundbrunnen', location: { type: 'location', @@ -181,7 +181,7 @@ module.exports = [{ }, destination: { type: 'stop', - id: '900000350127', + id: '900350127', name: 'Eberswalde, Hbf', location: { type: 'location', @@ -305,7 +305,7 @@ module.exports = [{ legs: [{ origin: { type: 'stop', - id: '900000042101', + id: '900042101', name: 'U Spichernstr.', location: { type: 'location', @@ -325,7 +325,7 @@ module.exports = [{ }, destination: { type: 'stop', - id: '900000001201', + id: '900001201', name: 'S+U Westhafen', location: { type: 'location', @@ -383,7 +383,7 @@ module.exports = [{ }, { origin: { type: 'stop', - id: '900000001201', + id: '900001201', name: 'S+U Westhafen', location: { type: 'location', @@ -403,7 +403,7 @@ module.exports = [{ }, destination: { type: 'stop', - id: '900000007102', + id: '900007102', name: 'S+U Gesundbrunnen', location: { type: 'location', @@ -462,7 +462,7 @@ module.exports = [{ }, { origin: { type: 'stop', - id: '900000007102', + id: '900007102', name: 'S+U Gesundbrunnen', location: { type: 'location', @@ -482,7 +482,7 @@ module.exports = [{ }, destination: { type: 'stop', - id: '900000350127', + id: '900350127', name: 'Eberswalde, Hbf', location: { type: 'location',