Author: desruisseaux
Date: Sat Jun 28 10:26:26 2014
New Revision: 1606312
URL: http://svn.apache.org/r1606312
Log:
Inline the matrix comparison. This is safer since it make more obvious where
the infinite recersivity may happen
(in the call to Matrices.equals(this, ...)).
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.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/LinearTransform1D.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java?rev=1606312&r1=1606311&r2=1606312&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
[UTF-8] Sat Jun 28 10:26:26 2014
@@ -33,7 +33,6 @@ import org.opengis.referencing.operation
import org.opengis.referencing.operation.SingleOperation;
import org.apache.sis.geometry.GeneralDirectPosition;
import org.apache.sis.parameter.Parameterized;
-import org.apache.sis.referencing.operation.matrix.Matrices;
import org.apache.sis.referencing.operation.matrix.MatrixSIS;
import org.apache.sis.io.wkt.Formatter;
import org.apache.sis.io.wkt.FormattableObject;
@@ -874,48 +873,6 @@ public abstract class AbstractMathTransf
}
/**
- * Helper method for implementation of {@link #equals(Object,
ComparisonMode)} methods in
- * {@link LinearTransform} implementations. Those implementations shall
replace completely the
- * {@link #equals(Object, ComparisonMode)} default implementation,
<strong>except</strong> for
- * {@link ComparisonMode#STRICT} which should continue to rely on the
default implementation.
- * The pattern is:
- *
- * {@preformat java
- * public boolean equals(Object object, ComparisonMode mode) {
- * if (object == this) { // Slight optimization
- * return true;
- * }
- * if (mode != ComparisonMode.STRICT) {
- * return equals(this, object, mode);
- * }
- * if (super.equals(object, mode)) {
- * // Compare the internal fields here.
- * }
- * return false;
- * }
- * }
- *
- * Note that this pattern considers {@link ComparisonMode#BY_CONTRACT} as
synonymous to
- * {@code IGNORE_METADATA} rather than {@code STRICT}. This is valid if we
consider that
- * the behavior of the math transform is completely specified by its
matrix.
- *
- * @param t1 The first transform to compare.
- * @param t2 The second transform to compare, or {@code null} if none.
- * @param mode The strictness level of the comparison.
- * @return {@code true} if both transforms are equal.
- */
- static boolean equals(final LinearTransform t1, final Object t2, final
ComparisonMode mode) {
- if (t2 instanceof LinearTransform) {
- /*
- * Note: do not delegate to ((LenientComparable) m1).equals(m2,
mode)
- * since it may cause a never-ending loop with ProjectiveTransform.
- */
- return Matrices.equals(t1.getMatrix(), ((LinearTransform)
t2).getMatrix(), mode);
- }
- return false;
- }
-
- /**
* Formats the inner part of a <cite>Well Known Text</cite> version 1 (WKT
1) element.
* The default implementation formats all parameter values returned by
{@link #getParameterValues()}.
* The parameter group name is used as the math transform name.
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=1606312&r1=1606311&r2=1606312&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] Sat Jun 28 10:26:26 2014
@@ -426,9 +426,10 @@ final class CopyTransform extends Abstra
return true;
}
if (mode != ComparisonMode.STRICT) {
- return equals(this, object, mode);
- }
- if (super.equals(object, mode)) {
+ if (object instanceof LinearTransform) {
+ return Matrices.equals(getMatrix(), ((LinearTransform)
object).getMatrix(), mode);
+ }
+ } else if (super.equals(object, mode)) {
final CopyTransform that = (CopyTransform) object;
return srcDim == that.srcDim && Arrays.equals(indices,
that.indices);
}
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=1606312&r1=1606311&r2=1606312&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] Sat Jun 28 10:26:26 2014
@@ -259,11 +259,11 @@ final class IdentityTransform extends Ab
return true;
}
if (mode != ComparisonMode.STRICT) {
- return equals(this, object, mode);
- }
- if (super.equals(object, mode)) {
- final IdentityTransform that = (IdentityTransform) object;
- return this.dimension == that.dimension;
+ if (object instanceof LinearTransform) {
+ return Matrices.equals(getMatrix(), ((LinearTransform)
object).getMatrix(), mode);
+ }
+ } else if (super.equals(object, mode)) {
+ return ((IdentityTransform) object).dimension == dimension;
}
return false;
}
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=1606312&r1=1606311&r2=1606312&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] Sat Jun 28 10:26:26 2014
@@ -24,6 +24,7 @@ import org.opengis.referencing.operation
import org.opengis.referencing.operation.MathTransform1D;
import org.opengis.referencing.operation.TransformException;
import org.opengis.referencing.operation.NoninvertibleTransformException;
+import org.apache.sis.referencing.operation.matrix.Matrices;
import org.apache.sis.referencing.operation.matrix.Matrix1;
import org.apache.sis.referencing.operation.matrix.Matrix2;
import org.apache.sis.referencing.operation.provider.Affine;
@@ -310,9 +311,10 @@ class LinearTransform1D extends Abstract
return true;
}
if (mode != ComparisonMode.STRICT) {
- return equals(this, object, mode);
- }
- if (super.equals(object, mode)) {
+ if (object instanceof LinearTransform) {
+ return Matrices.equals(getMatrix(), ((LinearTransform)
object).getMatrix(), mode);
+ }
+ } else if (super.equals(object, mode)) {
final LinearTransform1D that = (LinearTransform1D) object;
return doubleToRawLongBits(this.scale) ==
doubleToRawLongBits(that.scale) &&
doubleToRawLongBits(this.offset) ==
doubleToRawLongBits(that.offset);
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java?rev=1606312&r1=1606311&r2=1606312&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java
[UTF-8] Sat Jun 28 10:26:26 2014
@@ -516,9 +516,10 @@ class ProjectiveTransform extends Abstra
return true;
}
if (mode != ComparisonMode.STRICT) {
- return equals(this, object, mode);
- }
- if (super.equals(object, mode)) {
+ if (object instanceof LinearTransform) {
+ return Matrices.equals(this, ((LinearTransform)
object).getMatrix(), mode);
+ }
+ } else if (super.equals(object, mode)) {
final ProjectiveTransform that = (ProjectiveTransform) object;
return this.numRow == that.numRow &&
this.numCol == that.numCol &&