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 de7dadfd30c55147e1243f054d0111d6c3f5a160 Author: Martin Desruisseaux <[email protected]> AuthorDate: Thu Oct 2 16:23:40 2025 +0200 Remove the deprecated method related to math transform factory. --- .../internal/ParameterizedTransformBuilder.java | 17 + .../referencing/operation/DefaultConversion.java | 6 +- .../operation/projection/package-info.java | 15 +- .../GeocentricAffineBetweenGeographic.java | 15 +- .../operation/provider/MapProjection.java | 8 +- .../operation/transform/AbstractMathTransform.java | 51 +-- .../transform/DefaultMathTransformFactory.java | 425 +-------------------- .../operation/transform/MathTransformProvider.java | 26 +- .../transform/MathTransformFactoryMock.java | 2 - 9 files changed, 52 insertions(+), 513 deletions(-) diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/ParameterizedTransformBuilder.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/ParameterizedTransformBuilder.java index 3aec5d7e68..f1e10498d5 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/ParameterizedTransformBuilder.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/ParameterizedTransformBuilder.java @@ -19,6 +19,7 @@ package org.apache.sis.referencing.internal; import java.util.Map; import java.util.LinkedHashMap; import java.util.Collections; +import java.util.Optional; import java.util.OptionalInt; import java.util.logging.Level; import java.util.logging.LogRecord; @@ -288,6 +289,14 @@ public class ParameterizedTransformBuilder extends MathTransformBuilder implemen return (sourceCS != null) ? sourceCS.getClass() : CoordinateSystem.class; } + /** + * Returns the ellipsoid which is used together with the source coordinate system. + */ + @Override + public Optional<Ellipsoid> getSourceEllipsoid() { + return Optional.ofNullable(sourceEllipsoid); + } + /** * Returns the desired number of target dimensions of the transform to create. * This value is inferred from the target coordinate system if present. @@ -308,6 +317,14 @@ public class ParameterizedTransformBuilder extends MathTransformBuilder implemen return (targetCS != null) ? targetCS.getClass() : CoordinateSystem.class; } + /** + * Returns the ellipsoid which is used together with the target coordinate system. + */ + @Override + public Optional<Ellipsoid> getTargetEllipsoid() { + return Optional.ofNullable(targetEllipsoid); + } + /** * Returns the matrix that represent the affine transform to concatenate before or after * the parameterized transform. The {@code role} argument specifies which matrix is desired: 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 12a66c639c..8e3429579a 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 @@ -69,8 +69,8 @@ import org.opengis.referencing.crs.DerivedCRS; * derived or projected CRS themselves. This class provides a {@linkplain #DefaultConversion(Map, OperationMethod, * MathTransform, ParameterValueGroup) constructor} for such defining conversions. * - * <p>After the source and target CRS become known, we can invoke the {@link #specialize specialize(…)} method for - * {@linkplain DefaultMathTransformFactory#createParameterizedTransform creating a math transform from the parameters} + * <p>After the source and target CRS become known, we can invoke the {@link #specialize specialize(…)} method + * for {@linkplain DefaultMathTransformFactory#builder creating a math transform from the parameters} * and assign the source and target CRS to it.</p> * * <h2>Immutability and thread safety</h2> @@ -196,8 +196,6 @@ public class DefaultConversion extends AbstractSingleOperation implements Conver * @param method the operation method. * @param transform transform from positions in the source CRS to positions in the target CRS, or {@code null}. * @param parameters the {@code transform} parameter values, or {@code null}. - * - * @see DefaultMathTransformFactory#swapAndScaleAxes(MathTransform, MathTransformProvider.Context) */ @SuppressWarnings("this-escape") // False positive. public DefaultConversion(final Map<String,?> properties, diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/projection/package-info.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/projection/package-info.java index 7b28b53b7b..40b00fb16b 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/projection/package-info.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/projection/package-info.java @@ -19,18 +19,9 @@ * Map projection implementations. * This package should usually not be used directly. The best way to get a projection is to use the * {@linkplain org.apache.sis.referencing.operation.DefaultCoordinateOperationFactory coordinate operation factory} - * with the source and target CRS. That factory can bundle the projections defined in this package, together with any - * affine transform required for handling unit conversions and axis swapping, in a single (potentially concatenated) - * operation. - * - * <p>Users wanting to build their transforms directly should also avoid instantiating objects directly from this - * package and use a {@linkplain org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory math - * transform factory} instead. - * The {@link org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory#createParameterizedTransform - * createParameterizedTransform(…)} method of that factory is subjects to the same rules as this package, - * namely input coordinates must be (<var>longitude</var>, <var>latitude</var>) in decimal degrees - * and output coordinates must be (<var>easting</var>, <var>northing</var>) in metres. - * More on this convention is explained below.</p> + * with the source and target <abbr>CRS</abbr>. That factory can bundle the projections defined in this package, + * together with any affine transform required for handling unit conversions and axis swapping, + * in a single (potentially concatenated) operation. * * <p>Users wanting to know more about the available projections and their parameters should look at the * <a href="https://sis.apache.org/tables/CoordinateOperationMethods.html">list of coordinate operation methods</a>. diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/GeocentricAffineBetweenGeographic.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/GeocentricAffineBetweenGeographic.java index af29a5801d..64ca490cb4 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/GeocentricAffineBetweenGeographic.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/GeocentricAffineBetweenGeographic.java @@ -27,7 +27,6 @@ import org.opengis.referencing.operation.MathTransformFactory; import org.opengis.referencing.operation.NoninvertibleTransformException; import org.apache.sis.referencing.datum.DefaultEllipsoid; import org.apache.sis.referencing.operation.transform.EllipsoidToCentricTransform; -import org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory; import org.apache.sis.metadata.iso.citation.Citations; import org.apache.sis.parameter.ParameterBuilder; import org.apache.sis.parameter.Parameters; @@ -187,12 +186,7 @@ public abstract class GeocentricAffineBetweenGeographic extends GeocentricAffine * @throws ClassCastException if the unit of measurement of an axis length parameter is not linear. */ public static Ellipsoid getSourceEllipsoid(final Parameters values, final Context context) { - if (context instanceof DefaultMathTransformFactory.Context) { - // TODO: move getSourceEllipsoid() in `Context` interface with `Optional` return value. - Ellipsoid c = ((DefaultMathTransformFactory.Context) context).getSourceEllipsoid(); - if (c != null) return c; - } - return getEllipsoid("source", values, SRC_SEMI_MAJOR, SRC_SEMI_MINOR); + return context.getSourceEllipsoid().orElseGet(() -> getEllipsoid("source", values, SRC_SEMI_MAJOR, SRC_SEMI_MINOR)); } /** @@ -207,12 +201,7 @@ public abstract class GeocentricAffineBetweenGeographic extends GeocentricAffine * @throws ClassCastException if the unit of measurement of an axis length parameter is not linear. */ public static Ellipsoid getTargetEllipsoid(final Parameters values, final Context context) { - if (context instanceof DefaultMathTransformFactory.Context) { - // TODO: move getTargetEllipsoid() in `Context` interface with `Optional` return value. - Ellipsoid c = ((DefaultMathTransformFactory.Context) context).getTargetEllipsoid(); - if (c != null) return c; - } - return getEllipsoid("target", values, TGT_SEMI_MAJOR, TGT_SEMI_MINOR); + return context.getTargetEllipsoid().orElseGet(() -> getEllipsoid("target", values, TGT_SEMI_MAJOR, TGT_SEMI_MINOR)); } /** diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/MapProjection.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/MapProjection.java index 367f583827..e85b8fcaf9 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/MapProjection.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/MapProjection.java @@ -40,7 +40,6 @@ import org.apache.sis.referencing.IdentifiedObjects; import org.apache.sis.referencing.ImmutableIdentifier; import org.apache.sis.referencing.internal.Resources; import org.apache.sis.referencing.operation.projection.NormalizedProjection; -import org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory; import org.apache.sis.measure.MeasurementRange; import org.apache.sis.measure.Units; import org.apache.sis.metadata.iso.citation.Citations; @@ -249,12 +248,7 @@ public abstract class MapProjection extends AbstractProvider { * @throws ClassCastException if the unit of measurement of an axis length parameter is not linear. */ public static Ellipsoid getEllipsoid(final Parameters values, final Context context) { - if (context instanceof DefaultMathTransformFactory.Context) { - // TODO: move getSourceEllipsoid() in `Context` interface with `Optional` return value. - Ellipsoid c = ((DefaultMathTransformFactory.Context) context).getSourceEllipsoid(); - if (c != null) return c; - } - return getEllipsoid("source", values, SEMI_MAJOR, SEMI_MINOR); + return context.getSourceEllipsoid().orElseGet(() -> getEllipsoid("source", values, SEMI_MAJOR, SEMI_MINOR)); } /** diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java index 7bda380224..82d7417d89 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java @@ -27,7 +27,6 @@ import org.opengis.parameter.ParameterDescriptorGroup; import org.opengis.parameter.ParameterValueGroup; import org.opengis.referencing.operation.Matrix; import org.opengis.referencing.operation.MathTransform; -import org.opengis.referencing.operation.MathTransformFactory; import org.opengis.referencing.operation.TransformException; import org.opengis.referencing.operation.NoninvertibleTransformException; import org.opengis.referencing.operation.OperationMethod; @@ -85,7 +84,7 @@ import org.opengis.coordinate.MismatchedDimensionException; * running the same SIS version. * * @author Martin Desruisseaux (IRD, Geomatys) - * @version 1.5 + * @version 1.6 * * @see DefaultMathTransformFactory * @see org.apache.sis.referencing.operation.AbstractCoordinateOperation @@ -840,41 +839,6 @@ public abstract class AbstractMathTransform extends FormattableObject throw new NoninvertibleTransformException(Resources.format(Resources.Keys.NonInvertibleTransform)); } - /** - * Concatenates or pre-concatenates in an optimized way this math transform with the given one, if possible. - * If an optimization is possible, a new math transform is created to perform the combined transformation. - * The {@code applyOtherFirst} value determines the transformation order as bellow: - * - * <ul> - * <li>If {@code applyOtherFirst} is {@code true}, then transforming a point - * <var>p</var> by the combined transform is equivalent to first transforming - * <var>p</var> by {@code other} and then transforming the result by {@code this}.</li> - * <li>If {@code applyOtherFirst} is {@code false}, then transforming a point - * <var>p</var> by the combined transform is equivalent to first transforming - * <var>p</var> by {@code this} and then transforming the result by {@code other}.</li> - * </ul> - * - * If no optimization is available for the combined transform, then this method returns {@code null}. - * - * @param applyOtherFirst {@code true} if the transformation order is {@code other} followed by {@code this}, or - * {@code false} if the transformation order is {@code this} followed by {@code other}. - * @param other the other math transform to (pre-)concatenate with this transform. - * @param factory the factory which is (indirectly) invoking this method, or {@code null} if none. - * @return the math transforms combined in an optimized way, or {@code null} if no such optimization is available. - * @throws FactoryException if an error occurred while combining the transforms. - * - * @since 0.8 - * - * @deprecated Replaced by {@link #tryConcatenate(TransformJoiner)}. - * See <a href="https://issues.apache.org/jira/browse/SIS-595">SIS-595</a>. - */ - @Deprecated(forRemoval=true, since="1.5") - protected MathTransform tryConcatenate(boolean applyOtherFirst, MathTransform other, MathTransformFactory factory) - throws FactoryException - { - return null; - } - /** * Concatenates in an optimized way this math transform with its neighbor, if possible. * If an optimization is possible, a new {@link MathTransform} is created to perform a calculation @@ -897,19 +861,6 @@ public abstract class AbstractMathTransform extends FormattableObject * @since 1.5 */ protected void tryConcatenate(final TransformJoiner context) throws FactoryException { - // TODO: make this method empty after the deprecated method has been removed. - if (context.replacement == null) { - boolean applyOtherFirst = false; - do { - final MathTransform other = context.getTransform(applyOtherFirst ? -1 : +1).orElse(null); - if (other != null) { - context.replacement = tryConcatenate(applyOtherFirst, other, context.factory); - if (context.replacement != null) { - break; - } - } - } while ((applyOtherFirst = !applyOtherFirst) == true); - } } /** diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java index 599f18d30e..a3cb351e41 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java @@ -24,14 +24,8 @@ import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicReference; -import java.util.logging.Level; -import java.io.Serializable; import java.lang.reflect.Constructor; -import org.opengis.parameter.ParameterValueGroup; import org.opengis.parameter.ParameterNotFoundException; -import org.opengis.referencing.crs.GeodeticCRS; -import org.opengis.referencing.cs.CoordinateSystem; -import org.opengis.referencing.cs.EllipsoidalCS; import org.opengis.referencing.datum.Ellipsoid; import org.opengis.referencing.operation.Matrix; import org.opengis.referencing.operation.MathTransform; @@ -45,7 +39,6 @@ import org.apache.sis.util.ArgumentChecks; import org.apache.sis.util.internal.shared.Constants; import org.apache.sis.util.iso.AbstractFactory; import org.apache.sis.util.collection.WeakHashSet; -import org.apache.sis.referencing.datum.DatumOrEnsemble; import org.apache.sis.referencing.internal.ParameterizedTransformBuilder; import org.apache.sis.referencing.internal.shared.CoordinateOperations; import org.apache.sis.referencing.operation.DefaultOperationMethod; @@ -135,7 +128,7 @@ import org.apache.sis.referencing.operation.matrix.Matrices; * There is typically only one {@code MathTransformFactory} instance for the whole application. * * @author Martin Desruisseaux (Geomatys, IRD) - * @version 1.5 + * @version 1.6 * * @see MathTransformProvider * @see AbstractMathTransform @@ -486,422 +479,6 @@ public class DefaultMathTransformFactory extends AbstractFactory implements Math return new ParameterizedTransformBuilder(this, getOperationMethod(method)); } - /** - * Source and target coordinate systems for which a new parameterized transform is going to be used. - * - * @author Martin Desruisseaux (Geomatys) - * @version 1.5 - * @since 0.7 - * - * @deprecated Replaced by {@link #builder(String)}. - */ - @SuppressWarnings("serial") - @Deprecated(since="1.5", forRemoval=true) - public static class Context implements MathTransformProvider.Context, Serializable { - /** - * The factory to use if the provider needs to create other math transforms as operation steps. - * - * @see #getFactory() - */ - private transient DefaultMathTransformFactory factory; - - /** - * Coordinate system of the source or target points. - */ - private CoordinateSystem sourceCS, targetCS; - - /** - * The ellipsoid of the source or target ellipsoidal coordinate system, or {@code null} if it does not apply. - */ - private Ellipsoid sourceEllipsoid, targetEllipsoid; - - /** - * The builder, created when first needed. - */ - private ParameterizedTransformBuilder builder; - - /** - * The parameters actually used. - */ - private ParameterValueGroup parameters; - - /** - * Creates a new context with all properties initialized to {@code null}. - */ - public Context() { - } - - /** - * Sets the source coordinate system to the given value. - * The source ellipsoid is unconditionally set to {@code null}. - * - * @param cs the coordinate system to set as the source (can be {@code null}). - * @deprecated Replaced by {@link MathTransform.Builder#setSourceAxes(CoordinateSystem, Ellipsoid)}. - */ - @Deprecated(since="1.5", forRemoval=true) - public void setSource(final CoordinateSystem cs) { - sourceCS = cs; - sourceEllipsoid = null; - builder = null; - } - - /** - * Sets the source coordinate system and related ellipsoid to the components of given CRS. - * The {@link Ellipsoid}, fetched from the geodetic reference frame, is often used together with an {@link EllipsoidalCS}, - * but not necessarily. The geodetic CRS may also be associated with a spherical or Cartesian coordinate system, - * and the ellipsoid information may still be needed even with those non-ellipsoidal coordinate systems. - * - * <p><strong>This method is not for datum shifts.</strong> - * All datum information other than the ellipsoid are ignored.</p> - * - * @param crs the coordinate system and ellipsoid to set as the source, or {@code null}. - * - * @since 1.3 - * @deprecated Replaced by {@link MathTransform.Builder#setSourceAxes(CoordinateSystem, Ellipsoid)}. - */ - @Deprecated(since="1.5", forRemoval=true) - public void setSource(final GeodeticCRS crs) { - if (crs != null) { - sourceCS = crs.getCoordinateSystem(); - sourceEllipsoid = DatumOrEnsemble.getEllipsoid(crs).orElse(null); - } else { - sourceCS = null; - sourceEllipsoid = null; - } - builder = null; - } - - /** - * Sets the target coordinate system to the given value. - * The target ellipsoid is unconditionally set to {@code null}. - * - * @param cs the coordinate system to set as the target (can be {@code null}). - * @deprecated Replaced by {@link MathTransform.Builder#setTargetAxes(CoordinateSystem, Ellipsoid)}. - */ - @Deprecated(since="1.5", forRemoval=true) - public void setTarget(final CoordinateSystem cs) { - targetCS = cs; - targetEllipsoid = null; - builder = null; - } - - /** - * Sets the target coordinate system and related ellipsoid to the components of given CRS. - * The {@link Ellipsoid}, fetched from the geodetic reference frame, is often used together with an {@link EllipsoidalCS}, - * but not necessarily. The geodetic CRS may also be associated with a spherical or Cartesian coordinate system, - * and the ellipsoid information may still be needed even with those non-ellipsoidal coordinate systems. - * - * <p><strong>This method is not for datum shifts.</strong> - * All datum information other than the ellipsoid are ignored.</p> - * - * @param crs the coordinate system and ellipsoid to set as the target, or {@code null}. - * - * @since 1.3 - * @deprecated Replaced by {@link MathTransform.Builder#setTargetAxes(CoordinateSystem, Ellipsoid)}. - */ - @Deprecated(since="1.5", forRemoval=true) - public void setTarget(final GeodeticCRS crs) { - if (crs != null) { - targetCS = crs.getCoordinateSystem(); - targetEllipsoid = DatumOrEnsemble.getEllipsoid(crs).orElse(null); - } else { - targetCS = null; - targetEllipsoid = null; - } - builder = null; - } - - /** - * Returns the source coordinate system, or {@code null} if unspecified. - * - * @return the source coordinate system, or {@code null}. - */ - public CoordinateSystem getSourceCS() { - return sourceCS; - } - - /** - * Returns the ellipsoid used together with the source coordinate system, or {@code null} if none. - * - * @return the ellipsoid used together with the source coordinate system, or {@code null} if none. - */ - public Ellipsoid getSourceEllipsoid() { - return sourceEllipsoid; - } - - /** - * Returns the target coordinate system, or {@code null} if unspecified. - * - * @return the target coordinate system, or {@code null}. - */ - public CoordinateSystem getTargetCS() { - return targetCS; - } - - /** - * Returns the ellipsoid used together with the target coordinate system, or {@code null} if none. - * - * @return the ellipsoid used together with the target coordinate system, or {@code null} if none. - */ - public Ellipsoid getTargetEllipsoid() { - return targetEllipsoid; - } - - /** - * Returns the builder to which to delegate the {@code MathTransform} creation. - */ - final ParameterizedTransformBuilder builder() throws FactoryException { - if (builder == null) { - if (factory == null) { - factory = provider(); - } - builder = new ParameterizedTransformBuilder(factory, null); - if (parameters != null) { - builder.setParameters(parameters, false); - } - } - return builder; - } - - /** - * Returns the matrix that represent the affine transform to concatenate before or after - * the parameterized transform. The {@code role} argument specifies which matrix is desired: - * - * <ul class="verbose"> - * <li>{@link org.apache.sis.referencing.operation.transform.ContextualParameters.MatrixRole#NORMALIZATION - * NORMALIZATION} for the conversion from the {@linkplain #getSourceCS() source coordinate system} to - * a {@linkplain AxesConvention#NORMALIZED normalized} coordinate system, usually with - * (<var>longitude</var>, <var>latitude</var>) axis order in degrees or - * (<var>easting</var>, <var>northing</var>) in metres. - * This normalization needs to be applied <em>before</em> the parameterized transform.</li> - * - * <li>{@link org.apache.sis.referencing.operation.transform.ContextualParameters.MatrixRole#DENORMALIZATION - * DENORMALIZATION} for the conversion from a normalized coordinate system to the - * {@linkplain #getTargetCS() target coordinate system}, for example with - * (<var>latitude</var>, <var>longitude</var>) axis order. - * This denormalization needs to be applied <em>after</em> the parameterized transform.</li> - * - * <li>{@link org.apache.sis.referencing.operation.transform.ContextualParameters.MatrixRole#INVERSE_NORMALIZATION INVERSE_NORMALIZATION} and - * {@link org.apache.sis.referencing.operation.transform.ContextualParameters.MatrixRole#INVERSE_DENORMALIZATION INVERSE_DENORMALIZATION} - * are also supported but rarely used.</li> - * </ul> - * - * This method is invoked by {@link DefaultMathTransformFactory#swapAndScaleAxes(MathTransform, Context)}. - * Users can override this method if they need to customize the normalization process. - * - * @param role whether the normalization or denormalization matrix is desired. - * @return the requested matrix, or {@code null} if this {@code Context} has no information about the coordinate system. - * @throws FactoryException if an error occurred while computing the matrix. - * - * @see DefaultMathTransformFactory#createAffineTransform(Matrix) - * @see DefaultMathTransformFactory#createParameterizedTransform(ParameterValueGroup, Context) - */ - @SuppressWarnings("fallthrough") - public Matrix getMatrix(final ContextualParameters.MatrixRole role) throws FactoryException { - return builder().getMatrix(role); - } - - /** - * Returns the operation method used for the math transform creation. - * This is the same information as {@link #getLastMethodUsed()} but more stable - * (not affected by transforms created with other contexts). - * - * @return the operation method used by the factory. - * @throws IllegalStateException if {@link #createParameterizedTransform(ParameterValueGroup, Context)} - * has not yet been invoked. - * - * @deprecated Replaced by {@link MathTransform.Builder#getMethod()}. - * - * @since 1.3 - */ - @Deprecated(since="1.5", forRemoval=true) - public OperationMethod getMethodUsed() { - return (builder != null) ? builder.getMethod().orElse(null) : null; - } - - /** - * Returns the names of parameters that have been inferred from the context. - * The set of keys can contain any of {@code "dim"}, - * {@code "semi_major"}, {@code "semi_minor"}, - * {@code "src_semi_major"}, {@code "src_semi_minor"}, - * {@code "tgt_semi_major"}, {@code "tgt_semi_minor"} and/or - * {@code "inverse_flattening"}, depending on the operation method used. - * The parameters named in that set are included in the parameters - * returned by {@link #getCompletedParameters()}. - * - * <h4>Associated Boolean values</h4> - * The associated Boolean in the map tells whether the named parameter value is really contextual. - * The Boolean is {@code FALSE} if the user explicitly specified a value in the parameters given to - * the {@link #createParameterizedTransform(ParameterValueGroup, Context)} method, - * and that value is different than the value inferred from the context. - * Such inconsistencies are also logged at {@link Level#WARNING}. - * In all other cases - * (no value specified by the user, or a value was specified but is consistent with the context), - * the associated Boolean in the map is {@code TRUE}. - * - * @deprecated Replaced by {@link MathTransformProvider.Context#getContextualParameters()}. - * - * @return names of parameters inferred from context. - * - * @since 1.3 - */ - @Override - @Deprecated(since="1.5", forRemoval=true) - public Map<String,Boolean> getContextualParameters() { - try { - return builder().getContextualParameters(); - } catch (FactoryException e) { - throw new IllegalStateException(MESSAGE, e); - } - } - - /** - * Returns the parameter values used for the math transform creation, - * including the parameters completed by the factory. - * This is the union of {@link #parameters} with {@link #getContextualParameters()}. - * The completed parameters may only have additional parameters compared to the user-supplied parameters. - * Parameter values that were explicitly set by the user are not overwritten. - * - * <p>After this method has been invoked, the {@link #setSourceAxes setSourceAxes(…)} - * and {@link #setTargetAxes setTargetAxes(…)} methods can no longer be invoked.</p> - * - * @deprecated Replaced by {@link MathTransformProvider.Context#getCompletedParameters()}. - * - * @return the parameter values used by the factory. - */ - @Override - @Deprecated(since="1.5", forRemoval=true) - public ParameterValueGroup getCompletedParameters() { - try { - return builder().getCompletedParameters(); - } catch (FactoryException e) { - throw new IllegalStateException(MESSAGE, e); - } - } - - /** - * The "{@code createParameterizedTransform} has not been invoked" error message. - */ - private static final String MESSAGE = "createParameterizedTransform has not been invoked."; - - /** - * Returns a string representation of this context for debugging purposes. - * The current implementation writes the name of source/target coordinate systems and ellipsoids. - * If the {@linkplain #getContextualParameters() contextual parameters} have already been inferred, - * then their names are appended with inconsistent parameters (if any) written on a separated line. - * - * @return a string representation of this context. - */ - @Override - public String toString() { - return (builder != null) ? builder.toString() : super.toString(); - } - } - - /** - * Creates a transform from a group of parameters and a context. - * - * @param parameters the parameter values. - * @param context information about the context, or {@code null} if none. - * @return the transform created from the given parameters. - * @throws NoSuchIdentifierException if there is no method for the given parameter group name. - * @throws FactoryException if the object creation failed. - * @deprecated Replaced by a builder pattern with {@link #builder(String)}. - */ - @Deprecated(since="1.5", forRemoval=true) - public MathTransform createParameterizedTransform(final ParameterValueGroup parameters, - final Context context) throws NoSuchIdentifierException, FactoryException - { - context.builder = null; - context.factory = this; - context.parameters = parameters; - return context.builder().create(); - } - - /** - * Given a transform between normalized spaces, - * creates a transform taking in account axis directions, units of measurement and longitude rotation. - * This method {@linkplain #createConcatenatedTransform concatenates} the given parameterized transform - * with any other transform required for performing units changes and coordinates swapping. - * - * <p>The given {@code parameterized} transform shall expect - * {@linkplain org.apache.sis.referencing.cs.AxesConvention#NORMALIZED normalized} input coordinates and - * produce normalized output coordinates. See {@link org.apache.sis.referencing.cs.AxesConvention} for more - * information about what Apache SIS means by "normalized".</p> - * - * <h4>Example</h4> - * The most typical examples of transforms with normalized inputs/outputs are normalized - * map projections expecting (<var>longitude</var>, <var>latitude</var>) inputs in degrees - * and calculating (<var>x</var>, <var>y</var>) coordinates in metres, - * both of them with ({@linkplain org.opengis.referencing.cs.AxisDirection#EAST East}, - * {@linkplain org.opengis.referencing.cs.AxisDirection#NORTH North}) axis orientations. - * - * <h4>Controlling the normalization process</h4> - * Users who need a different normalized space than the default one may find more convenient to - * override the {@link Context#getMatrix Context.getMatrix(ContextualParameters.MatrixRole)} method. - * - * @param parameterized a transform for normalized input and output coordinates. - * @param context source and target coordinate systems in which the transform is going to be used. - * @return a transform taking in account unit conversions and axis swapping. - * @throws FactoryException if the object creation failed. - * - * @see org.apache.sis.referencing.cs.AxesConvention#NORMALIZED - * @see org.apache.sis.referencing.operation.DefaultConversion#DefaultConversion(Map, OperationMethod, MathTransform, ParameterValueGroup) - * - * @since 0.7 - * - * @deprecated Considered internal API because the definition of "normalized" is implementation-dependent. - */ - @Deprecated(since="1.5", forRemoval=true) - public MathTransform swapAndScaleAxes(final MathTransform parameterized, final Context context) throws FactoryException { - context.builder = null; - context.factory = this; - return context.builder().swapAndScaleAxes(parameterized); - } - - /** - * Creates a math transform that represent a change of coordinate system. If exactly one argument is - * an {@linkplain org.apache.sis.referencing.cs.DefaultEllipsoidalCS ellipsoidal coordinate systems}, - * then the {@code ellipsoid} argument is mandatory. In all other cases (including the case where both - * coordinate systems are ellipsoidal), the ellipsoid argument is ignored and can be {@code null}. - * - * <h4>Design note</h4> - * This method does not accept separated ellipsoid arguments for {@code source} and {@code target} because - * this method should not be used for datum shifts. If the two given coordinate systems are ellipsoidal, - * then they are assumed to use the same ellipsoid. If different ellipsoids are desired, then a - * {@linkplain #createParameterizedTransform parameterized transform} like <q>Molodensky</q>, - * <q>Geocentric translations</q>, <q>Coordinate Frame Rotation</q> or - * <q>Position Vector transformation</q> should be used instead. - * - * @param source the source coordinate system. - * @param target the target coordinate system. - * @param ellipsoid the ellipsoid of {@code EllipsoidalCS}, or {@code null} if none. - * @return a conversion from the given source to the given target coordinate system. - * @throws FactoryException if the conversion cannot be created. - * - * @since 0.8 - * - * @deprecated Replaced by the following pattern: - * - * {@snippet lang="java" : - * var builder = builder("Coordinate system conversion"); - * builder.setSourceAxes(source, ellipsoid); - * builder.setTargetAxes(target, ellipsoid); - * return builder.create(); - * } - */ - @Deprecated(since="1.5", forRemoval=true) - public MathTransform createCoordinateSystemChange(final CoordinateSystem source, final CoordinateSystem target, - final Ellipsoid ellipsoid) throws FactoryException - { - ArgumentChecks.ensureNonNull("source", source); - ArgumentChecks.ensureNonNull("target", target); - final var builder = builder(Constants.COORDINATE_SYSTEM_CONVERSION); - builder.setSourceAxes(source, ellipsoid); - builder.setTargetAxes(target, ellipsoid); - return builder.create(); - } - /** * Creates an affine transform from a matrix. If the transform input dimension is {@code M}, * and output dimension is {@code N}, then the matrix will have size {@code [N+1][M+1]}. The diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/MathTransformProvider.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/MathTransformProvider.java index 6b551af0aa..2523675f2c 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/MathTransformProvider.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/MathTransformProvider.java @@ -17,12 +17,14 @@ package org.apache.sis.referencing.operation.transform; import java.util.Map; +import java.util.Optional; import java.util.OptionalInt; import org.opengis.util.FactoryException; import org.opengis.parameter.ParameterValueGroup; import org.opengis.parameter.ParameterNotFoundException; import org.opengis.parameter.InvalidParameterNameException; import org.opengis.parameter.InvalidParameterValueException; +import org.opengis.referencing.datum.Ellipsoid; import org.opengis.referencing.cs.CoordinateSystem; import org.opengis.referencing.operation.MathTransform; import org.opengis.referencing.operation.MathTransformFactory; @@ -159,7 +161,7 @@ public interface MathTransformProvider { * and concatenating the affine steps. * * @author Martin Desruisseaux (Geomatys) - * @version 1.5 + * @version 1.6 * @since 1.5 */ public interface Context { @@ -234,6 +236,28 @@ public interface MathTransformProvider { return CoordinateSystem.class; } + /** + * Returns the ellipsoid which is used together with the source coordinate system. + * + * @return the ellipsoid which is used together with the source coordinate system, or empty if none. + * + * @since 1.6 + */ + default Optional<Ellipsoid> getSourceEllipsoid() { + return Optional.empty(); + } + + /** + * Returns the ellipsoid which is used together with the target coordinate system. + * + * @return the ellipsoid which is used together with the target coordinate system, or empty if none. + * + * @since 1.6 + */ + default Optional<Ellipsoid> getTargetEllipsoid() { + return Optional.empty(); + } + /** * Returns the names of parameters that have been inferred from the context. * The set of keys can contain any of {@code "dim"}, diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformFactoryMock.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformFactoryMock.java index 037d6c57fa..d36eb0e730 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformFactoryMock.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformFactoryMock.java @@ -52,8 +52,6 @@ public final class MathTransformFactoryMock implements MathTransformFactory { /** * Parameters used during the last creation of a math transform. * Stored for allowing callers to verify the parameters if needed. - * - * @see #createParameterizedTransform(ParameterValueGroup) */ public ParameterValueGroup lastParameters;
