org.geotools.coverage.grid
Class GridGeometry2D

java.lang.Object
  extended byorg.geotools.coverage.grid.GeneralGridGeometry
      extended byorg.geotools.coverage.grid.GridGeometry2D
All Implemented Interfaces:
org.opengis.coverage.grid.GridGeometry, java.io.Serializable

public class GridGeometry2D
extends GeneralGridGeometry

Describes the valid range of grid coordinates and the math transform, in the special case where only 2 dimensions are in use. By "in use", we means dimension with more than 1 pixel. For example a grid size of 512×512×1 pixels can be represented by this 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 , because a three-dimensional coordinate is mandatory for referencing a pixel without ambiguity.

Since:
2.1
Version:
$Id: GridGeometry2D.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Martin Desruisseaux
See Also:
Serialized Form

Field Summary
 int axisDimensionX
          The (gridDimensionX, gridDimensionY) dimensions in the envelope space.
 int axisDimensionY
          The (gridDimensionX, gridDimensionY) dimensions in the envelope space.
 int gridDimensionX
          The first () and second () dimensions of grid range with length greater than 1.
 int gridDimensionY
          The first () and second () dimensions of grid range with length greater than 1.
 
Fields inherited from class org.geotools.coverage.grid.GeneralGridGeometry
CRS, ENVELOPE, GRID_RANGE, GRID_TO_CRS, gridRange, gridToCRS
 
Constructor Summary
GridGeometry2D(org.opengis.coverage.grid.GridRange gridRange, org.opengis.spatialschema.geometry.Envelope userRange)
          Constructs a new grid geometry from an envelope.
GridGeometry2D(org.opengis.coverage.grid.GridRange gridRange, org.opengis.spatialschema.geometry.Envelope userRange, boolean[] reverse)
          Deprecated. Replaced by . Users just need to append the argument value, so this constructor will be removed in a future version in order to keep the API lighter.
GridGeometry2D(org.opengis.coverage.grid.GridRange gridRange, org.opengis.spatialschema.geometry.Envelope userRange, boolean[] reverse, boolean swapXY)
          Constructs a new grid geometry from an envelope.
GridGeometry2D(org.opengis.coverage.grid.GridRange gridRange, org.opengis.referencing.operation.MathTransform gridToCRS)
          Deprecated. Replaced by GridGeometry2D(gridRange, gridToCRS, null).
GridGeometry2D(org.opengis.coverage.grid.GridRange gridRange, org.opengis.referencing.operation.MathTransform gridToCRS, org.opengis.referencing.crs.CoordinateReferenceSystem crs)
          Constructs a new grid geometry from a math transform.
GridGeometry2D(java.awt.Rectangle gridRange, java.awt.geom.Rectangle2D userRange)
          Constructs a new two-dimensional grid geometry.
 
Method Summary
 boolean equals(java.lang.Object object)
          Compares the specified object with this grid geometry for equality.
 org.opengis.referencing.crs.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.
 java.awt.Rectangle getGridRange2D()
          Returns the two-dimensional part of the grid range as a rectangle.
 org.opengis.referencing.operation.MathTransform2D getGridToCoordinateSystem2D()
          Returns a math transform for the two dimensional part.
 
Methods inherited from class org.geotools.coverage.grid.GeneralGridGeometry
getCoordinateReferenceSystem, getDimension, getEnvelope, getGridRange, getGridToCoordinateSystem, hashCode, isDefined, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

gridDimensionX

public final int gridDimensionX
The first () and second () dimensions of grid range with length greater than 1. Those (x, y) dimensions are usually 0 and 1 respectively.


gridDimensionY

public final int gridDimensionY
The first () and second () dimensions of grid range with length greater than 1. Those (x, y) dimensions are usually 0 and 1 respectively.


axisDimensionX

public final int axisDimensionX
The (gridDimensionX, gridDimensionY) dimensions in the envelope space. They are the (x, y) dimensions after the grid to CRS transform. Those dimensions are usually 0 and 1 respectively.


axisDimensionY

public final int axisDimensionY
The (gridDimensionX, gridDimensionY) dimensions in the envelope space. They are the (x, y) dimensions after the grid to CRS transform. Those dimensions are usually 0 and 1 respectively.

Constructor Detail

GridGeometry2D

public GridGeometry2D(org.opengis.coverage.grid.GridRange gridRange,
                      org.opengis.referencing.operation.MathTransform gridToCRS)
               throws java.lang.IllegalArgumentException
Deprecated. Replaced by GridGeometry2D(gridRange, gridToCRS, null).

Constructs a new grid geometry from a math transform.


GridGeometry2D

public GridGeometry2D(org.opengis.coverage.grid.GridRange gridRange,
                      org.opengis.referencing.operation.MathTransform gridToCRS,
                      org.opengis.referencing.crs.CoordinateReferenceSystem crs)
               throws java.lang.IllegalArgumentException,
                      org.opengis.spatialschema.geometry.MismatchedDimensionException
Constructs a new grid geometry from a math transform. The arguments are passed unchanged to the super-class constructor. However, they must obey to one additional constraint: only two dimensions in the grid range can have a length larger than 1.

Parameters:
gridRange - The valid coordinate range of a grid coverage, or 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.
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 if unknown. This CRS is given to the envelope.
Throws:
org.opengis.spatialschema.geometry.MismatchedDimensionException - if the math transform and the CRS doesn't have consistent dimensions.
java.lang.IllegalArgumentException - if has more than 2 dimensions with a length larger than 1, or if the math transform can't transform coordinates in the domain of the specified grid range.
Since:
2.2
See Also:
RenderedImage.getMinX(), RenderedImage.getMinY(), RenderedImage.getWidth(), RenderedImage.getHeight()

