com.bbn.openmap.layer.rpf
Class RpfFrameCacheHandler

java.lang.Object
  extended by com.bbn.openmap.util.cacheHandler.CacheHandler
      extended by com.bbn.openmap.layer.rpf.RpfFrameCacheHandler
All Implemented Interfaces:
RpfFrameProvider

public class RpfFrameCacheHandler
extends CacheHandler
implements RpfFrameProvider

The RpfFrameCacheHandler does everything involved with handling RAW RPF frames. If used locally, it can also deal with filling the role of RpfFrameProvider. You create one of these with the paths to the RPF directories, and then hand it to something that needs a RpfFrameProvider, or that acts like one.


Field Summary
protected  RpfColortable colortable
          Colortable used on the frames.
protected  boolean Dchum
          For future use...
static int FRAME_CACHE_SIZE
           
protected  boolean outlineChum
          Special outlining for chummed subframes
protected  RpfTocHandler[] tocs
          The Table of Contents files, parsed and ready to use.
protected  RpfViewAttributes viewAttributes
          View and display attributes for the data.
 
Fields inherited from class com.bbn.openmap.util.cacheHandler.CacheHandler
DEFAULT_MAX_CACHE_SIZE, logger, logicalClock, objs
 
Constructor Summary
RpfFrameCacheHandler(RpfTocHandler[] tocHandlers)
          When you pre-initialize the RpfTocHandlers before giving them to the RpfFrameCacheHandler.
RpfFrameCacheHandler(java.lang.String[] RpfPaths)
          The default constructor.
RpfFrameCacheHandler(java.lang.String[] RpfPaths, int max_size)
          The constructor to use if you want to modify the number of frames held in the cache..
 
Method Summary
protected  void checkColortable(RpfFrame frame, RpfFrameEntry frameEntry, RpfTocEntry entry, int tocNumber, int entryNumber)
          Take a bunch of stuff that has already been calculated, and then figure out if a new colortable is needed.
static RpfTocHandler[] createTocHandlers(java.lang.String[] RpfPaths)
          Set up the A.TOC files, to find out what coverage there is.
 java.lang.Object get(RpfFrameEntry rfe)
          A customized way to retrieve a frame from the cache, using a RpfFrameEntry.
 float getCalculatedCoverage(double ullat, double ullon, double lrlat, double lrlon, Projection p, java.lang.String chartSeries)
          Given an area and a two-letter chart series code, find the percentage of coverage on the map that that chart series can offer.
 java.util.Vector<RpfCoverageBox> getCatalogCoverage(double ullat, double ullon, double lrlat, double lrlon, Projection proj, java.lang.String chartSeries)
          RpfFrameProvider interface method.
 RpfColortable getColortable()
           
 java.util.Vector<RpfCoverageBox> getCoverage(double ullat, double ullon, double lrlat, double lrlon, Projection proj)
          Given a projection which describes the map (or area of interest), return the best RpfTocEntry, from all the A.TOC, that covers the area.
 RpfIndexedImageData getRawSubframeData(int tocNumber, int entryNumber, int x, int y)
           
 java.lang.String getSubframeAttributes(int tocNumber, int entryNumber, int x, int y)
          Given the indexes to a certain RpfTocEntry within a certain A.TOC, find the frame and return the attribute information.
 int[] getSubframeData(int tocNumber, int entryNumber, int x, int y)
          Given the indexes to a certain RpfTocEntry within a certain A.TOC, find the frame/subframe data, decompress it, and return image pixels.
 CacheObject load(java.lang.Object key)
          Called from get if the key doesn't exist, to "load" the new object into the cache before returning it.
 boolean needViewAttributeUpdates()
          RpfFrameProvider interface method.
 void resetCache()
          CacheHandler method.
 void resizeCache(int max_size)
          Cachehandler method.
static float scaleDifference(Projection proj, RpfCoverageBox box)
           
 void setColortable(RpfColortable colortable)
           
 void setViewAttributes(RpfViewAttributes va)
          Should only be set via the object it is sending frame data to.
 
