sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1558587 [2/3] - in /sis/trunk: ./ core/sis-referencing/src/main/java/org/apache/sis/geometry/ core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ core/sis-referencing/src/main/java/org/apache/sis/referencing/ core/sis-r...
Date Wed, 15 Jan 2014 22:05:01 GMT
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java [UTF-8] Wed Jan 15 22:04:59 2014
@@ -17,6 +17,7 @@
 package org.apache.sis.referencing.cs;
 
 import java.util.Map;
+import java.util.EnumMap;
 import java.util.Arrays;
 import javax.measure.unit.SI;
 import javax.measure.unit.Unit;
@@ -105,6 +106,14 @@ public class AbstractCS extends Abstract
     private final CoordinateSystemAxis[] axes;
 
     /**
+     * Other coordinate systems derived from this coordinate systems for other axes conventions.
+     * Created only when first needed.
+     *
+     * @see #forConvention(AxesConvention)
+     */
+    private transient Map<AxesConvention,AbstractCS> derived;
+
+    /**
      * Constructs a new object in which every attributes are set to a null or empty value.
      * <strong>This is not a valid object.</strong> This constructor is strictly reserved
      * to JAXB, which will assign values to the fields using reflexion.
@@ -180,14 +189,16 @@ public class AbstractCS extends Abstract
                 }
             }
             /*
-             * Ensures there is no axis along the same direction
-             * (e.g. two North axes, or an East and a West axis).
+             * Ensures there is no axis along the same direction (e.g. two North axes, or an East and a West axis).
+             * An exception to this rule is the time axis, since ISO 19107 explicitely allows compound CRS to have
+             * more than one time axis. Such case happen in meteorological models.
              */
             final AxisDirection dir = AxisDirections.absolute(direction);
             if (!dir.equals(AxisDirection.OTHER)) {
                 for (int j=i; --j>=0;) {
                     final AxisDirection other = axes[j].getDirection();
-                    if (dir.equals(AxisDirections.absolute(other))) {
+                    final AxisDirection abs = AxisDirections.absolute(other);
+                    if (dir.equals(abs) && !abs.equals(AxisDirection.FUTURE)) {
                         throw new IllegalArgumentException(Errors.format(
                                 Errors.Keys.ColinearAxisDirections_2, direction, other));
                     }
@@ -220,6 +231,42 @@ public class AbstractCS extends Abstract
     }
 
     /**
+     * Returns a SIS coordinate system implementation with the values of the given arbitrary implementation.
+     * This method performs the first applicable actions in the following choices:
+     *
+     * <ul>
+     *   <li>If the given object is {@code null}, then this method returns {@code null}.</li>
+     *   <li>Otherwise if the given object is is an instance of
+     *       {@link org.opengis.referencing.cs.AffineCS},
+     *       {@link org.opengis.referencing.cs.CartesianCS},
+     *       {@link org.opengis.referencing.cs.SphericalCS},
+     *       {@link org.opengis.referencing.cs.EllipsoidalCS},
+     *       {@link org.opengis.referencing.cs.CylindricalCS},
+     *       {@link org.opengis.referencing.cs.PolarCS},
+     *       {@link org.opengis.referencing.cs.LinearCS},
+     *       {@link org.opengis.referencing.cs.VerticalCS},
+     *       {@link org.opengis.referencing.cs.TimeCS} or
+     *       {@link org.opengis.referencing.cs.UserDefinedCS},
+     *       then this method delegates to the {@code castOrCopy(…)} method of the corresponding SIS subclass.
+     *       Note that if the given object implements more than one of the above-cited interfaces,
+     *       then the {@code castOrCopy(…)} method to be used is unspecified.</li>
+     *   <li>Otherwise if the given object is already an instance of
+     *       {@code AbstractCS}, then it is returned unchanged.</li>
+     *   <li>Otherwise a new {@code AbstractCS} instance is created using the
+     *       {@linkplain #AbstractCS(CoordinateSystem) copy constructor}
+     *       and returned. Note that this is a <cite>shallow</cite> copy operation, since the other
+     *       properties contained in the given object are not recursively copied.</li>
+     * </ul>
+     *
+     * @param  object The object to get as a SIS implementation, or {@code null} if none.
+     * @return A SIS implementation containing the values of the given object (may be the
+     *         given object itself), or {@code null} if the argument was null.
+     */
+    public static AbstractCS castOrCopy(final CoordinateSystem object) {
+        return SubTypes.castOrCopy(object);
+    }
+
+    /**
      * Returns {@link #VALID} if the given argument values are allowed for an axis in this coordinate system,
      * or an {@code INVALID_*} error code otherwise. This method is invoked at construction time for checking
      * argument validity. The default implementation returns {@code VALID} in all cases. Subclasses override
@@ -274,6 +321,48 @@ public class AbstractCS extends Abstract
     }
 
     /**
+     * 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}.
+     *
+     * @param  convention The axes convention for which a coordinate system is desired.
+     * @return A coordinate system compatible with the given convention (may be {@code this}).
+     *
+     * @see org.apache.sis.referencing.crs.AbstractCRS#forConvention(AxesConvention)
+     */
+    public synchronized AbstractCS forConvention(final AxesConvention convention) {
+        ensureNonNull("convention", convention);
+        if (derived == null) {
+            derived = new EnumMap<AxesConvention,AbstractCS>(AxesConvention.class);
+        }
+        AbstractCS cs = derived.get(convention);
+        if (cs == null) {
+            switch (convention) {
+                case NORMALIZED:     cs = Normalizer.normalize(this, true);  break;
+                case RIGHT_HANDED:   cs = Normalizer.normalize(this, false); break;
+                case POSITIVE_RANGE: cs = Normalizer.shiftAxisRange(this);   break;
+                default: throw new AssertionError(convention);
+            }
+            for (final AbstractCS existing : derived.values()) {
+                if (cs.equals(existing)) {
+                    cs = existing;
+                    break;
+                }
+            }
+            derived.put(convention, cs);
+        }
+        return cs;
+    }
+
+    /**
+     * Returns a coordinate system of the same type than this CS but with different axes.
+     * This method shall be overridden by all {@code AbstractCS} subclasses in this package.
+     */
+    AbstractCS createSameType(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        return new AbstractCS(properties, axes);
+    }
+
+    /**
      * Compares the specified object with this coordinate system for equality.
      *
      * @param  object The object to compare to {@code this}.

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java [UTF-8] Wed Jan 15 22:04:59 2014
@@ -24,6 +24,8 @@ import javax.measure.converter.Conversio
 import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.operation.Matrix;
+import org.apache.sis.measure.Angle;
+import org.apache.sis.measure.ElevationAngle;
 import org.apache.sis.measure.Units;
 import org.apache.sis.util.Static;
 import org.apache.sis.util.Classes;
@@ -49,11 +51,6 @@ import org.apache.sis.internal.jdk7.Obje
  */
 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() {
@@ -101,12 +98,12 @@ public final class CoordinateSystems ext
     }
 
     /**
-     * Returns the arithmetic (counterclockwise) angle from the first axis direction to the second direction,
-     * 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.
+     * Returns the arithmetic (counterclockwise) angle from the first axis direction to the second direction.
+     * This method returns a value between -180° and +180°, or {@code null} 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>
+     * {@section Horizontal directions}
+     * For any pair of compass directions which are not opposite directions, a positive angle denotes
+     * a right-handed system while a negative angle denotes a left-handed system. Examples:
      *
      * <ul>
      *   <li>The angle from {@link AxisDirection#EAST EAST} to {@link AxisDirection#NORTH NORTH} is 90°</li>
@@ -114,51 +111,83 @@ 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 Horizontal and vertical directions}
+     * By convention this method defines the angle from any compass direction to the {@link AxisDirection#UP UP}
+     * vertical direction as 90°, and the angle of any compass direction to the {@link AxisDirection#DOWN DOWN}
+     * vertical direction as -90°. The sign of those angles gives no indication about whether the coordinate system
+     * is right-handed or left-handed. Those angles are returned as instances of {@link ElevationAngle}.
+     *
+     * <p>All angles are approximative since this method does not take the Earth ellipsoidal or geoidal shape in
+     * account.</p>
+     *
+     * {@section Invariants}
+     * For any non-null return value:
+     * <ul>
+     *   <li>{@code angle(A, A) = 0°}</li>
+     *   <li>{@code angle(A, opposite(A)) = ±180°}</li>
+     *   <li>{@code angle(A, B) = -angle(B, A)}</li>
+     * </ul>
+     *
      * @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
      *         the source direction in order to make it point toward the target direction, or
-     *         {@link Double#NaN} if this value can not be computed.
+     *         {@code null} if this value can not be computed.
      */
-    public static double angle(final AxisDirection source, final AxisDirection target) {
+    public static Angle 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);
-        }
-        // Tests for "South along 90 deg East", etc. directions.
-        final DirectionAlongMeridian src = DirectionAlongMeridian.parse(source);
-        if (src != null) {
-            final DirectionAlongMeridian tgt = DirectionAlongMeridian.parse(target);
-            if (tgt != null) {
-                return src.getAngle(tgt);
-            }
+        /*
+         * 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 new Angle(c * (360.0 / AxisDirections.COMPASS_COUNT));
         }
-        return Double.NaN;
-    }
-
-    /**
-     * 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;
+        /*
+         * Check for GEOCENTRIC_X, GEOCENTRIC_Y, GEOCENTRIC_Z.
+         */
+        c = AxisDirections.angleForGeocentric(source, target);
+        if (c != Integer.MIN_VALUE) {
+            return new Angle(c * 90);
+        }
+        /*
+         * Check for DISPLAY_UP, DISPLAY_DOWN, etc. assuming a flat screen.
+         * Note that we do not check for grid directions (COLUMN_POSITIVE,
+         * ROW_POSITIVE, etc.) because the grid geometry may be anything.
+         */
+        c = AxisDirections.angleForDisplay(source, target);
+        if (c != Integer.MIN_VALUE) {
+            return new Angle(c * (360 / AxisDirections.DISPLAY_COUNT));
+        }
+        /*
+         * Check for "South along 90° East", etc. directions. Note that this
+         * check may perform a relatively costly parsing of axis direction name.
+         */
+        final DirectionAlongMeridian srcMeridian = DirectionAlongMeridian.parse(source);
+        final DirectionAlongMeridian tgtMeridian = DirectionAlongMeridian.parse(target);
+        if (srcMeridian != null && tgtMeridian != null) {
+            return new Angle(srcMeridian.angle(tgtMeridian));
+        }
+        /*
+         * Check for UP and DOWN, with special case if one of the direction is horizontal
+         * (either a compass direction of a direction along a meridian).
+         */
+        final boolean srcVrt = AxisDirections.isVertical(source);
+        final boolean tgtVrt = AxisDirections.isVertical(target);
+        if (tgtVrt) {
+            if (srcVrt) {
+                return new Angle(source.equals(target) ? 0 : target.equals(AxisDirection.UP) ? 180 : -180);
+            } else if (AxisDirections.isCompass(source) || srcMeridian != null) {
+                return target.equals(AxisDirection.UP) ? ElevationAngle.ZENITH : ElevationAngle.NADIR;
+            }
+        } else if (srcVrt) {
+            if (AxisDirections.isCompass(target) || tgtMeridian != null) {
+                return source.equals(AxisDirection.UP) ? ElevationAngle.NADIR : ElevationAngle.ZENITH;
             }
         }
-        return Integer.MIN_VALUE;
+        return null;
     }
 
     /**

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java [UTF-8] Wed Jan 15 22:04:59 2014
@@ -208,4 +208,23 @@ public class DefaultAffineCS extends Abs
     public Class<? extends AffineCS> getInterface() {
         return AffineCS.class;
     }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @return {@inheritDoc}
+     */
+    @Override
+    public DefaultAffineCS forConvention(final AxesConvention convention) {
+        return (DefaultAffineCS) super.forConvention(convention);
+    }
+
+    /**
+     * Returns a coordinate system of the same class than this CS but with different axes.
+     * This method shall be overridden by all {@code AffineCS} subclasses in this package.
+     */
+    @Override
+    AbstractCS createSameType(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        return new DefaultAffineCS(properties, axes);
+    }
 }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java [UTF-8] Wed Jan 15 22:04:59 2014
