com.bbn.openmap.dataAccess.dted
Class DTEDFrameCache

java.lang.Object
  extended by com.bbn.openmap.util.cacheHandler.CacheHandler
      extended by com.bbn.openmap.dataAccess.dted.DTEDFrameCache
All Implemented Interfaces:
PropertyConsumer

public class DTEDFrameCache
extends CacheHandler
implements PropertyConsumer

The DTEDFrameCache is an object that retrieves DTED paths, frames or elevation values, given a latitude, longitude and dted level. It maintains a collection of the frames it has already used for quicker access later. The size of the cache is determined by startup settings.

The DTEDFrameCache can be placed in the MapHandler, where other objects can share it in order to all use the same DTED data. It can be configured with properties:

 
 
         frameCache.cacheSize=40
         frameCache.directoryHandlers=dteddir1 dteddir2
         frameCache.dteddir1.translator=com.bbn.openmap.dataAccess.dted.StandardDTEDNameTranslator
         frameCache.dteddir1.path=/data/dted
         frameCache.dteddir2.translator=com.bbn.openmap.dataAccess.dted.StandardDTEDNameTranslator
         frameCache.dteddir2.path=/data/dted
 
 
 
A DTEDDirectoryHandler needs to be specified for each DTED directory you want to use. If a translator isn't specified in the properties for a directory handler, the StandardDTEDNameTranslator will be used. If you have DTED data that doesn't conform to the naming conventions specified in the Military Standard, you can use a different DTEDNameTranslator instead for your particular directory handler.


Field Summary
 int DEFAULT_CACHE_SIZE
           
protected  java.util.Vector directories
           
static java.lang.String DTEDDirectoryHandlerProperty
           
static java.lang.String DTEDFrameCacheSizeProperty
           
protected  int highestResLevel
           
static int NO_DATA
          The elevation value returned if there is no data at a lat/lon (-32767).
protected  java.lang.String propertyPrefix
           
 
Fields inherited from class com.bbn.openmap.util.cacheHandler.CacheHandler
DEFAULT_MAX_CACHE_SIZE, logger, logicalClock, objs
 
Fields inherited from interface com.bbn.openmap.PropertyConsumer
EditorProperty, initPropertiesProperty, LabelEditorProperty, ScopedEditorProperty
 
Constructor Summary
DTEDFrameCache()
           
DTEDFrameCache(int max_size)
          Create the cache with paths to search for frames, and the maximum number of frames to keep on hand.
 
Method Summary
 void addDTEDDirectoryHandler(DTEDDirectoryHandler handler)
          Add a DTED DirectoryHandler to be used for the DTEDFrameCache.
 java.lang.String findFileName(double lat, double lon, int level)
          A utility to find the path to a dted file, given a lat, lon and a dted level.
 DTEDFrame get(double lat, double lon, int level)
          Return The DTED Frame, Given A Lat, Lon And DTED Level.
 java.util.Vector getDTEDDirectoryHandlers()
          Get the Vector of DTEDDirectoryHandlers used by the DTEDFrameCache.
 int getElevation(float lat, float lon)
          Return the elevation of a lat/lon point, in meters.
 int getElevation(float lat, float lon, int level)
          Return the elevation of a lat/lon point, in meters.
 short[][] getElevations(EqualArc proj, int dtedLevel)
          Return the two-dimensional matrix of elevation posts (heights) representing coverage of a given geographical rectangle.
 short[][] getElevations(float ullat, float ullon, float lrlat, float lrlon, int dtedLevel)
          Return the two-dimensional matrix of elevation posts (heights) representing coverage of a given geographical rectangle.
protected  short[][] getElevations(float ullat, float ullon, float lrlat, float lrlon, int dtedLevel, DTEDFrame refFrame)
          Return the two-dimensional matrix of elevation posts (heights) representing coverage of a given geographical rectangle.
 int getHighestResLevel()
           
 java.util.Properties getProperties(java.util.Properties props)
          PropertyConsumer method.
 java.util.Properties getPropertyInfo(java.util.Properties props)
          PropertyConsumer method.
 java.lang.String getPropertyPrefix()
          PropertyConsumer method.
 CacheObject load(java.lang.Object key)
          Load a dted frame into the cache, based on the path of the frame as a key.
