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 74a6061f9ea89eddb33461af10c672c4dfe920fd
Merge: 883dfe7e9b 7a049f9417
Author: Martin Desruisseaux <martin.desruisse...@geomatys.com>
AuthorDate: Thu Apr 18 17:27:13 2024 +0200

    Merge branch 'geoapi-4.0' into geoapi-3.1: quasi-removal of non-standard 
`Projection` interface.

 .../main/org/apache/sis/xml/XLink.java             |  1 +
 .../sis/referencing/crs/AbstractDerivedCRS.java    | 10 +--
 .../referencing/factory/sql/AuthorityCodes.java    | 45 ++++---------
 .../referencing/factory/sql/EPSGDataAccess.java    | 32 +--------
 .../sis/referencing/factory/sql/TableInfo.java     |  4 +-
 .../operation/AbstractCoordinateOperation.java     |  4 +-
 .../referencing/operation/DefaultConversion.java   | 71 +++++++++-----------
 .../DefaultCoordinateOperationFactory.java         |  6 +-
 .../operation/DefaultOperationMethod.java          | 20 +++---
 .../operation/DefaultPassThroughOperation.java     |  3 +-
 .../referencing/operation/DefaultProjection.java   | 36 +----------
 .../apache/sis/referencing/operation/SubTypes.java | 75 ----------------------
 .../operation/provider/AbstractProvider.java       |  6 +-
 .../operation/provider/Equirectangular.java        |  4 +-
 .../operation/provider/MapProjection.java          |  4 +-
 .../operation/provider/PseudoPlateCarree.java      |  3 -
 .../provider/ZonedTransverseMercator.java          |  4 +-
 .../transform/DefaultMathTransformFactory.java     | 12 ++--
 .../referencing/factory/sql/EPSGFactoryTest.java   | 11 +---
 .../operation/CoordinateOperationFinderTest.java   |  3 +-
 .../operation/DefaultConversionTest.java           | 21 +++---
 .../operation/provider/ProvidersTest.java          |  3 +-
 .../transform/DefaultMathTransformFactoryTest.java | 19 +++---
 .../report/CoordinateOperationMethods.java         |  4 +-
 geoapi/snapshot                                    |  2 +-
 25 files changed, 108 insertions(+), 295 deletions(-)

diff --cc 
endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractDerivedCRS.java
index ebbd881eee,7b2f7e7655..29391a9043
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractDerivedCRS.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractDerivedCRS.java
@@@ -168,7 -165,7 +168,7 @@@ abstract class AbstractDerivedCRS<C ext
              factory = (MathTransformFactory) 
properties.get(ReferencingFactoryContainer.MT_FACTORY);
          }
          try {
-             return 
DefaultConversion.castOrCopy(conversion).specialize(getConversionType(), 
baseCRS, this, factory);
 -            return 
DefaultConversion.castOrCopy(conversion).specialize(baseCRS, this, factory);
++            return 
getConversionType().cast(DefaultConversion.castOrCopy(conversion).specialize(baseCRS,
 this, factory));
          } catch (FactoryException e) {
              throw new 
IllegalArgumentException(Errors.forProperties(properties).getString(
                      Errors.Keys.IllegalArgumentValue_2, "conversion", 
conversion.getName()), e);
@@@ -176,22 -173,7 +176,16 @@@
      }
  
      /**
 -     * Returns the datum of the base CRS.
 +     * Returns the type of conversion associated to this {@code 
AbstractDerivedCRS}.
 +     *
 +     * <p><b>WARNING:</b> this method is invoked (indirectly) at construction 
time.
 +     * Consequently, it shall return a constant value - this method is not 
allowed to
 +     * depend on the object state.</p>
 +     */
 +    abstract Class<C> getConversionType();
 +
-     /**
-      * Returns the GeoAPI interface implemented by this class.
-      */
-     @Override
-     public abstract Class<? extends GeneralDerivedCRS> getInterface();
- 
 +    /**
 +     * Returns the datum of the {@linkplain #getBaseCRS() base CRS}.
       *
       * @return the datum of the base CRS.
       */
diff --cc 
endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConversion.java
index 4aadfc1fa5,90cf08b7bd..44cb55e6e2
--- 
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
@@@ -41,6 -40,6 +41,10 @@@ import org.apache.sis.util.ArgumentChec
  import org.apache.sis.util.Utilities;
  import org.apache.sis.util.resources.Errors;
  
++// Specific to the main and geoapi-3.1 branches:
++import org.opengis.referencing.crs.GeographicCRS;
++import org.opengis.referencing.crs.ProjectedCRS;
++
  
  /**
   * A parameterized mathematical operation that converts coordinates to 
another CRS without any change of
@@@ -219,14 -217,11 +222,12 @@@ public class DefaultConversion extends 
       * @param source      the new source CRS.
       * @param target      the new target CRS.
       * @param factory     the factory to use for creating a transform from 
the parameters or for performing axis changes.
-      * @param actual      an array of length 1 where to store the actual 
operation method used by the math transform factory.
       */
 -    private DefaultConversion(final Conversion definition,
 -                              final CoordinateReferenceSystem source,
 -                              final CoordinateReferenceSystem target,
 -                              final MathTransformFactory factory) throws 
FactoryException
 +    @SuppressWarnings("deprecation")
 +    DefaultConversion(final Conversion definition,
 +                      final CoordinateReferenceSystem source,
 +                      final CoordinateReferenceSystem target,
-                       final MathTransformFactory factory,
-                       final OperationMethod[] actual) throws FactoryException
++                      final MathTransformFactory factory) throws 
FactoryException
      {
          super(definition);
          int interpDim = 
ReferencingUtilities.getDimension(super.getInterpolationCRS().orElse(null));
@@@ -386,13 -359,13 +369,14 @@@
       *         failed.
       *
       * @see 
DefaultMathTransformFactory#createParameterizedTransform(ParameterValueGroup, 
DefaultMathTransformFactory.Context)
+      *
+      * @since 1.5
       */
 +    @SuppressWarnings("deprecation")
-     public <T extends Conversion> T specialize(final Class<T> baseType,
-             final CoordinateReferenceSystem sourceCRS, final 
CoordinateReferenceSystem targetCRS,
-             MathTransformFactory factory) throws FactoryException
+     public Conversion specialize(final CoordinateReferenceSystem sourceCRS,
+                                  final CoordinateReferenceSystem targetCRS,
+                                  MathTransformFactory factory) throws 
FactoryException
      {
-         ArgumentChecks.ensureNonNull("baseType",  baseType);
          ArgumentChecks.ensureNonNull("sourceCRS", sourceCRS);
          ArgumentChecks.ensureNonNull("targetCRS", targetCRS);
          /*
@@@ -413,14 -386,18 +397,23 @@@
               * datum for source and target CRS, since DerivedCRS and 
ProjectedCRS are expected to have the same
               * datum than their source CRS.
               */
-             if (super.getTargetCRS() != null) {
-                 ensureCompatibleDatum("targetCRS", sourceCRS, 
super.getTargetCRS());
-             }
+             ensureCompatibleDatum("targetCRS", sourceCRS, 
super.getTargetCRS());
+         }
++        final boolean isProjection = (targetCRS instanceof ProjectedCRS) && 
(sourceCRS instanceof GeographicCRS);
+         if (super.getSourceCRS() == sourceCRS &&
+             super.getTargetCRS() == targetCRS &&
 -            super.getMathTransform() != null)
++            super.getMathTransform() != null &&
++            isProjection == (this instanceof Projection))
+         {
+             return this;
          }
          if (factory == null) {
              factory = DefaultMathTransformFactory.provider();
          }
-         return SubTypes.create(baseType, this, sourceCRS, targetCRS, factory);
++        if (isProjection) {
++            return new DefaultProjection(this, sourceCRS, targetCRS, factory);
++        }
+         return new DefaultConversion(this, sourceCRS, targetCRS, factory);
      }
  
      /**
diff --cc 
endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java
index 1903225188,65fbd9cc84..546f1e0f94
--- 
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
@@@ -556,19 -554,9 +556,15 @@@ next:   for (int i=components.size(); -
           */
          if (baseType == SingleOperation.class) {
              if (isConversion(sourceCRS, targetCRS)) {
 -                baseType = Conversion.class;
 +                if (interpolationCRS == null && sourceCRS instanceof 
GeographicCRS
 +                                             && targetCRS instanceof 
ProjectedCRS)
 +                {
 +                    baseType = Projection.class;
 +                } else {
 +                    baseType = Conversion.class;
 +                }
              } else {
+                 // TODO: handle point motion operation.
                  baseType = Transformation.class;
              }
          }
