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


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new 502473dc98 Do not use the original coordinate system as the starting 
point for all `AxesConvention`. This is a modification of the cache sharing 
policy introduced in the previous commit. The previous policy was causing 
confusion when two `forConvention(…)` calls are chained and the first call was, 
for example, removing the vertical axis.
502473dc98 is described below

commit 502473dc98e52b39756982b7dddb63920c29558b
Author: Martin Desruisseaux <martin.desruisse...@geomatys.com>
AuthorDate: Mon Jan 15 12:23:30 2024 +0100

    Do not use the original coordinate system as the starting point for all 
`AxesConvention`.
    This is a modification of the cache sharing policy introduced in the 
previous commit.
    The previous policy was causing confusion when two `forConvention(…)` calls 
are chained
    and the first call was, for example, removing the vertical axis.
---
 .../apache/sis/referencing/crs/AbstractCRS.java    | 61 +++++++++--------
 .../sis/referencing/crs/AbstractDerivedCRS.java    | 16 +++--
 .../sis/referencing/crs/DefaultCompoundCRS.java    |  9 +--
 .../sis/referencing/crs/DefaultDerivedCRS.java     | 34 +++++-----
 .../sis/referencing/crs/DefaultEngineeringCRS.java | 10 +--
 .../sis/referencing/crs/DefaultGeocentricCRS.java  | 10 +--
 .../sis/referencing/crs/DefaultGeodeticCRS.java    |  8 +--
 .../sis/referencing/crs/DefaultGeographicCRS.java  | 10 +--
 .../sis/referencing/crs/DefaultImageCRS.java       | 17 +++--
 .../sis/referencing/crs/DefaultParametricCRS.java  | 16 ++---
 .../sis/referencing/crs/DefaultProjectedCRS.java   | 14 ++--
 .../sis/referencing/crs/DefaultTemporalCRS.java    | 18 +++--
 .../sis/referencing/crs/DefaultVerticalCRS.java    | 16 ++---
 .../org/apache/sis/referencing/cs/AbstractCS.java  | 77 ++++++++++++++++------
 .../apache/sis/referencing/cs/AxesConvention.java  |  8 +--
 .../apache/sis/referencing/cs/DefaultAffineCS.java | 12 ++--
 .../sis/referencing/cs/DefaultCartesianCS.java     | 12 ++--
 .../sis/referencing/cs/DefaultCompoundCS.java      | 23 ++++---
 .../sis/referencing/cs/DefaultCylindricalCS.java   | 12 ++--
 .../sis/referencing/cs/DefaultEllipsoidalCS.java   | 12 ++--
 .../apache/sis/referencing/cs/DefaultLinearCS.java | 12 ++--
 .../sis/referencing/cs/DefaultParametricCS.java    | 12 ++--
 .../apache/sis/referencing/cs/DefaultPolarCS.java  | 12 ++--
 .../sis/referencing/cs/DefaultSphericalCS.java     | 12 ++--
 .../apache/sis/referencing/cs/DefaultTimeCS.java   | 12 ++--
 .../sis/referencing/cs/DefaultUserDefinedCS.java   | 12 ++--
 .../sis/referencing/cs/DefaultVerticalCS.java      | 12 ++--
 .../org/apache/sis/referencing/cs/Normalizer.java  | 11 ++--
 28 files changed, 249 insertions(+), 241 deletions(-)

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 0dab42d7cc..3343469505 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
@@ -32,16 +32,16 @@ import org.opengis.referencing.crs.SingleCRS;
 import org.opengis.referencing.crs.GeneralDerivedCRS;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.apache.sis.referencing.AbstractReferenceSystem;
+import org.apache.sis.referencing.cs.AbstractCS;
+import org.apache.sis.referencing.cs.AxesConvention;
+import org.apache.sis.referencing.util.WKTUtilities;
 import org.apache.sis.referencing.util.ReferencingUtilities;
 import org.apache.sis.metadata.internal.ImplementationHelper;
-import org.apache.sis.referencing.cs.AxesConvention;
-import org.apache.sis.referencing.cs.AbstractCS;
-import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.io.wkt.Formatter;
-import static org.apache.sis.util.Utilities.deepEquals;
-import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
-import static org.apache.sis.referencing.util.WKTUtilities.toFormattable;
+import org.apache.sis.util.Utilities;
+import org.apache.sis.util.ArgumentChecks;
+import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.resources.Errors;
 
 // Specific to the geoapi-3.1 and geoapi-4.0 branches:
@@ -128,10 +128,13 @@ public class AbstractCRS extends AbstractReferenceSystem 
implements CoordinateRe
 
     /**
      * Creates the value to assign to the {@link #forConvention} map by 
constructors.
+     *
+     * @param  original  the coordinate system to declare as the original one.
+     * @return map to assign to the {@link #forConvention} field.
      */
-    private EnumMap<AxesConvention,AbstractCRS> forConvention() {
+    private static EnumMap<AxesConvention,AbstractCRS> forConvention(final 
AbstractCRS original) {
         var m = new EnumMap<AxesConvention,AbstractCRS>(AxesConvention.class);
-        m.put(AxesConvention.ORIGINAL, this);
+        m.put(AxesConvention.ORIGINAL, original);
         return m;
     }
 
@@ -176,9 +179,9 @@ public class AbstractCRS extends AbstractReferenceSystem 
implements CoordinateRe
     @SuppressWarnings("this-escape")
     public AbstractCRS(final Map<String,?> properties, final CoordinateSystem 
cs) {
         super(properties);
-        ensureNonNull("cs", cs);
+        ArgumentChecks.ensureNonNull("cs", cs);
         coordinateSystem = cs;
-        forConvention = forConvention();
+        forConvention = forConvention(this);
     }
 
     /**
@@ -188,12 +191,12 @@ public class AbstractCRS extends AbstractReferenceSystem 
implements CoordinateRe
      * @param id        new identifier for this CRS, or {@code null} if none.
      * @param cs        coordinate system with new axis order or units of 
measurement.
      *
-     * @see #createSameType(CoordinateSystem)
+     * @see #createSameType(AbstractCS)
      */
-    AbstractCRS(final AbstractCRS original, final Identifier id, final 
CoordinateSystem cs) {
+    AbstractCRS(final AbstractCRS original, final Identifier id, final 
AbstractCS cs) {
         super(ReferencingUtilities.getPropertiesWithoutIdentifiers(original, 
(id == null) ? null : Map.of(IDENTIFIERS_KEY, id)));
         coordinateSystem = cs;
-        forConvention = original.forConvention;
+        forConvention = cs.hasSameAxes(original.coordinateSystem) ? 
original.forConvention : forConvention(original);
     }
 
     /**
@@ -211,7 +214,7 @@ public class AbstractCRS extends AbstractReferenceSystem 
implements CoordinateRe
     protected AbstractCRS(final CoordinateReferenceSystem crs) {
         super(crs);
         coordinateSystem = crs.getCoordinateSystem();
-        forConvention = forConvention();
+        forConvention = forConvention(this);
     }
 
     /**
@@ -335,19 +338,17 @@ public class AbstractCRS extends AbstractReferenceSystem 
implements CoordinateRe
      * @see AbstractCS#forConvention(AxesConvention)
      */
     public AbstractCRS forConvention(final AxesConvention convention) {
-        ensureNonNull("convention", convention);
+        ArgumentChecks.ensureNonNull("convention", convention);
         synchronized (forConvention) {
             AbstractCRS crs = forConvention.get(convention);
             if (crs == null) {
-                final AbstractCRS original = 
forConvention.get(AxesConvention.ORIGINAL);
-                final AbstractCS cs = 
AbstractCS.castOrCopy(original.coordinateSystem);
+                final AbstractCS cs = AbstractCS.castOrCopy(coordinateSystem);
                 final AbstractCS candidate = cs.forConvention(convention);
                 if (candidate.equals(cs, ComparisonMode.IGNORE_METADATA)) {
-                    crs = original;
-                } else if (original != this && 
candidate.equals(coordinateSystem, ComparisonMode.IGNORE_METADATA)) {
                     crs = this;
                 } else try {
                     crs = createSameType(candidate);
+                    crs.getCoordinateSystem();          // Throws 
ClassCastException if the CS type is invalid.
                 } catch (ClassCastException e) {
                     throw new 
IllegalArgumentException(Errors.format(Errors.Keys.CanNotCompute_1, 
convention), e);
                 }
@@ -363,9 +364,8 @@ public class AbstractCRS extends AbstractReferenceSystem 
implements CoordinateRe
      *
      * @param  cs  the coordinate system with new axes.
      * @return new CRS of the same type and datum than this CRS, but with the 
given axes.
-     * @throws ClassCastException if the type of the given coordinate system 
is invalid.
      */
-    AbstractCRS createSameType(final CoordinateSystem cs) {
+    AbstractCRS createSameType(final AbstractCS cs) {
         return new AbstractCRS(this, null, cs);
     }
 
@@ -393,8 +393,8 @@ public class AbstractCRS extends AbstractReferenceSystem 
implements CoordinateRe
                            Objects.equals(coordinateSystem, 
that.coordinateSystem);
                 }
                 default: {
-                    return deepEquals(datum, (object instanceof SingleCRS) ? 
((SingleCRS) object).getDatum() : null, mode) &&
-                           deepEquals(getCoordinateSystem(), 
((CoordinateReferenceSystem) object).getCoordinateSystem(), mode);
+                    return Utilities.deepEquals(datum, (object instanceof 
SingleCRS) ? ((SingleCRS) object).getDatum() : null, mode) &&
+                           Utilities.deepEquals(getCoordinateSystem(), 
((CoordinateReferenceSystem) object).getCoordinateSystem(), mode);
                 }
             }
         }
@@ -440,7 +440,7 @@ public class AbstractCRS extends AbstractReferenceSystem 
implements CoordinateRe
     protected String formatTo(final Formatter formatter) {
         final String keyword = super.formatTo(formatter);
         formatter.newLine();
-        formatter.append(toFormattable(getDatum()));
+        formatter.append(WKTUtilities.toFormattable(getDatum()));
         formatter.newLine();
         final Convention convention = formatter.getConvention();
         final boolean isWKT1 = convention.majorVersion() == 1;
@@ -494,19 +494,22 @@ public class AbstractCRS extends AbstractReferenceSystem 
implements CoordinateRe
                 formatter.setInvalidWKT(this, null);
             }
         } else {
-            formatter.append(toFormattable(cs));    // WKT2 only, since the 
concept of CoordinateSystem was not explicit in WKT 1.
+            // WKT2 only, since the concept of CoordinateSystem was not 
explicit in WKT 1.
+            formatter.append(WKTUtilities.toFormattable(cs));
             formatter.indent(+1);
         }
         if (!isWKT1 || formatter.getConvention() != 
Convention.WKT1_IGNORE_AXES) {
-            if (cs != null) {                       // Should never be null, 
except sometimes temporarily during construction.
+            // Should never be null, except sometimes temporarily during 
construction.
+            if (cs != null) {
                 final int dimension = cs.getDimension();
                 for (int i=0; i<dimension; i++) {
                     formatter.newLine();
-                    formatter.append(toFormattable(cs.getAxis(i)));
+                    
formatter.append(WKTUtilities.toFormattable(cs.getAxis(i)));
                 }
             }
         }
-        if (!isWKT1) {                              // WKT 2 writes unit after 
axes, while WKT 1 wrote them before axes.
+        // WKT 2 writes unit after axes, while WKT 1 wrote them before axes.
+        if (!isWKT1) {
             formatter.newLine();
             formatter.append(unit);
             formatter.indent(-1);
@@ -538,7 +541,7 @@ public class AbstractCRS extends AbstractReferenceSystem 
implements CoordinateRe
      */
     AbstractCRS() {
         super(org.apache.sis.referencing.util.NilReferencingObject.INSTANCE);
-        forConvention = forConvention();
+        forConvention = forConvention(this);
         /*
          * The coordinate system is mandatory for SIS working. We do not 
verify its presence here
          * because the verification would have to be done in an 
`afterMarshal(…)` method and throwing
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 83c3e4942f..4a33694332 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
@@ -34,16 +34,17 @@ import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.MathTransformFactory;
 import org.opengis.geometry.MismatchedDimensionException;
 import org.apache.sis.referencing.GeodeticException;
+import org.apache.sis.referencing.cs.AbstractCS;
 import org.apache.sis.referencing.operation.DefaultConversion;
-import org.apache.sis.xml.bind.referencing.CC_Conversion;
 import org.apache.sis.referencing.util.ReferencingFactoryContainer;
+import org.apache.sis.xml.bind.referencing.CC_Conversion;
 import org.apache.sis.metadata.internal.ImplementationHelper;
 import org.apache.sis.metadata.internal.Identifiers;
 import org.apache.sis.system.Semaphores;
+import org.apache.sis.util.Utilities;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.resources.Errors;
-import static org.apache.sis.util.Utilities.deepEquals;
 
 
 /**
@@ -108,9 +109,9 @@ abstract class AbstractDerivedCRS<C extends Conversion> 
extends AbstractCRS impl
 
     /**
      * Creates a new CRS derived from the specified one, but with different 
axis order or unit.
-     * This is for implementing the {@link #createSameType(CoordinateSystem)} 
method only.
+     * This is for implementing the {@link #createSameType(AbstractCS)} method 
only.
      */
-    AbstractDerivedCRS(final AbstractDerivedCRS<C> original, final 
CoordinateSystem derivedCS) {
+    AbstractDerivedCRS(final AbstractDerivedCRS<C> original, final AbstractCS 
derivedCS) {
         super(original, null, derivedCS);
         final Conversion conversion = original.conversionFromBase;
         conversionFromBase = createConversionFromBase(null, (SingleCRS) 
conversion.getSourceCRS(), conversion);
@@ -237,9 +238,10 @@ abstract class AbstractDerivedCRS<C extends Conversion> 
extends AbstractCRS impl
             if (Semaphores.queryAndSet(Semaphores.CONVERSION_AND_CRS)) {
                 return true;
             } else try {
-                return deepEquals(strict ? conversionFromBase : 
getConversionFromBase(),
-                                  strict ? ((AbstractDerivedCRS) 
object).conversionFromBase
-                                         :  ((GeneralDerivedCRS) 
object).getConversionFromBase(), mode);
+                return Utilities.deepEquals(
+                        strict ? conversionFromBase : getConversionFromBase(),
+                        strict ? ((AbstractDerivedCRS) 
object).conversionFromBase
+                               :  ((GeneralDerivedCRS) 
object).getConversionFromBase(), mode);
             } finally {
                 Semaphores.clear(Semaphores.CONVERSION_AND_CRS);
             }
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 d3b4d4945b..631be75678 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
@@ -37,6 +37,7 @@ import org.opengis.referencing.crs.TemporalCRS;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.apache.sis.referencing.AbstractReferenceSystem;
+import org.apache.sis.referencing.cs.AbstractCS;
 import org.apache.sis.referencing.cs.AxesConvention;
 import org.apache.sis.referencing.cs.DefaultCompoundCS;
 import org.apache.sis.referencing.util.WKTKeywords;
@@ -242,7 +243,7 @@ public class DefaultCompoundCRS extends AbstractCRS 
implements CompoundCRS {
      * @param  components  the CRS components, usually singles but not 
necessarily.
      * @return the coordinate system for the given components.
      */
-    private static CoordinateSystem createCoordinateSystem(final Map<String,?> 
properties,
+    private static AbstractCS createCoordinateSystem(final Map<String,?> 
properties,
             final CoordinateReferenceSystem[] components)
     {
         ArgumentChecks.ensureNonNull("components", components);
@@ -495,10 +496,10 @@ public class DefaultCompoundCRS extends AbstractCRS 
implements CompoundCRS {
         synchronized (forConvention) {
             DefaultCompoundCRS crs = (DefaultCompoundCRS) 
forConvention.get(convention);
             if (crs == null) {
-                crs = (DefaultCompoundCRS) 
forConvention.get(AxesConvention.ORIGINAL);
+                crs = this;
                 boolean changed = false;
                 final boolean reorderCRS = convention.ordinal() <= 
AxesConvention.DISPLAY_ORIENTED.ordinal();
-                final List<? extends CoordinateReferenceSystem> elements = 
reorderCRS ? crs.singles : crs.components;
+                final List<? extends CoordinateReferenceSystem> elements = 
reorderCRS ? singles : components;
                 final CoordinateReferenceSystem[] newComponents = new 
CoordinateReferenceSystem[elements.size()];
                 for (int i=0; i<newComponents.length; i++) {
                     CoordinateReferenceSystem component = elements.get(i);
@@ -525,7 +526,7 @@ public class DefaultCompoundCRS extends AbstractCRS 
implements CompoundCRS {
      * Should never be invoked since we override {@link 
AbstractCRS#forConvention(AxesConvention)}.
      */
     @Override
-    final AbstractCRS createSameType(final CoordinateSystem cs) {
+    final AbstractCRS createSameType(final AbstractCS cs) {
         throw new AssertionError();
     }
 
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 1252bb3b01..250b2eb6c6 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
@@ -45,6 +45,7 @@ import 
org.opengis.referencing.operation.NoninvertibleTransformException;
 import org.opengis.geometry.MismatchedDimensionException;
 import org.apache.sis.referencing.AbstractIdentifiedObject;
 import org.apache.sis.referencing.operation.DefaultConversion;
+import org.apache.sis.referencing.cs.AbstractCS;
 import org.apache.sis.referencing.cs.AxesConvention;
 import org.apache.sis.referencing.cs.CoordinateSystems;
 import org.apache.sis.xml.bind.referencing.SC_SingleCRS;
@@ -173,9 +174,9 @@ public class DefaultDerivedCRS extends 
AbstractDerivedCRS<Conversion> implements
 
     /**
      * Creates a new CRS derived from the specified one, but with different 
axis order or unit.
-     * This is for implementing the {@link #createSameType(CoordinateSystem)} 
method only.
+     * This is for implementing the {@link #createSameType(AbstractCS)} method 
only.
      */
-    DefaultDerivedCRS(final DefaultDerivedCRS original, final CoordinateSystem 
derivedCS) {
+    DefaultDerivedCRS(final DefaultDerivedCRS original, final AbstractCS 
derivedCS) {
         super(original, derivedCS);
     }
 
@@ -479,10 +480,9 @@ public class DefaultDerivedCRS extends 
AbstractDerivedCRS<Conversion> implements
      *
      * @param  cs  the coordinate system with new axes.
      * @return new CRS of the same type and datum than this CRS, but with the 
given axes.
-     * @throws ClassCastException if the type of the given coordinate system 
is invalid.
      */
     @Override
-    AbstractCRS createSameType(final CoordinateSystem derivedCS) {
+    AbstractCRS createSameType(final AbstractCS derivedCS) {
         return new DefaultDerivedCRS(this, derivedCS);
     }
 
@@ -639,7 +639,7 @@ public class DefaultDerivedCRS extends 
AbstractDerivedCRS<Conversion> implements
         }
 
         /** Creates a new CRS derived from the specified one, but with 
different axis order or unit. */
-        private Geodetic(final Geodetic original, final CoordinateSystem 
derivedCS) {
+        private Geodetic(final Geodetic original, final AbstractCS derivedCS) {
             super(original, derivedCS);
         }
 
@@ -661,7 +661,7 @@ public class DefaultDerivedCRS extends 
AbstractDerivedCRS<Conversion> implements
         }
 
         /** Returns a coordinate reference system of the same type as this CRS 
but with different axes. */
-        @Override AbstractCRS createSameType(final CoordinateSystem derivedCS) 
{
+        @Override AbstractCRS createSameType(final AbstractCS derivedCS) {
             return new Geodetic(this, derivedCS);
         }
 
@@ -690,7 +690,7 @@ public class DefaultDerivedCRS extends 
AbstractDerivedCRS<Conversion> implements
         }
 
         /** Creates a new CRS derived from the specified one, but with 
different axis order or unit. */
-        private Vertical(final Vertical original, final VerticalCS derivedCS) {
+        private Vertical(final Vertical original, final AbstractCS derivedCS) {
             super(original, derivedCS);
         }
 
@@ -717,8 +717,8 @@ public class DefaultDerivedCRS extends 
AbstractDerivedCRS<Conversion> implements
         }
 
         /** Returns a coordinate reference system of the same type as this CRS 
but with different axes. */
-        @Override AbstractCRS createSameType(final CoordinateSystem derivedCS) 
{
-            return new Vertical(this, (VerticalCS) derivedCS);
+        @Override AbstractCRS createSameType(final AbstractCS derivedCS) {
+            return new Vertical(this, derivedCS);
         }
 
         /** Returns the WKT keyword for this derived CRS type. */
@@ -746,7 +746,7 @@ public class DefaultDerivedCRS extends 
AbstractDerivedCRS<Conversion> implements
         }
 
         /** Creates a new CRS derived from the specified one, but with 
different axis order or unit. */
-        private Temporal(final Temporal original, final TimeCS derivedCS) {
+        private Temporal(final Temporal original, final AbstractCS derivedCS) {
             super(original, derivedCS);
         }
 
@@ -773,8 +773,8 @@ public class DefaultDerivedCRS extends 
AbstractDerivedCRS<Conversion> implements
         }
 
         /** Returns a coordinate reference system of the same type as this CRS 
but with different axes. */
-        @Override AbstractCRS createSameType(final CoordinateSystem derivedCS) 
{
-            return new Temporal(this, (TimeCS) derivedCS);
+        @Override AbstractCRS createSameType(final AbstractCS derivedCS) {
+            return new Temporal(this, derivedCS);
         }
 
         /** Returns the WKT keyword for this derived CRS type. */
@@ -802,7 +802,7 @@ public class DefaultDerivedCRS extends 
AbstractDerivedCRS<Conversion> implements
         }
 
         /** Creates a new CRS derived from the specified one, but with 
different axis order or unit. */
-        private Parametric(final Parametric original, final ParametricCS 
derivedCS) {
+        private Parametric(final Parametric original, final AbstractCS 
derivedCS) {
             super(original, derivedCS);
         }
 
@@ -829,8 +829,8 @@ public class DefaultDerivedCRS extends 
AbstractDerivedCRS<Conversion> implements
         }
 
         /** Returns a coordinate reference system of the same type as this CRS 
but with different axes. */
-        @Override AbstractCRS createSameType(final CoordinateSystem derivedCS) 
{
-            return new Parametric(this, (ParametricCS) derivedCS);
+        @Override AbstractCRS createSameType(final AbstractCS derivedCS) {
+            return new Parametric(this, derivedCS);
         }
 
         /** Returns the WKT keyword for this derived CRS type. */
@@ -861,7 +861,7 @@ public class DefaultDerivedCRS extends 
AbstractDerivedCRS<Conversion> implements
         }
 
         /** Creates a new CRS derived from the specified one, but with 
different axis order or unit. */
-        private Engineering(final Engineering original, final CoordinateSystem 
derivedCS) {
+        private Engineering(final Engineering original, final AbstractCS 
derivedCS) {
             super(original, derivedCS);
         }
 
@@ -883,7 +883,7 @@ public class DefaultDerivedCRS extends 
AbstractDerivedCRS<Conversion> implements
         }
 
         /** Returns a coordinate reference system of the same type as this CRS 
but with different axes. */
-        @Override AbstractCRS createSameType(final CoordinateSystem derivedCS) 
{
+        @Override AbstractCRS createSameType(final AbstractCS derivedCS) {
             return new Engineering(this, derivedCS);
         }
 
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java
index 3467f5b3d9..1ce8d59bbf 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java
@@ -30,7 +30,7 @@ import org.apache.sis.metadata.internal.ImplementationHelper;
 import org.apache.sis.referencing.util.WKTKeywords;
 import org.apache.sis.xml.bind.referencing.CS_CoordinateSystem;
 import org.apache.sis.io.wkt.Formatter;
-import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
+import org.apache.sis.util.ArgumentChecks;
 
 
 /**
@@ -142,15 +142,15 @@ public class DefaultEngineeringCRS extends AbstractCRS 
implements EngineeringCRS
                                  final CoordinateSystem cs)
     {
         super(properties, cs);
-        ensureNonNull("datum", datum);
         this.datum = datum;
+        ArgumentChecks.ensureNonNull("datum", datum);
     }
 
     /**
      * Creates a new CRS derived from the specified one, but with different 
axis order or unit.
-     * This is for implementing the {@link #createSameType(CoordinateSystem)} 
method only.
+     * This is for implementing the {@link #createSameType(AbstractCS)} method 
only.
      */
-    private DefaultEngineeringCRS(final DefaultEngineeringCRS original, final 
CoordinateSystem cs) {
+    private DefaultEngineeringCRS(final DefaultEngineeringCRS original, final 
AbstractCS cs) {
         super(original, null, cs);
         datum = original.datum;
     }
@@ -230,7 +230,7 @@ public class DefaultEngineeringCRS extends AbstractCRS 
implements EngineeringCRS
      * @return new CRS of the same type and datum than this CRS, but with the 
given axes.
      */
     @Override
-    final AbstractCRS createSameType(final CoordinateSystem cs) {
+    final AbstractCRS createSameType(final AbstractCS cs) {
         return new DefaultEngineeringCRS(this, cs);
     }
 
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java
index afa8eacab4..57b4a45bb6 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java
@@ -20,12 +20,12 @@ import java.util.Map;
 import jakarta.xml.bind.annotation.XmlTransient;
 import org.opengis.referencing.cs.CartesianCS;
 import org.opengis.referencing.cs.SphericalCS;
-import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.crs.GeocentricCRS;
 import org.opengis.referencing.datum.GeodeticDatum;
-import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.referencing.AbstractReferenceSystem;
 import org.apache.sis.referencing.cs.AxesConvention;
+import org.apache.sis.referencing.cs.AbstractCS;
+import org.apache.sis.io.wkt.Formatter;
 
 
 /**
@@ -150,10 +150,10 @@ public class DefaultGeocentricCRS extends 
DefaultGeodeticCRS implements Geocentr
 
     /**
      * Creates a new CRS derived from the specified one, but with different 
axis order or unit.
-     * This is for implementing the {@link #createSameType(CoordinateSystem)} 
method only.
+     * This is for implementing the {@link #createSameType(AbstractCS)} method 
only.
      * This constructor does not verify the coordinate system type.
      */
-    private DefaultGeocentricCRS(final DefaultGeocentricCRS original, final 
CoordinateSystem cs) {
+    private DefaultGeocentricCRS(final DefaultGeocentricCRS original, final 
AbstractCS cs) {
         super(original, null, cs);
     }
 
@@ -231,7 +231,7 @@ public class DefaultGeocentricCRS extends 
DefaultGeodeticCRS implements Geocentr
      * @return new CRS of the same type and datum than this CRS, but with the 
given axes.
      */
     @Override
-    final AbstractCRS createSameType(final CoordinateSystem cs) {
+    final AbstractCRS createSameType(final AbstractCS cs) {
         return new DefaultGeocentricCRS(this, cs);
     }
 
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
index d87eac98bf..450449f0d9 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
@@ -33,6 +33,7 @@ import org.opengis.referencing.datum.GeodeticDatum;
 import org.opengis.referencing.datum.PrimeMeridian;
 import org.apache.sis.referencing.AbstractReferenceSystem;
 import org.apache.sis.referencing.CRS;
+import org.apache.sis.referencing.cs.AbstractCS;
 import org.apache.sis.referencing.internal.Legacy;
 import org.apache.sis.referencing.util.AxisDirections;
 import org.apache.sis.referencing.util.WKTKeywords;
@@ -109,9 +110,9 @@ class DefaultGeodeticCRS extends AbstractCRS implements 
GeodeticCRS { // If made
 
     /**
      * Creates a new CRS derived from the specified one, but with different 
axis order or unit.
-     * This is for implementing the {@link #createSameType(CoordinateSystem)} 
method only.
+     * This is for implementing the {@link #createSameType(AbstractCS)} method 
only.
      */
-    DefaultGeodeticCRS(final DefaultGeodeticCRS original, final Identifier id, 
final CoordinateSystem cs) {
+    DefaultGeodeticCRS(final DefaultGeodeticCRS original, final Identifier id, 
final AbstractCS cs) {
         super(original, id, cs);
         datum = original.datum;
     }
@@ -164,10 +165,9 @@ class DefaultGeodeticCRS extends AbstractCRS implements 
GeodeticCRS { // If made
      *
      * @param  cs  the coordinate system with new axes.
      * @return new CRS of the same type and datum than this CRS, but with the 
given axes.
-     * @throws ClassCastException if the type of the given coordinate system 
is invalid.
      */
     @Override
-    AbstractCRS createSameType(final CoordinateSystem cs) {
+    AbstractCRS createSameType(final AbstractCS cs) {
         return new DefaultGeodeticCRS(this, null, cs);
     }
 
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
index 0d3d037918..6e256f1900 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
@@ -29,6 +29,7 @@ import org.apache.sis.metadata.iso.citation.Citations;
 import org.apache.sis.referencing.ImmutableIdentifier;
 import org.apache.sis.referencing.AbstractReferenceSystem;
 import org.apache.sis.referencing.cs.AxesConvention;
+import org.apache.sis.referencing.cs.AbstractCS;
 import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.measure.Longitude;
 import org.apache.sis.util.resources.Errors;
@@ -158,9 +159,9 @@ public class DefaultGeographicCRS extends 
DefaultGeodeticCRS implements Geograph
 
     /**
      * Creates a new CRS derived from the specified one, but with different 
axis order or unit.
-     * This is for implementing the {@link #createSameType(CoordinateSystem)} 
method only.
+     * This is for implementing the {@link #createSameType(AbstractCS)} method 
only.
      */
-    private DefaultGeographicCRS(final DefaultGeographicCRS original, final 
Identifier id, final EllipsoidalCS cs) {
+    private DefaultGeographicCRS(final DefaultGeographicCRS original, final 
Identifier id, final AbstractCS cs) {
         super(original, id, cs);
     }
 
@@ -252,10 +253,9 @@ public class DefaultGeographicCRS extends 
DefaultGeodeticCRS implements Geograph
      *
      * @param  cs  the coordinate system with new axes.
      * @return new CRS of the same type and datum than this CRS, but with the 
given axes.
-     * @throws ClassCastException if the type of the given coordinate system 
is invalid.
      */
     @Override
-    final AbstractCRS createSameType(final CoordinateSystem cs) {
+    final AbstractCRS createSameType(final AbstractCS cs) {
         Identifier id = null;
         final CoordinateSystemAxis axis = cs.getAxis(0);
         if (axis.getMinimumValue() == Longitude.MIN_VALUE &&
@@ -273,7 +273,7 @@ public class DefaultGeographicCRS extends 
DefaultGeodeticCRS implements Geograph
                 }
             }
         }
-        return new DefaultGeographicCRS(this, id, (EllipsoidalCS) cs);
+        return new DefaultGeographicCRS(this, id, cs);
     }
 
     /**
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultImageCRS.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultImageCRS.java
index 4d880b390f..0cdc10d827 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultImageCRS.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultImageCRS.java
@@ -20,17 +20,17 @@ import java.util.Map;
 import jakarta.xml.bind.annotation.XmlType;
 import jakarta.xml.bind.annotation.XmlElement;
 import jakarta.xml.bind.annotation.XmlRootElement;
-import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.cs.AffineCS;
 import org.opengis.referencing.cs.CartesianCS;
 import org.opengis.referencing.crs.ImageCRS;
 import org.opengis.referencing.datum.ImageDatum;
 import org.apache.sis.referencing.AbstractReferenceSystem;
 import org.apache.sis.referencing.util.WKTKeywords;
-import org.apache.sis.metadata.internal.ImplementationHelper;
 import org.apache.sis.referencing.cs.AxesConvention;
+import org.apache.sis.referencing.cs.AbstractCS;
+import org.apache.sis.metadata.internal.ImplementationHelper;
 import org.apache.sis.io.wkt.Formatter;
-import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
+import org.apache.sis.util.ArgumentChecks;
 
 
 /**
@@ -127,15 +127,15 @@ public class DefaultImageCRS extends AbstractCRS 
implements ImageCRS {
                            final AffineCS      cs)
     {
         super(properties, cs);
-        ensureNonNull("datum", datum);
         this.datum = datum;
+        ArgumentChecks.ensureNonNull("datum", datum);
     }
 
     /**
      * Creates a new CRS derived from the specified one, but with different 
axis order or unit.
-     * This is for implementing the {@link #createSameType(CoordinateSystem)} 
method only.
+     * This is for implementing the {@link #createSameType(AbstractCS)} method 
only.
      */
-    private DefaultImageCRS(final DefaultImageCRS original, final AffineCS cs) 
{
+    private DefaultImageCRS(final DefaultImageCRS original, final AbstractCS 
cs) {
         super(original, null, cs);
         datum = original.datum;
     }
@@ -223,11 +223,10 @@ public class DefaultImageCRS extends AbstractCRS 
implements ImageCRS {
      *
      * @param  cs  the coordinate system with new axes.
      * @return new CRS of the same type and datum than this CRS, but with the 
given axes.
-     * @throws ClassCastException if the type of the given coordinate system 
is invalid.
      */
     @Override
-    final AbstractCRS createSameType(final CoordinateSystem cs) {
-        return new DefaultImageCRS(this, (AffineCS) cs);
+    final AbstractCRS createSameType(final AbstractCS cs) {
+        return new DefaultImageCRS(this, cs);
     }
 
     /**
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultParametricCRS.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultParametricCRS.java
index c53b99bd4a..b494749046 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultParametricCRS.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultParametricCRS.java
@@ -20,13 +20,12 @@ import java.util.Map;
 import jakarta.xml.bind.annotation.XmlElement;
 import jakarta.xml.bind.annotation.XmlRootElement;
 import jakarta.xml.bind.annotation.XmlType;
-import org.opengis.referencing.cs.CoordinateSystem;
 import org.apache.sis.metadata.internal.ImplementationHelper;
 import org.apache.sis.referencing.util.WKTKeywords;
 import org.apache.sis.referencing.cs.AxesConvention;
+import org.apache.sis.referencing.cs.AbstractCS;
 import org.apache.sis.io.wkt.Formatter;
-import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
-import static org.apache.sis.referencing.crs.AbstractCRS.isBaseCRS;
+import org.apache.sis.util.ArgumentChecks;
 
 // Specific to the geoapi-3.1 and geoapi-4.0 branches:
 import org.opengis.referencing.cs.ParametricCS;
@@ -127,15 +126,15 @@ public class DefaultParametricCRS extends AbstractCRS 
implements ParametricCRS {
                                 final ParametricCS cs)
     {
         super(properties, cs);
-        ensureNonNull("datum", datum);
         this.datum = datum;
+        ArgumentChecks.ensureNonNull("datum", datum);
     }
 
     /**
      * Creates a new CRS derived from the specified one, but with different 
axis order or unit.
-     * This is for implementing the {@link #createSameType(CoordinateSystem)} 
method only.
+     * This is for implementing the {@link #createSameType(AbstractCS)} method 
only.
      */
-    private DefaultParametricCRS(final DefaultParametricCRS original, final 
ParametricCS cs) {
+    private DefaultParametricCRS(final DefaultParametricCRS original, final 
AbstractCS cs) {
         super(original, null, cs);
         datum = original.datum;
     }
@@ -224,11 +223,10 @@ public class DefaultParametricCRS extends AbstractCRS 
implements ParametricCRS {
      *
      * @param  cs  the coordinate system with new axes.
      * @return new CRS of the same type and datum than this CRS, but with the 
given axes.
-     * @throws ClassCastException if the type of the given coordinate system 
is invalid.
      */
     @Override
-    final AbstractCRS createSameType(final CoordinateSystem cs) {
-        return new DefaultParametricCRS(this, (ParametricCS) cs);
+    final AbstractCRS createSameType(final AbstractCS cs) {
+        return new DefaultParametricCRS(this, cs);
     }
 
     /**
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 870c17a9ae..8b946ba809 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
@@ -31,6 +31,7 @@ import org.opengis.referencing.operation.Conversion;
 import org.opengis.referencing.operation.Projection;
 import org.opengis.geometry.MismatchedDimensionException;
 import org.apache.sis.referencing.cs.AxesConvention;
+import org.apache.sis.referencing.cs.AbstractCS;
 import org.apache.sis.referencing.util.ReferencingUtilities;
 import org.apache.sis.referencing.util.AxisDirections;
 import org.apache.sis.referencing.util.WKTKeywords;
@@ -38,7 +39,6 @@ import org.apache.sis.referencing.util.WKTUtilities;
 import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.util.ComparisonMode;
-import static org.apache.sis.referencing.util.WKTUtilities.toFormattable;
 
 
 /**
@@ -137,9 +137,9 @@ public class DefaultProjectedCRS extends 
AbstractDerivedCRS<Projection> implemen
 
     /**
      * Creates a new CRS derived from the specified one, but with different 
axis order or unit.
-     * This is for implementing the {@link #createSameType(CoordinateSystem)} 
method only.
+     * This is for implementing the {@link #createSameType(AbstractCS)} method 
only.
      */
-    private DefaultProjectedCRS(final DefaultProjectedCRS original, final 
CartesianCS derivedCS) {
+    private DefaultProjectedCRS(final DefaultProjectedCRS original, final 
AbstractCS derivedCS) {
         super(original, derivedCS);
     }
 
@@ -269,12 +269,10 @@ public class DefaultProjectedCRS extends 
AbstractDerivedCRS<Projection> implemen
 
     /**
      * Returns a coordinate reference system of the same type as this CRS but 
with different axes.
-     *
-     * @throws ClassCastException if the type of the given coordinate system 
is invalid.
      */
     @Override
-    final AbstractCRS createSameType(final CoordinateSystem cs) {
-        return new DefaultProjectedCRS(this, (CartesianCS) cs);
+    final AbstractCRS createSameType(final AbstractCS cs) {
+        return new DefaultProjectedCRS(this, cs);
     }
 
     /**
@@ -388,7 +386,7 @@ public class DefaultProjectedCRS extends 
AbstractDerivedCRS<Projection> implemen
          * format is part of an enclosing ProjectedCRS and will adapt 
accordingly.
          */
         formatter.newLine();
-        formatter.append(toFormattable(baseCRS));
+        formatter.append(WKTUtilities.toFormattable(baseCRS));
         formatter.newLine();
         final ExplicitParameters p = new ExplicitParameters(this, 
WKTKeywords.Conversion);
         final boolean isBaseCRS;
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultTemporalCRS.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultTemporalCRS.java
index 3be96cf380..0a027fb604 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultTemporalCRS.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultTemporalCRS.java
@@ -28,18 +28,18 @@ import jakarta.xml.bind.annotation.XmlRootElement;
 import javax.measure.UnitConverter;
 import javax.measure.Unit;
 import javax.measure.quantity.Time;
-import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.cs.TimeCS;
 import org.opengis.referencing.crs.TemporalCRS;
 import org.opengis.referencing.datum.TemporalDatum;
 import org.apache.sis.referencing.AbstractReferenceSystem;
 import org.apache.sis.referencing.cs.AxesConvention;
-import org.apache.sis.metadata.internal.ImplementationHelper;
+import org.apache.sis.referencing.cs.AbstractCS;
 import org.apache.sis.referencing.util.WKTKeywords;
+import org.apache.sis.metadata.internal.ImplementationHelper;
 import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.measure.Units;
 import org.apache.sis.math.Fraction;
-import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
+import org.apache.sis.util.ArgumentChecks;
 import static org.apache.sis.util.internal.StandardDateFormat.NANOS_PER_SECOND;
 import static 
org.apache.sis.util.internal.StandardDateFormat.MILLIS_PER_SECOND;
 
@@ -158,16 +158,16 @@ public class DefaultTemporalCRS extends AbstractCRS 
implements TemporalCRS {
                               final TimeCS        cs)
     {
         super(properties, cs);
-        ensureNonNull("datum", datum);
         this.datum = datum;
+        ArgumentChecks.ensureNonNull("datum", datum);
         initializeConverter();
     }
 
     /**
      * Creates a new CRS derived from the specified one, but with different 
axis order or unit.
-     * This is for implementing the {@link #createSameType(CoordinateSystem)} 
method only.
+     * This is for implementing the {@link #createSameType(AbstractCS)} method 
only.
      */
-    private DefaultTemporalCRS(final DefaultTemporalCRS original, final TimeCS 
cs) {
+    private DefaultTemporalCRS(final DefaultTemporalCRS original, final 
AbstractCS cs) {
         super(original, null, cs);
         datum = original.datum;
         initializeConverter();
@@ -308,12 +308,10 @@ public class DefaultTemporalCRS extends AbstractCRS 
implements TemporalCRS {
 
     /**
      * Returns a coordinate reference system of the same type as this CRS but 
with different axes.
-     *
-     * @throws ClassCastException if the type of the given coordinate system 
is invalid.
      */
     @Override
-    final AbstractCRS createSameType(final CoordinateSystem cs) {
-        return new DefaultTemporalCRS(this, (TimeCS) cs);
+    final AbstractCRS createSameType(final AbstractCS cs) {
+        return new DefaultTemporalCRS(this, cs);
     }
 
     /**
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultVerticalCRS.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultVerticalCRS.java
index 5554f4e16c..38ecdbd588 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultVerticalCRS.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultVerticalCRS.java
@@ -20,16 +20,16 @@ import java.util.Map;
 import jakarta.xml.bind.annotation.XmlType;
 import jakarta.xml.bind.annotation.XmlElement;
 import jakarta.xml.bind.annotation.XmlRootElement;
-import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.cs.VerticalCS;
 import org.opengis.referencing.crs.VerticalCRS;
 import org.opengis.referencing.datum.VerticalDatum;
 import org.apache.sis.referencing.AbstractReferenceSystem;
 import org.apache.sis.referencing.cs.AxesConvention;
+import org.apache.sis.referencing.cs.AbstractCS;
 import org.apache.sis.referencing.util.WKTKeywords;
 import org.apache.sis.metadata.internal.ImplementationHelper;
 import org.apache.sis.io.wkt.Formatter;
-import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
+import org.apache.sis.util.ArgumentChecks;
 
 
 /**
@@ -125,15 +125,15 @@ public class DefaultVerticalCRS extends AbstractCRS 
implements VerticalCRS {
                               final VerticalCS    cs)
     {
         super(properties, cs);
-        ensureNonNull("datum", datum);
         this.datum = datum;
+        ArgumentChecks.ensureNonNull("datum", datum);
     }
 
     /**
      * Creates a new CRS derived from the specified one, but with different 
axis order or unit.
-     * This is for implementing the {@link #createSameType(CoordinateSystem)} 
method only.
+     * This is for implementing the {@link #createSameType(AbstractCS)} method 
only.
      */
-    private DefaultVerticalCRS(final DefaultVerticalCRS original, final 
VerticalCS cs) {
+    private DefaultVerticalCRS(final DefaultVerticalCRS original, final 
AbstractCS cs) {
         super(original, null, cs);
         datum = original.datum;
     }
@@ -219,12 +219,10 @@ public class DefaultVerticalCRS extends AbstractCRS 
implements VerticalCRS {
 
     /**
      * Returns a coordinate reference system of the same type as this CRS but 
with different axes.
-     *
-     * @throws ClassCastException if the type of the given coordinate system 
is invalid.
      */
     @Override
-    final AbstractCRS createSameType(final CoordinateSystem cs) {
-        return new DefaultVerticalCRS(this, (VerticalCS) cs);
+    final AbstractCRS createSameType(final AbstractCS cs) {
+        return new DefaultVerticalCRS(this, cs);
     }
 
     /**
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 dd4d8d06ca..cb1cc73f1f 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
@@ -137,10 +137,13 @@ public class AbstractCS extends AbstractIdentifiedObject 
implements CoordinateSy
 
     /**
      * Creates the value to assign to the {@link #forConvention} map by 
constructors.
+     *
+     * @param  original  the coordinate system to declare as the original one.
+     * @return map to assign to the {@link #forConvention} field.
      */
-    private EnumMap<AxesConvention,AbstractCS> forConvention() {
+    private static EnumMap<AxesConvention,AbstractCS> forConvention(final 
AbstractCS original) {
         var m = new EnumMap<AxesConvention,AbstractCS>(AxesConvention.class);
-        m.put(AxesConvention.ORIGINAL, this);
+        m.put(AxesConvention.ORIGINAL, original);
         return m;
     }
 
@@ -185,7 +188,7 @@ public class AbstractCS extends AbstractIdentifiedObject 
implements CoordinateSy
         ensureNonNull("axes", axes);
         this.axes = axes.clone();
         validate(properties);
-        forConvention = forConvention();
+        forConvention = forConvention(this);
     }
 
     /**
@@ -266,17 +269,16 @@ public class AbstractCS extends AbstractIdentifiedObject 
implements CoordinateSy
      * @param  original  the original coordinate system from which to derive a 
new one.
      * @param  name      name of the new coordinate system, or {@code null} to 
inherit.
      * @param  axes      the new axes. This array is not cloned.
-     * @param  share     whether the new CS should use a cache shared with the 
original CS.
      * @throws IllegalArgumentException if an axis has illegal unit or 
direction.
      *
-     * @see #createForAxes(String, CoordinateSystemAxis[], boolean)
+     * @see #createForAxes(String, CoordinateSystemAxis[])
      */
-    @SuppressWarnings({"this-escape", "OverridableMethodCallInConstructor"})
-    AbstractCS(final AbstractCS original, final String name, final 
CoordinateSystemAxis[] axes, final boolean share) {
+    @SuppressWarnings("OverridableMethodCallInConstructor")
+    AbstractCS(final AbstractCS original, final String name, final 
CoordinateSystemAxis[] axes) {
         super(original.getPropertiesWithoutIdentifiers(name));
         this.axes = axes;
         validate(null);
-        forConvention = share ? original.forConvention : forConvention();
+        forConvention = hasSameAxes(original) ? original.forConvention : 
forConvention(original);
     }
 
     /**
@@ -295,7 +297,7 @@ public class AbstractCS extends AbstractIdentifiedObject 
implements CoordinateSy
         super(original);
         axes = (original instanceof AbstractCS) ? ((AbstractCS) original).axes 
: getAxes(original);
         validate(null);
-        forConvention = forConvention();
+        forConvention = forConvention(this);
     }
 
     /**
@@ -390,6 +392,41 @@ public class AbstractCS extends AbstractIdentifiedObject 
implements CoordinateSy
         return axes[dimension];
     }
 
+    /**
+     * {@return whether this coordinate system has the same axes than the 
specified CS, ignoring axis order}.
+     * If true, then the two coordinate systems have the same number of 
dimensions and the same set of axes.
+     * Axis instances are compared by the identity operator ({@code ==}), not 
by {@code equals(Object)}.
+     *
+     * <h4>Purpose</h4>
+     * This method can be invoked after a call to {@link 
#forConvention(AxesConvention)} for checking if that
+     * method changed only the axis order, with no change to axis directions, 
axis ranges or units of measurement.
+     *
+     * @param  other  the other coordinate system to compare with this CS.
+     *
+     * @since 1.5
+     */
+    public final boolean hasSameAxes(final CoordinateSystem other) {
+        if (other.getDimension() != axes.length) {
+            return false;
+        }
+        /*
+         * Need an unconditional copy of the axes of the other coordinate 
system, because the array will be modified.
+         * The implementation is okay for small arrays, but would be 
inefficient if the number of axes was very large.
+         */
+        final CoordinateSystemAxis[] copy = getAxes(other);
+        int n = copy.length;
+next:   for (final CoordinateSystemAxis axis : axes) {
+            for (int i=0; i<n; i++) {
+                if (axis == copy[i]) {
+                    System.arraycopy(copy, i+1, copy, i, --n - i);
+                    continue next;
+                }
+            }
+            return false;
+        }
+        return n == 0;
+    }
+
     /**
      * Sets the CS for the given axes convention.
      *
@@ -428,14 +465,11 @@ public class AbstractCS extends AbstractIdentifiedObject 
implements CoordinateSy
         synchronized (forConvention) {
             AbstractCS cs = forConvention.get(convention);
             if (cs == null) {
-                final AbstractCS original = 
forConvention.get(AxesConvention.ORIGINAL);
-                cs = Normalizer.forConvention(original, convention);
+                cs = Normalizer.forConvention(this, convention);
                 if (cs == null) {
-                    cs = original;          // The given coordinate system is 
already normalized.
-                } else if (equals(cs, ComparisonMode.IGNORE_METADATA)) {
-                    cs = this;
+                    cs = this;          // This coordinate system is already 
normalized.
                 } else if (convention != AxesConvention.POSITIVE_RANGE) {
-                    cs = cs.resolveEPSG(original);
+                    cs = cs.resolveEPSG(this);
                 }
                 cs = setCached(convention, cs);
             }
@@ -453,13 +487,12 @@ public class AbstractCS extends AbstractIdentifiedObject 
implements CoordinateSy
      *
      * @param  name   name of the new coordinate system.
      * @param  axes   the set of axes to give to the new coordinate system.
-     * @param  share  whether the new CS should use a cache shared with the 
original CS.
      * @return a new coordinate system of the same type as {@code this}, but 
using the given axes.
      * @throws IllegalArgumentException if {@code axes} contains an unexpected 
number of axes,
      *         or if an axis has an unexpected direction or unexpected unit of 
measurement.
      */
-    AbstractCS createForAxes(final String name, final CoordinateSystemAxis[] 
axes, final boolean share) {
-        return new AbstractCS(this, name, axes, share);
+    AbstractCS createForAxes(final String name, final CoordinateSystemAxis[] 
axes) {
+        return new AbstractCS(this, name, axes);
     }
 
     /**
@@ -510,7 +543,7 @@ public class AbstractCS extends AbstractIdentifiedObject 
implements CoordinateSy
      * @param  min   minimum number of dimensions, inclusive.
      * @param  max   maximum number of dimensions, inclusive.
      *
-     * @see #createForAxes(String, CoordinateSystemAxis[], boolean)
+     * @see #createForAxes(String, CoordinateSystemAxis[])
      */
     static IllegalArgumentException unexpectedDimension(final 
CoordinateSystemAxis[] axes, final int min, final int max) {
         final int n = axes.length;
@@ -638,9 +671,10 @@ public class AbstractCS extends AbstractIdentifiedObject 
implements CoordinateSy
      * <strong>This is not a valid object.</strong> This constructor is 
strictly reserved
      * to JAXB, which will assign values to the fields using reflection.
      */
+    @SuppressWarnings("this-escape")
     AbstractCS() {
         super(org.apache.sis.referencing.util.NilReferencingObject.INSTANCE);
-        forConvention = forConvention();
+        forConvention = forConvention(this);
         axes = EMPTY;
         /*
          * Coordinate system axes are mandatory for SIS working. We do not 
verify their presence here
@@ -654,8 +688,9 @@ public class AbstractCS extends AbstractIdentifiedObject 
implements CoordinateSy
      * Invoked by JAXB at marshalling time.
      */
     @XmlElement(name = "axis")
+    @SuppressWarnings("ReturnOfCollectionOrArrayField")
     private CoordinateSystemAxis[] getAxis() {
-        return getAxes(this);                           // Give a chance to 
users to override getAxis(int).
+        return axes;
     }
 
     /**
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/AxesConvention.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/AxesConvention.java
index 762f5f6977..42ac22998b 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/AxesConvention.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/AxesConvention.java
@@ -77,7 +77,7 @@ import org.apache.sis.measure.Units;
  * <h2>Note on axis order</h2>
  * The axis order is specified by the authority (typically a national agency) 
defining the Coordinate Reference System
  * (CRS). The order depends on the CRS type and the country defining the CRS. 
In the case of geographic CRS, the
- * (<var>latitude</var>, <var>longitude</var>) axis order is widely used by 
geographers and pilotes for centuries.
+ * (<var>latitude</var>, <var>longitude</var>) axis order is widely used by 
geographers and pilots for centuries.
  * However, software developers tend to consistently use the 
(<var>x</var>,<var>y</var>) order for every kind of CRS.
  * Those different practices resulted in contradictory definitions of axis 
order for almost every CRS of kind
  * {@code GeographicCRS}, for some {@code ProjectedCRS} in the South 
hemisphere (South Africa, Australia, <i>etc.</i>)
@@ -255,9 +255,8 @@ public enum AxesConvention implements AxisFilter {
     RIGHT_HANDED,
 
     /**
-     * Axes having a <cite>wraparound</cite>
-     * {@linkplain 
org.apache.sis.referencing.cs.DefaultCoordinateSystemAxis#getRangeMeaning() 
range meaning} are
-     * shifted to their ranges of positive values. The units of measurement 
and range period (difference between
+     * Axes having a <cite>wraparound</cite> range meaning are shifted to 
their ranges of positive values.
+     * The units of measurement and range period (difference between
      * {@linkplain 
org.apache.sis.referencing.cs.DefaultCoordinateSystemAxis#getMaximumValue() 
maximum} and
      * {@linkplain 
org.apache.sis.referencing.cs.DefaultCoordinateSystemAxis#getMinimumValue() 
minimum value})
      * are unchanged.
@@ -272,6 +271,7 @@ public enum AxesConvention implements AxisFilter {
      * may need to move on the right side of the East hemisphere ([180 … 
360]°).
      * Some geometries may need to be separated in two parts, and others may 
need to be merged.</p>
      *
+     * @see org.opengis.referencing.cs.CoordinateSystemAxis#getRangeMeaning()
      * @see org.opengis.referencing.cs.RangeMeaning#WRAPAROUND
      */
     POSITIVE_RANGE,
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultAffineCS.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultAffineCS.java
index 12c9fa3f09..33759f7b10 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultAffineCS.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultAffineCS.java
@@ -128,12 +128,10 @@ public class DefaultAffineCS extends AbstractCS 
implements AffineCS {
     /**
      * Creates a new CS derived from the specified one, but with different 
axis order or unit.
      *
-     * @see #createForAxes(String, CoordinateSystemAxis[], boolean)
+     * @see #createForAxes(String, CoordinateSystemAxis[])
      */
-    DefaultAffineCS(final DefaultAffineCS original, final String name,
-                    final CoordinateSystemAxis[] axes, final boolean share)
-    {
-        super(original, name, axes, share);
+    DefaultAffineCS(DefaultAffineCS original, String name, 
CoordinateSystemAxis[] axes) {
+        super(original, name, axes);
     }
 
     /**
@@ -221,10 +219,10 @@ public class DefaultAffineCS extends AbstractCS 
implements AffineCS {
      * This method shall be overridden by all {@code AffineCS} subclasses in 
this package.
      */
     @Override
-    AbstractCS createForAxes(final String name, final CoordinateSystemAxis[] 
axes, final boolean share) {
+    AbstractCS createForAxes(final String name, final CoordinateSystemAxis[] 
axes) {
         switch (axes.length) {
             case 2: // Fall through
-            case 3: return new DefaultAffineCS(this, name, axes, share);
+            case 3: return new DefaultAffineCS(this, name, axes);
             default: throw unexpectedDimension(axes, 2, 3);
         }
     }
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCartesianCS.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCartesianCS.java
index 993b983171..12f00ec052 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCartesianCS.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCartesianCS.java
@@ -137,12 +137,10 @@ public class DefaultCartesianCS extends DefaultAffineCS 
implements CartesianCS {
     /**
      * Creates a new CS derived from the specified one, but with different 
axis order or unit.
      *
-     * @see #createForAxes(String, CoordinateSystemAxis[], boolean)
+     * @see #createForAxes(String, CoordinateSystemAxis[])
      */
-    DefaultCartesianCS(final DefaultCartesianCS original, final String name,
-                       final CoordinateSystemAxis[] axes, final boolean share)
-    {
-        super(original, name, axes, share);
+    private DefaultCartesianCS(DefaultCartesianCS original, String name, 
CoordinateSystemAxis[] axes) {
+        super(original, name, axes);
     }
 
     /**
@@ -234,11 +232,11 @@ public class DefaultCartesianCS extends DefaultAffineCS 
implements CartesianCS {
      * Returns a coordinate system with different axes.
      */
     @Override
-    final AbstractCS createForAxes(final String name, final 
CoordinateSystemAxis[] axes, final boolean share) {
+    final AbstractCS createForAxes(final String name, final 
CoordinateSystemAxis[] axes) {
         switch (axes.length) {
             case 1: return SubTypes.createOneDimensional(this, name, axes);
             case 2: // Fall through
-            case 3: return new DefaultCartesianCS(this, name, axes, share);
+            case 3: return new DefaultCartesianCS(this, name, axes);
             default: throw unexpectedDimension(axes, 1, 3);
         }
     }
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 e1ce919b4c..a5ac52ab0b 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
@@ -18,16 +18,15 @@ package org.apache.sis.referencing.cs;
 
 import java.util.Map;
 import java.util.List;
-import static java.util.Collections.singletonMap;
 import jakarta.xml.bind.annotation.XmlTransient;
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.apache.sis.referencing.util.AxisDirections;
+import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.ComparisonMode;
+import org.apache.sis.util.Utilities;
 import org.apache.sis.util.Workaround;
 import org.apache.sis.util.internal.UnmodifiableArrayList;
-import static org.apache.sis.util.ArgumentChecks.*;
-import static org.apache.sis.util.Utilities.deepEquals;
 
 
 /**
@@ -110,7 +109,7 @@ public class DefaultCompoundCS extends AbstractCS {
      * This is used for the {@link #forConvention(AxesConvention)} 
implementation only.
      */
     private DefaultCompoundCS(final DefaultCompoundCS original, final 
CoordinateSystem[] components) {
-        super(original, null, getAxes(components), true);
+        super(original, null, getAxes(components));
         this.components = UnmodifiableArrayList.wrap(components);
     }
 
@@ -132,7 +131,7 @@ public class DefaultCompoundCS extends AbstractCS {
      */
     @Workaround(library="JDK", version="1.7")
     private DefaultCompoundCS(final CoordinateSystem[] components, final 
CoordinateSystemAxis[] axes) {
-        super(singletonMap(NAME_KEY, AxisDirections.appendTo(new 
StringBuilder(60).append("Compound CS"), axes)), axes);
+        super(Map.of(NAME_KEY, AxisDirections.appendTo(new 
StringBuilder(60).append("Compound CS"), axes)), axes);
         this.components = UnmodifiableArrayList.wrap(components);
     }
 
@@ -140,10 +139,10 @@ public class DefaultCompoundCS extends AbstractCS {
      * Returns a clone of the given array, making sure that it contains only 
non-null elements.
      */
     private static CoordinateSystem[] clone(CoordinateSystem[] components) {
-        ensureNonNull("components", components);
+        ArgumentChecks.ensureNonNull("components", components);
         components = components.clone();
         for (int i=0; i<components.length; i++) {
-            ensureNonNullElement("components", i, components[i]);
+            ArgumentChecks.ensureNonNullElement("components", i, 
components[i]);
         }
         return components;
     }
@@ -187,15 +186,15 @@ public class DefaultCompoundCS extends AbstractCS {
      */
     @Override
     public DefaultCompoundCS forConvention(final AxesConvention convention) {
-        ensureNonNull("convention", convention);
+        ArgumentChecks.ensureNonNull("convention", convention);
         synchronized (forConvention) {
             DefaultCompoundCS cs = (DefaultCompoundCS) 
forConvention.get(convention);
             if (cs == null) {
-                cs = (DefaultCompoundCS) 
forConvention.get(AxesConvention.ORIGINAL);
+                cs = this;
                 boolean changed = false;
-                final CoordinateSystem[] newComponents = new 
CoordinateSystem[cs.components.size()];
+                final CoordinateSystem[] newComponents = new 
CoordinateSystem[components.size()];
                 for (int i=0; i<newComponents.length; i++) {
-                    CoordinateSystem component = cs.components.get(i);
+                    CoordinateSystem component = components.get(i);
                     AbstractCS m = castOrCopy(component);
                     if (m != (m = m.forConvention(convention))) {
                         component = m;
@@ -236,6 +235,6 @@ public class DefaultCompoundCS extends AbstractCS {
         if (!(object instanceof DefaultCompoundCS && super.equals(object, 
mode))) {
             return false;
         }
-        return deepEquals(components, ((DefaultCompoundCS) object).components, 
mode);
+        return Utilities.deepEquals(components, ((DefaultCompoundCS) 
object).components, mode);
     }
 }
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCylindricalCS.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCylindricalCS.java
index ae6855ecf0..9c64619721 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCylindricalCS.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultCylindricalCS.java
@@ -112,12 +112,10 @@ public class DefaultCylindricalCS extends AbstractCS 
implements CylindricalCS {
     /**
      * Creates a new CS derived from the specified one, but with different 
axis order or unit.
      *
-     * @see #createForAxes(String, CoordinateSystemAxis[], boolean)
+     * @see #createForAxes(String, CoordinateSystemAxis[])
      */
-    private DefaultCylindricalCS(final DefaultCylindricalCS original, final 
String name,
-                                 final CoordinateSystemAxis[] axes, final 
boolean share)
-    {
-        super(original, name, axes, share);
+    private DefaultCylindricalCS(DefaultCylindricalCS original, String name, 
CoordinateSystemAxis[] axes) {
+        super(original, name, axes);
     }
 
     /**
@@ -199,10 +197,10 @@ public class DefaultCylindricalCS extends AbstractCS 
implements CylindricalCS {
      * Returns a coordinate system with different axes.
      */
     @Override
-    final AbstractCS createForAxes(final String name, final 
CoordinateSystemAxis[] axes, final boolean share) {
+    final AbstractCS createForAxes(final String name, final 
CoordinateSystemAxis[] axes) {
         switch (axes.length) {
             case 2: return new 
DefaultPolarCS(getPropertiesWithoutIdentifiers(name), axes[0], axes[1]);
-            case 3: return new DefaultCylindricalCS(this, name, axes, share);
+            case 3: return new DefaultCylindricalCS(this, name, axes);
             default: throw unexpectedDimension(axes, 2, 3);
         }
     }
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
index c843716613..4f055826a9 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
@@ -129,12 +129,10 @@ public class DefaultEllipsoidalCS extends AbstractCS 
implements EllipsoidalCS {
     /**
      * Creates a new CS derived from the specified one, but with different 
axis order or unit.
      *
-     * @see #createForAxes(String, CoordinateSystemAxis[], boolean)
+     * @see #createForAxes(String, CoordinateSystemAxis[])
      */
-    private DefaultEllipsoidalCS(final DefaultEllipsoidalCS original, final 
String name,
-                                 final CoordinateSystemAxis[] axes, final 
boolean share)
-    {
-        super(original, name, axes, share);
+    private DefaultEllipsoidalCS(DefaultEllipsoidalCS original, String name, 
CoordinateSystemAxis[] axes) {
+        super(original, name, axes);
     }
 
     /**
@@ -239,11 +237,11 @@ public class DefaultEllipsoidalCS extends AbstractCS 
implements EllipsoidalCS {
      * Returns a coordinate system with different axes.
      */
     @Override
-    final AbstractCS createForAxes(final String name, final 
CoordinateSystemAxis[] axes, final boolean share) {
+    final AbstractCS createForAxes(final String name, final 
CoordinateSystemAxis[] axes) {
         switch (axes.length) {
             case 1: return SubTypes.createOneDimensional(this, name, axes);
             case 2: // Fall through
-            case 3: return new DefaultEllipsoidalCS(this, name, axes, share);
+            case 3: return new DefaultEllipsoidalCS(this, name, axes);
             default: throw unexpectedDimension(axes, 1, 3);
         }
     }
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultLinearCS.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultLinearCS.java
index 01bb2aa3dc..a865a2cbde 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultLinearCS.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultLinearCS.java
@@ -103,12 +103,10 @@ public class DefaultLinearCS extends AbstractCS 
implements LinearCS {
     /**
      * Creates a new CS derived from the specified one, but with different 
axis order or unit.
      *
-     * @see #createForAxes(String, CoordinateSystemAxis[], boolean)
+     * @see #createForAxes(String, CoordinateSystemAxis[])
      */
-    private DefaultLinearCS(final DefaultLinearCS original, final String name,
-                            final CoordinateSystemAxis[] axes, final boolean 
share)
-    {
-        super(original, name, axes, share);
+    private DefaultLinearCS(DefaultLinearCS original, String name, 
CoordinateSystemAxis[] axes) {
+        super(original, name, axes);
     }
 
     /**
@@ -190,9 +188,9 @@ public class DefaultLinearCS extends AbstractCS implements 
LinearCS {
      * Returns a coordinate system with different axes.
      */
     @Override
-    final AbstractCS createForAxes(final String name, final 
CoordinateSystemAxis[] axes, final boolean share) {
+    final AbstractCS createForAxes(final String name, final 
CoordinateSystemAxis[] axes) {
         switch (axes.length) {
-            case 1: return new DefaultLinearCS(this, name, axes, share);
+            case 1: return new DefaultLinearCS(this, name, axes);
             default: throw unexpectedDimension(axes, 1, 1);
         }
     }
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultParametricCS.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultParametricCS.java
index b026f56205..be8df7421c 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultParametricCS.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultParametricCS.java
@@ -104,12 +104,10 @@ public class DefaultParametricCS extends AbstractCS 
implements ParametricCS {
     /**
      * Creates a new CS derived from the specified one, but with different 
axis order or unit.
      *
-     * @see #createForAxes(String, CoordinateSystemAxis[], boolean)
+     * @see #createForAxes(String, CoordinateSystemAxis[])
      */
-    private DefaultParametricCS(final DefaultParametricCS original, final 
String name,
-                                final CoordinateSystemAxis[] axes, final 
boolean share)
-    {
-        super(original, name, axes, share);
+    private DefaultParametricCS(DefaultParametricCS original, String name, 
CoordinateSystemAxis[] axes) {
+        super(original, name, axes);
     }
 
     /**
@@ -172,9 +170,9 @@ public class DefaultParametricCS extends AbstractCS 
implements ParametricCS {
      * Returns a coordinate system with different axes.
      */
     @Override
-    final AbstractCS createForAxes(final String name, final 
CoordinateSystemAxis[] axes, final boolean share) {
+    final AbstractCS createForAxes(final String name, final 
CoordinateSystemAxis[] axes) {
         switch (axes.length) {
-            case 1: return new DefaultParametricCS(this, name, axes, share);
+            case 1: return new DefaultParametricCS(this, name, axes);
             default: throw unexpectedDimension(axes, 1, 1);
         }
     }
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultPolarCS.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultPolarCS.java
index b20a4b9113..48c0313e92 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultPolarCS.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultPolarCS.java
@@ -110,12 +110,10 @@ public class DefaultPolarCS extends AbstractCS implements 
PolarCS {
     /**
      * Creates a new CS derived from the specified one, but with different 
axis order or unit.
      *
-     * @see #createForAxes(String, CoordinateSystemAxis[], boolean)
+     * @see #createForAxes(String, CoordinateSystemAxis[])
      */
-    private DefaultPolarCS(final DefaultPolarCS original, final String name,
-                           final CoordinateSystemAxis[] axes, final boolean 
share)
-    {
-        super(original, name, axes, share);
+    private DefaultPolarCS(DefaultPolarCS original, String name, 
CoordinateSystemAxis[] axes) {
+        super(original, name, axes);
     }
 
     /**
@@ -197,9 +195,9 @@ public class DefaultPolarCS extends AbstractCS implements 
PolarCS {
      * Returns a coordinate system with different axes.
      */
     @Override
-    final AbstractCS createForAxes(final String name, final 
CoordinateSystemAxis[] axes, final boolean share) {
+    final AbstractCS createForAxes(final String name, final 
CoordinateSystemAxis[] axes) {
         switch (axes.length) {
-            case 2: return new DefaultPolarCS(this, name, axes, share);
+            case 2: return new DefaultPolarCS(this, name, axes);
             default: throw unexpectedDimension(axes, 2, 2);
         }
     }
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultSphericalCS.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultSphericalCS.java
index 688eeece48..4ffdfc74b5 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultSphericalCS.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultSphericalCS.java
@@ -137,12 +137,10 @@ public class DefaultSphericalCS extends AbstractCS 
implements SphericalCS {
     /**
      * Creates a new CS derived from the specified one, but with different 
axis order or unit.
      *
-     * @see #createForAxes(String, CoordinateSystemAxis[], boolean)
+     * @see #createForAxes(String, CoordinateSystemAxis[])
      */
-    private DefaultSphericalCS(final DefaultSphericalCS original, final String 
name,
-                               final CoordinateSystemAxis[] axes, final 
boolean share)
-    {
-        super(original, name, axes, share);
+    private DefaultSphericalCS(DefaultSphericalCS original, String name, 
CoordinateSystemAxis[] axes) {
+        super(original, name, axes);
     }
 
     /**
@@ -222,7 +220,7 @@ public class DefaultSphericalCS extends AbstractCS 
implements SphericalCS {
      * Returns a coordinate system with different axes.
      */
     @Override
-    final AbstractCS createForAxes(final String name, final 
CoordinateSystemAxis[] axes, final boolean share) {
+    final AbstractCS createForAxes(final String name, final 
CoordinateSystemAxis[] axes) {
         switch (axes.length) {
             case 2: {
                 final Map<String,?> properties = 
getPropertiesWithoutIdentifiers(name);
@@ -232,7 +230,7 @@ public class DefaultSphericalCS extends AbstractCS 
implements SphericalCS {
                     return new DefaultSphericalCS(properties, axes[0], 
axes[1]);
                 }
             }
-            case 3: return new DefaultSphericalCS(this, name, axes, share);
+            case 3: return new DefaultSphericalCS(this, name, axes);
             default: throw unexpectedDimension(axes, 2, 3);
         }
     }
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultTimeCS.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultTimeCS.java
index 8f8a556816..1449c2835a 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultTimeCS.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultTimeCS.java
@@ -106,12 +106,10 @@ public class DefaultTimeCS extends AbstractCS implements 
TimeCS {
     /**
      * Creates a new CS derived from the specified one, but with different 
axis order or unit.
      *
-     * @see #createForAxes(String, CoordinateSystemAxis[], boolean)
+     * @see #createForAxes(String, CoordinateSystemAxis[])
      */
-    private DefaultTimeCS(final DefaultTimeCS original, final String name,
-                          final CoordinateSystemAxis[] axes, final boolean 
share)
-    {
-        super(original, name, axes, share);
+    private DefaultTimeCS(DefaultTimeCS original, String name, 
CoordinateSystemAxis[] axes) {
+        super(original, name, axes);
     }
 
     /**
@@ -191,9 +189,9 @@ public class DefaultTimeCS extends AbstractCS implements 
TimeCS {
      * Returns a coordinate system with different axes.
      */
     @Override
-    final AbstractCS createForAxes(final String name, final 
CoordinateSystemAxis[] axes, final boolean share) {
+    final AbstractCS createForAxes(final String name, final 
CoordinateSystemAxis[] axes) {
         switch (axes.length) {
-            case 1: return new DefaultTimeCS(this, name, axes, share);
+            case 1: return new DefaultTimeCS(this, name, axes);
             default: throw unexpectedDimension(axes, 1, 1);
         }
     }
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java
index 1637f2536f..7a5611bd0a 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java
@@ -121,12 +121,10 @@ public class DefaultUserDefinedCS extends AbstractCS 
implements UserDefinedCS {
     /**
      * Creates a new CS derived from the specified one, but with different 
axis order or unit.
      *
-     * @see #createForAxes(String, CoordinateSystemAxis[], boolean)
+     * @see #createForAxes(String, CoordinateSystemAxis[])
      */
-    private DefaultUserDefinedCS(final DefaultUserDefinedCS original, final 
String name,
-                                 final CoordinateSystemAxis[] axes, final 
boolean share)
-    {
-        super(original, name, axes, share);
+    private DefaultUserDefinedCS(DefaultUserDefinedCS original, String name, 
CoordinateSystemAxis[] axes) {
+        super(original, name, axes);
     }
 
     /**
@@ -189,10 +187,10 @@ public class DefaultUserDefinedCS extends AbstractCS 
implements UserDefinedCS {
      * Returns a coordinate system with different axes.
      */
     @Override
-    final AbstractCS createForAxes(final String name, final 
CoordinateSystemAxis[] axes, final boolean share) {
+    final AbstractCS createForAxes(final String name, final 
CoordinateSystemAxis[] axes) {
         switch (axes.length) {
             case 2: // Fall through
-            case 3: return new DefaultUserDefinedCS(this, name, axes, share);
+            case 3: return new DefaultUserDefinedCS(this, name, axes);
             default: throw unexpectedDimension(axes, 2, 3);
         }
     }
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultVerticalCS.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultVerticalCS.java
index 69f646c179..81d7297139 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultVerticalCS.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultVerticalCS.java
@@ -117,12 +117,10 @@ public class DefaultVerticalCS extends AbstractCS 
implements VerticalCS {
     /**
      * Creates a new CS derived from the specified one, but with different 
axis order or unit.
      *
-     * @see #createForAxes(String, CoordinateSystemAxis[], boolean)
+     * @see #createForAxes(String, CoordinateSystemAxis[])
      */
-    private DefaultVerticalCS(final DefaultVerticalCS original, final String 
name,
-                              final CoordinateSystemAxis[] axes, final boolean 
share)
-    {
-        super(original, name, axes, share);
+    private DefaultVerticalCS(DefaultVerticalCS original, String name, 
CoordinateSystemAxis[] axes) {
+        super(original, name, axes);
     }
 
     /**
@@ -207,9 +205,9 @@ public class DefaultVerticalCS extends AbstractCS 
implements VerticalCS {
      * Returns a coordinate system with different axes.
      */
     @Override
-    final AbstractCS createForAxes(final String name, final 
CoordinateSystemAxis[] axes, final boolean share) {
+    final AbstractCS createForAxes(final String name, final 
CoordinateSystemAxis[] axes) {
         switch (axes.length) {
-            case 1: return new DefaultVerticalCS(this, name, axes, share);
+            case 1: return new DefaultVerticalCS(this, name, axes);
             default: throw unexpectedDimension(axes, 1, 1);
         }
     }
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/Normalizer.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/Normalizer.java
index 8859b632a8..27ee6de2b2 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/Normalizer.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/Normalizer.java
@@ -364,7 +364,7 @@ final class Normalizer implements Comparable<Normalizer> {
         final AbstractCS impl = castOrCopy(cs);
         final var buffer = (StringBuilder) 
CharSequences.camelCaseToSentence(impl.getInterface().getSimpleName());
         final String name = AxisDirections.appendTo(buffer, newAxes);
-        return impl.createForAxes(name, newAxes, changes instanceof 
AxesConvention);
+        return impl.createForAxes(name, newAxes);
     }
 
     /**
@@ -386,11 +386,10 @@ final class Normalizer implements Comparable<Normalizer> {
      * of -60° still locate the same point in the old and the new coordinate 
system. But the preferred way to
      * locate that point become the 300° value if the longitude range has been 
shifted to positive values.</p>
      *
-     * @param  cs     the coordinate system to shift.
-     * @param  share  whether the new CS should use a cache shared with the 
original CS.
+     * @param  cs  the coordinate system to shift.
      * @return a coordinate system using the given kind of longitude range, or 
{@code null} if no change is needed.
      */
-    private static AbstractCS shiftAxisRange(final CoordinateSystem cs, final 
boolean share) {
+    private static AbstractCS shiftAxisRange(final CoordinateSystem cs) {
         boolean changed = false;
         final CoordinateSystemAxis[] axes = new 
CoordinateSystemAxis[cs.getDimension()];
         for (int i=0; i<axes.length; i++) {
@@ -414,7 +413,7 @@ final class Normalizer implements Comparable<Normalizer> {
         if (!changed) {
             return null;
         }
-        return castOrCopy(cs).createForAxes(null, axes, share);
+        return castOrCopy(cs).createForAxes(null, axes);
     }
 
     /**
@@ -454,7 +453,7 @@ final class Normalizer implements Comparable<Normalizer> {
             case NORMALIZED:       // Fall through
             case DISPLAY_ORIENTED: return normalize(cs, convention, true);
             case RIGHT_HANDED:     return normalize(cs, null, true);
-            case POSITIVE_RANGE:   return shiftAxisRange(cs, true);
+            case POSITIVE_RANGE:   return shiftAxisRange(cs);
             default: throw new AssertionError(convention);
         }
     }

Reply via email to