Skip to content

fix: respect an explicit zero observer/timestamp in getSatelliteInfo - #61

Open
DanMat wants to merge 1 commit into
davidcalhoun:mainfrom
DanMat:fix/explicit-zero-observer
Open

fix: respect an explicit zero observer/timestamp in getSatelliteInfo#61
DanMat wants to merge 1 commit into
davidcalhoun:mainfrom
DanMat:fix/explicit-zero-observer

Conversation

@DanMat

@DanMat DanMat commented Aug 19, 2026

Copy link
Copy Markdown

Bug

getSatelliteInfo uses observerLat || default (and the same for observerLng, observerHeight, and rawTimestamp), so an explicitly-passed 0 — a valid observer at the equator / prime meridian / sea level, or the Unix epoch — is silently replaced by the default Santa Cruz observer (36.96°N, −122.03°E, 0.37 km). The function's own docstring example passes 0 for elevation, so the documented usage hits this.

Reproduced locally

Same ISS TLE + timestamp, observer at the origin vs a near-identical point:

observer before after
(0, 0, 0) elev −45.47, az 226.54, range 9634.6 elev −71.00, az 172.10, range 12494.2
(1e-7, 1e-7, 1e-7) elev −71.00, az 172.10, range 12494.2 elev −71.00, az 172.10, range 12494.2

Before, (0,0,0) diverges wildly because it's swapped for the default observer; after, it matches the near-origin result.

Fix

Use nullish coalescing (??) so only undefined falls back to the default. Added a regression test asserting (0,0,0) matches a near-origin observer (placed at the end of the suite so it doesn't perturb the cache-size assertion in the existing clearCache test). Full suite (89 tests) + eslint pass.

Written with AI assistance; I've reviewed and tested the change and will maintain it.

getSatelliteInfo used `observerLat || default` (and the same for lng,
height, and rawTimestamp), so an explicitly-passed 0 — a valid observer
at the equator / prime meridian / sea level, or the Unix epoch — was
silently replaced by the default Santa Cruz observer. The function's own
docstring example passes elevation 0, so the documented usage hit this.

Use nullish coalescing (??) so only undefined falls back to the default.
Adds a regression test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant