summaryrefslogtreecommitdiff
path: root/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'index.html')
-rwxr-xr-xindex.html16
1 files changed, 15 insertions, 1 deletions
diff --git a/index.html b/index.html
index 00a15a7..d885829 100755
--- a/index.html
+++ b/index.html
@@ -111,7 +111,21 @@
}
}
- const remainingCoords = coords.slice(closestIndex);
+ // After finding closestIndex
+ const lookahead = 10;
+ let forwardIndex = closestIndex;
+
+ for (let i = closestIndex + 1; i < Math.min(closestIndex + lookahead, coords.length); i++) {
+ const [lat, lon] = coords[i].split(',').map(Number);
+ const dist = getDistance(userLat, userLon, lat, lon);
+ // Prefer slightly farther point if it's still reasonably close and farther along
+ if (dist < minDist * 1.5) {
+ forwardIndex = i;
+ minDist = dist;
+ }
+ }
+
+ const remainingCoords = coords.slice(forwardIndex);
const selectedCoords = downsampleWaypoints(remainingCoords);
const startCoord = "Current+Location";