com.bbn.openmap.layer.rpf
Class RpfTocHandler

java.lang.Object
  extended by com.bbn.openmap.layer.rpf.RpfTocHandler

public class RpfTocHandler
extends java.lang.Object

The RpfTocHandler knows how to read A.TOC files for RPF raster data. The A.TOC file describes the coverage found in the tree of data that accompanies it. This coverage is described as a series of rectangles describing the frame of groups of coverage, with common-scale maps, types for different CADRG zones. The RpfTocHandler can also provide a description of the frames and subframes to use for a screen with a given projection.

The RPF specification says that the frame paths and file names, from the RPF directory, should be in upper-case letters. The paths and file names are stored in the A.TOC file this way. Sometimes, however, through CDROM and downloading quirks, the paths and file names, as stored on the hard drive, are actually transferred to lower-case letters. This RpfTocHandler will check for lower case letter paths, but only for all the letters to be lower case. The frame will be marked as non-existent if some of the directories or filenames have be transformed to uppercase.


Field Summary
protected  boolean aTocByteOrder
           
protected  java.lang.String aTocFilePath
           
protected  BinaryFile binFile
           
protected  long currencyTime
           
protected  boolean Dchum
           
protected  boolean DEBUG_RPF
           
protected  boolean DEBUG_RPFTOC
           
protected  boolean DEBUG_RPFTOCDETAIL
           
protected  boolean DEBUG_RPFTOCFRAMEDETAIL
           
static int DEFAULT_FRAME_SPACE
           
protected  java.lang.String dir
           
protected  RpfTocEntry[] entries
          The boundary rectangles in the A.TOC file.
protected  long estimateDiskSpace
           
protected  boolean fullPathsInATOC
          Flag to note whether absolute pathnames are used in the A.TOC.
protected  RpfHeader head
           
protected  int indexRecordLength
           
static java.lang.String LITTLE_RPF_TOC_FILE_NAME
           
protected  RpfFileSections.RpfLocationRecord[] locations
           
protected  int numBoundaries
           
protected  long numFrameIndexRecords
           
static java.lang.String RPF_TOC_FILE_NAME
           
protected  boolean valid
           
 
Constructor Summary
RpfTocHandler()
           
RpfTocHandler(java.lang.String parentDir)
          Should be used in situations where it is certain that this is the only A.TOC in town.
RpfTocHandler(java.lang.String parentDir, int TOCNumber)
          Used when there is more than one A.TOC being used, or where there is a possibility of that happening, like in the RPF layer.
 
Method Summary
protected  void figureOutChartSeriesForEntries(BinaryFile binFile)
          Method that looks at one frame file for each RpfTocEntry, in order to check the suffix and load the chart series information into the RpfTocEntry.
protected  int getASCIIZone(double ullat, int zone)
           
 java.lang.String getATocFilePath()
           
 java.util.List<RpfTocEntry> getBestCoverageEntry(double ullat, double ullon, double lrlat, double lrlon, Projection proj, RpfViewAttributes viewAtts)
          Given a coordinate box and a scale, find the entry in the table of contents file with the right data.
 void getCatalogCoverage(double ullat, double ullon, double lrlat, double lrlon, Projection proj, java.lang.String chartSeriesCode, java.util.Vector<RpfCoverageBox> coverages)
          Given a coordinate box and a scale, return the entries that have coverage over the given area.
 RpfTocEntry[] getEntries()
          Return the list of grouped frames.
static char getHigherZone(char zone)
           
static char getLowerZone(char zone)
           
static float getLowerZoneExtent(char zone)
           
static char[] getOkZones(double ullat, double lrlat, char zone)
           
 java.io.File getTocFile(java.lang.String parentDir)
          Given a parent RPF directory, find the a.toc file directly inside it, as dictated by the specification.
static float getUpperZoneExtent(char zone)
           
 boolean hasChanged()
          A way to check if the status of the A.TOC file is different, in case another one has taken its place.
protected static boolean isAboveZone(double upperLat, char zone)
           
protected static boolean isBelowZone(double lowerLat, char zone)
           
 boolean isFullPathsInATOC()
           
 boolean isIgnoreZonesForCoverageBoxes()
           
static boolean isOkZone(char zone, char[] okZones)
           
 boolean isValid()
          True if the A.TOC file is readable/present/good.
 boolean loadFile(java.lang.String parentDir)
          Read the file and load its parameters into this object.
protected  void loadFrameInformation(RpfTocEntry rpfTocEntry)
          Should be called by the RpfFrameCacheHandler before any frame files are loaded from a RpfTocEntry.
static void main(java.lang.String[] args)
           
protected  boolean parseToc(BinaryFile binFile)
           
protected  void readFrameInformation(BinaryFile binFile, RpfTocEntry entry)
          Reads the BinaryFile to retrieve the Frame file information for the entry.
 boolean reload()
          Re-read the A.TOC file in the parent directory.
 void setATocFilePath(java.lang.String tocFilePath)
           
 void setFullPathsInATOC(boolean fullPathsInATOC)
           
 void setIgnoreZonesForCoverageBoxes(boolean ignoreZonesForCoverageBoxes)
           
static long textScaleToLong(java.lang.String textScale)
          Given the scale string found in the A.TOC file, decode it into a 'long' scale.
static java.lang.String translateScaleToSeries(long scale)
          Util-like function that translates a long to the string representation found in the A.TOC file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RPF_TOC_FILE_NAME

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

LITTLE_RPF_TOC_FILE_NAME

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

DEFAULT_FRAME_SPACE

public static final int DEFAULT_FRAME_SPACE
See Also:
Constant Field Values

head

protected RpfHeader head

aTocFilePath

protected java.lang.String aTocFilePath

aTocByteOrder

protected boolean aTocByteOrder

binFile

protected BinaryFile binFile

locations

protected RpfFileSections.RpfLocationRecord[] locations

entries

protected RpfTocEntry[] entries
The boundary rectangles in the A.TOC file.


dir

protected java.lang.String dir

Dchum

protected boolean Dchum

estimateDiskSpace

protected long estimateDiskSpace

numBoundaries

protected int numBoundaries

numFrameIndexRecords

protected long numFrameIndexRecords

indexRecordLength

protected int indexRecordLength

currencyTime

protected long currencyTime

valid

protected boolean valid

fullPathsInATOC

protected boolean fullPathsInATOC
Flag to note whether absolute pathnames are used in the A.TOC. Set to false, because it's not supposed to be that way, according to the specification. This is reset automatically when the A.TOC file is read. If the first two characters of the directory paths are ./, then it stays false.


DEBUG_RPF

protected boolean DEBUG_RPF

DEBUG_RPFTOC

protected boolean DEBUG_RPFTOC

DEBUG_RPFTOCDETAIL

protected boolean DEBUG_RPFTOCDETAIL

DEBUG_RPFTOCFRAMEDETAIL

protected boolean DEBUG_RPFTOCFRAMEDETAIL
Constructor Detail

RpfTocHandler

public RpfTocHandler()

RpfTocHandler

public RpfTocHandler(java.lang.String parentDir)
Should be used in situations where it is certain that this is the only A.TOC in town.


RpfTocHandler

public RpfTocHandler(java.lang.String parentDir,
                     int TOCNumber)
Used when there is more than one A.TOC being used, or where there is a possibility of that happening, like in the RPF layer. The TOC number should be unique for a certain RpfFrameProvider.

Parameters:
parentDir - the RPF directory
TOCNumber - a unique number to identify this TOC for a RpfFrameProvider.
Method Detail

getTocFile

public java.io.File getTocFile(java.lang.String parentDir)
Given a parent RPF directory, find the a.toc file directly inside it, as dictated by the specification. Not called anymore - the BinaryFile does the searching, and can find URL and jar files.

Parameters:
parentDir - Path to the RPF directory.
Returns:
File

isValid

public boolean isValid()
True if the A.TOC file is readable/present/good.


hasChanged

public boolean hasChanged()
A way to check if the status of the A.TOC file is different, in case another one has taken its place. Handy if the A.TOC is on a CDROM drive and the disk has been swapped. Not valid anymore, with the advent of the new BinaryFile, where the file information may not be available.


reload

public boolean reload()
Re-read the A.TOC file in the parent directory.


loadFile

public boolean loadFile(java.lang.String parentDir)
Read the file and load its parameters into this object.


parseToc

protected boolean parseToc(BinaryFile binFile)

figureOutChartSeriesForEntries

protected void figureOutChartSeriesForEntries(BinaryFile binFile)
                                       throws java.io.IOException,
                                              FormatException
Method that looks at one frame file for each RpfTocEntry, in order to check the suffix and load the chart series information into the RpfTocEntry. This is needed for when the RpfTocHandler is asked for matching RpfTocEntries for a given scale and location when the chart type has been limited to a certain chart code.

Parameters:
binFile -
Throws:
java.io.IOException
FormatException

loadFrameInformation

protected void loadFrameInformation(RpfTocEntry rpfTocEntry)
Should be called by the RpfFrameCacheHandler before any frame files are loaded from a RpfTocEntry. The RpfFrameCacheHandler should ask the RpfTocEntry if the frames have been loaded, and call this if they have not.


readFrameInformation

protected void readFrameInformation(BinaryFile binFile,
                                    RpfTocEntry entry)
                             throws java.io.IOException,
                                    FormatException
Reads the BinaryFile to retrieve the Frame file information for the entry.

Parameters:
binFile - a valid, open BinaryFile.
entry - the RpfTocEntry to fill.
Throws:
java.io.IOException
FormatException

translateScaleToSeries

public static java.lang.String translateScaleToSeries(long scale)
Util-like function that translates a long to the string representation found in the A.TOC file.


textScaleToLong

public static long textScaleToLong(java.lang.String textScale)
Given the scale string found in the A.TOC file, decode it into a 'long' scale.


getASCIIZone

protected int getASCIIZone(double ullat,
                           int zone)

getCatalogCoverage

public void getCatalogCoverage(double ullat,
                               double ullon,
                               double lrlat,
                               double lrlon,
                               Projection proj,
                               java.lang.String chartSeriesCode,
                               java.util.Vector<RpfCoverageBox> coverages)
Given a coordinate box and a scale, return the entries that have coverage over the given area. The chart types returned are dictated by the chartSeriesCode passed in, which must be an entry from an RpfProductInfo.seriesCode.

Parameters:
ullat - upper left latitude, in decimal degrees
ullon - upper left longitude, in decimal degrees
lrlat - lower right latitude, in decimal degrees
lrlon - lower right longitude, in decimal degrees
proj - CADRG projection describing map.
chartSeriesCode - chart selection. If null, all coverage boxes fitting on the screen will be returned.
coverages - a list of potential coverages

getBestCoverageEntry

public java.util.List<RpfTocEntry> getBestCoverageEntry(double ullat,
                                                        double ullon,
                                                        double lrlat,
                                                        double lrlon,
                                                        Projection proj,
                                                        RpfViewAttributes viewAtts)
Given a coordinate box and a scale, find the entry in the table of contents file with the right data. Zone is always of the northern hemisphere, and is transformed to southern inside if needed. The box will get filled in with the correct information. The subframe description will have scaling information for the subframes to be scaled to match the scale. If proj is null, only exact matches will be found NOTE: method getZone() of the CADRG projection is only relevant (according to OpenMap documentation) when you're viewing a map type (ONC, etc) at its proper scale (i.e. 1:1mil for ONC). There was a method in RpfTocHandler that only checked a TOC for coverage if the TOC zone matched the zone of the projection. This caused gaps of coverage when viewing the maps at large scales that were different from their proper scale (e.g. viewing JNC at 1:10mil). Modified this method so that it obtains all the possible zones the current map projection could be in, and compares the TOC zones to that set. Note that this now returns a list of coverage entries instead of just one.

Parameters:
ullat - upper left latitude, in decimal degrees
ullon - upper left longitude, in decimal degrees
lrlat - lower right latitude, in decimal degrees
lrlon - lower right longitude, in decimal degrees
proj - CADRG projection describing map.
viewAtts - view attributes determine chart selection.
Returns:
a Vector of applicable RpfCoverageBoxes.

getOkZones

public static char[] getOkZones(double ullat,
                                double lrlat,
                                char zone)

isOkZone

public static boolean isOkZone(char zone,
                               char[] okZones)

isBelowZone

protected static boolean isBelowZone(double lowerLat,
                                     char zone)

isAboveZone

protected static boolean isAboveZone(double upperLat,
                                     char zone)

getUpperZoneExtent

public static float getUpperZoneExtent(char zone)

getLowerZoneExtent

public static float getLowerZoneExtent(char zone)

getLowerZone

public static char getLowerZone(char zone)

getHigherZone

public static char getHigherZone(char zone)

getEntries

public RpfTocEntry[] getEntries()
Return the list of grouped frames.


getATocFilePath

public java.lang.String getATocFilePath()

setATocFilePath

public void setATocFilePath(java.lang.String tocFilePath)

isFullPathsInATOC

public boolean isFullPathsInATOC()

setFullPathsInATOC

public void setFullPathsInATOC(boolean fullPathsInATOC)

isIgnoreZonesForCoverageBoxes

public boolean isIgnoreZonesForCoverageBoxes()
Returns:
the ignoreZonesForCoverageBoxes

setIgnoreZonesForCoverageBoxes

public void setIgnoreZonesForCoverageBoxes(boolean ignoreZonesForCoverageBoxes)
Parameters:
ignoreZonesForCoverageBoxes - the ignoreZonesForCoverageBoxes to set

main

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


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