|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectGeneralGridGeometry
GridGeometry2D
@Immutable public class GridGeometry2D
A GeneralGridGeometry where only 2 dimensions have more than 1 cell.
For example a grid size of 512×512×1 pixels can be represented by this
GridGeometry2D class (some peoples said 2.5D) because a two-dimensional grid
coordinate is enough for referencing a pixel without ambiguity. But a grid size of
512×512×2 pixels can not be represented by this GridGeometry2D,
because a three-dimensional coordinate is mandatory for referencing a pixel without
ambiguity.
Constructors
The most complete way to create a GridGeometry2D instance is to provide all the
following information:
PixelInCell or PixelOrientation code, which specify whatever
the source of the "grid to CRS" transform maps a pixel corner or the pixel
center.This class defines also some convenience constructors for inferring the math transform from a geodetic envelope. However those convenience constructors use heuristic rules which try to guess whatever an axis should be reversed according common practice. Users should alway prefer the above listed argument types when possible.
Constraints
The above-listed arguments shall comply with the following constraints:
BufferedImage, then the
lowest valid grid ordinates shall be zero.
For other kind of RenderedImage, the lowest ordinates
may be non-zero.
ImageGeometry,
GeneralGridGeometry,
Serialized Form
| coverage/geotk-coverage (download) | View source code for this class |
| Field Summary | |
|---|---|
int |
axisDimensionX
The ( gridDimensionX, gridDimensionY) dimensions in the envelope space. |
int |
axisDimensionY
The ( gridDimensionX, gridDimensionY) dimensions in the envelope space. |
int |
gridDimensionX
Index of column ( gridDimensionX) and row (gridDimensionY) ordinates
in a grid point. |
int |
gridDimensionY
Index of column ( gridDimensionX) and row (gridDimensionY) ordinates
in a grid point. |
| Fields inherited from class GeneralGridGeometry |
|---|
CRS, envelope, ENVELOPE, extent, EXTENT, GRID_RANGE, GRID_TO_CRS, gridToCRS |
| Constructor Summary | |
|---|---|
GridGeometry2D(GridEnvelope extent,
Envelope envelope)
Constructs a new grid geometry from an envelope. |
|
GridGeometry2D(GridEnvelope extent,
MathTransform gridToCRS,
CoordinateReferenceSystem crs)
Constructs a new grid geometry from a grid envelope and a math transform. |
|
GridGeometry2D(GridEnvelope extent,
PixelInCell anchor,
MathTransform gridToCRS,
CoordinateReferenceSystem crs,
Hints hints)
Constructs a new grid geometry from a math transform. |
|
GridGeometry2D(GridEnvelope extent,
PixelOrientation anchor,
MathTransform gridToCRS,
CoordinateReferenceSystem crs,
Hints hints)
Constructs a new grid geometry from a math transform. |
|
GridGeometry2D(GridGeometry other)
Creates a new grid geometry with the same values than the given grid geometry. |
|
GridGeometry2D(PixelInCell anchor,
MathTransform gridToCRS,
Envelope envelope,
Hints hints)
Constructs a new grid geometry from an envelope and a math transform. |
|
GridGeometry2D(Rectangle extent,
Rectangle2D envelope)
Constructs a new two-dimensional grid geometry. |
|
| Method Summary | |
|---|---|
static GridGeometry2D |
castOrCopy(GridGeometry other)
Returns the given grid geometry as a GridGeometry2D. |
boolean |
equals(Object object)
Compares the specified object with this grid geometry for equality. |
CoordinateReferenceSystem |
getCoordinateReferenceSystem2D()
Returns the two-dimensional part of this grid geometry CRS. |
Envelope2D |
getEnvelope2D()
Returns the two-dimensional bounding box for the coverage domain in coordinate reference system coordinates. |
GridEnvelope2D |
getExtent2D()
Returns the two-dimensional part of the grid envelope as a rectangle. |
GridEnvelope2D |
getGridRange2D()
Deprecated. Renamed getGridRange2D(). |
MathTransform |
getGridToCRS(PixelOrientation orientation)
Returns a math transform mapping the specified pixel part. |
MathTransform2D |
getGridToCRS2D()
Returns a math transform for the two dimensional part. |
MathTransform2D |
getGridToCRS2D(PixelOrientation orientation)
Returns a math transform for the two dimensional part. |
CoordinateReferenceSystem |
reduce(CoordinateReferenceSystem crs)
Reduces the specified CRS to a two-dimensional one. |
Envelope2D |
reduce(Envelope envelope)
Reduces the specified envelope to a two-dimensional one. |
| Methods inherited from class GeneralGridGeometry |
|---|
getCoordinateReferenceSystem, getDimension, getEnvelope, getExtent, getGridRange, getGridToCRS, getGridToCRS, getResolution, hashCode, isDefined, toString |
| Methods inherited from class Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public final int gridDimensionX
gridDimensionX) and row (gridDimensionY) ordinates
in a grid point. They are the index of the first two dimensions with a span greater than 1 in the grid extent.
Their values are usually 0 and 1 respectively.
Notes:
gridDimensionX < gridDimensionY.
public final int gridDimensionY
gridDimensionX) and row (gridDimensionY) ordinates
in a grid point. They are the index of the first two dimensions with a span greater than 1 in the grid extent.
Their values are usually 0 and 1 respectively.
Notes:
gridDimensionX < gridDimensionY.
public final int axisDimensionX
gridDimensionX, gridDimensionY) dimensions in the envelope space.
They are index of (x, y) ordinates in a direct position after the
grid to CRS transform.
Notes:
axisDimensionX < axisDimensionY.gridDimensionX maps to axisDimensionX and
gridDimensionY maps to axisDimensionY, since axis may be interchanged.
public final int axisDimensionY
gridDimensionX, gridDimensionY) dimensions in the envelope space.
They are index of (x, y) ordinates in a direct position after the
grid to CRS transform.
Notes:
axisDimensionX < axisDimensionY.gridDimensionX maps to axisDimensionX and
gridDimensionY maps to axisDimensionY, since axis may be interchanged.
| Constructor Detail |
|---|
public GridGeometry2D(GridGeometry other)
throws IllegalArgumentException
GridGeometry2D.
other - The other grid geometry to copy.
IllegalArgumentException - If the given grid geometry does not comply to the
constraints documented in the class javadoc.castOrCopy(GridGeometry)
public GridGeometry2D(GridEnvelope extent,
MathTransform gridToCRS,
CoordinateReferenceSystem crs)
throws IllegalArgumentException,
MismatchedDimensionException
extent - The extent of grid coordinates in 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.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 extent has more than 2 dimensions with
a span larger than 1, or if the math transform
can't transform coordinates in the domain of the specified grid envelope.GridGeometry2D(GridEnvelope, PixelInCell, MathTransform, CoordinateReferenceSystem, Hints),
GridGeometry2D(GridEnvelope, PixelOrientation, MathTransform, CoordinateReferenceSystem, Hints)
public GridGeometry2D(GridEnvelope extent,
PixelInCell anchor,
MathTransform gridToCRS,
CoordinateReferenceSystem crs,
Hints hints)
throws MismatchedDimensionException,
IllegalArgumentException
GridGeometry2D(extent, gridToCRS, crs) with the addition of an explicit anchor
and an optional set of hints giving more control on the MathTransform2D to be
inferred from the n-dimensional transform.
The anchor argument tells whatever the gridToCRS transform maps cell center (OGC convention) or cell corner (Java2D/JAI convention). At the opposite of the constructor expecting a PixelOrientation argument, the translation (if any) applies to every dimensions, not just
the ones mapping the 2D part.
extent - The extent of grid coordinates in a grid coverage, or null if none.anchor - Whatever the gridToCRS transform maps
cell center (OGC convention) or
cell corner (Java2D/JAI convention).gridToCRS - The math transform which allows for the transformations from grid
coordinates to real world earth coordinates.crs - The coordinate reference system for the "real world" coordinates, or
null if unknown. This CRS is given to the
envelope.hints - An optional set of hints controlling the DimensionFilter to be
used for deriving the MathTransform2D instance from the given
gridToCRS transform.
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 envelope.
public GridGeometry2D(GridEnvelope extent,
PixelOrientation anchor,
MathTransform gridToCRS,
CoordinateReferenceSystem crs,
Hints hints)
throws IllegalArgumentException,
MismatchedDimensionException
GridGeometry2D(extent, gridToCRS, crs) with the addition of an explicit anchor
and an optional set of hints giving more control on the MathTransform2D to be
inferred from the n-dimensional transform.
The anchor argument tells whatever the gridToCRS transform maps pixel
center or some corner. Use CENTER for OGC conventions or
UPPER_LEFT for Java2D/JAI conventions. A translation
(if needed) is applied only on the gridDimensionX and gridDimensionY
parts of the transform - all other dimensions are assumed mapping pixel center.
extent - The extent of grid coordinates in a grid coverage, or null if none.anchor - Whatever the two-dimensional part of the gridToCRS transform
maps pixel center or some corner.gridToCRS - The math transform from grid coordinates to real world earth coordinates.crs - The coordinate reference system for the "real world" coordinates, or
null if unknown.hints - An optional set of hints controlling the DimensionFilter to be
used for deriving the MathTransform2D instance from the given
gridToCRS transform.
MismatchedDimensionException - if the math transform and the CRS don't have
consistent dimensions.
IllegalArgumentException - if extent has more than 2 dimensions with
a span larger than 1, or if the math transform
can't transform coordinates in the domain of the specified grid envelope.
public GridGeometry2D(PixelInCell anchor,
MathTransform gridToCRS,
Envelope envelope,
Hints hints)
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.hints - An optional set of hints controlling the DimensionFilter to be
used for deriving the MathTransform2D instance from the given
gridToCRS transform.
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 envelope.
public GridGeometry2D(GridEnvelope extent,
Envelope envelope)
throws IllegalArgumentException,
MismatchedDimensionException
extent - The valid coordinate range of a grid coverage.envelope - The corresponding coordinate range in user coordinate.
IllegalArgumentException - if extent has more than 2 dimensions with
a span larger than 1.
MismatchedDimensionException - if the grid envelope and the CRS doesn't have
consistent dimensions.
public GridGeometry2D(Rectangle extent,
Rectangle2D envelope)
extent and
userRange are assumed to have y axis in opposite direction).
extent - The valid domain of grid coordinates.
Increasing x values goes right and
increasing y values goes down.envelope - The corresponding coordinate range in user coordinate.
Increasing x values goes right and
increasing y values goes up.
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.| Method Detail |
|---|
public static GridGeometry2D castOrCopy(GridGeometry other)
GridGeometry2D. If the given
object is already an instance of GridGeometry2D, then it is returned
unchanged. Otherwise a new GridGeometry2D instance is created using the
copy constructor.
other - The grid geometry to cast or copy.
null if other was null.public Envelope2D reduce(Envelope envelope)
axisDimensionX, axisDimensionY) index.
The coordinate reference system of the
source envelope is ignored. The coordinate reference system of the target envelope
will be getCoordinateReferenceSystem2D() or null.
envelope - The envelope to reduce, or null. This envelope will not be modified.
null if envelope was null.
The returned envelope is always a new instance, so it can be modified safely.
public CoordinateReferenceSystem reduce(CoordinateReferenceSystem crs)
throws FactoryException
axisDimensionX,
axisDimensionY) index.
crs - The coordinate reference system to reduce, or null.
null if crs was null.
FactoryException - if the given CRS can't be reduced to two dimensions.
public CoordinateReferenceSystem getCoordinateReferenceSystem2D()
throws InvalidGridGeometryException
axisDimensionX,
axisDimensionY) axis. Note that those axis are guaranteed to appears in the
same order than in the complete CRS.
null).
InvalidGridGeometryException - if this grid geometry has no CRS (i.e.
isDefined(CRS)
returned false).GeneralGridGeometry.getCoordinateReferenceSystem()
public Envelope2D getEnvelope2D()
throws InvalidGridGeometryException
null).
InvalidGridGeometryException - if this grid geometry has no envelope (i.e.
isDefined(ENVELOPE)
returned false).GeneralGridGeometry.getEnvelope()
public GridEnvelope2D getExtent2D()
throws InvalidGridGeometryException
Rectangle subclass.
null).
InvalidGridGeometryException - if this grid geometry has no extent (i.e.
isDefined(EXTENT)
returned false).GeneralGridGeometry.getExtent()
@Deprecated
public GridEnvelope2D getGridRange2D()
throws InvalidGridGeometryException
getGridRange2D().
InvalidGridGeometryException
public MathTransform2D getGridToCRS2D()
throws InvalidGridGeometryException
AffineTransform, which
make it convenient for inter-operability with Java2D.
InvalidGridGeometryException - if a two-dimensional transform is not available
for this grid geometry.getGridToCRS(org.opengis.metadata.spatial.PixelOrientation)public MathTransform2D getGridToCRS2D(PixelOrientation orientation)
getGridToCRS2D() except that the transform may maps a pixel corner
instead of pixel center.
orientation - The pixel part to map. The default value is
CENTER.
InvalidGridGeometryException - if a two-dimensional transform is not available
for this grid geometry.public MathTransform getGridToCRS(PixelOrientation orientation)
gridDimensionX and gridDimensionY parts of the transform;
all other dimensions are assumed mapping pixel center. For applying a translation on all
dimensions, use GeneralGridGeometry.getGridToCRS(PixelInCell) instead.
orientation - The pixel part to map. The default value is
CENTER.
InvalidGridGeometryException - if a transform is not available
for this grid geometry.GeneralGridGeometry.getGridToCRS(PixelInCell),
PixelTranslationpublic boolean equals(Object object)
equals in class GeneralGridGeometryobject - The object to compare with.
true if the given object is equals to this grid geometry.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||