You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2015/12/07 11:02:23 UTC
svn commit: r1718280 - in /sis/branches/JDK8/core/sis-referencing/src:
main/java/org/apache/sis/internal/referencing/j2d/
main/java/org/apache/sis/internal/referencing/provider/
main/java/org/apache/sis/referencing/datum/ main/java/org/apache/sis/refer...
Author: desruisseaux
Date: Mon Dec 7 10:02:22 2015
New Revision: 1718280
URL: http://svn.apache.org/viewvc?rev=1718280&view=rev
Log:
LinearTransform.inverse() should return an instance of LinearTransform.
Added:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/LinearTransform2D.java (with props)
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractLinearTransform.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CopyTransform.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/IdentityTransform.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LinearTransform.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LinearTransform1D.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform2D.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NADCONTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NTv2Test.java
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java?rev=1718280&r1=1718279&r2=1718280&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java [UTF-8] Mon Dec 7 10:02:22 2015
@@ -49,13 +49,13 @@ import static org.apache.sis.util.Argume
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.5
- * @version 0.6
+ * @version 0.7
* @module
*
* @see ProjectiveTransform
*/
-public class AffineTransform2D extends ImmutableAffineTransform implements MathTransform2D,
- LinearTransform, LenientComparable, Parameterized
+public class AffineTransform2D extends ImmutableAffineTransform
+ implements LinearTransform2D, LenientComparable, Parameterized
{
/**
* Serial number for inter-operability with different versions.
@@ -284,7 +284,7 @@ public class AffineTransform2D extends I
* @throws NoninvertibleTransformException if this transform can not be inverted.
*/
@Override
- public final MathTransform2D inverse() throws NoninvertibleTransformException {
+ public final AffineTransform2D inverse() throws NoninvertibleTransformException {
if (inverse == null) {
if (super.isIdentity()) {
inverse = this;
Added: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/LinearTransform2D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/LinearTransform2D.java?rev=1718280&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/LinearTransform2D.java (added)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/LinearTransform2D.java [UTF-8] Mon Dec 7 10:02:22 2015
@@ -0,0 +1,41 @@
+/*
+ * 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.internal.referencing.j2d;
+
+import org.opengis.referencing.operation.MathTransform2D;
+import org.opengis.referencing.operation.NoninvertibleTransformException;
+import org.apache.sis.referencing.operation.transform.LinearTransform;
+
+
+/**
+ * A two dimensional, linear transform.
+ * The intend of this interface is to resolve type conflict in the {@link #inverse()} method.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.7
+ * @version 0.7
+ * @module
+ */
+public interface LinearTransform2D extends MathTransform2D, LinearTransform {
+ /**
+ * Returns the inverse transform, which shall be linear and two-dimensional.
+ *
+ * @return The inverse transform.
+ */
+ @Override
+ LinearTransform2D inverse() throws NoninvertibleTransformException;
+}
Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/LinearTransform2D.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/LinearTransform2D.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java?rev=1718280&r1=1718279&r2=1718280&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java [UTF-8] Mon Dec 7 10:02:22 2015
@@ -29,7 +29,6 @@ import org.apache.sis.util.collection.Ca
import org.apache.sis.util.Debug;
import org.apache.sis.parameter.Parameters;
import org.apache.sis.referencing.datum.DatumShiftGrid;
-import org.apache.sis.referencing.operation.transform.LinearTransform;
import org.apache.sis.internal.referencing.j2d.AffineTransform2D;
// Branch-specific imports
@@ -126,7 +125,7 @@ public abstract class DatumShiftGridFile
final ParameterDescriptorGroup descriptor,
final Path... files) throws NoninvertibleTransformException
{
- super(coordinateUnit, (LinearTransform) new AffineTransform2D(Δx, 0, 0, Δy, x0, y0).inverse(),
+ super(coordinateUnit, new AffineTransform2D(Δx, 0, 0, Δy, x0, y0).inverse(),
new int[] {nx, ny}, isCellValueRatio, translationUnit);
this.descriptor = descriptor;
this.files = files;
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java?rev=1718280&r1=1718279&r2=1718280&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java [UTF-8] Mon Dec 7 10:02:22 2015
@@ -429,7 +429,7 @@ public abstract class DatumShiftGrid<C e
c.transform(ordinates, 0, vector, 0, 1);
interpolateInCell(vector[0], vector[1], vector);
if (isCellValueRatio()) {
- ((LinearTransform) c.inverse()).deltaTransform(vector, 0, vector, 0, 1);
+ c.inverse().deltaTransform(vector, 0, vector, 0, 1);
}
if (vector.length != dim) {
vector = Arrays.copyOf(vector, dim);
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractLinearTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractLinearTransform.java?rev=1718280&r1=1718279&r2=1718280&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractLinearTransform.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractLinearTransform.java [UTF-8] Mon Dec 7 10:02:22 2015
@@ -20,7 +20,6 @@ import java.util.Arrays;
import java.io.Serializable;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.parameter.ParameterDescriptorGroup;
-import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.Matrix;
import org.opengis.referencing.operation.NoninvertibleTransformException;
import org.apache.sis.referencing.operation.matrix.Matrices;
@@ -56,7 +55,7 @@ abstract class AbstractLinearTransform e
* This field is part of the serialization form in order to avoid rounding errors if a user
* asks for the inverse of the inverse (i.e. the original transform) after deserialization.
*/
- MathTransform inverse;
+ LinearTransform inverse;
/**
* Constructs a transform.
@@ -111,7 +110,7 @@ abstract class AbstractLinearTransform e
* Creates the inverse transform of this object.
*/
@Override
- public synchronized MathTransform inverse() throws NoninvertibleTransformException {
+ public synchronized LinearTransform inverse() throws NoninvertibleTransformException {
if (inverse == null) {
/*
* Should never be the identity transform at this point (except during tests) because
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CopyTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CopyTransform.java?rev=1718280&r1=1718279&r2=1718280&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CopyTransform.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CopyTransform.java [UTF-8] Mon Dec 7 10:02:22 2015
@@ -19,7 +19,6 @@ package org.apache.sis.referencing.opera
import java.util.Arrays;
import org.opengis.geometry.DirectPosition;
import org.opengis.referencing.operation.Matrix;
-import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.NoninvertibleTransformException;
import org.apache.sis.referencing.operation.matrix.MatrixSIS;
import org.apache.sis.referencing.operation.matrix.Matrices;
@@ -330,7 +329,7 @@ final class CopyTransform extends Abstra
* Creates the inverse transform of this object.
*/
@Override
- public synchronized MathTransform inverse() throws NoninvertibleTransformException {
+ public synchronized LinearTransform inverse() throws NoninvertibleTransformException {
if (inverse == null) {
/*
* Note: no need to perform the following check as this point because MathTransforms.linear(…)
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/IdentityTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/IdentityTransform.java?rev=1718280&r1=1718279&r2=1718280&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/IdentityTransform.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/IdentityTransform.java [UTF-8] Mon Dec 7 10:02:22 2015
@@ -18,7 +18,6 @@ package org.apache.sis.referencing.opera
import org.opengis.geometry.DirectPosition;
import org.opengis.referencing.operation.Matrix;
-import org.opengis.referencing.operation.MathTransform;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.geometry.GeneralDirectPosition;
import org.apache.sis.referencing.operation.matrix.Matrices;
@@ -228,7 +227,7 @@ final class IdentityTransform extends Ab
* Returns the inverse transform of this object, which is this transform itself
*/
@Override
- public MathTransform inverse() {
+ public LinearTransform inverse() {
return this;
}
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LinearTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LinearTransform.java?rev=1718280&r1=1718279&r2=1718280&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LinearTransform.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LinearTransform.java [UTF-8] Mon Dec 7 10:02:22 2015
@@ -19,6 +19,7 @@ package org.apache.sis.referencing.opera
import org.opengis.referencing.operation.Matrix;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
+import org.opengis.referencing.operation.NoninvertibleTransformException;
/**
@@ -117,4 +118,19 @@ public interface LinearTransform extends
* @since 0.7
*/
void deltaTransform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) throws TransformException;
+
+ /**
+ * Returns the inverse transform of this object, which shall also be linear.
+ * The target of the inverse transform is the source of the original.
+ * The source of the inverse transform is the target of the original.
+ *
+ * @return The inverse transform.
+ * @throws NoninvertibleTransformException if the transform can not be inverted.
+ *
+ * @see java.awt.geom.AffineTransform#createInverse()
+ *
+ * @since 0.7
+ */
+ @Override
+ LinearTransform inverse() throws NoninvertibleTransformException;
}
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LinearTransform1D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LinearTransform1D.java?rev=1718280&r1=1718279&r2=1718280&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LinearTransform1D.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LinearTransform1D.java [UTF-8] Mon Dec 7 10:02:22 2015
@@ -142,7 +142,7 @@ class LinearTransform1D extends Abstract
* Creates the inverse transform of this object.
*/
@Override
- public MathTransform1D inverse() throws NoninvertibleTransformException {
+ public LinearTransform1D inverse() throws NoninvertibleTransformException {
if (inverse == null) {
/*
* Note: we do not perform the following optimization, because MathTransforms.linear(…)
@@ -158,10 +158,10 @@ class LinearTransform1D extends Abstract
inverse.inverse = this;
this.inverse = inverse;
} else {
- inverse = super.inverse();
+ inverse = super.inverse(); // Throws NoninvertibleTransformException
}
}
- return inverse;
+ return (LinearTransform1D) inverse;
}
/**
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform2D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform2D.java?rev=1718280&r1=1718279&r2=1718280&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform2D.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform2D.java [UTF-8] Mon Dec 7 10:02:22 2015
@@ -19,9 +19,9 @@ package org.apache.sis.referencing.opera
import java.awt.Shape;
import java.awt.geom.Point2D;
import org.opengis.referencing.operation.Matrix;
-import org.opengis.referencing.operation.MathTransform2D;
import org.opengis.referencing.operation.NoninvertibleTransformException;
import org.opengis.referencing.operation.TransformException;
+import org.apache.sis.internal.referencing.j2d.LinearTransform2D;
/**
@@ -33,10 +33,10 @@ import org.opengis.referencing.operation
* @author Jan Jezek (UWB)
* @author Martin Desruisseaux (Geomatys)
* @since 0.5
- * @version 0.5
+ * @version 0.7
* @module
*/
-final class ProjectiveTransform2D extends ProjectiveTransform implements MathTransform2D {
+final class ProjectiveTransform2D extends ProjectiveTransform implements LinearTransform2D {
/**
* For cross-version compatibility.
*/
@@ -87,9 +87,10 @@ final class ProjectiveTransform2D extend
/**
* Creates the inverse transform of this object.
+ * The inverse shall be linear and two-dimensional.
*/
@Override
- public MathTransform2D inverse() throws NoninvertibleTransformException {
- return (MathTransform2D) super.inverse();
+ public LinearTransform2D inverse() throws NoninvertibleTransformException {
+ return (LinearTransform2D) super.inverse();
}
}
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NADCONTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NADCONTest.java?rev=1718280&r1=1718279&r2=1718280&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NADCONTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NADCONTest.java [UTF-8] Mon Dec 7 10:02:22 2015
@@ -26,7 +26,6 @@ import javax.measure.quantity.Angle;
import org.opengis.geometry.Envelope;
import org.opengis.util.FactoryException;
import org.opengis.referencing.operation.TransformException;
-import org.apache.sis.referencing.operation.transform.LinearTransform;
import org.apache.sis.referencing.operation.matrix.Matrix3;
import org.apache.sis.geometry.Envelope2D;
import org.apache.sis.geometry.Envelopes;
@@ -165,7 +164,7 @@ public final strictfp class NADCONTest e
new Matrix3(cellSize, 0, xmin,
0, cellSize, ymin,
0, 0, 1),
- ((LinearTransform) grid.getCoordinateToGrid().inverse()).getMatrix(), STRICT);
+ grid.getCoordinateToGrid().inverse().getMatrix(), STRICT);
/*
* Test the Meades Ranch station. If we were using the complete Conus files, we would obtain
* after conversion the grid indices listed on the left side. But since we are using a sub-set
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NTv2Test.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NTv2Test.java?rev=1718280&r1=1718279&r2=1718280&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NTv2Test.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NTv2Test.java [UTF-8] Mon Dec 7 10:02:22 2015
@@ -29,7 +29,6 @@ import org.opengis.geometry.Envelope;
import org.opengis.util.FactoryException;
import org.opengis.referencing.operation.TransformException;
import org.apache.sis.referencing.operation.matrix.Matrix3;
-import org.apache.sis.referencing.operation.transform.LinearTransform;
import org.apache.sis.geometry.Envelope2D;
import org.apache.sis.geometry.Envelopes;
import org.apache.sis.test.TestCase;
@@ -134,7 +133,7 @@ public final strictfp class NTv2Test ext
new Matrix3(-cellSize, 0, xmax,
0, +cellSize, ymin,
0, 0, 1),
- ((LinearTransform) grid.getCoordinateToGrid().inverse()).getMatrix(), STRICT);
+ grid.getCoordinateToGrid().inverse().getMatrix(), STRICT);
/*
* Test the same point than FranceGeocentricInterpolationTest, which is itself derived from the
* NTG_88 guidance note. If we were using the official NTF_R93.gsb file, we would obtain after