📄 dtedadmin.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/dataAccess/dted/DTEDAdmin.java,v $// $RCSfile: DTEDAdmin.java,v $// $Revision: 1.3.2.3 $// $Date: 2005/08/04 18:11:16 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.dataAccess.dted;import com.bbn.openmap.io.BinaryBufferedFile;import com.bbn.openmap.io.FormatException;import com.bbn.openmap.util.ArgParser;import com.bbn.openmap.util.Debug;import java.io.File;import java.io.IOException;import java.io.RandomAccessFile;import java.util.LinkedList;import java.util.Iterator;/** * DTEDAdmin is a utility class that finds DTED frame files in order * to copy or delete them. You can specify coordinate boundaries and * DTED level as filters. Usage: * <P> * * <pre> * * -help Print usage statement, with arguments. (0 arguments expected) * -boundary upper lat, left lon, lower lat, right lon (4 arguments expected) * -copy Copy files to DTED directory. (1 argument expected) * -level DTED level to consider (0, 1, 2). (1 argument expected) * -outside Use files outside boundary. (0 arguments expected) * -query Print out files that meet parameters. (0 arguments expected) * -remove Delete DTED files. (0 arguments expected) * -source The source DTED directory path. (1 argument expected) * -verbose Print out progress. (0 arguments expected) * * </pre> */public class DTEDAdmin { protected boolean framesPrepped = false; protected int level_; protected double ullat_; protected double ullon_; protected double lrlat_; protected double lrlon_; protected boolean inside_; protected int equal_; protected LinkedList frameList = null; protected DTEDLocator locator = null; public final static int MAXLEVELS = 3; public final static int DTED_LARGER_LEVELS = 0; public final static int DTED_SMALLER_LEVELS = 1; public final static int DTED_NOTEQUAL_LEVELS = 2; public final static int DTED_EQUAL_LEVELS = 3; /** * Create a DTEDAdmin object, with file filter parameters to be * specified later. */ public DTEDAdmin() {} /** * Create a DTEDAdmin with the following parameters. * * @param dtedDir the source dted directory * @param ullat the upper latitude of the boundary box to use. * @param ullon the western latitude of the boundary box to use, * greater than -180. * @param lrlat the lower latitude of the boundary box to use. * @param lrlon the eastern latitude of the boundary box to use, * less than 180. * @param level the dted level to consider. * @param inside if true, files inside the boundary box will be * considered. If false, files outside the box will be. * @param equal filter for the level - Possible values are * DTED_LARGER_LEVELS (any file with a level greater than * the one specified) , DTED_SMALLER_LEVELS (any file with * a level less than the one specified), * DTED_NOTEQUAL_LEVELS (any file with a level not equal to * the one specified), and DTED_EQUAL_LEVELS (any file with * the level specified). */ public DTEDAdmin(String dtedDir, double ullat, double ullon, double lrlat, double lrlon, int level, boolean inside, int equal) { setFrameList(dtedDir, ullat, ullon, lrlat, lrlon, level, inside, equal); } /** * Create the internal list of frame files based on the following * parameters. * * @param dtedDir the source dted directory * @param ullat the upper latitude of the boundary box to use. * @param ullon the western latitude of the boundary box to use, * greater than -180. * @param lrlat the lower latitude of the boundary box to use. * @param lrlon the eastern latitude of the boundary box to use, * less than 180. * @param level the dted level to consider. * @param inside if true, files inside the boundary box will be * considered. If false, files outside the box will be. * @param equal filter for the level - Possible values are * DTED_LARGER_LEVELS (any file with a level greater than * the one specified) , DTED_SMALLER_LEVELS (any file with * a level less than the one specified), * DTED_NOTEQUAL_LEVELS (any file with a level not equal to * the one specified), and DTED_EQUAL_LEVELS (any file with * the level specified). */ protected LinkedList organizeFrames(String dtedDir, double ullat, double ullon, double lrlat, double lrlon, int level, boolean inside, int equal) { framesPrepped = false; if (Debug.debugging("dted")) { Debug.output("DTEDAdmin: Checking for directory " + dtedDir); } LinkedList frames = null; if (true/* (new File(dtedDir)).exists() */) { // not level_ = level; ullat_ = ullat; ullon_ = ullon; lrlat_ = lrlat; lrlon_ = lrlon; inside_ = inside; equal_ = equal; Debug.output("DTEDAdmin: Figuring out which frames fit the criteria..."); frames = getFrameList(dtedDir); framesPrepped = true; } return frames; } /** * Create the internal list of frame files based on the following * parameters. * * @param dtedDir the source dted directory * @param ullat the upper latitude of the boundary box to use. * @param ullon the western latitude of the boundary box to use, * greater than -180. * @param lrlat the lower latitude of the boundary box to use. * @param lrlon the eastern latitude of the boundary box to use, * less than 180. * @param level the dted level to consider. * @param inside if true, files inside the boundary box will be * considered. If false, files outside the box will be. * @param equal filter for the level - Possible values are * DTED_LARGER_LEVELS (any file with a level greater than * the one specified) , DTED_SMALLER_LEVELS (any file with * a level less than the one specified), * DTED_NOTEQUAL_LEVELS (any file with a level not equal to * the one specified), and DTED_EQUAL_LEVELS (any file with * the level specified). */ public void setFrameList(String dtedDir, double ullat, double ullon, double lrlat, double lrlon, int level, boolean inside, int equal) { setFrameList(organizeFrames(dtedDir, ullat, ullon, lrlat, lrlon, level, inside, equal)); } /** * Set the internal frame list, a LinkedList expected to hold File * objects. */ protected void setFrameList(LinkedList ll) { frameList = ll; } /** * Get the internal frame list, a LinkedList expected to hold File * objects. */ protected LinkedList getFrameList() { return frameList; } /** * Figure out the frames with the current parameters for the * source directory provided. */ protected LinkedList getFrameList(String dtedDir) { int lev; boolean dothisone; int leftx = (int) Math.floor(ullon_); int rightx = (int) Math.ceil(lrlon_); int bottomy = (int) Math.floor(lrlat_); int topy = (int) Math.ceil(ullat_); LinkedList frames = new LinkedList(); locator = new DTEDLocator(dtedDir); locator.organize(); for (int hor = leftx; hor < rightx; hor++) { for (int ver = bottomy; ver < topy; ver++) { for (lev = 0; lev < MAXLEVELS; lev++) { dothisone = false; switch (equal_) { case DTED_LARGER_LEVELS: if (lev > level_) dothisone = true; break; case DTED_SMALLER_LEVELS: if (lev < level_) dothisone = true; break; case DTED_NOTEQUAL_LEVELS: if (lev != level_) dothisone = true; break; case DTED_EQUAL_LEVELS: default: if (lev == level_) dothisone = true; break; } if (dothisone) { File file = locator.get(ver, hor, lev); if (file != null) { if (Debug.debugging("dted")) { Debug.output("DTEDAdmin adding " + file.getAbsolutePath() + " to list"); } frames.add(file); } } } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -