sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1568259 - in /sis/branches/JDK7/core: sis-metadata/src/main/java/org/apache/sis/io/wkt/ sis-metadata/src/test/java/org/apache/sis/io/wkt/ sis-referencing/src/main/java/org/apache/sis/internal/referencing/ sis-referencing/src/main/java/org/...
Date Fri, 14 Feb 2014 12:47:20 GMT
Author: desruisseaux
Date: Fri Feb 14 12:47:19 2014
New Revision: 1568259

URL: http://svn.apache.org/r1568259
Log:
Added check for coordinate system validity, more conformant code list, and documentation fixes.

Modified:
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/FormatterTest.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultVerticalCS.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/DefaultCoordinateSystemAxisTest.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=1568259&r1=1568258&r2=1568259&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] Fri Feb 14 12:47:19 2014
@@ -55,6 +55,7 @@ import org.opengis.util.CodeList;
 
 import org.apache.sis.measure.Units;
 import org.apache.sis.math.DecimalFunctions;
+import org.apache.sis.util.iso.Types;
 import org.apache.sis.util.Debug;
 import org.apache.sis.util.Classes;
 import org.apache.sis.util.Numbers;
@@ -833,7 +834,7 @@ public class Formatter implements Locali
         if (code != null) {
             appendSeparator();
             setColor(ElementKind.CODE_LIST);
-            buffer.append(code.name());
+            buffer.append(convention.versionOfWKT() == 1 ? code.name() : Types.getCodeName(code));
             resetColor();
         }
     }
@@ -1083,7 +1084,20 @@ public class Formatter implements Locali
         if (value == null) {
             appendSeparator();
             buffer.append("null");
-        } else if (value.getClass().isArray()) {
+        } else if (!appendValue(value) && !appendElement(value)) {
+            append(value.toString(), null);
+        }
+    }
+
+    /**
+     * Tries to append a small unit of information like number, date, boolean, code list,
character string
+     * or an array of those. The key difference between this method and {@link #appendElement(Object)}
is
+     * that the values formatted by this {@code appendValue(Object)} method do not have keyword.
+     *
+     * @return {@code true} on success, or {@code false} if the given type is not recognized.
+     */
+    final boolean appendValue(final Object value) {
+        if (value.getClass().isArray()) {
             appendSeparator();
             buffer.appendCodePoint(symbols.getOpenSequence());
             final int length = Array.getLength(value);
@@ -1099,17 +1113,34 @@ public class Formatter implements Locali
                 append(number.doubleValue());
             }
         }
-        else if (value instanceof CodeList<?>)           append((CodeList<?>)
          value);
-        else if (value instanceof Date)                  append((Date)                  value);
-        else if (value instanceof Boolean)               append((Boolean)               value);
-        else if (value instanceof Unit<?>)               append((Unit<?>)   
           value);
