2017-11-11 22:35:41 +01:00
|
|
|
'use strict'
|
|
|
|
|
2017-12-11 19:25:29 +01:00
|
|
|
const POI = 'P'
|
|
|
|
const STATION = 'S'
|
|
|
|
const ADDRESS = 'A'
|
2017-11-11 22:35:41 +01:00
|
|
|
|
|
|
|
// todo: what is s.rRefL?
|
2017-11-12 01:23:34 +01:00
|
|
|
// todo: is passing in profile necessary?
|
|
|
|
const parseLocation = (profile, l) => {
|
2017-12-11 19:25:29 +01:00
|
|
|
const res = {type: 'location'}
|
|
|
|
if (l.crd) {
|
|
|
|
res.latitude = l.crd.y / 1000000
|
|
|
|
res.longitude = l.crd.x / 1000000
|
2017-11-11 22:35:41 +01:00
|
|
|
}
|
2017-11-11 23:56:09 +01:00
|
|
|
|
2017-12-11 19:25:29 +01:00
|
|
|
if (l.type === STATION) {
|
|
|
|
const station = {
|
|
|
|
type: 'station',
|
|
|
|
id: l.extId,
|
2017-12-11 19:40:46 +01:00
|
|
|
name: l.name,
|
2017-12-11 19:25:29 +01:00
|
|
|
location: res
|
|
|
|
}
|
|
|
|
if ('pCls' in l) station.products = profile.parseProducts(l.pCls)
|
|
|
|
return station
|
|
|
|
}
|
|
|
|
|
2017-12-11 19:40:46 +01:00
|
|
|
if (l.type === POI) res.id = l.extId
|
2017-12-11 19:25:29 +01:00
|
|
|
else if (l.type === ADDRESS) res.address = l.name
|
|
|
|
else res.name = l.name
|
2017-11-11 23:56:09 +01:00
|
|
|
|
2017-11-12 01:23:34 +01:00
|
|
|
return res
|
2017-11-11 22:35:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = parseLocation
|