mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-04-27 19:52:14 +00:00
8 lines
455 B
JavaScript
8 lines
455 B
JavaScript
const analyzeGPS = async (readings, boundary) => {
|
|
const { booleanPointInPolygon, lineString, length } = await import('https://esm.sh/@turf/turf');
|
|
const v = readings.filter(r => booleanPointInPolygon(r.loc, boundary, { ignoreBoundary: true })).sort((a, b) => a.ts - b.ts);
|
|
return v.length < 2 ? 0 : +length(lineString(v.map(r => r.loc)), { units: 'kilometers' }).toFixed(2);
|
|
};
|
|
export default analyzeGPS;
|
|
// Generation time: 74.841s
|
|
// Result: PASS
|