@@ -22,8 +22,8 @@ import javax.xml.bind.annotation.XmlRoot
 import org.opengis.referencing.cs.CartesianCS;
 import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
-import org.apache.sis.internal.referencing.Formulas;
 import org.apache.sis.util.resources.Errors;
+import org.apache.sis.measure.Angle;
 
 
 /**
@@ -75,6 +75,15 @@ public class DefaultCartesianCS extends 
     }
 
     /**
+     * Creates a new coordinate system from an arbitrary number of axes. This constructor is for
+     * implementations of the {@link #createSameType(Map, CoordinateSystemAxis[])} method only,
+     * because it does not verify the number of axes.
+     */
+    private DefaultCartesianCS(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        super(properties, axes);
+    }
+
+    /**
      * Constructs a one-dimensional coordinate system from a set of properties.
      * The properties map is given unchanged to the
      * {@linkplain AbstractCS#AbstractCS(Map,CoordinateSystemAxis[]) super-class constructor}.
@@ -194,8 +203,13 @@ public class DefaultCartesianCS extends 
             final AxisDirection axis0 = getAxis(i).getDirection();
             for (int j=i; ++j<dimension;) {
                 final AxisDirection axis1 = getAxis(j).getDirection();
-                final double angle = CoordinateSystems.angle(axis0, axis1); // May be NaN, which we accept.
-                if (Math.abs(Math.abs(angle) - 90) > Formulas.ANGULAR_TOLERANCE) {
+                final Angle angle = CoordinateSystems.angle(axis0, axis1);
+                /*
+                 * The angle may be null for grid directions (COLUMN_POSITIVE, COLUMN_NEGATIVE,
+                 * ROW_POSITIVE, ROW_NEGATIVE). We conservatively accept those directions even if
+                 * they are not really for Cartesian CS because we do not know the grid geometry.
+                 */
+                if (angle != null && Math.abs(angle.degrees()) != 90) {
                     throw new IllegalArgumentException(Errors.format(
                             Errors.Keys.NonPerpendicularDirections_2, axis0, axis1));
                 }
