add products/modes for oebb

This commit is contained in:
Julius Tens 2017-12-26 00:58:12 +01:00
parent 477124a769
commit 4d4412d63f
2 changed files with 109 additions and 99 deletions

View file

@ -3,6 +3,11 @@
// todo: https://gist.github.com/anonymous/a5fc856bc80ae7364721943243f934f4#file-haf_config_base-properties-L5 // todo: https://gist.github.com/anonymous/a5fc856bc80ae7364721943243f934f4#file-haf_config_base-properties-L5
// todo: https://gist.github.com/anonymous/a5fc856bc80ae7364721943243f934f4#file-haf_config_base-properties-L47-L234 // todo: https://gist.github.com/anonymous/a5fc856bc80ae7364721943243f934f4#file-haf_config_base-properties-L47-L234
const createParseBitmask = require('../../parse/products-bitmask')
const createFormatBitmask = require('../../format/products-bitmask')
const modes = require('./modes')
const transformReqBody = (body) => { const transformReqBody = (body) => {
body.client = {type: 'IPA', id: 'OEBB'} body.client = {type: 'IPA', id: 'OEBB'}
// todo: https://gist.github.com/anonymous/a5fc856bc80ae7364721943243f934f4#file-haf_config_base-properties-L33 shows 1.16 // todo: https://gist.github.com/anonymous/a5fc856bc80ae7364721943243f934f4#file-haf_config_base-properties-L33 shows 1.16
@ -17,7 +22,13 @@ const oebbProfile = {
timezone: 'Europe/Vienna', timezone: 'Europe/Vienna',
// todo: there is also https://beta.verkehrsauskunft.at/bin/mgate.exe // todo: there is also https://beta.verkehrsauskunft.at/bin/mgate.exe
endpoint: 'http://fahrplan.oebb.at/bin/mgate.exe', endpoint: 'http://fahrplan.oebb.at/bin/mgate.exe',
transformReqBody transformReqBody,
products: modes.allProducts,
parseProducts: createParseBitmask(modes.bitmasks),
formatProducts: createFormatBitmask(modes)
} }
module.exports = oebbProfile module.exports = oebbProfile

View file

@ -1,110 +1,109 @@
'use strict' 'use strict'
// todo: https://gist.github.com/anonymous/a5fc856bc80ae7364721943243f934f4#file-haf_products-properties-L32-L144 const m = {
// - walking nationalExp: {
// - bicycle
// - car
// - taxi_t
// - ic_bus, bus_t
// - pr
// - comm, comm_t
// - sub_t
// - tram_t
// - wchair
// - ic
// - reg
// - gen
// - ship
// - plane
// - transf
// etc.
const m = [
{
category: 1,
bitmask: null, // todo
name: 'walking',
shortName: 'walking',
mode: 'walking',
product: 'walking'
}, {
category: 2,
bitmask: null, // todo
name: 'bicycle',
shortName: 'bicycle',
mode: 'bicycle',
product: 'bicycle'
}, {
category: 3,
bitmask: null, // todo
name: 'car',
shortName: 'car',
mode: 'car',
product: 'car'
}, {
category: 4,
bitmask: null, // todo
name: 'Taxi',
shortName: 'Taxi',
mode: 'taxi',
product: 'taxi'
}, {
category: 6,
bitmask: null, // todo
name: 'Bus',
shortName: 'Bus',
mode: 'bus',
product: 'bus'
}, {
category: 12,
bitmask: null, // todo
name: 'Subway',
shortName: 'Subway',
mode: 'train',
product: 'subway'
}, {
category: 14,
bitmask: null, // todo
name: 'Tram',
shortName: 'Tram',
mode: 'train',
product: 'tram'
}, {
category: 17,
bitmask: 1, bitmask: 1,
name: 'RailJet/InterCityExpress/TGV highspeed train', name: 'InterCityExpress & RailJet',
shortName: 'RJ/ICE/TGV', // todo: is there a way to tell which? short: 'ICE/RJ',
mode: 'train', mode: 'train',
product: 'nationalExpress' product: 'nationalExp'
}, { },
category: 18, national: {
bitmask: 2, bitmask: 2 + 4,
name: 'EuroCity/InterCity train', name: 'InterCity & EuroCity',
shortName: 'EC/IC', short: 'IC/EC',
mode: 'train', mode: 'train',
product: 'national' product: 'national'
}, { },
category: 24, interregional: {
bitmask: 3, bitmask: 8 + 4096,
name: 'NightJet/EuroNight/D train', name: 'Durchgangszug & EuroNight',
shortName: 'EN/D', short: 'D/EN',
mode: 'train', mode: 'train',
product: 'sleeper' product: 'regional'
}, { },
category: 22, regional: {
bitmask: null, // todo bitmask: 16,
name: 'Airplane', name: 'Regional & RegionalExpress',
shortName: 'Plane', short: 'R/REX',
mode: 'aircraft', mode: 'train',
product: 'airplane' product: 'regional'
}, { },
category: 0, suburban: {
bitmask: null, bitmask: 32,
name: 'S-Bahn',
short: 'S',
mode: 'train',
product: 'suburban'
},
bus: {
bitmask: 64,
name: 'Bus',
short: 'B',
mode: 'bus',
product: 'bus'
},
ferry: {
bitmask: 128,
name: 'Ferry',
short: 'F',
mode: 'watercraft',
product: 'ferry'
},
subway: {
bitmask: 256,
name: 'U-Bahn',
short: 'U',
mode: 'train',
product: 'subway'
},
tram: {
bitmask: 512,
name: 'Tram',
short: 'T',
mode: 'tram',
product: 'tram'
},
onCall: {
bitmask: 2048,
name: 'On-call transit',
short: 'on-call',
mode: null, // todo
product: 'onCall'
},
unknown: {
bitmask: 0,
name: 'unknown', name: 'unknown',
shortName: '?', short: '?',
mode: null, product: 'unknown'
product: null
} }
} }
m.bitmasks = []
m.bitmasks[1] = m.nationalExp
m.bitmasks[2] = m.national
m.bitmasks[4] = m.national
m.bitmasks[8] = m.interregional
m.bitmasks[16] = m.regional
m.bitmasks[32] = m.suburban
m.bitmasks[64] = m.bus
m.bitmasks[128] = m.ferry
m.bitmasks[256] = m.subway
m.bitmasks[512] = m.tram
m.bitmasks[2048] = m.onCall
m.bitmasks[4096] = m.interregional
m.allProducts = [
m.nationalExp,
m.national,
m.interregional,
m.regional,
m.suburban,
m.bus,
m.ferry,
m.subway,
m.tram,
m.onCall
]
module.exports = m module.exports = m