Skip to content

Commit 3366ce3

Browse files
committed
PM nulling bugfix after @vitcpp's PR review.
(and a few minor editorial changes)
1 parent 453990f commit 3366ce3

File tree

3 files changed

+5
-21
lines changed

3 files changed

+5
-21
lines changed

expected/epochprop.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ FROM (
8181
120) AS tp) AS q;
8282
to_char | to_char | to_char | to_char | to_char | to_char
8383
-----------------+-----------------+----------+---------+---------+----------
84-
269.4520769500 | 5.0388680565 | 23.007 | | | -97.120
84+
269.4520769500 | 4.6933649660 | 23.007 | | | -110.000
8585
(1 row)
8686

8787
SELECT epoch_prop(NULL,

src/epochprop.c

+3-10
Original file line numberDiff line numberDiff line change
@@ -144,28 +144,21 @@ epoch_prop(PG_FUNCTION_ARGS) {
144144
input.parallax = 0;
145145
output_null[2] = 1;
146146
/* The way we do our computation, with a bad parallax the RV
147-
will be horribly off, too, so null this out, too */
147+
will be horribly off, too, so null this out, too; if avaialble,
148+
we will fiddle in the original RV below again. */
148149
output_null[5] = 1;
149150
} else {
150151
input.parallax = PG_GETARG_FLOAT8(1);
151152
}
152153
input.parallax_valid = fabs(input.parallax) > PX_MIN;
153154

154-
if (PG_ARGISNULL(2)) {
155+
if (PG_ARGISNULL(2) || PG_ARGISNULL(3)) {
155156
input.pm[0] = 0;
156157
input.pm[1] = 0;
157158
output_null[3] = 1;
158159
output_null[4] = 1;
159160
} else {
160161
input.pm[0] = PG_GETARG_FLOAT8(2);
161-
}
162-
163-
if (PG_ARGISNULL(3)) {
164-
input.pm[0] = 0;
165-
input.pm[1] = 0;
166-
output_null[3] = 1;
167-
output_null[4] = 1;
168-
} else {
169162
input.pm[1] = PG_GETARG_FLOAT8(3);
170163
}
171164

src/epochprop.h

+1-10
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,12 @@
66
extern Datum epoch_prop(PG_FUNCTION_ARGS);
77

88

9-
/* a cartesian point; this is like geo_decl's point, but you can't
10-
have both geo_decls and pg_sphere right now (both define a type Point,
11-
not to mention they have different ideas on EPSILON */
12-
typedef struct s_cpoint
13-
{
14-
double x,
15-
y;
16-
} CPoint;
17-
189
typedef struct s_phasevec
1910
{
2011
SPoint pos; /* Position as an SPoint */
2112
double pm[2]; /* Proper motion long/lat in rad/year, PM in
2213
* longitude has cos(lat) applied */
2314
double parallax; /* in rad */
2415
double rv; /* radial velocity in km/s */
25-
int parallax_valid; /* 1 if the parallax really is a NULL */
16+
int parallax_valid; /* 1 if we accept the parallax as physical */
2617
} phasevec;

0 commit comments

Comments
 (0)