sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 03/04: Minor performance improvement in `WraparoundTransform.concatenate(…)`. Add a note in documentation about information lost during WKT formatting.
Date Fri, 09 Oct 2020 11:07:07 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 5e65f02b5b3300fa8cfa6a15ba236d9eab9b2af7
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Thu Oct 8 23:52:28 2020 +0200

    Minor performance improvement in `WraparoundTransform.concatenate(…)`.
    Add a note in documentation about information lost during WKT formatting.
---
 .../sis/referencing/operation/transform/AbstractMathTransform.java | 2 ++
 .../operation/transform/DefaultMathTransformFactory.java           | 6 ++++++
 .../sis/referencing/operation/transform/WraparoundTransform.java   | 7 ++++---
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
index 06735cf..97c30e5 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
@@ -1005,6 +1005,8 @@ public abstract class AbstractMathTransform extends FormattableObject
      *
      * @param  formatter  the formatter to use.
      * @return the WKT element name, which is {@code "Param_MT"} in the default implementation.
+     *
+     * @see DefaultMathTransformFactory#createFromWKT(String)
      */
     @Override
     protected String formatTo(final Formatter formatter) {
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 91c70f0..4190e33 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
@@ -1523,6 +1523,12 @@ public class DefaultMathTransformFactory extends AbstractFactory implements
Math
      * inconsistent unit definitions, <i>etc.</i>), warnings may be reported
in a
      * {@linkplain java.util.logging.Logger logger} named {@code "org.apache.sis.io.wkt"}.
      *
+     * <p>Note that the WKT format is not always lossless. A {@code MathTransform}
recreated from WKT may be
+     * non-invertible even if the original transform was invertible. For example if an "Affine"
operation is
+     * defined by a non-square matrix, Apache SIS implementation sometime has "hidden" information
about the
+     * inverse matrix but those information are lost at WKT formatting time. A similar "hidden"
information
+     * lost may also happen with {@link WraparoundTransform}, also making that transform
non-invertible.</p>
+     *
      * @param  text  math transform encoded in Well-Known Text format.
      * @return the math transform (never {@code null}).
      * @throws FactoryException if the Well-Known Text can not be parsed,
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/WraparoundTransform.java
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/WraparoundTransform.java
index 59dfefc..a50ccea 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/WraparoundTransform.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/WraparoundTransform.java
@@ -249,15 +249,16 @@ public class WraparoundTransform extends AbstractMathTransform implements
Serial
     {
         ArgumentChecks.ensureNonNull("transform",   transform);
         ArgumentChecks.ensureNonNull("replacement", replacement);
-        if (transform instanceof WraparoundTransform) {
-            transform = Objects.requireNonNull(replacement.apply((WraparoundTransform) transform));
-        } else if (transform instanceof ConcatenatedTransform) {
+        if (transform instanceof ConcatenatedTransform) {
             final ConcatenatedTransform ct = (ConcatenatedTransform) transform;
             final MathTransform tr1 = replace(ct.transform1, replacement);
             final MathTransform tr2 = replace(ct.transform2, replacement);
             if (tr1 != ct.transform1 || tr2 != ct.transform2) {
                 transform = MathTransforms.concatenate(tr1, tr2);
             }
+        } else if (transform instanceof WraparoundTransform) {
+            // Tested last because less frequent (most often, does not happen at all).
+            transform = Objects.requireNonNull(replacement.apply((WraparoundTransform) transform));
         }
         return transform;
     }


Mime
View raw message