public class GeneralGridGeometry extends Object implements GridGeometry, Serializable
All grid geometry attributes are optional because some of them may be inferred from a wider
context. For example a grid geometry know nothing about rendered
images, but GridCoverage2D
do. Consequently, the later may infer the grid range by itself.
By default, any request for an undefined attribute will thrown an InvalidGridGeometryException
. In order to check if an attribute is defined, use isDefined(int)
.
GridGeometry2D
,
ImageGeometry
,
Serialized FormModifier and Type | Field and Description |
---|---|
static int |
CRS_BITMASK
A bitmask to specify the validity of the coordinate
reference system.
|
static int |
ENVELOPE_BITMASK
A bitmask to specify the validity of the envelope.
|
static int |
GRID_RANGE_BITMASK
A bitmask to specify the validity of the grid range.
|
static int |
GRID_TO_CRS_BITMASK
A bitmask to specify the validity of the grid to CRS
transform.
|
protected GridEnvelope |
gridRange
The valid coordinate range of a grid coverage, or
null if none. |
protected MathTransform |
gridToCRS
The math transform (usually an affine transform), or
null if none. |
Constructor and Description |
---|
GeneralGridGeometry(GridEnvelope gridRange,
Envelope userRange)
Constructs a new grid geometry from an envelope.
|
GeneralGridGeometry(GridEnvelope gridRange,
MathTransform gridToCRS,
CoordinateReferenceSystem crs)
Constructs a new grid geometry from a grid range and a math
transform mapping pixel center.
|
GeneralGridGeometry(GridEnvelope gridRange,
PixelInCell anchor,
MathTransform gridToCRS,
CoordinateReferenceSystem crs)
Constructs a new grid geometry from a grid range and a math
transform mapping pixel center or corner.
|
GeneralGridGeometry(GridGeometry other)
Creates a new grid geometry with the same values than the given grid geometry.
|
GeneralGridGeometry(PixelInCell anchor,
MathTransform gridToCRS,
Envelope envelope)
Constructs a new grid geometry from an envelope and a math
transform.
|
GeneralGridGeometry(PixelInCell anchor,
MathTransform gridToCRS,
Envelope envelope,
boolean gridMaxInclusive,
boolean preserveGridToCRS)
Constructs a new grid geometry from an envelope and a math
transform.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object object)
Compares the specified object with this grid geometry for equality.
|
CoordinateReferenceSystem |
getCoordinateReferenceSystem()
Returns the "real world" coordinate reference system.
|
int |
getDimension()
Returns the number of dimensions.
|
Envelope |
getEnvelope()
Returns the bounding box of "real world" coordinates for this grid geometry.
|
GridEnvelope |
getGridRange()
Returns the valid coordinate range of a grid coverage.
|
MathTransform |
getGridToCRS()
Returns the transform from grid coordinates to real world earth coordinates.
|
MathTransform |
getGridToCRS(PixelInCell anchor)
Returns the transform from grid coordinates to real world earth coordinates.
|
int |
hashCode()
Returns a hash value for this grid geometry.
|
boolean |
isDefined(int bitmask)
Returns
true if all the parameters specified by the argument are set. |
String |
toString()
Returns a string representation of this grid geometry.
|
public static final int CRS_BITMASK
isDefined(int)
method.public static final int ENVELOPE_BITMASK
isDefined(int)
method.public static final int GRID_RANGE_BITMASK
isDefined(int)
method.public static final int GRID_TO_CRS_BITMASK
isDefined(int)
method.protected final GridEnvelope gridRange
null
if none. The lowest valid grid
coordinate is zero for BufferedImage
, but may be non-zero for
arbitrary RenderedImage
. A grid with 512 cells can have a minimum coordinate of 0 and
maximum of 512, with 511 as the highest valid index.protected MathTransform gridToCRS
null
if none. This math
transform maps pixel center to "real world" coordinate
using the following line:
gridToCRS.transform(pixels, point);
public GeneralGridGeometry(GridGeometry other)
GeneralGridGeometry
.other
- The other grid geometry to copy.public GeneralGridGeometry(GridEnvelope gridRange, MathTransform gridToCRS, CoordinateReferenceSystem crs) throws MismatchedDimensionException, IllegalArgumentException
gridRange
- The valid coordinate range of a grid coverage, or null
if none.gridToCRS
- The math transform which allows for the transformations from grid
coordinates (pixel's center) to real world earth coordinates. May be null
, but this is not recommanded.crs
- The coordinate reference system for the "real world" coordinates, or null
if unknown. This CRS is given to the envelope.MismatchedDimensionException
- if the math transform and the CRS don't have consistent
dimensions.IllegalArgumentException
- if the math transform can't transform coordinates in the
domain of the specified grid range.public GeneralGridGeometry(GridEnvelope gridRange, PixelInCell anchor, MathTransform gridToCRS, CoordinateReferenceSystem crs) throws MismatchedDimensionException, IllegalArgumentException
gridRange
- The valid coordinate range of a grid coverage, or null
if none.anchor
- CELL_CENTER
for OGC conventions or CELL_CORNER
for Java2D/JAI conventions.gridToCRS
- The math transform which allows for the transformations from grid
coordinates to real world earth coordinates. May be null
, but this is not
recommended.crs
- The coordinate reference system for the "real world" coordinates, or null
if unknown. This CRS is given to the envelope.MismatchedDimensionException
- if the math transform and the CRS don't have consistent
dimensions.IllegalArgumentException
- if the math transform can't transform coordinates in the
domain of the specified grid range.public GeneralGridGeometry(PixelInCell anchor, MathTransform gridToCRS, Envelope envelope, boolean gridMaxInclusive, boolean preserveGridToCRS) throws MismatchedDimensionException, IllegalArgumentException
anchor
argument.
It is worth to point a few guidelines for the usage of the gridMaxInclusive parameter. In
case we are using this contructor for a reprojection it might be worth using a false
value for this parameter since we would not force to create a new raster that might
be slightly bigger than the original one, causing problems with black or nodata collars
appearing after a resample. In case we are trying to build a source raster area to be used at
reading time, in that case we may want to provide true
for gridMaxInclusive
since we may want to read an area that is slightly bigger than what we need to be sure we
actually reading something.
anchor
- CELL_CENTER
for OGC conventions or CELL_CORNER
for Java2D/JAI conventions.gridToCRS
- The math transform which allows for the transformations from grid
coordinates to real world earth coordinates. May be null
, but this is not
recommended.envelope
- The envelope (including CRS) of a grid coverage, or null
if none.gridMaxInclusive
- Tells us whether or not the resulting gridRange max values should be
inclusive or not. See notes above.preserveGridToCRS
- Tells us whether we should try to preserve the the gridToCRS or the
envelope most part of the time we won't be able to preserve both for our purposes.MismatchedDimensionException
- if the math transform and the envelope doesn't have
consistent dimensions.IllegalArgumentException
- if the math transform can't transform coordinates in the
domain of the grid range.public GeneralGridGeometry(PixelInCell anchor, MathTransform gridToCRS, Envelope envelope) throws MismatchedDimensionException, IllegalArgumentException
anchor
argument.anchor
- CELL_CENTER
for OGC conventions or CELL_CORNER
for Java2D/JAI conventions.gridToCRS
- The math transform which allows for the transformations from grid
coordinates to real world earth coordinates. May be null
, but this is not
recommended.envelope
- The envelope (including CRS) of a grid coverage, or null
if none.MismatchedDimensionException
- if the math transform and the envelope doesn't have
consistent dimensions.IllegalArgumentException
- if the math transform can't transform coordinates in the
domain of the grid range.public GeneralGridGeometry(GridEnvelope gridRange, Envelope userRange) throws MismatchedDimensionException
GridToEnvelopeMapper
javadoc.
More specifically, heuristic rules are applied for:
gridRange
- The valid coordinate range of a grid coverage.userRange
- The corresponding coordinate range in user coordinate. This rectangle must
contains entirely all pixels, i.e. the rectangle's upper left corner must coincide with
the upper left corner of the first pixel and the rectangle's lower right corner must
coincide with the lower right corner of the last pixel.MismatchedDimensionException
- if the grid range and the envelope doesn't have
consistent dimensions.public int getDimension()
public CoordinateReferenceSystem getCoordinateReferenceSystem() throws InvalidGridGeometryException
null
).InvalidGridGeometryException
- if this grid geometry has no CRS (i.e.
isDefined(CRS_BITMASK)
returned false
).GridGeometry2D.getCoordinateReferenceSystem2D()
public Envelope getEnvelope() throws InvalidGridGeometryException
null
).InvalidGridGeometryException
- if this grid geometry has no envelope (i.e.
isDefined(ENVELOPE_BITMASK)
returned false
).GridGeometry2D.getEnvelope2D()
public GridEnvelope getGridRange() throws InvalidGridGeometryException
BufferedImage
, but may be non-zero for arbitrary RenderedImage
. A grid with 512 cells can have a minimum coordinate of 0 and maximum of 512,
with 511 as the highest valid index.getGridRange
in interface GridGeometry
null
).InvalidGridGeometryException
- if this grid geometry has no grid range (i.e.
isDefined(GRID_RANGE_BITMASK)
returned
false
).GridGeometry2D.getGridRange2D()
public MathTransform getGridToCRS() throws InvalidGridGeometryException
Coverage.getCoordinateReferenceSystem()
.
Note: OpenGIS requires that the transform maps pixel centers to real world coordinates. This is different from some other systems that map pixel's upper left corner.
getGridToCRS
in interface GridGeometry
null
).InvalidGridGeometryException
- if this grid geometry has no transform (i.e.
isDefined(GRID_TO_CRS_BITMASK)
returned
false
).GridGeometry2D.getGridToCRS2D()
public MathTransform getGridToCRS(PixelInCell anchor) throws InvalidGridGeometryException
getGridToCRS()
except that the transform may maps other parts than pixel center.anchor
- The pixel part to map.null
).InvalidGridGeometryException
- if this grid geometry has no transform (i.e.
isDefined(GRID_TO_CRS_BITMASK)
returned
false
).getGridToCRS(org.opengis.referencing.datum.PixelInCell)
public boolean isDefined(int bitmask) throws IllegalArgumentException
true
if all the parameters specified by the argument are set.bitmask
- Any combination of CRS_BITMASK
, ENVELOPE_BITMASK
, GRID_RANGE_BITMASK
and GRID_TO_CRS_BITMASK
.true
if all specified attributes are defined (i.e. invoking the corresponding
method will not thrown an InvalidGridGeometryException
).IllegalArgumentException
- if the specified bitmask is not a combination of known
masks.ImageLayout.isValid(int)
public int hashCode()
public boolean equals(Object object)
Copyright © 1996–2019 Geotools. All rights reserved.