sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1557278 - in /sis/branches/JDK7/core/sis-referencing/src: main/java/org/apache/sis/internal/referencing/ main/java/org/apache/sis/referencing/ main/java/org/apache/sis/referencing/cs/ test/java/org/apache/sis/internal/referencing/ test/jav...
Date Fri, 10 Jan 2014 23:10:20 GMT
Author: desruisseaux
Date: Fri Jan 10 23:10:19 2014
New Revision: 1557278

URL: http://svn.apache.org/r1557278
Log:
Initial port of ComparableAxisWrapper, and try to make AxisDirections utility methods more 3D-aware.

Added:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/ComparableAxisWrapper.java   (with props)
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/AbstractCSTest.java   (with props)
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/ComparableAxisWrapperTest.java   (with props)
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/AbstractIdentifiedObject.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.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/cs/CoordinateSystemsTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCartesianCSTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCSTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.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=1557278&r1=1557277&r2=1557278&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] Fri Jan 10 23:10:19 2014
@@ -35,10 +35,22 @@ import static org.apache.sis.util.CharSe
  */
 public final class AxisDirections extends Static {
     /**
-     * Do not allow instantiation of this class.
+     * Number of directions like "North", "North-North-East", "North-East", etc.
+     * The first of those directions is {@link AxisDirection#NORTH}.
      */
-    private AxisDirections() {
-    }
+    public static final int COMPASS_COUNT = 16;
+
+    /**
+     * Number of geocentric directions.
+     * The first of those directions is {@link AxisDirection#GEOCENTRIC_X}.
+     */
+    public static final int GEOCENTRIC_COUNT = 3;
+
+    /**
+     * Number of directions like "Display right", "Display down", etc.
+     * The first of those directions is {@link AxisDirection#DISPLAY_RIGHT}.
+     */
+    public static final int DISPLAY_COUNT = 4;
 
     /**
      * For each direction, the opposite direction.
@@ -71,6 +83,12 @@ public final class AxisDirections extend
     }
 
     /**
+     * Do not allow instantiation of this class.
+     */
+    private AxisDirections() {
+    }
+
+    /**
      * Returns the "absolute" direction of the given direction.
      * This "absolute" operation is similar to the {@code Math.abs(int)} method in that "negative" directions like
      * ({@code SOUTH}, {@code WEST}, {@code DOWN}, {@code PAST}) are changed for their "positive" counterparts
@@ -151,6 +169,32 @@ public final class AxisDirections extend
     }
 
     /**
+     * Returns {@code true} if the specified direction is a compass direction.
+     * Compass directions are {@code NORTH}, {@code EAST}, {@code NORTH_EAST}, etc.
+     *
+     * @param  dir The direction to test, or {@code null}.
+     * @return {@code true} if the given direction is a compass direction.
+     *
+     * @see #angleForCompass(AxisDirection, AxisDirection)
+     */
+    public static boolean isCompass(final AxisDirection dir) {
+        if (dir == null) return false;
+        final int n  = dir.ordinal() - NORTH.ordinal();
+        return n >= 0 && n < COMPASS_COUNT;
+    }
+
+    /**
+     * Returns {@code true} if the given direction is {@code UP} or {@code DOWN}.
+     *
+     * @param  dir The direction to test, or {@code null}.
+     * @return {@code true} if the direction is vertical, or {@code false} otherwise.
+     */
+    public static boolean isVertical(final AxisDirection dir) {
+        if (dir == null) return false;
+        return ((dir.ordinal() - UP.ordinal()) & ~1) == 0;
+    }
+
+    /**
      * Returns {@code true} if the given direction is a spatial axis direction (including vertical and geocentric axes).
      * The current implementation conservatively returns {@code true} for every non-null directions except a hard-coded
      * set of directions which are known to be non-spatial. We conservatively accept unknown axis directions because
@@ -185,6 +229,89 @@ public final class AxisDirections extend
     }
 
     /**
+     * Angle between geocentric directions only.
+     *
+     * @param  source The start direction.
+     * @param  target The final direction.
+     * @return The angle as a multiple of 90°, or {@link Integer#MIN_VALUE} if none.
+     */
+    public static int angleForGeocentric(final AxisDirection source, final AxisDirection target) {
+        final int base = GEOCENTRIC_X.ordinal();
+        final int src  = source.ordinal() - base;
+        if (src >= 0 && src < GEOCENTRIC_COUNT) {
+            final int tgt = target.ordinal() - base;
+            if (tgt >= 0 && tgt < GEOCENTRIC_COUNT) {
+                int n = (tgt - src);
+                n -= GEOCENTRIC_COUNT * (n/2); // If -2 add 3.  If +2 subtract 3.  Otherwise do nothing.
+                return n;
+            }
+        }
+        return Integer.MIN_VALUE;
+    }
+
+    /**
+     * Angle between compass directions only (not for angle between direction along meridians).
+     *
+     * @param  source The start direction.
+     * @param  target The final direction.
+     * @return The arithmetic angle as a multiple of 360/{@link #COMPASS_COUNT}, or {@link Integer#MIN_VALUE} if none.
+     *
+     * @see #isCompass(AxisDirection)
+     */
+    public static int angleForCompass(final AxisDirection source, final AxisDirection target) {
+        final int base = NORTH.ordinal();
+        final int src  = source.ordinal() - base;
+        if (src >= 0 && src < COMPASS_COUNT) {
+            final int tgt = target.ordinal() - base;
+            if (tgt >= 0 && tgt < COMPASS_COUNT) {
+                int n = src - tgt;
+                if (n < -COMPASS_COUNT/2) {
+                    n += COMPASS_COUNT;
+                } else if (n > COMPASS_COUNT/2) {
+                    n -= COMPASS_COUNT;
+                }
+                return n;
+            }
+        }
+        return Integer.MIN_VALUE;
+    }
+
+    /**
+     * Angle between display directions only.
+     *
+     * @param  source The start direction.
+     * @param  target The final direction.
+     * @return The arithmetic angle as a multiple of 360/{@link #DISPLAY_RIGHT}, or {@link Integer#MIN_VALUE} if none.
+     */
+    public static int angleForDisplay(final AxisDirection source, final AxisDirection target) {
+        final int base = DISPLAY_RIGHT.ordinal();
+        int src  = source.ordinal() - base;
+        if (src >= 0 && src < DISPLAY_COUNT) {
+            int tgt = target.ordinal() - base;
+            if (tgt >= 0 && tgt < DISPLAY_COUNT) {
+                /*
+                 * Display directions are RIGHT, LEFT, UP, DOWN. We need to reorder them as UP, RIGHT, DOWN, LEFT.
+                 */
+                src = DISPLAY_ORDER[src];
+                tgt = DISPLAY_ORDER[tgt];
+                int n = src - tgt;
+                if (n < -DISPLAY_COUNT/2) {
+                    n += DISPLAY_COUNT;
+                } else if (n > DISPLAY_COUNT/2) {
+                    n -= DISPLAY_COUNT;
+                }
+                return n;
+            }
+        }
+        return Integer.MIN_VALUE;
+    }
+
+    /**
+     * Maps RIGHT, LEFT, UP, DOWN display order to UP, RIGHT, DOWN, LEFT.
+     */
+    private static final byte[] DISPLAY_ORDER = {1, 3, 0, 2};
+
+    /**
      * Finds the dimension of an axis having the given direction or its opposite.
      * If more than one axis has the given direction, only the first occurrence is returned.
      * If both the given direction and its opposite exist, then the dimension for the given

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=1557278&r1=1557277&r2=1557278&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] Fri Jan 10 23:10:19 2014
@@ -497,38 +497,46 @@ public class AbstractIdentifiedObject ex
          */
         @Override
         public boolean add(final ReferenceIdentifier id) {
-            if (name == null) {
-                name = id;
+            addName(id);
+            return true;
+        }
+    }
+
+    /**
+     * Implementation of {@link Names#add(ReferenceIdentifier)}, defined in the enclosing class
+     * for access to private fields without compiler-generated bridge methods.
+     */
+    final void addName(final ReferenceIdentifier id) {
+        if (name == null) {
+            name = id;
+        } else {
+            /*
+             * Our Code and RS_Identifier implementations should always create NamedIdentifier instance,
+             * so the 'instanceof' check should not be necessary. But we do a paranoiac check anyway.
+             */
+            final GenericName n = id instanceof GenericName ? (GenericName) id : new NamedIdentifier(id);
+            if (alias == null) {
+                alias = Collections.singleton(n);
             } else {
                 /*
-                 * Our Code and RS_Identifier implementations should always create NamedIdentifier instance,
-                 * so the 'instanceof' check should not be necessary. But we do a paranoiac check anyway.
+                 * This implementation is inefficient since each addition copies the array, but we rarely
+                 * have more than two aliases.  This implementation is okay for a small number of aliases
+                 * and ensures that the enclosing AbstractIdentifiedObject is unmodifiable except by this
+                 * add(…) method.
+                 *
+                 * Note about alternative approaches
+                 * ---------------------------------
+                 * An alternative approach could be to use an ArrayList and replace it by an unmodifiable
+                 * list only after unmarshalling (using an afterUnmarshal(Unmarshaller, Object) method),
+                 * but we want to avoid Unmarshaller dependency (for reducing classes loading for users
+                 * who are not interrested in XML) and it may actually be less efficient for the vast
+                 * majority of cases where there is less than 3 aliases.
                  */
-                final GenericName n = id instanceof GenericName ? (GenericName) id : new NamedIdentifier(id);
-                if (alias == null) {
-                    alias = Collections.singleton(n);
-                } else {
-                    /*
-                     * This implementation is inefficient since each addition copies the array, but we rarely
-                     * have more than two aliases.  This implementation is okay for a small number of aliases
-                     * and ensures that the enclosing AbstractIdentifiedObject is unmodifiable except by this
-                     * add(…) method.
-                     *
-                     * Note about alternative approaches
-                     * ---------------------------------
-                     * An alternative approach could be to use an ArrayList and replace it by an unmodifiable
-                     * list only after unmarshalling (using an afterUnmarshal(Unmarshaller, Object) method),
-                     * but we want to avoid Unmarshaller dependency (for reducing classes loading for users
-                     * who are not interrested in XML) and it may actually be less efficient for the vast
-                     * majority of cases where there is less than 3 aliases.
-                     */
-                    final int size = alias.size();
-                    final GenericName[] names = alias.toArray(new GenericName[size + 1]);
-                    names[size] = n;
-                    alias = UnmodifiableArrayList.wrap(names);
-                }
+                final int size = alias.size();
+                final GenericName[] names = alias.toArray(new GenericName[size + 1]);
+                names[size] = n;
+                alias = UnmodifiableArrayList.wrap(names);
             }
-            return true;
         }
     }
 

Added: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/ComparableAxisWrapper.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/ComparableAxisWrapper.java?rev=1557278&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/ComparableAxisWrapper.java (added)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/ComparableAxisWrapper.java [UTF-8] Fri Jan 10 23:10:19 2014
@@ -0,0 +1,103 @@
+/*
+ * 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.cs;
+
+import java.util.Arrays;
+import org.opengis.referencing.cs.AxisDirection;
+import org.opengis.referencing.cs.CoordinateSystemAxis;
+import org.apache.sis.internal.referencing.AxisDirections;
+
+
+/**
+ * Wraps a {@link CoordinateSystemAxis} for comparison purpose. The sorting order tries to favor
+ * a right-handed system. Compass directions like North and East are first. Vertical or temporal
+ * directions like Up or Down are last.
+ *
+ * @author  Martin Desruisseaux (IRD, Geomatys)
+ * @since   0.4 (derived from geotk-2.4)
+ * @version 0.4
+ * @module
+ */
+final class ComparableAxisWrapper implements Comparable<ComparableAxisWrapper> {
+    /**
+     * The wrapped axis.
+     */
+    private final CoordinateSystemAxis axis;
+
+    /**
+     * The direction along meridian, or {@code null} if none.
+     */
+    private final DirectionAlongMeridian meridian;
+
+    /**
+     * Creates a new wrapper for the given axis.
+     */
+    private ComparableAxisWrapper(final CoordinateSystemAxis axis) {
+        this.axis = axis;
+        meridian = DirectionAlongMeridian.parse(axis.getDirection());
+    }
+
+    /**
+     * Compares with the specified object. See class javadoc for a description of the sorting order.
+     */
+    @Override
+    public int compareTo(final ComparableAxisWrapper that) {
+        final AxisDirection d1 = this.axis.getDirection();
+        final AxisDirection d2 = that.axis.getDirection();
+        final int compass = AxisDirections.angleForCompass(d2, d1);
+        if (compass != Integer.MIN_VALUE) {
+            return compass;
+        }
+        if (AxisDirections.isCompass(d1)) {
+            assert !AxisDirections.isCompass(d2) : d2;
+            return -1;
+        }
+        if (AxisDirections.isCompass(d2)) {
+            assert !AxisDirections.isCompass(d1) : d1;
+            return +1;
+        }
+        if (meridian != null) {
+            if (that.meridian != null) {
+                return meridian.compareTo(that.meridian);
+            }
+            return -1;
+        } else if (that.meridian != null) {
+            return +1;
+        }
+        return 0;
+    }
+
+    /**
+     * Sorts the specified axis in an attempt to create a right-handed system.
+     * The sorting is performed in place. This method returns {@code true} if
+     * at least one axis moved.
+     */
+    public static boolean sort(final CoordinateSystemAxis[] axis) {
+        final ComparableAxisWrapper[] wrappers = new ComparableAxisWrapper[axis.length];
+        for (int i=0; i<axis.length; i++) {
+            wrappers[i] = new ComparableAxisWrapper(axis[i]);
+        }
+        Arrays.sort(wrappers);
+        boolean changed = false;
+        for (int i=0; i<axis.length; i++) {
+            final CoordinateSystemAxis a = wrappers[i].axis;
+            changed |= (axis[i] != a);
+            axis[i] = a;
+        }
+        return changed;
+    }
+}

Propchange: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/ComparableAxisWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java?rev=1557278&r1=1557277&r2=1557278&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java [UTF-8] Fri Jan 10 23:10:19 2014
@@ -49,11 +49,6 @@ import java.util.Objects;
  */
 public final class CoordinateSystems extends Static {
     /**
-     * Number of directions from "North", "North-North-East", "North-East", etc.
-     */
-    static final int COMPASS_DIRECTION_COUNT = 16;
-
-    /**
      * Do not allow instantiation of this class.
      */
     private CoordinateSystems() {
@@ -105,8 +100,8 @@ public final class CoordinateSystems ext
      * in decimal <strong>degrees</strong>. This method returns a value between -180° and +180°,
      * or {@link Double#NaN NaN} if no angle can be computed.
      *
-     * <p>A positive angle denotes a right-handed system, while a negative angle denotes a left-handed system.
-     * Example:</p>
+     * <p>A positive angle between two compass directions denotes a right-handed system,
+     * while a negative angle denotes a left-handed system. Examples:</p>
      *
      * <ul>
      *   <li>The angle from {@link AxisDirection#EAST EAST} to {@link AxisDirection#NORTH NORTH} is 90°</li>
@@ -114,6 +109,17 @@ public final class CoordinateSystems ext
      *   <li>The angle from "<cite>North along 90° East</cite>" to "<cite>North along 0°</cite>" is 90°.</li>
      * </ul>
      *
+     * {@section Vertical directions}
+     * By convention, this method defines the angle from any compass direction to the {@link AxisDirection#UP UP}
+     * vertical direction (the <cite>altitude</cite> or <cite>elevation</cite>) as 90°, and the angle of any compass
+     * direction to the {@link AxisDirection#DOWN DOWN} vertical direction as -90°. The angle between two opposite
+     * vertical directions is ±180°. Those directions are approximative since this method does not take the Earth
+     * ellipsoidal or geoidal shape in account.
+     *
+     * {@section Invariants}
+     * {@code angle(A, B) == -angle(B, A)} for any return value different than {@code NaN}.
+     * This invariant holds also for angles of ±180°, even if an angle of -180° is equivalent to +180°.
+     *
      * @param  source The source axis direction.
      * @param  target The target axis direction.
      * @return The arithmetic angle (in degrees) of the rotation to apply on a line pointing toward
@@ -123,12 +129,45 @@ public final class CoordinateSystems ext
     public static double angle(final AxisDirection source, final AxisDirection target) {
         ensureNonNull("source", source);
         ensureNonNull("target", target);
-        // Tests for NORTH, SOUTH, EAST, EAST-NORTH-EAST, etc. directions.
-        final int compass = getCompassAngle(source, target);
-        if (compass != Integer.MIN_VALUE) {
-            return compass * (360.0 / COMPASS_DIRECTION_COUNT);
+        /*
+         * Check for NORTH, SOUTH, EAST, EAST-NORTH-EAST, etc.
+         * Checked first because this is the most common case.
+         */
+        int c = AxisDirections.angleForCompass(source, target);
+        if (c != Integer.MIN_VALUE) {
+            return c * (360.0 / AxisDirections.COMPASS_COUNT);
+        }
+        /*
+         * Check for UP and DOWN, with special case if one of the direction is a compass one.
+         */
+        final boolean v1 = AxisDirections.isVertical(source);
+        final boolean v2 = AxisDirections.isVertical(target);
+        if (v1 | v2) {
+            if (v1 & v2) {
+                return (source == target) ? 0 : (target == AxisDirection.UP) ? 180 : -180;
+            }
+            if (AxisDirections.isCompass(v1 ? target : source)) {
+                return (v1 ? source : target) == AxisDirection.UP ? 90 : -90;
+            }
+        }
+        /*
+         * Check for GEOCENTRIC_X, GEOCENTRIC_Y, GEOCENTRIC_Z.
+         */
+        c = AxisDirections.angleForGeocentric(source, target);
+        if (c != Integer.MIN_VALUE) {
+            return c * 90.0;
+        }
+        /*
+         * Check for DISPLAY_UP, DISPLAY_DOWN, etc.
+         */
+        c = AxisDirections.angleForDisplay(source, target);
+        if (c != Integer.MIN_VALUE) {
+            return c * (360.0 / AxisDirections.DISPLAY_COUNT);
         }
-        // Tests for "South along 90 deg East", etc. directions.
+        /*
+         * Check for "South along 90° East", etc. directions. We do this test last
+         * because it performs a relatively costly parsing of axis direction name.
+         */
         final DirectionAlongMeridian src = DirectionAlongMeridian.parse(source);
         if (src != null) {
             final DirectionAlongMeridian tgt = DirectionAlongMeridian.parse(target);
@@ -140,28 +179,6 @@ public final class CoordinateSystems ext
     }
 
     /**
-     * Tests for angle on compass only (do not tests angle between direction along meridians).
-     * Returns {@link Integer#MIN_VALUE} if the angle can't be computed.
-     */
-    static int getCompassAngle(final AxisDirection source, final AxisDirection target) {
-        final int base = AxisDirection.NORTH.ordinal();
-        final int src  = source.ordinal() - base;
-        if (src >= 0 && src < COMPASS_DIRECTION_COUNT) {
-            int tgt = target.ordinal() - base;
-            if (tgt >= 0 && tgt < COMPASS_DIRECTION_COUNT) {
-                tgt = src - tgt;
-                if (tgt < -COMPASS_DIRECTION_COUNT/2) {
-                    tgt += COMPASS_DIRECTION_COUNT;
-                } else if (tgt > COMPASS_DIRECTION_COUNT/2) {
-                    tgt -= COMPASS_DIRECTION_COUNT;
-                }
-                return tgt;
-            }
-        }
-        return Integer.MIN_VALUE;
-    }
-
-    /**
      * Returns the axis direction for the specified coordinate system.
      *
      * @param  cs The coordinate system.

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=1557278&r1=1557277&r2=1557278&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] Fri Jan 10 23:10:19 2014
@@ -22,6 +22,7 @@ import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
+import static java.lang.StrictMath.abs;
 import static org.opengis.referencing.cs.AxisDirection.*;
 
 
@@ -90,6 +91,16 @@ public final strictfp class AxisDirectio
     }
 
     /**
+     * Tests {@link AxisDirections#isVertical(AxisDirection)}.
+     */
+    @Test
+    public void testIsVertical() {
+        for (final AxisDirection dir : AxisDirection.values()) {
+            assertEquals(dir.name(), dir == UP || dir == DOWN, AxisDirections.isVertical(dir));
+        }
+    }
+
+    /**
      * Tests {@link AxisDirections#isSpatialOrCustom(AxisDirection, boolean)} and
      * {@link AxisDirections#isGrid(AxisDirection)}.
      */
@@ -139,6 +150,84 @@ public final strictfp class AxisDirectio
     }
 
     /**
+     * Tests the {@link AxisDirections#angleForCompass(AxisDirection, AxisDirection)} method.
+     */
+    @Test
+    public void testAngleForCompass() {
+        final AxisDirection[] compass = new AxisDirection[] {
+            NORTH,
+            NORTH_NORTH_EAST,
+            NORTH_EAST,
+            EAST_NORTH_EAST,
+            EAST,
+            EAST_SOUTH_EAST,
+            SOUTH_EAST,
+            SOUTH_SOUTH_EAST,
+            SOUTH,
+            SOUTH_SOUTH_WEST,
+            SOUTH_WEST,
+            WEST_SOUTH_WEST,
+            WEST,
+            WEST_NORTH_WEST,
+            NORTH_WEST,
+            NORTH_NORTH_WEST
+        };
+        assertEquals(compass.length, AxisDirections.COMPASS_COUNT);
+        final int base = NORTH.ordinal();
+        final int h = compass.length / 2;
+        for (int i=0; i<compass.length; i++) {
+            final AxisDirection direction = compass[i];
+            final AxisDirection opposite  = AxisDirections.opposite(direction);
+            final String        message   = direction.name();
+            int io = i+h, in = i;
+            if (i >= h) io -= AxisDirections.COMPASS_COUNT;
+            if (i >  h) in -= AxisDirections.COMPASS_COUNT;
+            assertEquals(message, base + i,  direction.ordinal());
+            assertEquals(message, base + io, opposite.ordinal());
+            assertEquals(message, 0,     AxisDirections.angleForCompass(direction, direction));
+            assertEquals(message, h, abs(AxisDirections.angleForCompass(direction, opposite)));
+            assertEquals(message, in,    AxisDirections.angleForCompass(direction, NORTH));
+        }
+    }
+
+    /**
+     * Tests the {@link AxisDirections#angleForGeocentric(AxisDirection, AxisDirection)} method.
+     */
+    @Test
+    public void testAngleForGeocentric() {
+        assertEquals( 0, AxisDirections.angleForGeocentric(GEOCENTRIC_X, GEOCENTRIC_X));
+        assertEquals( 1, AxisDirections.angleForGeocentric(GEOCENTRIC_X, GEOCENTRIC_Y));
+        assertEquals( 1, AxisDirections.angleForGeocentric(GEOCENTRIC_Y, GEOCENTRIC_Z));
+        assertEquals( 1, AxisDirections.angleForGeocentric(GEOCENTRIC_Z, GEOCENTRIC_X));
+        assertEquals(-1, AxisDirections.angleForGeocentric(GEOCENTRIC_X, GEOCENTRIC_Z));
+        assertEquals(-1, AxisDirections.angleForGeocentric(GEOCENTRIC_Z, GEOCENTRIC_Y));
+        assertEquals(-1, AxisDirections.angleForGeocentric(GEOCENTRIC_Y, GEOCENTRIC_X));
+    }
+
+    /**
+     * Tests the {@link AxisDirections#angleForDisplay(AxisDirection, AxisDirection)} method.
+     */
+    @Test
+    public void testAngleForDisplay() {
+        assertEquals( 0, AxisDirections.angleForDisplay(DISPLAY_RIGHT, DISPLAY_RIGHT));
+        assertEquals( 1, AxisDirections.angleForDisplay(DISPLAY_RIGHT, DISPLAY_UP));
+        assertEquals(-2, AxisDirections.angleForDisplay(DISPLAY_RIGHT, DISPLAY_LEFT));
+        assertEquals(-1, AxisDirections.angleForDisplay(DISPLAY_RIGHT, DISPLAY_DOWN));
+        assertEquals( 0, AxisDirections.angleForDisplay(DISPLAY_UP,    DISPLAY_UP));
+        assertEquals( 1, AxisDirections.angleForDisplay(DISPLAY_UP,    DISPLAY_LEFT));
+        assertEquals(-2, AxisDirections.angleForDisplay(DISPLAY_UP,    DISPLAY_DOWN));
+        assertEquals(-1, AxisDirections.angleForDisplay(DISPLAY_UP,    DISPLAY_RIGHT));
+        assertEquals( 0, AxisDirections.angleForDisplay(DISPLAY_LEFT,  DISPLAY_LEFT));
+        assertEquals( 1, AxisDirections.angleForDisplay(DISPLAY_LEFT,  DISPLAY_DOWN));
+        assertEquals( 2, AxisDirections.angleForDisplay(DISPLAY_LEFT,  DISPLAY_RIGHT));
+        assertEquals(-1, AxisDirections.angleForDisplay(DISPLAY_LEFT,  DISPLAY_UP));
+        assertEquals( 0, AxisDirections.angleForDisplay(DISPLAY_DOWN,  DISPLAY_DOWN));
+        assertEquals( 1, AxisDirections.angleForDisplay(DISPLAY_DOWN,  DISPLAY_RIGHT));
+        assertEquals( 2, AxisDirections.angleForDisplay(DISPLAY_DOWN,  DISPLAY_UP));
+        assertEquals(-1, AxisDirections.angleForDisplay(DISPLAY_DOWN,  DISPLAY_LEFT));
+    }
+
+    /**
      * Tests {@link AxisDirections#valueOf(String)} for the North, South, East and West directions.
      */
     @Test

Added: 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=1557278&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/AbstractCSTest.java (added)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/AbstractCSTest.java [UTF-8] Fri Jan 10 23:10:19 2014
@@ -0,0 +1,49 @@
+/*
+ * 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.cs;
+
+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.apache.sis.test.Assert.*;
+
+
+/**
+ * Tests {@link AbstractCS}.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4
+ * @version 0.4
+ * @module
+ */
+@DependsOn({
+    DefaultCoordinateSystemAxisTest.class,
+    org.apache.sis.referencing.AbstractIdentifiedObjectTest.class
+})
+public final strictfp class AbstractCSTest extends TestCase {
+    /**
+     * Tests serialization.
+     */
+    @Test
+    public void testSerialization() {
+        AbstractCS cs = new AbstractCS(singletonMap(NAME_KEY, "Test"), CommonAxes.X, CommonAxes.Y);
+        cs = assertSerializedEquals(cs);
+    }
+}

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

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

Added: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/ComparableAxisWrapperTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/ComparableAxisWrapperTest.java?rev=1557278&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/ComparableAxisWrapperTest.java (added)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/ComparableAxisWrapperTest.java [UTF-8] Fri Jan 10 23:10:19 2014
@@ -0,0 +1,157 @@
+/*
+ * 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.cs;
+
+import java.util.Arrays;
+import java.util.Map;
+import javax.measure.unit.SI;
+import org.opengis.referencing.cs.AxisDirection;
+import org.opengis.referencing.cs.CoordinateSystemAxis;
+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.*;
+
+
+/**
+ * Tests the {@link ComparableAxisWrapper} class.
+ *
+ * @author  Martin Desruisseaux (IRD, Geomatys)
+ * @since   0.4 (derived from geotk-2.4)
+ * @version 0.4
+ * @module
+ */
+@DependsOn({
+    DirectionAlongMeridianTest.class,
+    DefaultCoordinateSystemAxisTest.class
+})
+public final strictfp class ComparableAxisWrapperTest extends TestCase {
+    /**
+     * Tests sorting of axes.
+     */
+    @Test
+    public void testSortAxis() {
+        assertOrdered(new CoordinateSystemAxis[] {
+            CommonAxes.LONGITUDE,
+            CommonAxes.LATITUDE,
+            CommonAxes.ELLIPSOIDAL_HEIGHT
+        }, new CoordinateSystemAxis[] {
+            CommonAxes.LONGITUDE,
+            CommonAxes.LATITUDE,
+            CommonAxes.ELLIPSOIDAL_HEIGHT
+        });
+        assertOrdered(new CoordinateSystemAxis[] {
+            CommonAxes.LONGITUDE,
+            CommonAxes.LATITUDE,
+            CommonAxes.ELLIPSOIDAL_HEIGHT
+        }, new CoordinateSystemAxis[] {
+            CommonAxes.LATITUDE,
+            CommonAxes.ELLIPSOIDAL_HEIGHT,
+            CommonAxes.LONGITUDE
+        });
+    }
+
+    /**
+     * Tests sorting of directions.
+     */
+    @Test
+    public void testSortDirections() {
+        // A plausible CS.
+        assertOrdered(new AxisDirection[] {
+            AxisDirection.EAST,    // Right handed-rule
+            AxisDirection.NORTH,   // Right handed-rule
+            AxisDirection.UP
+        }, new AxisDirection[] {
+            AxisDirection.NORTH,
+            AxisDirection.UP,
+            AxisDirection.EAST
+        });
+
+        // A very dummy CS just for testing. The order of
+        // any non-compass direction should be unchanged.
+        assertOrdered(new AxisDirection[] {
+            AxisDirection.NORTH_EAST,        // Right handed-rule
+            AxisDirection.NORTH_NORTH_WEST,  // Right handed-rule
+            AxisDirection.GEOCENTRIC_Y,
+            AxisDirection.GEOCENTRIC_X,
+            AxisDirection.PAST
+        }, new AxisDirection[] {
+            AxisDirection.GEOCENTRIC_Y,
+            AxisDirection.NORTH_NORTH_WEST,
+            AxisDirection.GEOCENTRIC_X,
+            AxisDirection.NORTH_EAST,
+            AxisDirection.PAST
+        });
+
+        // An other plausible CS.
+        assertOrdered(new AxisDirection[] {
+            AxisDirection.WEST,   // Right handed-rule
+            AxisDirection.SOUTH,  // Right handed-rule
+            AxisDirection.DOWN
+        }, new AxisDirection[] {
+            AxisDirection.SOUTH,
+            AxisDirection.DOWN,
+            AxisDirection.WEST
+        });
+
+        // An other plausible CS.
+        assertOrdered(new AxisDirection[] {
+            AxisDirection.SOUTH,  // Right handed-rule
+            AxisDirection.EAST,   // Right handed-rule
+            AxisDirection.DOWN
+        }, new AxisDirection[] {
+            AxisDirection.SOUTH,
+            AxisDirection.DOWN,
+            AxisDirection.EAST
+        });
+    }
+
+    /**
+     * Sorts the specified axis and compares against the expected result.
+     */
+    private static void assertOrdered(final CoordinateSystemAxis[] expected,
+                                      final CoordinateSystemAxis[] actual)
+    {
+        final boolean changeExpected = !Arrays.equals(actual, expected);
+        assertEquals(changeExpected, ComparableAxisWrapper.sort(actual));
+        assertArrayEquals(expected, actual);
+    }
+
+    /**
+     * Sorts the specified directions and compares against the expected result.
+     */
+    private static void assertOrdered(final AxisDirection[] expected,
+                                      final AxisDirection[] actual)
+    {
+        assertOrdered(toAxes(expected), toAxes(actual));
+    }
+
+    /**
+     * Creates axis from the specified directions.
+     */
+    private static CoordinateSystemAxis[] toAxes(final AxisDirection[] directions) {
+        final Map<String,?> properties = singletonMap(NAME_KEY, "Test");
+        final CoordinateSystemAxis[] axis = new CoordinateSystemAxis[directions.length];
+        for (int i=0; i<directions.length; i++) {
+            axis[i] = new DefaultCoordinateSystemAxis(properties, "none", directions[i], SI.METRE);
+        }
+        return axis;
+    }
+}

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

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

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java?rev=1557278&r1=1557277&r2=1557278&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java [UTF-8] Fri Jan 10 23:10:19 2014
@@ -21,13 +21,12 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.apache.sis.referencing.operation.matrix.Matrices;
-import org.apache.sis.internal.referencing.AxisDirections;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
-import static java.lang.StrictMath.*;
+import static java.lang.Double.NaN;
 import static java.util.Collections.singletonMap;
 import static org.opengis.referencing.IdentifiedObject.NAME_KEY;
 import static org.apache.sis.referencing.cs.CoordinateSystems.*;
@@ -42,7 +41,10 @@ import static org.apache.sis.test.Assert
  * @version 0.4
  * @module
  */
-@DependsOn(DirectionAlongMeridianTest.class)
+@DependsOn({
+    org.apache.sis.internal.referencing.AxisDirectionsTest.class,
+    DirectionAlongMeridianTest.class
+})
 public final strictfp class CoordinateSystemsTest extends TestCase {
     /**
      * Tolerance threshold for strict floating point comparisons.
@@ -72,63 +74,31 @@ public final strictfp class CoordinateSy
     }
 
     /**
-     * Tests the {@link CoordinateSystems#getCompassAngle(AxisDirection, AxisDirection)} method.
-     */
-    @Test
-    public void testGetCompassAngle() {
-        final AxisDirection[] compass = new AxisDirection[] {
-            AxisDirection.NORTH,
-            AxisDirection.NORTH_NORTH_EAST,
-            AxisDirection.NORTH_EAST,
-            AxisDirection.EAST_NORTH_EAST,
-            AxisDirection.EAST,
-            AxisDirection.EAST_SOUTH_EAST,
-            AxisDirection.SOUTH_EAST,
-            AxisDirection.SOUTH_SOUTH_EAST,
-            AxisDirection.SOUTH,
-            AxisDirection.SOUTH_SOUTH_WEST,
-            AxisDirection.SOUTH_WEST,
-            AxisDirection.WEST_SOUTH_WEST,
-            AxisDirection.WEST,
-            AxisDirection.WEST_NORTH_WEST,
-            AxisDirection.NORTH_WEST,
-            AxisDirection.NORTH_NORTH_WEST
-        };
-        assertEquals(compass.length, COMPASS_DIRECTION_COUNT);
-        final int base = AxisDirection.NORTH.ordinal();
-        final int h = compass.length / 2;
-        for (int i=0; i<compass.length; i++) {
-            final AxisDirection direction = compass[i];
-            final AxisDirection opposite  = AxisDirections.opposite(direction);
-            final String        message   = direction.name();
-            int io = i+h, in = i;
-            if (i >= h) io -= COMPASS_DIRECTION_COUNT;
-            if (i >  h) in -= COMPASS_DIRECTION_COUNT;
-            assertEquals(message, base + i,  direction.ordinal());
-            assertEquals(message, base + io, opposite.ordinal());
-            assertEquals(message, 0,     getCompassAngle(direction, direction));
-            assertEquals(message, h, abs(getCompassAngle(direction, opposite)));
-            assertEquals(message, in,    getCompassAngle(direction, AxisDirection.NORTH));
-        }
-    }
-
-    /**
      * Tests {@link CoordinateSystems#angle(AxisDirection, AxisDirection)}.
      */
     @Test
-    @DependsOnMethod("testGetCompassAngle")
     public void testAngle() {
-        assertEquals(    0, angle(AxisDirection.EAST,             AxisDirection.EAST),       STRICT);
-        assertEquals(  +90, angle(AxisDirection.EAST,             AxisDirection.NORTH),      STRICT);
-        assertEquals(  -90, angle(AxisDirection.NORTH,            AxisDirection.EAST),       STRICT);
-        assertEquals(  +90, angle(AxisDirection.WEST,             AxisDirection.SOUTH),      STRICT);
-        assertEquals(  -90, angle(AxisDirection.SOUTH,            AxisDirection.WEST),       STRICT);
-        assertEquals( -180, angle(AxisDirection.NORTH,            AxisDirection.SOUTH),      STRICT);
-        assertEquals(  180, angle(AxisDirection.SOUTH,            AxisDirection.NORTH),      STRICT);
-        assertEquals(   45, angle(AxisDirection.NORTH_EAST,       AxisDirection.NORTH),      STRICT);
-        assertEquals( 22.5, angle(AxisDirection.NORTH_NORTH_EAST, AxisDirection.NORTH),      STRICT);
-        assertEquals(-22.5, angle(AxisDirection.NORTH_NORTH_WEST, AxisDirection.NORTH),      STRICT);
-        assertEquals(   45, angle(AxisDirection.SOUTH,            AxisDirection.SOUTH_EAST), STRICT);
+        assertAngleEquals(  0,   AxisDirection.EAST,             AxisDirection.EAST);
+        assertAngleEquals( 90,   AxisDirection.EAST,             AxisDirection.NORTH);
+        assertAngleEquals( 90,   AxisDirection.WEST,             AxisDirection.SOUTH);
+        assertAngleEquals(180,   AxisDirection.SOUTH,            AxisDirection.NORTH);
+        assertAngleEquals(180,   AxisDirection.WEST,             AxisDirection.EAST);
+        assertAngleEquals( 45,   AxisDirection.NORTH_EAST,       AxisDirection.NORTH);
+        assertAngleEquals( 22.5, AxisDirection.NORTH_NORTH_EAST, AxisDirection.NORTH);
+        assertAngleEquals( 45,   AxisDirection.SOUTH,            AxisDirection.SOUTH_EAST);
+        assertAngleEquals(NaN,   AxisDirection.NORTH,            AxisDirection.FUTURE);
+        assertAngleEquals(  0,   AxisDirection.UP,               AxisDirection.UP);
+        assertAngleEquals(  0,   AxisDirection.DOWN,             AxisDirection.DOWN);
+        assertAngleEquals(180,   AxisDirection.DOWN,             AxisDirection.UP);
+        assertAngleEquals(NaN,   AxisDirection.DOWN,             AxisDirection.FUTURE);
+        assertAngleEquals(180,   AxisDirection.DISPLAY_DOWN,     AxisDirection.DISPLAY_UP);
+        assertAngleEquals(-90,   AxisDirection.DISPLAY_RIGHT,    AxisDirection.DISPLAY_DOWN);
+        assertAngleEquals(NaN,   AxisDirection.DISPLAY_UP,       AxisDirection.DOWN);
+        assertAngleEquals(NaN,   AxisDirection.PAST,             AxisDirection.FUTURE); // Not spatial directions.
+        assertAngleEquals( 90,   AxisDirection.GEOCENTRIC_X,     AxisDirection.GEOCENTRIC_Y);
+        assertAngleEquals( 90,   AxisDirection.GEOCENTRIC_Y,     AxisDirection.GEOCENTRIC_Z);
+        assertAngleEquals(  0,   AxisDirection.GEOCENTRIC_Y,     AxisDirection.GEOCENTRIC_Y);
+        assertAngleEquals(NaN,   AxisDirection.GEOCENTRIC_Z,     AxisDirection.UP);
     }
 
     /**
@@ -137,28 +107,38 @@ public final strictfp class CoordinateSy
     @Test
     @DependsOnMethod({"testParseAxisDirection", "testAngle"})
     public void testAngleAlongMeridians() {
-        compareAngle( 90.0, "West",                    "South");
-        compareAngle(-90.0, "South",                   "West");
-        compareAngle( 45.0, "South",                   "South-East");
-        compareAngle(-22.5, "North-North-West",        "North");
-        compareAngle(-22.5, "North_North_West",        "North");
-        compareAngle(-22.5, "North North West",        "North");
-        compareAngle( 90.0, "North along 90 deg East", "North along 0 deg");
-        compareAngle( 90.0, "South along 180 deg",     "South along 90 deg West");
-        compareAngle(   90, "North along 90°E",        "North along 0°");
-        compareAngle(  135, "North along 90°E",        "North along 45°W");
-        compareAngle( -135, "North along 45°W",        "North along 90°E");
+        assertAngleEquals( 90.0, "West",                    "South");
+        assertAngleEquals(-90.0, "South",                   "West");
+        assertAngleEquals( 45.0, "South",                   "South-East");
+        assertAngleEquals(-22.5, "North-North-West",        "North");
+        assertAngleEquals(-22.5, "North_North_West",        "North");
+        assertAngleEquals(-22.5, "North North West",        "North");
+        assertAngleEquals( 90.0, "North along 90 deg East", "North along 0 deg");
+        assertAngleEquals( 90.0, "South along 180 deg",     "South along 90 deg West");
+        assertAngleEquals(   90, "North along 90°E",        "North along 0°");
+        assertAngleEquals(  135, "North along 90°E",        "North along 45°W");
+        assertAngleEquals( -135, "North along 45°W",        "North along 90°E");
     }
 
     /**
-     * Compare the angle between the specified directions.
+     * Asserts that the angle between the parsed directions is equals to the given value.
+     * This method tests also the angle by interchanging the axis directions.
      */
-    private static void compareAngle(final double expected, final String source, final String target) {
+    private static void assertAngleEquals(final double expected, final String source, final String target) {
         final AxisDirection dir1 = parseAxisDirection(source);
         final AxisDirection dir2 = parseAxisDirection(target);
         assertNotNull(source, dir1);
         assertNotNull(target, dir2);
-        assertEquals(expected, angle(dir1, dir2), STRICT);
+        assertAngleEquals(expected, dir1, dir2);
+    }
+
+    /**
+     * Asserts that the angle between the given directions is equals to the given value.
+     * This method tests also the angle by interchanging the given directions.
+     */
+    private static void assertAngleEquals(final double expected, final AxisDirection source, final AxisDirection target) {
+        assertEquals(+expected, angle(source, target), STRICT);
+        assertEquals(-expected, angle(target, source), STRICT);
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCartesianCSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCartesianCSTest.java?rev=1557278&r1=1557277&r2=1557278&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCartesianCSTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCartesianCSTest.java [UTF-8] Fri Jan 10 23:10:19 2014
@@ -38,7 +38,7 @@ import static org.apache.sis.test.TestUt
  * @version 0.4
  * @module
  */
-@DependsOn(DefaultCoordinateSystemAxisTest.class)
+@DependsOn(AbstractCSTest.class)
 public final strictfp class DefaultCartesianCSTest extends XMLTestCase {
     /**
      * An XML file in this package containing a Cartesian coordinate system definition.

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCSTest.java?rev=1557278&r1=1557277&r2=1557278&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCSTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCSTest.java [UTF-8] Fri Jan 10 23:10:19 2014
@@ -36,7 +36,7 @@ import static org.apache.sis.test.TestUt
  * @version 0.4
  * @module
  */
-@DependsOn(DefaultCoordinateSystemAxisTest.class)
+@DependsOn(AbstractCSTest.class)
 public final strictfp class DefaultEllipsoidalCSTest extends XMLTestCase {
     /**
      * An XML file in this package containing an ellipsoidal coordinate system definition.

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=1557278&r1=1557277&r2=1557278&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] Fri Jan 10 23:10:19 2014
@@ -63,6 +63,8 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.datum.DefaultGeodeticDatumTest.class,
     org.apache.sis.referencing.cs.DirectionAlongMeridianTest.class,
     org.apache.sis.referencing.cs.DefaultCoordinateSystemAxisTest.class,
+    org.apache.sis.referencing.cs.ComparableAxisWrapperTest.class,
+    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.CoordinateSystemsTest.class,



Mime
View raw message