mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09: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) => {
|
||||
// Ö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)
|
||||
if(res.type === 'station' && !res.products && res.name && res.id && res.id.length !== 7){
|
||||
const newRes = {
|
||||
if (
|
||||
res.type === 'station' &&
|
||||
!res.products &&
|
||||
res.name &&
|
||||
res.id && res.id.length !== 7
|
||||
) {
|
||||
return Object.assign({
|
||||
type: 'location',
|
||||
id: res.id,
|
||||
name: res.name
|
||||
}
|
||||
return Object.assign({}, newRes, res.location)
|
||||
}, res.location)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
@ -61,9 +66,12 @@ const createParseMovement = (profile, locations, lines, remarks) => {
|
|||
const _parseMovement = _createParseMovement(profile, locations, lines, remarks)
|
||||
const 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.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 parseMovement
|
||||
|
|
|
@ -16,3 +16,4 @@ const client = createClient(oebbProfile)
|
|||
## Customisations
|
||||
|
||||
- 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