aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Desruisseaux <martin.desruisseaux@geomatys.fr>2012-05-31 14:15:10 +0000
committerMartin Desruisseaux <martin.desruisseaux@geomatys.fr>2012-05-31 14:15:10 +0000
commit36ce9c9987f8f6e4795db541d9ba293f3fbeaedc (patch)
tree77d6d238da412ce185613262346de63e0681850e
parentd120af82e2b252322b334d168eafab1cf80f36c8 (diff)
downloadPROJ-4.8.tar.gz
PROJ-4.8.zip
JNI: Replaced usages of NAN C/C++ constant by the java.lang.Double.NaN constant.4.8
git-svn-id: http://svn.osgeo.org/metacrs/proj/trunk@2211 4e78687f-474d-0410-85f9-8d5e500ac6b2
-rw-r--r--ChangeLog28
-rw-r--r--src/jniproj.c31
2 files changed, 43 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 9c9baf79..149cef86 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-05-31 Martin Desruisseaux <martin.desruisseaux@geomatys.fr>
+
+ * Replaced usages of NAN C/C++ constant by the java.lang.Double.NaN constant.
+ This was done because not all C/C++ compilers define the NAN constant, and for
+ making sure that the bits pattern is exactly the one expected by Java.
+
2012-03-25 Frank Warmerdam <warmerdam@pobox.com>
* src/Makefile.am: Add org_proj4_PJ.h to files to distribute.
@@ -25,13 +31,13 @@
2012-02-26 Frank Warmerdam <warmerdam@pobox.com>
- * src/PJ_geos.c, nad/testvarious: Added GEOS +sweep and add GEOS
+ * src/PJ_geos.c, nad/testvarious: Added GEOS +sweep and add GEOS
to the test suite (#146)
* nad/CH: added swiss datum related definitions from strk (#145)
* src/Makefile.am, src/mutltistresstest.c: provide for building
- multistresstest in the makefile, and slightly improve it.
+ multistresstest in the makefile, and slightly improve it.
2012-02-25 Frank Warmerdam <warmerdam@pobox.com>
@@ -39,7 +45,7 @@
2012-02-20 Frank Warmerdam <warmerdam@pobox.com>
- * Prepare 4.8.0 Beta1.
+ * Prepare 4.8.0 Beta1.
* src/PJ_isea.c: Add Icosahedral Snyder Equal Area projection (#111)
@@ -65,7 +71,7 @@
2012-02-01 Frank Warmerdam <warmerdam@pobox.com>
* src/pj_apply_gridshift.c: ensure we try to use grids as long as we
- are within epsilon of the edge (#141).
+ are within epsilon of the edge (#141).
2012-01-31 Frank Warmerdam <warmerdam@pobox.com>
@@ -73,7 +79,7 @@
2011-12-22 Frank Warmerdam <warmerdam@google.com>
- * src/pj_init.c; Only split arguments on pluses following spaces
+ * src/pj_init.c; Only split arguments on pluses following spaces
in pj_init_plus() (#132)
2011-12-14 Frank Warmerdam <warmerdam@google.com>
@@ -83,7 +89,7 @@
2011-12-13 Frank Warmerdam <warmerdam@google.com>
* src/PJ_healpix.c, etc: added healpix support contributed by
- Landcare in New Zealand.
+ Landcare in New Zealand.
2011-11-22 Frank Warmerdam <warmerdam@pobox.com>
@@ -102,20 +108,20 @@
2011-09-28 Frank Warmerdam <warmerdam@pobox.com>
- * nad/epsg: Upgrade to EPSG 7.9. Ideal datum selection rules also
+ * nad/epsg: Upgrade to EPSG 7.9. Ideal datum selection rules also
changed a bit upstream.
2011-09-01 Martin Desruisseaux <martin.desruisseaux@geomatys.fr>
- * Updated jniwrap/build.xml Ant script and README file.
+ * Updated jniwrap/build.xml Ant script and README file.
2011-08-27 Martin Desruisseaux <martin.desruisseaux@geomatys.fr>
- * Fixed some (but not all) memory leaks in org.proj4.Projections JNI bindings
+ * Fixed some (but not all) memory leaks in org.proj4.Projections JNI bindings
- * Deprecated org.proj4.Projections JNI bindings
+ * Deprecated org.proj4.Projections JNI bindings
- * Added org.proj4.PJ JNI bindings in replacement of org.proj4.Projections
+ * Added org.proj4.PJ JNI bindings in replacement of org.proj4.Projections
2011-08-27 Frank Warmerdam <warmerdam@pobox.com>
diff --git a/src/jniproj.c b/src/jniproj.c
index 7261a0c3..a0d9180b 100644
--- a/src/jniproj.c
+++ b/src/jniproj.c
@@ -80,6 +80,27 @@ PJ *getPJ(JNIEnv *env, jobject object)
/*!
* \brief
+ * Internal method returning the java.lang.Double.NaN constant value.
+ * Efficiency is no a high concern for this particular method, because it
+ * is used mostly when the user wrongly attempt to use a disposed PJ object.
+ *
+ * \param env - The JNI environment.
+ * \return The java.lang.Double.NaN constant value.
+ */
+jdouble javaNaN(JNIEnv *env)
+{
+ jclass c = (*env)->FindClass(env, "java/lang/Double");
+ if (c) { // Should never be NULL, but let be paranoiac.
+ jfieldID id = (*env)->GetStaticFieldID(env, c, "NaN", "D");
+ if (id) { // Should never be NULL, but let be paranoiac.
+ return (*env)->GetStaticDoubleField(env, c, id);
+ }
+ }
+ return 0.0; // Should never happen.
+}
+
+/*!
+ * \brief
* Returns the Proj4 release number.
*
* \param env - The JNI environment.
@@ -218,7 +239,7 @@ JNIEXPORT jdouble JNICALL Java_org_proj4_PJ_getSemiMajorAxis
(JNIEnv *env, jobject object)
{
PJ *pj = getPJ(env, object);
- return pj ? pj->a_orig : NAN;
+ return pj ? pj->a_orig : javaNaN(env);
}
/*!
@@ -234,7 +255,7 @@ JNIEXPORT jdouble JNICALL Java_org_proj4_PJ_getSemiMinorAxis
(JNIEnv *env, jobject object)
{
PJ *pj = getPJ(env, object);
- if (!pj) return NAN;
+ if (!pj) return javaNaN(env);
double a = pj->a_orig;
return sqrt(a*a * (1.0 - pj->es_orig));
}
@@ -251,7 +272,7 @@ JNIEXPORT jdouble JNICALL Java_org_proj4_PJ_getEccentricitySquared
(JNIEnv *env, jobject object)
{
PJ *pj = getPJ(env, object);
- return pj ? pj->es_orig : NAN;
+ return pj ? pj->es_orig : javaNaN(env);
}
/*!
@@ -297,7 +318,7 @@ JNIEXPORT jdouble JNICALL Java_org_proj4_PJ_getGreenwichLongitude
(JNIEnv *env, jobject object)
{
PJ *pj = getPJ(env, object);
- return (pj) ? (pj->from_greenwich)*(180/M_PI) : NAN;
+ return (pj) ? (pj->from_greenwich)*(180/M_PI) : javaNaN(env);
}
/*!
@@ -316,7 +337,7 @@ JNIEXPORT jdouble JNICALL Java_org_proj4_PJ_getLinearUnitToMetre
if (pj) {
return (vertical) ? pj->vto_meter : pj->to_meter;
}
- return NAN;
+ return javaNaN(env);
}
/*!