|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectAbstractEnvelope
ImmutableEnvelope
@Immutable public final class ImmutableEnvelope
Immutable representation of an envelope. This class is final in order to ensure that the immutability contract can not be broken (assuming not using Java Native Interface or reflections).
| referencing/geotk-referencing (download) | View source code for this class |
| Constructor Summary | |
|---|---|
ImmutableEnvelope(CoordinateReferenceSystem crs,
double xmin,
double xmax,
double ymin,
double ymax)
Builds a two-dimensional envelope with the specified bounds. |
|
ImmutableEnvelope(CoordinateReferenceSystem crs,
Envelope envelope)
Creates an immutable envelope with the ordinate values of the given envelope but a different CRS. |
|
ImmutableEnvelope(CoordinateReferenceSystem crs,
String wkt)
Constructs a new envelope initialized to the values parsed from the given string in Well Known Text (WKT) format. |
|
ImmutableEnvelope(Envelope envelope)
Creates an immutable envelope with the values of the given envelope. |
|
ImmutableEnvelope(GeographicBoundingBox box)
Constructs a new envelope with the same data than the specified geographic bounding box. |
|
| Method Summary | |
|---|---|
static ImmutableEnvelope |
castOrCopy(Envelope envelope)
Returns the given envelope as an ImmutableEnvelope instance. |
boolean |
equals(Object object)
Compares the specified object with this envelope for equality. |
CoordinateReferenceSystem |
getCoordinateReferenceSystem()
|
int |
getDimension()
|
double |
getLower(int dimension)
Returns the limit in the direction of decreasing ordinate values in the specified dimension. |
DirectPosition |
getLowerCorner()
A coordinate position consisting of all the lower ordinates. |
double |
getMaximum(int dimension)
Returns the maximal ordinate value for the specified dimension. |
double |
getMedian(int dimension)
Returns the median ordinate along the specified dimension. |
double |
getMinimum(int dimension)
Returns the minimal ordinate value for the specified dimension. |
double |
getSpan(int dimension)
Returns the envelope span (typically width or height) along the specified dimension. |
double |
getUpper(int dimension)
Returns the limit in the direction of increasing ordinate values in the specified dimension. |
DirectPosition |
getUpperCorner()
A coordinate position consisting of all the upper ordinates. |
int |
hashCode()
Returns a hash value for this envelope. |
boolean |
isEmpty()
Determines whether or not this envelope is empty. |
boolean |
isNull()
Returns false if at least one ordinate value is not NaN. |
| Methods inherited from class AbstractEnvelope |
|---|
contains, contains, equals, getMedian, getSpan, intersects, toPolygonString, toRectangle2D, toString |
| Methods inherited from class Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ImmutableEnvelope(Envelope envelope)
envelope - The envelope to copy.public ImmutableEnvelope(GeographicBoundingBox box)
box - The bounding box to copy.
public ImmutableEnvelope(CoordinateReferenceSystem crs,
Envelope envelope)
throws MismatchedDimensionException
The main purpose of this method is to assign a non-null CRS when the envelope to copy has a null CRS.
crs - The CRS to assign to this envelope, or null.envelope - The envelope from which to copy ordinate values.
MismatchedDimensionException - If the dimension of the given CRS is not equals
to the dimension of the given envelope.
public ImmutableEnvelope(CoordinateReferenceSystem crs,
double xmin,
double xmax,
double ymin,
double ymax)
throws MismatchedDimensionException
crs - The coordinate reference system, or null if none.xmin - The lower value for the first ordinate.xmax - The upper value for the first ordinate.ymin - The lower value for the second ordinate.ymax - The upper value for the second ordinate.
MismatchedDimensionException - If the dimension of the given CRS is not equals to 2.
public ImmutableEnvelope(CoordinateReferenceSystem crs,
String wkt)
throws NumberFormatException,
IllegalArgumentException,
MismatchedDimensionException
BOX
element like below:
However this constructor is lenient to other geometry types likeBOX(-180 -90, 180 90)
POLYGON.
See the javadoc of the GeneralEnvelope
constructor for more information.
crs - The coordinate reference system, or null if none.wkt - The BOX, POLYGON or other kind of element to parse.
NumberFormatException - If a number can not be parsed.
IllegalArgumentException - If the parenthesis are not balanced.
MismatchedDimensionException - If the dimension of the given CRS is not equals
to the dimension of the parsed envelope.| Method Detail |
|---|
public static ImmutableEnvelope castOrCopy(Envelope envelope)
ImmutableEnvelope instance. If the given envelope
is already an instance of ImmutableEnvelope, then it is returned unchanged.
Otherwise the coordinate values and the CRS of the given envelope are copied in a
new envelope.
envelope - The envelope to cast, or null.
ImmutableEnvelope instance.GeneralEnvelope.castOrCopy(Envelope)public int getDimension()
getDimension in interface Envelopepublic CoordinateReferenceSystem getCoordinateReferenceSystem()
getCoordinateReferenceSystem in interface Envelopepublic DirectPosition getLowerCorner()
Note:
The Web Coverage Service (WCS) 1.1 specification uses an extended
interpretation of the bounding box definition. In a WCS 1.1 data structure, the lower
corner defines the edges region in the directions of decreasing coordinate
values in the envelope CRS. This is usually the algebraic minimum coordinates, but not
always. For example, an envelope crossing the anti-meridian could have a lower corner
longitude greater than the upper corner longitude. Such extended interpretation applies
mostly to axes having WRAPAROUND range meaning.
getLowerCorner in interface EnvelopegetLowerCorner in class AbstractEnvelopepublic DirectPosition getUpperCorner()
Note:
The Web Coverage Service (WCS) 1.1 specification uses an extended
interpretation of the bounding box definition. In a WCS 1.1 data structure, the upper
corner defines the edges region in the directions of increasing coordinate
values in the envelope CRS. This is usually the algebraic maximum coordinates, but not
always. For example, an envelope crossing the anti-meridian could have an upper corner
longitude less than the lower corner longitude. Such extended interpretation applies
mostly to axes having WRAPAROUND range meaning.
getUpperCorner in interface EnvelopegetUpperCorner in class AbstractEnvelope
public double getLower(int dimension)
throws IndexOutOfBoundsException
getLower in class AbstractEnvelopedimension - The dimension for which to obtain the ordinate value.
IndexOutOfBoundsException - If the given index is negative or is equals or greater
than the envelope dimension.
public double getUpper(int dimension)
throws IndexOutOfBoundsException
getUpper in class AbstractEnvelopedimension - The dimension for which to obtain the ordinate value.
IndexOutOfBoundsException - If the given index is negative or is equals or greater
than the envelope dimension.
public double getMinimum(int dimension)
throws IndexOutOfBoundsException
AbstractEnvelope.getLower(int) value verbatim. In the case of envelope spanning the anti-meridian,
this method returns the axis minimum value.
getMinimum in interface EnvelopegetMinimum in class AbstractEnvelopedimension - The dimension for which to obtain the ordinate value.
IndexOutOfBoundsException - If the given index is negative or is equals or greater
than the envelope dimension.
public double getMaximum(int dimension)
throws IndexOutOfBoundsException
AbstractEnvelope.getUpper(int) value verbatim. In the case of envelope spanning the anti-meridian,
this method returns the axis maximum value.
getMaximum in interface EnvelopegetMaximum in class AbstractEnvelopedimension - The dimension for which to obtain the ordinate value.
IndexOutOfBoundsException - If the given index is negative or is equals or greater
than the envelope dimension.
public double getMedian(int dimension)
throws IndexOutOfBoundsException
median = (getUpper(dimension) + getLower(dimension)) / 2;
Spanning the anti-meridian of a Geographic CRS
If upper < lower and the
range meaning for the requested
dimension is wraparound, then the median calculated
above is actually in the middle of the space outside the envelope. In such cases,
this method shifts the median value by half of the periodicity (180° in the
longitude case) in order to switch from outer space to inner
space. If the axis range meaning is not WRAPAROUND, then this method returns
NaN.
getMedian in interface EnvelopegetMedian in class AbstractEnvelopedimension - The dimension for which to obtain the ordinate value.
Double.NaN.
IndexOutOfBoundsException - If the given index is negative or is equals or greater
than the envelope dimension.
public double getSpan(int dimension)
throws IndexOutOfBoundsException
span = getUpper(dimension) - getLower(dimension);
Spanning the anti-meridian of a Geographic CRS
If upper < lower and the
range meaning for the requested
dimension is wraparound, then the span calculated
above is negative. In such cases, this method adds the periodicity (typically 360° of
longitude) to the span. If the result is a positive number, it is returned. Otherwise
this method returns NaN.
getSpan in interface EnvelopegetSpan in class AbstractEnvelopedimension - The dimension for which to obtain the span.
Double.NaN.
IndexOutOfBoundsException - If the given index is negative or is equals or greater
than the envelope dimension.public boolean isEmpty()
isEmpty in class AbstractEnvelopetrue if this envelope is empty.DefaultGeographicBoundingBox.isEmpty(),
RectangularShape.isEmpty()public boolean isNull()
false if at least one ordinate value is not NaN. The
isNull() check is a little bit different than AbstractEnvelope.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:
isNull() == true, then AbstractEnvelope.isEmpty() == trueAbstractEnvelope.isEmpty() == false, then isNull() == false
isNull in class AbstractEnvelopetrue if this envelope has NaN values.GeneralEnvelope.setToNull()public int hashCode()
hashCode in class AbstractEnvelopepublic boolean equals(Object object)
equals in class AbstractEnvelopeobject - The object to compare with this envelope.
true if the given object is equal to this envelope.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||