sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1569683 - in /sis/branches/JDK7/core: sis-metadata/src/main/java/org/apache/sis/io/wkt/ sis-referencing/src/main/java/org/apache/sis/referencing/ sis-referencing/src/main/java/org/apache/sis/referencing/crs/ sis-referencing/src/main/java/o...
Date Wed, 19 Feb 2014 11:08:49 GMT
Author: desruisseaux
Date: Wed Feb 19 11:08:49 2014
New Revision: 1569683

URL: http://svn.apache.org/r1569683
Log:
Modified the Formatter.setContextualUnit method in a way that allow us to set the unit even
when we do not know the quantity type.
Miscallaneous correction in javadoc and added/moved tests.

Added:
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultVerticalCRSTest.java
  (with props)
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultSphericalCSTest.java
      - copied, changed from r1568827, sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCSTest.java
Modified:
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRSTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCSTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java?rev=1569683&r1=1569682&r2=1569683&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
[UTF-8] Wed Feb 19 11:08:49 2014
@@ -17,7 +17,7 @@
 package org.apache.sis.io.wkt;
 
 import java.util.Map;
-import java.util.IdentityHashMap;
+import java.util.HashMap;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -34,8 +34,6 @@ import javax.measure.unit.SI;
 import javax.measure.unit.NonSI;
 import javax.measure.unit.Unit;
 import javax.measure.unit.UnitFormat;
-import javax.measure.quantity.Angle;
-import javax.measure.quantity.Length;
 import javax.measure.quantity.Quantity;
 
 import org.opengis.util.InternationalString;
@@ -80,7 +78,7 @@ import org.apache.sis.metadata.iso.exten
  *
  * <ul>
  *   <li>A series of {@code append(…)} methods to be invoked by the {@code formatTo(Formatter)}
implementations.</li>
- *   <li>Contextual information. In particular, the {@linkplain #getContextualUnit(Class)
contextual units} depend on
+ *   <li>Contextual information. In particular, the {@linkplain #toContextualUnit(Unit)
contextual units} depend on
  *       the {@linkplain #getEnclosingElement(int) enclosing WKT element}.</li>
  *   <li>A flag for declaring the object unformattable.</li>
  * </ul>
@@ -172,10 +170,10 @@ public class Formatter implements Locali
      * This value is set for example by {@code "GEOGCS"}, which force its enclosing {@code
"PRIMEM"}
      * to take the same units than itself.
      *
-     * @see #getContextualUnit(Class)
-     * @see #setContextualUnit(Class, Unit)
+     * @see #addContextualUnit(Unit)
+     * @see #toContextualUnit(Unit)
      */
-    private final Map<Class<? extends Quantity>, Unit<?>> units = new IdentityHashMap<>(4);
+    private final Map<Unit<?>, Unit<?>> units = new HashMap<>(4);
 
     /**
      * A bits mask of elements which defined a contextual units.
@@ -1200,14 +1198,13 @@ public class Formatter implements Locali
     /**
      * Returns {@code true} if the element at the given depth specified a contextual unit.
      * This method returns {@code true} if the formattable object given by {@code getEnclosingElement(depth)}
-     * has invoked {@link #setContextualUnit(Class, Unit) setContextualUnit(…)} with a
non-null unit at least once.
+     * has invoked {@link #addContextualUnit(Unit)} with a non-null unit at least once.
      *
      * {@note The main purpose of this method is to allow <code>AXIS[…]</code>
elements to determine if they should
      *        inherit the unit specified by the enclosing CRS, or if they should specify
their unit explicitly.}
      *
      * @param  depth 1 for the immediate parent, 2 for the parent of the parent, <i>etc.</i>
-     * @return Whether the parent element at the given depth has invoked {@code setContextualUnit(…)}
-     *         with a non-null unit at least once.
+     * @return Whether the parent element at the given depth has invoked {@code addContextualUnit(…)}
at least once.
      */
     public boolean hasContextualUnit(final int depth) {
         ArgumentChecks.ensurePositive("depth", depth);
@@ -1215,69 +1212,57 @@ public class Formatter implements Locali
     }
 
     /**
-     * Returns the unit for expressing measurements of the given quantity, or {@code null}
for the default unit
-     * of each WKT element. If {@code null}, then the default value depends on the object
to format.
+     * Adds a unit to use for the next measurements of the quantity {@code Q}. The given
unit will apply to
+     * all WKT elements containing a value of quantity {@code Q} without their own {@code
UNIT[…]} element,
+     * until the {@link #removeContextualUnit(Unit)} method is invoked with a unit of the
same quantity.
      *
-     * <p>This method may return a non-null value if the next WKT elements to format
are enclosed in a larger WKT
-     * element, and the child elements shall inherit the unit of the enclosing element. A
typical case is
-     * the angular unit of the {@code PRIMEM[…]} element enclosed in a {@code GEOGCS[…]}
element.</p>
-     *
-     * <p>The value returned by this method can be ignored if the WKT element to format
contains an explicit
-     * {@code UNIT[…]} element.</p>
-     *
-     * @param  <Q> The compile-time type of the {@code quantity} argument.
-     * @param  quantity The quantity, typically as <code>{@linkplain Angle}.class</code>
or
-     *         <code>{@linkplain Length}.class</code>.
-     * @return The unit for measurements of the given quantity, or {@code null} for the default
unit.
+     * <p>If the given unit is null, then this method does nothing and returns {@code
null}.</p>
+     *
+     * {@section Special case}
+     * If the WKT conventions are {@code WKT1_COMMON_UNITS}, then this method ignores the
given unit
+     * and returns {@code null}. See {@link Convention#WKT1_COMMON_UNITS} javadoc for more
information.
+     *
+     * @param  <Q>  The unit quantity.
+     * @param  unit The contextual unit to add, or {@code null} if none.
+     * @return The previous contextual unit for quantity {@code Q}, or {@code null} if none.
      */
     @SuppressWarnings("unchecked")
-    public <Q extends Quantity> Unit<Q> getContextualUnit(final Class<Q>
quantity) {
-        return (Unit<Q>) units.get(quantity);
+    public <Q extends Quantity> Unit<Q> addContextualUnit(final Unit<Q>
unit) {
+        if (unit == null || convention.usesCommonUnits()) {
+            return null;
+        }
+        hasContextualUnit |= 1;
+        return (Unit<Q>) units.put(unit.toSI(), unit);
     }
 
     /**
-     * Sets the unit to use for the next measurements of the given quantity. If non-null,
the given unit will apply
-     * to all WKT elements that do not define their own {@code UNIT[…]}, until this {@code
setUnit(…)} method is
-     * invoked again for the same quantity.
-     *
-     * {@section Special case}
-     * If the WKT conventions are {@code WKT1_COMMON_UNITS}, then this method ignores the
given unit.
-     * See {@link Convention#WKT1_COMMON_UNITS} javadoc for more information.
+     * Removes the unit previously added by a call to {@code addContextualUnit(unit)}.
+     * If the given unit is null, then this method does nothing.
      *
-     * @param  <Q> The compile-time type of the {@code quantity} argument.
-     * @param  quantity The quantity, typically as <code>{@linkplain Angle}.class</code>
or
-     *         <code>{@linkplain Length}.class</code>.
-     * @param unit The new contextual unit, or {@code null} for letting elements use their
own default.
-     */
-    public <Q extends Quantity> void setContextualUnit(final Class<Q> quantity,
final Unit<Q> unit) {
-        ArgumentChecks.ensureNonNull("quantity", quantity);
-        if (!convention.usesCommonUnits()) {
-            if (unit != null) {
-                units.put(quantity, unit);
-                hasContextualUnit |= 1;
-            } else {
-                units.remove(quantity);
-            }
+     * @param unit The contextual unit to remove, or {@code null} if none.
+     */
+    public void removeContextualUnit(final Unit<?> unit) {
+        if (unit != null) {
+            units.remove(unit.toSI());
         }
     }
 
     /**
      * Returns the unit to use instead than the given one, or the given unit if there is
no replacement for it.
-     * This method searches for a unit specified by {@link #setContextualUnit(Class, Unit)}
which
+     * This method searches for a unit specified by {@link #addContextualUnit(Unit)} which
      * {@linkplain Unit#isCompatible(Unit) is compatible} with the given unit.
      *
      * @param  <Q>  The quantity of the unit.
      * @param  unit The unit to replace by the contextual unit, or {@code null}.
      * @return A contextual unit compatible with the given unit, or {@code unit}
-     *         if not contextual unit has been found.
+     *         if no contextual unit has been found.
      */
-    @SuppressWarnings("unchecked")
     public <Q extends Quantity> Unit<Q> toContextualUnit(final Unit<Q>
unit) {
         if (unit != null) {
-            for (final Unit<?> c : units.values()) {
-                if (unit.isCompatible(c)) {
-                    return (Unit<Q>) c;
-                }
+            @SuppressWarnings("unchecked")
+            final Unit<Q> candidate = (Unit<Q>) units.get(unit.toSI());
+            if (candidate != null) {
+                return candidate;
             }
         }
         return unit;

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java?rev=1569683&r1=1569682&r2=1569683&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
[UTF-8] Wed Feb 19 11:08:49 2014
@@ -959,7 +959,7 @@ public class AbstractIdentifiedObject ex
      * For example if this formattable element is for a {@code GeodeticCRS[…]} element,
      * then subclasses shall write the content starting at the insertion point shown below:
      *
-     * <table class="compact">
+     * <p><table class="compact">
      * <tr>
      *   <th>WKT example</th>
      *   <th>Java code example</th>
@@ -975,7 +975,7 @@ public class AbstractIdentifiedObject ex
      *     // ... write the elements at the insertion point ...
      *     return "GeodeticCRS";
      * }
-     * </td></tr></table>
+     * </td></tr></table></p>
      *
      * {@section Formatting non-standard WKT}
      * If the implementation can not represent this object without violating some WKT constraints,

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=1569683&r1=1569682&r2=1569683&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 Feb 19 11:08:49 2014
@@ -418,10 +418,11 @@ public class AbstractCRS extends Abstrac
      */
     @Override
     protected String formatTo(final Formatter formatter) {
-        final String keyword = super.formatTo(formatter);
-        final boolean isWKT1 = formatter.getConvention().versionOfWKT() == 1;
+        final String  keyword = super.formatTo(formatter);
         final CoordinateSystem cs = coordinateSystem;
-        final Unit<?> unit = ReferencingUtilities.getUnit(cs);
+        final boolean isWKT1  = formatter.getConvention().versionOfWKT() == 1;
+        final Unit<?> unit    = ReferencingUtilities.getUnit(cs);
+        final Unit<?> oldUnit = formatter.addContextualUnit(unit);
         formatter.newLine();
         formatter.append(getDatum());
         formatter.newLine();
@@ -442,6 +443,8 @@ public class AbstractCRS extends Abstrac
             formatter.newLine();
             formatter.append(unit);
         }
+        formatter.removeContextualUnit(unit);
+        formatter.addContextualUnit(oldUnit);
         formatter.newLine(); // For writing the ID[…] element on its own line.
         return keyword;
     }

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=1569683&r1=1569682&r2=1569683&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 Feb 19 11:08:49 2014
@@ -18,7 +18,6 @@ package org.apache.sis.referencing.crs;
 
 import java.util.Map;
 import javax.measure.unit.Unit;
-import javax.measure.quantity.Angle;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
@@ -32,7 +31,6 @@ import org.apache.sis.internal.referenci
 import org.apache.sis.internal.referencing.WKTUtilities;
 import org.apache.sis.referencing.AbstractReferenceSystem;
 import org.apache.sis.io.wkt.Formatter;
-import org.apache.sis.measure.Units;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
 
@@ -169,13 +167,9 @@ class DefaultGeodeticCRS extends Abstrac
     @Override
     protected String formatTo(final Formatter formatter) {
         WKTUtilities.appendName(this, formatter, null);
-        final boolean isWKT1 = formatter.getConvention().versionOfWKT() == 1;
-        Unit<Angle>  oldUnit = null; // Previous contextual unit.
-        final Unit<?>   unit = getUnit();
-        if (Units.isAngular(unit)) {
-            oldUnit = formatter.getContextualUnit(Angle.class);
-            formatter.setContextualUnit(Angle.class, unit.asType(Angle.class));
-        }
+        final boolean isWKT1  = formatter.getConvention().versionOfWKT() == 1;
+        final Unit<?> unit    = getUnit();
+        final Unit<?> oldUnit = formatter.addContextualUnit(unit);
         formatter.newLine();
         formatter.append(datum);
         formatter.newLine();
@@ -212,9 +206,8 @@ class DefaultGeodeticCRS extends Abstrac
             formatter.newLine();
             formatter.append(unit);
         }
-        if (unit != null) { // Really 'unit', not 'oldUnit'.
-            formatter.setContextualUnit(Angle.class, oldUnit);
-        }
+        formatter.removeContextualUnit(unit);
+        formatter.addContextualUnit(oldUnit);
         formatter.newLine(); // For writing the ID[…] element on its own line.
         return isWKT1 ? null : "GeodeticCRS";
     }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java?rev=1569683&r1=1569682&r2=1569683&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
[UTF-8] Wed Feb 19 11:08:49 2014
@@ -192,13 +192,9 @@ public class DefaultGeographicCRS extend
     /**
      * Formats this CRS as a <cite>Well Known Text</cite> {@code GeodeticCRS[…]}
element.
      *
-     * <blockquote><font size="-1"><b>Example: Well-Known Text of a geographic
coordinate reference system
-     * using the WGS 84 datum.</b>
-     * <table class="compact">
-     * <tr>
-     *   <th>WKT 2</th>
-     *   <th>WKT 1</th>
-     * </tr><tr><td>
+     * <blockquote><font size="-1"><b>Example:</b> Well-Known Text
(version 2)
+     * of a geographic coordinate reference system using the WGS 84 datum.
+     *
      * {@preformat wkt
      *   GeodeticCRS["WGS 84",
      *      Datum["World Geodetic System 1984",
@@ -213,7 +209,9 @@ public class DefaultGeographicCRS extend
      *      Scope["Used by GPS satellite navigation system."]
      *      Id["EPSG", 4326, Citation["OGP"], URI["urn:ogc:def:crs:EPSG::4326"]]]
      * }
-     * </td><td>
+     *
+     * <p>Same coordinate reference system using WKT 1.</p>
+     *
      * {@preformat wkt
      *   GEOGCS["WGS 84"
      *      DATUM["World Geodetic System 1984"
@@ -224,7 +222,6 @@ public class DefaultGeographicCRS extend
      *      AXIS["Longitude", EAST],
      *      AUTHORITY["EPSG", "4326"]]
      * }
-     * </td></tr></table>
      * </font></blockquote>
      *
      * @return {@code "GeodeticCRS"} (WKT 2) or {@code "GeogCS"} (WKT 1).

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=1569683&r1=1569682&r2=1569683&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 Feb 19 11:08:49 2014
@@ -499,24 +499,21 @@ public class DefaultGeodeticDatum extend
     /**
      * Formats this datum as a <cite>Well Known Text</cite> {@code Datum[…]}
element.
      *
-     * <blockquote><font size="-1"><b>Example: Well-Known Text of a WGS
84 datum.</b>
-     * <table class="compact">
-     * <tr>
-     *   <th>WKT 2</th>
-     *   <th>WKT 1</th>
-     * </tr><tr><td>
+     * <blockquote><font size="-1"><b>Example:</b> Well-Known Text
of a WGS 84 datum.
+     *
      * {@preformat wkt
      *      Datum["World Geodetic System 1984",
      *        Ellipsoid["WGS84", 6378137.0, 298.257223563, LengthUnit["metre", 1]],
      *      Id["EPSG", 6326, Citation["OGP"], URI["urn:ogc:def:datum:EPSG::6326"]]]
      * }
-     * </td><td>
+     *
+     * <p>Same datum using WKT 1.</p>
+     *
      * {@preformat wkt
      *      DATUM["World Geodetic System 1984"
      *        SPHEROID["WGS84", 6378137.0, 298.257223563],
      *      AUTHORITY["EPSG", "6326"]]
      * }
-     * </td></tr></table>
      * </font></blockquote>
      *
      * @return {@code "Datum"}.

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=1569683&r1=1569682&r2=1569683&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 Feb 19 11:08:49 2014
@@ -341,10 +341,7 @@ public class DefaultPrimeMeridian extend
         super.formatTo(formatter);
         final Convention convention = formatter.getConvention();
         final boolean isWKT1 = convention.versionOfWKT() == 1;
-        Unit<Angle> targetUnit = formatter.getContextualUnit(Angle.class);
-        if (targetUnit == null) {
-            targetUnit = NonSI.DEGREE_ANGLE;
-        }
+        final Unit<Angle> targetUnit = formatter.toContextualUnit(NonSI.DEGREE_ANGLE);
         formatter.append(isWKT1 ? getGreenwichLongitude(targetUnit) : greenwichLongitude);
         if (isWKT1) {
             return "PrimeM";

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java?rev=1569683&r1=1569682&r2=1569683&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
[UTF-8] Wed Feb 19 11:08:49 2014
@@ -21,11 +21,13 @@ import org.opengis.referencing.cs.Ellips
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.apache.sis.referencing.cs.AxesConvention;
 import org.apache.sis.referencing.CommonCRS;
+import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
-import static org.apache.sis.test.Assert.*;
+import static org.apache.sis.test.MetadataAssert.*;
 
 
 /**
@@ -83,4 +85,67 @@ public final strictfp class DefaultGeogr
         assertSame("latitude",  ref.getAxis(0), cs.getAxis(1));
         assertSame("height",    ref.getAxis(2), cs.getAxis(2));
     }
+
+    /**
+     * Tests WKT 1 formatting.
+     */
+    @Test
+    public void testWKT1() {
+        assertWktEquals(Convention.WKT1,
+                "GEOGCS[“WGS 84”,\n" +
+                "  DATUM[“World Geodetic System 1984”,\n" +
+                "    SPHEROID[“WGS84”, 6378137.0, 298.257223563]],\n" +
+                "  PRIMEM[“Greenwich”, 0.0],\n" +
+                "  UNIT[“degree”, 0.017453292519943295],\n" +
+                "  AXIS[“Longitude”, EAST],\n" +
+                "  AXIS[“Latitude”, NORTH]]",
+                HardCodedCRS.WGS84);
+    }
+
+    /**
+     * Tests WKT 2 formatting.
+     */
+    @Test
+    @DependsOnMethod("testWKT1")
+    public void testWKT2() {
+        assertWktEquals(Convention.WKT2,
+                "GeodeticCRS[“WGS 84”,\n" +
+                "  Datum[“World Geodetic System 1984”,\n" +
+                "    Ellipsoid[“WGS84”, 6378137.0, 298.257223563, LengthUnit[“metre”,
1]]],\n" +
+                "  PrimeMeridian[“Greenwich”, 0.0, AngleUnit[“degree”, 0.017453292519943295]],\n"
+
+                "  CS[“ellipsoidal”, 2],\n" +
+                "    Axis[“Longitude (λ)”, east],\n" +
+                "    Axis[“Latitude (φ)”, north],\n" +
+                "    AngleUnit[“degree”, 0.017453292519943295],\n" +
+                "  Area[“World”],\n" +
+                "  BBox[-90.00, -180.00, 90.00, 180.00]]",
+                HardCodedCRS.WGS84);
+
+        assertWktEquals(Convention.WKT2_SIMPLIFIED,
+                "GeodeticCRS[“WGS 84”,\n" +
+                "  Datum[“World Geodetic System 1984”,\n" +
+                "    Ellipsoid[“WGS84”, 6378137.0, 298.257223563]],\n" +
+                "  PrimeMeridian[“Greenwich”, 0.0],\n" +
+                "  CS[“ellipsoidal”, 2],\n" +
+                "    Axis[“Longitude (λ)”, east],\n" +
+                "    Axis[“Latitude (φ)”, north],\n" +
+                "    Unit[“degree”, 0.017453292519943295],\n" +
+                "  Area[“World”],\n" +
+                "  BBox[-90.00, -180.00, 90.00, 180.00]]",
+                HardCodedCRS.WGS84);
+
+        assertWktEquals(Convention.INTERNAL,
+                "GeodeticCRS[“WGS 84”,\n" +
+                "  Datum[“World Geodetic System 1984”,\n" +
+                "    Ellipsoid[“WGS84”, 6378137.0, 298.257223563],\n" +
+                "    Id[“EPSG”, 6326]],\n" +
+                "  PrimeMeridian[“Greenwich”, 0.0, Id[“EPSG”, 8901]],\n" +
+                "  CS[“ellipsoidal”, 2],\n" +
+                "    Axis[“Geodetic longitude (λ)”, east],\n" +
+                "    Axis[“Geodetic latitude (φ)”, north],\n" +
+                "    Unit[“degree”, 0.017453292519943295],\n" +
+                "  Area[“World”],\n" +
+                "  BBox[-90.00, -180.00, 90.00, 180.00]]",
+                HardCodedCRS.WGS84);
+    }
 }

