| java.lang.Object org.geotools.referencing.operation.builder.GridToEnvelopeMapper
GridToEnvelopeMapper | public class GridToEnvelopeMapper (Code) | | A helper class for building n-dimensional
mapping
to
. The affine transform will be computed automatically from the information
specified by the
GridToEnvelopeMapper.setGridRange setGridRange and
GridToEnvelopeMapper.setEnvelope 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:
Pixels coordinates (usually (x,y) integer values inside
the rectangle specified by the grid range) are expressed in some
known at compile
time. This is often the case. For example the CRS attached to
BufferedImage has always (
,
) axis, with the origin (0,0) in the upper
left corner, and row values increasing down.
"Real world" coordinates (inside the envelope) are expressed in arbitrary
horizontal coordinate reference system. Axis directions may be
(
,
),
or (
,
),
etc..
In such case (and assuming that the image's CRS has the same characteristics than the
BufferedImage 's CRS described above):
GridToEnvelopeMapper.setSwapXY swapXY shall be set to
true if the "real world" axis
order is (
,
)
instead of (
,
).
This axis swapping is necessary for mapping the (
,
) axis order associated to the
image CRS.
In addition, the "real world" axis directions shall be reversed (by invoking
(dimension) ) if their direction is
AxisDirection.WEST WEST (x axis) or
AxisDirection.NORTH NORTH (y axis), in order to get them oriented toward the
AxisDirection.EASTEAST or
AxisDirection.SOUTH SOUTH direction respectively. The later may seems
unatural, but it reflects the fact that row values are increasing down in an
BufferedImage 's CRS.
since: 2.3 version: $Id: GridToEnvelopeMapper.java 25778 2007-06-08 08:46:34Z desruisseaux $ author: Martin Desruisseaux |
Constructor Summary | |
public | GridToEnvelopeMapper() Creates a new instance of
GridToEnvelopeMapper . | public | GridToEnvelopeMapper(GridRange gridRange, Envelope userRange) Creates a new instance for the specified grid range and envelope.
Parameters: gridRange - The valid coordinate range of a grid coverage. Parameters: userRange - The corresponding coordinate range in user coordinate. |
Method Summary | |
public AffineTransform | createAffineTransform() Returns the math transform as a two-dimensional affine transform. | public MathTransform | createTransform() Creates a math transform using the information provided by setter methods. | public Envelope | getEnvelope() Returns the envelope. | public GridRange | getGridRange() Returns the grid range. | public PixelInCell | getGridType() Returns whatever the grid range maps
or
. | public boolean[] | getReverseAxis() Returns which (if any) axis in user space
(not grid space) should have their direction reversed. | public boolean | getSwapXY() Returns
true if the two first axis should be interchanged. | public boolean | isAutomatic(int mask) Returns
true if all properties designed by the specified bit mask
will be computed automatically. | public void | reverseAxis(int dimension) Reverses a single axis in user space. | public void | setAutomatic(int mask) Set all properties designed by the specified bit mask as automatic. | public void | setEnvelope(Envelope envelope) Set the envelope. | public void | setGridRange(GridRange gridRange) Set the grid range. | public void | setGridType(PixelInCell gridType) Set whatever the grid range maps
or
. | public void | setReverseAxis(boolean[] reverse) Set which (if any) axis in user space (not grid space)
should have their direction reversed. | public void | setSwapXY(boolean swapXY) Tells if the two first axis should be interchanged. | public static boolean | swapXY(CoordinateSystem cs) Applies heuristic rules in order to determine if the two first axis should be interchanged. |
GridToEnvelopeMapper | public GridToEnvelopeMapper()(Code) | | Creates a new instance of
GridToEnvelopeMapper .
|
GridToEnvelopeMapper | public GridToEnvelopeMapper(GridRange gridRange, Envelope userRange) throws MismatchedDimensionException(Code) | | Creates a new instance for the specified grid range and envelope.
Parameters: gridRange - The valid coordinate range of a grid coverage. Parameters: userRange - The corresponding coordinate range in user coordinate. This envelope mustcontains entirely all pixels, i.e. the envelope's upper left corner mustcoincide with the upper left corner of the first pixel and the envelope'slower right corner must coincide with the lower right corner of the lastpixel. throws: MismatchedDimensionException - if the grid range and the envelope doesn't haveconsistent dimensions. |
createTransform | public MathTransform createTransform() throws IllegalStateException(Code) | | Creates a math transform using the information provided by setter methods.
throws: IllegalStateException - if the grid range or the envelope were not set. |
getEnvelope | public Envelope getEnvelope() throws IllegalStateException(Code) | | Returns the envelope. For performance reason, this method do not
clone the envelope. So the returned object should not be modified.
throws: IllegalStateException - if the envelope has not yet been defined. |
getGridType | public PixelInCell getGridType()(Code) | | Returns whatever the grid range maps
or
.
|
getReverseAxis | public boolean[] getReverseAxis()(Code) | | Returns which (if any) axis in user space
(not grid space) should have their direction reversed. If
(
)
returns
true (which is the default), then this method make the
following assumptions:
- Axis should be reverted if needed in order to point toward their
"
" direction.
- An exception to the above rule is the second axis in grid space,
which is assumed to be the y axis on output device (usually
the screen). This axis is reversed again in order to match the bottom
direction often used with such devices.
The reversal state of each axis, or null if unspecified.For performance reason, this method do not clone the returned array. |
getSwapXY | public boolean getSwapXY()(Code) | | Returns
true if the two first axis should be interchanged. If
(
)
returns
true (which is the default), then this method make the
following assumptions:
Axis order in the grid range matches exactly axis order in the envelope, except
for the special case described in the next point. In other words, if axis order in
the underlying image is (column, row) (which is the case for
a majority of images), then the envelope should probably have a (longitude,
latitude) or (easting, northing) axis order.
An exception to the above rule applies for CRS using exactly the following axis
order: (
AxisDirection.NORTH NORTH |
AxisDirection.SOUTH SOUTH ,
AxisDirection.EAST EAST |
AxisDirection.WEST WEST ). An example
of such CRS is
EPSG:4326 . In this particular case, this method will
returns
true , thus suggesting to interchange the
(y,x) axis for such CRS.
|
reverseAxis | public void reverseAxis(int dimension)(Code) | | 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
(reverse) .
|
setEnvelope | public void setEnvelope(Envelope envelope)(Code) | | Set the envelope. This method do not clone the specified envelope,
so it should not be modified after this method has been invoked.
|
setGridRange | public void setGridRange(GridRange gridRange)(Code) | | Set the grid range.
|
setGridType | public void setGridType(PixelInCell gridType)(Code) | | Set whatever the grid range maps
or
.
|
setReverseAxis | public void setReverseAxis(boolean[] reverse)(Code) | | Set which (if any) axis in user space (not grid space)
should have their direction reversed. Invoking this method force
(
)
to
false .
Parameters: reverse - The reversal state of each axis. A null value means toreverse no axis. For performance reason, this method do not clone thesupplied array. |
setSwapXY | public void setSwapXY(boolean swapXY)(Code) | | Tells if the two first axis should be interchanged. Invoking this method force
(
) to
false .
|
swapXY | public static boolean swapXY(CoordinateSystem cs)(Code) | | Applies heuristic rules in order to determine if the two first axis should be interchanged.
|
|
|