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 2025/08/23 14:50:18 UTC
(sis) 01/02: Add a new `ComparisonMode.COMPATIBILITY` enumeration value for handling the difference between old and new definition of WGS84 datum. Modify the rest of Apache SIS source code for using that new compatibility mode when appropriate.
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 4126048b2ae70a07543e6852f02f70515b1261c5
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Sat Aug 23 15:00:11 2025 +0200
Add a new `ComparisonMode.COMPATIBILITY` enumeration value for handling the difference between old and new definition of WGS84 datum.
Modify the rest of Apache SIS source code for using that new compatibility mode when appropriate.
---
.../sis/coverage/grid/DimensionalityReduction.java | 2 +-
.../org/apache/sis/coverage/grid/GridExtent.java | 2 +-
.../org/apache/sis/coverage/grid/GridGeometry.java | 2 +-
.../sis/coverage/grid/ResampledGridCoverage.java | 7 +-
.../geometry/wrapper/SpatialOperationContext.java | 9 +-
.../org/apache/sis/geometry/wrapper/jts/JTS.java | 5 +-
.../coverage/grid/DimensionalityReductionTest.java | 2 +-
.../metadata/iso/extent/DefaultVerticalExtent.java | 3 +-
.../main/org/apache/sis/temporal/TemporalDate.java | 2 +-
.../org/apache/sis/map/coverage/RenderingData.java | 3 +-
.../main/org/apache/sis/portrayal/Canvas.java | 13 +-
.../gazetteer/AbstractLocationType.java | 4 +-
.../gazetteer/GeohashReferenceSystem.java | 5 +-
.../gazetteer/MilitaryGridReferenceSystem.java | 5 +-
.../gazetteer/ReferencingByIdentifiers.java | 4 +-
.../sis/coordinate/DefaultCoordinateMetadata.java | 4 +-
.../sis/geometry/AbstractDirectPosition.java | 6 +-
.../org/apache/sis/geometry/AbstractEnvelope.java | 2 +-
.../org/apache/sis/geometry/EnvelopeReducer.java | 5 +-
.../main/org/apache/sis/geometry/Envelopes.java | 6 +-
.../apache/sis/geometry/WraparoundAdjustment.java | 3 +-
.../sis/parameter/DefaultParameterDescriptor.java | 6 +-
.../sis/parameter/DefaultParameterValueGroup.java | 8 +-
.../parameter/UnmodifiableParameterValueGroup.java | 8 +-
.../sis/referencing/AbstractIdentifiedObject.java | 15 +--
.../main/org/apache/sis/referencing/CRS.java | 36 ++++-
.../sis/referencing/DefaultObjectDomain.java | 3 +-
.../apache/sis/referencing/IdentifiedObjects.java | 21 ++-
.../apache/sis/referencing/crs/AbstractCRS.java | 4 +-
.../sis/referencing/crs/AbstractDerivedCRS.java | 4 +-
.../sis/referencing/crs/AbstractSingleCRS.java | 4 +-
.../sis/referencing/crs/DefaultCompoundCRS.java | 4 +-
.../sis/referencing/crs/DefaultDerivedCRS.java | 8 +-
.../sis/referencing/crs/DefaultProjectedCRS.java | 8 +-
.../org/apache/sis/referencing/cs/AbstractCS.java | 26 ++--
.../sis/referencing/cs/DefaultCompoundCS.java | 4 +-
.../cs/DefaultCoordinateSystemAxis.java | 4 +-
.../sis/referencing/datum/AbstractDatum.java | 10 +-
.../referencing/datum/DefaultDatumEnsemble.java | 4 +-
.../sis/referencing/datum/DefaultEllipsoid.java | 11 +-
.../referencing/datum/DefaultGeodeticDatum.java | 6 +-
.../sis/referencing/datum/DefaultImageDatum.java | 4 +-
.../referencing/datum/DefaultPrimeMeridian.java | 14 +-
.../referencing/datum/DefaultTemporalDatum.java | 4 +-
.../referencing/datum/DefaultVerticalDatum.java | 4 +-
.../referencing/internal/PositionTransformer.java | 6 +-
.../apache/sis/referencing/internal/RTreeNode.java | 4 +-
.../operation/AbstractCoordinateOperation.java | 16 +--
.../apache/sis/referencing/operation/CRSPair.java | 7 +-
.../operation/CoordinateOperationFinder.java | 2 +-
.../operation/CoordinateOperationRegistry.java | 2 +-
.../operation/DefaultConcatenatedOperation.java | 1 +
.../operation/DefaultOperationMethod.java | 4 +-
.../sis/referencing/operation/matrix/Matrices.java | 15 +--
.../operation/projection/NormalizedProjection.java | 5 +-
.../operation/transform/AbstractMathTransform.java | 2 +-
.../sis/storage/geotiff/reader/CRSBuilder.java | 6 +-
.../apache/sis/storage/netcdf/base/CRSMerger.java | 4 +-
.../sis/storage/sql/feature/InfoStatements.java | 4 +-
.../sis/storage/sql/feature/SelectionClause.java | 4 +-
.../sis/storage/aggregate/CoverageAggregator.java | 2 +-
.../apache/sis/storage/aggregate/GroupByCRS.java | 4 +-
.../apache/sis/storage/image/WritableStore.java | 2 +-
.../main/org/apache/sis/util/ComparisonMode.java | 146 ++++++++++++---------
.../org/apache/sis/util/LenientComparable.java | 18 +--
.../main/org/apache/sis/util/Utilities.java | 2 +-
.../org/apache/sis/util/collection/TreeTable.java | 2 +-
.../main/org/apache/sis/util/privy/Numerics.java | 2 +-
.../test/org/apache/sis/test/Assertions.java | 4 +-
.../main/org/apache/sis/geometries/Geometries.java | 3 +-
.../org/apache/sis/geometries/PreparedTIN.java | 12 +-
.../apache/sis/geometries/math/AbstractTuple.java | 4 +-
.../main/org/apache/sis/geometries/math/Tuple.java | 4 +-
.../geometries/mesh/MeshPrimitiveComparator.java | 6 +-
.../sis/geometries/mesh/MultiMeshPrimitive.java | 4 +-
.../sis/geometries/processor/ProcessorUtils.java | 8 +-
.../simplify/greedyinsert/TINBuilder.java | 4 +-
.../main/org/apache/sis/gui/map/StatusBar.java | 2 +-
.../gui/referencing/PositionableProjection.java | 3 +-
79 files changed, 311 insertions(+), 317 deletions(-)
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/DimensionalityReduction.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/DimensionalityReduction.java
index 51fe89be0c..240e8ca9e5 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/DimensionalityReduction.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/DimensionalityReduction.java
@@ -826,7 +826,7 @@ public class DimensionalityReduction implements UnaryOperator<GridCoverage>, Ser
CoordinateReferenceSystem crs = null;
if (reduced.isDefined(GridGeometry.CRS) && sourceGeometry.isDefined(GridGeometry.CRS)) {
final CoordinateReferenceSystem reducedCRS = reduced.getCoordinateReferenceSystem();
- if (Utilities.equalsIgnoreMetadata(reducedGeometry.getCoordinateReferenceSystem(), reducedCRS)) {
+ if (CRS.equivalent(reducedGeometry.getCoordinateReferenceSystem(), reducedCRS)) {
crs = sourceGeometry.getCoordinateReferenceSystem();
} else {
FactoryException cause = null;
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridExtent.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridExtent.java
index b5e33cb0e9..50ede01bbf 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridExtent.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridExtent.java
@@ -2173,7 +2173,7 @@ public class GridExtent implements GridEnvelope, LenientComparable, Serializable
return true;
}
if (object instanceof GridExtent) {
- final GridExtent other = (GridExtent) object;
+ final var other = (GridExtent) object;
if (Arrays.equals(coordinates, other.coordinates)) {
switch (mode) {
case STRICT: if (!getClass().equals(object.getClass())) return false; // else fallthrough
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridGeometry.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridGeometry.java
index d70c086fac..aef757ced4 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridGeometry.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridGeometry.java
@@ -1044,7 +1044,7 @@ public class GridGeometry implements LenientComparable, Serializable {
final int bitmask; // CRS, EXTENT or GRID_TO_CRS
final short errorKey; // Resource key for error message.
final CoordinateReferenceSystem sourceCRS = getCoordinateReferenceSystem(envelope);
- if (Utilities.equalsIgnoreMetadata(sourceCRS, crs)) {
+ if (org.apache.sis.referencing.CRS.equivalent(sourceCRS, crs)) {
return envelope;
} else if (sourceCRS == null) {
bitmask = CRS;
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/ResampledGridCoverage.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/ResampledGridCoverage.java
index f13e8aab52..890c791275 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/ResampledGridCoverage.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/ResampledGridCoverage.java
@@ -32,6 +32,7 @@ import org.apache.sis.feature.internal.Resources;
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.util.Utilities;
import org.apache.sis.util.privy.DoubleDouble;
+import org.apache.sis.referencing.CRS;
import org.apache.sis.referencing.privy.DirectPositionView;
import org.apache.sis.referencing.privy.ExtendedPrecisionMatrix;
import org.apache.sis.referencing.operation.transform.LinearTransform;
@@ -237,8 +238,8 @@ final class ResampledGridCoverage extends DerivedGridCoverage {
|| Utilities.equalsIgnoreMetadata(sourceGG.getExtent(),
targetGG.getExtent()))
&& (!isDefined(sourceGG, targetGG, GridGeometry.CRS)
- || Utilities.equalsIgnoreMetadata(sourceGG.getCoordinateReferenceSystem(),
- targetGG.getCoordinateReferenceSystem()))
+ || CRS.equivalent(sourceGG.getCoordinateReferenceSystem(),
+ targetGG.getCoordinateReferenceSystem()))
&& (!isDefined(sourceGG, targetGG, GridGeometry.GRID_TO_CRS)
|| Utilities.equalsIgnoreMetadata(sourceGG.getGridToCRS(PixelInCell.CELL_CORNER),
targetGG.getGridToCRS(PixelInCell.CELL_CORNER))
@@ -451,7 +452,7 @@ final class ResampledGridCoverage extends DerivedGridCoverage {
* If an envelope is defined, resample only that sub-region.
*/
GridGeometry complete = target;
- ComparisonMode mode = ComparisonMode.IGNORE_METADATA;
+ ComparisonMode mode = ComparisonMode.COMPATIBILITY;
if (!target.isDefined(GridGeometry.EXTENT | GridGeometry.GRID_TO_CRS | GridGeometry.CRS)) {
final CoordinateReferenceSystem targetCRS = changeOfCRS.getTargetCRS();
complete = new GridGeometry(targetExtent, PixelInCell.CELL_CENTER, targetCenterToCRS, targetCRS);
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 7fa87083ee..0f0f9784b7 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
@@ -37,7 +37,6 @@ import org.apache.sis.referencing.ImmutableIdentifier;
import org.apache.sis.referencing.CRS;
import org.apache.sis.referencing.privy.ReferencingFactoryContainer;
import org.apache.sis.referencing.privy.ReferencingUtilities;
-import org.apache.sis.util.Utilities;
import org.apache.sis.util.collection.BackingStoreException;
import org.apache.sis.referencing.operation.DefaultConversion;
import org.apache.sis.referencing.crs.DefaultProjectedCRS;
@@ -164,7 +163,7 @@ public final class SpatialOperationContext implements Serializable {
public GeometryWrapper transform(GeometryWrapper geometry) throws FactoryException, TransformException {
if (computationCRS != null) {
final CoordinateReferenceSystem sourceCRS = to2D(geometry.getCoordinateReferenceSystem());
- if (sourceCRS != null && !Utilities.equalsIgnoreMetadata(computationCRS, sourceCRS)) {
+ if (sourceCRS != null && !CRS.equivalent(computationCRS, sourceCRS)) {
geometry = geometry.transform(CRS.findOperation(sourceCRS, computationCRS, areaOfInterest), false);
}
}
@@ -172,7 +171,7 @@ public final class SpatialOperationContext implements Serializable {
}
/**
- * Transforms the specified geometries to the common CRS.
+ * Transforms the specified geometries to the common <abbr>CRS</abbr>.
* If {@link #computationCRS} is {@code null}, then this method tries to infer one automatically.
* Geometries with unspecified CRS will be used as-is, without transformation.
* The common CRS is stored in the {@link #commonCRS} field.
@@ -217,7 +216,7 @@ public final class SpatialOperationContext implements Serializable {
do {
if (--i < 0) return true; // All geometries are in common CRS.
crs = allCRS[i];
- } while (crs == null || Utilities.equalsIgnoreMetadata(commonCRS, crs));
+ } while (crs == null || CRS.equivalent(commonCRS, crs));
}
}
/*
@@ -271,7 +270,7 @@ select: if (commonCRS == null) {
for (int i=0; i<allCRS.length; i++) {
if (i != skipIndex) {
final CoordinateReferenceSystem sourceCRS = allCRS[i];
- if (!Utilities.equalsIgnoreMetadata(commonCRS, sourceCRS)) {
+ if (!CRS.equivalent(commonCRS, sourceCRS)) {
geometries[i] = geometries[i].transform(CRS.findOperation(sourceCRS, commonCRS, areaOfInterest), false);
}
}
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/jts/JTS.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/jts/JTS.java
index 3a207803a8..0abd88f558 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/jts/JTS.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/jts/JTS.java
@@ -40,7 +40,6 @@ import org.apache.sis.referencing.IdentifiedObjects;
import org.apache.sis.referencing.crs.AbstractCRS;
import org.apache.sis.referencing.cs.AxesConvention;
import org.apache.sis.util.Static;
-import org.apache.sis.util.Utilities;
import org.apache.sis.util.logging.Logging;
import org.apache.sis.metadata.iso.citation.Citations;
import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
@@ -219,7 +218,7 @@ public final class JTS extends Static {
if (geometry != null && targetCRS != null) {
final CoordinateReferenceSystem sourceCRS = getCoordinateReferenceSystem(geometry);
if (sourceCRS != null) {
- if (!Utilities.equalsIgnoreMetadata(sourceCRS, targetCRS)) {
+ if (!CRS.equivalent(sourceCRS, targetCRS)) {
geometry = transform(geometry, findOperation(sourceCRS, targetCRS, geometry), false);
}
}
@@ -250,7 +249,7 @@ public final class JTS extends Static {
final CoordinateReferenceSystem sourceCRS = operation.getSourceCRS();
if (sourceCRS != null) {
final CoordinateReferenceSystem crs = getCoordinateReferenceSystem(geometry);
- if (crs != null && !Utilities.equalsIgnoreMetadata(sourceCRS, crs)) {
+ if (crs != null && !CRS.equivalent(sourceCRS, crs)) {
operation = findOperation(crs, operation.getTargetCRS(), geometry);
}
}
diff --git a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/DimensionalityReductionTest.java b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/DimensionalityReductionTest.java
index 43762619ee..753d44867d 100644
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/DimensionalityReductionTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/DimensionalityReductionTest.java
@@ -194,7 +194,7 @@ public final class DimensionalityReductionTest extends TestCase {
* CRS should have different axis order.
*/
var sourceCRS = reduction.getSourceGridGeometry().getCoordinateReferenceSystem();
- assertFalse(Utilities.equalsIgnoreMetadata(sourceCRS, crs));
+ assertFalse(CRS.equivalent(sourceCRS, crs));
assertTrue(Utilities.deepEquals(test, test, ComparisonMode.ALLOW_VARIANT)); // Ignore axis order.
testPosition(reduction, new double[] {100, 101, 102, 103}, new double[] {100, 101});
}
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java
index d9b1e63c9a..8e05d05367 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java
@@ -31,6 +31,7 @@ import org.apache.sis.xml.NilReason;
import org.apache.sis.xml.bind.gco.GO_Real;
import org.apache.sis.metadata.privy.ReferencingServices;
import org.apache.sis.math.MathFunctions;
+import org.apache.sis.util.ComparisonMode;
import org.apache.sis.util.Utilities;
import org.apache.sis.util.resources.Errors;
@@ -330,7 +331,7 @@ public class DefaultVerticalExtent extends ISOMetadata implements VerticalExtent
* @throws ClassCastException if the conversion is not an instance of {@link MathTransform1D}.
*/
private MathTransform1D getConversionFrom(final VerticalCRS source) throws FactoryException {
- if (!Utilities.equalsIgnoreMetadata(verticalCRS, source) && verticalCRS != null && source != null) {
+ if (source != null && verticalCRS != null && !Utilities.deepEquals(verticalCRS, source, ComparisonMode.COMPATIBILITY)) {
final MathTransform1D cv = ReferencingServices.getInstance().findTransform(source, verticalCRS);
if (!cv.isIdentity()) {
return cv;
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/TemporalDate.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/TemporalDate.java
index e54b06c085..0533095386 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/TemporalDate.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/TemporalDate.java
@@ -240,7 +240,7 @@ public final class TemporalDate extends Date implements LenientComparable {
*/
@Override
public boolean equals(final Object other, final ComparisonMode mode) {
- if (other instanceof TemporalDate && mode.allowsVariant()) {
+ if (mode.isCompatibility() && other instanceof TemporalDate) {
/*
* The number of milliseconds may differ when comparing two local dates,
* depending on which timezone was assumed when `Date` has been constructed.
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/map/coverage/RenderingData.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/map/coverage/RenderingData.java
index 30363b34d3..191612b4e9 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/map/coverage/RenderingData.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/map/coverage/RenderingData.java
@@ -61,7 +61,6 @@ import org.apache.sis.referencing.privy.WraparoundApplicator;
import org.apache.sis.system.Modules;
import org.apache.sis.util.Debug;
import org.apache.sis.util.ArraysExt;
-import org.apache.sis.util.Utilities;
import org.apache.sis.util.privy.CloneAccess;
import org.apache.sis.io.TableAppender;
import org.apache.sis.math.Statistics;
@@ -292,7 +291,7 @@ public class RenderingData implements CloneAccess {
* @return whether the data are valid for the given objective CRS.
*/
public final boolean validateCRS(final CoordinateReferenceSystem objectiveCRS) {
- if (changeOfCRS != null && !Utilities.equalsIgnoreMetadata(objectiveCRS, changeOfCRS.getTargetCRS())) {
+ if (changeOfCRS != null && !CRS.equivalent(objectiveCRS, changeOfCRS.getTargetCRS())) {
clearCRS();
return false;
}
diff --git a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/portrayal/Canvas.java b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/portrayal/Canvas.java
index 9ae081d419..5644549f9e 100644
--- a/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/portrayal/Canvas.java
+++ b/endorsed/src/org.apache.sis.portrayal/main/org/apache/sis/portrayal/Canvas.java
@@ -32,7 +32,6 @@ import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
import org.opengis.referencing.operation.CoordinateOperation;
import org.opengis.util.FactoryException;
-import org.apache.sis.util.Utilities;
import org.apache.sis.util.Localized;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.resources.Errors;
@@ -554,9 +553,9 @@ public class Canvas extends Observable implements Localized {
} else {
final CoordinateReferenceSystem crs = anchor.getCoordinateReferenceSystem();
ArgumentChecks.ensureNonNull("anchor.CRS", crs);
- if (!Utilities.equalsIgnoreMetadata(crs, newValue)) {
+ if (!CRS.equivalent(crs, newValue)) {
MathTransform anchorToNew = poiToNew;
- if (!Utilities.equalsIgnoreMetadata(crs, poiCRS)) {
+ if (!CRS.equivalent(crs, poiCRS)) {
anchorToNew = findTransform(crs, newValue, true);
}
anchor = anchorToNew.transform(anchor, allocatePosition());
@@ -797,7 +796,7 @@ public class Canvas extends Observable implements Localized {
public void setDisplayBounds(final Envelope newValue) throws RenderException {
ArgumentChecks.ensureNonNull(DISPLAY_BOUNDS_PROPERTY, newValue);
final CoordinateReferenceSystem crs = newValue.getCoordinateReferenceSystem();
- if (crs != null && !Utilities.equalsIgnoreMetadata(getDisplayCRS(), crs)) {
+ if (crs != null && !CRS.equivalent(getDisplayCRS(), crs)) {
throw new MismatchedCoordinateMetadataException(errors().getString(
Errors.Keys.IllegalCoordinateSystem_1, IdentifiedObjects.getDisplayName(crs, getLocale())));
}
@@ -889,7 +888,7 @@ public class Canvas extends Observable implements Localized {
* Note 2: `oldValue` cannot be null if `multidimToObjective` is non-null.
*/
MathTransform mt = multidimToObjective;
- if (mt == null || !Utilities.equalsIgnoreMetadata(crs, oldValue.getCoordinateReferenceSystem())) {
+ if (mt == null || !CRS.equivalent(crs, oldValue.getCoordinateReferenceSystem())) {
mt = findTransform(crs, objectiveCRS, false);
}
objectivePOI = mt.transform(copy, allocatePosition());
@@ -977,7 +976,7 @@ public class Canvas extends Observable implements Localized {
supplementalDimensions = CanvasExtent.findSupplementalDimensions(crs,
multidimToObjective.derivative(pointOfInterest), components);
augmentedObjectiveCRS = CRS.compound(components.toArray(CoordinateReferenceSystem[]::new));
- if (Utilities.equalsIgnoreMetadata(augmentedObjectiveCRS, crs)) {
+ if (CRS.equivalent(augmentedObjectiveCRS, crs)) {
augmentedObjectiveCRS = crs;
}
} else {
@@ -1218,7 +1217,7 @@ public class Canvas extends Observable implements Localized {
throws FactoryException, TransformException, RenderException
{
if (allowDisplayCRS) {
- allowDisplayCRS = Utilities.equalsIgnoreMetadata(source, displayBounds.getCoordinateReferenceSystem());
+ allowDisplayCRS = CRS.equivalent(source, displayBounds.getCoordinateReferenceSystem());
}
if (allowDisplayCRS) {
source = objectiveCRS;
diff --git a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/AbstractLocationType.java b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/AbstractLocationType.java
index 0af8af30c2..795bb378b7 100644
--- a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/AbstractLocationType.java
+++ b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/AbstractLocationType.java
@@ -109,9 +109,7 @@ abstract class AbstractLocationType implements LocationType, LenientComparable {
* including the {@linkplain #getTheme() theme} and the {@linkplain #getOwner() owner}.</p>
*
* @param object the object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only
- * properties relevant to location identifications.
+ * @param mode the strictness level of the comparison.
* @return {@code true} if both objects are equal.
*/
@Override
diff --git a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/GeohashReferenceSystem.java b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/GeohashReferenceSystem.java
index 512e608b95..ae64ff408e 100644
--- a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/GeohashReferenceSystem.java
+++ b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/GeohashReferenceSystem.java
@@ -37,7 +37,6 @@ import org.apache.sis.referencing.CommonCRS;
import org.apache.sis.referencing.cs.AxesConvention;
import org.apache.sis.referencing.crs.DefaultGeographicCRS;
import org.apache.sis.referencing.privy.Formulas;
-import org.apache.sis.util.Utilities;
import org.apache.sis.util.Workaround;
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.util.ArgumentChecks;
@@ -512,10 +511,10 @@ public class GeohashReferenceSystem extends ReferencingByIdentifiers {
*/
private DirectPosition toGeographic(final DirectPosition position) throws FactoryException, TransformException {
final CoordinateReferenceSystem ps = position.getCoordinateReferenceSystem();
- if (ps == null || normalizedCRS.equals(ps, ComparisonMode.IGNORE_METADATA)) {
+ if (ps == null || normalizedCRS.equals(ps, ComparisonMode.COMPATIBILITY)) {
return position;
}
- if (lastOp == null || !Utilities.equalsIgnoreMetadata(lastOp.getSourceCRS(), ps)) {
+ if (lastOp == null || !CRS.equivalent(lastOp.getSourceCRS(), ps)) {
lastOp = CRS.findOperation(ps, normalizedCRS, null);
}
return lastOp.getMathTransform().transform(position, null);
diff --git a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
index 24bacf8623..24b59c9ba4 100644
--- a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
+++ b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
@@ -62,7 +62,6 @@ import org.apache.sis.math.DecimalFunctions;
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.StringBuilders;
-import org.apache.sis.util.Utilities;
import org.apache.sis.util.Workaround;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.resources.Vocabulary;
@@ -1230,7 +1229,7 @@ public class MilitaryGridReferenceSystem extends ReferencingByIdentifiers {
* we need the 'optimize' flag to have the value that we get after 'trySplit()' execution. This implies
* that invoking 'trySplit()' is mandatory before using this iterator, but IteratorAllZones ensures that.
*/
- optimize = !isSpecialCase && Utilities.equalsIgnoreMetadata(geographicArea.getCoordinateReferenceSystem(), sourceCRS);
+ optimize = !isSpecialCase && CRS.equivalent(geographicArea.getCoordinateReferenceSystem(), sourceCRS);
}
/**
@@ -1557,7 +1556,7 @@ public class MilitaryGridReferenceSystem extends ReferencingByIdentifiers {
* longitude (in that order) in degrees. We can get this transform directly from the
* projected CRS if its base CRS already has the expected axis orientations and units.
*/
- if (crs == horizontal && Utilities.equalsIgnoreMetadata(projCRS.getBaseCRS(), datum.geographic())) {
+ if (crs == horizontal && CRS.equivalent(projCRS.getBaseCRS(), datum.geographic())) {
toGeographic = projection.getMathTransform().inverse();
return;
}
diff --git a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java
index 9c48b39e3b..396fb336c1 100644
--- a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java
+++ b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java
@@ -378,9 +378,7 @@ public abstract class ReferencingByIdentifiers extends AbstractReferenceSystem i
* the {@linkplain #getOverallOwner() overall owner}.
*
* @param object the object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only
- * properties relevant to location identifications.
+ * @param mode the strictness level of the comparison.
* @return {@code true} if both objects are equal.
*/
@Override
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/coordinate/DefaultCoordinateMetadata.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/coordinate/DefaultCoordinateMetadata.java
index a5ee561b56..1aaa840548 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/coordinate/DefaultCoordinateMetadata.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/coordinate/DefaultCoordinateMetadata.java
@@ -166,9 +166,7 @@ public class DefaultCoordinateMetadata extends FormattableObject
* Compares this metadata with the given object for equality.
*
* @param obj the object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only
- * properties relevant to coordinate transformations.
+ * @param mode the strictness level of the comparison.
* @return {@code true} if both objects are equal.
*/
@Override
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/AbstractDirectPosition.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/AbstractDirectPosition.java
index ea9a9412e6..3c5731c819 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/AbstractDirectPosition.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/AbstractDirectPosition.java
@@ -32,10 +32,10 @@ import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.opengis.referencing.cs.CoordinateSystem;
import org.opengis.referencing.cs.RangeMeaning;
import org.apache.sis.util.ArraysExt;
-import org.apache.sis.util.Utilities;
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.privy.Numerics;
+import org.apache.sis.referencing.CRS;
import org.apache.sis.referencing.privy.WKTKeywords;
import org.apache.sis.referencing.privy.WKTUtilities;
import org.apache.sis.io.wkt.FormattableObject;
@@ -110,7 +110,7 @@ public abstract class AbstractDirectPosition extends FormattableObject implement
* {@code null}, then all coordinate values are set to {@link Double#NaN NaN}.
*
* <p>If this position and the given position have a non-null CRS, then the default implementation
- * requires the CRS to be {@linkplain Utilities#equalsIgnoreMetadata equals (ignoring metadata)},
+ * requires the CRS to be {@linkplain CRS#equivalent equivalent},
* otherwise a {@code MismatchedCoordinateMetadataException} is thrown. However, subclass may choose
* to assign the CRS of this position to the CRS of the given position.</p>
*
@@ -127,7 +127,7 @@ public abstract class AbstractDirectPosition extends FormattableObject implement
final CoordinateReferenceSystem crs = getCoordinateReferenceSystem();
if (crs != null) {
final CoordinateReferenceSystem other = position.getCoordinateReferenceSystem();
- if (other != null && !Utilities.equalsIgnoreMetadata(crs, other)) {
+ if (other != null && !CRS.equivalent(crs, other)) {
throw new MismatchedCoordinateMetadataException(Errors.format(Errors.Keys.MismatchedCRS));
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/AbstractEnvelope.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/AbstractEnvelope.java
index 348f3c4809..64d805f372 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/AbstractEnvelope.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/AbstractEnvelope.java
@@ -1109,7 +1109,7 @@ public abstract class AbstractEnvelope extends FormattableObject implements Enve
final int dimension = getDimension();
if (other.getDimension() != dimension ||
!equals(getCoordinateReferenceSystem(), other.getCoordinateReferenceSystem(),
- (eps == 0) ? ComparisonMode.IGNORE_METADATA : ComparisonMode.APPROXIMATE))
+ (eps == 0) ? ComparisonMode.COMPATIBILITY : ComparisonMode.APPROXIMATE))
{
return false;
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/EnvelopeReducer.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/EnvelopeReducer.java
index 2b18e7440e..48e13d4573 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/EnvelopeReducer.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/EnvelopeReducer.java
@@ -24,7 +24,6 @@ import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
import org.apache.sis.metadata.privy.ReferencingServices;
import org.apache.sis.referencing.CRS;
import org.apache.sis.referencing.internal.Resources;
-import org.apache.sis.util.Utilities;
/**
@@ -106,14 +105,14 @@ class EnvelopeReducer {
* without performing any reprojection. In the common case where all envelopes use
* the same CRS, this will result in an array having only one non-null element.
*/
- final GeneralEnvelope[] reduced = new GeneralEnvelope[envelopes.length];
+ final var reduced = new GeneralEnvelope[envelopes.length];
int count = 0;
merge: for (final Envelope envelope : envelopes) {
if (envelope != null) {
final CoordinateReferenceSystem crs = envelope.getCoordinateReferenceSystem();
for (int i=0; i<count; i++) {
final GeneralEnvelope previous = reduced[i];
- if (Utilities.equalsIgnoreMetadata(crs, previous.getCoordinateReferenceSystem())) {
+ if (CRS.equivalent(crs, previous.getCoordinateReferenceSystem())) {
reduce(previous, envelope);
continue merge;
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/Envelopes.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/Envelopes.java
index 15776e3034..a8ac8e4390 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/Envelopes.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/Envelopes.java
@@ -188,7 +188,7 @@ public final class Envelopes extends Static {
/**
* Computes the union of all given envelopes, transforming them to a common CRS if necessary.
- * If all envelopes use the same CRS ({@link ComparisonMode#IGNORE_METADATA ignoring metadata})
+ * If all envelopes use {@linkplain CRS#equivalent equivalent} <abbr>CRS</abbr>,
* or if the CRS of all envelopes is {@code null}, then the {@linkplain GeneralEnvelope#add(Envelope)
* union is computed} without transforming any envelope. Otherwise, all envelopes are transformed
* to a {@linkplain CRS#suggestCommonTarget common CRS} before union is computed.
@@ -208,7 +208,7 @@ public final class Envelopes extends Static {
/**
* Computes the intersection of all given envelopes, transforming them to a common CRS if necessary.
- * If all envelopes use the same CRS ({@link ComparisonMode#IGNORE_METADATA ignoring metadata})
+ * If all envelopes use {@linkplain CRS#equivalent equivalent} <abbr>CRS</abbr>,
* or if the CRS of all envelopes is {@code null}, then the {@linkplain GeneralEnvelope#intersect(Envelope)
* intersection is computed} without transforming any envelope. Otherwise, all envelopes are transformed
* to a {@linkplain CRS#suggestCommonTarget common CRS} before intersection is computed.
@@ -625,7 +625,7 @@ nextPoint: for (int pointIndex = 0;;) { // Break condition at th
final CoordinateReferenceSystem sourceCRS = operation.getSourceCRS();
if (sourceCRS != null) {
final CoordinateReferenceSystem crs = envelope.getCoordinateReferenceSystem();
- if (crs != null && !Utilities.equalsIgnoreMetadata(crs, sourceCRS)) {
+ if (crs != null && !CRS.equivalent(crs, sourceCRS)) {
/*
* Argument-check: the envelope CRS seems inconsistent with the given operation.
* However, we need to push the check a little bit further, since 3D-GeographicCRS
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/WraparoundAdjustment.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/WraparoundAdjustment.java
index c4cbca0dd1..02037979ec 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/WraparoundAdjustment.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/WraparoundAdjustment.java
@@ -31,7 +31,6 @@ import org.apache.sis.math.MathFunctions;
import org.apache.sis.metadata.privy.ReferencingServices;
import org.apache.sis.referencing.privy.ReferencingUtilities;
import org.apache.sis.referencing.privy.WraparoundAxesFinder;
-import org.apache.sis.util.Utilities;
import org.apache.sis.util.logging.Logging;
@@ -183,7 +182,7 @@ public class WraparoundAdjustment {
* The (source ≉ target) condition is a quick check for avoiding
* unnecessary calculation of `geographicDomain` in common cases.
*/
- if (!geographicDomainKnown && !Utilities.equalsIgnoreMetadata(source, target)) try {
+ if (!geographicDomainKnown && !CRS.equivalent(source, target)) try {
geographicDomainKnown = true; // Shall be set even in case of failure.
geographicDomain = ReferencingServices.getInstance().setBounds(domainOfValidity, null, "shift");
} catch (TransformException e) {
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/DefaultParameterDescriptor.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/DefaultParameterDescriptor.java
index 04612d322a..9eeaf57591 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/DefaultParameterDescriptor.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/DefaultParameterDescriptor.java
@@ -498,7 +498,7 @@ public class DefaultParameterDescriptor<T> extends AbstractParameterDescriptor i
* except the name. We do not perform this comparison if the user asked for metadata
* comparison, because in such case the names have already been compared by the super-class.
*/
- final ParameterDescriptor<?> that = (ParameterDescriptor<?>) object;
+ final var that = (ParameterDescriptor<?>) object;
return getValueClass() == that.getValueClass() &&
Objects.deepEquals(getDefaultValue(), that.getDefaultValue()) &&
Utilities.deepEquals(getUnit(), that.getUnit(), mode) &&
@@ -506,7 +506,7 @@ public class DefaultParameterDescriptor<T> extends AbstractParameterDescriptor i
IdentifiedObjects.isHeuristicMatchForName(that, getName().getCode()));
}
case BY_CONTRACT: {
- final ParameterDescriptor<?> that = (ParameterDescriptor<?>) object;
+ final var that = (ParameterDescriptor<?>) object;
return getMinimumOccurs() == that.getMinimumOccurs() &&
getMaximumOccurs() == that.getMaximumOccurs() &&
getValueClass() == that.getValueClass() &&
@@ -518,7 +518,7 @@ public class DefaultParameterDescriptor<T> extends AbstractParameterDescriptor i
Utilities.deepEquals(getUnit(), that.getUnit(), mode);
}
case STRICT: {
- final DefaultParameterDescriptor<?> that = (DefaultParameterDescriptor<?>) object;
+ final var that = (DefaultParameterDescriptor<?>) object;
return valueClass == that.valueClass &&
Objects. equals(validValues, that.validValues) &&
Objects. equals(valueDomain, that.valueDomain) &&
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/DefaultParameterValueGroup.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/DefaultParameterValueGroup.java
index a59d4d55cb..dad8b221ed 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/DefaultParameterValueGroup.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/DefaultParameterValueGroup.java
@@ -372,7 +372,7 @@ public class DefaultParameterValueGroup extends Parameters implements LenientCom
Objects.requireNonNull(name);
@SuppressWarnings("LocalVariableHidesMemberVariable")
final ParameterValueList values = this.values; // Protect against accidental changes.
- final List<ParameterValueGroup> groups = new ArrayList<>(4);
+ final var groups = new ArrayList<ParameterValueGroup>(4);
final int size = values.size();
for (int i=0; i<size; i++) {
final GeneralParameterDescriptor descriptor = values.descriptor(i);
@@ -438,7 +438,7 @@ public class DefaultParameterValueGroup extends Parameters implements LenientCom
* <ul>
* <li>{@link ComparisonMode#STRICT} and {@link ComparisonMode#BY_CONTRACT BY_CONTRACT}
* take in account the parameter order.</li>
- * <li>{@link ComparisonMode#IGNORE_METADATA} and {@link ComparisonMode#APPROXIMATE APPROXIMATE}
+ * <li>Other comparison modes
* ignore the order of parameter values (but not necessarily the order of parameter descriptors).</li>
* </ul>
*
@@ -455,7 +455,7 @@ public class DefaultParameterValueGroup extends Parameters implements LenientCom
if (object != null) {
if (mode == ComparisonMode.STRICT) {
if (getClass() == object.getClass()) {
- final DefaultParameterValueGroup that = (DefaultParameterValueGroup) object;
+ final var that = (DefaultParameterValueGroup) object;
return Objects.equals(values.descriptor, that.values.descriptor) &&
Objects.equals(values, that.values);
}
@@ -476,7 +476,7 @@ public class DefaultParameterValueGroup extends Parameters implements LenientCom
if (!mode.isIgnoringMetadata()) {
return Utilities.deepEquals(expected.values(), actual.values(), mode);
}
- final List<GeneralParameterValue> values = new LinkedList<>(expected.values());
+ final var values = new LinkedList<GeneralParameterValue>(expected.values());
scan: for (final GeneralParameterValue param : actual.values()) {
final Iterator<GeneralParameterValue> it = values.iterator();
while (it.hasNext()) {
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/UnmodifiableParameterValueGroup.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/UnmodifiableParameterValueGroup.java
index cd9507bacb..e117928a7e 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/UnmodifiableParameterValueGroup.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/UnmodifiableParameterValueGroup.java
@@ -164,7 +164,7 @@ class UnmodifiableParameterValueGroup extends Parameters implements LenientCompa
@Override
public List<ParameterValueGroup> groups(final String name) throws ParameterNotFoundException {
Objects.requireNonNull(name);
- final List<ParameterValueGroup> groups = new ArrayList<>(4);
+ final var groups = new ArrayList<ParameterValueGroup>(4);
for (final GeneralParameterValue value : values) {
if (value instanceof ParameterValueGroup) {
if (IdentifiedObjects.isHeuristicMatchForName(value.getDescriptor(), name)) {
@@ -195,7 +195,7 @@ class UnmodifiableParameterValueGroup extends Parameters implements LenientCompa
@Override
@SuppressWarnings("CloneDoesntCallSuperClone")
public Parameters clone() {
- final DefaultParameterValueGroup copy = new DefaultParameterValueGroup(descriptor);
+ final var copy = new DefaultParameterValueGroup(descriptor);
Parameters.copy(this, copy);
return copy;
}
@@ -207,7 +207,7 @@ class UnmodifiableParameterValueGroup extends Parameters implements LenientCompa
* <ul>
* <li>{@link ComparisonMode#STRICT} and {@link ComparisonMode#BY_CONTRACT BY_CONTRACT}
* take in account the parameter order.</li>
- * <li>{@link ComparisonMode#IGNORE_METADATA} and {@link ComparisonMode#APPROXIMATE APPROXIMATE}
+ * <li>Other comparison modes
* ignore the order of parameter values (but not necessarily the order of parameter descriptors).</li>
* </ul>
*
@@ -223,7 +223,7 @@ class UnmodifiableParameterValueGroup extends Parameters implements LenientCompa
if (object != null) {
if (mode == ComparisonMode.STRICT) {
if (getClass() == object.getClass()) {
- final UnmodifiableParameterValueGroup that = (UnmodifiableParameterValueGroup) object;
+ final var that = (UnmodifiableParameterValueGroup) object;
return Objects.equals(descriptor, that.descriptor) &&
Objects.equals(values, that.values);
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/AbstractIdentifiedObject.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/AbstractIdentifiedObject.java
index f96874251d..4237b39dc9 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/AbstractIdentifiedObject.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/AbstractIdentifiedObject.java
@@ -707,15 +707,17 @@ public class AbstractIdentifiedObject extends FormattableObject implements Ident
* is considered ignorable metadata while the explicit arguments given to the constructor (if any) are
* considered non-ignorable. Note that there is some exceptions to this rule of thumb — see
* <cite>When object name matter</cite> below.</td></tr>
+ * <tr><td>{@link ComparisonMode#COMPATIBILITY COMPATIBILITY}:</td>
+ * <td>Same as {@code IGNORE_METADATA}, with some tolerance about structural changes due to historical reasons.</td></tr>
* <tr><td>{@link ComparisonMode#APPROXIMATE APPROXIMATE}:</td>
- * <td>Same as {@code IGNORE_METADATA}, with some tolerance threshold on numerical values.</td></tr>
+ * <td>Same as {@code COMPATIBILITY}, with some tolerance threshold on numerical values.</td></tr>
* <tr><td>{@link ComparisonMode#ALLOW_VARIANT ALLOW_VARIANT}:</td>
* <td>Same as {@code APPROXIMATE}, but ignores coordinate system axes.</td></tr>
* <tr><td>{@link ComparisonMode#DEBUG DEBUG}:</td>
* <td>Special mode for figuring out why two objects expected to be equal are not.</td></tr>
* </table>
*
- * The main guideline is that if {@code sourceCRS.equals(targetCRS, IGNORE_METADATA)} returns {@code true},
+ * The main guideline is that if {@code sourceCRS.equals(targetCRS, COMPATIBILITY)} returns {@code true},
* then the transformation from {@code sourceCRS} to {@code targetCRS} should be the identity transform
* even if the two CRS do not have the same name.
*
@@ -785,15 +787,8 @@ public class AbstractIdentifiedObject extends FormattableObject implements Ident
deepEquals(getDomains(), that.getDomains(), mode) &&
deepEquals(getRemarks(), that.getRemarks(), mode);
}
- case IGNORE_METADATA:
- case APPROXIMATE:
- case ALLOW_VARIANT:
- case DEBUG: {
- return implementsSameInterface(object);
- }
default: {
- throw new IllegalArgumentException(Errors.format(
- Errors.Keys.UnknownEnumValue_2, ComparisonMode.class, mode));
+ return implementsSameInterface(object);
}
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/CRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/CRS.java
index ee0fe5f571..ce0953116f 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/CRS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/CRS.java
@@ -85,6 +85,7 @@ import org.apache.sis.referencing.internal.ParameterizedTransformBuilder;
import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
import org.apache.sis.metadata.iso.extent.Extents;
import org.apache.sis.util.ArgumentChecks;
+import org.apache.sis.util.ComparisonMode;
import org.apache.sis.util.OptionalCandidate;
import org.apache.sis.util.Static;
import org.apache.sis.util.Utilities;
@@ -417,8 +418,8 @@ public final class CRS extends Static {
* {@linkplain org.apache.sis.referencing.factory.GeodeticAuthorityFactory#createCoordinateReferenceSystem(String) create a CRS}
* for that identifier, then:
* <ul>
- * <li>If the CRS defined by the authority is {@linkplain Utilities#equalsIgnoreMetadata equal, ignoring metadata},
- * to the given CRS, then this method returns silently the <em>authoritative</em> CRS.</li>
+ * <li>If the CRS defined by the authority is {@linkplain #equivalent equivalent} to the given CRS,
+ * then this method returns silently the <em>authoritative</em> CRS.</li>
* <li>Otherwise if the CRS defined by the authority is equal, ignoring axis order and units, to the given CRS,
* then this method returns a <em>new</em> CRS derived from the authoritative one but with same
* {@linkplain org.apache.sis.referencing.cs.AxesConvention axes convention} than the given CRS.
@@ -431,8 +432,8 @@ public final class CRS extends Static {
* {@linkplain org.apache.sis.referencing.factory.IdentifiedObjectFinder searches for an equivalent CRS}
* defined by the authority factory. If such CRS is found, then:
* <ul>
- * <li>If the CRS defined by the authority is {@linkplain Utilities#equalsIgnoreMetadata equal, ignoring metadata},
- * to the given CRS, then this method returns silently the <em>authoritative</em> CRS.</li>
+ * <li>If the CRS defined by the authority is {@linkplain #equivalent equivalent} to the given CRS,
+ * then this method returns silently the <em>authoritative</em> CRS.</li>
* <li>Otherwise if the CRS defined by the authority is equal, ignoring axis order and units, to the given CRS,
* then this method returns silently a <em>new</em> CRS derived from the authoritative one but with same
* {@linkplain org.apache.sis.referencing.cs.AxesConvention axes convention} than the given CRS.</li>
@@ -480,6 +481,31 @@ public final class CRS extends Static {
return crs;
}
+ /**
+ * Returns whether the given Coordinate Reference Systems can be considered as equivalent.
+ * Two <abbr>CRS</abbr>s are considered equivalent if they may have some differences in metadata or data structure,
+ * but replacing one <abbr>CRS</abbr> by the other should not change the input and output coordinate values in operations.
+ *
+ * <h4>Implementation note</h4>
+ * This is a convenience method for the following method call:
+ *
+ * {@snippet lang="java" :
+ * return deepEquals(object1, object2, ComparisonMode.IGNORE_METADATA);
+ * }
+ *
+ * @param object1 the first object to compare (may be null).
+ * @param object2 the second object to compare (may be null).
+ * @return {@code true} if both objects are equivalent.
+ *
+ * @see ComparisonMode#COMPATIBILITY
+ * @see Utilities#equalsIgnoreMetadata(Object, Object)
+ *
+ * @since 1.5
+ */
+ public static boolean equivalent(final CoordinateReferenceSystem object1, final CoordinateReferenceSystem object2) {
+ return Utilities.deepEquals(object1, object2, ComparisonMode.COMPATIBILITY);
+ }
+
/**
* Suggests a coordinate reference system which could be a common target for coordinate operations having the
* given sources. This method compares the {@linkplain #getGeographicBoundingBox(CoordinateReferenceSystem)
@@ -900,7 +926,7 @@ public final class CRS extends Static {
final Envelope candidate = geometry.getEnvelope();
if (candidate != null) {
final CoordinateReferenceSystem sourceCRS = candidate.getCoordinateReferenceSystem();
- if (sourceCRS == null || Utilities.equalsIgnoreMetadata(sourceCRS, crs)) {
+ if (sourceCRS == null || equivalent(sourceCRS, crs)) {
if (envelope == null) {
envelope = candidate;
} else {
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/DefaultObjectDomain.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/DefaultObjectDomain.java
index 3241d94d3e..4131570f6b 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/DefaultObjectDomain.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/DefaultObjectDomain.java
@@ -242,8 +242,7 @@ public class DefaultObjectDomain extends FormattableObject implements ObjectDoma
* Compares this object system with the specified object for equality.
*
* @param object the object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA}.
+ * @param mode the strictness level of the comparison.
* @return {@code true} if both objects are equal.
*/
@Override
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/IdentifiedObjects.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/IdentifiedObjects.java
index 18cfc6617d..da6e9567a4 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/IdentifiedObjects.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/IdentifiedObjects.java
@@ -36,7 +36,6 @@ import org.opengis.referencing.IdentifiedObject;
import org.opengis.referencing.crs.CompoundCRS;
import org.opengis.referencing.operation.CoordinateOperation;
import org.opengis.referencing.operation.ConcatenatedOperation;
-import static org.apache.sis.util.Utilities.equalsIgnoreMetadata;
import org.apache.sis.util.Static;
import org.apache.sis.util.Emptiable;
import org.apache.sis.util.CharSequences;
@@ -46,7 +45,7 @@ import org.apache.sis.util.logging.Logging;
import org.apache.sis.util.privy.Strings;
import org.apache.sis.util.privy.Constants;
import org.apache.sis.util.privy.DefinitionURI;
-import static org.apache.sis.util.privy.CollectionsExt.nonNull;
+import org.apache.sis.util.privy.CollectionsExt;
import org.apache.sis.pending.jdk.JDK21;
import org.apache.sis.xml.IdentifierSpace;
import org.apache.sis.metadata.privy.Identifiers;
@@ -217,7 +216,7 @@ public final class IdentifiedObjects extends Static {
* If we do not found a primary name for the specified authority,
* or if the user requested all names, search among aliases.
*/
- for (final GenericName alias : nonNull(object.getAlias())) {
+ for (final GenericName alias : CollectionsExt.nonNull(object.getAlias())) {
if (alias != null) {
final String name;
if (alias instanceof Identifier) {
@@ -271,7 +270,7 @@ public final class IdentifiedObjects extends Static {
if (authority instanceof IdentifierSpace<?>) {
cs = ((IdentifierSpace<?>) authority).getName();
}
- for (final Identifier identifier : nonNull(object.getIdentifiers())) {
+ for (final Identifier identifier : CollectionsExt.nonNull(object.getIdentifiers())) {
if (identifier != null) { // Paranoiac check.
if (cs != null && cs.equalsIgnoreCase(identifier.getCodeSpace())) {
return identifier; // Match based on codespace.
@@ -310,7 +309,7 @@ public final class IdentifiedObjects extends Static {
if (object == null) {
return null;
}
- for (final Identifier id : nonNull(object.getIdentifiers())) {
+ for (final Identifier id : CollectionsExt.nonNull(object.getIdentifiers())) {
final String code = toString(id);
if (code != null) { // Paranoiac check.
return code;
@@ -353,7 +352,7 @@ public final class IdentifiedObjects extends Static {
return code;
}
}
- for (GenericName alias : nonNull(object.getAlias())) {
+ for (GenericName alias : CollectionsExt.nonNull(object.getAlias())) {
if (alias != null && (alias = alias.tip()) != null) {
final String code = alias.toString();
if (CharSequences.isUnicodeIdentifier(code)) {
@@ -361,7 +360,7 @@ public final class IdentifiedObjects extends Static {
}
}
}
- for (final Identifier id : nonNull(object.getIdentifiers())) {
+ for (final Identifier id : CollectionsExt.nonNull(object.getIdentifiers())) {
if (id != null) { // Paranoiac check.
final String code = id.getCode();
if (CharSequences.isUnicodeIdentifier(code)) {
@@ -418,7 +417,7 @@ public final class IdentifiedObjects extends Static {
return null;
}
String name = toString(object.getName(), locale);
- for (final GenericName c : nonNull(object.getAlias())) {
+ for (final GenericName c : CollectionsExt.nonNull(object.getAlias())) {
final String alias = toString(c, locale);
if (alias != null) {
if (name == null || CharSequences.isAcronymForWords(name, alias)) {
@@ -431,7 +430,7 @@ public final class IdentifiedObjects extends Static {
}
}
if (name == null) {
- for (final Identifier id : nonNull(object.getIdentifiers())) {
+ for (final Identifier id : CollectionsExt.nonNull(object.getIdentifiers())) {
name = toString(id, locale);
if (name != null) break;
}
@@ -548,8 +547,8 @@ public final class IdentifiedObjects extends Static {
} else if (object instanceof ConcatenatedOperation) {
final var cop = (ConcatenatedOperation) object;
final List<? extends CoordinateOperation> steps = cop.getOperations();
- if (equalsIgnoreMetadata(cop.getSourceCRS(), JDK21.getFirst(steps).getSourceCRS()) &&
- equalsIgnoreMetadata(cop.getTargetCRS(), JDK21.getLast (steps).getTargetCRS()))
+ if (CRS.equivalent(cop.getSourceCRS(), JDK21.getFirst(steps).getSourceCRS()) &&
+ CRS.equivalent(cop.getTargetCRS(), JDK21.getLast (steps).getTargetCRS()))
{
components = steps;
} else {
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractCRS.java
index 0c2e4c37fa..55593e9fd2 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractCRS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractCRS.java
@@ -403,9 +403,7 @@ public class AbstractCRS extends AbstractReferenceSystem implements CoordinateRe
* are compared including the {@linkplain #getDomains() domains} and remarks.
*
* @param object the object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only
- * properties relevant to coordinate transformations.
+ * @param mode the strictness level of the comparison.
* @return {@code true} if both objects are equal.
*/
@Override
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractDerivedCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractDerivedCRS.java
index a957194948..cabb6fd81c 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractDerivedCRS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractDerivedCRS.java
@@ -190,9 +190,7 @@ abstract class AbstractDerivedCRS extends AbstractCRS implements DerivedCRS {
* Compares this coordinate reference system with the specified object for equality.
*
* @param object the object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only
- * properties relevant to coordinate transformations.
+ * @param mode the strictness level of the comparison.
* @return {@code true} if both objects are equal.
*
* @hidden because nothing new to said.
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractSingleCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractSingleCRS.java
index 115d7d3d79..70690e8e25 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractSingleCRS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractSingleCRS.java
@@ -232,11 +232,11 @@ class AbstractSingleCRS<D extends Datum> extends AbstractCRS implements SingleCR
mode = ComparisonMode.ALLOW_VARIANT; // For avoiding too early `AssertionError`.
}
if (Utilities.deepEquals(d1, d2, mode)) {
- if (d1 != null && d2 != null && mode.allowsVariant()) {
+ if (d1 != null && d2 != null && mode.isCompatibility()) {
return true;
}
return Utilities.deepEquals(getDatumEnsemble(), that.getDatumEnsemble(), mode);
- } else if (mode.allowsVariant()) {
+ } else if (mode.isCompatibility()) {
return DatumOrEnsemble.isLegacyDatum(this.getDatumEnsemble(), d2, mode) ||
DatumOrEnsemble.isLegacyDatum(that.getDatumEnsemble(), d1, mode);
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultCompoundCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
index 0ac473adaa..7c619b698b 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
@@ -575,9 +575,7 @@ public class DefaultCompoundCRS extends AbstractCRS implements CompoundCRS {
* Compares this coordinate reference system with the specified object for equality.
*
* @param object the object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only
- * properties relevant to transformations.
+ * @param mode the strictness level of the comparison.
* @return {@code true} if both objects are equal.
*
* @hidden because nothing new to said.
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultDerivedCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultDerivedCRS.java
index c7258fde90..69f517b7eb 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultDerivedCRS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultDerivedCRS.java
@@ -510,14 +510,12 @@ public class DefaultDerivedCRS extends AbstractDerivedCRS implements DerivedCRS
* In addition to the metadata documented in the
* {@linkplain org.apache.sis.referencing.AbstractIdentifiedObject#equals(Object, ComparisonMode) parent class},
* this method considers coordinate system axes of the {@linkplain #getBaseCRS() base CRS} as metadata.
- * This means that if the given {@code ComparisonMode} is {@code IGNORE_METADATA} or {@code APPROXIMATE},
- * then axis order of the base CRS are ignored
+ * This means that if the given {@code ComparisonMode} is {@code IGNORE_METADATA} or more permissive,
+ * then axis order of the base <abbr>CRS</abbr> is ignored
* (but <strong>not</strong> axis order of <strong>this</strong> derived CRS).
*
* @param object the object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only
- * properties relevant to coordinate transformations.
+ * @param mode the strictness level of the comparison.
* @return {@code true} if both objects are equal.
*/
@Override
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultProjectedCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultProjectedCRS.java
index 0356022db8..bb17a910a4 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultProjectedCRS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultProjectedCRS.java
@@ -318,14 +318,12 @@ public class DefaultProjectedCRS extends AbstractDerivedCRS implements Projected
* In addition to the metadata documented in the
* {@linkplain org.apache.sis.referencing.AbstractIdentifiedObject#equals(Object, ComparisonMode) parent class},
* this method considers coordinate system axes of the {@linkplain #getBaseCRS() base CRS} as metadata.
- * This means that if the given {@code ComparisonMode} is {@code IGNORE_METADATA} or {@code APPROXIMATE},
- * then axis order of the base geographic CRS are ignored
+ * This means that if the given {@code ComparisonMode} is {@code IGNORE_METADATA} or more permissive,
+ * then axis order of the base geodetic <abbr>CRS</abbr> is ignored
* (but <strong>not</strong> axis order of <strong>this</strong> projected CRS).
*
* @param object the object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only
- * properties relevant to coordinate transformations.
+ * @param mode the strictness level of the comparison.
* @return {@code true} if both objects are equal.
*/
@Override
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/AbstractCS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/AbstractCS.java
index feba4754fe..08eda817e8 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/AbstractCS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/AbstractCS.java
@@ -553,15 +553,12 @@ next: for (final CoordinateSystemAxis axis : axes) {
* Compares the specified object with this coordinate system for equality.
*
* @param object the object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only
- * properties relevant to coordinate transformations.
+ * @param mode the strictness level of the comparison.
* @return {@code true} if both objects are equal.
*
* @hidden because nothing new to said.
*/
@Override
- @SuppressWarnings({"AssertWithSideEffects", "fallthrough"})
public boolean equals(final Object object, final ComparisonMode mode) {
if (object == this) {
return true; // Slight optimization.
@@ -574,23 +571,22 @@ next: for (final CoordinateSystemAxis axis : axes) {
// No need to check the class - this check has been done by super.equals(…).
return Arrays.equals(axes, ((AbstractCS) object).axes);
}
- case DEBUG: {
- final int d1, d2;
- assert (d1 = axes.length) == (d2 = ((CoordinateSystem) object).getDimension())
- : Errors.format(Errors.Keys.MismatchedDimension_2, d1, d2);
- // Fall through
+ case DEBUG:
+ case ALLOW_VARIANT: {
+ final int dimension = getDimension();
+ final int that = ((CoordinateSystem) object).getDimension();
+ assert dimension == that || mode != ComparisonMode.DEBUG : Errors.format(Errors.Keys.MismatchedDimension_2, dimension, that);
+ return dimension == that;
}
default: {
- final CoordinateSystem that = (CoordinateSystem) object;
+ final var that = (CoordinateSystem) object;
final int dimension = getDimension();
if (dimension != that.getDimension()) {
return false;
}
- if (!mode.allowsVariant()) {
- for (int i=0; i<dimension; i++) {
- if (!Utilities.deepEquals(getAxis(i), that.getAxis(i), mode)) {
- return false;
- }
+ for (int i=0; i<dimension; i++) {
+ if (!Utilities.deepEquals(getAxis(i), that.getAxis(i), mode)) {
+ return false;
}
}
return true;
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCompoundCS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCompoundCS.java
index b77b1d65eb..c43920f06f 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCompoundCS.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCompoundCS.java
@@ -227,9 +227,7 @@ public class DefaultCompoundCS extends AbstractCS {
* Compares this coordinate system with the specified object for equality.
*
* @param object the object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only
- * properties relevant to coordinate transformations.
+ * @param mode the strictness level of the comparison.
* @return {@code true} if both objects are equal.
*/
@Override
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
index 120198b4a5..c73bb74027 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
@@ -587,9 +587,7 @@ public class DefaultCoordinateSystemAxis extends AbstractIdentifiedObject implem
* All other properties are compared only for modes stricter than {@link ComparisonMode#IGNORE_METADATA}.
*
* @param object the object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only
- * properties relevant to coordinate transformations.
+ * @param mode the strictness level of the comparison.
* @return {@code true} if both objects are equal.
*/
@Override
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/AbstractDatum.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/AbstractDatum.java
index 17be60c6da..f9d86b2e79 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/AbstractDatum.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/AbstractDatum.java
@@ -409,14 +409,14 @@ public class AbstractDatum extends AbstractIdentifiedObject implements Datum {
*
* <h4>Static versus dynamic datum</h4>
* If this datum implements the {@link DynamicReferenceFrame} interface, then the given object needs
- * to also implement that interfaces and provide the same reference epoch for being considered equal.
+ * to also implement that interface and provide the same reference epoch for being considered equal.
* Conversely, if this datum does not implement {@link DynamicReferenceFrame}, then the given object
* also need to <em>not</em> implement that interface for being considered equal.
+ * This condition is relaxed with {@link ComparisonMode#COMPATIBILITY} if the two reference frames have a common identifier
+ * or an {@linkplain org.apache.sis.referencing.IdentifiedObjects#isHeuristicMatchForName equivalent name}.
*
* @param object the object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only
- * properties relevant to coordinate transformations.
+ * @param mode the strictness level of the comparison.
* @return {@code true} if both objects are equal.
*/
@Override
@@ -451,7 +451,7 @@ public class AbstractDatum extends AbstractIdentifiedObject implements Datum {
* and parameters. We extend this rule to datum as well.
*/
final var that = (Datum) object;
- if (!(mode.allowsVariant() || compareDynamicReferenceFrames(that, mode))) {
+ if (!(mode.isCompatibility() || compareDynamicReferenceFrames(that, mode))) {
return false;
}
final Boolean match = Identifiers.hasCommonIdentifier(getIdentifiers(), that.getIdentifiers());
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 26b7d5bb3d..ab6976f313 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
@@ -447,9 +447,7 @@ check: if (it.hasNext()) {
* Compares the specified object with this ensemble for equality.
*
* @param object the object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only
- * properties relevant to coordinate transformations.
+ * @param mode the strictness level of the comparison.
* @return {@code true} if both objects are equal.
*
* @hidden because nothing new to said.
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultEllipsoid.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultEllipsoid.java
index 4f8a8ae51f..d062f44a98 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultEllipsoid.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultEllipsoid.java
@@ -595,9 +595,7 @@ public class DefaultEllipsoid extends AbstractIdentifiedObject implements Ellips
* Compares this ellipsoid with the specified object for equality.
*
* @param object the object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only
- * properties relevant to coordinate transformations.
+ * @param mode the strictness level of the comparison.
* @return {@code true} if both objects are equal.
*
* @hidden because nothing new to said.
@@ -630,6 +628,7 @@ public class DefaultEllipsoid extends AbstractIdentifiedObject implements Ellips
}
// Fall through
}
+ case COMPATIBILITY:
case IGNORE_METADATA: {
/*
* "Inverse flattening factor" and "semi-minor axis length" are computed from each other,
@@ -643,7 +642,7 @@ public class DefaultEllipsoid extends AbstractIdentifiedObject implements Ellips
}
default: {
/*
- * Note: DefaultPrimeMeridian.equals(object, IGNORE_METADATA) ignores the unit.
+ * Note: `DefaultPrimeMeridian.equals(object, IGNORE_METADATA)` ignores the unit.
* But we do not perform the same relaxation here because the ellipsoid unit will
* become the linear unit of map projections if the user does not overwrite them
* with an explicit CoordinateSystem declaration.
@@ -670,8 +669,8 @@ public class DefaultEllipsoid extends AbstractIdentifiedObject implements Ellips
return true;
}
}
- assert (mode != ComparisonMode.DEBUG) : Numerics.messageForDifference(
- isMinor ? "semiMinorAxis" : "semiMajorAxis", v1, v2);
+ assert (mode != ComparisonMode.DEBUG)
+ : Numerics.messageForDifference(isMinor ? "semiMinorAxis" : "semiMajorAxis", v1, v2);
return false;
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
index d1393fe5b6..b9942668e1 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
@@ -500,7 +500,7 @@ public class DefaultGeodeticDatum extends AbstractDatum implements GeodeticDatum
return null;
}
for (final BursaWolfParameters candidate : bursaWolf) {
- if (deepEquals(targetDatum, candidate.getTargetDatum(), ComparisonMode.IGNORE_METADATA)) {
+ if (deepEquals(targetDatum, candidate.getTargetDatum(), ComparisonMode.COMPATIBILITY)) {
selector.evaluate(candidate.getDomainOfValidity(), candidate);
}
}
@@ -667,9 +667,7 @@ public class DefaultGeodeticDatum extends AbstractDatum implements GeodeticDatum
* Compares this datum with the specified object for equality.
*
* @param object the object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only
- * properties relevant to coordinate transformations.
+ * @param mode the strictness level of the comparison.
* @return {@code true} if both objects are equal.
*
* @hidden because nothing new to said.
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultImageDatum.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultImageDatum.java
index 422ac691f5..36f705d391 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultImageDatum.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultImageDatum.java
@@ -146,9 +146,7 @@ public final class DefaultImageDatum extends AbstractDatum {
* Compares this datum with the specified object for equality.
*
* @param object the object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
- * relevant to coordinate transformations.
+ * @param mode the strictness level of the comparison.
* @return {@code true} if both objects are equal.
*
* @hidden because nothing new to said.
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
index 174f7f62a3..83f9b56b1c 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
@@ -249,9 +249,7 @@ public class DefaultPrimeMeridian extends AbstractIdentifiedObject implements Pr
* Compares this prime meridian with the specified object for equality.
*
* @param object the object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
- * relevant to coordinate transformations.
+ * @param mode the strictness level of the comparison.
* @return {@code true} if both objects are equal.
*
* @hidden because nothing new to said.
@@ -268,14 +266,14 @@ public class DefaultPrimeMeridian extends AbstractIdentifiedObject implements Pr
Objects.equals(this.angularUnit, that.angularUnit);
}
case BY_CONTRACT: {
- final PrimeMeridian that = (PrimeMeridian) object;
+ final var that = (PrimeMeridian) object;
return Numerics.equals(getGreenwichLongitude(), that.getGreenwichLongitude()) &&
Objects.equals(getAngularUnit(), that.getAngularUnit());
}
default: {
final double v1 = getGreenwichLongitude(Units.DEGREE);
final double v2 = ReferencingUtilities.getGreenwichLongitude((PrimeMeridian) object, Units.DEGREE);
- if (mode == ComparisonMode.IGNORE_METADATA) {
+ if (mode.isIgnoringMetadata()) {
/*
* We relax the check on unit of measurement because EPSG uses sexagesimal degrees
* for the Greenwich meridian. Requirying the same unit would make more difficult
@@ -284,9 +282,11 @@ public class DefaultPrimeMeridian extends AbstractIdentifiedObject implements Pr
* they are often not the same in the EPSG dataset). The same is not true for other
* objects like DefaultEllipsoid.
*/
+ if (Numerics.epsilonEqual(v1, v2, Formulas.ANGULAR_TOLERANCE)) {
+ return true;
+ }
+ } else {
return Numerics.equals(v1, v2);
- } else if (Numerics.epsilonEqual(v1, v2, Formulas.ANGULAR_TOLERANCE)) {
- return true;
}
assert (mode != ComparisonMode.DEBUG) : Numerics.messageForDifference("greenwichLongitude", v1, v2);
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultTemporalDatum.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
index b3116635db..ed8814e498 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
@@ -216,9 +216,7 @@ public class DefaultTemporalDatum extends AbstractDatum implements TemporalDatum
* Compares this temporal datum with the specified object for equality.
*
* @param object the object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only
- * properties relevant to coordinate transformations.
+ * @param mode the strictness level of the comparison.
* @return {@code true} if both objects are equal.
*
* @hidden because nothing new to said.
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultVerticalDatum.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
index 58fa153b79..214fe8f0c7 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
@@ -320,9 +320,7 @@ public class DefaultVerticalDatum extends AbstractDatum implements VerticalDatum
* Compares this vertical datum with the specified object for equality.
*
* @param object the object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only
- * properties relevant to coordinate transformations.
+ * @param mode the strictness level of the comparison.
* @return {@code true} if both objects are equal.
*
* @hidden because nothing new to said.
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/PositionTransformer.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/PositionTransformer.java
index 25866b05e7..40f545525a 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/PositionTransformer.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/PositionTransformer.java
@@ -25,10 +25,10 @@ import org.opengis.referencing.operation.CoordinateOperation;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.Matrix;
import org.opengis.referencing.operation.TransformException;
+import org.apache.sis.referencing.CRS;
import org.apache.sis.referencing.MultiRegisterOperations;
import org.apache.sis.referencing.operation.transform.MathTransforms;
import org.apache.sis.geometry.GeneralDirectPosition;
-import org.apache.sis.util.Utilities;
// Specific to the geoapi-3.1 and geoapi-4.0 branches:
import org.opengis.referencing.RegisterOperations;
@@ -218,7 +218,7 @@ public final class PositionTransformer extends GeneralDirectPosition {
* has been invoked. If the specified position uses a new CRS, then get the transformation and save
* it in case the next call to this method would use again the same transformation.
*/
- if (!Utilities.equalsIgnoreMetadata(lastCRS, userCRS)) {
+ if (!CRS.equivalent(lastCRS, userCRS)) {
setSourceCRS(userCRS);
}
if (forward != null) {
@@ -233,7 +233,7 @@ public final class PositionTransformer extends GeneralDirectPosition {
*/
private MathTransform inverse() throws TransformException {
if (inverse == null) {
- if (!Utilities.equalsIgnoreMetadata(lastCRS, defaultCRS)) {
+ if (!CRS.equivalent(lastCRS, defaultCRS)) {
setSourceCRS(defaultCRS);
}
inverse = (forward != null) ? forward.inverse() : MathTransforms.identity(getDimension());
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/RTreeNode.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/RTreeNode.java
index d513113af1..28ee86f03f 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/RTreeNode.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/RTreeNode.java
@@ -24,7 +24,7 @@ import org.opengis.geometry.Envelope;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.apache.sis.geometry.GeneralEnvelope;
import org.apache.sis.io.wkt.Formatter;
-import org.apache.sis.util.Utilities;
+import org.apache.sis.referencing.CRS;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.collection.TreeTable;
import org.apache.sis.util.collection.TableColumn;
@@ -250,7 +250,7 @@ detach: for (RTreeNode next; node != null; node = next) {
final CoordinateReferenceSystem crs = node.getCoordinateReferenceSystem();
if (common == null) {
common = crs;
- } else if (crs != null && !Utilities.equalsIgnoreMetadata(common, crs)) {
+ } else if (crs != null && !CRS.equivalent(common, crs)) {
throw new MismatchedCoordinateMetadataException(Errors.format(Errors.Keys.MismatchedCRS));
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
index 3619628b83..e1d0e580b4 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
@@ -821,9 +821,7 @@ check: for (int isTarget=0; ; isTarget++) { // 0 == source check; 1
* properties are compared including the {@linkplain #getDomains() domains} and the accuracy.
*
* @param object the object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for ignoring properties
- * that do not make a difference in the numerical results of coordinate operations.
+ * @param mode the strictness level of the comparison.
* @return {@code true} if both objects are equal for the given comparison mode.
*/
@Override
@@ -861,7 +859,7 @@ check: for (int isTarget=0; ; isTarget++) { // 0 == source check; 1
{
/*
* At this point all metadata match or can be ignored. First, compare the targetCRS.
- * We need to perform this comparison only if this 'equals(…)' method is not invoked
+ * We need to perform this comparison only if this `equals(…)` method is not invoked
* from AbstractDerivedCRS, otherwise we would fall in an infinite recursive loop
* (because targetCRS is the DerivedCRS, which in turn wants to compare this operation).
*
@@ -890,14 +888,14 @@ check: for (int isTarget=0; ; isTarget++) { // 0 == source check; 1
* Now compare the sourceCRS, potentially with a relaxed ComparisonMode (see above comment).
* If the comparison mode allows the two CRS to have different axis order and units, then we
* need to take in account those difference before to compare the MathTransform. We proceed
- * by modifying 'tr2' as if it was a MathTransform with crs1 as the source instead of crs2.
+ * by modifying `tr2` as if it was a MathTransform with crs1 as the source instead of crs2.
*/
final CoordinateReferenceSystem crs1 = this.getSourceCRS();
final CoordinateReferenceSystem crs2 = that.getSourceCRS();
if (deepEquals(crs1, crs2, mode)) {
MathTransform tr1 = this.getMathTransform();
MathTransform tr2 = that.getMathTransform();
- if (mode.allowsVariant()) try {
+ if (mode.ordinal() >= ComparisonMode.ALLOW_VARIANT.ordinal()) try {
final MathTransform before = MathTransforms.linear(
CoordinateSystems.swapAndScaleAxes(crs1.getCoordinateSystem(),
crs2.getCoordinateSystem()));
@@ -928,9 +926,9 @@ check: for (int isTarget=0; ; isTarget++) { // 0 == source check; 1
@Override
protected long computeHashCode() {
/*
- * Do NOT take 'getMethod()' in account in hash code calculation. See the comment
- * inside the above 'equals(Object, ComparisonMode)' method for more information.
- * Note that we use the 'transform' hash code, which should be sufficient.
+ * Do NOT take `getMethod()` in account in hash code calculation. See the comment
+ * inside the above `equals(Object, ComparisonMode)` method for more information.
+ * Note that we use the `transform` hash code, which should be sufficient.
*/
return super.computeHashCode() + Objects.hash(sourceCRS, targetCRS, interpolationCRS, transform);
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CRSPair.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CRSPair.java
index 3df3ecb118..cd06e050d8 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CRSPair.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CRSPair.java
@@ -62,10 +62,9 @@ final class CRSPair extends org.apache.sis.pending.jdk.Record {
/**
* Compares this pair to the specified object for equality.
*
- * {@note We perform the CRS comparison using strict equality, not using
- * <code>equalsIgnoreMetadata</code>, because metadata matter since
- * they are attributes of the <code>CoordinateOperation</code>
- * object to be created.}
+ * <h4>Implementation note</h4>
+ * We perform the CRS comparison using strict equality, not using {@code equalsIgnoreMetadata(…)},
+ * because metadata matter since they are attributes of the {@code CoordinateOperation} object to be created.
*/
@Override
public boolean equals(final Object object) {
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationFinder.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
index e127c1d49f..9f977bc288 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
@@ -236,7 +236,7 @@ public class CoordinateOperationFinder extends CoordinateOperationRegistry {
{
ArgumentChecks.ensureNonNull("sourceCRS", sourceCRS);
ArgumentChecks.ensureNonNull("targetCRS", targetCRS);
- if (Utilities.equalsIgnoreMetadata(sourceCRS, targetCRS)) try {
+ if (CRS.equivalent(sourceCRS, targetCRS)) try {
return asList(createFromAffineTransform(AXIS_CHANGES, sourceCRS, targetCRS, null,
CoordinateSystems.swapAndScaleAxes(sourceCRS.getCoordinateSystem(),
targetCRS.getCoordinateSystem())));
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java
index a53de1e800..2e9b18a75a 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java
@@ -299,7 +299,7 @@ class CoordinateOperationRegistry {
codeFinder.setIgnoringAxes(false);
codeFinder.setSearchDomain(IdentifiedObjectFinder.Domain.VALID_DATASET);
final IdentifiedObject candidate = codeFinder.findSingleton(object);
- if (Utilities.equalsIgnoreMetadata(object, candidate)) {
+ if (Utilities.deepEquals(object, candidate, ComparisonMode.COMPATIBILITY)) {
return type.cast(candidate);
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
index 802e121ad4..11784505da 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
@@ -81,6 +81,7 @@ final class DefaultConcatenatedOperation extends AbstractCoordinateOperation imp
private static final ComparisonMode[] CRS_ORDER_CRITERIA = {
ComparisonMode.BY_CONTRACT,
ComparisonMode.IGNORE_METADATA,
+ ComparisonMode.COMPATIBILITY,
ComparisonMode.APPROXIMATE
};
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultOperationMethod.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultOperationMethod.java
index 18f93c0c1f..8a202cff50 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultOperationMethod.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultOperationMethod.java
@@ -400,9 +400,7 @@ public class DefaultOperationMethod extends AbstractIdentifiedObject implements
* are compared including the {@linkplain #getFormula() formula}.
*
* @param object the object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only
- * properties relevant to transformations.
+ * @param mode the strictness level of the comparison.
* @return {@code true} if both objects are equal.
*/
@Override
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/matrix/Matrices.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/matrix/Matrices.java
index 3283878af9..fa02ce927b 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/matrix/Matrices.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/matrix/Matrices.java
@@ -1218,16 +1218,13 @@ search: while (freeColumn < numCol) {
* @see MatrixSIS#equals(Object, ComparisonMode)
*/
public static boolean equals(final Matrix m1, final Matrix m2, final ComparisonMode mode) {
- switch (mode) {
- case STRICT: return Objects.equals(m1, m2);
- case BY_CONTRACT: // Fall through
- case IGNORE_METADATA: return equals(m1, m2, 0, false);
- case DEBUG: // Fall through
- case ALLOW_VARIANT: // Fall through
- case APPROXIMATE: return equals(m1, m2, Numerics.COMPARISON_THRESHOLD, true);
- default: throw new IllegalArgumentException(Errors.format(
- Errors.Keys.UnknownEnumValue_2, ComparisonMode.class, mode));
+ if (mode.isApproximate()) {
+ return equals(m1, m2, Numerics.COMPARISON_THRESHOLD, true);
}
+ if (mode == ComparisonMode.STRICT) {
+ return Objects.equals(m1, m2);
+ }
+ return equals(m1, m2, 0, false);
}
/**
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/projection/NormalizedProjection.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
index 7621ccfc9a..7b8c82cdc3 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
@@ -925,6 +925,7 @@ public abstract class NormalizedProjection extends AbstractMathTransform2D imple
}
// Fall through for comparing the eccentricity.
}
+ case COMPATIBILITY:
case IGNORE_METADATA: {
/*
* There is no need to compare both `eccentricity` and `eccentricitySquared` since the former
@@ -961,8 +962,8 @@ public abstract class NormalizedProjection extends AbstractMathTransform2D imple
*/
final double e = max(eccentricity, that.eccentricity);
if (!Numerics.epsilonEqual(eccentricity, that.eccentricity, ANGULAR_TOLERANCE * (1/e - e))) {
- assert (mode != ComparisonMode.DEBUG) : Numerics.messageForDifference(
- "eccentricity", eccentricity, that.eccentricity);
+ assert (mode != ComparisonMode.DEBUG)
+ : Numerics.messageForDifference("eccentricity", eccentricity, that.eccentricity);
return false;
}
break;
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
index 1a123095d6..0ca531980b 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
@@ -887,7 +887,7 @@ public abstract class AbstractMathTransform extends FormattableObject
* typically uses mathematical identities that depend on the formulas used by this transform.
* This method does not need to care about the following more generic cases:
* {@linkplain #isIdentity() identity} transforms, transforms immediately followed by their {@linkplain #inverse() inverses},
- * multiplication of {@linkplain MathTransforms#getMatrix(MathTransform) matrixes} in consecutive transforms.</p>
+ * multiplication of {@linkplain MathTransforms#getMatrix(MathTransform) matrices} in consecutive transforms.</p>
*
* @param context information about the neighbor transforms, and the object where to set the result.
* @throws FactoryException if an error occurred while combining the transforms.
diff --git a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/reader/CRSBuilder.java b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/reader/CRSBuilder.java
index c24d460a8b..85983970b5 100644
--- a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/reader/CRSBuilder.java
+++ b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/reader/CRSBuilder.java
@@ -76,6 +76,7 @@ import org.apache.sis.referencing.operation.provider.PolarStereographicB;
import org.apache.sis.io.TableAppender;
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.Characters;
+import org.apache.sis.util.Utilities;
import org.apache.sis.util.privy.Constants;
import org.apache.sis.util.privy.Strings;
import org.apache.sis.util.privy.Numerics;
@@ -90,7 +91,6 @@ import org.apache.sis.storage.geotiff.base.Resources;
import org.apache.sis.storage.geotiff.base.GeoCodes;
import org.apache.sis.storage.geotiff.base.GeoKeys;
import org.apache.sis.storage.geotiff.base.UnitKey;
-import static org.apache.sis.util.Utilities.equalsIgnoreMetadata;
/**
@@ -913,8 +913,8 @@ public final class CRSBuilder extends ReferencingFactoryContainer {
lastName = datum.getName();
try {
final CommonCRS predefined = CommonCRS.valueOf(name);
- if (equalsIgnoreMetadata(predefined.ellipsoid(), ellipsoid) &&
- equalsIgnoreMetadata(predefined.primeMeridian(), meridian))
+ if (Utilities.equalsIgnoreMetadata(predefined.ellipsoid(), ellipsoid) &&
+ Utilities.equalsIgnoreMetadata(predefined.primeMeridian(), meridian))
{
return predefined.datum();
}
diff --git a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/CRSMerger.java b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/CRSMerger.java
index e37a4ac523..484289640b 100644
--- a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/CRSMerger.java
+++ b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/CRSMerger.java
@@ -21,11 +21,11 @@ import org.opengis.referencing.cs.AxisDirection;
import org.opengis.referencing.cs.EllipsoidalCS;
import org.opengis.referencing.cs.CoordinateSystem;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.apache.sis.referencing.CRS;
import org.apache.sis.referencing.privy.AxisDirections;
import org.apache.sis.referencing.privy.GeodeticObjectBuilder;
import org.apache.sis.referencing.cs.AxesConvention;
import org.apache.sis.referencing.crs.AbstractCRS;
-import org.apache.sis.util.Utilities;
/**
@@ -68,6 +68,6 @@ final class CRSMerger extends GeodeticObjectBuilder {
}
}
final CoordinateReferenceSystem result = super.replaceComponent(implicit, firstDimension, explicit);
- return Utilities.equalsIgnoreMetadata(implicit, result) ? implicit : result;
+ return CRS.equivalent(implicit, result) ? implicit : result;
}
}
diff --git a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/InfoStatements.java b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/InfoStatements.java
index 1bf546c8a2..ad0bb48804 100644
--- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/InfoStatements.java
+++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/InfoStatements.java
@@ -423,7 +423,7 @@ public class InfoStatements implements Localized, AutoCloseable {
if (crs != null) {
if (first == null) {
first = crs;
- } else if (!Utilities.equalsIgnoreMetadata(first, crs)) {
+ } else if (!CRS.equivalent(first, crs)) {
return null;
}
}
@@ -995,7 +995,7 @@ public class InfoStatements implements Localized, AutoCloseable {
*/
try {
final CoordinateReferenceSystem candidate = fetchCRS(srid);
- if (Utilities.equalsIgnoreMetadata(search.crs, candidate)) {
+ if (CRS.equivalent(search.crs, candidate)) {
return srid;
}
} catch (Exception f) {
diff --git a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/SelectionClause.java b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/SelectionClause.java
index efafb0a78f..27f589215a 100644
--- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/SelectionClause.java
+++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/SelectionClause.java
@@ -34,9 +34,9 @@ import org.apache.sis.geometry.wrapper.Geometries;
import org.apache.sis.geometry.wrapper.GeometryWrapper;
import org.apache.sis.metadata.sql.privy.SQLBuilder;
import org.apache.sis.filter.privy.WarningEvent;
+import org.apache.sis.referencing.CRS;
import org.apache.sis.storage.FeatureSet;
import org.apache.sis.system.Modules;
-import org.apache.sis.util.Utilities;
import org.apache.sis.util.Workaround;
// Specific to the geoapi-3.1 and geoapi-4.0 branches:
@@ -150,7 +150,7 @@ public final class SelectionClause extends SQLBuilder implements Consumer<Warnin
final Optional<CoordinateReferenceSystem> crs = c.getDefaultCRS();
if (columnCRS == null) {
columnCRS = crs; // May be empty, which is not the same as null for this class.
- } else if (!Utilities.equalsIgnoreMetadata(columnCRS.orElse(null), crs.orElse(null))) {
+ } else if (!CRS.equivalent(columnCRS.orElse(null), crs.orElse(null))) {
clearColumnCRS();
return true;
}
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/CoverageAggregator.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/CoverageAggregator.java
index 35f0b36fdd..e7af3ad4d8 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/CoverageAggregator.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/CoverageAggregator.java
@@ -95,7 +95,7 @@ import org.apache.sis.util.privy.Numerics;
*
* <ul>
* <li><dfn>Equivalent reference systems</dfn> means two {@link org.opengis.referencing.crs.CoordinateReferenceSystem} instances
- * for which {@link org.apache.sis.util.Utilities#equalsIgnoreMetadata(Object, Object)} returns {@code true}.</li>
+ * for which {@link org.apache.sis.referencing.CRS#equivalent CRS.equivalent(…)} returns {@code true}.</li>
* <li><dfn>Compatible grid to CRS</dfn> means two {@linkplain org.apache.sis.coverage.grid.GridGeometry#getGridToCRS grid to CRS}
* transforms which are identical (with small tolerance for rounding errors) except for the translation terms,
* with the additional condition that the translations, when expressed in units of grid cell indices,
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/GroupByCRS.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/GroupByCRS.java
index 3a9b12e69e..e20eb0dfd1 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/GroupByCRS.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/aggregate/GroupByCRS.java
@@ -19,7 +19,7 @@ package org.apache.sis.storage.aggregate;
import java.util.Locale;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.apache.sis.referencing.IdentifiedObjects;
-import org.apache.sis.util.Utilities;
+import org.apache.sis.referencing.CRS;
/**
@@ -56,7 +56,7 @@ final class GroupByCRS<E> extends Group<E> {
* Returns whether an object having the given <abbr>CRS</abbr> can be a member of this group.
*/
final boolean accepts(final CoordinateReferenceSystem candidate) {
- return Utilities.equalsIgnoreMetadata(crs, candidate);
+ return CRS.equivalent(crs, candidate);
}
/**
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/image/WritableStore.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/image/WritableStore.java
index f6faac8564..593564b149 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/image/WritableStore.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/image/WritableStore.java
@@ -216,7 +216,7 @@ class WritableStore extends WorldFileStore {
* must be identical to the existing one, in which case there is nothing to do.
*/
if (index != MAIN_IMAGE || isMultiImages() > 1) {
- if (!getGridGeometry(MAIN_IMAGE).equals(gg, ComparisonMode.IGNORE_METADATA)) {
+ if (!getGridGeometry(MAIN_IMAGE).equals(gg, ComparisonMode.COMPATIBILITY)) {
String message = resources().getString(Resources.Keys.IncompatibleGridGeometry);
throw new IncompatibleResourceException(message).addAspect("gridGeometry");
}
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/ComparisonMode.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/ComparisonMode.java
index ed337dad42..88c1a98f29 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/ComparisonMode.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/ComparisonMode.java
@@ -16,12 +16,15 @@
*/
package org.apache.sis.util;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.opengis.referencing.operation.MathTransform;
+
/**
- * Specifies the level of strictness when comparing two {@link LenientComparable} objects
- * for equality. This enumeration allows users to specify which kind of differences can be
- * tolerated between two objects: differences in implementation class, differences in
- * some kinds of property, or slight difference in numerical values.
+ * Specifies the level of strictness when comparing two {@link LenientComparable} objects for equality.
+ * This enumeration allows users to specify which kind of differences can be tolerated between two objects:
+ * differences in implementation class, differences in some kinds of property,
+ * or slight difference in numerical values.
*
* <p>This enumeration is <em>ordered</em> from stricter to more lenient levels:</p>
*
@@ -29,16 +32,17 @@ package org.apache.sis.util;
* <li>{@link #STRICT} – All attributes of the compared objects shall be strictly equal.</li>
* <li>{@link #BY_CONTRACT} – Only the attributes published in the interface contract need to be compared.</li>
* <li>{@link #IGNORE_METADATA} – Only the attributes relevant to the object functionality are compared.</li>
- * <li>{@link #APPROXIMATE} – Only the attributes relevant to the object functionality are compared,
- * with some tolerance threshold on numerical values.</li>
- * <li>{@link #ALLOW_VARIANT} – For objects not really equal but related (e.g. CRS using different axis order).</li>
+ * <li>{@link #COMPATIBILITY} – Like {@code IGNORE_METADATA}, but ignore also some structural changes for historical reasons.</li>
+ * <li>{@link #APPROXIMATE} – Like {@code COMPATIBILITY}, with some tolerance threshold on numerical values.</li>
+ * <li>{@link #ALLOW_VARIANT} – Objects not really equal but related (e.g., <abbr>CRS</abbr> using different axis order).</li>
* <li>{@link #DEBUG} – Special mode for figuring out why two objects expected to be equal are not.</li>
* </ol>
*
- * If two objects are equal at some level of strictness <var>E</var>, then they should also
- * be equal at all levels listed below <var>E</var> in the above list. For example if two objects
- * are equal at the {@link #BY_CONTRACT} level, then they should also be equal at the
- * {@link #IGNORE_METADATA} level but not necessarily at the {@link #STRICT} level.
+ * If two objects are equal at some level of strictness <var>E</var>,
+ * then they shall also be equal at all levels listed after <var>E</var> in the above list.
+ * For example, if two objects are equal at the {@link #BY_CONTRACT} level,
+ * then they shall also be equal at the {@link #IGNORE_METADATA} level
+ * but not necessarily at the {@link #STRICT} level.
*
* @author Martin Desruisseaux (Geomatys)
* @version 1.5
@@ -57,7 +61,7 @@ public enum ComparisonMode {
* {@code B.equals(A)}).
*
* <h4>Implementation note</h4>
- * In the SIS implementation, this comparison mode usually have the following
+ * In the <abbr>SIS</abbr> implementations, this comparison mode usually have the following
* characteristics (not always, this is only typical):
*
* <ul>
@@ -73,12 +77,12 @@ public enum ComparisonMode {
* Only the attributes published in some contract (typically a GeoAPI interface) need to be compared.
* The implementation classes do not need to be the same and some private attributes may be ignored.
*
- * <p>Note that this comparison mode does <strong>not</strong> guaranteed {@link Object#hashCode()}
+ * <p>Note that this comparison mode does <strong>not</strong> guarantee {@link Object#hashCode()}
* consistency, neither comparison symmetry (i.e. {@code A.equals(B)} and {@code B.equals(A)} may
* return different results if the {@code equals} methods are implemented differently).</p>
*
* <h4>Implementation note</h4>
- * In the SIS implementation, this comparison mode usually have the following
+ * In the <abbr>SIS</abbr> implementations, this comparison mode usually have the following
* characteristics (not always, this is only typical):
*
* <ul>
@@ -94,24 +98,24 @@ public enum ComparisonMode {
* {@link #BY_CONTRACT}.
*
* <h4>Application to coordinate reference systems</h4>
- * If the objects being compared are {@link org.opengis.referencing.crs.CoordinateReferenceSystem} instances,
+ * If the objects being compared are {@link CoordinateReferenceSystem} instances,
* then only the properties impacting coordinate values shall be compared.
- * Metadata like the {@linkplain org.apache.sis.referencing.crs.AbstractCRS#getIdentifiers() identifiers}
+ * Metadata like the {@linkplain CoordinateReferenceSystem#getIdentifiers() identifiers}
* or the {@linkplain org.apache.sis.referencing.crs.AbstractCRS#getDomains() domain of validity},
* which have no impact on the coordinates being calculated, shall be ignored.
*
* <h4>Application to coordinate operations</h4>
- * If the objects being compared are {@link org.opengis.referencing.operation.MathTransform} instances,
- * then two transforms defined in a different way may be considered equivalent. For example, it is possible
- * to define a Mercator projection in different ways, named "variant A", "variant B" and "variant C"
- * in EPSG dataset, each having their own set of parameters.
+ * If the objects being compared are {@link MathTransform} instances,
+ * then two transforms defined in a different way may be considered equivalent.
+ * For example, it is possible to define a Mercator projection in different ways,
+ * named "variant A", "variant B" and "variant C" in EPSG dataset, each having their own set of parameters.
* The {@link #STRICT} or {@link #BY_CONTRACT} modes shall consider two projections as equal only if their
* {@linkplain org.apache.sis.referencing.operation.transform.AbstractMathTransform#getParameterValues()
* parameter values} are strictly identical, while the {@code IGNORE_METADATA} mode can consider
- * those objects as equivalent despite difference in the set of parameters, as long as coordinate
- * transformations still produce the same results.
+ * those objects as equivalent despite difference in the set of parameters,
+ * as long as coordinate operations still produce the same results.
*
- * <h4>Example</h4>
+ * <h5>Example</h5>
* A <q>Mercator (variant B)</q> projection with a <i>standard parallel</i> value of 60° produces the
* same results as a <q>Mercator (variant A)</q> projection with a <i>scale factor</i> value of 0.5.
*
@@ -121,14 +125,44 @@ public enum ComparisonMode {
IGNORE_METADATA,
/**
- * Only the attributes relevant to the object functionality are compared, with some tolerance* threshold on numerical values.
- * The threshold is implementation dependent, but the current <abbr>SIS</abbr> implementation generally aims for a precision
- * of 1 centimeter in the linear and angular parameter values for a planet of the size of Earth.
+ * Only the attributes relevant to the object functionality are compared, with a tolerance for some structural changes.
+ * The changes may exist for historical reasons, or for compatibility with common practice in other software.
+ * However, the changes should not have a practical impact on the numerical results of coordinate operations.
+ * For example, changes of input or output axis order is not accepted by this comparison mode.
+ *
+ * <h4>Application to datum ensembles</h4>
+ * Two Coordinate Reference Systems (<abbr>CRS</abbr>) may be considered compatible when
+ * one <abbr>CRS</abbr> is associated to a datum and the other <abbr>CRS</abbr> is associated to a datum ensemble,
+ * but the former can be considered as the {@linkplain org.apache.sis.referencing.datum.DatumOrEnsemble#isLegacyDatum
+ * legacy definition} of the latter. This comparison mode can check, among other criteria,
+ * whether the datum and the datum ensemble share a common authority code.
+ *
+ * <p><b>Example:</b> {@code EPSG:9:4326} and {@code EPSG:10:4326}, which are both the same (at least conceptually)
+ * geographic <abbr>CRS</abbr> associated to the authority code 4326 in the <abbr>EPSG</abbr> geodetic dataset,
+ * but as defined in version 9 and 10 respectively of the <abbr>EPSG</abbr> database.
+ * They are the <abbr>CRS</abbr> definitions before and after the introduction of datum ensemble in the schema.</p>
+ *
+ * <h4>Application to dynamic reference frames</h4>
+ * Two Reference Frames may be considered compatible despite one frame being static and the other frame being dynamic.
+ * This comparison mode can check, among other criteria, whether the two reference frames share a common authority code
+ * or have an {@linkplain org.apache.sis.referencing.IdentifiedObjects#isHeuristicMatchForName equivalent name}.
+ *
+ * <p><b>Example:</b> the "WGS 1972" reference frame as defined in versions 9 and 10 of <abbr>EPSG</abbr> database.</p>
+ *
+ * @see #isCompatibility()
+ *
+ * @since 1.5
+ */
+ COMPATIBILITY,
+
+ /**
+ * Only the attributes relevant to compatibility are compared, with some tolerance threshold on numerical values.
+ * The threshold is implementation dependent, but the current <abbr>SIS</abbr> implementation generally aims for
+ * a precision of 1 centimeter in the linear and angular parameter values for a planet of the size of Earth.
*
* <h4>Application to coordinate operations</h4>
- * If two {@link org.opengis.referencing.operation.MathTransform} objects are considered equal according this mode,
- * then for any given identical source position, the two compared transforms shall compute at least approximately
- * the same target position.
+ * If two {@link MathTransform} objects are considered equal according this mode, then for any given identical source position,
+ * the two compared transforms shall compute at least approximately the same target position.
* A small difference is tolerated between the target coordinates calculated by the two math transforms.
* How small is “small” is implementation dependent — the threshold cannot be specified in the current
* implementation, because of the non-linear nature of map projections.
@@ -152,29 +186,18 @@ public enum ComparisonMode {
* <b>Example:</b> two geographic <abbr>CRS</abbr>s with the same attributes but with
* (<var>latitude</var>, <var>longitude</var>) axes in one case and
* (<var>longitude</var>, <var>latitude</var>) axes in the other case.</li>
- * <li>Two Coordinate Reference Systems where one is associated to a datum and the other to a datum ensemble,
- * but the datum and the ensemble share a common authority code or have an
- * {@link org.apache.sis.referencing.IdentifiedObjects#isHeuristicMatchForName equivalent name}.
- * <b>Example:</b> {@code EPSG:9:4326} and {@code EPSG:10:4326}, which are both the same (at least conceptually)
- * geographic <abbr>CRS</abbr> associated to the authority code 4326 in the <abbr>EPSG</abbr> geodetic dataset,
- * but as defined in version 9 and 10 respectively of the <abbr>EPSG</abbr> database.
- * They are the <abbr>CRS</abbr> definitions before and after the introduction of datum ensemble in the schema.</li>
- * <li>Two Reference Frames which share a common authority code or have an
- * {@link org.apache.sis.referencing.IdentifiedObjects#isHeuristicMatchForName equivalent name},
- * despite one frame being static and the other frame being dynamic.
- * <b>Example:</b> the "WGS 1972" reference frame as defined in versions 9 and 10 of <abbr>EPSG</abbr> database.</li>
* </ul>
*
- * @see #allowsVariant()
- *
* @since 0.7
*/
ALLOW_VARIANT,
/**
- * Same as {@link #APPROXIMATE}, except that an {@link AssertionError} is thrown if the two
- * objects are not equal and assertions are enabled. The exception message and stack trace help
- * to locate which attributes are not equal. This mode is typically used in assertions like below:
+ * Asserts that two objects shall be approximately equal.
+ * The same comparison as {@link #APPROXIMATE} is performed,
+ * except that an {@link AssertionError} is thrown if the two objects are not equal and assertions are enabled.
+ * The exception message and stack trace help to locate which attributes are not equal.
+ * This mode is typically used in assertions like below:
*
* {@snippet lang="java" :
* assert Utilities.deepEquals(object1, object2, ComparisonMode.DEBUG);
@@ -189,10 +212,10 @@ public enum ComparisonMode {
/**
* Returns {@code true} if this comparison ignores metadata.
- * This method currently returns {@code true} for {@link #IGNORE_METADATA}, {@link #APPROXIMATE},
- * {@link #ALLOW_VARIANT} or {@link #DEBUG}, but this list may be extended in future <abbr>SIS</abbr> versions.
+ * This method returns {@code true} for {@link #IGNORE_METADATA}, {@link #COMPATIBILITY}, {@link #APPROXIMATE},
+ * {@link #ALLOW_VARIANT} and {@link #DEBUG}.
*
- * @return whether this comparison ignore metadata.
+ * @return whether this comparison ignores metadata.
*
* @since 0.6
*/
@@ -201,29 +224,28 @@ public enum ComparisonMode {
}
/**
- * Returns {@code true} if this comparison uses a tolerance threshold.
- * This method currently returns {@code true} for {@link #APPROXIMATE}, {@link #ALLOW_VARIANT}
- * or {@link #DEBUG}, but this list may be extended in future <abbr>SIS</abbr> versions.
+ * Returns {@code true} if this comparison accepts structural changes for compatibility reasons.
+ * This method returns {@code true} for {@link #COMPATIBILITY}, {@link #APPROXIMATE}, {@link #ALLOW_VARIANT}
+ * and {@link #DEBUG}.
*
- * @return whether this comparison uses a tolerance threshold.
+ * @return whether this comparison accepts structural changes for compatibility reasons.
*
- * @since 1.0
+ * @since 1.5
*/
- public boolean isApproximate() {
- return ordinal() >= APPROXIMATE.ordinal();
+ public boolean isCompatibility() {
+ return ordinal() >= COMPATIBILITY.ordinal();
}
/**
- * Returns {@code true} if this comparison allow variants.
- * This method currently returns {@code true} for {@link #ALLOW_VARIANT}
- * or {@link #DEBUG}, but this list may be extended in future <abbr>SIS</abbr> versions.
+ * Returns {@code true} if this comparison uses a tolerance threshold.
+ * This method returns {@code true} for {@link #APPROXIMATE}, {@link #ALLOW_VARIANT} and {@link #DEBUG}.
*
- * @return whether this comparison allows variants.
+ * @return whether this comparison uses a tolerance threshold.
*
- * @since 1.5
+ * @since 1.0
*/
- public boolean allowsVariant() {
- return ordinal() >= ALLOW_VARIANT.ordinal();
+ public boolean isApproximate() {
+ return ordinal() >= APPROXIMATE.ordinal();
}
/**
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/LenientComparable.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/LenientComparable.java
index b1539f6d71..692710efac 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/LenientComparable.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/LenientComparable.java
@@ -37,7 +37,7 @@ package org.apache.sis.util;
* in the GeoAPI interfaces are compared. The above-cited identifiers and {@code xlinks}
* attributes are ignored.</li>
* <li>{@link ComparisonMode#APPROXIMATE APPROXIMATE} – The same attributes as the above
- * {@code IGNORE_METADATA} mode are compared, but a slight (implementation dependant)
+ * {@code IGNORE_METADATA} mode are compared, but a slight (implementation dependent)
* difference is tolerated in floating point numbers.</li>
* </ol>
* </li>
@@ -56,8 +56,10 @@ package org.apache.sis.util;
* are ignored because they have no incidence on the coordinate values to be computed by
* {@linkplain org.opengis.referencing.operation.ConcatenatedOperation coordinate operations}.
* All other attributes that are relevant to coordinate calculations, must be equal.</li>
+ * <li>{@link ComparisonMode#COMPATIBILITY COMPATIBILITY} – The same attributes as the above
+ * {@code IGNORE_METADATA} mode are compared, but some structural changes are accepted for historical reasons.</li>
* <li>{@link ComparisonMode#APPROXIMATE APPROXIMATE} – The same attributes as the above
- * {@code IGNORE_METADATA} mode are compared, but a slight (implementation dependant)
+ * {@code COMPATIBILITY} mode are compared, but a slight (implementation dependent)
* difference is tolerated in floating point numbers.</li>
* </ol>
* </li>
@@ -75,22 +77,22 @@ package org.apache.sis.util;
* value of 60° produces the same results as a <q>Mercator (1SP)</q> projection on the same sphere
* with a <i>scale factor</i> value of 0.5.</li>
* <li>{@link ComparisonMode#APPROXIMATE APPROXIMATE} – The same attributes as the above
- * {@code IGNORE_METADATA} mode are compared, but a slight (implementation dependant)
+ * {@code IGNORE_METADATA} mode are compared, but a slight (implementation dependent)
* difference is tolerated in floating point numbers.</li>
* </ol>
* </li>
* <li>{@link org.apache.sis.referencing.operation.matrix.MatrixSIS} and
* {@link org.apache.sis.referencing.operation.transform.LinearTransform} implementations
* <ol>
- * <li>{@link ComparisonMode#STRICT STRICT} – Objects must be of the same class, matrixes
+ * <li>{@link ComparisonMode#STRICT STRICT} – Objects must be of the same class, matrices
* must have the same size and all matrix elements must be equal.</li>
- * <li>{@link ComparisonMode#BY_CONTRACT BY_CONTRACT} – Matrixes must have the same size
- * and all matrix elements must be equal, but the matrixes are not required to be the
+ * <li>{@link ComparisonMode#BY_CONTRACT BY_CONTRACT} – Matrices must have the same size
+ * and all matrix elements must be equal, but the matrices are not required to be the
* same implementation class (any {@link org.opengis.referencing.operation.Matrix} is okay).</li>
* <li>{@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} – Synonymous to the
- * {@code BY_CONTRACT} mode, because matrixes don't have metadata.</li>
+ * {@code BY_CONTRACT} mode, because matrices don't have metadata.</li>
* <li>{@link ComparisonMode#APPROXIMATE APPROXIMATE} – The same attributes as the above
- * {@code BY_CONTRACT} mode are compared, but a slight (implementation dependant)
+ * {@code BY_CONTRACT} mode are compared, but a slight (implementation dependent)
* difference is tolerated in floating point numbers.</li>
* </ol>
* </li>
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/Utilities.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/Utilities.java
index 8db47aea4e..e281e42d0b 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/Utilities.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/Utilities.java
@@ -52,7 +52,7 @@ public final class Utilities extends Static {
* results than transforming the same coordinates with the other transform.</li>
*
* <li>If the two given objects are
- * {@linkplain org.apache.sis.referencing.crs.AbstractCRS Coordinate Reference Systems} (CRS), then a call to
+ * {@linkplain org.opengis.referencing.crs.CoordinateReferenceSystem Coordinate Reference Systems} (CRS), then a call to
* <code>{@linkplain org.apache.sis.referencing.CRS#findOperation findOperation}(crs1, crs2, null)</code>
* will return an identity operation.</li>
* </ul>
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/TreeTable.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/TreeTable.java
index c4ed6524c5..372fe26d16 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/TreeTable.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/TreeTable.java
@@ -127,7 +127,7 @@ public interface TreeTable {
* Returns the parent node, or {@code null} if this node is the root of the tree.
*
* <p>There is intentionally no {@code setParent(Node)} method, as children and parent managements
- * are highly implementation-dependant. If the {@linkplain #getChildren() children collection} is
+ * are highly implementation dependent. If the {@linkplain #getChildren() children collection} is
* modifiable, then implementations are encouraged to update automatically the parent when a child
* is <em>added to</em> or <em>removed from</em> that collection.</p>
*
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/privy/Numerics.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/privy/Numerics.java
index 7d69c314da..dff8bca68e 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/privy/Numerics.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/privy/Numerics.java
@@ -72,7 +72,7 @@ public final class Numerics extends Static {
* Matrix m1 = ...;
* Matrix m2 = ...;
* if (Matrices.epsilonEqual(m1, m2, COMPARISON_THRESHOLD, true)) {
- * // Consider that matrixes are equal.
+ * // Consider that matrices are equal.
* }
* }
*
diff --git a/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/Assertions.java b/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/Assertions.java
index dd883066f4..13c92950c7 100644
--- a/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/Assertions.java
+++ b/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/Assertions.java
@@ -69,6 +69,7 @@ public final class Assertions extends Static {
assertFalse(Utilities.deepEquals(o1, o2, ComparisonMode.STRICT), "deepEquals(STRICT)");
assertFalse(Utilities.deepEquals(o1, o2, ComparisonMode.BY_CONTRACT), "deepEquals(BY_CONTRACT)");
assertFalse(Utilities.deepEquals(o1, o2, ComparisonMode.IGNORE_METADATA), "deepEquals(IGNORE_METADATA)");
+ assertFalse(Utilities.deepEquals(o1, o2, ComparisonMode.COMPATIBILITY), "deepEquals(COMPATIBILITY)");
assertFalse(Utilities.deepEquals(o1, o2, ComparisonMode.APPROXIMATE), "deepEquals(APPROXIMATE)");
}
@@ -76,7 +77,7 @@ public final class Assertions extends Static {
* Asserts that the two given objects are approximately equal, while slightly different.
* More specifically, this method asserts that the given objects are equal according the
* {@link ComparisonMode#APPROXIMATE} criterion, but not equal according the
- * {@link ComparisonMode#IGNORE_METADATA} criterion.
+ * {@link ComparisonMode#COMPATIBILITY} criterion.
*
* @param expected the expected object.
* @param actual the actual object.
@@ -84,6 +85,7 @@ public final class Assertions extends Static {
public static void assertAlmostEquals(final Object expected, final Object actual) {
assertFalse(Utilities.deepEquals(expected, actual, ComparisonMode.STRICT), "Shall not be strictly equal.");
assertFalse(Utilities.deepEquals(expected, actual, ComparisonMode.IGNORE_METADATA), "Shall be slightly different.");
+ assertFalse(Utilities.deepEquals(expected, actual, ComparisonMode.COMPATIBILITY), "Shall be slightly different.");
assertTrue (Utilities.deepEquals(expected, actual, ComparisonMode.DEBUG), "Shall be approximately equal.");
assertTrue (Utilities.deepEquals(expected, actual, ComparisonMode.APPROXIMATE), "DEBUG inconsistent with APPROXIMATE.");
}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Geometries.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Geometries.java
index 157cd5d6d8..c890aff7f3 100644
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Geometries.java
+++ b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/Geometries.java
@@ -69,7 +69,6 @@ import org.apache.sis.referencing.privy.AxisDirections;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.SimpleInternationalString;
import org.apache.sis.util.Static;
-import org.apache.sis.util.Utilities;
/**
@@ -442,7 +441,7 @@ public final class Geometries extends Static {
if (!primitive.getType().equals(type)) {
throw new IllegalArgumentException("All primitives must have the same type");
}
- if (!Utilities.equalsIgnoreMetadata(crs, primitive.getCoordinateReferenceSystem())) {
+ if (!CRS.equivalent(crs, primitive.getCoordinateReferenceSystem())) {
throw new IllegalArgumentException("All primitives must have the same CRS, found \n" + crs +"\n and \n" + primitive.getCoordinateReferenceSystem());
}
if (resultAttributes.size() != primitive.getAttributesType().getAttributeNames().size()) {
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/PreparedTIN.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/PreparedTIN.java
index 587cb78163..7064707f7e 100644
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/PreparedTIN.java
+++ b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/PreparedTIN.java
@@ -24,7 +24,6 @@ import java.util.Optional;
import java.util.stream.Stream;
import org.locationtech.jts.index.quadtree.Quadtree;
import org.opengis.coverage.CannotEvaluateException;
-import org.opengis.geometry.DirectPosition;
import org.opengis.geometry.Envelope;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.MathTransform;
@@ -38,7 +37,6 @@ import org.apache.sis.geometry.Envelopes;
import org.apache.sis.geometry.GeneralEnvelope;
import org.apache.sis.referencing.CRS;
import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.util.Utilities;
/**
@@ -105,8 +103,8 @@ public interface PreparedTIN extends TIN {
} else {
final CoordinateReferenceSystem envCrs = env.getCoordinateReferenceSystem();
final org.locationtech.jts.geom.Envelope e;
- if (Utilities.equalsIgnoreMetadata(envCrs, crs)
- || Utilities.equalsIgnoreMetadata(envCrs, crs2d)) {
+ if (CRS.equivalent(envCrs, crs)
+ || CRS.equivalent(envCrs, crs2d)) {
//compatible crs
} else {
env = Envelopes.transform(env, crs2d);
@@ -199,8 +197,8 @@ public interface PreparedTIN extends TIN {
} else {
final CoordinateReferenceSystem envCrs = env.getCoordinateReferenceSystem();
final org.locationtech.jts.geom.Envelope e;
- if (Utilities.equalsIgnoreMetadata(envCrs, base[0].crs)
- || Utilities.equalsIgnoreMetadata(envCrs, base[0].crs2d)) {
+ if (CRS.equivalent(envCrs, base[0].crs)
+ || CRS.equivalent(envCrs, base[0].crs2d)) {
//compatible crs
} else {
env = Envelopes.transform(env, base[0].crs2d);
@@ -305,7 +303,7 @@ public interface PreparedTIN extends TIN {
if (Geometries.isUndefined(dpCrs)) {
//expecting the same crs as the surface, no transform
lastTransform = null;
- } else if (Utilities.equalsIgnoreMetadata(tincrs, dpCrs)) {
+ } else if (CRS.equivalent(tincrs, dpCrs)) {
//equivalent crs, no transform
lastTransform = null;
} else {
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/AbstractTuple.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/AbstractTuple.java
index a04cb798de..0fa09f39f7 100644
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/AbstractTuple.java
+++ b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/AbstractTuple.java
@@ -19,7 +19,7 @@ package org.apache.sis.geometries.math;
import java.util.Arrays;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.util.Utilities;
+import org.apache.sis.referencing.CRS;
/**
@@ -86,7 +86,7 @@ abstract class AbstractTuple<T extends AbstractTuple<T>> implements Tuple<T> {
}
}
//checking crs is expensive, do it last
- if (!Utilities.equalsIgnoreMetadata(getCoordinateReferenceSystem(), other.getCoordinateReferenceSystem())) {
+ if (!CRS.equivalent(getCoordinateReferenceSystem(), other.getCoordinateReferenceSystem())) {
return false;
}
return true;
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Tuple.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Tuple.java
index cbee7c1a88..4d95f79ebe 100644
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Tuple.java
+++ b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Tuple.java
@@ -20,7 +20,7 @@ import org.opengis.geometry.DirectPosition;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
-import org.apache.sis.util.Utilities;
+import org.apache.sis.referencing.CRS;
/**
@@ -378,7 +378,7 @@ public interface Tuple<T extends Tuple <T>> {
}
}
//checking crs is expensive, do it last
- if (!Utilities.equalsIgnoreMetadata(getCoordinateReferenceSystem(), other.getCoordinateReferenceSystem())) {
+ if (!CRS.equivalent(getCoordinateReferenceSystem(), other.getCoordinateReferenceSystem())) {
return false;
}
return true;
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/mesh/MeshPrimitiveComparator.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/mesh/MeshPrimitiveComparator.java
index 677b2bd57b..1dff2651fe 100644
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/mesh/MeshPrimitiveComparator.java
+++ b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/mesh/MeshPrimitiveComparator.java
@@ -29,7 +29,7 @@ import org.apache.sis.geometries.Triangle;
import org.apache.sis.geometries.mesh.MeshPrimitive.Vertex;
import org.apache.sis.geometries.math.Tuple;
import org.apache.sis.geometries.math.TupleArray;
-import org.apache.sis.util.Utilities;
+import org.apache.sis.referencing.CRS;
/**
@@ -85,7 +85,7 @@ public final class MeshPrimitiveComparator {
public void compare(MeshPrimitive expected, MeshPrimitive candidate) throws IllegalArgumentException {
if (compareCrs) {
- if (!Utilities.equalsIgnoreMetadata(expected.getCoordinateReferenceSystem(), candidate.getCoordinateReferenceSystem())) {
+ if (!CRS.equivalent(expected.getCoordinateReferenceSystem(), candidate.getCoordinateReferenceSystem())) {
throw new IllegalArgumentException("CRS are different");
}
}
@@ -162,7 +162,7 @@ public final class MeshPrimitiveComparator {
public void compare(MultiMeshPrimitive expected, MultiMeshPrimitive candidate) throws IllegalArgumentException {
if (compareCrs) {
- if (!Utilities.equalsIgnoreMetadata(expected.getCoordinateReferenceSystem(), candidate.getCoordinateReferenceSystem())) {
+ if (!CRS.equivalent(expected.getCoordinateReferenceSystem(), candidate.getCoordinateReferenceSystem())) {
throw new IllegalArgumentException("CRS are different");
}
}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/mesh/MultiMeshPrimitive.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/mesh/MultiMeshPrimitive.java
index 4a91844abd..71507405f1 100644
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/mesh/MultiMeshPrimitive.java
+++ b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/mesh/MultiMeshPrimitive.java
@@ -29,8 +29,8 @@ import org.opengis.referencing.operation.TransformException;
import org.apache.sis.geometries.Geometries;
import org.apache.sis.geometries.GeometryCollection;
import org.apache.sis.geometries.privy.AbstractGeometry;
+import org.apache.sis.referencing.CRS;
import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.util.Utilities;
/**
@@ -118,7 +118,7 @@ public final class MultiMeshPrimitive<T extends MeshPrimitive> extends AbstractG
*/
public void append(Collection<? extends MeshPrimitive> other) {
for (MeshPrimitive p : other) {
- if (!Utilities.equalsIgnoreMetadata(crs, p.getCoordinateReferenceSystem())) {
+ if (!CRS.equivalent(crs, p.getCoordinateReferenceSystem())) {
throw new IllegalArgumentException("Primitives must have the same CRS as the MultiPrimitive.");
}
}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/ProcessorUtils.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/ProcessorUtils.java
index 9f9f71f4f3..a3e0a8c8a0 100644
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/ProcessorUtils.java
+++ b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/processor/ProcessorUtils.java
@@ -23,8 +23,8 @@ import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.util.FactoryException;
import org.apache.sis.geometries.Geometry;
import org.apache.sis.geometries.operation.OperationException;
+import org.apache.sis.referencing.CRS;
import org.apache.sis.util.Static;
-import org.apache.sis.util.Utilities;
/**
@@ -41,7 +41,7 @@ public final class ProcessorUtils extends Static {
public static void ensureSameCRS(Geometry geom1, Geometry geom2) {
final CoordinateReferenceSystem crs1 = geom1.getCoordinateReferenceSystem();
final CoordinateReferenceSystem crs2 = geom2.getCoordinateReferenceSystem();
- if (!Utilities.equalsIgnoreMetadata(crs1, crs2)) {
+ if (!CRS.equivalent(crs1, crs2)) {
throw new OperationException("Geometries do not have the same CRS");
}
}
@@ -60,11 +60,11 @@ public final class ProcessorUtils extends Static {
throw new OperationException("Geometries CRS must be at least 2D");
}
- if (!Utilities.equalsIgnoreMetadata(crs1, crs2)) {
+ if (!CRS.equivalent(crs1, crs2)) {
if (dim1 != 2 || dim2 != 2) {
CoordinateReferenceSystem subcrs1 = getCrs2d(crs1);
CoordinateReferenceSystem subcrs2 = getCrs2d(crs2);
- if (subcrs1 == null || !Utilities.equalsIgnoreMetadata(subcrs1, subcrs2)) {
+ if (subcrs1 == null || !CRS.equivalent(subcrs1, subcrs2)) {
throw new OperationException("Geometries do not have the same CRS 2D");
}
}
diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/simplify/greedyinsert/TINBuilder.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/simplify/greedyinsert/TINBuilder.java
index 351d8d211c..0bdee91ade 100644
--- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/simplify/greedyinsert/TINBuilder.java
+++ b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/simplify/greedyinsert/TINBuilder.java
@@ -38,8 +38,8 @@ import org.apache.sis.geometries.math.Tuple;
import org.apache.sis.geometries.math.TupleArray;
import org.apache.sis.geometries.math.TupleArrays;
import org.apache.sis.geometries.operation.OperationException;
+import org.apache.sis.referencing.CRS;
import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.util.Utilities;
/**
@@ -158,7 +158,7 @@ public final class TINBuilder {
final Set<Point2D.Double> set = new HashSet<>(pts.size());
final List<Tuple> uniques = new ArrayList<>();
for (Tuple t : pts) {
- if (!Utilities.equalsIgnoreMetadata(crs, t.getCoordinateReferenceSystem())) {
+ if (!CRS.equivalent(crs, t.getCoordinateReferenceSystem())) {
throw new OperationException("Points must have the same crs avec corner points");
}
if (set.add(new Point2D.Double(t.get(0), t.get(1)))) {
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/StatusBar.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/StatusBar.java
index 85590488cd..dd8c3913ac 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/StatusBar.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/StatusBar.java
@@ -796,7 +796,7 @@ public class StatusBar extends Widget implements EventHandler<MouseEvent> {
* (which may be different), which implies keeping the same `objectiveToPositionCRS`.
*/
final boolean clear = (fullOperationSearchRequired != null) && fullOperationSearchRequired.test(canvas);
- final boolean sameCRS = !clear && Utilities.equalsIgnoreMetadata(objectiveCRS, crs);
+ final boolean sameCRS = !clear && CRS.equivalent(objectiveCRS, crs);
if (localToCRS == null) {
localToCRS = MathTransforms.identity(BIDIMENSIONAL);
}
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/PositionableProjection.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/PositionableProjection.java
index 6336eb1bf9..f8b36e3526 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/PositionableProjection.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/PositionableProjection.java
@@ -32,7 +32,6 @@ import org.apache.sis.measure.AngleFormat;
import org.apache.sis.measure.Latitude;
import org.apache.sis.measure.Longitude;
import org.apache.sis.measure.Units;
-import org.apache.sis.util.Utilities;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.logging.Logging;
import static org.apache.sis.gui.internal.LogHandler.LOGGER;
@@ -194,7 +193,7 @@ public abstract class PositionableProjection extends CodeList<PositionableProjec
if (normalizedCRS == null) {
normalizedCRS = CommonCRS.WGS84.geographic();
}
- if (!Utilities.equalsIgnoreMetadata(normalizedCRS, inherit)) {
+ if (!CRS.equivalent(normalizedCRS, inherit)) {
center = CRS.findOperation(inherit, normalizedCRS, null).getMathTransform().transform(center, null);
}
return createProjectedCRS(normalizedCRS,