sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1719354 - in /sis/branches/JDK8/core: sis-referencing/src/main/java/org/apache/sis/referencing/crs/ sis-referencing/src/main/java/org/apache/sis/referencing/factory/ sis-referencing/src/test/java/org/apache/sis/referencing/factory/ sis-uti...
Date Fri, 11 Dec 2015 11:47:42 GMT
Author: desruisseaux
Date: Fri Dec 11 11:47:42 2015
New Revision: 1719354

URL: http://svn.apache.org/viewvc?rev=1719354&view=rev
Log:
CommonAuthorityFactory.getAuthorityCodes(Class) can filter according the given type.
Improved some javadoc.

Added:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/FilteredCodes.java   (with props)
Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java?rev=1719354&r1=1719353&r2=1719354&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java [UTF-8] Fri Dec 11 11:47:42 2015
@@ -48,7 +48,7 @@ import org.apache.sis.referencing.Abstra
  *   <li>Create a {@code GeocentricCRS} from one of the static convenience shortcuts listed in
  *       {@link org.apache.sis.referencing.CommonCRS#geocentric()}.</li>
  *   <li>Create a {@code GeocentricCRS} from an identifier in a database by invoking
- *       {@link org.opengis.referencing.crs.CRSAuthorityFactory#createGeocentricCRS(String)}.</li>
+ *       {@link org.apache.sis.referencing.factory.GeodeticAuthorityFactory#createGeocentricCRS(String)}.</li>
  *   <li>Create a {@code GeocentricCRS} by invoking the {@code CRSFactory.createGeocentricCRS(…)} method
  *       (implemented for example by {@link org.apache.sis.referencing.factory.GeodeticObjectFactory}).</li>
  *   <li>Create a {@code GeocentricCRS} by invoking the

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java?rev=1719354&r1=1719353&r2=1719354&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java [UTF-8] Fri Dec 11 11:47:42 2015
@@ -62,7 +62,7 @@ import static org.apache.sis.internal.ut
  *       {@link org.apache.sis.referencing.CommonCRS#geographic()} or
  *       {@link org.apache.sis.referencing.CommonCRS#geographic3D()}.</li>
  *   <li>Create a {@code GeographicCRS} from an identifier in a database by invoking
- *       {@link org.opengis.referencing.crs.CRSAuthorityFactory#createGeographicCRS(String)}.</li>
+ *       {@link org.apache.sis.referencing.factory.GeodeticAuthorityFactory#createGeographicCRS(String)}.</li>
  *   <li>Create a {@code GeographicCRS} by invoking the {@code CRSFactory.createGeographicCRS(…)} method
  *       (implemented for example by {@link org.apache.sis.referencing.factory.GeodeticObjectFactory}).</li>
  *   <li>Create a {@code GeographicCRS} by invoking the

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java?rev=1719354&r1=1719353&r2=1719354&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java [UTF-8] Fri Dec 11 11:47:42 2015
@@ -55,9 +55,9 @@ import static org.apache.sis.internal.re
 
 /**
  * A 2-dimensional coordinate reference system used to approximate the shape of the earth on a planar surface.
- * It is done in such a way that the distortion that is inherent to the approximation is carefully
- * controlled and known. Distortion correction is commonly applied to calculated bearings and
- * distances to produce values that are a close match to actual field values.
+ * It is done in such a way that the distortion that is inherent to the approximation is carefully controlled and known.
+ * Distortion correction is commonly applied to calculated bearings and distances to produce values
+ * that are a close match to actual field values.
  *
  * <p><b>Used with coordinate system type:</b>
  *   {@linkplain org.apache.sis.referencing.cs.DefaultCartesianCS Cartesian}.

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java?rev=1719354&r1=1719353&r2=1719354&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java [UTF-8] Fri Dec 11 11:47:42 2015
@@ -34,7 +34,7 @@ import org.apache.sis.util.resources.Err
  * It is possible to use the generic {@link AuthorityFactory#createObject(String)} method instead of this class,
  * but some factories are more efficient when we use the most specific {@code create} method.
  * For example when using a {@linkplain org.apache.sis.referencing.factory.epsg.EPSGFactory},
- * invoking {@link CRSAuthorityFactory#createProjectedCRS(String)} instead of
+ * invoking {@link GeodeticAuthorityFactory#createProjectedCRS(String)} instead of
  * {@code AuthorityFactory.createObject(String)} method reduce the amount of tables to be queried.
  *
  * <p>This class is useful when the same {@code create} method need to be invoked often, but is unknown at compile time.
@@ -43,7 +43,7 @@ import org.apache.sis.util.resources.Err
  *
  * <div class="note"><b>Example:</b>
  * the following code creates a proxy which will delegates its work to the
- * {@link CRSAuthorityFactory#createGeographicCRS createGeographicCRS} method.
+ * {@link GeodeticAuthorityFactory#createGeographicCRS createGeographicCRS} method.
  *
  * {@preformat java
  *     String code = ...;

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java?rev=1719354&r1=1719353&r2=1719354&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java [UTF-8] Fri Dec 11 11:47:42 2015
@@ -19,7 +19,7 @@ package org.apache.sis.referencing.facto
 import java.util.Map;
 import java.util.Set;
 import java.util.HashMap;
-import java.util.LinkedHashSet;
+import java.util.LinkedHashMap;
 import java.util.Collections;
 import java.util.Arrays;
 import java.util.Locale;
@@ -30,32 +30,77 @@ import org.opengis.metadata.citation.Cit
 import org.opengis.referencing.IdentifiedObject;
 import org.opengis.referencing.NoSuchAuthorityCodeException;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.opengis.referencing.crs.CRSFactory;
 import org.opengis.referencing.crs.CRSAuthorityFactory;
+import org.opengis.referencing.crs.EngineeringCRS;
+import org.opengis.referencing.crs.GeographicCRS;
+import org.opengis.referencing.crs.VerticalCRS;
+import org.opengis.referencing.crs.SingleCRS;
+import org.opengis.referencing.cs.CSFactory;
+import org.opengis.referencing.cs.CartesianCS;
 import org.opengis.referencing.cs.AxisDirection;
-import org.opengis.referencing.cs.CoordinateSystemAxis;
+import org.opengis.referencing.datum.DatumFactory;
+import org.opengis.referencing.datum.EngineeringDatum;
 import org.apache.sis.metadata.iso.citation.Citations;
 import org.apache.sis.metadata.iso.citation.DefaultCitation;
 import org.apache.sis.internal.simple.SimpleIdentifier;
+import org.apache.sis.internal.system.DefaultFactories;
+import org.apache.sis.internal.util.Constants;
 import org.apache.sis.referencing.CommonCRS;
-import org.apache.sis.referencing.datum.DefaultEngineeringDatum;
-import org.apache.sis.referencing.crs.DefaultEngineeringCRS;
-import org.apache.sis.referencing.cs.DefaultCartesianCS;
-import org.apache.sis.referencing.cs.DefaultCoordinateSystemAxis;
+import org.apache.sis.util.ArgumentChecks;
+import org.apache.sis.util.CharSequences;
 
 
 /**
- * The factory for coordinate reference systems in the "{@code OGC}" or "{@code CRS}" namespace.
+ * Creates coordinate reference systems in the "{@code OGC}" or "{@code CRS}" namespace.
  * All namespaces recognized by this factory are defined by the Open Geospatial Consortium (OGC).
  * Most codes map to one of the constants in the {@link CommonCRS} enumeration.
  *
  * <table class="sis">
- *   <caption>Codes recognized by <code>CommonAuthorityFactory</code></caption>
- *   <tr><th>Code</th> <th>Name</th>             <th>Datum type</th>  <th>CS type</th>     <th>Axis direction</th></tr>
- *   <tr><td>   1</td> <td>Computer display</td> <td>Engineering</td> <td>Cartesian</td>   <td>East, South</td></tr>
- *   <tr><td>  27</td> <td>NAD27</td>            <td>Geodetic</td>    <td>Ellipsoidal</td> <td>East, South</td></tr>
- *   <tr><td>  83</td> <td>NAD83</td>            <td>Geodetic</td>    <td>Ellipsoidal</td> <td>East, South</td></tr>
- *   <tr><td>  84</td> <td>WGS84</td>            <td>Geodetic</td>    <td>Ellipsoidal</td> <td>East, South</td></tr>
- *   <tr><td>  88</td> <td>NAVD88</td>           <td>Vertical</td>    <td>Vertical</td>    <td>Up</td></tr>
+ *   <caption>Recognized Coordinate Reference System codes</caption>
+ *   <tr>
+ *     <th>Code</th>
+ *     <th>Name</th>
+ *     <th>Datum type</th>
+ *     <th>CS type</th>
+ *     <th>Axis direction</th>
+ *     <th>Units</th>
+ *   </tr><tr>
+ *     <td>1</td>
+ *     <td>Computer display</td>
+ *     <td>{@linkplain org.apache.sis.referencing.crs.DefaultEngineeringCRS Engineering}</td>
+ *     <td>{@linkplain org.apache.sis.referencing.cs.DefaultCartesianCS Cartesian}</td>
+ *     <td>(east, south)</td>
+ *     <td>pixels</td>
+ *   </tr><tr>
+ *     <td>27</td>
+ *     <td>NAD27</td>
+ *     <td>{@linkplain org.apache.sis.referencing.crs.DefaultGeographicCRS Geographic}</td>
+ *     <td>{@linkplain org.apache.sis.referencing.cs.DefaultEllipsoidalCS Ellipsoidal}</td>
+ *     <td>(east, north)</td>
+ *     <td>degrees</td>
+ *   </tr><tr>
+ *     <td>83</td>
+ *     <td>NAD83</td>
+ *     <td>{@linkplain org.apache.sis.referencing.crs.DefaultGeographicCRS Geographic}</td>
+ *     <td>{@linkplain org.apache.sis.referencing.cs.DefaultEllipsoidalCS Ellipsoidal}</td>
+ *     <td>(east, north)</td>
+ *     <td>degrees</td>
+ *   </tr><tr>
+ *     <td>84</td>
+ *     <td>WGS84</td>
+ *     <td>{@linkplain org.apache.sis.referencing.crs.DefaultGeographicCRS Geographic}</td>
+ *     <td>{@linkplain org.apache.sis.referencing.cs.DefaultEllipsoidalCS Ellipsoidal}</td>
+ *     <td>(east, north)</td>
+ *     <td>degrees</td>
+ *   </tr><tr>
+ *     <td>88</td>
+ *     <td>NAVD88</td>
+ *     <td>{@linkplain org.apache.sis.referencing.crs.DefaultVerticalCRS Vertical}</td>
+ *     <td>{@linkplain org.apache.sis.referencing.cs.DefaultVerticalCS Vertical}</td>
+ *     <td>up</td>
+ *     <td>metres</td>
+ *   </tr>
  * </table>
  *
  * <div class="section">Note on codes in CRS namespace</div>
@@ -76,22 +121,10 @@ import org.apache.sis.referencing.cs.Def
  */
 public class CommonAuthorityFactory extends GeodeticAuthorityFactory implements CRSAuthorityFactory {
     /**
-     * An optional prefix put in front of code. For example a code may be {@code "CRS84"} instead of a plain {@code "84"}.
-     * This is useful in order to understand URN syntax like {@code "urn:ogc:def:crs:OGC:1.3:CRS84"}.
-     * Must be uppercase for this implementation, but parsing will be case-insensitive.
+     * The codes known to this factory, associated with their CRS type. This is set to an empty map
+     * at {@code CommonAuthorityFactory} construction time, but filled only when first needed.
      */
-    private static final String PREFIX = "CRS";
-
-    /**
-     * Authority codes known to this factory.
-     * We are better to declare first the codes that are most likely to be requested.
-     */
-    private static final String[] CODES = {"84", "83", "27", "88", "1"};
-
-    /**
-     * The set of codes known to this factory. Created when first needed.
-     */
-    private Set<String> codes;
+    private final Map<String,Class<?>> codes;
 
     /**
      * The authority for this factory.
@@ -114,11 +147,12 @@ public class CommonAuthorityFactory exte
         super(nameFactory);
         final DefaultCitation c = new DefaultCitation(Citations.OGC);
         c.setIdentifiers(Arrays.asList(
-                new SimpleIdentifier(null, "OGC", false),
-                new SimpleIdentifier(null, "CRS", false)
+                new SimpleIdentifier(null, Constants.OGC, false),
+                new SimpleIdentifier(null, Constants.CRS, false)
         ));
         c.freeze();
         authority = c;
+        codes = new LinkedHashMap<>();
     }
 
     /**
@@ -136,14 +170,37 @@ public class CommonAuthorityFactory exte
      * Provides a complete set of the known codes provided by this authority.
      * The returned set contains only numeric identifiers like {@code "84"}, {@code "27"}, <i>etc</i>.
      * The authority name ({@code "CRS"}) is not included in the character strings.
+     *
+     * @param  type The spatial reference objects type.
+     * @return The set of authority codes for spatial reference objects of the given type.
+     * @throws FactoryException if this method failed to provide the set of codes.
      */
     @Override
-    @SuppressWarnings("ReturnOfCollectionOrArrayField")     // Because the returned set is unmodifiable.
-    public synchronized Set<String> getAuthorityCodes(final Class<? extends IdentifiedObject> type) {
-        if (codes == null) {
-            codes = Collections.unmodifiableSet(new LinkedHashSet<>(Arrays.asList(CODES)));
+    public Set<String> getAuthorityCodes(final Class<? extends IdentifiedObject> type) throws FactoryException {
+        ArgumentChecks.ensureNonNull("type", type);
+        final boolean all = type.isAssignableFrom(SingleCRS.class);
+        if (!all && !SingleCRS.class.isAssignableFrom(type)) {
+            return Collections.emptySet();
+        }
+        synchronized (codes) {
+            if (codes.isEmpty()) {
+                add(Constants.CRS84, GeographicCRS.class);   // Put first the codes that are most likely to be requested.
+                add(Constants.CRS83, GeographicCRS.class);
+                add(Constants.CRS27, GeographicCRS.class);
+                add(Constants.CRS88, VerticalCRS.class);
+                add(Constants.CRS1,  EngineeringCRS.class);
+            }
+        }
+        return all ? Collections.unmodifiableSet(codes.keySet()) : new FilteredCodes(codes, type).keySet();
+    }
+
+    /**
+     * Adds an element in the {@link #codes} map, witch check against duplicated values.
+     */
+    private void add(final byte code, final Class<? extends SingleCRS> type) throws FactoryException {
+        if (codes.put(String.valueOf(code).intern(), type) != null) {
+            throw new FactoryException();    // Should never happen, but we are paranoiac.
         }
-        return codes;
     }
 
     /**
@@ -165,12 +222,12 @@ public class CommonAuthorityFactory exte
     @Override
     public CoordinateReferenceSystem createCoordinateReferenceSystem(final String code) throws FactoryException {
         String c = trimAuthority(code).toUpperCase(Locale.US);
-        if (c.startsWith(PREFIX)) {
+        if (c.startsWith(Constants.CRS)) {
             /*
              * "trimAuthority" removed "CRS" when it was separated from the code, as in "CRS:84".
              * This block removes "CRS" when it is concatenated with the code, as in "CRS84".
              */
-            c = c.substring(PREFIX.length());
+            c = CharSequences.trimWhitespaces(c.substring(Constants.CRS.length()));
         }
         final int n;
         try {
@@ -183,11 +240,11 @@ public class CommonAuthorityFactory exte
         }
         final CommonCRS crs;
         switch (n) {
-            case  1: return displayCRS();
-            case 84: crs = CommonCRS.WGS84; break;
-            case 83: crs = CommonCRS.NAD83; break;
-            case 27: crs = CommonCRS.NAD27; break;
-            case 88: return CommonCRS.Vertical.NAVD88.crs();
+            case Constants.CRS1:  return displayCRS();
+            case Constants.CRS84: crs = CommonCRS.WGS84; break;
+            case Constants.CRS83: crs = CommonCRS.NAD83; break;
+            case Constants.CRS27: crs = CommonCRS.NAD27; break;
+            case Constants.CRS88: return CommonCRS.Vertical.NAVD88.crs();
             default: throw noSuchAuthorityCode(CoordinateReferenceSystem.class, code);
         }
         return crs.normalizedGeographic();
@@ -196,26 +253,20 @@ public class CommonAuthorityFactory exte
     /**
      * Returns the "Computer display" reference system (CRS:1). This is rarely used.
      */
-    private synchronized CoordinateReferenceSystem displayCRS() {
+    private synchronized CoordinateReferenceSystem displayCRS() throws FactoryException {
         if (displayCRS == null) {
-            final DefaultCartesianCS cs = new DefaultCartesianCS(
-                    Collections.singletonMap(DefaultCartesianCS.NAME_KEY, "Computer display"),
-                    createDisplayAxis("i", AxisDirection.EAST),
-                    createDisplayAxis("j", AxisDirection.SOUTH));
+            final CSFactory csFactory = DefaultFactories.forBuildin(CSFactory.class);
+            final CartesianCS cs = csFactory.createCartesianCS(
+                    Collections.singletonMap(CartesianCS.NAME_KEY, "Computer display"),
+                    csFactory.createCoordinateSystemAxis(Collections.singletonMap(CartesianCS.NAME_KEY, "i"), "i", AxisDirection.EAST, NonSI.PIXEL),
+                    csFactory.createCoordinateSystemAxis(Collections.singletonMap(CartesianCS.NAME_KEY, "j"), "j", AxisDirection.SOUTH, NonSI.PIXEL));
 
             final Map<String,Object> properties = new HashMap<>(4);
-            properties.put(DefaultEngineeringDatum.NAME_KEY, cs.getName());
-            properties.put(DefaultEngineeringDatum.ANCHOR_POINT_KEY, "Origin is in upper left.");
-            displayCRS = new DefaultEngineeringCRS(properties, new DefaultEngineeringDatum(properties), cs);
+            properties.put(EngineeringDatum.NAME_KEY, cs.getName());
+            properties.put(EngineeringDatum.ANCHOR_POINT_KEY, "Origin is in upper left.");
+            displayCRS = DefaultFactories.forBuildin(CRSFactory.class).createEngineeringCRS(properties,
+                         DefaultFactories.forBuildin(DatumFactory.class).createEngineeringDatum(properties), cs);
         }
         return displayCRS;
     }
-
-    /**
-     * Creates a coordinate axis for "Computer display" (CRS:1).
-     */
-    private static CoordinateSystemAxis createDisplayAxis(final String abbreviation, final AxisDirection direction) {
-        return new DefaultCoordinateSystemAxis(Collections.singletonMap(DefaultCoordinateSystemAxis.NAME_KEY, abbreviation),
-                abbreviation, direction, NonSI.PIXEL);
-    }
 }

Added: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/FilteredCodes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/FilteredCodes.java?rev=1719354&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/FilteredCodes.java (added)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/FilteredCodes.java [UTF-8] Fri Dec 11 11:47:42 2015
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.referencing.factory;
+
+import java.util.Iterator;
+import java.util.Map;
+import org.apache.sis.internal.util.AbstractMap;
+
+
+/**
+ * A map of authority codes filtered by their type.
+ * This map is used for implementation of {@link CommonAuthorityFactory#getAuthorityCodes(Class)}.
+ * Only keys in this map are useful; values are meaningless.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.7
+ * @version 0.7
+ * @module
+ */
+final class FilteredCodes extends AbstractMap<String, Boolean> {
+    /**
+     * The codes known to the authority factory, associated with their CRS type.
+     */
+    final Map<String,Class<?>> codes;
+
+    /**
+     * The type of spatial reference objects for which the codes are desired.
+     */
+    final Class<?> type;
+
+    /**
+     * Creates a new filtered view over the given authority codes.
+     */
+    FilteredCodes(final Map<String,Class<?>> codes, final Class<?> type) {
+        this.codes = codes;
+        this.type = type;
+    }
+
+    /**
+     * Returns an iterator over the entries to retain.
+     * Values in the returned entries are meaningless; only the keys matter.
+     */
+    @Override
+    protected EntryIterator<String,Boolean> entryIterator() {
+        return new EntryIterator<String,Boolean>() {
+            /** Iterator over the backing map. */
+            private final Iterator<Map.Entry<String,Class<?>>> it = codes.entrySet().iterator();
+
+            /** The next code to return. */
+            private String code;
+
+            /** Move the iterator position to the next code to return. */
+            @Override protected boolean next() {
+                while (it.hasNext()) {
+                    final Map.Entry<String, Class<?>> entry = it.next();
+                    if (type.isAssignableFrom(entry.getValue())) {
+                        code = entry.getKey();
+                        return true;
+                    }
+                }
+                return false;
+            }
+
+            /** Returns the code at the current iterator position. */
+            @Override protected String getKey() {
+                return code;
+            }
+
+            /** Ignored, except that it must be non-null. */
+            @Override protected Boolean getValue() {
+                return Boolean.TRUE;
+            }
+        };
+    }
+
+    /**
+     * Ignored, except that it must be non-null.
+     */
+    @Override
+    public Boolean get(final Object key) {
+        return Boolean.TRUE;
+    }
+}

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/FilteredCodes.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/FilteredCodes.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java?rev=1719354&r1=1719353&r2=1719354&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java [UTF-8] Fri Dec 11 11:47:42 2015
@@ -114,10 +114,11 @@ public abstract class GeodeticAuthorityF
 
     /**
      * 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.
      *
      * <div class="section">Default implementation</div>
      * The default implementation invokes {@link #createObject(String)} for the given code
-     * and returns the object {@linkplain AbstractIdentifiedObject#getName() name}.
+     * and returns the {@linkplain AbstractIdentifiedObject#getName() object name}.
      * This may be costly since it involves a full object creation.
      * Subclasses are encouraged to provide a more efficient implementation if they can.
      *
@@ -131,14 +132,15 @@ public abstract class GeodeticAuthorityF
     /**
      * Returns an arbitrary object from a code. The returned object will typically be an instance of {@link Datum},
      * {@link CoordinateSystem}, {@link CoordinateReferenceSystem} or {@link CoordinateOperation}.
-     *
-     * <p>In default {@code GeodeticAuthorityFactory} implementation, all {@code createFoo(String)} methods
-     * ultimately delegate to this {@code createObject(String)} method. However subclasses are encouraged
-     * to override more specific methods for efficiency.</p>
-     *
-     * <div class="section">Default implementation</div>
-     * The default implementation always throw an exception. Subclasses should override this method
-     * if they are capable to automatically detect the object type from its code.
+     * This method may be used when the type of the object to create is unknown.
+     * But it is recommended to invoke the most specific {@code createFoo(String)} method when the type is known,
+     * both for performance reason and for avoiding ambiguity.
+     *
+     * <div class="section">Note for subclasses</div>
+     * In default {@code GeodeticAuthorityFactory} implementation, all {@code createFoo(String)} methods ultimately
+     * delegate to this {@code createObject(String)} method and verify if the created object is of the desired type.
+     * Overriding this method is sufficient for supporting the more specific {@code createFoo(String)} methods,
+     * but subclasses are encouraged to override the later for efficiency.
      *
      * @param  code Value allocated by authority.
      * @return The object for the given code.
@@ -150,13 +152,12 @@ public abstract class GeodeticAuthorityF
      * @see #createCoordinateSystem(String)
      */
     @Override
-    public IdentifiedObject createObject(final String code) throws NoSuchAuthorityCodeException, FactoryException {
-        ArgumentChecks.ensureNonNull("code", code);
-        throw noSuchAuthorityCode(IdentifiedObject.class, code);
-    }
+    public abstract IdentifiedObject createObject(String code) throws NoSuchAuthorityCodeException, FactoryException;
 
     /**
      * Creates an arbitrary coordinate reference system from a code.
+     * The returned object will typically be an instance of {@link GeographicCRS}, {@link ProjectedCRS},
+     * {@link VerticalCRS} or {@link CompoundCRS}.
      * If the coordinate reference system type is known at compile time,
      * it is recommended to invoke the most precise method instead of this one (for example
      * {@link #createGeographicCRS createGeographicCRS(String)} instead of
@@ -184,7 +185,9 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates a geographic coordinate reference system from a code.
+     * Creates a 2- or 3-dimensional coordinate reference system based on an ellipsoidal approximation of the geoid.
+     * This provides an accurate representation of the geometry of geographic features
+     * for a large portion of the earth's surface.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createCoordinateReferenceSystem(String)} and casts the result.
@@ -204,7 +207,9 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates a geocentric coordinate reference system from a code.
+     * Creates a 3-dimensional coordinate reference system with the origin at the approximate centre of mass of the earth.
+     * A geocentric CRS deals with the earth's curvature by taking a 3-dimensional spatial view, which obviates
+     * the need to model the earth's curvature.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createCoordinateReferenceSystem(String)} and casts the result.
@@ -225,7 +230,10 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates a projected coordinate reference system from a code.
+     * Creates a 2-dimensional coordinate reference system used to approximate the shape of the earth on a planar surface.
+     * It is done in such a way that the distortion that is inherent to the approximation is carefully controlled and known.
+     * Distortion correction is commonly applied to calculated bearings and distances to produce values
+     * that are a close match to actual field values.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createCoordinateReferenceSystem(String)} and casts the result.
@@ -245,7 +253,9 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates a vertical coordinate reference system from a code.
+     * Creates a 1-dimensional coordinate reference system used for recording heights or depths.
+     * Vertical CRSs make use of the direction of gravity to define the concept of height or depth,
+     * but the relationship with gravity may not be straightforward.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createCoordinateReferenceSystem(String)} and casts the result.
@@ -265,7 +275,7 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates a temporal coordinate reference system from a code.
+     * Creates a 1-dimensional coordinate reference system used for the recording of time.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createCoordinateReferenceSystem(String)} and casts the result.
@@ -285,7 +295,7 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates a 3D or 4D coordinate reference system from a code.
+     * Creates a CRS describing the position of points through two or more independent coordinate reference systems.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createCoordinateReferenceSystem(String)} and casts the result.
@@ -305,7 +315,8 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates a derived coordinate reference system from a code.
+     * Creates a CRS that is defined by its coordinate conversion from another CRS (not by a datum).
+     * {@code DerivedCRS} can not be {@code ProjectedCRS} themselves, but may be derived from a projected CRS.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createCoordinateReferenceSystem(String)} and casts the result.
@@ -323,7 +334,7 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates an engineering coordinate reference system from a code.
+     * Creates a 1-, 2- or 3-dimensional contextually local coordinate reference system.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createCoordinateReferenceSystem(String)} and casts the result.
@@ -342,7 +353,9 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates an image coordinate reference system from a code.
+     * Creates a 2-dimensional engineering coordinate reference system applied to locations in images.
+     * Image coordinate reference systems are treated as a separate sub-type because a separate
+     * user community exists for images with its own terms of reference.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createCoordinateReferenceSystem(String)} and casts the result.
@@ -361,7 +374,9 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Returns an arbitrary datum from a code.
+     * Creates an arbitrary datum from a code. The returned object will typically be an
+     * instance of {@link GeodeticDatum}, {@link VerticalDatum} or {@link TemporalDatum}.
+     * If the datum is known at compile time, it is recommended to invoke the most precise method instead of this one.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createObject(String)} and casts the result.
@@ -381,7 +396,9 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates a geodetic datum from a code.
+     * Creates a datum defining the location and orientation of an ellipsoid that approximates the shape of the earth.
+     * Geodetic datum are used together with ellipsoidal coordinate system, and also with Cartesian coordinate system
+     * centered in the ellipsoid (or sphere).
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createDatum(String)} and casts the result.
@@ -403,7 +420,9 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates a vertical datum from a code.
+     * Creates a datum identifying a particular reference level surface used as a zero-height surface.
+     * There are several types of vertical datums, and each may place constraints on the axis with which
+     * it is combined to create a vertical CRS.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createDatum(String)} and casts the result.
@@ -422,7 +441,7 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates a temporal datum from a code.
+     * Creates a datum defining the origin of a temporal coordinate reference system.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createDatum(String)} and casts the result.
@@ -441,7 +460,9 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates a engineering datum from a code.
+     * Creates a datum defining the origin of an engineering coordinate reference system.
+     * An engineering datum is used in a region around that origin.
+     * This origin can be fixed with respect to the earth or be a defined point on a moving vehicle.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createDatum(String)} and casts the result.
@@ -460,7 +481,9 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates a image datum from a code.
+     * Creates a datum defining the origin of an image coordinate reference system.
+     * An image datum is used in a local context only.
+     * For an image datum, the anchor point is usually either the centre of the image or the corner of the image.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createDatum(String)} and casts the result.
@@ -479,7 +502,8 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates an ellipsoid from a code.
+     * Creates a geometric figure that can be used to describe the approximate shape of the earth.
+     * In mathematical terms, it is a surface formed by the rotation of an ellipse about its minor axis.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createObject(String)} and casts the result.
@@ -499,7 +523,7 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates a prime meridian from a code.
+     * Creates a prime meridian defining the origin from which longitude values are determined.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createObject(String)} and casts the result.
@@ -518,7 +542,7 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates an extent (usually an domain of validity) from a code.
+     * Creates information about spatial, vertical, and temporal extent (usually a domain of validity) from a code.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createObject(String)} and casts the result.
@@ -538,7 +562,10 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates an arbitrary coordinate system from a code.
+     * Creates an arbitrary coordinate system from a code. The returned object will typically be an
+     * instance of {@link EllipsoidalCS}, {@link CartesianCS}, {@link VerticalCS} or {@link TimeCS}.
+     * If the coordinate system is known at compile time, it is recommended to invoke the most precise
+     * method instead of this one.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createObject(String)} and casts the result.
@@ -558,7 +585,8 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates an ellipsoidal coordinate system from a code.
+     * Creates 2- or 3-dimensional coordinate system for geodetic latitude and longitude,
+     * sometime with ellipsoidal height.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createCoordinateSystem(String)} and casts the result.
@@ -579,7 +607,7 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates a vertical coordinate system from a code.
+     * Creates a 1-dimensional coordinate system for heights or depths of points.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createCoordinateSystem(String)} and casts the result.
@@ -599,7 +627,8 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates a temporal coordinate system from a code.
+     * Creates a 1-dimensional coordinate system for time elapsed in the specified time units
+     * from a specified time origin.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createCoordinateSystem(String)} and casts the result.
@@ -619,7 +648,8 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates a Cartesian coordinate system from a code.
+     * Creates a 2- or 3-dimensional Cartesian coordinate system made of straight orthogonal axes.
+     * All axes shall have the same linear unit of measure.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createCoordinateSystem(String)} and casts the result.
@@ -639,7 +669,8 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates a spherical coordinate system from a code.
+     * Creates a 3-dimensional coordinate system with one distance measured from the origin and two angular coordinates.
+     * Not to be confused with an ellipsoidal coordinate system based on an ellipsoid "degenerated" into a sphere.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createCoordinateSystem(String)} and casts the result.
@@ -658,7 +689,8 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates a cylindrical coordinate system from a code.
+     * Creates a 3-dimensional coordinate system made of a polar coordinate system
+     * extended by a straight perpendicular axis.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createCoordinateSystem(String)} and casts the result.
@@ -676,7 +708,8 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates a polar coordinate system from a code.
+     * Creates a 2-dimensional coordinate system for coordinates represented by a distance from the origin
+     * and an angle from a fixed direction.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createCoordinateSystem(String)} and casts the result.
@@ -694,7 +727,7 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates a coordinate system axis from a code.
+     * Creates a coordinate system axis with name, direction, unit and range of values.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createObject(String)} and casts the result.
@@ -731,7 +764,7 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates a parameter descriptor from a code.
+     * Creates a definition of a single parameter used by an operation method.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createObject(String)} and casts the result.
@@ -751,7 +784,9 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates an operation method from a code.
+     * Creates  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.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createObject(String)} and casts the result.
@@ -769,7 +804,9 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates an operation from a code.
+     * Creates an operation for transforming coordinates in the source CRS to coordinates in the target CRS.
+     * Coordinate operations contain a {@linkplain org.apache.sis.referencing.operation.transform.AbstractMathTransform
+     * math transform}, which does the actual work of transforming coordinates.
      *
      * <div class="section">Default implementation</div>
      * The default implementation delegates to {@link #createObject(String)} and casts the result.

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=1719354&r1=1719353&r2=1719354&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] Fri Dec 11 11:47:42 2015
@@ -38,7 +38,7 @@ import org.apache.sis.util.resources.Err
 
 
 /**
- * Search in an authority factory for objects approximatively equal to a given object.
+ * Searches in an authority factory for objects approximatively equal to a given object.
  * This class can be used for fetching a fully {@linkplain AbstractIdentifiedObject identified object}
  * from an incomplete one, for example from an object without "{@code ID[…]}" or "{@code AUTHORITY[…]}"
  * element in <cite>Well Known Text</cite>.

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java?rev=1719354&r1=1719353&r2=1719354&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java [UTF-8] Fri Dec 11 11:47:42 2015
@@ -16,10 +16,16 @@
  */
 package org.apache.sis.referencing.factory;
 
+import java.util.Arrays;
 import org.opengis.util.NameFactory;
 import org.opengis.util.FactoryException;
 import org.opengis.metadata.citation.Citation;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.opengis.referencing.crs.EngineeringCRS;
 import org.opengis.referencing.crs.GeographicCRS;
+import org.opengis.referencing.crs.VerticalCRS;
+import org.opengis.referencing.cs.AxisDirection;
+import org.opengis.referencing.datum.Datum;
 import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.metadata.iso.citation.Citations;
 import org.apache.sis.referencing.CommonCRS;
@@ -57,7 +63,26 @@ public final strictfp class CommonAuthor
     }
 
     /**
-     * Checks the authority names.
+     * Tests {@link CommonAuthorityFactory#getAuthorityCodes(Class)}.
+     *
+     * @throws FactoryException if an error occurred while fetching the set of codes.
+     */
+    @Test
+    public void testGetAuthorityCodes() throws FactoryException {
+        assertTrue("getAuthorityCodes(Datum.class)",
+                factory.getAuthorityCodes(Datum.class).isEmpty());
+        assertSetEquals(Arrays.asList("1", "27", "83", "84", "88"),
+                factory.getAuthorityCodes(CoordinateReferenceSystem.class));
+        assertSetEquals(Arrays.asList("27", "83", "84"),
+                factory.getAuthorityCodes(GeographicCRS.class));
+        assertSetEquals(Arrays.asList("88"),
+                factory.getAuthorityCodes(VerticalCRS.class));
+        assertSetEquals(Arrays.asList("1"),
+                factory.getAuthorityCodes(EngineeringCRS.class));
+    }
+
+    /**
+     * Checks the value returned by {@link CommonAuthorityFactory#getAuthority()}.
      */
     @Test
     public void testAuthority() {
@@ -71,7 +96,7 @@ public final strictfp class CommonAuthor
     }
 
     /**
-     * Tests the CRS:84 code.
+     * Tests {@link CommonAuthorityFactory#createGeographicCRS(String)} with the {@code "CRS:84"} code.
      *
      * @throws FactoryException if an error occurred while creating a CRS.
      */
@@ -86,10 +111,11 @@ public final strictfp class CommonAuthor
         assertSame   (crs,  factory.createGeographicCRS("OGC:84"));         // Not in real use as far as I know.
         assertSame   (crs,  factory.createGeographicCRS("OGC:CRS84"));
         assertNotSame(crs,  factory.createGeographicCRS("CRS:83"));
+        assertAxisDirectionsEqual("CS", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH);
     }
 
     /**
-     * Tests the CRS:83 code.
+     * Tests {@link CommonAuthorityFactory#createGeographicCRS(String)} with the {@code "CRS:83"} code.
      *
      * @throws FactoryException if an error occurred while creating a CRS.
      */
@@ -102,6 +128,37 @@ public final strictfp class CommonAuthor
         assertSame   (crs,  factory.createGeographicCRS("CRS:CRS83"));
         assertNotSame(crs,  factory.createGeographicCRS("CRS:84"));
         assertNotDeepEquals(CommonCRS.WGS84.normalizedGeographic(), crs);
+        assertAxisDirectionsEqual("CS", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH);
+    }
+
+    /**
+     * Tests {@link CommonAuthorityFactory#createVerticalCRS(String)} with the {@code "CRS:88"} code.
+     *
+     * @throws FactoryException if an error occurred while creating a CRS.
+     */
+    @Test
+    @DependsOnMethod("testAuthority")
+    public void testCRS88() throws FactoryException {
+        VerticalCRS crs = factory.createVerticalCRS("CRS:88");
+        assertSame (crs,  factory.createVerticalCRS("88"));
+        assertSame (crs,  factory.createVerticalCRS("CRS88"));
+        assertSame (crs,  factory.createVerticalCRS("CRS:CRS 88"));
+        assertAxisDirectionsEqual("CS", crs.getCoordinateSystem(), AxisDirection.UP);
+    }
+
+    /**
+     * Tests {@link CommonAuthorityFactory#createEngineeringCRS(String)} with the {@code "CRS:1"} code.
+     *
+     * @throws FactoryException if an error occurred while creating a CRS.
+     */
+    @Test
+    @DependsOnMethod("testAuthority")
+    public void testCRS1() throws FactoryException {
+        EngineeringCRS crs = factory.createEngineeringCRS("CRS:1");
+        assertSame (crs,  factory.createEngineeringCRS("1"));
+        assertSame (crs,  factory.createEngineeringCRS("CRS1"));
+        assertSame (crs,  factory.createEngineeringCRS("CRS:CRS 1"));
+        assertAxisDirectionsEqual("CS", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.SOUTH);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java?rev=1719354&r1=1719353&r2=1719354&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java [UTF-8] Fri Dec 11 11:47:42 2015
@@ -32,7 +32,7 @@ import org.apache.sis.util.Static;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
- * @version 0.6
+ * @version 0.7
  * @module
  */
 public final class Constants extends Static {
@@ -78,6 +78,16 @@ public final class Constants extends Sta
     public static final byte CRS84 = 84;
 
     /**
+     * The {@code CRS:88} identifier for a coordinate reference system.
+     */
+    public static final byte CRS88 = 88;
+
+    /**
+     * The {@code CRS:1} identifier for a coordinate reference system.
+     */
+    public static final byte CRS1 = 1;
+
+    /**
      * The NetCDF parameter name for the Earth radius.
      */
     public static final String EARTH_RADIUS = "earth_radius";



Mime
View raw message