|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.bbn.openmap.layer.rpf.MakeToc
public class MakeToc
This is a class that will generate A.TOC files that the RpfLayer requires. A.TOC files provide the RpfLayer with an idea of what data is available to it, its geographic coverage, and chart type. With the A.TOC contents, the RpfLayer is able to find which frames are appropriate for a given projection location. It is very important to have a valid A.TOC directory.
The RPF specification, MIL-STD-2411, has definitions for how frames are to be laid out and found within a RPF directory. All RPF data is supposed to lie under one RPF directory, and an A.TOC file, describing all the files and their groupings, should be directly within the RPF directory. That's why the RpfLayer needs a path to a RPF directory - it's really looking for the A.TOC file, and knows where to find it. It also needs a path to the RPF directory because it needs to prepend that path to the paths to the files that the A.TOC file knows about.
The A.TOC files that can be created with this MakeToc class can be created to contain absolute frame paths. The MakeToc class can take the paths to several RPF directories, and create a single A.TOC file that preserves all of their current file paths. You have to use a lot of caution with this capability, however. These A.TOCs containing absolute file paths will not work if the data is moved to another machine, or if referenced by a machine with a different type file system (i.e. Windows). They may not work for other implementations of code that display RPF data - the code in this package has been modified to test for absolute file names.
That said, absolute file names should be used instead of giving the RpfLayer several RPF directories. The RpfTocHandler does much less work when it is allowed to group coverages together to make bigger areas.
This code was ported from C code provided in the original Mitre RPF package that had limits to the number of frames that could make up the areas. I'll be working to eliminate those limits, but I wanted to get a working version of the code out there. I'm also planning on modifying this class so that it can load the RpfTocHandler directly, therefore eliminating the need for A.TOCs altogether when there is more than one RPF directory.
Usage: java com.bbn.openmap.layer.rpf.MakeToc (RPF dir path) (RPF dir path) ...This will create an A.TOC file in the current directory for the RPF files in the RPF directory paths. Use:
java com.bbn.openmap.layer.rpf.MakeToc -helpfor other options.
NOTE: Make sure that the RPF directories and their contents are in upper case. It's a spec requirement, although with CD copies and FTP downloads, the file name cases sometimes get switched. Use com.bbn.openmap.layer.rpf.ChangeCase to modify the file name cases. Also, if there is more than one RPF directory in the path to the image frames, use the absolute path option. Otherwise, the code will focus on making the top-most RPF directory the one to key the internal relative paths off of, and that might not be what you want.
ChangeCase
Nested Class Summary | |
---|---|
class |
MakeToc.Frame
An internal representation of a Frame file. |
class |
MakeToc.Group
An internal representation of a boundary rectangle for frames. |
Field Summary | |
---|---|
static java.lang.String |
ATOC_FILENAME
Output file name of the A.TOC file. |
static int |
DEFAULT_MAX_SIDE
According to Dan Scholten's original code, this was 2 times the max - changed from 30 on 6/17/94 to 200 for 81 JNC's in zone 1. |
static double |
EPS
|
static double |
EPS2
|
protected int |
maxSide
The boundary edge frame length for groups. |
protected java.lang.String |
producer
The producer name for the frame files. |
protected ProgressSupport |
progressSupport
|
protected boolean |
relativeFramePaths
Flag to use relative frames paths - default is true. |
Constructor Summary | |
---|---|
MakeToc()
|
Method Summary | |
---|---|
protected boolean |
addFrameToGroup(MakeToc.Group grp,
MakeToc.Frame frm,
int index)
Does the actual checking to see if the frame gets added to the group, by checking the frame's location with the group's current boundaries, and resizing the group boundary if the frame is touching it. |
void |
addProgressListener(ProgressListener list)
Add a ProgressListener that will display build progress. |
void |
clearProgressListeners()
Clear all progress listeners. |
void |
create(java.lang.String[] rpfFilePaths,
java.lang.String outputFile)
Create a A.TOC file specificed by the frame file list, at the location specified. |
void |
create(java.lang.String[] rpfFilePaths,
java.lang.String outputFile,
boolean dchum)
Create a A.TOC file specificed by the frame file list, at the location specified. |
java.lang.String |
createPadding(int length,
boolean nullTerminated)
|
protected void |
fireProgressUpdate(int type,
java.lang.String task,
int frameNumber,
int totalFrames)
Fire an build update to progress listeners. |
protected int |
getMaxSide()
Get the Maximum number of frames along a group boundary edge. |
java.lang.String |
getProducer()
Get the producer code currently set. |
boolean |
getRelativeFramePaths()
|
protected void |
groupFrames(java.util.Vector<MakeToc.Frame> frames,
java.util.Vector<MakeToc.Group> groups,
boolean isDchum)
Take the Vector of frames, and group them into boundary rectangles, represented by groups. |
protected java.lang.String |
latlong2GEOREF(double latitude,
double longitude)
This program attempts to convert latitudes and longitudes given in a decimal format into a GEOREF alphanumeric designation code. |
static void |
main(java.lang.String[] argv)
Create an A.TOC file. |
protected boolean |
near(double a,
double b,
double eps)
A little function to tell of one edge is near another. |
void |
organizeFrames(java.lang.String[] framePaths,
RpfHeader head,
java.util.Vector<MakeToc.Frame> frames)
Get all the frame paths, and sort through them. |
protected java.lang.String |
promptForScale(java.lang.String query)
Prompt for input. |
void |
removeProgressListener(ProgressListener list)
Remove a ProgressListener that displayed build progress. |
protected java.lang.String |
searchForATOCForScaleReference(java.lang.String framePath)
|
java.lang.String[] |
searchForRpfFiles(java.lang.String[] startDirs)
Look for RPF frame files, given a bunch of places to start looking. |
protected void |
setMaxSide(int set)
Set the Maximum number of frames along a group boundary edge. |
void |
setProducer(java.lang.String setting)
Set the 5 letter producer code for the frames. |
void |
setRelativeFramePaths(boolean setting)
Set whether to use relative frame paths in the A.TOC file. |
protected void |
writeTOCFile(java.lang.String filename,
RpfHeader head,
java.util.Vector<MakeToc.Frame> frames,
java.util.Vector<MakeToc.Group> groups)
Create and write out an A.TOC file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_MAX_SIDE
public static final double EPS
public static final double EPS2
public static final java.lang.String ATOC_FILENAME
protected int maxSide
protected boolean relativeFramePaths
protected java.lang.String producer
protected ProgressSupport progressSupport
Constructor Detail |
---|
public MakeToc()
Method Detail |
---|
public static void main(java.lang.String[] argv)
argv
- The arguments should at least include a path to a RPF file
root directory. Other options can be found by using a -help
option.public void create(java.lang.String[] rpfFilePaths, java.lang.String outputFile) throws MakeTocException
rpfFilePaths
- An array of all RPF Frame file paths. If these paths are
relative, the MakeToc class should be set for that.outputFile
- the complete pathname to an A.TOC file to be written.
MakeTocException
- if anything goes wrong.public void create(java.lang.String[] rpfFilePaths, java.lang.String outputFile, boolean dchum) throws MakeTocException
rpfFilePaths
- An array of all RPF Frame file paths. If these paths are
relative, the MakeToc class should be set for that.outputFile
- the complete pathname to an A.TOC file to be written.dchum
- If dchum is present, all frames get placed in their own group.
False is default. Dchum are replacement subframes.
MakeTocException
- if anything goes wrong.public java.lang.String[] searchForRpfFiles(java.lang.String[] startDirs)
startDirs
- Directory paths.
public void setRelativeFramePaths(boolean setting)
public boolean getRelativeFramePaths()
public void setProducer(java.lang.String setting)
public java.lang.String getProducer()
protected void setMaxSide(int set)
protected int getMaxSide()
protected boolean near(double a, double b, double eps)
public void organizeFrames(java.lang.String[] framePaths, RpfHeader head, java.util.Vector<MakeToc.Frame> frames)
framePaths
- the array of RPF file paths.head
- an RpfHeader object to load with production information, that
will be put into the A.TOC file.frames
- the frame vector to load.protected java.lang.String searchForATOCForScaleReference(java.lang.String framePath)
protected java.lang.String promptForScale(java.lang.String query)
protected void writeTOCFile(java.lang.String filename, RpfHeader head, java.util.Vector<MakeToc.Frame> frames, java.util.Vector<MakeToc.Group> groups) throws MakeTocException
filename
- the output filename.head
- the RpfHeader containing header information.frames
- the frame Vector.groups
- the file groups Vector.
MakeTocException
protected void groupFrames(java.util.Vector<MakeToc.Frame> frames, java.util.Vector<MakeToc.Group> groups, boolean isDchum) throws MakeTocException
frames
- the frame Vector.groups
- the group Vector.isDchum
- flag to note if Dchum frames are present.
MakeTocException
protected boolean addFrameToGroup(MakeToc.Group grp, MakeToc.Frame frm, int index) throws MakeTocException
grp
- the groupfrm
- the frame.index
- the group index, referring to it's position in the Group
Vector.
MakeTocException
protected java.lang.String latlong2GEOREF(double latitude, double longitude)
public java.lang.String createPadding(int length, boolean nullTerminated)
public void addProgressListener(ProgressListener list)
public void removeProgressListener(ProgressListener list)
public void clearProgressListeners()
protected void fireProgressUpdate(int type, java.lang.String task, int frameNumber, int totalFrames)
frameNumber
- the current frame counttotalFrames
- the total number of frames.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |