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 4065171388b647f26914d5fc7d34d21a221954b3
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Mon Jan 26 16:55:07 2026 +0100

    Add a note about a work to do in `PassThroughTransform`.
---
 .../operation/transform/PassThroughTransform.java       | 10 +++-------
 .../operation/transform/TransformJoiner.java            | 17 ++++++++---------
 .../operation/transform/WraparoundTransform.java        |  5 +++--
 3 files changed, 14 insertions(+), 18 deletions(-)

diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/PassThroughTransform.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/PassThroughTransform.java
index c775ff5db7..fd1e6c7d78 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/PassThroughTransform.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/PassThroughTransform.java
@@ -825,13 +825,6 @@ public class PassThroughTransform extends 
AbstractMathTransform implements Seria
          * which above loop was executed.
          */
         if (m == null) {
-            /*
-             * Do not invoke `super.tryConcatenate(context)`. We do not want 
to test if this transform
-             * is the inverse of the `other` transform because this check is 
costly and unnecessary.
-             * If the two transforms were the inverse of each other, then the 
concatenation of
-             * `this.subTransform` with `other.subTransform` done at the 
beginning of this method
-             * would have produced the identity transform already.
-             */
             return;
         }
         /*
@@ -852,6 +845,9 @@ public class PassThroughTransform extends 
AbstractMathTransform implements Seria
             }
         }
         /*
+         * TODO: replace the remaining code by a call to 
`TransformJoiner.reduceDimension(…)`.
+         * But first, we need to verify if this is really equivalent.
+         *
          * Verify if matrix discards the sub-transform. If it does not, then 
we need to keep all the sub-transform
          * dimensions (discarding them is a "all or nothing" operation). Other 
dimensions (leading and trailing)
          * can be keep or discarded on a case-by-case basis.
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/TransformJoiner.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/TransformJoiner.java
index 42ab864fca..b4562242a4 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/TransformJoiner.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/TransformJoiner.java
@@ -22,7 +22,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Iterator;
 import java.util.Optional;
-import java.util.Set;
 import java.util.function.BiFunction;
 import java.util.function.IntFunction;
 import java.util.function.UnaryOperator;
@@ -785,14 +784,14 @@ valid:  if (i >= 0 && i < steps.size()) {
      * (depending on the second argument) equals to {@link 
BitSet#cardinality()}, or {@code null}
      * if the reducer cannot build the transform.
      *
-     * @param  inputDimensions   dimensions of coordinates used by the main 
transform.
-     * @param  outputDimensions  dimensions of coordinates with a value 
modified by the transform.
+     * @param  inputDimensions   dimensions of input coordinates of the main 
transform that are not pass-through.
+     * @param  outputDimensions  dimensions of output coordinates of the main 
transform that are not pass-through.
      * @param  reducer  a constructor accepting selected dimension and 
returning the new transform.
      * @return whether  the transform chain has been modified as a result of 
this method call.
      * @throws FactoryException if the concatenation is not a valid 
replacement.
      */
-    final boolean reduceDimension(final Set<Integer> inputDimensions,
-                                  final Set<Integer> outputDimensions,
+    final boolean reduceDimension(final BitSet inputDimensions,
+                                  final BitSet outputDimensions,
                                   final BiFunction<BitSet, Integer, 
MathTransform> reducer)
             throws FactoryException
     {
@@ -820,7 +819,7 @@ prepare:    if (relativeIndex < 0) {
                  * We will try to move `matrix` after the main transform for 
making that transform smaller.
                  * We only need to keep the rows which modify the input 
coordinates of the main transform.
                  */
-                inputDimensions.forEach(rowsToKeep::set);
+                rowsToKeep.or(inputDimensions);
                 if (rowsToKeep.length() >= numCol) continue;
             } else {
                 /*
@@ -828,13 +827,13 @@ prepare:    if (relativeIndex < 0) {
                  * We will try to move `matrix` before the main transform for 
making that transform smaller.
                  * But we cannot move the rows which depend on the output 
coordinates of the main transform.
                  */
-                for (int i : outputDimensions) {
+                outputDimensions.stream().forEach((i) -> {
                     for (int j=0; j<numRow; j++) {
                         if (move.getElement(j, i) != 0) {
                             rowsToKeep.set(j);
                         }
                     }
-                }
+                });
                 if (rowsToKeep.isEmpty()) {
                     if (replace(0, 
factory.createAffineTransform(createDiagonalMatrix(0)))) {
                         return true;
@@ -865,7 +864,7 @@ prepare:    if (relativeIndex < 0) {
              * the coordinates modified by `move` will not impact or will not 
be impacted (depending on
              * whether `move` will be moved to the right or to the left) by 
the main transform.
              */
-            (relativeIndex < 0 ? outputDimensions : 
inputDimensions).forEach(rowsToKeep::set);
+            rowsToKeep.or(relativeIndex < 0 ? outputDimensions : 
inputDimensions);
             // Check input coordinates (columns) because `move` is still a 
step after `keep`.
             for (int i=0; (i = rowsToKeep.nextSetBit(i)) >= 0; i++) {
                 for (int j=0; j<numRow; j++) {
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/WraparoundTransform.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/WraparoundTransform.java
index ac1100232f..55167755e4 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/WraparoundTransform.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/WraparoundTransform.java
@@ -16,7 +16,7 @@
  */
 package org.apache.sis.referencing.operation.transform;
 
-import java.util.Set;
+import java.util.BitSet;
 import java.util.HashMap;
 import java.util.Objects;
 import java.util.function.Function;
@@ -495,7 +495,8 @@ public class WraparoundTransform extends 
AbstractMathTransform implements Serial
             return;
         }
         if (getClass() == WraparoundTransform.class) {      // Because we did 
not defined an overrideable `redimension` method yet.
-            final var workOn = Set.of(wraparoundDimension);
+            final var workOn = new BitSet();
+            workOn.set(wraparoundDimension);
             if (context.reduceDimension(workOn, workOn,
                     (selected, ignored) -> new WraparoundTransform(
                             selected.cardinality(),

Reply via email to