Added: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultVerticalCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultVerticalCRSTest.java?rev=1569683&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultVerticalCRSTest.java
(added)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultVerticalCRSTest.java
[UTF-8] Wed Feb 19 11:08:49 2014
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.referencing.crs;
+
+import org.apache.sis.io.wkt.Convention;
+import org.apache.sis.test.DependsOnMethod;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.apache.sis.test.MetadataAssert.*;
+
+
+/**
+ * Tests {@link DefaultVerticalCRS}.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4
+ * @version 0.4
+ * @module
+ */
+public final strictfp class DefaultVerticalCRSTest extends TestCase {
+    /**
+     * Tests WKT 1 formatting.
+     */
+    @Test
+    public void testWKT1() {
+        assertWktEquals(Convention.WKT1,
+                "VERT_CS[“Depth”,\n" +
+                "  VERT_DATUM[“Mean Sea Level”, 2005],\n" +
+                "  UNIT[“metre”, 1],\n" +
+                "  AXIS[“Depth”, DOWN]]",
+                HardCodedCRS.DEPTH);
+    }
+
+    /**
+     * Tests WKT 2 formatting.
+     */
+    @Test
+    @DependsOnMethod("testWKT1")
+    public void testWKT2() {
+        assertWktEquals(Convention.WKT2,
+                "VerticalCRS[“Depth”,\n" +
+                "  VerticalDatum[“Mean Sea Level”],\n" +
+                "  CS[“vertical”, 1],\n" +
+                "  Axis[“Depth (D)”, down],\n" +
+                "  LengthUnit[“metre”, 1]]",
+                HardCodedCRS.DEPTH);
+    }
+}

Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultVerticalCRSTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultVerticalCRSTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRSTest.java?rev=1569683&r1=1569682&r2=1569683&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRSTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRSTest.java
[UTF-8] Wed Feb 19 11:08:49 2014
@@ -17,12 +17,11 @@
 package org.apache.sis.referencing.crs;
 
 import org.opengis.test.ValidatorContainer;
-import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.test.TestCase;
 import org.apache.sis.test.DependsOn;
 import org.junit.Test;
 
-import static org.apache.sis.test.MetadataAssert.*;
+import static org.apache.sis.test.Assert.*;
 import static org.apache.sis.referencing.crs.HardCodedCRS.*;
 
 
@@ -69,62 +68,6 @@ public final strictfp class HardCodedCRS
     }
 
     /**
-     * Tests WKT formatting.
-     */
-    @Test
-    public void testWKT() {
-        assertWktEquals(Convention.WKT1,
-                "GEOGCS[“WGS 84”,\n" +
-                "  DATUM[“World Geodetic System 1984”,\n" +
-                "    SPHEROID[“WGS84”, 6378137.0, 298.257223563]],\n" +
-                "  PRIMEM[“Greenwich”, 0.0],\n" +
-                "  UNIT[“degree”, 0.017453292519943295],\n" +
-                "  AXIS[“Longitude”, EAST],\n" +
-                "  AXIS[“Latitude”, NORTH]]",
-                WGS84);
-
-        assertWktEquals(Convention.WKT2,
-                "GeodeticCRS[“WGS 84”,\n" +
-                "  Datum[“World Geodetic System 1984”,\n" +
-                "    Ellipsoid[“WGS84”, 6378137.0, 298.257223563, LengthUnit[“metre”,
1]]],\n" +
-                "  PrimeMeridian[“Greenwich”, 0.0, AngleUnit[“degree”, 0.017453292519943295]],\n"
+
-                "  CS[“ellipsoidal”, 2],\n" +
-                "    Axis[“Longitude (λ)”, east],\n" +
-                "    Axis[“Latitude (φ)”, north],\n" +
-                "    AngleUnit[“degree”, 0.017453292519943295],\n" +
-                "  Area[“World”],\n" +
-                "  BBox[-90.00, -180.00, 90.00, 180.00]]",
-                WGS84);
-
-        assertWktEquals(Convention.WKT2_SIMPLIFIED,
-                "GeodeticCRS[“WGS 84”,\n" +
-                "  Datum[“World Geodetic System 1984”,\n" +
-                "    Ellipsoid[“WGS84”, 6378137.0, 298.257223563]],\n" +
-                "  PrimeMeridian[“Greenwich”, 0.0],\n" +
-                "  CS[“ellipsoidal”, 2],\n" +
-                "    Axis[“Longitude (λ)”, east],\n" +
-                "    Axis[“Latitude (φ)”, north],\n" +
-                "    Unit[“degree”, 0.017453292519943295],\n" +
-                "  Area[“World”],\n" +
-                "  BBox[-90.00, -180.00, 90.00, 180.00]]",
-                WGS84);
-
-        assertWktEquals(Convention.INTERNAL,
-                "GeodeticCRS[“WGS 84”,\n" +
-                "  Datum[“World Geodetic System 1984”,\n" +
-                "    Ellipsoid[“WGS84”, 6378137.0, 298.257223563],\n" +
-                "    Id[“EPSG”, 6326]],\n" +
-                "  PrimeMeridian[“Greenwich”, 0.0, Id[“EPSG”, 8901]],\n" +
-                "  CS[“ellipsoidal”, 2],\n" +
-                "    Axis[“Geodetic longitude (λ)”, east],\n" +
-                "    Axis[“Geodetic latitude (φ)”, north],\n" +
-                "    Unit[“degree”, 0.017453292519943295],\n" +
-                "  Area[“World”],\n" +
-                "  BBox[-90.00, -180.00, 90.00, 180.00]]",
-                WGS84);
-    }
-
-    /**
      * Tests serialization.
      */
     @Test

Copied: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultSphericalCSTest.java
(from r1568827, sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCSTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultSphericalCSTest.java?p2=sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultSphericalCSTest.java&p1=sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCSTest.java&r1=1568827&r2=1569683&rev=1569683&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCSTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultSphericalCSTest.java
[UTF-8] Wed Feb 19 11:08:49 2014
@@ -17,10 +17,8 @@
 package org.apache.sis.referencing.cs;
 
 import java.util.Collections;
-import org.opengis.test.Validators;
 import org.apache.sis.test.TestCase;
 import org.apache.sis.test.DependsOn;
-import org.apache.sis.test.DependsOnMethod;
 import org.junit.Test;
 
 import static org.apache.sis.test.Assert.*;
@@ -28,86 +26,19 @@ import static org.apache.sis.referencing
 
 
 /**
- * Validates the {@link HardCodedCS} definitions.
+ * Tests {@link DefaultSphericalCS}.
  *
- * @author  Martin Desruisseaux (IRD, Geomatys)
- * @since   0.4 (derived from geotk-2.4)
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4
  * @version 0.4
  * @module
  */
-@DependsOn({
-    DefaultCartesianCSTest.class,
-    DefaultEllipsoidalCSTest.class
-})
-public final strictfp class HardCodedCSTest extends TestCase {
-    /**
-     * Validates constants.
-     */
-    @Test
-    public void validate() {
-        Validators.validate(PROJECTED);
-        Validators.validate(GEOCENTRIC);
-        Validators.validate(CARTESIAN_2D);
-        Validators.validate(CARTESIAN_3D);
-        Validators.validate(GRID);
-        Validators.validate(DISPLAY);
-        Validators.validate(GEODETIC_2D);
-        Validators.validate(GEODETIC_3D);
-        Validators.validate(ELLIPSOIDAL_HEIGHT);
-        Validators.validate(GRAVITY_RELATED_HEIGHT);
-        Validators.validate(DEPTH);
-        Validators.validate(DAYS);
-        Validators.validate(SECONDS);
-        Validators.validate(MILLISECONDS);
-        Validators.validate(SPHERICAL);
-    }
-
-    /**
-     * Tests the dimensions of some hard-coded coordinate systems.
-     */
-    @Test
-    public void testDimensions() {
-        assertEquals("Cartesian 2D",   2, PROJECTED  .getDimension());
-        assertEquals("Cartesian 3D",   3, GEOCENTRIC .getDimension());
-        assertEquals("Ellipsoidal 2D", 2, GEODETIC_2D.getDimension());
-        assertEquals("Ellipsoidal 3D", 3, GEODETIC_3D.getDimension());
-        assertEquals("Vertical",       1, DEPTH      .getDimension());
-        assertEquals("Temporal",       1, DAYS       .getDimension());
-    }
-
-    /**
-     * Tests serialization of various objects.
-     */
-    @Test
-    public void testSerialization() {
-        assertSerializedEquals(PROJECTED);
-        assertSerializedEquals(GEOCENTRIC);
-        assertSerializedEquals(GEODETIC_2D);
-        assertSerializedEquals(GEODETIC_3D);
-    }
-
-    /**
-     * Verifies that some definitions are already normalized.
-     */
-    @Test
-    public void testNormalized() {
-        AbstractCS cs;
-        cs = GRID;               assertSame(cs, cs.forConvention(AxesConvention.NORMALIZED));
-        cs = GEOCENTRIC;         assertSame(cs, cs.forConvention(AxesConvention.NORMALIZED));
-        cs = CARTESIAN_2D;       assertSame(cs, cs.forConvention(AxesConvention.NORMALIZED));
-        cs = CARTESIAN_3D;       assertSame(cs, cs.forConvention(AxesConvention.NORMALIZED));
-        cs = PROJECTED;          assertSame(cs, cs.forConvention(AxesConvention.NORMALIZED));
-        cs = GEODETIC_2D;        assertSame(cs, cs.forConvention(AxesConvention.NORMALIZED));
-        cs = GEODETIC_3D;        assertSame(cs, cs.forConvention(AxesConvention.NORMALIZED));
-        cs = DAYS;               assertSame(cs, cs.forConvention(AxesConvention.NORMALIZED));
-        cs = ELLIPSOIDAL_HEIGHT; assertSame(cs, cs.forConvention(AxesConvention.NORMALIZED));
-    }
-
+@DependsOn(AbstractCSTest.class)
+public final strictfp class DefaultSphericalCSTest extends TestCase {
     /**
      * Tests the normalization of a coordinate system.
      */
     @Test
-    @DependsOnMethod("testNormalized")
     public void testNormalize() {
         final AbstractCS normalized = SPHERICAL.forConvention(AxesConvention.NORMALIZED);
         assertNotSame(SPHERICAL, normalized);

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCSTest.java?rev=1569683&r1=1569682&r2=1569683&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCSTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCSTest.java
[UTF-8] Wed Feb 19 11:08:49 2014
@@ -16,11 +16,9 @@
  */
 package org.apache.sis.referencing.cs;
 
-import java.util.Collections;
 import org.opengis.test.Validators;
 import org.apache.sis.test.TestCase;
 import org.apache.sis.test.DependsOn;
-import org.apache.sis.test.DependsOnMethod;
 import org.junit.Test;
 
 import static org.apache.sis.test.Assert.*;
@@ -102,20 +100,4 @@ public final strictfp class HardCodedCST
         cs = DAYS;               assertSame(cs, cs.forConvention(AxesConvention.NORMALIZED));
         cs = ELLIPSOIDAL_HEIGHT; assertSame(cs, cs.forConvention(AxesConvention.NORMALIZED));
     }
-
-    /**
-     * Tests the normalization of a coordinate system.
-     */
-    @Test
-    @DependsOnMethod("testNormalized")
-    public void testNormalize() {
-        final AbstractCS normalized = SPHERICAL.forConvention(AxesConvention.NORMALIZED);
-        assertNotSame(SPHERICAL, normalized);
-        assertEquals(new DefaultSphericalCS(
-            Collections.singletonMap(AbstractCS.NAME_KEY, "Spherical CS: East (deg), North
(deg), Up (m)."),
-            HardCodedAxes.SPHERICAL_LONGITUDE,
-            HardCodedAxes.SPHERICAL_LATITUDE,
-            HardCodedAxes.GEOCENTRIC_RADIUS
-        ), normalized);
-    }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1569683&r1=1569682&r2=1569683&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] Wed Feb 19 11:08:49 2014
@@ -65,12 +65,14 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.cs.AbstractCSTest.class,
     org.apache.sis.referencing.cs.DefaultCartesianCSTest.class,
     org.apache.sis.referencing.cs.DefaultEllipsoidalCSTest.class,
+    org.apache.sis.referencing.cs.DefaultSphericalCSTest.class,
     org.apache.sis.referencing.cs.DefaultCompoundCSTest.class,
     org.apache.sis.referencing.cs.CoordinateSystemsTest.class,
     org.apache.sis.referencing.cs.HardCodedCSTest.class,
     org.apache.sis.referencing.crs.AbstractCRSTest.class,
     org.apache.sis.referencing.crs.DefaultGeodeticCRSTest.class,
     org.apache.sis.referencing.crs.DefaultGeographicCRSTest.class,
+    org.apache.sis.referencing.crs.DefaultVerticalCRSTest.class,
     org.apache.sis.referencing.crs.SubTypesTest.class,
     org.apache.sis.referencing.crs.DefaultCompoundCRSTest.class,
     org.apache.sis.referencing.crs.HardCodedCRSTest.class,



Mime
View raw message