static void main(java.lang.String[] args)
           
 void removeDTEDDirectoryHandler(DTEDDirectoryHandler handler)
          Remove a DTED DirectoryHandler from the list used for the DTEDFrameCache.
 void resizeCache(int max_size)
          This version of resizeCache is for screen size changes, where the number of frames kept on hand in the cache must change, but the images themselves don't have to because the pixel/posting spacing hasn't changed in the projection.
 void setDTEDDirectoryHandlers(java.util.Vector handlers)
          Set the Vector of DTEDDirectoryHandlers used by the DTEDFrameCache.
 void setHighestResLevel(int highestResLevel)
           
 void setProperties(java.util.Properties props)
          PropertyConsumer method.
 void setProperties(java.lang.String prefix, java.util.Properties props)
          PropertyConsumer method.
 void setPropertyPrefix(java.lang.String prefix)
          PropertyConsumer method.
 
Methods inherited from class com.bbn.openmap.util.cacheHandler.CacheHandler
clear, get, getCacheSize, listIterator, replaceLeastUsed, resetCache, resetCache, searchCache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_DATA

public static final int NO_DATA
The elevation value returned if there is no data at a lat/lon (-32767).

See Also:
Constant Field Values

DTEDDirectoryHandlerProperty

public static final java.lang.String DTEDDirectoryHandlerProperty
See Also:
Constant Field Values

DTEDFrameCacheSizeProperty

public static final java.lang.String DTEDFrameCacheSizeProperty
See Also:
Constant Field Values

DEFAULT_CACHE_SIZE

public int DEFAULT_CACHE_SIZE

propertyPrefix

protected java.lang.String propertyPrefix

directories

protected java.util.Vector directories

highestResLevel

protected int highestResLevel
Constructor Detail

DTEDFrameCache

public DTEDFrameCache()

DTEDFrameCache

public DTEDFrameCache(int max_size)
Create the cache with paths to search for frames, and the maximum number of frames to keep on hand. Assumes the paths given are for level 0 and 1 data.

Parameters:
max_size - max number of frames to keep in the cache..
Method Detail

addDTEDDirectoryHandler

public void addDTEDDirectoryHandler(DTEDDirectoryHandler handler)
Add a DTED DirectoryHandler to be used for the DTEDFrameCache.


removeDTEDDirectoryHandler

public void removeDTEDDirectoryHandler(DTEDDirectoryHandler handler)
Remove a DTED DirectoryHandler from the list used for the DTEDFrameCache.


getDTEDDirectoryHandlers

public java.util.Vector getDTEDDirectoryHandlers()
Get the Vector of DTEDDirectoryHandlers used by the DTEDFrameCache.


setDTEDDirectoryHandlers

public void setDTEDDirectoryHandlers(java.util.Vector handlers)
Set the Vector of DTEDDirectoryHandlers used by the DTEDFrameCache. You might want to use this to set the order of directories that are searched for a DTED frame.


findFileName

public java.lang.String findFileName(double lat,
                                     double lon,
                                     int level)
A utility to find the path to a dted file, given a lat, lon and a dted level. Assumes that paths have been given to the cache. Lat/lons in decimal degrees.

Parameters:
lat - latitude of point
lon - longitude of point
level - the dted level wanted (0, 1)
Returns:
complete path to file with lat/lon.

get

public DTEDFrame get(double lat,
                     double lon,
                     int level)
Return The DTED Frame, Given A Lat, Lon And DTED Level.

Parameters:
lat - latitude of point
lon - longitude of point
level - the dted level wanted (0, 1, 2)
Returns:
DTED frame.

load

public CacheObject load(java.lang.Object key)
Load a dted frame into the cache, based on the path of the frame as a key.

Specified by:
load in class CacheHandler
Parameters:
key - complete path to the frame, String.
Returns:
DTED frame, hidden as a CacheObject.

resizeCache

public void resizeCache(int max_size)
This version of resizeCache is for screen size changes, where the number of frames kept on hand in the cache must change, but the images themselves don't have to because the pixel/posting spacing hasn't changed in the projection. The frames already in the cache are re-added to the new cache, if the cache size is increasing. If the cache size is shrinking, then as many as will fit are added to the new cache.

Parameters:
max_size - the new size of the cache.

getHighestResLevel

public int getHighestResLevel()

setHighestResLevel

public void setHighestResLevel(int highestResLevel)

getElevation

public int getElevation(float lat,
                        float lon)
Return the elevation of a lat/lon point, in meters. Will look for frames starting at the highest resolution specified in this DTEDFrameCache, and work up to level 0, searching for a frame to provide an answer. Will return NO_DATA if a frame is not found, or if there is no data in the frame file that is found. The default highest resolution DTED level is 2.

Parameters:
lat - in decimal degrees.
lon - in decimal degrees.
Returns:
elevation in meters.

getElevation

public int getElevation(float lat,
                        float lon,
                        int level)
Return the elevation of a lat/lon point, in meters.

