sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1558364 - in /sis/branches/JDK7/core: sis-referencing/src/main/java/org/apache/sis/internal/referencing/ sis-referencing/src/main/java/org/apache/sis/referencing/cs/ sis-referencing/src/test/java/org/apache/sis/geometry/ sis-referencing/sr...
Date Wed, 15 Jan 2014 12:47:13 GMT
Author: desruisseaux
Date: Wed Jan 15 12:47:12 2014
New Revision: 1558364

URL: http://svn.apache.org/r1558364
Log:
Moved AbstractCS.forUnit(...) to the internal implementation of AxesConvention.NORMALIZED.
If we want to provide the functionality of 'forUnit' in public API in a future SIS version,
we will be better to do that in an ReferencingObjectBuilder class instead.

Modified:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.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/AxesConvention.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/Normalizer.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/SubEnvelopeTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/AbstractCSTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CommonAxes.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/NormalizerTest.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
    sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java?rev=1558364&r1=1558363&r2=1558364&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java [UTF-8] Wed Jan 15 12:47:12 2014
@@ -184,6 +184,19 @@ public final class AxisDirections extend
     }
 
     /**
+     * Returns {@code true} if the specified direction is an inter-cardinal direction.
+     * Inter-cardinal directions are {@code NORTH_EAST}, {@code SOUTH_SOUTH_EAST}, etc.
+     *
+     * @param  dir The direction to test, or {@code null}.
+     * @return {@code true} if the given direction is an inter-cardinal direction.
+     */
+    public static boolean isIntercardinal(final AxisDirection dir) {
+        if (dir == null) return false;
+        final int n  = dir.ordinal() - NORTH.ordinal();
+        return n >= 0 && n < COMPASS_COUNT && (n & 3) != 0;
+    }
+
+    /**
      * Returns {@code true} if the given direction is {@code UP} or {@code DOWN}.
      *
      * @param  dir The direction to test, or {@code null}.
@@ -340,7 +353,7 @@ public final class AxisDirections extend
     }
 
     /**
-     * Searches for a axis direction having the given name in the specified list of directions.
+     * Searches for an axis direction having the given name in the specified list of directions.
      * This method compares the given name with the name of each {@code AxisDirection} in a lenient way:
      *
      * <ul>

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=1558364&r1=1558363&r2=1558364&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java [UTF-8] Wed Jan 15 12:47:12 2014
@@ -22,7 +22,6 @@ import java.util.Arrays;
 import javax.measure.unit.SI;
 import javax.measure.unit.Unit;
 import javax.measure.unit.NonSI;
-import javax.measure.converter.ConversionException;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
@@ -34,7 +33,6 @@ import org.opengis.referencing.cs.AxisDi
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.apache.sis.referencing.AbstractIdentifiedObject;
-import org.apache.sis.referencing.IdentifiedObjects;
 import org.apache.sis.internal.referencing.AxisDirections;
 import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.util.ComparisonMode;
@@ -321,44 +319,6 @@ public class AbstractCS extends Abstract
     }
 
     /**
-     * Returns a coordinate system with the same properties than this one (except identifiers)
-     * but different units of measurement. If this coordinate system already uses the given units,
-     * then this method returns {@code this}.
-     *
-     * @param  units The desired units of measurement for each axis. If this array length is smaller
-     *         than the coordinate system {@linkplain #getDimension() dimension}, then the last unit
-     *         is repeated for all remaining axes.
-     * @return A coordinate system with axis using the given units, or {@code this}.
-     * @throws ConversionException If at least one unit is incompatible with the existing ones.
-     */
-    public AbstractCS forUnits(final Unit<?>... units) throws ConversionException {
-        ensureNonNull("units", units);
-        if (units.length == 0 || units.length > axes.length) {
-            throw new IllegalArgumentException(Errors.format(Errors.Keys.MismatchedDimension_3,
-                    "units", axes.length, units.length));
-        }
-        CoordinateSystemAxis[] newAxes = null;
-        for (int i=0; i<axes.length; i++) {
-            final CoordinateSystemAxis axis = axes[i];
-            final Unit<?> unit = axis.getUnit();
-            final Unit<?> newUnit = units[Math.min(i, units.length - 1)];
-            if (!unit.equals(newUnit)) {
-                final DefaultCoordinateSystemAxis c = DefaultCoordinateSystemAxis.castOrCopy(axis).forUnit(newUnit);
-                if (c != axis) {
-                    if (newAxes == null) {
-                        newAxes = axes.clone();
-                    }
-                    newAxes[i] = c;
-                }
-            }
-        }
-        if (newAxes != null) {
-            return createSameType(IdentifiedObjects.getProperties(this, IDENTIFIERS_KEY), newAxes);
-        }
-        return this;
-    }
-
-    /**
      * Returns a coordinate system equivalent to this one but with axes rearranged according the given convention.
      * If this coordinate system is already compatible with the given convention, then this method returns
      * {@code this}.
@@ -374,11 +334,17 @@ public class AbstractCS extends Abstract
         AbstractCS cs = derived.get(convention);
         if (cs == null) {
             switch (convention) {
-                case NORMALIZED:     // TODO
-                case RIGHT_HANDED:   cs = Normalizer.normalize(this); break;
+                case NORMALIZED:     cs = Normalizer.normalize(this, true);  break;
+                case RIGHT_HANDED:   cs = Normalizer.normalize(this, false); break;
                 case POSITIVE_RANGE: cs = this; break; // TODO
                 default: throw new AssertionError(convention);
             }
+            for (final AbstractCS existing : derived.values()) {
+                if (cs.equals(existing)) {
+                    cs = existing;
+                    break;
+                }
+            }
             derived.put(convention, cs);
         }
         return cs;

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java?rev=1558364&r1=1558363&r2=1558364&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java [UTF-8] Wed Jan 15 12:47:12 2014
@@ -74,7 +74,7 @@ public enum AxesConvention {
      *     <ul>
      *       <li>{@link AxisDirection#EAST EAST}, {@link AxisDirection#NORTH NORTH},
      *           {@link AxisDirection#UP UP}, {@link AxisDirection#FUTURE FUTURE} —
-     *           commonly used directions for (<var>x</var>, <var>y</var>, <var>z</var>, <var>t</var>) coordinates.</li>
+     *           commonly used (<var>x</var>, <var>y</var>, <var>z</var>, <var>t</var>) directions for coordinates.</li>
      *       <li>{@link AxisDirection#DISPLAY_RIGHT DISPLAY_RIGHT}, {@link AxisDirection#DISPLAY_DOWN DISPLAY_DOWN} —
      *           commonly used (<var>x</var>, <var>y</var>) directions for screen devices.</li>
      *       <li>{@link AxisDirection#ROW_POSITIVE ROW_POSITIVE},

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=1558364&r1=1558363&r2=1558364&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java [UTF-8] Wed Jan 15 12:47:12 2014
@@ -23,7 +23,6 @@ import javax.measure.unit.Unit;
 import javax.measure.unit.NonSI;
 import javax.measure.quantity.Angle;
 import javax.measure.converter.UnitConverter;
-import javax.measure.converter.ConversionException;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlAttribute;
@@ -606,7 +605,7 @@ public class DefaultCoordinateSystemAxis
         } else {
             /*
              * Checking the abbreviation is not sufficient. For example the polar angle and the
-             * spherical latitude have the same abbreviation (θ). SIS names like "Longitude"
+             * spherical latitude have the same abbreviation (θ). Legacy names like "Longitude"
              * (in addition to ISO 19111 "Geodetic longitude") bring more potential confusion.
              * Furthermore, not all implementors use the greek letters. For example most CRS in
              * WKT format use the "Lat" abbreviation instead of the greek letter φ.
@@ -673,22 +672,4 @@ public class DefaultCoordinateSystemAxis
         formatter.append(direction);
         return "AXIS";
     }
-
-    /**
-     * Returns a new axis with the same properties (except identifiers) than current axis,
-     * but with a different unit of measurement.
-     *
-     * @param  newUnit The unit of measurement for the new axis.
-     * @return An axis using the given unit, or {@code this} if the current axis already use the given unit.
-     * @throws ConversionException If the given unit is incompatible with this axis unit.
-     */
-    final DefaultCoordinateSystemAxis forUnit(final Unit<?> newUnit) throws ConversionException {
-        if (unit.equals(newUnit)) {
-            return this;
-        }
-        final UnitConverter converter = unit.getConverterToAny(newUnit);
-        return new DefaultCoordinateSystemAxis(IdentifiedObjects.getProperties(this, IDENTIFIERS_KEY),
-                abbreviation, direction, newUnit, converter.convert(minimumValue),
-                converter.convert(maximumValue), rangeMeaning);
-    }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java?rev=1558364&r1=1558363&r2=1558364&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java [UTF-8] Wed Jan 15 12:47:12 2014
@@ -16,13 +16,25 @@
  */
 package org.apache.sis.referencing.cs;
 
+import java.util.Map;
 import java.util.Arrays;
+import javax.measure.unit.Unit;
+import javax.measure.unit.SI;
+import javax.measure.unit.NonSI;
+import javax.measure.converter.UnitConverter;
+import javax.measure.converter.ConversionException;
 import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.apache.sis.internal.referencing.AxisDirections;
+import org.apache.sis.referencing.IdentifiedObjects;
+import org.apache.sis.util.resources.Vocabulary;
+import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.CharSequences;
+import org.apache.sis.measure.Units;
 
 import static java.util.Collections.singletonMap;
-import org.apache.sis.util.CharSequences;
+import static org.opengis.referencing.IdentifiedObject.NAME_KEY;
+import static org.opengis.referencing.IdentifiedObject.IDENTIFIERS_KEY;
 
 
 /**
@@ -102,23 +114,107 @@ final class Normalizer implements Compar
     }
 
     /**
+     * Returns a new axis with the same properties (except identifiers) than given axis,
+     * but with normalized axis direction and unit of measurement.
+     *
+     * @param  axis The axis to normalize.
+     * @return An axis using normalized direction unit, or {@code axis} if the given axis already uses the given unit.
+     */
+    static CoordinateSystemAxis normalize(final CoordinateSystemAxis axis) {
+        /*
+         * Normalize the axis direction. For now we do not touch to inter-cardinal directions (e.g. "North-East")
+         * because it is not clear which normalization policy would match common usage.
+         */
+        final AxisDirection direction = axis.getDirection();
+        AxisDirection newDir = direction;
+        if (!AxisDirections.isIntercardinal(direction)) {
+            newDir = AxisDirections.absolute(direction);
+        }
+        final boolean sameDirection = newDir.equals(direction);
+        /*
+         * Normalize unit of measurement.
+         */
+        final Unit<?> unit = axis.getUnit(), newUnit;
+        if (Units.isLinear(unit)) {
+            newUnit = SI.METRE;
+        } else if (Units.isAngular(unit)) {
+            newUnit = NonSI.DEGREE_ANGLE;
+        } else if (Units.isTemporal(unit)) {
+            newUnit = NonSI.DAY;
+        } else {
+            newUnit = unit;
+        }
+        /*
+         * Reuse some properties (name, remarks, etc.) from the existing axis. If the direction changed,
+         * then the axis name may need change too (e.g. "Westing" → "Easting"). The new axis name may be
+         * set to "Unnamed", but the caller will hopefully be able to replace the returned instance by
+         * an instance from the EPSG database with appropriate name.
+         */
+        if (sameDirection && newUnit.equals(unit)) {
+            return axis;
+        }
+        final String abbreviation = axis.getAbbreviation();
+        String newAbbr = abbreviation;
+        if (!sameDirection) {
+            if (AxisDirections.isCompass(direction)) {
+                if (CharSequences.isAcronymForWords(abbreviation, direction.name())) {
+                    if (newDir.equals(AxisDirection.EAST)) {
+                        newAbbr = "E";
+                    } else if (newDir.equals(AxisDirection.NORTH)) {
+                        newAbbr = "N";
+                    }
+                }
+            } else if (newDir.equals(AxisDirection.UP)) {
+                newAbbr = "z";
+            } else if (newDir.equals(AxisDirection.FUTURE)) {
+                newAbbr = "t";
+            }
+        }
+        final Map<String,?> properties;
+        if (newAbbr.equals(abbreviation)) {
+            properties = IdentifiedObjects.getProperties(axis, IDENTIFIERS_KEY);
+        } else {
+            properties = singletonMap(NAME_KEY, Vocabulary.format(Vocabulary.Keys.Unnamed));
+        }
+        /*
+         * Converts the axis range and build the new axis.
+         */
+        final UnitConverter c;
+        try {
+            c = unit.getConverterToAny(newUnit);
+        } catch (ConversionException e) {
+            // Use IllegalStateException because the public API is an AbstractCS member method.
+            throw new IllegalStateException(Errors.format(Errors.Keys.IllegalUnitFor_2, "axis", unit), e);
+        }
+        return new DefaultCoordinateSystemAxis(properties, newAbbr, newDir, newUnit,
+                c.convert(axis.getMinimumValue()), c.convert(axis.getMaximumValue()), axis.getRangeMeaning());
+    }
+
+    /**
      * Reorder the axes in an attempt to get a right-handed system.
      * If no axis change is needed, then this method returns {@code cs} unchanged.
      *
      * @param  cs The coordinate system to normalize.
+     * @param  allowAxisChanges {@code true} for normalizing axis directions and units.
      * @return The normalized coordinate system.
      */
