Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.ka2ddo.yaac.gui.rastermap
Class RasterMapEntry

    java.lang.Object
      org.ka2ddo.yaac.gui.rastermap.RasterMapEntry

All Implemented Interfaces:
  java.io.Serializable

    public class RasterMapEntry

extends java.lang.Object
implements java.io.Serializable

This class describes one raster map image file and the translation information needed to render it on the screen with the correct registration.

Because of the distortion caused by projecting a nearly-spherical Earth onto a flat map panel view, the image re-registration algorithm assumes a trapezoidal distortion as a good-enough approximation for rasters in units of meters (or other linear length), so the Java AffineTransform is insufficient to project raster map images into the map viewport. Instead, the following equations are used to map viewport pixel coordinates into raster map image pixel coordinates: `xi = x0 + x1 * xv + x2 * yv + x3 * xv * yv yi = y0 + y1 * yv + y2 * xv + y3 * yv * xv`

To compute the coefficients of the above equations, the least squares method is used to fit a series of pinpoints (associations between image pixels and geographical map coordinates) into the mapping between viewport pixel coordinates and image pixel coordinates.

If the raster image pixel step is in units of fractional degrees (for example, US National Weather Service radar maps), the full Mercator projection is needed to convert between degree-based image coordinates and linear pixel-based viewport coordinates.

`xi = x0 + x1 * xv yi = y0 + y1 * atan(sinh(y3 * yv + y2))` and, unlike the linear formula, the Mercator formula does not allow for any relative rotation of coordinate systems.

See Also:
  Serialized Form

Nested Class Summary
`static class` | `RasterMapEntry.PinPoint` This class contains one association between a pixel in the image and its latitude/longitude position on the planet.

Field Summary
`boolean` | `enabled` Flag indicating whether this particular raster overlay should be displayed in the map.
`int` | `height` Height of raster image in pixels.
`java.awt.image.BufferedImage` | `img` The image as a renderable object (assuming it can be loaded successfully).
`java.util.Date` | `imgCreationDate` Timestamp when the image was created (used to detect an updated image for automatic refreshing).
`boolean` | `isLinear` Indicates that the steps between pixels are in units of linear distance (meters), rather than in angular distance (degrees) across the approximately spherical Earth.
`java.lang.String` | `pathname` Pathname to where the image file is stored on this computer.
`java.util.ArrayList<RasterMapEntry.PinPoint>` | `pinpointList` The list of PinPoints matching image pixels with global lat/lon positions.
`int` | `transparency` The level of transparency fading to apply to the raster map (alpha component).
`java.awt.Color` | `transparentColor` The color of the raster image that is to be replaced with full transparency, so the map behind the raster image can still be seen.
`int` | `width` Width of raster image in pixels.

Constructor Summary
`RasterMapEntry()`

Method Summary
`void` | `computeTransform(Projection proj)`
`RasterMapEntry.PinPoint` | `getPinPointAt(int vx, int vy, Projection proj)` Find which (if any) PinPoint that the specified viewport coordinates are upon.
`java.awt.geom.Rectangle2D.Float` | `getViewportBounds2DOfImage(int vWidth, int vHeight, Mercator projection)` Get the coordinates within the viewport that intersect the raster image.
`void` | `read(java.io.DataInput dis)` Read a serialized dump of this object from an input stream for restoration.
`java.lang.String` | `toString()` Returns a string representation of the object.
`java.awt.geom.Point2D.Float` | `transformImageToViewport(float xi, float yi, java.awt.geom.Point2D.Float dstPt, Mercator projection)` Convert coordinates within an image into viewport coordinates.
`java.awt.geom.Point2D.Float` | `transformViewportToImage(float vx, float vy, java.awt.geom.Point2D.Float dstPt, Mercator projection)` Convert viewport coordinates into a position within the raster image.
`void` | `write(java.io.DataOutput dos)` Write a serialized dump of this object to an output stream for storage and later restoration.
`void` | `writeToPreferences(java.util.prefs.Preferences prefs)` Write a serialized dump of this object to Java Preferences.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### pathname

    public java.lang.String pathname

  Pathname to where the image file is stored on this computer.

### img

    public transient java.awt.image.BufferedImage img

  The image as a renderable object (assuming it can be loaded successfully).

### width

    public int width

  Width of raster image in pixels.

