db-vendo-client/parse/location.js
Jannis R fb43a4e43b
code style 👕
- rename variables
- more consistent indentation
- give crucial anonymous functions a name
- add more TODOs
2017-11-12 00:05:32 +01:00

26 lines
506 B
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'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
}
if (type === 'poi' || type === 'station') result.id = l.extId
if ('pCls' in l) result.products = l.pCls
return result
}
module.exports = parseLocation