From 31a9f54eff82964432818a3c6a3e9c62470adac8 Mon Sep 17 00:00:00 2001 From: Theodore Kruczek Date: Fri, 27 Oct 2023 18:12:41 -0400 Subject: [PATCH] fix: :bug: fix getGroundTracks stopping short of antemeridian (#44) fixes issue #43 --- __tests__/sgp4.js | 3 ++- src/sgp4.js | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/__tests__/sgp4.js b/__tests__/sgp4.js index b4df440..52c628e 100644 --- a/__tests__/sgp4.js +++ b/__tests__/sgp4.js @@ -324,7 +324,8 @@ describe("problematic TLES (geosync, decayed)", () => { tle: tleStr, startTimeMS: timestamp }); - expect(result.length).toEqual(6001); + // Time until it reaches the antemeridian + expect(result.length).toEqual(172809); }); test("getGroundTracks", async () => { diff --git a/src/sgp4.js b/src/sgp4.js index 79a89bd..eeedc1f 100644 --- a/src/sgp4.js +++ b/src/sgp4.js @@ -390,11 +390,13 @@ export async function getOrbitTrack({ stepMS = 1000, sleepMS = 0, jobChunkSize = 1000, - maxTimeMS = 6000000, + maxTimeMS, isLngLatFormat = true }) { const { tle: tleArr } = parseTLE(tle); + maxTimeMS ??= getAverageOrbitTimeMS(tleArr) * 1.5; + const startS = (startTimeMS / 1000).toFixed(); const cacheKey = `${tleArr[0]}-${startS}-${stepMS}-${isLngLatFormat}`; if (cachedOrbitTracks[cacheKey]) {