From ec988dd35ba5300bec3a0593c58a93f83b11a288 Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 29 Dec 2025 22:09:59 +0000 Subject: [PATCH] Fix ground track line crossing antimeridian MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Split pass ground track at 180° longitude crossings to prevent lines being drawn across the entire map. --- templates/satellite_dashboard.html | 39 ++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/templates/satellite_dashboard.html b/templates/satellite_dashboard.html index 8c431d8..44cf690 100644 --- a/templates/satellite_dashboard.html +++ b/templates/satellite_dashboard.html @@ -1165,14 +1165,39 @@ if (orbitTrack) groundMap.removeLayer(orbitTrack); if (pass && pass.groundTrack) { - const coords = pass.groundTrack.map(pt => [pt.lat, pt.lon]); + // Split track at antimeridian crossings to avoid lines across map + const segments = []; + let currentSegment = []; - trackLine = L.polyline(coords, { - color: pass.color || '#00d4ff', - weight: 3, - opacity: 0.8, - dashArray: '10, 5' - }).addTo(groundMap); + for (let i = 0; i < pass.groundTrack.length; i++) { + const p = pass.groundTrack[i]; + if (currentSegment.length > 0) { + const prevLon = currentSegment[currentSegment.length - 1][1]; + // If longitude jumps more than 180°, start new segment + if (Math.abs(p.lon - prevLon) > 180) { + if (currentSegment.length > 1) { + segments.push(currentSegment); + } + currentSegment = []; + } + } + currentSegment.push([p.lat, p.lon]); + } + if (currentSegment.length > 1) { + segments.push(currentSegment); + } + + // Draw each segment as separate polyline + trackLine = L.layerGroup(); + segments.forEach(seg => { + L.polyline(seg, { + color: pass.color || '#00d4ff', + weight: 3, + opacity: 0.8, + dashArray: '10, 5' + }).addTo(trackLine); + }); + trackLine.addTo(groundMap); // Current position marker if (pass.currentPos) {