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 f03e23af5987e6f3cf91f97396cc755300d4e171 Author: Martin Desruisseaux <[email protected]> AuthorDate: Thu Oct 2 17:05:15 2025 +0200 Remove deprecated method in `CoordinateOperationFactory`. Comes together with the corresponding change in GeoAPI. --- .../org/apache/sis/console/TransformCommand.java | 5 +- .../factory/MultiAuthoritiesFactory.java | 11 ++-- .../referencing/factory/sql/EPSGDataAccess.java | 3 +- .../operation/CoordinateOperationFinder.java | 6 ++- .../operation/CoordinateOperationRegistry.java | 10 ++-- .../DefaultCoordinateOperationFactory.java | 59 +--------------------- .../operation/InverseOperationMethod.java | 4 +- .../transform/DefaultMathTransformFactory.java | 2 - .../xml/bind/referencing/CC_OperationMethod.java | 4 +- .../operation/CoordinateOperationFinderTest.java | 5 +- .../DefaultCoordinateOperationFactoryTest.java | 13 ----- .../sis/storage/geotiff/base/GeoCodesTest.java | 4 +- geoapi/snapshot | 2 +- 13 files changed, 35 insertions(+), 93 deletions(-) diff --git a/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/TransformCommand.java b/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/TransformCommand.java index efed1ce08f..033046b050 100644 --- a/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/TransformCommand.java +++ b/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/TransformCommand.java @@ -336,7 +336,10 @@ final class TransformCommand extends FormattedOutputCommand { if (steps.size() > 1) { var factory = DefaultCoordinateOperationFactory.provider(); var properties = IdentifiedObjects.getProperties(operation, CoordinateOperation.IDENTIFIERS_KEY); - operation = factory.createConcatenatedOperation(properties, steps.toArray(CoordinateOperation[]::new)); + operation = factory.createConcatenatedOperation( + properties, + null, null, // Infer source and target CRS from the first and last steps. + steps.toArray(CoordinateOperation[]::new)); } } /* diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java index 493b8141a9..b6dd73c42d 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java @@ -1601,11 +1601,14 @@ public class MultiAuthoritiesFactory extends GeodeticAuthorityFactory implements * yet support swapping roles of source and target CRS if an implied-reverse coordinate * operation is included. */ - final CoordinateOperation[] ops = (CoordinateOperation[]) components; - String name = IdentifiedObjects.getIdentifierOrName(ops[0]) + " ⟶ " - + IdentifiedObjects.getIdentifierOrName(ops[ops.length - 1]); + final CoordinateOperation[] steps = (CoordinateOperation[]) components; + String name = IdentifiedObjects.getIdentifierOrName(steps[0]) + " ⟶ " + + IdentifiedObjects.getIdentifierOrName(steps[steps.length - 1]); combined = DefaultCoordinateOperationFactory.provider() - .createConcatenatedOperation(Map.of(CoordinateOperation.NAME_KEY, name), ops); + .createConcatenatedOperation( + Map.of(CoordinateOperation.NAME_KEY, name), + null, null, // Infer source and target CRS from the first and last steps. + steps); } break; } diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java index 81a0e58e0e..b0e62db918 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java @@ -3539,7 +3539,8 @@ search: try (ResultSet result = executeMetadataQuery("Deprecation", + " FROM \"Coordinate_Operation Path\"" + " WHERE (CONCAT_OPERATION_CODE = ?)" + " ORDER BY OP_PATH_STEP", epsg).toArray(CoordinateOperation[]::new); - constructor = (factory, metadata) -> factory.createConcatenatedOperation(metadata, operations); + constructor = (factory, metadata) -> + factory.createConcatenatedOperation(metadata, sourceCRS, targetCRS, operations); } else { /* * At this stage, the parameters are ready for use. Create the math transform and wrap it in the diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationFinder.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationFinder.java index bfb2efc217..2921d6c4e0 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationFinder.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationFinder.java @@ -1138,7 +1138,9 @@ public class CoordinateOperationFinder extends CoordinateOperationRegistry { op.getParameterValues(), typeOf(op)); } else { - main = factory.createConcatenatedOperation(defaultName(sourceCRS, targetCRS), step1, step2); + main = factory.createConcatenatedOperation( + defaultName(sourceCRS, targetCRS), + sourceCRS, targetCRS, step1, step2); } /* * Sometimes we get a concatenated operation made of an operation followed by its inverse. @@ -1181,7 +1183,7 @@ public class CoordinateOperationFinder extends CoordinateOperationRegistry { if (canHide(step1.getName())) return concatenate(concatenate(step1, step2), step3); if (canHide(step3.getName())) return concatenate(step1, concatenate(step2, step3)); final Map<String,?> properties = defaultName(step1.getSourceCRS(), step3.getTargetCRS()); - return factory.createConcatenatedOperation(properties, step1, step2, step3); + return factory.createConcatenatedOperation(properties, null, null, step1, step2, step3); } /** diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java index 478fd7eebd..58a2f1df00 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java @@ -797,7 +797,7 @@ class CoordinateOperationRegistry { if (transform != null) { properties.put(DefaultConcatenatedOperation.TRANSFORM_KEY, transform.inverse()); } - inverse = factory.createConcatenatedOperation(properties, inverted); + inverse = factory.createConcatenatedOperation(properties, null, null, inverted); AbstractCoordinateOperation.setCachedInverse(operation, inverse); } return inverse; @@ -944,7 +944,7 @@ class CoordinateOperationRegistry { final CoordinateOperation last = steps[n]; steps[0] = transform(sourceCRS, prepend, first, null, first.getTargetCRS(), mtFactory); steps[n] = transform(last.getSourceCRS(), null, last, append, targetCRS, mtFactory); - return factory.createConcatenatedOperation(derivedFrom(operation), steps); + return factory.createConcatenatedOperation(derivedFrom(operation), null, null, steps); } } } @@ -1087,8 +1087,10 @@ class CoordinateOperationRegistry { switch (operations.size()) { case 0: return null; case 1: return operations.get(0); - default: return factory.createConcatenatedOperation(derivedFrom(operation), - operations.toArray(CoordinateOperation[]::new)); + default: return factory.createConcatenatedOperation( + derivedFrom(operation), + null, null, // Take source and target CRS from the first and last steps. + operations.toArray(CoordinateOperation[]::new)); } } 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 fae7ffc19c..6efdc5f69c 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 @@ -64,9 +64,6 @@ import org.apache.sis.util.resources.Errors; * <ul> * <li>By fetching or building explicitly each components of the operation: * <ul> - * <li>The {@link DefaultOperationMethod operation method}, which can be - * {@linkplain #getOperationMethod fetched from a set of predefined methods} or - * {@linkplain #createOperationMethod built explicitly}.</li> * <li>A single {@linkplain #createDefiningConversion defining conversion}.</li> * <li>A {@linkplain #createConcatenatedOperation concatenation} of other operations.</li> * </ul> @@ -246,30 +243,6 @@ public class DefaultCoordinateOperationFactory extends AbstractFactory implement return mtFactory; } - /** - * Returns the operation method of the given name. The given argument shall be either a method - * {@linkplain DefaultOperationMethod#getName() name} (e.g. <q>Transverse Mercator</q>) - * or one of its {@linkplain DefaultOperationMethod#getIdentifiers() identifiers} (e.g. {@code "EPSG:9807"}). - * The search is case-insensitive and comparisons against method names can be - * {@linkplain DefaultOperationMethod#isHeuristicMatchForName(String) heuristic}. - * - * <p>If more than one method match the given name, then the first (according iteration order) - * non-{@linkplain org.apache.sis.util.Deprecable#isDeprecated() deprecated} matching method is returned. - * If all matching methods are deprecated, the first one is returned.</p> - * - * @param name the name of the operation method to fetch. - * @return the operation method of the given name. - * @throws FactoryException if the requested operation method cannot be fetched. - * - * @see DefaultMathTransformFactory#getOperationMethod(String) - * - * @deprecated Use {@link DefaultMathTransformFactory} instead. - */ - @Deprecated(since="1.5", forRemoval=true) - public OperationMethod getOperationMethod(String name) throws FactoryException { - return CoordinateOperations.findMethod(mtFactory, name); - } - /** * Creates an operation method from a set of properties and a descriptor group. * The source and target dimensions may be {@code null} if the method can work @@ -326,17 +299,6 @@ public class DefaultCoordinateOperationFactory extends AbstractFactory implement return pool.unique(method); } - /** - * @deprecated The dimensions attributes have been removed in ISO 19111:2019 revision. - */ - @Deprecated(since="1.4", forRemoval=true) - public OperationMethod createOperationMethod(final Map<String,?> properties, - final Integer sourceDimensions, final Integer targetDimensions, - ParameterDescriptorGroup parameters) throws FactoryException - { - return createOperationMethod(properties, parameters); - } - /** * Creates a defining conversion from the given operation parameters. * This conversion has no source and target CRS since those elements are usually unknown at this stage. @@ -559,26 +521,6 @@ next: for (SingleCRS component : CRS.getSingleComponents(targetCRS)) { return pool.unique(op); } - /** - * Creates an ordered sequence of two or more single coordinate operations. - * - * @deprecated Replaced by {@linkplain #createConcatenatedOperation(Map, CoordinateReferenceSystem, - * CoordinateReferenceSystem, CoordinateOperation...) a method with explicit CRS arguments} because - * of potential <abbr>CRS</abbr> swapping. - * - * @param properties the properties to be given to the identified object. - * @param operations the sequence of operations. Shall contain at least two operations. - * @return the concatenated operation created from the given arguments. - * @throws FactoryException if the object creation failed. - */ - @Override - @Deprecated(since="1.5", forRemoval=true) - public CoordinateOperation createConcatenatedOperation(final Map<String,?> properties, - final CoordinateOperation... operations) throws FactoryException - { - return createConcatenatedOperation(properties, null, null, operations); - } - /** * Creates an ordered sequence of two or more single coordinate operations. * The sequence of operations is constrained by the requirement that the source coordinate reference system @@ -623,6 +565,7 @@ next: for (SingleCRS component : CRS.getSingleComponents(targetCRS)) { * * @since 1.5 */ + @Override public CoordinateOperation createConcatenatedOperation( final Map<String,?> properties, final CoordinateReferenceSystem sourceCRS, diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/InverseOperationMethod.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/InverseOperationMethod.java index ee93967569..50a5a0d9c0 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/InverseOperationMethod.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/InverseOperationMethod.java @@ -83,7 +83,9 @@ final class InverseOperationMethod extends DefaultOperationMethod { return ((InverseOperationMethod) method).inverse; } if (!(method instanceof AbstractProvider)) try { - method = factorySIS.getOperationMethod(method.getName().getCode()); + method = CoordinateOperations.findMethod( + factorySIS.getMathTransformFactory(), + method.getName().getCode()); } catch (NoSuchIdentifierException e) { CoordinateOperationRegistry.recoverableException("inverse", e); } 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 a3cb351e41..65397554b0 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 @@ -415,8 +415,6 @@ public class DefaultMathTransformFactory extends AbstractFactory implements Math * @param identifier the name or identifier of the operation method to search. * @return the coordinate operation method for the given name or identifier. * @throws NoSuchIdentifierException if there is no operation method registered for the specified identifier. - * - * @see org.apache.sis.referencing.operation.DefaultCoordinateOperationFactory#getOperationMethod(String) */ public OperationMethod getOperationMethod(String identifier) throws NoSuchIdentifierException { ArgumentChecks.ensureNonEmpty("identifier", identifier = identifier.strip()); diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CC_OperationMethod.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CC_OperationMethod.java index c66eafed8d..9156a6f2ba 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CC_OperationMethod.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CC_OperationMethod.java @@ -32,9 +32,9 @@ import org.opengis.referencing.operation.OperationMethod; import org.apache.sis.xml.bind.Context; import org.apache.sis.xml.bind.gco.PropertyType; import org.apache.sis.referencing.IdentifiedObjects; -import org.apache.sis.referencing.operation.DefaultCoordinateOperationFactory; import org.apache.sis.referencing.operation.DefaultOperationMethod; import org.apache.sis.referencing.operation.provider.MapProjection; +import org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory; import org.apache.sis.parameter.DefaultParameterValue; import org.apache.sis.parameter.DefaultParameterValueGroup; import org.apache.sis.parameter.DefaultParameterDescriptorGroup; @@ -170,7 +170,7 @@ public final class CC_OperationMethod extends PropertyType<CC_OperationMethod, O public static ParameterDescriptorGroup group(final Identifier name, final GeneralParameterDescriptor[] descriptors) { OperationMethod method; try { - method = DefaultCoordinateOperationFactory.provider().getOperationMethod(name.getCode()); + method = DefaultMathTransformFactory.provider().getOperationMethod(name.getCode()); } catch (FactoryException e) { // Use DefaultOperationMethod as the source class because it is the first public class in callers. Context.warningOccured(Context.current(), DefaultOperationMethod.class, "setDescriptors", e, true); diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java index 5e30468948..059e817a19 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java @@ -79,6 +79,7 @@ import org.opengis.test.Assertions; // Specific to the geoapi-4.0 branch: import java.time.temporal.ChronoField; +import org.apache.sis.referencing.internal.shared.CoordinateOperations; /** @@ -1045,8 +1046,8 @@ public final class CoordinateOperationFinderTest extends MathTransformTestCase { final GeographicCRS WGS84 = CommonCRS.WGS84.normalizedGeographic(); final CompoundCRS sourceCRS = compound("Test3D", WGS84, CommonCRS.Temporal.UNIX.crs()); - final DerivedCRS targetCRS = DefaultDerivedCRS.create(properties, - WGS84, null, factory.getOperationMethod("Affine"), + final DerivedCRS targetCRS = DefaultDerivedCRS.create(properties, WGS84, null, + CoordinateOperations.findMethod(factory.getMathTransformFactory(), "Affine"), MathTransforms.linear(Matrices.create(3, 3, new double[] { 12, 0, 480, 0, -12, 790, 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 11c339cef4..b4e9223c46 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 @@ -19,7 +19,6 @@ package org.apache.sis.referencing.operation; import java.util.List; import java.text.ParseException; import org.opengis.util.FactoryException; -import org.opengis.util.NoSuchIdentifierException; import org.opengis.parameter.ParameterValueGroup; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.referencing.operation.ConcatenatedOperation; @@ -43,7 +42,6 @@ import org.junit.jupiter.api.parallel.Execution; import org.junit.jupiter.api.parallel.ExecutionMode; import org.apache.sis.referencing.crs.HardCodedCRS; import org.apache.sis.referencing.operation.transform.MathTransformTestCase; -import static org.apache.sis.test.Assertions.assertMessageContains; import static org.apache.sis.referencing.Assertions.assertEpsgNameAndIdentifierEqual; @@ -338,15 +336,4 @@ public final class DefaultCoordinateOperationFactoryTest extends MathTransformTe CoordinateOperationFinderTest.expectedAGD66(false)); validate(); } - - /** - * Verifies that requesting an unknown method throws {@link NoSuchIdentifierException}. - * - * @throws FactoryException if an unexpected error occurred. - */ - @Test - public void testUnknownMethod() throws FactoryException { - var e = assertThrows(NoSuchIdentifierException.class, () -> factory.getOperationMethod("I do not exist")); - assertMessageContains(e, "I do not exist"); - } } diff --git a/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/base/GeoCodesTest.java b/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/base/GeoCodesTest.java index 211b11daaf..59ebb8c45c 100644 --- a/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/base/GeoCodesTest.java +++ b/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/base/GeoCodesTest.java @@ -21,7 +21,7 @@ import org.opengis.parameter.ParameterDescriptorGroup; import org.opengis.referencing.IdentifiedObject; import org.apache.sis.metadata.iso.citation.Citations; import org.apache.sis.referencing.IdentifiedObjects; -import org.apache.sis.referencing.operation.DefaultCoordinateOperationFactory; +import org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory; // Test dependencies import org.junit.jupiter.api.Test; @@ -63,7 +63,7 @@ public final class GeoCodesTest extends TestCase { * Returns the parameters for the operation method of the given name. */ private static ParameterDescriptorGroup parameters(final String method) throws FactoryException { - return DefaultCoordinateOperationFactory.provider().getOperationMethod(method).getParameters(); + return DefaultMathTransformFactory.provider().getOperationMethod(method).getParameters(); } /** diff --git a/geoapi/snapshot b/geoapi/snapshot index 0d2c695d36..8cc86e44c8 160000 --- a/geoapi/snapshot +++ b/geoapi/snapshot @@ -1 +1 @@ -Subproject commit 0d2c695d36f3f38c5783316b82fc8516326496b0 +Subproject commit 8cc86e44c8cebbb07cd65cd666354d1397a2e975
