parse stops and their stations

This commit is contained in:
Jannis R 2018-07-10 23:32:34 +02:00 committed by Jannis Redmann
parent fe8e68e4a2
commit a475f2048d
4 changed files with 19 additions and 9 deletions

View file

@ -104,8 +104,18 @@ const request = (profile, opt, data) => {
d.lines = c.prodL.map(parse)
}
if (Array.isArray(c.locL)) {
const parse = loc => profile.parseLocation(profile, opt, {lines: d.lines}, loc)
const data = {lines: d.lines}
const parse = loc => profile.parseLocation(profile, opt, data, loc)
d.locations = c.locL.map(parse)
for (let i = 0; i < d.locations.length; i++) {
const raw = c.locL[i]
const loc = d.locations[i]
if ('number' === typeof raw.mMastLocX) {
loc.station = Object.assign({}, d.locations[raw.mMastLocX])
loc.station.type = 'station'
} else if (raw.isMainMast) loc.type = 'station'
}
}
return d
})

View file

@ -30,7 +30,7 @@ const parseLocation = (profile, opt, data, l) => {
// like station entrances, that are actually POIs.
const res = _parseLocation(profile, opt, data, l)
if (
res.type === 'station' &&
(res.type === 'station' || res.type === 'stop') &&
!res.products &&
res.name &&
res.id && res.id.length !== 7

View file

@ -45,7 +45,7 @@ const createParseLine = (profile, opt, data) => {
const parseLocation = (profile, opt, data, l) => {
const res = _parseLocation(profile, opt, data, l)
if (res.type === 'station') {
if (res.type === 'stop' || res.type === 'station') {
res.name = shorten(res.name)
res.id = to12Digit(res.id)
if (!res.location.latitude || !res.location.longitude) {

View file

@ -13,28 +13,28 @@ const parseLocation = (profile, opt, {lines}, l) => {
}
if (l.type === STATION) {
const station = {
type: 'station',
const stop = {
type: l.isMainMast ? 'station' : 'stop',
id: l.extId,
name: l.name ? profile.parseStationName(l.name) : null,
location: 'number' === typeof res.latitude ? res : null
}
if ('pCls' in l) station.products = profile.parseProducts(l.pCls)
if ('pCls' in l) stop.products = profile.parseProducts(l.pCls)
if (
opt.stationLines &&
Array.isArray(l.pRefL) &&
Array.isArray(lines)
) {
station.lines = []
stop.lines = []
for (let pRef of l.pRefL) {
const line = lines[pRef]
if (line) station.lines.push(line)
if (line) stop.lines.push(line)
}
}
return station
return stop
}
if (l.type === ADDRESS) res.address = l.name