sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 02/03: Fix an mismatched dimension errors when the source CRS has more dimensions than the core transform.
Date Mon, 17 Aug 2020 18:18:52 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

commit 7c71f388d5763036de1ad6641f43588f5a3e0723
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Mon Aug 17 15:14:55 2020 +0200

    Fix an mismatched dimension errors when the source CRS has more dimensions than the core
transform.
---
 .../operation/transform/DefaultMathTransformFactory.java  | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
index a1c77ce..91c70f0 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
@@ -79,6 +79,7 @@ import org.apache.sis.referencing.operation.matrix.Matrices;
 import org.apache.sis.measure.Units;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.CharSequences;
+import org.apache.sis.util.ArraysExt;
 import org.apache.sis.util.Classes;
 import org.apache.sis.util.collection.WeakHashSet;
 import org.apache.sis.util.iso.AbstractFactory;
@@ -1225,11 +1226,17 @@ public class DefaultMathTransformFactory extends AbstractFactory implements
Math
          *
          * The reverse order (projected source CRS and geographic target CRS) is also accepted
but should be uncommon.
          */
-        final int resultDim = step3.getSourceDimensions();
-        final int numTrailingCoordinates = resultDim - step2.getTargetDimensions();
-        if (numTrailingCoordinates > 0) {
+        final int resultDim = step3.getSourceDimensions();              // Final result (minus
trivial changes).
+        final int kernelDim = step2.getTargetDimensions();              // Result of the
core part of transform.
+        final int numTrailingCoordinates = resultDim - kernelDim;
+        if (numTrailingCoordinates != 0) {
             ensureDimensionChangeAllowed(parameterized, context, numTrailingCoordinates,
resultDim);
-            step2 = createPassThroughTransform(0, step2, numTrailingCoordinates);
+            if (numTrailingCoordinates > 0) {
+                step2 = createPassThroughTransform(0, step2, numTrailingCoordinates);
+            } else {
+                step2 = createConcatenatedTransform(step2, createAffineTransform(
+                        Matrices.createDimensionSelect(kernelDim, ArraysExt.range(0, resultDim))));
+            }
         }
         /*
          * If the source CS has a height but the target CS doesn't, drops the extra coordinates.


Mime
View raw message