fix(map): connect legs whose endpoints sit on different GPX files

intelligent_gpx mode required BOTH endpoints of a leg to be near the SAME
GPX file before treating it as covered. This trip's routes are one
contiguous chain recorded a day per file (…-to-X.gpx, X-to-….gpx), so any
leg spanning a file boundary — an unblogged intermediate stop — read as
uncovered and got a straight connector drawn over an already-GPX-covered
path.

Each endpoint now only has to be near some file. The trade is that a real
gap (flight, train transfer) whose endpoints each sit on their own track
also reads as covered and gets no connector; that case is not detectable
from proximity alone, and `force_connect: true` on the entry after the gap
already handles it.

js/map.js is the rebuilt bundle (make build-assets), not a hand-edit.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-24 23:27:01 +02:00
co-authored by Claude Opus 5
parent 4721af6452
commit 47ec72fa1d
2 changed files with 23 additions and 12 deletions
+18 -7
View File
@@ -259,15 +259,26 @@
} else if (!trackpointsPerFile || trackpointsPerFile.length === 0) {
connect = true; /* no GPX present → connect all */
} else {
var prev = entries[i - 1];
var covered = false;
var prev = entries[i - 1];
// Each endpoint just needs to be near SOME GPX file, not necessarily
// the same one — a leg can legitimately span two consecutive files
// (e.g. an unblogged intermediate stop splits one route in two).
// Requiring one shared file used to draw a straight connector straight
// over an already-GPX-covered path, since this trip's routes are one
// contiguous chain recorded a day per file (…-to-X.gpx, X-to-….gpx).
//
// The trade: two endpoints each near a DIFFERENT track now read as
// covered even when there is a real gap between them (a flight or a
// train transfer), so no connector is drawn across it. That case is
// not detectable from proximity alone — mark the entry after the gap
// `force_connect: true` and the branch above handles it.
var prevNear = false, currNear = false;
for (var f = 0; f < trackpointsPerFile.length; f++) {
if (isNearTrack(parseFloat(prev.lat), parseFloat(prev.lng), trackpointsPerFile[f], 10) &&
isNearTrack(parseFloat(e.lat), parseFloat(e.lng), trackpointsPerFile[f], 10)) {
covered = true; break;
}
if (!prevNear && isNearTrack(parseFloat(prev.lat), parseFloat(prev.lng), trackpointsPerFile[f], 10)) prevNear = true;
if (!currNear && isNearTrack(parseFloat(e.lat), parseFloat(e.lng), trackpointsPerFile[f], 10)) currNear = true;
if (prevNear && currNear) break;
}
connect = !covered;
connect = !(prevNear && currNear);
}
}