-        else if (value instanceof FormattableObject)     append((FormattableObject)     value);
+        else if (value instanceof CodeList<?>) append((CodeList<?>) value);
+        else if (value instanceof Date)        append((Date)        value);
+        else if (value instanceof Boolean)     append((Boolean)     value);
+        else if (value instanceof CharSequence) {
+            append((value instanceof InternationalString) ?
+                    ((InternationalString) value).toString(locale) : value.toString(), null);
+        } else {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Tries to append an object of the {@code KEYWORD[something]} form. The given value
is typically,
+     * but not necessarily, a {@link FormattableObject} object or an instance of an interface
that can
+     * be converted to {@code FormattableObject}.
+     *
+     * @return {@code true} on success, or {@code false} if the given type is not recognized.
+     */
+    final boolean appendElement(final Object value) {
+             if (value instanceof FormattableObject)     append((FormattableObject)     value);
         else if (value instanceof IdentifiedObject)      append((IdentifiedObject)      value);
         else if (value instanceof GeographicBoundingBox) append((GeographicBoundingBox) value,
BBOX_ACCURACY);
         else if (value instanceof MathTransform)         append((MathTransform)         value);
         else if (value instanceof Matrix)                append((Matrix)                value);
-        else append((value instanceof InternationalString) ?
-                ((InternationalString) value).toString(locale) : value.toString(), null);
+        else if (value instanceof Unit<?>)               append((Unit<?>)   
           value);
+        else return false;
+        return true;
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java?rev=1568259&r1=1568258&r2=1568259&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
[UTF-8] Fri Feb 14 12:47:19 2014
@@ -28,10 +28,7 @@ import java.text.ParsePosition;
 import javax.measure.unit.Unit;
 import javax.measure.unit.UnitFormat;
 import org.opengis.metadata.citation.Citation;
-import org.opengis.metadata.extent.GeographicBoundingBox;
 import org.opengis.referencing.IdentifiedObject;
-import org.opengis.referencing.operation.Matrix;
-import org.opengis.referencing.operation.MathTransform;
 import org.apache.sis.io.CompoundFormat;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.resources.Errors;
@@ -346,9 +343,11 @@ public class WKTFormat extends CompoundF
     }
 
     /**
-     * Formats the specified object as a Well Know Text. The given object shall be an instance
of one of
-     * {@link FormattableObject}, {@link IdentifiedObject}, {@link GeographicBoundingBox},
-     * {@link MathTransform}, {@link Matrix} or {@link Unit}.
+     * Formats the specified object as a Well Know Text. The formatter accepts at least the
following types:
+     * {@link FormattableObject}, {@link IdentifiedObject},
+     * {@link org.opengis.metadata.extent.GeographicBoundingBox},
+     * {@link org.opengis.referencing.operation.MathTransform},
+     * {@link org.opengis.referencing.operation.Matrix} and {@link Unit}.
      *
      * @param  object     The object to format.
      * @param  toAppendTo Where the text is to be appended.
@@ -358,6 +357,8 @@ public class WKTFormat extends CompoundF
      */
     @Override
     public void format(final Object object, final Appendable toAppendTo) throws IOException
{
+        ArgumentChecks.ensureNonNull("object",     object);
+        ArgumentChecks.ensureNonNull("toAppendTo", toAppendTo);
         /*
          * If the given Appendable is not a StringBuffer, creates a temporary StringBuffer.
          * We can not write directly in an arbitrary Appendable because Formatter needs the
@@ -382,28 +383,18 @@ public class WKTFormat extends CompoundF
             updateFormatter(formatter);
             this.formatter = formatter;
         }
+        final boolean valid;
         try {
             formatter.setBuffer(buffer);
-            if (object instanceof FormattableObject) {
-                formatter.append((FormattableObject) object);
-            } else if (object instanceof IdentifiedObject) {
-                formatter.append((IdentifiedObject) object);
-            } else if (object instanceof MathTransform) {
-                formatter.append((MathTransform) object);
-            } else if (object instanceof Matrix) {
-                formatter.append((Matrix) object);
-            } else if (object instanceof GeographicBoundingBox) {
-                formatter.append((GeographicBoundingBox) object, Formatter.BBOX_ACCURACY);
-            } else if (object instanceof Unit<?>) {
-                formatter.append((Unit<?>) object);
-            } else {
-                throw new ClassCastException(Errors.format(
-                        Errors.Keys.IllegalArgumentClass_2, "object", object.getClass()));
-            }
+            valid = formatter.appendElement(object) || formatter.appendValue(object);
         } finally {
             formatter.setBuffer(null);
             formatter.clear();
         }
+        if (!valid) {
+            throw new ClassCastException(Errors.format(
+                    Errors.Keys.IllegalArgumentClass_2, "object", object.getClass()));
+        }
         if (buffer != toAppendTo) {
             toAppendTo.append(buffer);
         }

Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/FormatterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/FormatterTest.java?rev=1568259&r1=1568258&r2=1568259&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/FormatterTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/FormatterTest.java
[UTF-8] Fri Feb 14 12:47:19 2014
@@ -18,7 +18,9 @@ package org.apache.sis.io.wkt;
 
 import javax.measure.unit.SI;
 import javax.measure.unit.NonSI;
+import org.opengis.util.CodeList;
 import org.opengis.referencing.operation.Matrix;
+import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.metadata.extent.GeographicBoundingBox;
 import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
 import org.apache.sis.measure.Units;
@@ -86,4 +88,13 @@ public final strictfp class FormatterTes
         assertWktEquals("ANGLEUNIT[“degree”, 0.017453292519943295]", NonSI.DEGREE_ANGLE);
         assertWktEquals("SCALEUNIT[“parts per million”, 1.0E-6]", Units.PPM);
     }
+
+    /**
+     * Tests (indirectly) {@link Formatter#append(CodeList)}.
+     */
+    @Test
+    public void testAppendCodeList() {
+        assertWktEquals(Convention.WKT2, "northEast",  AxisDirection.NORTH_EAST);
+        assertWktEquals(Convention.WKT1, "NORTH_EAST", AxisDirection.NORTH_EAST);
+    }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java?rev=1568259&r1=1568258&r2=1568259&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java
[UTF-8] Fri Feb 14 12:47:19 2014
@@ -72,7 +72,12 @@ public final class WKTUtilities extends 
      */
     public static void append(GeneralParameterValue parameter, final Formatter formatter)
{
         if (parameter instanceof ParameterValueGroup) {
+            boolean first = true;
             for (final GeneralParameterValue param : ((ParameterValueGroup) parameter).values())
{
+                if (first) {
+                    formatter.newLine();
+                    first = false;
+                }
                 append(param, formatter);
             }
         }
@@ -81,6 +86,7 @@ public final class WKTUtilities extends 
                 parameter = new DefaultParameterValue<>((ParameterValue<?>) parameter);
             }
             formatter.append((FormattableObject) parameter);
+            formatter.newLine();
         }
     }
 }

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=1568259&r1=1568258&r2=1568259&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] Fri Feb 14 12:47:19 2014
@@ -277,8 +277,8 @@ public class AbstractCS extends Abstract
      * <p><b>Note for implementors:</b> since this method is invoked at
