public class RasterMapEntry
extends java.lang.Object
implements java.io.Serializable
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.Modifier and Type | Class and Description |
---|---|
static class |
RasterMapEntry.PinPoint
This class contains one association between a pixel in the image and its latitude/longitude
position on the planet.
|
Modifier and Type | Field and Description |
---|---|
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.
|
boolean |
keepImg
Indicates whether local storage is available for image so it can be quickly
reloaded.
|
java.lang.String |
pathname
Pathname to where the image file is stored on this computer.
|
boolean |
persist
Flag indicating whether this particular raster overlay should be persisted over YAAC restarts.
|
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 and Description |
---|
RasterMapEntry() |
Modifier and Type | Method and Description |
---|---|
RasterMapEntry.PinPoint |
getPinPointAt(int vx,
int vy,
com.bbn.openmap.proj.Projection proj)
Find which (if any) PinPoint that the specified viewport coordinates are upon.
|
java.awt.geom.Rectangle2D.Float |
getViewportBounds2DOfImage(int vWidth,
int vHeight,
com.bbn.openmap.proj.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.
|
void |
removePersistence(java.util.prefs.Preferences prefs)
Remove this RasterMapEntry from the Preferences persistence cache.
|
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,
com.bbn.openmap.proj.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,
com.bbn.openmap.proj.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.
|
public java.lang.String pathname
public transient java.awt.image.BufferedImage img
public int width
public int height
public java.awt.Color transparentColor
public int transparency
public boolean enabled
public boolean persist
public transient java.util.Date imgCreationDate
public boolean isLinear
public boolean keepImg
public final java.util.ArrayList<RasterMapEntry.PinPoint> pinpointList
public final java.awt.geom.Point2D.Float transformViewportToImage(float vx, float vy, java.awt.geom.Point2D.Float dstPt, com.bbn.openmap.proj.Mercator projection)
vx
- X coordinate of point in the viewportvy
- Y coordinate of point in the viewportdstPt
- Point2D.Float object to contain the answer, or null to allocate a new Point2D.Float objectprojection
- Mercator projection used to translate coordinates (only needed for degree-scaled rasters)public java.awt.geom.Point2D.Float transformImageToViewport(float xi, float yi, java.awt.geom.Point2D.Float dstPt, com.bbn.openmap.proj.Mercator projection)
xi
- X coordinate of pixel within the raster imageyi
- Y coordinate of pixel within the raster imagedstPt
- Point2D.Float object to contain the answer, or null to allocate a new Point2D.Float objectprojection
- Mercator projection used to translate coordinates (only needed for degree-scaled rasters)public java.awt.geom.Rectangle2D.Float getViewportBounds2DOfImage(int vWidth, int vHeight, com.bbn.openmap.proj.Mercator projection)
vWidth
- viewport width in pixelsvHeight
- viewport height in pixelsprojection
- Mercator projection used to translate coordinates (only needed for degree-scaled rasters)public RasterMapEntry.PinPoint getPinPointAt(int vx, int vy, com.bbn.openmap.proj.Projection proj)
vx
- viewport X coordinatevy
- viewport Y coordinateproj
- Projection of the current viewportpublic void read(java.io.DataInput dis) throws java.io.IOException
dis
- DataInput object to read the object data fromjava.io.IOException
- if read fails for any reasonpublic void write(java.io.DataOutput dos) throws java.io.IOException
dos
- DataOutput object to write the RasterMapEntry tojava.io.IOException
- if write fails for any reasonpublic void writeToPreferences(java.util.prefs.Preferences prefs)
prefs
- Preferences object to store this objectpublic void removePersistence(java.util.prefs.Preferences prefs)
prefs
- Preferences object supposedly containing an entry for this RasterMapEntrypublic java.lang.String toString()
toString
in class java.lang.Object