## com.bbn.openmap.layer.dted
Class DTEDFrameCache

    java.lang.Object
      com.bbn.openmap.layer.util.cacheHandler.CacheHandler
          com.bbn.openmap.layer.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, logitude and dted level. It maintains a collection of the frames it has already used for quicker access later. The size of the cache is user-determined, and the cache also relies on user provided paths to the dted directory, which is the top level directory in a dted file structure. The paths are provided in a String array, so you can have data in different places on a system, including a CDROM drive. Because older DTED Level 2 data has the same name extension as Level 1 data, a separate array of pathnames is available for that old data. Level 0 and 1 data should be lumped together, or listed in the same array of paths. Newer level 2 data with the .dt2 extension should be listed in the regular dted path property with the level 0 and 1 data.

Field Summary
`protected java.lang.String[]` `dted2DirPaths` An array of strings available to represent old level 2 data directory paths.
`static java.lang.String` `DTED2PathsProperty`
`protected java.lang.String[]` `dtedDirPaths` An array of strings representing data directory paths.
`static java.lang.String` `DTEDFrameCacheSizeProperty`
`static java.lang.String` `DTEDPathsProperty`
`static int` `MAX_DTED_LEVEL` The maxumim DTED level to check for data, given a lat/lon and a path to a dted data directory.
`static int` `NO_DATA` The elevation value returned if there is no data at a lat/lon.
`protected int` `numXSubframes` Number of subframes used by each frame.
`protected int` `numYSubframes` Number of subframes used by each frame.
`protected java.lang.String` `propertyPrefix`

Fields inherited from class com.bbn.openmap.layer.util.cacheHandler.CacheHandler
`DEFAULT_MAX_CACHE_SIZE, logicalClock, objs`

Fields inherited from interface com.bbn.openmap.PropertyConsumer
`EditorProperty, initPropertiesProperty, LabelEditorProperty, ScopedEditorProperty`

Constructor Summary
`DTEDFrameCache()`
`DTEDFrameCache(java.lang.String[] dtedPaths, int max_size)` Create the cache with paths to search for frames, and the maximum number of frames to keep on hand.
`DTEDFrameCache(java.lang.String[] dtedPaths, java.lang.String[] dted2Paths, int max_size)` Create the cache with paths to search for frames, and the maximum number of frames to keep on hand.

Method Summary
`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.
`protected java.lang.String` `findFileName(java.lang.String[] searchPaths, java.lang.String partialFile)` Method to check the searchPaths for a file.
`DTEDFrame` `get(double lat, double lon, int level)` Return The Dted Frame, Given A Lat, Lon And Dted Level.
`int` `getElevation(float lat, float lon)` 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.
`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.String dtedFramePath)` 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` `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` `resizeCache(int max_size, int num_x_subframes, int num_y_subframes)` This version of resizeCache is for projection changes, where the post/pixel spacing of the images has changed, and the images need to be rebuilt.
`void` `setDtedDirPaths(java.lang.String[] paths)` Set the data paths.
`void` `setDtedDirPaths(java.lang.String[] paths, java.lang.String[] paths2)` Set the data paths.
`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.layer.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.

  See Also:
    Constant Field Values

### MAX_DTED_LEVEL

    public static final int MAX_DTED_LEVEL

  The maxumim DTED level to check for data, given a lat/lon and a path to a dted data directory.

  See Also:
    Constant Field Values

### dtedDirPaths

    protected java.lang.String[] dtedDirPaths

  An array of strings representing data directory paths.

### dted2DirPaths

    protected java.lang.String[] dted2DirPaths

  An array of strings available to represent old level 2 data directory paths. We have to do this because you couldn't tell the difference between level 1 and level 2 just by looking at it, which is done by looking at the data extension. Newer data is fixed, meaning that the new data meets the data specification.

### numXSubframes

    protected int numXSubframes

  Number of subframes used by each frame. Calculated by the DTEDCacheHandler when it is given a projection.

### numYSubframes

    protected int numYSubframes

  Number of subframes used by each frame. Calculated by the DTEDCacheHandler when it is given a projection.

### DTEDPathsProperty

    public static final java.lang.String DTEDPathsProperty

See Also:
  Constant Field Values

### DTED2PathsProperty

    public static final java.lang.String DTED2PathsProperty

See Also:
  Constant Field Values

### DTEDFrameCacheSizeProperty

    public static final java.lang.String DTEDFrameCacheSizeProperty

See Also:
  Constant Field Values

### propertyPrefix

    protected java.lang.String propertyPrefix

Constructor Detail

### DTEDFrameCache

    public DTEDFrameCache()

### DTEDFrameCache

    public DTEDFrameCache(java.lang.String[] dtedPaths,
                          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:
  `dtedPaths` - path to the level 0 and level 1 dted directories
  `max_size` - max number of frames to keep in the cache..

### DTEDFrameCache

    public DTEDFrameCache(java.lang.String[] dtedPaths,
                          java.lang.String[] dted2Paths,
                          int max_size)

  Create the cache with paths to search for frames, and the maximum number of frames to keep on hand.

Parameters:
  `dtedPaths` - path to the level 0 and level 1 dted directories
  `dted2Paths` - paths to the level 2 dted directories
  `max_size` - max number of frames to keep in the cache..

Method Detail

### setDtedDirPaths

    public void setDtedDirPaths(java.lang.String[] paths)

  Set the data paths.

  Parameters:
    `paths` - paths to the dted level 0 and 1 directories.

### setDtedDirPaths

    public void setDtedDirPaths(java.lang.String[] paths,
                                java.lang.String[] paths2)

  Set the data paths.

  Parameters:
    `paths` - paths to the dted level 0 and 1 directories.
    `paths2` - paths to the dted level 2 directories.

### 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.

### findFileName

    protected java.lang.String findFileName(java.lang.String[] searchPaths,
                                            java.lang.String partialFile)

  Method to check the searchPaths for a file.

  Parameters:
    `searchPaths` - an array of dted root directories
    `partialFile` - the relative pathname of a dted frame file from the dted root.
  Returns:
    the name of the file, or null if not found.

### 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.String dtedFramePath)

  Load a dted frame into the cache, based on the path of the frame as a key.

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

### resizeCache

    public void resizeCache(int max_size,
                            int num_x_subframes,
                            int num_y_subframes)

  This version of resizeCache is for projection changes, where the post/pixel spacing of the images has changed, and the images need to be rebuilt. The cache size will change based on scale, because more frames are needed for smaller scales. If the number of subframes in either direction is zero, then the resize becomes non-destructive, which means that the frames will not delete their subframes. If the scale of the map changes, then the frame subframe sizes need to be recalculated, and a destructive resizing is necessary.

  Parameters:
    `max_size` - the maximum number of frames in the cache.
    `num_x_subframes` - the number of horizontal subframes in each frame.
    `num_y_subframes` - the number of vertical subframes in each frame.

### 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.

### getElevation

    public int getElevation(float lat,
                            float lon)

  Return the elevation of a lat/lon point, in meters.

  Parameters:
    `lat` - in decimal degrees.
    `lon` - in decimal degrees.
  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