sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1733199 [2/3] - in /sis/branches/JDK7: ./ application/sis-console/src/main/java/org/apache/sis/console/ application/sis-console/src/main/resources/META-INF/ application/sis-console/src/main/resources/org/apache/sis/console/ application/sis...
Date Wed, 02 Mar 2016 00:07:51 GMT
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AuthorityFactories.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AuthorityFactories.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AuthorityFactories.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AuthorityFactories.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -110,7 +110,7 @@ final class AuthorityFactories<T extends
             if (factory == null) try {
                 factory = new EPSGFactory(null);
             } catch (FactoryException e) {
-                log(Level.CONFIG, e);
+                log(Level.CONFIG, e, false);
                 factory = EPSGFactoryFallback.INSTANCE;
             }
             EPSG[0] = factory;
@@ -137,7 +137,12 @@ final class AuthorityFactories<T extends
                 EPSG[0] = factory;
             }
         }
-        log(Level.WARNING, e);
+        /*
+         * We do not log at Level.WARNING because the UnavailableFactoryException message is usually
+         * not very informative, and a more informative warning has already been logged by EPSGFactory.
+         * However the stack trace may have some interest.
+         */
+        log(Level.FINE, e, true);
         return factory;
     }
 
@@ -161,9 +166,14 @@ final class AuthorityFactories<T extends
      * Logs the given exception at the given level. This method pretends that the logging come from
      * {@link CRS#getAuthorityFactory(String)}, which is the public facade for {@link #EPSG()}.
      */
-    private static void log(final Level level, final Exception e) {
-        final LogRecord record = new LogRecord(level, e.getLocalizedMessage());
+    private static void log(final Level level, final Exception e, final boolean trace) {
+        String message = e.getLocalizedMessage();
+        if (message == null) {
+            message = e.toString();
+        }
+        final LogRecord record = new LogRecord(level, message);
         record.setLoggerName(Loggers.CRS_FACTORY);
+        if (trace) record.setThrown(e);
         Logging.log(CRS.class, "getAuthorityFactory", record);
     }
 

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -83,7 +83,7 @@ import static java.util.Collections.sing
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3
- * @version 0.6
+ * @version 0.7
  * @module
  */
 public final class CRS extends Static {
@@ -290,27 +290,26 @@ public final class CRS extends Static {
      * @category information
      */
     public static SingleCRS getHorizontalComponent(final CoordinateReferenceSystem crs) {
-        if (isHorizontalCRS(crs)) {
-            return (SingleCRS) crs;
-        }
         if (crs instanceof GeodeticCRS) {
             CoordinateSystem cs = crs.getCoordinateSystem();
-            if (cs instanceof EllipsoidalCS) {  // See comment in isHorizontalCRS(…) method.
+            if (cs instanceof EllipsoidalCS) {                          // See comment in isHorizontalCRS(…) method.
                 final int i = AxisDirections.indexOfColinear(cs, AxisDirection.UP);
-                if (i >= 0) {
-                    final CoordinateSystemAxis xAxis = cs.getAxis(i > 0 ? 0 : 1);
-                    final CoordinateSystemAxis yAxis = cs.getAxis(i > 1 ? 1 : 2);
-                    cs = CommonCRS.DEFAULT.geographic().getCoordinateSystem();
-                    if (!Utilities.equalsIgnoreMetadata(cs.getAxis(0), xAxis) ||
-                        !Utilities.equalsIgnoreMetadata(cs.getAxis(1), yAxis))
-                    {
-                        // We can not reuse the name of the existing CS, because it typically
-                        // contains text about axes including the axis that we just dropped.
-                        cs = new DefaultEllipsoidalCS(singletonMap(EllipsoidalCS.NAME_KEY, "Ellipsoidal 2D"), xAxis, yAxis);
-                    }
-                    return new DefaultGeographicCRS(IdentifiedObjects.getProperties(crs),
-                            ((GeodeticCRS) crs).getDatum(), (EllipsoidalCS) cs);
+                if (i < 0) {
+                    return (SingleCRS) crs;
+                }
+                final CoordinateSystemAxis xAxis = cs.getAxis(i > 0 ? 0 : 1);
+                final CoordinateSystemAxis yAxis = cs.getAxis(i > 1 ? 1 : 2);
+                cs = CommonCRS.DEFAULT.geographic().getCoordinateSystem();
+                if (!Utilities.equalsIgnoreMetadata(cs.getAxis(0), xAxis) ||
+                    !Utilities.equalsIgnoreMetadata(cs.getAxis(1), yAxis))
+                {
+                    // We can not reuse the name of the existing CS, because it typically
+                    // contains text about axes including the axis that we just dropped.
+                    cs = new DefaultEllipsoidalCS(singletonMap(EllipsoidalCS.NAME_KEY, "Ellipsoidal 2D"), xAxis, yAxis);
                 }
+                return new DefaultGeographicCRS(
+                        ReferencingUtilities.getPropertiesForModifiedCRS(crs, CoordinateReferenceSystem.IDENTIFIERS_KEY),
+                        ((GeodeticCRS) crs).getDatum(), (EllipsoidalCS) cs);
             }
         }
         if (crs instanceof CompoundCRS) {
@@ -322,7 +321,7 @@ public final class CRS extends Static {
                 }
             }
         }
-        return null;
+        return isHorizontalCRS(crs) ? (SingleCRS) crs : null;
     }
 
     /**
@@ -375,7 +374,7 @@ public final class CRS extends Static {
         }
         if (allowCreateEllipsoidal && crs instanceof GeodeticCRS) {
             final CoordinateSystem cs = crs.getCoordinateSystem();
-            if (cs instanceof EllipsoidalCS) {  // See comment in isHorizontalCRS(…) method.
+            if (cs instanceof EllipsoidalCS) {                          // See comment in isHorizontalCRS(…) method.
                 final int i = AxisDirections.indexOfColinear(cs, AxisDirection.UP);
                 if (i >= 0) {
                     final CoordinateSystemAxis axis = cs.getAxis(i);

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/EPSGFactoryFallback.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/EPSGFactoryFallback.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/EPSGFactoryFallback.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/EPSGFactoryFallback.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -34,6 +34,7 @@ import org.apache.sis.metadata.iso.citat
 import org.apache.sis.referencing.factory.GeodeticAuthorityFactory;
 import org.apache.sis.internal.referencing.provider.TransverseMercator;
 import org.apache.sis.internal.util.Constants;
+import org.apache.sis.internal.util.Fallback;
 import org.apache.sis.util.iso.SimpleInternationalString;
 import org.apache.sis.util.iso.DefaultNameSpace;
 import org.apache.sis.util.resources.Errors;
@@ -51,6 +52,7 @@ import org.apache.sis.util.Debug;
  * @version 0.7
  * @module
  */
+@Fallback
 final class EPSGFactoryFallback extends GeodeticAuthorityFactory implements CRSAuthorityFactory {
     /**
      * Whether to disallow {@code CommonCRS} to use {@link org.apache.sis.referencing.factory.sql.EPSGFactory}

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -103,7 +103,7 @@ public final class IdentifiedObjects ext
      *
      * @param  object The identified object to view as a properties map.
      * @param  excludes The keys of properties to exclude from the map.
-     * @return An view of the identified object as an immutable map.
+     * @return A view of the identified object properties as an immutable map.
      */
     public static Map<String,?> getProperties(final IdentifiedObject object, final String... excludes) {
         ArgumentChecks.ensureNonNull("object", object);
@@ -302,7 +302,7 @@ public final class IdentifiedObjects ext
      * @return A string representation of the first identifier or name, or {@code null} if none.
      *
      * @see #getIdentifier(IdentifiedObject, Citation)
-     * @see #searchIdentifierCode(IdentifiedObject, boolean)
+     * @see #lookupURN(IdentifiedObject, Citation)
      */
     public static String getIdentifierOrName(final IdentifiedObject object) {
         if (object != null) {
@@ -408,7 +408,18 @@ public final class IdentifiedObjects ext
         String urn = null;
         if (object != null) {
             for (final IdentifiedObject candidate : newFinder(null).find(object)) {
-                final String c = toURN(candidate.getClass(), getIdentifier(candidate, authority));
+                String c = toURN(candidate.getClass(), getIdentifier(candidate, authority));
+                if (c == null && authority == null) {
+                    /*
+                     * If 'authority' was null, then getIdentifier(candidate, authority) returned the identifier
+                     * for the first authority.  But not all authorities can be formatted as a URN. So try other
+                     * authorities.
+                     */
+                    for (final Identifier id : candidate.getIdentifiers()) {
+                        c = toURN(candidate.getClass(), id);
+                        if (c != null) break;
+                    }
+                }
                 if (c != null) {
                     if (urn != null && !urn.equals(c)) {
                         return null;
@@ -501,6 +512,8 @@ public final class IdentifiedObjects ext
      * @return A finder to use for looking up unidentified objects.
      * @throws FactoryException if the finder can not be created.
      *
+     * @see #lookupEPSG(IdentifiedObject)
+     * @see #lookupURN(IdentifiedObject, Citation)
      * @see org.apache.sis.referencing.factory.GeodeticAuthorityFactory#newIdentifiedObjectFinder()
      * @see IdentifiedObjectFinder#find(IdentifiedObject)
      */
@@ -541,20 +554,26 @@ public final class IdentifiedObjects ext
      *       projection or parameter name.</li>
      * </ul>
      *
-     * @param  object The object for which to check the name or alias.
+     * If the {@code object} argument is {@code null}, then this method returns {@code false}.
+     *
+     * @param  object The object for which to check the name or alias, or {@code null}.
      * @param  name The name to compare with the object name or aliases.
-     * @return {@code true} if the primary name of at least one alias matches the specified {@code name}.
+     * @return {@code true} if the primary name or at least one alias matches the specified {@code name}.
      *
      * @see AbstractIdentifiedObject#isHeuristicMatchForName(String)
      */
     public static boolean isHeuristicMatchForName(final IdentifiedObject object, final String name) {
+        ArgumentChecks.ensureNonNull("name", name);
+        if (object == null) {
+            return false;
+        }
         if (object instanceof AbstractIdentifiedObject) {
             // DefaultCoordinateSystemAxis overrides this method.
             // We really need to delegate to the overridden method.
             return ((AbstractIdentifiedObject) object).isHeuristicMatchForName(name);
         } else {
-            ArgumentChecks.ensureNonNull("object", object);
-            return NameToIdentifier.isHeuristicMatchForName(object.getName(), object.getAlias(), name);
+            return NameToIdentifier.isHeuristicMatchForName(object.getName(), object.getAlias(), name,
+                    NameToIdentifier.Simplifier.DEFAULT);
         }
     }
 

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -31,6 +31,7 @@ import org.opengis.referencing.crs.Singl
 import org.opengis.referencing.crs.GeneralDerivedCRS;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.apache.sis.internal.referencing.ReferencingUtilities;
+import org.apache.sis.internal.metadata.MetadataUtilities;
 import org.apache.sis.referencing.AbstractReferenceSystem;
 import org.apache.sis.referencing.IdentifiedObjects;
 import org.apache.sis.referencing.cs.AxesConvention;
@@ -536,7 +537,7 @@ public class AbstractCRS extends Abstrac
             if (name == null) {
                 name = String.valueOf(ReferencingUtilities.toPropertyName(CoordinateSystem.class, cs.getClass()));
             }
-            ReferencingUtilities.propertyAlreadySet(AbstractCRS.class, "setCoordinateSystem", name);
+            MetadataUtilities.propertyAlreadySet(AbstractCRS.class, "setCoordinateSystem", name);
         }
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractDerivedCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractDerivedCRS.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractDerivedCRS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractDerivedCRS.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -36,7 +36,7 @@ import org.opengis.referencing.operation
 import org.opengis.geometry.MismatchedDimensionException;
 import org.apache.sis.referencing.operation.DefaultConversion;
 import org.apache.sis.internal.jaxb.referencing.CC_Conversion;
-import org.apache.sis.internal.referencing.ReferencingUtilities;
+import org.apache.sis.internal.metadata.MetadataUtilities;
 import org.apache.sis.internal.metadata.ReferencingServices;
 import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.internal.system.Semaphores;
@@ -296,7 +296,7 @@ abstract class AbstractDerivedCRS<C exte
         if (conversionFromBase == null) {
             conversionFromBase = conversion;
         } else {
-            ReferencingUtilities.propertyAlreadySet(AbstractDerivedCRS.class, "setConversionFromBase", "conversion");
+            MetadataUtilities.propertyAlreadySet(AbstractDerivedCRS.class, "setConversionFromBase", "conversion");
         }
     }
 
@@ -319,7 +319,7 @@ abstract class AbstractDerivedCRS<C exte
             final SingleCRS previous = CC_Conversion.setBaseCRS(conversionFromBase, baseCRS);
             if (previous != null) {
                 CC_Conversion.setBaseCRS(conversionFromBase, previous);   // Temporary location.
-                ReferencingUtilities.propertyAlreadySet(AbstractDerivedCRS.class, "setBaseCRS", name);
+                MetadataUtilities.propertyAlreadySet(AbstractDerivedCRS.class, "setBaseCRS", name);
             }
         } else {
             throw new IllegalStateException(Errors.format(Errors.Keys.MissingComponentInElement_2, getInterface(), "conversion"));

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -49,14 +49,12 @@ import org.apache.sis.internal.jaxb.refe
 import org.apache.sis.util.collection.CheckedContainer;
 import org.apache.sis.util.collection.Containers;
 import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.ComparisonMode;
+import org.apache.sis.util.Utilities;
 import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.io.wkt.Convention;
 
-import static org.apache.sis.util.ArgumentChecks.*;
-import static org.apache.sis.util.Utilities.deepEquals;
-import static org.apache.sis.internal.referencing.WKTUtilities.toFormattable;
-
 
 /**
  * A CRS describing the position of points through two or more independent coordinate reference systems.
@@ -204,7 +202,7 @@ public class DefaultCompoundCRS extends
     private static CoordinateSystem createCoordinateSystem(final Map<String,?> properties,
             final CoordinateReferenceSystem[] components)
     {
-        ensureNonNull("components", components);
+        ArgumentChecks.ensureNonNull("components", components);
         if (components.length < 2) {
             throw new IllegalArgumentException(Errors.getResources(properties).getString(
                     Errors.Keys.TooFewArguments_2, 2, components.length));
@@ -212,7 +210,7 @@ public class DefaultCompoundCRS extends
         final CoordinateSystem[] cs = new CoordinateSystem[components.length];
         for (int i=0; i<components.length; i++) {
             final CoordinateReferenceSystem crs = components[i];
-            ensureNonNullElement("components", i, crs);
+            ArgumentChecks.ensureNonNullElement("components", i, crs);
             cs[i] = crs.getCoordinateSystem();
         }
         return new DefaultCompoundCS(cs);
@@ -438,7 +436,7 @@ public class DefaultCompoundCRS extends
      */
     @Override
     public synchronized DefaultCompoundCRS forConvention(final AxesConvention convention) {
-        ensureNonNull("convention", convention);
+        ArgumentChecks.ensureNonNull("convention", convention);
         DefaultCompoundCRS crs = (DefaultCompoundCRS) getCached(convention);
         if (crs == null) {
             crs = this;
@@ -494,7 +492,7 @@ public class DefaultCompoundCRS extends
                     return components.equals(((DefaultCompoundCRS) object).components);
                 }
                 default: {
-                    return deepEquals(getComponents(), ((CompoundCRS) object).getComponents(), mode);
+                    return Utilities.deepEquals(getComponents(), ((CompoundCRS) object).getComponents(), mode);
                 }
             }
         }
@@ -539,16 +537,16 @@ public class DefaultCompoundCRS extends
         final boolean isWKT1 = convention.majorVersion() == 1;
         if (isWKT1 || convention == Convention.INTERNAL) {
             crs = getComponents();
-            isStandardCompliant = true;    // WKT 1 does not put any restriction.
+            isStandardCompliant = true;                     // WKT 1 does not put any restriction.
         } else {
             crs = getSingleComponents();
             isStandardCompliant = isStandardCompliant(crs);
         }
         for (final CoordinateReferenceSystem element : crs) {
             formatter.newLine();
-            formatter.append(toFormattable(element));
+            formatter.append(WKTUtilities.toFormattable(element));
         }
-        formatter.newLine();    // For writing the ID[…] element on its own line.
+        formatter.newLine();                                // For writing the ID[…] element on its own line.
         if (!isStandardCompliant) {
             formatter.setInvalidWKT(this, null);
         }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -26,7 +26,7 @@ import org.opengis.referencing.crs.Engin
 import org.opengis.referencing.datum.EngineeringDatum;
 import org.apache.sis.referencing.cs.*;
 import org.apache.sis.referencing.AbstractReferenceSystem;
-import org.apache.sis.internal.referencing.ReferencingUtilities;
+import org.apache.sis.internal.metadata.MetadataUtilities;
 import org.apache.sis.internal.metadata.WKTKeywords;
 import org.apache.sis.io.wkt.Formatter;
 
@@ -293,7 +293,7 @@ public class DefaultEngineeringCRS exten
         if (datum == null) {
             datum = value;
         } else {
-            ReferencingUtilities.propertyAlreadySet(DefaultEngineeringCRS.class, "setDatum", "engineeringDatum");
+            MetadataUtilities.propertyAlreadySet(DefaultEngineeringCRS.class, "setDatum", "engineeringDatum");
         }
     }
 

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -27,17 +27,21 @@ import org.opengis.referencing.cs.Cartes
 import org.opengis.referencing.cs.SphericalCS;
 import org.opengis.referencing.cs.EllipsoidalCS;
 import org.opengis.referencing.cs.CoordinateSystem;
+import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.crs.GeodeticCRS;
+import org.opengis.referencing.crs.SingleCRS;
 import org.opengis.referencing.datum.GeodeticDatum;
 import org.opengis.referencing.datum.PrimeMeridian;
 import org.apache.sis.internal.referencing.Legacy;
 import org.apache.sis.internal.metadata.AxisDirections;
+import org.apache.sis.internal.metadata.MetadataUtilities;
 import org.apache.sis.internal.metadata.WKTKeywords;
 import org.apache.sis.internal.referencing.WKTUtilities;
 import org.apache.sis.internal.referencing.ReferencingUtilities;
 import org.apache.sis.referencing.AbstractReferenceSystem;
 import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.io.wkt.Formatter;
+import org.apache.sis.referencing.CRS;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
 
@@ -161,21 +165,43 @@ class DefaultGeodeticCRS extends Abstrac
     @Override
     protected String formatTo(final Formatter formatter) {
         WKTUtilities.appendName(this, formatter, null);
+        CoordinateSystem cs = getCoordinateSystem();
         final Convention convention = formatter.getConvention();
         final boolean isWKT1 = (convention.majorVersion() == 1);
-        CoordinateSystem cs = getCoordinateSystem();
+        final boolean isGeographicWKT1 = isWKT1 && (cs instanceof EllipsoidalCS);
+        if (isGeographicWKT1 && cs.getDimension() == 3) {
+            /*
+             * Version 1 of WKT format did not have three-dimensional GeographicCRS. Instead, such CRS were formatted
+             * as a CompoundCRS made of a two-dimensional GeographicCRS with a VerticalCRS for the ellipsoidal height.
+             * Note that such compound is illegal in WKT 2 and ISO 19111 standard, as ellipsoidal height shall not be
+             * separated from the geographic component. So we perform this separation only at WKT 1 formatting time.
+             */
+            SingleCRS first  = CRS.getHorizontalComponent(this);
+            SingleCRS second = CRS.getVerticalComponent(this, true);
+            if (first != null && second != null) {                      // Should not be null, but we are paranoiac.
+                if (AxisDirection.UP.equals(AxisDirections.absolute(cs.getAxis(0).getDirection()))) {
+                    // It is very unusual to have VerticalCRS first, but our code tries to be robust.
+                    final SingleCRS t = first;
+                    first = second; second = t;
+                }
+                formatter.newLine(); formatter.append(WKTUtilities.toFormattable(first));
+                formatter.newLine(); formatter.append(WKTUtilities.toFormattable(second));
+                formatter.newLine();
+                return WKTKeywords.Compd_CS;
+            }
+        }
         /*
          * Unconditionally format the datum element, followed by the prime meridian.
          * The prime meridian is part of datum according ISO 19111, but is formatted
          * as a sibling (rather than a child) element in WKT for historical reasons.
          */
-        final GeodeticDatum datum = getDatum();     // Gives subclasses a chance to override.
+        final GeodeticDatum datum = getDatum();             // Gives subclasses a chance to override.
         formatter.newLine();
         formatter.append(WKTUtilities.toFormattable(datum));
         formatter.newLine();
         final PrimeMeridian pm = datum.getPrimeMeridian();
         final Unit<Angle> angularUnit = AxisDirections.getAngularUnit(cs, null);
-        if (convention != Convention.WKT2_SIMPLIFIED ||   // Really this specific enum, not Convention.isSimplified().
+        if (convention != Convention.WKT2_SIMPLIFIED ||     // Really this specific enum, not Convention.isSimplified().
                 ReferencingUtilities.getGreenwichLongitude(pm, NonSI.DEGREE_ANGLE) != 0)
         {
             final Unit<Angle> oldUnit = formatter.addContextualUnit(angularUnit);
@@ -196,11 +222,11 @@ class DefaultGeodeticCRS extends Abstrac
          */
         final boolean isBaseCRS;
         if (isWKT1) {
-            if (!(cs instanceof EllipsoidalCS)) { // Tested first because this is the most common case.
+            if (!isGeographicWKT1) {                        // If not geographic, then presumed geocentric.
                 if (cs instanceof CartesianCS) {
                     cs = Legacy.forGeocentricCRS((CartesianCS) cs, true);
                 } else {
-                    formatter.setInvalidWKT(cs, null);  // SphericalCS was not supported in WKT 1.
+                    formatter.setInvalidWKT(cs, null);      // SphericalCS was not supported in WKT 1.
                 }
             }
             isBaseCRS = false;
@@ -230,7 +256,7 @@ class DefaultGeodeticCRS extends Abstrac
          * have a GeodeticCRS. We need to make the choice in this base class. The CS type is a sufficient criterion.
          */
         if (isWKT1) {
-            return (cs instanceof EllipsoidalCS) ? WKTKeywords.GeogCS : WKTKeywords.GeocCS;
+            return isGeographicWKT1 ? WKTKeywords.GeogCS : WKTKeywords.GeocCS;
         } else {
             return isBaseCRS ? WKTKeywords.BaseGeodCRS
                    : formatter.shortOrLong(WKTKeywords.GeodCRS, WKTKeywords.GeodeticCRS);
@@ -274,7 +300,7 @@ class DefaultGeodeticCRS extends Abstrac
         if (datum == null) {
             datum = value;
         } else {
-            ReferencingUtilities.propertyAlreadySet(DefaultGeodeticCRS.class, "setDatum", "geodeticDatum");
+            MetadataUtilities.propertyAlreadySet(DefaultGeodeticCRS.class, "setDatum", "geodeticDatum");
         }
     }
 

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultImageCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultImageCRS.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultImageCRS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultImageCRS.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -26,7 +26,7 @@ import org.opengis.referencing.crs.Image
 import org.opengis.referencing.cs.CartesianCS;
 import org.opengis.referencing.datum.ImageDatum;
 import org.apache.sis.internal.metadata.WKTKeywords;
-import org.apache.sis.internal.referencing.ReferencingUtilities;
+import org.apache.sis.internal.metadata.MetadataUtilities;
 import org.apache.sis.referencing.cs.AxesConvention;
 import org.apache.sis.referencing.AbstractReferenceSystem;
 import org.apache.sis.io.wkt.Formatter;
@@ -281,7 +281,7 @@ public class DefaultImageCRS extends Abs
         if (datum == null) {
             datum = value;
         } else {
-            ReferencingUtilities.propertyAlreadySet(DefaultImageCRS.class, "setDatum", "imageDatum");
+            MetadataUtilities.propertyAlreadySet(DefaultImageCRS.class, "setDatum", "imageDatum");
         }
     }
 

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultTemporalCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultTemporalCRS.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultTemporalCRS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultTemporalCRS.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -29,7 +29,7 @@ import org.opengis.referencing.crs.Tempo
 import org.opengis.referencing.datum.TemporalDatum;
 import org.apache.sis.referencing.cs.AxesConvention;
 import org.apache.sis.referencing.AbstractReferenceSystem;
-import org.apache.sis.internal.referencing.ReferencingUtilities;
+import org.apache.sis.internal.metadata.MetadataUtilities;
 import org.apache.sis.internal.metadata.WKTKeywords;
 import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.measure.Units;
@@ -347,7 +347,7 @@ public class DefaultTemporalCRS extends
         if (datum == null) {
             datum = value;
         } else {
-            ReferencingUtilities.propertyAlreadySet(DefaultVerticalCRS.class, "setDatum", "temporalDatum");
+            MetadataUtilities.propertyAlreadySet(DefaultVerticalCRS.class, "setDatum", "temporalDatum");
         }
     }
 

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultVerticalCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultVerticalCRS.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultVerticalCRS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultVerticalCRS.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -27,7 +27,7 @@ import org.opengis.referencing.datum.Ver
 import org.apache.sis.referencing.cs.AxesConvention;
 import org.apache.sis.referencing.AbstractReferenceSystem;
 import org.apache.sis.internal.metadata.WKTKeywords;
-import org.apache.sis.internal.referencing.ReferencingUtilities;
+import org.apache.sis.internal.metadata.MetadataUtilities;
 import org.apache.sis.io.wkt.Formatter;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
@@ -276,7 +276,7 @@ public class DefaultVerticalCRS extends
         if (datum == null) {
             datum = value;
         } else {
-            ReferencingUtilities.propertyAlreadySet(DefaultVerticalCRS.class, "setDatum", "verticalDatum");
+            MetadataUtilities.propertyAlreadySet(DefaultVerticalCRS.class, "setDatum", "verticalDatum");
         }
     }
 

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -33,7 +33,7 @@ import org.opengis.referencing.cs.AxisDi
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.apache.sis.referencing.AbstractIdentifiedObject;
-import org.apache.sis.internal.referencing.ReferencingUtilities;
+import org.apache.sis.internal.referencing.WKTUtilities;
 import org.apache.sis.internal.metadata.AxisDirections;
 import org.apache.sis.internal.metadata.WKTKeywords;
 import org.apache.sis.io.wkt.ElementKind;
@@ -457,7 +457,7 @@ public class AbstractCS extends Abstract
      */
     @Override
     protected String formatTo(final Formatter formatter) {
-        final String type = ReferencingUtilities.toWKTType(CoordinateSystem.class, getInterface());
+        final String type = WKTUtilities.toType(CoordinateSystem.class, getInterface());
         if (type == null) {
             formatter.setInvalidWKT(this, null);
         }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -20,7 +20,7 @@ import javax.measure.unit.Unit;
 import javax.measure.unit.SI;
 import javax.measure.unit.NonSI;
 import org.opengis.referencing.cs.AxisDirection;
-import org.opengis.referencing.cs.CoordinateSystem; // For javadoc
+import org.opengis.referencing.cs.CoordinateSystem;                 // For javadoc
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.apache.sis.internal.metadata.AxisDirections;
 import org.apache.sis.measure.Units;

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -40,7 +40,7 @@ import org.opengis.referencing.crs.Coord
 import org.apache.sis.internal.metadata.AxisNames;
 import org.apache.sis.internal.metadata.WKTKeywords;
 import org.apache.sis.internal.metadata.AxisDirections;
-import org.apache.sis.internal.referencing.ReferencingUtilities;
+import org.apache.sis.internal.metadata.MetadataUtilities;
 import org.apache.sis.referencing.AbstractIdentifiedObject;
 import org.apache.sis.referencing.IdentifiedObjects;
 import org.apache.sis.measure.Longitude;
@@ -54,7 +54,6 @@ import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.io.wkt.ElementKind;
 import org.apache.sis.io.wkt.Transliterator;
 import org.apache.sis.io.wkt.FormattableObject;
-import org.apache.sis.io.wkt.UnformattableObjectException;
 
 import static java.lang.Double.doubleToLongBits;
 import static java.lang.Double.NEGATIVE_INFINITY;
@@ -776,11 +775,10 @@ public class DefaultCoordinateSystemAxis
         if (AxisDirections.isUserDefined(dir)) {
             meridian = DirectionAlongMeridian.parse(dir);
             if (meridian != null) {
+                dir = meridian.baseDirection;
                 if (isWKT1) {
-                    throw new UnformattableObjectException(Errors.format(
-                            Errors.Keys.CanNotRepresentInFormat_2, "WKT 1", meridian));
+                    formatter.setInvalidWKT(this, null);
                 }
-                dir = meridian.baseDirection;
             }
         }
         formatter.append(dir);
@@ -900,7 +898,7 @@ public class DefaultCoordinateSystemAxis
         if (abbreviation == null) {
             abbreviation = value;
         } else {
-            ReferencingUtilities.propertyAlreadySet(DefaultCoordinateSystemAxis.class, "setAbbreviation", "abbreviation");
+            MetadataUtilities.propertyAlreadySet(DefaultCoordinateSystemAxis.class, "setAbbreviation", "abbreviation");
         }
     }
 
@@ -913,7 +911,7 @@ public class DefaultCoordinateSystemAxis
         if (direction == null) {
             direction = value;
         } else {
-            ReferencingUtilities.propertyAlreadySet(DefaultCoordinateSystemAxis.class, "setDirection", "direction");
+            MetadataUtilities.propertyAlreadySet(DefaultCoordinateSystemAxis.class, "setDirection", "direction");
         }
     }
 
@@ -926,7 +924,7 @@ public class DefaultCoordinateSystemAxis
         if (unit == null) {
             unit = value;
         } else {
-            ReferencingUtilities.propertyAlreadySet(DefaultCoordinateSystemAxis.class, "setUnit", "unit");
+            MetadataUtilities.propertyAlreadySet(DefaultCoordinateSystemAxis.class, "setUnit", "unit");
         }
     }
 
@@ -939,7 +937,7 @@ public class DefaultCoordinateSystemAxis
         if (rangeMeaning == null) {
             rangeMeaning = value;
         } else {
-            ReferencingUtilities.propertyAlreadySet(DefaultCoordinateSystemAxis.class, "setRangeMeaning", "rangeMeaning");
+            MetadataUtilities.propertyAlreadySet(DefaultCoordinateSystemAxis.class, "setRangeMeaning", "rangeMeaning");
         }
     }
 
@@ -965,7 +963,7 @@ public class DefaultCoordinateSystemAxis
                 outOfRange("minimumValue", value);
             }
         } else {
-            ReferencingUtilities.propertyAlreadySet(DefaultCoordinateSystemAxis.class, "setMinimum", "minimumValue");
+            MetadataUtilities.propertyAlreadySet(DefaultCoordinateSystemAxis.class, "setMinimum", "minimumValue");
         }
     }
 
@@ -991,7 +989,7 @@ public class DefaultCoordinateSystemAxis
                 outOfRange("maximumValue", value);
             }
         } else {
-            ReferencingUtilities.propertyAlreadySet(DefaultCoordinateSystemAxis.class, "setMaximum", "maximumValue");
+            MetadataUtilities.propertyAlreadySet(DefaultCoordinateSystemAxis.class, "setMaximum", "maximumValue");
         }
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -32,10 +32,11 @@ import org.opengis.referencing.datum.Dat
 import org.apache.sis.referencing.AbstractIdentifiedObject;
 import org.apache.sis.referencing.IdentifiedObjects;
 import org.apache.sis.util.iso.Types;
+import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.internal.util.Citations;
+import org.apache.sis.internal.metadata.NameToIdentifier;
 import org.apache.sis.internal.metadata.MetadataUtilities;
-import org.apache.sis.internal.referencing.ReferencingUtilities;
 import org.apache.sis.io.wkt.ElementKind;
 import org.apache.sis.io.wkt.Formatter;
 
@@ -335,12 +336,14 @@ public class AbstractDatum extends Abstr
      * Returns {@code true} if either the {@linkplain #getName() primary name} or at least
      * one {@linkplain #getAlias() alias} matches the given string according heuristic rules.
      * This method performs the comparison documented in the
-     * {@link AbstractIdentifiedObject#isHeuristicMatchForName(String) super-class},
+     * {@linkplain AbstractIdentifiedObject#isHeuristicMatchForName(String) super-class},
      * with the following additional flexibility:
      *
      * <ul>
      *   <li>The {@code "D_"} prefix (used in ESRI datum names), if presents in the given name or in this datum name,
      *       is ignored.</li>
+     *   <li>If this datum is an instance of {@link DefaultGeodeticDatum}, then the prime meridian name may also
+     *       be ignored.</li>
      * </ul>
      *
      * <div class="section">Future evolutions</div>
@@ -349,20 +352,33 @@ public class AbstractDatum extends Abstr
      * gained while working with more data producers.
      *
      * @param  name The name to compare.
-     * @return {@code true} if the primary name of at least one alias matches the specified {@code name}.
+     * @return {@code true} if the primary name or at least one alias matches the specified {@code name}.
      */
     @Override
     public boolean isHeuristicMatchForName(final String name) {
-        if (name.startsWith((ESRI_PREFIX))) {
-            if (super.isHeuristicMatchForName(name.substring(ESRI_PREFIX.length()))) {
-                return true;
-            }
-        } else if (getName().getCode().startsWith(ESRI_PREFIX)) {
-            if (super.isHeuristicMatchForName(ESRI_PREFIX.concat(name))) {
-                return true;
+        return NameToIdentifier.isHeuristicMatchForName(super.getName(), super.getAlias(), name, Simplifier.INSTANCE);
+    }
+
+    /**
+     * A function for simplifying a {@link Datum} name before comparison.
+     *
+     * @since 0.7
+     */
+    static class Simplifier extends NameToIdentifier.Simplifier {
+        /** The singleton simplifier for non-geodetic datum. */
+        static final Simplifier INSTANCE = new Simplifier();
+
+        /** For subclasses and default instance only. */
+        Simplifier() {}
+
+        /** Simplify the given datum name. */
+        @Override protected CharSequence apply(CharSequence name) {
+            name = super.apply(name);
+            if (CharSequences.startsWith(name, ESRI_PREFIX, false)) {
+                name = name.subSequence(ESRI_PREFIX.length(), name.length());
             }
+            return name;
         }
-        return super.isHeuristicMatchForName(name);
     }
 
     /**
@@ -489,7 +505,7 @@ public class AbstractDatum extends Abstr
         if (anchorDefinition == null) {
             anchorDefinition = value;
         } else {
-            ReferencingUtilities.propertyAlreadySet(AbstractDatum.class, "setAnchorPoint", "anchorDefinition");
+            MetadataUtilities.propertyAlreadySet(AbstractDatum.class, "setAnchorPoint", "anchorDefinition");
         }
     }
 
@@ -502,7 +518,7 @@ public class AbstractDatum extends Abstr
         if (realizationEpoch == Long.MIN_VALUE) {
             realizationEpoch = value.getTime();
         } else {
-            ReferencingUtilities.propertyAlreadySet(AbstractDatum.class, "setRealizationEpoch", "realizationEpoch");
+            MetadataUtilities.propertyAlreadySet(AbstractDatum.class, "setRealizationEpoch", "realizationEpoch");
         }
     }
 
@@ -515,7 +531,7 @@ public class AbstractDatum extends Abstr
         if (domainOfValidity == null) {
             domainOfValidity = value;
         } else {
-            ReferencingUtilities.propertyAlreadySet(AbstractDatum.class, "setDomainOfValidity", "domainOfValidity");
+            MetadataUtilities.propertyAlreadySet(AbstractDatum.class, "setDomainOfValidity", "domainOfValidity");
         }
     }
 
@@ -528,7 +544,7 @@ public class AbstractDatum extends Abstr
         if (scope == null) {
             scope = value;
         } else {
-            ReferencingUtilities.propertyAlreadySet(AbstractDatum.class, "setScope", "scope");
+            MetadataUtilities.propertyAlreadySet(AbstractDatum.class, "setScope", "scope");
         }
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -34,7 +34,7 @@ import org.apache.sis.internal.util.Nume
 import org.apache.sis.internal.util.DoubleDouble;
 import org.apache.sis.internal.jaxb.gml.Measure;
 import org.apache.sis.internal.jaxb.referencing.SecondDefiningParameter;
-import org.apache.sis.internal.referencing.ReferencingUtilities;
+import org.apache.sis.internal.metadata.MetadataUtilities;
 import org.apache.sis.internal.referencing.Formulas;
 import org.apache.sis.internal.metadata.WKTKeywords;
 import org.apache.sis.referencing.IdentifiedObjects;
@@ -862,7 +862,7 @@ public class DefaultEllipsoid extends Ab
             unit = measure.getUnit(Length.class);
             harmonizeAxisUnits(uom);
         } else {
-            ReferencingUtilities.propertyAlreadySet(DefaultEllipsoid.class, "setSemiMajorAxisMeasure", "semiMajorAxis");
+            MetadataUtilities.propertyAlreadySet(DefaultEllipsoid.class, "setSemiMajorAxisMeasure", "semiMajorAxis");
         }
     }
 
@@ -904,7 +904,7 @@ public class DefaultEllipsoid extends Ab
                     harmonizeAxisUnits(measure.getUnit(Length.class));
                 }
             } else {
-                ReferencingUtilities.propertyAlreadySet(DefaultEllipsoid.class,
+                MetadataUtilities.propertyAlreadySet(DefaultEllipsoid.class,
                         "setSecondDefiningParameter", "secondDefiningParameter");
             }
         }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -35,13 +35,15 @@ import org.apache.sis.referencing.operat
 import org.apache.sis.referencing.operation.matrix.NoninvertibleMatrixException;
 import org.apache.sis.metadata.iso.extent.Extents;
 import org.apache.sis.internal.metadata.WKTKeywords;
+import org.apache.sis.internal.metadata.NameToIdentifier;
+import org.apache.sis.internal.metadata.MetadataUtilities;
 import org.apache.sis.internal.metadata.ReferencingServices;
 import org.apache.sis.internal.referencing.ExtentSelector;
-import org.apache.sis.internal.referencing.ReferencingUtilities;
 import org.apache.sis.internal.util.CollectionsExt;
 import org.apache.sis.internal.system.Loggers;
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.util.ComparisonMode;
+import org.apache.sis.util.CharSequences;
 import org.apache.sis.io.wkt.Formatter;
 
 import static org.apache.sis.util.Utilities.deepEquals;
@@ -466,6 +468,57 @@ public class DefaultGeodeticDatum extend
     }
 
     /**
+     * Returns {@code true} if either the {@linkplain #getName() primary name} or at least
+     * one {@linkplain #getAlias() alias} matches the given string according heuristic rules.
+     * This method implements the flexibility documented in the
+     * {@linkplain AbstractDatum#isHeuristicMatchForName(String) super-class}. In particular,
+     * this method ignores the prime meridian name if that name is found between parenthesis in the datum name.
+     * The meridian can be safely ignored in the datum name because the {@link PrimeMeridian} object is already
+     * compared by the {@link #equals(Object)} method.
+     *
+     * <div class="note"><b>Example:</b>
+     * if the datum name is <cite>"Nouvelle Triangulation Française (Paris)"</cite> and the prime meridian name is
+     * <cite>"Paris"</cite>, then this method compares only the <cite>"Nouvelle Triangulation Française"</cite> part.
+     * </div>
+     *
+     * <div class="section">Future evolutions</div>
+     * This method implements heuristic rules learned from experience while trying to provide inter-operability
+     * with different data producers. Those rules may be adjusted in any future SIS version according experience
+     * gained while working with more data producers.
+     *
+     * @param  name The name to compare.
+     * @return {@code true} if the primary name or at least one alias matches the specified {@code name}.
+     *
+     * @since 0.7
+     */
+    @Override
+    public boolean isHeuristicMatchForName(final String name) {
+        final String meridian = primeMeridian.getName().getCode();
+        return NameToIdentifier.isHeuristicMatchForName(super.getName(), super.getAlias(), name, new Simplifier() {
+            @Override protected CharSequence apply(CharSequence name) {
+                name = super.apply(name);
+                int lower = CharSequences.indexOf(name, meridian, 0, name.length()) - 1;
+                if (lower >= 0 && name.charAt(lower) == '(') {
+                    int upper = lower + meridian.length() + 1;
+                    if (upper < name.length() && name.charAt(upper) == ')') {
+                        lower = CharSequences.skipTrailingWhitespaces(name, 0, lower);
+                        while (lower > 0) {
+                            final int c = Character.codePointBefore(name, lower);
+                            if (Character.isLetterOrDigit(c)) {
+                                // Remove the meridian name only if it is not at the beginning of the name.
+                                name = new StringBuilder(name).delete(lower, upper+1).toString();
+                                break;
+                            }
+                            lower -= Character.charCount(c);
+                        }
+                    }
+                }
+                return name;
+            }
+        });
+    }
+
+    /**
      * Compare this datum with the specified object for equality.
      *
      * @param  object The object to compare to {@code this}.
@@ -622,7 +675,7 @@ public class DefaultGeodeticDatum extend
         if (ellipsoid == null) {
             ellipsoid = value;
         } else {
-            ReferencingUtilities.propertyAlreadySet(DefaultGeodeticDatum.class, "setEllipsoid", "ellipsoid");
+            MetadataUtilities.propertyAlreadySet(DefaultGeodeticDatum.class, "setEllipsoid", "ellipsoid");
         }
     }
 
@@ -635,7 +688,7 @@ public class DefaultGeodeticDatum extend
         if (primeMeridian == null) {
             primeMeridian = value;
         } else {
-            ReferencingUtilities.propertyAlreadySet(DefaultGeodeticDatum.class, "setPrimeMeridian", "primeMeridian");
+            MetadataUtilities.propertyAlreadySet(DefaultGeodeticDatum.class, "setPrimeMeridian", "primeMeridian");
         }
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -26,7 +26,7 @@ import org.opengis.metadata.Identifier;
 import org.opengis.referencing.datum.ImageDatum;
 import org.opengis.referencing.datum.PixelInCell;
 import org.apache.sis.internal.metadata.WKTKeywords;
-import org.apache.sis.internal.referencing.ReferencingUtilities;
+import org.apache.sis.internal.metadata.MetadataUtilities;
 import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.util.ComparisonMode;
@@ -288,7 +288,7 @@ public class DefaultImageDatum extends A
         if (pixelInCell == null) {
             pixelInCell = value;
         } else {
-            ReferencingUtilities.propertyAlreadySet(DefaultImageDatum.class, "setPixelInCell", "pixelInCell");
+            MetadataUtilities.propertyAlreadySet(DefaultImageDatum.class, "setPixelInCell", "pixelInCell");
         }
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -31,6 +31,7 @@ import org.opengis.referencing.crs.Gener
 import org.apache.sis.referencing.AbstractIdentifiedObject;
 import org.apache.sis.internal.referencing.ReferencingUtilities;
 import org.apache.sis.internal.util.PatchedUnitFormat;
+import org.apache.sis.internal.metadata.MetadataUtilities;
 import org.apache.sis.internal.metadata.WKTKeywords;
 import org.apache.sis.internal.jaxb.gml.Measure;
 import org.apache.sis.internal.util.Numerics;
@@ -444,7 +445,7 @@ public class DefaultPrimeMeridian extend
                 }
             }
         } else {
-            ReferencingUtilities.propertyAlreadySet(DefaultPrimeMeridian.class, "setGreenwichMeasure", "greenwichLongitude");
+            MetadataUtilities.propertyAlreadySet(DefaultPrimeMeridian.class, "setGreenwichMeasure", "greenwichLongitude");
         }
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -30,7 +30,6 @@ import org.opengis.referencing.datum.Tem
 import org.apache.sis.internal.metadata.WKTKeywords;
 import org.apache.sis.internal.jaxb.gml.UniversalTimeAdapter;
 import org.apache.sis.internal.metadata.MetadataUtilities;
-import org.apache.sis.internal.referencing.ReferencingUtilities;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.io.wkt.FormattableObject;
@@ -341,7 +340,7 @@ public class DefaultTemporalDatum extend
         if (origin == Long.MIN_VALUE) {
             origin = value.getTime();
         } else {
-            ReferencingUtilities.propertyAlreadySet(DefaultTemporalDatum.class, "setOrigin", "origin");
+            MetadataUtilities.propertyAlreadySet(DefaultTemporalDatum.class, "setOrigin", "origin");
         }
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -31,7 +31,7 @@ import org.apache.sis.internal.jaxb.Cont
 import org.apache.sis.internal.jaxb.LegacyNamespaces;
 import org.apache.sis.internal.metadata.WKTKeywords;
 import org.apache.sis.internal.metadata.VerticalDatumTypes;
-import org.apache.sis.internal.referencing.ReferencingUtilities;
+import org.apache.sis.internal.metadata.MetadataUtilities;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
 
@@ -238,6 +238,12 @@ public class DefaultVerticalDatum extend
     /**
      * Returns the type of this vertical datum.
      *
+     * <div class="note"><b>Historical note:</b>
+     * this property was defined in the ISO 19111 specification published in 2003,
+     * but removed from the revision published 2007.
+     * This property provides an information similar to the {@linkplain #getAnchorPoint() anchor definition},
+     * but in a programmatic way more suitable to coordinate transformation engines.</div>
+     *
      * @return The type of this vertical datum.
      */
     @Override
@@ -257,7 +263,7 @@ public class DefaultVerticalDatum extend
     @Override
     public boolean equals(final Object object, final ComparisonMode mode) {
         if (object == this) {
-            return true; // Slight optimization.
+            return true;                                                    // Slight optimization.
         }
         if (!super.equals(object, mode)) {
             return false;
@@ -266,9 +272,18 @@ public class DefaultVerticalDatum extend
             case STRICT: {
                 return type().equals(((DefaultVerticalDatum) object).type());
             }
-            default: {
+            case BY_CONTRACT: {
                 return Objects.equals(getVerticalDatumType(), ((VerticalDatum) object).getVerticalDatumType());
             }
+            default: {
+                /*
+                 * VerticalDatumType is considered as metadata because it is related to the anchor definition,
+                 * which is itself considered as metadata. Furthermore GeodeticObjectParser and EPSGDataAccess
+                 * do not always set this property to the same value: the former uses the information provided
+                 * by the coordinate system axis while the other does not.
+                 */
+                return true;
+            }
         }
     }
 
@@ -301,7 +316,7 @@ public class DefaultVerticalDatum extend
     protected String formatTo(final Formatter formatter) {
         super.formatTo(formatter);
         if (formatter.getConvention().majorVersion() == 1) {
-            formatter.append(VerticalDatumTypes.toLegacy(type().ordinal()));
+            formatter.append(VerticalDatumTypes.toLegacy(type()));
             return WKTKeywords.Vert_Datum;
         }
         return formatter.shortOrLong(WKTKeywords.VDatum, WKTKeywords.VerticalDatum);
@@ -347,7 +362,7 @@ public class DefaultVerticalDatum extend
         if (type == null) {
             type = t;
         } else {
-            ReferencingUtilities.propertyAlreadySet(DefaultVerticalDatum.class, "setTypeElement", "verticalDatumType");
+            MetadataUtilities.propertyAlreadySet(DefaultVerticalDatum.class, "setTypeElement", "verticalDatumType");
         }
     }
 }

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=1733199&r1=1733198&r2=1733199&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 Mar  2 00:07:49 2016
@@ -44,10 +44,13 @@ import org.apache.sis.util.Debug;
 /**
  * Creates geodetic objects from codes defined by an authority.
  * An <cite>authority</cite> is an organization that maintains definitions of authority codes.
- * An <cite>authority code</cite> is a compact string defined by an authority to reference a particular
- * spatial reference object. For example the <a href="http://www.epsg.org">EPSG geodetic dataset</a> maintains
- * a database of coordinate systems, and other spatial referencing objects, where each object has a code number ID.
- * For example, the EPSG code for a WGS84 Lat/Lon coordinate system is {@code "4326"}.
+ * An <cite>authority code</cite> is a compact string defined by an authority to reference a particular spatial reference object.
+ * A frequently used set of authority codes is the <a href="http://www.epsg.org">EPSG geodetic dataset</a>,
+ * a database of coordinate systems and other spatial referencing objects where each object has a code number ID.
+ *
+ * <div class="note"><b>Example:</b>
+ * the EPSG code for a <cite>World Geodetic System 1984</cite> (WGS84) coordinate reference system
+ * with latitude and longitude axes is {@code "4326"}.</div>
  *
  * <p>This class defines a default implementation for most methods defined in the {@link DatumAuthorityFactory},
  * {@link CSAuthorityFactory} and {@link CRSAuthorityFactory} interfaces. However, those interfaces do not appear

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticObjectFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticObjectFactory.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticObjectFactory.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticObjectFactory.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -69,7 +69,7 @@ import org.apache.sis.xml.XML;
  * This factory serves two purposes:
  *
  * <ul>
- *   <li><b>For users</b>, allows the creation of complex objects that can not be created by the authority factory,
+ *   <li><b>For users</b>, allows the creation of complex objects that can not be created by the authority factories,
  *       without explicit dependency to Apache SIS (when using the GeoAPI interfaces implemented by this class).</li>
  *   <li><b>For providers</b>, allows <cite>inversion of control</cite> by overriding methods in this class,
  *       then specifying the customized instance to other services that consume {@code CRSFactory} (for example
@@ -78,8 +78,8 @@ import org.apache.sis.xml.XML;
  *
  * This {@code GeodeticObjectFactory} class is not easy to use directly.
  * Users are encouraged to use an authority factory instead
- * (or the {@link CRS#forCode(String)} convenience method) when the CRS object to construct can be identified
- * by a code in the namespace of an authority (typically EPSG).
+ * (or the {@link org.apache.sis.referencing.CRS#forCode(String)} convenience method)
+ * when the CRS object to construct can be identified by a code in the namespace of an authority (typically EPSG).
  *
  * <div class="section">Object properties</div>
  * Most factory methods expect a {@link Map Map&lt;String,?&gt;} argument, often followed by explicit arguments.

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -62,7 +62,7 @@ import org.apache.sis.util.Utilities;
  * @module
  *
  * @see GeodeticAuthorityFactory#newIdentifiedObjectFinder()
- * @see IdentifiedObjects#lookupIdentifier(IdentifiedObject, boolean)
+ * @see IdentifiedObjects#newFinder(String)
  */
 public class IdentifiedObjectFinder {
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/package-info.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/package-info.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/package-info.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -16,10 +16,47 @@
  */
 
 /**
- * Creates Coordinate Reference System (CRS) objects from given properties.
+ * Creates Coordinate Reference System (CRS) objects from given properties or authority codes.
+ * This package provides two kinds of factories:
+ *
+ * <ul class="verbose">
+ *   <li>{@link org.apache.sis.referencing.factory.GeodeticAuthorityFactory}
+ *     creates geodetic objects from codes defined by an authority.
+ *     An <cite>authority</cite> is an organization that maintains definitions of authority codes.
+ *     An <cite>authority code</cite> is a compact string defined by an authority to reference a particular spatial reference object.
+ *     A frequently used set of authority codes is the <a href="http://www.epsg.org">EPSG geodetic dataset</a>,
+ *     a database of coordinate systems and other spatial referencing objects where each object has a code number ID.</li>
+ *
+ *   <li>{@link org.apache.sis.referencing.factory.GeodeticObjectFactory}
+ *     creates complex objects that can not be created by the authority factories.
+ *     Allows also <cite>inversion of control</cite> when used with the
+ *     {@linkplain org.apache.sis.referencing.factory.sql.EPSGFactory EPSG authority factory}
+ *     or with the {@linkplain org.apache.sis.io.wkt.WKTFormat WKT parser}.</li>
+ * </ul>
+ *
+ * Authority factories available in Apache SIS are listed below.
+ * Factories defined in this package do not require any configuration or external resources.
+ * Factories defined in the {@link org.apache.sis.referencing.factory.sql sql} sub-package require a connection to a database.
+ *
+ * <table class="sis">
+ *   <caption>Authority factory implementations</caption>
+ *   <tr>
+ *     <th>Authorities</th>
+ *     <th>Implementation class</th>
+ *     <th>Conditions</th>
+ *   </tr><tr>
+ *     <td>{@code CRS}, {@code AUTO} and {@code AUTO2}</td>
+ *     <td>{@link org.apache.sis.referencing.factory.CommonAuthorityFactory}</td>
+ *     <td>None.</td>
+ *   </tr><tr>
+ *     <td>{@code EPSG}</td>
+ *     <td>{@link org.apache.sis.referencing.factory.sql.EPSGFactory}</td>
+ *     <td>Requires installation of EPSG dataset.</td>
+ *   </tr>
+ * </table>
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
- * @version 0.6
+ * @version 0.7
  * @since   0.6
  * @module
  */

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=1733199&r1=1733198&r2=1733199&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 Mar  2 00:07:49 2016
@@ -1559,9 +1559,6 @@ addURIs:    for (int i=0; ; i++) {
      * @return The datum for the given code.
      * @throws NoSuchAuthorityCodeException if the specified {@code code} was not found.
      * @throws FactoryException if the object creation failed for some other reason.
-     *
-     * @todo Current implementation maps all "vertical" datum to {@link VerticalDatumType#GEOIDAL}.
-     *       We do not know yet how to maps the exact vertical datum type from the EPSG database.
      */
     @Override
     public synchronized Datum createDatum(final String code) throws NoSuchAuthorityCodeException, FactoryException {
@@ -1629,7 +1626,10 @@ addURIs:    for (int i=0; ; i++) {
                         break;
                     }
                     /*
-                     * Vertical datum type is hard-coded to geoidal for now. See @todo in method javadoc.
+                     * Vertical datum type is hard-coded to geoidal. It would be possible to infer other
+                     * types by looking at the coordinate system, but it could result in different datum
+                     * associated to the same EPSG code.  Since vertical datum type is no longer part of
+                     * ISO 19111:2007, it is probably not worth to handle such cases.
                      */
                     case "vertical": {
                         datum = datumFactory.createVerticalDatum(properties, VerticalDatumType.GEOIDAL);
@@ -3276,7 +3276,7 @@ next:               while (r.next()) {
                 return iteration != 0;
             }
         }
-        while (++iteration < 15);      // Arbitrary limit for avoiding never-ending loop.
+        while (++iteration < Formulas.MAXIMUM_ITERATIONS);      // Arbitrary limit for avoiding never-ending loop.
         return true;
     }
 

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java?rev=1733199&r1=1733198&r2=1733199&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java [UTF-8] Wed Mar  2 00:07:49 2016
@@ -76,6 +76,7 @@ import org.apache.sis.util.Localized;
  *
  * @see EPSGDataAccess
  * @see SQLTranslator
+ * @see <a href="http://sis.apache.org/book/tables/CoordinateReferenceSystems.html">List of authority codes</a>
  */
 public class EPSGFactory extends ConcurrentAuthorityFactory<EPSGDataAccess> implements CRSAuthorityFactory,
         CSAuthorityFactory, DatumAuthorityFactory, CoordinateOperationAuthorityFactory, Localized
@@ -348,6 +349,8 @@ public class EPSGFactory extends Concurr
      * @param  connection Connection to the database where to create the EPSG schema.
      * @throws IOException if the SQL script can not be found or an I/O error occurred while reading them.
      * @throws SQLException if an error occurred while writing to the database.
+     *
+     * @see InstallationScriptProvider
      */
     public synchronized void install(final Connection connection) throws IOException, SQLException {
         ArgumentChecks.ensureNonNull("connection", connection);

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=1733199&r1=1733198&r2=1733199&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 Mar  2 00:07:49 2016
@@ -33,14 +33,19 @@ import org.apache.sis.util.StringBuilder
 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.internal.util.Fallback;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.resources.Messages;
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.util.logging.PerformanceLevel;
+import org.apache.sis.setup.InstallationResources;
 
+import static org.apache.sis.internal.util.Constants.EPSG;
+
+// Branch-dependent imports
 import org.apache.sis.internal.jdk8.BiFunction;
 
+
 /**
  * Runs the SQL scripts for creating an EPSG database.
  *
@@ -242,20 +247,21 @@ final class EPSGInstaller extends Script
     /**
      * Processes to the creation of the EPSG database using the SQL scripts from the given provider.
      *
+     * @param  scriptProvider User-provided scripts, or {@code null} for automatic lookup.
      * @throws IOException if an error occurred while reading an input.
      * @throws SQLException if an error occurred while executing a SQL statement.
      */
-    public void run(InstallationScriptProvider scriptProvider) throws SQLException, IOException {
+    public void run(InstallationResources scriptProvider) throws SQLException, IOException {
         long time = System.nanoTime();
-        log(Messages.getResources(null).getLogRecord(Level.INFO, Messages.Keys.CreatingSchema_2, Constants.EPSG,
+        log(Messages.getResources(null).getLogRecord(Level.INFO, Messages.Keys.CreatingSchema_2, EPSG,
                 SQLUtilities.getSimplifiedURL(getConnection().getMetaData())));
         if (scriptProvider == null) {
             scriptProvider = lookupProvider();
         }
-        final String[] scripts = scriptProvider.getScriptNames();
+        final String[] scripts = scriptProvider.getResourceNames(EPSG);
         int numRows = 0;
         for (int i=0; i<scripts.length; i++) {
-            try (BufferedReader in = scriptProvider.getScriptContent(i)) {
+            try (BufferedReader in = scriptProvider.openScript(EPSG, i)) {
                 numRows += run(scripts[i], in);
             }
         }
@@ -268,20 +274,24 @@ final class EPSGInstaller extends Script
     /**
      * Searches for a SQL script provider on the classpath before to fallback on the default provider.
      */
-    private static InstallationScriptProvider lookupProvider() {
-        for (final InstallationScriptProvider p : ServiceLoader.load(InstallationScriptProvider.class)) {
-            if (Constants.EPSG.equals(p.getAuthority())) {
-                return p;
+    private static InstallationResources lookupProvider() {
+        InstallationResources fallback = null;
+        for (final InstallationResources provider : ServiceLoader.load(InstallationResources.class)) {
+            if (provider.getAuthorities().contains(EPSG)) {
+                if (provider.getClass().isAnnotationPresent(Fallback.class)) {
+                    return provider;
+                }
+                fallback = provider;
             }
         }
-        return new InstallationScriptProvider.Default();
+        return (fallback != null) ? fallback : new InstallationScriptProvider.Default();
     }
 
     /**
      * Logs a message reporting the failure to create EPSG database.
      */
     final void logFailure(final Locale locale) {
-        String message = Messages.getResources(locale).getString(Messages.Keys.CanNotCreateSchema_1, Constants.EPSG);
+        String message = Messages.getResources(locale).getString(Messages.Keys.CanNotCreateSchema_1, EPSG);
         String status = status(locale);
         if (status != null) {
             message = message + ' ' + status;



Mime
View raw message