sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1730904 [1/2] - in /sis/branches/JDK7: ./ core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/ core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ core/sis-referencing/src/main/java/org/apache/sis/inter...
Date Wed, 17 Feb 2016 18:44:26 GMT
Author: desruisseaux
Date: Wed Feb 17 18:44:26 2016
New Revision: 1730904

URL: http://svn.apache.org/viewvc?rev=1730904&view=rev
Log:
Merge from the JDK8 branch.

Added:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/EPSGParameterDomain.java
      - copied unchanged from r1730896, sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/EPSGParameterDomain.java
Modified:
    sis/branches/JDK7/   (props changed)
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/SQLUtilities.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/DeprecatedCode.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator2SP.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/Verifier.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java
    sis/branches/JDK7/core/sis-referencing/src/main/resources/org/apache/sis/referencing/factory/sql/EPSG.sql
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2004.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatter.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateReferenceSystems.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Range.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/SexagesimalConverter.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/StringBuilders.java
    sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/MeasurementRangeTest.java

Propchange: sis/branches/JDK7/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Feb 17 18:44:26 2016
@@ -1,4 +1,4 @@
 /sis/branches/Android:1430670-1480699
 /sis/branches/JDK6:1394913-1508480
-/sis/branches/JDK8:1584960-1730364
+/sis/branches/JDK8:1584960-1730896
 /sis/trunk:1394364-1508466,1519089-1519674

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/SQLUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/SQLUtilities.java?rev=1730904&r1=1730903&r2=1730904&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/SQLUtilities.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/SQLUtilities.java [UTF-8] Wed Feb 17 18:44:26 2016
@@ -16,6 +16,8 @@
  */
 package org.apache.sis.internal.metadata.sql;
 
+import java.sql.SQLException;
+import java.sql.DatabaseMetaData;
 import org.apache.sis.util.Static;
 import org.apache.sis.util.Characters;
 import org.apache.sis.util.CharSequences;
@@ -42,6 +44,21 @@ public final class SQLUtilities extends
     }
 
     /**
+     * Returns a simplified form of the URL (truncated before the first {@code ?} or {@code ;} character),
+     * for logging or informative purpose only.
+     *
+     * @param  metadata The metadata of the database.
+     * @return A simplified version of database URL.
+     * @throws SQLException if an error occurred while fetching the URL.
+     */
+    public static String getSimplifiedURL(final DatabaseMetaData metadata) throws SQLException {
+        String url = metadata.getURL();
+        int s1 = url.indexOf('?'); if (s1 < 0) s1 = url.length();
+        int s2 = url.indexOf(';'); if (s2 < 0) s2 = url.length();
+        return url.substring(0, Math.min(s1, s2));
+    }
+
+    /**
      * Returns a string like the given string but with all characters that are not letter or digit
      * replaced by the wildcard % character.
      *

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/DeprecatedCode.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/DeprecatedCode.java?rev=1730904&r1=1730903&r2=1730904&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/DeprecatedCode.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/DeprecatedCode.java [UTF-8] Wed Feb 17 18:44:26 2016
@@ -44,18 +44,26 @@ public final class DeprecatedCode extend
     private static final long serialVersionUID = 357222258307746767L;
 
     /**
+     * The replacement for the deprecated object, or {@code null} if none.
+     */
+    public final String replacedBy;
+
+    /**
      * Creates a deprecated identifier.
      *
      * @param authority  Organization or party responsible for definition and maintenance of the code space or code.
      * @param codeSpace  Name or identifier of the person or organization responsible for namespace.
      * @param code       Identifier code or name, optionally from a controlled list or pattern defined by a code space.
      * @param version    The version of the associated code space or code as specified by the code authority, or {@code null} if none.
+     * @param replacedBy The replacement for the deprecated object, or {@code null} if none.
      * @param remarks    Comments on or information about why this identifier is deprecated, or {@code null} if none.
      */
     public DeprecatedCode(final Citation authority, final String codeSpace,
-            final String code, final String version, final InternationalString remarks)
+            final String code, final String version, final String replacedBy,
+            InternationalString remarks)
     {
         super(authority, codeSpace, code, version, remarks);
+        this.replacedBy = replacedBy;
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator2SP.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator2SP.java?rev=1730904&r1=1730903&r2=1730904&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator2SP.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator2SP.java [UTF-8] Wed Feb 17 18:44:26 2016
@@ -77,7 +77,7 @@ public final class Mercator2SP extends A
          * projection according EPSG. But we declare them as optional parameters because they are sometime used in
          * Well Known Text (WKT).
          */
-        builder.setRequired(false); // Will apply to all remaining parameters.
+        builder.setRequired(false);         // Will apply to all remaining parameters.
         final InternationalString remarks = notFormalParameter("Mercator (variant A)");
         final ParameterDescriptor<Double> latitudeOfOrigin = createZeroConstant(builder
                 .addNamesAndIdentifiers(Mercator1SP.LATITUDE_OF_ORIGIN)

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java?rev=1730904&r1=1730903&r2=1730904&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java [UTF-8] Wed Feb 17 18:44:26 2016
@@ -684,8 +684,11 @@ public class DefaultParameterValue<T> ex
     public void setValue(final double value, final Unit<?> unit) throws InvalidParameterValueException {
         try {
             setValue(wrap(value, descriptor.getValueClass()), unit);
+        } catch (InvalidParameterValueException e) {
+            throw e;        // Need to be thrown explicitely because it is a subclass of IllegalArgumentException.
         } catch (IllegalArgumentException e) {
-            throw new InvalidParameterValueException(e.getLocalizedMessage(), Verifier.getDisplayName(descriptor), value);
+            throw (InvalidParameterValueException) new InvalidParameterValueException(
+                    e.getLocalizedMessage(), Verifier.getDisplayName(descriptor), value).initCause(e);
         }
     }
 

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/Verifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/Verifier.java?rev=1730904&r1=1730903&r2=1730904&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/Verifier.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/Verifier.java [UTF-8] Wed Feb 17 18:44:26 2016
@@ -26,6 +26,7 @@ import org.opengis.metadata.Identifier;
 import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.GeneralParameterDescriptor;
 import org.opengis.parameter.InvalidParameterValueException;
+import org.apache.sis.internal.referencing.EPSGParameterDomain;
 import org.apache.sis.measure.Range;
 import org.apache.sis.measure.Units;
 import org.apache.sis.util.Numbers;
@@ -40,7 +41,7 @@ import org.apache.sis.util.resources.Voc
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.7
  * @module
  */
 final class Verifier {
@@ -106,10 +107,13 @@ final class Verifier {
         UnitConverter converter = null;
         Object convertedValue = value;
         if (unit != null) {
-            final Unit<?> def = descriptor.getUnit();
+            Unit<?> def = descriptor.getUnit();
             if (def == null) {
-                final String name = getDisplayName(descriptor);
-                throw new InvalidParameterValueException(Errors.format(Errors.Keys.UnitlessParameter_1, name), name, unit);
+                def = getCompatibleUnit(Parameters.getValueDomain(descriptor), unit);
+                if (def == null) {
+                    final String name = getDisplayName(descriptor);
+                    throw new InvalidParameterValueException(Errors.format(Errors.Keys.UnitlessParameter_1, name), name, unit);
+                }
             }
             if (!unit.equals(def)) {
                 final short expectedID = getUnitMessageID(def);
@@ -161,7 +165,7 @@ final class Verifier {
                         componentType = Numbers.primitiveToWrapper(componentType);
                         for (int i=0; i<length; i++) {
                             Number n = (Number) Array.get(value, i);
-                            n = converter.convert(n.doubleValue()); // Value in units that we can compare.
+                            n = converter.convert(n.doubleValue());         // Value in units that we can compare.
                             try {
                                 n = Numbers.cast(n, componentType.asSubclass(Number.class));
                             } catch (IllegalArgumentException e) {
@@ -290,6 +294,22 @@ final class Verifier {
     }
 
     /**
+     * If the given domain of values accepts units of incompatible dimensions, return the unit which is compatible
+     * with the given units. This is a non-public mechanism handling a few parameters in the EPSG database, like
+     * <cite>Ordinate 1 of evaluation point</cite> (EPSG:8617).
+     */
+    private static Unit<?> getCompatibleUnit(final Range<?> valueDomain, final Unit<?> unit) {
+        if (valueDomain instanceof EPSGParameterDomain) {
+            for (final Unit<?> valid : ((EPSGParameterDomain) valueDomain).units) {
+                if (unit.isCompatible(valid)) {
+                    return valid;
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
      * Returns an error message for the error detected by
      * {@link #ensureValidValue(Class, Set, Range, Object)}.
      *

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java?rev=1730904&r1=1730903&r2=1730904&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java [UTF-8] Wed Feb 17 18:44:26 2016
@@ -649,7 +649,7 @@ public abstract class Builder<B extends
     private void addIdentifier(final Citation authority, final String codeSpace, final String identifier, final String version) {
         final Identifier id;
         if (isDeprecated()) {
-            id = new DeprecatedCode(authority, codeSpace, identifier, version, getRemarks());
+            id = new DeprecatedCode(authority, codeSpace, identifier, version, null, getRemarks());
         } else {
             id = new ImmutableIdentifier(authority, codeSpace, identifier, version, getDescription());
         }

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=1730904&r1=1730903&r2=1730904&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] Wed Feb 17 18:44:26 2016
@@ -88,7 +88,7 @@ public abstract class GeodeticAuthorityF
      *   │  └─ 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.
+     *      ├─ Description ……………………………… EPSG dataset version 8.9 on “Apache Derby Embedded JDBC Driver” version 10.12.
      *      └─ Function ……………………………………… Connection
      * }
      *
@@ -1189,7 +1189,7 @@ public abstract class GeodeticAuthorityF
                     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 separator sometime appears twice, as in "EPSG::4326" or "EPSG:8.9:4326".
                          * The part between the two separators is the verion number, which we ignore in
                          * this simple version.
                          */

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=1730904&r1=1730903&r2=1730904&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] Wed Feb 17 18:44:26 2016
@@ -71,6 +71,7 @@ import org.apache.sis.internal.metadata.
 import org.apache.sis.internal.metadata.TransformationAccuracy;
 import org.apache.sis.internal.metadata.sql.SQLUtilities;
 import org.apache.sis.internal.referencing.DeprecatedCode;
+import org.apache.sis.internal.referencing.EPSGParameterDomain;
 import org.apache.sis.internal.referencing.Formulas;
 import org.apache.sis.internal.system.Loggers;
 import org.apache.sis.internal.util.Constants;
@@ -107,6 +108,7 @@ import org.apache.sis.util.Localized;
 import org.apache.sis.util.Version;
 import org.apache.sis.util.collection.Containers;
 import org.apache.sis.measure.MeasurementRange;
+import org.apache.sis.measure.NumberRange;
 import org.apache.sis.measure.Units;
 
 import static org.apache.sis.internal.referencing.ServicesForMetadata.CONNECTION;
@@ -159,6 +161,38 @@ public class EPSGDataAccess extends Geod
         CSAuthorityFactory, DatumAuthorityFactory, CoordinateOperationAuthorityFactory, Localized, AutoCloseable
 {
     /**
+     * The deprecated ellipsoidal coordinate systems and their replacements. Those coordinate systems are deprecated
+     * because they use a unit of measurement which is no longer supported by OGC (for example degree-minute-second).
+     * Those replacements can be used only if the ellipsoidal CS is used for the base geographic CRS of a derived or
+     * projected CRS, because the units of measurement of the base CRS do not impact the units of measurements of the
+     * derived CRS.
+     *
+     * <p>We perform those replacements for avoiding a "Unit conversion from “DMS” to “°” is non-linear" exception
+     * at projected CRS creation time.</p>
+     *
+     * @see #replaceDeprecatedCS
+     */
+    private static final Map<Integer,Integer> DEPRECATED_CS = deprecatedCS();
+    static Map<Integer,Integer> deprecatedCS() {
+        final Map<Integer,Integer> m = new HashMap<>(24);
+
+        // Ellipsoidal 2D CS. Axes: latitude, longitude. Orientations: north, east. UoM: degree
+        Integer replacement = 6422;
+        m.put(6402, replacement);
+        for (int code = 6405; code <= 6412; code++) {
+            m.put(code, replacement);
+        }
+
+        // Ellipsoidal 3D CS. Axes: latitude, longitude, ellipsoidal height. Orientations: north, east, up. UoM: degree, degree, metre.
+        replacement = 6423;
+        m.put(6401, replacement);
+        for (int code = 6413; code <= 6420; code++) {
+            m.put(code, replacement);
+        }
+        return m;
+    }
+
+    /**
      * The namespace of EPSG names and codes. This namespace is needed by all {@code createFoo(String)} methods.
      * The {@code EPSGDataAccess} constructor relies on the {@link EPSGFactory#nameFactory} caching mechanism
      * for giving us the same {@code NameSpace} instance than the one used by previous {@code EPSGDataAccess}
@@ -267,10 +301,20 @@ public class EPSGDataAccess extends Geod
      * {@code true} for disabling the logging of warnings when this factory creates deprecated objects.
      * This flag should be always {@code false}, except during {@link Finder#find(IdentifiedObject)}
      * execution since that method may temporarily creates deprecated objects which are later discarded.
+     * May also be {@code false} when creating base CRS of deprecated projected or derived CRS.
      */
     private transient boolean quiet;
 
     /**
+     * {@code true} if {@link #createCoordinateReferenceSystem(String)} is allowed to replace deprecated
+     * coordinate system at CRS creation time. This flag should be set to {@code true} only when creating
+     * the base CRS of a projected or derived CRS.
+     *
+     * @see #DEPRECATED_CS
+     */
+    private transient boolean replaceDeprecatedCS;
+
+    /**
      * The {@code ConcurrentAuthorityFactory} that created this Data Access Object (DAO).
      * The owner supplies caching for all {@code createFoo(String)} methods.
      */
@@ -356,7 +400,7 @@ public class EPSGDataAccess extends Geod
      *   │  └─ 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.
+     *      ├─ Description ……………………………… EPSG dataset version 8.9 on “Apache Derby Embedded JDBC Driver” version 10.12.
      *      └─ Function ……………………………………… Connection
      * }
      */
@@ -395,7 +439,7 @@ 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.
+             *    Description:  EPSG dataset version 8.9 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).
@@ -421,7 +465,7 @@ addURIs:    for (int i=0; ; i++) {
                 }
                 final DefaultOnlineResource r = new DefaultOnlineResource();
                 try {
-                    r.setLinkage(new URI(url));
+                    r.setLinkage(new URI(SQLUtilities.getSimplifiedURL(metadata)));
                 } catch (URISyntaxException exception) {
                     unexpectedException("getAuthority", exception);
                 }
@@ -652,7 +696,7 @@ addURIs:    for (int i=0; ; i++) {
                     statements.put(KEY, statement);
                     lastTableForName = table;
                 }
-                statement.setString(1, SQLUtilities.toLikePattern(code));
+                statement.setString(1, toLikePattern(code));
                 Integer resolved = null;
                 try (ResultSet result = statement.executeQuery()) {
                     while (result.next()) {
@@ -947,16 +991,14 @@ addURIs:    for (int i=0; ; i++) {
     }
 
     /**
-     * Logs a warning saying that the given code is deprecated and returns a message proposing a replacement.
+     * Logs a warning saying that the given code is deprecated and returns the code of the proposed replacement.
      *
      * @param  table  The table of the deprecated code.
      * @param  code   The deprecated code.
      * @param  locale The locale for logging messages.
-     * @return A message proposing a replacement, or {@code null} if none.
+     * @return The proposed replacement (may be the "(none)" text).
      */
-    private InternationalString getSupersession(final String table, final Integer code, final Locale locale)
-            throws SQLException
-    {
+    private String getSupersession(final String table, final Integer code, final Locale locale) throws SQLException {
         String reason = null;
         Object replacedBy = null;
         try (ResultSet result = executeQuery("Deprecation",
@@ -994,7 +1036,7 @@ addURIs:    for (int i=0; ; i++) {
             record.setLoggerName(Loggers.CRS_FACTORY);
             Logging.log(EPSGDataAccess.class, method, record);
         }
-        return Vocabulary.formatInternational(Vocabulary.Keys.SupersededBy_1, replacedBy);
+        return (String) replacedBy;
     }
 
     /**
@@ -1008,42 +1050,21 @@ addURIs:    for (int i=0; ; i++) {
      * @return The name together with a set of properties.
      */
     @SuppressWarnings("ReturnOfCollectionOrArrayField")
-    private Map<String,Object> createProperties(final String table, final String name, final Integer code,
+    private Map<String,Object> createProperties(final String table, String name, final Integer code,
             String remarks, final boolean deprecated) throws SQLException, FactoryDataException
     {
-        properties.clear();
-        GenericName gn = null;
-        final Locale locale = getLocale();
-        final Citation authority = owner.getAuthority();
-        final InternationalString edition = authority.getEdition();
-        final String version = (edition != null) ? edition.toString() : null;
-        if (name != null) {
-            gn = owner.nameFactory.createGenericName(namespace, Constants.EPSG, name);
-            properties.put("name", gn);
-            properties.put(NamedIdentifier.CODE_KEY,      name);
-            properties.put(NamedIdentifier.VERSION_KEY,   version);
-            properties.put(NamedIdentifier.AUTHORITY_KEY, authority);
-            properties.put(AbstractIdentifiedObject.LOCALE_KEY, locale);
-            final NamedIdentifier id = new NamedIdentifier(properties);
-            properties.clear();
-            properties.put(IdentifiedObject.NAME_KEY, id);
-        }
-        if (code != null) {
-            final String codeString = code.toString();
-            final ImmutableIdentifier identifier;
-            if (deprecated) {
-                identifier = new DeprecatedCode(authority, Constants.EPSG, codeString, version, getSupersession(table, code, locale));
-                properties.put(AbstractIdentifiedObject.DEPRECATED_KEY, Boolean.TRUE);
-            } else {
-                identifier = new ImmutableIdentifier(authority, Constants.EPSG, codeString, version,
-                                    (gn != null) ? gn.toInternationalString() : null);
-            }
-            properties.put(IdentifiedObject.IDENTIFIERS_KEY, identifier);
-        }
-        properties.put(IdentifiedObject.REMARKS_KEY, remarks);
         /*
          * Search for aliases. Note that searching for the object code is not sufficient. We also need to check if the
          * record is really from the table we are looking for since different tables may have objects with the same ID.
+         *
+         * Some aliases are identical to the name except that some letters are replaced by their accented letters.
+         * For example "Reseau Geodesique Francais" → "Réseau Géodésique Français". If we find such alias, replace
+         * the name by the alias so we have proper display in user interface. Notes:
+         *
+         *   - WKT formatting will still be compliant with ISO 19162 because the WKT formatter replaces accented
+         *     letters by ASCII ones.
+         *   - We do not perform this replacement directly in our EPSG database because ASCII letters are more
+         *     convenient for implementing accent-insensitive searches.
          */
         final List<GenericName> aliases = new ArrayList<>();
         try (ResultSet result = executeQuery("Alias",
@@ -1065,13 +1086,53 @@ addURIs:    for (int i=0; ; i++) {
                             namingSystems.put(naming, ns);
                         }
                     }
-                    aliases.add(owner.nameFactory.createLocalName(ns, alias));
+                    if (CharSequences.toASCII(alias).toString().equals(name)) {
+                        name = alias;
+                    } else {
+                        aliases.add(owner.nameFactory.createLocalName(ns, alias));
+                    }
                 }
             }
         }
+        /*
+         * At this point we can fill the properties map.
+         */
+        properties.clear();
+        GenericName gn = null;
+        final Locale locale = getLocale();
+        final Citation authority = owner.getAuthority();
+        final InternationalString edition = authority.getEdition();
+        final String version = (edition != null) ? edition.toString() : null;
+        if (name != null) {
+            gn = owner.nameFactory.createGenericName(namespace, Constants.EPSG, name);
+            properties.put("name", gn);
+            properties.put(NamedIdentifier.CODE_KEY,      name);
+            properties.put(NamedIdentifier.VERSION_KEY,   version);
+            properties.put(NamedIdentifier.AUTHORITY_KEY, authority);
+            properties.put(AbstractIdentifiedObject.LOCALE_KEY, locale);
+            final NamedIdentifier id = new NamedIdentifier(properties);
+            properties.clear();
+            properties.put(IdentifiedObject.NAME_KEY, id);
+        }
         if (!aliases.isEmpty()) {
             properties.put(IdentifiedObject.ALIAS_KEY, aliases.toArray(new GenericName[aliases.size()]));
         }
+        if (code != null) {
+            final String codeString = code.toString();
+            final ImmutableIdentifier identifier;
+            if (deprecated) {
+                final String replacedBy = getSupersession(table, code, locale);
+                identifier = new DeprecatedCode(authority, Constants.EPSG, codeString, version,
+                        Character.isDigit(replacedBy.charAt(0)) ? replacedBy : null,
+                        Vocabulary.formatInternational(Vocabulary.Keys.SupersededBy_1, replacedBy));
+                properties.put(AbstractIdentifiedObject.DEPRECATED_KEY, Boolean.TRUE);
+            } else {
+                identifier = new ImmutableIdentifier(authority, Constants.EPSG, codeString, version,
+                                    (gn != null) ? gn.toInternationalString() : null);
+            }
+            properties.put(IdentifiedObject.IDENTIFIERS_KEY, identifier);
+        }
+        properties.put(IdentifiedObject.REMARKS_KEY, remarks);
         properties.put(AbstractIdentifiedObject.LOCALE_KEY, locale);
         properties.put(ReferencingServices.MT_FACTORY, owner.mtFactory);
         return properties;
@@ -1101,6 +1162,16 @@ addURIs:    for (int i=0; ; i++) {
     }
 
     /**
+     * Returns a string like the given string but with accented letters replaced by ASCII letters
+     * and all characters that are not letter or digit replaced by the wildcard % character.
+     *
+     * @see SQLUtilities#toLikePattern(String)
+     */
+    private static String toLikePattern(final String name) {
+        return SQLUtilities.toLikePattern(CharSequences.toASCII(name).toString());
+    }
+
+    /**
      * Returns an arbitrary object from a code. The default implementation delegates to more specific methods,
      * for example {@link #createCoordinateReferenceSystem(String)}, {@link #createDatum(String)}, <i>etc.</i>
      * until a successful one is found.
@@ -1151,7 +1222,7 @@ addURIs:    for (int i=0; ; i++) {
                     if (isPrimaryKey) {
                         stmt.setInt(1, pk);
                     } else {
-                        stmt.setString(1, SQLUtilities.toLikePattern(code));
+                        stmt.setString(1, toLikePattern(code));
                     }
                     Integer present = null;
                     try (ResultSet result = stmt.executeQuery()) {
@@ -1263,7 +1334,11 @@ addURIs:    for (int i=0; ; i++) {
                      * ---------------------------------------------------------------------- */
                     case "geographic 2d":
                     case "geographic 3d": {
-                        final EllipsoidalCS cs = owner.createEllipsoidalCS(getString(code, result, 8));
+                        Integer csCode = getInteger(code, result, 8);
+                        if (replaceDeprecatedCS) {
+                            csCode = JDK8.getOrDefault(DEPRECATED_CS, csCode, csCode);
+                        }
+                        final EllipsoidalCS cs = owner.createEllipsoidalCS(csCode.toString());
                         final String datumCode = getOptionalString(result, 9);
                         final GeodeticDatum datum;
                         if (datumCode != null) {
@@ -1295,8 +1370,18 @@ addURIs:    for (int i=0; ; i++) {
                         result.close();      // Must be closed before call to createFoo(String)
                         ensureNoCycle(ProjectedCRS.class, epsg);
                         try {
-                            final CartesianCS   cs       = owner.createCartesianCS(csCode);
-                            final GeographicCRS baseCRS  = owner.createGeographicCRS(geoCode);
+                            final CartesianCS cs = owner.createCartesianCS(csCode);
+                            final GeographicCRS baseCRS;
+                            if (deprecated) try {
+                                quiet = true;
+                                replaceDeprecatedCS = true;
+                                baseCRS = createGeographicCRS(geoCode);                 // Do not cache that CRS.
+                            } finally {
+                                quiet = false;
+                                replaceDeprecatedCS = false;
+                            } else {
+                                baseCRS = owner.createGeographicCRS(geoCode);
+                            }
                             final CoordinateOperation op = owner.createCoordinateOperation(opCode);
                             if (op instanceof Conversion) {
                                 crs = crsFactory.createProjectedCRS(createProperties("Coordinate Reference System",
@@ -2279,37 +2364,61 @@ addURIs:    for (int i=0; ; i++) {
                 final String  name       = getString   (code, result, 2);
                 final String  remarks    = getOptionalString (result, 3);
                 final boolean deprecated = getOptionalBoolean(result, 4);
-                MeasurementRange<?> valueDomain = null;
-                final Class<?> type;
+                Class<?> type = Double.class;
                 /*
-                 * Search for units. We will choose the most commonly used one in parameter values.
                  * If the parameter appears to have at least one non-null value in the "Parameter File Name" column,
                  * then the type is assumed to be URI as a string. Otherwise, the type is a floating point number.
                  */
-                try (ResultSet resultUnits = executeQuery("ParameterUnit",
-                        "SELECT MIN(UOM_CODE) AS UOM," +
-                              " MIN(PARAM_VALUE_FILE_REF) AS PARAM_FILE" +
-                            " FROM [Coordinate_Operation Parameter Value]" +
+                try (ResultSet r = executeQuery("ParameterType",
+                        "SELECT PARAM_VALUE_FILE_REF FROM [Coordinate_Operation Parameter Value]" +
+                        " WHERE (PARAMETER_CODE = ?) AND PARAM_VALUE_FILE_REF IS NOT NULL", epsg))
+                {
+                    while (r.next()) {
+                        String element = getOptionalString(r, 1);
+                        if (element != null && !element.isEmpty()) {
+                            type = String.class;
+                            break;
+                        }
+                    }
+                }
+                /*
+                 * Search for units.   We typically have many different units but all of the same dimension
+                 * (for example metres, kilometres, feet, etc.). In such case, the units Set will have only
+                 * one element and that element will be the most frequently used unit.  But some parameters
+                 * accept units of different dimensions.   For example the "Ordinate 1 of evaluation point"
+                 * (EPSG:8617) parameter value may be in metres or in degrees.   In such case the units Set
+                 * will have two elements.
+                 */
+                final Set<Unit<?>> units = new LinkedHashSet<>();
+                try (ResultSet r = executeQuery("ParameterUnit",
+                        "SELECT UOM_CODE FROM [Coordinate_Operation Parameter Value]" +
                         " WHERE (PARAMETER_CODE = ?)" +
                         " GROUP BY UOM_CODE" +
                         " ORDER BY COUNT(UOM_CODE) DESC", epsg))
                 {
-                    if (resultUnits.next()) {
-                        String element = getOptionalString(resultUnits, 2);
-                        type = (element != null) ? String.class : Double.class;
-                        element = getOptionalString(resultUnits, 1);
-                        if (element != null) {
-                            valueDomain = MeasurementRange.create(Double.NEGATIVE_INFINITY, false,
-                                    Double.POSITIVE_INFINITY, false,
-                                    owner.createUnit(element));
+next:               while (r.next()) {
+                        final String c = getOptionalString(r, 1);
+                        if (c != null) {
+                            final Unit<?> candidate = owner.createUnit(c);
+                            for (final Unit<?> e : units) {
+                                if (candidate.isCompatible(e)) {
+                                    continue next;
+                                }
+                            }
+                            units.add(candidate);
                         }
-                    } else {
-                        type = Double.class;
                     }
                 }
                 /*
                  * Now creates the parameter descriptor.
                  */
+                final NumberRange<?> valueDomain;
+                switch (units.size()) {
+                    case 0:  valueDomain = null; break;
+                    default: valueDomain = new EPSGParameterDomain(units); break;
+                    case 1:  valueDomain = MeasurementRange.create(Double.NEGATIVE_INFINITY, false,
+                                    Double.POSITIVE_INFINITY, false, CollectionsExt.first(units)); break;
+                }
                 final ParameterDescriptor<?> descriptor = new DefaultParameterDescriptor<>(
                         createProperties("Coordinate_Operation Parameter", name, epsg, remarks, deprecated),
                         1, 1, type, valueDomain, null, null);

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java?rev=1730904&r1=1730903&r2=1730904&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java [UTF-8] Wed Feb 17 18:44:26 2016
@@ -31,6 +31,7 @@ import java.util.regex.Pattern;
 import java.io.BufferedReader;
 import org.apache.sis.util.StringBuilders;
 import org.apache.sis.internal.metadata.sql.ScriptRunner;
+import org.apache.sis.internal.metadata.sql.SQLUtilities;
 import org.apache.sis.internal.system.Loggers;
 import org.apache.sis.internal.util.Constants;
 import org.apache.sis.util.CharSequences;
@@ -226,7 +227,8 @@ final class EPSGInstaller extends Script
      */
     public void run(InstallationScriptProvider scriptProvider) throws SQLException, IOException {
         long time = System.nanoTime();
-        log(Messages.getResources(null).getLogRecord(Level.INFO, Messages.Keys.CreatingSchema_2, Constants.EPSG, getSimplifiedURL()));
+        log(Messages.getResources(null).getLogRecord(Level.INFO, Messages.Keys.CreatingSchema_2, Constants.EPSG,
+                SQLUtilities.getSimplifiedURL(getConnection().getMetaData())));
         if (scriptProvider == null) {
             scriptProvider = lookupProvider();
         }
@@ -256,17 +258,6 @@ final class EPSGInstaller extends Script
     }
 
     /**
-     * Returns a simplified form of the URL (truncated before the first ? or ; character),
-     * for logging purpose only.
-     */
-    private String getSimplifiedURL() throws SQLException {
-        String url = getConnection().getMetaData().getURL();
-        int s1 = url.indexOf('?'); if (s1 < 0) s1 = url.length();
-        int s2 = url.indexOf(';'); if (s2 < 0) s2 = url.length();
-        return url.substring(0, Math.min(s1, s2));
-    }
-
-    /**
      * Logs a message reporting the failure to create EPSG database.
      */
     final void logFailure(final Locale locale) {

Modified: sis/branches/JDK7/core/sis-referencing/src/main/resources/org/apache/sis/referencing/factory/sql/EPSG.sql
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/resources/org/apache/sis/referencing/factory/sql/EPSG.sql?rev=1730904&r1=1730903&r2=1730904&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/resources/org/apache/sis/referencing/factory/sql/EPSG.sql [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/resources/org/apache/sis/referencing/factory/sql/EPSG.sql [UTF-8] Wed Feb 17 18:44:26 2016
@@ -5,6 +5,21 @@
 
 
 --
+-- Corrections to some deprecated Coordinate Reference Systems (CRS).  The errors that we fix here are known to EPSG,
+-- but were fixed by deprecating the erroneous CRS and creating a new one. This approach allows reproductive behavior
+-- of applications that used the erroneous CRS. However in a few cases, Apache SIS can not instantiate the deprecated
+-- object without some minimal corrections. The following UPDATEs perform the minimal amount of changes needed by SIS.
+--
+
+-- "Scale factor at natural origin" (EPSG:8805) shall be dimensionless (EPSG:9201), not in "m" units (EPSG:9001).
+UPDATE epsg_coordoperationparamvalue SET uom_code = 9201 WHERE parameter_code = 8805 AND uom_code = 9001;
+
+-- Value 44°87′ is illegal for DMS units (EPSG:9110). A value equivalent to the erroneous DMS value is 45°27′.
+UPDATE epsg_coordoperationparamvalue SET parameter_value = 45.27 WHERE parameter_value = 44.87 AND uom_code = 9110;
+
+
+
+--
 -- Additional indexes for the EPSG database. Those indexes are not declared
 -- in the SQL scripts distributed by EPSG. They are not required for proper
 -- working of the EPSG factory, but can significantly improve performances.

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2004.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2004.java?rev=1730904&r1=1730903&r2=1730904&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2004.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2004.java [UTF-8] Wed Feb 17 18:44:26 2016
@@ -17,7 +17,9 @@
 package org.apache.sis.referencing.factory;
 
 import org.opengis.util.FactoryException;
+import org.opengis.referencing.IdentifiedObject;
 import org.apache.sis.internal.system.Loggers;
+import org.apache.sis.util.CharSequences;
 
 // Test imports
 import org.junit.Rule;
@@ -90,6 +92,17 @@ public final strictfp class GIGS2004 ext
     }
 
     /**
+     * Removes the accented characters from the object name, so it can be compared against the expected name.
+     *
+     * @param object The object from which to get a name than can be verified against the expected name.
+     * @return The name of the given object, eventually modified in order to match the expected name.
+     */
+    @Override
+    protected String getVerifiableName(final IdentifiedObject object) {
+        return CharSequences.toASCII(super.getVerifiableName(object)).toString();
+    }
+
+    /**
      * Overrides the GeoAPI test for verifying the log messages emitted during the construction of deprecated objects.
      *
      * @throws FactoryException if an error occurred while creating the object.

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatter.java?rev=1730904&r1=1730903&r2=1730904&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatter.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatter.java [UTF-8] Wed Feb 17 18:44:26 2016
@@ -47,12 +47,12 @@ import java.nio.charset.StandardCharsets
  *
  * <ol class="verbose">
  *   <li><p>Download the latest SQL scripts for PostgreSQL from <a href="http://www.epsg.org">http://www.epsg.org</a>.</p></li>
- *   <li><p>Unzip in the directory of your choice (replace "8.8" by the appropriate version number in the ZIP filename),
+ *   <li><p>Unzip in the directory of your choice (replace "8_9" by the appropriate version number in the ZIP filename),
  *          and remember the path to that directory:</p>
  *
  *          {@preformat text
- *            unzip epsg-v8_8sql-PostgreSQL.zip
- *            cd epsg-v8_8sql-PostgreSQL
+ *            unzip epsg-v8_9sql-PostgreSQL.zip
+ *            cd epsg-v8_9sql-PostgreSQL
  *            export EPSG_SCRIPTS=$PWD
  *          }
  *   </li>
@@ -120,7 +120,7 @@ public final class EPSGDataFormatter ext
      * The values of those arguments are typically:
      *
      * <ol>
-     *   <li>{@code EPSG_vX.mdb_Data_MySQL.sql}</li>
+     *   <li>{@code EPSG_vX.mdb_Data_PostgreSQL.sql}</li>
      *   <li>{@code core/sis-referencing/src/main/resources/org/apache/sis/referencing/factory/sql/Data.sql}</li>
      * </ol>
      *

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java?rev=1730904&r1=1730903&r2=1730904&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java [UTF-8] Wed Feb 17 18:44:26 2016
@@ -118,7 +118,7 @@ public final strictfp class EPSGFactoryT
     }
 
     /**
-     * Force releases of JDBC connections after the tests in this class.
+     * Forces release of JDBC connections after the tests in this class.
      *
      * @throws FactoryException if an error occurred while closing the connections.
      */
@@ -463,13 +463,53 @@ public final strictfp class EPSGFactoryT
     }
 
     /**
+     * Tests creation of deprecated coordinate systems.
+     *
+     * @throws FactoryException if an error occurred while querying the factory.
+     */
+    @Test
+    public void testDeprecatedCoordinateSystems() throws FactoryException {
+        assumeNotNull(factory);
+        for (final Map.Entry<Integer,Integer> entry : EPSGDataAccess.deprecatedCS().entrySet()) {
+            final CoordinateSystem expected = factory.createEllipsoidalCS(entry.getValue().toString());
+            loggings.assertNoUnexpectedLog();
+            final String code = entry.getKey().toString();
+            final CoordinateSystem deprecated;
+            try {
+                deprecated = factory.createEllipsoidalCS(code);
+            } catch (FactoryException e) {
+                final String m = e.getMessage();
+                if (m.contains("9115") || m.contains("9116") || m.contains("9117") ||
+                    m.contains("9118") || m.contains("9119") || m.contains("9120"))
+                {
+                    // Unit "9116" to "9120" are known to be unsupported.
+                    continue;
+                }
+                throw e;
+            }
+            loggings.assertNextLogContains(code);
+            final int dimension = expected.getDimension();
+            assertEquals("dimension", dimension, deprecated.getDimension());
+            for (int i=0; i<dimension; i++) {
+                final CoordinateSystemAxis ref  = expected.getAxis(i);
+                final CoordinateSystemAxis axis = deprecated.getAxis(i);
+                assertEquals("name",         ref.getName(),         axis.getName());
+                assertEquals("alias",        ref.getAlias(),        axis.getAlias());
+                assertEquals("direction",    ref.getDirection(),    axis.getDirection());
+                assertEquals("rangeMeaning", ref.getRangeMeaning(), axis.getRangeMeaning());
+                assertEquals("unit",         ref.getUnit().toSI(),  axis.getUnit().toSI());
+            }
+        }
+    }
+
+    /**
      * Tests a legacy geographic CRS (no longer supported by EPSG).
      * This test verifies that the expected warnings are logged.
      *
      * @throws FactoryException if an error occurred while querying the factory.
      */
     @Test
-    @DependsOnMethod("testGeographic2D")
+    @DependsOnMethod({"testGeographic2D", "testDeprecatedCoordinateSystems"})
     public void testDeprecatedGeographic() throws FactoryException {
         assumeNotNull(factory);
 
@@ -478,7 +518,7 @@ public final strictfp class EPSGFactoryT
         assertAxisDirectionsEqual(null, crs.getCoordinateSystem(), AxisDirection.NORTH, AxisDirection.EAST);
         assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("63266405"));
 
-        loggings.assertNextLogContains("EPSG:6405");                 // Coordinate System 6405 is no longer supported by EPSG
+        loggings.skipNextLogIfContains("EPSG:6405");                 // Coordinate System 6405 is no longer supported by EPSG
         loggings.assertNextLogContains("EPSG:63266405", "4326");     // EPSG no longer support codes in the 60000000 series.
         loggings.assertNoUnexpectedLog();
     }
@@ -490,7 +530,7 @@ public final strictfp class EPSGFactoryT
      * @throws FactoryException if an error occurred while querying the factory.
      */
     @Test
-    @DependsOnMethod("testDeprecatedGeographic")
+    @DependsOnMethod({"testDeprecatedGeographic", "testDeprecatedCoordinateSystems"})
     public void testDeprecatedProjected() throws FactoryException {
         assumeNotNull(factory);
 

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateReferenceSystems.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateReferenceSystems.java?rev=1730904&r1=1730903&r2=1730904&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateReferenceSystems.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateReferenceSystems.java [UTF-8] Wed Feb 17 18:44:26 2016
@@ -16,8 +16,11 @@
  */
 package org.apache.sis.referencing.report;
 
+import java.util.Arrays;
 import java.util.Locale;
+import java.util.Set;
 import java.util.Map;
+import java.util.HashSet;
 import java.util.HashMap;
 import java.util.TreeMap;
 import java.io.File;
@@ -43,6 +46,7 @@ import org.opengis.referencing.datum.Ver
 import org.opengis.referencing.operation.OperationMethod;
 import org.opengis.test.report.AuthorityCodesReport;
 import org.apache.sis.metadata.iso.citation.Citations;
+import org.apache.sis.internal.referencing.DeprecatedCode;
 import org.apache.sis.referencing.CRS;
 import org.apache.sis.referencing.CommonCRS;
 import org.apache.sis.referencing.IdentifiedObjects;
@@ -103,10 +107,11 @@ public final strictfp class CoordinateRe
         rd("Australian Geodetic Datum 1966",                              "Australian Geodetic Datum");
         rd("Australian Geodetic Datum 1984",                              "Australian Geodetic Datum");
         rd("Australian Height Datum (Tasmania)",                          "Australian Height Datum");
-        rd("Azores Central Islands 1948",                                 "Azores Central Islands");
-        rd("Azores Central Islands 1995",                                 "Azores Central Islands");
-        rd("Azores Oriental Islands 1940",                                "Azores Oriental Islands");
-        rd("Azores Oriental Islands 1995",                                "Azores Oriental Islands");
+        rd("Azores Central Islands 1948",                                 "Azores Islands");
+        rd("Azores Central Islands 1995",                                 "Azores Islands");
+        rd("Azores Occidental Islands 1939",                              "Azores Islands");
+        rd("Azores Oriental Islands 1940",                                "Azores Islands");
+        rd("Azores Oriental Islands 1995",                                "Azores Islands");
         rd("Baltic 1980",                                                 "Baltic");
         rd("Baltic 1982",                                                 "Baltic");
         rd("Baltic Sea",                                                  "Baltic");
@@ -116,6 +121,14 @@ public final strictfp class CoordinateRe
         rd("Bogota 1975 (Bogota)",                                        "Bogota 1975");
         rd("Carthage (Paris)",                                            "Carthage");
         rd("Bern 1938",                                                   "Bern / CH1903");
+        rd("Cais da Figueirinha - Angra do Heroísmo",                     "Cais");
+        rd("Cais da Madalena",                                            "Cais");
+        rd("Cais da Pontinha - Funchal",                                  "Cais");
+        rd("Cais da Vila - Porto Santo",                                  "Cais");
+        rd("Cais da Vila do Porto",                                       "Cais");
+        rd("Cais das Velas",                                              "Cais");
+        rd("Cayman Brac Vertical Datum 1961",                             "Cayman Islands");
+        rd("Cayman Islands Geodetic Datum 2011",                          "Cayman Islands");
         rd("CH1903",                                                      "Bern / CH1903");
         rd("CH1903+",                                                     "Bern / CH1903");
         rd("CH1903 (Bern)",                                               "Bern / CH1903");
@@ -125,8 +138,12 @@ public final strictfp class CoordinateRe
         rd("Chatham Islands Datum 1979",                                  "Chatham Islands Datum");
         rd("Corrego Alegre 1961",                                         "Corrego Alegre");
         rd("Corrego Alegre 1970-72",                                      "Corrego Alegre");
+        rd("Danger 1950",                                                 "Saint Pierre et Miquelon 1950");
+        rd("Dansk Normal Nul",                                            "Dansk");
+        rd("Dansk Vertikal Reference 1990",                               "Dansk");
         rd("Dealul Piscului 1930",                                        "Dealul Piscului");
         rd("Dealul Piscului 1970",                                        "Dealul Piscului");
+        rd("Deutsches Haupthoehennetz 1912",                              "Deutsches Haupthoehennetz");
         rd("Deutsches Haupthoehennetz 1985",                              "Deutsches Haupthoehennetz");
         rd("Deutsches Haupthoehennetz 1992",                              "Deutsches Haupthoehennetz");
         rd("Douala 1948",                                                 "Douala");
@@ -149,18 +166,25 @@ public final strictfp class CoordinateRe
         rd("European Vertical Reference Frame 2007",                      "European Vertical Reference Frame");
         rd("Fahud Height Datum",                                          "Fahud");
         rd("Fao 1979",                                                    "Fao");
+        rd("Fehmarnbelt Datum 2010",                                      "Fehmarnbelt");
+        rd("Fehmarnbelt Vertical Reference 2010",                         "Fehmarnbelt");
         rd("Faroe Datum 1954",                                            "Faroe Islands");
         rd("Faroe Islands Vertical Reference 2009",                       "Faroe Islands");
         rd("fk89",                                                        "Faroe Islands");
         rd("Fiji 1956",                                                   "Fiji");
         rd("Fiji Geodetic Datum 1986",                                    "Fiji");
+        rd("Gan 1970",                                                    "Gandajika");
+        rd("Grand Cayman Geodetic Datum 1959",                            "Grand Cayman");
+        rd("Grand Cayman Vertical Datum 1954",                            "Grand Cayman");
         rd("Greek (Athens)",                                              "Greek");
         rd("Greek Geodetic Reference System 1987",                        "Greek");
         rd("Guadeloupe 1948",                                             "Guadeloupe");
         rd("Guadeloupe 1951",                                             "Guadeloupe");
         rd("Guadeloupe 1988",                                             "Guadeloupe");
+        rd("Guam 1963",                                                   "Guam");
+        rd("Guam Vertical Datum of 1963",                                 "Guam");
+        rd("Guam Vertical Datum of 2004",                                 "Guam");
         rd("Gunung Segara (Jakarta)",                                     "Gunung Segara");
-        rd("Guyane Francaise",                                            "Centre Spatial Guyanais 1967");   // For a deprecated CRS.
         rd("Hong Kong 1963",                                              "Hong Kong");
         rd("Hong Kong 1963(67)",                                          "Hong Kong");
         rd("Hong Kong 1980",                                              "Hong Kong");
@@ -181,10 +205,10 @@ public final strictfp class CoordinateRe
         rd("IGN63 Hiva Oa",                                               "IGN");
         rd("IGN72 Grande Terre",                                          "IGN");
         rd("IGN72 Nuku Hiva",                                             "IGN");
-        rd("IGN78 Corsica",                                               "IGN");
         rd("Indian 1954",                                                 "Indian");
         rd("Indian 1960",                                                 "Indian");
         rd("Indian 1975",                                                 "Indian");
+        rd("Indian Spring Low Water",                                     "Indian");
         rd("International Great Lakes Datum 1955",                        "International Great Lakes Datum");
         rd("International Great Lakes Datum 1985",                        "International Great Lakes Datum");
         rd("International Terrestrial Reference Frame 1988",              "International Terrestrial Reference Frame");
@@ -204,12 +228,17 @@ public final strictfp class CoordinateRe
         rd("Jamaica 1875",                                                "Jamaica");
         rd("Jamaica 1969",                                                "Jamaica");
         rd("Jamaica 2001",                                                "Jamaica");
+        rd("Japanese Geodetic Datum 2011 (vertical)",                     "Japanese Geodetic Datum 2011");
+        rd("Japanese Standard Levelling Datum 1969",                      "Japanese Standard Levelling Datum");
+        rd("Japanese Standard Levelling Datum 1972",                      "Japanese Standard Levelling Datum");
         rd("Kalianpur 1880",                                              "Kalianpur");
         rd("Kalianpur 1937",                                              "Kalianpur");
         rd("Kalianpur 1962",                                              "Kalianpur");
         rd("Kalianpur 1975",                                              "Kalianpur");
         rd("Kertau (RSO)",                                                "Kertau");
         rd("Kertau 1968",                                                 "Kertau");
+        rd("KOC Construction Datum",                                      "KOC Construction Datum / Well Datum");
+        rd("KOC Well Datum",                                              "KOC Construction Datum / Well Datum");
         rd("Korean Datum 1985",                                           "Korean Datum");
         rd("Korean Datum 1995",                                           "Korean Datum");
         rd("Kuwait Oil Company",                                          "Kuwait Oil Company / Kuwait Utility");
@@ -217,12 +246,14 @@ public final strictfp class CoordinateRe
         rd("Kuwait Utility",                                              "Kuwait Oil Company / Kuwait Utility");
         rd("Lao 1993",                                                    "Lao");
         rd("Lao National Datum 1997",                                     "Lao");
+        rd("Latvia 1992",                                                 "Latvia");
+        rd("Latvian Height System 2000",                                  "Latvia");
         rd("Lisbon 1890",                                                 "Lisbon");
         rd("Lisbon 1890 (Lisbon)",                                        "Lisbon");
         rd("Lisbon 1937",                                                 "Lisbon");
         rd("Lisbon 1937 (Lisbon)",                                        "Lisbon");
-        rd("Cote d'Ivoire",                                               "Locodjo 1965");   // For a deprecated CRS.
-        rd("Madeira 1936",                                                "Porto Santo");    // For a deprecated CRS.
+        rd("Lower Low Water Large Tide",                                  "Low Water");
+        rd("Lowest Astronomic Tide",                                      "Low Water");
         rd("Makassar (Jakarta)",                                          "Makassar");
         rd("Manoca 1962",                                                 "Manoca");
         rd("Martinique 1938",                                             "Martinique");
@@ -230,8 +261,14 @@ public final strictfp class CoordinateRe
         rd("Martinique 1987",                                             "Martinique");
         rd("Maupiti 83",                                                  "Maupiti");
         rd("Maupiti SAU 2001",                                            "Maupiti");
+        rd("Mean High Water",                                             "Mean Sea Level");
+        rd("Mean High Water Spring Tides",                                "Mean Sea Level");
+        rd("Mean Higher High Water",                                      "Mean Sea Level");
+        rd("Mean Low Water",                                              "Mean Sea Level");
+        rd("Mean Low Water Spring Tides",                                 "Mean Sea Level");
+        rd("Mean Lower Low Water",                                        "Mean Sea Level");
+        rd("Mean Lower Low Water Spring Tides",                           "Mean Sea Level");
         rd("Missao Hidrografico Angola y Sao Tome 1951",                  "Missao Hidrografico Angola y Sao Tome");
-        rd("Mhast",                                                       "Missao Hidrografico Angola y Sao Tome");
         rd("Mhast (offshore)",                                            "Missao Hidrografico Angola y Sao Tome");
         rd("Mhast (onshore)",                                             "Missao Hidrografico Angola y Sao Tome");
         rd("Militar-Geographische Institut (Ferro)",                      "Militar-Geographische Institut");
@@ -255,10 +292,12 @@ public final strictfp class CoordinateRe
         rd("NAD83 (High Accuracy Reference Network)",                     "North American Datum 1983 — High Accuracy Reference Network");
         rd("NAD83 (National Spatial Reference System 2007)",              "North American Datum 1983 — National Spatial Reference System 2007");
         rd("NAD83 Canadian Spatial Reference System",                     "North American Datum 1983 — Canadian Spatial Reference System");
-        rd("Nord Sahara 1959 (Paris)",                                    "Nord Sahara 1959");
-        rd("Nord de Guerre (Paris)",                                      "Ancienne Triangulation Française");
         rd("Nouvelle Triangulation Francaise",                            "Nouvelle Triangulation Française");
         rd("Nouvelle Triangulation Francaise (Paris)",                    "Nouvelle Triangulation Française");
+        rd("NAD83 (Continuously Operating Reference Station 1996)",       "North American Datum 1983 — Continuously Operating Reference Station 1996");       // For better sort order.
+        rd("NAD83 (National Spatial Reference System 2011)",              "North American Datum 1983 — National Spatial Reference System 2011");
+        rd("NAD83 (National Spatial Reference System MA11)",              "North American Datum 1983 — National Spatial Reference System MA11 / PA11");
+        rd("NAD83 (National Spatial Reference System PA11)",              "North American Datum 1983 — National Spatial Reference System MA11 / PA11");
         rd("Norway Normal Null 1954",                                     "Norway Normal Null");
         rd("Norway Normal Null 2000",                                     "Norway Normal Null");
         rd("Ordnance Datum Newlyn (Orkney Isles)",                        "Ordnance Datum Newlyn");
@@ -271,9 +310,9 @@ public final strictfp class CoordinateRe
         rd("Pitcairn 2006",                                               "Pitcairn");
         rd("Porto Santo 1936",                                            "Porto Santo");
         rd("Porto Santo 1995",                                            "Porto Santo");
-        rd("Posiciones Geodesicas Argentinas 1994",                       "Posiciones Geodesicas Argentinas");
-        rd("Posiciones Geodesicas Argentinas 1998",                       "Posiciones Geodesicas Argentinas");
-        rd("Posiciones Geodesicas Argentinas 2007",                       "Posiciones Geodesicas Argentinas");
+        rd("Posiciones Geodésicas Argentinas 1994",                       "Posiciones Geodésicas Argentinas");
+        rd("Posiciones Geodésicas Argentinas 1998",                       "Posiciones Geodésicas Argentinas");
+        rd("Posiciones Geodésicas Argentinas 2007",                       "Posiciones Geodésicas Argentinas");
         rd("Puerto Rico Vertical Datum of 2002",                          "Puerto Rico");
         rd("Qatar 1948",                                                  "Qatar");
         rd("Qatar 1974",                                                  "Qatar");
@@ -289,8 +328,8 @@ public final strictfp class CoordinateRe
         rd("Rikets hojdsystem 1900",                                      "Rikets hojdsystem");
         rd("Rikets hojdsystem 1970",                                      "Rikets hojdsystem");
         rd("Rikets hojdsystem 2000",                                      "Rikets hojdsystem");
-        rd("Samboja",                                                     "Gunung Segara");      // For a deprecated CRS.
-        rd("Segora",                                                      "Gunung Segara");      // For a deprecated CRS.
+        rd("Santa Cruz da Graciosa",                                      "Santa Cruz");
+        rd("Santa Cruz das Flores",                                       "Santa Cruz");
         rd("Sierra Leone 1968",                                           "Sierra Leone");
         rd("Sierra Leone Colony 1924",                                    "Sierra Leone");
         rd("SIRGAS-Chile",                                                "SIRGAS");
@@ -301,10 +340,9 @@ public final strictfp class CoordinateRe
         rd("Sri Lanka Datum 1999",                                        "Sri Lanka");
         rd("Sri Lanka Vertical Datum",                                    "Sri Lanka");
         rd("Stockholm 1938 (Stockholm)",                                  "Stockholm 1938");
-        rd("Sudan",                                                       "Adindan");            // For a deprecated CRS.
-        rd("System Jednotne Trigonometricke Site Katastralni (Ferro)",    "System Jednotne Trigonometricke Site Katastralni");
-        rd("System Jednotne Trigonometricke Site Katastralni/05",         "System Jednotne Trigonometricke Site Katastralni");
-        rd("System Jednotne Trigonometricke Site Katastralni/05 (Ferro)", "System Jednotne Trigonometricke Site Katastralni");
+        rd("Systém Jednotné Trigonometrické Síte Katastrální (Ferro)",    "Systém Jednotné Trigonometrické Síte Katastrální");
+        rd("Systém Jednotné Trigonometrické Síte Katastrální/05",         "Systém Jednotné Trigonometrické Síte Katastrální");
+        rd("Systém Jednotné Trigonometrické Síte Katastrální/05 (Ferro)", "Systém Jednotné Trigonometrické Síte Katastrální");
         rd("Tahaa 54",                                                    "Tahaa");
         rd("Tahaa SAU 2001",                                              "Tahaa");
         rd("Tahiti 52",                                                   "Tahiti");
@@ -312,8 +350,8 @@ public final strictfp class CoordinateRe
         rd("Taiwan Datum 1967",                                           "Taiwan Datum");
         rd("Taiwan Datum 1997",                                           "Taiwan Datum");
         rd("Tananarive 1925 (Paris)",                                     "Tananarive 1925");
+        rd("Tokyo 1892",                                                  "Tokyo");
         rd("Viti Levu 1912",                                              "Viti Levu");
-        rd("Viti Levu 1916",                                              "Viti Levu");          // For a deprecated CRS.
         rd("Voirol 1875",                                                 "Voirol");
         rd("Voirol 1875 (Paris)",                                         "Voirol");
         rd("Voirol 1879",                                                 "Voirol");
@@ -324,6 +362,13 @@ public final strictfp class CoordinateRe
     }
 
     /**
+     * The datums from the above list which are deprecated, but that we do not want to replace by the non-deprecated
+     * datum. We disable some replacements when they allow better sorting of deprecated CRS.
+     */
+    private static final Set<String> KEEP_DEPRECATED_DATUM = new HashSet<>(Arrays.asList(
+        "Dealul Piscului 1970"));           // Datum does not exist but is an alias for S-42 in Romania.
+
+    /**
      * Shortcut for {@link #SECTION_TITLES} initialization.
      * {@code "rd"} stands for "rename datum".
      */
@@ -332,6 +377,20 @@ public final strictfp class CoordinateRe
     }
 
     /**
+     * Words to ignore in a datum name in order to detect if a CRS name is the acronym of the datum name.
+     */
+    private static final Set<String> DATUM_WORDS_TO_IGNORE = new HashSet<>(Arrays.asList(
+            "of",           // VIVD:   Virgin Islands Vertical Datum of 2009
+            "de",           // RRAF:   Reseau de Reference des Antilles Francaises
+            "des",          // RGAF:   Reseau Geodesique des Antilles Francaises
+            "la",           // RGR:    Reseau Geodesique de la Reunion
+            "et",           // RGSPM:  Reseau Geodesique de Saint Pierre et Miquelon
+            "para",         // SIRGAS: Sistema de Referencia Geocentrico para America del Sur 1995
+            "del",          // SIRGAS: Sistema de Referencia Geocentrico para America del Sur 1995
+            "las",          // SIRGAS: Sistema de Referencia Geocentrico para las AmericaS 2000
+            "Tides"));      // MLWS:   Mean Low Water Spring Tides
+
+    /**
      * The keywords before which to cut the CRS names when sorting by alphabetical order.
      * The main intend here is to preserve the "far west", "west", "central west", "central",
      * "central east", "east", "far east" order.
@@ -381,17 +440,24 @@ public final strictfp class CoordinateRe
     private final CRSAuthorityFactory factory;
 
     /**
+     * The datum from the {@link #SECTION_TITLES} that we didn't found after we processed all codes.
+     * Used for verification purpose only.
+     */
+    private final Set<String> unusedDatumMapping;
+
+    /**
      * Creates a new instance.
      */
     private CoordinateReferenceSystems() throws FactoryException {
         super(null);
+        unusedDatumMapping = new HashSet<>(SECTION_TITLES.keySet());
         properties.setProperty("TITLE",           "Apache SIS™ Coordinate Reference System (CRS) codes");
         properties.setProperty("PRODUCT.NAME",    "Apache SIS™");
         properties.setProperty("PRODUCT.VERSION", getVersion());
         properties.setProperty("PRODUCT.URL",     "http://sis.apache.org");
         properties.setProperty("JAVADOC.GEOAPI",  "http://www.geoapi.org/snapshot/javadoc");
         properties.setProperty("FACTORY.NAME",    "EPSG");
-        properties.setProperty("FACTORY.VERSION", "8.8");
+        properties.setProperty("FACTORY.VERSION", "8.9");
         properties.setProperty("FACTORY.VERSION.SUFFIX", ", together with other sources");
         properties.setProperty("DESCRIPTION", "<p><b>Notation:</b></p>\n" +
                 "<ul>\n" +
@@ -417,6 +483,14 @@ public final strictfp class CoordinateRe
         final CoordinateReferenceSystems writer = new CoordinateReferenceSystems();
         final File file = writer.write(new File("CoordinateReferenceSystems.html"));
         System.out.println("Created " + file.getAbsolutePath());
+        if (!writer.unusedDatumMapping.isEmpty()) {
+            System.out.println();
+            System.out.println("WARNING: the following datums were expected but not found. Maybe their spelling changed?");
+            for (final String name : writer.unusedDatumMapping) {
+                System.out.print("  - ");
+                System.out.println(name);
+            }
+        }
     }
 
     /**
@@ -476,6 +550,66 @@ public final strictfp class CoordinateRe
     }
 
     /**
+     * Omits the trailing number, if any.
+     * For example if the given name is "Abidjan 1987", then this method returns "Abidjan".
+     */
+    private static String omitTrailingNumber(String name) {
+        int i = CharSequences.skipTrailingWhitespaces(name, 0, name.length());
+        while (i != 0) {
+            final char c = name.charAt(--i);
+            if (c < '0' || c > '9') {
+                name = name.substring(0, CharSequences.skipTrailingWhitespaces(name, 0, i+1));
+                break;
+            }
+        }
+        return name;
+    }
+
+    /**
+     * If the first word of the CRS name seems to be an acronym of the datum name,
+     * puts that acronym in a {@code <abbr title="datum name">...</abbr>} element.
+     */
+    static String insertAbbreviationTitle(final String crsName, final String datumName) {
+        int s = crsName.indexOf(' ');
+        if (s < 0) s = crsName.length();
+        int p = crsName.indexOf('(');
+        if (p >= 0 && p < s) s = p;
+        p = datumName.indexOf('(');
+        if (p < 0) p = datumName.length();
+        final String acronym = crsName.substring(0, s);
+        final String ar = omitTrailingNumber(acronym);
+        final String dr = omitTrailingNumber(datumName.substring(0, p));
+        if (dr.startsWith(ar)) {
+            return crsName;                                 // Avoid redudancy between CRS name and datum name.
+        }
+        /*
+         * If the first CRS word does not seem to be an acronym of the datum name, verify
+         * if there is some words that we should ignore in the datum name and try again.
+         */
+        if (!CharSequences.isAcronymForWords(ar, dr)) {
+            final String[] words = (String[]) CharSequences.split(dr, ' ');
+            int n = 0;
+            for (final String word : words) {
+                if (!DATUM_WORDS_TO_IGNORE.contains(word)) {
+                    words[n++] = word;
+                }
+            }
+            if (n == words.length || n < 2) {
+                return crsName;
+            }
+            final StringBuilder b = new StringBuilder();
+            for (int i=0; i<n; i++) {
+                if (i != 0) b.append(' ');
+                b.append(words[i]);
+            }
+            if (!CharSequences.isAcronymForWords(ar, b)) {
+                return crsName;
+            }
+        }
+        return "<abbr title=\"" + datumName + "\">" + acronym + "</abbr>" + crsName.substring(s);
+    }
+
+    /**
      * Invoked when a CRS has been successfully created. This method modifies the default
      * {@link org.opengis.test.report.AuthorityCodesReport.Row} attribute values created
      * by GeoAPI.
@@ -486,36 +620,51 @@ public final strictfp class CoordinateRe
      */
     @Override
     protected Row createRow(final String code, final IdentifiedObject object) {
-        if (code.equals("EPSG:5804")) {
-            System.out.println("");
-        }
         final Row row = super.createRow(code, object);
         final CoordinateReferenceSystem crs = (CoordinateReferenceSystem) object;
         final CoordinateReferenceSystem crsXY = AbstractCRS.castOrCopy(crs).forConvention(AxesConvention.RIGHT_HANDED);
         if (!Utilities.deepEquals(crs.getCoordinateSystem(), crsXY.getCoordinateSystem(), ComparisonMode.IGNORE_METADATA)) {
             row.annotation = YX_ORDER;
         }
+        CoordinateReferenceSystem replacement = crs;
         row.remark = getRemark(crs);
-        if (object instanceof Deprecable) {
-            row.isDeprecated = ((Deprecable) object).isDeprecated();
-        }
         /*
-         * If the object is deprecated, try to find the reason.
-         * Don't take the whole comment, because it may be pretty long.
+         * If the object is deprecated, find the replacement.
+         * We do not take the whole comment because it may be pretty long.
          */
-        if (row.isDeprecated) {
-            InternationalString i18n = object.getRemarks();
-            for (final Identifier id : object.getIdentifiers()) {
-                if (id instanceof Deprecable && ((Deprecable) id).isDeprecated()) {
-                    i18n = ((Deprecable) id).getRemarks();
-                    break;
+        if (object instanceof Deprecable) {
+            row.isDeprecated = ((Deprecable) object).isDeprecated();
+            if (row.isDeprecated) {
+                String replacedBy = null;
+                InternationalString i18n = object.getRemarks();
+                for (final Identifier id : object.getIdentifiers()) {
+                    if (id instanceof Deprecable && ((Deprecable) id).isDeprecated()) {
+                        i18n = ((Deprecable) id).getRemarks();
+                        if (id instanceof DeprecatedCode) {
+                            replacedBy = ((DeprecatedCode) id).replacedBy;
+                        }
+                        break;
+                    }
+                }
+                if (i18n != null) {
+                    row.remark = i18n.toString(getLocale());
+                }
+                /*
+                 * If a replacement exists for a deprecated CRS, use the datum of the replacement instead than
+                 * the datum of the deprecated CRS for determining in which section to put the CRS. The reason
+                 * is that some CRS are deprecated because they were associated to the wrong datum, in which
+                 * case the deprecated CRS would appear in the wrong section if we do not apply this correction.
+                 */
+                if (!KEEP_DEPRECATED_DATUM.contains(CRS.getSingleComponents(crs).get(0).getDatum().getName().getCode())) {
+                    if (replacedBy != null) try {
+                        replacement = factory.createCoordinateReferenceSystem("EPSG:" + replacedBy);
+                    } catch (FactoryException e) {
+                        // Ignore - keep the datum of the deprecated object.
+                    }
                 }
-            }
-            if (i18n != null) {
-                row.remark = i18n.toString(getLocale());
             }
         }
-        ((ByName) row).setup(CRS.getSingleComponents(crs).get(0).getDatum());
+        ((ByName) row).setup(CRS.getSingleComponents(replacement).get(0).getDatum(), unusedDatumMapping);
         return row;
     }
 
@@ -541,15 +690,10 @@ public final strictfp class CoordinateRe
             // because those authority codes need parameters.
             row.hasError = false;
             row.remark = "Projected";
-            ((ByName) row).setup(CommonCRS.WGS84.datum());
+            ((ByName) row).setup(CommonCRS.WGS84.datum(), unusedDatumMapping);
         } else {
-            String message = exception.getMessage();
-            if (message.contains("Unable to format units in UCUM")) {
-                // Simplify a very long and badly formatted message.
-                message = "Unable to format units in UCUM";
-            }
-            row.remark = message;
-            ((ByName) row).setup(null);
+            row.remark = exception.getMessage();
+            ((ByName) row).setup(null, unusedDatumMapping);
         }
         return row;
     }
@@ -564,6 +708,9 @@ public final strictfp class CoordinateRe
         return new ByName();
     }
 
+
+
+
     /**
      * A row with an natural ordering that use the first part of the name before to use the authority code.
      * We use only the part of the name prior some keywords (e.g. {@code "zone"}).
@@ -598,20 +745,24 @@ public final strictfp class CoordinateRe
         /**
          * Computes the {@link #reducedName} field value.
          */
-        final void setup(final Datum datum) {
+        final void setup(final Datum datum, final Set<String> unusedDatumMapping) {
+            final String datumName;
             if (datum != null) {
-                section = datum.getName().getCode();
+                datumName = datum.getName().getCode();
             } else {
                 // Temporary patch (TODO: remove after we implemented the missing methods in SIS)
                 if (name.startsWith("NSIDC EASE-Grid")) {
-                    section = "Unspecified datum";
+                    datumName = "Unspecified datum";
                 } else if (code.equals("EPSG:2163")) {
-                    section = "Unspecified datum";
+                    datumName = "Unspecified datum";
                 } else if (code.equals("EPSG:5818")) {
-                    section = "Seismic bin grid datum";
+                    datumName = "Seismic bin grid datum";
+                } else {
+                    datumName = null;       // Keep ordering based on the name.
                 }
             }
-            section = JDK8.getOrDefault(SECTION_TITLES, section, section);
+            section = JDK8.getOrDefault(SECTION_TITLES, datumName, datumName);
+            unusedDatumMapping.remove(datumName);
             /*
              * Get a copy of the name in all lower case.
              */
@@ -640,11 +791,15 @@ public final strictfp class CoordinateRe
             if (s != 0) b.setLength(s);
             uniformizeZoneNumber(b);
             reducedName = b.toString();
+            if (datumName != null) {
+                name = insertAbbreviationTitle(name, datumName);
+            }
         }
 
         /**
          * If the string ends with a number optionally followed by "N" or "S", replaces the hemisphere
          * symbol by a sign and makes sure that the number uses at least 3 digits (e.g. "2N" → "+002").
+         * This string will be used for better sorting order.
          */
         private static void uniformizeZoneNumber(final StringBuilder b) {
             if (b.indexOf("/") < 0) {

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java?rev=1730904&r1=1730903&r2=1730904&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java [UTF-8] Wed Feb 17 18:44:26 2016
@@ -75,7 +75,7 @@ public final class CollectionsExt extend
     public static <T> T first(final Iterable<T> collection) {
         if (collection != null) {
             final Iterator<T> it = collection.iterator();
-            if (it != null && it.hasNext()) { // This check for null is paranoiac.
+            if (it != null && it.hasNext()) {                       // This check for null is paranoiac.
                 return it.next();
             }
         }

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Range.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Range.java?rev=1730904&r1=1730903&r2=1730904&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Range.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Range.java [UTF-8] Wed Feb 17 18:44:26 2016
@@ -22,6 +22,7 @@ import java.util.FormattableFlags;
 import java.io.Serializable;
 import javax.measure.unit.Unit;
 import org.apache.sis.internal.util.Utilities;
+import org.apache.sis.internal.util.PatchedUnitFormat;
 import org.apache.sis.util.collection.CheckedContainer;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.Emptiable;
@@ -675,9 +676,13 @@ public class Range<E extends Comparable<
         }
         final Unit<?> unit = unit();
         if (unit != null) {
-            // No need to check if we should omit the space because Unit.toString()
-            // uses UCUM format, so we will never have symbol like the ° one.
-            buffer.append(' ').append(unit);
+            final String symbol = PatchedUnitFormat.toString(unit);
+            if (!symbol.isEmpty()) {
+                if (Character.isLetterOrDigit(symbol.codePointAt(0))) {
+                    buffer.append(' ');
+                }
+                buffer.append(symbol);
+            }
         }
         return buffer.toString();
     }




Mime
View raw message