UNPKG

hmpps-open-layers-map

Version:

A native Web Component for displaying maps using OpenLayers.

50 lines (49 loc) 1.21 kB
function r(t) { if (!t || t.length === 0) return { type: "FeatureCollection", features: [] }; const d = t.map((e) => ({ type: "Feature", id: e.positionId.toString(), geometry: { type: "Point", coordinates: [e.longitude, e.latitude] }, properties: { "@id": e.positionId.toString(), confidence: e.precision, speed: e.speed, direction: e.direction, timestamp: e.timestamp, geolocationMechanism: e.geolocationMechanism, sequenceNumber: e.sequenceNumber, type: "mdss-location" } })), n = []; return t.forEach((e, o) => { if (o < t.length - 1) { const i = t[o + 1]; n.push({ type: "Feature", id: `${e.positionId}-${i.positionId}`, geometry: { type: "LineString", coordinates: [ [e.longitude, e.latitude], [i.longitude, i.latitude] ] }, properties: { "@id": `${e.positionId}-${i.positionId}`, direction: e.direction, type: "mdss-line" } }); } }), { type: "FeatureCollection", features: [...d, ...n] }; } export { r as mdssPositionsToGeoJson };