@@ -217,4 +231,22 @@ public class DefaultCartesianCS extends 
     public Class<? extends CartesianCS> getInterface() {
         return CartesianCS.class;
     }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @return {@inheritDoc}
+     */
+    @Override
+    public DefaultCartesianCS forConvention(final AxesConvention convention) {
+        return (DefaultCartesianCS) super.forConvention(convention);
+    }
+
+    /**
+     * Returns a coordinate system of the same class than this CS but with different axes.
+     */
+    @Override
+    final AbstractCS createSameType(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        return new DefaultCartesianCS(properties, axes);
+    }
 }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCompoundCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCompoundCS.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCompoundCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCompoundCS.java [UTF-8] Wed Jan 15 22:04:59 2014
@@ -18,11 +18,13 @@ package org.apache.sis.referencing.cs;
 
 import java.util.Map;
 import java.util.List;
+import javax.measure.unit.Unit;
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.apache.sis.internal.util.UnmodifiableArrayList;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.Workaround;
+import org.apache.sis.util.iso.Types;
 
 import static java.util.Collections.singletonMap;
 import static org.apache.sis.util.ArgumentChecks.*;
@@ -111,27 +113,49 @@ public class DefaultCompoundCS extends A
      * @param components The set of coordinate system.
      */
     public DefaultCompoundCS(CoordinateSystem... components) {
-        super(singletonMap(NAME_KEY, nameFor(components = clone(components))), getAxes(components));
-        this.components = UnmodifiableArrayList.wrap(components);
+        this(components = clone(components), getAxes(components));
     }
 
     /**
-     * Constructs a name from a merge of the name of all coordinate systems.
      * This is a work around for RFE #4093999 in Sun's bug database
      * ("Relax constraint on placement of this()/super() call in constructors").
      *
      * @param components The coordinate systems.
      */
     @Workaround(library="JDK", version="1.7")
