|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.geotools.coverage.grid.GeneralGridEnvelope
public class GeneralGridEnvelope
Defines a range of grid coverage coordinates.
CAUTION:
ISO 19123 defines high coordinates as inclusive.
We follow this specification for all getters methods, but keep in mind that this is the
opposite of Java2D usage where Rectangle
maximal values are exclusive. When the
context is ambiguous, an explicit isHighIncluded
argument is required.
GridEnvelope2D
,
Serialized FormConstructor Summary | |
---|---|
GeneralGridEnvelope(org.opengis.geometry.Envelope envelope,
org.opengis.referencing.datum.PixelInCell anchor)
Casts the specified envelope into a grid envelope. |
|
GeneralGridEnvelope(org.opengis.geometry.Envelope envelope,
org.opengis.referencing.datum.PixelInCell anchor,
boolean isHighIncluded)
Casts the specified envelope into a grid envelope. |
|
GeneralGridEnvelope(org.opengis.coverage.grid.GridEnvelope envelope)
Creates a new grid envelope as a copy of the given one. |
|
GeneralGridEnvelope(int[] low,
int[] high)
Constructs a new grid envelope. |
|
GeneralGridEnvelope(int[] low,
int[] high,
boolean isHighIncluded)
Constructs a new grid envelope. |
|
GeneralGridEnvelope(java.awt.image.Raster raster,
int dimension)
Constructs multi-dimensional grid envelope defined by a Raster . |
|
GeneralGridEnvelope(java.awt.Rectangle rect)
Constructs a 2D grid envelope defined by a Rectangle . |
|
GeneralGridEnvelope(java.awt.Rectangle rect,
int dimension)
Constructs a multi-dimensional grid envelope defined by a Rectangle . |
|
GeneralGridEnvelope(java.awt.image.RenderedImage image,
int dimension)
Constructs multi-dimensional grid envelope defined by a RenderedImage . |
Method Summary | |
---|---|
boolean |
equals(java.lang.Object object)
Compares the specified object with this grid envelope for equality. |
int |
getDimension()
Returns the number of dimensions. |
org.opengis.coverage.grid.GridCoordinates |
getHigh()
Returns the valid maximum inclusive grid coordinates. |
int |
getHigh(int dimension)
Returns the valid maximum inclusive grid coordinate along the specified dimension. |
org.opengis.coverage.grid.GridCoordinates |
getLow()
Returns the valid minimum inclusive grid coordinates. |
int |
getLow(int dimension)
Returns the valid minimum inclusive grid coordinate along the specified dimension. |
int |
getSpan(int dimension)
Returns the number of integer grid coordinates along the specified dimension. |
GeneralGridEnvelope |
getSubGridEnvelope(int lower,
int upper)
Returns a new grid envelope that encompass only some dimensions of this grid envelope. |
int |
hashCode()
Returns a hash value for this grid envelope. |
java.awt.Rectangle |
toRectangle()
Returns a Rectangle with the same bounds as this GeneralGridEnvelope . |
java.lang.String |
toString()
Returns a string représentation of this grid envelope. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public GeneralGridEnvelope(org.opengis.coverage.grid.GridEnvelope envelope)
envelope
- The grid envelope to copy.public GeneralGridEnvelope(java.awt.Rectangle rect, int dimension)
Rectangle
.
The two first dimensions are set to the
[x .. x+width-1] and
[y .. y+height-1]
inclusive ranges respectively.
Extra dimensions (if any) are set to the [0..0] inclusive range.
Notice that this method ensure interoperability between Raster
dimensions in Java2D style and
GridEnvelope
dimensions in ISO 19123 style providing that the user remember to add 1 to the
GridEnvelope.getHigh(int)
values.
rect
- The grid coordinates as a rectangle.dimension
- Number of dimensions for this grid envelope.
Must be equals or greater than 2.public GeneralGridEnvelope(java.awt.Rectangle rect)
Rectangle
.
The 2 dimensions are set to the
[x .. x+width-1] and
[y .. y+height-1]
inclusive ranges respectively.
Notice that this method ensure interoperability between Raster
dimensions in Java2D style and
GridEnvelope
dimensions in ISO 19123 style providing that the user remember to add 1 to the
GridEnvelope.getHigh(int)
values.
rect
- The grid coordinates as a rectangle.public GeneralGridEnvelope(java.awt.image.Raster raster, int dimension)
Raster
.
The two first dimensions are set to the
[x .. x+width-1] and
[y .. y+height-1]
inclusive ranges respectively.
Extra dimensions (if any) are set to the [0..0] inclusive range.
Notice that this method ensure interoperability between Raster
dimensions in Java2D style and
GridEnvelope
dimensions in ISO 19123 style providing that the user remember to add 1 to the
GridEnvelope.getHigh(int)
values.
raster
- The raster for which to construct a grid envelope.dimension
- Number of dimensions for this grid envelope.
Must be equals or greater than 2.public GeneralGridEnvelope(java.awt.image.RenderedImage image, int dimension)
RenderedImage
.
The two first dimensions are set to the
[x .. x+width-1] and
[y .. y+height-1]
inclusive ranges respectively.
Extra dimensions (if any) are set to the [0..0] inclusive range.
Notice that this method ensure interoperability between Raster
dimensions in Java2D style and
GridEnvelope
dimensions in ISO 19123 style providing that the user remember to add 1 to the
GridEnvelope.getHigh(int)
values.
image
- The image for which to construct a grid envelope.dimension
- Number of dimensions for this grid envelope.
Must be equals or greater than 2.public GeneralGridEnvelope(org.opengis.geometry.Envelope envelope, org.opengis.referencing.datum.PixelInCell anchor) throws java.lang.IllegalArgumentException
Notice that highest values are interpreted as inclusive
Anchor
According OpenGIS specification, grid
geometry maps pixel's center. But envelopes typically encompass all pixels. This means
that grid coordinates (0,0) has an envelope starting at (-0.5, -0.5). In order to revert
back such envelope to a grid envelope, it is necessary to add 0.5 to every coordinates
(including the maximum value since it is exclusive in a grid envelope). This offset is
applied only if anchor
is PixelInCell.CELL_CENTER
. Users who don't want
such offset should specify PixelInCell.CELL_CORNER
.
The convention is specified as a PixelInCell
code instead than the more detailed
PixelOrientation
because the latter is restricted to
the two-dimensional case while the former can be used for any number of dimensions.
envelope
- The envelope to use for initializing this grid envelope.anchor
- Whatever envelope coordinates map to pixel center or pixel corner. Should be
PixelInCell.CELL_CENTER
for OGC convention (an offset of 0.5 will be
added to every envelope coordinate values), or PixelInCell.CELL_CORNER
for Java2D/JAI convention (no offset will be added).
java.lang.IllegalArgumentException
- If anchor
is not valid.org.geotools.referencing.GeneralEnvelope#GeneralEnvelope(GridEnvelope, PixelInCell,
org.opengis.referencing.operation.MathTransform,
org.opengis.referencing.crs.CoordinateReferenceSystem)
public GeneralGridEnvelope(org.opengis.geometry.Envelope envelope, org.opengis.referencing.datum.PixelInCell anchor, boolean isHighIncluded) throws java.lang.IllegalArgumentException
Note about rounding mode
It would have been possible to round the minimal value
toward floor and the maximal value
toward ceil in order to make sure that the grid envelope encompass
fully the envelope - like what Java2D does when converting Rectangle2D
to Rectangle
). But this approach may increase by 1 or 2 units the image
width or height. For
example the range [-0.25 ... 99.75]
(which is exactly 101 units wide) would be casted
to [-1 ... 100]
, which is 102 units wide. This leads to unexpected results when using
grid envelope with image operations like "Affine
". For avoiding such changes in size, it is necessary to use the same rounding mode
for both minimal and maximal values. The selected rounding mode is nearest integer in this implementation.
Anchor
According OpenGIS specification, grid
geometry maps pixel's center. But envelopes typically encompass all pixels. This means
that grid coordinates (0,0) has an envelope starting at (-0.5, -0.5). In order to revert
back such envelope to a grid envelope, it is necessary to add 0.5 to every coordinates
(including the maximum value since it is exclusive in a grid envelope). This offset is
applied only if anchor
is PixelInCell.CELL_CENTER
. Users who don't want
such offset should specify PixelInCell.CELL_CORNER
.
The convention is specified as a PixelInCell
code instead than the more detailed
PixelOrientation
because the latter is restricted to
the two-dimensional case while the former can be used for any number of dimensions.
envelope
- The envelope to use for initializing this grid envelope.anchor
- Whatever envelope coordinates map to pixel center or pixel corner. Should be
PixelInCell.CELL_CENTER
for OGC convention (an offset of 0.5 will be
added to every envelope coordinate values), or PixelInCell.CELL_CORNER
for Java2D/JAI convention (no offset will be added).isHighIncluded
- true
if the envelope maximal values are inclusive, or false
if
they are exclusive. This argument does not apply to minimal values, which are
always inclusive.
java.lang.IllegalArgumentException
- If anchor
is not valid.org.geotools.referencing.GeneralEnvelope#GeneralEnvelope(GridEnvelope, PixelInCell,
org.opengis.referencing.operation.MathTransform,
org.opengis.referencing.crs.CoordinateReferenceSystem)
public GeneralGridEnvelope(int[] low, int[] high, boolean isHighIncluded)
low
- The valid minimum inclusive grid coordinate. The array contains a minimum
value (inclusive) for each dimension of the grid coverage. The lowest valid
grid coordinate is often zero, but this is not mandatory.high
- The valid maximum grid coordinate. The array contains a maximum
value for each dimension of the grid coverage.isHighIncluded
- true
if the high
values are inclusive (as in ISO 19123
specification), or false
if they are exclusive (as in Java usage).
This argument does not apply to low values, which are always inclusive.getLow()
,
getHigh()
public GeneralGridEnvelope(int[] low, int[] high)
Notice that this constructor has been added for compatibility with JAVA2D, which means that the high coords are intepreted as EXCLUSIVE
low
- The valid minimum inclusive grid coordinate. The array contains a minimum
value (inclusive) for each dimension of the grid coverage. The lowest valid
grid coordinate is often zero, but this is not mandatory.high
- The valid maximum grid coordinate. The array contains a maximum
value for each dimension of the grid coverage.isHighIncluded
- true
if the high
values are inclusive (as in ISO 19123
specification), or false
if they are exclusive (as in Java usage).
This argument does not apply to low values, which are always inclusive.getLow()
,
getHigh()
Method Detail |
---|
public int getDimension()
getDimension
in interface org.opengis.coverage.grid.GridEnvelope
public org.opengis.coverage.grid.GridCoordinates getLow()
getLow
in interface org.opengis.coverage.grid.GridEnvelope
public org.opengis.coverage.grid.GridCoordinates getHigh()
getHigh
in interface org.opengis.coverage.grid.GridEnvelope
public int getLow(int dimension)
getLow
in interface org.opengis.coverage.grid.GridEnvelope
getLow()
public int getHigh(int dimension)
getHigh
in interface org.opengis.coverage.grid.GridEnvelope
getHigh()
public int getSpan(int dimension)
getHigh(dimension) - getLow(dimension)
.
getSpan
in interface org.opengis.coverage.grid.GridEnvelope
public GeneralGridEnvelope getSubGridEnvelope(int lower, int upper) throws java.lang.IndexOutOfBoundsException
lower
and extending to dimension upper-1
inclusive. Thus the dimension
of the sub grid envelope is upper - lower
.
lower
- The first dimension to copy, inclusive.upper
- The last dimension to copy, exclusive.
java.lang.IndexOutOfBoundsException
- if an index is out of bounds.public java.awt.Rectangle toRectangle() throws java.lang.IllegalStateException
Rectangle
with the same bounds as this GeneralGridEnvelope
.
This is a convenience method for interoperability with Java2D.
java.lang.IllegalStateException
- if this grid envelope is not two-dimensional.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
object
- The object to compare with this grid envelope for equality.
true
if the given object is equals to this grid envelope.public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |