sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 02/02: Remove an unnecessary field and add a clarification in documentation.
Date Wed, 05 Jun 2019 09:46:18 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 df4d04d68e41cf364e7b3584dd2eca95cf8cf644
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Wed Jun 5 11:43:12 2019 +0200

    Remove an unnecessary field and add a clarification in documentation.
---
 .../operation/transform/TransformSeparator.java    | 23 ++++++++--------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/TransformSeparator.java
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/TransformSeparator.java
index 6a12a80..592e1e3 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/TransformSeparator.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/TransformSeparator.java
@@ -97,15 +97,6 @@ public class TransformSeparator {
     private final MathTransformsOrFactory factory;
 
     /**
-     * Whether {@link #sourceDimensions} have been specified explicitly. If {@code false},
then {@link #separate()}
-     * will try to reduce the set of source dimensions to the smallest set required for computing
the target dimensions.
-     *
-     * <p>The default value is {@code false}. The value become {@code true} if the
user specified explicitly the desired
-     * source dimensions, in which case removing source dimensions become disallowed.</p>
-     */
-    private boolean isSourceSpecified;
-
-    /**
      * Constructs a separator for the given transform.
      *
      * @param transform  the transform to separate.
@@ -133,9 +124,8 @@ public class TransformSeparator {
      * for example an horizontal and a vertical component.
      */
     public void clear() {
-        sourceDimensions  = null;
-        targetDimensions  = null;
-        isSourceSpecified = false;
+        sourceDimensions = null;
+        targetDimensions = null;
     }
 
     /**
@@ -254,7 +244,6 @@ public class TransformSeparator {
     public void addSourceDimensions(final int... dimensions) throws IllegalArgumentException
{
         ArgumentChecks.ensureNonNull("dimensions", dimensions);
         sourceDimensions = add(sourceDimensions, dimensions, transform.getSourceDimensions());
-        isSourceSpecified = true;
     }
 
     /**
@@ -268,7 +257,6 @@ public class TransformSeparator {
      */
     public void addSourceDimensionRange(final int lower, final int upper) throws IllegalArgumentException
{
         sourceDimensions = add(sourceDimensions, lower, upper, transform.getSourceDimensions());
-        isSourceSpecified = true;
     }
 
     /**
@@ -375,6 +363,10 @@ public class TransformSeparator {
      *
      *   <li>If target dimensions were unspecified, then the returned transform will
expect only the specified
      *       source dimensions as inputs, and the target dimensions will be inferred automatically.</li>
+     *
+     *   <li>If neither source and target positions were specified, then the returned
transform will have the same
+     *       set of target dimensions, but only the set of source dimensions required for
computing those targets.
+     *       In other words, this method drops unused source dimensions.</li>
      * </ul>
      *
      * The source and target dimensions actually used can be queried by calls to {@link #getSourceDimensions()}
@@ -385,6 +377,7 @@ public class TransformSeparator {
      */
     public MathTransform separate() throws FactoryException {
         MathTransform tr = transform;
+        final boolean isSourceSpecified = (sourceDimensions != null);
         if (sourceDimensions == null || containsAll(sourceDimensions, 0, tr.getSourceDimensions()))
{
             if (targetDimensions != null && !containsAll(targetDimensions, 0, tr.getTargetDimensions()))
{
                 tr = filterTargetDimensions(tr, targetDimensions);
@@ -690,7 +683,7 @@ reduce:     for (int j=0; j <= numTgt; j++) {
 
     /**
      * Removes the sources dimensions that are not required for computing the target dimensions.
-     * This method is invoked only if {@link #isSourceSpecified} is {@code false}.
+     * This method is invoked only if {@link #sourceDimensions} is non-null at {@link #separate()}
invocation time.
      * This method can operate only on the first transform of a transformation chain.
      * If this method succeed, then {@link #sourceDimensions} will be updated.
      *


Mime
View raw message