mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
BVG/VBB: parse stop DHIDs ✅
This commit is contained in:
parent
f8ca2d5d17
commit
7e1f7ed4ee
5 changed files with 50 additions and 0 deletions
|
@ -6,6 +6,8 @@ const parseLineName = require('vbb-parse-line')
|
||||||
const getStations = require('vbb-stations')
|
const getStations = require('vbb-stations')
|
||||||
const {parseHook} = require('../../lib/profile-hooks')
|
const {parseHook} = require('../../lib/profile-hooks')
|
||||||
|
|
||||||
|
const parseAndAddLocationDHID = require('../vbb/parse-loc-dhid')
|
||||||
|
|
||||||
const {
|
const {
|
||||||
parseLine: _parseLine,
|
parseLine: _parseLine,
|
||||||
parseLocation: _parseLocation,
|
parseLocation: _parseLocation,
|
||||||
|
@ -65,6 +67,8 @@ const parseLocation = ({parsed}, l) => {
|
||||||
if (s) Object.assign(parsed.location, s.location)
|
if (s) Object.assign(parsed.location, s.location)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parseAndAddLocationDHID(parsed, l)
|
||||||
return parsed
|
return parsed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ const parseTicket = require('vbb-parse-ticket')
|
||||||
const getStations = require('vbb-stations')
|
const getStations = require('vbb-stations')
|
||||||
const {parseHook} = require('../../lib/profile-hooks')
|
const {parseHook} = require('../../lib/profile-hooks')
|
||||||
|
|
||||||
|
const parseAndAddLocationDHID = require('./parse-loc-dhid')
|
||||||
const _parseLine = require('../../parse/line')
|
const _parseLine = require('../../parse/line')
|
||||||
const _parseLocation = require('../../parse/location')
|
const _parseLocation = require('../../parse/location')
|
||||||
const _parseJourney = require('../../parse/journey')
|
const _parseJourney = require('../../parse/journey')
|
||||||
|
@ -38,6 +39,8 @@ const parseLocation = ({parsed}, l) => {
|
||||||
if (s) Object.assign(parsed.location, s.location)
|
if (s) Object.assign(parsed.location, s.location)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parseAndAddLocationDHID(parsed, l)
|
||||||
return parsed
|
return parsed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
18
p/vbb/parse-loc-dhid.js
Normal file
18
p/vbb/parse-loc-dhid.js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const dhidPrefix = 'A×'
|
||||||
|
|
||||||
|
const parseAndAddLocationDHID = (loc, l) => {
|
||||||
|
if (!Array.isArray(l.gidL)) return;
|
||||||
|
|
||||||
|
const dhidGid = l.gidL.find(gid => gid.slice(0, dhidPrefix.length) === dhidPrefix)
|
||||||
|
if (!dhidGid) return;
|
||||||
|
const dhid = dhidGid.slice(dhidPrefix.length)
|
||||||
|
|
||||||
|
// It seems that the DHID of the parent station is being used, not of the stop.
|
||||||
|
// if (!loc.ids) loc.ids = {}
|
||||||
|
// loc.ids.dhid = dhid
|
||||||
|
loc.stationDHID = dhid
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = parseAndAddLocationDHID
|
1
test/fixtures/bvg-arrivals.js
vendored
1
test/fixtures/bvg-arrivals.js
vendored
|
@ -3,6 +3,7 @@
|
||||||
const sLandsbergerAllee = {
|
const sLandsbergerAllee = {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '900000110004',
|
id: '900000110004',
|
||||||
|
stationDHID: 'de:11000:900110004',
|
||||||
name: 'S Landsberger Allee',
|
name: 'S Landsberger Allee',
|
||||||
location: {
|
location: {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
|
|
24
test/fixtures/vbb-departures.js
vendored
24
test/fixtures/vbb-departures.js
vendored
|
@ -6,6 +6,7 @@ module.exports = [
|
||||||
stop: {
|
stop: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '900000100004',
|
id: '900000100004',
|
||||||
|
stationDHID: 'de:11000:900100004',
|
||||||
name: 'S+U Jannowitzbrücke',
|
name: 'S+U Jannowitzbrücke',
|
||||||
location: {
|
location: {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
|
@ -200,6 +201,7 @@ module.exports = [
|
||||||
destination: {
|
destination: {
|
||||||
type: "stop",
|
type: "stop",
|
||||||
id: "900000310004",
|
id: "900000310004",
|
||||||
|
stationDHID: 'de:12067:900310004',
|
||||||
name: "S Erkner",
|
name: "S Erkner",
|
||||||
location: {
|
location: {
|
||||||
type: "location",
|
type: "location",
|
||||||
|
@ -278,6 +280,7 @@ module.exports = [
|
||||||
stop: {
|
stop: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '900000100004',
|
id: '900000100004',
|
||||||
|
stationDHID: 'de:11000:900100004',
|
||||||
name: 'S+U Jannowitzbrücke',
|
name: 'S+U Jannowitzbrücke',
|
||||||
location: {
|
location: {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
|
@ -521,6 +524,7 @@ module.exports = [
|
||||||
destination: {
|
destination: {
|
||||||
type: "stop",
|
type: "stop",
|
||||||
id: "900000005207",
|
id: "900000005207",
|
||||||
|
stationDHID: 'de:11000:900005207',
|
||||||
name: "Philharmonie Süd",
|
name: "Philharmonie Süd",
|
||||||
location: {
|
location: {
|
||||||
type: "location",
|
type: "location",
|
||||||
|
@ -549,6 +553,7 @@ module.exports = [
|
||||||
stop: {
|
stop: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '900000100004',
|
id: '900000100004',
|
||||||
|
stationDHID: 'de:11000:900100004',
|
||||||
name: 'S+U Jannowitzbrücke',
|
name: 'S+U Jannowitzbrücke',
|
||||||
location: {
|
location: {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
|
@ -793,6 +798,7 @@ module.exports = [
|
||||||
destination: {
|
destination: {
|
||||||
type: "stop",
|
type: "stop",
|
||||||
id: "900000079221",
|
id: "900000079221",
|
||||||
|
stationDHID: 'de:11000:900079221',
|
||||||
name: "S+U Hermannstr.",
|
name: "S+U Hermannstr.",
|
||||||
location: {
|
location: {
|
||||||
type: "location",
|
type: "location",
|
||||||
|
@ -821,6 +827,7 @@ module.exports = [
|
||||||
stop: {
|
stop: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '900000100004',
|
id: '900000100004',
|
||||||
|
stationDHID: 'de:11000:900100004',
|
||||||
name: 'S+U Jannowitzbrücke',
|
name: 'S+U Jannowitzbrücke',
|
||||||
location: {
|
location: {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
|
@ -1065,6 +1072,7 @@ module.exports = [
|
||||||
destination: {
|
destination: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '900000096197',
|
id: '900000096197',
|
||||||
|
stationDHID: 'de:11000:900096197',
|
||||||
name: 'S+U Wittenau [U8]',
|
name: 'S+U Wittenau [U8]',
|
||||||
location: {
|
location: {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
|
@ -1093,6 +1101,7 @@ module.exports = [
|
||||||
stop: {
|
stop: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '900000100004',
|
id: '900000100004',
|
||||||
|
stationDHID: 'de:11000:900100004',
|
||||||
name: 'S+U Jannowitzbrücke',
|
name: 'S+U Jannowitzbrücke',
|
||||||
location: {
|
location: {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
|
@ -1337,6 +1346,7 @@ module.exports = [
|
||||||
destination: {
|
destination: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '900000024102',
|
id: '900000024102',
|
||||||
|
stationDHID: 'de:11000:900024102',
|
||||||
name: 'S Westkreuz',
|
name: 'S Westkreuz',
|
||||||
location: {
|
location: {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
|
@ -1365,6 +1375,7 @@ module.exports = [
|
||||||
stop: {
|
stop: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '900000100004',
|
id: '900000100004',
|
||||||
|
stationDHID: 'de:11000:900100004',
|
||||||
name: 'S+U Jannowitzbrücke',
|
name: 'S+U Jannowitzbrücke',
|
||||||
location: {
|
location: {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
|
@ -1609,6 +1620,7 @@ module.exports = [
|
||||||
destination: {
|
destination: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '900000170004',
|
id: '900000170004',
|
||||||
|
stationDHID: 'de:11000:900170004',
|
||||||
name: 'S Ahrensfelde',
|
name: 'S Ahrensfelde',
|
||||||
location: {
|
location: {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
|
@ -1637,6 +1649,7 @@ module.exports = [
|
||||||
stop: {
|
stop: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '900000100004',
|
id: '900000100004',
|
||||||
|
stationDHID: 'de:11000:900100004',
|
||||||
name: 'S+U Jannowitzbrücke',
|
name: 'S+U Jannowitzbrücke',
|
||||||
location: {
|
location: {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
|
@ -1881,6 +1894,7 @@ module.exports = [
|
||||||
destination: {
|
destination: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '900000230999',
|
id: '900000230999',
|
||||||
|
stationDHID: 'de:12054:900230999',
|
||||||
name: 'S Potsdam Hauptbahnhof',
|
name: 'S Potsdam Hauptbahnhof',
|
||||||
location: {
|
location: {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
|
@ -1909,6 +1923,7 @@ module.exports = [
|
||||||
stop: {
|
stop: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '900000100004',
|
id: '900000100004',
|
||||||
|
stationDHID: 'de:11000:900100004',
|
||||||
name: 'S+U Jannowitzbrücke',
|
name: 'S+U Jannowitzbrücke',
|
||||||
location: {
|
location: {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
|
@ -2153,6 +2168,7 @@ module.exports = [
|
||||||
destination: {
|
destination: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '900000320004',
|
id: '900000320004',
|
||||||
|
stationDHID: 'de:12064:900320004',
|
||||||
name: 'S Strausberg',
|
name: 'S Strausberg',
|
||||||
location: {
|
location: {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
|
@ -2181,6 +2197,7 @@ module.exports = [
|
||||||
stop: {
|
stop: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '900000100004',
|
id: '900000100004',
|
||||||
|
stationDHID: 'de:11000:900100004',
|
||||||
name: 'S+U Jannowitzbrücke',
|
name: 'S+U Jannowitzbrücke',
|
||||||
location: {
|
location: {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
|
@ -2425,6 +2442,7 @@ module.exports = [
|
||||||
destination: {
|
destination: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '900000079221',
|
id: '900000079221',
|
||||||
|
stationDHID: 'de:11000:900079221',
|
||||||
name: 'S+U Hermannstr.',
|
name: 'S+U Hermannstr.',
|
||||||
location: {
|
location: {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
|
@ -2453,6 +2471,7 @@ module.exports = [
|
||||||
stop: {
|
stop: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '900000100004',
|
id: '900000100004',
|
||||||
|
stationDHID: 'de:11000:900100004',
|
||||||
name: 'S+U Jannowitzbrücke',
|
name: 'S+U Jannowitzbrücke',
|
||||||
location: {
|
location: {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
|
@ -2697,6 +2716,7 @@ module.exports = [
|
||||||
destination: {
|
destination: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '900000085104',
|
id: '900000085104',
|
||||||
|
stationDHID: 'de:11000:900085104',
|
||||||
name: 'U Paracelsus-Bad',
|
name: 'U Paracelsus-Bad',
|
||||||
location: {
|
location: {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
|
@ -2725,6 +2745,7 @@ module.exports = [
|
||||||
stop: {
|
stop: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '900000100004',
|
id: '900000100004',
|
||||||
|
stationDHID: 'de:11000:900100004',
|
||||||
name: 'S+U Jannowitzbrücke',
|
name: 'S+U Jannowitzbrücke',
|
||||||
location: {
|
location: {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
|
@ -2968,6 +2989,7 @@ module.exports = [
|
||||||
destination: {
|
destination: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '900000120004',
|
id: '900000120004',
|
||||||
|
stationDHID: 'de:11000:900120004',
|
||||||
name: 'S+U Warschauer Str.',
|
name: 'S+U Warschauer Str.',
|
||||||
location: {
|
location: {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
|
@ -2996,6 +3018,7 @@ module.exports = [
|
||||||
stop: {
|
stop: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '900000100004',
|
id: '900000100004',
|
||||||
|
stationDHID: 'de:11000:900100004',
|
||||||
name: 'S+U Jannowitzbrücke',
|
name: 'S+U Jannowitzbrücke',
|
||||||
location: {
|
location: {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
|
@ -3240,6 +3263,7 @@ module.exports = [
|
||||||
destination: {
|
destination: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '900000029101',
|
id: '900000029101',
|
||||||
|
stationDHID: 'de:11000:900029101',
|
||||||
name: 'S Spandau',
|
name: 'S Spandau',
|
||||||
location: {
|
location: {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
|
|
Loading…
Add table
Reference in a new issue