construction time, it shall not depend
      * on this object's state. This method is not in public API for that reason.</p>
      *
-     * @param  direction The direction to test for compatibility.
-     * @param  unit The unit to test for compatibility.
+     * @param  direction The direction to test for compatibility (never {@code null}).
+     * @param  unit The unit to test for compatibility (never {@code null}).
      * @return {@link #VALID} if the given direction and unit are compatible with this coordinate
system,
      *         {@link #DIRECTION} if the direction is invalid or {@link #UNIT} if the unit
is invalid.
      */

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java?rev=1568259&r1=1568258&r2=1568259&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java
[UTF-8] Fri Feb 14 12:47:19 2014
@@ -29,7 +29,7 @@ import org.apache.sis.measure.Units;
 
 
 /**
- * A 2- or 3-dimensional coordinate system made of straight axes (not necessarily orthogonal).
+ * A 2- or 3-dimensional coordinate system with straight axes that are not necessarily orthogonal.
  *
  * <table class="sis"><tr>
  *   <th>Used with CRS</th>

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java?rev=1568259&r1=1568258&r2=1568259&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java
[UTF-8] Fri Feb 14 12:47:19 2014
@@ -27,7 +27,7 @@ import org.apache.sis.measure.Angle;
 
 
 /**
- * A 2-, or 3-dimensional Cartesian coordinate system made of straight orthogonal axes.
+ * A 2- or 3-dimensional Cartesian coordinate system made of straight orthogonal axes.
  * All axes shall have the same linear unit of measure.
  *
  * <table class="sis"><tr>

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=1568259&r1=1568258&r2=1568259&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] Fri Feb 14 12:47:19 2014
@@ -737,14 +737,14 @@ public class DefaultCoordinateSystemAxis
      *
      * {@section Constraints for WKT validity}
      * The ISO 19162 specification puts many constraints on axis names, abbreviations and
directions allowed in WKT.
-     * Most of those constraints are inherited from ISO 19111 - see {@link CoordinateSystemAxis}
javadoc for some of
+     * Most of those constraints are inherited from ISO 19111 — see {@link CoordinateSystemAxis}
javadoc for some of
      * those. The current Apache SIS implementation does not verify whether this axis name
and abbreviation are
      * compliant; we assume that the user created a valid axis.
-     * The only exceptions are:
+     * The only verifications performed by this method are:
      *
      * <ul>
-     *   <li>“<cite>Geodetic latitude</cite>” and “<cite>Geodetic
longitude</cite>” name (case insensitive)
-     *       are replaced by “<cite>Latitude</cite>” and “<cite>Longitude</cite>”
respectively.</li>
+     *   <li>Replace “<cite>Geodetic latitude</cite>” and “<cite>Geodetic
longitude</cite>” names (case insensitive)
+     *       by “<cite>Latitude</cite>” and “<cite>Longitude</cite>”
respectively.</li>
      * </ul>
      *
      * @param  formatter The formatter to use.

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java?rev=1568259&r1=1568258&r2=1568259&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
[UTF-8] Fri Feb 14 12:47:19 2014
@@ -24,6 +24,7 @@ import org.opengis.referencing.cs.Ellips
 import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.apache.sis.internal.referencing.AxisDirections;
+import org.apache.sis.util.resources.Errors;
 import org.apache.sis.measure.Units;
 
 
@@ -36,9 +37,6 @@ import org.apache.sis.measure.Units;
  * </tr><tr>
  *   <td>{@linkplain org.apache.sis.referencing.crs.DefaultGeocentricCRS Geographic}</td>
  *   <td>“Geodetic latitude”, “Geodetic longitude”, “Ellipsoidal height”
(if 3D)</td>
- * </tr><tr>
- *   <td>{@linkplain org.apache.sis.referencing.crs.DefaultEngineeringCRS Engineering}</td>
- *   <td>unspecified</td>
  * </tr></table>
  *
  * {@section Immutability and thread safety}
@@ -120,6 +118,13 @@ public class DefaultEllipsoidalCS extend
                                 final CoordinateSystemAxis axis1)
     {
         super(properties, axis0, axis1);
+        for (int i=0; i<2; i++) {
+            final AxisDirection direction = super.getAxis(i).getDirection();
+            if (AxisDirections.isVertical(direction)) {
+                throw new IllegalArgumentException(Errors.format(
+                        Errors.Keys.IllegalAxisDirection_2, "EllipdoicalCS (2D)", direction));
+            }
+        }
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java?rev=1568259&r1=1568258&r2=1568259&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java
[UTF-8] Fri Feb 14 12:47:19 2014
@@ -26,6 +26,14 @@ import org.opengis.referencing.cs.Coordi
 /**
  * A 2- or 3-dimensional coordinate system for any combination of coordinate axes not covered
by other CS types.
  *
+ * <table class="sis"><tr>
+ *   <th>Used with CRS</th>
+ *   <th>Permitted axis names</th>
+ * </tr><tr>
+ *   <td>{@linkplain org.apache.sis.referencing.crs.DefaultEngineeringCRS Engineering}</td>
+ *   <td>unspecified</td>
+ * </tr></table>
+ *
  * {@section Immutability and thread safety}
  * This class is immutable and thus thread-safe if the property <em>values</em>
(not necessarily the map itself)
  * and the {@link CoordinateSystemAxis} instances given to the constructor are also immutable.
Unless otherwise

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultVerticalCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultVerticalCS.java?rev=1568259&r1=1568258&r2=1568259&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultVerticalCS.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultVerticalCS.java
[UTF-8] Fri Feb 14 12:47:19 2014
@@ -17,6 +17,7 @@
 package org.apache.sis.referencing.cs;
 
 import java.util.Map;
+import javax.measure.unit.SI;
 import javax.measure.unit.Unit;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlRootElement;
@@ -46,9 +47,6 @@ import org.apache.sis.internal.referenci
  * </tr><tr>
  *   <td>{@linkplain org.apache.sis.referencing.crs.DefaultVerticalCRS Vertical}</td>
  *   <td>“Gravity-related height” or “Depth”</td>
- * </tr><tr>
- *   <td>{@linkplain org.apache.sis.referencing.crs.DefaultEngineeringCRS Engineering}</td>
- *   <td>unspecified</td>
  * </tr></table>
  *
  * {@section Immutability and thread safety}
@@ -166,16 +164,21 @@ public class DefaultVerticalCS extends A
      * or an {@code INVALID_*} error code otherwise. This method is invoked at construction
time.
      * The current implementation accepts only temporal directions (i.e. {@link AxisDirection#UP}
      * and {@link AxisDirection#DOWN}).
-     *
-     * <p>We currently put no restriction on the unit because it may be linear, temporal
(time
-     * needed for echo to travel), pressure, or dimensionless (sigma-level).</p>
      */
     @Override
-    final int validateAxis(final AxisDirection direction, final Unit<?> unit) {
+    final int validateAxis(final AxisDirection direction, Unit<?> unit) {
         if (!AxisDirection.UP.equals(AxisDirections.absolute(direction))) {
             return INVALID_DIRECTION;
         }
-        return VALID;
+        unit = unit.toSI();
+        if (unit.equals(SI.METRE)   ||  // Most usual case.
+            unit.equals(SI.PASCAL)  ||  // Height or depth estimated by the atmospheric or
ocean pressure.
+            unit.equals(SI.SECOND)  ||  // Depth estimated by the time needed for an echo
to travel.
+            unit.equals(Unit.ONE))      // Sigma-level (percentage from sea surface to ocean
floor).
+        {
+            return VALID;
+        }
+        return INVALID_UNIT;
     }
 
     /**

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=1568259&r1=1568258&r2=1568259&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] Fri Feb 14 12:47:19 2014
@@ -89,8 +89,8 @@ public final strictfp class HardCodedCRS
                 "    SPHEROID[“WGS84”, 6378137.0, 298.257223563]],\n" +
                 "  PRIMEM[“Greenwich”, 0.0],\n" +
                 "  ANGLEUNIT[“degree”, 0.017453292519943295],\n" +
-                "  AXIS[“Longitude (λ)”, EAST],\n" +
-                "  AXIS[“Latitude (φ)”, NORTH],\n" +
+                "  AXIS[“Longitude (λ)”, east],\n" +
+                "  AXIS[“Latitude (φ)”, north],\n" +
                 "  AREA[“World”],\n" +
                 "  BBOX[-90.00, -180.00, 90.00, 180.00]]",
                 WGS84);
@@ -101,8 +101,8 @@ public final strictfp class HardCodedCRS
                 "    SPHEROID[“WGS84”, 6378137.0, 298.257223563]],\n" +
                 "  PRIMEM[“Greenwich”, 0.0],\n" +
                 "  UNIT[“degree”, 0.017453292519943295],\n" +
-                "  AXIS[“Longitude (λ)”, EAST],\n" +
-                "  AXIS[“Latitude (φ)”, NORTH],\n" +
+                "  AXIS[“Longitude (λ)”, east],\n" +
+                "  AXIS[“Latitude (φ)”, north],\n" +
                 "  AREA[“World”],\n" +
                 "  BBOX[-90.00, -180.00, 90.00, 180.00]]",
                 WGS84);
@@ -114,8 +114,8 @@ public final strictfp class HardCodedCRS
                 "    ID[“EPSG”, 6326]],\n" +
                 "  PRIMEM[“Greenwich”, 0.0, ID[“EPSG”, 8901]],\n" +
                 "  UNIT[“degree”, 0.017453292519943295],\n" +
-                "  AXIS[“Geodetic longitude (λ)”, EAST],\n" +
-                "  AXIS[“Geodetic latitude (φ)”, NORTH],\n" +
+                "  AXIS[“Geodetic longitude (λ)”, east],\n" +
+                "  AXIS[“Geodetic latitude (φ)”, north],\n" +
                 "  AREA[“World”],\n" +
                 "  BBOX[-90.00, -180.00, 90.00, 180.00]]",
                 WGS84);

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java?rev=1568259&r1=1568258&r2=1568259&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java
[UTF-8] Fri Feb 14 12:47:19 2014
@@ -84,22 +84,25 @@ public final strictfp class DefaultCoord
      */
     @Test
     public void testWKT() {
-        assertWktEquals("AXIS[“x”, EAST]",                       X);
-        assertWktEquals("AXIS[“y”, NORTH]",                      Y);
-        assertWktEquals("AXIS[“z”, UP]",                         Z);
-        assertWktEquals("AXIS[“Longitude (λ)”, EAST]",           LONGITUDE_gon);
-        assertWktEquals("AXIS[“Latitude (φ)”, NORTH]",           LATITUDE_gon);
-        assertWktEquals("AXIS[“Altitude (h)”, UP]",              ALTITUDE);
-        assertWktEquals("AXIS[“Time (t)”, FUTURE]",              TIME);
-        assertWktEquals("AXIS[“Longitude (λ)”, EAST]",           GEODETIC_LONGITUDE);
-        assertWktEquals("AXIS[“Spherical longitude (Ω)”, EAST]", SPHERICAL_LONGITUDE);
-        assertWktEquals("AXIS[“Latitude (φ)”, NORTH]",           GEODETIC_LATITUDE);
-        assertWktEquals("AXIS[“Spherical latitude (Θ)”, NORTH]", SPHERICAL_LATITUDE);
+        assertWktEquals("AXIS[“x”, east]",                       X);
+        assertWktEquals("AXIS[“y”, north]",                      Y);
+        assertWktEquals("AXIS[“z”, up]",                         Z);
+        assertWktEquals("AXIS[“Longitude (λ)”, east]",           LONGITUDE_gon);
+        assertWktEquals("AXIS[“Latitude (φ)”, north]",           LATITUDE_gon);
+        assertWktEquals("AXIS[“Altitude (h)”, up]",              ALTITUDE);
+        assertWktEquals("AXIS[“Time (t)”, future]",              TIME);
+        assertWktEquals("AXIS[“Longitude (λ)”, east]",           GEODETIC_LONGITUDE);
+        assertWktEquals("AXIS[“Spherical longitude (Ω)”, east]", SPHERICAL_LONGITUDE);
+        assertWktEquals("AXIS[“Latitude (φ)”, north]",           GEODETIC_LATITUDE);
+        assertWktEquals("AXIS[“Spherical latitude (Θ)”, north]", SPHERICAL_LATITUDE);
 
-        assertWktEquals(Convention.INTERNAL, "AXIS[“Geodetic longitude (λ)”, EAST]",
 GEODETIC_LONGITUDE);
-        assertWktEquals(Convention.INTERNAL, "AXIS[“Spherical longitude (Ω)”, EAST]",
SPHERICAL_LONGITUDE);
-        assertWktEquals(Convention.INTERNAL, "AXIS[“Geodetic latitude (φ)”, NORTH]",
 GEODETIC_LATITUDE);
-        assertWktEquals(Convention.INTERNAL, "AXIS[“Spherical latitude (Θ)”, NORTH]",
SPHERICAL_LATITUDE);
+        assertWktEquals(Convention.WKT1,     "AXIS[“x”, EAST]",                     
 X);
+        assertWktEquals(Convention.WKT1,     "AXIS[“y”, NORTH]",                    
 Y);
+        assertWktEquals(Convention.WKT1,     "AXIS[“z”, UP]",                       
 Z);
+        assertWktEquals(Convention.INTERNAL, "AXIS[“Geodetic longitude (λ)”, east]",
 GEODETIC_LONGITUDE);
+        assertWktEquals(Convention.INTERNAL, "AXIS[“Spherical longitude (Ω)”, east]",
SPHERICAL_LONGITUDE);
+        assertWktEquals(Convention.INTERNAL, "AXIS[“Geodetic latitude (φ)”, north]",
 GEODETIC_LATITUDE);
+        assertWktEquals(Convention.INTERNAL, "AXIS[“Spherical latitude (Θ)”, north]",
SPHERICAL_LATITUDE);
     }
 
     /**



Mime
View raw message