Integrate IAU 2000B nutation (~9 arcsec) into the solar system observation pipeline via precess_and_nutate_j2000_to_date(). Affects all planet, star, moon, and small body RA/Dec and az/el values. Satellite SGP4/TEME pipeline unchanged. Add make_equatorial(ra_hours, dec_deg, distance_km) constructor to replace error-prone text literal casts. Add 8 rise/set prediction functions (planet_next_rise/set, sun_next_rise/set, moon_next_rise/set, sun_next_rise/set_refracted) using bisection algorithm adapted from satellite pass prediction. Returns NULL for circumpolar and polar night edge cases. Fix DE fallback test fragility: replace exact float equality with tolerance comparisons to handle GCC LTO inlining divergence across translation units. 132 -> 141 SQL objects. 22 -> 24 regression suites. All 24 passing.
97 lines
3.3 KiB
Plaintext
97 lines
3.3 KiB
Plaintext
-- v013_features.sql -- Tests for v0.13.0: make_equatorial constructor
|
|
--
|
|
-- Verifies that make_equatorial() produces the same result as text
|
|
-- literal casting, validates input bounds, and round-trips correctly.
|
|
-- Load the extension
|
|
CREATE EXTENSION IF NOT EXISTS pg_orrery;
|
|
NOTICE: extension "pg_orrery" already exists, skipping
|
|
-- ============================================================
|
|
-- make_equatorial() constructor
|
|
-- ============================================================
|
|
-- Basic construction and accessor round-trip
|
|
SELECT eq_ra(make_equatorial(6.75, 45.0, 1000.0)) AS ra_hours;
|
|
ra_hours
|
|
-------------------
|
|
6.749999999999999
|
|
(1 row)
|
|
|
|
SELECT eq_dec(make_equatorial(6.75, 45.0, 1000.0)) AS dec_deg;
|
|
dec_deg
|
|
---------
|
|
45
|
|
(1 row)
|
|
|
|
SELECT eq_distance(make_equatorial(6.75, 45.0, 1000.0)) AS dist_km;
|
|
dist_km
|
|
---------
|
|
1000
|
|
(1 row)
|
|
|
|
-- Compare with text literal cast (must match)
|
|
SELECT make_equatorial(6.75, 45.0, 1000.0)::text = '(6.75000000,45.00000000,1000.000)'::equatorial::text
|
|
AS constructor_matches_literal;
|
|
constructor_matches_literal
|
|
-----------------------------
|
|
t
|
|
(1 row)
|
|
|
|
-- Edge cases: RA boundaries
|
|
SELECT make_equatorial(0.0, 0.0, 0.0) IS NOT NULL AS ra_zero;
|
|
ra_zero
|
|
---------
|
|
t
|
|
(1 row)
|
|
|
|
SELECT make_equatorial(23.99999999, 0.0, 0.0) IS NOT NULL AS ra_max;
|
|
ra_max
|
|
--------
|
|
t
|
|
(1 row)
|
|
|
|
-- Edge cases: Dec boundaries
|
|
SELECT make_equatorial(12.0, -90.0, 0.0) IS NOT NULL AS dec_south_pole;
|
|
dec_south_pole
|
|
----------------
|
|
t
|
|
(1 row)
|
|
|
|
SELECT make_equatorial(12.0, 90.0, 0.0) IS NOT NULL AS dec_north_pole;
|
|
dec_north_pole
|
|
----------------
|
|
t
|
|
(1 row)
|
|
|
|
-- Edge cases: zero distance (stars)
|
|
SELECT eq_distance(make_equatorial(12.0, 45.0, 0.0)) AS zero_distance;
|
|
zero_distance
|
|
---------------
|
|
0
|
|
(1 row)
|
|
|
|
-- Negative distance (allowed -- could represent parallax distance in km)
|
|
SELECT eq_distance(make_equatorial(12.0, 45.0, -1000.0)) AS negative_distance;
|
|
negative_distance
|
|
-------------------
|
|
-1000
|
|
(1 row)
|
|
|
|
-- ============================================================
|
|
-- Error cases
|
|
-- ============================================================
|
|
-- RA out of range (must fail)
|
|
\set ON_ERROR_ROLLBACK on
|
|
DO $$ BEGIN PERFORM make_equatorial(24.0, 0.0, 0.0); EXCEPTION WHEN OTHERS THEN RAISE NOTICE 'ra=24: %', SQLERRM; END $$;
|
|
NOTICE: ra=24: right ascension out of range: 24.000000
|
|
DO $$ BEGIN PERFORM make_equatorial(-0.1, 0.0, 0.0); EXCEPTION WHEN OTHERS THEN RAISE NOTICE 'ra=-0.1: %', SQLERRM; END $$;
|
|
NOTICE: ra=-0.1: right ascension out of range: -0.100000
|
|
-- Dec out of range (must fail)
|
|
DO $$ BEGIN PERFORM make_equatorial(12.0, 90.1, 0.0); EXCEPTION WHEN OTHERS THEN RAISE NOTICE 'dec=90.1: %', SQLERRM; END $$;
|
|
NOTICE: dec=90.1: declination out of range: 90.100000
|
|
DO $$ BEGIN PERFORM make_equatorial(12.0, -90.1, 0.0); EXCEPTION WHEN OTHERS THEN RAISE NOTICE 'dec=-90.1: %', SQLERRM; END $$;
|
|
NOTICE: dec=-90.1: declination out of range: -90.100000
|
|
-- NaN and Inf (must fail)
|
|
DO $$ BEGIN PERFORM make_equatorial('NaN'::float8, 0.0, 0.0); EXCEPTION WHEN OTHERS THEN RAISE NOTICE 'ra=NaN: %', SQLERRM; END $$;
|
|
NOTICE: ra=NaN: make_equatorial: RA and Dec must be finite
|
|
DO $$ BEGIN PERFORM make_equatorial(12.0, 'Infinity'::float8, 0.0); EXCEPTION WHEN OTHERS THEN RAISE NOTICE 'dec=Inf: %', SQLERRM; END $$;
|
|
NOTICE: dec=Inf: make_equatorial: RA and Dec must be finite
|