Add Universal Variable Lambert solver for computing transfer orbits between any two planets. Enables pork chop plot generation as SQL: SELECT dep_date, arr_date, lambert_c3(3, 4, dep_date, arr_date) FROM generate_series(...) dep CROSS JOIN generate_series(...) arr; New functions: - lambert_transfer(dep_body, arr_body, dep_time, arr_time) → RECORD Returns C3 departure/arrival (km^2/s^2), v_infinity (km/s), time of flight (days), and transfer orbit SMA (AU). - lambert_c3(dep_body, arr_body, dep_time, arr_time) → float8 Convenience: departure C3 only, NULL on solver failure. The solver uses Stumpff functions for unified elliptic/parabolic/hyperbolic handling, with Newton-Raphson iteration and bisection fallback. Each solve is sub-millisecond; PARALLEL SAFE for batch computation. All 11 regression tests pass.
74 lines
2.7 KiB
Makefile
74 lines
2.7 KiB
Makefile
MODULE_big = pg_orbit
|
|
EXTENSION = pg_orbit
|
|
DATA = sql/pg_orbit--0.1.0.sql sql/pg_orbit--0.2.0.sql sql/pg_orbit--0.1.0--0.2.0.sql
|
|
|
|
# Our extension C sources
|
|
OBJS = src/pg_orbit.o src/tle_type.o src/eci_type.o src/observer_type.o \
|
|
src/sgp4_funcs.o src/coord_funcs.o src/pass_funcs.o src/gist_tle.o \
|
|
src/star_funcs.o src/kepler_funcs.o \
|
|
src/vsop87.o src/elp82b.o src/elliptic_to_rectangular.o \
|
|
src/precession.o src/sidereal_time.o src/planet_funcs.o \
|
|
src/tass17.o src/gust86.o src/marssat.o src/l12.o \
|
|
src/moon_funcs.o src/radio_funcs.o \
|
|
src/lambert.o src/transfer_funcs.o
|
|
|
|
# sat_code C++ sources (compiled with g++, linked with extern "C" symbols)
|
|
SAT_CODE_DIR = lib/sat_code
|
|
SAT_CODE_SRCS = $(SAT_CODE_DIR)/sgp4.cpp $(SAT_CODE_DIR)/sdp4.cpp \
|
|
$(SAT_CODE_DIR)/deep.cpp $(SAT_CODE_DIR)/common.cpp \
|
|
$(SAT_CODE_DIR)/basics.cpp $(SAT_CODE_DIR)/get_el.cpp \
|
|
$(SAT_CODE_DIR)/tle_out.cpp
|
|
SAT_CODE_OBJS = $(SAT_CODE_SRCS:.cpp=.o)
|
|
|
|
OBJS += $(SAT_CODE_OBJS)
|
|
|
|
# Regression tests
|
|
REGRESS = tle_parse sgp4_propagate coord_transforms pass_prediction gist_index convenience \
|
|
star_observe kepler_comet planet_observe moon_observe lambert_transfer
|
|
REGRESS_OPTS = --inputdir=test
|
|
|
|
# Need C++ runtime for sat_code
|
|
SHLIB_LINK += -lstdc++ -lm
|
|
|
|
# Compiler flags
|
|
PG_CPPFLAGS = -I$(SAT_CODE_DIR)
|
|
|
|
# Use PGXS
|
|
PG_CONFIG ?= pg_config
|
|
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
|
include $(PGXS)
|
|
|
|
# Rule for compiling sat_code C++ files
|
|
$(SAT_CODE_DIR)/%.o: $(SAT_CODE_DIR)/%.cpp
|
|
$(CXX) $(CXXFLAGS) -fPIC -I$(SAT_CODE_DIR) -c -o $@ $<
|
|
|
|
# ── Docker packaging ────────────────────────────────────────
|
|
REGISTRY ?= git.supported.systems/warehack.ing
|
|
IMAGE ?= pg_orbit
|
|
PG_MAJOR ?= 17
|
|
TAG ?= pg$(PG_MAJOR)
|
|
|
|
docker-build:
|
|
docker build --build-arg PG_MAJOR=$(PG_MAJOR) \
|
|
--target artifact -t $(REGISTRY)/$(IMAGE):$(TAG)-artifact .
|
|
docker build --build-arg PG_MAJOR=$(PG_MAJOR) \
|
|
--target standalone -t $(REGISTRY)/$(IMAGE):$(TAG) .
|
|
|
|
docker-push:
|
|
docker push $(REGISTRY)/$(IMAGE):$(TAG)-artifact
|
|
docker push $(REGISTRY)/$(IMAGE):$(TAG)
|
|
|
|
docker-test:
|
|
@echo "Smoke-testing standalone image..."
|
|
docker run --rm -d --name pg_orbit_test \
|
|
-e POSTGRES_PASSWORD=test $(REGISTRY)/$(IMAGE):$(TAG)
|
|
@echo "Waiting for PostgreSQL to initialize..."
|
|
@sleep 10
|
|
docker exec pg_orbit_test psql -U postgres -tAc \
|
|
"SELECT tle_norad_id(E'1 25544U 98067A 24001.50000000 .00016717 00000-0 10270-3 0 9025\n2 25544 51.6400 208.9163 0006703 30.1694 61.7520 15.50100486 00001'::tle);" \
|
|
| grep -q 25544
|
|
@docker stop pg_orbit_test
|
|
@echo "Smoke test passed."
|
|
|
|
.PHONY: docker-build docker-push docker-test
|