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/11/28 18:08:46 UTC
(sis) 02/02: Cleanup with one new public method but no other significant code change.
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 d650ed458d84c7e32bd9ee28a8ace4cd6bfe6d77
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Fri Nov 28 12:37:28 2025 +0100
Cleanup with one new public method but no other significant code change.
- Move `ReferencingUtilities.getDimension` to `CRS.getDimensionOrZero` for clarity.
- Define a `CRS.BIDIMENSIONAL` package-private constant for clarity.
- Replacements of a few codes by standard Java methods.
- Spelling and javadoc fixes.
---
.../feature/internal/shared/FeatureProjection.java | 2 +-
.../apache/sis/filter/DefaultFilterFactory.java | 4 +-
.../org/apache/sis/filter/FunctionRegister.java | 10 +--
.../geometry/wrapper/SpatialOperationContext.java | 2 +-
.../apache/sis/geometry/wrapper/jts/Wrapper.java | 4 +-
.../org/apache/sis/image/BandAggregateLayout.java | 2 +-
.../main/org/apache/sis/portrayal/Canvas.java | 2 +-
.../apache/sis/geometry/WraparoundAdjustment.java | 6 +-
.../main/org/apache/sis/parameter/IntegerList.java | 2 +-
.../main/org/apache/sis/referencing/CRS.java | 89 ++++++++++++++--------
.../referencing/EllipsoidalHeightSeparator.java | 3 +-
.../apache/sis/referencing/GeodeticCalculator.java | 4 +-
.../apache/sis/referencing/crs/AbstractCRS.java | 2 +-
.../sis/referencing/crs/DefaultProjectedCRS.java | 2 +-
.../referencing/internal/PositionTransformer.java | 2 +-
.../internal/shared/GeodeticObjectBuilder.java | 7 +-
.../internal/shared/ReferencingUtilities.java | 27 -------
.../internal/shared/TemporalAccessor.java | 3 +-
.../internal/shared/WraparoundAxesFinder.java | 3 +-
.../operation/AbstractCoordinateOperation.java | 6 +-
.../operation/CoordinateOperationRegistry.java | 3 +-
.../referencing/operation/DefaultConversion.java | 4 +-
.../operation/DefaultPassThroughOperation.java | 11 ++-
.../operation/transform/MathTransforms.java | 2 +-
.../test/org/apache/sis/io/wkt/CRSParserTest.java | 2 +-
.../operation/DefaultConversionTest.java | 4 +-
.../sis/storage/geotiff/reader/CRSBuilder.java | 4 +-
.../sis/storage/geotiff/reader/XMLMetadata.java | 4 +-
.../sis/storage/netcdf/base/GridMapping.java | 4 +-
.../sis/storage/netcdf/base/NamedElement.java | 2 +-
.../apache/sis/storage/esri/AsciiGridStore.java | 5 +-
.../main/org/apache/sis/math/Vector.java | 2 +-
optional/src/org.apache.sis.gui/bundle/bin/sisfx | 1 +
.../main/org/apache/sis/gui/RecentFiles.java | 2 +-
.../org/apache/sis/gui/coverage/GridViewSkin.java | 2 +-
.../main/org/apache/sis/gui/dataset/LogViewer.java | 7 +-
.../sis/gui/metadata/IdentificationInfo.java | 2 +-
.../apache/sis/gui/metadata/MetadataSummary.java | 2 +-
.../org/apache/sis/gui/referencing/CRSChooser.java | 4 +-
.../org/apache/sis/gui/referencing/MenuSync.java | 8 +-
40 files changed, 120 insertions(+), 137 deletions(-)
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/internal/shared/FeatureProjection.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/internal/shared/FeatureProjection.java
index 297d4257f5..e1ab0ebe1f 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/internal/shared/FeatureProjection.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/internal/shared/FeatureProjection.java
@@ -347,7 +347,7 @@ public final class FeatureProjection extends Record implements UnaryOperator<Fea
/**
* Returns the expression which is executed for fetching the property value at the given index.
*
- * @param index index of the stored property for which to get the expression for fething the value.
+ * @param index index of the stored property for which to get the expression for fetching the value.
* @return the expression which is executed for fetching the property value at the given index.
*/
public final Expression<? super Feature, ?> expression(final int index) {
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/DefaultFilterFactory.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/DefaultFilterFactory.java
index b25e35aa0e..efe4a01e24 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/DefaultFilterFactory.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/DefaultFilterFactory.java
@@ -76,9 +76,9 @@ public abstract class DefaultFilterFactory<R,G,T> extends AbstractFactory implem
/**
* All functions identified by a name like {@code "cos"}, {@code "hypot"}, <i>etc</i>.
* The actual function creations is delegated to an external factory such as SQLMM registry.
- * The factories are fetched by {@link #function(String, Expression...)} when first needed.
+ * The factories are fetched by {@link #function(String, Expression[])} when first needed.
*
- * @see #function(String, Expression...)
+ * @see #function(String, Expression[])
*/
@LazyCandidate
private final Capabilities availableFunctions;
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/FunctionRegister.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/FunctionRegister.java
index 1589a3e661..3e88d34c6b 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/FunctionRegister.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/FunctionRegister.java
@@ -26,18 +26,14 @@ import org.opengis.filter.capability.AvailableFunction;
/**
* A factory of {@code org.opengis.filter} functions identified by their names.
* Each factory can provide an arbitrary number of functions, enumerated by {@link #getNames()}.
- * The {@link org.apache.sis.filter.DefaultFilterFactory#function(String, Expression...)} method
- * delegates to this interface for creating the function implementation for a given name.
- *
- * <p><b>Warning:</b> there is currently no mechanism for avoiding name collision.
- * It is implementer responsibility to keep trace of the whole universe of functions and avoid collision.
- * Checks against name collisions may be added in a future version.</p>
+ * The {@link DefaultFilterFactory#function(String, Expression[])} method delegates to this interface
+ * for creating the function implementation for a given name.
*
* @author Johann Sorel (Geomatys)
* @version 1.6
* @since 1.5
*
- * @see org.opengis.filter.FilterFactory#function(String, Expression...)
+ * @see DefaultFilterFactory#function(String, Expression[])
*/
public interface FunctionRegister {
/**
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 df9078b625..709d962403 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
@@ -144,7 +144,7 @@ public final class SpatialOperationContext implements Serializable {
* that {@link ReferencingUtilities#getUnit(CoordinateSystem)} returns {@code null}.
*/
private static CoordinateReferenceSystem to2D(CoordinateReferenceSystem crs) {
- if (ReferencingUtilities.getDimension(crs) > BIDIMENSIONAL) {
+ if (CRS.getDimensionOrZero(crs) > BIDIMENSIONAL) {
crs = CRS.getComponentAt(crs, 0, BIDIMENSIONAL);
}
return crs;
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/jts/Wrapper.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/jts/Wrapper.java
index d568096b0c..3b1bc00fb5 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/jts/Wrapper.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/jts/Wrapper.java
@@ -47,7 +47,7 @@ import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.CoordinateOperation;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
-import org.apache.sis.referencing.internal.shared.ReferencingUtilities;
+import org.apache.sis.referencing.CRS;
import org.apache.sis.geometry.DirectPosition2D;
import org.apache.sis.geometry.GeneralDirectPosition;
import org.apache.sis.geometry.GeneralEnvelope;
@@ -219,7 +219,7 @@ final class Wrapper extends GeometryWrapper {
if (!Double.isNaN(z)) {
return new GeneralDirectPosition(c.x, c.y, z);
}
- } else if (ReferencingUtilities.getDimension(crs) != Factory.BIDIMENSIONAL) {
+ } else if (CRS.getDimensionOrZero(crs) != Factory.BIDIMENSIONAL) {
final var point = new GeneralDirectPosition(crs);
point.setCoordinate(0, c.x);
point.setCoordinate(1, c.y);
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/BandAggregateLayout.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/BandAggregateLayout.java
index c7e6cc30b7..dd7e51c684 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/BandAggregateLayout.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/BandAggregateLayout.java
@@ -110,7 +110,7 @@ final class BandAggregateLayout {
/**
* Whether to allow the sharing of data buffers (instead of copying) if possible.
* This flag depends on the {@link ImageProcessor} configuration. Its purpose is
- * to express <em>user intend</em>, not whether sharing is effectively enabled.
+ * to express <em>user's intent</em>, not whether sharing is effectively enabled.
*
* <h4>Design note</h4>
* This flag is not the result of the modification done in {@code BandAggregateLayout} constructor
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 a0a1c1e71c..89ea01640d 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
@@ -428,7 +428,7 @@ public class Canvas extends Observable implements Localized {
* Subclasses may override for a little bit more efficiency.
*/
int getDisplayDimensions() {
- return ReferencingUtilities.getDimension(getDisplayCRS());
+ return CRS.getDimensionOrZero(getDisplayCRS());
}
/**
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 25e84b73fc..5d2574acc4 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
@@ -29,7 +29,6 @@ import org.apache.sis.referencing.CRS;
import org.apache.sis.referencing.operation.transform.MathTransforms;
import org.apache.sis.math.MathFunctions;
import org.apache.sis.metadata.internal.shared.ReferencingServices;
-import org.apache.sis.referencing.internal.shared.ReferencingUtilities;
import org.apache.sis.referencing.internal.shared.WraparoundAxesFinder;
import org.apache.sis.util.logging.Logging;
@@ -243,9 +242,8 @@ public class WraparoundAdjustment {
if (crs != null && resultCRS != null) {
inputToResult = findOperation(crs, resultCRS).getMathTransform();
} else {
- inputToResult = MathTransforms.identity(
- (crs != null) ? ReferencingUtilities.getDimension(crs)
- : domainOfValidity.getDimension());
+ final int dim = CRS.getDimensionOrZero(crs);
+ inputToResult = MathTransforms.identity(dim != 0 ? dim : domainOfValidity.getDimension());
}
}
/*
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/IntegerList.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/IntegerList.java
index f14a2ae2e6..70f3cc223b 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/IntegerList.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/IntegerList.java
@@ -49,7 +49,7 @@ final class IntegerList {
* @param array the integer values as a Java array.
*/
public IntegerList(final Object array) {
- final StringJoiner builder = new StringJoiner(" ");
+ final var builder = new StringJoiner(" ");
final int length = Array.getLength(array);
for (int i=0; i<length; i++) {
builder.add(String.valueOf(Array.get(array, i)));
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 7fe88aff7f..8fb46bdba5 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
@@ -158,6 +158,11 @@ public final class CRS {
*/
static final Logger LOGGER = Logger.getLogger(Modules.REFERENCING);
+ /**
+ * The {@value} value, for identifying code that assume two-dimensional objects.
+ */
+ static final int BIDIMENSIONAL = 2;
+
/**
* Do not allow instantiation of this class.
*/
@@ -1046,6 +1051,30 @@ public final class CRS {
return Optional.empty();
}
+ /**
+ * Returns the number of dimensions of the given <abbr>CRS</abbr>, or 0 if {@code null}.
+ * This method also returns 0 if the <abbr>CRS</abbr> is associated to a null coordinate system.
+ *
+ * <p>This is convenience method for cases such as <abbr>CRS</abbr> separated in optional components.
+ * For example, a class may have an optional {@link VerticalCRS} component allowed to be {@code null}.
+ * When computing the total number of dimensions, it is sometime convenient to handle null components
+ * as a component of dimension zero.</p>
+ *
+ * @param crs the <abbr>CRS</abbr> from which to get the number of dimensions, or {@code null}.
+ * @return the number of dimensions, or 0 if the given <abbr>CRS</abbr> or its coordinate system is null.
+ *
+ * @since 1.6
+ */
+ public static int getDimensionOrZero(final CoordinateReferenceSystem crs) {
+ if (crs != null) {
+ final CoordinateSystem cs = crs.getCoordinateSystem();
+ if (cs != null) { // Should never be null, but let be safe.
+ return cs.getDimension();
+ }
+ }
+ return 0;
+ }
+
/**
* Creates a compound coordinate reference system from an ordered list of CRS components.
* A CRS is inferred from the given components and the domain of validity is set to the
@@ -1114,25 +1143,22 @@ public final class CRS {
*
* @since 1.3
*/
- public static CoordinateReferenceSystem selectDimensions(final CoordinateReferenceSystem crs,
- final int... dimensions) throws FactoryException
+ public static CoordinateReferenceSystem selectDimensions(final CoordinateReferenceSystem crs, final int... dimensions)
+ throws FactoryException
{
final var components = selectComponents(crs, dimensions);
- if (components.isEmpty()) {
- return null;
- }
- return compound(components.toArray(CoordinateReferenceSystem[]::new));
+ return components.isEmpty() ? null : compound(components.toArray(CoordinateReferenceSystem[]::new));
}
/**
- * Gets or creates CRS components for a subset of the dimensions of the given CRS.
+ * Gets or creates CRS components for a subset of the dimensions of the given <abbr>CRS</abbr>.
* The method performs the same work as {@link #selectDimensions(CoordinateReferenceSystem, int...)}
* except that it does not build new {@link CompoundCRS} instances when the specified dimensions span
* more than one {@linkplain DefaultCompoundCRS#getComponents() component}.
* Instead, the components are returned directly.
*
- * <p>While this method does not create new {@code CompoundCRS} instances, it still may create other
- * kinds of CRS for handling ellipsoidal height as documented in the {@code selectDimensions(…)} method.</p>
+ * <p>While this method does not create new {@code CompoundCRS} instances, it may create other kinds
+ * of CRS for handling ellipsoidal height as documented in the {@code selectDimensions(…)} method.</p>
*
* @param crs the CRS from which to get a subset of the components, or {@code null} if none.
* @param dimensions the dimensions to retain. The dimensions will be taken in increasing order, ignoring duplicated values.
@@ -1144,28 +1170,24 @@ public final class CRS {
*
* @since 1.4
*/
- public static List<CoordinateReferenceSystem> selectComponents(final CoordinateReferenceSystem crs,
- final int... dimensions) throws FactoryException
+ public static List<CoordinateReferenceSystem> selectComponents(final CoordinateReferenceSystem crs, final int... dimensions)
+ throws FactoryException
{
ArgumentChecks.ensureNonNull("dimensions", dimensions);
- if (crs == null) {
- return List.of();
- }
- final int dimension = ReferencingUtilities.getDimension(crs);
+ final int dimension = getDimensionOrZero(crs);
long selected = 0;
- for (final int d : dimensions) {
- if (d < 0 || d >= dimension) {
- throw new IndexOutOfBoundsException(Errors.format(Errors.Keys.IndexOutOfBounds_1, d));
+ if (crs != null) {
+ for (final int d : dimensions) {
+ if (Objects.checkIndex(d, dimension) >= Long.SIZE) {
+ throw new ArithmeticException(Errors.format(Errors.Keys.ExcessiveNumberOfDimensions_1, d+1));
+ }
+ selected |= (1L << d);
}
- if (d >= Long.SIZE) {
- throw new ArithmeticException(Errors.format(Errors.Keys.ExcessiveNumberOfDimensions_1, d+1));
+ if (selected == 0) {
+ throw new IllegalArgumentException(Errors.format(Errors.Keys.EmptyArgument_1, "dimensions"));
}
- selected |= (1L << d);
- }
- if (selected == 0) {
- throw new IllegalArgumentException(Errors.format(Errors.Keys.EmptyArgument_1, "dimensions"));
}
- final List<CoordinateReferenceSystem> components = new ArrayList<>(Long.bitCount(selected));
+ final var components = new ArrayList<CoordinateReferenceSystem>(Long.bitCount(selected));
reduce(0, crs, dimension, selected, components);
return components;
}
@@ -1182,7 +1204,8 @@ public final class CRS {
* @return new bitmask after removal of dimensions of the components added to {@code addTo}.
*/
private static long reduce(int previous, final CoordinateReferenceSystem crs, int dimension, long selected,
- final List<CoordinateReferenceSystem> addTo) throws FactoryException
+ final List<CoordinateReferenceSystem> addTo)
+ throws FactoryException
{
final long current = (Numerics.bitmask(dimension) - 1) << previous;
final long intersect = selected & current;
@@ -1192,7 +1215,7 @@ choice: if (intersect != 0) {
selected &= ~current;
} else if (crs instanceof CompoundCRS) {
for (final CoordinateReferenceSystem component : ((CompoundCRS) crs).getComponents()) {
- dimension = ReferencingUtilities.getDimension(component);
+ dimension = getDimensionOrZero(component);
selected = reduce(previous, component, dimension, selected, addTo);
if ((selected & current) == 0) break; // Stop if it would be useless to continue.
previous += dimension;
@@ -1248,7 +1271,7 @@ choice: if (intersect != 0) {
* @category information
*/
public static boolean isHorizontalCRS(final CoordinateReferenceSystem crs) {
- return horizontalCode(crs) == 2;
+ return horizontalCode(crs) == BIDIMENSIONAL;
}
/**
@@ -1267,14 +1290,14 @@ choice: if (intersect != 0) {
if (isGeodetic || crs instanceof ProjectedCRS || (isEngineering = (crs instanceof EngineeringCRS))) {
final CoordinateSystem cs = crs.getCoordinateSystem();
final int dim = cs.getDimension();
- if ((dim & ~1) == 2 && (!isGeodetic || (cs instanceof EllipsoidalCS))) {
+ if ((dim & ~1) == BIDIMENSIONAL && (!isGeodetic || (cs instanceof EllipsoidalCS))) {
if (isEngineering) {
int n = 0;
for (int i=0; i<dim; i++) {
if (AxisDirections.isCompass(cs.getAxis(i).getDirection())) n++;
}
// If we don't have exactly 2 east, north, etc. directions, consider as non-horizontal.
- if (n != 2) return 0;
+ if (n != BIDIMENSIONAL) return 0;
}
return dim;
}
@@ -1333,7 +1356,7 @@ choice: if (intersect != 0) {
* We don't need to check if crs is an instance of SingleCRS since all
* CRS accepted by horizontalCode(…) are SingleCRS.
*/
- case 2: {
+ case BIDIMENSIONAL: {
return (SingleCRS) crs;
}
case 3: {
@@ -1347,7 +1370,7 @@ choice: if (intersect != 0) {
return !AxisDirections.isVertical(axis.getDirection());
}
});
- if (cs.getDimension() != 2) break;
+ if (cs.getDimension() != BIDIMENSIONAL) break;
/*
* Most of the time, the CRS to rebuild will be geodetic. In such case we known that the
* coordinate system is ellipsoidal because (i.e. the CRS is geographic) because it was
@@ -1578,7 +1601,7 @@ choice: if (intersect != 0) {
@OptionalCandidate
public static CoordinateReferenceSystem getComponentAt(CoordinateReferenceSystem crs, int lower, int upper) {
if (crs == null) return null; // Skip bounds check.
- int dimension = ReferencingUtilities.getDimension(crs);
+ int dimension = getDimensionOrZero(crs);
Objects.checkFromToIndex(lower, upper, dimension);
check: while (lower != 0 || upper != dimension) {
if (crs instanceof CompoundCRS) {
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/EllipsoidalHeightSeparator.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/EllipsoidalHeightSeparator.java
index 73a4a1a107..f5c52cb9f6 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/EllipsoidalHeightSeparator.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/EllipsoidalHeightSeparator.java
@@ -30,7 +30,6 @@ import org.opengis.referencing.crs.GeodeticCRS;
import org.opengis.referencing.datum.GeodeticDatum;
import org.opengis.referencing.operation.Conversion;
import org.apache.sis.referencing.internal.shared.AxisDirections;
-import org.apache.sis.referencing.internal.shared.ReferencingUtilities;
import org.apache.sis.referencing.cs.CoordinateSystems;
import org.apache.sis.referencing.cs.AxisFilter;
import org.apache.sis.referencing.operation.DefaultConversion;
@@ -141,7 +140,7 @@ final class EllipsoidalHeightSeparator implements AxisFilter {
*/
if (crs instanceof ProjectedCRS) {
GeodeticCRS baseCRS = ((ProjectedCRS) crs).getBaseCRS();
- if (ReferencingUtilities.getDimension(baseCRS) != 2) {
+ if (CRS.getDimensionOrZero(baseCRS) != CRS.BIDIMENSIONAL) {
baseCRS = (GeodeticCRS) separate(baseCRS);
}
Conversion projection = ((ProjectedCRS) crs).getConversionFromBase();
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/GeodeticCalculator.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/GeodeticCalculator.java
index 903bf749be..06a0112bc6 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/GeodeticCalculator.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/GeodeticCalculator.java
@@ -353,7 +353,7 @@ public class GeodeticCalculator {
private PositionTransformer geographic(final double φ, final double λ) {
userToGeodetic.setCoordinate(0, toDegrees(φ));
userToGeodetic.setCoordinate(1, toDegrees(λ));
- for (int i=userToGeodetic.getDimension(); --i >= 2;) {
+ for (int i = userToGeodetic.getDimension(); --i >= CRS.BIDIMENSIONAL;) {
userToGeodetic.setCoordinate(i, 0); // Set height to ellipsoid surface.
}
return userToGeodetic;
@@ -941,7 +941,7 @@ public class GeodeticCalculator {
* Creates a builder for the given tolerance at equator in metres.
*/
PathBuilder(final double εx) {
- super(ReferencingUtilities.getDimension(userToGeodetic.defaultCRS));
+ super(CRS.getDimensionOrZero(userToGeodetic.defaultCRS));
φf = φ2;
λf = λ2;
msinαf = msinα2;
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 549fe464af..44709671ac 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
@@ -58,7 +58,7 @@ import org.opengis.coordinate.MismatchedDimensionException;
/**
* Coordinate reference system, defined by a {@linkplain AbstractCS coordinate system}
* and (usually) a {@linkplain org.apache.sis.referencing.datum.AbstractDatum datum}.
- * A coordinate reference system (CRS) consists of an ordered sequence of
+ * A coordinate reference system (<abbr>CRS</abbr>) consists of an ordered sequence of
* {@linkplain org.apache.sis.referencing.cs.DefaultCoordinateSystemAxis coordinate system axes}
* that are related to the earth through the datum.
* Most coordinate reference system do not move relative to the earth, except for
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 c58440eb67..9201692401 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
@@ -145,7 +145,7 @@ public class DefaultProjectedCRS extends AbstractDerivedCRS implements Projected
*/
@Workaround(library="JDK", version="1.7")
private static GeodeticCRS checkDimensions(final GeodeticCRS baseCRS, final CartesianCS derivedCS) {
- int n = ReferencingUtilities.getDimension(baseCRS);
+ int n = baseCRS.getCoordinateSystem().getDimension();
if (derivedCS != null) {
n = Math.max(n, derivedCS.getDimension());
}
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 40f545525a..e2ca84acd4 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
@@ -254,7 +254,7 @@ public final class PositionTransformer extends GeneralDirectPosition {
/**
* Transforms this point to the default CRS and stores the result in the given array, and returns the derivative.
- * The {@code target} array length should be {@code ReferencingUtilities.getDimension(defaultCRS)}.
+ * The {@code target} array length should be {@code CRS.getDimensionOrZero(defaultCRS)}.
*
* @param target where to store the transformed coordinates.
* @return the derivative (Jacobian matrix) at the location of this point.
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/shared/GeodeticObjectBuilder.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/shared/GeodeticObjectBuilder.java
index e5583b0ce9..40a5a071b9 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/shared/GeodeticObjectBuilder.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/shared/GeodeticObjectBuilder.java
@@ -49,6 +49,7 @@ import org.opengis.referencing.operation.OperationMethod;
import org.opengis.referencing.operation.Conversion;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.resources.Errors;
+import org.apache.sis.referencing.CRS;
import org.apache.sis.referencing.Builder;
import org.apache.sis.referencing.CommonCRS;
import org.apache.sis.referencing.IdentifiedObjects;
@@ -655,8 +656,8 @@ public class GeodeticObjectBuilder extends Builder<GeodeticObjectBuilder> {
public CoordinateReferenceSystem replaceComponent(final CoordinateReferenceSystem source,
final int firstDimension, final CoordinateReferenceSystem replacement) throws FactoryException
{
- final int srcDim = ReferencingUtilities.getDimension(source);
- final int repDim = ReferencingUtilities.getDimension(replacement);
+ final int srcDim = CRS.getDimensionOrZero(source);
+ final int repDim = CRS.getDimensionOrZero(replacement);
if (firstDimension == 0 && srcDim == repDim) {
/*
* conceptually return the replacement. But returning the original instance if applicable
@@ -695,7 +696,7 @@ public class GeodeticObjectBuilder extends Builder<GeodeticObjectBuilder> {
components[i] = nc;
return createCompoundCRS(components);
}
- lower += ReferencingUtilities.getDimension(c);
+ lower += CRS.getDimensionOrZero(c);
}
}
throw new IllegalArgumentException(Resources.forLocale(locale).getString(
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/shared/ReferencingUtilities.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/shared/ReferencingUtilities.java
index 0e9e469553..734af0a2a6 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/shared/ReferencingUtilities.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/shared/ReferencingUtilities.java
@@ -18,7 +18,6 @@ package org.apache.sis.referencing.internal.shared;
import java.util.Map;
import java.util.HashMap;
-import java.util.OptionalInt;
import javax.measure.Unit;
import javax.measure.quantity.Angle;
import org.opengis.annotation.UML;
@@ -137,32 +136,6 @@ public final class ReferencingUtilities {
return (crs != null) ? getUnit(crs.getCoordinateSystem()) : null;
}
- /**
- * Returns the number of dimensions of the given CRS, or 0 if {@code null}.
- *
- * @param crs the CRS from which to get the number of dimensions, or {@code null}.
- * @return the number of dimensions, or 0 if the given CRS or its coordinate system is null.
- */
- public static int getDimension(final CoordinateReferenceSystem crs) {
- return getOptionalDimension(crs).orElse(0);
- }
-
- /**
- * Returns the number of dimensions of the given <abbr>CRS</abbr>.
- *
- * @param crs the <abbr>CRS</abbr> from which to get the number of dimensions, or {@code null}.
- * @return the number of dimensions, or empty if the given CRS or its coordinate system is null.
- */
- public static OptionalInt getOptionalDimension(final CoordinateReferenceSystem crs) {
- if (crs != null) {
- final CoordinateSystem cs = crs.getCoordinateSystem();
- if (cs != null) { // Should never be null, but let be safe.
- return OptionalInt.of(cs.getDimension());
- }
- }
- return OptionalInt.empty();
- }
-
/**
* Returns the GeoAPI interface implemented by the given object, or the implementation class
* if the interface is unknown. This method can be used when the base type (CRS, CS, Datum…)
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/shared/TemporalAccessor.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/shared/TemporalAccessor.java
index bab0c03bf3..632e147f05 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/shared/TemporalAccessor.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/shared/TemporalAccessor.java
@@ -21,6 +21,7 @@ import org.opengis.geometry.Envelope;
import org.opengis.referencing.crs.CompoundCRS;
import org.opengis.referencing.crs.TemporalCRS;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.apache.sis.referencing.CRS;
import org.apache.sis.referencing.crs.DefaultTemporalCRS;
import org.apache.sis.metadata.iso.extent.DefaultTemporalExtent;
import org.apache.sis.geometry.AbstractEnvelope;
@@ -77,7 +78,7 @@ public final class TemporalAccessor {
if (accessor != null) {
return accessor;
}
- dim += ReferencingUtilities.getDimension(component);
+ dim += CRS.getDimensionOrZero(component);
}
}
return null;
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/shared/WraparoundAxesFinder.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/shared/WraparoundAxesFinder.java
index a352dd0cfd..57135db41a 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/shared/WraparoundAxesFinder.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/shared/WraparoundAxesFinder.java
@@ -20,6 +20,7 @@ import org.opengis.referencing.cs.CoordinateSystem;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.crs.ProjectedCRS;
import org.opengis.referencing.operation.MathTransform;
+import org.apache.sis.referencing.CRS;
import org.apache.sis.referencing.operation.transform.MathTransforms;
@@ -54,7 +55,7 @@ public final class WraparoundAxesFinder {
preferredToSpecified = p.getConversionFromBase().getMathTransform();
} else {
// TODO: we should handle the case of CompoundCRS before to fallback on identity.
- preferredToSpecified = MathTransforms.identity(ReferencingUtilities.getDimension(crs));
+ preferredToSpecified = MathTransforms.identity(CRS.getDimensionOrZero(crs));
}
preferredCRS = crs;
}
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 9d9a53dee8..4afc281adb 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
@@ -59,6 +59,7 @@ import org.apache.sis.util.logging.Logging;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.parameter.Parameterized;
import org.apache.sis.metadata.iso.citation.Citations;
+import org.apache.sis.referencing.CRS;
import org.apache.sis.referencing.AbstractIdentifiedObject;
import org.apache.sis.referencing.cs.CoordinateSystems;
import org.apache.sis.referencing.operation.transform.MathTransforms;
@@ -66,7 +67,6 @@ import org.apache.sis.referencing.operation.transform.PassThroughTransform;
import org.apache.sis.referencing.internal.PositionalAccuracyConstant;
import org.apache.sis.referencing.internal.Resources;
import org.apache.sis.referencing.internal.shared.CoordinateOperations;
-import org.apache.sis.referencing.internal.shared.ReferencingUtilities;
import org.apache.sis.referencing.internal.shared.WKTUtilities;
import org.apache.sis.referencing.internal.shared.WKTKeywords;
import org.apache.sis.metadata.internal.shared.ImplementationHelper;
@@ -355,7 +355,7 @@ public class AbstractCoordinateOperation extends AbstractIdentifiedObject implem
@SuppressWarnings("LocalVariableHidesMemberVariable")
final MathTransform transform = this.transform; // Protect from changes.
if (transform != null) {
- final int interpDim = ReferencingUtilities.getDimension(interpolationCRS);
+ final int interpDim = CRS.getDimensionOrZero(interpolationCRS);
check: for (int isTarget=0; ; isTarget++) { // 0 == source check; 1 == target check.
final CoordinateReferenceSystem crs; // Will determine the expected dimensions.
int actual; // The MathTransform number of dimensions.
@@ -364,7 +364,7 @@ check: for (int isTarget=0; ; isTarget++) { // 0 == source check; 1
case 1: crs = targetCRS; actual = transform.getTargetDimensions(); break;
default: break check;
}
- int expected = ReferencingUtilities.getDimension(crs);
+ int expected = CRS.getDimensionOrZero(crs);
if (interpDim != 0) {
if (actual == expected || actual < interpDim) {
// This check is not strictly necessary as the next check below would catch the error,
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 2473b66070..af31347efd 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
@@ -68,7 +68,6 @@ import org.apache.sis.referencing.internal.DeferredCoordinateOperation;
import org.apache.sis.referencing.internal.Resources;
import org.apache.sis.referencing.internal.shared.CoordinateOperations;
import org.apache.sis.referencing.internal.shared.EllipsoidalHeightCombiner;
-import org.apache.sis.referencing.internal.shared.ReferencingUtilities;
import org.apache.sis.metadata.iso.citation.Citations;
import org.apache.sis.metadata.iso.extent.Extents;
import org.apache.sis.system.Semaphores;
@@ -889,7 +888,7 @@ class CoordinateOperationRegistry {
* (e.g. as in the "geographic 3D to geographic 2D" conversion) because ALLOW_VARIANT mode
* still requires a matching number of dimensions.
*/
- assert ReferencingUtilities.getDimension(sourceCRS) != ReferencingUtilities.getDimension(targetCRS)
+ assert CRS.getDimensionOrZero(sourceCRS) != CRS.getDimensionOrZero(targetCRS)
|| Utilities.deepEquals(sourceCRS, targetCRS, ComparisonMode.ALLOW_VARIANT);
final Matrix m = CoordinateSystems.swapAndScaleAxes(sourceCRS.getCoordinateSystem(), targetCRS.getCoordinateSystem());
return (m.isIdentity()) ? null : mtFactory.createAffineTransform(m);
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConversion.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConversion.java
index 8e3429579a..f3501c4cd6 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConversion.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConversion.java
@@ -31,6 +31,7 @@ import org.opengis.referencing.operation.MathTransformFactory;
import org.opengis.referencing.operation.Matrix;
import org.opengis.referencing.crs.SingleCRS;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.apache.sis.referencing.CRS;
import org.apache.sis.referencing.cs.CoordinateSystems;
import org.apache.sis.referencing.datum.DatumOrEnsemble;
import org.apache.sis.referencing.factory.InvalidGeodeticParameterException;
@@ -39,7 +40,6 @@ import org.apache.sis.referencing.internal.Resources;
import org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory;
import org.apache.sis.referencing.operation.transform.MathTransformProvider;
import org.apache.sis.referencing.operation.matrix.Matrices;
-import org.apache.sis.referencing.internal.shared.ReferencingUtilities;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.Utilities;
import org.apache.sis.util.resources.Errors;
@@ -229,7 +229,7 @@ public class DefaultConversion extends AbstractSingleOperation implements Conver
final MathTransformFactory factory) throws FactoryException
{
super(definition);
- int interpDim = ReferencingUtilities.getDimension(super.getInterpolationCRS().orElse(null));
+ int interpDim = CRS.getDimensionOrZero(super.getInterpolationCRS().orElse(null));
if (transform == null) {
/*
* If the user did not specify explicitly a MathTransform, we will need to create it from the parameters.
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultPassThroughOperation.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultPassThroughOperation.java
index 05ebe8dfad..79855d7e65 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultPassThroughOperation.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultPassThroughOperation.java
@@ -33,7 +33,6 @@ import org.apache.sis.referencing.GeodeticException;
import org.apache.sis.referencing.CRS;
import org.apache.sis.referencing.operation.transform.MathTransforms;
import org.apache.sis.referencing.operation.transform.PassThroughTransform;
-import org.apache.sis.referencing.internal.shared.ReferencingUtilities;
import org.apache.sis.metadata.internal.shared.ImplementationHelper;
import org.apache.sis.util.ArraysExt;
import org.apache.sis.util.ComparisonMode;
@@ -364,22 +363,22 @@ public class DefaultPassThroughOperation extends AbstractCoordinateOperation imp
* of the nested operation from the source/target CRS of the enclosing pass-through operation.
*/
@Override
+ @SuppressWarnings("LocalVariableHidesMemberVariable")
final void afterUnmarshal(Unmarshaller unmarshaller, Object parent) {
super.afterUnmarshal(unmarshaller, parent);
/*
* State validation. The `missing` string will be used in exception message
* at the end of this method if a required component is reported missing.
*/
- @SuppressWarnings("LocalVariableHidesMemberVariable")
final int[] modifiedCoordinates = this.modifiedCoordinates;
FactoryException cause = null;
String missing = "modifiedCoordinate";
if (modifiedCoordinates.length != 0) {
missing = "sourceCRS";
- final CoordinateReferenceSystem sourceCRS = super.getSourceCRS();
+ final CoordinateReferenceSystem sourceCRS = super.sourceCRS;
if (sourceCRS != null) {
missing = "targetCRS";
- final CoordinateReferenceSystem targetCRS = super.getTargetCRS();
+ final CoordinateReferenceSystem targetCRS = super.targetCRS;
if (targetCRS != null) {
missing = "coordOperation";
if (operation != null) {
@@ -401,8 +400,8 @@ public class DefaultPassThroughOperation extends AbstractCoordinateOperation imp
}
}
if (subTransform != null) {
- transform = MathTransforms.passThrough(modifiedCoordinates, subTransform,
- ReferencingUtilities.getDimension(sourceCRS));
+ final int resultDim = sourceCRS.getCoordinateSystem().getDimension();
+ transform = MathTransforms.passThrough(modifiedCoordinates, subTransform, resultDim);
return;
}
}
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/MathTransforms.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/MathTransforms.java
index 5d776ca4a3..86e777f0c0 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/MathTransforms.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/MathTransforms.java
@@ -403,7 +403,7 @@ public final class MathTransforms {
*/
public static MathTransform passThrough(final int[] modifiedCoordinates, final MathTransform subTransform, final int resultDim) {
ArgumentChecks.ensureNonNull("modifiedCoordinates", modifiedCoordinates);
- final BitSet bitset = new BitSet();
+ final var bitset = new BitSet();
int previous = -1;
for (int i=0; i < modifiedCoordinates.length; i++) {
final int dim = modifiedCoordinates[i];
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/CRSParserTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/CRSParserTest.java
index 5da7217039..c73cf2bd1f 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/CRSParserTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/CRSParserTest.java
@@ -50,7 +50,7 @@ public final class CRSParserTest extends WKTParserTest {
* This is done for avoiding race conditions logging the same message many times.
*/
static {
- // Will do nothing, the intend is only to force class initialization.
+ // Will do nothing, the intent is only to force class initialization.
TestCase.out.flush();
}
diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultConversionTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultConversionTest.java
index afec45c053..eac21492dd 100644
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultConversionTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultConversionTest.java
@@ -29,9 +29,9 @@ import org.opengis.referencing.cs.EllipsoidalCS;
import org.opengis.referencing.operation.Matrix;
import org.opengis.referencing.operation.Conversion;
import org.opengis.referencing.operation.OperationMethod;
+import org.apache.sis.referencing.CRS;
import org.apache.sis.referencing.IdentifiedObjects;
import org.apache.sis.referencing.internal.shared.CoordinateOperations;
-import org.apache.sis.referencing.internal.shared.ReferencingUtilities;
import org.apache.sis.referencing.datum.DefaultGeodeticDatum;
import org.apache.sis.referencing.crs.DefaultGeographicCRS;
import org.apache.sis.referencing.operation.matrix.Matrix3;
@@ -142,7 +142,7 @@ public final class DefaultConversionTest extends TestCase {
* from the parameters. But we don't do the normal steps here because this class is a unit test:
* we want to test DefaultConversion in isolation of MathTransformFactory.
*/
- final int interpDim = ReferencingUtilities.getDimension(interpolationCRS);
+ final int interpDim = CRS.getDimensionOrZero(interpolationCRS);
final int sourceDim = sourceCRS.getCoordinateSystem().getDimension();
final int targetDim = targetCRS.getCoordinateSystem().getDimension();
final OperationMethod method = DefaultOperationMethodTest.create(
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 4604c24a3a..6c72ab4a9d 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
@@ -283,7 +283,7 @@ public final class CRSBuilder extends ReferencingFactoryContainer {
if (value != null) {
if (value.getClass().isArray()) {
final int length = Array.getLength(value);
- final StringJoiner buffer = new StringJoiner(", ");
+ final var buffer = new StringJoiner(", ");
for (int i=0; i<length; i++) {
buffer.add(String.valueOf(Array.get(value, i)));
}
@@ -574,7 +574,7 @@ public final class CRSBuilder extends ReferencingFactoryContainer {
* Emits a warning for unprocessed GeoTIFF tags. A single warning is emitted for all ignored tags.
*/
if (!geoKeys.isEmpty()) {
- final StringJoiner joiner = new StringJoiner(", ");
+ final var joiner = new StringJoiner(", ");
final Short[] keys = geoKeys.keySet().toArray(Short[]::new);
Arrays.sort(keys);
for (final short key : keys) {
diff --git a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/reader/XMLMetadata.java b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/reader/XMLMetadata.java
index 9daaeb1969..d4c8376956 100644
--- a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/reader/XMLMetadata.java
+++ b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/reader/XMLMetadata.java
@@ -339,7 +339,7 @@ public final class XMLMetadata implements Filter {
}
}
}
- final StringJoiner buffer = new StringJoiner("");
+ final var buffer = new StringJoiner("");
while (reader.hasNext()) {
final XMLEvent event = reader.nextEvent();
if (event.isStartElement()) {
@@ -470,7 +470,7 @@ public final class XMLMetadata implements Filter {
final Attribute a = start.getAttributeByName(name);
if (a != null) attribute = a.getValue();
}
- final StringJoiner buffer = new StringJoiner("");
+ final var buffer = new StringJoiner("");
while (reader.hasNext()) {
final XMLEvent event = reader.nextEvent();
if (event.isEndElement()) {
diff --git a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/GridMapping.java b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/GridMapping.java
index 355f2077ab..732e1b21a7 100644
--- a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/GridMapping.java
+++ b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/GridMapping.java
@@ -68,7 +68,6 @@ import org.apache.sis.referencing.operation.transform.TransformSeparator;
import org.apache.sis.referencing.operation.provider.PseudoPlateCarree;
import org.apache.sis.referencing.internal.shared.AxisDirections;
import org.apache.sis.referencing.internal.shared.AffineTransform2D;
-import org.apache.sis.referencing.internal.shared.ReferencingUtilities;
import org.apache.sis.storage.DataStoreContentException;
import org.apache.sis.storage.netcdf.internal.Resources;
import org.apache.sis.coverage.grid.GridGeometry;
@@ -791,7 +790,8 @@ final class GridMapping {
MathTransform implicitG2C = gridToCRS(variable);
CoordinateReferenceSystem implicitCRS = crs;
if (implicitG2C != null) {
- final int tgtDim = ReferencingUtilities.getOptionalDimension(implicitCRS).orElse(srcDim);
+ int tgtDim = CRS.getDimensionOrZero(implicitCRS);
+ if (tgtDim == 0) tgtDim = srcDim;
MathTransform step1 = changeOfDimension(srcDim, implicitG2C.getSourceDimensions());
MathTransform step3 = changeOfDimension(implicitG2C.getTargetDimensions(), tgtDim);
implicitG2C = MathTransforms.concatenate(step1, implicitG2C, step3);
diff --git a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/NamedElement.java b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/NamedElement.java
index 76cc09263e..baa3a5bb52 100644
--- a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/NamedElement.java
+++ b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/NamedElement.java
@@ -70,7 +70,7 @@ public abstract class NamedElement {
* @return a name for an object composed of the given components.
*/
protected static String listNames(final NamedElement[] components, final int count, final String delimiter) {
- final StringJoiner joiner = new StringJoiner(delimiter);
+ final var joiner = new StringJoiner(delimiter);
for (int i=0; i<count; i++) {
joiner.add(components[i].getName());
}
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/esri/AsciiGridStore.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/esri/AsciiGridStore.java
index 543d0b5fd7..fda499dda2 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/esri/AsciiGridStore.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/esri/AsciiGridStore.java
@@ -18,7 +18,6 @@ package org.apache.sis.storage.esri;
import java.util.Map;
import java.util.List;
-import java.util.StringJoiner;
import java.io.IOException;
import java.nio.file.StandardOpenOption;
import java.awt.image.RenderedImage;
@@ -319,9 +318,7 @@ cellsize: if (value != null) {
* We list all properties in a single message.
*/
if (!header.isEmpty()) {
- final StringJoiner joiner = new StringJoiner(", ");
- header.keySet().forEach(joiner::add);
- listeners.warning(messageForProperty(Errors.Keys.UnexpectedProperty_2, joiner.toString()));
+ listeners.warning(messageForProperty(Errors.Keys.UnexpectedProperty_2, String.join(", ", header.keySet())));
}
} catch (DataStoreException e) {
closeOnError(e);
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/Vector.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/Vector.java
index e4dce03219..e3d9f87d1d 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/Vector.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/Vector.java
@@ -1604,7 +1604,7 @@ search: for (;;) {
*/
@Override
public String toString() {
- final StringJoiner buffer = new StringJoiner(", ", "[", "]");
+ final var buffer = new StringJoiner(", ", "[", "]");
final int length = size();
for (int i=0; i<length; i++) {
buffer.add(stringValue(i));
diff --git a/optional/src/org.apache.sis.gui/bundle/bin/sisfx b/optional/src/org.apache.sis.gui/bundle/bin/sisfx
index d4ab463fd5..4c3054a447 100755
--- a/optional/src/org.apache.sis.gui/bundle/bin/sisfx
+++ b/optional/src/org.apache.sis.gui/bundle/bin/sisfx
@@ -89,6 +89,7 @@ shopt -u nullglob
# Execute SIS with any optional JAR that the user may put in the `lib` directory.
#
java -splash:"$BASE_DIR/lib/logo.jpg" \
+ --enable-native-access javafx.graphics \
--module-path "$PATH_TO_FX:$BASE_DIR/lib:$BASE_DIR/lib/app/org.apache.sis.gui.jar" \
-Djava.util.logging.config.class="org.apache.sis.util.logging.Initializer" \
-Djava.util.logging.config.file="$BASE_DIR/conf/logging.properties" \
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/RecentFiles.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/RecentFiles.java
index dda531c721..e1a4894eb0 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/RecentFiles.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/RecentFiles.java
@@ -155,7 +155,7 @@ final class RecentFiles implements EventHandler<ActionEvent> {
} while (++i < MAX_COUNT-1);
System.arraycopy(allFiles, 0, allFiles, 1, i);
allFiles[0] = file;
- final StringJoiner s = new StringJoiner(System.lineSeparator());
+ final var s = new StringJoiner(System.lineSeparator());
for (final File f : allFiles) {
if (f == null) break;
s.add(f.getPath());
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/GridViewSkin.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/GridViewSkin.java
index a4fceba2a4..e2e6047f8c 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/GridViewSkin.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/GridViewSkin.java
@@ -475,7 +475,7 @@ final class GridViewSkin extends SkinBase<GridView> implements EventHandler<Mous
/**
* Resizes the given array of cells. If the array become longer, new labels are created.
- * This is an helper method for {@link #layoutChildren(double, double, double, double)}.
+ * This is a helper method for {@link #layoutChildren(double, double, double, double)}.
*
* @param cells the array to resize.
* @param count the desired number of elements.
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/LogViewer.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/LogViewer.java
index 5fdb1e8feb..9e4612ab17 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/LogViewer.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/LogViewer.java
@@ -21,7 +21,6 @@ import java.util.Date;
import java.util.Map;
import java.util.HashMap;
import java.util.ArrayList;
-import java.util.StringJoiner;
import java.util.function.Predicate;
import java.util.logging.Level;
import java.util.logging.LogRecord;
@@ -603,11 +602,7 @@ public class LogViewer extends Widget {
path.add(item.getValue());
item = item.getParent();
}
- final var joiner = new StringJoiner(".");
- for (int i = path.size(); --i >= 0;) {
- joiner.add(path.get(i));
- }
- return joiner.toString();
+ return String.join(".", path.reversed());
});
dialog.setResizable(true);
final DialogPane pane = dialog.getDialogPane();
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/metadata/IdentificationInfo.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/metadata/IdentificationInfo.java
index c92f390c2c..263afc1df2 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/metadata/IdentificationInfo.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/metadata/IdentificationInfo.java
@@ -290,7 +290,7 @@ final class IdentificationInfo extends Section<Identification> {
* is formatted as "codespace:code" or only "code" if there is no codespace.
*/
if (citation != null) {
- final StringJoiner buffer = new StringJoiner(", ");
+ final var buffer = new StringJoiner(", ");
for (final Identifier id : citation.getIdentifiers()) {
buffer.add(IdentifiedObjects.toString(id));
}
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/metadata/MetadataSummary.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/metadata/MetadataSummary.java
index 49dec24f81..de8c591e6c 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/metadata/MetadataSummary.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/metadata/MetadataSummary.java
@@ -353,7 +353,7 @@ public class MetadataSummary extends Widget {
* Returns all code lists in a comma-separated list.
*/
final String string(final Collection<? extends ControlledVocabulary> codes) {
- final StringJoiner buffer = new StringJoiner(", ");
+ final var buffer = new StringJoiner(", ");
for (final ControlledVocabulary c : codes) {
final String text = string(Types.getCodeTitle(c));
if (text != null) buffer.add(text);
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/CRSChooser.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/CRSChooser.java
index 5d01defd3e..9b49ea947b 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/CRSChooser.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/CRSChooser.java
@@ -56,8 +56,8 @@ import org.opengis.referencing.crs.CRSAuthorityFactory;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.Conversion;
import org.opengis.referencing.operation.OperationMethod;
+import org.apache.sis.referencing.CRS;
import org.apache.sis.referencing.IdentifiedObjects;
-import org.apache.sis.referencing.internal.shared.ReferencingUtilities;
import org.apache.sis.gui.internal.BackgroundThreads;
import org.apache.sis.gui.internal.ExceptionReporter;
import org.apache.sis.gui.internal.IdentityValueFactory;
@@ -387,7 +387,7 @@ public class CRSChooser extends Dialog<CoordinateReferenceSystem> {
expected = 0;
}
String text = Vocabulary.forLocale(locale).getString(key);
- final int dimension = ReferencingUtilities.getDimension(crs);
+ final int dimension = CRS.getDimensionOrZero(crs);
final boolean addDimension = (dimension != expected && expected != 0);
final boolean isProjection = (crs instanceof DerivedCRS);
if (addDimension | isProjection) {
diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/MenuSync.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/MenuSync.java
index 5bcb63d1f6..409812c2c7 100644
--- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/MenuSync.java
+++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/MenuSync.java
@@ -33,12 +33,12 @@ import javafx.scene.control.ToggleGroup;
import org.opengis.referencing.ReferenceSystem;
import org.opengis.referencing.crs.DerivedCRS;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.apache.sis.referencing.CRS;
import org.apache.sis.referencing.IdentifiedObjects;
-import org.apache.sis.referencing.internal.shared.ReferencingUtilities;
-import org.apache.sis.gui.internal.GUIUtilities;
-import org.apache.sis.gui.internal.Resources;
import org.apache.sis.referencing.gazetteer.GazetteerFactory;
import org.apache.sis.referencing.gazetteer.GazetteerException;
+import org.apache.sis.gui.internal.GUIUtilities;
+import org.apache.sis.gui.internal.Resources;
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.util.Utilities;
@@ -166,7 +166,7 @@ final class MenuSync extends SimpleObjectProperty<ReferenceSystem> implements Ev
private void initialize() {
for (final ReferenceSystem system : recentSystems) {
if (system instanceof CoordinateReferenceSystem) {
- if (ReferencingUtilities.getDimension((CoordinateReferenceSystem) system) == BIDIMENSIONAL) {
+ if (CRS.getDimensionOrZero((CoordinateReferenceSystem) system) == BIDIMENSIONAL) {
set(system);
break;
}