CMTA: hafas-client@2 modes -> hafas-client@3 products

This commit is contained in:
Jannis R 2018-08-24 19:25:30 +02:00 committed by Jannis Redmann
parent 6acbd8b1b1
commit d0b0b56fbc
3 changed files with 32 additions and 80 deletions

View file

@ -1,11 +1,6 @@
'use strict'
const createParseBitmask = require('../../parse/products-bitmask')
const createFormatBitmask = require('../../format/products-bitmask')
const modes = require('./modes')
const formatBitmask = createFormatBitmask(modes)
const products = require('./products')
const transformReqBody = (body) => {
body.client = {type: 'WEB', id: 'CMTA', name: 'webapp', l: ''}
@ -16,29 +11,14 @@ const transformReqBody = (body) => {
return body
}
const defaultProducts = {
bus: true,
rapid: true,
rail: true
}
const formatProducts = (products) => {
products = Object.assign(Object.create(null), defaultProducts, products)
return {
type: 'PROD',
mode: 'INC',
value: formatBitmask(products) + ''
}
}
const cmtaProfile = {
endpoint: 'https://capmetro.hafas.de/bin/mgate.exe',
locale: 'en-US',
timezone: 'America/Chicago',
products: modes.allProducts,
transformReqBody,
formatProducts,
parseProducts: createParseBitmask(modes.allProducts, defaultProducts),
products,
journeyLeg: true,
radar: true
}

View file

@ -1,56 +0,0 @@
'use strict'
const m = {
bus: {
category: 1,
bitmask: 32,
name: 'Bus',
mode: 'bus',
short: 'B',
product: 'bus'
},
rapid: {
category: 2,
bitmask: 4096,
name: 'MetroRapid',
mode: 'bus',
short: 'R',
product: 'rapid'
},
rail: {
category: 3,
bitmask: 8,
name: 'MetroRail',
mode: 'train',
short: 'M',
product: 'rail'
},
unknown: {
category: null,
bitmask: 0,
name: 'unknown',
mode: null,
short: '?',
product: 'unknown'
}
}
m.bitmasks = []
m.bitmasks[8] = m.rail
m.bitmasks[32] = m.bus
m.bitmasks[4096] = m.rapid
m.categories = [
m.bus,
m.rapid,
m.rail,
m.unknown
]
m.allProducts = [
m.bus,
m.rapid,
m.rail
]
module.exports = m

28
p/cmta/products.js Normal file
View file

@ -0,0 +1,28 @@
'use strict'
module.exports = [
{
id: 'bus',
mode: 'bus',
bitmasks: [32],
name: 'MetroBus',
short: 'B',
default: true
},
{
id: 'rapid',
mode: 'bus',
bitmasks: [4096],
name: 'MetroRapid',
short: 'R',
default: true
},
{
id: 'rail',
mode: 'train',
bitmasks: [8],
name: 'MetroRail',
short: 'M',
default: true
}
]