From d7db623fc4e3ac31b8ef7bc8fa1fef104b4d670b Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 22 Dec 2025 17:33:33 +0000 Subject: [PATCH] Fix satellite orbit track crossing antimeridian MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Split orbit track into segments when longitude jumps > 180° to prevent Leaflet from drawing lines across the entire map at the antimeridian. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- intercept.py | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/intercept.py b/intercept.py index ab51dd4..6f04c65 100755 --- a/intercept.py +++ b/intercept.py @@ -13702,12 +13702,39 @@ def satellite_dashboard(): if (trackLine) groundMap.removeLayer(trackLine); trackLine = null; // Clear pass track when showing live orbit - orbitTrack = L.polyline(pos.track.map(p => [p.lat, p.lon]), { - color: satColor, - weight: 2, - opacity: 0.6, - dashArray: '5, 5' - }).addTo(groundMap); + // Split track at antimeridian crossings to avoid lines across map + const segments = []; + let currentSegment = []; + + for (let i = 0; i < pos.track.length; i++) { + const p = pos.track[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 + orbitTrack = L.layerGroup(); + segments.forEach(seg => { + L.polyline(seg, { + color: satColor, + weight: 2, + opacity: 0.6, + dashArray: '5, 5' + }).addTo(orbitTrack); + }); + orbitTrack.addTo(groundMap); } // Update polar plot with current position