Fix satellite orbit track crossing antimeridian

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 <noreply@anthropic.com>
This commit is contained in:
James Smith
2025-12-22 17:33:33 +00:00
parent 959a1d9f6e
commit d7db623fc4

View File

@@ -13702,12 +13702,39 @@ def satellite_dashboard():
if (trackLine) groundMap.removeLayer(trackLine); if (trackLine) groundMap.removeLayer(trackLine);
trackLine = null; // Clear pass track when showing live orbit trackLine = null; // Clear pass track when showing live orbit
orbitTrack = L.polyline(pos.track.map(p => [p.lat, p.lon]), { // Split track at antimeridian crossings to avoid lines across map
color: satColor, const segments = [];
weight: 2, let currentSegment = [];
opacity: 0.6,
dashArray: '5, 5' for (let i = 0; i < pos.track.length; i++) {
}).addTo(groundMap); 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 // Update polar plot with current position