pg_orrery/test/expected/pass_prediction.out
Ryan Malloy 3915d1784f Rename pg_orbit to pg_orrery
An existing product called PG Orbit (a mobile PostgreSQL client)
creates a naming conflict. pg_orrery — a database orrery built from
Keplerian parameters and SQL instead of brass gears.

Build system: control file, Makefile, Dockerfile, docker init script.
C source: GUC prefix, PG_FUNCTION_INFO_V1 symbol, header guards,
ereport prefixes, comments across ~30 files including vendored SGP4.
SQL: all 5 install/migration scripts, function name pg_orrery_ephemeris_info.
Tests: 9 SQL suites, 8 expected outputs, standalone DE reader test.
Documentation: CLAUDE.md, README.md, DESIGN.md, Starlight site infra,
36 MDX pages, OG renderer, logo SVG, docker-compose, agent threads.

All 13 regression suites pass. Docs site builds (37 pages).
2026-02-17 13:36:22 -07:00

92 lines
3.3 KiB
Plaintext

-- Test pass prediction functions
CREATE EXTENSION IF NOT EXISTS pg_orrery;
NOTICE: extension "pg_orrery" already exists, skipping
-- Predict ISS passes over Boulder in 24-hour window
WITH iss AS (
SELECT '1 25544U 98067A 24001.50000000 .00016717 00000-0 10270-3 0 9025
2 25544 51.6400 208.9163 0006703 30.1694 61.7520 15.50100486 00001'::tle AS t
)
SELECT count(*) AS pass_count
FROM iss, predict_passes(t, '40.0N 105.3W 1655m'::observer,
'2024-01-01 12:00:00+00', '2024-01-02 12:00:00+00');
pass_count
------------
7
(1 row)
-- Pass details: max elevation should be positive, duration reasonable
WITH iss AS (
SELECT '1 25544U 98067A 24001.50000000 .00016717 00000-0 10270-3 0 9025
2 25544 51.6400 208.9163 0006703 30.1694 61.7520 15.50100486 00001'::tle AS t
)
SELECT
round(pass_max_elevation(p)::numeric, 1) AS max_el,
pass_aos_time(p) < pass_max_el_time(p) AS aos_before_max,
pass_max_el_time(p) < pass_los_time(p) AS max_before_los,
pass_aos_azimuth(p) >= 0 AND pass_aos_azimuth(p) <= 360 AS az_valid,
extract(epoch from pass_duration(p)) BETWEEN 60 AND 900 AS duration_ok
FROM iss, predict_passes(t, '40.0N 105.3W 1655m'::observer,
'2024-01-01 12:00:00+00', '2024-01-02 12:00:00+00') AS p
LIMIT 3;
max_el | aos_before_max | max_before_los | az_valid | duration_ok
--------+----------------+----------------+----------+-------------
3.3 | t | t | t | t
46.4 | t | t | t | t
24.4 | t | t | t | t
(3 rows)
-- next_pass returns same first pass as predict_passes
WITH iss AS (
SELECT '1 25544U 98067A 24001.50000000 .00016717 00000-0 10270-3 0 9025
2 25544 51.6400 208.9163 0006703 30.1694 61.7520 15.50100486 00001'::tle AS t
),
np AS (
SELECT next_pass(t, '40.0N 105.3W 1655m'::observer, '2024-01-01 12:00:00+00') AS p FROM iss
),
pp AS (
SELECT p AS pass FROM iss, predict_passes(t, '40.0N 105.3W 1655m'::observer,
'2024-01-01 12:00:00+00', '2024-01-02 12:00:00+00') AS p
LIMIT 1
)
SELECT
pass_aos_time(np.p) = pass_aos_time(pp.pass) AS same_aos
FROM np, pp;
same_aos
----------
t
(1 row)
-- pass_visible should be true for ISS over Boulder in a 24h window
WITH iss AS (
SELECT '1 25544U 98067A 24001.50000000 .00016717 00000-0 10270-3 0 9025
2 25544 51.6400 208.9163 0006703 30.1694 61.7520 15.50100486 00001'::tle AS t
)
SELECT pass_visible(t, '40.0N 105.3W 1655m'::observer,
'2024-01-01 12:00:00+00', '2024-01-02 12:00:00+00') AS visible
FROM iss;
visible
---------
t
(1 row)
-- Minimum elevation filter should reduce pass count
WITH iss AS (
SELECT '1 25544U 98067A 24001.50000000 .00016717 00000-0 10270-3 0 9025
2 25544 51.6400 208.9163 0006703 30.1694 61.7520 15.50100486 00001'::tle AS t
),
all_passes AS (
SELECT count(*) AS total FROM iss, predict_passes(t, '40.0N 105.3W 1655m'::observer,
'2024-01-01 12:00:00+00', '2024-01-02 12:00:00+00')
),
high_passes AS (
SELECT count(*) AS high FROM iss, predict_passes(t, '40.0N 105.3W 1655m'::observer,
'2024-01-01 12:00:00+00', '2024-01-02 12:00:00+00', 30.0)
)
SELECT high <= total AS filter_works
FROM all_passes, high_passes;
filter_works
--------------
t
(1 row)