mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
ÖBB: code style 👕, add TODOs, improve docs 📝
This commit is contained in:
parent
2a67733edf
commit
4ec458bf6a
2 changed files with 16 additions and 7 deletions
|
@ -44,15 +44,20 @@ const parseLine = (profile, l) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const parseLocation = (profile, l) => {
|
const parseLocation = (profile, l) => {
|
||||||
// ÖBB has some 'stations' **in austria** with no departures/products, like station entrances, that are actually POI
|
// ÖBB has some 'stations' **in austria** with no departures/products,
|
||||||
|
// like station entrances, that are actually POIs.
|
||||||
const res = _parseLocation(profile, l)
|
const res = _parseLocation(profile, l)
|
||||||
if(res.type === 'station' && !res.products && res.name && res.id && res.id.length !== 7){
|
if (
|
||||||
const newRes = {
|
res.type === 'station' &&
|
||||||
|
!res.products &&
|
||||||
|
res.name &&
|
||||||
|
res.id && res.id.length !== 7
|
||||||
|
) {
|
||||||
|
return Object.assign({
|
||||||
type: 'location',
|
type: 'location',
|
||||||
id: res.id,
|
id: res.id,
|
||||||
name: res.name
|
name: res.name
|
||||||
}
|
}, res.location)
|
||||||
return Object.assign({}, newRes, res.location)
|
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
@ -61,9 +66,12 @@ const createParseMovement = (profile, locations, lines, remarks) => {
|
||||||
const _parseMovement = _createParseMovement(profile, locations, lines, remarks)
|
const _parseMovement = _createParseMovement(profile, locations, lines, remarks)
|
||||||
const parseMovement = (m) => {
|
const parseMovement = (m) => {
|
||||||
const res = _parseMovement(m)
|
const res = _parseMovement(m)
|
||||||
// filter POI
|
// filter out POIs
|
||||||
|
// todo: make use of them, as some of them specify fare zones
|
||||||
res.nextStops = res.nextStops.filter(s => s.type === 'station')
|
res.nextStops = res.nextStops.filter(s => s.type === 'station')
|
||||||
res.frames = res.frames.filter(f => !(f.origin.type === 'location' && f.destination.type === 'location'))
|
res.frames = res.frames.filter((f) => {
|
||||||
|
return f.origin.type !== 'location' && f.destination.type !== 'location'
|
||||||
|
})
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
return parseMovement
|
return parseMovement
|
||||||
|
|
|
@ -16,3 +16,4 @@ const client = createClient(oebbProfile)
|
||||||
## Customisations
|
## Customisations
|
||||||
|
|
||||||
- parses *ÖBB*-specific products (such as *RailJet*)
|
- parses *ÖBB*-specific products (such as *RailJet*)
|
||||||
|
- parses invalid empty stations from the API as [`location`](https://github.com/public-transport/friendly-public-transport-format/blob/1.0.1/spec/readme.md#location-objects)s
|
||||||
|
|
Loading…
Add table
Reference in a new issue