|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectGridToEnvelopeMapper
public class GridToEnvelopeMapper
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:
Pixels coordinates (usually (x,y) integer values inside
the rectangle specified by the grid range) are expressed in some
coordinate reference system known at compile
time. This is often the case. For example the CRS attached to BufferedImage
has always (column,
row) 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 (North, West), or (East, North), etc..
In such case (and assuming that the image's CRS has the same characteristics than the
BufferedImage
's CRS described above):
swapXY
shall be set to true
if the "real world" axis
order is (North, East)
instead of (East, North).
This axis swapping is necessary for mapping the (column, row) axis order associated to the
image CRS.
In addition, the "real world" axis directions shall be reversed (by invoking
reverseAxis(dimension)
) if their direction is
WEST
(x axis) or NORTH
(y axis), in order to get them oriented toward the EAST
or SOUTH
direction respectively. The later may seems
unatural, but it reflects the fact that row values are increasing down in an
BufferedImage
's CRS.
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 |
---|
public static final int SWAP_XY
swapXY
property.
isAutomatic(int)
,
setAutomatic(int)
,
Constant Field Valuespublic static final int REVERSE_AXIS
reverseAxis
property.
isAutomatic(int)
,
setAutomatic(int)
,
Constant Field ValuesConstructor Detail |
---|
public GridToEnvelopeMapper()
GridToEnvelopeMapper
.
public GridToEnvelopeMapper(GridEnvelope gridRange, Envelope userRange) throws MismatchedDimensionException
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.
MismatchedDimensionException
- if the grid range and the envelope doesn't have
consistent dimensions.Method Detail |
---|
@Deprecated public PixelInCell getGridType()
getPixelAnchor()
.
public PixelInCell getPixelAnchor()
@Deprecated public void setGridType(PixelInCell anchor)
setPixelAnchor(org.opengis.referencing.datum.PixelInCell)
.
public void setPixelAnchor(PixelInCell anchor)
anchor
- Whatever the grid range maps pixel center or corner.public GridEnvelope getGridRange() throws IllegalStateException
IllegalStateException
- if the grid range has not yet been defined.public void setGridRange(GridEnvelope gridRange)
gridRange
- The new grid range.public Envelope getEnvelope() throws IllegalStateException
IllegalStateException
- if the envelope has not yet been defined.public void setEnvelope(Envelope envelope)
envelope
- The new envelope.public boolean getSwapXY()
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:
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: (NORTH
|SOUTH
,
EAST
|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.
true
if the two first axis should be interchanged.public void setSwapXY(boolean swapXY)
isAutomatic(SWAP_XY)
to
false
.
swapXY
- true
if the two first axis should be interchanged.public boolean[] getReverseAxis()
isAutomatic(REVERSE_AXIS)
returns true
(which is the default), then this method make the
following assumptions:
null
if unspecified.public void setReverseAxis(boolean[] reverse)
isAutomatic(REVERSE_AXIS)
to false
.
reverse
- The reversal state of each axis. A null
value means to
reverse no axis.public void reverseAxis(int dimension)
reverse
array of the appropriate length,
setting reverse[dimension] = true
for the n axis to be reversed,
and invoke setReverseAxis(reverse)
.
dimension
- The index of the axis to reverse.public boolean isAutomatic(int mask)
true
if all properties designed by the specified bit mask
will be computed automatically.
mask
- Any combinaison of REVERSE_AXIS
or SWAP_XY
.
true
if all properties given by the mask will be computed automatically.public void setAutomatic(int mask)
getReverseAxis()
, getSwapXY()
). By default, all properties
are automatic.
mask
- Any combinaison of REVERSE_AXIS
or SWAP_XY
.public MathTransform createTransform() throws IllegalStateException
IllegalStateException
- if the grid range or the envelope were not set.public AffineTransform createAffineTransform() throws IllegalStateException
IllegalStateException
- if the math transform is not of the appropriate type.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |