mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-08-28 04:45:42 +00:00
16 lines
501 B
JavaScript
16 lines
501 B
JavaScript
export async function analyzeGPS(readings, boundary) {
|
|
const { booleanPointInPolygon, lineString, length } = await import('https://esm.sh/@turf/turf');
|
|
|
|
const pts = readings
|
|
.filter(r => booleanPointInPolygon(r.loc, boundary))
|
|
.sort((a, b) => a.ts - b.ts)
|
|
.map(r => r.loc);
|
|
|
|
if (pts.length < 2) return 0;
|
|
|
|
const totalLength = length(lineString(pts), { units: 'kilometers' });
|
|
return +totalLength.toFixed(2);
|
|
}
|
|
export default analyzeGPS;
|
|
// Generation time: 9.365s
|
|
// Result: PASS
|