diff --git a/expected/epochprop.out b/expected/epochprop.out index 6e10108..f83d488 100644 --- a/expected/epochprop.out +++ b/expected/epochprop.out @@ -1,4 +1,4 @@ -SET extra_float_digits=2; +SET extra_float_digits = 1; SELECT to_char(DEGREES(tp[1]), '999D9999999999'), to_char(DEGREES(tp[2]), '999D9999999999'), @@ -45,9 +45,9 @@ FROM ( NULL, RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), -110, -100) AS tp) AS q; - to_char | to_char | to_char | to_char | to_char | to_char ------------------+-----------------+---------+----------+------------+--------- - 269.4744079540 | 4.4055337210 | | -801.210 | 10361.762 | + to_char | to_char | to_char | to_char | to_char | to_char +-----------------+-----------------+---------+----------+------------+---------- + 269.4744079540 | 4.4055337210 | | -801.210 | 10361.762 | -110.000 (1 row) SELECT diff --git a/sql/epochprop.sql b/sql/epochprop.sql index 4176c55..a6c69dd 100644 --- a/sql/epochprop.sql +++ b/sql/epochprop.sql @@ -1,4 +1,4 @@ -SET extra_float_digits=2; +SET extra_float_digits = 1; SELECT to_char(DEGREES(tp[1]), '999D9999999999'), diff --git a/src/epochprop.c b/src/epochprop.c index ddc28f4..463238e 100644 --- a/src/epochprop.c +++ b/src/epochprop.c @@ -184,6 +184,15 @@ epoch_prop(PG_FUNCTION_ARGS) { propagate_phasevec(&input, delta_t, &output); + /* If we have a null parallax but a good RV, preserve the original, + untransformed RV on output. See + https://github.com/ivoa-std/udf-catalogue/pull/20#issuecomment-2115053757 + for the rationale. */ + if (!PG_ARGISNULL(4) && PG_ARGISNULL(1)) { + output_null[5] = 0; + output.rv = input.rv; + } + /* change to internal units: rad, rad/yr, mas, and km/s */ retvals[0] = Float8GetDatum(output.pos.lng); retvals[1] = Float8GetDatum(output.pos.lat); @@ -191,7 +200,7 @@ epoch_prop(PG_FUNCTION_ARGS) { retvals[3] = Float8GetDatum(output.pm[0]); retvals[4] = Float8GetDatum(output.pm[1]); retvals[5] = Float8GetDatum(output.rv); - + { int lower_bounds[1] = {1}; int dims[1] = {6};