56 Commits

Author SHA1 Message Date
28511a34a2 Close Craft integration thread — install instructions
Craft-side code is wired up. pg_orbit just needs to be installed on
the Craft database for satellites to appear in /api/sky/up.
2026-02-15 18:33:34 -07:00
2dc90a992e Reply to Craft test data package with verification results
All 8 suggested regression tests pass. Amateur satellite batch
(6 TLEs) propagates cleanly. Report includes 2-D GiST index
upgrade results showing inclination-based pruning with real
satellite data.
2026-02-15 18:26:39 -07:00
3fe11a5d7f Add test data package for Craft integration
ISS reference vectors, edge case TLEs (deep space, Molniya, decayed,
sun-sync, GEO), amateur satellite batch, Skyfield cross-verification
script, and 6 suggested regression SQL tests.
2026-02-15 18:24:59 -07:00
a792e7e083 Extend GiST index to 2-D: altitude + inclination
The 1-D altitude-band index only pruned ~25% of the 22k satellite
catalog (eliminates MEO/GEO/HEO but 75% is LEO).  Adding inclination
as a second indexed dimension prunes an additional ~40% of remaining
candidates — objects in equatorial or low-inclination orbits that
geometrically cannot pass over the observer's latitude.

Key changes:
- tle_alt_range (16 bytes) → tle_orbital_key (32 bytes) with
  inc_low/inc_high fields
- All 8 GiST support functions updated for 2-D bounding boxes
- Penalty uses margin (half-perimeter) not area to avoid degeneracy
  when leaf entries have zero-width inclination ranges
- Picksplit selects split dimension by normalized spread
- && operator now checks altitude AND inclination overlap
- <-> operator remains altitude-only (conjunction screening is
  altitude-dominant)
- SQL operator comments updated for 2-D semantics
- Test adds Equatorial-LEO satellite at ISS altitude but 5° inclination
  to validate inclination-based pruning
2026-02-15 18:10:19 -07:00
5552bf3280 Add convenience functions for Craft integration
Implements 5 new C functions requested by the Craft (Astrolock) API team:
- tle_from_lines(text, text): two-argument TLE constructor
- observer_from_geodetic(float8, float8, float8): numeric observer constructor
- observe(tle, observer, timestamptz): single-call propagate + topocentric
- sgp4_propagate_safe(tle, timestamptz): returns NULL on propagation error
- observe_safe(tle, observer, timestamptz): returns NULL on propagation error

Refactors do_propagate() into safe/unsafe variants to support NULL returns.
Adds regression test (convenience.sql) covering all new functions including
an equivalence test verifying observe() matches the manual two-step pipeline.
All 6 regression tests pass.
2026-02-15 17:44:41 -07:00
15a830dc40 Initial implementation of pg_orbit PostgreSQL extension
6 custom types (tle, eci_position, geodetic, topocentric, observer,
pass_event), 67 SQL functions, 2 operators (&&, <->), and a GiST
operator class for altitude-band indexing. Wraps Bill Gray's sat_code
for SGP4/SDP4 propagation with WGS-72 constants for propagation and
WGS-84 for coordinate output. All 5 regression tests pass on PG 18.
2026-02-15 17:07:07 -07:00