sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1737585 - in /sis/branches/JDK8/core/sis-referencing/src: main/java/org/apache/sis/referencing/operation/ test/java/org/apache/sis/referencing/operation/
Date Sun, 03 Apr 2016 12:42:04 GMT
Author: desruisseaux
Date: Sun Apr  3 12:42:04 2016
New Revision: 1737585

URL: http://svn.apache.org/viewvc?rev=1737585&view=rev
Log:
Fix parameter declarations in operations created by CoordinateOperationInference.

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationInference.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationInferenceTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java?rev=1737585&r1=1737584&r2=1737585&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
[UTF-8] Sun Apr  3 12:42:04 2016
@@ -882,9 +882,11 @@ check:      for (int isTarget=0; ; isTar
             }
             if (parameters != null) {
                 formatter.newLine();
+                formatter.indent(+1);
                 for (final GeneralParameterValue param : parameters.values()) {
                     WKTUtilities.append(param, formatter);
                 }
+                formatter.indent(-1);
             }
         }
         if (!isComponent) {

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationInference.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationInference.java?rev=1737585&r1=1737584&r2=1737585&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationInference.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationInference.java
[UTF-8] Sun Apr  3 12:42:04 2016
@@ -505,7 +505,10 @@ public class CoordinateOperationInferenc
         } else {
             final int sourceDim = sourceCS.getDimension();
             final int targetDim = targetCS.getDimension();
-            if ((sourceDim & ~1) == 2 && (sourceDim ^ targetDim) == 1) {    //
sourceDim == 2 or 3 and difference with targetDim is 1.
+            if ((sourceDim & ~1) == 2 && (sourceDim ^ targetDim) == 1    // sourceDim
== 2 or 3 and difference with targetDim is 1.
+                    && (sourceCS instanceof EllipsoidalCS)
+                    && (targetCS instanceof EllipsoidalCS))
+            {
                 parameters = (sourceDim == 2 ? Geographic2Dto3D.PARAMETERS
                                              : Geographic3Dto2D.PARAMETERS).createValue();
             } else {
@@ -537,7 +540,7 @@ public class CoordinateOperationInferenc
                 transform = mtFactory.createConcatenatedTransform(transform, after);
             }
         }
-        return createFromMathTransform(properties(identifier), sourceCRS, targetCRS, transform,
method, null);
+        return createFromMathTransform(properties(identifier), sourceCRS, targetCRS, transform,
method, parameters, null);
     }
 
     /**
@@ -641,7 +644,7 @@ public class CoordinateOperationInferenc
             throws FactoryException
     {
         final MathTransform transform  = factorySIS.getMathTransformFactory().createAffineTransform(matrix);
-        return createFromMathTransform(properties(name), sourceCRS, targetCRS, transform,
null, null);
+        return createFromMathTransform(properties(name), sourceCRS, targetCRS, transform,
null, null, null);
     }
 
     /**
@@ -675,6 +678,7 @@ public class CoordinateOperationInferenc
      * @param  targetCRS  The destination coordinate reference system.
      * @param  transform  The math transform.
      * @param  method     The operation method, or {@code null} if unknown.
+     * @param  parameters The operations parameters, or {@code null} for automatic detection
(not always reliable).
      * @param  type       {@code Conversion.class}, {@code Transformation.class}, or {@code
null} if unknown.
      * @return A coordinate operation using the specified math transform.
      * @throws FactoryException if the operation can not be created.
@@ -684,6 +688,7 @@ public class CoordinateOperationInferenc
                                                         final CoordinateReferenceSystem targetCRS,
                                                         final MathTransform             transform,
                                                               OperationMethod           method,
+                                                        final ParameterValueGroup       parameters,
                                                         Class<? extends CoordinateOperation>
type)
             throws FactoryException
     {
@@ -735,6 +740,9 @@ public class CoordinateOperationInferenc
                 }
             }
         }
+        if (parameters != null) {
+            properties.put(ReferencingServices.PARAMETERS_KEY, parameters);
+        }
         properties.put(ReferencingServices.OPERATION_TYPE_KEY, type);
         if (Conversion.class.isAssignableFrom(type) && transform.isIdentity()) {
             properties.replace(IdentifiedObject.NAME_KEY, AXIS_CHANGES, IDENTITY);
@@ -755,7 +763,7 @@ public class CoordinateOperationInferenc
             throw new OperationNotFoundException(notFoundMessage(targetCRS, sourceCRS), exception);
         }
         return createFromMathTransform(properties(INVERSE_OPERATION), targetCRS, sourceCRS,
-                transform, InverseOperationMethod.create(op.getMethod()), null);
+                transform, InverseOperationMethod.create(op.getMethod()), null, null);
     }
 
     /**
@@ -791,9 +799,10 @@ public class CoordinateOperationInferenc
         if (step1.getName() == AXIS_CHANGES && mt1.getSourceDimensions() == mt1.getTargetDimensions())
main = step2;
         if (step2.getName() == AXIS_CHANGES && mt2.getSourceDimensions() == mt2.getTargetDimensions())
main = step1;
         if (main instanceof SingleOperation) {
+            final SingleOperation op = (SingleOperation) main;
             final MathTransform mt = factorySIS.getMathTransformFactory().createConcatenatedTransform(mt1,
mt2);
             main = createFromMathTransform(new HashMap<>(IdentifiedObjects.getProperties(main)),
-                   sourceCRS, targetCRS, mt, ((SingleOperation) main).getMethod(),
+                   sourceCRS, targetCRS, mt, op.getMethod(), op.getParameterValues(),
                    (main instanceof Transformation) ? Transformation.class : SingleOperation.class);
         } else {
             main = factory.createConcatenatedOperation(defaultName(sourceCRS, targetCRS),
step1, step2);
@@ -812,7 +821,7 @@ public class CoordinateOperationInferenc
                 }
             }
             main = createFromMathTransform(new HashMap<>(IdentifiedObjects.getProperties(main)),
-                    main.getSourceCRS(), main.getTargetCRS(), main.getMathTransform(), null,
type);
+                    main.getSourceCRS(), main.getTargetCRS(), main.getMathTransform(), null,
null, type);
         }
         return main;
     }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java?rev=1737585&r1=1737584&r2=1737585&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java
[UTF-8] Sun Apr  3 12:42:04 2016
@@ -487,7 +487,7 @@ next:   for (int i=components.size(); --
         }
         /*
          * Now create the coordinate operation of the requested type. If we can not find
a concrete class for the
-         * requested type, we will instantiate an SingleOperation in last resort. The later
action is a departure
+         * requested type, we will instantiate a SingleOperation in last resort.  The later
action is a departure
          * from ISO 19111 since 'SingleOperation' is conceptually abstract.  But we do that
as a way to said that
          * we are missing this important piece of information but still go ahead.
          *

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationInferenceTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationInferenceTest.java?rev=1737585&r1=1737584&r2=1737585&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationInferenceTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationInferenceTest.java
[UTF-8] Sun Apr  3 12:42:04 2016
@@ -435,11 +435,15 @@ public final strictfp class CoordinateOp
         final GeographicCRS sourceCRS = CommonCRS.WGS84.geographic3D();
         final GeographicCRS targetCRS = CommonCRS.WGS84.geographic();
         final CoordinateOperation operation = factory.createOperation(sourceCRS, targetCRS);
-        assertSame  ("sourceCRS", sourceCRS, operation.getSourceCRS());
-        assertSame  ("targetCRS", targetCRS, operation.getTargetCRS());
-        assertEquals("name", "Axis changes", operation.getName().getCode());
+        assertSame      ("sourceCRS", sourceCRS,        operation.getSourceCRS());
+        assertSame      ("targetCRS", targetCRS,        operation.getTargetCRS());
+        assertEquals    ("name",      "Axis changes",   operation.getName().getCode());
         assertInstanceOf("operation", Conversion.class, operation);
 
+        final ParameterValueGroup parameters = ((SingleOperation) operation).getParameterValues();
+        assertEquals("parameters.descriptor", "Geographic3D to 2D conversion", parameters.getDescriptor().getName().getCode());
+        assertTrue  ("parameters.isEmpty", parameters.values().isEmpty());
+
         transform = operation.getMathTransform();
         assertInstanceOf("transform", LinearTransform.class, transform);
         assertEquals(3, transform.getSourceDimensions());
@@ -474,11 +478,15 @@ public final strictfp class CoordinateOp
         final GeographicCRS sourceCRS = CommonCRS.WGS84.geographic();
         final GeographicCRS targetCRS = CommonCRS.WGS84.geographic3D();
         final CoordinateOperation operation = factory.createOperation(sourceCRS, targetCRS);
-        assertSame  ("sourceCRS", sourceCRS, operation.getSourceCRS());
-        assertSame  ("targetCRS", targetCRS, operation.getTargetCRS());
-        assertEquals("name", "Axis changes", operation.getName().getCode());
+        assertSame      ("sourceCRS", sourceCRS,        operation.getSourceCRS());
+        assertSame      ("targetCRS", targetCRS,        operation.getTargetCRS());
+        assertEquals    ("name",      "Axis changes",   operation.getName().getCode());
         assertInstanceOf("operation", Conversion.class, operation);
 
+        final ParameterValueGroup parameters = ((SingleOperation) operation).getParameterValues();
+        assertEquals("parameters.descriptor", "Geographic2D to 3D conversion", parameters.getDescriptor().getName().getCode());
+        assertEquals("parameters.height", 0, parameters.parameter("height").doubleValue(),
STRICT);
+
         transform = operation.getMathTransform();
         assertInstanceOf("transform", LinearTransform.class, transform);
         assertEquals(2, transform.getSourceDimensions());
@@ -489,6 +497,14 @@ public final strictfp class CoordinateOp
             0, 0, 0,
             0, 0, 1
         }), ((LinearTransform) transform).getMatrix(), STRICT, false));
+
+        verifyTransform(new double[] {
+            30, 10,
+            20, 30
+        }, new double[] {
+            30, 10, 0,
+            20, 30, 0
+        });
         validate();
     }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java?rev=1737585&r1=1737584&r2=1737585&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java
[UTF-8] Sun Apr  3 12:42:04 2016
@@ -177,9 +177,9 @@ public final strictfp class DefaultTrans
                 "      AXIS[“(Z)”, geocentricZ, ORDER[3]],\n" +
                 "      LENGTHUNIT[“metre”, 1]]],\n" +
                 "  METHOD[“Geocentric translations”, ID[“EPSG”, 1031]],\n" +
-                "  PARAMETER[“X-axis translation”, -146.414, ID[“EPSG”, 8605]],\n"
+
-                "  PARAMETER[“Y-axis translation”, 507.337, ID[“EPSG”, 8606]],\n"
+
-                "  PARAMETER[“Z-axis translation”, 680.507, ID[“EPSG”, 8607]]]",
op);
+                "    PARAMETER[“X-axis translation”, -146.414, ID[“EPSG”, 8605]],\n"
+
+                "    PARAMETER[“Y-axis translation”, 507.337, ID[“EPSG”, 8606]],\n"
+
+                "    PARAMETER[“Z-axis translation”, 680.507, ID[“EPSG”, 8607]]]",
op);
 
         assertWktEquals(Convention.WKT2_SIMPLIFIED,
                 "CoordinateOperation[“Tokyo to JGD2000 (GSI)”,\n" +
@@ -200,9 +200,9 @@ public final strictfp class DefaultTrans
                 "      Axis[“(Z)”, geocentricZ],\n" +
                 "      Unit[“metre”, 1]]],\n" +
                 "  Method[“Geocentric translations”],\n" +
-                "  Parameter[“X-axis translation”, -146.414],\n" +
-                "  Parameter[“Y-axis translation”, 507.337],\n" +
-                "  Parameter[“Z-axis translation”, 680.507]]", op);
+                "    Parameter[“X-axis translation”, -146.414],\n" +
+                "    Parameter[“Y-axis translation”, 507.337],\n" +
+                "    Parameter[“Z-axis translation”, 680.507]]", op);
     }
 
     /**



Mime
View raw message