Parameters:
lat - in decimal degrees.
lon - in decimal degrees.
level - the dted level.
Returns:
elevation in meters.

getElevations

public short[][] getElevations(EqualArc proj,
                               int dtedLevel)
Return the two-dimensional matrix of elevation posts (heights) representing coverage of a given geographical rectangle. The matrix represents coverage in an Equal Arc projection, and that's why the rectangle is defined by the projection parameters.

Parameters:
proj - the projection describing the wanted area
dtedLevel - the DTED level (0, 1, 2) to be used, which describes the geographicsal spacing between the posts.
Returns:
array of elevations, in meters. Spacing depends on the DTED level.

getElevations

public short[][] getElevations(float ullat,
                               float ullon,
                               float lrlat,
                               float lrlon,
                               int dtedLevel)
Return the two-dimensional matrix of elevation posts (heights) representing coverage of a given geographical rectangle. The matrix represents coverage in an Equal Arc projection. Doesn't handle projections which cross the dateline - You must handle that yourself by making two inquiries.

Parameters:
ullat - upper latitude, in decimal degrees
ullon - left longitude, in decimal degrees
lrlat - lower latitude, in decimal degrees
lrlon - right longitude, in decimal degrees
dtedLevel - the DTED level (0, 1, 2) to be used, which describes the geographicsal spacing between the posts.

getElevations

protected short[][] getElevations(float ullat,
                                  float ullon,
                                  float lrlat,
                                  float lrlon,
                                  int dtedLevel,
                                  DTEDFrame refFrame)
Return the two-dimensional matrix of elevation posts (heights) representing coverage of a given geographical rectangle. The matrix represents coverage in an Equal Arc projection. Doesn't handle projections which cross the dateline - You must handle that yourself by making two inquiries.

This method is slightly different that the one above, because it includes a input variable DTEDFrame. There is an inherent problem in the algorithm if some of the DTED frames are missing. It's too difficult to calculate the size of the return array if you don't know that any frames are available. So, you should always use the method above, which calls this method with a null refFrame. If some of the DTED frames are missing, then this method is called recursively, with a frame to use for calculating post spacings at the right time.

Parameters:
ullat - upper latitude, in decimal degrees
ullon - left longitude, in decimal degrees
lrlat - lower latitude, in decimal degrees
lrlon - right longitude, in decimal degrees
dtedLevel - the DTED level (0, 1, 2) to be used, which describes the geographicsal spacing between the posts.
refFrame - DTEDFrame used to calculate measurements.
Returns:
array of elevations, in meters. Spacing depends on the DTED level.

setPropertyPrefix

public void setPropertyPrefix(java.lang.String prefix)
PropertyConsumer method.

Specified by:
setPropertyPrefix in interface PropertyConsumer
Parameters:
prefix - the prefix String.

getPropertyPrefix

public java.lang.String getPropertyPrefix()
PropertyConsumer method.

Specified by:
getPropertyPrefix in interface PropertyConsumer
Returns:
the prefix string

setProperties

public void setProperties(java.util.Properties props)
PropertyConsumer method.

Specified by:
setProperties in interface PropertyConsumer
Parameters:
props - a properties object that the PropertyConsumer can use to retrieve expected properties it can use for configuration.

setProperties

public void setProperties(java.lang.String prefix,
                          java.util.Properties props)
PropertyConsumer method.

Specified by:
setProperties in interface PropertyConsumer
Parameters:
prefix - a String used by the PropertyConsumer to prepend to each property value it wants to look up - setList.getProperty(prefix.propertyKey). If the prefix had already been set, then the prefix passed in should replace that previous value.
props - a Properties object that the PropertyConsumer can use to retrieve expected properties it can use for configuration.

getProperties

public java.util.Properties getProperties(java.util.Properties props)
PropertyConsumer method.

Specified by:
getProperties in interface PropertyConsumer
Parameters:
props - a Properties object to load the PropertyConsumer properties into. If getList equals null, then a new Properties object should be created.
Returns:
Properties object containing PropertyConsumer property values. If getList was not null, this should equal getList. Otherwise, it should be the Properties object created by the PropertyConsumer.

getPropertyInfo

public java.util.Properties getPropertyInfo(java.util.Properties props)
PropertyConsumer method.

Specified by:
getPropertyInfo in interface PropertyConsumer
Parameters:
props - a Properties object to load the PropertyConsumer properties into. If getList equals null, then a new Properties object should be created.
Returns:
Properties object containing PropertyConsumer property values. If getList was not null, this should equal getList. Otherwise, it should be the Properties object created by the PropertyConsumer.

main

public static void main(java.lang.String[] args)


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