sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1726717 [2/4] - in /sis/branches/JDK7: ./ core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/ core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ core/s...
Date Tue, 26 Jan 2016 00:12:36 GMT
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java?rev=1726717&r1=1726716&r2=1726717&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java [UTF-8] Tue Jan 26 00:12:35 2016
@@ -26,16 +26,14 @@ import javax.measure.unit.Unit;
 import javax.measure.quantity.Duration;
 import org.opengis.util.FactoryException;
 import org.opengis.util.InternationalString;
-import org.opengis.util.NoSuchIdentifierException;
-import org.opengis.referencing.NoSuchAuthorityCodeException;
 import org.opengis.referencing.IdentifiedObject;
+import org.opengis.referencing.AuthorityFactory;
 import org.opengis.referencing.crs.GeodeticCRS;
 import org.opengis.referencing.crs.VerticalCRS;
 import org.opengis.referencing.crs.TemporalCRS;
 import org.opengis.referencing.crs.GeographicCRS;
 import org.opengis.referencing.crs.GeocentricCRS;
 import org.opengis.referencing.crs.ProjectedCRS;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.opengis.referencing.crs.CRSAuthorityFactory;
 import org.opengis.referencing.cs.TimeCS;
 import org.opengis.referencing.cs.VerticalCS;
@@ -66,7 +64,6 @@ import org.apache.sis.internal.system.Sy
 import org.apache.sis.internal.system.Modules;
 import org.apache.sis.internal.system.Loggers;
 import org.apache.sis.util.resources.Vocabulary;
-import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.math.MathFunctions;
@@ -75,11 +72,6 @@ import org.apache.sis.measure.Units;
 
 import static java.util.Collections.singletonMap;
 import static org.opengis.referencing.IdentifiedObject.NAME_KEY;
-import static org.apache.sis.internal.util.Constants.CRS;
-import static org.apache.sis.internal.util.Constants.EPSG;
-import static org.apache.sis.internal.util.Constants.CRS27;
-import static org.apache.sis.internal.util.Constants.CRS83;
-import static org.apache.sis.internal.util.Constants.CRS84;
 
 // Branch-dependent imports
 import org.apache.sis.internal.jdk8.JDK8;
@@ -923,26 +915,6 @@ public enum CommonCRS {
         return crs;
     }
 
-    /**
-     * Returns the CRS for the given EPSG code, or {@code null} if none.
-     * This is a helper method for {@link #forCode(String, String, FactoryException)} only.
-     */
-    private CoordinateReferenceSystem forCode(final int code) {
-        if (code == geographic) return geographic();
-        if (code == geocentric) return geocentric();
-        if (code == geo3D)      return geographic3D();
-        final double latitude;
-        int zone;
-        if (northUTM != 0 && (zone = code - northUTM) >= firstZone && zone <= lastZone) {
-            latitude = +1;
-        } else if (southUTM != 0 && (zone = code - southUTM) >= firstZone && zone <= lastZone) {
-            latitude = -1;
-        } else {
-            return null;
-        }
-        return UTM(latitude, TransverseMercator.centralMeridian(zone));
-    }
-
 
 
 
