sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1718276 - in /sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform: InterpolatedTransform.java InterpolatedTransform2D.java
Date Mon, 07 Dec 2015 09:59:53 GMT
Author: desruisseaux
Date: Mon Dec  7 09:59:52 2015
New Revision: 1718276

URL: http://svn.apache.org/viewvc?rev=1718276&view=rev
Log:
Add the two-dimensional case of InterpolatedTransform.

Added:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform2D.java
  (with props)
Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java?rev=1718276&r1=1718275&r2=1718276&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java
[UTF-8] Mon Dec  7 09:59:52 2015
@@ -145,6 +145,7 @@ public class InterpolatedTransform exten
      *
      * @see #createGeodeticTransformation(MathTransformFactory, DatumShiftGrid)
      */
+    @SuppressWarnings("OverridableMethodCallDuringObjectConstruction")
     protected <T extends Quantity> InterpolatedTransform(final DatumShiftGrid<T,T>
grid)
             throws NoninvertibleMatrixException
     {
@@ -198,7 +199,7 @@ public class InterpolatedTransform exten
          * Denormalization is the inverse of all above conversions.
          */
         context.getMatrix(ContextualParameters.MatrixRole.DENORMALIZATION).setMatrix(normalize.inverse());
-        inverse = new Inverse();
+        inverse = createInverse();
     }
 
     /**
@@ -234,7 +235,11 @@ public class InterpolatedTransform exten
         ArgumentChecks.ensureNonNull("grid", grid);
         final InterpolatedTransform tr;
         try {
-            tr = new InterpolatedTransform(grid);
+            if (grid.getTranslationDimensions() == 2) {
+                tr = new InterpolatedTransform2D(grid);
+            } else {
+                tr = new InterpolatedTransform(grid);
+            }
         } catch (NoninvertibleMatrixException e) {
             throw new FactoryException(e.getLocalizedMessage(), e);
         }
@@ -390,7 +395,7 @@ public class InterpolatedTransform exten
      */
 
     /**
-     * Returns the inverse of this interpolated geocentric transform.
+     * Returns the inverse of this interpolated transform.
      * The source ellipsoid of the returned transform will be the target ellipsoid of this
transform, and conversely.
      *
      * @return A transform from the target ellipsoid to the source ellipsoid of this transform.
@@ -401,6 +406,14 @@ public class InterpolatedTransform exten
     }
 
     /**
+     * Invoked at construction time for creating the inverse transform.
+     * To overridden by the two-dimensional transform case.
+     */
+    InterpolatedTransform.Inverse createInverse() {
+        return new Inverse();
+    }
+
+    /**
      * {@inheritDoc}
      *
      * @return {@inheritDoc}
@@ -434,7 +447,7 @@ public class InterpolatedTransform exten
      * @since   0.7
      * @module
      */