### height

    public int height

  Height of raster image in pixels.

### transparentColor

    public java.awt.Color transparentColor

  The color of the raster image that is to be replaced with full transparency, so the map behind the raster image can still be seen.

### transparency

    public int transparency

  The level of transparency fading to apply to the raster map (alpha component).

### enabled

    public boolean enabled

  Flag indicating whether this particular raster overlay should be displayed in the map.

### imgCreationDate

    public transient java.util.Date imgCreationDate

  Timestamp when the image was created (used to detect an updated image for automatic refreshing).

### isLinear

    public boolean isLinear

  Indicates that the steps between pixels are in units of linear distance (meters), rather than in angular distance (degrees) across the approximately spherical Earth. This affects the formula used for Mercator projection of the image into the viewport.

### pinpointList

    public final java.util.ArrayList<RasterMapEntry.PinPoint> pinpointList

  The list of PinPoints matching image pixels with global lat/lon positions.

Constructor Detail

### RasterMapEntry

    public RasterMapEntry()

Method Detail

### computeTransform

    public void computeTransform(Projection proj)

### transformViewportToImage

    public java.awt.geom.Point2D.Float transformViewportToImage(float vx,
                                                                float vy,
                                                                java.awt.geom.Point2D.Float dstPt,
                                                                Mercator projection)

  Convert viewport coordinates into a position within the raster image.

  Parameters:
    `vx` - X coordinate of point in the viewport
    `vy` - Y coordinate of point in the viewport
    `dstPt` - Point2D.Float object to contain the answer, or null to allocate a new Point2D.Float object
    `projection` - Mercator projection used to translate coordinates (only needed for degree-scaled rasters)
  Returns:
    raster image pixel coordinates corresponding to the viewport coordinates

### transformImageToViewport

    public java.awt.geom.Point2D.Float transformImageToViewport(float xi,
                                                                float yi,
                                                                java.awt.geom.Point2D.Float dstPt,
                                                                Mercator projection)

  Convert coordinates within an image into viewport coordinates.

  Parameters:
    `xi` - X coordinate of pixel within the raster image
    `yi` - Y coordinate of pixel within the raster image
    `dstPt` - Point2D.Float object to contain the answer, or null to allocate a new Point2D.Float object
    `projection` - Mercator projection used to translate coordinates (only needed for degree-scaled rasters)
  Returns:
    viewport coordinates for the specified position within the image

### getViewportBounds2DOfImage

    public java.awt.geom.Rectangle2D.Float getViewportBounds2DOfImage(int vWidth,
                                                                      int vHeight,
                                                                      Mercator projection)

  Get the coordinates within the viewport that intersect the raster image.

  Parameters:
    `vWidth` - viewport width in pixels
    `vHeight` - viewport height in pixels
    `projection` - Mercator projection used to translate coordinates (only needed for degree-scaled rasters)
  Returns:
    Rectangle2D of viewport coordinates bounding the image, or null if no intersection

### getPinPointAt

    public RasterMapEntry.PinPoint getPinPointAt(int vx,
                                                 int vy,
                                                 Projection proj)

  Find which (if any) PinPoint that the specified viewport coordinates are upon.

  Parameters:
    `vx` - viewport X coordinate
    `vy` - viewport Y coordinate
    `proj` - Projection of the current viewport
  Returns:
    PinPoint at the specified viewport coordinates, or null if no matching PinPoint found

### read

    public void read(java.io.DataInput dis)
              throws java.io.IOException

  Read a serialized dump of this object from an input stream for restoration.

  Parameters:
    `dis` - DataInput object to read the object data from
  Throws:
    `java.io.IOException` - if read fails for any reason

### write

    public void write(java.io.DataOutput dos)
               throws java.io.IOException

  Write a serialized dump of this object to an output stream for storage and later restoration.

  Parameters:
    `dos` - DataOutput object to write the RasterMapEntry to
  Throws:
    `java.io.IOException` - if write fails for any reason

### writeToPreferences

    public void writeToPreferences(java.util.prefs.Preferences prefs)

  Write a serialized dump of this object to Java Preferences.

  Parameters:
    `prefs` - Preferences object to store this object

### toString

    public java.lang.String toString()

  Returns a string representation of the object.

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    a string representation of the RasterMapEntry.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD