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

asf-gitbox-commits 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 f9ada6f7bc Be more tolerant in the comparison of members of a datum 
ensemble.
f9ada6f7bc is described below

commit f9ada6f7bccf6347d00cc8a032707d78011c4ab3
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Thu May 7 12:56:18 2026 +0200

    Be more tolerant in the comparison of members of a datum ensemble.
---
 .../referencing/datum/DefaultDatumEnsemble.java    | 30 ++++++++++++----------
 .../apache/sis/referencing/datum/package-info.java |  2 +-
 .../test/org/apache/sis/io/wkt/WKTFormatTest.java  | 21 +++++++++++++--
 3 files changed, 36 insertions(+), 17 deletions(-)

diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultDatumEnsemble.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultDatumEnsemble.java
index e733eb37e6..f61d51f2b9 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultDatumEnsemble.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultDatumEnsemble.java
@@ -82,7 +82,7 @@ import org.opengis.referencing.datum.RealizationMethod;
  * For getting a single object which may be a datum or an ensemble, see the 
{@link DatumOrEnsemble} static methods.</p>
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.5
+ * @version 1.7
  *
  * @param <D> the type of datum members contained in this ensemble.
  *
@@ -490,21 +490,23 @@ check:  if (it.hasNext()) {
      * @hidden because nothing new to said.
      */
     @Override
-    public boolean equals(final Object object, final ComparisonMode mode) {
-        if (!super.equals(object, mode)) {
-            return false;
-        }
-        switch (mode) {
-            case STRICT: {
-                final var that = (DefaultDatumEnsemble<?>) object;
-                return members.equals(that.members) && 
ensembleAccuracy.equals(that.ensembleAccuracy);
-            }
-            default: {
-                final var that = (DatumEnsemble<?>) object;
-                return Utilities.deepEquals(getMembers(), that.getMembers(), 
mode) &&
-                       Utilities.deepEquals(getEnsembleAccuracy(), 
that.getEnsembleAccuracy(), mode);
+    public boolean equals(final Object object, ComparisonMode mode) {
+        if (super.equals(object, mode)) {
+            switch (mode) {
+                case STRICT: {
+                    final var that = (DefaultDatumEnsemble<?>) object;
+                    return members.equals(that.members) && 
ensembleAccuracy.equals(that.ensembleAccuracy);
+                }
+                default: {
+                    final var that = (DatumEnsemble<?>) object;
+                    if (Utilities.deepEquals(getEnsembleAccuracy(), 
that.getEnsembleAccuracy(), mode)) {
+                        if (mode == ComparisonMode.IGNORE_METADATA) mode = 
ComparisonMode.COMPATIBILITY;
+                        return Utilities.deepEquals(getMembers(), 
that.getMembers(), mode);
+                    }
+                }
             }
         }
+        return false;
     }
 
     /**
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/package-info.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/package-info.java
index 57bb360e1d..a291048161 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/package-info.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/package-info.java
@@ -52,7 +52,7 @@
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @author  Cédric Briançon (Geomatys)
- * @version 1.6
+ * @version 1.7
  * @since   0.4
  */
 @XmlSchema(location = "http://schemas.opengis.net/gml/3.2.1/datums.xsd";,
diff --git 
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/WKTFormatTest.java
 
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/WKTFormatTest.java
index 1e9140068f..11ae21e03f 100644
--- 
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/WKTFormatTest.java
+++ 
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/WKTFormatTest.java
@@ -23,9 +23,11 @@ import java.text.ParseException;
 import java.time.ZoneId;
 import org.opengis.parameter.ParameterValue;
 import org.opengis.referencing.crs.VerticalCRS;
+import org.opengis.referencing.crs.GeographicCRS;
 import org.opengis.referencing.operation.MathTransformFactory;
 import org.apache.sis.measure.Units;
 import org.apache.sis.metadata.iso.citation.Citations;
+import org.apache.sis.referencing.CommonCRS;
 import org.apache.sis.referencing.crs.DefaultProjectedCRS;
 import org.apache.sis.referencing.datum.DefaultPrimeMeridian;
 import org.apache.sis.parameter.DefaultParameterValue;
@@ -87,6 +89,21 @@ public final class WKTFormatTest extends TestCase {
         GeodeticObjectParserTest.assertNameAndIdentifierEqual("Mean Sea 
Level", 0, crs.getDatum());
     }
 
+    /**
+     * Ensures that formatting {@code CRS:84} and parsing it produces an 
equivalent object.
+     *
+     * @throws ParseException if the parsing failed.
+     */
+    @Test
+    public void testRoundtrip() throws ParseException {
+        format = parser = new WKTFormat();
+        format.setConvention(Convention.WKT2);
+        final GeographicCRS crs = CommonCRS.WGS84.normalizedGeographic();
+        final String wkt = format.format(crs);
+        var parsed = assertInstanceOf(GeographicCRS.class, 
parser.parseObject(wkt));
+        assertEqualsIgnoreMetadata(crs, parsed);
+    }
+
     /**
      * Tests consistency between the parser and the formatter when using the 
WKT 1 format.
      * This test parses a WKT, formats it then parses again. We should obtain 
the same result.
@@ -242,7 +259,7 @@ public final class WKTFormatTest extends TestCase {
      */
     @Test
     public void testConsistencyOfGeogTran() throws ParseException {
-        final Symbols symbols = new Symbols(Symbols.SQUARE_BRACKETS);
+        final var symbols = new Symbols(Symbols.SQUARE_BRACKETS);
         symbols.setPairedQuotes("“”", "\"\"");
         format = new WKTFormat();
         format.setConvention(Convention.WKT1_IGNORE_AXES);
@@ -268,7 +285,7 @@ public final class WKTFormatTest extends TestCase {
     }
 
     /**
-     * Implementation of {@link #testConsistency()} for a single WKT.
+     * Implementation of {@link #testConsistency()} for a single 
<abbr>WKT</abbr>.
      *
      * @param  strict  whether to require strict equality of WKT strings.
      * @param  wkt     the Well-Known Text to parse and reformat.

Reply via email to