GridGeometry2D

public GridGeometry2D(org.opengis.coverage.grid.GridRange gridRange,
                      org.opengis.spatialschema.geometry.Envelope userRange)
               throws java.lang.IllegalArgumentException,
                      org.opengis.spatialschema.geometry.MismatchedDimensionException
Constructs a new grid geometry from an envelope. This constructors applies the same heuristic rules than the super-class constructor. However, they must obey to one additional constraint: only two dimensions in the grid range can have a length larger than 1.

Parameters:
gridRange - The valid coordinate range of a grid coverage.
userRange - The corresponding coordinate range in user coordinate.
Throws:
java.lang.IllegalArgumentException - if has more than 2 dimensions with a length larger than 1.
org.opengis.spatialschema.geometry.MismatchedDimensionException - if the grid range and the CRS doesn't have consistent dimensions.
Since:
2.2

GridGeometry2D

public GridGeometry2D(org.opengis.coverage.grid.GridRange gridRange,
                      org.opengis.spatialschema.geometry.Envelope userRange,
                      boolean[] reverse)
               throws java.lang.IllegalArgumentException,
                      org.opengis.spatialschema.geometry.MismatchedDimensionException
Deprecated. Replaced by . Users just need to append the argument value, so this constructor will be removed in a future version in order to keep the API lighter.

Constructs a new grid geometry from an envelope.


GridGeometry2D

public GridGeometry2D(org.opengis.coverage.grid.GridRange gridRange,
                      org.opengis.spatialschema.geometry.Envelope userRange,
                      boolean[] reverse,
                      boolean swapXY)
               throws java.lang.IllegalArgumentException,
                      org.opengis.spatialschema.geometry.MismatchedDimensionException
Constructs a new grid geometry from an envelope. The argument are passed unchanged to the super-class constructor. However, they must obey to one additional constraint: only two dimensions in the grid range can have a length larger than 1.

Parameters:
gridRange - The valid coordinate range of a grid coverage.
userRange - The corresponding coordinate range in user coordinate.
reverse - Tells for each axis in user space whatever or not its direction should be reversed. A value reverse no axis.
swapXY - If , then the two first axis will be interchanged.
Throws:
java.lang.IllegalArgumentException - if has more than 2 dimensions with a length larger than 1.
org.opengis.spatialschema.geometry.MismatchedDimensionException - if the grid range and the CRS doesn't have consistent dimensions.
Since:
2.2

GridGeometry2D

public GridGeometry2D(java.awt.Rectangle gridRange,
                      java.awt.geom.Rectangle2D userRange)
Constructs a new two-dimensional grid geometry. A math transform will be computed automatically with an inverted y axis (i.e. and are assumed to have y axis in opposite direction).

Parameters:
gridRange - The valid coordinate range of a grid coverage. Increasing x values goes right and increasing y values goes down.
userRange - 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

getCoordinateReferenceSystem2D

public org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem2D()
                                                                                     throws InvalidGridGeometryException
Returns the two-dimensional part of this grid geometry CRS. This is usually (but not always) identical to the full CRS.

Returns:
The coordinate reference system (never ).
Throws:
InvalidGridGeometryException - if this grid geometry has no CRS (i.e. isDefined(CRS) returned ).
Since:
2.2
See Also:
GeneralGridGeometry.getCoordinateReferenceSystem()

getEnvelope2D

public Envelope2D getEnvelope2D()
                         throws InvalidGridGeometryException
Returns the two-dimensional bounding box for the coverage domain in coordinate reference system coordinates. If the coverage envelope has more than two dimensions, only the dimensions used in the underlying rendered image are returned.

Returns:
The bounding box in "real world" coordinates (never ).
Throws:
InvalidGridGeometryException - if this grid geometry has no envelope (i.e. isDefined(ENVELOPE) returned ).
See Also:
GeneralGridGeometry.getEnvelope()

getGridRange2D

public java.awt.Rectangle getGridRange2D()
                                  throws InvalidGridGeometryException
Returns the two-dimensional part of the grid range as a rectangle.

Returns:
The grid range (never ).
Throws:
InvalidGridGeometryException - if this grid geometry has no grid range (i.e. isDefined(GRID_RANGE) returned ).
See Also:
GeneralGridGeometry.getGridRange(), RenderedImage.getMinX(), RenderedImage.getMinY(), RenderedImage.getWidth(), RenderedImage.getHeight()

getGridToCoordinateSystem2D

public org.opengis.referencing.operation.MathTransform2D getGridToCoordinateSystem2D()
                                                                              throws InvalidGridGeometryException
Returns a math transform for the two dimensional part. This is a convenience method for working on horizontal data while ignoring vertical or temporal dimensions.

Returns:
The transform which allows for the transformations from grid coordinates to real world earth coordinates, operating only on two dimensions. The returned transform is often an instance of AffineTransform, which make it convenient for interoperability with Java2D.
Throws:
InvalidGridGeometryException - if a two-dimensional transform is not available for this grid geometry.
See Also:
GeneralGridGeometry.getGridToCoordinateSystem()

equals

public boolean equals(java.lang.Object object)
Compares the specified object with this grid geometry for equality.

Overrides:
equals in class GeneralGridGeometry


Copyright © GeoTools. All Rights Reserved.