db-vendo-client/parse/location.js

28 lines
545 B
JavaScript
Raw Normal View History

2017-11-11 22:35:41 +01:00
'use strict'
const types = Object.create(null)
types.P = 'poi'
types.S = 'station'
types.A = 'address'
// todo: what is s.rRefL?
2017-11-12 01:23:34 +01:00
// todo: is passing in profile necessary?
const parseLocation = (profile, l) => {
2017-11-11 22:35:41 +01:00
const type = types[l.type] || 'unknown'
2017-11-12 01:23:34 +01:00
const res = {
2017-11-11 22:35:41 +01:00
type,
name: l.name,
coordinates: l.crd ? {
latitude: l.crd.y / 1000000,
longitude: l.crd.x / 1000000
} : null
}
2017-11-12 01:23:34 +01:00
if (type === 'poi' || type === 'station') res.id = l.extId
if ('pCls' in l) res.products = l.pCls
2017-11-12 01:23:34 +01:00
return res
2017-11-11 22:35:41 +01:00
}
module.exports = parseLocation