NASA World Wind

gov.nasa.worldwind.util
Class GeographicImageInterpolator

java.lang.Object
  extended by gov.nasa.worldwind.util.ImageInterpolator
      extended by gov.nasa.worldwind.util.GeographicImageInterpolator

public class GeographicImageInterpolator
extends ImageInterpolator

GeographicImageInterpolator extends the functionality of ImageInterpolator to correctly map from geographic coordinates to image coordinates. Unlike its superclass, which works in Cartesian coordinates, GeographicImageInterpolator handles the singularities of geographic coordinates. For example, GeographicImageInterpolator can map images which cross the international dateline.


Nested Class Summary
protected static class GeographicImageInterpolator.GeographicCell
          GeographicCell extends ImageInterpolator.Cell to correctly handle image cells which have geographic coordinates.
 
Nested classes/interfaces inherited from class gov.nasa.worldwind.util.ImageInterpolator
ImageInterpolator.Cell, ImageInterpolator.ContainingCell
 
Field Summary
 
Fields inherited from class gov.nasa.worldwind.util.ImageInterpolator
cellSize, gridSize, kidCache, root, xs, ys
 
Constructor Summary
GeographicImageInterpolator(Dimension gridSize, float[] xs, float[] ys, int depth, int cellSize)
          Creates a new GeographicImageInterpolator, initializing this interpolator's internal image cell tree with root cell dimensions of (gridSize.width * gridSize.height) and with the specified depth.
 
Method Summary
protected  double[] computeBilinearCoordinates(float x, float y, ImageInterpolator.Cell cell)
          Overridden to correctly compute bilinear interpolation coordinates for image cells which cross the international dateline.
 Sector getSector()
          Returns the sector containing the image's geographic coordinates.
protected  ImageInterpolator.Cell makeRootCell(int m0, int m1, int n0, int n1)
          Overridden to create a GeographicImageInterpolator.GeographicCell.
 
Methods inherited from class gov.nasa.worldwind.util.ImageInterpolator
checkContainment, findContainingCell, findContainingCell, getFieldIndices
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeographicImageInterpolator

public GeographicImageInterpolator(Dimension gridSize,
                                   float[] xs,
                                   float[] ys,
                                   int depth,
                                   int cellSize)
Creates a new GeographicImageInterpolator, initializing this interpolator's internal image cell tree with root cell dimensions of (gridSize.width * gridSize.height) and with the specified depth.

Parameters:
gridSize - the image's dimensions.
xs - the x-coordinates of the image's pixels. Must contain at least gridSize.width * gridSize.height elements.
ys - the y-coordinates of the image's pixels. Must contain at least gridSize.width * gridSize.height elements.
depth - the initial depth of this interpolator's image cell tree.
cellSize - the size of a leaf cell in this interpolator's image cell tree, in pixels.
Throws:
IllegalStateException - if any of the the gridSize, x-coordinates, or y-coordinates are null, if either the x-coordinates or y-coordinates contain less than gridSize.width * gridSize.height elements, if the depth is less than zero, or if the cell size is less than one.
Method Detail

computeBilinearCoordinates

protected double[] computeBilinearCoordinates(float x,
                                              float y,
                                              ImageInterpolator.Cell cell)
Overridden to correctly compute bilinear interpolation coordinates for image cells which cross the international dateline. If the specified cell does not cross the dateline, this invokes the superclass' functionality. This returns null if the specified (x, y) point does not intersect the cell.

Overrides:
computeBilinearCoordinates in class ImageInterpolator
Parameters:
x - the x-component of the point to compute bilinear coordinate for.
y - the y-component of the point to compute bilinear coordinate for.
cell - the cell to compute bilinear coordinates for.
Returns:
the bilinear coordinates of the specified (x, y) point in the specified cell, or null if the point does not intersect the cell.

getSector

public Sector getSector()
Returns the sector containing the image's geographic coordinates. This returns a sector which spans the longitude range [-180, 180] if the image crosses the international dateline.

Returns:
the image's bounding sector.

makeRootCell

protected ImageInterpolator.Cell makeRootCell(int m0,
                                              int m1,
                                              int n0,
                                              int n1)
Overridden to create a GeographicImageInterpolator.GeographicCell.

Overrides:
makeRootCell in class ImageInterpolator
Parameters:
m0 - the root cell's left image coordinate.
m1 - the root cell's right image coordinate.
n0 - the root cell's bottom image coordinate.
n1 - the root cell's top image coordinate.
Returns:
a new GeographicCell with the specified image coordinates.

NASA World Wind