2024-02-06 22:58:49 +01:00
|
|
|
import {formatLocationIdentifier} from './location-identifier.js';
|
|
|
|
import {formatCoord} from './coord.js';
|
2017-11-12 00:53:34 +01:00
|
|
|
|
2017-11-12 19:15:13 +01:00
|
|
|
const formatPoi = (p) => {
|
2023-12-07 00:54:29 +01:00
|
|
|
// todo: use Number.isFinite()!
|
2017-12-12 23:40:12 +01:00
|
|
|
if (p.type !== 'location' || !p.latitude || !p.longitude || !p.id || !p.name) {
|
2024-02-06 22:58:49 +01:00
|
|
|
throw new TypeError('invalid POI');
|
2017-12-12 23:15:06 +01:00
|
|
|
}
|
2017-11-12 19:15:13 +01:00
|
|
|
|
2017-11-12 00:53:34 +01:00
|
|
|
return {
|
2019-02-07 17:46:49 +01:00
|
|
|
type: 'P', // POI
|
2017-11-12 19:15:13 +01:00
|
|
|
name: p.name,
|
2018-03-03 00:18:52 +01:00
|
|
|
lid: formatLocationIdentifier({
|
2019-02-07 17:46:49 +01:00
|
|
|
A: '4', // POI?
|
2018-03-03 00:18:52 +01:00
|
|
|
O: p.name,
|
|
|
|
L: p.id,
|
|
|
|
X: formatCoord(p.longitude),
|
2024-02-06 22:58:49 +01:00
|
|
|
Y: formatCoord(p.latitude),
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
};
|
2017-11-12 00:53:34 +01:00
|
|
|
|
2022-05-07 16:17:37 +02:00
|
|
|
export {
|
|
|
|
formatPoi,
|
2024-02-06 22:58:49 +01:00
|
|
|
};
|