-    private static String nameFor(final CoordinateSystem[] components) {
-        final StringBuilder buffer = new StringBuilder();
-        for (int i=0; i<components.length; i++) {
-            if (buffer.length() != 0) {
-                buffer.append(" / ");
+    private DefaultCompoundCS(final CoordinateSystem[] components, final CoordinateSystemAxis[] axes) {
+        super(singletonMap(NAME_KEY, createName(new StringBuilder(60).append("Compound CS"), axes)), axes);
+        this.components = UnmodifiableArrayList.wrap(components);
+    }
+
+    /**
+     * Returns a name for a coordinate system.
+     * Examples:
+     *
+     * <ul>
+     *   <li>Ellipsoidal CS: North (°), East (°).</li>
+     *   <li>Cartesian CS: East (km), North (km).</li>
+     *   <li>Compound CS: East (km), North (km), Up (m).</li>
+     * </ul>
+     *
+     * @param  buffer A buffer filled with the name header.
+     * @param  axes The axes.
+     * @return A name for the given coordinate system type and axes.
+     */
+    static String createName(final StringBuilder buffer, final CoordinateSystemAxis[] axes) {
+        String separator = ": ";
+        for (final CoordinateSystemAxis axis : axes) {
+            buffer.append(separator).append(Types.getCodeLabel(axis.getDirection()));
+            separator = ", ";
+            final Unit<?> unit = axis.getUnit();
+            if (unit != null) {
+                final String symbol = unit.toString();
+                if (!symbol.isEmpty()) {
+                    buffer.append(" (").append(symbol).append(')');
+                }
             }
-            buffer.append(components[i].getName().getCode());
         }
-        return buffer.toString();
+        return buffer.append('.').toString();
     }
 
     /**
@@ -175,6 +199,16 @@ public class DefaultCompoundCS extends A
         return components;
     }
 
+    /*
+     * Do not override createSameType(…) and forConvention(…) because we can not create a new DefaultCompoundCS
+     * without knownledge of the CoordinateSystem components to give to it. It would be possible to recursively
+     * invoke components[i].forConvention(…), but it would be useless to perform such decomposition here because
+     * DefaultCompoundCRS will need to perform its own decomposition anyway.
+     *
+     * If the user invokes DefaultCompoundCS.forConvention(…) anyway, he will get an AbstractCS instance, which
+     * is not that bad.
+     */
+
     /**
      * Compares this coordinate system with the specified object for equality.
      *

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java [UTF-8] Wed Jan 15 22:04:59 2014
@@ -605,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 φ.

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCylindricalCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCylindricalCS.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCylindricalCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCylindricalCS.java [UTF-8] Wed Jan 15 22:04:59 2014
@@ -69,6 +69,15 @@ public class DefaultCylindricalCS extend
     }
 
     /**
+     * Creates a new coordinate system from an arbitrary number of axes. This constructor is for
+     * implementations of the {@link #createSameType(Map, CoordinateSystemAxis[])} method only,
+     * because it does not verify the number of axes.
+     */
+    private DefaultCylindricalCS(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        super(properties, axes);
+    }
+
+    /**
      * Constructs a three-dimensional coordinate system from a set of properties.
      * The properties map is given unchanged to the
      * {@linkplain AbstractCS#AbstractCS(Map,CoordinateSystemAxis[]) super-class constructor}.
@@ -178,4 +187,22 @@ public class DefaultCylindricalCS extend
     public Class<? extends CylindricalCS> getInterface() {
         return CylindricalCS.class;
     }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @return {@inheritDoc}
+     */
+    @Override
+    public DefaultCylindricalCS forConvention(final AxesConvention convention) {
+        return (DefaultCylindricalCS) super.forConvention(convention);
+    }
+
+    /**
+     * Returns a coordinate system of the same class than this CS but with different axes.
+     */
+    @Override
+    final AbstractCS createSameType(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        return new DefaultCylindricalCS(properties, axes);
+    }
 }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java [UTF-8] Wed Jan 15 22:04:59 2014
@@ -69,6 +69,15 @@ public class DefaultEllipsoidalCS extend
     }
 
     /**
+     * Creates a new coordinate system from an arbitrary number of axes. This constructor is for
+     * implementations of the {@link #createSameType(Map, CoordinateSystemAxis[])} method only,
+     * because it does not verify the number of axes.
+     */
+    private DefaultEllipsoidalCS(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        super(properties, axes);
+    }
+
+    /**
      * Constructs a two-dimensional coordinate system from a set of properties.
      * The properties map is given unchanged to the
      * {@linkplain AbstractCS#AbstractCS(Map,CoordinateSystemAxis[]) super-class constructor}.
@@ -198,4 +207,22 @@ public class DefaultEllipsoidalCS extend
     public Class<? extends EllipsoidalCS> getInterface() {
         return EllipsoidalCS.class;
     }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @return {@inheritDoc}
+     */
+    @Override
+    public DefaultEllipsoidalCS forConvention(final AxesConvention convention) {
+        return (DefaultEllipsoidalCS) super.forConvention(convention);
+    }
+
+    /**
+     * Returns a coordinate system of the same class than this CS but with different axes.
+     */
+    @Override
+    final AbstractCS createSameType(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        return new DefaultEllipsoidalCS(properties, axes);
+    }
 }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultLinearCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultLinearCS.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultLinearCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultLinearCS.java [UTF-8] Wed Jan 15 22:04:59 2014
@@ -68,6 +68,15 @@ public class DefaultLinearCS extends Abs
     }
 
     /**
+     * Creates a new coordinate system from an arbitrary number of axes. This constructor is for
+     * implementations of the {@link #createSameType(Map, CoordinateSystemAxis[])} method only,
+     * because it does not verify the number of axes.
+     */
+    private DefaultLinearCS(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        super(properties, axes);
+    }
+
+    /**
      * Constructs a coordinate system from a set of properties.
      * The properties map is given unchanged to the
      * {@linkplain AbstractCS#AbstractCS(Map,CoordinateSystemAxis[]) super-class constructor}.
@@ -171,4 +180,22 @@ public class DefaultLinearCS extends Abs
     public Class<? extends LinearCS> getInterface() {
         return LinearCS.class;
     }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @return {@inheritDoc}
+     */
+    @Override
+    public DefaultLinearCS forConvention(final AxesConvention convention) {
+        return (DefaultLinearCS) super.forConvention(convention);
+    }
+
+    /**
+     * Returns a coordinate system of the same class than this CS but with different axes.
+     */
+    @Override
+    final AbstractCS createSameType(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        return new DefaultLinearCS(properties, axes);
+    }
 }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultPolarCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultPolarCS.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultPolarCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultPolarCS.java [UTF-8] Wed Jan 15 22:04:59 2014
