This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push: new 9c13d9f4f6 Removal of deprecated methods. - MathTransformFactory.createParameterizedTransform — replaced by builder. - CoordinateOperationFactory.createOperation(sourceCRS, targetCRS) — replaced by RegisterOperations. 9c13d9f4f6 is described below commit 9c13d9f4f601e89bb61fa269edf55d82a2b6cf62 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Wed Jul 10 12:30:50 2024 +0200 Removal of deprecated methods. - MathTransformFactory.createParameterizedTransform — replaced by builder. - CoordinateOperationFactory.createOperation(sourceCRS, targetCRS) — replaced by RegisterOperations. --- .../metadata/iso/extent/DefaultVerticalExtent.java | 4 +- .../sis/metadata/privy/ReferencingServices.java | 12 +- .../main/org/apache/sis/portrayal/Canvas.java | 2 +- .../main/org/apache/sis/geometry/Envelopes.java | 5 +- .../referencing/internal/PositionTransformer.java | 27 +++-- .../referencing/internal/ServicesForMetadata.java | 18 +-- .../DefaultCoordinateOperationFactory.java | 51 -------- .../transform/DefaultMathTransformFactory.java | 131 --------------------- .../referencing/privy/GeodeticObjectBuilder.java | 9 +- .../DefaultCoordinateOperationFactoryTest.java | 8 +- .../projection/AuthalicConversionTest.java | 7 +- .../operation/projection/EquirectangularTest.java | 4 +- .../projection/MapProjectionTestCase.java | 5 +- .../operation/projection/MercatorTest.java | 4 +- .../operation/projection/MeridianArcTest.java | 5 +- .../projection/PolarStereographicTest.java | 4 +- .../operation/projection/ProjectionBenchmark.java | 2 +- .../projection/SatelliteTrackingTest.java | 2 +- .../operation/projection/ZonedGridSystemTest.java | 4 +- .../provider/GeocentricTranslationTest.java | 2 +- .../operation/provider/Geographic3Dto2DTest.java | 12 +- .../transform/DefaultMathTransformFactoryTest.java | 5 +- .../transform/MathTransformFactoryBase.java | 29 ----- .../transform/MathTransformFactoryMock.java | 60 ---------- .../transform/MolodenskyTransformTest.java | 5 +- .../test/integration/CoordinateOperationTest.java | 7 +- .../apache/sis/storage/landsat/MetadataReader.java | 17 +-- geoapi/snapshot | 2 +- 28 files changed, 90 insertions(+), 353 deletions(-) diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java index d16a4b27a3..04185e917c 100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java @@ -329,9 +329,7 @@ public class DefaultVerticalExtent extends ISOMetadata implements VerticalExtent */ private MathTransform1D getConversionFrom(final VerticalCRS source) throws FactoryException { if (!Utilities.equalsIgnoreMetadata(verticalCRS, source) && verticalCRS != null && source != null) { - final MathTransform1D cv = (MathTransform1D) ReferencingServices.getInstance() - .getCoordinateOperationFactory().createOperation(source, verticalCRS) - .getMathTransform(); + final MathTransform1D cv = ReferencingServices.getInstance().findTransform(source, verticalCRS); if (!cv.isIdentity()) { return cv; } diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/privy/ReferencingServices.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/privy/ReferencingServices.java index eed74e2426..b62e674a47 100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/privy/ReferencingServices.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/privy/ReferencingServices.java @@ -24,7 +24,8 @@ import org.opengis.geometry.Envelope; import org.opengis.geometry.DirectPosition; import org.opengis.parameter.ParameterDescriptor; import org.opengis.referencing.IdentifiedObject; -import org.opengis.referencing.operation.CoordinateOperationFactory; +import org.opengis.referencing.crs.VerticalCRS; +import org.opengis.referencing.operation.MathTransform1D; import org.opengis.referencing.operation.TransformException; import org.opengis.util.FactoryException; import org.apache.sis.metadata.iso.extent.DefaultExtent; @@ -272,11 +273,14 @@ public class ReferencingServices extends OptionalDependency { } /** - * Returns the default coordinate operation factory. + * Returns transform between a pair of vertical CRS. * - * @return the coordinate operation factory to use. + * @param source first CRS. + * @param target second CRS. + * @return transform between the given pair of CRS. + * @throws FactoryException if the transform cannot be found. */ - public CoordinateOperationFactory getCoordinateOperationFactory() { + public MathTransform1D findTransform(VerticalCRS source, VerticalCRS target) throws FactoryException { throw moduleNotFound(); } 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 d174280828..363dc5f7ca 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 @@ -1200,7 +1200,7 @@ public class Canvas extends Observable implements Localized { */ private CoordinateOperation objectiveToGeographic(final CoordinateReferenceSystem crs) throws FactoryException { final GeographicCRS geoCRS = ReferencingUtilities.toNormalizedGeographicCRS(crs, false, false); - return (geoCRS != null) ? coordinateOperationFactory.createOperation(crs, geoCRS) : null; + return (geoCRS != null) ? coordinateOperationFactory.createOperation(crs, geoCRS, null) : null; } /** diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/Envelopes.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/Envelopes.java index 8ab34a9fa6..0a8a44e9cf 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/Envelopes.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/geometry/Envelopes.java @@ -47,7 +47,6 @@ import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox; import org.apache.sis.referencing.CRS; import org.apache.sis.referencing.operation.AbstractCoordinateOperation; import org.apache.sis.referencing.operation.transform.AbstractMathTransform; -import org.apache.sis.referencing.operation.DefaultCoordinateOperationFactory; import org.apache.sis.metadata.privy.ReferencingServices; import org.apache.sis.referencing.privy.CoordinateOperations; import org.apache.sis.referencing.privy.DirectPositionView; @@ -356,7 +355,7 @@ public final class Envelopes extends Static { // See https://issues.apache.org/jira/browse/SIS-442 final CoordinateOperation operation; try { - operation = DefaultCoordinateOperationFactory.provider().createOperation(sourceCRS, targetCRS); + operation = CRS.findOperation(sourceCRS, targetCRS, null); } catch (FactoryException exception) { throw new TransformException(Errors.format(Errors.Keys.CanNotTransformEnvelope), exception); } @@ -634,7 +633,7 @@ nextPoint: for (int pointIndex = 0;;) { // Break condition at th */ final MathTransform mt; try { - mt = DefaultCoordinateOperationFactory.provider().createOperation(crs, sourceCRS).getMathTransform(); + mt = CRS.findOperation(crs, sourceCRS, null).getMathTransform(); } catch (FactoryException e) { throw new TransformException(Errors.format(Errors.Keys.CanNotTransformEnvelope), e); } 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 5604b1889c..a647fe9ace 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 @@ -17,30 +17,31 @@ package org.apache.sis.referencing.internal; import java.util.Objects; +import java.util.NoSuchElementException; import org.opengis.util.FactoryException; import org.opengis.geometry.DirectPosition; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.referencing.operation.CoordinateOperation; -import org.opengis.referencing.operation.CoordinateOperationFactory; import org.opengis.referencing.operation.MathTransform; import org.opengis.referencing.operation.Matrix; import org.opengis.referencing.operation.TransformException; -import org.apache.sis.referencing.operation.DefaultCoordinateOperationFactory; +import org.apache.sis.referencing.MultiRegisterOperations; import org.apache.sis.referencing.operation.transform.MathTransforms; import org.apache.sis.geometry.GeneralDirectPosition; import org.apache.sis.util.Utilities; // Specific to the geoapi-3.1 and geoapi-4.0 branches: import org.opengis.coordinate.MismatchedDimensionException; +import org.opengis.referencing.RegisterOperations; /** - * A direct position capable to {@linkplain #transform transform} another position from its arbitrary CRS to - * {@linkplain #getCoordinateReferenceSystem() the CRS of this position}. This class caches the last transform - * used in order to improve performance when {@linkplain CoordinateOperation#getSourceCRS() source} - * and {@linkplain CoordinateOperation#getTargetCRS() target} CRS do not change often. - * Using this class is faster than invoking <code>{@linkplain CoordinateOperationFactory#createOperation - * CoordinateOperationFactory.createOperation}(lastCRS, targetCRS)</code> for every points. + * A direct position capable to transform another position from its arbitrary CRS to the CRS of this position. + * This class caches the last transform used in order to improve performance when + * {@linkplain CoordinateOperation#getSourceCRS() source} and + * {@linkplain CoordinateOperation#getTargetCRS() target} CRS do not change often. + * Using this class is faster than invoking <code>{@linkplain RegisterOperations#findCoordinateOperations + * RegisterOperations.findCoordinateOperations}(lastCRS, targetCRS)</code> for every points. * * <ul class="verbose"> * <li><b>Note 1:</b> @@ -87,7 +88,7 @@ public final class PositionTransformer extends GeneralDirectPosition { /** * The factory to use for creating new coordinate operation. */ - private final CoordinateOperationFactory factory; + private final RegisterOperations factory; /** * The default CRS to assume when {@link #transform(DirectPosition)} has been invoked without associated CRS. @@ -126,11 +127,11 @@ public final class PositionTransformer extends GeneralDirectPosition { * @param factory the factory to use for creating coordinate operations, or {@code null} for the default. */ public PositionTransformer(final CoordinateReferenceSystem defaultCRS, final CoordinateReferenceSystem targetCRS, - final CoordinateOperationFactory factory) + final RegisterOperations factory) { super(targetCRS); this.defaultCRS = (defaultCRS != null) ? defaultCRS : targetCRS; - this.factory = (factory != null) ? factory : DefaultCoordinateOperationFactory.provider(); + this.factory = (factory != null) ? factory : MultiRegisterOperations.provider(); } /** @@ -160,8 +161,8 @@ public final class PositionTransformer extends GeneralDirectPosition { final CoordinateReferenceSystem targetCRS = getCoordinateReferenceSystem(); final CoordinateOperation operation; try { - operation = factory.createOperation(crs, targetCRS); - } catch (FactoryException exception) { + operation = factory.findCoordinateOperations(crs, targetCRS).iterator().next(); + } catch (FactoryException | NoSuchElementException exception) { throw new TransformException(exception.getLocalizedMessage(), exception); } /* diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/ServicesForMetadata.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/ServicesForMetadata.java index 4a6635c71b..7c6eb1fd3a 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/ServicesForMetadata.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/ServicesForMetadata.java @@ -31,9 +31,9 @@ import org.opengis.referencing.crs.VerticalCRS; import org.opengis.referencing.crs.GeographicCRS; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.referencing.cs.CoordinateSystem; +import org.opengis.referencing.operation.MathTransform1D; import org.opengis.referencing.operation.TransformException; import org.opengis.referencing.operation.CoordinateOperation; -import org.opengis.referencing.operation.CoordinateOperationFactory; import org.opengis.metadata.citation.Citation; import org.opengis.metadata.citation.OnLineFunction; import org.opengis.metadata.citation.OnlineResource; @@ -52,7 +52,6 @@ import org.apache.sis.referencing.IdentifiedObjects; import org.apache.sis.referencing.privy.AxisDirections; import org.apache.sis.referencing.privy.TemporalAccessor; import org.apache.sis.referencing.privy.ReferencingUtilities; -import org.apache.sis.referencing.operation.DefaultCoordinateOperationFactory; import org.apache.sis.parameter.DefaultParameterDescriptor; import org.apache.sis.metadata.iso.extent.DefaultExtent; import org.apache.sis.metadata.iso.extent.DefaultVerticalExtent; @@ -127,9 +126,8 @@ public final class ServicesForMetadata extends ReferencingServices { !Utilities.equalsIgnoreMetadata(cs2.getAxis(1), cs1.getAxis(1))) { final CoordinateOperation operation; - final CoordinateOperationFactory factory = DefaultCoordinateOperationFactory.provider(); try { - operation = factory.createOperation(crs, normalizedCRS); + operation = CRS.findOperation(crs, normalizedCRS, null); } catch (FactoryException e) { if (findOpCaller != null) { // See javadoc for the assumption that optional mode is used by Envelopes.findOperation(…). @@ -471,14 +469,18 @@ public final class ServicesForMetadata extends ReferencingServices { return new CoordinateFormat(locale, timezone); } + /** - * Returns the default coordinate operation factory. + * Returns transform between a pair of vertical CRS. * - * @return the coordinate operation factory to use. + * @param source first CRS. + * @param target second CRS. + * @return transform between the given pair of CRS. + * @throws FactoryException if the transform cannot be found. */ @Override - public CoordinateOperationFactory getCoordinateOperationFactory() { - return DefaultCoordinateOperationFactory.provider(); + public MathTransform1D findTransform(final VerticalCRS source, final VerticalCRS target) throws FactoryException { + return (MathTransform1D) CRS.findOperation(source, target, null).getMathTransform(); } /** diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java index 4064e84ed3..17b4758b75 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java @@ -656,28 +656,6 @@ next: for (int i=components.size(); --i >= 0;) { return single; } - /** - * Finds or creates an operation for conversion or transformation between two coordinate reference systems. - * If an operation exists, it is returned. If more than one operation exists, the operation having the widest - * domain of validity is returned. If no operation exists, then an exception is thrown. - * - * <p>The default implementation delegates to <code>{@linkplain #createOperation(CoordinateReferenceSystem, - * CoordinateReferenceSystem, CoordinateOperationContext) createOperation}(sourceCRS, targetCRS, null)}</code>.</p> - * - * @param sourceCRS input coordinate reference system. - * @param targetCRS output coordinate reference system. - * @return a coordinate operation from {@code sourceCRS} to {@code targetCRS}. - * @throws OperationNotFoundException if no operation path was found from {@code sourceCRS} to {@code targetCRS}. - * @throws FactoryException if the operation creation failed for some other reason. - */ - @Override - public CoordinateOperation createOperation(final CoordinateReferenceSystem sourceCRS, - final CoordinateReferenceSystem targetCRS) - throws OperationNotFoundException, FactoryException - { - return createOperation(sourceCRS, targetCRS, (CoordinateOperationContext) null); - } - /** * Finds or creates an operation for conversion or transformation between two coordinate reference systems. * If an operation exists, it is returned. If more than one operation exists, then the operation having the @@ -808,33 +786,4 @@ next: for (int i=components.size(); --i >= 0;) { { return new CoordinateOperationFinder(registry, this, context); } - - /** - * Returns an operation using a particular method for conversion or transformation between - * two coordinate reference systems. If an operation exists using the given method, then it - * is returned. If no operation using the given method is found, then the implementation has - * the option of inferring the operation from the argument objects. - * - * <p>Current implementation ignores the {@code method} argument. - * This behavior may change in a future Apache SIS version.</p> - * - * @param sourceCRS input coordinate reference system. - * @param targetCRS output coordinate reference system. - * @param method the algorithmic method for conversion or transformation. - * @return a coordinate operation from {@code sourceCRS} to {@code targetCRS}. - * @throws OperationNotFoundException if no operation path was found from {@code sourceCRS} to {@code targetCRS}. - * @throws FactoryException if the operation creation failed for some other reason. - * - * @deprecated Replaced by {@link #createOperation(CoordinateReferenceSystem, CoordinateReferenceSystem, CoordinateOperationContext)}. - */ - @Override - @Deprecated(since="0.7") - public CoordinateOperation createOperation(final CoordinateReferenceSystem sourceCRS, - final CoordinateReferenceSystem targetCRS, - final OperationMethod method) - throws FactoryException - { - ArgumentChecks.ensureNonNull("method", method); // As a matter of principle. - return createOperation(sourceCRS, targetCRS, (CoordinateOperationContext) null); - } } 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 a408b92ac3..a7daa49664 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 @@ -28,9 +28,7 @@ import java.util.logging.Level; import java.io.Serializable; import java.lang.reflect.Constructor; import org.opengis.parameter.ParameterValueGroup; -import org.opengis.parameter.ParameterDescriptorGroup; import org.opengis.parameter.ParameterNotFoundException; -import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.referencing.crs.GeodeticCRS; import org.opengis.referencing.cs.CoordinateSystem; import org.opengis.referencing.cs.EllipsoidalCS; @@ -374,8 +372,6 @@ public class DefaultMathTransformFactory extends AbstractFactory implements Math * for operations defined by empirical parameters, <i>etc</i>. * @return methods available in this factory for coordinate operations of the given type. * - * @see #getDefaultParameters(String) - * @see #createParameterizedTransform(ParameterValueGroup) * @see DefaultOperationMethod#getOperationType() */ @Override @@ -483,33 +479,6 @@ public class DefaultMathTransformFactory extends AbstractFactory implements Math return new ParameterizedTransformBuilder(this, getOperationMethod(method)); } - /** - * Returns the default parameter values for a math transform using the given operation method. - * The {@code method} argument is the name of any {@code OperationMethod} instance returned by - * <code>{@link #getAvailableMethods(Class) getAvailableMethods}({@linkplain SingleOperation}.class)</code>. - * Valid names are <a href="https://sis.apache.org/tables/CoordinateOperationMethods.html">listed here</a>. - * - * <p>This function creates new parameter instances at every call. - * Parameters are intended to be modified by the user before to be given to the - * {@link #createParameterizedTransform createParameterizedTransform(…)} method.</p> - * - * @param method the case insensitive name of the coordinate operation method to search for. - * @return a new group of parameter values for the {@code OperationMethod} identified by the given name. - * @throws NoSuchIdentifierException if there is no method registered for the given name or identifier. - * - * @see #getAvailableMethods(Class) - * @see #createParameterizedTransform(ParameterValueGroup) - * @see AbstractMathTransform#getParameterValues() - * - * @deprecated This {@linkplain #createParameterizedTransform way to create parameterized transform} is ambiguous. - * Use {@link #builder(String)} instead. - */ - @Override - @Deprecated(since="1.5") - public ParameterValueGroup getDefaultParameters(final String method) throws NoSuchIdentifierException { - return getOperationMethod(method).getParameters().createValue(); - } - /** * Source and target coordinate systems for which a new parameterized transform is going to be used. * @@ -822,50 +791,6 @@ public class DefaultMathTransformFactory extends AbstractFactory implements Math } } - /** - * Creates a transform from a group of parameters. - * The set of expected parameters varies for each operation. - * The easiest way to provide parameter values is to get an initially empty group for the desired - * operation by calling {@link #getDefaultParameters(String)}, then to fill the parameter values. - * Example: - * - * {@snippet lang="java" : - * ParameterValueGroup group = factory.getDefaultParameters("Transverse_Mercator"); - * group.parameter("semi_major").setValue(6378137.000); - * group.parameter("semi_minor").setValue(6356752.314); - * MathTransform mt = factory.createParameterizedTransform(group); - * } - * - * Sometimes the {@code "semi_major"} and {@code "semi_minor"} parameter values are not explicitly provided, - * but rather inferred from the {@linkplain org.opengis.referencing.datum.GeodeticDatum geodetic - * reference frame} of the source Coordinate Reference System. - * - * @param parameters the parameter values. The {@linkplain ParameterDescriptorGroup#getName() parameter group name} - * shall be the name of the desired {@linkplain DefaultOperationMethod operation method}. - * @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. This exception is thrown - * if some required parameter has not been supplied, or has illegal value. - * - * @see #getDefaultParameters(String) - * @see #getAvailableMethods(Class) - * @see #getLastMethodUsed() - * @see org.apache.sis.parameter.ParameterBuilder#createGroupForMapProjection(ParameterDescriptor...) - * - * @deprecated This constructor is ambiguous when axis directions are parts of the map projection definition - * as in <q>Transverse Mercator (South Orientated)</q>. - * Use {@link #builder(String)} instead for allowing the implementation to resolve such ambiguities. - */ - @Override - @Deprecated(since="1.5") - public MathTransform createParameterizedTransform(final ParameterValueGroup parameters) - throws NoSuchIdentifierException, FactoryException - { - final var builder = new ParameterizedTransformBuilder(this, null); - builder.setParameters(parameters, false); - return builder.create(); - } - /** * Creates a transform from a group of parameters and a context. * @@ -880,9 +805,6 @@ public class DefaultMathTransformFactory extends AbstractFactory implements Math public MathTransform createParameterizedTransform(final ParameterValueGroup parameters, final Context context) throws NoSuchIdentifierException, FactoryException { - if (context == null) { - return createParameterizedTransform(parameters); - } context.builder = null; context.factory = this; context.parameters = parameters; @@ -930,40 +852,6 @@ public class DefaultMathTransformFactory extends AbstractFactory implements Math return context.builder().swapAndScaleAxes(parameterized); } - /** - * Creates a transform from a base CRS to a derived CS using the given parameters. - * If this method needs to set the values of {@code "semi_major"} and {@code "semi_minor"} parameters, - * then it sets those values directly on the given {@code parameters} instance – not on a clone – for - * allowing the caller to get back the complete parameter values. - * However, this method only fills missing values, it never modify existing values. - * - * @param baseCRS the source coordinate reference system. - * @param parameters the parameter values for the transform. - * @param derivedCS the target coordinate system. - * @return the parameterized transform from {@code baseCRS} to {@code derivedCS}, - * including unit conversions and axis swapping. - * @throws NoSuchIdentifierException if there is no transform registered for the coordinate operation method. - * @throws FactoryException if the object creation failed. This exception is thrown - * if some required parameter has not been supplied, or has illegal value. - * - * @deprecated Replaced by {@link #builder(String)}. - */ - @Override - @Deprecated(since="0.7") - public MathTransform createBaseToDerived(final CoordinateReferenceSystem baseCRS, - final ParameterValueGroup parameters, final CoordinateSystem derivedCS) - throws NoSuchIdentifierException, FactoryException - { - ArgumentChecks.ensureNonNull("baseCRS", baseCRS); - ArgumentChecks.ensureNonNull("parameters", parameters); - ArgumentChecks.ensureNonNull("derivedCS", derivedCS); - final var builder = new ParameterizedTransformBuilder(this, null); - builder.setParameters(parameters, true); - builder.setSourceAxes(baseCRS); - builder.setTargetAxes(derivedCS, null); - return builder.create(); - } - /** * 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}, @@ -1187,25 +1075,6 @@ public class DefaultMathTransformFactory extends AbstractFactory implements Math return (pool != null) ? pool.unique(tr) : tr; } - /** - * Returns the operation method used by the latest call to a {@code create(…)} constructor - * in the currently running thread. Returns {@code null} if not applicable. - * - * <p>Invoking {@code getLastMethodUsed()} can be useful after a call to - * {@link #createParameterizedTransform createParameterizedTransform(…)}.</p> - * - * @return the last method used by a {@code create(…)} constructor, or {@code null} if unknown of unsupported. - * - * @see #createParameterizedTransform(ParameterValueGroup) - * - * @deprecated Replaced by {@link MathTransform.Builder#getMethod()}. - */ - @Override - @Deprecated(since = "1.5") - public OperationMethod getLastMethodUsed() { - return lastMethod.get(); - } - /** * Notifies this factory that the elements provided by the {@code Iterable<OperationMethod>} may have changed. * This method performs the following steps: diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/GeodeticObjectBuilder.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/GeodeticObjectBuilder.java index 287eb6d631..0c84f2a1eb 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/GeodeticObjectBuilder.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/GeodeticObjectBuilder.java @@ -63,6 +63,7 @@ import org.apache.sis.parameter.Parameters; // Specific to the geoapi-3.1 and geoapi-4.0 branches: import org.opengis.referencing.ObjectDomain; +import org.opengis.referencing.operation.MathTransform; // Specific to the geoapi-4.0 branch: import org.opengis.referencing.crs.GeodeticCRS; @@ -258,13 +259,13 @@ public class GeodeticObjectBuilder extends Builder<GeodeticObjectBuilder> { * Sets the conversion method together with all parameters. This method does not set the conversion name. * If a name different than the default is desired, {@link #setConversionName(String)} should be invoked. * - * @param parameters the map projection parameter values. + * @param builder the map projection parameter values. * @return {@code this}, for method calls chaining. * @throws FactoryException if the operation method cannot be obtained. */ - public GeodeticObjectBuilder setConversion(final ParameterValueGroup parameters) throws FactoryException { - method = factories.findOperationMethod(parameters.getDescriptor().getName().getCode()); - this.parameters = parameters; // Set only if above line succeed. + public GeodeticObjectBuilder setConversion(final MathTransform.Builder builder) throws FactoryException { + method = builder.getMethod().orElseThrow(() -> new FactoryException()); + parameters = builder.parameters(); // Set only if above line succeed. return this; } diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactoryTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactoryTest.java index 6ac6f3c8a0..8decba736b 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactoryTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactoryTest.java @@ -153,7 +153,7 @@ public final class DefaultCoordinateOperationFactoryTest extends MathTransformTe public void testProjectionAndLongitudeRotation() throws ParseException, FactoryException, TransformException { final CoordinateReferenceSystem sourceCRS = parse("$NTF"); final CoordinateReferenceSystem targetCRS = parse("$Mercator"); - final CoordinateOperation operation = factory.createOperation(sourceCRS, targetCRS); + final CoordinateOperation operation = factory.createOperation(sourceCRS, targetCRS, null); assertSame (sourceCRS, operation.getSourceCRS()); assertSame (targetCRS, operation.getTargetCRS()); assertInstanceOf(ConcatenatedOperation.class, operation); @@ -214,7 +214,7 @@ public final class DefaultCoordinateOperationFactoryTest extends MathTransformTe " TimeUnit[“day”, 86400]]]"); final CoordinateReferenceSystem targetCRS = parse("$Mercator"); - final CoordinateOperation operation = factory.createOperation(sourceCRS, targetCRS); + final CoordinateOperation operation = factory.createOperation(sourceCRS, targetCRS, null); assertSame (sourceCRS, operation.getSourceCRS()); assertSame (targetCRS, operation.getTargetCRS()); assertInstanceOf(ConcatenatedOperation.class, operation); @@ -297,7 +297,7 @@ public final class DefaultCoordinateOperationFactoryTest extends MathTransformTe " Unit[“metre”, 1],\n" + " Id[“EPSG”, 3857]]"); - final CoordinateOperation operation = factory.createOperation(sourceCRS, targetCRS); + final CoordinateOperation operation = factory.createOperation(sourceCRS, targetCRS, null); assertSame (sourceCRS, operation.getSourceCRS()); assertSame (targetCRS, operation.getTargetCRS()); assertInstanceOf(ConcatenatedOperation.class, operation); @@ -330,7 +330,7 @@ public final class DefaultCoordinateOperationFactoryTest extends MathTransformTe public void testPositionVectorTransformation() throws ParseException, FactoryException, TransformException { final CoordinateReferenceSystem sourceCRS = CommonCRS.WGS84.geographic(); final CoordinateReferenceSystem targetCRS = parse(CoordinateOperationFinderTest.AGD66()); - final CoordinateOperation operation = factory.createOperation(sourceCRS, targetCRS); + final CoordinateOperation operation = factory.createOperation(sourceCRS, targetCRS, null); transform = operation.getMathTransform(); tolerance = Formulas.LINEAR_TOLERANCE; λDimension = new int[] {0}; diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/AuthalicConversionTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/AuthalicConversionTest.java index 79d289d970..2f6da7c17c 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/AuthalicConversionTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/AuthalicConversionTest.java @@ -19,7 +19,6 @@ package org.apache.sis.referencing.operation.projection; import java.util.Random; import static java.lang.StrictMath.*; import org.apache.sis.parameter.Parameters; -import org.apache.sis.referencing.operation.DefaultOperationMethod; import org.apache.sis.referencing.operation.provider.LambertCylindricalEqualArea; import org.apache.sis.util.privy.Constants; import static org.apache.sis.math.MathFunctions.atanh; @@ -49,8 +48,8 @@ public final class AuthalicConversionTest extends MapProjectionTestCase { * @return a test instance of the projection. */ private AuthalicConversion create(final boolean ellipsoidal) { - final DefaultOperationMethod provider = new LambertCylindricalEqualArea(); - final CylindricalEqualArea projection = new CylindricalEqualArea(provider, parameters(provider, ellipsoidal)); + final var provider = new LambertCylindricalEqualArea(); + final var projection = new CylindricalEqualArea(provider, parameters(provider, ellipsoidal)); tolerance = NormalizedProjection.ANGULAR_TOLERANCE; // = linear tolerance on a sphere of radius 1. return projection; } @@ -110,7 +109,7 @@ public final class AuthalicConversionTest extends MapProjectionTestCase { @SuppressWarnings("UseOfSystemOutOrSystemErr") public void searchThreshold() throws ProjectionException { tolerance = NormalizedProjection.ANGULAR_TOLERANCE; - final DefaultOperationMethod provider = new LambertCylindricalEqualArea(); + final var provider = new LambertCylindricalEqualArea(); final Parameters parameters = parameters(provider, true); for (double e = 0.05; e <= 0.2; e += 0.001) { final double a = parameters.parameter(Constants.SEMI_MAJOR).doubleValue(); diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/EquirectangularTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/EquirectangularTest.java index 74fa87d09b..00302f78b9 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/EquirectangularTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/EquirectangularTest.java @@ -54,9 +54,9 @@ public final class EquirectangularTest extends MapProjectionTestCase { * for the whole projection (not only the normalized part). */ private void createCompleteProjection() throws FactoryException { - final Equirectangular provider = new Equirectangular(); + final var provider = new Equirectangular(); final Parameters parameters = parameters(provider, false); - transform = new MathTransformFactoryMock(provider).createParameterizedTransform(parameters); + transform = provider.createMathTransform(new MathTransformFactoryMock(provider), parameters); tolerance = Formulas.LINEAR_TOLERANCE; // Not NORMALIZED_TOLERANCE since this is not a NormalizedProjection. validate(); } diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MapProjectionTestCase.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MapProjectionTestCase.java index b0b03ff68d..e653311165 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MapProjectionTestCase.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MapProjectionTestCase.java @@ -27,7 +27,6 @@ import org.opengis.referencing.operation.MathTransformFactory; import org.opengis.parameter.ParameterValueGroup; import org.apache.sis.parameter.Parameters; import org.apache.sis.util.privy.Constants; -import org.apache.sis.referencing.operation.DefaultOperationMethod; import org.apache.sis.referencing.operation.provider.MapProjection; import org.apache.sis.referencing.operation.provider.AbstractProvider; import org.apache.sis.referencing.operation.transform.CoordinateDomain; @@ -136,7 +135,7 @@ abstract class MapProjectionTestCase extends MathTransformTestCase { * @param ellipsoidal {@code false} for a sphere, or {@code true} for WGS84 ellipsoid. * @return the parameters to use for instantiating the projection. */ - static Parameters parameters(final DefaultOperationMethod provider, final boolean ellipsoidal) { + static Parameters parameters(final AbstractProvider provider, final boolean ellipsoidal) { final Parameters parameters = Parameters.castOrWrap(provider.getParameters().createValue()); final Ellipsoid ellipsoid = (ellipsoidal ? GeodeticDatumMock.WGS84 : GeodeticDatumMock.SPHERE).getEllipsoid(); parameters.parameter(Constants.SEMI_MAJOR).setValue(ellipsoid.getSemiMajorAxis()); @@ -175,7 +174,7 @@ abstract class MapProjectionTestCase extends MathTransformTestCase { if (!isNaN(scaleFactor)) values.parameter(Constants.SCALE_FACTOR) .setValue(scaleFactor); if (!isNaN(falseEasting)) values.parameter(Constants.FALSE_EASTING) .setValue(falseEasting); if (!isNaN(falseNorthing)) values.parameter(Constants.FALSE_NORTHING) .setValue(falseNorthing); - transform = new MathTransformFactoryMock(provider).createParameterizedTransform(values); + transform = provider.createMathTransform(new MathTransformFactoryMock(provider), values); validate(); } diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MercatorTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MercatorTest.java index aa87936c76..8e508081cc 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MercatorTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MercatorTest.java @@ -316,12 +316,12 @@ public final class MercatorTest extends MapProjectionTestCase { * @throws FactoryException if an error occurred while creating the map projection. */ private void createAuxiliarySphereProjection(final int type) throws FactoryException { - final MercatorAuxiliarySphere provider = new MercatorAuxiliarySphere(); + final var provider = new MercatorAuxiliarySphere(); final Parameters values = Parameters.castOrWrap(provider.getParameters().createValue()); values.parameter(Constants.SEMI_MAJOR).setValue(WGS84_A); values.parameter(Constants.SEMI_MINOR).setValue(WGS84_B); values.parameter("Auxiliary_Sphere_Type").setValue(type); - transform = new MathTransformFactoryMock(provider).createParameterizedTransform(values); + transform = provider.createMathTransform(new MathTransformFactoryMock(provider), values); validate(); } diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MeridianArcTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MeridianArcTest.java index 74bbf8f6d7..0f06991868 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MeridianArcTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MeridianArcTest.java @@ -20,7 +20,6 @@ import java.util.Random; import static java.lang.StrictMath.*; import org.opengis.referencing.operation.MathTransform1D; import org.opengis.referencing.operation.TransformException; -import org.apache.sis.referencing.operation.DefaultOperationMethod; import org.apache.sis.referencing.operation.transform.AbstractMathTransform1D; import org.apache.sis.referencing.internal.Resources; @@ -49,8 +48,8 @@ public final class MeridianArcTest extends MapProjectionTestCase { * @return a test instance of the projection. */ private MeridianArcBased create(final boolean ellipsoidal) { - final DefaultOperationMethod provider = new org.apache.sis.referencing.operation.provider.Sinusoidal(); - final Sinusoidal projection = new Sinusoidal(provider, parameters(provider, ellipsoidal)); + final var provider = new org.apache.sis.referencing.operation.provider.Sinusoidal(); + final var projection = new Sinusoidal(provider, parameters(provider, ellipsoidal)); tolerance = NormalizedProjection.ANGULAR_TOLERANCE; // = linear tolerance on a sphere of radius 1. return projection; } diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java index a7880985cb..b57c1e54b7 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java @@ -99,11 +99,11 @@ public final class PolarStereographicTest extends MapProjectionTestCase { */ @Test public void testPolarStereographicNorth() throws FactoryException, TransformException { - final PolarStereographicNorth method = new PolarStereographicNorth(); + final var method = new PolarStereographicNorth(); final Parameters pg = parameters(method, true); pg.parameter("standard_parallel_1").setValue(71.0); pg.parameter("central_meridian").setValue(-96.0); - transform = new MathTransformFactoryMock(method).createParameterizedTransform(pg); + transform = method.createMathTransform(new MathTransformFactoryMock(method), pg); tolerance = 0.02; verifyTransform(new double[] { -121 - (20 + 22.380/60)/60, // 121°20'22.380"W diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ProjectionBenchmark.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ProjectionBenchmark.java index 673af07dc7..86a9f9c9c7 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ProjectionBenchmark.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ProjectionBenchmark.java @@ -127,7 +127,7 @@ public final class ProjectionBenchmark { values.parameter(Constants.CENTRAL_MERIDIAN) .setValue(centralMeridian); values.parameter(Constants.STANDARD_PARALLEL_1).setValue(standardParallel1); values.parameter(Constants.STANDARD_PARALLEL_2).setValue(standardParallel2); - forward = new Transforms("Forward", new MathTransformFactoryMock(provider).createParameterizedTransform(values)); + forward = new Transforms("Forward", provider.createMathTransform(new MathTransformFactoryMock(provider), values)); inverse = new Transforms("Inverse", forward.projection.inverse()); coordinates = new double[NUM_POINTS * DIMENSION]; final double λmin = centralMeridian - 40; diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/SatelliteTrackingTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/SatelliteTrackingTest.java index d1b6d184b5..a54df0f84f 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/SatelliteTrackingTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/SatelliteTrackingTest.java @@ -83,7 +83,7 @@ public final class SatelliteTrackingTest extends MapProjectionTestCase { values.parameter("satellite_orbit_inclination").setValue( 99.092); values.parameter("satellite_orbital_period") .setValue( 103.267, Units.MINUTE); values.parameter("ascending_node_period") .setValue(1440.0, Units.MINUTE); - transform = new MathTransformFactoryMock(provider).createParameterizedTransform(values); + transform = provider.createMathTransform(new MathTransformFactoryMock(provider), values); validate(); /* * Assuming that tolerance has been set to the number of fraction digits published in Snyder tables, diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ZonedGridSystemTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ZonedGridSystemTest.java index 009bd88deb..3a1af70f3a 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ZonedGridSystemTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ZonedGridSystemTest.java @@ -50,13 +50,13 @@ public final class ZonedGridSystemTest extends MapProjectionTestCase { * @param ellipsoidal {@code false} for a sphere, or {@code true} for WGS84 ellipsoid. */ private void createProjection(final boolean ellipsoidal) throws FactoryException { - final ZonedTransverseMercator method = new ZonedTransverseMercator(); + final var method = new ZonedTransverseMercator(); final Parameters values = parameters(method, ellipsoidal); values.parameter(Constants.SCALE_FACTOR) .setValue(0.9996, Units.UNITY ); values.parameter(Constants.FALSE_EASTING).setValue(500000, Units.METRE ); values.parameter("Initial longitude") .setValue( -180, Units.DEGREE); values.parameter("Zone width") .setValue( 6, Units.DEGREE); - transform = new MathTransformFactoryMock(method).createParameterizedTransform(values); + transform = method.createMathTransform(new MathTransformFactoryMock(method), values); tolerance = Formulas.LINEAR_TOLERANCE; validate(); } diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/GeocentricTranslationTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/GeocentricTranslationTest.java index 7be31fd7aa..986da2a0d2 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/GeocentricTranslationTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/GeocentricTranslationTest.java @@ -189,7 +189,7 @@ public final class GeocentricTranslationTest extends MathTransformTestCase { * @throws FactoryException if an error occurred while creating a transform. */ public static MathTransform createDatumShiftForGeographic2D(final MathTransformFactory factory) throws FactoryException { - final Parameters values = Parameters.castOrWrap(factory.getDefaultParameters("Geocentric translations (geog2D domain)")); + final Parameters values = Parameters.castOrWrap(factory.builder("Geocentric translations (geog2D domain)").parameters()); setTranslation(values); setEllipsoids(values, CommonCRS.WGS84.ellipsoid(), CommonCRS.ED50.ellipsoid()); final MathTransform gt = new GeocentricTranslation().createMathTransform(factory, values); diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/Geographic3Dto2DTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/Geographic3Dto2DTest.java index 350e3bc6e9..c9a324b527 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/Geographic3Dto2DTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/Geographic3Dto2DTest.java @@ -115,14 +115,15 @@ public final class Geographic3Dto2DTest extends TestCase { * Create a "Geographic to Geocentric" conversion with ellipsoid axis length units converted to metres * (the unit implied by SRC_SEMI_MAJOR) because it is the unit of Bursa-Wolf parameters that we created above. */ - Parameters step = Parameters.castOrWrap(factory.getDefaultParameters(GeographicToGeocentric.NAME)); + var builder = factory.builder(GeographicToGeocentric.NAME); + Parameters step = Parameters.castOrWrap(builder.parameters()); step.getOrCreate(MapProjection.SEMI_MAJOR).setValue(pv.doubleValue(GeocentricAffineBetweenGeographic.SRC_SEMI_MAJOR)); step.getOrCreate(MapProjection.SEMI_MINOR).setValue(pv.doubleValue(GeocentricAffineBetweenGeographic.SRC_SEMI_MINOR)); - MathTransform toGeocentric = factory.createParameterizedTransform(step); + MathTransform toGeocentric = builder.create(); assertEquals(3, toGeocentric.getSourceDimensions()); assertEquals(3, toGeocentric.getTargetDimensions()); - final MathTransform reduce = factory.createParameterizedTransform(factory.getDefaultParameters("Geographic3D to 2D conversion")); + final MathTransform reduce = factory.builder("Geographic3D to 2D conversion").create(); assertEquals(3, reduce.getSourceDimensions()); assertEquals(2, reduce.getTargetDimensions()); try { @@ -136,10 +137,11 @@ public final class Geographic3Dto2DTest extends TestCase { * Create a "Geocentric to Geographic" conversion with ellipsoid axis length units converted to metres * because this is the unit of the Geocentric CRS used above. */ - step = Parameters.castOrWrap(factory.getDefaultParameters(GeocentricToGeographic.NAME)); + builder = factory.builder(GeocentricToGeographic.NAME); + step = Parameters.castOrWrap(builder.parameters()); step.getOrCreate(MapProjection.SEMI_MAJOR).setValue(pv.doubleValue(GeocentricAffineBetweenGeographic.TGT_SEMI_MAJOR)); step.getOrCreate(MapProjection.SEMI_MINOR).setValue(pv.doubleValue(GeocentricAffineBetweenGeographic.TGT_SEMI_MINOR)); - MathTransform toGeographic = factory.createParameterizedTransform(step); + MathTransform toGeographic = builder.create(); assertEquals(3, toGeographic.getSourceDimensions()); assertEquals(3, toGeographic.getTargetDimensions()); diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java index da0eab5c15..c8fa84b027 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java @@ -216,7 +216,8 @@ public final class DefaultMathTransformFactoryTest extends TestCase { continue; } final String classification = method.getName().getCode(); - ParameterValueGroup pg = factory.getDefaultParameters(classification); + final var builder = factory.builder(classification); + ParameterValueGroup pg = builder.parameters(); pg.parameter("semi_major").setValue(6377563.396); pg.parameter("semi_minor").setValue(6356256.909237285); /* @@ -263,7 +264,7 @@ public final class DefaultMathTransformFactoryTest extends TestCase { } final MathTransform mt; try { - mt = factory.createParameterizedTransform(pg); + mt = builder.create(); } catch (InvalidGeodeticParameterException e) { fail(classification + ": " + e.getLocalizedMessage()); continue; diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformFactoryBase.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformFactoryBase.java index 84412badde..0789a11e12 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformFactoryBase.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformFactoryBase.java @@ -20,9 +20,6 @@ import java.util.Set; import org.opengis.util.FactoryException; import org.opengis.util.NoSuchIdentifierException; import org.opengis.metadata.citation.Citation; -import org.opengis.parameter.ParameterValueGroup; -import org.opengis.referencing.cs.CoordinateSystem; -import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.referencing.operation.Matrix; import org.opengis.referencing.operation.OperationMethod; import org.opengis.referencing.operation.SingleOperation; @@ -63,38 +60,12 @@ class MathTransformFactoryBase implements MathTransformFactory { return Set.of(); } - /** Default implementation unconditionally returns {@code null}. */ - @Override - @Deprecated - public OperationMethod getLastMethodUsed() { - return null; - } - - /** Default implementation throws an exception. */ - @Override - public ParameterValueGroup getDefaultParameters(String method) throws NoSuchIdentifierException { - throw new NoSuchIdentifierException(MESSAGE, method); - } - - /** Default implementation throws an exception. */ - @Override - @Deprecated - public MathTransform createBaseToDerived(CoordinateReferenceSystem baseCRS, ParameterValueGroup parameters, CoordinateSystem derivedCS) throws FactoryException { - throw new FactoryException(MESSAGE); - } - /** Default implementation throws an exception. */ @Override public MathTransform.Builder builder(String code) throws NoSuchIdentifierException { throw new NoSuchIdentifierException(MESSAGE, code); } - /** Default implementation throws an exception. */ - @Override - public MathTransform createParameterizedTransform(ParameterValueGroup parameters) throws FactoryException { - throw new FactoryException(MESSAGE); - } - /** Default implementation throws an exception. */ @Override public MathTransform createAffineTransform(Matrix matrix) throws FactoryException { 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 9ac5cca778..12c76e45b5 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 @@ -22,8 +22,6 @@ import org.opengis.util.FactoryException; import org.opengis.util.NoSuchIdentifierException; import org.opengis.metadata.citation.Citation; import org.opengis.parameter.ParameterValueGroup; -import org.opengis.referencing.crs.CoordinateReferenceSystem; -import org.opengis.referencing.cs.CoordinateSystem; import org.opengis.referencing.operation.Matrix; import org.opengis.referencing.operation.MathTransform; import org.opengis.referencing.operation.MathTransformFactory; @@ -97,17 +95,6 @@ public final class MathTransformFactoryMock implements MathTransformFactory { return type.isAssignableFrom(Conversion.class) ? Set.of(method) : Set.of(); } - /** - * Returns the last method used, which can only be null or the method given at construction time. - * - * @return the method given at construction time. - */ - @Override - @Deprecated - public OperationMethod getLastMethodUsed() { - return method; - } - /** * Returns the builder for the operation method. * @@ -138,37 +125,6 @@ public final class MathTransformFactoryMock implements MathTransformFactory { throw new NoSuchIdentifierException(null, name); } - /** - * Returns the parameters for the operation method. - * - * @param name shall be the operation method name. - * @return the parameters. - * @throws NoSuchIdentifierException if the given name is not the name - * of the operation method known to this factory. - */ - @Override - @Deprecated - public ParameterValueGroup getDefaultParameters(final String name) throws NoSuchIdentifierException { - if (method.isHeuristicMatchForName(name)) { - return method.getParameters().createValue(); - } - throw new NoSuchIdentifierException(null, name); - } - - /** - * Delegates to the method given at construction time. - * - * @param parameters the parameters to give to the math transform provider. - * @return the transform created by the provider. - * @throws FactoryException if the provider cannot create the transform. - */ - @Override - @Deprecated - public MathTransform createParameterizedTransform(ParameterValueGroup parameters) throws FactoryException { - lastParameters = parameters; - return method.createMathTransform(this, parameters); - } - /** * Delegates to {@link MathTransforms}. * @@ -217,22 +173,6 @@ public final class MathTransformFactoryMock implements MathTransformFactory { throw new UnsupportedOperationException(); } - /** - * Unimplemented method. - * - * @param baseCRS ignored. - * @param parameters ignored. - * @param derivedCS ignored. - * @return never returned. - */ - @Override - @Deprecated - public MathTransform createBaseToDerived(CoordinateReferenceSystem baseCRS, - ParameterValueGroup parameters, CoordinateSystem derivedCS) - { - throw new UnsupportedOperationException(); - } - /** * Unimplemented method. * diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MolodenskyTransformTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MolodenskyTransformTest.java index a1152f3c1d..8c44de1097 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MolodenskyTransformTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MolodenskyTransformTest.java @@ -343,7 +343,8 @@ public final class MolodenskyTransformTest extends MathTransformTestCase { @Test public void testProvider() throws FactoryException, TransformException { final MathTransformFactory factory = new MathTransformFactoryMock(new Molodensky()); - final ParameterValueGroup parameters = factory.getDefaultParameters("Molodenski"); + final var builder = factory.builder("Molodenski"); + final ParameterValueGroup parameters = builder.parameters(); parameters.parameter("dim").setValue(3); parameters.parameter("dx").setValue(-3.0); parameters.parameter("dy").setValue(142.0); @@ -352,7 +353,7 @@ public final class MolodenskyTransformTest extends MathTransformTestCase { parameters.parameter("src_semi_minor").setValue(6356583.8); parameters.parameter("tgt_semi_major").setValue(6378137.0); parameters.parameter("tgt_semi_minor").setValue(6356752.31414036); - transform = factory.createParameterizedTransform(parameters); + transform = builder.create(); assertEquals(3, transform.getSourceDimensions()); assertEquals(3, transform.getTargetDimensions()); tolerance = Formulas.ANGULAR_TOLERANCE * 5; diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/CoordinateOperationTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/CoordinateOperationTest.java index 5170f4ce91..ed84528418 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/CoordinateOperationTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/CoordinateOperationTest.java @@ -26,7 +26,6 @@ import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.referencing.operation.MathTransform; import org.opengis.referencing.operation.CoordinateOperation; import org.opengis.referencing.operation.TransformException; -import org.opengis.referencing.operation.CoordinateOperationFactory; import org.opengis.referencing.operation.CoordinateOperationAuthorityFactory; import org.apache.sis.math.MathFunctions; import org.apache.sis.referencing.CRS; @@ -57,7 +56,7 @@ public final class CoordinateOperationTest extends MathTransformTestCase { /** * The transformation factory to use for testing. */ - private final CoordinateOperationFactory opFactory; + private final DefaultCoordinateOperationFactory opFactory; /** * Creates the test suite. @@ -81,7 +80,7 @@ public final class CoordinateOperationTest extends MathTransformTestCase { final Ellipsoid ellipsoid = CommonCRS.WGS84.ellipsoid(); final CoordinateReferenceSystem sourceCRS = AbstractCRS.castOrCopy(CommonCRS.WGS84.geographic3D()).forConvention(AxesConvention.RIGHT_HANDED); final CoordinateReferenceSystem targetCRS = CommonCRS.WGS84.geocentric(); - final CoordinateOperation operation = opFactory.createOperation(sourceCRS, targetCRS); + final CoordinateOperation operation = opFactory.createOperation(sourceCRS, targetCRS, null); transform = operation.getMathTransform(); final int dimension = transform.getSourceDimensions(); assertEquals(3, dimension); @@ -237,7 +236,7 @@ public final class CoordinateOperationTest extends MathTransformTestCase { CoordinateReferenceSystem sourceCRS = crsFactory.createCoordinateReferenceSystem("3001"); CoordinateReferenceSystem targetCRS = crsFactory.createCoordinateReferenceSystem("4211"); - CoordinateOperation operation = opFactory.createOperation(sourceCRS, targetCRS); + CoordinateOperation operation = opFactory.createOperation(sourceCRS, targetCRS, null); MathTransform mt = operation.getMathTransform(); double[] expectedXyValues = new double[] {-2.0, -71.0}; diff --git a/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/MetadataReader.java b/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/MetadataReader.java index 2abfe48b54..4c3b7ff5d1 100644 --- a/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/MetadataReader.java +++ b/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/MetadataReader.java @@ -41,6 +41,7 @@ import org.opengis.metadata.content.TransferFunctionType; import org.opengis.metadata.maintenance.ScopeCode; import org.opengis.parameter.ParameterValueGroup; import org.opengis.referencing.crs.ProjectedCRS; +import org.opengis.referencing.operation.MathTransform; import org.opengis.util.NoSuchIdentifierException; import org.opengis.util.FactoryException; import org.apache.sis.measure.Units; @@ -223,7 +224,7 @@ final class MetadataReader extends MetadataBuilder { /** * The map projection parameters. This is used only for the polar stereographic case. */ - private ParameterValueGroup projection; + private MathTransform.Builder projection; /** * The referencing objects factories. @@ -673,7 +674,7 @@ final class MetadataReader extends MetadataBuilder { projection = null; } else if ("PS".equalsIgnoreCase(value)) try { projection = factories.getMathTransformFactory() - .getDefaultParameters(Constants.EPSG + ':' + PolarStereographicB.IDENTIFIER); + .builder(Constants.EPSG + ':' + PolarStereographicB.IDENTIFIER); utmZone = -1; } catch (NoSuchIdentifierException e) { // Should never happen with Apache SIS implementation of MathTransformFactory. @@ -790,7 +791,8 @@ final class MetadataReader extends MetadataBuilder { */ private void setProjectionParameter(final String key, final String name, final String value, final boolean isLinear) { if (projection != null) { - projection.parameter(name).setValue(Double.parseDouble(value), isLinear ? Units.METRE : Units.DEGREE); + projection.parameters().parameter(name) + .setValue(Double.parseDouble(value), isLinear ? Units.METRE : Units.DEGREE); } else { listeners.warning(errors().getString(Errors.Keys.UnexpectedProperty_2, filename, key)); } @@ -867,14 +869,15 @@ final class MetadataReader extends MetadataBuilder { addReferenceSystem(datum.universal(1, TransverseMercator.Zoner.UTM.centralMeridian(utmZone))); } if (projection != null) { - final double sp = projection.parameter(Constants.STANDARD_PARALLEL_1).doubleValue(); + final ParameterValueGroup p = projection.parameters(); + final double sp = p.parameter(Constants.STANDARD_PARALLEL_1).doubleValue(); ProjectedCRS crs = (ProjectedCRS) CRS.forCode(Constants.EPSG + ":" + (sp >= 0 ? Constants.EPSG_ARCTIC_POLAR_STEREOGRAPHIC // Standard parallel = 71°N : Constants.EPSG_ANTARCTIC_POLAR_STEREOGRAPHIC)); // Standard parallel = 71°S if (datum != CommonCRS.WGS84 || Math.abs(sp) != 71 - || projection.parameter(Constants.FALSE_EASTING) .doubleValue() != 0 - || projection.parameter(Constants.FALSE_NORTHING) .doubleValue() != 0 - || projection.parameter(Constants.CENTRAL_MERIDIAN).doubleValue() != 0) + || p.parameter(Constants.FALSE_EASTING) .doubleValue() != 0 + || p.parameter(Constants.FALSE_NORTHING) .doubleValue() != 0 + || p.parameter(Constants.CENTRAL_MERIDIAN).doubleValue() != 0) { crs = new GeodeticObjectBuilder(factories, listeners.getLocale()) .addName("Polar stereographic").setConversion(projection) diff --git a/geoapi/snapshot b/geoapi/snapshot index 48d58002a5..e55b18a854 160000 --- a/geoapi/snapshot +++ b/geoapi/snapshot @@ -1 +1 @@ -Subproject commit 48d58002a5f500446c1237bf8718f018d0f90982 +Subproject commit e55b18a85498f5baaa5ca83cce323a1cfe038eda