This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-3.1 in repository https://gitbox.apache.org/repos/asf/sis.git
commit eb43834def49da76394636d118ccfcaac1c6b001 Merge: 1930d30455 973019be6b Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Mon Jul 8 12:43:27 2024 +0200 Merge branch 'geoapi-4.0' into geoapi-3.1: - Implementation of RegisterOperations. - Refactoring of DefaultMathTransformFactory. - Fixes in Shapefile reader (incubator). .../geometry/wrapper/SpatialOperationContext.java | 4 +- .../org/apache/sis/util/iso/AbstractFactory.java | 22 +- .../main/module-info.java | 3 + .../org/apache/sis/io/wkt/MathTransformParser.java | 11 +- .../org/apache/sis/parameter/TensorParameters.java | 12 +- .../main/org/apache/sis/referencing/CRS.java | 3 +- .../sis/referencing/MultiRegisterOperations.java | 445 ++++++++++ .../referencing/factory/IdentifiedObjectSet.java | 5 +- .../factory/MultiAuthoritiesFactory.java | 22 +- .../referencing/factory/sql/EPSGDataAccess.java | 11 +- .../internal/ParameterizedTransformBuilder.java | 880 +++++++++++++++++++ .../operation/AbstractSingleOperation.java | 11 +- .../operation/CoordinateOperationFinder.java | 44 +- .../operation/CoordinateOperationRegistry.java | 82 +- .../operation/DefaultConcatenatedOperation.java | 13 +- .../referencing/operation/DefaultConversion.java | 74 +- .../DefaultCoordinateOperationFactory.java | 26 +- .../operation/LooselyDefinedMethod.java | 3 - .../operation/MathTransformContext.java | 68 +- .../sis/referencing/operation/package-info.java | 14 - .../operation/projection/NormalizedProjection.java | 3 +- .../operation/projection/package-info.java | 5 +- .../operation/provider/AbstractProvider.java | 2 +- .../operation/provider/GeographicToGeocentric.java | 7 +- .../transform/CoordinateSystemTransform.java | 153 +--- .../CoordinateSystemTransformBuilder.java | 255 ++++++ .../transform/DefaultMathTransformFactory.java | 954 +++++---------------- .../operation/transform/MathTransformBuilder.java | 111 +++ .../operation/transform/MathTransformProvider.java | 61 ++ .../referencing/privy/CoordinateOperations.java | 85 +- .../privy/ReferencingFactoryContainer.java | 9 +- .../referencing/privy/ReferencingUtilities.java | 59 -- .../factory/GeodeticObjectFactoryTest.java | 18 +- .../referencing/geoapi/AuthorityFactoryTest.java | 3 +- .../ParameterizedTransformBuilderTest.java | 116 +++ .../projection/MapProjectionTestCase.java | 3 +- .../operation/provider/GeographicOffsetsTest.java | 13 +- .../transform/CoordinateSystemTransformTest.java | 42 +- .../transform/DefaultMathTransformFactoryTest.java | 70 -- .../transform/MathTransformFactoryBase.java | 8 + .../transform/MathTransformFactoryMock.java | 42 +- .../main/org/apache/sis/util/privy/Constants.java | 5 + geoapi/snapshot | 2 +- .../sis/storage/shapefile/ShapefileStore.java | 27 +- .../apache/sis/storage/shapefile/dbf/DBFField.java | 22 +- 45 files changed, 2516 insertions(+), 1312 deletions(-) diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java index 2674de752b,7edfc6f93f..8f900fd7a8 --- 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 @@@ -1139,24 -1136,21 +1137,21 @@@ class CoordinateOperationRegistry */ Matrix matrix = MathTransforms.getMatrix(op.getMathTransform()); if (matrix == null) { - if (op instanceof SingleOperation) { + if (SubTypes.isSingleOperation(op)) { - final MathTransformFactory mtFactory = factorySIS.getMathTransformFactory(); - if (mtFactory instanceof DefaultMathTransformFactory) { - if (forward) sourceCRS = toGeodetic3D(sourceCRS, source3D); - else targetCRS = toGeodetic3D(targetCRS, target3D); - final DefaultMathTransformFactory.Context context; - final MathTransform mt; - try { - context = ReferencingUtilities.createTransformContext(sourceCRS, targetCRS); - mt = ((DefaultMathTransformFactory) mtFactory).createParameterizedTransform( - ((SingleOperation) op).getParameterValues(), context); - } catch (InvalidGeodeticParameterException e) { - log(null, e); - break; - } - operations.set(recreate(op, sourceCRS, targetCRS, mt, context.getMethodUsed())); - return true; + if (forward) sourceCRS = toGeodetic3D(sourceCRS, source3D); + else targetCRS = toGeodetic3D(targetCRS, target3D); + final MathTransform.Builder builder; + final MathTransform mt; + try { + final var parameters = ((SingleOperation) op).getParameterValues(); + builder = createTransformBuilder(parameters, sourceCRS, targetCRS); + mt = builder.create(); + } catch (InvalidGeodeticParameterException e) { + log(null, e); + break; } + operations.set(recreate(op, sourceCRS, targetCRS, mt, builder.getMethod().orElse(null))); + return true; } break; } diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConversion.java index 8e5f601b02,cd485a045b..2ee557109e --- 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 @@@ -239,31 -239,22 +243,22 @@@ public class DefaultConversion extends * thanks to the `sourceCRS` argument, we can complete the parameters. */ if (parameters == null) { - throw new IllegalArgumentException(Resources.format(Resources.Keys.UnspecifiedParameterValues)); + throw new InvalidGeodeticParameterException(Resources.format(Resources.Keys.UnspecifiedParameterValues)); } - if (factory instanceof DefaultMathTransformFactory) { - /* - * Apache SIS specific API (not yet defined in GeoAPI, but could be proposed). - * Note that setTarget(…) intentionally uses only the CoordinateSystem instead of the full - * CoordinateReferenceSystem because the targetCRS is typically under construction when this - * method in invoked, and attempts to use it can cause NullPointerException. - */ - final DefaultMathTransformFactory.Context context; - if (target instanceof GeneralDerivedCRS) { - context = ReferencingUtilities.createTransformContext(source, null); - context.setTarget(target.getCoordinateSystem()); // Using `target` would be unsafe here. - } else { - context = ReferencingUtilities.createTransformContext(source, target); - } - transform = ((DefaultMathTransformFactory) factory).createParameterizedTransform(parameters, context); - setParameterValues(context.getCompletedParameters(), context.getContextualParameters()); - } else { - /* - * Fallback for non-SIS implementation. Equivalent to the above code, except that we can - * not get the parameters completed with semi-major and semi-minor axis lengths. Most of - * the code should work anyway. - */ - transform = factory.createBaseToDerived(source, parameters, target.getCoordinateSystem()); + /* + * Note that setTargetAxes(…) intentionally uses only the CoordinateSystem instead of the full + * CoordinateReferenceSystem because the targetCRS is typically under construction when this + * method in invoked, and attempts to use it can cause NullPointerException. + */ - final boolean isDerived = (target instanceof DerivedCRS); ++ final boolean isDerived = (target instanceof GeneralDerivedCRS); + final var builder = new ParameterizedTransformBuilder(factory, null); + builder.setParameters(parameters, true); + builder.setSourceAxes(source); + builder.setTargetAxes(target.getCoordinateSystem(), isDerived ? null : ReferencingUtilities.getEllipsoid(target)); + transform = builder.create(); + if (builder instanceof MathTransformProvider.Context) { + final var context = (MathTransformProvider.Context) builder; + setParameterValues(context.getCompletedParameters(), new HashMap<>(context.getContextualParameters())); } } else { /* @@@ -368,11 -355,8 +362,9 @@@ * parameter values}, or a {@linkplain CoordinateSystems#swapAndScaleAxes change of axis order or units} * failed. * - * @see DefaultMathTransformFactory#createParameterizedTransform(ParameterValueGroup, DefaultMathTransformFactory.Context) - * * @since 1.5 */ + @SuppressWarnings("deprecation") public Conversion specialize(final CoordinateReferenceSystem sourceCRS, final CoordinateReferenceSystem targetCRS, MathTransformFactory factory) throws FactoryException diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java index e920fc06d0,a408b92ac3..ac9393145a --- 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 @@@ -55,36 -44,17 +44,19 @@@ import org.opengis.util.FactoryExceptio import org.opengis.util.NoSuchIdentifierException; import org.apache.sis.io.wkt.Parser; import org.apache.sis.util.ArgumentChecks; - import org.apache.sis.util.ArraysExt; - import org.apache.sis.util.Classes; - import org.apache.sis.util.privy.Strings; import org.apache.sis.util.privy.Constants; - import org.apache.sis.referencing.IdentifiedObjects; - import org.apache.sis.referencing.privy.Formulas; + import org.apache.sis.util.iso.AbstractFactory; + import org.apache.sis.util.collection.WeakHashSet; import org.apache.sis.referencing.privy.CoordinateOperations; - import org.apache.sis.referencing.privy.ReferencingUtilities; - import org.apache.sis.referencing.internal.ParameterizedAffine; - import org.apache.sis.referencing.internal.Resources; import org.apache.sis.referencing.operation.DefaultOperationMethod; - import org.apache.sis.referencing.operation.provider.AbstractProvider; - import org.apache.sis.referencing.operation.provider.VerticalOffset; - import org.apache.sis.referencing.operation.provider.GeographicToGeocentric; - import org.apache.sis.referencing.operation.provider.GeocentricToGeographic; - import org.apache.sis.system.Reflect; - import org.apache.sis.metadata.iso.citation.Citations; - import org.apache.sis.parameter.DefaultParameterValueGroup; - import org.apache.sis.parameter.Parameterized; - import org.apache.sis.parameter.Parameters; - import org.apache.sis.referencing.cs.AxesConvention; - import org.apache.sis.referencing.cs.CoordinateSystems; - import org.apache.sis.referencing.factory.InvalidGeodeticParameterException; import org.apache.sis.referencing.operation.matrix.Matrices; - import org.apache.sis.measure.Units; - import org.apache.sis.util.collection.WeakHashSet; - import org.apache.sis.util.iso.AbstractFactory; - import org.apache.sis.util.logging.Logging; - import org.apache.sis.util.resources.Errors; + import org.apache.sis.referencing.internal.ParameterizedTransformBuilder; + import org.apache.sis.referencing.factory.InvalidGeodeticParameterException; + import org.apache.sis.parameter.DefaultParameterValueGroup; + import org.apache.sis.system.Reflect; ++// Specific to the main and geoapi-3.1 branches: ++import org.apache.sis.util.resources.Errors; /** * Low level factory for creating {@linkplain AbstractMathTransform math transforms}. diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/CoordinateOperations.java index dcd9cc99b3,fbf24e4b88..9034a63ef8 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/CoordinateOperations.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/CoordinateOperations.java @@@ -47,9 -51,11 +51,11 @@@ import org.apache.sis.util.privy.Collec import org.apache.sis.util.privy.Numerics; import org.apache.sis.util.privy.URLs; import org.apache.sis.util.collection.Containers; + import org.apache.sis.util.logging.Logging; + import org.apache.sis.system.Loggers; -// Specific to the geoapi-4.0 branch: -import org.opengis.referencing.crs.DerivedCRS; +// Specific to the main and geoapi-3.1 branches: +import org.opengis.referencing.crs.GeneralDerivedCRS; /** diff --cc geoapi/snapshot index 3a789ec3cf,48d58002a5..cea536768f --- a/geoapi/snapshot +++ b/geoapi/snapshot @@@ -1,1 -1,1 +1,1 @@@ - Subproject commit 3a789ec3cfbbc41a961963bbc1447f0b988185bc -Subproject commit 48d58002a5f500446c1237bf8718f018d0f90982 ++Subproject commit cea536768f975f275f2fb4d32d99274e094f4b53