Skip to content

Commit

Permalink
PM nulling bugfix after @vitcpp's PR review.
Browse files Browse the repository at this point in the history
(and a few minor editorial changes)
  • Loading branch information
msdemlei committed May 24, 2024
1 parent 453990f commit 3366ce3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
2 changes: 1 addition & 1 deletion expected/epochprop.out
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ FROM (
120) AS tp) AS q;
to_char | to_char | to_char | to_char | to_char | to_char
-----------------+-----------------+----------+---------+---------+----------
269.4520769500 | 5.0388680565 | 23.007 | | | -97.120
269.4520769500 | 4.6933649660 | 23.007 | | | -110.000
(1 row)

SELECT epoch_prop(NULL,
Expand Down
13 changes: 3 additions & 10 deletions src/epochprop.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,28 +144,21 @@ epoch_prop(PG_FUNCTION_ARGS) {
input.parallax = 0;
output_null[2] = 1;
/* The way we do our computation, with a bad parallax the RV
will be horribly off, too, so null this out, too */
will be horribly off, too, so null this out, too; if avaialble,
we will fiddle in the original RV below again. */
output_null[5] = 1;
} else {
input.parallax = PG_GETARG_FLOAT8(1);
}
input.parallax_valid = fabs(input.parallax) > PX_MIN;

if (PG_ARGISNULL(2)) {
if (PG_ARGISNULL(2) || PG_ARGISNULL(3)) {
input.pm[0] = 0;
input.pm[1] = 0;
output_null[3] = 1;
output_null[4] = 1;
} else {
input.pm[0] = PG_GETARG_FLOAT8(2);
}

if (PG_ARGISNULL(3)) {
input.pm[0] = 0;
input.pm[1] = 0;
output_null[3] = 1;
output_null[4] = 1;
} else {
input.pm[1] = PG_GETARG_FLOAT8(3);
}

Expand Down
11 changes: 1 addition & 10 deletions src/epochprop.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,12 @@
extern Datum epoch_prop(PG_FUNCTION_ARGS);


/* a cartesian point; this is like geo_decl's point, but you can't
have both geo_decls and pg_sphere right now (both define a type Point,
not to mention they have different ideas on EPSILON */
typedef struct s_cpoint
{
double x,
y;
} CPoint;

typedef struct s_phasevec
{
SPoint pos; /* Position as an SPoint */
double pm[2]; /* Proper motion long/lat in rad/year, PM in
* longitude has cos(lat) applied */
double parallax; /* in rad */
double rv; /* radial velocity in km/s */
int parallax_valid; /* 1 if the parallax really is a NULL */
int parallax_valid; /* 1 if we accept the parallax as physical */
} phasevec;

0 comments on commit 3366ce3

Please sign in to comment.