Class RasterMapEntry
- All Implemented Interfaces:
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.- Author:
- Andrew Pavlin, KA2DDO
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
This class contains one association between a pixel in the image and its latitude/longitude position on the planet. -
Field Summary
Modifier and TypeFieldDescriptionboolean
Flag indicating whether this particular raster overlay should be displayed in the map.int
Height of raster image in pixels.The image as a renderable object (assuming it can be loaded successfully).Timestamp when the image was created (used to detect an updated image for automatic refreshing).boolean
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
Indicates whether local storage is available for image so it can be quickly reloaded.Pathname to where the image file is stored on this computer.boolean
Flag indicating whether this particular raster overlay should be persisted over YAAC restarts.final ArrayList<RasterMapEntry.PinPoint>
The list of PinPoints matching image pixels with global lat/lon positions.int
The level of transparency fading to apply to the raster map (alpha component).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 of raster image in pixels. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetPinPointAt
(int vx, int vy, com.bbn.openmap.proj.Projection proj) Find which (if any) PinPoint that the specified viewport coordinates are upon.getViewportBounds2DOfImage
(int vWidth, int vHeight, com.bbn.openmap.proj.Mercator projection) Get the coordinates within the viewport that intersect the raster image.void
Read a serialized dump of this object from an input stream for restoration.void
removePersistence
(Preferences prefs) Remove this RasterMapEntry from the Preferences persistence cache.toString()
Returns a string representation of the object.transformImageToViewport
(float xi, float yi, Point2D.Float dstPt, com.bbn.openmap.proj.Mercator projection) Convert coordinates within an image into viewport coordinates.final Point2D.Float
transformViewportToImage
(float vx, float vy, Point2D.Float dstPt, com.bbn.openmap.proj.Mercator projection) Convert viewport coordinates into a position within the raster image.void
write
(DataOutput dos) Write a serialized dump of this object to an output stream for storage and later restoration.void
writeToPreferences
(Preferences prefs) Write a serialized dump of this object to Java Preferences.
-
Field Details
-
pathname
Pathname to where the image file is stored on this computer. -
img
The image as a renderable object (assuming it can be loaded successfully). -
width
public int widthWidth of raster image in pixels. -
height
public int heightHeight of raster image in pixels. -
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 transparencyThe level of transparency fading to apply to the raster map (alpha component). -
enabled
public boolean enabledFlag indicating whether this particular raster overlay should be displayed in the map. -
persist
public boolean persistFlag indicating whether this particular raster overlay should be persisted over YAAC restarts. -
imgCreationDate
Timestamp when the image was created (used to detect an updated image for automatic refreshing). -
isLinear
public boolean isLinearIndicates 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. -
keepImg
public boolean keepImgIndicates whether local storage is available for image so it can be quickly reloaded. Should be true for network-provided images that would be expensive to reload. -
pinpointList
The list of PinPoints matching image pixels with global lat/lon positions.
-
-
Constructor Details
-
RasterMapEntry
public RasterMapEntry()
-
-
Method Details
-
transformViewportToImage
public final Point2D.Float transformViewportToImage(float vx, float vy, Point2D.Float dstPt, com.bbn.openmap.proj.Mercator projection) Convert viewport coordinates into a position within the raster image.- Parameters:
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)- Returns:
- raster image pixel coordinates corresponding to the viewport coordinates
-
transformImageToViewport
public Point2D.Float transformImageToViewport(float xi, float yi, Point2D.Float dstPt, com.bbn.openmap.proj.Mercator projection) Convert coordinates within an image into viewport coordinates.- Parameters:
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)- Returns:
- viewport coordinates for the specified position within the image
-
getViewportBounds2DOfImage
public Rectangle2D.Float getViewportBounds2DOfImage(int vWidth, int vHeight, com.bbn.openmap.proj.Mercator projection) Get the coordinates within the viewport that intersect the raster image.- Parameters:
vWidth
- viewport width in pixelsvHeight
- viewport height in pixelsprojection
- 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
Find which (if any) PinPoint that the specified viewport coordinates are upon.- Parameters:
vx
- viewport X coordinatevy
- viewport Y coordinateproj
- Projection of the current viewport- Returns:
- PinPoint at the specified viewport coordinates, or null if no matching PinPoint found
-
read
Read a serialized dump of this object from an input stream for restoration.- Parameters:
dis
- DataInput object to read the object data from- Throws:
IOException
- if read fails for any reason
-
write
Write a serialized dump of this object to an output stream for storage and later restoration. Note this does not write the persist flag, as this code wouldn't be getting called if the record wasn't supposed to be persisted.- Parameters:
dos
- DataOutput object to write the RasterMapEntry to- Throws:
IOException
- if write fails for any reason
-
writeToPreferences
Write a serialized dump of this object to Java Preferences.- Parameters:
prefs
- Preferences object to store this object
-
removePersistence
Remove this RasterMapEntry from the Preferences persistence cache.- Parameters:
prefs
- Preferences object supposedly containing an entry for this RasterMapEntry
-
toString
Returns a string representation of the object.
-