sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1713927 - in /sis/branches/JDK8/core/sis-referencing/src: main/java/org/apache/sis/referencing/operation/transform/ test/java/org/apache/sis/referencing/operation/projection/
Date Wed, 11 Nov 2015 20:15:26 GMT
Author: desruisseaux
Date: Wed Nov 11 20:15:25 2015
New Revision: 1713927

URL: http://svn.apache.org/viewvc?rev=1713927&view=rev
Log:
Bug fix in formatting of "INVERSE_MT[...]": in some cases we concatenated a matrix which was
not supposed to be there.

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.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/referencing/operation/projection/MercatorTest.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java?rev=1713927&r1=1713926&r2=1713927&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
[UTF-8] Wed Nov 11 20:15:25 2015
@@ -1127,6 +1127,7 @@ public abstract class AbstractMathTransf
                 WKTUtilities.appendParamMT(parameters, formatter);
                 return WKTKeywords.Param_MT;
             } else {
+                formatter.newLine();
                 formatter.append((FormattableObject) AbstractMathTransform.this);
                 return WKTKeywords.Inverse_MT;
             }

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=1713927&r1=1713926&r2=1713927&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] Wed Nov 11 20:15:25 2015
@@ -784,6 +784,7 @@ public class ContextualParameters extend
         @Override
         protected String formatTo(final Formatter formatter) {
             if (inverse) {
+                formatter.newLine();
                 formatter.append(new WKT(false));
                 return WKTKeywords.Inverse_MT;
             } else {
@@ -888,7 +889,7 @@ public class ContextualParameters extend
          * Note that if this operation fails, we will cancel everything we would have done
          * in this method (i.e. we do not touch the transforms list at all).
          */
-        if (!inverse) try {
+        try {
             userDefined = getMatrix(inverse ? MatrixRole.NORMALIZATION : MatrixRole.INVERSE_DENORMALIZATION);
         } catch (IllegalStateException e) {
             unexpectedException(e);

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MercatorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MercatorTest.java?rev=1713927&r1=1713926&r2=1713927&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MercatorTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MercatorTest.java
[UTF-8] Wed Nov 11 20:15:25 2015
@@ -18,6 +18,7 @@ package org.apache.sis.referencing.opera
 
 import org.opengis.util.FactoryException;
 import org.opengis.referencing.operation.TransformException;
+import org.opengis.referencing.operation.NoninvertibleTransformException;
 import org.apache.sis.internal.referencing.Formulas;
 import org.apache.sis.internal.referencing.provider.Mercator1SP;
 import org.apache.sis.internal.referencing.provider.Mercator2SP;
@@ -43,7 +44,7 @@ import static org.apache.sis.referencing
  * @author  Simon Reynard (Geomatys)
  * @author  Rémi Maréchal (Geomatys)
  * @since   0.6
- * @version 0.6
+ * @version 0.7
  * @module
  */
 @DependsOn(ConformalProjectionTest.class)
@@ -69,14 +70,56 @@ public final strictfp class MercatorTest
      * the ellipsoid eccentricity. We expect nothing else because all other parameters are
used
      * by the (de)normalization affine transforms instead than the {@link Mercator} class
itself.
      *
+     * @throws NoninvertibleTransformException should never happen.
+     *
      * @see LambertConicConformalTest#testNormalizedWKT()
      */
     @Test
-    public void testNormalizedWKT() {
+    public void testNormalizedWKT() throws NoninvertibleTransformException {
         createNormalizedProjection(true);
-        assertWktEquals(
-                "PARAM_MT[“Mercator”,\n" +
-                "  PARAMETER[“eccentricity”, 0.0818191908426215]]");
+        assertWktEquals("PARAM_MT[“Mercator”,\n" +
+                        "  PARAMETER[“eccentricity”, 0.0818191908426215]]");
+
+        transform = transform.inverse();
+        assertWktEquals("INVERSE_MT[\n" +
+                        "  PARAM_MT[“Mercator”,\n" +
+                        "    PARAMETER[“eccentricity”, 0.0818191908426215]]]");
+    }
+
+    /**
+     * Tests WKT of a complete map projection.
+     *
+     * @throws FactoryException if an error occurred while creating the map projection.
+     * @throws NoninvertibleTransformException should never happen.
+     */
+    @Test
+    @DependsOnMethod("testNormalizedWKT")
+    public void testCompleteWKT() throws FactoryException, NoninvertibleTransformException
{
+        createCompleteProjection(new Mercator1SP(), true,
+                  0.5,    // Central meridian
+                  0,      // Latitude of origin (none)
+                  0,      // Standard parallel (none)
+                  0.997,  // Scale factor
+                200,      // False easting
+                100);     // False northing
+
+        assertWktEquals("PARAM_MT[“Mercator_1SP”,\n" +
+                        "  PARAMETER[“semi_major”, 6378137.0],\n" +
+                        "  PARAMETER[“semi_minor”, 6356752.314245179],\n" +
+                        "  PARAMETER[“central_meridian”, 0.5],\n" +
+                        "  PARAMETER[“scale_factor”, 0.997],\n" +
+                        "  PARAMETER[“false_easting”, 200.0],\n" +
+                        "  PARAMETER[“false_northing”, 100.0]]");
+
+        transform = transform.inverse();
+        assertWktEquals("INVERSE_MT[\n" +
+                        "  PARAM_MT[“Mercator_1SP”,\n" +
+                        "    PARAMETER[“semi_major”, 6378137.0],\n" +
+                        "    PARAMETER[“semi_minor”, 6356752.314245179],\n" +
+                        "    PARAMETER[“central_meridian”, 0.5],\n" +
+                        "    PARAMETER[“scale_factor”, 0.997],\n" +
+                        "    PARAMETER[“false_easting”, 200.0],\n" +
+                        "    PARAMETER[“false_northing”, 100.0]]]");
     }
 
     /**



Mime
View raw message