ÖBB: code style 👕, add TODOs, improve docs 📝

This commit is contained in:
Jannis R 2017-12-29 23:46:07 +01:00
parent 2a67733edf
commit 4ec458bf6a
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
2 changed files with 16 additions and 7 deletions

View file

@ -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

View file

@ -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