| java.lang.Object org.geotools.geometry.AbstractEnvelope org.geotools.geometry.GeneralEnvelope
GeneralEnvelope | public class GeneralEnvelope extends AbstractEnvelope implements Cloneable,Serializable(Code) | | A minimum bounding box or rectangle. Regardless of dimension, an
Envelope can
be represented without ambiguity as two
(coordinate points). To encode an
Envelope , it is sufficient to encode these
two points.
This particular implementation of
Envelope is said "General" because it
uses coordinates of an arbitrary dimension.
Tip: The metadata package provides a
org.opengis.metadata.extent.GeographicBoundingBox , which can be used as
a kind of envelope with a coordinate reference system fixed to WGS 84 (EPSG:4326).
since: 2.0 version: $Id: GeneralEnvelope.java 26151 2007-07-04 18:54:48Z desruisseaux $ author: Martin Desruisseaux author: Simone Giannecchini See Also: Envelope2D See Also: org.geotools.geometry.jts.ReferencedEnvelope See Also: org.opengis.metadata.extent.GeographicBoundingBox |
Constructor Summary | |
public | GeneralEnvelope(int dimension) Constructs an empty envelope of the specified dimension. | public | GeneralEnvelope(double min, double max) Constructs one-dimensional envelope defined by a range of values. | public | GeneralEnvelope(double[] minDP, double[] maxDP) Constructs a envelope defined by two positions. | public | GeneralEnvelope(GeneralDirectPosition minDP, GeneralDirectPosition maxDP) Constructs a envelope defined by two positions. | public | GeneralEnvelope(CoordinateReferenceSystem crs) Constructs an empty envelope with the specified coordinate reference system. | public | GeneralEnvelope(Envelope envelope) Constructs a new envelope with the same data than the specified envelope. | public | GeneralEnvelope(GeographicBoundingBox box) Constructs a new envelope with the same data than the specified
geographic bounding box. | public | GeneralEnvelope(Rectangle2D rect) Constructs two-dimensional envelope defined by a
Rectangle2D . | public | GeneralEnvelope(GridRange gridRange, PixelInCell gridType, MathTransform gridToCRS, CoordinateReferenceSystem crs) Creates an envelope for a grid range transformed using the specified math transform. |
Method Summary | |
public void | add(DirectPosition position) Adds a point to this envelope. | public void | add(Envelope envelope) Adds an envelope object to this envelope. | public Object | clone() Returns a deep copy of this envelope. | public boolean | contains(DirectPosition position) Tests if a specified coordinate is inside the boundary of this envelope.
This method assumes that the specified point uses the same CRS than this envelope.
For performance reason, it will no be verified unless J2SE assertions are enabled.
Parameters: position - The point to text. | public boolean | contains(Envelope envelope, boolean edgesInclusive) Returns
true if this envelope completly encloses the specified envelope.
If one or more edges from the specified envelope coincide with an edge from this
envelope, then this method returns
true only if
edgesInclusive is
true .
This method assumes that the specified envelope uses the same CRS than this envelope.
For performance reason, it will no be verified unless J2SE assertions are enabled.
Parameters: envelope - The envelope to test for inclusion. Parameters: edgesInclusive - true if this envelope edges are inclusive. | public boolean | equals(Object object) Compares the specified object with this envelope for equality. | public boolean | equals(Envelope envelope, double eps) Compares to the specified envelope for equality up to the specified relative tolerance value.
The tolerance value
eps is relative to the
along each dimension. | public boolean | equals(Envelope envelope, double eps, boolean relativeToLength) Compares to the specified envelope for equality up to the specified tolerance value.
The tolerance value
eps can be either relative to the
along each dimension or can be an absolute value (as for example some
ground resolution of a
).
If
relativeToLength is set to
true , the actual tolerance value for a given
dimension i is
eps ×
length where
length is the
maximum of
and the specified envelope length
along dimension i.
If
relativeToLength is set to
false , the actual tolerance value for a
given dimension i is
eps .
Relative tolerance value (as opposed to absolute tolerance value) help to workaround the
fact that tolerance value are CRS dependent. | public DirectPosition | getCenter() A coordinate position consisting of all the
for each dimension for all points within the
Envelope . | final public double | getCenter(int dimension) Returns the center ordinate along the specified dimension. | public static CoordinateReferenceSystem | getCoordinateReferenceSystem(Envelope envelope) Returns the coordinate reference system from an arbitrary envelope, or
null if unknown. | final public CoordinateReferenceSystem | getCoordinateReferenceSystem() Returns the coordinate reference system in which the coordinates are given. | final public int | getDimension() Returns the number of dimensions. | final public double | getLength(int dimension) Returns the envelope length along the specified dimension. | public double | getLength(int dimension, Unit unit) Returns the envelope length along the specified dimension, in terms of the given units.
Parameters: unit - The unit for the return value. | public DirectPosition | getLowerCorner() A coordinate position consisting of all the
for each dimension for all points within the
Envelope . | final public double | getMaximum(int dimension) Returns the maximal ordinate along the specified dimension. | final public double | getMinimum(int dimension) Returns the minimal ordinate along the specified dimension. | public GeneralEnvelope | getReducedEnvelope(int lower, int upper) Returns a new envelope with the same values than this envelope minus the
specified range of dimensions.
Parameters: lower - The first dimension to omit, inclusive. Parameters: upper - The last dimension to omit, exclusive. | public GeneralEnvelope | getSubEnvelope(int lower, int upper) Returns a new envelope that encompass only some dimensions of this envelope.
This method copy this envelope's ordinates into a new envelope, beginning at
dimension lower and extending to dimension upper-1 .
Thus the dimension of the subenvelope is upper-lower .
Parameters: lower - The first dimension to copy, inclusive. Parameters: upper - The last dimension to copy, exclusive. | public DirectPosition | getUpperCorner() A coordinate position consisting of all the
for each dimension for all points within the
Envelope . | public int | hashCode() Returns a hash value for this envelope. | public void | intersect(Envelope envelope) Sets this envelope to the intersection if this envelope with the specified one. | public boolean | intersects(Envelope envelope, boolean edgesInclusive) Returns
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
true only if
edgesInclusive is
true .
This method assumes that the specified envelope uses the same CRS than this envelope.
For performance reason, it will no be verified unless J2SE assertions are enabled.
Parameters: envelope - The envelope to test for intersection. Parameters: edgesInclusive - true if this envelope edges are inclusive. | public boolean | isEmpty() Determines whether or not this envelope is empty. | public boolean | isInfinite() Returns
true if at least one ordinate has an
value. | public boolean | isNull() Returns
false if at least one ordinate value is not
. | public void | setCoordinateReferenceSystem(CoordinateReferenceSystem crs) Set the coordinate reference system in which the coordinate are given. | public void | setEnvelope(GeneralEnvelope envelope) Set this envelope to the same coordinate values than the specified envelope. | public void | setRange(int dimension, double minimum, double maximum) Set the envelope's range along the specified dimension. | public void | setToInfinite() Sets the lower corner to
and the upper corner to
. | public void | setToNull() Sets all ordinate values to
. | public Rectangle2D | toRectangle2D() Returns a
Rectangle2D with the same bounds as this
Envelope . |
GeneralEnvelope | public GeneralEnvelope(int dimension)(Code) | | Constructs an empty envelope of the specified dimension.
All ordinates are initialized to 0 and the coordinate reference
system is undefined.
|
GeneralEnvelope | public GeneralEnvelope(double min, double max)(Code) | | Constructs one-dimensional envelope defined by a range of values.
Parameters: min - The minimal value. Parameters: max - The maximal value. |
GeneralEnvelope | public GeneralEnvelope(double[] minDP, double[] maxDP) throws IllegalArgumentException(Code) | | Constructs a envelope defined by two positions.
Parameters: minDP - Minimum ordinate values. Parameters: maxDP - Maximum ordinate values. throws: MismatchedDimensionException - if the two positions don't have the same dimension. throws: IllegalArgumentException - if an ordinate value in the minimum point is notless than or equal to the corresponding ordinate value in the maximum point. |
GeneralEnvelope | public GeneralEnvelope(GeneralDirectPosition minDP, GeneralDirectPosition maxDP) throws IllegalArgumentException(Code) | | Constructs a envelope defined by two positions. The coordinate
reference system is inferred from the supplied direct position.
Parameters: minDP - Point containing minimum ordinate values. Parameters: maxDP - Point containing maximum ordinate values. throws: MismatchedDimensionException - if the two positions don't have the same dimension. throws: MismatchedReferenceSystemException - if the two positions don't use the same CRS. throws: IllegalArgumentException - if an ordinate value in the minimum point is notless than or equal to the corresponding ordinate value in the maximum point. |
GeneralEnvelope | public GeneralEnvelope(CoordinateReferenceSystem crs)(Code) | | Constructs an empty envelope with the specified coordinate reference system.
All ordinates are initialized to 0.
since: 2.2 |
GeneralEnvelope | public GeneralEnvelope(Envelope envelope)(Code) | | Constructs a new envelope with the same data than the specified envelope.
|
GeneralEnvelope | public GeneralEnvelope(GeographicBoundingBox box)(Code) | | Constructs a new envelope with the same data than the specified
geographic bounding box. The coordinate reference system is set
to
.
since: 2.4 |
GeneralEnvelope | public GeneralEnvelope(Rectangle2D rect)(Code) | | Constructs two-dimensional envelope defined by a
Rectangle2D .
The coordinate reference system is initially undefined.
|
GeneralEnvelope | public GeneralEnvelope(GridRange gridRange, PixelInCell gridType, MathTransform gridToCRS, CoordinateReferenceSystem crs) throws IllegalArgumentException(Code) | | Creates an envelope for a grid range transformed using the specified math transform.
Parameters: gridRange - The grid range. Parameters: gridType - Whatever grid range coordinates map to pixel center or pixel corner. Parameters: gridToCRS - The transform (usually affine) from grid range to the envelope CRS. Parameters: crs - The envelope CRS, or null if unknow. throws: MismatchedDimensionException - If one of the supplied object doesn't havea dimension compatible with the other objects. throws: IllegalArgumentException - if an argument is illegal for some other reason,including failure to use the provided math transform. since: 2.3 |
add | public void add(DirectPosition position) throws MismatchedDimensionException(Code) | | Adds a point to this envelope. The resulting envelope is the smallest envelope that
contains both the original envelope and the specified point. After adding a point,
a call to
GeneralEnvelope.contains with the added point as an argument will return
true ,
except if one of the point's ordinates was
Double.NaN (in which case the
corresponding ordinate have been ignored).
This method assumes that the specified point uses the same CRS than this envelope.
For performance reason, it will no be verified unless J2SE assertions are enabled.
Parameters: position - The point to add. throws: MismatchedDimensionException - if the specified point doesn't havethe expected dimension. |
add | public void add(Envelope envelope) throws MismatchedDimensionException(Code) | | Adds an envelope object to this envelope. The resulting envelope is the union of the
two
Envelope objects.
This method assumes that the specified envelope uses the same CRS than this envelope.
For performance reason, it will no be verified unless J2SE assertions are enabled.
Parameters: envelope - the Envelope to add to this envelope. throws: MismatchedDimensionException - if the specified envelope doesn'thave the expected dimension. |
clone | public Object clone()(Code) | | Returns a deep copy of this envelope.
|
contains | public boolean contains(DirectPosition position) throws MismatchedDimensionException(Code) | | Tests if a specified coordinate is inside the boundary of this envelope.
This method assumes that the specified point uses the same CRS than this envelope.
For performance reason, it will no be verified unless J2SE assertions are enabled.
Parameters: position - The point to text. true if the specified coordinates are inside the boundaryof this envelope; false otherwise. throws: MismatchedDimensionException - if the specified point doesn't havethe expected dimension. |
contains | public boolean contains(Envelope envelope, boolean edgesInclusive) throws MismatchedDimensionException(Code) | | Returns
true if this envelope completly encloses the specified envelope.
If one or more edges from the specified envelope coincide with an edge from this
envelope, then this method returns
true only if
edgesInclusive is
true .
This method assumes that the specified envelope uses the same CRS than this envelope.
For performance reason, it will no be verified unless J2SE assertions are enabled.
Parameters: envelope - The envelope to test for inclusion. Parameters: edgesInclusive - true if this envelope edges are inclusive. true if this envelope completly encloses the specified one. throws: MismatchedDimensionException - if the specified envelope doesn't havethe expected dimension. See Also: GeneralEnvelope.intersects(Envelope,boolean) See Also: GeneralEnvelope.equals(Envelope,double) since: 2.2 |
equals | public boolean equals(Object object)(Code) | | Compares the specified object with this envelope for equality.
|
equals | public boolean equals(Envelope envelope, double eps)(Code) | | Compares to the specified envelope for equality up to the specified relative tolerance value.
The tolerance value
eps is relative to the
along each dimension. More specifically, the actual tolerance value for a given dimension
i is
eps ×
length where
length is the maximum of
and the specified envelope length along
dimension i.
Relative tolerance value (as opposed to absolute tolerance value) help to workaround the
fact that tolerance value are CRS dependent. For example the tolerance value need to be
smaller for geographic CRS than for UTM projections, because the former typically has a
range of -180 to 180° while the later can have a range of thousands of meters.
This method assumes that the specified envelope uses the same CRS than this envelope.
For performance reason, it will no be verified unless J2SE assertions are enabled.
See Also: GeneralEnvelope.contains(Envelope,boolean) See Also: GeneralEnvelope.intersects(Envelope,boolean) since: 2.3GeneralEnvelope.equals(Envelope,double,boolean) |
equals | public boolean equals(Envelope envelope, double eps, boolean relativeToLength)(Code) | | Compares to the specified envelope for equality up to the specified tolerance value.
The tolerance value
eps can be either relative to the
along each dimension or can be an absolute value (as for example some
ground resolution of a
).
If
relativeToLength is set to
true , the actual tolerance value for a given
dimension i is
eps ×
length where
length is the
maximum of
and the specified envelope length
along dimension i.
If
relativeToLength is set to
false , the actual tolerance value for a
given dimension i is
eps .
Relative tolerance value (as opposed to absolute tolerance value) help to workaround the
fact that tolerance value are CRS dependent. For example the tolerance value need to be
smaller for geographic CRS than for UTM projections, because the former typically has a
range of -180 to 180° while the later can have a range of thousands of meters.
This method assumes that the specified envelope uses the same CRS than this envelope.
For performance reason, it will no be verified unless J2SE assertions are enabled.
Parameters: envelope - The envelope to compare with. Parameters: eps - The tolerance value to use for numerical comparaisons. Parameters: relativeToLength - true if the tolerance value should be relative toaxis length, or false if it is an absolute value. See Also: GeneralEnvelope.contains(Envelope,boolean) See Also: GeneralEnvelope.intersects(Envelope,boolean) since: 2.4 |
getCenter | public DirectPosition getCenter()(Code) | | A coordinate position consisting of all the
for each dimension for all points within the
Envelope .
since: 2.3 |
getCenter | final public double getCenter(int dimension)(Code) | | Returns the center ordinate along the specified dimension.
|
getCoordinateReferenceSystem | public static CoordinateReferenceSystem getCoordinateReferenceSystem(Envelope envelope)(Code) | | Returns the coordinate reference system from an arbitrary envelope, or
null if unknown. This method performs some sanity checking for ensuring that the envelope
CRS is consistent.
Envelope.getCoordinateReferenceSystem since: 2.3 |
getCoordinateReferenceSystem | final public CoordinateReferenceSystem getCoordinateReferenceSystem()(Code) | | Returns the coordinate reference system in which the coordinates are given.
The coordinate reference system, or null . |
getDimension | final public int getDimension()(Code) | | Returns the number of dimensions.
|
getLength | final public double getLength(int dimension)(Code) | | Returns the envelope length along the specified dimension.
This length is equals to the maximum ordinate minus the
minimal ordinate.
|
getLength | public double getLength(int dimension, Unit unit) throws ConversionException(Code) | | Returns the envelope length along the specified dimension, in terms of the given units.
Parameters: unit - The unit for the return value. The length in terms of the given unit. throws: ConversionException - if the length can't be converted to the specified units. since: 2.2 |
getLowerCorner | public DirectPosition getLowerCorner()(Code) | | A coordinate position consisting of all the
for each dimension for all points within the
Envelope .
The lower corner. |
getMaximum | final public double getMaximum(int dimension)(Code) | | Returns the maximal ordinate along the specified dimension.
|
getMinimum | final public double getMinimum(int dimension)(Code) | | Returns the minimal ordinate along the specified dimension.
|
getReducedEnvelope | public GeneralEnvelope getReducedEnvelope(int lower, int upper) throws IndexOutOfBoundsException(Code) | | Returns a new envelope with the same values than this envelope minus the
specified range of dimensions.
Parameters: lower - The first dimension to omit, inclusive. Parameters: upper - The last dimension to omit, exclusive. The subenvelope. throws: IndexOutOfBoundsException - if an index is out of bounds. |
getSubEnvelope | public GeneralEnvelope getSubEnvelope(int lower, int upper) throws IndexOutOfBoundsException(Code) | | Returns a new envelope that encompass only some dimensions of this envelope.
This method copy this envelope's ordinates into a new envelope, beginning at
dimension lower and extending to dimension upper-1 .
Thus the dimension of the subenvelope is upper-lower .
Parameters: lower - The first dimension to copy, inclusive. Parameters: upper - The last dimension to copy, exclusive. The subenvelope. throws: IndexOutOfBoundsException - if an index is out of bounds. |
getUpperCorner | public DirectPosition getUpperCorner()(Code) | | A coordinate position consisting of all the
for each dimension for all points within the
Envelope .
The upper corner. |
hashCode | public int hashCode()(Code) | | Returns a hash value for this envelope.
|
intersect | public void intersect(Envelope envelope) throws MismatchedDimensionException(Code) | | Sets this envelope to the intersection if this envelope with the specified one.
This method assumes that the specified envelope uses the same CRS than this envelope.
For performance reason, it will no be verified unless J2SE assertions are enabled.
Parameters: envelope - the Envelope to intersect to this envelope. throws: MismatchedDimensionException - if the specified envelope doesn'thave the expected dimension. |
intersects | public boolean intersects(Envelope envelope, boolean edgesInclusive) throws MismatchedDimensionException(Code) | | Returns
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
true only if
edgesInclusive is
true .
This method assumes that the specified envelope uses the same CRS than this envelope.
For performance reason, it will no be verified unless J2SE assertions are enabled.
Parameters: envelope - The envelope to test for intersection. Parameters: edgesInclusive - true if this envelope edges are inclusive. true if this envelope intersects the specified one. throws: MismatchedDimensionException - if the specified envelope doesn't havethe expected dimension. See Also: GeneralEnvelope.contains(Envelope,boolean) See Also: GeneralEnvelope.equals(Envelope,double) since: 2.2 |
isEmpty | public boolean isEmpty()(Code) | | Determines whether or not this envelope is empty. An envelope is non-empty only if it has
at least one
, and the
is greater than 0 along all dimensions. Note that a non-empty envelope is always
non-
, but the converse is not always true.
|
isInfinite | public boolean isInfinite()(Code) | | Returns
true if at least one ordinate has an
value.
since: 2.2 |
isNull | public boolean isNull()(Code) | | Returns
false if at least one ordinate value is not
. The
isNull() check is a little bit different than
GeneralEnvelope.isEmpty() since it returns
false for a partially initialized envelope, while
isEmpty() returns
false only after all dimensions have been initialized. More specifically, the
following rules apply:
- If
isNull() == true , then
== true
- If
== false , then isNull() == false
- The converse of the above-cited rules are not always true.
since: 2.2 |
setCoordinateReferenceSystem | public void setCoordinateReferenceSystem(CoordinateReferenceSystem crs) throws MismatchedDimensionException(Code) | | Set the coordinate reference system in which the coordinate are given.
Note: this method do not reproject the envelope.
Parameters: crs - The new coordinate reference system, or null . throws: MismatchedDimensionException - if the specified CRS doesn't have the expectednumber of dimensions. |
setEnvelope | public void setEnvelope(GeneralEnvelope envelope) throws MismatchedDimensionException(Code) | | Set this envelope to the same coordinate values than the specified envelope.
Parameters: envelope - The new envelope to copy coordinates from. throws: MismatchedDimensionException - if the specified envelope doesn't have the expectednumber of dimensions. since: 2.2 |
setRange | public void setRange(int dimension, double minimum, double maximum)(Code) | | Set the envelope's range along the specified dimension.
Parameters: dimension - The dimension to set. Parameters: minimum - The minimum value along the specified dimension. Parameters: maximum - The maximum value along the specified dimension. |
setToInfinite | public void setToInfinite()(Code) | | Sets the lower corner to
and the upper corner to
.
The
(if any)
stay unchanged.
since: 2.2 |
setToNull | public void setToNull()(Code) | | Sets all ordinate values to
. The
(if any) stay
unchanged.
since: 2.2 |
|
|