@@ -1540,7 +1512,13 @@ public enum CommonCRS {
      * If this method returns {@code null}, then the caller will silently fallback on hard-coded values.
      */
     static CRSAuthorityFactory crsFactory() {
-        return null; // TODO
+        if (!EPSGFactoryFallback.FORCE_HARDCODED) {
+            final AuthorityFactory factory = AuthorityFactories.EPSG();
+            if (!(factory instanceof EPSGFactoryFallback)) {
+                return (CRSAuthorityFactory) factory;
+            }
+        }
+        return null;
     }
 
     /**
@@ -1548,7 +1526,13 @@ public enum CommonCRS {
      * If this method returns {@code null}, then the caller will silently fallback on hard-coded values.
      */
     static DatumAuthorityFactory datumFactory() {
-        return null; // TODO
+        if (!EPSGFactoryFallback.FORCE_HARDCODED) {
+            final AuthorityFactory factory = AuthorityFactories.EPSG();
+            if (!(factory instanceof EPSGFactoryFallback)) {
+                return (DatumAuthorityFactory) factory;
+            }
+        }
+        return null;
     }
 
     /**
@@ -1558,61 +1542,4 @@ public enum CommonCRS {
     static void failure(final Object caller, final String method, final FactoryException e) {
         Logging.unexpectedException(Logging.getLogger(Loggers.CRS_FACTORY), caller.getClass(), method, e);
     }
-
-    /**
-     * Returns a coordinate reference system for the given authority code.
-     * This method is invoked as a fallback when {@link CRS#forCode(String)}
-     * can not create a CRS for a given code.
-     *
-     * @param authority The authority, either {@code "CRS"} or {@code "EPSG"} (case-insensitive).
-     * @param code      The code, to be parsed as an integer.
-     * @param failure   The exception to throw in case of failure, or {@code null} for creating our own.
-     *                  A non-null value is provided when a real EPSG factory exists but failed to create the CRS.
-     *                  In such case, we want to report the error from the real factory instead than from this fallback.
-     *
-     * @since 0.5
-     */
-    static CoordinateReferenceSystem forCode(final String authority, final String code, final FactoryException failure)
-            throws FactoryException
-    {
-        NumberFormatException cause = null;
-        try {
-            if (authority.equalsIgnoreCase(CRS)) {
-                switch (Integer.parseInt(code)) {
-                    case CRS27: return CommonCRS.NAD27.normalizedGeographic();
-                    case CRS83: return CommonCRS.NAD83.normalizedGeographic();
-                    case CRS84: return CommonCRS.WGS84.normalizedGeographic();
-                }
-            } else if (authority.equalsIgnoreCase(EPSG)) {
-                final int n = Integer.parseInt(code);
-                if (n != 0) { // CommonCRS uses 0 as a sentinel value for "no EPSG code".
-                    for (final CommonCRS candidate : CommonCRS.values()) {
-                        final CoordinateReferenceSystem crs = candidate.forCode(n);
-                        if (crs != null) {
-                            return crs;
-                        }
-                    }
-                    for (final CommonCRS.Vertical candidate : CommonCRS.Vertical.values()) {
-                        if (candidate.isEPSG && candidate.crs == n) {
-                            return candidate.crs();
-                        }
-                    }
-                }
-            } else if (failure != null) {
-                throw failure;
-            } else {
-                throw new NoSuchIdentifierException(Errors.format(Errors.Keys.UnknownAuthority_1, authority), authority);
-            }
-        } catch (NumberFormatException e) {
-            cause = e;
-        }
-        if (failure != null) {
-            throw failure;
-        }
-        final NoSuchAuthorityCodeException e = new NoSuchAuthorityCodeException(
-                Errors.format(Errors.Keys.NoSuchAuthorityCode_3, authority, CoordinateReferenceSystem.class, code),
-                authority, code, code);
-        e.initCause(cause);
-        throw e;
-    }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java?rev=1726717&r1=1726716&r2=1726717&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java [UTF-8] Tue Jan 26 00:12:35 2016
@@ -113,12 +113,12 @@ final class StandardDefinitions {
 
     /**
      * Adds to the given properties an additional identifier in the {@code "CRS"} namespace.
-     * This method presume that the only identifier that existed before this method call was the EPSG one.
+     * This method presumes that the only identifier that existed before this method call was the EPSG one.
      */
     private static void addWMS(final Map<String,Object> properties, final String code) {
         properties.put(IDENTIFIERS_KEY, new NamedIdentifier[] {
             (NamedIdentifier) properties.get(IDENTIFIERS_KEY),
-            new NamedIdentifier(Citations.OGC, code)
+            new NamedIdentifier(Citations.WMS, code)
         });
     }
 

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java?rev=1726717&r1=1726716&r2=1726717&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java [UTF-8] Tue Jan 26 00:12:35 2016
@@ -260,7 +260,7 @@ public class DefaultGeographicCRS extend
                     final int i = Arrays.binarySearch(EPSG_CODES, Short.parseShort(identifier.getCode()));
                     if (i >= 0) {
                         final Map<String,Object> c = new HashMap<>(properties);
-                        c.put(IDENTIFIERS_KEY, new ImmutableIdentifier(Citations.OGC, CRS, Short.toString(CRS_CODES[i])));
+                        c.put(IDENTIFIERS_KEY, new ImmutableIdentifier(Citations.WMS, CRS, Short.toString(CRS_CODES[i])));
                         properties = c;
                     }
                 } catch (NumberFormatException e) {

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java?rev=1726717&r1=1726716&r2=1726717&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java [UTF-8] Tue Jan 26 00:12:35 2016
@@ -72,24 +72,24 @@ import java.util.Objects;
  * and apply the interpolated translations on coordinate values in their own step between above steps 3 and 4.
  *
  * <div class="note"><b>Use cases:</b>
- * <ul>
- *   <li><p><b>Datum shift by geographic translations</b><br>
+ * <ul class="verbose">
+ *   <li><b>Datum shift by geographic translations</b><br>
  *   NADCON and NTv2 grids are defined with longitude (<var>λ</var>) and latitude (<var>φ</var>) inputs in angular
  *   <em>degrees</em> and give (<var>Δλ</var>, <var>Δφ</var>) translations in angular <em>seconds</em>.
  *   However SIS stores the translation values in units of grid cell rather than angular seconds.
  *   The translations will be applied by {@link org.apache.sis.referencing.operation.transform.InterpolatedTransform}
  *   directly on the given (<var>λ</var>,<var>φ</var>) coordinates.
- *   </p></li>
+ *   </li>
  *
- *   <li><p><b>Datum shift by geocentric translations</b><br>
+ *   <li><b>Datum shift by geocentric translations</b><br>
  *   France interpolation grid is defined with longitude (<var>λ</var>) and latitude (<var>φ</var>) inputs in angular
  *   <em>degrees</em> and gives (<var>ΔX</var>, <var>ΔY</var>, <var>ΔZ</var>) geocentric translations in <em>metres</em>.
  *   Those translations will not be added directly to the given (<var>λ</var>,<var>φ</var>) coordinates since there is
  *   a geographic/geocentric conversion in the middle
  *   (see {@link org.apache.sis.referencing.operation.transform.InterpolatedGeocentricTransform}).
- *   </p></li>
+ *   </li>
  *
- *   <li><p><b>Localization grid of raster data</b><br>
+ *   <li><b>Localization grid of raster data</b><br>
  *   Some remote sensing raster data are provided with a <cite>localization grid</cite> giving pixel coordinates
  *   (e.g. latitude and longitude). This can been seen as a change from {@linkplain DefaultImageDatum image datum}
  *   to {@linkplain DefaultGeodeticDatum geodetic datum}. The coordinate transformation process can sometime be
@@ -97,7 +97,7 @@ import java.util.Objects;
  *   {@linkplain org.apache.sis.referencing.operation.builder.LinearTransformBuilder first approximation},
  *   followed by small corrections for the residual part.
  *   {@code DatumShiftGrid} can describe the small corrections part.
- *   </p></li>
+ *   </li>
  * </ul></div>
  *
  * Implementations of this class shall be immutable and thread-safe.

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java?rev=1726717&r1=1726716&r2=1726717&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java [UTF-8] Tue Jan 26 00:12:35 2016
@@ -16,6 +16,9 @@
  */
 package org.apache.sis.referencing.factory;
 
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Locale;
 import javax.measure.unit.Unit;
 import org.opengis.referencing.cs.*;
 import org.opengis.referencing.crs.*;
@@ -26,6 +29,7 @@ import org.opengis.referencing.Authority
 import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.metadata.extent.Extent;
 import org.opengis.util.FactoryException;
+import org.opengis.util.InternationalString;
 import org.apache.sis.util.resources.Errors;
 
 
@@ -64,10 +68,17 @@ abstract class AuthorityFactoryProxy<T>
     final Class<T> type;
 
     /**
+     * The type of factory needed for creating objects,
+     * as one of the constants defined in {@link AuthorityFactoryIdentifier}.
+     */
+    final byte factoryType;
+
+    /**
      * Creates a new proxy for objects of the given type.
      */
-    AuthorityFactoryProxy(final Class<T> type) {
+    AuthorityFactoryProxy(final Class<T> type, final byte factoryType) {
         this.type = type;
+        this.factoryType = factoryType;
     }
 
     /**
@@ -148,7 +159,9 @@ abstract class AuthorityFactoryProxy<T>
      * @return The object created from the given code.
      * @throws FactoryException If an error occurred while creating the object.
      */
-    abstract T create(GeodeticAuthorityFactory factory, String code) throws FactoryException;
+    T create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
+        return createFromAPI(factory, code);
+    }
 
     /**
      * Creates the object for the given code using only GeoAPI interfaces.
@@ -162,20 +175,27 @@ abstract class AuthorityFactoryProxy<T>
     abstract T createFromAPI(AuthorityFactory factory, String code) throws FactoryException;
 
     /**
-     * The proxy for the {@link GeodeticAuthorityFactory#createObject} method.
+     * The proxy for the {@link GeodeticAuthorityFactory#getDescriptionText(String)} method.
      */
-    static final AuthorityFactoryProxy<IdentifiedObject> OBJECT =
-        new AuthorityFactoryProxy<IdentifiedObject>(IdentifiedObject.class) {
-            @Override IdentifiedObject create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
-                return factory.createObject(code);
+    static final AuthorityFactoryProxy<InternationalString> DESCRIPTION =
+        new AuthorityFactoryProxy<InternationalString>(InternationalString.class, AuthorityFactoryIdentifier.ANY) {
+            @Override InternationalString createFromAPI(AuthorityFactory factory, String code) throws FactoryException {
+                return factory.getDescriptionText(code);
             }
+    };
+
+    /**
+     * The proxy for the {@link GeodeticAuthorityFactory#createObject(String)} method.
+     */
+    static final AuthorityFactoryProxy<IdentifiedObject> OBJECT =
+        new AuthorityFactoryProxy<IdentifiedObject>(IdentifiedObject.class, AuthorityFactoryIdentifier.ANY) {
             @Override IdentifiedObject createFromAPI(AuthorityFactory factory, String code) throws FactoryException {
                 return factory.createObject(code);
             }
     };
 
     static final AuthorityFactoryProxy<Datum> DATUM =
-        new AuthorityFactoryProxy<Datum>(Datum.class) {
+        new AuthorityFactoryProxy<Datum>(Datum.class, AuthorityFactoryIdentifier.DATUM) {
             @Override Datum create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createDatum(code);
             }
@@ -185,7 +205,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<EngineeringDatum> ENGINEERING_DATUM =
-        new AuthorityFactoryProxy<EngineeringDatum>(EngineeringDatum.class) {
+        new AuthorityFactoryProxy<EngineeringDatum>(EngineeringDatum.class, AuthorityFactoryIdentifier.DATUM) {
             @Override EngineeringDatum create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createEngineeringDatum(code);
             }
@@ -195,7 +215,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<ImageDatum> IMAGE_DATUM =
-        new AuthorityFactoryProxy<ImageDatum>(ImageDatum.class) {
+        new AuthorityFactoryProxy<ImageDatum>(ImageDatum.class, AuthorityFactoryIdentifier.DATUM) {
             @Override ImageDatum create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createImageDatum(code);
             }
@@ -205,7 +225,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<VerticalDatum> VERTICAL_DATUM =
-        new AuthorityFactoryProxy<VerticalDatum>(VerticalDatum.class) {
+        new AuthorityFactoryProxy<VerticalDatum>(VerticalDatum.class, AuthorityFactoryIdentifier.DATUM) {
             @Override VerticalDatum create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createVerticalDatum(code);
             }
@@ -215,7 +235,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<TemporalDatum> TEMPORAL_DATUM =
-        new AuthorityFactoryProxy<TemporalDatum>(TemporalDatum.class) {
+        new AuthorityFactoryProxy<TemporalDatum>(TemporalDatum.class, AuthorityFactoryIdentifier.DATUM) {
             @Override TemporalDatum create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createTemporalDatum(code);
             }
@@ -225,7 +245,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<GeodeticDatum> GEODETIC_DATUM =
-        new AuthorityFactoryProxy<GeodeticDatum>(GeodeticDatum.class) {
+        new AuthorityFactoryProxy<GeodeticDatum>(GeodeticDatum.class, AuthorityFactoryIdentifier.DATUM) {
             @Override GeodeticDatum create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createGeodeticDatum(code);
             }
@@ -235,7 +255,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<Ellipsoid> ELLIPSOID =
-        new AuthorityFactoryProxy<Ellipsoid>(Ellipsoid.class) {
+        new AuthorityFactoryProxy<Ellipsoid>(Ellipsoid.class, AuthorityFactoryIdentifier.DATUM) {
             @Override Ellipsoid create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createEllipsoid(code);
             }
@@ -245,7 +265,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<PrimeMeridian> PRIME_MERIDIAN =
-        new AuthorityFactoryProxy<PrimeMeridian>(PrimeMeridian.class) {
+        new AuthorityFactoryProxy<PrimeMeridian>(PrimeMeridian.class, AuthorityFactoryIdentifier.DATUM) {
             @Override PrimeMeridian create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createPrimeMeridian(code);
             }
@@ -255,7 +275,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<Extent> EXTENT =
-        new AuthorityFactoryProxy<Extent>(Extent.class) {
+        new AuthorityFactoryProxy<Extent>(Extent.class, AuthorityFactoryIdentifier.GEODETIC) {
             @Override Extent create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createExtent(code);
             }
@@ -265,7 +285,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<CoordinateSystem> COORDINATE_SYSTEM =
-        new AuthorityFactoryProxy<CoordinateSystem>(CoordinateSystem.class) {
+        new AuthorityFactoryProxy<CoordinateSystem>(CoordinateSystem.class, AuthorityFactoryIdentifier.CS) {
             @Override CoordinateSystem create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createCoordinateSystem(code);
             }
@@ -275,7 +295,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<CartesianCS> CARTESIAN_CS =
-        new AuthorityFactoryProxy<CartesianCS>(CartesianCS.class) {
+        new AuthorityFactoryProxy<CartesianCS>(CartesianCS.class, AuthorityFactoryIdentifier.CS) {
             @Override CartesianCS create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createCartesianCS(code);
             }
@@ -285,7 +305,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<PolarCS> POLAR_CS =
-        new AuthorityFactoryProxy<PolarCS>(PolarCS.class) {
+        new AuthorityFactoryProxy<PolarCS>(PolarCS.class, AuthorityFactoryIdentifier.CS) {
             @Override PolarCS create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createPolarCS(code);
             }
@@ -295,7 +315,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<CylindricalCS> CYLINDRICAL_CS =
-        new AuthorityFactoryProxy<CylindricalCS>(CylindricalCS.class) {
+        new AuthorityFactoryProxy<CylindricalCS>(CylindricalCS.class, AuthorityFactoryIdentifier.CS) {
             @Override CylindricalCS create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createCylindricalCS(code);
             }
@@ -305,7 +325,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<SphericalCS> SPHERICAL_CS =
-        new AuthorityFactoryProxy<SphericalCS>(SphericalCS.class) {
+        new AuthorityFactoryProxy<SphericalCS>(SphericalCS.class, AuthorityFactoryIdentifier.CS) {
             @Override SphericalCS create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createSphericalCS(code);
             }
@@ -315,7 +335,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<EllipsoidalCS> ELLIPSOIDAL_CS =
-        new AuthorityFactoryProxy<EllipsoidalCS>(EllipsoidalCS.class) {
+        new AuthorityFactoryProxy<EllipsoidalCS>(EllipsoidalCS.class, AuthorityFactoryIdentifier.CS) {
             @Override EllipsoidalCS create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createEllipsoidalCS(code);
             }
@@ -325,7 +345,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<VerticalCS> VERTICAL_CS =
-        new AuthorityFactoryProxy<VerticalCS>(VerticalCS.class) {
+        new AuthorityFactoryProxy<VerticalCS>(VerticalCS.class, AuthorityFactoryIdentifier.CS) {
             @Override VerticalCS create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createVerticalCS(code);
             }
@@ -335,7 +355,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<TimeCS> TIME_CS =
-        new AuthorityFactoryProxy<TimeCS>(TimeCS.class) {
+        new AuthorityFactoryProxy<TimeCS>(TimeCS.class, AuthorityFactoryIdentifier.CS) {
             @Override TimeCS create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createTimeCS(code);
             }
@@ -345,7 +365,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<CoordinateSystemAxis> AXIS =
-        new AuthorityFactoryProxy<CoordinateSystemAxis>(CoordinateSystemAxis.class) {
+        new AuthorityFactoryProxy<CoordinateSystemAxis>(CoordinateSystemAxis.class, AuthorityFactoryIdentifier.CS) {
             @Override CoordinateSystemAxis create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createCoordinateSystemAxis(code);
             }
@@ -356,7 +376,7 @@ abstract class AuthorityFactoryProxy<T>
 
     @SuppressWarnings({"rawtypes","unchecked"})
     static final AuthorityFactoryProxy<Unit<?>> UNIT =
-        new AuthorityFactoryProxy<Unit<?>>((Class) Unit.class) {
+        new AuthorityFactoryProxy<Unit<?>>((Class) Unit.class, AuthorityFactoryIdentifier.CS) {
             @Override Unit<?> create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createUnit(code);
             }
@@ -366,7 +386,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<CoordinateReferenceSystem> CRS =
-        new AuthorityFactoryProxy<CoordinateReferenceSystem>(CoordinateReferenceSystem.class) {
+        new AuthorityFactoryProxy<CoordinateReferenceSystem>(CoordinateReferenceSystem.class, AuthorityFactoryIdentifier.CRS) {
             @Override CoordinateReferenceSystem create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createCoordinateReferenceSystem(code);
             }
@@ -376,7 +396,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<CompoundCRS> COMPOUND_CRS =
-        new AuthorityFactoryProxy<CompoundCRS>(CompoundCRS.class) {
+        new AuthorityFactoryProxy<CompoundCRS>(CompoundCRS.class, AuthorityFactoryIdentifier.CRS) {
             @Override CompoundCRS create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createCompoundCRS(code);
             }
@@ -386,7 +406,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<DerivedCRS> DERIVED_CRS =
-        new AuthorityFactoryProxy<DerivedCRS>(DerivedCRS.class) {
+        new AuthorityFactoryProxy<DerivedCRS>(DerivedCRS.class, AuthorityFactoryIdentifier.CRS) {
             @Override DerivedCRS create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createDerivedCRS(code);
             }
@@ -396,7 +416,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<EngineeringCRS> ENGINEERING_CRS =
-        new AuthorityFactoryProxy<EngineeringCRS>(EngineeringCRS.class) {
+        new AuthorityFactoryProxy<EngineeringCRS>(EngineeringCRS.class, AuthorityFactoryIdentifier.CRS) {
             @Override EngineeringCRS create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createEngineeringCRS(code);
             }
@@ -406,7 +426,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<GeographicCRS> GEOGRAPHIC_CRS =
-        new AuthorityFactoryProxy<GeographicCRS>(GeographicCRS.class) {
+        new AuthorityFactoryProxy<GeographicCRS>(GeographicCRS.class, AuthorityFactoryIdentifier.CRS) {
             @Override GeographicCRS create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createGeographicCRS(code);
             }
@@ -416,7 +436,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<GeocentricCRS> GEOCENTRIC_CRS =
-        new AuthorityFactoryProxy<GeocentricCRS>(GeocentricCRS.class) {
+        new AuthorityFactoryProxy<GeocentricCRS>(GeocentricCRS.class, AuthorityFactoryIdentifier.CRS) {
             @Override GeocentricCRS create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createGeocentricCRS(code);
             }
@@ -426,7 +446,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<ImageCRS> IMAGE_CRS =
-        new AuthorityFactoryProxy<ImageCRS>(ImageCRS.class) {
+        new AuthorityFactoryProxy<ImageCRS>(ImageCRS.class, AuthorityFactoryIdentifier.CRS) {
             @Override ImageCRS create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createImageCRS(code);
             }
@@ -436,7 +456,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<ProjectedCRS> PROJECTED_CRS =
-        new AuthorityFactoryProxy<ProjectedCRS>(ProjectedCRS.class) {
+        new AuthorityFactoryProxy<ProjectedCRS>(ProjectedCRS.class, AuthorityFactoryIdentifier.CRS) {
             @Override ProjectedCRS create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createProjectedCRS(code);
             }
@@ -446,7 +466,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<TemporalCRS> TEMPORAL_CRS =
-        new AuthorityFactoryProxy<TemporalCRS>(TemporalCRS.class) {
+        new AuthorityFactoryProxy<TemporalCRS>(TemporalCRS.class, AuthorityFactoryIdentifier.CRS) {
             @Override TemporalCRS create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createTemporalCRS(code);
             }
@@ -456,7 +476,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<VerticalCRS> VERTICAL_CRS =
-        new AuthorityFactoryProxy<VerticalCRS>(VerticalCRS.class) {
+        new AuthorityFactoryProxy<VerticalCRS>(VerticalCRS.class, AuthorityFactoryIdentifier.CRS) {
             @Override VerticalCRS create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createVerticalCRS(code);
             }
@@ -467,7 +487,7 @@ abstract class AuthorityFactoryProxy<T>
 
     @SuppressWarnings("rawtypes")
     static final AuthorityFactoryProxy<ParameterDescriptor> PARAMETER =
-        new AuthorityFactoryProxy<ParameterDescriptor>(ParameterDescriptor.class) {
+        new AuthorityFactoryProxy<ParameterDescriptor>(ParameterDescriptor.class, AuthorityFactoryIdentifier.GEODETIC) {
             @Override ParameterDescriptor<?> create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createParameterDescriptor(code);
             }
@@ -477,7 +497,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<OperationMethod> METHOD =
-        new AuthorityFactoryProxy<OperationMethod>(OperationMethod.class) {
+        new AuthorityFactoryProxy<OperationMethod>(OperationMethod.class, AuthorityFactoryIdentifier.OPERATION) {
             @Override OperationMethod create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createOperationMethod(code);
             }
@@ -487,7 +507,7 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     static final AuthorityFactoryProxy<CoordinateOperation> OPERATION =
-        new AuthorityFactoryProxy<CoordinateOperation>(CoordinateOperation.class) {
+        new AuthorityFactoryProxy<CoordinateOperation>(CoordinateOperation.class, AuthorityFactoryIdentifier.OPERATION) {
             @Override CoordinateOperation create(GeodeticAuthorityFactory factory, String code) throws FactoryException {
                 return factory.createCoordinateOperation(code);
             }
@@ -497,6 +517,71 @@ abstract class AuthorityFactoryProxy<T>
     };
 
     /**
+     * The list of all proxies. The most specific types must appear first in this array,
+     * with a preference for those who are more likely to be requested.
+     * This field can be declared only after all the above constants.
+     */
+    static final AuthorityFactoryProxy<?>[] PROXIES = new AuthorityFactoryProxy<?>[] {
+        PROJECTED_CRS,      // Special kind of GeneralDerivedCRS.
+        GEOGRAPHIC_CRS,     // Special kind of GeodeticCRS.
+        GEOCENTRIC_CRS,     // Special kind of GeodeticCRS.
+        VERTICAL_CRS,
+        TEMPORAL_CRS,
+        IMAGE_CRS,          // Can been seen as a special kind of EngineeringCRS (even if not shown in hierarchy).
+        ENGINEERING_CRS,
+        DERIVED_CRS,        // DerivedCRS can be also Vertical, Temporal or Engineering CRS. Give precedence to those.
+        COMPOUND_CRS,
+        CRS,
+        GEODETIC_DATUM,
+        VERTICAL_DATUM,
+        TEMPORAL_DATUM,
+        IMAGE_DATUM,        // Can been seen as a special kind of EngineeringDatum (even if not shown in hierarchy).
+        ENGINEERING_DATUM,
+        DATUM,
+        ELLIPSOID,
+        PRIME_MERIDIAN,
+        CARTESIAN_CS,       // Special case of AffineCS.
+        ELLIPSOIDAL_CS,
+        SPHERICAL_CS,
+        CYLINDRICAL_CS,
+        POLAR_CS,
+        VERTICAL_CS,
+        TIME_CS,
+        COORDINATE_SYSTEM,
+        AXIS,
+        OPERATION,
+        METHOD,
+        PARAMETER,
+        UNIT,
+        EXTENT,
+        OBJECT,
+        DESCRIPTION
+    };
+
+    /**
+     * The proxy to use for a given type declared in a URN.
+     * For example in the {@code "urn:ogc:def:crs:EPSG::4326"} URN, the proxy to use is {@link #CRS}.
+     *
+     * <p>Keys must be in lower case.</p>
+     */
+    private static final Map<String, AuthorityFactoryProxy<?>> BY_URN_TYPE;
+    static {
+        final Map<String, AuthorityFactoryProxy<?>> map = new HashMap<>(14);
+        map.put("crs",                  CRS);
+        map.put("datum",                DATUM);
+        map.put("ellipsoid",            ELLIPSOID);
+        map.put("meridian",             PRIME_MERIDIAN);
+        map.put("cs",                   COORDINATE_SYSTEM);
+        map.put("axis",                 AXIS);
+        map.put("coordinateoperation",  OPERATION);
+        map.put("method",               METHOD);
+        map.put("parameter",            PARAMETER);
+        map.put("referencesystem",      CRS);
+        map.put("uom",                  UNIT);
+        BY_URN_TYPE = map;
+    }
+
+    /**
      * Returns the instance for the given type. The {@code type} argument can be a GeoAPI interface
      * or some implementation class like {@link org.apache.sis.referencing.crs.DefaultProjectedCRS}.
      * This method returns the most specific proxy for the given type.
@@ -519,42 +604,23 @@ abstract class AuthorityFactoryProxy<T>
     }
 
     /**
-     * The types of proxies. The most specific types must appear first in this list.
-     * This field can be declared only after all the above constants.
+     * The proxy to use for a given type declared in a URN.
+     * For example in the {@code "urn:ogc:def:crs:EPSG::4326"} URN, the proxy to use is {@link #CRS}.
+     *
+     * @param  typeName The URN type.
+     * @return The proxy for the given type, or {@code null} if the given type is illegal.
      */
-    static final AuthorityFactoryProxy<?>[] PROXIES = new AuthorityFactoryProxy<?>[] {
-        OPERATION,
-        METHOD,
-        PARAMETER,
-        PROJECTED_CRS,
-        GEOGRAPHIC_CRS,
-        GEOCENTRIC_CRS,
-        IMAGE_CRS,
-        DERIVED_CRS,
-        VERTICAL_CRS,
-        TEMPORAL_CRS,
-        ENGINEERING_CRS,
-        COMPOUND_CRS,
-        CRS,
-        AXIS,
-        CARTESIAN_CS,
-        ELLIPSOIDAL_CS,
-        SPHERICAL_CS,
-        CYLINDRICAL_CS,
-        POLAR_CS,
-        VERTICAL_CS,
-        TIME_CS,
-        COORDINATE_SYSTEM,
-        PRIME_MERIDIAN,
-        ELLIPSOID,
-        GEODETIC_DATUM,
-        IMAGE_DATUM,
-        VERTICAL_DATUM,
-        TEMPORAL_DATUM,
-        ENGINEERING_DATUM,
-        DATUM,
-        EXTENT,
-        UNIT,
-        OBJECT
-    };
+    @SuppressWarnings("unchecked")
+    AuthorityFactoryProxy<? extends T> specialize(final String typeName) {
+        final AuthorityFactoryProxy<?> c = BY_URN_TYPE.get(typeName.toLowerCase(Locale.US));
+        if (c != null) {
+            if (c.type.isAssignableFrom(type)) {
+                return this;
+            }
+            if (type.isAssignableFrom(c.type)) {
+                return (AuthorityFactoryProxy<? extends T>) c;
+            }
+        }
+        return null;
+    }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java?rev=1726717&r1=1726716&r2=1726717&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java [UTF-8] Tue Jan 26 00:12:35 2016
@@ -20,7 +20,9 @@ import java.util.Map;
 import java.util.Set;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
 import java.util.Collections;
+import java.util.Arrays;
 import javax.measure.unit.SI;
 import javax.measure.unit.NonSI;
 import javax.measure.unit.Unit;
@@ -201,6 +203,14 @@ public class CommonAuthorityFactory exte
     private static final String AUTO2 = "AUTO2";
 
     /**
+     * The namespaces of codes defined by OGC.
+     *
+     * @see #getCodeSpaces()
+     */
+    private static final Set<String> CODESPACES = Collections.unmodifiableSet(
+            new LinkedHashSet<>(Arrays.asList(Constants.OGC, Constants.CRS, "AUTO", AUTO2)));
+
+    /**
      * The bit for saying that a namespace is the legacy {@code "AUTO"} namespace.
      */
     private static final int LEGACY_MASK = 0x80000000;
@@ -227,7 +237,7 @@ public class CommonAuthorityFactory exte
     /**
      * The parameter separator for codes in the {@code "AUTO(2)"} namespace.
      */
-    private static final char SEPARATOR = ',';
+    static final char SEPARATOR = ',';
 
     /**
      * The codes known to this factory, associated with their CRS type. This is set to an empty map
@@ -255,23 +265,22 @@ public class CommonAuthorityFactory exte
     }
 
     /**
-     * Returns the organization responsible for definition of the CRS codes recognized by this factory.
-     * The authority for this factory is the <cite>Open Geospatial Consortium</cite>.
+     * Returns the specification that defines the codes recognized by this factory. The definitive source for this
+     * factory is OGC <a href="http://www.opengeospatial.org/standards/wms">Web Map Service</a> (WMS) specification,
+     * also available as the ISO 19128 <cite>Geographic Information — Web map server interface</cite> standard.
+     *
+     * <p>While the authority is WMS, the {@linkplain org.apache.sis.xml.IdentifierSpace#getName() namespace}
+     * of that authority is set to {@code "OGC"}. Apache SIS does that for consistency with the namespace used
+     * in URNs (for example {@code "urn:ogc:def:crs:OGC:1.3:CRS84"}).</p>
      *
-     * @return The OGC authority.
+     * @return The <cite>"Web Map Service"</cite> authority.
      *
-     * @see Citations#OGC
+     * @see #getCodeSpaces()
+     * @see Citations#WMS
      */
     @Override
     public Citation getAuthority() {
-        return Citations.OGC;
-    }
-
-    /**
-     * Returns {@code true} if the given portion of the code is equal, ignoring case, to the given namespace.
-     */
-    private static boolean regionMatches(final String namespace, final String code, final int start, final int end) {
-        return (namespace.length() == end - start) && code.regionMatches(true, start, namespace, 0, namespace.length());
+        return Citations.WMS;
     }
 
     /**
@@ -311,7 +320,7 @@ public class CommonAuthorityFactory exte
                 }
                 if (!isRecognized) {
                     throw new NoSuchAuthorityCodeException(Errors.format(Errors.Keys.UnknownAuthority_1,
-                            CharSequences.trimWhitespaces(code.substring(0, s))), Constants.OGC, code);
+                            CharSequences.trimWhitespaces(code, 0, s)), Constants.OGC, code);
                 }
             }
         }
@@ -373,6 +382,28 @@ public class CommonAuthorityFactory exte
     }
 
     /**
+     * Returns the namespaces defined by the OGC specifications implemented by this factory.
+     * At the difference of other factories, the namespaces of {@code CommonAuthorityFactory}
+     * are quite different than the {@linkplain #getAuthority() authority} title or identifier:
+     *
+     * <ul>
+     *   <li><b>Authority:</b> {@code "WMS"} (for <cite>"Web Map Services"</cite>)</li>
+     *   <li><b>Namespaces:</b> {@code "CRS"}, {@code "AUTO"}, {@code "AUTO2"}.
+     *       The {@code "OGC"} namespace is also accepted for compatibility reason,
+     *       but its scope is wider than the above-cited namespaces.</li>
+     * </ul>
+     *
+     * @return A set containing at least the {@code "CRS"}, {@code "AUTO"} and {@code "AUTO2"} strings.
+     *
+     * @see #getAuthority()
+     * @see Citations#WMS
+     */
+    @Override
+    public Set<String> getCodeSpaces() {
+        return CODESPACES;
+    }
+
+    /**
      * Returns a description of the object corresponding to a code.
      * The description can be used for example in a combo box in a graphical user interface.
      *

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java?rev=1726717&r1=1726716&r2=1726717&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java [UTF-8] Tue Jan 26 00:12:35 2016
@@ -653,7 +653,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns the organization or party responsible for definition and maintenance of the underlying database.
+     * Returns the database or specification that defines the codes recognized by this factory.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Returns the cached value if it exists.</li>
@@ -765,9 +765,8 @@ public abstract class ConcurrentAuthorit
      *
      * <p>The default implementation performs the following steps:</p>
      * <ol>
-     *   <li>Removes the authority scope if presents. For example if the {@linkplain #getAuthority() authority}
-     *       is EPSG and the given code starts with the {@code "EPSG:"} prefix, then that prefix is removed.
-     *       Otherwise, the scope is unchanged.</li>
+     *   <li>Removes the namespace if presents. For example if the {@linkplain #getCodeSpaces() codespace}
+     *       is EPSG and the given code starts with the {@code "EPSG:"} prefix, then that prefix is removed.</li>
      *   <li>Removes leading and trailing spaces.</li>
      * </ol>
      *
@@ -780,7 +779,7 @@ public abstract class ConcurrentAuthorit
      * @throws FactoryException if an error occurred while normalizing the given code.
      */
     protected String normalizeCode(String code) throws FactoryException {
-        return trimAuthority(code, null);
+        return trimNamespace(code);
     }
 
     /**
@@ -830,7 +829,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a geographic coordinate reference system from a code.
+     * Returns a 2- or 3-dimensional coordinate reference system based on an ellipsoidal approximation of the geoid.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -853,7 +852,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a geocentric coordinate reference system from a code.
+     * Returns a 3-dimensional coordinate reference system with the origin at the approximate centre of mass of the earth.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -876,7 +875,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a projected coordinate reference system from a code.
+     * Returns a 2-dimensional coordinate reference system used to approximate the shape of the earth on a planar surface.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -899,7 +898,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a vertical coordinate reference system from a code.
+     * Returns a 1-dimensional coordinate reference system used for recording heights or depths.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -922,7 +921,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a temporal coordinate reference system from a code.
+     * Returns a 1-dimensional coordinate reference system used for the recording of time.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -945,7 +944,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a 3D or 4D coordinate reference system from a code.
+     * Returns a CRS describing the position of points through two or more independent coordinate reference systems.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -968,7 +967,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a derived coordinate reference system from a code.
+     * Returns a CRS that is defined by its coordinate conversion from another CRS (not by a datum).
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -991,7 +990,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns an engineering coordinate reference system from a code.
+     * Returns a 1-, 2- or 3-dimensional contextually local coordinate reference system.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1014,7 +1013,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns an image coordinate reference system from a code.
+     * Returns a 2-dimensional engineering coordinate reference system applied to locations in images.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1037,7 +1036,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns an arbitrary datum from a code.
+     * Returns an arbitrary datum from a code. The returned object will typically be an
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1060,7 +1059,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a geodetic datum from a code.
+     * Returns a datum defining the location and orientation of an ellipsoid that approximates the shape of the earth.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1083,7 +1082,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a vertical datum from a code.
+     * Returns a datum identifying a particular reference level surface used as a zero-height surface.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1106,7 +1105,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a temporal datum from a code.
+     * Returns a datum defining the origin of a temporal coordinate reference system.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1129,7 +1128,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns an engineering datum from a code.
+     * Returns a datum defining the origin of an engineering coordinate reference system.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1152,7 +1151,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns an image datum from a code.
+     * Returns a datum defining the origin of an image coordinate reference system.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1175,7 +1174,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns an ellipsoid from a code.
+     * Returns a geometric figure that can be used to describe the approximate shape of the earth.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1198,7 +1197,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a prime meridian from a code.
+     * Returns a prime meridian defining the origin from which longitude values are determined.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1221,7 +1220,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns an extent (usually a domain of validity) from a code.
+     * Returns information about spatial, vertical, and temporal extent (usually a domain of validity) from a code.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1266,7 +1265,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns an ellipsoidal coordinate system from a code.
+     * Returns a 2- or 3-dimensional coordinate system for geodetic latitude and longitude, sometime with ellipsoidal height.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1289,7 +1288,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a vertical coordinate system from a code.
+     * Returns a 1-dimensional coordinate system for heights or depths of points.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1312,7 +1311,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a temporal coordinate system from a code.
+     * Returns a 1-dimensional coordinate system for heights or depths of points.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1335,7 +1334,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a Cartesian coordinate system from a code.
+     * Returns a 2- or 3-dimensional Cartesian coordinate system made of straight orthogonal axes.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1358,7 +1357,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a spherical coordinate system from a code.
+     * Returns a 3-dimensional coordinate system with one distance measured from the origin and two angular coordinates.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1381,7 +1380,8 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a cylindrical coordinate system from a code.
+     * Returns a 3-dimensional coordinate system made of a polar coordinate system
+     * extended by a straight perpendicular axis.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1404,7 +1404,8 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a polar coordinate system from a code.
+     * Returns a 2-dimensional coordinate system for coordinates represented by a distance from the origin
+     * and an angle from a fixed direction.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1427,7 +1428,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a coordinate system axis from a code.
+     * Returns a coordinate system axis with name, direction, unit and range of values.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1472,7 +1473,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a parameter descriptor from a code.
+     * Returns a definition of a single parameter used by an operation method.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1495,7 +1496,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns an operation method from a code.
+     * Returns a description of the algorithm and parameters used to perform a coordinate operation.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1518,7 +1519,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns an operation from a code.
+     * Returns an operation for transforming coordinates in the source CRS to coordinates in the target CRS.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1786,19 +1787,6 @@ public abstract class ConcurrentAuthorit
             }
         }
 
-        /**
-         * Returns the authority of the factory examined by this finder.
-         */
-        @Override
-        public synchronized Citation getAuthority() throws FactoryException {
-            try {
-                acquire();
-                return finder.getAuthority();
-            } finally {
-                release();
-            }
-        }
-
         /**
          * Returns a set of authority codes that <strong>may</strong> identify the same
          * object than the specified one. This method delegates to the data access object.

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java?rev=1726717&r1=1726716&r2=1726717&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java [UTF-8] Tue Jan 26 00:12:35 2016
@@ -71,12 +71,12 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Returns the organization or party responsible for definition and maintenance of the database.
+     * Returns the database or specification that defines the codes recognized by this factory.
      * This method may return {@code null} if it can not obtain this information, for example because
      * the connection to a database is not available.
      *
-     * <div class="note"><b>Example</b>
-     * A factory that create coordinate reference system objects from EPSG codes could return
+     * <div class="note"><b>Example:</b>
+     * a factory that create coordinate reference system objects from EPSG codes could return
      * a citation like below:
      *
      * {@preformat text
@@ -102,6 +102,43 @@ public abstract class GeodeticAuthorityF
     public abstract Citation getAuthority();
 
     /**
+     * Returns all namespaces recognized by this factory. Those namespaces can appear before codes in
+     * calls to {@code createFoo(String)} methods, for example {@code "EPSG"} in {@code "EPSG::4326"}.
+     * Namespaces are case-insensitive.
+     *
+     * <p>The namespaces are closely related to the {@linkplain #getAuthority() authority}. Often the namespace is
+     * the authority {@linkplain org.apache.sis.metadata.iso.citation.DefaultCitation#getIdentifiers() identifier},
+     * but not always.</p>
+     *
+     * <div class="note"><b>Examples:</b>
+     * <ul class="verbose">
+     *   <li>The {@link org.apache.sis.referencing.factory.sql.EPSGFactory} authority identifier is {@code "EPSG"}
+     *       and its {@code getCodeSpaces()} method returns a set containing {@code "EPSG"}. So in this example,
+     *       authority and namespace match. That namespace value means that {@code EPSGFactory.createFoo(String)}
+     *       methods accept both {@code "EPSG::4326"} (case-insensitive) and {@code "4326"} codes as argument.</li>
+     *
+     *   <li>The {@link org.apache.sis.referencing.factory.sql.EPSGDataAccess} authority identifier is {@code "EPSG"}
+     *       but its {@code getCodeSpaces()} method returns an empty set. This means that despite the EPSG authority,
+     *       {@code EPSGDataAccess.createFoo(String)} methods accept only codes like {@code "4326"} without
+     *       {@code "EPSG:"} prefix (the reason is that {@code EPSGDataAccess} is not expected to be used directly).</li>
+     *
+     *   <li>The {@link CommonAuthorityFactory} authority identifiers are ISO 19128 and OGC 06-042 (the WMS specification)
+     *       but its {@code getCodeSpaces()} method returns a set containing {@code "CRS"}, {@code "AUTO"} and {@code "AUTO2"}.
+     *       While ISO 19128 is defined as the first authority, the namespace is actually defined by OGC.</li>
+     * </ul></div>
+     *
+     * The default implementation infers the namespace from the {@linkplain #getAuthority() authority}.
+     * Subclasses can override this method, but the set should always contain the same elements during
+     * all factory lifetime.
+     *
+     * @return The namespaces recognized by this factory, or an empty set if none.
+     */
+    public Set<String> getCodeSpaces() {
+        final String authority = Citations.getCodeSpace(getAuthority());
+        return (authority != null) ? Collections.singleton(authority) : Collections.<String>emptySet();
+    }
+
+    /**
      * Returns a description of the object corresponding to a code.
      * The description can be used for example in a combo box in a graphical user interface.
      *
@@ -750,7 +787,7 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates 2- or 3-dimensional coordinate system for geodetic latitude and longitude,
+     * Creates a 2- or 3-dimensional coordinate system for geodetic latitude and longitude,
      * sometime with ellipsoidal height.
      *
      * <div class="note"><b>Example:</b>
@@ -1031,7 +1068,7 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates description of the algorithm and parameters used to perform a coordinate operation.
+     * Creates a description of the algorithm and parameters used to perform a coordinate operation.
      * An {@code OperationMethod} is a kind of metadata: it does not perform any coordinate operation
      * (e.g. map projection) by itself, but tells us what is needed in order to perform such operation.
      *
@@ -1125,33 +1162,40 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Trims the authority scope, if present. For example if this factory is an EPSG authority factory
+     * Returns {@code true} if the given portion of the code is equal, ignoring case, to the given namespace.
+     */
+    static boolean regionMatches(final String namespace, final String code, final int start, final int end) {
+        return (namespace.length() == end - start) && code.regionMatches(true, start, namespace, 0, namespace.length());
+    }
+
+    /**
+     * Trims the namespace, if present. For example if this factory is an EPSG authority factory
      * and the specified code start with the {@code "EPSG:"} prefix, then the prefix is removed.
      * Otherwise, the string is returned unchanged (except for leading and trailing spaces).
      *
      * @param  code The code to trim.
-     * @param  authority The authority factory, or {@code null} for {@link #getAuthority()}.
-     * @return The code with the authority part removed if that part matched the expected authority.
+     * @return The code with the namespace part removed if that part matched one of the values given by
+     *         {@link #getCodeSpaces()}.
      */
-    final String trimAuthority(final String code, Citation authority) {
+    final String trimNamespace(final String code) {
         int s = code.indexOf(DefaultNameSpace.DEFAULT_SEPARATOR);
         if (s >= 0) {
-            if (authority == null) {
-                authority = getAuthority();     // Costly operation for EPSGDataAccess.
-            }
-            if (Citations.identifierMatches(authority, null, code.substring(0, s))) {    // Comparison ignores spaces.
-                final int n = code.indexOf(DefaultNameSpace.DEFAULT_SEPARATOR, s + 1);
-                if (n >= 0) {
-                    /*
-                     * The separator sometime appears twice, as in "EPSG::4326" or "EPSG:8.8:4326".
-                     * The part between the two separators is the verion number, which we ignore in
-                     * this simple version.
-                     */
-                    s = n;
+            final int end   = CharSequences.skipTrailingWhitespaces(code, 0, s);
+            final int start = CharSequences.skipLeadingWhitespaces (code, 0, end);
+            for (final String codespace : getCodeSpaces()) {
+                if (regionMatches(codespace, code, start, end)) {
+                    final int n = code.indexOf(DefaultNameSpace.DEFAULT_SEPARATOR, s + 1);
+                    if (n >= 0) {
+                        /*
+                         * The separator sometime appears twice, as in "EPSG::4326" or "EPSG:8.8:4326".
+                         * The part between the two separators is the verion number, which we ignore in
+                         * this simple version.
+                         */
+                        s = n;
+                    }
+                    final int length = code.length();
+                    return CharSequences.trimWhitespaces(code, s+1, length).toString();
                 }
-                final int length = code.length();
-                s = CharSequences.skipLeadingWhitespaces(code, s+1, length);
-                return code.substring(s, CharSequences.skipTrailingWhitespaces(code, s, length));
             }
         }
         return CharSequences.trimWhitespaces(code);
@@ -1191,7 +1235,7 @@ public abstract class GeodeticAuthorityF
         final Identifier id = object.getName();
         final Citation authority = (id != null) ? id.getAuthority() : getAuthority();
         throw new NoSuchAuthorityCodeException(Errors.format(Errors.Keys.UnexpectedTypeForReference_3, code, type, actual),
-                Citations.getIdentifier(authority, false), trimAuthority(code, authority), code);
+                Citations.getIdentifier(authority, false), trimNamespace(code), code);
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java?rev=1726717&r1=1726716&r2=1726717&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java [UTF-8] Tue Jan 26 00:12:35 2016
@@ -23,15 +23,14 @@ import java.util.LinkedHashSet;
 import org.opengis.util.GenericName;
 import org.opengis.util.FactoryException;
 import org.opengis.metadata.Identifier;
-import org.opengis.metadata.citation.Citation;
 import org.opengis.referencing.IdentifiedObject;
 import org.opengis.referencing.AuthorityFactory;
 import org.opengis.referencing.NoSuchAuthorityCodeException;
 import org.apache.sis.referencing.AbstractIdentifiedObject;
 import org.apache.sis.referencing.IdentifiedObjects;
-import org.apache.sis.internal.util.Citations;
 import org.apache.sis.internal.system.Loggers;
 import org.apache.sis.util.collection.BackingStoreException;
+import org.apache.sis.util.iso.DefaultNameSpace;
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.ComparisonMode;
@@ -154,6 +153,13 @@ public class IdentifiedObjectFinder {
     private boolean ignoreAxes;
 
     /**
+     * {@code true} if the search should ignore names, aliases and identifiers. This is set to {@code true}
+     * only when this finder is wrapped by a {@link MultiAuthoritiesFactory} finder, which performs it own
+     * search based on identifiers.
+     */
+    boolean ignoreIdentifiers;
+
+    /**
      * Creates a finder using the specified factory.
      *
      * <div class="note"><b>Design note:</b>
@@ -186,17 +192,6 @@ public class IdentifiedObjectFinder {
     }
 
     /**
-     * Returns the authority of the factory used by this finder.
-     * The default implementation delegates to {@link GeodeticAuthorityFactory#getAuthority()}.
-     *
-     * @return The authority of the factory used for the searches, or {@code null} if unknown.
-     * @throws FactoryException If an error occurred while fetching the authority.
-     */
-    public Citation getAuthority() throws FactoryException {
-        return factory.getAuthority();
-    }
-
-    /**
      * Returns the domain of the search (for example whether to include deprecated objects in the search).
      * If {@code DECLARATION}, only a fast lookup based on embedded identifiers and names will be performed.
      * Otherwise an exhaustive full scan against all registered objects will be performed (may be slow).
@@ -305,23 +300,25 @@ public class IdentifiedObjectFinder {
             final AuthorityFactoryProxy<?> previous = proxy;
             proxy = AuthorityFactoryProxy.getInstance(object.getClass());
             try {
-                /*
-                 * First check if one of the identifiers can be used to find directly an identified object.
-                 * Verify that the object that we found is actually equal to given one; we do not blindly
-                 * trust the identifiers in the user object.
-                 */
-                IdentifiedObject candidate = createFromIdentifiers(object);
-                if (candidate != null) {
-                    return Collections.singleton(candidate);    // Not worth to cache.
-                }
-                /*
-                 * We are unable to find the object from its identifiers. Try a quick name lookup.
-                 * Some implementations like the one backed by the EPSG database are capable to find
-                 * an object from its name.
-                 */
-                candidate = createFromNames(object);
-                if (candidate != null) {
-                    return Collections.singleton(candidate);    // Not worth to cache.
+                if (!ignoreIdentifiers) {
+                    /*
+                     * First check if one of the identifiers can be used to find directly an identified object.
+                     * Verify that the object that we found is actually equal to given one; we do not blindly
+                     * trust the identifiers in the user object.
+                     */
+                    IdentifiedObject candidate = createFromIdentifiers(object);
+                    if (candidate != null) {
+                        return Collections.singleton(candidate);    // Not worth to cache.
+                    }
+                    /*
+                     * We are unable to find the object from its identifiers. Try a quick name lookup.
+                     * Some implementations like the one backed by the EPSG database are capable to find
+                     * an object from its name.
+                     */
+                    candidate = createFromNames(object);
+                    if (candidate != null) {
+                        return Collections.singleton(candidate);    // Not worth to cache.
+                    }
                 }
                 /*
                  * Here we exhausted the quick paths.
@@ -385,10 +382,15 @@ public class IdentifiedObjectFinder {
      * @see #createFromNames(IdentifiedObject)
      */
     private IdentifiedObject createFromIdentifiers(final IdentifiedObject object) throws FactoryException {
-        final Citation authority = getAuthority();
         for (final Identifier id : object.getIdentifiers()) {
-            if (Citations.identifierMatches(authority, id.getAuthority())) {
-                final String code = IdentifiedObjects.toString(id);
+            final String code = IdentifiedObjects.toString(id);
+            /*
+             * We will process only codes with a namespace (e.g. "AUTHORITY:CODE") for avoiding ambiguity.
+             * We do not try to check by ourselves if the identifier is in the namespace of the factory,
+             * because calling factory.getAuthorityCodes() or factory.getCodeSpaces() may be costly for
+             * some implementations.
+             */
+            if (code.indexOf(DefaultNameSpace.DEFAULT_SEPARATOR) >= 0) {
                 final IdentifiedObject candidate;
                 try {
                     candidate = create(code);
@@ -458,11 +460,11 @@ public class IdentifiedObjectFinder {
     /**
      * Creates an object equals (optionally ignoring metadata), to the specified object.
      * This method scans the {@linkplain #getCodeCandidates(IdentifiedObject) authority codes},
-     * create the objects and returns the first one which is equal to the specified object in
+     * creates the objects and returns the first one which is equal to the specified object in
      * the sense of {@link Utilities#deepEquals(Object, Object, ComparisonMode)}.
      *
-     * <p>This method may be used in order to get a fully {@linkplain AbstractIdentifiedObject identified
-     * object} from an object without {@linkplain AbstractIdentifiedObject#getIdentifiers() identifiers}.</p>
+     * <p>This method may be used in order to get a fully {@linkplain AbstractIdentifiedObject identified object}
+     * from an object without {@linkplain AbstractIdentifiedObject#getIdentifiers() identifiers}.</p>
      *
      * <p>Scanning the whole set of authority codes may be slow. Users should try
      * <code>{@linkplain #createFromIdentifiers createFromIdentifiers}(object)</code> and/or
@@ -476,7 +478,7 @@ public class IdentifiedObjectFinder {
      * @see #createFromIdentifiers(IdentifiedObject)
      * @see #createFromNames(IdentifiedObject)
      */
-    private Set<IdentifiedObject> createFromCodes(final IdentifiedObject object) throws FactoryException {
+    Set<IdentifiedObject> createFromCodes(final IdentifiedObject object) throws FactoryException {
         final Set<IdentifiedObject> result = new LinkedHashSet<>();     // We need to preserve order.
         for (final String code : getCodeCandidates(object)) {
             final IdentifiedObject candidate;
@@ -536,6 +538,6 @@ public class IdentifiedObjectFinder {
      * Invoked when an exception occurred during the creation of a candidate from a code.
      */
     private static void exceptionOccurred(final FactoryException exception) {
-        Logging.recoverableException(Logging.getLogger(Loggers.CRS_FACTORY), IdentifiedObjectFinder.class, "fine", exception);
+        Logging.recoverableException(Logging.getLogger(Loggers.CRS_FACTORY), IdentifiedObjectFinder.class, "find", exception);
     }
 }

Copied: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java (from r1726714, sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java?p2=sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java&p1=sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java&r1=1726714&r2=1726717&rev=1726717&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java [UTF-8] Tue Jan 26 00:12:35 2016
@@ -440,7 +440,7 @@ public class MultiAuthoritiesFactory ext
             return ((GeodeticAuthorityFactory) factory).getCodeSpaces();
         } else {
             final String authority = Citations.getCodeSpace(factory.getAuthority());
-            return (authority != null) ? Collections.singleton(authority) : Collections.emptySet();
+            return (authority != null) ? Collections.singleton(authority) : Collections.<String>emptySet();
         }
     }
 

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java?rev=1726717&r1=1726716&r2=1726717&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java [UTF-8] Tue Jan 26 00:12:35 2016
@@ -339,9 +339,23 @@ public class EPSGDataAccess extends Geod
     }
 
     /**
-     * Returns the authority for this EPSG database. The returned citation contains the database version
+     * Returns the authority for this EPSG dataset. The returned citation contains the database version
      * in the {@linkplain Citation#getEdition() edition} attribute, together with date of last update in
      * the {@linkplain Citation#getEditionDate() edition date}.
+     * Example (the exact content will vary with Apache SIS versions, JDBC driver and EPSG dataset versions):
+     *
+     * {@preformat text
+     *   Citation
+     *   ├─ Title ……………………………………………………… EPSG Geodetic Parameter Dataset
+     *   ├─ Identifier ………………………………………… EPSG
+     *   ├─ Online resource (1 of 2)
+     *   │  ├─ Linkage ………………………………………… http://epsg-registry.org/
+     *   │  └─ Function ……………………………………… Browse
+     *   └─ Online resource (2 of 2)
+     *      ├─ Linkage ………………………………………… jdbc:derby:/my/path/to/SIS_DATA/Databases/SpatialMetadata
+     *      ├─ Description ……………………………… EPSG dataset version 8.8 on “Apache Derby Embedded JDBC Driver” version 10.12.
+     *      └─ Function ……………………………………… Connection
+     * }
      */
     @Override
     public synchronized Citation getAuthority() {
@@ -379,6 +393,9 @@ public class EPSGDataAccess extends Geod
              *    Linkage:      jdbc:derby:/my/path/to/SIS_DATA/Databases/SpatialMetadata
              *    Function:     Connection
              *    Description:  EPSG dataset version 8.8 on “Apache Derby Embedded JDBC Driver” version 10.12.
+             *
+             * TODO: A future version should use Citations.EPSG as a template.
+             *       See the "EPSG" case in ServiceForUtility.createCitation(String).
              */
             final DatabaseMetaData metadata  = connection.getMetaData();
 addURIs:    for (int i=0; ; i++) {
@@ -521,6 +538,17 @@ addURIs:    for (int i=0; ; i++) {
     }
 
     /**
+     * Returns an empty set since this data access class expects no namespace.
+     * Code shall be given to {@code createFoo(String)} methods directly, without {@code "EPSG:"} prefix.
+     *
+     * @return Empty set.
+     */
+    @Override
+    public Set<String> getCodeSpaces() {
+        return Collections.emptySet();
+    }
+
+    /**
      * Gets a description of the object corresponding to a code.
      * This method returns the object name in a lightweight manner, without creating the full {@link IdentifiedObject}.
      *

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java?rev=1726717&r1=1726716&r2=1726717&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java [UTF-8] Tue Jan 26 00:12:35 2016
@@ -16,10 +16,13 @@
  */
 package org.apache.sis.referencing.factory.sql;
 
+import java.util.Collections;
 import java.util.Locale;
+import java.util.Set;
 import java.sql.Connection;
 import java.sql.SQLException;
 import javax.sql.DataSource;
+import java.util.concurrent.TimeUnit;
 import org.opengis.util.NameFactory;
 import org.opengis.util.FactoryException;
 import org.opengis.referencing.crs.CRSFactory;
@@ -33,6 +36,7 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.operation.MathTransformFactory;
 import org.apache.sis.internal.metadata.sql.Initializer;
 import org.apache.sis.internal.system.DefaultFactories;
+import org.apache.sis.internal.util.Constants;
 import org.apache.sis.referencing.factory.ConcurrentAuthorityFactory;
 import org.apache.sis.referencing.factory.UnavailableFactoryException;
 import org.apache.sis.util.ArgumentChecks;
@@ -59,6 +63,13 @@ public class EPSGFactory extends Concurr
         CSAuthorityFactory, DatumAuthorityFactory, CoordinateOperationAuthorityFactory, Localized
 {
     /**
+     * The namespace of EPSG codes.
+     *
+     * @see #getCodeSpaces()
+     */
+    private static final Set<String> CODESPACES = Collections.singleton(Constants.EPSG);
+
+    /**
      * The factory to use for creating {@link Connection}s to the EPSG database.
      */
     protected final DataSource dataSource;
@@ -168,6 +179,7 @@ public class EPSGFactory extends Concurr
         this.mtFactory    = factory(MathTransformFactory.class, mtFactory);
         this.translator   = translator;
         this.locale       = Locale.getDefault(Locale.Category.DISPLAY);
+        super.setTimeout(10, TimeUnit.SECONDS);
     }
 
     /**
@@ -181,6 +193,16 @@ public class EPSGFactory extends Concurr
     }
 
     /**
+     * Returns the namespace of EPSG codes.
+     *
+     * @return The {@code "EPSG"} string in a singleton map.
+     */
+    @Override
+    public Set<String> getCodeSpaces() {
+        return CODESPACES;
+    }
+
+    /**
      * Returns the locale used by this factory for producing error messages.
      * This locale does not change the way data are read from the EPSG database.
      *

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java?rev=1726717&r1=1726716&r2=1726717&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java [UTF-8] Tue Jan 26 00:12:35 2016
@@ -266,7 +266,7 @@ public class DefaultMathTransformFactory
          *
          * Wrapping the ServiceLoader in a LazySet avoid this issue.
          */
-        this(new LazySet<>(ServiceLoader.load(OperationMethod.class).iterator()));
+        this(new LazySet<>(ServiceLoader.load(OperationMethod.class)));
     }
 
     /**
@@ -1295,8 +1295,7 @@ public class DefaultMathTransformFactory
             methodsByName.clear();
             Iterable<? extends OperationMethod> m = methods;
             if (m instanceof LazySet<?>) { // Workaround for JDK bug. See DefaultMathTransformFactory() constructor.
-                ((LazySet<?>) m).reload();
-                m = ((LazySet<? extends OperationMethod>) m).source;
+                m = ((LazySet<? extends OperationMethod>) m).reload();
             }
             if (m instanceof ServiceLoader<?>) {
                 ((ServiceLoader<?>) m).reload();

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java?rev=1726717&r1=1726716&r2=1726717&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java [UTF-8] Tue Jan 26 00:12:35 2016
@@ -19,12 +19,12 @@ package org.apache.sis.referencing.opera
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Set;
-import java.util.AbstractSet;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 import java.util.ServiceLoader;
 import org.opengis.referencing.operation.SingleOperation;
 import org.opengis.referencing.operation.OperationMethod;
+import org.apache.sis.internal.util.SetOfUnknownSize;
 import org.apache.sis.referencing.operation.DefaultOperationMethod;
 
 
@@ -43,10 +43,10 @@ import org.apache.sis.referencing.operat
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.6
- * @version 0.6
+ * @version 0.7
  * @module
  */
-final class OperationMethodSet extends AbstractSet<OperationMethod> {
+final class OperationMethodSet extends SetOfUnknownSize<OperationMethod> {
     /**
      * The operation type we are looking for.
      */
@@ -163,6 +163,14 @@ final class OperationMethodSet extends A
     }
 
     /**
+     * Returns {@code true} if the {@link #size()} method is cheap.
+     */
+    @Override
+    protected synchronized boolean isSizeKnown() {
+        return methodIterator == null;
+    }
+
+    /**
      * Returns {@code true} if {@link #next(int)} can return an operation method at the given index.
      */
     final synchronized boolean hasNext(final int index) {



Mime
View raw message