db-vendo-client/format/poi.js

22 lines
367 B
JavaScript
Raw Normal View History

2017-11-12 00:53:34 +01:00
'use strict'
const formatCoord = require('./coord')
const formatPoi = (p) => {
2017-12-12 23:15:06 +01:00
if (!p.type !== 'location' || !p.latitude || !p.longitude || !p.id || !p.name) {
throw new Error('invalid POI')
}
2017-11-12 00:53:34 +01:00
return {
type: 'P',
name: p.name,
lid: 'L=' + p.id,
2017-11-12 00:53:34 +01:00
crd: {
x: formatCoord(p.longitude),
y: formatCoord(p.latitude)
2017-11-12 00:53:34 +01:00
}
}
}
module.exports = formatPoi