@@ -67,6 +67,15 @@ public class DefaultPolarCS extends Abst
     }
 
     /**
+     * Creates a new coordinate system from an arbitrary number of axes. This constructor is for
+     * implementations of the {@link #createSameType(Map, CoordinateSystemAxis[])} method only,
+     * because it does not verify the number of axes.
+     */
+    private DefaultPolarCS(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        super(properties, axes);
+    }
+
+    /**
      * Constructs a two-dimensional coordinate system from a set of properties.
      * The properties map is given unchanged to the
      * {@linkplain AbstractCS#AbstractCS(Map,CoordinateSystemAxis[]) super-class constructor}.
@@ -174,4 +183,22 @@ public class DefaultPolarCS extends Abst
     public Class<? extends PolarCS> getInterface() {
         return PolarCS.class;
     }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @return {@inheritDoc}
+     */
+    @Override
+    public DefaultPolarCS forConvention(final AxesConvention convention) {
+        return (DefaultPolarCS) super.forConvention(convention);
+    }
+
+    /**
+     * Returns a coordinate system of the same class than this CS but with different axes.
+     */
+    @Override
+    final AbstractCS createSameType(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        return new DefaultPolarCS(properties, axes);
+    }
 }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultSphericalCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultSphericalCS.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultSphericalCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultSphericalCS.java [UTF-8] Wed Jan 15 22:04:59 2014
@@ -71,6 +71,15 @@ public class DefaultSphericalCS extends 
     }
 
     /**
+     * Creates a new coordinate system from an arbitrary number of axes. This constructor is for
+     * implementations of the {@link #createSameType(Map, CoordinateSystemAxis[])} method only,
+     * because it does not verify the number of axes.
+     */
+    private DefaultSphericalCS(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        super(properties, axes);
+    }
+
+    /**
      * Constructs a three-dimensional coordinate system from a set of properties.
      * The properties map is given unchanged to the
      * {@linkplain AbstractCS#AbstractCS(Map,CoordinateSystemAxis[]) super-class constructor}.
@@ -178,4 +187,22 @@ public class DefaultSphericalCS extends 
     public Class<? extends SphericalCS> getInterface() {
         return SphericalCS.class;
     }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @return {@inheritDoc}
+     */
+    @Override
+    public DefaultSphericalCS forConvention(final AxesConvention convention) {
+        return (DefaultSphericalCS) super.forConvention(convention);
+    }
+
+    /**
+     * Returns a coordinate system of the same class than this CS but with different axes.
+     */
+    @Override
+    final AbstractCS createSameType(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        return new DefaultSphericalCS(properties, axes);
+    }
 }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultTimeCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultTimeCS.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultTimeCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultTimeCS.java [UTF-8] Wed Jan 15 22:04:59 2014
@@ -70,6 +70,15 @@ public class DefaultTimeCS extends Abstr
     }
 
     /**
+     * Creates a new coordinate system from an arbitrary number of axes. This constructor is for
+     * implementations of the {@link #createSameType(Map, CoordinateSystemAxis[])} method only,
+     * because it does not verify the number of axes.
+     */
+    private DefaultTimeCS(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        super(properties, axes);
+    }
+
+    /**
      * Constructs a coordinate system from a set of properties.
      * The properties map is given unchanged to the
      * {@linkplain AbstractCS#AbstractCS(Map,CoordinateSystemAxis[]) super-class constructor}.
@@ -171,4 +180,22 @@ public class DefaultTimeCS extends Abstr
     public Class<? extends TimeCS> getInterface() {
         return TimeCS.class;
     }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @return {@inheritDoc}
+     */
+    @Override
+    public DefaultTimeCS forConvention(final AxesConvention convention) {
+        return (DefaultTimeCS) super.forConvention(convention);
+    }
+
+    /**
+     * Returns a coordinate system of the same class than this CS but with different axes.
+     */
+    @Override
+    final AbstractCS createSameType(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        return new DefaultTimeCS(properties, axes);
+    }
 }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java [UTF-8] Wed Jan 15 22:04:59 2014
@@ -54,6 +54,15 @@ public class DefaultUserDefinedCS extend
     }
 
     /**
+     * Creates a new coordinate system from an arbitrary number of axes. This constructor is for
+     * implementations of the {@link #createSameType(Map, CoordinateSystemAxis[])} method only,
+     * because it does not verify the number of axes.
+     */
+    private DefaultUserDefinedCS(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        super(properties, axes);
+    }
+
+    /**
      * Constructs a two-dimensional coordinate system from a set of properties.
      * The properties map is given unchanged to the
      * {@linkplain AbstractCS#AbstractCS(Map,CoordinateSystemAxis[]) super-class constructor}.
@@ -160,4 +169,22 @@ public class DefaultUserDefinedCS extend
     public Class<? extends UserDefinedCS> getInterface() {
         return UserDefinedCS.class;
     }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @return {@inheritDoc}
+     */
+    @Override
+    public DefaultUserDefinedCS forConvention(final AxesConvention convention) {
+        return (DefaultUserDefinedCS) super.forConvention(convention);
+    }
+
+    /**
+     * Returns a coordinate system of the same class than this CS but with different axes.
+     */
+    @Override
+    final AbstractCS createSameType(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        return new DefaultUserDefinedCS(properties, axes);
+    }
 }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultVerticalCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultVerticalCS.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultVerticalCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultVerticalCS.java [UTF-8] Wed Jan 15 22:04:59 2014
