mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
25 lines
523 B
JavaScript
25 lines
523 B
JavaScript
import {formatLocationIdentifier} from './location-identifier.js'
|
|
import {formatCoord} from './coord.js'
|
|
|
|
const formatAddress = (a) => {
|
|
if (a.type !== 'location' || !a.latitude || !a.longitude || !a.address) {
|
|
throw new TypeError('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 {
|
|
type: 'A', // address
|
|
name: a.address,
|
|
lid: formatLocationIdentifier(data)
|
|
}
|
|
}
|
|
|
|
export {
|
|
formatAddress,
|
|
}
|