Object
SimpleEnvelope
- All Implemented Interfaces:
Envelope
An unmodifiable
Envelope
implementation defined by two corners.
This implementation can store an optional reference to an existing
Coordinate Reference System.
This simple implementation does not support envelopes crossing the anti-meridian. Consequently, lower coordinate values shall not be greater than corresponding upper coordinate values.
- Since:
- 3.1
-
Constructor Summary
ConstructorDescriptionSimpleEnvelope
(DirectPosition lowerCorner, DirectPosition upperCorner) Constructs an envelope defined by two direct positions.SimpleEnvelope
(Envelope envelope) Constructs a new envelope with the same data than the specified envelope. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares this envelope with the specified object for equality.Returns the envelope coordinate reference system, ornull
if unknown.final int
Returns the length of coordinate sequence (the number of entries) in this envelope.The limits in the direction of decreasing coordinate values for each dimension.double
getMaximum
(int dimension) Returns the maximal coordinate value for the specified dimension.double
getMedian
(int dimension) Returns the median coordinate along the specified dimension.double
getMinimum
(int dimension) Returns the minimal coordinate value for the specified dimension.double
getSpan
(int dimension) Returns the envelope span (typically width or height) along the specified dimension.The limits in the direction of increasing coordinate values for each dimension.int
hashCode()
Returns an arbitrary hash code value for this envelope.toString()
Formats this envelope in the Well-Known Text (WKT) format.
-
Constructor Details
-
SimpleEnvelope
public SimpleEnvelope(DirectPosition lowerCorner, DirectPosition upperCorner) throws MismatchedDimensionException Constructs an envelope defined by two direct positions. The CRS of the envelope will be the CRS of the given direct positions, which shall be the equal.- Parameters:
lowerCorner
- the limits in the direction of decreasing coordinate values for each dimension.upperCorner
- the limits in the direction of increasing coordinate values for each dimension.- Throws:
MismatchedDimensionException
- if the two positions do not have the same dimension.IllegalArgumentException
- if an coordinate value in the lower corner is greater than the corresponding coordinate value in the upper corner.
-
SimpleEnvelope
Constructs a new envelope with the same data than the specified envelope. This is a copy constructor.- Parameters:
envelope
- the envelope to copy.- Throws:
IllegalArgumentException
- if an coordinate value in the lower corner is greater than the corresponding coordinate value in the upper corner.
-
-
Method Details
-
getDimension
public final int getDimension()Returns the length of coordinate sequence (the number of entries) in this envelope.- Specified by:
getDimension
in interfaceEnvelope
- Returns:
- the dimensionality of this envelope.
-
getCoordinateReferenceSystem
Returns the envelope coordinate reference system, ornull
if unknown.- Specified by:
getCoordinateReferenceSystem
in interfaceEnvelope
- Returns:
- the envelope CRS, or
null
if unknown.
-
getLowerCorner
The limits in the direction of decreasing coordinate values for each dimension. This is typically a coordinate position consisting of all the minimal coordinates for each dimension for all points within theEnvelope
.This method returns a copy of the lower corner. Changes in the returned position will not be reflected in this envelope.
- Specified by:
getLowerCorner
in interfaceEnvelope
- Returns:
- the lower corner, typically (but not necessarily) containing minimal coordinate values.
-
getUpperCorner
The limits in the direction of increasing coordinate values for each dimension. This is typically a coordinate position consisting of all the maximal coordinates for each dimension for all points within theEnvelope
.This method returns a copy of the upper corner. Changes in the returned position will not be reflected in this envelope.
- Specified by:
getUpperCorner
in interfaceEnvelope
- Returns:
- the upper corner, typically (but not necessarily) containing maximal coordinate values.
-
getMinimum
Returns the minimal coordinate value for the specified dimension. Since this simple class does not support envelopes crossing the anti-meridian, this method is equivalent to the following code:return getLowerCorner().getOrdinate(dimension);
- Specified by:
getMinimum
in interfaceEnvelope
- Parameters:
dimension
- the dimension for which to obtain the coordinate value.- Returns:
- the minimal coordinate at the given dimension.
- Throws:
IndexOutOfBoundsException
- if the given index is negative or is equal or greater than the envelope dimension.- See Also:
-
getMaximum
Returns the maximal coordinate value for the specified dimension. Since this simple class does not support envelopes crossing the anti-meridian, this method is equivalent to the following code:return getUpperCorner().getOrdinate(dimension);
- Specified by:
getMaximum
in interfaceEnvelope
- Parameters:
dimension
- the dimension for which to obtain the coordinate value.- Returns:
- the maximal coordinate at the given dimension.
- Throws:
IndexOutOfBoundsException
- if the given index is negative or is equal or greater than the envelope dimension.- See Also:
-
getMedian
Returns the median coordinate along the specified dimension. Since this simple class does not support envelopes crossing the anti-meridian, this method is equivalent to the following code:return 0.5*(getMinimum(dimension) + getMaximum(dimension));
- Specified by:
getMedian
in interfaceEnvelope
- Parameters:
dimension
- the dimension for which to obtain the coordinate value.- Returns:
- the median coordinate at the given dimension.
- Throws:
IndexOutOfBoundsException
- if the given index is negative or is equal or greater than the envelope dimension.- See Also:
-
getSpan
Returns the envelope span (typically width or height) along the specified dimension. Since this simple class does not support envelopes crossing the anti-meridian, this method is equivalent to the following code:return getMaximum(dimension) - getMinimum(dimension);
- Specified by:
getSpan
in interfaceEnvelope
- Parameters:
dimension
- the dimension for which to obtain the span.- Returns:
- the span (typically width or height) at the given dimension.
- Throws:
IndexOutOfBoundsException
- if the given index is negative or is equal or greater than the envelope dimension.- See Also:
-
equals
Compares this envelope with the specified object for equality. Since theequals(Object)
andhashCode()
methods are not documented in theEnvelope
interface, this method returnsfalse
if the given object is not an instance of the sameSimpleEnvelope
class. We do that in order to preserve consistency withhashCode()
. -
hashCode
public int hashCode()Returns an arbitrary hash code value for this envelope. -
toString
Formats this envelope in the Well-Known Text (WKT) format. The output is of the form "BOX
nD(
lower corner,
upper corner)
" where n is the number of dimensions.
-