org.geotools.gc
Class LocalizationGrid

java.lang.Object
  extended byorg.geotools.gc.LocalizationGrid

Deprecated. Replaced by LocalizationGrid.

public class LocalizationGrid
extends java.lang.Object

A factory for MathTransform2D backed by a grid of localization. A grid of localization is a two-dimensional array (or a matrix) of coordinate points. The grid size is width × height. Input coordinates are (i,j) index in the grid, where i must be in the range [0..width-1] and j in the range [0..height-1] inclusive. Output coordinates are the values stored in the grid of localization at the specified index.

The LocalizationGrid class is usefull when the "grid to coordinate system" transform for a coverage is not some kind of global mathematical relationship like an affine transform. Instead, the "real world" coordinates are explicitly specified for each pixels. If the real world coordinates are know only for some pixels at a fixed interval, then a transformation can be constructed by the concatenation of an affine transform with a grid of localization. After a LocalizationGrid object has been fully constructed (i.e. real world coordinates have been specified for all grid cells), a transformation from grid coordinates to "real world" coordinates can be obtained with the getMathTransform() method. If this transformation is close enough to an affine transform, then an instance of AffineTransform is returned. Otherwise, a transform backed by the localization grid is returned.

The example below goes through the steps of constructing a coordinate system for a grid coverage from its grid of localization. This example assumes that the "real world" coordinates are longitudes and latitudes on the WGS84 ellipsoid.

 //
 // Constructs a localization grid of size 10×10.
 //
 LocalizationGrid grid = new LocalizationGrid(10,10);
 for (int j=0; j<10; j++) {
     for (int i=0; i<10; i++) {
         double x = ...; // Set longitude here
         double y = ...; // Set latitude here
         grid.setLocalizationPoint(i,j,x,y);
     }
 }
 //
 // Constructs the grid coordinate system.
 //
 CoordinateSystem realCS = GeographicCoordinateSystem.WGS84;
 CoordinateSystem gridCS = new FittedCoordinateSystem("The grid CS", realCS, grid.getMathTransform(),
                               new AxisInfo[] {
                                   AxisInfo.X,
                                   AxisInfo.Y});
 //
 // Constructs the grid coverage using the grid coordinate system (not the "real world"
 // one). It is usefull to display the coverage in its native CS before we resample it.
 // Note that if the grid of localization does not define the geographic location  for
 // all pixels, then we need to specify some affine transform in place of the IDENTITY
 // argument. For example if the grid of localization defines the location of 1 pixel,
 // then skip 3, then defines the location of 1 pixel, etc., then the affine transform
 // should be AffineTransform.getScaleInstance(0.25, 0.25).
 //
 GridCoverage coverage;
 coverage = new GridCoverage("The grid coverage", theRaster, gridCS,
                             MathTransform2D.IDENTITY, ...);
 FrameFactory.show(coverage);
 //
 // Project the coverage from its current 'gridCS' to the 'realCS'. If the grid of
 // localization was built from the orbit of some satellite, then the projected
 // coverage will tpypically have a curved aspect.
 //
 GridCoverageProcessor processor = GridCoverageProcessor.getDefault();
 coverage = processor.doOperation("Resample",         coverage,
                                  "CoordinateSystem", realCS);
 FrameFactory.show(coverage);
 

Version:
$Id: LocalizationGrid.java 11002 2005-02-02 03:45:45Z desruisseaux $
Author:
Remi Eve, Martin Desruisseaux
See Also:
FittedCoordinateSystem

Constructor Summary
LocalizationGrid(int width, int height)
          Deprecated. Construct an initially empty localization grid.
 
Method Summary
 java.awt.geom.AffineTransform getAffineTransform()
          Deprecated. Returns an affine transform for the whole grid.
 java.awt.geom.Point2D getLocalizationPoint(java.awt.Point source)
          Deprecated. Returns the "real world" coordinates for the specified grid coordinates.
 MathTransform2D getMathTransform()
          Deprecated. Returns a math transform from grid to "real world" coordinates.
 java.awt.Dimension getSize()
          Deprecated. Returns the grid size.
 boolean isMonotonic(boolean strict)
          Deprecated. Returns true if all coordinates in this grid are increasing or decreasing.
 boolean isNaN()
          Deprecated. Returns true if this localization grid contains at least one NaN value.
 void removeSingularities()
          Deprecated. Make sure that the grid doesn't contains identical consecutive ordinates.
 void setLocalizationPoint(int sourceX, int sourceY, double targetX, double targetY)
          Deprecated. Set a point in this localization grid.
 void setLocalizationPoint(java.awt.Point source, java.awt.geom.Point2D target)
          Deprecated. Set a point in this localization grid.
 void transform(java.awt.geom.AffineTransform transform, java.awt.Rectangle region)
          Deprecated. Apply a transformation to every "real world" coordinate points in a sub-region of this grid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalizationGrid

public LocalizationGrid(int width,
                        int height)
Deprecated. 
Construct an initially empty localization grid. All "real worlds" coordinates are initially set to (NaN,NaN).

Parameters:
width - Number of grid's columns.
height - Number of grid's rows.
Method Detail

getSize

public java.awt.Dimension getSize()
Deprecated. 
Returns the grid size. Grid coordinates are always in the range xinput = [0..width-1] and yinput = [0..height-1] inclusive.


getLocalizationPoint

public java.awt.geom.Point2D getLocalizationPoint(java.awt.Point source)
Deprecated. 
Returns the "real world" coordinates for the specified grid coordinates. Grid coordinates must be integers inside this grid's range. For general transformations involving non-integer grid coordinates and/or coordinates outside this grid's range, use getMathTransform() instead.

Parameters:
source - The point in grid coordinates.
Returns:
target The corresponding point in "real world" coordinates.
Throws:
java.lang.IndexOutOfBoundsException - If the source point is not in this grid's range.

setLocalizationPoint

public void setLocalizationPoint(java.awt.Point source,
                                 java.awt.geom.Point2D target)
Deprecated. 
Set a point in this localization grid.

Parameters:
source - The point in grid coordinates.
target - The corresponding point in "real world" coordinates.
Throws:
java.lang.IndexOutOfBoundsException - If the source point is not in this grid's range.

setLocalizationPoint

public void setLocalizationPoint(int sourceX,
                                 int sourceY,
                                 double targetX,
                                 double targetY)
Deprecated. 
Set a point in this localization grid.

Parameters:
sourceX - x coordinates in grid coordinates, in the range [0..width-1] inclusive.
sourceY - y coordinates in grid coordinates. in the range [0..height-1] inclusive.
targetX - x coordinates in "real world" coordinates.
targetY - y coordinates in "real world" coordinates.
Throws:
java.lang.IndexOutOfBoundsException - If the source coordinates is not in this grid's range.

transform

public void transform(java.awt.geom.AffineTransform transform,
                      java.awt.Rectangle region)
Deprecated. 
Apply a transformation to every "real world" coordinate points in a sub-region of this grid.

Parameters:
transform - The transform to apply.
region - The bounding rectangle (in grid coordinate) for region where to apply the transform, or null to transform the whole grid.

isNaN

public boolean isNaN()
Deprecated. 
Returns true if this localization grid contains at least one NaN value.


isMonotonic

public boolean isMonotonic(boolean strict)
Deprecated. 
Returns true if all coordinates in this grid are increasing or decreasing. More specifically, returns true if the following conditions are meets: x and y coordinates are tested independently.

Parameters:
strict - true to require strictly increasing or decreasing order, or false to accept values that are equals.
Returns:
true if coordinates are increasing or decreasing in the same direction for all rows and columns.

removeSingularities

public void removeSingularities()
Deprecated. 
Make sure that the grid doesn't contains identical consecutive ordinates. If many consecutives ordinates are found to be identical in a row or in a column, then the first one is left inchanged and the other ones are linearly interpolated.


getAffineTransform

public java.awt.geom.AffineTransform getAffineTransform()
Deprecated. 
Returns an affine transform for the whole grid. This transform is only an approximation for this localization grid. It is fitted (like "curve fitting") to grid data using the "least squares" method.

Returns:
A global affine transform as an approximation for the whole localization grid.

getMathTransform

public MathTransform2D getMathTransform()
Deprecated. 
Returns a math transform from grid to "real world" coordinates.

Returns:
A transform from grid to real world coordinates.


Copyright © GeoTools. All Rights Reserved.