Class 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.
    • Constructor Detail

      • GeographicImageInterpolator

        public GeographicImageInterpolator​(java.awt.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:
        java.lang.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

      • makeRootCell

        protected ImageInterpolator.Cell makeRootCell​(int m0,
                                                      int m1,
                                                      int n0,
                                                      int n1)
        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.
      • 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.
      • 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.