2024-02-06 22:58:49 +01:00
|
|
|
|
import {formatLocationIdentifier} from './location-identifier.js';
|
2018-03-03 00:18:52 +01:00
|
|
|
|
|
2024-12-21 15:26:49 +00:00
|
|
|
|
const isIBNR = /^\d{6,}$/;
|
|
|
|
|
|
2018-03-03 00:18:52 +01:00
|
|
|
|
const formatStation = (id) => {
|
2024-12-21 15:26:49 +00:00
|
|
|
|
if (!isIBNR.test(id)) {
|
|
|
|
|
throw new Error('station ID must be an IBNR.');
|
|
|
|
|
}
|
2018-03-03 00:18:52 +01:00
|
|
|
|
return {
|
2019-02-07 17:46:49 +01:00
|
|
|
|
type: 'S', // station
|
2018-03-03 00:18:52 +01:00
|
|
|
|
// todo: name necessary?
|
|
|
|
|
lid: formatLocationIdentifier({
|
2019-02-07 17:46:49 +01:00
|
|
|
|
A: '1', // station?
|
2024-02-06 22:58:49 +01:00
|
|
|
|
L: id,
|
2023-12-07 00:54:29 +01:00
|
|
|
|
// todo: `p` – timestamp of when the ID was obtained
|
2024-02-06 22:58:49 +01:00
|
|
|
|
}),
|
|
|
|
|
};
|
|
|
|
|
};
|
2017-11-12 00:53:34 +01:00
|
|
|
|
|
2022-05-07 16:17:37 +02:00
|
|
|
|
export {
|
|
|
|
|
formatStation,
|
2024-02-06 22:58:49 +01:00
|
|
|
|
};
|