sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1802140 - /sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4.java
Date Mon, 17 Jul 2017 13:28:23 GMT
Author: desruisseaux
Date: Mon Jul 17 13:28:23 2017
New Revision: 1802140

URL: http://svn.apache.org/viewvc?rev=1802140&view=rev
Log:
Make the check for native PJ structure optional, as documented in javadoc.

Modified:
    sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4.java

Modified: sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4.java?rev=1802140&r1=1802139&r2=1802140&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4.java
[UTF-8] Mon Jul 17 13:28:23 2017
@@ -105,11 +105,29 @@ public final class Proj4 extends Static
      */
     public static String definition(final CoordinateReferenceSystem crs) throws FactoryException
{
         ArgumentChecks.ensureNonNull("crs", crs);
-        for (final Identifier id : crs.getIdentifiers()) {
-            if (id instanceof PJ) {
-                return ((PJ) id).getCode();
+        /*
+         * If the given CRS object is associated to a Proj.4 structure, let Proj.4 formats
itself
+         * the definition string. Note that this operation may fail if there is no Proj.4
library
+         * in the current system, or no JNI bindings to that library.
+         */
+        try {
+            for (final Identifier id : crs.getIdentifiers()) {
+                if (id instanceof PJ) {
+                    return ((PJ) id).getCode();
+                }
             }
+        } catch (UnsatisfiedLinkError e) {
+            // Thrown the first time that we try to use the library.
+            Logging.unexpectedException(Logging.getLogger(Modules.GDAL), Proj4.class, "definition",
e);
+        } catch (NoClassDefFoundError e) {
+            // Thrown on all attempts after the first one.
+            Logging.recoverableException(Logging.getLogger(Modules.GDAL), Proj4.class, "definition",
e);
         }
+        /*
+         * If we found no Proj.4 structure, formats the definition string ourself. The string
may differ from
+         * what Proj.4 would have given. In particular, we do not provide "+init=" or "+datum="
parameter.
+         * But the definition should still be semantically equivalent.
+         */
         final String method;
         final GeodeticDatum datum;
         final ParameterValueGroup parameters;



Mime
View raw message