You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2024/02/08 17:31:57 UTC

(sis) branch geoapi-4.0 updated (738fd95772 -> 11bade0b82)

This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a change to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git


    from 738fd95772 Move to public API the annotation used for documenting methods that use assertions for arguments validation.
     new 39cac3fa63 Simplify the merge of identifiers during WKT parsing.
     new 11bade0b82 Rename an internal method: `negativeResult` → `emptyResult`.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/sis/filter/BinaryGeometryFilter.java  |  6 +++---
 .../org/apache/sis/filter/BinarySpatialFilter.java   |  6 +++---
 .../main/org/apache/sis/filter/DistanceFilter.java   |  6 +++---
 .../apache/sis/geometry/wrapper/GeometryWrapper.java |  4 ++--
 .../geometry/wrapper/SpatialOperationContext.java    |  4 ++--
 .../org/apache/sis/io/wkt/GeodeticObjectParser.java  | 20 ++++++++------------
 6 files changed, 21 insertions(+), 25 deletions(-)


(sis) 02/02: Rename an internal method: `negativeResult` → `emptyResult`.

Posted by de...@apache.org.
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 11bade0b822800f949eb5c05058a023bbea8bb00
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Thu Feb 8 18:27:17 2024 +0100

    Rename an internal method: `negativeResult` → `emptyResult`.
---
 .../main/org/apache/sis/filter/BinaryGeometryFilter.java            | 6 +++---
 .../main/org/apache/sis/filter/BinarySpatialFilter.java             | 6 +++---
 .../main/org/apache/sis/filter/DistanceFilter.java                  | 6 +++---
 .../main/org/apache/sis/geometry/wrapper/GeometryWrapper.java       | 4 ++--
 .../org/apache/sis/geometry/wrapper/SpatialOperationContext.java    | 4 ++--
 5 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/BinaryGeometryFilter.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/BinaryGeometryFilter.java
index c7f0875914..61e27d49eb 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/BinaryGeometryFilter.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/BinaryGeometryFilter.java
@@ -209,8 +209,8 @@ abstract class BinaryGeometryFilter<R> extends Node implements SpatialOperator<R
         literalIsNull = (literal.getValue() == null);
         final boolean result;
         if (literalIsNull) {
-            // If the literal has no value, then the filter will always evaluate to a negative result.
-            result = negativeResult();
+            // If the literal has no value, then the filter will always evaluate to an empty result.
+            result = emptyResult();
         } else {
             /*
              * If we are optimizing for a feature type, and if the other expression is a property value,
@@ -252,5 +252,5 @@ abstract class BinaryGeometryFilter<R> extends Node implements SpatialOperator<R
     /**
      * Returns the value to return when a test cannot be applied.
      */
-    protected abstract boolean negativeResult();
+    protected abstract boolean emptyResult();
 }
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/BinarySpatialFilter.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/BinarySpatialFilter.java
index 7a3eb192d2..240cd00afc 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/BinarySpatialFilter.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/BinarySpatialFilter.java
@@ -147,14 +147,14 @@ final class BinarySpatialFilter<R> extends BinaryGeometryFilter<R> implements Bi
                 warning(e, true);
             }
         }
-        return negativeResult();
+        return emptyResult();
     }
 
     /**
      * Returns the value to return when a test cannot be applied.
      */
     @Override
-    protected boolean negativeResult() {
-        return SpatialOperationContext.negativeResult(operatorType);
+    protected boolean emptyResult() {
+        return SpatialOperationContext.emptyResult(operatorType);
     }
 }
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/DistanceFilter.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/DistanceFilter.java
index 4b551af15d..72d5a396fc 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/DistanceFilter.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/DistanceFilter.java
@@ -164,14 +164,14 @@ final class DistanceFilter<R> extends BinaryGeometryFilter<R> implements Distanc
                 warning(e, true);
             }
         }
-        return negativeResult();
+        return emptyResult();
     }
 
     /**
      * Returns the value to return when a test cannot be applied.
      */
     @Override
-    protected boolean negativeResult() {
-        return SpatialOperationContext.negativeResult(operatorType);
+    protected boolean emptyResult() {
+        return SpatialOperationContext.emptyResult(operatorType);
     }
 }
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/GeometryWrapper.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/GeometryWrapper.java
index 7771d235e7..51c7e8f5f5 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/GeometryWrapper.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/GeometryWrapper.java
@@ -220,7 +220,7 @@ public abstract class GeometryWrapper extends AbstractGeometry implements Geomet
          * No common CRS. Consider that we have no intersection, no overlap, etc.
          * since the two geometries are existing in different coordinate spaces.
          */
