sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1683837 [4/7] - in /sis/trunk: ./ application/sis-console/src/test/java/org/apache/sis/console/ core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ core/sis-metadata/src/...
Date Fri, 05 Jun 2015 18:41:32 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=1683837&r1=1683836&r2=1683837&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] Fri Jun  5 18:41:29 2015
@@ -65,7 +65,7 @@ import static org.apache.sis.util.Utilit
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4
- * @version 0.5
+ * @version 0.6
  * @module
  *
  * @see DefaultCoordinateSystemAxis
@@ -224,7 +224,7 @@ public class AbstractCS extends Abstract
     protected AbstractCS(final CoordinateSystem cs) {
         super(cs);
         if (cs instanceof AbstractCS) {
-            axes = ((AbstractCS) cs).axes; // Share the array.
+            axes = ((AbstractCS) cs).axes;  // Share the array.
         } else {
             axes = new CoordinateSystemAxis[cs.getDimension()];
             for (int i=0; i<axes.length; i++) {
@@ -340,12 +340,9 @@ public class AbstractCS extends Abstract
         }
         AbstractCS cs = derived.get(convention);
         if (cs == null) {
-            switch (convention) {
-                case NORMALIZED:              cs = Normalizer.normalize(this, true,  true);  break;
-                case CONVENTIONALLY_ORIENTED: cs = Normalizer.normalize(this, true,  false); break;
-                case RIGHT_HANDED:            cs = Normalizer.normalize(this, false, false); break;
-                case POSITIVE_RANGE:          cs = Normalizer.shiftAxisRange(this);          break;
-                default: throw new AssertionError(convention);
+            cs = Normalizer.forConvention(this, convention);
+            if (cs == null) {
+                cs = this;  // This coordinate system is already normalized.
             }
             for (final AbstractCS existing : derived.values()) {
                 if (cs.equals(existing)) {
@@ -359,17 +356,36 @@ public class AbstractCS extends Abstract
     }
 
     /**
-     * Returns a coordinate system of the same type than this CS but with different axes.
+     * Returns a coordinate system usually of the same type than this CS but with different axes.
      * This method shall be overridden by all {@code AbstractCS} subclasses in this package.
      *
+     * <p>This method returns a coordinate system of the same type if the number of axes is unchanged.
+     * But if the given {@code axes} array has less elements than this coordinate system dimension, then
+     * this method may return an other kind of coordinate system. See {@link AxisFilter} for an example.</p>
+     *
      * @param  axes The set of axes to give to the new coordinate system.
      * @return A new coordinate system of the same type than {@code this}, but using the given axes.
      */
-    AbstractCS createSameType(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+    AbstractCS createForAxes(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
         return new AbstractCS(properties, axes);
     }
 
     /**
+     * Convenience method for implementations of {@link #createForAxes(Map, CoordinateSystemAxis[])}
+     * when the resulting coordinate system would have an unexpected number of dimensions.
+     *
+     * @param properties The properties which was supposed to be given to the constructor.
+     * @param axes       The axes which was supposed to be given to the constructor.
+     * @param expected   The minimal expected number of dimensions (may be less than {@link #getDimension()}).
+     */
+    static IllegalArgumentException unexpectedDimension(final Map<String,?> properties,
+            final CoordinateSystemAxis[] axes, final int expected)
+    {
+        return new IllegalArgumentException(Errors.getResources(properties).getString(
+                Errors.Keys.MismatchedDimension_3, "filter(cs)", expected, axes.length));
+    }
+
+    /**
      * 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/AxesConvention.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java?rev=1683837&r1=1683836&r2=1683837&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java [UTF-8] Fri Jun  5 18:41:29 2015
@@ -16,8 +16,14 @@
  */
 package org.apache.sis.referencing.cs;
 
-import org.opengis.referencing.cs.AxisDirection;    // For javadoc
+import javax.measure.unit.Unit;
+import javax.measure.unit.SI;
+import javax.measure.unit.NonSI;
+import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.cs.CoordinateSystem; // For javadoc
+import org.opengis.referencing.cs.CoordinateSystemAxis;
+import org.apache.sis.internal.referencing.AxisDirections;
+import org.apache.sis.measure.Units;
 
 
 /**
@@ -102,13 +108,13 @@ import org.opengis.referencing.cs.Coordi
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.5
+ * @version 0.6
  * @module
  *
  * @see AbstractCS#forConvention(AxesConvention)
  * @see org.apache.sis.referencing.crs.AbstractCRS#forConvention(AxesConvention)
  */
-public enum AxesConvention {
+public enum AxesConvention implements AxisFilter {
     /**
      * Axes order, direction and units of measure are forced to commonly used pre-defined values.
      * This enum represents the following changes to apply on a coordinate system:
@@ -140,7 +146,32 @@ public enum AxesConvention {
      * @see CoordinateSystems#normalize(CoordinateSystem)
      * @see org.apache.sis.referencing.CommonCRS#normalizedGeographic()
      */
-    NORMALIZED,
+    NORMALIZED {
+        @Override
+        public boolean accept(final CoordinateSystemAxis axis) {
+            return true;
+        }
+
+        @Override
+        public Unit<?> getUnitReplacement(Unit<?> unit) {
+            if (Units.isLinear(unit)) {
+                unit = SI.METRE;
+            } else if (Units.isAngular(unit)) {
+                unit = NonSI.DEGREE_ANGLE;
+            } else if (Units.isTemporal(unit)) {
+                unit = NonSI.DAY;
+            }
+            return unit;
+        }
+
+        /*
+         * Same policy than AxesConvention.CONVENTIONALLY_ORIENTATED.
+         */
+        @Override
+        public AxisDirection getDirectionReplacement(final AxisDirection direction) {
+            return AxisDirections.isIntercardinal(direction) ? direction : AxisDirections.absolute(direction);
+        }
+    },
 
     /**
      * Axes are oriented toward conventional directions and ordered for a {@linkplain #RIGHT_HANDED right-handed}
@@ -189,7 +220,26 @@ public enum AxesConvention {
      *
      * @since 0.5
      */
-    CONVENTIONALLY_ORIENTED,
+    CONVENTIONALLY_ORIENTED {
+        @Override
+        public boolean accept(final CoordinateSystemAxis axis) {
+            return true;
+        }
+
+        @Override
+        public Unit<?> getUnitReplacement(final Unit<?> unit) {
+            return unit;
+        }
+
+        /*
+         * For now we do not touch to inter-cardinal directions (e.g. "North-East")
+         * because it is not clear which normalization policy would match common usage.
+         */
+        @Override
+        public AxisDirection getDirectionReplacement(final AxisDirection direction) {
+            return AxisDirections.isIntercardinal(direction) ? direction : AxisDirections.absolute(direction);
+        }
+    },
 
     /**
      * Axes are ordered for a <cite>right-handed</cite> coordinate system. Axis directions, ranges or ordinate values
@@ -218,7 +268,22 @@ public enum AxesConvention {
      * @see org.apache.sis.referencing.cs.CoordinateSystems#angle(AxisDirection, AxisDirection)
      * @see <a href="http://en.wikipedia.org/wiki/Right_hand_rule">Right-hand rule on Wikipedia</a>
      */
-    RIGHT_HANDED,
+    RIGHT_HANDED {
+        @Override
+        public boolean accept(final CoordinateSystemAxis axis) {
+            return true;
+        }
+
+        @Override
+        public Unit<?> getUnitReplacement(final Unit<?> unit) {
+            return unit;
+        }
+
+        @Override
+        public AxisDirection getDirectionReplacement(final AxisDirection direction) {
+            return direction;
+        }
+    },
 
     /**
      * Axes having a <cite>wraparound</cite>
@@ -243,5 +308,20 @@ public enum AxesConvention {
      *
      * @see org.opengis.referencing.cs.RangeMeaning#WRAPAROUND
      */
-    POSITIVE_RANGE
+    POSITIVE_RANGE {
+        @Override
+        public boolean accept(final CoordinateSystemAxis axis) {
+            return true;
+        }
+
+        @Override
+        public Unit<?> getUnitReplacement(final Unit<?> unit) {
+            return unit;
+        }
+
+        @Override
+        public AxisDirection getDirectionReplacement(final AxisDirection direction) {
+            return direction;
+        }
+    }
 }

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=1683837&r1=1683836&r2=1683837&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] Fri Jun  5 18:41:29 2015
@@ -43,6 +43,9 @@ import org.apache.sis.internal.jdk7.Obje
 
 /**
  * Utility methods working on {@link CoordinateSystem} objects and their axes.
+ * Those methods allow for example to {@linkplain #angle estimate an angle between two axes}
+ * or {@linkplain #swapAndScaleAxes determining the change of axis directions and units}
+ * between two coordinate systems.
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4
@@ -300,38 +303,71 @@ public final class CoordinateSystems ext
     }
 
     /**
-     * Returns a coordinate system with {@linkplain AxesConvention#NORMALIZED normalized} axis order and units.
-     * This method is typically used together with {@link #swapAndScaleAxes swapAndScaleAxes} for the creation
-     * of a transformation step before some
-     * {@linkplain org.apache.sis.referencing.operation.transform.AbstractMathTransform math transform}.
-     * Example:
+     * Returns a coordinate system derived from the given one but with a modified list of axes.
+     * The axes may be filtered (excluding some axes), reordered or have their unit and direction modified.
      *
-     * {@preformat java
-     *     Matrix step1 = swapAndScaleAxes(sourceCS, normalize(sourceCS));
-     *     Matrix step2 = ... some transform operating on standard axis ...
-     *     Matrix step3 = swapAndScaleAxes(normalize(targetCS), targetCS);
-     * }
+     * <div class="note"><b>Example:</b>
+     * for replacing all angular units of a coordinate system to degrees (regardless what the original
+     * angular units were) while leaving other kinds of units unchanged, one can write:
      *
-     * A rational for normalized axis order and units is explained in the <cite>Axis units and
-     * direction</cite> section in the {@linkplain org.apache.sis.referencing.operation.projection
-     * description of map projection package}.
+     * {@preformat java
+     *     CoordinateSystem cs = ...;
+     *     cs = CoordinateSystems.replaceAxes(cs, new AxisFilter() {
+     *         &#64;Override
+     *         public Unit<?> getUnitReplacement(Unit<?> unit) {
+     *             if (Units.isAngular(unit)) {
+     *                 unit = NonSI.DEGREE_ANGLE;
+     *             }
+     *             return unit;
+     *         }
+     *     });
+     * }</div>
+     *
+     * <div class="section">Coordinate system normalization</div>
+     * This method is often used together with {@link #swapAndScaleAxes swapAndScaleAxes(…)} for normalizing the
+     * coordinate values given to a {@linkplain org.apache.sis.referencing.operation.transform.AbstractMathTransform
+     * math transform}.
      *
-     * @param  cs The coordinate system.
-     * @return A constant similar to the specified {@code cs} with normalized axes.
+     * <div class="note"><b>Example:</b>
+     * {@preformat java
+     *     CoordinateSystem sourceCS = ...;
+     *     CoordinateSystem targetCS = ...;
+     *     Matrix step1 = swapAndScaleAxes(sourceCS, replaceAxes(sourceCS, AxisConvention.NORMALIZED));
+     *     Matrix step2 = ...; // some transform working on coordinates with standard axis order and unit.
+     *     Matrix step3 = swapAndScaleAxes(replaceAxes(targetCS, AxisConvention.NORMALIZED), targetCS);
+     * }</div>
+     *
+     * A rational for normalized axis order and units is explained in the <cite>Axis units and direction</cite> section
+     * in the description of the {@linkplain org.apache.sis.referencing.operation.projection map projection package}.
+     *
+     * @param  cs     The coordinate system, or {@code null}.
+     * @param  filter The modifications to apply on coordinate system axes.
+     * @return The modified coordinate system as a new instance,
+     *         or {@code cs} if the given coordinate system was null or does not need any change.
      * @throws IllegalArgumentException if the specified coordinate system can not be normalized.
      *
      * @see AxesConvention#NORMALIZED
      *
      * @since 0.6
      */
-    public static CoordinateSystem normalize(final CoordinateSystem cs) throws IllegalArgumentException {
-        if (cs == null) {
-            return null;
-        } else if (cs instanceof AbstractCS) {
-            // User may have overridden the 'forConvention' method.
-            return ((AbstractCS) cs).forConvention(AxesConvention.NORMALIZED);
-        } else {
-            return Normalizer.normalize(cs);
+    public static CoordinateSystem replaceAxes(final CoordinateSystem cs, final AxisFilter filter) {
+        ensureNonNull("filter", filter);
+        if (cs != null) {
+            final CoordinateSystem newCS;
+            if (filter instanceof AxesConvention) {
+                if (cs instanceof AbstractCS) {
+                    // User may have overridden the 'forConvention' method.
+                    return ((AbstractCS) cs).forConvention((AxesConvention) filter);
+                } else {
+                    newCS = Normalizer.forConvention(cs, (AxesConvention) filter);
+                }
+            } else {
+                newCS = Normalizer.normalize(cs, filter, false);
+            }
+            if (newCS != null) {
+                return newCS;
+            }
         }
+        return cs;
     }
 }

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=1683837&r1=1683836&r2=1683837&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] Fri Jun  5 18:41:29 2015
@@ -223,11 +223,15 @@ public class DefaultAffineCS extends Abs
     }
 
     /**
-     * Returns a coordinate system of the same class than this CS but with different axes.
+     * Returns a coordinate system 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);
+    AbstractCS createForAxes(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        switch (axes.length) {
+            case 2: // Fall through
+            case 3: return new DefaultAffineCS(properties, axes);
+            default: throw unexpectedDimension(properties, axes, 2);
+        }
     }
 }

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=1683837&r1=1683836&r2=1683837&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] Fri Jun  5 18:41:29 2015
@@ -78,7 +78,7 @@ 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,
+     * implementations of the {@link #createForAxes(Map, CoordinateSystemAxis[])} method only,
      * because it does not verify the number of axes.
      */
     private DefaultCartesianCS(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
@@ -232,10 +232,14 @@ public class DefaultCartesianCS extends
     }
 
     /**
-     * Returns a coordinate system of the same class than this CS but with different axes.
+     * Returns a coordinate system with different axes.
      */
     @Override
-    final AbstractCS createSameType(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
-        return new DefaultCartesianCS(properties, axes);
+    final AbstractCS createForAxes(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        switch (axes.length) {
+            case 2: // Fall through
+            case 3: return new DefaultCartesianCS(properties, axes);
+            default: throw unexpectedDimension(properties, axes, 2);
+        }
     }
 }

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=1683837&r1=1683836&r2=1683837&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] Fri Jun  5 18:41:29 2015
@@ -20,11 +20,10 @@ import java.util.Map;
 import java.util.List;
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
+import org.apache.sis.internal.referencing.AxisDirections;
 import org.apache.sis.internal.util.UnmodifiableArrayList;
-import org.apache.sis.internal.util.Utilities;
 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.*;
@@ -52,7 +51,7 @@ import static org.apache.sis.util.Utilit
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.6
  * @module
  */
 public class DefaultCompoundCS extends AbstractCS {
@@ -127,38 +126,11 @@ public class DefaultCompoundCS extends A
      */
     @Workaround(library="JDK", version="1.7")
     private DefaultCompoundCS(final CoordinateSystem[] components, final CoordinateSystemAxis[] axes) {
-        super(singletonMap(NAME_KEY, createName(new StringBuilder(60).append("Compound CS"), axes)), axes);
+        super(singletonMap(NAME_KEY, AxisDirections.appendTo(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 String symbol = Utilities.toString(axis.getUnit());
-            if (symbol != null && !symbol.isEmpty()) {
-                buffer.append(" (").append(symbol).append(')');
-            }
-        }
-        return buffer.append('.').toString();
-    }
-
-    /**
      * Returns a clone of the given array, making sure that it contains only non-null elements.
      */
     private static CoordinateSystem[] clone(CoordinateSystem[] components) {
@@ -200,7 +172,7 @@ public class DefaultCompoundCS extends A
     }
 
     /*
-     * Do not override createSameType(…) and forConvention(…) because we can not create a new DefaultCompoundCS
+     * Do not override createForAxes(…) 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.

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=1683837&r1=1683836&r2=1683837&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] Fri Jun  5 18:41:29 2015
@@ -72,7 +72,7 @@ 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,
+     * implementations of the {@link #createForAxes(Map, CoordinateSystemAxis[])} method only,
      * because it does not verify the number of axes.
      */
     private DefaultCylindricalCS(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
@@ -203,10 +203,14 @@ public class DefaultCylindricalCS extend
     }
 
     /**
-     * Returns a coordinate system of the same class than this CS but with different axes.
+     * Returns a coordinate system with different axes.
      */
     @Override
-    final AbstractCS createSameType(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
-        return new DefaultCylindricalCS(properties, axes);
+    final AbstractCS createForAxes(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        switch (axes.length) {
+            case 2: return new DefaultPolarCS(properties, axes);
+            case 3: return new DefaultCylindricalCS(properties, axes);
+            default: throw unexpectedDimension(properties, axes, 2);
+        }
     }
 }

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=1683837&r1=1683836&r2=1683837&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] Fri Jun  5 18:41:29 2015
@@ -70,11 +70,12 @@ 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,
+     * implementations of the {@link #createForAxes(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);
+        validateAxes(properties);
     }
 
     /**
@@ -121,13 +122,7 @@ public class DefaultEllipsoidalCS extend
                                 final CoordinateSystemAxis axis1)
     {
         super(properties, axis0, axis1);
-        for (int i=0; i<2; i++) {
-            final AxisDirection direction = super.getAxis(i).getDirection();
-            if (AxisDirections.isVertical(direction)) {
-                throw new IllegalArgumentException(Errors.getResources(properties).getString(
-                        Errors.Keys.IllegalAxisDirection_2, "EllipdoicalCS (2D)", direction));
-            }
-        }
+        validateAxes(properties);
     }
 
     /**
@@ -146,6 +141,7 @@ public class DefaultEllipsoidalCS extend
                                 final CoordinateSystemAxis axis2)
     {
         super(properties, axis0, axis1, axis2);
+        validateAxes(properties);
     }
 
     /**
@@ -202,6 +198,23 @@ public class DefaultEllipsoidalCS extend
     }
 
     /**
+     * Validates the set of axes after the validation of each individual axis.
+     *
+     * @param properties The properties given at construction time.
+     */
+    private void validateAxes(final Map<String,?> properties) {
+        int i = super.getDimension();
+        int n = i - 2; // Number of vertical axes allowed.
+        while (--i >= 0) {
+            final AxisDirection direction = super.getAxis(i).getDirection();
+            if (AxisDirections.isVertical(direction) && --n < 0) {
+                throw new IllegalArgumentException(Errors.getResources(properties).getString(
+                        Errors.Keys.IllegalAxisDirection_2, EllipsoidalCS.class, direction));
+            }
+        }
+    }
+
+    /**
      * Returns the GeoAPI interface implemented by this class.
      * The SIS implementation returns {@code EllipsoidalCS.class}.
      *
@@ -228,10 +241,15 @@ public class DefaultEllipsoidalCS extend
     }
 
     /**
-     * Returns a coordinate system of the same class than this CS but with different axes.
+     * Returns a coordinate system with different axes.
      */
     @Override
-    final AbstractCS createSameType(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
-        return new DefaultEllipsoidalCS(properties, axes);
+    final AbstractCS createForAxes(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        switch (axes.length) {
+            case 1: return new DefaultVerticalCS(properties, axes);
+            case 2: // Fall through
+            case 3: return new DefaultEllipsoidalCS(properties, axes);
+            default: throw unexpectedDimension(properties, axes, 1);
+        }
     }
 }

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=1683837&r1=1683836&r2=1683837&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] Fri Jun  5 18:41:29 2015
@@ -71,7 +71,7 @@ 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,
+     * implementations of the {@link #createForAxes(Map, CoordinateSystemAxis[])} method only,
      * because it does not verify the number of axes.
      */
     private DefaultLinearCS(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
@@ -196,10 +196,13 @@ public class DefaultLinearCS extends Abs
     }
 
     /**
-     * Returns a coordinate system of the same class than this CS but with different axes.
+     * Returns a coordinate system with different axes.
      */
     @Override
-    final AbstractCS createSameType(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
-        return new DefaultLinearCS(properties, axes);
+    final AbstractCS createForAxes(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        switch (axes.length) {
+            case 1: return new DefaultLinearCS(properties, axes);
+            default: throw unexpectedDimension(properties, axes, 1);
+        }
     }
 }

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=1683837&r1=1683836&r2=1683837&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] Fri Jun  5 18:41:29 2015
@@ -70,10 +70,10 @@ 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,
+     * implementations of the {@link #createForAxes(Map, CoordinateSystemAxis[])} method only,
      * because it does not verify the number of axes.
      */
-    private DefaultPolarCS(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+    DefaultPolarCS(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
         super(properties, axes);
     }
 
@@ -199,10 +199,13 @@ public class DefaultPolarCS extends Abst
     }
 
     /**
-     * Returns a coordinate system of the same class than this CS but with different axes.
+     * Returns a coordinate system with different axes.
      */
     @Override
-    final AbstractCS createSameType(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
-        return new DefaultPolarCS(properties, axes);
+    final AbstractCS createForAxes(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        switch (axes.length) {
+            case 2: return new DefaultPolarCS(properties, axes);
+            default: throw unexpectedDimension(properties, axes, 2);
+        }
     }
 }

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=1683837&r1=1683836&r2=1683837&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] Fri Jun  5 18:41:29 2015
@@ -74,7 +74,7 @@ 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,
+     * implementations of the {@link #createForAxes(Map, CoordinateSystemAxis[])} method only,
      * because it does not verify the number of axes.
      */
     private DefaultSphericalCS(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
@@ -203,10 +203,14 @@ public class DefaultSphericalCS extends
     }
 
     /**
-     * Returns a coordinate system of the same class than this CS but with different axes.
+     * Returns a coordinate system with different axes.
      */
     @Override
-    final AbstractCS createSameType(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
-        return new DefaultSphericalCS(properties, axes);
+    final AbstractCS createForAxes(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        switch (axes.length) {
+            case 2: return new DefaultPolarCS(properties, axes);
+            case 3: return new DefaultSphericalCS(properties, axes);
+            default: throw unexpectedDimension(properties, axes, 2);
+        }
     }
 }

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=1683837&r1=1683836&r2=1683837&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] Fri Jun  5 18:41:29 2015
@@ -73,7 +73,7 @@ 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,
+     * implementations of the {@link #createForAxes(Map, CoordinateSystemAxis[])} method only,
      * because it does not verify the number of axes.
      */
     private DefaultTimeCS(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
@@ -196,10 +196,13 @@ public class DefaultTimeCS extends Abstr
     }
 
     /**
-     * Returns a coordinate system of the same class than this CS but with different axes.
+     * Returns a coordinate system with different axes.
      */
     @Override
-    final AbstractCS createSameType(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
-        return new DefaultTimeCS(properties, axes);
+    final AbstractCS createForAxes(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        switch (axes.length) {
+            case 1: return new DefaultTimeCS(properties, axes);
+            default: throw unexpectedDimension(properties, axes, 1);
+        }
     }
 }

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=1683837&r1=1683836&r2=1683837&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] Fri Jun  5 18:41:29 2015
@@ -65,7 +65,7 @@ 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,
+     * implementations of the {@link #createForAxes(Map, CoordinateSystemAxis[])} method only,
      * because it does not verify the number of axes.
      */
     private DefaultUserDefinedCS(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
@@ -193,10 +193,14 @@ public class DefaultUserDefinedCS extend
     }
 
     /**
-     * Returns a coordinate system of the same class than this CS but with different axes.
+     * Returns a coordinate system with different axes.
      */
     @Override
-    final AbstractCS createSameType(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
-        return new DefaultUserDefinedCS(properties, axes);
+    final AbstractCS createForAxes(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        switch (axes.length) {
+            case 2: // Fall through
+            case 3: return new DefaultUserDefinedCS(properties, axes);
+            default: throw unexpectedDimension(properties, axes, 2);
+        }
     }
 }

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=1683837&r1=1683836&r2=1683837&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] Fri Jun  5 18:41:29 2015
@@ -83,10 +83,10 @@ 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,
+     * implementations of the {@link #createForAxes(Map, CoordinateSystemAxis[])} method only,
      * because it does not verify the number of axes.
      */
-    private DefaultVerticalCS(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+    DefaultVerticalCS(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
         super(properties, axes);
     }
 
@@ -211,10 +211,13 @@ public class DefaultVerticalCS extends A
     }
 
     /**
-     * Returns a coordinate system of the same class than this CS but with different axes.
+     * Returns a coordinate system with different axes.
      */
     @Override
-    final AbstractCS createSameType(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
-        return new DefaultVerticalCS(properties, axes);
+    final AbstractCS createForAxes(final Map<String,?> properties, final CoordinateSystemAxis[] axes) {
+        switch (axes.length) {
+            case 1: return new DefaultVerticalCS(properties, axes);
+            default: throw unexpectedDimension(properties, axes, 1);
+        }
     }
 }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java?rev=1683837&r1=1683836&r2=1683837&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java [UTF-8] Fri Jun  5 18:41:29 2015
@@ -20,8 +20,6 @@ import java.util.Map;
 import java.util.HashMap;
 import java.util.Arrays;
 import javax.measure.unit.Unit;
-import javax.measure.unit.SI;
-import javax.measure.unit.NonSI;
 import javax.measure.converter.UnitConverter;
 import javax.measure.converter.ConversionException;
 import org.opengis.referencing.cs.RangeMeaning;
@@ -32,7 +30,7 @@ import org.apache.sis.internal.referenci
 import org.apache.sis.referencing.IdentifiedObjects;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.CharSequences;
-import org.apache.sis.measure.Units;
+import org.apache.sis.util.ArraysExt;
 
 import static java.util.Collections.singletonMap;
 import static org.opengis.referencing.IdentifiedObject.NAME_KEY;
@@ -127,44 +125,22 @@ final class Normalizer implements Compar
      * Returns a new axis with the same properties (except identifiers) than given axis,
      * but with normalized axis direction and unit of measurement.
      *
-     * @param  axis The axis to normalize.
-     * @param  normalizeUnits {@code true} for normalizing units.
-     * @return An axis using normalized direction unit, or {@code axis} if the given axis already uses the given unit.
+     * @param  axis    The axis to normalize.
+     * @param  changes The change to apply on axis direction and units.
+     * @return An axis using normalized direction and units, or {@code axis} if there is no change.
      */
-    static CoordinateSystemAxis normalize(final CoordinateSystemAxis axis, final boolean normalizeUnits) {
-        /*
-         * Normalize the axis direction. For now we do not touch to inter-cardinal directions (e.g. "North-East")
-         * because it is not clear which normalization policy would match common usage.
-         */
+    static CoordinateSystemAxis normalize(final CoordinateSystemAxis axis, final AxisFilter changes) {
+        final Unit<?>       unit      = axis.getUnit();
         final AxisDirection direction = axis.getDirection();
-        AxisDirection newDir = direction;
-        if (!AxisDirections.isIntercardinal(direction)) {
-            newDir = AxisDirections.absolute(direction);
-        }
-        final boolean sameDirection = newDir.equals(direction);
-        /*
-         * Normalize unit of measurement.
-         */
-        final Unit<?> unit = axis.getUnit(), newUnit;
-        if (normalizeUnits) {
-            if (Units.isLinear(unit)) {
-                newUnit = SI.METRE;
-            } else if (Units.isAngular(unit)) {
-                newUnit = NonSI.DEGREE_ANGLE;
-            } else if (Units.isTemporal(unit)) {
-                newUnit = NonSI.DAY;
-            } else {
-                newUnit = unit;
-            }
-        } else {
-            newUnit = unit;
-        }
+        final Unit<?>       newUnit   = changes.getUnitReplacement(unit);
+        final AxisDirection newDir    = changes.getDirectionReplacement(direction);
         /*
          * Reuse some properties (name, remarks, etc.) from the existing axis. If the direction changed,
          * then the axis name may need change too (e.g. "Westing" → "Easting"). The new axis name may be
          * set to "Unnamed", but the caller will hopefully be able to replace the returned instance by
          * an instance from the EPSG database with appropriate name.
          */
+        final boolean sameDirection = newDir.equals(direction);
         if (sameDirection && newUnit.equals(unit)) {
             return axis;
         }
@@ -208,71 +184,47 @@ final class Normalizer implements Compar
     }
 
     /**
-     * Reorders the axes in an attempt to get a right-handed system.
-     * If no axis change is needed, then this method returns {@code cs} unchanged.
+     * Optionally normalizes and reorders the axes in an attempt to get a right-handed system.
+     * If no axis change is needed, then this method returns {@code null}.
      *
-     * @param  cs The coordinate system to normalize.
-     * @return The normalized coordinate system.
+     * @param  cs      The coordinate system to normalize.
+     * @param  changes The change to apply on axis direction and units.
+     * @param  reorder {@code true} for reordering the axis for a right-handed coordinate system.
+     * @return The normalized coordinate system, or {@code null} if no normalization is needed.
      */
-    static CoordinateSystem normalize(final CoordinateSystem cs) {
-        final CoordinateSystemAxis[] axes = normalizeAxes(cs, true, true);
-        return (axes != null) ? createSameType(AbstractCS.castOrCopy(cs), axes) : cs;
-    }
-
-    /**
-     * Reorders the axes in an attempt to get a right-handed system.
-     * If no axis change is needed, then this method returns {@code cs} unchanged.
-     *
-     * @param  cs The coordinate system to normalize.
-     * @param  normalizeAxes  {@code true} for normalizing axis directions.
-     * @param  normalizeUnits {@code true} for normalizing units (currently ignored if {@code normalizeAxes} is {@code false}).
-     * @return The normalized coordinate system.
-     */
-    static AbstractCS normalize(final AbstractCS cs, final boolean normalizeAxes, final boolean normalizeUnits) {
-        final CoordinateSystemAxis[] axes = normalizeAxes(cs, normalizeAxes, normalizeUnits);
-        return (axes != null) ? createSameType(cs, axes) : cs;
-    }
-
-    /**
-     * Returns the normalized set of axes for the given coordinate system,
-     * or {@code null} if its axes were already normalized.
-     *
-     * @param  cs The coordinate system to normalize.
-     * @param  normalizeAxes  {@code true} for normalizing axis directions.
-     * @param  normalizeUnits {@code true} for normalizing units (currently ignored if {@code normalizeAxes} is {@code false}).
-     * @return The normalized set of coordinate system axes.
-     */
-    private static CoordinateSystemAxis[] normalizeAxes(final CoordinateSystem cs,
-            final boolean normalizeAxes, final boolean normalizeUnits)
-    {
+    static AbstractCS normalize(final CoordinateSystem cs, final AxisFilter changes, final boolean reorder) {
         boolean changed = false;
         final int dimension = cs.getDimension();
-        final CoordinateSystemAxis[] axes = new CoordinateSystemAxis[dimension];
+        CoordinateSystemAxis[] axes = new CoordinateSystemAxis[dimension];
+        int n = 0;
         for (int i=0; i<dimension; i++) {
             CoordinateSystemAxis axis = cs.getAxis(i);
-            if (normalizeAxes) {
-                changed |= (axis != (axis = normalize(axis, normalizeUnits)));
+            if (changes != null) {
+                if (!changes.accept(axis)) {
+                    continue;
+                }
+                changed |= (axis != (axis = normalize(axis, changes)));
             }
-            axes[i] = axis;
+            axes[n++] = axis;
         }
+        axes = ArraysExt.resize(axes, n);
         /*
-         * Sorts the axis in an attempt to create a right-handed system.
-         * Caller will create a new Coordinate System only if at least one axis changed.
+         * Sort the axes in an attempt to create a right-handed system.
+         * If nothing changed, return the given Coordinate System as-is.
          */
-        changed |= sort(axes);
-        return changed ? axes : null;
-    }
-
-    /**
-     * Creates a new coordinate system of the same type than the given one, but with the given axes.
-     *
-     * @param  cs   The coordinate system to copy.
-     * @param  axes The set of axes to give to the new coordinate system.
-     * @return A new coordinate system of the same type than {@code cs}, but using the given axes.
-     */
-    private static AbstractCS createSameType(final AbstractCS cs, final CoordinateSystemAxis[] axes) {
-        final StringBuilder buffer = (StringBuilder) CharSequences.camelCaseToSentence(cs.getInterface().getSimpleName());
-        return cs.createSameType(singletonMap(AbstractCS.NAME_KEY, DefaultCompoundCS.createName(buffer, axes)), axes);
+        if (reorder) {
+            changed |= sort(axes);
+        }
+        if (!changed && n == dimension) {
+            return null;
+        }
+        /*
+         * Create a new coordinate system of the same type than the given one, but with the given axes.
+         * We need to change the Coordinate System name, since it is likely to not be valid anymore.
+         */
+        final AbstractCS impl = castOrCopy(cs);
+        final StringBuilder buffer = (StringBuilder) CharSequences.camelCaseToSentence(impl.getInterface().getSimpleName());
+        return impl.createForAxes(singletonMap(AbstractCS.NAME_KEY, AxisDirections.appendTo(buffer, axes)), axes);
     }
 
     /**
@@ -286,9 +238,9 @@ final class Normalizer implements Compar
      * of -60° still locate the same point in the old and the new coordinate system. But the preferred way
      * to locate that point become the 300° value if the longitude range has been shifted to positive values.</p>
      *
-     * @return A coordinate system using the given kind of longitude range (may be {@code axis}).
+     * @return A coordinate system using the given kind of longitude range, or {@code null} if no change is needed.
      */
-    static AbstractCS shiftAxisRange(final AbstractCS cs) {
+    private static AbstractCS shiftAxisRange(final CoordinateSystem cs) {
         boolean changed = false;
         final CoordinateSystemAxis[] axes = new CoordinateSystemAxis[cs.getDimension()];
         for (int i=0; i<axes.length; i++) {
@@ -317,8 +269,37 @@ final class Normalizer implements Compar
             axes[i] = axis;
         }
         if (!changed) {
-            return cs;
+            return null;
+        }
+        return castOrCopy(cs).createForAxes(IdentifiedObjects.getProperties(cs, EXCLUDES), axes);
+    }
+
+    /**
+     * Returns the given coordinate system as an {@code AbstractCS} instance. This method performs an
+     * {@code instanceof} check before to delegate to {@link AbstractCS#castOrCopy(CoordinateSystem)}
+     * because there is no need to check for all interfaces before the implementation class here.
+     * Checking the implementation class first is usually more efficient in this particular case.
+     */
+    private static AbstractCS castOrCopy(final CoordinateSystem cs) {
+        return (cs instanceof AbstractCS) ? (AbstractCS) cs : AbstractCS.castOrCopy(cs);
+    }
+
+    /**
+     * Returns a coordinate system equivalent to the given one but with axes rearranged according the given convention.
+     * If the given coordinate system is already compatible with the given convention, then returns {@code null}.
+     *
+     * @param  convention The axes convention for which a coordinate system is desired.
+     * @return A coordinate system compatible with the given convention, or {@code null} if no change is needed.
+     *
+     * @see AbstractCS#forConvention(AxesConvention)
+     */
+    static AbstractCS forConvention(final CoordinateSystem cs, final AxesConvention convention) {
+        switch (convention) {
+            case NORMALIZED:              // Fall through
+            case CONVENTIONALLY_ORIENTED: return normalize(cs, convention, true);
+            case RIGHT_HANDED:            return normalize(cs, null, true);
+            case POSITIVE_RANGE:          return shiftAxisRange(cs);
+            default: throw new AssertionError(convention);
         }
-        return cs.createSameType(IdentifiedObjects.getProperties(cs, EXCLUDES), axes);
     }
 }

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=1683837&r1=1683836&r2=1683837&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] Fri Jun  5 18:41:29 2015
@@ -28,9 +28,13 @@
  *   <li>{@link org.apache.sis.referencing.cs.AbstractCS#forConvention AbstractCS.forConvention(AxesConvention)}</li>
  * </ul>
  *
+ * This package provides also a {@link org.apache.sis.referencing.cs.CoordinateSystems} utility class
+ * with static methods for estimating an angle between two axes, determining the change of axis directions
+ * and units between two coordinate systems, or filtering axes.
+ *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.6
  * @module
  */
 @XmlSchema(elementFormDefault = XmlNsForm.QUALIFIED, namespace = Namespaces.GML, xmlns = {

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java?rev=1683837&r1=1683836&r2=1683837&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java [UTF-8] Fri Jun  5 18:41:29 2015
@@ -27,7 +27,6 @@ import org.apache.sis.referencing.operat
 import org.apache.sis.io.wkt.FormattableObject;
 import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.util.resources.Errors;
-import org.apache.sis.internal.util.Numerics;
 import org.apache.sis.internal.util.DoubleDouble;
 import org.apache.sis.internal.metadata.WKTKeywords;
 import org.apache.sis.referencing.IdentifiedObjects;
@@ -124,7 +123,7 @@ import org.apache.sis.internal.jdk7.Obje
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.6
  * @module
  *
  * @see DefaultGeodeticDatum#getBursaWolfParameters()
@@ -226,7 +225,7 @@ public class BursaWolfParameters extends
     }
 
     /**
-     * Verifies parameters validity after initialization.
+     * Verifies parameters validity after initialization of {@link DefaultGeodeticDatum}.
      */
     void verify() {
         ensureFinite("tX", tX);
@@ -252,6 +251,74 @@ public class BursaWolfParameters extends
     }
 
     /**
+     * Returns the parameter values. The length of the returned array depends on the values:
+     *
+     * <ul>
+     *   <li>If this instance is an {@link TimeDependentBWP}, then the array length will be 14.</li>
+     *   <li>Otherwise if this instance contains a non-zero {@link #dS} value, then the array length will be 7 with
+     *       {@link #tX}, {@link #tY}, {@link #tZ}, {@link #rX}, {@link #rY}, {@link #rZ} and {@link #dS} values
+     *       in that order.</li>
+     *   <li>Otherwise if this instance contains non-zero rotation terms,
+     *       then this method returns the first 6 of the above-cited values.</li>
+     *   <li>Otherwise (i.e. this instance {@linkplain #isTranslation() is a translation}),
+     *       this method returns only the first 3 of the above-cited values.</li>
+     * </ul>
+     *
+     * <div class="note"><b>Note:</b>
+     * the rules about the arrays of length 3, 6 or 7 are derived from the <cite>Well Known Text</cite> (WKT)
+     * version 1 specification. The rule about the array of length 14 is an extension.</div>
+     *
+     * @return The parameter values as an array of length 3, 6, 7 or 14.
+     *
+     * @since 0.6
+     */
+    @SuppressWarnings("fallthrough")
+    public double[] getValues() {
+        final double[] elements = new double[(dS != 0) ? 7 : (rZ != 0 || rY != 0 || rX != 0) ? 6 : 3];
+        switch (elements.length) {
+            default: elements[6] = dS;  // Fallthrough everywhere.
+            case 6:  elements[5] = rZ;
+                     elements[4] = rY;
+                     elements[3] = rX;
+            case 3:  elements[2] = tZ;
+                     elements[1] = tY;
+                     elements[0] = tX;
+        }
+        return elements;
+    }
+
+    /**
+     * Sets the parameters to the given values. The given array can have any length. The first array elements will be
+     * assigned to the {@link #tX}, {@link #tY}, {@link #tZ}, {@link #rX}, {@link #rY}, {@link #rZ} and {@link #dS}
+     * fields in that order.
+     *
+     * <ul>
+     *   <li>If the length of the given array is not sufficient for assigning a value to every fields,
+     *       then the remaining fields are left unchanged (they are <strong>not</strong> reset to zero,
+     *       but this is not a problem if this {@code BursaWolfParameters} is a new instance).</li>
+     *   <li>If the length of the given array is greater than necessary, then extra elements are ignored by this base
+     *       class. Note however that those extra elements may be used by subclasses like {@link TimeDependentBWP}.</li>
+     * </ul>
+     *
+     * @param elements The new parameter values, as an array of any length.
+     *
+     * @since 0.6
+     */
+    @SuppressWarnings("fallthrough")
+    public void setValues(final double... elements) {
+        switch (elements.length) {
+            default: dS = elements[6];  // Fallthrough everywhere.
+            case 6:  rZ = elements[5];
+            case 5:  rY = elements[4];
+            case 4:  rX = elements[3];
+            case 3:  tZ = elements[2];
+            case 2:  tY = elements[1];
+            case 1:  tX = elements[0];
+            case 0:  break;
+         }
+    }
+
+    /**
      * Returns {@code true} if the {@linkplain #targetDatum target datum} is equals (at least on computation purpose)
      * to the WGS84 datum. If the datum is unspecified, then this method returns {@code true} since WGS84 is the only
      * datum supported by the WKT 1 format, and is what users often mean.
@@ -302,13 +369,11 @@ public class BursaWolfParameters extends
      * because the parameter values are very small (parts per millions and arc-seconds).
      */
     public void invert() {
-        tX = -tX;
-        tY = -tY;
-        tZ = -tZ;
-        rX = -rX;
-        rY = -rY;
-        rZ = -rZ;
-        dS = -dS;
+        final double[] values = getValues();
+        for (int i=0; i<values.length; i++) {
+            values[i] = -values[i];
+        }
+        setValues(values);
     }
 
     /**
@@ -556,15 +621,9 @@ public class BursaWolfParameters extends
     public boolean equals(final Object object) {
         if (object != null && object.getClass() == getClass()) {
             final BursaWolfParameters that = (BursaWolfParameters) object;
-            return Numerics.equals(this.tX, that.tX) &&
-                   Numerics.equals(this.tY, that.tY) &&
-                   Numerics.equals(this.tZ, that.tZ) &&
-                   Numerics.equals(this.rX, that.rX) &&
-                   Numerics.equals(this.rY, that.rY) &&
-                   Numerics.equals(this.rZ, that.rZ) &&
-                   Numerics.equals(this.dS, that.dS) &&
-                    Objects.equals(this.targetDatum, that.targetDatum) &&
-                    Objects.equals(this.domainOfValidity, that.domainOfValidity);
+            return Arrays.equals(this.getValues(),      that.getValues()) &&
+                  Objects.equals(this.targetDatum,      that.targetDatum) &&
+                  Objects.equals(this.domainOfValidity, that.domainOfValidity);
         }
         return false;
     }
@@ -572,12 +631,11 @@ public class BursaWolfParameters extends
     /**
      * Returns a hash value for this object.
      *
-     * @return The hash code value. This value doesn't need to be the same
-     *         in past or future versions of this class.
+     * @return The hash code value. This value does not need to be the same in past or future versions of this class.
      */
     @Override
     public int hashCode() {
-        return Arrays.hashCode(new double[] {tX, tY, tZ, rX, rY, rZ, dS}) ^ (int) serialVersionUID;
+        return Arrays.hashCode(getValues()) ^ (int) serialVersionUID;
     }
 
     /**
@@ -599,14 +657,14 @@ public class BursaWolfParameters extends
      */
     @Override
     protected String formatTo(final Formatter formatter) {
-        formatter.append(tX);
-        formatter.append(tY);
-        formatter.append(tZ);
-        formatter.append(rX);
-        formatter.append(rY);
-        formatter.append(rZ);
-        formatter.append(dS);
+        final double[] values = getValues();
+        for (final double value : values) {
+            formatter.append(value);
+        }
         if (isToWGS84()) {
+            if (values.length > 7) {
+                formatter.setInvalidWKT(BursaWolfParameters.class, null);
+            }
             return WKTKeywords.ToWGS84;
         }
         formatter.setInvalidWKT(BursaWolfParameters.class, null);

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java?rev=1683837&r1=1683836&r2=1683837&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java [UTF-8] Fri Jun  5 18:41:29 2015
@@ -92,7 +92,7 @@ import org.apache.sis.internal.jdk7.Obje
  *   <li>Create an {@code Ellipsoid} from an identifier in a database by invoking
  *       {@link org.opengis.referencing.datum.DatumAuthorityFactory#createEllipsoid(String)}.</li>
  *   <li>Create an {@code Ellipsoid} by invoking the {@code DatumFactory.createEllipsoid(…)} or {@code createFlattenedSphere(…)}
- *       method (implemented for example by {@link org.apache.sis.referencing.GeodeticObjectFactory}).</li>
+ *       method (implemented for example by {@link org.apache.sis.referencing.factory.GeodeticObjectFactory}).</li>
  *   <li>Create a {@code DefaultEllipsoid} by invoking the
  *       {@link #createEllipsoid(Map, double, double, Unit) createEllipsoid(…)} or
  *       {@link #createFlattenedSphere(Map, double, double, Unit) createFlattenedSphere(…)}

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java?rev=1683837&r1=1683836&r2=1683837&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java [UTF-8] Fri Jun  5 18:41:29 2015
@@ -34,6 +34,7 @@ import org.apache.sis.referencing.operat
 import org.apache.sis.referencing.operation.matrix.NoninvertibleMatrixException;
 import org.apache.sis.metadata.iso.extent.Extents;
 import org.apache.sis.internal.metadata.WKTKeywords;
+import org.apache.sis.internal.metadata.ReferencingServices;
 import org.apache.sis.internal.referencing.ExtentSelector;
 import org.apache.sis.internal.util.CollectionsExt;
 import org.apache.sis.util.logging.Logging;
@@ -100,7 +101,7 @@ import org.apache.sis.internal.jdk7.Obje
  *   <li>Create a {@code GeodeticDatum} from an identifier in a database by invoking
  *       {@link org.opengis.referencing.datum.DatumAuthorityFactory#createGeodeticDatum(String)}.</li>
  *   <li>Create a {@code GeodeticDatum} by invoking the {@code DatumFactory.createGeodeticDatum(…)} method
- *       (implemented for example by {@link org.apache.sis.referencing.GeodeticObjectFactory}).</li>
+ *       (implemented for example by {@link org.apache.sis.referencing.factory.GeodeticObjectFactory}).</li>
  *   <li>Create a {@code DefaultGeodeticDatum} by invoking the
  *       {@linkplain #DefaultGeodeticDatum(Map, Ellipsoid, PrimeMeridian) constructor}.</li>
  * </ol>
@@ -141,7 +142,7 @@ public class DefaultGeodeticDatum extend
      * The <code>{@value #BURSA_WOLF_KEY}</code> property for
      * {@linkplain #getBursaWolfParameters() Bursa-Wolf parameters}.
      */
-    public static final String BURSA_WOLF_KEY = "bursaWolf";
+    public static final String BURSA_WOLF_KEY = ReferencingServices.BURSA_WOLF_KEY;
 
     /**
      * The array to be returned by {@link #getBursaWolfParameters()} when there is no Bursa-Wolf parameters.

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java?rev=1683837&r1=1683836&r2=1683837&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java [UTF-8] Fri Jun  5 18:41:29 2015
@@ -62,7 +62,7 @@ import org.apache.sis.internal.jdk7.Obje
  *   <li>Create a {@code PrimeMeridian} from an identifier in a database by invoking
  *       {@link org.opengis.referencing.datum.DatumAuthorityFactory#createPrimeMeridian(String)}.</li>
  *   <li>Create a {@code PrimeMeridian} by invoking the {@code DatumFactory.createPrimeMeridian(…)} method
- *       (implemented for example by {@link org.apache.sis.referencing.GeodeticObjectFactory}).</li>
+ *       (implemented for example by {@link org.apache.sis.referencing.factory.GeodeticObjectFactory}).</li>
  *   <li>Create a {@code DefaultPrimeMeridian} by invoking the
  *       {@linkplain #DefaultPrimeMeridian(Map, double, Unit) constructor}.</li>
  * </ol>

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java?rev=1683837&r1=1683836&r2=1683837&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java [UTF-8] Fri Jun  5 18:41:29 2015
@@ -55,7 +55,7 @@ import org.apache.sis.internal.jdk7.Obje
  *   <li>Create a {@code TemporalDatum} from an identifier in a database by invoking
  *       {@link org.opengis.referencing.datum.DatumAuthorityFactory#createTemporalDatum(String)}.</li>
  *   <li>Create a {@code TemporalDatum} by invoking the {@code DatumFactory.createTemporalDatum(…)} method,
- *       (implemented for example by {@link org.apache.sis.referencing.GeodeticObjectFactory}).</li>
+ *       (implemented for example by {@link org.apache.sis.referencing.factory.GeodeticObjectFactory}).</li>
  *   <li>Create a {@code DefaultTemporalDatum} by invoking the
  *       {@linkplain #DefaultTemporalDatum(Map, Date) constructor}.</li>
  * </ol>

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java?rev=1683837&r1=1683836&r2=1683837&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java [UTF-8] Fri Jun  5 18:41:29 2015
@@ -30,7 +30,7 @@ import org.apache.sis.util.ComparisonMod
 import org.apache.sis.internal.jaxb.Context;
 import org.apache.sis.internal.jaxb.LegacyNamespaces;
 import org.apache.sis.internal.metadata.WKTKeywords;
-import org.apache.sis.internal.referencing.VerticalDatumTypes;
+import org.apache.sis.internal.metadata.VerticalDatumTypes;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
 import static org.apache.sis.internal.referencing.ReferencingUtilities.canSetProperty;
@@ -57,7 +57,7 @@ import org.apache.sis.internal.jdk7.Obje
  *   <li>Create a {@code VerticalDatum} from an identifier in a database by invoking
  *       {@link org.opengis.referencing.datum.DatumAuthorityFactory#createVerticalDatum(String)}.</li>
  *   <li>Create a {@code VerticalDatum} by invoking the {@code DatumFactory.createVerticalDatum(…)} method
- *       (implemented for example by {@link org.apache.sis.referencing.GeodeticObjectFactory}).</li>
+ *       (implemented for example by {@link org.apache.sis.referencing.factory.GeodeticObjectFactory}).</li>
  *   <li>Create a {@code DefaultVerticalDatum} by invoking the
  *       {@linkplain #DefaultVerticalDatum(Map, VerticalDatumType) constructor}.</li>
  * </ol>

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/TimeDependentBWP.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/TimeDependentBWP.java?rev=1683837&r1=1683836&r2=1683837&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/TimeDependentBWP.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/TimeDependentBWP.java [UTF-8] Fri Jun  5 18:41:29 2015
@@ -17,7 +17,6 @@
 package org.apache.sis.referencing.datum;
 
 import java.util.Date;
-import java.util.Arrays;
 import org.opengis.metadata.extent.Extent;
 import org.opengis.referencing.datum.GeodeticDatum;
 import org.apache.sis.internal.util.Numerics;
@@ -60,7 +59,7 @@ import static org.apache.sis.internal.re
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.6
  * @module
  */
 public class TimeDependentBWP extends BursaWolfParameters {
@@ -201,7 +200,50 @@ public class TimeDependentBWP extends Bu
     }
 
     /**
+     * Returns the parameter values. The first 14 elements are always {@link #tX tX}, {@link #tY tY}, {@link #tZ tZ},
+     * {@link #rX rX}, {@link #rY rY}, {@link #rZ rZ}, {@link #dS dS}, {@link #dtX}, {@link #dtY}, {@link #dtZ},
+     * {@link #drX}, {@link #drY}, {@link #drZ} and {@link #ddS} in that order.
+     *
+     * @return The parameter values as an array of length 14.
+     *
+     * @since 0.6
+     */
+    @Override
+    public double[] getValues() {
+        return new double[] {tX, tY, tZ, rX, rY, rZ, dS, dtX, dtY, dtZ, drX, drY, drZ, ddS};
+    }
+
+    /**
+     * Sets the parameters to the given values. The given array can have any length. The first array elements will be
+     * assigned to the {@link #tX tX}, {@link #tY tY}, {@link #tZ tZ}, {@link #rX rX}, {@link #rY rY}, {@link #rZ rZ},
+     * {@link #dS dS}, {@link #dtX}, {@link #dtY}, {@link #dtZ}, {@link #drX}, {@link #drY}, {@link #drZ} and
+     * {@link #ddS} fields in that order.
+     *
+     * @param elements The new parameter values, as an array of any length.
+     *
+     * @since 0.6
+     */
+    @Override
+    @SuppressWarnings("fallthrough")
+    public void setValues(final double... elements) {
+        if (elements.length >= 8) {
+            switch (elements.length) {
+                default:  ddS = elements[13];  // Fallthrough everywhere.
+                case 13:  drZ = elements[12];
+                case 12:  drY = elements[11];
+                case 11:  drX = elements[10];
+                case 10:  dtZ = elements[ 9];
+                case  9:  dtY = elements[ 8];
+                case  8:  dtX = elements[ 7];
+            }
+        }
+        super.setValues(elements);
+    }
+
+    /**
      * {@inheritDoc}
+     *
+     * @return {@code true} if the parameters describe no operation.
      */
     @Override
     public boolean isIdentity() {
@@ -210,6 +252,8 @@ public class TimeDependentBWP extends Bu
 
     /**
      * {@inheritDoc}
+     *
+     * @return {@code true} if the parameters describe a translation only.
      */
     @Override
     public boolean isTranslation() {
@@ -232,45 +276,21 @@ public class TimeDependentBWP extends Bu
 
     /**
      * {@inheritDoc}
-     */
-    @Override
-    public void invert() {
-        super.invert();
-        dtX = -dtX;
-        dtY = -dtY;
-        dtZ = -dtZ;
-        drX = -drX;
-        drY = -drY;
-        drZ = -drZ;
-        ddS = -ddS;
-    }
-
-    /**
-     * {@inheritDoc}
+     *
+     * @return {@code true} if the given object is equal to this {@code TimeDependentBWP}.
      */
     @Override
     public boolean equals(final Object object) {
-        if (super.equals(object)) {
-            final TimeDependentBWP that = (TimeDependentBWP) object;
-            return timeReference == that.timeReference &&
-                   Numerics.equals(this.dtX, that.dtX) &&
-                   Numerics.equals(this.dtY, that.dtY) &&
-                   Numerics.equals(this.dtZ, that.dtZ) &&
-                   Numerics.equals(this.drX, that.drX) &&
-                   Numerics.equals(this.drY, that.drY) &&
-                   Numerics.equals(this.drZ, that.drZ) &&
-                   Numerics.equals(this.ddS, that.ddS);
-        }
-        return false;
+        return super.equals(object) && timeReference == ((TimeDependentBWP) object).timeReference;
     }
 
     /**
      * {@inheritDoc}
+     *
+     * @return The hash code value. This value does not need to be the same in past or future versions of this class.
      */
     @Override
     public int hashCode() {
-        return ((int) serialVersionUID) ^ Arrays.hashCode(new double[] {
-            tX, tY, tZ, rX, rY, rZ, dS, dtX, dtY, dtZ, drX, drY, drZ, ddS, timeReference
-        });
+        return super.hashCode() ^ Numerics.hashCode(timeReference);
     }
 }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java?rev=1683837&r1=1683836&r2=1683837&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java [UTF-8] Fri Jun  5 18:41:29 2015
@@ -45,8 +45,8 @@ import org.apache.sis.util.collection.Co
 import org.apache.sis.util.UnsupportedImplementationException;
 import org.apache.sis.referencing.AbstractIdentifiedObject;
 import org.apache.sis.referencing.operation.transform.PassThroughTransform;
+import org.apache.sis.internal.referencing.PositionalAccuracyConstant;
 import org.apache.sis.internal.referencing.ReferencingUtilities;
-import org.apache.sis.internal.referencing.OperationMethods;
 import org.apache.sis.internal.referencing.WKTUtilities;
 import org.apache.sis.internal.metadata.WKTKeywords;
 import org.apache.sis.internal.util.CollectionsExt;
@@ -533,7 +533,7 @@ check:      for (int isTarget=0; ; isTar
      * @return The accuracy estimation (always in meters), or NaN if unknown.
      */
     public double getLinearAccuracy() {
-        return OperationMethods.getLinearAccuracy(this);
+        return PositionalAccuracyConstant.getLinearAccuracy(this);
     }
 
     /**

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java?rev=1683837&r1=1683836&r2=1683837&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java [UTF-8] Fri Jun  5 18:41:29 2015
@@ -32,7 +32,7 @@ import org.apache.sis.referencing.Identi
 import org.apache.sis.referencing.operation.transform.MathTransforms;
 import org.apache.sis.referencing.operation.transform.PassThroughTransform;
 import org.apache.sis.internal.referencing.ReferencingUtilities;
-import org.apache.sis.internal.referencing.OperationMethods;
+import org.apache.sis.internal.metadata.ReferencingServices;
 import org.apache.sis.internal.util.Constants;
 import org.apache.sis.util.collection.Containers;
 import org.apache.sis.util.resources.Errors;
@@ -108,7 +108,7 @@ class AbstractSingleOperation extends Ab
          * However there is a few cases, for example the Molodenski transform, where we can not infer the
          * parameters easily because the operation is implemented by a concatenation of math transforms.
          */
-        parameters = Containers.property(properties, OperationMethods.PARAMETERS_KEY, ParameterValueGroup.class);
+        parameters = Containers.property(properties, ReferencingServices.PARAMETERS_KEY, ParameterValueGroup.class);
         // No clone since this is a SIS internal property and SIS does not modify those values after construction.
     }
 

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java?rev=1683837&r1=1683836&r2=1683837&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java [UTF-8] Fri Jun  5 18:41:29 2015
@@ -56,7 +56,7 @@ import org.apache.sis.internal.jdk7.Obje
  * @version 0.6
  * @module
  */
-public class DefaultConcatenatedOperation extends AbstractCoordinateOperation implements ConcatenatedOperation {
+final class DefaultConcatenatedOperation extends AbstractCoordinateOperation implements ConcatenatedOperation {
     /**
      * Serial number for inter-operability with different versions.
      */

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConversion.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConversion.java?rev=1683837&r1=1683836&r2=1683837&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConversion.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConversion.java [UTF-8] Fri Jun  5 18:41:29 2015
@@ -132,6 +132,27 @@ public class DefaultConversion extends A
      *   </tr>
      * </table>
      *
+     * <div class="section">Relationship between datum</div>
+     * By definition, coordinate <b>conversions</b> do not change the datum. Consequently the given {@code sourceCRS}
+     * and {@code targetCRS} should use the same datum. If the datum is not the same, then the coordinate operation
+     * should probably be a {@linkplain DefaultTransformation transformation} instead.
+     * However Apache SIS does not enforce that condition, but we encourage users to follow it.
+     * The reason why SIS is tolerant is because some gray areas may exist about whether an operation
+     * should be considered as a conversion or a transformation.
+     *
+     * <div class="note"><b>Example:</b>
+     * converting time instants from a {@linkplain org.apache.sis.referencing.crs.DefaultTemporalCRS temporal CRS} using
+     * the <cite>January 1st, 1950</cite> epoch to another temporal CRS using the <cite>January 1st, 1970</cite> epoch
+     * is a datum change, since the epoch is part of {@linkplain org.apache.sis.referencing.datum.DefaultTemporalDatum
+     * temporal datum} definition. However such operation does not have all the accuracy issues of transformations
+     * between geodetic datum (empirically determined, over-determined systems, stochastic nature of the parameters).
+     * Consequently some users may consider sufficient to represent temporal epoch changes as conversions instead
+     * than transformations.</div>
+     *
+     * Note that while Apache SIS accepts to construct {@code DefaultConversion} instances
+     * with different source and target datum, it does not accept to use such instances for
+     * {@linkplain org.apache.sis.referencing.crs.DefaultDerivedCRS derived CRS} construction.
+     *
      * @param properties The properties to be given to the identified object.
      * @param sourceCRS  The source CRS.
      * @param targetCRS  The target CRS, which shall use a datum
@@ -139,7 +160,6 @@ public class DefaultConversion extends A
      * @param interpolationCRS The CRS of additional coordinates needed for the operation, or {@code null} if none.
      * @param method     The coordinate operation method (mandatory in all cases).
      * @param transform  Transform from positions in the source CRS to positions in the target CRS.
-     * @throws MismatchedDatumException if the source and target CRS use different datum.
      */
     public DefaultConversion(final Map<String,?>             properties,
                              final CoordinateReferenceSystem sourceCRS,
@@ -151,7 +171,6 @@ public class DefaultConversion extends A
         super(properties, sourceCRS, targetCRS, interpolationCRS, method, transform);
         ArgumentChecks.ensureNonNull("sourceCRS", sourceCRS);
         ArgumentChecks.ensureNonNull("targetCRS", targetCRS);
-        ensureCompatibleDatum("targetCRS", sourceCRS, targetCRS);
     }
 
     /**

Copied: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java (from r1683824, sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java)
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java?p2=sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java&p1=sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java&r1=1683824&r2=1683837&rev=1683837&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java [UTF-8] Fri Jun  5 18:41:29 2015
@@ -168,7 +168,6 @@ public class DefaultCoordinateOperationF
      *
      * @see DefaultMathTransformFactory#getOperationMethod(String)
      */
-    @Override
     public OperationMethod getOperationMethod(String name) throws FactoryException {
         final MathTransformFactory mtFactory = getMathTransformFactory();
         if (mtFactory instanceof DefaultMathTransformFactory) {
@@ -232,7 +231,6 @@ public class DefaultCoordinateOperationF
      *
      * @see DefaultOperationMethod#DefaultOperationMethod(Map, Integer, Integer, ParameterDescriptorGroup)
      */
-    @Override
     public OperationMethod createOperationMethod(final Map<String,?> properties,
             final Integer sourceDimensions, final Integer targetDimensions,
             ParameterDescriptorGroup parameters) throws FactoryException

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/MismatchedDatumException.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/MismatchedDatumException.java?rev=1683837&r1=1683836&r2=1683837&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/MismatchedDatumException.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/MismatchedDatumException.java [UTF-8] Fri Jun  5 18:41:29 2015
@@ -22,10 +22,25 @@ package org.apache.sis.referencing.opera
  * By definition, conversions do not perform any change of datum
  * while {@linkplain DefaultTransformation transformations} can do.
  *
+ * <div class="note"><b>Note:</b>
+ * SIS is tolerant about different datum at {@code DefaultConversion} construction time,
+ * for the reasons explained in {@linkplain DefaultConversion#DefaultConversion(java.util.Map,
+ * org.opengis.referencing.crs.CoordinateReferenceSystem,
+ * org.opengis.referencing.crs.CoordinateReferenceSystem,
+ * org.opengis.referencing.crs.CoordinateReferenceSystem,
+ * org.opengis.referencing.operation.OperationMethod,
+ * org.opengis.referencing.operation.MathTransform) its constructor}.
+ * However SIS is stricter at {@linkplain org.apache.sis.referencing.crs.DefaultDerivedCRS Derived CRS}
+ * construction time.</div>
+ *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.6
  * @version 0.6
  * @module
+ *
+ * @see org.opengis.geometry.MismatchedReferenceSystemException
+ * @see org.opengis.geometry.MismatchedDimensionException
+ * @see org.apache.sis.referencing.operation.matrix.MismatchedMatrixSizeException
  */
 public class MismatchedDatumException extends IllegalArgumentException {
     /**

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MismatchedMatrixSizeException.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MismatchedMatrixSizeException.java?rev=1683837&r1=1683836&r2=1683837&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MismatchedMatrixSizeException.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MismatchedMatrixSizeException.java [UTF-8] Fri Jun  5 18:41:29 2015
@@ -31,6 +31,9 @@ import org.opengis.geometry.MismatchedDi
  * @since   0.4
  * @version 0.4
  * @module
+ *
+ * @see org.opengis.geometry.MismatchedReferenceSystemException
+ * @see org.apache.sis.referencing.operation.MismatchedDatumException
  */
 public class MismatchedMatrixSizeException extends MismatchedDimensionException {
     /**



Mime
View raw message