pg_orrery/sql/pg_orrery--0.10.0--0.11.0.sql
Ryan Malloy 9158c7c55a Add v0.11.0: make_orbital_elements constructors + moon equatorial functions
6 new SQL functions (114 -> 120):
- make_orbital_elements(): construct from 9 floats, angles in radians
- make_orbital_elements_deg(): same with angles in degrees, matches
  text I/O convention and typical catalog column layouts
- galilean_equatorial(): geocentric RA/Dec for Io/Europa/Ganymede/Callisto
- saturn_moon_equatorial(): geocentric RA/Dec for Mimas through Hyperion
- uranus_moon_equatorial(): geocentric RA/Dec for Miranda through Oberon
- mars_moon_equatorial(): geocentric RA/Dec for Phobos/Deimos

Constructors requested by astrolock-api to replace fragile
format(9 args)::orbital_elements cast pattern. Moon equatorial
functions fill the last NULL RA/Dec gaps in their unified sky query.

All 20 regression suites pass.
2026-02-23 14:07:39 -07:00

52 lines
2.6 KiB
SQL

-- pg_orrery 0.10.0 -> 0.11.0 migration
--
-- Adds make_orbital_elements() constructors and
-- geocentric equatorial functions for planetary moons.
-- ============================================================
-- orbital_elements constructors
-- ============================================================
CREATE FUNCTION make_orbital_elements(
epoch_jd float8, q_au float8, e float8,
inc_rad float8, omega_rad float8, node_rad float8,
tp_jd float8, h_mag float8, g_slope float8
) RETURNS orbital_elements
AS 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
COMMENT ON FUNCTION make_orbital_elements(float8,float8,float8,float8,float8,float8,float8,float8,float8) IS
'Construct orbital_elements from 9 floats (angular elements in radians).';
CREATE FUNCTION make_orbital_elements_deg(
epoch_jd float8, q_au float8, e float8,
inc_deg float8, omega_deg float8, node_deg float8,
tp_jd float8, h_mag float8, g_slope float8
) RETURNS orbital_elements
AS 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
COMMENT ON FUNCTION make_orbital_elements_deg(float8,float8,float8,float8,float8,float8,float8,float8,float8) IS
'Construct orbital_elements from 9 floats (angular elements in degrees). Matches text I/O and most catalog column layouts.';
-- ============================================================
-- Planetary moon equatorial functions
-- ============================================================
CREATE FUNCTION galilean_equatorial(int4, timestamptz) RETURNS equatorial
AS 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
COMMENT ON FUNCTION galilean_equatorial(int4, timestamptz) IS
'Geocentric RA/Dec of a Galilean moon (0=Io, 1=Europa, 2=Ganymede, 3=Callisto). L1.2 theory + VSOP87.';
CREATE FUNCTION saturn_moon_equatorial(int4, timestamptz) RETURNS equatorial
AS 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
COMMENT ON FUNCTION saturn_moon_equatorial(int4, timestamptz) IS
'Geocentric RA/Dec of a Saturn moon (0=Mimas..7=Hyperion). TASS17 theory + VSOP87.';
CREATE FUNCTION uranus_moon_equatorial(int4, timestamptz) RETURNS equatorial
AS 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
COMMENT ON FUNCTION uranus_moon_equatorial(int4, timestamptz) IS
'Geocentric RA/Dec of a Uranus moon (0=Miranda..4=Oberon). GUST86 theory + VSOP87.';
CREATE FUNCTION mars_moon_equatorial(int4, timestamptz) RETURNS equatorial
AS 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
COMMENT ON FUNCTION mars_moon_equatorial(int4, timestamptz) IS
'Geocentric RA/Dec of a Mars moon (0=Phobos, 1=Deimos). MarsSat theory + VSOP87.';