summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitrii Morozov <snoopdesigns@gmail.com>2025-05-04 23:28:29 +0200
committerDmitrii Morozov <snoopdesigns@gmail.com>2025-05-04 23:28:29 +0200
commit544366425ec79069f67a75f824b8619c34a5a28b (patch)
treec5bd4d3ecc25bd0e2b5fd8ef03a243a13d292d98
parent4870596d0f3c8f812e0684faa906d6afe79ae01e (diff)
Smart reroute fix
-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";