@@ -82,6 +82,15 @@ public class DefaultVerticalCS extends A
     }
 
     /**
+     * Creates a new coordinate system from an arbitrary number of axes. This constructor is for
+     * implementations of the {@link #createSameType(Map, CoordinateSystemAxis[])} method only,
+     * because it does not verify the number of axes.
+     */
+    private DefaultVerticalCS(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        super(properties, axes);
+    }
+
+    /**
      * Constructs a coordinate system from a set of properties.
      * The properties map is given unchanged to the
      * {@linkplain AbstractCS#AbstractCS(Map,CoordinateSystemAxis[]) super-class constructor}.
@@ -183,4 +192,22 @@ public class DefaultVerticalCS extends A
     public Class<? extends VerticalCS> getInterface() {
         return VerticalCS.class;
     }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @return {@inheritDoc}
+     */
+    @Override
+    public DefaultVerticalCS forConvention(final AxesConvention convention) {
+        return (DefaultVerticalCS) super.forConvention(convention);
+    }
+
+    /**
+     * Returns a coordinate system of the same class than this CS but with different axes.
+     */
+    @Override
+    final AbstractCS createSameType(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        return new DefaultVerticalCS(properties, axes);
+    }
 }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DirectionAlongMeridian.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DirectionAlongMeridian.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DirectionAlongMeridian.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DirectionAlongMeridian.java [UTF-8] Wed Jan 15 22:04:59 2014
@@ -21,6 +21,7 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import org.opengis.referencing.cs.AxisDirection;
 import org.apache.sis.util.iso.Types;
+import org.apache.sis.measure.Longitude;
 import org.apache.sis.internal.util.Numerics;
 import org.apache.sis.internal.referencing.AxisDirections;
 
@@ -127,7 +128,7 @@ final class DirectionAlongMeridian imple
             // since we are supposed to return 'null' in this situation.
             return null;
         }