Methods inherited from class com.bbn.openmap.util.cacheHandler.CacheHandler
clear, get, getCacheSize, listIterator, replaceLeastUsed, resetCache, searchCache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FRAME_CACHE_SIZE

public static final int FRAME_CACHE_SIZE
See Also:
Constant Field Values

colortable

protected RpfColortable colortable
Colortable used on the frames.


Dchum

protected boolean Dchum
For future use...


outlineChum

protected boolean outlineChum
Special outlining for chummed subframes


tocs

protected RpfTocHandler[] tocs
The Table of Contents files, parsed and ready to use.


viewAttributes

protected RpfViewAttributes viewAttributes
View and display attributes for the data.

Constructor Detail

RpfFrameCacheHandler

public RpfFrameCacheHandler(java.lang.String[] RpfPaths)
The default constructor.

Parameters:
RpfPaths - the directory paths to the RPF directories.

RpfFrameCacheHandler

public RpfFrameCacheHandler(java.lang.String[] RpfPaths,
                            int max_size)
The constructor to use if you want to modify the number of frames held in the cache..

Parameters:
RpfPaths - the directory paths to the RPF directories.

RpfFrameCacheHandler

public RpfFrameCacheHandler(RpfTocHandler[] tocHandlers)
When you pre-initialize the RpfTocHandlers before giving them to the RpfFrameCacheHandler.

Method Detail

needViewAttributeUpdates

public boolean needViewAttributeUpdates()
RpfFrameProvider interface method. If this is being used as a frame provider, it's local, right?

Specified by:
needViewAttributeUpdates in interface RpfFrameProvider

setViewAttributes

public void setViewAttributes(RpfViewAttributes va)
Should only be set via the object it is sending frame data to. Don't send in a null value, since this is assumed to be valid in other parts of the code.

Specified by:
setViewAttributes in interface RpfFrameProvider

getCatalogCoverage

public java.util.Vector<RpfCoverageBox> getCatalogCoverage(double ullat,
                                                           double ullon,
                                                           double lrlat,
                                                           double lrlon,
                                                           Projection proj,
                                                           java.lang.String chartSeries)
RpfFrameProvider interface method. Return all the RpfCoverageBoxes that fall in the area of interest.

Specified by:
getCatalogCoverage in interface RpfFrameProvider
Parameters:
ullat - NW latitude.
ullon - NW longitude.
lrlat - SE latitude.
lrlon - SE longitude
proj - projection to use for zone decisions.
chartSeries - RpfProductInfo.seriesCode entry.
Returns:
Vector of RpfCoverageBoxes.

getCalculatedCoverage

public float getCalculatedCoverage(double ullat,
                                   double ullon,
                                   double lrlat,
                                   double lrlon,
                                   Projection p,
                                   java.lang.String chartSeries)
Given an area and a two-letter chart series code, find the percentage of coverage on the map that that chart series can offer. If you want specific coverage information, use the getCatalogCoverage call. Don't send a chart series code of ANY, since that doesn't make sense.

Specified by:
getCalculatedCoverage in interface RpfFrameProvider
Parameters:
ullat - NW latitude.
ullon - NW longitude.
lrlat - SE latitude.
lrlon - SE longitude
p - projection to use for zone decisions.
chartSeries - RpfProductInfo.seriesCode entry.
Returns:
percentage of map covered by specific chart type.
See Also:
getCatalogCoverage(double, double, double, double, com.bbn.openmap.proj.Projection, java.lang.String)

getCoverage

public java.util.Vector<RpfCoverageBox> getCoverage(double ullat,
                                                    double ullon,
                                                    double lrlat,
                                                    double lrlon,
                                                    Projection proj)
Given a projection which describes the map (or area of interest), return the best RpfTocEntry, from all the A.TOC, that covers the area. RpfFrameProvider method. 1. Fixed bug that was preventing it from actually returning the best coverage box in the first position of the Vector. 2. Prevented the method from returning early when it found a box that claimed perfect coverage. This was causing problems in some areas, where boxes that claimed coverage didn't actually have it. This could be a data problem, so maybe we can add the early return back in in the future. 3. Changed < to <= below. 4. Iterates thru list returned by RpcTocHandler since the return type for getBestCoverageEntry changed from RpfTocEntry to List.

Specified by:
getCoverage in interface RpfFrameProvider
Parameters:
ullat - NW latitude.
ullon - NW longitude.
lrlat - SE latitude.
lrlon - SE longitude
proj - CADRG projection to use for zone decisions.
Returns:
Vector of RpfCoverageBoxes.

getSubframeAttributes

public java.lang.String getSubframeAttributes(int tocNumber,
                                              int entryNumber,
                                              int x,
                                              int y)
Given the indexes to a certain RpfTocEntry within a certain A.TOC, find the frame and return the attribute information. The tocNumber and entryNumber are given within the RpfCoverageBox received from a getCoverage call.

Specified by:
getSubframeAttributes in interface RpfFrameProvider
Parameters:
tocNumber - the toc id for a RpfTocHandler for a particular frame provider.
entryNumber - the RpfTocEntry id for a RpfTocHandler for a particular frame provider.
x - the horizontal subframe index, from the left side of a boundary rectangle of the entry.
y - the vertical subframe index, from the top side of a boundary rectangle of the entry.
Returns:
string.
See Also:
getCoverage(double, double, double, double, com.bbn.openmap.proj.Projection)

getSubframeData

public int[] getSubframeData(int tocNumber,
                             int entryNumber,
                             int x,
                             int y)
Given the indexes to a certain RpfTocEntry within a certain A.TOC, find the frame/subframe data, decompress it, and return image pixels. The tocNumber and entryNumber are given within the RpfCoverageBox received from a getCoverage call.

Specified by:
getSubframeData in interface RpfFrameProvider
Parameters:
tocNumber - the toc id for a RpfTocHandler for a particular frame provider.
entryNumber - the RpfTocEntry id for a RpfTocHandler for a particular frame provider.
x - the horizontal subframe index, from the left side of a boundary rectangle of the entry.
y - the vertical subframe index, from the top side of a boundary rectangle of the entry.
Returns:
integer pixel data.
See Also:
getCoverage(double, double, double, double, com.bbn.openmap.proj.Projection)

getRawSubframeData

public RpfIndexedImageData getRawSubframeData(int tocNumber,
                                              int entryNumber,
                                              int x,
                                              int y)
Specified by:
getRawSubframeData in interface RpfFrameProvider

checkColortable

protected void checkColortable(RpfFrame frame,
                               RpfFrameEntry frameEntry,
                               RpfTocEntry entry,
                               int tocNumber,
                               int entryNumber)
Take a bunch of stuff that has already been calculated, and then figure out if a new colortable is needed. If it is, load it up with info. Called from two different places, which is why it exists. It's been determined that, for each subframe, the colortable from it's parent frame should be used. Although RPF was designed and specified that the colortable should be constant across zones, that's not always the case.


createTocHandlers

public static RpfTocHandler[] createTocHandlers(java.lang.String[] RpfPaths)
Set up the A.TOC files, to find out what coverage there is.

Parameters:
RpfPaths - the paths to the RPF directories.
Returns:
the RpfTocHandlers for the A.TOCs.

get

public java.lang.Object get(RpfFrameEntry rfe)
A customized way to retrieve a frame from the cache, using a RpfFrameEntry. A RpfFrameEntry is the way to get the Dchum capability kicked off in the frame. If you don't care about Dchum, use the other get method. CacheHandler method.


load

public CacheObject load(java.lang.Object key)
Description copied from class: CacheHandler
Called from get if the key doesn't exist, to "load" the new object into the cache before returning it. This function should define how a CacheObject is created, or loaded from the file system, or whatever.

Specified by:
load in class CacheHandler

resizeCache

public void resizeCache(int max_size)
Cachehandler method.


resetCache

public void resetCache()
CacheHandler method. Need to clear memory, get gc moving, and ready for new objects

Overrides:
resetCache in class CacheHandler

scaleDifference

public static float scaleDifference(Projection proj,
                                    RpfCoverageBox box)

getColortable

public RpfColortable getColortable()

setColortable

public void setColortable(RpfColortable colortable)


Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details