db-vendo-client/format/address.js

28 lines
540 B
JavaScript
Raw Normal View History

import {formatLocationIdentifier} from './location-identifier.js';
import {formatCoord} from './coord.js';
2017-11-12 00:53:34 +01:00
const formatAddress = (a) => {
2017-12-12 23:40:12 +01:00
if (a.type !== 'location' || !a.latitude || !a.longitude || !a.address) {
throw new TypeError('invalid address');
2017-12-12 23:15:06 +01:00
}
2018-02-15 17:31:43 +01:00
const data = {
A: '2', // address?
2018-02-15 17:31:43 +01:00
O: a.address,
X: formatCoord(a.longitude),
Y: formatCoord(a.latitude),
};
if (a.id) {
data.L = a.id;
2018-02-15 17:31:43 +01:00
}
2017-11-12 00:53:34 +01:00
return {
type: 'A', // address
2017-12-12 23:40:12 +01:00
name: a.address,
lid: formatLocationIdentifier(data),
};
};
2017-11-12 00:53:34 +01:00
2022-05-07 16:17:37 +02:00
export {
formatAddress,
};