diff --cc 
endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultProjection.java
index fe4ab2a377,0000000000..b8243c7e96
mode 100644,000000..100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultProjection.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultProjection.java
@@@ -1,139 -1,0 +1,109 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one or more
 + * contributor license agreements.  See the NOTICE file distributed with
 + * this work for additional information regarding copyright ownership.
 + * The ASF licenses this file to You under the Apache License, Version 2.0
 + * (the "License"); you may not use this file except in compliance with
 + * the License.  You may obtain a copy of the License at
 + *
 + *     http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing, software
 + * distributed under the License is distributed on an "AS IS" BASIS,
 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 + * See the License for the specific language governing permissions and
 + * limitations under the License.
 + */
 +package org.apache.sis.referencing.operation;
 +
 +import java.util.Map;
 +import jakarta.xml.bind.annotation.XmlTransient;
 +import org.opengis.util.FactoryException;
 +import org.opengis.referencing.operation.Conversion;
 +import org.opengis.referencing.operation.Projection;
 +import org.opengis.referencing.operation.OperationMethod;
 +import org.opengis.referencing.operation.MathTransform;
 +import org.opengis.referencing.operation.MathTransformFactory;
 +import org.opengis.referencing.crs.ProjectedCRS;
 +import org.opengis.referencing.crs.GeographicCRS;
 +import org.opengis.referencing.crs.CoordinateReferenceSystem;
 +import org.apache.sis.util.ArgumentChecks;
 +
 +
 +/**
 + * A conversion from (<var>longitude</var>, <var>latitude</var>) coordinates 
to Cartesian coordinates
 + * (<var>x</var>,<var>y</var>).
 + *
-  * <p>An unofficial list of projections and their parameters can be found
-  * <a href="http://geotiff.maptools.org/proj_list/";>there</a>.
-  * Most projections expect the following parameters:</p>
-  *
-  * <ul>
-  *   <li>{@code "central_meridian"} (default to 0),
-  *   <li>{@code "latitude_of_origin"} (default to 0),
-  *   <li>{@code "scale_factor"} (default to 1),
-  *   <li>{@code "false_easting"} (default to 0) and
-  *   <li>{@code "false_northing"} (default to 0).
-  * </ul>
-  *
 + * @author  Martin Desruisseaux (IRD, Geomatys)
 + *
 + * @see org.apache.sis.referencing.crs.DefaultProjectedCRS
 + */
 +@XmlTransient
 +final class DefaultProjection extends DefaultConversion implements Projection 
{
 +    /**
 +     * Serial number for inter-operability with different versions.
 +     */
 +    private static final long serialVersionUID = -7176751851369816864L;
 +
 +    /**
 +     * Creates a projection from the given properties.
 +     *
 +     * @param  properties  the properties to be given to the identified 
object.
 +     * @param  sourceCRS   the source CRS.
 +     * @param  targetCRS   the target CRS.
 +     * @param  method      the coordinate operation method.
 +     * @param  transform   transform from positions in the source CRS to 
positions in the target CRS.
 +     */
 +    public DefaultProjection(final Map<String,?>   properties,
 +                             final GeographicCRS   sourceCRS,
 +                             final ProjectedCRS    targetCRS,
 +                             final OperationMethod method,
 +                             final MathTransform   transform)
 +    {
 +        super(properties, sourceCRS, targetCRS, null, method, transform);
 +    }
 +
 +    /**
 +     * Creates a new projection with the same values as the specified one, 
together with the
 +     * specified source and target CRS. While the source conversion can be an 
arbitrary one,
 +     * it is typically a defining conversion.
 +     *
 +     * @param  definition  the defining conversion.
 +     * @param  sourceCRS   the source CRS.
 +     * @param  targetCRS   the target CRS.
 +     * @param  factory     the factory to use for creating a transform from 
the parameters or for performing axis changes.
-      * @param  actual      an array of length 1 where to store the actual 
operation method used by the math transform factory.
-      * @throws IllegalArgumentException if the source or targe CRS is not of 
the requested type.
++     * @throws IllegalArgumentException if the source or targe CRS is not of 
the expected types.
 +     */
 +    DefaultProjection(final Conversion definition,
 +                      final CoordinateReferenceSystem sourceCRS,
 +                      final CoordinateReferenceSystem targetCRS,
-                       final MathTransformFactory factory,
-                       final OperationMethod[] actual) throws FactoryException
++                      final MathTransformFactory factory) throws 
FactoryException
 +    {
-         super(definition, sourceCRS, targetCRS, factory, actual);
++        super(definition, sourceCRS, targetCRS, factory);
 +        ArgumentChecks.ensureCanCast("sourceCRS", GeographicCRS.class, 
sourceCRS);
 +        ArgumentChecks.ensureCanCast("targetCRS", ProjectedCRS .class, 
targetCRS);
 +    }
 +
 +    /**
 +     * Creates a new coordinate operation with the same values as the 
specified one.
 +     * This copy constructor provides a way to convert an arbitrary 
implementation
 +     * into a SIS one, usually in order to leverage some 
implementation-specific API.
 +     *
 +     * <p>This constructor performs a shallow copy, i.e. the properties are 
not cloned.</p>
 +     *
 +     * @param  operation  the coordinate operation to copy.
 +     */
 +    protected DefaultProjection(final Projection operation) {
 +        super(operation);
 +    }
 +
 +    /**
 +     * Returns the GeoAPI interface implemented by this class.
 +     *
 +     * @return the conversion interface implemented by this class.
 +     */
 +    @Override
 +    public Class<? extends Projection> getInterface() {
 +        return Projection.class;
 +    }
- 
-     /**
-      * Returns the source CRS, which must be geographic or {@code null}.
-      */
-     @Override
-     public final GeographicCRS getSourceCRS() {
-         return (GeographicCRS) super.getSourceCRS();
-     }
- 
-     /**
-      * Returns the target CRS, which must be projected or {@code null}.
-      */
-     @Override
-     public final ProjectedCRS getTargetCRS() {
-         return (ProjectedCRS) super.getTargetCRS();
-     }
 +}
diff --cc geoapi/snapshot
index b6f55a7306,1dd682e1b3..0eadc94db1
--- a/geoapi/snapshot
+++ b/geoapi/snapshot
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit b6f55a7306de16494d1d9c49c91be18a2438dc0e
 -Subproject commit 1dd682e1b3950d7024b17f6639673b896f701441
++Subproject commit 0eadc94db1598764a6b96ed990a41ef92c502748

Reply via email to