aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2018-04-22 22:39:57 +0200
committerKristian Evers <kristianevers@gmail.com>2018-04-23 10:26:14 +0200
commit6f640d76e13cb643574b44b7498d51ecff6fb83e (patch)
treeac17c997cf7efcea8854e3e1a616ede93ea07ebf /src
parente197e40e9b9ae99b8dac569428af35036822dca2 (diff)
downloadPROJ-6f640d76e13cb643574b44b7498d51ecff6fb83e.tar.gz
PROJ-6f640d76e13cb643574b44b7498d51ecff6fb83e.zip
Add isnan() to proj_math.h
Code updated to use isnan() instead of pj_is_nan().
Diffstat (limited to 'src')
-rw-r--r--src/PJ_robin.c5
-rw-r--r--src/geodesic.c3
-rw-r--r--src/nad_intr.c5
-rw-r--r--src/pj_apply_vgridshift.c4
-rw-r--r--src/pj_internal.c16
-rw-r--r--src/pj_math.c7
-rw-r--r--src/proj_math.h2
7 files changed, 17 insertions, 25 deletions
diff --git a/src/PJ_robin.c b/src/PJ_robin.c
index 92aebfd3..a1d5ad4d 100644
--- a/src/PJ_robin.c
+++ b/src/PJ_robin.c
@@ -1,4 +1,5 @@
#define PJ_LIB__
+#include "proj_math.h"
#include "proj_internal.h"
#include "proj.h"
#include "projects.h"
@@ -82,7 +83,7 @@ static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
(void) P;
dphi = fabs(lp.phi);
- i = pj_is_nan(lp.phi) ? -1 : (int)floor(dphi * C1);
+ i = isnan(lp.phi) ? -1 : (int)floor(dphi * C1);
if( i < 0 ){
proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION);
return xy;
@@ -117,7 +118,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
}
} else { /* general problem */
/* in Y space, reduce to table interval */
- i = pj_is_nan(lp.phi) ? -1 : (int)floor(lp.phi * NODES);
+ i = isnan(lp.phi) ? -1 : (int)floor(lp.phi * NODES);
if( i < 0 || i >= NODES ) {
proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION);
return lp;
diff --git a/src/geodesic.c b/src/geodesic.c
index 5cb273ac..9904c7fa 100644
--- a/src/geodesic.c
+++ b/src/geodesic.c
@@ -243,8 +243,7 @@ static void sincosdx(real x, real* sinx, real* cosx) {
r = remquo(x, (real)(90), &q);
#else
r = fmod(x, (real)(360));
- /* check for NaN -- do not use pj_is_nan, since we want geodesic.c not to
- * depend on the rest of proj.4 */
+ /* check for NaN */
q = r == r ? (int)(floor(r / 90 + (real)(0.5))) : 0;
r -= 90 * q;
#endif
diff --git a/src/nad_intr.c b/src/nad_intr.c
index dc245831..80e428ed 100644
--- a/src/nad_intr.c
+++ b/src/nad_intr.c
@@ -1,6 +1,7 @@
/* Determine nad table correction value */
#define PJ_LIB__
#include "proj_internal.h"
+#include "proj_math.h"
#include "projects.h"
LP
@@ -13,9 +14,9 @@ nad_intr(LP t, struct CTABLE *ct) {
int in;
t.lam /= ct->del.lam;
- indx.lam = pj_is_nan(t.lam) ? 0 : (int)floor(t.lam);
+ indx.lam = isnan(t.lam) ? 0 : (int)floor(t.lam);
t.phi /= ct->del.phi;
- indx.phi = pj_is_nan(t.phi) ? 0 : (int)floor(t.phi);
+ indx.phi = isnan(t.phi) ? 0 : (int)floor(t.phi);
frct.lam = t.lam - indx.lam;
frct.phi = t.phi - indx.phi;
diff --git a/src/pj_apply_vgridshift.c b/src/pj_apply_vgridshift.c
index 05803bc8..e7106b25 100644
--- a/src/pj_apply_vgridshift.c
+++ b/src/pj_apply_vgridshift.c
@@ -29,7 +29,7 @@
#define PJ_LIB__
#include <string.h>
-#include <math.h>
+#include "proj_math.h"
#include "proj_internal.h"
#include "projects.h"
@@ -42,7 +42,7 @@ static double read_vgrid_value( PJ *defn, LP input, int *gridlist_count_p, PJ_GR
float *cvs;
/* do not deal with NaN coordinates */
/* cppcheck-suppress duplicateExpression */
- if( pj_is_nan(input.phi) || pj_is_nan(input.lam) )
+ if( isnan(input.phi) || isnan(input.lam) )
itable = *gridlist_count_p;
/* keep trying till we find a table that works */
diff --git a/src/pj_internal.c b/src/pj_internal.c
index 891e0b9f..dc528649 100644
--- a/src/pj_internal.c
+++ b/src/pj_internal.c
@@ -438,19 +438,3 @@ void proj_log_func (PJ_CONTEXT *ctx, void *app_data, PJ_LOG_FUNCTION logf) {
if (0!=logf)
ctx->logger = logf;
}
-
-
-#if HAVE_C99_MATH
-/* proj_internal.h defines pj_is_nan as isnan */
-#else
-/*****************************************************************************/
-int pj_is_nan (double val) {
-/******************************************************************************
- Returns 0 if not a NaN and non-zero if val is a NaN.
-
- Provides an equivalent to isnan().
-******************************************************************************/
- /* cppcheck-suppress duplicateExpression */
- return val != val;
-}
-#endif
diff --git a/src/pj_math.c b/src/pj_math.c
index d5242636..751c2750 100644
--- a/src/pj_math.c
+++ b/src/pj_math.c
@@ -61,6 +61,11 @@ double pj_asinh(double x) {
return x > 0 ? y : (x < 0 ? -y : x);
}
-#endif /* !(defined(HAVE_C99_MATH) && HAVE_C99_MATH) */
+/* Returns 0 if not a NaN and non-zero if val is a NaN */
+int pj_isnan (double x) {
+ /* cppcheck-suppress duplicateExpression */
+ return x != x;
+}
+#endif /* !(defined(HAVE_C99_MATH) && HAVE_C99_MATH) */
diff --git a/src/proj_math.h b/src/proj_math.h
index 0d28cb30..0108a439 100644
--- a/src/proj_math.h
+++ b/src/proj_math.h
@@ -39,10 +39,12 @@ extern "C" {
double pj_hypot(double x, double y);
double pj_log1p(double x);
double pj_asinh(double x);
+int pj_isnan(double x);
#define hypot pj_hypot
#define log1p pj_log1p
#define asinh pj_asinh
+#define isnan pj_isnan
#endif /* !(defined(HAVE_C99_MATH) && HAVE_C99_MATH) */