?? maketoc.java
字號:
// **********************************************************************//// <copyright>// // BBN Technologies// 10 Moulton Street// Cambridge, MA 02138// (617) 873-8000// // Copyright (C) BBNT Solutions LLC. All rights reserved.// // </copyright>// **********************************************************************// // $Source: /cvs/distapps/openmap/src/openmap/com/bbn/openmap/layer/rpf/MakeToc.java,v $// $RCSfile: MakeToc.java,v $// $Revision: 1.6.2.5 $// $Date: 2005/09/15 14:03:39 $// $Author: dietrick $// // **********************************************************************/* * The meat of this code is based on source code provided by The MITRE * Corporation, through the browse application source code. Many * thanks to Nancy Markuson who provided BBN with the software, and to * Theron Tock, who wrote the software, and Daniel Scholten, who * revised it - (c) 1994 The MITRE Corporation for those parts, and * used/distributed with permission. */package com.bbn.openmap.layer.rpf;import java.io.BufferedReader;import java.io.File;import java.io.FileNotFoundException;import java.io.IOException;import java.io.InputStreamReader;import java.io.RandomAccessFile;import java.util.Vector;import com.bbn.openmap.event.ProgressEvent;import com.bbn.openmap.event.ProgressListener;import com.bbn.openmap.event.ProgressSupport;import com.bbn.openmap.io.BinaryBufferedFile;import com.bbn.openmap.io.BinaryFile;import com.bbn.openmap.util.Debug;import com.bbn.openmap.util.ArgParser;import com.bbn.openmap.LatLonPoint;import com.bbn.openmap.proj.coords.DMSLatLonPoint;/** * 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. * <P> * * 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. * <P> * * 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 alot 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. * <P> * * 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. * <P> * * 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. * <P> * * <pre> * * * * * * * * * Usage: java com.bbn.openmap.layer.rpf.MakeToc (RPF dir path) (RPF dir path) ... * * * * * * * * * </pre> * * This will create an A.TOC file in the current directory for the RPF * files in the RPF directory paths. Use: * * <pre> * * * * * * * * * java com.bbn.openmap.layer.rpf.MakeToc -help * * * * * * * * * </pre> * * for other options. * * <P> * 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. * </P> * * @see com.bbn.openmap.layer.rpf.ChangeCase */public class MakeToc { /** * 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. * This might not be enough for world-wide coverage of larger * scale maps that are now available. This number may have to be * increased depending on how much data you need. */ public final static int DEFAULT_MAX_SIDE = 200; public final static double EPS = 0.01; public final static double EPS2 = 0.0001; /** Output file name of the A.TOC file. */ public final static String ATOC_FILENAME = "A.TOC"; /** The boundary edge frame length for groups. */ protected int maxSide = DEFAULT_MAX_SIDE; /** Flag to use relative frames paths - default is true. */ protected boolean relativeFramePaths = true; /** The producer name for the frame files. Default is DMAAC. */ protected String producer = "DMAAC"; protected ProgressSupport progressSupport; /** An internal representation of a Frame file. */ public class Frame { double left; double right; double top; double bottom; /* New DKS: for computing GEOREF #'s over polar region */ double swlat; double swlon; double h_interval; double v_interval; double h_resolution; double v_resolution; String scale; // length 12 char zone; boolean marked; int group; int x; int y; String filename; boolean cib; boolean cdted; public double EPS() { return (Math.abs(right - left) * MakeToc.EPS); }; public String toString() { StringBuffer s = new StringBuffer(); s.append("Frame - " + filename + "\n"); s.append(" zone = " + zone + "\n"); s.append(" marked = " + marked + "\n"); s.append(" scale = " + scale + "\n"); s.append(" group = " + group + "\n"); if (Debug.debugging("maketocframe")) { s.append(" top = " + top + "\n"); s.append(" bottom = " + bottom + "\n"); s.append(" left = " + left + "\n"); s.append(" right = " + right + "\n"); s.append(" h_interval = " + h_interval + "\n"); s.append(" v_interval = " + v_interval + "\n"); s.append(" h_resolution = " + h_resolution + "\n"); s.append(" v_resolution = " + v_resolution + "\n"); } return s.toString(); } } /** An internal representation of a boundary rectangle for frames. */ public class Group { double[] horiz_pos; double[] vert_pos; int left; int right; int top; int bottom; String scale; char zone; double h_interval; double v_interval; double h_resolution; double v_resolution; boolean cib; boolean cdted; public Group() { horiz_pos = new double[maxSide]; vert_pos = new double[maxSide]; } public String toString() { StringBuffer s = new StringBuffer(); s.append("Group - \n"); s.append(" zone = " + zone + "\n"); s.append(" scale = " + scale + "\n"); s.append(" left = " + left + "\n"); s.append(" right = " + right + "\n"); s.append(" top = " + top + "\n"); s.append(" bottom = " + bottom + "\n"); s.append(" is cdted = " + cdted + "\n"); s.append(" is cib = " + cib + "\n"); return s.toString(); } } public MakeToc() { progressSupport = new ProgressSupport(this); } /** * Create an A.TOC file. * * @param 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 static void main(String[] argv) { Debug.init(); boolean Dchum = false; ArgParser ap = new ArgParser("MakeToc"); ap.add("absolute", "Use absolute paths in A.TOC - Use for multiple RPF Directories"); ap.add("boundary", "Maximum frames on a boundary edge (Default 200)", 1); ap.add("dchum", "DCHUM files are included."); ap.add("log", "Pathname of log file to list A.TOC creation output.", 1); ap.add("output", "Path to directory to place A.TOC file. (Default is current directory)", 1); ap.add("producer", "The producer of the frames (Default DMAAC). Five letter code.", 1); ap.add("verbose", "Print out progress"); ap.add("extraverbose", "Print out ALL progress"); ap.add("nw", "Don't put up swing progress window (Use this if you are getting weird exceptions)"); ap.add("paths", "Space separated paths to RPF directory or directories. Should be last. If more than one directory is listed, then absolute paths are used in the A.TOC file.", ArgParser.TO_END); if (!ap.parse(argv)) { ap.printUsage(); System.exit(0); } String outputFile = "." + File.separator + RpfTocHandler.RPF_TOC_FILE_NAME; String arg[]; arg = ap.getArgValues("output"); if (arg != null) { outputFile = arg[0] + File.separator + RpfTocHandler.RPF_TOC_FILE_NAME; } arg = ap.getArgValues("log"); if (arg != null) { String logfile = arg[0]; Debug.directOutput(logfile, false, true); Debug.output("MakeToc: Creating log at " + logfile + " at " + java.util.Calendar.getInstance().getTime()); } arg = ap.getArgValues("dchum"); if (arg != null) { Dchum = true; } arg = ap.getArgValues("verbose"); if (arg != null) { Debug.put("maketoc"); } arg = ap.getArgValues("extraverbose"); if (arg != null) { Debug.put("maketoc"); Debug.put("maketocdetail"); } String[] paths = null; arg = ap.getArgValues("paths"); if (arg != null) { paths = arg; } else {
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -