org.geotoolkit.metadata.iso.spatial
Class PixelTranslation

Object
  extended by Static
      extended by PixelTranslation
All Implemented Interfaces:
Serializable

public final class PixelTranslation
extends Static
implements Serializable

The translation to apply for different values of PixelOrientation or PixelInCell. The translation are returned by a call to one of the static getPixelTranslation(...) methods, where the argument is either a PixelOrientation for the two-dimensional case, or a PixelInCell for the n-dimensional case.

This class provides also a few translate(...) convenience methods, which apply the pixel translation on a given math transform.

Since:
2.5
Version:
3.00
Author:
Martin Desruisseaux (IRD)
See Also:
GeneralGridGeometry, GridGeometry2D, Serialized Form
Module:
referencing/geotk-referencing (download)    View source code for this class

Field Summary
 double dx
          The translation among the x axis relative to pixel center.
 double dy
          The translation among the y axis relative to pixel center.
 PixelOrientation orientation
          The pixel orientation for this translation.
 
Method Summary
static PixelOrientation getPixelOrientation(double dx, double dy)
          Returns the pixel orientation for the given offset, or null if none.
static PixelOrientation getPixelOrientation(PixelInCell anchor)
          Returns the pixel orientation for the given PixelInCell code.
static double getPixelTranslation(PixelInCell anchor)
          Returns the position relative to the pixel center.
static PixelTranslation getPixelTranslation(PixelOrientation anchor)
          Returns the specified position relative to the pixel center.
 String toString()
          Returns a string representation of this pixel translation.
static MathTransform translate(MathTransform gridToCRS, PixelInCell current, PixelInCell expected)
          Translates the specified math transform according the specified pixel orientations.
static MathTransform translate(MathTransform gridToCRS, PixelOrientation current, PixelOrientation expected, int xDimension, int yDimension)
          Translates the specified math transform according the specified pixel orientations.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

orientation

public final PixelOrientation orientation
The pixel orientation for this translation.


dx

public final double dx
The translation among the x axis relative to pixel center. The value is typically in the [-0.5 .. +0.5] range.


dy

public final double dy
The translation among the y axis relative to pixel center. The value is typically in the [-0.5 .. +0.5] range.

Method Detail

getPixelOrientation

public static PixelOrientation getPixelOrientation(PixelInCell anchor)
                                            throws IllegalArgumentException
Returns the pixel orientation for the given PixelInCell code.

Parameters:
anchor - The PixelInCell code, or null.
Returns:
The corresponding pixel orientation, or null if the argument was null.
Throws:
IllegalArgumentException - if the given code is unknown.

getPixelTranslation

public static double getPixelTranslation(PixelInCell anchor)
Returns the position relative to the pixel center. This method returns a value from the following table:

Pixel in celloffset
CELL_CENTER 0.0
CELL_CORNER-0.5

This method is typically used for n-dimensional grids, where the number of dimension is unknown.

Parameters:
anchor - The "pixel in cell" value.
Returns:
The translation for the given "pixel in cell" value.

getPixelTranslation

public static PixelTranslation getPixelTranslation(PixelOrientation anchor)
                                            throws IllegalArgumentException
Returns the specified position relative to the pixel center. This method returns a value from the following table:

Pixel orientation x y
CENTER 0.0 0.0
UPPER_LEFT -0.5-0.5
UPPER_RIGHT+0.5-0.5
LOWER_LEFT -0.5+0.5
LOWER_RIGHT+0.5+0.5

This method can be used for grid restricted to 2 dimensions.

Parameters:
anchor - The pixel orientation.
Returns:
The position relative to the pixel center.
Throws:
IllegalArgumentException - if the specified orientation is unknown.

getPixelOrientation

public static PixelOrientation getPixelOrientation(double dx,
                                                   double dy)
Returns the pixel orientation for the given offset, or null if none. This is the reverse of getPixelTranslation(PixelOrientation).

Parameters:
dx - The translation along x axis.
dy - The translation along y axis.
Returns:
The pixel orientation of the given values, or null if none.

translate

public static MathTransform translate(MathTransform gridToCRS,
                                      PixelInCell current,
                                      PixelInCell expected)
Translates the specified math transform according the specified pixel orientations.

Parameters:
gridToCRS - A math transform from pixel coordinates to any CRS.
current - The pixel orientation of the given gridToCRS transform.
expected - The pixel orientation of the desired transform.
Returns:
The translation from current to expected.

translate

public static MathTransform translate(MathTransform gridToCRS,
                                      PixelOrientation current,
                                      PixelOrientation expected,
                                      int xDimension,
                                      int yDimension)
Translates the specified math transform according the specified pixel orientations.

Parameters:
gridToCRS - A math transform from pixel coordinates to any CRS.
current - The pixel orientation of the given gridToCRS transform.
expected - The pixel orientation of the desired transform.
xDimension - The dimension of x coordinates (pixel columns). Often 0.
yDimension - The dimension of y coordinates (pixel rows). Often 1.
Returns:
The translation from current to expected.

toString

public String toString()
Returns a string representation of this pixel translation.

Overrides:
toString in class Object


Copyright © 2009-2011 Geotoolkit.org. All Rights Reserved.