Author: desruisseaux
Date: Tue Apr 1 03:15:11 2014
New Revision: 1583519
URL: http://svn.apache.org/r1583519
Log:
Added AbstratEnvelope.contains and intersects method expecting only an Envelope
argument, without boolean.
Those convenience methods cover the vast majority of cases, and are added in
anticipation to SIS-172.
The intend is to reduce the risk that a fix for SIS-172 would be an API break.
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java?rev=1583519&r1=1583518&r2=1583519&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java
[UTF-8] Tue Apr 1 03:15:11 2014
@@ -86,8 +86,8 @@ import java.util.Objects;
* <li>{@link #getSpan(int)}</li>
* <li>{@link #toSimpleEnvelopes()}</li>
* <li>{@link #contains(DirectPosition)}</li>
- * <li>{@link #contains(Envelope, boolean)}</li>
- * <li>{@link #intersects(Envelope, boolean)}</li>
+ * <li>{@link #contains(Envelope)}</li>
+ * <li>{@link #intersects(Envelope)}</li>
* </ul>
* </td></tr></table>
*
@@ -110,7 +110,7 @@ import java.util.Objects;
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.3 (derived from geotk-2.4)
- * @version 0.3
+ * @version 0.4
* @module
*/
public abstract class AbstractEnvelope implements Envelope, Emptiable {
@@ -728,9 +728,7 @@ public abstract class AbstractEnvelope i
/**
* Returns {@code true} if this envelope completely encloses the specified
envelope.
- * If one or more edges from the specified envelope coincide with an edge
from this
- * envelope, then this method returns {@code true} only if {@code
edgesInclusive}
- * is {@code true}.
+ * All edges of this envelope are considered inclusive.
*
* {@section Pre-conditions}
* This method assumes that the specified envelope uses the same CRS than
this envelope.
@@ -740,17 +738,38 @@ public abstract class AbstractEnvelope i
* For every cases illustrated below, the yellow box is considered
completely enclosed
* in the blue envelope:
*
- * <center><img src="doc-files/Contains.png"></center>
+ * <img src="doc-files/Contains.png">
+ *
+ * @param envelope The envelope to test for inclusion.
+ * @return {@code true} if this envelope completely encloses the specified
one.
+ * @throws MismatchedDimensionException if the specified envelope doesn't
have the expected dimension.
+ * @throws AssertionError If assertions are enabled and the envelopes have
mismatched CRS.
+ *
+ * @see #intersects(Envelope)
+ * @see #equals(Envelope, double, boolean)
+ *
+ * @since 0.4
+ */
+ public final boolean contains(final Envelope envelope) throws
MismatchedDimensionException {
+ return contains(envelope, true);
+ }
+
+ /**
+ * Returns {@code true} if this envelope completely encloses the specified
envelope.
+ * If one or more edges from the specified envelope coincide with an edge
from this
+ * envelope, then this method returns {@code true} only if {@code
edgesInclusive}
+ * is {@code true}.
+ *
+ * <p>This method is subject to the same pre-conditions than {@link
#contains(Envelope)},
+ * and handles envelopes spanning the anti-meridian in the same way.</p>
*
* @param envelope The envelope to test for inclusion.
* @param edgesInclusive {@code true} if this envelope edges are
inclusive.
* @return {@code true} if this envelope completely encloses the specified
one.
- * @throws MismatchedDimensionException if the specified envelope doesn't
have
- * the expected dimension.
+ * @throws MismatchedDimensionException if the specified envelope doesn't
have the expected dimension.
* @throws AssertionError If assertions are enabled and the envelopes have
mismatched CRS.
*
* @see #intersects(Envelope, boolean)
- * @see #equals(Envelope, double, boolean)
*/
public boolean contains(final Envelope envelope, final boolean
edgesInclusive) throws MismatchedDimensionException {
ensureNonNull("envelope", envelope);
@@ -824,8 +843,7 @@ public abstract class AbstractEnvelope i
/**
* Returns {@code true} if this envelope intersects the specified envelope.
- * If one or more edges from the specified envelope coincide with an edge
from this envelope,
- * then this method returns {@code true} only if {@code edgesInclusive} is
{@code true}.
+ * All edges of this envelope are considered inclusive.
*
* {@section Pre-conditions}
* This method assumes that the specified envelope uses the same CRS than
this envelope.
@@ -835,6 +853,28 @@ public abstract class AbstractEnvelope i
* This method can handle envelopes spanning the anti-meridian.
*
* @param envelope The envelope to test for intersection.
+ * @return {@code true} if this envelope intersects the specified one.
+ * @throws MismatchedDimensionException if the specified envelope doesn't
have the expected dimension.
+ * @throws AssertionError If assertions are enabled and the envelopes have
mismatched CRS.
+ *
+ * @see #contains(Envelope, boolean)
+ * @see #equals(Envelope, double, boolean)
+ *
+ * @since 0.4
+ */
+ public boolean intersects(final Envelope envelope) throws
MismatchedDimensionException {
+ return intersects(envelope, true);
+ }
+
+ /**
+ * Returns {@code true} if this envelope intersects the specified envelope.
+ * If one or more edges from the specified envelope coincide with an edge
from this envelope,
+ * then this method returns {@code true} only if {@code edgesInclusive} is
{@code true}.
+ *
+ * <p>This method is subject to the same pre-conditions than {@link
#intersects(Envelope)},
+ * and handles envelopes spanning the anti-meridian in the same way.</p>
+ *
+ * @param envelope The envelope to test for intersection.
* @param edgesInclusive {@code true} if this envelope edges are
inclusive.
* @return {@code true} if this envelope intersects the specified one.
* @throws MismatchedDimensionException if the specified envelope doesn't
have the expected dimension.
@@ -950,8 +990,8 @@ public abstract class AbstractEnvelope i
* axis length, or {@code false} if it is an absolute value.
* @return {@code true} if the given object is equal to this envelope up
to the given tolerance value.
*
- * @see #contains(Envelope, boolean)
- * @see #intersects(Envelope, boolean)
+ * @see #contains(Envelope)
+ * @see #intersects(Envelope)
*/
public boolean equals(final Envelope other, final double eps, final
boolean epsIsRelative) {
ensureNonNull("other", other);
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java?rev=1583519&r1=1583518&r2=1583519&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java
[UTF-8] Tue Apr 1 03:15:11 2014
@@ -674,7 +674,7 @@ public class Envelope2D extends Rectangl
*
* {@section Spanning the anti-meridian of a Geographic CRS}
* This method supports anti-meridian spanning in the same way than
- * {@link AbstractEnvelope#contains(Envelope, boolean)}.
+ * {@link AbstractEnvelope#contains(Envelope)}.
*
* @param rect The rectangle to test for inclusion.
* @return {@code true} if this envelope completely encloses the specified
rectangle.
@@ -696,7 +696,7 @@ public class Envelope2D extends Rectangl
*
* {@section Spanning the anti-meridian of a Geographic CRS}
* This method supports anti-meridian spanning in the same way than
- * {@link AbstractEnvelope#contains(Envelope, boolean)}.
+ * {@link AbstractEnvelope#contains(Envelope)}.
*
* @param rx The <var>x</var> ordinate of the lower corner of the
rectangle to test for inclusion.
* @param ry The <var>y</var> ordinate of the lower corner of the
rectangle to test for inclusion.
@@ -743,7 +743,7 @@ public class Envelope2D extends Rectangl
*
* {@section Spanning the anti-meridian of a Geographic CRS}
* This method supports anti-meridian spanning in the same way than
- * {@link AbstractEnvelope#intersects(Envelope, boolean)}.
+ * {@link AbstractEnvelope#intersects(Envelope)}.
*
* @param rect The rectangle to test for intersection.
* @return {@code true} if this envelope intersects the specified
rectangle.
@@ -765,7 +765,7 @@ public class Envelope2D extends Rectangl
*
* {@section Spanning the anti-meridian of a Geographic CRS}
* This method supports anti-meridian spanning in the same way than
- * {@link AbstractEnvelope#intersects(Envelope, boolean)}.
+ * {@link AbstractEnvelope#intersects(Envelope)}.
*
* @param rx The <var>x</var> ordinate of the lower corner of the
rectangle to test for intersection.
* @param ry The <var>y</var> ordinate of the lower corner of the
rectangle to test for intersection.
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java?rev=1583519&r1=1583518&r2=1583519&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java
[UTF-8] Tue Apr 1 03:15:11 2014
@@ -83,8 +83,8 @@ import static org.apache.sis.math.MathFu
* <li>{@link #isEmpty()}</li>
* <li>{@link #toSimpleEnvelopes() toSimpleEnvelopes()}</li>
* <li>{@link #contains(DirectPosition) contains(DirectPosition)}</li>
- * <li>{@link #contains(Envelope, boolean) contains(Envelope, boolean)}</li>
- * <li>{@link #intersects(Envelope, boolean) intersects(Envelope,
boolean)}</li>
+ * <li>{@link #contains(Envelope) contains(Envelope)}</li>
+ * <li>{@link #intersects(Envelope) intersects(Envelope)}</li>
* <li>{@link #intersect(Envelope)}</li>
* <li>{@link #add(Envelope)}</li>
* <li>{@link #add(DirectPosition)}</li>
@@ -665,7 +665,7 @@ public class GeneralEnvelope extends Arr
ordinates[iUpper] = Double.POSITIVE_INFINITY;
}
}
- assert contains(envelope, true) || isEmpty() || hasNaN(envelope) :
this;
+ assert contains(envelope) || isEmpty() || hasNaN(envelope) : this;
}
/**
@@ -796,7 +796,7 @@ public class GeneralEnvelope extends Arr
if (max1 < max0) ordinates[iUpper] = max1;
}
// Tests only if the interection result is non-empty.
- assert isEmpty() ||
AbstractEnvelope.castOrCopy(envelope).contains(this, true) : this;
+ assert isEmpty() ||
AbstractEnvelope.castOrCopy(envelope).contains(this) : this;
}
/**