sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1678729 - in /sis/branches/JDK7: ./ core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java
Date Mon, 11 May 2015 11:36:48 GMT
Author: desruisseaux
Date: Mon May 11 11:36:47 2015
New Revision: 1678729

URL: http://svn.apache.org/r1678729
Log:
Merge from the JDK8 branch.

Modified:
    sis/branches/JDK7/   (props changed)
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java

Propchange: sis/branches/JDK7/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 11 11:36:47 2015
@@ -1,4 +1,4 @@
 /sis/branches/Android:1430670-1480699
 /sis/branches/JDK6:1394913-1508480
-/sis/branches/JDK8:1584960-1678711
+/sis/branches/JDK8:1584960-1678723
 /sis/trunk:1394364-1508466,1519089-1519674

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java?rev=1678729&r1=1678728&r2=1678729&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java
[UTF-8] Mon May 11 11:36:47 2015
@@ -359,9 +359,18 @@ public class DefaultDerivedCRS extends A
      */
     @Override
     protected String formatTo(final Formatter formatter) {
+        final Conversion conversion = getConversionFromBase();  // Gives to users a chance
to override.
+        if (conversion == null) {
+            /*
+             * Should never happen except temporarily at construction time, or if the user
invoked the copy
+             * constructor with an invalid Conversion, or if the user overrides the getConversionFromBase()
+             * method. Delegates to the super-class method for avoiding a NullPointerException.
That method
+             * returns 'null', which will cause the WKT to be declared invalid.
+             */
+            return super.formatTo(formatter);
+        }
         WKTUtilities.appendName(this, formatter, null);
         final boolean isWKT1 = (formatter.getConvention().majorVersion() == 1);
-        final Conversion conversion = getConversionFromBase();  // Gives to users a chance
to override.
         /*
          * Both WKT 1 and WKT 2 format the base CRS. But WKT 1 formats the MathTransform
before the base CRS,
          * while WKT 2 formats the conversion method and parameter values after the base
CRS.

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java?rev=1678729&r1=1678728&r2=1678729&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java
[UTF-8] Mon May 11 11:36:47 2015
@@ -46,6 +46,7 @@ import org.apache.sis.io.wkt.Formattable
 import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.util.ComparisonMode;
+import org.apache.sis.util.logging.Logging;
 
 import static org.apache.sis.internal.referencing.WKTUtilities.toFormattable;
 
@@ -368,6 +369,14 @@ public class DefaultProjectedCRS extends
      */
     @Override
     protected String formatTo(final Formatter formatter) {
+        if (super.getConversionFromBase() == null) {
+            /*
+             * Should never happen except temporarily at construction time, or if the user
invoked the copy constructor
+             * with an invalid Conversion. Delegates to the super-class method for avoiding
a NullPointerException.
+             * That method returns 'null', which will cause the WKT to be declared invalid.
+             */
+            return super.formatTo(formatter);
+        }
         WKTUtilities.appendName(this, formatter, null);
         final Convention    convention = formatter.getConvention();
         final boolean       isWKT1     = (convention.majorVersion() == 1);
@@ -445,7 +454,23 @@ public class DefaultProjectedCRS extends
                      * the lengths are different from the ones declared in the datum.
                      */
                     if (param instanceof ParameterValue<?>) {
-                        final double value = ((ParameterValue<?>) param).doubleValue(axisUnit);
+                        final double value;
+                        try {
+                            value = ((ParameterValue<?>) param).doubleValue(axisUnit);
+                        } catch (IllegalStateException e) {
+                            /*
+                             * May happen if the 'conversionFromBase' parameter group does
not provide values
+                             * for "semi_major" or "semi_minor" axis length. This should
not happen with SIS
+                             * implementation, but may happen with user-defined map projection
implementations.
+                             * Since the intend of this check was to skip those parameters
anyway, it is okay
+                             * for the purpose of WKT formatting if there is no parameter
for axis lengths.
+                             */
+                            Logging.recoverableException(DefaultProjectedCRS.class, "formatTo",
e);
+                            continue;
+                        }
+                        if (Double.isNaN(value)) {
+                            continue;
+                        }
                         final double expected = (name == Constants.SEMI_MINOR)   // using
'==' is okay here.
                                 ? ellipsoid.getSemiMinorAxis() : ellipsoid.getSemiMajorAxis();
                         if (value == expected) {



Mime
View raw message