sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1542821 - in /sis/trunk: ./ core/sis-referencing/src/main/java/org/apache/sis/io/wkt/ core/sis-referencing/src/main/java/org/apache/sis/referencing/ core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/ core/sis-referencing/...
Date Sun, 17 Nov 2013 21:11:11 GMT
Author: desruisseaux
Date: Sun Nov 17 21:11:10 2013
New Revision: 1542821

URL: http://svn.apache.org/r1542821
Log:
Merge from the JDK6 branch.

Added:
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/SubTypes.java
      - copied unchanged from r1542820, sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/SubTypes.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/SubTypes.java
      - copied unchanged from r1542820, sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/SubTypes.java
    sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
      - copied unchanged from r1542820, sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
Removed:
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Formattable.java
Modified:
    sis/trunk/   (props changed)
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/FormattableObject.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Formatter.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
    sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java
    sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java
    sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
    sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
    sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java

Propchange: sis/trunk/
------------------------------------------------------------------------------
  Merged /sis/branches/JDK7:r1542034-1542818
  Merged /sis/branches/JDK6:r1542035-1542820

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/FormattableObject.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/FormattableObject.java?rev=1542821&r1=1542820&r2=1542821&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/FormattableObject.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/FormattableObject.java
[UTF-8] Sun Nov 17 21:11:10 2013
@@ -27,7 +27,9 @@ import org.apache.sis.internal.util.X364
 
 /**
  * Base class for objects that can be formatted as <cite>Well Known Text</cite>
(WKT).
- * Almost every Apache SIS implementations of referencing objects extend this class.
+ * {@link WKTFormat} checks for this interface at formatting time for each element to format.
+ * When a {@code FormattableObject} element is found, its {@link #formatTo(Formatter)} method
+ * is invoked for allowing the element to control its formatting.
  *
  * <p>This class provides two methods for getting a default <cite>Well Known
Text</cite>
  * representation of this object:</p>
@@ -52,7 +54,7 @@ import org.apache.sis.internal.util.X364
  * @version 0.4
  * @module
  */
