mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
24 lines
512 B
JavaScript
24 lines
512 B
JavaScript
'use strict'
|
|
|
|
const formatLocationIdentifier = require('./location-identifier')
|
|
const formatCoord = require('./coord')
|
|
|
|
const formatAddress = (a) => {
|
|
if (a.type !== 'location' || !a.latitude || !a.longitude || !a.address) {
|
|
throw new Error('invalid address')
|
|
}
|
|
|
|
const data = {
|
|
A: '2', // address
|
|
O: a.address,
|
|
X: formatCoord(a.longitude),
|
|
Y: formatCoord(a.latitude)
|
|
}
|
|
if (a.id) data.L = a.id
|
|
return {
|
|
name: a.address,
|
|
lid: formatLocationIdentifier(data)
|
|
}
|
|
}
|
|
|
|
module.exports = formatAddress
|