sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] branch geoapi-4.0 updated: Move the check for identity case into Matrices.createTransform(…). It allows the fix to apply to a wider range of cases.
Date Fri, 11 Jan 2019 14:23:30 GMT
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new 678e7ee  Move the check for identity case into Matrices.createTransform(…). It
allows the fix to apply to a wider range of cases.
678e7ee is described below

commit 678e7eeafa1d50855050654214ebfeeca3a88767
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Fri Jan 11 14:49:57 2019 +0100

    Move the check for identity case into Matrices.createTransform(…). It allows the fix
to apply to a wider range of cases.
---
 .../java/org/apache/sis/referencing/cs/CoordinateSystems.java  |  3 ---
 .../org/apache/sis/referencing/operation/matrix/Matrices.java  | 10 +++++++++-
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java
index 94f01e9..b8a00a3 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java
@@ -281,9 +281,6 @@ public final class CoordinateSystems extends Static {
         if (!Classes.implementSameInterfaces(sourceCS.getClass(), targetCS.getClass(), CoordinateSystem.class))
{
             throw new IllegalArgumentException(Resources.format(Resources.Keys.IncompatibleCoordinateSystemTypes));
         }
-        if (sourceCS.equals(targetCS)) {
-            return Matrices.createIdentity(sourceCS.getDimension() + 1);
-        }
         final AxisDirection[] srcAxes = getAxisDirections(sourceCS);
         final AxisDirection[] dstAxes = getAxisDirections(targetCS);
         final MatrixSIS matrix = Matrices.createTransform(srcAxes, dstAxes);
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java
index d931d8c..a66c03d 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java
@@ -16,6 +16,7 @@
  */
 package org.apache.sis.referencing.operation.matrix;
 
+import java.util.Arrays;
 import java.util.Objects;
 import org.opengis.geometry.Envelope;
 import org.opengis.geometry.DirectPosition;
@@ -68,7 +69,7 @@ import org.apache.sis.internal.referencing.ExtendedPrecisionMatrix;
  * </ul>
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
- * @version 0.8
+ * @version 1.0
  *
  * @see org.apache.sis.parameter.TensorParameters
  *
@@ -438,6 +439,13 @@ public final class Matrices extends Static {
     public static MatrixSIS createTransform(final AxisDirection[] srcAxes, final AxisDirection[]
dstAxes) {
         ArgumentChecks.ensureNonNull("srcAxes", srcAxes);
         ArgumentChecks.ensureNonNull("dstAxes", dstAxes);
+        if (Arrays.equals(srcAxes, dstAxes)) {
+            /*
+             * createTransform(…) may fail if the arrays contain two axes with the same
direction, for example
+             * AxisDirection.OTHER. This check prevents that failure for the common case
of an identity transform.
+             */
+            return Matrices.createIdentity(srcAxes.length + 1);
+        }
         return createTransform(null, srcAxes, null, dstAxes, false);
     }
 


Mime
View raw message