mirror of
https://github.com/smittix/intercept.git
synced 2026-04-24 06:40:00 -07:00
Fix orbit track splitting to only occur at true antimeridian crossings
The previous logic split the track whenever longitude jumped by more than 180°, which could happen in cases other than actual antimeridian crossings, causing gaps in the middle of the orbit track. New logic only splits when one longitude is > 90° and the other is < -90°, which specifically identifies crossings of the ±180° line. Also changed segment minimum from 2 to 1 point to preserve all data. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8380,21 +8380,23 @@
|
||||
pastOrbitLine = null;
|
||||
}
|
||||
|
||||
// Split ground track at antimeridian crossings
|
||||
// Split ground track only at true antimeridian crossings (±180° line)
|
||||
const segments = [];
|
||||
let currentSegment = [];
|
||||
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 (Math.abs(p.lon - prevLon) > 180) {
|
||||
if (currentSegment.length > 1) segments.push(currentSegment);
|
||||
// Only split when crossing the antimeridian (one side > 90, other < -90)
|
||||
const crossesAntimeridian = (prevLon > 90 && p.lon < -90) || (prevLon < -90 && p.lon > 90);
|
||||
if (crossesAntimeridian) {
|
||||
if (currentSegment.length >= 1) segments.push(currentSegment);
|
||||
currentSegment = [];
|
||||
}
|
||||
}
|
||||
currentSegment.push([p.lat, p.lon]);
|
||||
}
|
||||
if (currentSegment.length > 1) segments.push(currentSegment);
|
||||
if (currentSegment.length >= 1) segments.push(currentSegment);
|
||||
|
||||
// Draw ground track segments
|
||||
groundTrackLine = L.layerGroup();
|
||||
@@ -8510,7 +8512,7 @@
|
||||
const pastPoints = orbitData.filter(p => p.past);
|
||||
const futurePoints = orbitData.filter(p => !p.past);
|
||||
|
||||
// Helper to split coords at antimeridian crossings
|
||||
// Helper to split coords only at true antimeridian crossings (±180° line)
|
||||
function splitAtAntimeridian(points) {
|
||||
const segments = [];
|
||||
let currentSegment = [];
|
||||
@@ -8518,15 +8520,16 @@
|
||||
const p = points[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);
|
||||
// Only split when crossing the antimeridian (one side > 90, other < -90)
|
||||
const crossesAntimeridian = (prevLon > 90 && p.lon < -90) || (prevLon < -90 && p.lon > 90);
|
||||
if (crossesAntimeridian) {
|
||||
if (currentSegment.length >= 1) segments.push(currentSegment);
|
||||
currentSegment = [];
|
||||
}
|
||||
}
|
||||
currentSegment.push([p.lat, p.lon]);
|
||||
}
|
||||
if (currentSegment.length > 1) segments.push(currentSegment);
|
||||
if (currentSegment.length >= 1) segments.push(currentSegment);
|
||||
return segments;
|
||||
}
|
||||
|
||||
|
||||
@@ -1185,7 +1185,7 @@
|
||||
}
|
||||
|
||||
if (pass && pass.groundTrack) {
|
||||
// Split track at antimeridian crossings to avoid lines across map
|
||||
// Split track only at true antimeridian crossings (±180° line)
|
||||
const segments = [];
|
||||
let currentSegment = [];
|
||||
|
||||
@@ -1193,9 +1193,10 @@
|
||||
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) {
|
||||
// Only split when crossing the antimeridian (one side > 90, other < -90)
|
||||
const crossesAntimeridian = (prevLon > 90 && p.lon < -90) || (prevLon < -90 && p.lon > 90);
|
||||
if (crossesAntimeridian) {
|
||||
if (currentSegment.length >= 1) {
|
||||
segments.push(currentSegment);
|
||||
}
|
||||
currentSegment = [];
|
||||
@@ -1203,7 +1204,7 @@
|
||||
}
|
||||
currentSegment.push([p.lat, p.lon]);
|
||||
}
|
||||
if (currentSegment.length > 1) {
|
||||
if (currentSegment.length >= 1) {
|
||||
segments.push(currentSegment);
|
||||
}
|
||||
|
||||
@@ -1426,7 +1427,7 @@
|
||||
groundMap.removeLayer(orbitTrack);
|
||||
}
|
||||
|
||||
// Split track at antimeridian crossings to avoid lines across map
|
||||
// Split track only at true antimeridian crossings (±180° line)
|
||||
const segments = [];
|
||||
let currentSegment = [];
|
||||
|
||||
@@ -1434,9 +1435,10 @@
|
||||
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 >= 2) {
|
||||
// Only split when crossing the antimeridian (one side > 90, other < -90)
|
||||
const crossesAntimeridian = (prevLon > 90 && p.lon < -90) || (prevLon < -90 && p.lon > 90);
|
||||
if (crossesAntimeridian) {
|
||||
if (currentSegment.length >= 1) {
|
||||
segments.push(currentSegment);
|
||||
}
|
||||
currentSegment = [];
|
||||
@@ -1444,7 +1446,7 @@
|
||||
}
|
||||
currentSegment.push([p.lat, p.lon]);
|
||||
}
|
||||
if (currentSegment.length >= 2) {
|
||||
if (currentSegment.length >= 1) {
|
||||
segments.push(currentSegment);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user