2024-12-07 22:46:04 +00:00
|
|
|
import maxBy from 'lodash/maxBy.js';
|
|
|
|
|
2024-12-07 16:16:31 +00:00
|
|
|
const parsePolyline = (ctx, p) => { // p = raw polylineGroup
|
2025-01-03 10:57:24 +00:00
|
|
|
const desc = p.polylineDescriptions || p.polylineDesc;
|
|
|
|
if (desc.length < 1) {
|
2024-12-07 16:16:31 +00:00
|
|
|
return null;
|
|
|
|
}
|
2025-01-03 10:57:24 +00:00
|
|
|
const points = maxBy(desc, d => d.coordinates.length).coordinates; // TODO initial and final poly?
|
2024-02-06 22:58:49 +01:00
|
|
|
if (points.length === 0) {
|
|
|
|
return null;
|
|
|
|
}
|
2018-05-16 21:07:05 +02:00
|
|
|
|
2024-12-07 16:16:31 +00:00
|
|
|
const res = points.map(ll => ({
|
2019-10-20 00:19:11 +02:00
|
|
|
type: 'Feature',
|
|
|
|
properties: {},
|
|
|
|
geometry: {
|
|
|
|
type: 'Point',
|
2025-01-03 10:57:24 +00:00
|
|
|
coordinates: [ll.lng || ll.longitude, ll.lat || ll.latitude],
|
2024-02-06 22:58:49 +01:00
|
|
|
},
|
|
|
|
}));
|
2018-05-16 21:07:05 +02:00
|
|
|
|
2024-12-07 16:16:31 +00:00
|
|
|
// TODO initial and final descriptions?, match station info?
|
2019-10-20 00:19:11 +02:00
|
|
|
|
|
|
|
return {
|
|
|
|
type: 'FeatureCollection',
|
2024-02-06 22:58:49 +01:00
|
|
|
features: res,
|
|
|
|
};
|
|
|
|
};
|
2018-05-16 21:07:05 +02:00
|
|
|
|
2022-05-07 16:17:37 +02:00
|
|
|
export {
|
|
|
|
parsePolyline,
|
2024-02-06 22:58:49 +01:00
|
|
|
};
|