db-vendo-client/format/poi.js

24 lines
469 B
JavaScript
Raw Normal View History

2017-11-12 00:53:34 +01:00
'use strict'
2018-02-15 17:31:43 +01:00
const formatLocationIdentifier = require('./location-identifier')
2017-11-12 00:53:34 +01:00
const formatCoord = require('./coord')
const formatPoi = (p) => {
2017-12-12 23:40:12 +01:00
if (p.type !== 'location' || !p.latitude || !p.longitude || !p.id || !p.name) {
2017-12-12 23:15:06 +01:00
throw new Error('invalid POI')
}
2017-11-12 00:53:34 +01:00
return {
name: p.name,
2018-02-15 17:31:43 +01:00
lid: formatLocationIdentifier({
A: '4', // POI
O: p.name,
X: formatCoord(p.longitude),
Y: formatCoord(p.latitude),
L: p.id
})
2017-11-12 00:53:34 +01:00
}
}
module.exports = formatPoi