sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1674423 - in /sis/branches/JDK8/core/sis-referencing/src: main/java/org/apache/sis/referencing/operation/projection/ main/java/org/apache/sis/referencing/operation/transform/ test/java/org/apache/sis/internal/referencing/provider/ test/jav...
Date Sat, 18 Apr 2015 00:47:14 GMT
Author: desruisseaux
Date: Sat Apr 18 00:47:14 2015
New Revision: 1674423

URL: http://svn.apache.org/r1674423
Log:
Referencing: bug fix in ConcatenatedTransform.getParameterized(): the ContextualParameters
instance was not correctly recognized as a Parameterized object.

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/HTMLGenerator.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java?rev=1674423&r1=1674422&r2=1674423&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java
[UTF-8] Sat Apr 18 00:47:14 2015
@@ -91,7 +91,6 @@ public class LambertConformal extends No
      * @param  type One of {@link #SP1}, {@link #SP2} or {@link #BELGIUM} constants.
      * @return The roles map to give to super-class constructor.
      */
-    @SuppressWarnings("fallthrough")
     private static Map<ParameterRole, ParameterDescriptor<Double>> roles(final
byte type) {
         final EnumMap<ParameterRole, ParameterDescriptor<Double>> roles = new
EnumMap<>(ParameterRole.class);
         /*

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java?rev=1674423&r1=1674422&r2=1674423&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
[UTF-8] Sat Apr 18 00:47:14 2015
@@ -485,33 +485,24 @@ class ConcatenatedTransform extends Abst
         final List<Object> transforms = getPseudoSteps();
         if (transforms.size() == 1 || Semaphores.query(Semaphores.PROJCS)) {
             for (final Object candidate : transforms) {
-                if (!(candidate instanceof Parameterized)) {
-                    /*
-                     * If a step does not implement the Parameterized interface, we conservatively
-                     * handle it as if it was a non-linear step: we should return its parameters
-                     * (which are null), or return null if there is more non-linear steps.
-                     */
-                    return null;
-                }
-                if (param != null) {
-                    /*
-                     * We found more than one Parameterized step. If both steps are non-linear,
-                     * we fail (return null) because we don't know which one to choose. If
both
-                     * steps are linear, we fail for the same reason   (actually the later
case
-                     * should never occur, since consecutive linear transforms should have
been
-                     * concatenated in a single affine transform. But we check as a safety).
If
-                     * the previous step was linear and the current candidate is non-linear,
we
-                     * retain the current candidate. Otherwise we discart it.
-                     */
-                    final boolean isLinear = (candidate instanceof LinearTransform);
-                    if ((param instanceof LinearTransform) == isLinear) {
+                /*
+                 * Search for non-linear parameters only, ignoring affine transforms and
the matrices
+                 * computed by ContextualParameters. Note that the 'transforms' list is guaranteed
to
+                 * contains at least one non-linear parameter, otherwise we would not have
created a
+                 * ConcatenatedTransform instance.
+                 */
+                if (!(candidate instanceof Matrix) && !(candidate instanceof LinearTransform))
{
+                    if ((param == null) && (candidate instanceof Parameterized))
{
+                        param = (Parameterized) candidate;
+                    } else {
+                        /*
+                         * Found more than one group of non-linear parameters, or found an
object
+                         * that do not declare its parameters.  In the later case, conservatively
+                         * returns 'null' because we do not know what the real parameters
are.
+                         */
                         return null;
                     }
-                    if (isLinear) {
-                        continue;
-                    }
                 }
-                param = (Parameterized) candidate;
             }
         }
         return param;

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java?rev=1674423&r1=1674422&r2=1674423&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java
[UTF-8] Sat Apr 18 00:47:14 2015
@@ -36,6 +36,7 @@ import org.apache.sis.internal.referenci
 import org.apache.sis.internal.referencing.WKTUtilities;
 import org.apache.sis.internal.util.DoubleDouble;
 import org.apache.sis.internal.util.UnmodifiableArrayList;
+import org.apache.sis.parameter.Parameters;
 import org.apache.sis.parameter.Parameterized;
 import org.apache.sis.parameter.DefaultParameterValue;
 import org.apache.sis.referencing.operation.matrix.Matrices;
@@ -125,7 +126,7 @@ import static org.apache.sis.util.Argume
  * @see org.apache.sis.referencing.operation.projection.NormalizedProjection
  * @see AbstractMathTransform#getContextualParameters()
  */
-public class ContextualParameters extends FormattableObject implements ParameterValueGroup,
Cloneable, Serializable {
+public class ContextualParameters extends Parameters implements Serializable {
     /**
      * For cross-version compatibility.
      */
@@ -506,12 +507,7 @@ public class ContextualParameters extend
         /*
          * Now proceed to the clone of this ContextualParameters instance.
          */
-        final ContextualParameters clone;
-        try {
-            clone = (ContextualParameters) super.clone();
-        } catch (CloneNotSupportedException e) {
-            throw new AssertionError(e);    // Should never happen since we are cloneable.
-        }
+        final ContextualParameters clone = (ContextualParameters) super.clone();
         clone.values      = param;
         clone.normalize   = normalize.clone();
         clone.denormalize = denormalize.clone();
@@ -545,30 +541,20 @@ public class ContextualParameters extend
     }
 
     /**
-     * Formats a <cite>Well Known Text</cite> version 1 (WKT 1) element for a
transform using this group of parameters.
-     *
-     * <div class="note"><b>Compatibility note:</b>
-     * {@code Param_MT} is defined in the WKT 1 specification only.
-     * If the {@linkplain Formatter#getConvention() formatter convention} is set to WKT 2,
-     * then this method silently uses the WKT 1 convention without raising an error.</div>
-     *
-     * @return {@code "Param_MT"}.
+     * Formats the <cite>Well Known Text</cite> for the transform or the inverse
of the transform
+     * that would be built from the enclosing {@code ContextualParameters}.
      */
-    @Override
-    protected String formatTo(final Formatter formatter) {
-        WKTUtilities.appendParamMT(this, formatter);
-        return "Param_MT";
-    }
+    private final class WKT extends FormattableObject implements Parameterized {
+        /**
+         * {@code true} if this proxy is for the inverse transform instead than the direct
one.
+         */
+        private final boolean inverse;
 
-    /**
-     * Formats the <cite>Well Known Text</cite> for the inverse of the transform
that would be built
-     * from the enclosing {@code ContextualParameters}.
-     */
-    private final class InverseWKT extends FormattableObject implements Parameterized {
         /**
          * Creates a new object to be formatted instead than the enclosing transform.
          */
-        InverseWKT() {
+        WKT(final boolean inverse) {
+            this.inverse = inverse;
         }
 
         /**
@@ -588,12 +574,24 @@ public class ContextualParameters extend
         }
 
         /**
-         * Process to the WKT formatting of the inverse transform.
+         * Formats a <cite>Well Known Text</cite> version 1 (WKT 1) element for
a transform using this group of parameters.
+         *
+         * <div class="note"><b>Compatibility note:</b>
+         * {@code Param_MT} is defined in the WKT 1 specification only.
+         * If the {@linkplain Formatter#getConvention() formatter convention} is set to WKT
2,
+         * then this method silently uses the WKT 1 convention without raising an error.</div>
+         *
+         * @return {@code "Param_MT"}.
          */
         @Override
         protected String formatTo(final Formatter formatter) {
-            formatter.append(ContextualParameters.this);
-            return "Inverse_MT";
+            if (inverse) {
+                formatter.append(new WKT(false));
+                return "Inverse_MT";
+            } else {
+                WKTUtilities.appendParamMT(ContextualParameters.this, formatter);
+                return "Param_MT";
+            }
         }
     }
 
@@ -703,7 +701,7 @@ public class ContextualParameters extend
                 transforms.add(index++, before);
             }
         }
-        transforms.set(index, inverse ? new InverseWKT() : this);
+        transforms.set(index, new WKT(inverse));
         if (after == null) {
             if (hasAfter) {
                 final Object old = transforms.remove(index + 1);

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java?rev=1674423&r1=1674422&r2=1674423&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java
[UTF-8] Sat Apr 18 00:47:14 2015
@@ -22,7 +22,6 @@ import org.opengis.metadata.Identifier;
 import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.GeneralParameterDescriptor;
 import org.apache.sis.metadata.iso.citation.Citations;
-import org.apache.sis.internal.util.Constants;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/HTMLGenerator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/HTMLGenerator.java?rev=1674423&r1=1674422&r2=1674423&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/HTMLGenerator.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/HTMLGenerator.java
[UTF-8] Sat Apr 18 00:47:14 2015
@@ -24,6 +24,7 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.BufferedWriter;
 import java.io.OutputStreamWriter;
+import java.io.Closeable;
 import org.opengis.util.InternationalString;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.Deprecable;
@@ -41,7 +42,7 @@ import org.apache.sis.util.Deprecable;
  * @version 0.6
  * @module
  */
-public abstract class HTMLGenerator implements AutoCloseable {
+public abstract class HTMLGenerator implements Closeable {
     /**
      * The encoding of the files to generate.
      */



Mime
View raw message