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 68225b78a9 Fix an exception in the creation of a concatenated 
operation when one of the steps has different source and target CRS but 
nevertheless an identity transform.
68225b78a9 is described below

commit 68225b78a9cc7ab5330a6344395cf3e2ef6b420a
Author: Martin Desruisseaux <martin.desruisse...@geomatys.com>
AuthorDate: Mon Feb 3 11:09:50 2025 +0100

    Fix an exception in the creation of a concatenated operation
    when one of the steps has different source and target CRS but
    nevertheless an identity transform.
---
 .../sis/referencing/operation/DefaultConcatenatedOperation.java   | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
index 90aa8b6b0c..014ea8313c 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
@@ -165,7 +165,7 @@ final class DefaultConcatenatedOperation extends 
AbstractCoordinateOperation imp
                             final MathTransformFactory  mtFactory)
             throws FactoryException
     {
-        final List<CoordinateOperation> flattened = new 
ArrayList<>(operations.length);
+        final var flattened = new 
ArrayList<CoordinateOperation>(operations.length);
         final CoordinateReferenceSystem crs = initialize(properties, 
operations, flattened, mtFactory,
                 sourceCRS, (sourceCRS == null), (coordinateOperationAccuracy 
== null));
 
@@ -285,9 +285,11 @@ final class DefaultConcatenatedOperation extends 
AbstractCoordinateOperation imp
             if (op instanceof ConcatenatedOperation) {
                 final var nested = ((ConcatenatedOperation) 
op).getOperations().toArray(CoordinateOperation[]::new);
                 previous = initialize(properties, nested, flattened, null, 
previous, false, setAccuracy);
-            } else if (!step.isIdentity()) {
+            } else {
                 // Note: operation (source, target) may be in reverse order, 
but it should be taken as metadata.
-                flattened.add(op);
+                if (!step.isIdentity()) {
+                    flattened.add(op);
+                }
                 previous = target;          // For next iteration cycle.
             }
             if (mtFactory != null) {

Reply via email to