-    private final class Inverse extends AbstractMathTransform.Inverse {
+    class Inverse extends AbstractMathTransform.Inverse {
         /**
          * Serial number for inter-operability with different versions.
          */
@@ -463,8 +476,8 @@ public class InterpolatedTransform exten
          * @throws TransformException If there is no convergence.
          */
         @Override
-        public Matrix transform(final double[] srcPts, final int srcOff, double[] dstPts,
int dstOff,
-                                final boolean derivate) throws TransformException
+        public final Matrix transform(final double[] srcPts, final int srcOff, double[] dstPts,
int dstOff,
+                                      final boolean derivate) throws TransformException
         {
             if (dstPts == null) {
                 dstPts = new double[dimension];
@@ -516,7 +529,7 @@ public class InterpolatedTransform exten
          * @throws TransformException if a point can not be transformed.
          */
         @Override
-        public void transform(double[] srcPts, int srcOff, final double[] dstPts, int dstOff,
int numPts)
+        public final void transform(double[] srcPts, int srcOff, final double[] dstPts, int
dstOff, int numPts)
                 throws TransformException
         {
             int inc = dimension;

Added: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform2D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform2D.java?rev=1718276&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform2D.java
(added)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform2D.java
Mon Dec  7 09:59:52 2015
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.referencing.operation.transform;
+
+import java.awt.Shape;
+import java.awt.geom.Point2D;
+import javax.measure.quantity.Quantity;
+import org.opengis.referencing.operation.Matrix;
+import org.opengis.referencing.operation.MathTransform2D;
+import org.opengis.referencing.operation.TransformException;
+import org.apache.sis.referencing.datum.DatumShiftGrid;
+import org.apache.sis.referencing.operation.matrix.NoninvertibleMatrixException;
+
+
+/**
+ * An interpolated transform for two-dimensional input and output coordinates.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.7
+ * @version 0.7
+ * @module
+ */
+final class InterpolatedTransform2D extends InterpolatedTransform implements MathTransform2D
{
+    /**
+     * Serial number for compatibility with different versions.
+     */
+    private static final long serialVersionUID = -4273636001174024827L;
+
+    /**
+     * Constructs a 2D transform.
+     */
+    <T extends Quantity> InterpolatedTransform2D(final DatumShiftGrid<T,T> grid)
throws NoninvertibleMatrixException {
+        super(grid);
+    }
+
+    /**
+     * Computes the derivative at the given position point.
+     */
+    @Override
+    public Matrix derivative(Point2D point) throws TransformException {
+        return AbstractMathTransform2D.derivative(this, point);
+    }
+
+    /**
+     * Transforms a single point.
+     */
+    @Override
+    public Point2D transform(Point2D ptSrc, Point2D ptDst) throws TransformException {
+        return AbstractMathTransform2D.transform(this, ptSrc, ptDst);
+    }
+
+    /**
+     * Transforms the given shape.
+     */
+    @Override
+    public Shape createTransformedShape(Shape shape) throws TransformException {
+        return AbstractMathTransform2D.createTransformedShape(this, shape, null, null, false);
+    }
+
+    /**
+     * Returns the inverse transform of this transform.
+     */
+    @Override
+    public MathTransform2D inverse() {
+        return (MathTransform2D) super.inverse();
+    }
+
+    /**
+     * Invoked at construction time for creating the two-dimensional inverse transform.
+     */
+    @Override
+    InterpolatedTransform.Inverse createInverse() {
+        return new Inverse();
+    }
+
+    /**
+     * The inverse of the enclosing {@link InterpolatedTransform2D}.
+     *
+     * @author  Martin Desruisseaux (Geomatys)
+     * @since   0.7
+     * @version 0.7
+     * @module
+     */
+    final class Inverse extends InterpolatedTransform.Inverse implements MathTransform2D
{
+        /**
+         * Serial number for inter-operability with different versions.
+         */
+        private static final long serialVersionUID = 5739665311481484972L;
+
+        /**
+         * Constructs the inverse of an interpolated transform.
+         */
+        Inverse() {
+        }
+
+        /**
+         * Computes the derivative at the given position point.
+         */
+        @Override
+        public Matrix derivative(Point2D point) throws TransformException {
+            return AbstractMathTransform2D.derivative(this, point);
+        }
+
+        /**
+         * Transforms a single point.
+         */
+        @Override
+        public Point2D transform(Point2D ptSrc, Point2D ptDst) throws TransformException
{
+            return AbstractMathTransform2D.transform(this, ptSrc, ptDst);
+        }
+
+        /**
+         * Transforms the given shape.
+         */
+        @Override
+        public Shape createTransformedShape(Shape shape) throws TransformException {
+            return AbstractMathTransform2D.createTransformedShape(this, shape, null, null,
false);
+        }
+
+        /**
+         * Returns the inverse transform of this transform.
+         */
+        @Override
+        public MathTransform2D inverse() {
+            return (MathTransform2D) super.inverse();
+        }
+    }
+}

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform2D.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform2D.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message