org.geotools.referencing.operation.builder
Class GridToEnvelopeMapper

Object
  extended by GridToEnvelopeMapper

public class GridToEnvelopeMapper
extends Object

A helper class for building n-dimensional affine transform mapping grid ranges to envelopes. The affine transform will be computed automatically from the information specified by the setGridRange and setEnvelope methods, which are mandatory. All other setter methods are optional hints about the affine transform to be created. This builder is convenient when the following conditions are meet:

In such case (and assuming that the image's CRS has the same characteristics than the BufferedImage's CRS described above):

Since:
2.3
Author:
Martin Desruisseaux (IRD)
Module:
modules/library/referencing (gt-referencing.jar)

Field Summary
static int REVERSE_AXIS
          A bit mask for the reverseAxis property.
static int SWAP_XY
          A bit mask for the swapXY property.
 
Constructor Summary
GridToEnvelopeMapper()
          Creates a new instance of GridToEnvelopeMapper.
GridToEnvelopeMapper(GridEnvelope gridRange, Envelope userRange)
          Creates a new instance for the specified grid range and envelope.
 
Method Summary
 AffineTransform createAffineTransform()
          Returns the math transform as a two-dimensional affine transform.
 MathTransform createTransform()
          Creates a math transform using the information provided by setter methods.
 Envelope getEnvelope()
          Returns the envelope.
 GridEnvelope getGridRange()
          Returns the grid range.
 PixelInCell getGridType()
          Deprecated. Renamed getPixelAnchor().
 PixelInCell getPixelAnchor()
          Returns whatever the grid range maps pixel center or pixel corner.
 boolean[] getReverseAxis()
          Returns which (if any) axis in user space (not grid space) should have their direction reversed.
 boolean getSwapXY()
          Returns true if the two first axis should be interchanged.
 boolean isAutomatic(int mask)
          Returns true if all properties designed by the specified bit mask will be computed automatically.
 void reverseAxis(int dimension)
          Reverses a single axis in user space.
 void setAutomatic(int mask)
          Set all properties designed by the specified bit mask as automatic.
 void setEnvelope(Envelope envelope)
          Sets the envelope.
 void setGridRange(GridEnvelope gridRange)
          Sets the grid range.
 void setGridType(PixelInCell anchor)
          Deprecated. Renamed setPixelAnchor(org.opengis.referencing.datum.PixelInCell).
 void setPixelAnchor(PixelInCell anchor)
          Sets whatever the grid range maps pixel center or pixel corner.
 void setReverseAxis(boolean[] reverse)
          Set which (if any) axis in user space (not grid space) should have their direction reversed.
 void setSwapXY(boolean swapXY)
          Tells if the two first axis should be interchanged.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SWAP_XY

public static final int SWAP_XY
A bit mask for the swapXY property.

See Also:
isAutomatic(int), setAutomatic(int), Constant Field Values

REVERSE_AXIS

public static final int REVERSE_AXIS
A bit mask for the reverseAxis property.

See Also:
isAutomatic(int), setAutomatic(int), Constant Field Values
Constructor Detail

GridToEnvelopeMapper

public GridToEnvelopeMapper()
Creates a new instance of GridToEnvelopeMapper.


GridToEnvelopeMapper

public GridToEnvelopeMapper(GridEnvelope gridRange,
                            Envelope userRange)
                     throws MismatchedDimensionException
Creates a new instance for the specified grid range and envelope.

Parameters:
gridRange - The valid coordinate range of a grid coverage.
userRange - The corresponding coordinate range in user coordinate. This envelope must contains entirely all pixels, i.e. the envelope's upper left corner must coincide with the upper left corner of the first pixel and the envelope's lower right corner must coincide with the lower right corner of the last pixel.
Throws:
MismatchedDimensionException - if the grid range and the envelope doesn't have consistent dimensions.
Method Detail

getGridType

@Deprecated
public PixelInCell getGridType()
Deprecated. Renamed getPixelAnchor().

Returns whatever the grid range maps pixel center or pixel corner.


getPixelAnchor

