sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1826327 [3/5] - in /sis/branches/JDK9: ./ application/sis-console/src/main/java/org/apache/sis/console/ core/sis-build-helper/src/main/resources/org/apache/sis/ core/sis-metadata/ core/sis-metadata/src/main/java/org/apache/sis/internal/jax...
Date Fri, 09 Mar 2018 11:00:28 GMT
Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -37,6 +37,7 @@ import org.apache.sis.referencing.Common
 import org.apache.sis.util.ArraysExt;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.resources.Errors;
+import org.apache.sis.internal.util.Numerics;
 
 import static org.apache.sis.util.ArgumentChecks.*;
 import static org.apache.sis.math.MathFunctions.isNegative;
@@ -56,7 +57,7 @@ import static org.apache.sis.internal.re
  * in {@link SubEnvelope}.</p>
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
- * @version 0.3
+ * @version 1.0
  * @since   0.3
  * @module
  */
@@ -593,6 +594,6 @@ scanNumber: while ((i += Character.charC
      */
     @Override
     public String toString() {
-        return toString(this, AbstractDirectPosition.isSimplePrecision(ordinates));
+        return toString(this, Numerics.isSimplePrecision(ordinates));
     }
 }

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition2D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition2D.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition2D.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition2D.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -292,7 +292,7 @@ public class DirectPosition2D extends Po
      */
     @Override
     public String toString() {
-        return AbstractDirectPosition.toString(this, AbstractDirectPosition.isSimplePrecision(x, y));
+        return AbstractDirectPosition.toString(this, Numerics.isSimplePrecision(x, y));
     }
 
     /**

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -131,7 +131,8 @@ public final class Envelopes extends Sta
             return ((AbstractMathTransform) transform).transform(srcPts, 0, dstPts, dstOff, derivate);
         }
         // Derivative must be calculated before to transform the coordinate.
-        final Matrix derivative = derivate ? transform.derivative(new DirectPositionView(srcPts, 0, transform.getSourceDimensions())) : null;
+        final Matrix derivative = derivate ? transform.derivative(
+                new DirectPositionView.Double(srcPts, 0, transform.getSourceDimensions())) : null;
         transform.transform(srcPts, 0, dstPts, dstOff, 1);
         return derivative;
     }
@@ -265,7 +266,7 @@ public final class Envelopes extends Sta
             sourcePt[i] = envelope.getMinimum(i);
         }
         // A window over a single coordinate in the 'ordinates' array.
-        final DirectPositionView ordinatesView = new DirectPositionView(ordinates, 0, targetDim);
+        final DirectPositionView ordinatesView = new DirectPositionView.Double(ordinates, 0, targetDim);
         /*
          * Iterates over every minimal, maximal and median ordinate values (3 points) along each
          * dimension. The total number of iterations is 3 ^ (number of source dimensions).
@@ -339,7 +340,7 @@ public final class Envelopes extends Sta
          * to avoid the need for storage.
          */
         DirectPosition temporary = null;
-        final DirectPositionView sourceView = new DirectPositionView(sourcePt, 0, sourceDim);
+        final DirectPositionView sourceView = new DirectPositionView.Double(sourcePt, 0, sourceDim);
         final CurveExtremum extremum = new CurveExtremum();
         for (pointIndex=0; pointIndex < derivatives.length; pointIndex++) {
             final Matrix D1 = derivatives[pointIndex];

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -30,6 +30,7 @@ import java.security.PrivilegedAction;
 import org.opengis.geometry.DirectPosition;
 import org.opengis.geometry.MismatchedDimensionException;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.apache.sis.internal.util.Numerics;
 import org.apache.sis.util.resources.Errors;
 
 import static org.apache.sis.util.ArgumentChecks.ensureDimensionMatches;
@@ -51,7 +52,7 @@ import static org.apache.sis.util.Argume
  * on the value of the containing object's {@code CoordinateReferenceSystem}.
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
- * @version 0.3
+ * @version 1.0
  *
  * @see DirectPosition1D
  * @see DirectPosition2D
@@ -282,7 +283,7 @@ public class GeneralDirectPosition exten
      */
     @Override
     public String toString() {
-        return toString(this, isSimplePrecision(ordinates));
+        return toString(this, Numerics.isSimplePrecision(ordinates));
     }
 
     /**

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -701,7 +701,7 @@ public class GeneralEnvelope extends Arr
     }
 
     /**
-     * Sets this envelope to the intersection if this envelope with the specified one.
+     * Sets this envelope to the intersection of this envelope with the specified one.
      *
      * <div class="section">Pre-conditions</div>
      * This method assumes that the specified envelope uses the same CRS than this envelope.

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/geometry/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/geometry/package-info.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/geometry/package-info.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/geometry/package-info.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -84,7 +84,7 @@
  * @see org.apache.sis.setup.GeometryLibrary
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
- * @version 0.8
+ * @version 1.0
  * @since   0.3
  * @module
  */

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/DirectPositionView.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/DirectPositionView.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/DirectPositionView.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/DirectPositionView.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -17,8 +17,8 @@
 package org.apache.sis.internal.referencing;
 
 import java.util.Arrays;
-import org.opengis.geometry.DirectPosition;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.apache.sis.geometry.AbstractDirectPosition;
 
 // Branch-dependent imports
 import org.opengis.geometry.UnmodifiableGeometryException;
@@ -29,19 +29,13 @@ import org.opengis.geometry.Unmodifiable
  * This class shall be used for temporary objects only (it is not serializable for this reason).
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.5
+ * @version 1.0
  * @since   0.5
  * @module
  */
-public final class DirectPositionView implements DirectPosition {
+public abstract class DirectPositionView extends AbstractDirectPosition {
     /**
-     * The ordinate values. This is a direct reference to the array given to the constructor.
-     * The length of this array may be greater then the number of dimensions.
-     */
-    private final double[] ordinates;
-
-    /**
-     * The index of the first value in the {@linkplain #ordinates} array.
+     * The index of the first value in the ordinates array.
      * This field is non-final in order to allow the caller to move the view over an array of coordinates.
      */
     public int offset;
@@ -49,70 +43,129 @@ public final class DirectPositionView im
     /**
      * The number of valid ordinate values.
      */
-    private final int dimension;
+    final int dimension;
 
     /**
      * Creates a new direct position wrapping the given array.
      *
-     * @param  ordinates  the ordinate values.
      * @param  offset     the first value index in the ordinates array.
      * @param  dimension  the number of valid ordinate values.
      */
-    public DirectPositionView(final double[] ordinates, final int offset, final int dimension) {
-        this.ordinates = ordinates;
+    DirectPositionView(final int offset, final int dimension) {
         this.offset    = offset;
         this.dimension = dimension;
     }
 
     /**
      * Returns {@code null} since there is no CRS associated with this position.
+     *
+     * @return {@code null}.
      */
     @Override
-    public CoordinateReferenceSystem getCoordinateReferenceSystem() {
+    public final CoordinateReferenceSystem getCoordinateReferenceSystem() {
         return null;
     }
 
     /**
      * Returns the dimension given at construction time.
-     */
-    @Override
-    public int getDimension() {
-        return dimension;
-    }
-
-    /**
-     * Returns all ordinate values.
-     */
-    @Override
-    public double[] getCoordinate() {
-        return Arrays.copyOfRange(ordinates, offset, offset + dimension);
-    }
-
-    /**
-     * Returns the ordinate at the given index.
-     * <strong>This implementation does not check index validity</strong>, unless assertions are enabled.
      *
-     * @param  dim  the dimension of the ordinate to get fetch.
+     * @return number of dimensions.
      */
     @Override
-    public double getOrdinate(final int dim) {
-        assert dim >= 0 && dim < dimension : dim;
-        return ordinates[offset + dim];
+    public final int getDimension() {
+        return dimension;
     }
 
     /**
      * Do not allow any change.
+     *
+     * @param  dimension  ignored.
+     * @param  value      ignored.
      */
     @Override
-    public void setOrdinate(final int dimension, final double value) {
+    public final void setOrdinate(final int dimension, final double value) {
         throw new UnmodifiableGeometryException();
     }
 
     /**
-     * Returns the direct position, which is {@code this}.
+     * The double-precision version of {@link DirectPositionView}.
      */
-    @Override
-    public DirectPosition getDirectPosition() {
-        return this;
+    public static final class Double extends DirectPositionView {
+        /**
+         * The ordinate values. This is a direct reference to the array given to the constructor.
+         * The length of this array may be greater then the number of dimensions.
+         */
+        private final double[] ordinates;
+
+        /**
+         * Creates a new direct position wrapping the given array.
+         *
+         * @param  ordinates  the ordinate values.
+         * @param  offset     the first value index in the ordinates array.
+         * @param  dimension  the number of valid ordinate values.
+         */
+        public Double(final double[] ordinates, final int offset, final int dimension) {
+            super(offset, dimension);
+            this.ordinates = ordinates;
+        }
+
+        /**
+         * Returns the ordinate at the given index.
+         * <strong>This implementation does not check index validity</strong>, unless assertions are enabled.
+         *
+         * @param  dim  the dimension of the ordinate to get fetch.
+         * @return the coordinate value at the given dimension.
+         */
+        @Override
+        public double getOrdinate(final int dim) {
+            assert dim >= 0 && dim < dimension : dim;
+            return ordinates[offset + dim];
+        }
+
+        /**
+         * Returns all ordinate values.
+         *
+         * @return all coordinate values.
+         */
+        @Override
+        public double[] getCoordinate() {
+            return Arrays.copyOfRange(ordinates, offset, offset + dimension);
+        }
+    }
+
+    /**
+     * The single-precision version of {@link DirectPositionView}.
+     */
+    public static final class Float extends DirectPositionView {
+        /**
+         * The ordinate values. This is a direct reference to the array given to the constructor.
+         * The length of this array may be greater then the number of dimensions.
+         */
+        private final float[] ordinates;
+
+        /**
+         * Creates a new direct position wrapping the given array.
+         *
+         * @param  ordinates  the ordinate values.
+         * @param  offset     the first value index in the ordinates array.
+         * @param  dimension  the number of valid ordinate values.
+         */
+        public Float(final float[] ordinates, final int offset, final int dimension) {
+            super(offset, dimension);
+            this.ordinates = ordinates;
+        }
+
+        /**
+         * Returns the ordinate at the given index.
+         * <strong>This implementation does not check index validity</strong>, unless assertions are enabled.
+         *
+         * @param  dim  the dimension of the ordinate to get fetch.
+         * @return the coordinate value at the given dimension.
+         */
+        @Override
+        public double getOrdinate(final int dim) {
+            assert dim >= 0 && dim < dimension : dim;
+            return ordinates[offset + dim];
+        }
     }
 }

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/EPSGFactoryProxy.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/EPSGFactoryProxy.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/EPSGFactoryProxy.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/EPSGFactoryProxy.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -47,9 +47,6 @@ import org.opengis.util.InternationalStr
 public final class EPSGFactoryProxy implements CRSAuthorityFactory {
     private volatile CRSAuthorityFactory factory;
 
-    public EPSGFactoryProxy() {
-    }
-
     private CRSAuthorityFactory factory() throws FactoryException {
         CRSAuthorityFactory f = factory;
         if (f == null) {

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -19,6 +19,7 @@ package org.apache.sis.internal.referenc
 import org.apache.sis.util.Static;
 import org.apache.sis.measure.Latitude;
 import org.apache.sis.internal.util.Numerics;
+import org.opengis.referencing.datum.Ellipsoid;
 
 import static java.lang.Math.*;
 import static org.apache.sis.math.MathFunctions.atanh;
@@ -31,7 +32,7 @@ import static org.apache.sis.internal.me
  * do not want to expose publicly those arbitrary values (or at least not in a too direct way).
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.7
+ * @version 1.0
  * @since   0.4
  * @module
  */
@@ -59,6 +60,13 @@ public final class Formulas extends Stat
     public static final double ANGULAR_TOLERANCE = LINEAR_TOLERANCE / (NAUTICAL_MILE * 60);
 
     /**
+     * Default tolerance threshold for comparing ordinate values in temporal CRS,
+     * assuming that the unit of measurement is second. Current value is arbitrary
+     * and may change in any future Apache SIS version.
+     */
+    public static final double TEMPORAL_TOLERANCE = 60;             // One minute.
+
+    /**
      * The maximal longitude value before normalization if a centimetric precision is desired.
      * This is about 4×10⁸ degrees.
      *
@@ -87,6 +95,19 @@ public final class Formulas extends Stat
     }
 
     /**
+     * Returns the size of a planet described by the given ellipsoid compared to earth.
+     * This method returns a ratio of given planet authalic radius compared to WGS84.
+     * This can be used for adjusting {@link #LINEAR_TOLERANCE} and {@link #ANGULAR_TOLERANCE} to another planet.
+     *
+     * @param  planet  ellipsoid of the other planet to compare to Earth.
+     * @return ratio of planet authalic radius on WGS84 authalic radius.
+     */
+    public static double scaleComparedToEarth(final Ellipsoid planet) {
+        return getAuthalicRadius(planet.getSemiMajorAxis(),
+                                 planet.getSemiMinorAxis()) / 6371007.180918474;
+    }
+
+    /**
      * Returns 3ⁿ for very small (less than 10) positive values of <var>n</var>.
      * Note that this method overflow for any value equals or greater than 20.
      *

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -31,8 +31,10 @@ import org.opengis.parameter.GeneralPara
 import org.opengis.referencing.cs.*;
 import org.opengis.referencing.crs.*;
 import org.opengis.referencing.IdentifiedObject;
+import org.opengis.referencing.datum.Datum;
 import org.opengis.referencing.datum.Ellipsoid;
 import org.opengis.referencing.datum.PrimeMeridian;
+import org.opengis.referencing.datum.GeodeticDatum;
 import org.opengis.referencing.datum.VerticalDatum;
 import org.opengis.referencing.datum.VerticalDatumType;
 import org.opengis.referencing.operation.CoordinateOperationFactory;
@@ -60,7 +62,7 @@ import static java.util.Collections.sing
  * <p><strong>Do not rely on this API!</strong> It may change in incompatible way in any future release.</p>
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
- * @version 0.8
+ * @version 1.0
  * @since   0.5
  * @module
  */
@@ -110,7 +112,7 @@ public final class ReferencingUtilities
         if (cs != null) {
             for (int i=cs.getDimension(); --i>=0;) {
                 final CoordinateSystemAxis axis = cs.getAxis(i);
-                if (axis != null) {  // Paranoiac check.
+                if (axis != null) {                                         // Paranoiac check.
                     final Unit<?> candidate = axis.getUnit();
                     if (candidate != null) {
                         if (unit == null) {
@@ -136,7 +138,7 @@ public final class ReferencingUtilities
     public static int getDimension(final CoordinateReferenceSystem crs) {
         if (crs != null) {
             final CoordinateSystem cs = crs.getCoordinateSystem();
-            if (cs != null) {  // Paranoiac check.
+            if (cs != null) {                                               // Paranoiac check.
                 return cs.getDimension();
             }
         }
@@ -199,6 +201,31 @@ public final class ReferencingUtilities
     }
 
     /**
+     * Returns the ellipsoid used by the given coordinate reference system, or {@code null} if none.
+     *
+     * @param  crs  the coordinate reference system for which to get the ellipsoid.
+     * @return the ellipsoid, or {@code null} if none.
+     */
+    public static Ellipsoid getEllipsoid(final CoordinateReferenceSystem crs) {
+        if (crs != null) {
+            if (crs instanceof SingleCRS) {
+                final Datum datum = ((SingleCRS) crs).getDatum();
+                if (datum instanceof GeodeticDatum) {
+                    final Ellipsoid e = ((GeodeticDatum) datum).getEllipsoid();
+                    if (e != null) return e;
+                }
+            }
+            if (crs instanceof CompoundCRS) {
+                for (final CoordinateReferenceSystem c : ((CompoundCRS) crs).getComponents()) {
+                    final Ellipsoid e = getEllipsoid(c);
+                    if (e != null) return e;
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
      * Returns the ellipsoid used by the specified coordinate reference system, provided that the two first dimensions
      * use an instance of {@link GeographicCRS}. Otherwise (i.e. if the two first dimensions are not geographic),
      * returns {@code null}.

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -322,6 +322,11 @@ public final class Resources extends Ind
         public static final short MissingValueForParameter_1 = 44;
 
         /**
+         * The localization grid still have some undefined source or target coordinates.
+         */
+        public static final short MissingValuesInLocalizationGrid = 81;
+
+        /**
          * No vertical dimension found in “{0}”
          */
         public static final short MissingVerticalDimension_1 = 45;

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.properties?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.properties [ISO-8859-1] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.properties [ISO-8859-1] Fri Mar  9 11:00:27 2018
@@ -80,6 +80,7 @@ MissingTemporalDimension_1        = No t
 MissingSpatioTemporalDimension_1  = No spatial or temporal dimension found in \u201c{0}\u201d
 MissingParameterValues_1          = Missing parameter values for \u201c{0}\u201d coordinate operation.
 MissingValueForParameter_1        = Missing value for \u201c{0}\u201d parameter.
+MissingValuesInLocalizationGrid   = The localization grid still have some undefined source or target coordinates.
 NoConvergence                     = No convergence.
 NoConvergenceForPoints_2          = No convergence for points {0} and {1}.
 NonHorizontalCRS_1                = No horizontal component found in the \u201c{0}\u201d coordinate reference system.

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources_fr.properties?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources_fr.properties [ISO-8859-1] Fri Mar  9 11:00:27 2018
@@ -85,6 +85,7 @@ MissingTemporalDimension_1        = Aucu
 MissingSpatioTemporalDimension_1  = Aucune dimension spatiale ou temporelle n\u2019a \u00e9t\u00e9 trouv\u00e9e dans \u00ab\u202f{0}\u202f\u00bb.
 MissingParameterValues_1          = Il manque les valeurs des param\u00e8tres pour l\u2019op\u00e9ration \u00ab\u202f{0}\u202f\u00bb.
 MissingValueForParameter_1        = Aucune valeur n\u2019a \u00e9t\u00e9 d\u00e9finie pour le param\u00e8tre \u00ab\u202f{0}\u202f\u00bb.
+MissingValuesInLocalizationGrid   = Il manque encore des coordonn\u00e9es sources ou destinations dans la grille de localisation.
 NoConvergence                     = Le calcul ne converge pas.
 NoConvergenceForPoints_2          = Le calcul ne converge pas pour les points {0} et {1}.
 NonHorizontalCRS_1                = Aucune composante horizontale n\u2019a \u00e9t\u00e9 trouv\u00e9e dans le syst\u00e8me de r\u00e9f\u00e9rence des coordonn\u00e9es \u00ab\u202f{0}\u202f\u00bb.

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -49,6 +49,8 @@ import org.apache.sis.util.Static;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.resources.Vocabulary;
 import org.apache.sis.internal.util.Constants;
+import org.apache.sis.internal.util.Numerics;
+import org.apache.sis.math.DecimalFunctions;
 
 
 /**
@@ -60,7 +62,7 @@ import org.apache.sis.internal.util.Cons
  * We need to be specific in order to select the right "aspect" of the given object.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
  * @since   0.4
  * @module
  */
@@ -72,6 +74,39 @@ public final class WKTUtilities extends
     }
 
     /**
+     * Returns the WKT type of the given interface.
+     *
+     * For {@link CoordinateSystem} base type, the returned value shall be one of
+     * {@code affine}, {@code Cartesian}, {@code cylindrical}, {@code ellipsoidal}, {@code linear},
+     * {@code parametric}, {@code polar}, {@code spherical}, {@code temporal} or {@code vertical}.
+     *
+     * @param  base  the abstract base interface.
+     * @param  type  the interface or classes for which to get the WKT type.
+     * @return the WKT type for the given class or interface, or {@code null} if none.
+     *
+     * @see ReferencingUtilities#toPropertyName(Class, Class)
+     */
+    public static String toType(final Class<?> base, final Class<?> type) {
+        if (type != base) {
+            final StringBuilder name = ReferencingUtilities.toPropertyName(base, type);
+            if (name != null) {
+                int end = name.length() - 2;
+                if (CharSequences.regionMatches(name, end, "CS")) {
+                    name.setLength(end);
+                    if ("time".contentEquals(name)) {
+                        return "temporal";
+                    }
+                    if (CharSequences.regionMatches(name, 0, "cartesian")) {
+                        name.setCharAt(0, 'C');     // "Cartesian"
+                    }
+                    return name.toString();
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
      * Returns the given coordinate reference system as a formattable object.
      *
      * @param  object  the coordinate reference system, or {@code null}.
@@ -275,35 +310,44 @@ public final class WKTUtilities extends
     }
 
     /**
-     * Returns the WKT type of the given interface.
-     *
-     * For {@link CoordinateSystem} base type, the returned value shall be one of
-     * {@code affine}, {@code Cartesian}, {@code cylindrical}, {@code ellipsoidal}, {@code linear},
-     * {@code parametric}, {@code polar}, {@code spherical}, {@code temporal} or {@code vertical}.
+     * Suggests an amount of fraction digits to use for formatting numbers in each column of the given sequence
+     * of points. The number of fraction digits may be negative if we could round the numbers to 10, <i>etc</i>.
      *
-     * @param  base  the abstract base interface.
-     * @param  type  the interface or classes for which to get the WKT type.
-     * @return the WKT type for the given class or interface, or {@code null} if none.
-     *
-     * @see ReferencingUtilities#toPropertyName(Class, Class)
-     */
-    public static String toType(final Class<?> base, final Class<?> type) {
-        if (type != base) {
-            final StringBuilder name = ReferencingUtilities.toPropertyName(base, type);
-            if (name != null) {
-                int end = name.length() - 2;
-                if (CharSequences.regionMatches(name, end, "CS")) {
-                    name.setLength(end);
-                    if ("time".contentEquals(name)) {
-                        return "temporal";
-                    }
-                    if (CharSequences.regionMatches(name, 0, "cartesian")) {
-                        name.setCharAt(0, 'C');     // "Cartesian"
-                    }
-                    return name.toString();
+     * @param  crs     the coordinate reference system for each points, or {@code null} if unknown.
+     * @param  points  the sequence of points. It is not required that each point has the same dimension.
+     * @return suggested amount of fraction digits as an array as long as the longest row.
+     */
+    public static int[] suggestFractionDigits(final CoordinateReferenceSystem crs, final double[]... points) {
+        final int[] fractionDigits = Numerics.suggestFractionDigits(points);
+        final Ellipsoid ellipsoid = ReferencingUtilities.getEllipsoid(crs);
+        if (ellipsoid != null) {
+            /*
+             * Use heuristic precisions for geodetic or projected CRS. We do not apply those heuristics
+             * for other kind of CRS (e.g. engineering) because we do not know what could be the size
+             * of the object attached to the CRS.
+             */
+            final CoordinateSystem cs = crs.getCoordinateSystem();
+            final int dimension = Math.min(cs.getDimension(), fractionDigits.length);
+            final double scale = Formulas.scaleComparedToEarth(ellipsoid);
+            for (int i=0; i<dimension; i++) {
+                final Unit<?> unit = cs.getAxis(i).getUnit();
+                double precision;
+                if (Units.isLinear(unit)) {
+                    precision = Formulas.LINEAR_TOLERANCE * scale;                          // In metres
+                } else if (Units.isAngular(unit)) {
+                    precision = Formulas.ANGULAR_TOLERANCE * (Math.PI / 180) * scale;       // In radians
+                } else if (Units.isTemporal(unit)) {
+                    precision = Formulas.TEMPORAL_TOLERANCE;                                // In seconds
+                } else {
+                    continue;
+                }
+                precision /= Units.toStandardUnit(unit);                // In units used by the coordinates.
+                final int f = DecimalFunctions.fractionDigitsForDelta(precision, false);
+                if (f > fractionDigits[i]) {
+                    fractionDigits[i] = f;                              // Use at least the heuristic precision.
                 }
             }
         }
-        return null;
+        return fractionDigits;
     }
 }

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/package-info.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/package-info.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/package-info.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -24,7 +24,7 @@
  * may change in incompatible ways in any future version without notice.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.3
+ * @version 1.0
  * @since   0.3
  * @module
  */

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -280,7 +280,7 @@ public class NamedIdentifier extends Imm
             return c;
         }
         /*
-         * May happen if the user gave us an instance of 'org.apache.sis.internal.jaxb.gmx.Anchor' class
+         * May happen if the user gave us an instance of 'org.apache.sis.internal.jaxb.gcx.Anchor' class
          * (maybe he got the instance indirectly) and the construction of that instance is not completed.
          */
         throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalArgumentClass_2, "code", code.getClass()));

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/LinearTransformBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/LinearTransformBuilder.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/LinearTransformBuilder.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/LinearTransformBuilder.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -20,11 +20,13 @@ import java.util.Map;
 import java.util.Arrays;
 import java.io.IOException;
 import org.opengis.util.FactoryException;
+import org.opengis.geometry.Envelope;
 import org.opengis.geometry.DirectPosition;
 import org.opengis.geometry.MismatchedDimensionException;
 import org.opengis.geometry.coordinate.Position;
 import org.opengis.referencing.operation.Matrix;
 import org.opengis.referencing.operation.MathTransformFactory;
+import org.apache.sis.geometry.GeneralEnvelope;
 import org.apache.sis.io.TableAppender;
 import org.apache.sis.math.Line;
 import org.apache.sis.math.Plane;
@@ -32,7 +34,9 @@ import org.apache.sis.math.Vector;
 import org.apache.sis.referencing.operation.matrix.Matrices;
 import org.apache.sis.referencing.operation.matrix.MatrixSIS;
 import org.apache.sis.referencing.operation.transform.LinearTransform;
+import org.apache.sis.referencing.factory.InvalidGeodeticParameterException;
 import org.apache.sis.internal.referencing.ExtendedPrecisionMatrix;
+import org.apache.sis.internal.referencing.Resources;
 import org.apache.sis.util.resources.Vocabulary;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.ArgumentChecks;
@@ -53,7 +57,7 @@ import org.apache.sis.util.Debug;
  * with the assumption that source positions are exact and all the uncertainty is in the target positions.</p>
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
  *
  * @see LocalizationGridBuilder
  * @see LinearTransform
@@ -302,7 +306,7 @@ search: for (int j=0; j<numPoints; j++)
      * Returns the error message to be given to {@link IllegalStateException} when there is no data.
      */
     private static String noData() {
-        return Errors.format(Errors.Keys.MissingValueForProperty_1, "sourceToTarget");
+        return Resources.format(Resources.Keys.MissingValuesInLocalizationGrid);
     }
 
     /**
@@ -337,6 +341,64 @@ search: for (int j=0; j<numPoints; j++)
     }
 
     /**
+     * Returns the envelope of source points. The lower and upper values are inclusive.
+     *
+     * @return the envelope of source points.
+     * @throws IllegalStateException if the source points are not yet known.
+     *
+     * @since 1.0
+     */
+    public Envelope getSourceEnvelope() {
+        if (gridSize != null) {
+            final int dim = gridSize.length;
+            final GeneralEnvelope envelope = new GeneralEnvelope(dim);
+            for (int i=0; i <dim; i++) {
+                envelope.setRange(i, 0, gridSize[i] - 1);
+            }
+            return envelope;
+        } else {
+            return envelope(sources);
+        }
+    }
+
+    /**
+     * Returns the envelope of target points. The lower and upper values are inclusive.
+     *
+     * @return the envelope of target points.
+     * @throws IllegalStateException if the target points are not yet known.
+     *
+     * @since 1.0
+     */
+    public Envelope getTargetEnvelope() {
+        return envelope(targets);
+    }
+
+    /**
+     * Implementation of {@link #getSourceEnvelope()} and {@link #getTargetEnvelope()}.
+     */
+    private static Envelope envelope(final double[][] points) {
+        if (points == null) {
+            throw new IllegalStateException(noData());
+        }
+        final int dim = points.length;
+        final GeneralEnvelope envelope = new GeneralEnvelope(dim);
+        for (int i=0; i <dim; i++) {
+            final double[] data = points[i];
+            double lower = Double.POSITIVE_INFINITY;
+            double upper = Double.NEGATIVE_INFINITY;
+            for (final double value : data) {
+                if (value < lower) lower = value;
+                if (value > upper) upper = value;
+            }
+            if (lower > upper) {
+                lower = upper = Double.NaN;
+            }
+            envelope.setRange(i, lower, upper);
+        }
+        return envelope;
+    }
+
+    /**
      * Returns the direct position of the given position, or {@code null} if none.
      */
     private static DirectPosition position(final Position p) {
@@ -567,7 +629,7 @@ search: for (int j=0; j<numPoints; j++)
             final double[][] sources = this.sources;                    // Protect from changes.
             final double[][] targets = this.targets;
             if (targets == null) {
-                throw new FactoryException(noData());
+                throw new InvalidGeodeticParameterException(noData());
             }
             final int sourceDim = (sources != null) ? sources.length : gridSize.length;
             final int targetDim = targets.length;
@@ -610,7 +672,7 @@ search: for (int j=0; j<numPoints; j++)
                             c = plan.fit(gridSize[0], gridSize[1], Vector.create(targets[j], false));
                         } catch (IllegalArgumentException e) {
                             // This may happen if the z vector still contain some "NaN" values.
-                            throw new FactoryException(noData(), e);
+                            throw new InvalidGeodeticParameterException(noData(), e);
                         }
                         break;
                     }

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/LocalizationGridBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/LocalizationGridBuilder.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/LocalizationGridBuilder.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/LocalizationGridBuilder.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -17,6 +17,7 @@
 package org.apache.sis.referencing.operation.builder;
 
 import org.opengis.util.FactoryException;
+import org.opengis.geometry.Envelope;
 import org.opengis.geometry.MismatchedDimensionException;
 import org.opengis.referencing.operation.Matrix;
 import org.opengis.referencing.operation.MathTransform;
@@ -27,10 +28,11 @@ import org.apache.sis.referencing.operat
 import org.apache.sis.referencing.operation.transform.LinearTransform;
 import org.apache.sis.referencing.operation.transform.MathTransforms;
 import org.apache.sis.referencing.operation.matrix.MatrixSIS;
-import org.apache.sis.referencing.operation.matrix.Matrices;
+import org.apache.sis.referencing.operation.matrix.Matrix3;
 import org.apache.sis.referencing.datum.DatumShiftGrid;
 import org.apache.sis.internal.referencing.Resources;
 import org.apache.sis.geometry.DirectPosition2D;
+import org.apache.sis.geometry.Envelopes;
 import org.apache.sis.internal.util.Numerics;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.measure.NumberRange;
@@ -58,7 +60,7 @@ import org.apache.sis.math.Vector;
  * </ol>
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
  *
  * @see InterpolatedTransform
  * @see LinearTransform
@@ -128,7 +130,7 @@ public class LocalizationGridBuilder ext
      * @throws ArithmeticException if this constructor can not infer a reasonable grid size from the given vectors.
      */
     public LocalizationGridBuilder(final Vector sourceX, final Vector sourceY) {
-        final Matrix fromGrid = Matrices.createDiagonal(3,3);
+        final Matrix fromGrid = new Matrix3();
         linear = new LinearTransformBuilder(infer(sourceX, fromGrid, 0), infer(sourceY, fromGrid, 1));
         try {
             sourceToGrid = MathTransforms.linear(fromGrid).inverse();
@@ -171,10 +173,16 @@ public class LocalizationGridBuilder ext
                 }
             }
         }
+        /*
+         * Compute the size from the increment that we found. If the size is larger than the vector length,
+         * consider as too large. The rational is that attempt to create a localization grid with that size
+         * would fail anyway, because it would contain holes where no value is defined. A limit is important
+         * for preventing useless allocation of large arrays - https://issues.apache.org/jira/browse/SIS-407
+         */
         fromGrid.setElement(dim, dim, inc);
         fromGrid.setElement(dim,   2, min);
         final double n = span / inc;
-        if (n > 0.5 && n < 0.5 + Short.MAX_VALUE) {
+        if (n >= 0.5 && n < source.size() - 0.5) {          // Compare as 'double' in case the value is large.
             return ((int) Math.round(n)) + 1;
         }
         throw new ArithmeticException(Resources.format(Resources.Keys.CanNotInferGridSizeFromValues_1, range));
@@ -308,6 +316,25 @@ public class LocalizationGridBuilder ext
     }
 
     /**
+     * Returns the envelope of source coordinates. This is the envelope of the grid domain
+     * (i.e. the ranges of valid {@code gridX} and {@code gridY} argument values in calls
+     * to {@code get/setControlPoint(…)} methods) transformed by the inverse of
+     * {@linkplain #getSourceToGrid() source to grid} transform.
+     * The lower and upper values are inclusive.
+     *
+     * @return the envelope of grid points.
+     * @throws IllegalStateException if the grid points are not yet known.
+     * @throws TransformException if the envelope can not be calculated.
+     *
+     * @see LinearTransformBuilder#getSourceEnvelope()
+     *
+     * @since 1.0
+     */
+    public Envelope getSourceEnvelope() throws TransformException {
+        return Envelopes.transform(sourceToGrid.inverse(), linear.getSourceEnvelope());
+    }
+
+    /**
      * Creates a transform from the source points to the target points.
      * This method assumes that source points are precise and all uncertainty is in the target points.
      * If this transform is close enough to an affine transform, then an instance of {@link LinearTransform} is returned.

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/package-info.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/package-info.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/package-info.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -30,8 +30,8 @@
  * convenience.</p>
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.5
- * @since   0.8
+ * @version 1.0
+ * @since   0.5
  * @module
  */
 package org.apache.sis.referencing.operation.builder;

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -437,7 +437,7 @@ public abstract class NormalizedProjecti
         context             = initializer.context;
         eccentricitySquared = initializer.eccentricitySquared.value;
         eccentricity        = sqrt(eccentricitySquared);    // DoubleDouble.sqrt() does not make any difference here.
-        inverse             = new Inverse();
+        inverse             = new Inverse(this);
     }
 
     /**
@@ -450,7 +450,7 @@ public abstract class NormalizedProjecti
         context             = other.context;
         eccentricity        = other.eccentricity;
         eccentricitySquared = other.eccentricitySquared;
-        inverse             = new Inverse();
+        inverse             = new Inverse(this);
     }
 
     /**
@@ -725,20 +725,34 @@ public abstract class NormalizedProjecti
      * Inverse of a normalized map projection.
      *
      * @author  Martin Desruisseaux (Geomatys)
-     * @version 0.8
+     * @version 1.0
      * @since   0.6
      * @module
      */
-    private final class Inverse extends AbstractMathTransform2D.Inverse {
+    private static final class Inverse extends AbstractMathTransform2D.Inverse implements Serializable {
         /**
          * For cross-version compatibility.
          */
-        private static final long serialVersionUID = -9138242780765956870L;
+        private static final long serialVersionUID = 6014176098150309651L;
+
+        /**
+         * The enclosing transform.
+         */
+        private final NormalizedProjection forward;
 
         /**
          * Default constructor.
          */
-        Inverse() {
+        Inverse(final NormalizedProjection forward) {
+            this.forward = forward;
+        }
+
+        /**
+         * Returns the inverse of this math transform.
+         */
+        @Override
+        public MathTransform2D inverse() {
+            return forward;
         }
 
         /**
@@ -752,15 +766,15 @@ public abstract class NormalizedProjecti
                                 final boolean derivate) throws TransformException
         {
             if (!derivate) {
-                inverseTransform(srcPts, srcOff, dstPts, dstOff);
+                forward.inverseTransform(srcPts, srcOff, dstPts, dstOff);
                 return null;
             } else {
                 if (dstPts == null) {
                     dstPts = new double[DIMENSION];
                     dstOff = 0;
                 }
-                inverseTransform(srcPts, srcOff, dstPts, dstOff);
-                return Matrices.inverse(NormalizedProjection.this.transform(dstPts, dstOff, null, 0, true));
+                forward.inverseTransform(srcPts, srcOff, dstPts, dstOff);
+                return Matrices.inverse(forward.transform(dstPts, dstOff, null, 0, true));
             }
         }
 
@@ -775,7 +789,7 @@ public abstract class NormalizedProjecti
             if (srcPts == dstPts && srcOff < dstOff) {
                 super.transform(srcPts, srcOff, dstPts, dstOff, numPts);
             } else while (--numPts >= 0) {
-                inverseTransform(srcPts, srcOff, dstPts, dstOff);
+                forward.inverseTransform(srcPts, srcOff, dstPts, dstOff);
                 srcOff += DIMENSION;
                 dstOff += DIMENSION;
             }
@@ -796,7 +810,7 @@ public abstract class NormalizedProjecti
                  *   - false if applyOtherFirst == false since we have (inverse projection) → (affine) → (projection).
                  *   - true  if applyOtherFirst == true  since we have (projection) → (affine) → (inverse projection).
                  */
-                return NormalizedProjection.this.tryConcatenate(applyOtherFirst, m, factory);
+                return forward.tryConcatenate(applyOtherFirst, m, factory);
             }
             return super.tryConcatenate(applyOtherFirst, other, factory);
         }

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ZonedGridSystem.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ZonedGridSystem.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ZonedGridSystem.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ZonedGridSystem.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -131,7 +131,7 @@ public class ZonedGridSystem extends Abs
         final MatrixSIS normalize = initializer.context.getMatrix(ContextualParameters.MatrixRole.NORMALIZATION);
         normalize.convertBefore(0, null, zoneWidth / -2);
         projection = (AbstractMathTransform) new TransverseMercator(initializer).createMapProjection(factory);
-        inverse    = new Inverse();
+        inverse    = new Inverse(this);
     }
 
 
@@ -185,15 +185,20 @@ public class ZonedGridSystem extends Abs
      * Inverse of a zoned grid system.
      *
      * @author  Martin Desruisseaux (Geomatys)
-     * @version 0.8
+     * @version 1.0
      * @since   0.8
      * @module
      */
-    private final class Inverse extends AbstractMathTransform2D.Inverse {
+    private static final class Inverse extends AbstractMathTransform2D.Inverse implements Serializable {
         /**
          * For cross-version compatibility.
          */
-        private static final long serialVersionUID = 1900563285661407519L;
+        private static final long serialVersionUID = -4417726238412154175L;
+
+        /**
+         * The enclosing transform.
+         */
+        private final ZonedGridSystem forward;
 
         /**
          * The projection that performs the actual work after we removed the zone number.
@@ -203,15 +208,24 @@ public class ZonedGridSystem extends Abs
         /**
          * Default constructor.
          */
-        Inverse() throws FactoryException {
+        Inverse(final ZonedGridSystem forward) throws FactoryException {
+            this.forward = forward;
             try {
-                inverseProjection = (AbstractMathTransform) projection.inverse();
+                inverseProjection = (AbstractMathTransform) forward.projection.inverse();
             } catch (NoninvertibleTransformException e) {
                 throw new FactoryException(e);                  // Should not happen.
             }
         }
 
         /**
+         * Returns the inverse of this math transform.
+         */
+        @Override
+        public MathTransform2D inverse() {
+            return forward;
+        }
+
+        /**
          * Inverse transforms the specified {@code srcPts} and stores the result in {@code dstPts}.
          * If the derivative has been requested, then this method will delegate the derivative
          * calculation to the enclosing class and inverts the resulting matrix.
@@ -228,7 +242,7 @@ public class ZonedGridSystem extends Abs
             dstPts[dstOff  ] = x;
             dstPts[dstOff+1] = y;
             final Matrix derivative = inverseProjection.transform(dstPts, dstOff, dstPts, dstOff, derivate);
-            dstPts[dstOff] += zone * zoneWidth + initialLongitude;
+            dstPts[dstOff] += zone * forward.zoneWidth + forward.initialLongitude;
             return derivative;
         }
     }

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/package-info.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/package-info.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/package-info.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -159,7 +159,7 @@
  * @author  Martin Desruisseaux (Geomatys)
  * @author  Rémi Maréchal (Geomatys)
  * @author  Adrian Custer (Geomatys)
- * @version 0.8
+ * @version 1.0
  *
  * @see <a href="http://www.remotesensing.org/geotiff/proj_list">Projections list on RemoteSensing.org</a>
  * @see <a href="http://mathworld.wolfram.com/MapProjection.html">Map projections on MathWorld</a>

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -18,7 +18,6 @@ package org.apache.sis.referencing.opera
 
 import java.util.List;
 import java.util.Arrays;
-import java.io.Serializable;
 import org.opengis.util.FactoryException;
 import org.opengis.geometry.DirectPosition;
 import org.opengis.geometry.MismatchedDimensionException;
@@ -988,31 +987,20 @@ public abstract class AbstractMathTransf
 
     /**
      * Base class for implementations of inverse math transforms.
-     * This inner class is the inverse of the enclosing {@link AbstractMathTransform}.
+     * Subclasses need to implement the {@link #inverse()} method.
      *
      * <div class="section">Serialization</div>
-     * Instances of this class are serializable only if the enclosing math transform is also serializable.
-     * Serialized math transforms are not guaranteed to be compatible with future SIS versions.
-     * Serialization, if allowed, should be used only for short term storage or RMI between applications
+     * This object may or may not be serializable, at implementation choices.
+     * Most Apache SIS implementations are serializable, but the serialized objects are not guaranteed to be compatible
+     * with future SIS versions. Serialization should be used only for short term storage or RMI between applications
      * running the same SIS version.
      *
      * @author  Martin Desruisseaux (IRD, Geomatys)
-     * @version 0.6
+     * @version 1.0
      * @since   0.5
      * @module
      */
-    protected abstract class Inverse extends AbstractMathTransform implements Serializable {
-        /**
-         * Serial number for inter-operability with different versions. This serial number is
-         * especially important for inner classes, since the default {@code serialVersionUID}
-         * computation will not produce consistent results across implementations of different
-         * Java compiler. This is because different compilers may generate different names for
-         * synthetic members used in the implementation of inner classes. See:
-         *
-         * http://developer.java.sun.com/developer/bugParade/bugs/4211550.html
-         */
-        private static final long serialVersionUID = 3528274816628012283L;
-
+    protected abstract static class Inverse extends AbstractMathTransform {
         /**
          * Constructs an inverse math transform.
          */
@@ -1021,29 +1009,32 @@ public abstract class AbstractMathTransf
 
         /**
          * Gets the dimension of input points.
-         * The implementation returns the dimension of output points of the enclosing math transform.
+         * The default implementation returns the dimension of output points
+         * of the {@linkplain #inverse() inverse} math transform.
          *
          * @return {@inheritDoc}
          */
         @Override
-        public final int getSourceDimensions() {
-            return AbstractMathTransform.this.getTargetDimensions();
+        public int getSourceDimensions() {
+            return inverse().getTargetDimensions();
         }
 
         /**
          * Gets the dimension of output points.
-         * The implementation returns the dimension of input points of the enclosing math transform.
+         * The default implementation returns the dimension of input points
+         * of the {@linkplain #inverse() inverse} math transform.
          *
          * @return {@inheritDoc}
          */
         @Override
-        public final int getTargetDimensions() {
-            return AbstractMathTransform.this.getSourceDimensions();
+        public int getTargetDimensions() {
+            return inverse().getSourceDimensions();
         }
 
         /**
          * Gets the derivative of this transform at a point.
-         * The default implementation computes the inverse of the matrix returned by the enclosing math transform.
+         * The default implementation computes the inverse of the matrix
+         * returned by the {@linkplain #inverse() inverse} math transform.
          *
          * @return {@inheritDoc}
          * @throws NullPointerException if the derivative depends on coordinate and {@code point} is {@code null}.
@@ -1055,28 +1046,27 @@ public abstract class AbstractMathTransf
             if (point != null) {
                 point = this.transform(point, null);
             }
-            return Matrices.inverse(AbstractMathTransform.this.derivative(point));
+            return Matrices.inverse(inverse().derivative(point));
         }
 
         /**
-         * Returns the inverse of this math transform, which is the enclosing math transform.
+         * Returns the inverse of this math transform.
+         * The returned transform should be the enclosing math transform.
          *
-         * @return the enclosing math transform.
+         * @return the inverse of this transform.
          */
         @Override
-        public MathTransform inverse() {
-            return AbstractMathTransform.this;
-        }
+        public abstract MathTransform inverse();
 
         /**
          * Tests whether this transform does not move any points.
-         * The default implementation delegates this tests to the enclosing math transform.
+         * The default implementation delegates this tests to the {@linkplain #inverse() inverse} math transform.
          *
          * @return {@inheritDoc}
          */
         @Override
         public boolean isIdentity() {
-            return AbstractMathTransform.this.isIdentity();
+            return inverse().isIdentity();
         }
 
         /**
@@ -1086,13 +1076,13 @@ public abstract class AbstractMathTransf
          */
         @Override
         protected int computeHashCode() {
-            return super.computeHashCode() + 31*AbstractMathTransform.this.hashCode();
+            return super.computeHashCode() + 31 * inverse().hashCode();
         }
 
         /**
          * Compares the specified object with this inverse math transform for equality.
-         * The default implementation tests if {@code object} in an instance of the same class
-         * than {@code this}, and if so compares their enclosing {@code AbstractMathTransform}.
+         * The default implementation tests if {@code object} in an instance of the same class than {@code this},
+         * and if so compares their {@linkplain #inverse() inverse} {@code MathTransform}.
          *
          * @return {@inheritDoc}
          */
@@ -1102,7 +1092,13 @@ public abstract class AbstractMathTransf
                 return true;                                            // Slight optimization
             }
             if (object != null && object.getClass() == getClass()) {
-                return AbstractMathTransform.this.equals(((Inverse) object).inverse(), mode);
+                final MathTransform other = ((Inverse) object).inverse();
+                final MathTransform inverse = inverse();
+                if (inverse instanceof LenientComparable) {
+                    return ((LenientComparable) inverse).equals(other, mode);
+                } else {
+                    return inverse.equals(other);
+                }
             } else {
                 return false;
             }
@@ -1118,7 +1114,12 @@ public abstract class AbstractMathTransf
             if (parameters != null) {
                 return parameters.beforeFormat(transforms, index, inverse);
             } else {
-                return AbstractMathTransform.this.beforeFormat(transforms, index, !inverse);
+                final MathTransform inv = inverse();
+                if (inv instanceof AbstractMathTransform) {
+                    return ((AbstractMathTransform) inv).beforeFormat(transforms, index, !inverse);
+                } else {
+                    return index;
+                }
             }
         }
 
@@ -1143,7 +1144,7 @@ public abstract class AbstractMathTransf
                 return WKTKeywords.Param_MT;
             } else {
                 formatter.newLine();
-                formatter.append((FormattableObject) AbstractMathTransform.this);
+                formatter.append((FormattableObject) inverse());
                 return WKTKeywords.Inverse_MT;
             }
         }

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform1D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform1D.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform1D.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform1D.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -156,22 +156,17 @@ public abstract class AbstractMathTransf
      * This inner class is the inverse of the enclosing {@link AbstractMathTransform1D}.
      *
      * <div class="section">Serialization</div>
-     * Instances of this class are serializable only if the enclosing math transform is also serializable.
-     * Serialized math transforms are not guaranteed to be compatible with future SIS versions.
-     * Serialization, if allowed, should be used only for short term storage or RMI between applications
+     * This object may or may not be serializable, at implementation choices.
+     * Most Apache SIS implementations are serializable, but the serialized objects are not guaranteed to be compatible
+     * with future SIS versions. Serialization should be used only for short term storage or RMI between applications
      * running the same SIS version.
      *
      * @author  Martin Desruisseaux (Geomatys)
-     * @version 0.7
+     * @version 1.0
      * @since   0.7
      * @module
      */
-    protected abstract class Inverse extends AbstractMathTransform.Inverse implements MathTransform1D {
-        /**
-         * Serial number for inter-operability with different versions.
-         */
-        private static final long serialVersionUID = 2018412413506158560L;
-
+    protected abstract static class Inverse extends AbstractMathTransform.Inverse implements MathTransform1D {
         /**
          * Constructs an inverse math transform.
          */
@@ -179,12 +174,11 @@ public abstract class AbstractMathTransf
         }
 
         /**
-         * Returns the enclosing math transform.
+         * Returns the inverse of this math transform.
+         * The returned transform should be the enclosing math transform.
          */
         @Override
-        public MathTransform1D inverse() {
-            return (MathTransform1D) super.inverse();
-        }
+        public abstract MathTransform1D inverse();
 
         /**
          * Transforms a single point in the given array and opportunistically computes its derivative if requested.

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform2D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform2D.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform2D.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform2D.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -319,22 +319,17 @@ public abstract class AbstractMathTransf
      * This inner class is the inverse of the enclosing {@link AbstractMathTransform2D}.
      *
      * <div class="section">Serialization</div>
-     * Instances of this class are serializable only if the enclosing math transform is also serializable.
-     * Serialized math transforms are not guaranteed to be compatible with future SIS versions.
-     * Serialization, if allowed, should be used only for short term storage or RMI between applications
+     * This object may or may not be serializable, at implementation choices.
+     * Most Apache SIS implementations are serializable, but the serialized objects are not guaranteed to be compatible
+     * with future SIS versions. Serialization should be used only for short term storage or RMI between applications
      * running the same SIS version.
      *
      * @author  Martin Desruisseaux (Geomatys)
-     * @version 0.5
+     * @version 1.0
      * @since   0.5
      * @module
      */
-    protected abstract class Inverse extends AbstractMathTransform.Inverse implements MathTransform2D {
-        /**
-         * Serial number for inter-operability with different versions.
-         */
-        private static final long serialVersionUID = 5751908928042026412L;
-
+    protected abstract static class Inverse extends AbstractMathTransform.Inverse implements MathTransform2D {
         /**
          * Constructs an inverse math transform.
          */
@@ -342,12 +337,11 @@ public abstract class AbstractMathTransf
         }
 
         /**
-         * Returns the enclosing math transform.
+         * Returns the inverse of this math transform.
+         * The returned transform should be the enclosing math transform.
          */
         @Override
-        public MathTransform2D inverse() {
-            return (MathTransform2D) super.inverse();
-        }
+        public abstract MathTransform2D inverse();
 
         /**
          * Transforms the specified {@code ptSrc} and stores the result in {@code ptDst}.

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransform.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransform.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransform.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -299,7 +299,7 @@ public class EllipsoidToCentricTransform
             final MatrixSIS normalize = context.getMatrix(ContextualParameters.MatrixRole.NORMALIZATION);
             normalize.convertBefore(2, a, null);    // Divide ellipsoidal height by a.
         }
-        inverse = new Inverse();
+        inverse = new Inverse(this);
     }
 
     /**
@@ -779,20 +779,34 @@ next:   while (--numPts >= 0) {
      * to ellipsoidal coordinates (λ,φ) or (λ,φ,<var>h</var>).
      *
      * @author  Martin Desruisseaux (IRD, Geomatys)
-     * @version 0.7
+     * @version 1.0
      * @since   0.7
      * @module
      */
-    private final class Inverse extends AbstractMathTransform.Inverse implements Serializable {
+    private static final class Inverse extends AbstractMathTransform.Inverse implements Serializable {
         /**
          * Serial number for inter-operability with different versions.
          */
-        private static final long serialVersionUID = 6942084702259211803L;
+        private static final long serialVersionUID = 33004303758761821L;
+
+        /**
+         * The enclosing transform.
+         */
+        private final EllipsoidToCentricTransform forward;
 
         /**
          * Creates the inverse of the enclosing transform.
          */
-        Inverse() {
+        Inverse(final EllipsoidToCentricTransform forward) {
+            this.forward = forward;
+        }
+
+        /**
+         * Returns the inverse of this math transform.
+         */
+        @Override
+        public MathTransform inverse() {
+            return forward;
         }
 
         /**
@@ -801,7 +815,7 @@ next:   while (--numPts >= 0) {
          */
         @Override
         protected ContextualParameters getContextualParameters() {
-            return context.inverse(GeocentricToGeographic.PARAMETERS);
+            return forward.context.inverse(GeocentricToGeographic.PARAMETERS);
         }
 
         /**
@@ -812,7 +826,7 @@ next:   while (--numPts >= 0) {
         @Override
         public ParameterValueGroup getParameterValues() {
             final ParameterValueGroup pg = getParameterDescriptors().createValue();
-            pg.values().addAll(EllipsoidToCentricTransform.this.getParameterValues().values());
+            pg.values().addAll(forward.getParameterValues().values());
             return pg;
         }
 
@@ -830,7 +844,7 @@ next:   while (--numPts >= 0) {
         public ParameterDescriptorGroup getParameterDescriptors() {
             return new DefaultParameterDescriptorGroup(Collections.singletonMap(ParameterDescriptorGroup.NAME_KEY,
                             new ImmutableIdentifier(Citations.SIS, Constants.SIS, "Centric to ellipsoid (radians domain)")),
-                    EllipsoidToCentricTransform.this.getParameterDescriptors());
+                    forward.getParameterDescriptors());
         }
 
         /**
@@ -860,14 +874,14 @@ next:   while (--numPts >= 0) {
         {
             final double[] point;
             final int offset;
-            if (derivate && (dstPts == null || !withHeight)) {
+            if (derivate && (dstPts == null || !forward.withHeight)) {
                 point  = new double[3];
                 offset = 0;
             } else {
                 point  = dstPts;
                 offset = dstOff;
             }
-            inverseTransform(srcPts, srcOff, point, offset, 1);
+            forward.inverseTransform(srcPts, srcOff, point, offset, 1);
             if (!derivate) {
                 return null;
             }
@@ -876,9 +890,9 @@ next:   while (--numPts >= 0) {
                 dstPts[dstOff+1] = point[1];
             }
             // We need to keep h during matrix inversion because (λ,φ,h) values are not independent.
-            Matrix matrix = EllipsoidToCentricTransform.this.derivative(new DirectPositionView(point, offset, 3));
+            Matrix matrix = forward.derivative(new DirectPositionView.Double(point, offset, 3));
             matrix = Matrices.inverse(matrix);
-            if (!withHeight) {
+            if (!forward.withHeight) {
                 matrix = MatrixSIS.castOrCopy(matrix).removeRows(2, 3);     // Drop height only after matrix inversion is done.
             }
             return matrix;
@@ -892,7 +906,7 @@ next:   while (--numPts >= 0) {
         public void transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)
                 throws TransformException
         {
-            inverseTransform(srcPts, srcOff, dstPts, dstOff, numPts);
+            forward.inverseTransform(srcPts, srcOff, dstPts, dstOff, numPts);
         }
 
         /**
@@ -918,7 +932,7 @@ next:   while (--numPts >= 0) {
         protected MathTransform tryConcatenate(final boolean applyOtherFirst, final MathTransform other,
                 final MathTransformFactory factory) throws FactoryException
         {
-            if (!applyOtherFirst && withHeight && other instanceof LinearTransform && other.getTargetDimensions() == 2) {
+            if (!applyOtherFirst && forward.withHeight && other instanceof LinearTransform && other.getTargetDimensions() == 2) {
                 /*
                  * Found a 3×4 matrix after this transform. We can reduce to a 3×3 matrix only if no dimension
                  * use the column that we are about to drop (i.e. all coefficients in that column are zero).
@@ -929,7 +943,7 @@ next:   while (--numPts >= 0) {
                     matrix.getElement(2,2) == 0)
                 {
                     matrix = MatrixSIS.castOrCopy(matrix).removeColumns(2, 3);
-                    final MathTransform tr2D = create2D().inverse();
+                    final MathTransform tr2D = forward.create2D().inverse();
                     if (factory != null) {
                         return factory.createConcatenatedTransform(tr2D, factory.createAffineTransform(matrix));
                     } else {
@@ -951,7 +965,7 @@ next:   while (--numPts >= 0) {
         @Override
         final int beforeFormat(final List<Object> transforms, int index, final boolean inverse) {
             index = super.beforeFormat(transforms, index, inverse);
-            if (!withHeight) {
+            if (!forward.withHeight) {
                 transforms.add(++index, new Geographic3Dto2D.WKT(false));
             }
             return index;

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -18,6 +18,7 @@ package org.apache.sis.referencing.opera
 
 import java.util.Arrays;
 import java.util.Objects;
+import java.io.Serializable;
 import javax.measure.Unit;
 import javax.measure.Quantity;
 import org.opengis.util.FactoryException;
@@ -382,7 +383,7 @@ public class InterpolatedTransform exten
      * To overridden by the two-dimensional transform case.
      */
     InterpolatedTransform.Inverse createInverse() {
-        return new Inverse();
+        return new Inverse(this);
     }
 
     /**
@@ -416,15 +417,20 @@ public class InterpolatedTransform exten
      *
      * @author  Rueben Schulz (UBC)
      * @author  Martin Desruisseaux (IRD, Geomatys)
-     * @version 0.7
+     * @version 1.0
      * @since   0.7
      * @module
      */
-    class Inverse extends AbstractMathTransform.Inverse {
+    static class Inverse extends AbstractMathTransform.Inverse implements Serializable {
         /**
          * Serial number for inter-operability with different versions.
          */
-        private static final long serialVersionUID = -6779719408779847014L;
+        private static final long serialVersionUID = 4335801994727826360L;
+
+        /**
+         * The enclosing transform.
+         */
+        private final InterpolatedTransform forward;
 
         /**
          * Difference allowed in iterative computations, in units of grid cell size.
@@ -434,15 +440,24 @@ public class InterpolatedTransform exten
         /**
          * Creates an inverse transform.
          */
-        Inverse() {
-            tolerance = grid.getCellPrecision();
-            if (!(tolerance > 0)) {         // Use ! for catching NaN.
+        Inverse(final InterpolatedTransform forward) {
+            this.forward = forward;
+            tolerance = forward.grid.getCellPrecision();
+            if (!(tolerance > 0)) {                                     // Use ! for catching NaN.
                 throw new IllegalArgumentException(Errors.format(
                         Errors.Keys.ValueNotGreaterThanZero_2, "grid.cellPrecision", tolerance));
             }
         }
 
         /**
+         * Returns the inverse of this math transform.
+         */
+        @Override
+        public MathTransform inverse() {
+            return forward;
+        }
+
+        /**
          * Transforms a single coordinate in a list of ordinal values,
          * and optionally returns the derivative at that location.
          *
@@ -452,6 +467,7 @@ public class InterpolatedTransform exten
         public final Matrix transform(final double[] srcPts, final int srcOff, double[] dstPts, int dstOff,
                                       final boolean derivate) throws TransformException
         {
+            final int dimension = forward.dimension;
             if (dstPts == null) {
                 dstPts = new double[dimension];
                 dstOff = 0;
@@ -462,7 +478,7 @@ public class InterpolatedTransform exten
             final double[] vector = new double[dimension];
             int it = Formulas.MAXIMUM_ITERATIONS;
             do {
-                grid.interpolateInCell(xi, yi, vector);
+                forward.grid.interpolateInCell(xi, yi, vector);
                 final double ox = xi;
                 final double oy = yi;
                 xi = x - vector[0];
@@ -487,8 +503,8 @@ public class InterpolatedTransform exten
                     dstPts[dstOff  ] = xi;      // Shall not be done before above loop.
                     dstPts[dstOff+1] = yi;
                     if (derivate) {
-                        return Matrices.inverse(InterpolatedTransform.this.derivative(
-                                new DirectPositionView(dstPts, dstOff, dimension)));
+                        return Matrices.inverse(forward.derivative(
+                                new DirectPositionView.Double(dstPts, dstOff, dimension)));
                     }
                     return null;
                 }
@@ -505,6 +521,7 @@ public class InterpolatedTransform exten
         public final void transform(double[] srcPts, int srcOff, final double[] dstPts, int dstOff, int numPts)
                 throws TransformException
         {
+            final int dimension = forward.dimension;
             int inc = dimension;
             if (srcPts == dstPts) {
                 switch (IterationStrategy.suggest(srcOff, inc, dstOff, inc, numPts)) {
@@ -531,7 +548,7 @@ nextPoint:  while (--numPts >= 0) {
                 final double y = yi = srcPts[srcOff+1];
                 int it = Formulas.MAXIMUM_ITERATIONS;
                 do {
-                    grid.interpolateInCell(xi, yi, vector);
+                    forward.grid.interpolateInCell(xi, yi, vector);
                     final double ox = xi;
                     final double oy = yi;
                     xi = x - vector[0];

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform2D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform2D.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform2D.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform2D.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -84,14 +84,14 @@ final class InterpolatedTransform2D exte
      */
     @Override
     InterpolatedTransform.Inverse createInverse() {
-        return new Inverse();
+        return new Inverse(this);
     }
 
     /**
      * The inverse of the enclosing {@link InterpolatedTransform2D}.
      *
      * @author  Martin Desruisseaux (Geomatys)
-     * @version 0.7
+     * @version 1.0
      * @since   0.7
      * @module
      */
@@ -99,12 +99,13 @@ final class InterpolatedTransform2D exte
         /**
          * Serial number for inter-operability with different versions.
          */
-        private static final long serialVersionUID = 5739665311481484972L;
+        private static final long serialVersionUID = 4802773675799229357L;
 
         /**
          * Constructs the inverse of an interpolated transform.
          */
-        Inverse() {
+        Inverse(final InterpolatedTransform2D forward) {
+            super(forward);
         }
 
         /**

Modified: sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/IterationStrategy.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/IterationStrategy.java?rev=1826327&r1=1826326&r2=1826327&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/IterationStrategy.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/IterationStrategy.java [UTF-8] Fri Mar  9 11:00:27 2018
@@ -95,7 +95,7 @@ public enum IterationStrategy {
     DESCENDING(false),
 
     /**
-     * Copies the points to transform in a temporary array before to apply the transform.
+     * Copy the points to transform in a temporary array before to apply the transform.
      * The temporary array will be used for fetching the source ordinates.
      *
      * <p>This algorithm can be used as a fallback for any unknown enumeration.</p>
@@ -103,7 +103,7 @@ public enum IterationStrategy {
     BUFFER_SOURCE(true),
 
     /**
-     * Writes the transformed points in a temporary array and copies them to the
+     * Write the transformed points in a temporary array and copies them to the
      * destination subarray when the transformation is finished.
      *
      * <p>Developers are allowed to ignore this value and fallback on the same algorithm



Mime
View raw message