-    static AbstractCS normalize(final AbstractCS cs) {
+    static AbstractCS normalize(final AbstractCS cs, final boolean allowAxisChanges) {
+        boolean changed = false;
         final int dimension = cs.getDimension();
         final CoordinateSystemAxis[] axes = new CoordinateSystemAxis[dimension];
         for (int i=0; i<dimension; i++) {
-            axes[i] = cs.getAxis(i);
+            CoordinateSystemAxis axis = cs.getAxis(i);
+            if (allowAxisChanges) {
+                changed |= (axis != (axis = normalize(axis)));
+            }
+            axes[i] = axis;
         }
         /*
          * Sorts the axis in an attempt to create a right-handed system
          * and creates a new Coordinate System if at least one axis changed.
          */
-        if (!sort(axes)) {
+        changed |= sort(axes);
+        if (!changed) {
             return cs;
         }
         final StringBuilder buffer = (StringBuilder) CharSequences.camelCaseToSentence(cs.getInterface().getSimpleName());

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java?rev=1558364&r1=1558363&r2=1558364&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java [UTF-8] Wed Jan 15 12:47:12 2014
@@ -29,6 +29,7 @@ import static java.lang.Double.NaN;
 import static org.opengis.test.Validators.*;
 import static org.apache.sis.referencing.Assert.*;
 import static org.apache.sis.geometry.AbstractEnvelopeTest.WGS84;
+import static org.apache.sis.geometry.AbstractEnvelopeTest.STRICT;
 
 
 /**
@@ -46,11 +47,6 @@ import static org.apache.sis.geometry.Ab
 @DependsOn(AbstractEnvelopeTest.class)
 public strictfp class GeneralEnvelopeTest extends TestCase {
     /**
-     * The comparison threshold for strict comparisons.
-     */
-    static final double STRICT = 0;
-
-    /**
      * Tolerance threshold for floating point comparisons.
      */
     private static final double EPS = 1E-4;

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/SubEnvelopeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/SubEnvelopeTest.java?rev=1558364&r1=1558363&r2=1558364&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/SubEnvelopeTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/SubEnvelopeTest.java [UTF-8] Wed Jan 15 12:47:12 2014
@@ -23,7 +23,7 @@ import static java.lang.Double.NaN;
 import static org.junit.Assert.*;
 import static org.opengis.test.Validators.validate;
 import static org.apache.sis.geometry.AbstractEnvelopeTest.WGS84;
-import static org.apache.sis.geometry.GeneralEnvelopeTest.STRICT;
+import static org.apache.sis.geometry.AbstractEnvelopeTest.STRICT;
 
 
 /**

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java?rev=1558364&r1=1558363&r2=1558364&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java [UTF-8] Wed Jan 15 12:47:12 2014
@@ -91,6 +91,32 @@ public final strictfp class AxisDirectio
     }
 
     /**
+     * Tests {@link AxisDirections#isIntercardinal(AxisDirection)}.
+     */
+    @Test
+    public void testIsIntercardinal() {
+        assertFalse(AxisDirections.isIntercardinal(NORTH));
+        assertTrue (AxisDirections.isIntercardinal(NORTH_NORTH_EAST));
+        assertTrue (AxisDirections.isIntercardinal(NORTH_EAST));
+        assertTrue (AxisDirections.isIntercardinal(EAST_NORTH_EAST));
+        assertFalse(AxisDirections.isIntercardinal(EAST));
+        assertTrue (AxisDirections.isIntercardinal(EAST_SOUTH_EAST));
+        assertTrue (AxisDirections.isIntercardinal(SOUTH_EAST));
+        assertTrue (AxisDirections.isIntercardinal(SOUTH_SOUTH_EAST));
+        assertFalse(AxisDirections.isIntercardinal(SOUTH));
+        assertTrue (AxisDirections.isIntercardinal(SOUTH_SOUTH_WEST));
+        assertTrue (AxisDirections.isIntercardinal(SOUTH_WEST));
+        assertTrue (AxisDirections.isIntercardinal(WEST_SOUTH_WEST));
+        assertFalse(AxisDirections.isIntercardinal(WEST));
+        assertTrue (AxisDirections.isIntercardinal(WEST_NORTH_WEST));
+        assertTrue (AxisDirections.isIntercardinal(NORTH_WEST));
+        assertTrue (AxisDirections.isIntercardinal(NORTH_NORTH_WEST));
+        assertFalse(AxisDirections.isIntercardinal(UP));
+        assertFalse(AxisDirections.isIntercardinal(FUTURE));
+        assertFalse(AxisDirections.isIntercardinal(OTHER));
+    }
+
+    /**
      * Tests {@link AxisDirections#isVertical(AxisDirection)}.
      */
     @Test

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java?rev=1558364&r1=1558363&r2=1558364&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java [UTF-8] Wed Jan 15 12:47:12 2014
@@ -27,6 +27,9 @@ import org.opengis.parameter.ParameterVa
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.referencing.IdentifiedObject;
 import org.opengis.referencing.operation.Matrix;
+import org.opengis.referencing.cs.AxisDirection;
+import org.opengis.referencing.cs.CoordinateSystemAxis;
+import org.opengis.referencing.cs.RangeMeaning;
 import org.apache.sis.geometry.AbstractEnvelope;
 import org.apache.sis.geometry.GeneralDirectPosition;
 
@@ -44,12 +47,42 @@ import static java.lang.StrictMath.*;
  */
 public strictfp class Assert extends org.apache.sis.test.Assert {
     /**
+     * Tolerance threshold for strict floating point comparisons.
+     */
+    private static final double STRICT = 0;
+
+    /**
      * For subclass constructor only.
      */
     protected Assert() {
     }
 
     /**
+     * Compares the given coordinate system axis against the expected values.
+     *
+     * @param name          The expected axis name code.
+     * @param abbreviation  The expected axis abbreviation.
+     * @param direction     The expected axis direction.
+     * @param minimumValue  The expected axis minimal value.
+     * @param maximumValue  The expected axis maximal value.
+     * @param unit          The expected axis unit of measurement.
+     * @param rangeMeaning  The expected axis range meaning.
+     * @param axis          The axis to verify.
+     */
+    public static void assertAxisEquals(final String name, final String abbreviation, final AxisDirection direction,
+            final double minimumValue, final double maximumValue, final Unit<?> unit, final RangeMeaning rangeMeaning,
+            final CoordinateSystemAxis axis)
+    {
+        assertEquals("name",         name,         axis.getName().getCode());
+        assertEquals("abbreviation", abbreviation, axis.getAbbreviation());
+        assertEquals("direction",    direction,    axis.getDirection());
+        assertEquals("minimumValue", minimumValue, axis.getMinimumValue(), STRICT);
+        assertEquals("maximumValue", maximumValue, axis.getMaximumValue(), STRICT);
+        assertEquals("unit",         unit,         axis.getUnit());
+        assertEquals("rangeMeaning", rangeMeaning, axis.getRangeMeaning());
+    }
+
+    /**
      * Asserts that the given parameter values are equal to the expected ones within
      * a positive delta. Only the elements in the given descriptor are compared, and
      * the comparisons are done in the units declared in the descriptor.

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/AbstractCSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/AbstractCSTest.java?rev=1558364&r1=1558363&r2=1558364&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/AbstractCSTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/AbstractCSTest.java [UTF-8] Wed Jan 15 12:47:12 2014
@@ -16,7 +16,11 @@
  */
 package org.apache.sis.referencing.cs;
 
+import javax.measure.unit.SI;
+import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
+import org.apache.sis.util.resources.Vocabulary;
+import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
@@ -66,9 +70,40 @@ public final strictfp class AbstractCSTe
      */
     @Test
     public void testForRightHandedConvention() {
-        verifyAxesConvention(AxesConvention.RIGHT_HANDED, new AbstractCS(singletonMap(NAME_KEY, "Test"),
-            CommonAxes.LATITUDE, CommonAxes.TIME, CommonAxes.ALTITUDE, CommonAxes.LONGITUDE),
-            CommonAxes.LONGITUDE, CommonAxes.LATITUDE, CommonAxes.ALTITUDE, CommonAxes.TIME);
+        final AbstractCS cs = new AbstractCS(singletonMap(NAME_KEY, "Test"),
+                CommonAxes.LATITUDE, CommonAxes.TIME, CommonAxes.ALTITUDE, CommonAxes.LONGITUDE);
+        verifyAxesConvention(AxesConvention.RIGHT_HANDED, cs,
+                CommonAxes.LONGITUDE, CommonAxes.LATITUDE, CommonAxes.ALTITUDE, CommonAxes.TIME);
+        assertSame("Right-handed CS shall be same as normalized.",
+                cs.forConvention(AxesConvention.RIGHT_HANDED),
+                cs.forConvention(AxesConvention.NORMALIZED));
+    }
+
+    /**
+     * Tests {@link AbstractCS#forConvention(AxesConvention)}
+     * with a {@link AxesConvention#NORMALIZED} argument.
+     */
+    @Test
+    @DependsOnMethod("testForRightHandedConvention")
+    public void testForNormalizedConvention() {
+        /*
+         * Some expected axes, identical to the one in CommonAxes except for name or units.
+         */
+        final DefaultCoordinateSystemAxis EASTING = new DefaultCoordinateSystemAxis(
+                singletonMap(NAME_KEY, Vocabulary.format(Vocabulary.Keys.Unnamed)), "E",
+                AxisDirection.EAST, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
+        final DefaultCoordinateSystemAxis HEIGHT = new DefaultCoordinateSystemAxis(
+                singletonMap(NAME_KEY, "Height"), "h",
+            AxisDirection.UP, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
+        /*
+         * Test RIGHT_HANDED as a matter of principle before to test NORMALIZED.
+         */
+        final AbstractCS cs = new AbstractCS(singletonMap(NAME_KEY, "Test"),
+                CommonAxes.TIME, CommonAxes.NORTHING, CommonAxes.WESTING, CommonAxes.HEIGHT_cm);
+        verifyAxesConvention(AxesConvention.RIGHT_HANDED, cs,
+                CommonAxes.NORTHING, CommonAxes.WESTING, CommonAxes.HEIGHT_cm, CommonAxes.TIME);
+        verifyAxesConvention(AxesConvention.NORMALIZED, cs,
+                EASTING, CommonAxes.NORTHING, HEIGHT, CommonAxes.TIME);
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CommonAxes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CommonAxes.java?rev=1558364&r1=1558363&r2=1558364&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CommonAxes.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CommonAxes.java [UTF-8] Wed Jan 15 12:47:12 2014
@@ -50,7 +50,7 @@ public final strictfp class CommonAxes {
      * @see #GEODETIC_LATITUDE
      */
     public static final DefaultCoordinateSystemAxis GEODETIC_LONGITUDE = create("Geodetic longitude", "λ",
-            AxisDirection.EAST, -180, 180, NonSI.DEGREE_ANGLE, RangeMeaning.WRAPAROUND);
+            AxisDirection.EAST, NonSI.DEGREE_ANGLE, -180, 180, RangeMeaning.WRAPAROUND);
 
     /**
      * Default axis info for geodetic latitudes in a
@@ -67,7 +67,7 @@ public final strictfp class CommonAxes {
      * @see #GEODETIC_LONGITUDE
      */
     public static final DefaultCoordinateSystemAxis GEODETIC_LATITUDE = create("Geodetic latitude", "φ",
-            AxisDirection.NORTH, -90, 90, NonSI.DEGREE_ANGLE, RangeMeaning.EXACT);
+            AxisDirection.NORTH, NonSI.DEGREE_ANGLE, -90, 90, RangeMeaning.EXACT);
 
     /**
      * Default axis info for longitudes.
@@ -82,7 +82,7 @@ public final strictfp class CommonAxes {
      * @see #LATITUDE
      */
     public static final DefaultCoordinateSystemAxis LONGITUDE = create("Longitude", "λ",
-            AxisDirection.EAST, -180, 180, NonSI.DEGREE_ANGLE, RangeMeaning.WRAPAROUND);
+            AxisDirection.EAST, NonSI.DEGREE_ANGLE, -180, 180, RangeMeaning.WRAPAROUND);
 
     /**
      * Default axis info for latitudes.
@@ -97,7 +97,7 @@ public final strictfp class CommonAxes {
      * @see #LONGITUDE
      */
     public static final DefaultCoordinateSystemAxis LATITUDE = create("Latitude", "φ",
-            AxisDirection.NORTH, -90, 90, NonSI.DEGREE_ANGLE, RangeMeaning.EXACT);
+            AxisDirection.NORTH, NonSI.DEGREE_ANGLE, -90, 90, RangeMeaning.EXACT);
 
     /**
      * The default axis for height values above the ellipsoid in a
@@ -114,7 +114,7 @@ public final strictfp class CommonAxes {
      * @see #DEPTH
      */
     public static final DefaultCoordinateSystemAxis ELLIPSOIDAL_HEIGHT = create("Ellipsoidal height", "h",
-            AxisDirection.UP, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METRE, null);
+            AxisDirection.UP, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
      * The default axis for height values measured from gravity.
@@ -127,13 +127,13 @@ public final strictfp class CommonAxes {
      * @see #DEPTH
      */
     public static final DefaultCoordinateSystemAxis GRAVITY_RELATED_HEIGHT = create("Gravity-related height", "H",
-            AxisDirection.UP, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METRE, null);
+            AxisDirection.UP, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
      * A height in centimetres, for {@link CoordinateSystemsTest} only.
      */
     static final DefaultCoordinateSystemAxis HEIGHT_cm = create("Height", "h",
-            AxisDirection.UP, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.CENTIMETRE, null);
+            AxisDirection.UP, SI.CENTIMETRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
      * The default axis for altitude values.
@@ -148,7 +148,7 @@ public final strictfp class CommonAxes {
      * @see #DEPTH
      */
     public static final DefaultCoordinateSystemAxis ALTITUDE = create("Altitude", "h",
-            AxisDirection.UP, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METRE, null);
+            AxisDirection.UP, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
      * The default axis for depth.
@@ -161,7 +161,7 @@ public final strictfp class CommonAxes {
      * @see #GRAVITY_RELATED_HEIGHT
      */
     public static final DefaultCoordinateSystemAxis DEPTH = create("Depth", "d",
-            AxisDirection.DOWN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METRE, null);
+            AxisDirection.DOWN, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
      * Default axis info for radius in a
@@ -179,7 +179,7 @@ public final strictfp class CommonAxes {
      * @see #DEPTH
      */
     public static final DefaultCoordinateSystemAxis GEOCENTRIC_RADIUS = create("Geocentric radius", "r",
-            AxisDirection.UP, 0, Double.POSITIVE_INFINITY, SI.METRE, RangeMeaning.EXACT);
+            AxisDirection.UP, SI.METRE, 0, Double.POSITIVE_INFINITY, RangeMeaning.EXACT);
 
     /**
      * Default axis info for longitudes in a
@@ -197,7 +197,7 @@ public final strictfp class CommonAxes {
      * @see #SPHERICAL_LATITUDE
      */
     public static final DefaultCoordinateSystemAxis SPHERICAL_LONGITUDE = create("Spherical longitude", "Ω",
-            AxisDirection.EAST, -180, 180, NonSI.DEGREE_ANGLE, RangeMeaning.WRAPAROUND);
+            AxisDirection.EAST, NonSI.DEGREE_ANGLE, -180, 180, RangeMeaning.WRAPAROUND);
 
     /**
      * Default axis info for latitudes in a
@@ -215,7 +215,7 @@ public final strictfp class CommonAxes {
      * @see #SPHERICAL_LONGITUDE
      */
     public static final DefaultCoordinateSystemAxis SPHERICAL_LATITUDE = create("Spherical latitude", "Θ",
-            AxisDirection.NORTH, -90, 90, NonSI.DEGREE_ANGLE, RangeMeaning.EXACT);
+            AxisDirection.NORTH, NonSI.DEGREE_ANGLE, -90, 90, RangeMeaning.EXACT);
 
     /**
      * Default axis info for <var>x</var> values in a
@@ -233,7 +233,7 @@ public final strictfp class CommonAxes {
      * @see #COLUMN
      */
     public static final DefaultCoordinateSystemAxis X = create("x", "x",
-            AxisDirection.EAST, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METRE, null);
+            AxisDirection.EAST, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
      * Default axis info for <var>y</var> values in a
@@ -251,7 +251,7 @@ public final strictfp class CommonAxes {
      * @see #ROW
      */
     public static final DefaultCoordinateSystemAxis Y = create("y", "y",
-            AxisDirection.NORTH, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METRE, null);
+            AxisDirection.NORTH, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
      * Default axis info for <var>z</var> values in a
@@ -263,7 +263,7 @@ public final strictfp class CommonAxes {
      * <p>This axis is usually part of a {@link #X}, {@link #Y}, {@link #Z} set.</p>
      */
     public static final DefaultCoordinateSystemAxis Z = create("z", "z",
-            AxisDirection.UP, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METRE, null);
+            AxisDirection.UP, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
      * Default axis info for <var>x</var> values in a
@@ -279,7 +279,7 @@ public final strictfp class CommonAxes {
      * <p>This axis is usually part of a {@link #GEOCENTRIC_X}, {@link #GEOCENTRIC_Y}, {@link #GEOCENTRIC_Z} set.</p>
      */
     public static final DefaultCoordinateSystemAxis GEOCENTRIC_X = create("X", "X",
-            AxisDirection.GEOCENTRIC_X, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METRE, null);
+            AxisDirection.GEOCENTRIC_X, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
      * Default axis info for <var>y</var> values in a
@@ -295,7 +295,7 @@ public final strictfp class CommonAxes {
      * <p>This axis is usually part of a {@link #GEOCENTRIC_X}, {@link #GEOCENTRIC_Y}, {@link #GEOCENTRIC_Z} set.</p>
      */
     public static final DefaultCoordinateSystemAxis GEOCENTRIC_Y = create("Y", "Y",
-            AxisDirection.GEOCENTRIC_Y, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METRE, null);
+            AxisDirection.GEOCENTRIC_Y, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
      * Default axis info for <var>z</var> values in a
@@ -311,7 +311,7 @@ public final strictfp class CommonAxes {
      * <p>This axis is usually part of a {@link #GEOCENTRIC_X}, {@link #GEOCENTRIC_Y}, {@link #GEOCENTRIC_Z} set.</p>
      */
     public static final DefaultCoordinateSystemAxis GEOCENTRIC_Z = create("Z", "Z",
-            AxisDirection.GEOCENTRIC_Z, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METRE, null);
+            AxisDirection.GEOCENTRIC_Z, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
      * Default axis info for Easting values in a
@@ -326,7 +326,7 @@ public final strictfp class CommonAxes {
      * @see #WESTING
      */
     public static final DefaultCoordinateSystemAxis EASTING = create("Easting", "E",
-            AxisDirection.EAST, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METRE, null);
+            AxisDirection.EAST, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
      * Default axis info for Westing values in a
@@ -339,7 +339,7 @@ public final strictfp class CommonAxes {
      * @see #WESTING
      */
     public static final DefaultCoordinateSystemAxis WESTING = create("Westing", "W",
-            AxisDirection.WEST, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METRE, null);
+            AxisDirection.WEST, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
      * Default axis info for Northing values in a
@@ -354,7 +354,7 @@ public final strictfp class CommonAxes {
      * @see #SOUTHING
      */
     public static final DefaultCoordinateSystemAxis NORTHING = create("Northing", "N",
-            AxisDirection.NORTH, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METRE, null);
+            AxisDirection.NORTH, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
      * Default axis info for Southing values in a
@@ -367,19 +367,19 @@ public final strictfp class CommonAxes {
      * @see #SOUTHING
      */
     public static final DefaultCoordinateSystemAxis SOUTHING = create("Southing", "S",
-            AxisDirection.SOUTH, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METRE, null);
+            AxisDirection.SOUTH, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
      * An axis with North-East orientation.
      */
     static final DefaultCoordinateSystemAxis NORTH_EAST = create("NORTH_EAST", "NE",
-            AxisDirection.NORTH_EAST, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METRE, null);
+            AxisDirection.NORTH_EAST, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
      * An axis with South-East orientation.
      */
     static final DefaultCoordinateSystemAxis SOUTH_EAST = create("SOUTH_EAST", "SE",
-            AxisDirection.SOUTH_EAST, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METRE, null);
+            AxisDirection.SOUTH_EAST, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
      * A default axis for time values in a {@linkplain org.opengis.referencing.cs.TimeCS time CS}.
@@ -387,7 +387,7 @@ public final strictfp class CommonAxes {
      * The abbreviation is lower case "<var>t</var>".
      */
     public static final DefaultCoordinateSystemAxis TIME = create("Time", "t",
-            AxisDirection.FUTURE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, NonSI.DAY, null);
+            AxisDirection.FUTURE, NonSI.DAY, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
      * A default axis for column indices in a {@linkplain org.opengis.coverage.grid.GridCoverage grid coverage}.
@@ -395,7 +395,7 @@ public final strictfp class CommonAxes {
      * The abbreviation is lower case "<var>i</var>".
      */
     public static final DefaultCoordinateSystemAxis COLUMN = create("Column", "i",
-            AxisDirection.COLUMN_POSITIVE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Unit.ONE, null);
+            AxisDirection.COLUMN_POSITIVE, Unit.ONE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
      * A default axis for row indices in a {@linkplain org.opengis.coverage.grid.GridCoverage grid coverage}.
@@ -403,7 +403,7 @@ public final strictfp class CommonAxes {
      * The abbreviation is lower case "<var>j</var>".
      */
     public static final DefaultCoordinateSystemAxis ROW = create("Row", "j",
-            AxisDirection.ROW_POSITIVE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Unit.ONE, null);
+            AxisDirection.ROW_POSITIVE, Unit.ONE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
      * A default axis for <var>x</var> values in a display device. Increasing values go toward
@@ -411,7 +411,7 @@ public final strictfp class CommonAxes {
      * The abbreviation is lower case "<var>x</var>".
      */
     public static final DefaultCoordinateSystemAxis DISPLAY_X = create("x", "x",
-            AxisDirection.DISPLAY_RIGHT, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Unit.ONE, null);
+            AxisDirection.DISPLAY_RIGHT, Unit.ONE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
      * A default axis for <var>y</var> values in a display device. Increasing values go toward
@@ -419,7 +419,7 @@ public final strictfp class CommonAxes {
      * The abbreviation is lower case "<var>y</var>".
      */
     public static final DefaultCoordinateSystemAxis DISPLAY_Y = create("y", "y",
-            AxisDirection.DISPLAY_DOWN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Unit.ONE, null);
+            AxisDirection.DISPLAY_DOWN, Unit.ONE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
      * Undefined or unknown axis. Axis direction is {@link AxisDirection#OTHER OTHER}
@@ -427,13 +427,13 @@ public final strictfp class CommonAxes {
      * for axes that were not properly defined.
      */
     public static final DefaultCoordinateSystemAxis UNDEFINED = create("Undefined", "?",
-            AxisDirection.OTHER, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Unit.ONE, null);
+            AxisDirection.OTHER, Unit.ONE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
      * Creates a new axis of the given name, abbreviation, direction and unit.
      */
     private static DefaultCoordinateSystemAxis create(final String name, final String abbreviation,
-            final AxisDirection direction, final double minimum, final double maximum, final Unit<?> unit,
+            final AxisDirection direction, final Unit<?> unit, final double minimum, final double maximum,
             final RangeMeaning meaning)
     {
         return new DefaultCoordinateSystemAxis(singletonMap(DefaultCoordinateSystemAxis.NAME_KEY, name),

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/NormalizerTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/NormalizerTest.java?rev=1558364&r1=1558363&r2=1558364&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/NormalizerTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/NormalizerTest.java [UTF-8] Wed Jan 15 12:47:12 2014
@@ -16,18 +16,19 @@
  */
 package org.apache.sis.referencing.cs;
 
-import java.util.Arrays;
 import java.util.Map;
+import java.util.Arrays;
 import javax.measure.unit.SI;
 import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
+import org.apache.sis.util.resources.Vocabulary;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
 import static java.util.Collections.singletonMap;
 import static org.opengis.referencing.cs.CoordinateSystem.NAME_KEY;
-import static org.junit.Assert.*;
+import static org.apache.sis.referencing.Assert.*;
 
 
 /**
@@ -44,10 +45,10 @@ import static org.junit.Assert.*;
 })
 public final strictfp class NormalizerTest extends TestCase {
     /**
-     * Tests sorting of axes.
+     * Tests {@link Normalizer#sort(CoordinateSystemAxis[])}.
      */
     @Test
-    public void testSortAxis() {
+    public void testSort() {
         assertOrdered(new CoordinateSystemAxis[] {
             CommonAxes.LONGITUDE,
             CommonAxes.LATITUDE,
@@ -66,13 +67,7 @@ public final strictfp class NormalizerTe
             CommonAxes.ELLIPSOIDAL_HEIGHT,
             CommonAxes.LONGITUDE
         });
-    }
 
-    /**
-     * Tests sorting of directions.
-     */
-    @Test
-    public void testSortDirections() {
         // A plausible CS.
         assertOrdered(new AxisDirection[] {
             AxisDirection.EAST,    // Right handed-rule
@@ -165,4 +160,29 @@ public final strictfp class NormalizerTe
         }
         return axis;
     }
+
+    /**
+     * Tests {@link Normalizer#normalize(CoordinateSystemAxis, int)}.
+     */
+    @Test
+    public void testNormalizeAxis() {
+        assertSame(CommonAxes.LATITUDE,  Normalizer.normalize(CommonAxes.LATITUDE));
+        assertSame(CommonAxes.LONGITUDE, Normalizer.normalize(CommonAxes.LONGITUDE));
+        assertSame(CommonAxes.EASTING,   Normalizer.normalize(CommonAxes.EASTING));
+        assertSame(CommonAxes.NORTHING,  Normalizer.normalize(CommonAxes.NORTHING));
+        assertSame(CommonAxes.ALTITUDE,  Normalizer.normalize(CommonAxes.ALTITUDE));
+        assertSame(CommonAxes.TIME,      Normalizer.normalize(CommonAxes.TIME));
+        /*
+         * Test a change of unit from centimetre to metre.
+         */
+        assertAxisEquals("Height", "h", AxisDirection.UP,
+            Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METRE, null,
+            Normalizer.normalize(CommonAxes.HEIGHT_cm));
+        /*
+         * Test a change of direction from West to East.
+         */
+        assertAxisEquals(Vocabulary.format(Vocabulary.Keys.Unnamed), "E",
+            AxisDirection.EAST, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METRE, null,
+            Normalizer.normalize(CommonAxes.WESTING));
+    }
 }

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java?rev=1558364&r1=1558363&r2=1558364&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java [UTF-8] Wed Jan 15 12:47:12 2014
@@ -345,6 +345,11 @@ public final class Vocabulary extends In
         public static final short UnavailableContent = 57;
 
         /**
+         * Unnamed
+         */
+        public static final short Unnamed = 65;
+
+        /**
          * Untitled
          */
         public static final short Untitled = 58;

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties?rev=1558364&r1=1558363&r2=1558364&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties [ISO-8859-1] Wed Jan 15 12:47:12 2014
@@ -71,6 +71,7 @@ Time_1             = {0} time
 Timezone           = Timezone
 TruncatedJulian    = Truncated Julian
 Type               = Type
+Unnamed            = Unnamed
 Untitled           = Untitled
 UnavailableContent = Unavailable content.
 UserHome           = User home directory

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties?rev=1558364&r1=1558363&r2=1558364&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties [ISO-8859-1] Wed Jan 15 12:47:12 2014
@@ -71,6 +71,7 @@ Time_1             = Heure {0}
 Timezone           = Fuseau horaire
 TruncatedJulian    = Julien tronqu\u00e9
 Type               = Type
+Unnamed            = Sans nom
 Untitled           = Sans titre
 UnavailableContent = Contenu non-disponible.
 UserHome           = R\u00e9pertoire de l'utilisateur

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java?rev=1558364&r1=1558363&r2=1558364&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java [UTF-8] Wed Jan 15 12:47:12 2014
@@ -327,21 +327,24 @@ public final strictfp class CharSequence
     @Test
     public void testIsAcronymForWords() {
         /*
-         * Following should be accepted as acronyms...
+         * Following shall be accepted as acronyms...
          */
         assertTrue(isAcronymForWords("OGC",                        "Open Geospatial Consortium"));
         assertTrue(isAcronymForWords("O.G.C.",                     "Open Geospatial Consortium"));
         assertTrue(isAcronymForWords("OpGeoCon",                   "Open Geospatial Consortium"));
         assertTrue(isAcronymForWords("Open Geospatial Consortium", "Open Geospatial Consortium"));
         assertTrue(isAcronymForWords("ogc",                        "Open Geospatial Consortium"));
+        assertTrue(isAcronymForWords("E",                          "EAST"));
+        assertTrue(isAcronymForWords("ENE",                        "EAST_NORTH_EAST"));
         /*
-         * Following should be rejected...
+         * Following shall be rejected...
          */
         assertFalse(isAcronymForWords("ORC",    "Open Geospatial Consortium"));
         assertFalse(isAcronymForWords("O.C.G.", "Open Geospatial Consortium"));
         assertFalse(isAcronymForWords("OGC2",   "Open Geospatial Consortium"));
         assertFalse(isAcronymForWords("OG",     "Open Geospatial Consortium"));
         assertFalse(isAcronymForWords("GC",     "Open Geospatial Consortium"));
+        assertFalse(isAcronymForWords("ENE",    "NORTH_EAST"));
         /*
          * Following are mapping of EPSG table names from MS-Access to ANSI SQL.
          * All those items must be recognized as acroynms - this is requred by DirectEpsgFactory.
@@ -369,7 +372,7 @@ public final strictfp class CharSequence
         assertTrue(isAcronymForWords("deprecation",               "[Deprecation]"));
         assertFalse(isAcronymForWords(null,                       "[Deprecation]"));
         /*
-         * It is important the the following is not recognized as an acronym,
+         * It is important the following is not recognized as an acronym,
          * otherwise it leads to a confusion in DirectEpsgFactory.
          */
         assertFalse(isAcronymForWords("coordoperation", "[Coordinate_Operation Method]"));



Mime
View raw message