diff --git a/templates/index.html b/templates/index.html
index b3cf7ad..1d05f5b 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -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;
}
diff --git a/templates/satellite_dashboard.html b/templates/satellite_dashboard.html
index a8940eb..edd0fdd 100644
--- a/templates/satellite_dashboard.html
+++ b/templates/satellite_dashboard.html
@@ -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);
}