public PixelInCell getPixelAnchor()
Returns whatever the grid range maps pixel center or pixel corner. The former is OGC convention while the later is Java2D/JAI convention. The default is cell center (OGC convention).

Returns:
Whatever the grid range maps pixel center or corner.
Since:
2.5

setGridType

@Deprecated
public void setGridType(PixelInCell anchor)
Deprecated. Renamed setPixelAnchor(org.opengis.referencing.datum.PixelInCell).

Set whatever the grid range maps pixel center or pixel corner.


setPixelAnchor

public void setPixelAnchor(PixelInCell anchor)
Sets whatever the grid range maps pixel center or pixel corner. The former is OGC convention while the later is Java2D/JAI convention.

Parameters:
anchor - Whatever the grid range maps pixel center or corner.
Since:
2.5

getGridRange

public GridEnvelope getGridRange()
                          throws IllegalStateException
Returns the grid range.

Returns:
The grid range.
Throws:
IllegalStateException - if the grid range has not yet been defined.

setGridRange

public void setGridRange(GridEnvelope gridRange)
Sets the grid range.

Parameters:
gridRange - The new grid range.

getEnvelope

public Envelope getEnvelope()
                     throws IllegalStateException
Returns the envelope. For performance reason, this method do not clone the envelope. So the returned object should not be modified.

Returns:
The envelope.
Throws:
IllegalStateException - if the envelope has not yet been defined.

setEnvelope

public void setEnvelope(Envelope envelope)
Sets the envelope. This method do not clone the specified envelope, so it should not be modified after this method has been invoked.

Parameters:
envelope - The new envelope.

getSwapXY

public boolean getSwapXY()
Returns true if the two first axis should be interchanged. If isAutomatic(SWAP_XY) returns true (which is the default), then this method make the following assumptions:

Returns:
true if the two first axis should be interchanged.

setSwapXY

public void setSwapXY(boolean swapXY)
Tells if the two first axis should be interchanged. Invoking this method force isAutomatic(SWAP_XY) to false.

Parameters:
swapXY - true if the two first axis should be interchanged.

getReverseAxis

public boolean[] getReverseAxis()
Returns which (if any) axis in user space (not grid space) should have their direction reversed. If isAutomatic(REVERSE_AXIS) returns true (which is the default), then this method make the following assumptions:

Returns:
The reversal state of each axis, or null if unspecified.

setReverseAxis

public void setReverseAxis(boolean[] reverse)
Set which (if any) axis in user space (not grid space) should have their direction reversed. Invoking this method force isAutomatic(REVERSE_AXIS) to false.

Parameters:
reverse - The reversal state of each axis. A null value means to reverse no axis.

reverseAxis

public void reverseAxis(int dimension)
Reverses a single axis in user space. Invoking this methods n time is equivalent to creating a boolean reverse array of the appropriate length, setting reverse[dimension] = true for the n axis to be reversed, and invoke setReverseAxis(reverse).

Parameters:
dimension - The index of the axis to reverse.

isAutomatic

public boolean isAutomatic(int mask)
Returns true if all properties designed by the specified bit mask will be computed automatically.

Parameters:
mask - Any combinaison of REVERSE_AXIS or SWAP_XY.
Returns:
true if all properties given by the mask will be computed automatically.

setAutomatic

public void setAutomatic(int mask)
Set all properties designed by the specified bit mask as automatic. Their value will be computed automatically by the corresponding methods (e.g. getReverseAxis(), getSwapXY()). By default, all properties are automatic.

Parameters:
mask - Any combinaison of REVERSE_AXIS or SWAP_XY.

createTransform

public MathTransform createTransform()
                              throws IllegalStateException
Creates a math transform using the information provided by setter methods.

Returns:
The math transform.
Throws:
IllegalStateException - if the grid range or the envelope were not set.

createAffineTransform

public AffineTransform createAffineTransform()
                                      throws IllegalStateException
Returns the math transform as a two-dimensional affine transform.

Returns:
The math transform as a two-dimensional affine transform.
Throws:
IllegalStateException - if the math transform is not of the appropriate type.


Copyright © 1996-2009 Geotools. All Rights Reserved.