mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-03-17 03:11:01 +00:00
16 lines
491 B
JavaScript
16 lines
491 B
JavaScript
async function analyzeGPS(readings, boundary) {
|
|
const { booleanPointInPolygon, lineString, length } = await import('https://cdn.skypack.dev/@turf/turf');
|
|
|
|
const valid = readings
|
|
.filter(r => booleanPointInPolygon(r.loc, boundary))
|
|
.sort((a, b) => a.ts - b.ts);
|
|
|
|
if (valid.length < 2) return 0;
|
|
|
|
const dist = length(lineString(valid.map(r => r.loc)), { units: 'kilometers' });
|
|
|
|
return +dist.toFixed(2);
|
|
}
|
|
export default analyzeGPS;
|
|
// Generation time: 1.377s
|
|
// Result: PASS
|