db-vendo-client/parse/location.js

27 lines
506 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?
const parseLocation = (l) => {
const type = types[l.type] || 'unknown'
const result = {
type,
name: l.name,
coordinates: l.crd ? {
latitude: l.crd.y / 1000000,
longitude: l.crd.x / 1000000
} : null
}
2017-11-11 22:35:41 +01:00
if (type === 'poi' || type === 'station') result.id = l.extId
if ('pCls' in l) result.products = l.pCls
2017-11-11 22:35:41 +01:00
return result
}
module.exports = parseLocation