-        if (!(meridian >= -180 && meridian <= 180)) {
+        if (!(meridian >= Longitude.MIN_VALUE && meridian <= Longitude.MAX_VALUE)) {
             // Meridian is NaN or is not in the valid range.
             return null;
         }
@@ -172,24 +173,14 @@ final class DirectionAlongMeridian imple
      *
      * {@example The angle from "<cite>North along 90 deg East</cite>" to "<cite>North along 0 deg</cite> is 90°.}
      */
-    public double getAngle(final DirectionAlongMeridian other) {
+    public double angle(final DirectionAlongMeridian other) {
         if (!baseDirection.equals(other.baseDirection)) {
             return Double.NaN;
         }
         /*
-         * We want the following pair of axis:
-         * (NORTH along 90°E, NORTH along 0°)
-         * to give a positive angle of 90°
+         * Example: angle between (NORTH along 90°E, NORTH along 0°) shall be +90°
          */
-        double angle = meridian - other.meridian;
-        /*
-         * Forces to the [-180° .. +180°] range.
-         */
-        if (angle < -180) {
-            angle += 360;
-        } else if (angle > 180) {
-            angle -= 360;
-        }
+        double angle = Longitude.normalize(meridian - other.meridian);
         /*
          * Reverses the sign for axis oriented toward SOUTH,
          * so a positive angle is a right-handed system.
@@ -220,7 +211,7 @@ final class DirectionAlongMeridian imple
         if (c != 0) {
             return c;
         }
-        final double angle = getAngle(that);
+        final double angle = angle(that);
         if (angle < 0) return +1;  // Really the opposite sign.
         if (angle > 0) return -1;  // Really the opposite sign.
         return 0;
@@ -275,7 +266,7 @@ final class DirectionAlongMeridian imple
             buffer.append(md);
         }
         buffer.append('°');
-        if (md != 0 && md != 180) {
+        if (md != 0 && md != Longitude.MAX_VALUE) {
             buffer.append(meridian < 0 ? 'W' : 'E');
         }
         name = buffer.toString();

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/package-info.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/package-info.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/package-info.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/package-info.java [UTF-8] Wed Jan 15 22:04:59 2014
@@ -22,7 +22,11 @@
  *
  * <p>The root class in this package is {@link org.apache.sis.referencing.cs.AbstractCS}.
  * Various subclasses are defined for various kinds of mathematical rules that determine
- * how coordinates are associated to quantities such as angles and distances.</p>
+ * how coordinates are associated to quantities such as angles and distances.
+ * Those SIS subclasses provide additional methods that are not part of OGC/ISO specifications:</p>
+ * <ul>
+ *   <li>{@link org.apache.sis.referencing.cs.AbstractCS#forConvention AbstractCS.forConvention(AxesConvention)}</li>
+ * </ul>
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4 (derived from geotk-2.0)

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/SubTypes.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/SubTypes.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/SubTypes.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/SubTypes.java [UTF-8] Wed Jan 15 22:04:59 2014
@@ -67,7 +67,12 @@ final class SubTypes {
         if (object instanceof ImageDatum) {
             return DefaultImageDatum.castOrCopy((ImageDatum) object);
         }
-        // Intentionally tested after the sub-interfaces.
+        /*
+         * Intentionally check for AbstractDatum after the interfaces because user may have defined his own
+         * subclass implementing the interface. If we were checking for AbstractDatum before the interfaces,
+         * the returned instance could have been a user subclass without the JAXB annotations required for
+         * XML marshalling.
+         */
         if (object == null || object instanceof AbstractDatum) {
             return (AbstractDatum) object;
         }

Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/geometry/AbstractEnvelopeTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/geometry/AbstractEnvelopeTest.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/geometry/AbstractEnvelopeTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/geometry/AbstractEnvelopeTest.java [UTF-8] Wed Jan 15 22:04:59 2014
@@ -20,10 +20,10 @@ import java.awt.geom.Rectangle2D;
 import org.opengis.geometry.Envelope;
 import org.opengis.geometry.DirectPosition;
 import org.opengis.referencing.crs.GeographicCRS;
+import org.apache.sis.referencing.GeodeticObjects;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import static java.lang.Double.NaN;
@@ -55,10 +55,8 @@ public final strictfp class AbstractEnve
 
     /**
      * The coordinate reference system used for the tests.
-     *
-     * @todo Need to be assigned when we will have ported the CRS implementations.
      */
-    static final GeographicCRS WGS84 = null;
+    static final GeographicCRS WGS84 = GeodeticObjects.WGS84.normalizedGeographic();
 
     /**
      * Creates an envelope of the given type. The type shall be one of the
@@ -87,14 +85,15 @@ public final strictfp class AbstractEnve
                 break;
             }
             case SUBENVELOPE: {
-                final GeneralEnvelope ge = new GeneralEnvelope(5);
-                ge.setCoordinateReferenceSystem(WGS84);
+                GeneralEnvelope ge = new GeneralEnvelope(5);
                 ge.setRange(1, xmin, xmax);
                 ge.setRange(2, ymin, ymax);
                 ge.setRange(0, 2, 3); // Following values will be verified in verifyInvariants(…)
                 ge.setRange(3, 4, 6);
                 ge.setRange(4, 8, 9);
-                envelope = ge.subEnvelope(1, 3);
+                ge = ge.subEnvelope(1, 3);
+                ge.setCoordinateReferenceSystem(WGS84);
+                envelope = ge;
                 break;
             }
             default: throw new IllegalArgumentException(String.valueOf(type));
@@ -190,7 +189,6 @@ public final strictfp class AbstractEnve
      * }
      */
     @Test
-    @Ignore("The tested envelope needs to be associated to CRS:84")
     public void testCrossingAntiMeridian() {
         final DirectPosition2D inside  = new DirectPosition2D(18, 32);
         final DirectPosition2D outside = new DirectPosition2D( 3, 32);
@@ -253,7 +251,6 @@ public final strictfp class AbstractEnve
      * }
      */
     @Test
-    @Ignore("The tested envelope needs to be associated to CRS:84")
     public void testCrossingAntiMeridianTwice() {
         final DirectPosition2D inside  = new DirectPosition2D(18, 32);
         final DirectPosition2D outside = new DirectPosition2D( 3, 32);
@@ -309,7 +306,6 @@ public final strictfp class AbstractEnve
      * on the left and right sides.
      */
     @Test
-    @Ignore("The tested envelope needs to be associated to CRS:84")
     public void testCrossingAntiMeridianThreeTimes() {
         final DirectPosition2D wasInside = new DirectPosition2D(18, 32);
         final DirectPosition2D outside   = new DirectPosition2D( 3, 32);
@@ -415,7 +411,6 @@ public final strictfp class AbstractEnve
      * Tests a case crossing the anti-meridian crossing, from 0° to -0°.
      */
     @Test
-    @Ignore("The tested envelope needs to be associated to CRS:84")
     public void testRange360() {
         final DirectPosition2D inside     = new DirectPosition2D(18, 32);
         final DirectPosition2D wasOutside = new DirectPosition2D( 3, 32);
@@ -501,7 +496,6 @@ public final strictfp class AbstractEnve
      */
     @Test
     @DependsOnMethod("testToSimpleEnvelopesOnEmptyEnvelope")
-    @Ignore("The tested envelope needs to be associated to CRS:84")
     public void testToSimpleEnvelopesOverAntiMeridian() {
         for (int type=0; type<LAST; type++) {
             if (type != RECTANGLE) {

Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralDirectPositionTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralDirectPositionTest.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralDirectPositionTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralDirectPositionTest.java [UTF-8] Wed Jan 15 22:04:59 2014
@@ -19,7 +19,6 @@ package org.apache.sis.geometry;
 import java.util.Arrays;
 import org.apache.sis.test.TestCase;
 import org.apache.sis.test.DependsOn;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import static org.apache.sis.test.Assert.*;
@@ -41,7 +40,6 @@ public final strictfp class GeneralDirec
      * Tests the {@link GeneralDirectPosition#normalize()} method.
      */
     @Test
-    @Ignore("The tested position needs to be associated to CRS:84")
     public void testNormalize() {
         final GeneralDirectPosition position = new GeneralDirectPosition(WGS84);
         position.setCoordinate(300, -100);

Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java [UTF-8] Wed Jan 15 22:04:59 2014
@@ -22,13 +22,13 @@ import org.apache.sis.math.MathFunctions
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.apache.sis.test.DependsOnMethod;
-import org.junit.Ignore;
 import org.junit.Test;
 
 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 +46,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;
@@ -219,7 +214,6 @@ public strictfp class GeneralEnvelopeTes
      * {@link Envelope2D#createIntersection(Rectangle2D)} methods.
      */
     @Test
-    @Ignore("The tested envelope needs to be associated to CRS:84")
     public void testIntersection() {
         //  ┌─────────────┐
         //  │  ┌───────┐  │
@@ -284,7 +278,6 @@ public strictfp class GeneralEnvelopeTes
      * {@link Envelope2D#createUnion(Rectangle2D)} methods.
      */
     @Test
-    @Ignore("The tested envelope needs to be associated to CRS:84")
     public void testUnion() {
         //  ┌─────────────┐
         //  │  ┌───────┐  │
@@ -349,7 +342,6 @@ public strictfp class GeneralEnvelopeTes
      * {@link Envelope2D#add(Point2D)} methods.
      */
     @Test
-    @Ignore("The tested envelope needs to be associated to CRS:84")
     public void testAddPoint() {
         final double ymin=-20, ymax=30; // Will not change anymore
         final GeneralEnvelope  e = create(20, ymin,  80, ymax);
@@ -379,7 +371,6 @@ public strictfp class GeneralEnvelopeTes
      * Tests the {@link GeneralEnvelope#normalize()} method.
      */
     @Test
-    @Ignore("The tested envelope needs to be associated to CRS:84")
     public void testNormalize() {
         GeneralEnvelope e = create(-100, -100, +100, +100);
         assertTrue(e.normalize());
@@ -405,7 +396,6 @@ public strictfp class GeneralEnvelopeTes
      * with an envelope having more then 360° of longitude.
      */
     @Test
-    @Ignore("The tested envelope needs to be associated to CRS:84")
     public void testNormalizeWorld() {
         GeneralEnvelope e = create(-195, -90, +170, +90); // -195° is equivalent to 165°
         assertTrue(e.normalize());
@@ -417,7 +407,6 @@ public strictfp class GeneralEnvelopeTes
      * Tests the {@link GeneralEnvelope#simplify()}.
      */
     @Test
-    @Ignore("The tested envelope needs to be associated to CRS:84")
     public void testSimplify() {
         // Normal envelope: no change expected.
         GeneralEnvelope e = create(-100, -10, +100, +10);

Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/geometry/SubEnvelopeTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/geometry/SubEnvelopeTest.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/geometry/SubEnvelopeTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/geometry/SubEnvelopeTest.java [UTF-8] Wed Jan 15 22:04:59 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/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java [UTF-8] Wed Jan 15 22:04:59 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,42 @@ 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
+    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 +176,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

Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java [UTF-8] Wed Jan 15 22:04:59 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/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectsTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectsTest.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectsTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectsTest.java [UTF-8] Wed Jan 15 22:04:59 2014
@@ -18,6 +18,7 @@ package org.apache.sis.referencing;
 
 import java.util.Date;
 import org.opengis.referencing.crs.GeographicCRS;
+import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.datum.TemporalDatum;
 import org.opengis.referencing.datum.VerticalDatum;
 import org.opengis.referencing.datum.VerticalDatumType;
@@ -40,7 +41,7 @@ import static org.apache.sis.test.TestUt
  * @module
  */
 @DependsOn({
-  org.apache.sis.referencing.datum.DefaultGeodeticDatumTest.class,
+  org.apache.sis.referencing.crs.DefaultGeodeticCRSTest.class,
   org.apache.sis.referencing.datum.DefaultVerticalDatumTest.class,
   StandardDefinitionsTest.class
 })
@@ -55,9 +56,21 @@ public final strictfp class GeodeticObje
      */
     @Test
     public void testWGS84() {
-        final GeographicCRS crs = GeodeticObjects.WGS84.geographic();
-        Validators.validate(crs);
-        GeodeticObjectVerifier.assertIsWGS84(crs, false, true);
+        final GeographicCRS geographic = GeodeticObjects.WGS84.geographic();
+        Validators.validate(geographic);
+        GeodeticObjectVerifier.assertIsWGS84(geographic, false, true);
+        assertSame("Cached value", geographic, GeodeticObjects.WGS84.geographic());
+        /*
+         * Verifies the variant using (longitude, latitude) axis order.
+         */
+        final GeographicCRS normalized = GeodeticObjects.WGS84.normalizedGeographic();
+        Validators.validate(normalized);
+        assertSame(geographic.getDatum(), normalized.getDatum());
+        final CoordinateSystem φλ = geographic.getCoordinateSystem();
+        final CoordinateSystem λφ = normalized.getCoordinateSystem();
+        assertSame("Longitude", φλ.getAxis(1), λφ.getAxis(0));
+        assertSame("Latitude",  φλ.getAxis(0), λφ.getAxis(1));
+        assertSame("Cached value", normalized, GeodeticObjects.WGS84.normalizedGeographic());
     }
 
     /**

Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeodeticCRSTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeodeticCRSTest.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeodeticCRSTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeodeticCRSTest.java [UTF-8] Wed Jan 15 22:04:59 2014
@@ -37,6 +37,7 @@ import static org.apache.sis.test.Assert
  * @module
  */
 @DependsOn({
+    AbstractCRSTest.class,
     org.apache.sis.referencing.cs.DefaultEllipsoidalCSTest.class,
     org.apache.sis.referencing.datum.DefaultGeodeticDatumTest.class
 })

Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CommonAxes.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CommonAxes.java?rev=1558587&r1=1558586&r2=1558587&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CommonAxes.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CommonAxes.java [UTF-8] Wed Jan 15 22:04:59 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,13 @@ 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);
+
+    /**
+     * Identical to {@link #LONGITUDE} except for the range of longitude values.
+     */
+    public static final DefaultCoordinateSystemAxis SHIFTED_LONGITUDE = create("Longitude", "λ",
+            AxisDirection.EAST, NonSI.DEGREE_ANGLE, 0, 360, RangeMeaning.WRAPAROUND);
 
     /**
      * Default axis info for longitudes.
@@ -82,7 +88,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 +103,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 +120,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 +133,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 +154,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 +167,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 +185,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 +203,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 +221,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 +239,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 +257,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 +269,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 +285,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 +301,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 +317,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 +332,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 +345,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 +360,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 +373,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 +393,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 +401,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 +409,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 +417,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 +425,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 +433,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),



Mime
View raw message