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')
|
|
|
|
|
2017-11-12 19:15:13 +01:00
|
|
|
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 19:15:13 +01:00
|
|
|
|
2017-11-12 00:53:34 +01:00
|
|
|
return {
|
2017-11-12 19:15:13 +01:00
|
|
|
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
|