mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-06-07 20:12:13 +00:00
12 lines
492 B
JavaScript
12 lines
492 B
JavaScript
async function analyzeGPS(readings, boundary) {
|
|
const turf = await import("https://cdn.skypack.dev/@turf/turf");
|
|
const inside = readings
|
|
.filter((r) => turf.booleanPointInPolygon(turf.point(r.loc), boundary))
|
|
.sort((a, b) => a.ts - b.ts);
|
|
if (inside.length < 2) return 0;
|
|
const line = turf.lineString(inside.map((r) => r.loc));
|
|
return Math.round(turf.length(line, { units: "kilometers" }) * 100) / 100;
|
|
}
|
|
export default analyzeGPS;
|
|
// Generation time: 2.996s
|
|
// Result: FAIL
|