-public class FormattableObject implements Formattable {
+public class FormattableObject {
     /**
      * The formatter for the {@link #toWKT()} and {@link #toString()} methods.
      * Formatters are not thread-safe, consequently we need a different instance for each
thread.
@@ -169,17 +171,31 @@ public class FormattableObject implement
     }
 
     /**
-     * {@inheritDoc}
+     * Formats the inner part of this <cite>Well Known Text</cite> (WKT) element
into the given formatter.
+     * This method is automatically invoked by {@link WKTFormat} when a formattable element
is found.
+     *
+     * <p>Element keyword and {@linkplain org.apache.sis.referencing.IdentifiedObjects#getIdentifierCode
+     * authority code} shall not be formatted here. For example if this formattable element
is for a
+     * {@code GEOGCS} element, then this method shall write the content starting at the insertion
point
+     * shows below:</p>
+     *
+     * {@preformat text
+     *     GEOGCS["WGS 84", AUTHORITY["EPSG","4326"]]
+     *                    ↑
+     *            (insertion point)
+     * }
      *
      * The default implementation declares that this object produces an invalid WKT.
      * Subclasses shall override this method for proper WKT formatting and shall <strong>not</strong>
      * invoke {@code super.formatTo(formatter)} if they can use a standard WKT syntax.
      *
+     * @param  formatter The formatter where to format the inner content of this WKT element.
+     * @return The WKT element keyword (e.g. {@code "GEOGCS"}).
+     *
      * @see #toWKT()
      * @see #toString()
      */
-    @Override
-    public String formatTo(final Formatter formatter) {
+    protected String formatTo(final Formatter formatter) {
         Class<?> type = getClass();
         for (final Class<?> candidate : type.getInterfaces()) {
             final String name = candidate.getName();

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Formatter.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Formatter.java?rev=1542821&r1=1542820&r2=1542821&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Formatter.java [UTF-8]
(original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Formatter.java [UTF-8]
Sun Nov 17 21:11:10 2013
@@ -46,6 +46,7 @@ import org.apache.sis.util.ArgumentCheck
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.internal.util.Citations;
 import org.apache.sis.referencing.IdentifiedObjects;
+import org.apache.sis.referencing.AbstractIdentifiedObject;
 
 // Related to JDK7
 import org.apache.sis.internal.jdk7.JDK7;
@@ -180,15 +181,14 @@ public class Formatter {
     private int margin;
 
     /**
-     * {@code true} if a new line were requested during the execution of {@link #append(Formattable)}.
-     * This is used to determine if the next {@code UNIT} and {@code AUTHORITY} elements
shall appear
-     * on a new line.
+     * {@code true} if a new line were requested during the execution of {@link #append(FormattableObject)}.
+     * This is used to determine if the next {@code UNIT} and {@code AUTHORITY} elements
shall appear on a new line.
      */
     private boolean requestNewLine;
 
     /**
      * {@code true} if the last formatted element was invalid WKT. This field is for internal
use only.
-     * It is reset to {@code false} after the invalid part has been processed by {@link #append(Formattable)}.
+     * It is reset to {@code false} after the invalid part has been processed by {@link #append(FormattableObject)}.
      */
     private boolean wasInvalidWKT;
 
@@ -395,14 +395,14 @@ public class Formatter {
     }
 
     /**
-     * Appends the given {@code Formattable} object.
+     * Appends the given {@code FormattableObject}.
      * This method will automatically append the keyword (e.g. {@code "GEOCS"}), the name
and the authority code,
      * and will invoke <code>formattable.{@linkplain FormattableObject#formatTo(Formatter)
formatTo}(this)</code>
      * for completing the inner part of the WKT.
      *
      * @param object The formattable object to append to the WKT, or {@code null} if none.
      */
-    public void append(final Formattable object) {
+    public void append(final FormattableObject object) {
         if (object == null) {
             return;
         }
@@ -494,11 +494,8 @@ public class Formatter {
      */
     public void append(final IdentifiedObject object) {
         if (object != null) {
-            if (object instanceof Formattable) {
-                append((Formattable) object);
-            } else {
-                throw unsupported(object);
-            }
+            append(object instanceof FormattableObject ? (FormattableObject) object :
+                   AbstractIdentifiedObject.castOrCopy(object));
         }
     }
 
@@ -509,26 +506,16 @@ public class Formatter {
      */
     public void append(final MathTransform transform) {
         if (transform != null) {
-            if (transform instanceof Formattable) {
-                append((Formattable) transform);
+            if (transform instanceof FormattableObject) {
+                append((FormattableObject) transform);
             } else {
-                throw unsupported(transform);
+                throw new UnformattableObjectException(Errors.format(
+                        Errors.Keys.IllegalClass_2, FormattableObject.class, transform.getClass()));
             }
         }
     }
 
     /**
-     * Invoked when an object is not a supported implementation.
-     *
-     * @param object The object of unknown type.
-     * @return The exception to be thrown.
-     */
-    private static UnformattableObjectException unsupported(final Object object) {
-        return new UnformattableObjectException(Errors.format(
-                Errors.Keys.IllegalClass_2, Formattable.class, object.getClass()));
-    }
-
-    /**
      * Appends a {@linkplain ParameterValue parameter} in WKT form.
      * If the supplied parameter is actually a {@linkplain ParameterValueGroup parameter
group},
      * all contained parameters will flattened in a single list.

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java?rev=1542821&r1=1542820&r2=1542821&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
[UTF-8] Sun Nov 17 21:11:10 2013
@@ -290,6 +290,35 @@ public class AbstractIdentifiedObject ex
     }
 
     /**
+     * Returns a SIS identified object implementation with the values of the given arbitrary
implementation.
+     * This method performs the first applicable actions in the following choices:
+     *
+     * <ul>
+     *   <li>If the given object is {@code null}, then this method returns {@code null}.</li>
+     *   <li>Otherwise if the given object is is an instance of
+     *       {@link org.opengis.referencing.datum.Datum},
+     *       {@link org.opengis.referencing.datum.Ellipsoid} or
+     *       {@link org.opengis.referencing.datum.PrimeMeridian},
+     *       then this method delegates to the {@code castOrCopy(…)} method of the corresponding
SIS subclass.
+     *       Note that if the given object implements more than one of the above-cited interfaces,
+     *       then the {@code castOrCopy(…)} method to be used is unspecified.</li>
+     *   <li>Otherwise if the given object is already an instance of
+     *       {@code AbstractIdentifiedObject}, then it is returned unchanged.</li>
+     *   <li>Otherwise a new {@code AbstractIdentifiedObject} instance is created using
the
+     *       {@linkplain #AbstractIdentifiedObject(IdentifiedObject) copy constructor}
+     *       and returned. Note that this is a <cite>shallow</cite> copy operation,
since the other
+     *       properties contained in the given object are not recursively copied.</li>
+     * </ul>
+     *
+     * @param  object The object to get as a SIS implementation, or {@code null} if none.
+     * @return A SIS implementation containing the values of the given object (may be the
+     *         given object itself), or {@code null} if the argument was null.
+     */
+    public static AbstractIdentifiedObject castOrCopy(final IdentifiedObject object) {
+        return SubTypes.castOrCopy(object);
+    }
+
+    /**
      * The {@code gml:id}, which is mandatory. The current implementation searches for the
first identifier,
      * regardless its authority. If no identifier is found, then the name is used.
      * If no name is found (which should not occur for valid objects), then this method returns
{@code null}.
@@ -525,7 +554,7 @@ public class AbstractIdentifiedObject ex
                 }
             }
         } else {
-            if (mode == ComparisonMode.STRICT) { // Same classes was required for this mode.
+            if (mode == ComparisonMode.STRICT) { // Same class was required for this mode.
                 return false;
             }
             if (!(object instanceof IdentifiedObject)) {

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java?rev=1542821&r1=1542820&r2=1542821&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
[UTF-8] Sun Nov 17 21:11:10 2013
@@ -183,6 +183,37 @@ public class AbstractDatum extends Abstr
     }
 
     /**
+     * Returns a SIS datum implementation with the values of the given arbitrary implementation.
+     * This method performs the first applicable actions in the following choices:
+     *
+     * <ul>
+     *   <li>If the given object is {@code null}, then this method returns {@code null}.</li>
+     *   <li>Otherwise if the given object is is an instance of
+     *       {@link org.opengis.referencing.datum.GeodeticDatum},
+     *       {@link org.opengis.referencing.datum.VerticalDatum},
+     *       {@link org.opengis.referencing.datum.TemporalDatum},
+     *       {@link org.opengis.referencing.datum.EngineeringDatum} or
+     *       {@link org.opengis.referencing.datum.ImageDatum},
+     *       then this method delegates to the {@code castOrCopy(…)} method of the corresponding
SIS subclass.
+     *       Note that if the given object implements more than one of the above-cited interfaces,
+     *       then the {@code castOrCopy(…)} method to be used is unspecified.</li>
+     *   <li>Otherwise if the given object is already an instance of
+     *       {@code AbstractDatum}, then it is returned unchanged.</li>
+     *   <li>Otherwise a new {@code AbstractDatum} instance is created using the
+     *       {@linkplain #AbstractDatum(Datum) copy constructor}
+     *       and returned. Note that this is a <cite>shallow</cite> copy operation,
since the other
+     *       properties contained in the given object are not recursively copied.</li>
+     * </ul>
+     *
+     * @param  object The object to get as a SIS implementation, or {@code null} if none.
+     * @return A SIS implementation containing the values of the given object (may be the
+     *         given object itself), or {@code null} if the argument was null.
+     */
+    public static AbstractDatum castOrCopy(final Datum object) {
+        return SubTypes.castOrCopy(object);
+    }
+
+    /**
      * Returns a description of the point(s) used to anchor the datum to the Earth.
      * Also known as the "origin", especially for Engineering and Image Datums.
      *
@@ -349,7 +380,7 @@ public class AbstractDatum extends Abstr
      * @return The WKT element name.
      */
     @Override
-    public String formatTo(final Formatter formatter) {
+    protected String formatTo(final Formatter formatter) {
         formatter.append(getLegacyDatumType());
         return Classes.getShortClassName(this);
     }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java?rev=1542821&r1=1542820&r2=1542821&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java
[UTF-8] Sun Nov 17 21:11:10 2013
@@ -601,7 +601,7 @@ public class BursaWolfParameters extends
      * @return The WKT element name, usually {@code "TOWGS84"}.
      */
     @Override
-    public String formatTo(final Formatter formatter) {
+    protected String formatTo(final Formatter formatter) {
         formatter.append(tX);
         formatter.append(tY);
         formatter.append(tZ);

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java?rev=1542821&r1=1542820&r2=1542821&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
[UTF-8] Sun Nov 17 21:11:10 2013
@@ -715,7 +715,7 @@ public class DefaultEllipsoid extends Ab
      * @return The WKT element name, which is {@code "SPHEROID"}.
      */
     @Override
-    public String formatTo(final Formatter formatter) {
+    protected String formatTo(final Formatter formatter) {
         final double ivf = getInverseFlattening();
         formatter.append(getAxisUnit().getConverterTo(SI.METRE).convert(getSemiMajorAxis()));
         formatter.append(isInfinite(ivf) ? 0 : ivf);

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java?rev=1542821&r1=1542820&r2=1542821&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java
[UTF-8] Sun Nov 17 21:11:10 2013
@@ -176,7 +176,7 @@ public class DefaultEngineeringDatum ext
      * @return The WKT element name, which is {@code "LOCAL_DATUM"}.
      */
     @Override
-    public String formatTo(final Formatter formatter) {
+    protected String formatTo(final Formatter formatter) {
         super.formatTo(formatter);
         return "LOCAL_DATUM";
     }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java?rev=1542821&r1=1542820&r2=1542821&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
[UTF-8] Sun Nov 17 21:11:10 2013
@@ -39,6 +39,7 @@ import org.apache.sis.util.logging.Loggi
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.Immutable;
 import org.apache.sis.io.wkt.Formatter;
+import org.apache.sis.io.wkt.FormattableObject;
 
 import static org.apache.sis.util.Utilities.deepEquals;
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
@@ -434,6 +435,7 @@ public class DefaultGeodeticDatum extend
                             Arrays.equals(this.bursaWolf,     that.bursaWolf);
                 }
                 default: {
+                    if (!(object instanceof GeodeticDatum)) break;
                     final GeodeticDatum that = (GeodeticDatum) object;
                     return deepEquals(getEllipsoid(),     that.getEllipsoid(),     mode)
&&
                            deepEquals(getPrimeMeridian(), that.getPrimeMeridian(), mode);
@@ -470,10 +472,11 @@ public class DefaultGeodeticDatum extend
      * @return The WKT element name, which is {@code "DATUM"}.
      */
     @Override
-    public String formatTo(final Formatter formatter) {
+    protected String formatTo(final Formatter formatter) {
         // Do NOT invokes the super-class method, because
         // horizontal datum do not write the datum type.
-        formatter.append(ellipsoid);
+        formatter.append(ellipsoid instanceof FormattableObject ? (FormattableObject) ellipsoid
:
+                         DefaultEllipsoid.castOrCopy(ellipsoid));
         if (bursaWolf != null) {
             for (final BursaWolfParameters candidate : bursaWolf) {
                 if (candidate.isToWGS84()) {

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java?rev=1542821&r1=1542820&r2=1542821&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java
[UTF-8] Sun Nov 17 21:11:10 2013
@@ -224,7 +224,7 @@ public class DefaultImageDatum extends A
      * @return The WKT element name.
      */
     @Override
-    public String formatTo(final Formatter formatter) {
+    protected String formatTo(final Formatter formatter) {
         super.formatTo(formatter);
         formatter.append(pixelInCell);
         formatter.setInvalidWKT("ImageDatum");

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java?rev=1542821&r1=1542820&r2=1542821&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
[UTF-8] Sun Nov 17 21:11:10 2013
@@ -288,8 +288,7 @@ public class DefaultPrimeMeridian extend
      * @return The WKT element name, which is {@code "PRIMEM"}.
      */
     @Override
-    @SuppressWarnings("fallthrough")
-    public String formatTo(final Formatter formatter) {
+    protected String formatTo(final Formatter formatter) {
         /*
          * If the PrimeMeridian is written inside a "GEOGCS", then OGC say that it must be
          * written in the unit of the enclosing geographic coordinate system. Otherwise,

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java?rev=1542821&r1=1542820&r2=1542821&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
[UTF-8] Sun Nov 17 21:11:10 2013
@@ -293,7 +293,7 @@ public class DefaultVerticalDatum extend
      * @return The WKT element name, which is {@code "VERT_DATUM"}.
      */
     @Override
-    public String formatTo(final Formatter formatter) {
+    protected String formatTo(final Formatter formatter) {
         super.formatTo(formatter);
         return "VERT_DATUM";
     }

Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java?rev=1542821&r1=1542820&r2=1542821&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java [UTF-8]
(original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java [UTF-8]
Sun Nov 17 21:11:10 2013
@@ -25,6 +25,7 @@ import org.opengis.parameter.GeneralPara
 import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.ParameterValue;
 import org.opengis.parameter.ParameterValueGroup;
+import org.opengis.referencing.IdentifiedObject;
 import org.opengis.referencing.operation.Matrix;
 import org.apache.sis.geometry.AbstractEnvelope;
 import org.apache.sis.geometry.GeneralDirectPosition;
@@ -38,7 +39,7 @@ import static java.lang.StrictMath.*;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.00)
- * @version 0.3
+ * @version 0.4
  * @module
  */
 public strictfp class Assert extends org.apache.sis.test.Assert {
@@ -282,4 +283,22 @@ public strictfp class Assert extends org
             assertFalse("e1.contains(" + pos + ')', e1.contains(pos));
         }
     }
+
+    /**
+     * Asserts that the WKT of the given object is equal to the expected one. If the given
string contains
+     * {@code '“'} and {@code '”'} characters (for easier reading), then those characters
will be replaced
+     * by "ordinary" quote characters ({@code '"'}).
+     *
+     * @param object The object to format in <cite>Well Known Text</cite> format.
+     * @param expected The expected text, or {@code null} if {@code object} is expected to
be null.
+     */
+    public static void assertWktEquals(final IdentifiedObject object, String expected) {
+        if (expected == null) {
+            assertNull(object);
+        } else {
+            assertNotNull(object);
+            expected = expected.replace('“', '"').replace('”', '"');
+            assertMultilinesEquals(object.getName().getCode(), expected, object.toWKT());
+        }
+    }
 }

Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java?rev=1542821&r1=1542820&r2=1542821&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java
[UTF-8] Sun Nov 17 21:11:10 2013
@@ -28,7 +28,7 @@ import org.apache.sis.test.DependsOnMeth
 import org.junit.Test;
 
 import static java.lang.StrictMath.*;
-import static org.opengis.test.Assert.*;
+import static org.apache.sis.referencing.Assert.*;
 
 
 /**
@@ -149,4 +149,13 @@ public final strictfp class DefaultEllip
         assertEquals("SPHERE", 6371007, sphere.getAuthalicRadius(), 0.0);
         assertEquals("GRS80",  6371007, GRS80 .getAuthalicRadius(), 0.2);
     }
+
+    /**
+     * Tests {@link DefaultEllipsoid#toWKT()}.
+     */
+    @Test
+    public void testToWKT() {
+        final DefaultEllipsoid e = new DefaultEllipsoid(GeodeticDatumMock.WGS84.getEllipsoid());
+        assertWktEquals(e, "SPHEROID[“WGS84”, 6378137.0, 298.257223563]");
+    }
 }

Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java?rev=1542821&r1=1542820&r2=1542821&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
[UTF-8] Sun Nov 17 21:11:10 2013
@@ -32,7 +32,7 @@ import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
-import static org.apache.sis.test.Assert.*;
+import static org.apache.sis.referencing.Assert.*;
 import static org.apache.sis.test.mock.GeodeticDatumMock.*;
 
 
@@ -44,7 +44,11 @@ import static org.apache.sis.test.mock.G
  * @version 0.4
  * @module
  */
-@DependsOn({DefaultEllipsoidTest.class, BursaWolfParametersTest.class})
+@DependsOn({
+  DefaultPrimeMeridianTest.class,
+  DefaultEllipsoidTest.class,
+  BursaWolfParametersTest.class
+})
 public final strictfp class DefaultGeodeticDatumTest extends TestCase {
     /**
      * Tests the creation and serialization of a {@link DefaultGeodeticDatum}.
@@ -148,4 +152,15 @@ public final strictfp class DefaultGeode
         assertEquals("tY", expected.tY, actual.getElement(1, 3), tolerance);
         assertEquals("tZ", expected.tZ, actual.getElement(2, 3), tolerance);
     }
+
+    /**
+     * Tests {@link DefaultEllipsoid#toWKT()}.
+     */
+    @Test
+    public void testToWKT() {
+        final DefaultGeodeticDatum datum = new DefaultGeodeticDatum(WGS84);
+        assertWktEquals(datum,
+                "DATUM[“WGS84”,\n" +
+                "  SPHEROID[“WGS84”, 6378137.0, 298.257223563]]");
+    }
 }

Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java?rev=1542821&r1=1542820&r2=1542821&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
[UTF-8] Sun Nov 17 21:11:10 2013
@@ -1,19 +1,18 @@
 /*
- *    Geotoolkit.org - An Open Source Java GIS Toolkit
- *    http://www.geotoolkit.org
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
- *    (C) 2011-2012, Open Source Geospatial Foundation (OSGeo)
- *    (C) 2011-2012, Geomatys
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License as published by the Free Software Foundation;
- *    version 2.1 of the License.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.sis.referencing.datum;
 
@@ -24,7 +23,7 @@ import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
-import static org.junit.Assert.*;
+import static org.apache.sis.referencing.Assert.*;
 import static java.util.Collections.singletonMap;
 
 
@@ -64,4 +63,17 @@ public final strictfp class DefaultVerti
         typeField.set(datum, null);
         return datum.getVerticalDatumType();
     }
+
+    /**
+     * Tests {@link DefaultVerticalDatum#toWKT()}.
+     */
+    @Test
+    public void testToWKT() {
+        DefaultVerticalDatum datum;
+        datum = new DefaultVerticalDatum(singletonMap(DefaultVerticalDatum.NAME_KEY, "Geoidal"),
VerticalDatumType.GEOIDAL);
+        assertWktEquals(datum, "VERT_DATUM[“Geoidal”, 2005]");
+
+        datum = new DefaultVerticalDatum(singletonMap(DefaultVerticalDatum.NAME_KEY, "Ellipsoidal"),
VerticalDatumTypes.ELLIPSOIDAL);
+        assertWktEquals(datum, "VERT_DATUM[“Ellipsoidal”, 2002]");
+    }
 }

Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1542821&r1=1542820&r2=1542821&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] Sun Nov 17 21:11:10 2013
@@ -52,6 +52,7 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.datum.BursaWolfParametersTest.class,
     org.apache.sis.referencing.datum.TimeDependentBWPTest.class,
     org.apache.sis.referencing.datum.DefaultEllipsoidTest.class,
+    org.apache.sis.referencing.datum.DefaultPrimeMeridianTest.class,
     org.apache.sis.referencing.datum.DefaultVerticalDatumTest.class,
     org.apache.sis.referencing.datum.DefaultGeodeticDatumTest.class,
     org.apache.sis.referencing.StandardDefinitionsTest.class,



Mime
View raw message