sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1653355 - in /sis/branches/JDK7: ./ core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ core/sis-referencing/src/test/java/org/apache/si...
Date Tue, 20 Jan 2015 20:00:58 GMT
Author: desruisseaux
Date: Tue Jan 20 20:00:57 2015
New Revision: 1653355

URL: http://svn.apache.org/r1653355
Log:
Merge the API change (committed 48 hours ago) from JDK8 branch.

Added:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/OperationMethods.java
      - copied unchanged from r1653351, sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/OperationMethods.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/OperationMethodsTest.java
      - copied unchanged from r1653351, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/OperationMethodsTest.java
Modified:
    sis/branches/JDK7/   (props changed)
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MathTransforms.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformsTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java

Propchange: sis/branches/JDK7/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 20 20:00:57 2015
@@ -1,4 +1,4 @@
 /sis/branches/Android:1430670-1480699
 /sis/branches/JDK6:1394913-1508480
-/sis/branches/JDK8:1584960-1653100
+/sis/branches/JDK8:1584960-1653351
 /sis/trunk:1394364-1508466,1519089-1519674

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MathTransforms.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MathTransforms.java?rev=1653355&r1=1653354&r2=1653355&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MathTransforms.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MathTransforms.java
[UTF-8] Tue Jan 20 20:00:57 2015
@@ -283,71 +283,6 @@ public final class MathTransforms extend
     }
 
     /**
-     * Returns what seems to be the "core" of the given math transform. This method should
be used only
-     * for information purpose, since the definition of "core" is imprecise and may be adjusted
in future
-     * SIS versions. The current algorithm is as below:
-     *
-     * <ul>
-     *   <li>If the given transform can be decomposed in {@linkplain #getSteps(MathTransform)
steps}, then the steps for
-     *       {@linkplain org.apache.sis.referencing.cs.CoordinateSystems#swapAndScaleAxes
axis swapping and scaling} are
-     *       ignored.</li>
-     *   <li>If the given transform or one of its steps is a {@link PassThroughTransform},
then its sub-transform
-     *       it taken.</li>
-     * </ul>
-     *
-     * @param  transform The math transform from which to get the "core" transform, or {@code
null}.
-     * @return The "core" (may be the whole math transform), or {@code null} if the given
argument was null.
-     */
-    public static MathTransform getCore(final MathTransform transform) {
-        MathTransform step = transform;
-        while (!isIgnorable(step)) {
-            if (step instanceof ConcatenatedTransform) {
-                // Ignore axis switch and scaling (usually unit conversions).
-                final ConcatenatedTransform c = (ConcatenatedTransform) step;
-                if (isIgnorable(c.transform1)) {
-                    step = c.transform2;
-                } else if (isIgnorable(c.transform2)) {
-                    step = c.transform1;
-                } else {
-                    return c; // Both components are non-ignorable: return the ConcatenatedTransform
as a whole.
-                }
-            } else if (step instanceof PassThroughTransform) {
-                step = ((PassThroughTransform) step).subTransform;
-            } else {
-                return step;
-            }
-        }
-        return transform; // The full MathTransform is ignorable. Do not try to decompose
it.
-    }
-
-    /**
-     * Returns {@code true} if the specified transform is likely to exists only for axis
swapping
-     * and/or unit conversions. The heuristic rule checks if the transform is backed by a
square
-     * matrix with exactly one non-null value in each row and each column. This method is
used for
-     * implementation of the {@link #getCore(MathTransform)} method only.
-     */
-    private static boolean isIgnorable(final MathTransform transform) {
-        final Matrix matrix = getMatrix(transform);
-        if (matrix != null) {
-            final int size = matrix.getNumRow();
-            if (matrix.getNumCol() == size) {
-                for (int j=0; j<size; j++) {
-                    int n1=0, n2=0;
-                    for (int i=0; i<size; i++) {
-                        if (matrix.getElement(j,i) != 0) n1++;
-                        if (matrix.getElement(i,j) != 0) n2++;
-                    }
-                    if (n1 != 1 || n2 != 1) {
-                        return false;
-                    }
-                }
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
      * If the given transform is linear, returns its coefficients as a matrix.
      * More specifically:
      *

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformsTest.java?rev=1653355&r1=1653354&r2=1653355&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformsTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformsTest.java
[UTF-8] Tue Jan 20 20:00:57 2015
@@ -19,7 +19,6 @@ package org.apache.sis.referencing.opera
 import java.util.List;
 import org.opengis.referencing.operation.MathTransform;
 import org.apache.sis.referencing.operation.matrix.Matrix4;
-import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
@@ -42,6 +41,23 @@ public final strictfp class MathTransfor
 
     /**
      * Creates a dummy transform for testing purpose.
+     * The transform has the folowing properties:
+     *
+     * <ul>
+     *   <li>The source and target dimensions are 3.</li>
+     *   <li>The transform contains 3 step.</li>
+     *   <li>The second step is a {@link PassThroughTransform}.</li>
+     *   <li>The transform in the middle (at dimension 1) is non-linear.</li>
+     * </ul>
+     *
+     * @return The dummy math transform.
+     */
+    public static MathTransform createConcatenateAndPassThrough() {
+        return createConcatenateAndPassThrough(new Matrix4(), new Matrix4());
+    }
+
+    /**
+     * Creates a dummy transform for testing purpose.
      * The {@code scale} and {@code scap} arguments are initially identity matrices,
      * and will be written by this method with dummy coefficient values for testing purpose.
      *
@@ -75,15 +91,4 @@ public final strictfp class MathTransfor
         assertMatrixEquals("Step 3", swap,  MathTransforms.getMatrix(steps.get(2)), STRICT);
         assertInstanceOf  ("Step 2", PassThroughTransform.class, steps.get(1));
     }
-
-    /**
-     * Tests {@link MathTransforms#getCore(MathTransform)}.
-     */
-    @Test
-    @DependsOnMethod("testGetSteps")
-    public void testGetCore() {
-        MathTransform tr = createConcatenateAndPassThrough(new Matrix4(), new Matrix4());
-        tr = MathTransforms.getCore(tr);
-        assertInstanceOf("The only non-ignorable part should be the exponential one.", ExponentialTransform1D.class,
tr);
-    }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1653355&r1=1653354&r2=1653355&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] Tue Jan 20 20:00:57 2015
@@ -77,6 +77,10 @@ import org.junit.BeforeClass;
     org.apache.sis.parameter.TensorParametersTest.class,
     org.apache.sis.parameter.TensorValuesTest.class,
 
+    org.apache.sis.referencing.operation.DefaultFormulaTest.class,
+    org.apache.sis.referencing.operation.DefaultOperationMethodTest.class,
+    org.apache.sis.internal.referencing.OperationMethodsTest.class,
+
     org.apache.sis.referencing.datum.BursaWolfParametersTest.class,
     org.apache.sis.referencing.datum.TimeDependentBWPTest.class,
     org.apache.sis.referencing.datum.DefaultEllipsoidTest.class,
@@ -107,9 +111,6 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.CommonCRSTest.class,
     org.apache.sis.referencing.CRSTest.class,
 
-    org.apache.sis.referencing.operation.DefaultFormulaTest.class,
-    org.apache.sis.referencing.operation.DefaultOperationMethodTest.class,
-
     org.apache.sis.geometry.AbstractDirectPositionTest.class,
     org.apache.sis.geometry.GeneralDirectPositionTest.class,
     org.apache.sis.geometry.DirectPosition1DTest.class,



Mime
View raw message