parseWarning

This commit is contained in:
Jannis R 2018-06-07 18:46:24 +02:00
parent b6e37595a5
commit d909be3b65
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
5 changed files with 43 additions and 0 deletions

View file

@ -11,6 +11,7 @@ const parseMovement = require('../parse/movement')
const parseNearby = require('../parse/nearby')
const parseOperator = require('../parse/operator')
const parseHint = require('../parse/hint')
const parseWarning = require('../parse/warning')
const parseStopover = require('../parse/stopover')
const formatAddress = require('../format/address')
@ -48,6 +49,7 @@ const defaultProfile = {
parseNearby,
parseOperator,
parseHint,
parseWarning,
parseStopover,
formatAddress,

View file

@ -83,6 +83,10 @@ const request = (profile, data) => {
if (Array.isArray(c.remL)) {
d.hints = c.remL.map(hint => profile.parseHint(profile, hint))
}
d.warnings = []
if (Array.isArray(c.himL)) {
d.warnings = c.himL.map(w => profile.parseWarning(profile, w))
}
if (Array.isArray(c.opL)) {
d.operators = c.opL.map(op => profile.parseOperator(profile, op))
}

View file

@ -21,6 +21,7 @@ const types = {
parseNearby: 'function',
parseOperator: 'function',
parseHint: 'function',
parseWarning: 'function',
parseStopover: 'function',
formatAddress: 'function',

View file

@ -33,6 +33,7 @@
},
"dependencies": {
"@mapbox/polyline": "^1.0.0",
"br2nl": "^1.0.0",
"capture-stack-trace": "^1.0.0",
"create-hash": "^1.2.0",
"fetch-ponyfill": "^6.0.0",

35
parse/warning.js Normal file
View file

@ -0,0 +1,35 @@
'use strict'
const brToNewline = require('br2nl')
const parseDateTime = require('./date-time')
// todo: is passing in profile necessary?
const parseWarning = (profile, w) => {
// todo: hid, act, pub, lead, tckr, icoX, fLocX, tLocX, prod, comp,
// todo: cat (1, 2), pubChL
// pubChL:
// [ { name: 'timetable',
// fDate: '20180606',
// fTime: '073000',
// tDate: '20180713',
// tTime: '030000' },
// { name: 'export',
// fDate: '20180606',
// fTime: '073000',
// tDate: '20180713',
// tTime: '030000' } ]
return {
type: 'warning',
summary: brToNewline(w.head),
text: brToNewline(w.text),
priority: w.prio,
category: w.cat, // todo: parse to sth meaningful
validFrom: parseDateTime(profile, w.sDate, w.sTime).toISO(),
validUntil: parseDateTime(profile, w.eDate, w.eTime).toISO(),
modified: parseDateTime(profile, w.lModDate, w.lModTime).toISO()
}
}
module.exports = parseWarning