sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1723436 - in /sis/branches/JDK8/core/sis-referencing/src: main/java/org/apache/sis/referencing/factory/ main/java/org/apache/sis/referencing/factory/sql/ main/java/org/apache/sis/referencing/operation/ test/java/org/apache/sis/referencing/...
Date Wed, 06 Jan 2016 23:31:56 GMT
Author: desruisseaux
Date: Wed Jan  6 23:31:55 2016
New Revision: 1723436

URL: http://svn.apache.org/viewvc?rev=1723436&view=rev
Log:
Test and debug IdentifiedObjectFinder for ProjectedCRS.

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConicProjection.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConversion.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCylindricalProjection.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPlanarProjection.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultProjection.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/SubTypes.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java?rev=1723436&r1=1723435&r2=1723436&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java
[UTF-8] Wed Jan  6 23:31:55 2016
@@ -1815,8 +1815,10 @@ public abstract class ConcurrentAuthorit
             /*
              * If the full scan was allowed, then stores the result even if empty so
              * we can remember that no object has been found for the given argument.
+             * Note that we need to distinguish whether deprecated objects are included or
not.
+             * Since the need to include deprecated objects should be rare, we do not cache
them.
              */
-            if (isFullScanAllowed()) {
+            if (isFullScanAllowed() && !getIncludeDeprecated()) {
                 candidate = CollectionsExt.unmodifiableOrCopy(candidate);
                 Set<IdentifiedObject> concurrent;
                 synchronized (findPool) {

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java?rev=1723436&r1=1723435&r2=1723436&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java
[UTF-8] Wed Jan  6 23:31:55 2016
@@ -438,6 +438,7 @@ public class IdentifiedObjectFinder {
                 if (!strict && Utilities.deepEquals(candidate, object, ComparisonMode.IGNORE_METADATA))
{
                     /*
                      * If we find at least one object without rounding error, do not accept
rounding error for anyone.
+                     * The most typical case is when comparing ellipsoids.
                      */
                     result.clear();
                     strict = true;

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java?rev=1723436&r1=1723435&r2=1723436&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
[UTF-8] Wed Jan  6 23:31:55 2016
@@ -2589,17 +2589,8 @@ addURIs:    for (int i=0; ; i++) {
                          * final operation (a Conversion or a Transformation). We need to
give to MathTransformFactory
                          * some information about the context (source and target CRS) for
allowing the factory to set
                          * the values of above-mentioned implicit parameters (semi-major
and semi-minor axis lengths).
-                         */
-                        final Class<? extends SingleOperation> expected;
-                        if (isTransformation) {
-                            expected = Transformation.class;
-                        } else if (isConversion) {
-                            expected = Conversion.class;
-                        } else {
-                            throw new FactoryDataException(error().getString(Errors.Keys.UnknownType_1,
type));
-                        }
-                        /*
-                         * Following special case may be removed in a future SIS version
if the missing method is added
+                         *
+                         * The first special case may be removed in a future SIS version
if the missing method is added
                          * to GeoAPI. Actually GeoAPI has a method doing part of the job,
but incomplete (e.g. the pure
                          * GeoAPI method can not handle Molodensky transform because it does
not give the target datum).
                          */
@@ -2614,7 +2605,28 @@ addURIs:    for (int i=0; ; i++) {
                             // Fallback for non-SIS implementations. Work for map projections
but not for Molodensky.
                             mt = mtFactory.createBaseToDerived(sourceCRS, parameters, targetCRS.getCoordinateSystem());
                         }
-                        opProperties.put(ReferencingServices.OPERATION_TYPE_KEY, expected);
+                        /*
+                         * Give a hint to the factory about the type of the coordinate operation.
ISO 19111 defines
+                         * Conversion and Transformation, but SIS also have more specific
sub-types.  We begin with
+                         * what we can infer from the EPSG database.  Next, if the SIS MathTransform
providers give
+                         * more information, then we refine the type.
+                         */
+                        Class<? extends SingleOperation> opType;
+                        if (isTransformation) {
+                            opType = Transformation.class;
+                        } else if (isConversion) {
+                            opType = Conversion.class;
+                        } else {
+                            opType = SingleOperation.class;
+                        }
+                        final OperationMethod provider = mtFactory.getLastMethodUsed();
+                        if (provider instanceof DefaultOperationMethod) {               
 // SIS-specific
+                            final Class<?> s = ((DefaultOperationMethod) provider).getOperationType();
+                            if (s != null && opType.isAssignableFrom(s)) {
+                                opType = s.asSubclass(SingleOperation.class);
+                            }
+                        }
+                        opProperties.put(ReferencingServices.OPERATION_TYPE_KEY, opType);
                         /*
                          * Following restriction will be removed in a future SIS version
if the method is added to GeoAPI.
                          */

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConicProjection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConicProjection.java?rev=1723436&r1=1723435&r2=1723436&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConicProjection.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConicProjection.java
[UTF-8] Wed Jan  6 23:31:55 2016
@@ -74,13 +74,15 @@ final class DefaultConicProjection exten
      * @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.
      */
     DefaultConicProjection(final Conversion definition,
                            final CoordinateReferenceSystem sourceCRS,
                            final CoordinateReferenceSystem targetCRS,
-                           final MathTransformFactory factory) throws FactoryException
+                           final MathTransformFactory factory,
+                           final OperationMethod[] actual) throws FactoryException
     {
-        super(definition, sourceCRS, targetCRS, factory);
+        super(definition, sourceCRS, targetCRS, factory, actual);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConversion.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConversion.java?rev=1723436&r1=1723435&r2=1723436&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConversion.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConversion.java
[UTF-8] Wed Jan  6 23:31:55 2016
@@ -227,11 +227,13 @@ public class DefaultConversion extends A
      * @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.
      */
     DefaultConversion(final Conversion definition,
                       final CoordinateReferenceSystem source,
                       final CoordinateReferenceSystem target,
-                      final MathTransformFactory factory) throws FactoryException
+                      final MathTransformFactory factory,
+                      final OperationMethod[] actual) throws FactoryException
     {
         super(definition);
         int interpDim = ReferencingUtilities.getDimension(super.getInterpolationCRS());
@@ -265,6 +267,7 @@ public class DefaultConversion extends A
                  */
                 transform = factory.createBaseToDerived(source, parameters, target.getCoordinateSystem());
             }
+            actual[0] = factory.getLastMethodUsed();
         } else {
             /*
              * If the user specified explicitely a MathTransform, we may still need to swap
or scale axes.

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCylindricalProjection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCylindricalProjection.java?rev=1723436&r1=1723435&r2=1723436&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCylindricalProjection.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCylindricalProjection.java
[UTF-8] Wed Jan  6 23:31:55 2016
@@ -74,13 +74,15 @@ final class DefaultCylindricalProjection
      * @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.
      */
     DefaultCylindricalProjection(final Conversion definition,
                                  final CoordinateReferenceSystem sourceCRS,
                                  final CoordinateReferenceSystem targetCRS,
-                                 final MathTransformFactory factory) throws FactoryException
+                                 final MathTransformFactory factory,
+                                 final OperationMethod[] actual) throws FactoryException
     {
-        super(definition, sourceCRS, targetCRS, factory);
+        super(definition, sourceCRS, targetCRS, factory, actual);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPlanarProjection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPlanarProjection.java?rev=1723436&r1=1723435&r2=1723436&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPlanarProjection.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPlanarProjection.java
[UTF-8] Wed Jan  6 23:31:55 2016
@@ -74,13 +74,15 @@ final class DefaultPlanarProjection exte
      * @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.
      */
     DefaultPlanarProjection(final Conversion definition,
                             final CoordinateReferenceSystem sourceCRS,
                             final CoordinateReferenceSystem targetCRS,
-                            final MathTransformFactory factory) throws FactoryException
+                            final MathTransformFactory factory,
+                            final OperationMethod[] actual) throws FactoryException
     {
-        super(definition, sourceCRS, targetCRS, factory);
+        super(definition, sourceCRS, targetCRS, factory, actual);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultProjection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultProjection.java?rev=1723436&r1=1723435&r2=1723436&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultProjection.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultProjection.java
[UTF-8] Wed Jan  6 23:31:55 2016
@@ -87,13 +87,15 @@ class DefaultProjection extends DefaultC
      * @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.
      */
     DefaultProjection(final Conversion definition,
                       final CoordinateReferenceSystem sourceCRS,
                       final CoordinateReferenceSystem targetCRS,
-                      final MathTransformFactory factory) throws FactoryException
+                      final MathTransformFactory factory,
+                      final OperationMethod[] actual) throws FactoryException
     {
-        super(definition, sourceCRS, targetCRS, factory);
+        super(definition, sourceCRS, targetCRS, factory, actual);
         ArgumentChecks.ensureCanCast("sourceCRS", GeographicCRS.class, sourceCRS);
         ArgumentChecks.ensureCanCast("targetCRS", ProjectedCRS .class, targetCRS);
     }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/SubTypes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/SubTypes.java?rev=1723436&r1=1723435&r2=1723436&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/SubTypes.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/SubTypes.java
[UTF-8] Wed Jan  6 23:31:55 2016
@@ -36,7 +36,7 @@ import org.apache.sis.referencing.Abstra
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.6
- * @version 0.6
+ * @version 0.7
  * @module
  */
 final class SubTypes {
@@ -126,7 +126,7 @@ final class SubTypes {
      *         the defining {@linkplain DefaultConversion#getInterface() conversion type}
and
      *         the {@linkplain DefaultOperationMethod#getOperationType() method operation
type}.
      */
-    static <T extends Conversion> T create(final Class<T> baseType, final Conversion
definition,
+    static <T extends Conversion> T create(final Class<T> baseType, Conversion
definition,
             final CoordinateReferenceSystem sourceCRS, final CoordinateReferenceSystem targetCRS,
             final MathTransformFactory factory) throws FactoryException
     {
@@ -144,23 +144,44 @@ final class SubTypes {
                 type = c.asSubclass(type);
             }
         }
-        final Conversion conversion;
+        Conversion conversion;
         if (type.isInstance(definition)
                 && definition.getSourceCRS() == sourceCRS
                 && definition.getTargetCRS() == targetCRS
                 && definition.getMathTransform() != null)
         {
             conversion = definition;
-        } else if (CylindricalProjection.class.isAssignableFrom(type)) {
-            conversion = new DefaultCylindricalProjection(definition, sourceCRS, targetCRS,
factory);
-        } else if (ConicProjection.class.isAssignableFrom(type)) {
-            conversion = new DefaultConicProjection(definition, sourceCRS, targetCRS, factory);
-        } else if (PlanarProjection.class.isAssignableFrom(type)) {
-            conversion = new DefaultPlanarProjection(definition, sourceCRS, targetCRS, factory);
-        } else if (Projection.class.isAssignableFrom(type)) {
-            conversion = new DefaultProjection(definition, sourceCRS, targetCRS, factory);
         } else {
-            conversion = new DefaultConversion(definition, sourceCRS, targetCRS, factory);
+            final OperationMethod[] actual = new OperationMethod[1];
+            boolean tryAgain;
+            do {
+                tryAgain = false;
+                if (CylindricalProjection.class.isAssignableFrom(type)) {
+                    conversion = new DefaultCylindricalProjection(definition, sourceCRS,
targetCRS, factory, actual);
+                } else if (ConicProjection.class.isAssignableFrom(type)) {
+                    conversion = new DefaultConicProjection(definition, sourceCRS, targetCRS,
factory, actual);
+                } else if (PlanarProjection.class.isAssignableFrom(type)) {
+                    conversion = new DefaultPlanarProjection(definition, sourceCRS, targetCRS,
factory, actual);
+                } else if (Projection.class.isAssignableFrom(type)) {
+                    conversion = new DefaultProjection(definition, sourceCRS, targetCRS,
factory, actual);
+                } else {
+                    conversion = new DefaultConversion(definition, sourceCRS, targetCRS,
factory, actual);
+                }
+                /*
+                 * The DefaultConversion constructor may have used by MathTransformFactory
for creating the actual
+                 * MathTransform object. In such case, we can use the knownledge that the
factory has about the
+                 * coordinate operation for refining again the type of the object to be returned.
+                 */
+                final OperationMethod m = actual[0];
+                if (m instanceof DefaultOperationMethod) {
+                    final Class<?> t = ((DefaultOperationMethod) m).getOperationType();
+                    if (t != null && t != type && type.isAssignableFrom(t))
{
+                        type = t.asSubclass(type);
+                        definition = conversion;
+                        tryAgain = true;
+                    }
+                }
+            } while (tryAgain);
         }
         return type.cast(conversion);
     }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java?rev=1723436&r1=1723435&r2=1723436&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
[UTF-8] Wed Jan  6 23:31:55 2016
@@ -19,6 +19,7 @@ package org.apache.sis.referencing.facto
 import java.util.Set;
 import java.util.List;
 import java.util.Locale;
+import java.util.Iterator;
 import org.opengis.metadata.extent.GeographicBoundingBox;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.referencing.IdentifiedObject;
@@ -27,9 +28,9 @@ import org.opengis.referencing.crs.*;
 import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.operation.Conversion;
-import org.opengis.referencing.operation.Projection;
 import org.opengis.referencing.operation.Transformation;
 import org.opengis.referencing.operation.CoordinateOperation;
+import org.opengis.referencing.operation.CylindricalProjection;
 import org.opengis.referencing.operation.OperationMethod;
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.util.FactoryException;
@@ -583,7 +584,7 @@ public final strictfp class EPSGFactoryT
         assertEpsgNameAndIdentifierEqual("UTM zone 10N", 16010, projection);
         assertNotSame("The defining conversion and the actual conversion should differ since
the "
                 + "actual conversion should have semi-axis length values.", projection, operation);
-        assertInstanceOf("EPSG::16010", Projection.class, projection);
+        assertInstanceOf("EPSG::16010", CylindricalProjection.class, projection);
         assertNotNull("sourceCRS", projection.getSourceCRS());
         assertNotNull("targetCRS", projection.getTargetCRS());
         assertNotNull("transform", projection.getMathTransform());
@@ -766,4 +767,58 @@ public final strictfp class EPSGFactoryT
         finder.setFullScanAllowed(false);
         assertSame("The CRS should still in the cache.", found, finder.findSingleton(crs));
     }
+
+    /**
+     * Tests {@link EPSGFactory#newIdentifiedObjectFinder()} method with a projected CRS.
+     *
+     * @throws FactoryException if an error occurred while querying the factory.
+     */
+    @Test
+    @DependsOnMethod("testFindGeographic")
+    public void testFindProjected() throws FactoryException {
+        assumeNotNull(factory);
+        final IdentifiedObjectFinder finder = factory.newIdentifiedObjectFinder();
+        /*
+         * The PROJCS below intentionally uses a name different from the one found in the
+         * EPSG database, in order to force a full scan (otherwise the EPSG database would
+         * find it by name, but we want to test the scan).
+         */
+        final CoordinateReferenceSystem crs = CRS.fromWKT(
+                "PROJCS[“Beijing 1954 (modified)”,\n" +
+                "   GEOGCS[“Beijing 1954 (modified)”,\n" +
+                "     DATUM[“Beijing 1954”,\n" +                                    
           // Datum name matter.
+                "       SPHEROID[“Krassowsky 1940”, 6378245.00000006, 298.299999999998]],\n"
+  // Intentional rounding error.
+                "     PRIMEM[“Greenwich”, 0.0],\n" +
+                "     UNIT[“degree”, 0.017453292519943295],\n" +
+                "     AXIS[“Geodetic latitude”, NORTH],\n" +
+                "     AXIS[“Geodetic longitude”, EAST]],\n" +
+                "   PROJECTION[“Transverse Mercator”],\n" +
+                "   PARAMETER[“central_meridian”, 135.0000000000013],\n" +      // Intentional
rounding error.
+                "   PARAMETER[“latitude_of_origin”, 0.0],\n" +
+                "   PARAMETER[“scale_factor”, 1.0],\n" +
+                "   PARAMETER[“false_easting”, 500000.000000004],\n" +          // Intentional
rounding error.
+                "   PARAMETER[“false_northing”, 0.0],\n" +
+                "   UNIT[“m”, 1.0],\n" +
+                "   AXIS[“Northing”, NORTH],\n" +
+                "   AXIS[“Easting”, EAST]]");
+
+        finder.setFullScanAllowed(false);
+        assertTrue("Should not find the CRS without a full scan.", finder.find(crs).isEmpty());
+
+        finder.setFullScanAllowed(true);
+        final Set<IdentifiedObject> find = finder.find(crs);
+        assertFalse("With full scan allowed, the CRS should be found.", find.isEmpty());
+        /*
+         * Both EPSG:2442 and EPSG:21463 defines the same projection with the same parameters
+         * and the same base GeographicCRS (EPSG:4214). The only difference I found was the
+         * area of validity...
+         *
+         * Note that there is also a EPSG:21483 code, but that one is deprecated and should
+         * not be selected in this test.
+         */
+        final Iterator<IdentifiedObject> it = find.iterator();
+        assertEpsgNameAndIdentifierEqual("Beijing 1954 / 3-degree Gauss-Kruger CM 135E",
 2442, it.next());
+        assertEpsgNameAndIdentifierEqual("Beijing 1954 / Gauss-Kruger CM 135E", 21463, it.next());
+        assertFalse("Expected no more element.", it.hasNext());
+    }
 }



Mime
View raw message