-        return SpatialOperationContext.negativeResult(type);
+        return SpatialOperationContext.emptyResult(type);
     }
 
     /**
@@ -252,7 +252,7 @@ public abstract class GeometryWrapper extends AbstractGeometry implements Geomet
          * No common CRS. Consider that we have no intersection, no overlap, etc.
          * since the two geometries are existing in different coordinate spaces.
          */
-        return SpatialOperationContext.negativeResult(type);
+        return SpatialOperationContext.emptyResult(type);
     }
 
     /**
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/SpatialOperationContext.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/SpatialOperationContext.java
index eb2d80eda3..f6c399813b 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/SpatialOperationContext.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/SpatialOperationContext.java
@@ -450,7 +450,7 @@ select: if (commonCRS == null) {
      * @param   type  the test that could not be applied.
      * @return  the operation result to assume.
      */
-    public static boolean negativeResult(final SpatialOperatorName type) {
+    public static boolean emptyResult(final SpatialOperatorName type) {
         return type == SpatialOperatorName.DISJOINT;
     }
 
@@ -461,7 +461,7 @@ select: if (commonCRS == null) {
      * @param   type  the test that could not be applied.
      * @return  the operation result to assume.
      */
-    public static boolean negativeResult(final DistanceOperatorName type) {
+    public static boolean emptyResult(final DistanceOperatorName type) {
         return type == DistanceOperatorName.BEYOND;
     }
 }


(sis) 01/02: Simplify the merge of identifiers during WKT parsing.

Posted by de...@apache.org.
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 39cac3fa63980e1ae74e7649cd3ece81de19457a
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Thu Feb 8 18:13:10 2024 +0100

    Simplify the merge of identifiers during WKT parsing.
---
 .../org/apache/sis/io/wkt/GeodeticObjectParser.java  | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/GeodeticObjectParser.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/GeodeticObjectParser.java
index 12d578e6bc..94e7851074 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/GeodeticObjectParser.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/GeodeticObjectParser.java
@@ -78,6 +78,7 @@ import org.apache.sis.metadata.iso.extent.DefaultTemporalExtent;
 import org.apache.sis.metadata.internal.AxisNames;
 import org.apache.sis.metadata.internal.TransformationAccuracy;
 import org.apache.sis.referencing.operation.provider.AbstractProvider;
+import org.apache.sis.util.ArraysExt;
 import org.apache.sis.util.internal.Constants;
 import org.apache.sis.util.internal.Numerics;
 import org.apache.sis.util.internal.Strings;
@@ -452,22 +453,17 @@ class GeodeticObjectParser extends MathTransformParser implements Comparator<Coo
              * (for example "WGS84" for the datum instead of "World Geodetic System 1984"),
              * so the name in WKT is often not compliant with the name actually defined by the authority.
              */
-            final ImmutableIdentifier id = new ImmutableIdentifier(Citations.fromName(authority),
+            final var id = new ImmutableIdentifier(Citations.fromName(authority),
                     codeSpace, code, (version != null) ? version.toString() : null, null);
-            final Object previous = properties.put(IdentifiedObject.IDENTIFIERS_KEY, id);
-            if (previous != null) {
-                Identifier[] identifiers;
+            properties.merge(IdentifiedObject.IDENTIFIERS_KEY, id, (previous, toAdd) -> {
+                final var more = (Identifier) toAdd;
                 if (previous instanceof Identifier) {
-                    identifiers = new Identifier[] {(Identifier) previous, id};
+                    return new Identifier[] {(Identifier) previous, more};
                 } else {
-                    identifiers = (Identifier[]) previous;
-                    final int n = identifiers.length;
-                    identifiers = Arrays.copyOf(identifiers, n + 1);
-                    identifiers[n] = id;
+                    return ArraysExt.append((Identifier[]) previous, more);
                 }
-                properties.put(IdentifiedObject.IDENTIFIERS_KEY, identifiers);
-                // REMINDER: values associated to IDENTIFIERS_KEY shall be recognized by `toIdentifier(Object)`.
-            }
+            });
+            // REMINDER: values associated to IDENTIFIERS_KEY shall be recognized by `toIdentifier(Object)`.
         }
         /*
          * Other metadata (SCOPE, AREA, etc.).  ISO 19162 said that at most one of each type shall be present,