⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dtedadmin.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        return frames;    }    /**     * Get the internal frame list and copy those frames to the given     * directory.     *      * @return true if everything went OK, false if not enough     *         information is available to create a source file list.     */    public boolean copyTo(String todteddir) {        return copyTo(getFrameList(), todteddir);    }    /**     * Get the internal frame list and copy those frames to the given     * directory.     *      * @param files a LinkedList of Files to copy.     * @param todteddir a dted directory to copy files into.     * @return true if everything went OK, false if not enough     *         information is available to create a source file list.     */    protected boolean copyTo(LinkedList files, String todteddir) {        if (files == null) {            Debug.error("No files configured for copying!");            return false;        }        Iterator it = files.iterator();        while (it.hasNext()) {            File file = (File) it.next();            DTEDNameTranslator dnt = locator.getTranslator();            try {                dnt.set(file.getAbsolutePath());                String dsd = dnt.getSubDirs();                if (dsd != null && dsd.length() > 0) {                    dsd = "/" + dsd;                }                File toDir = new File(todteddir + dsd);                if (!toDir.exists()) {                    toDir.mkdirs();                }                File outputFile = new File(toDir, dnt.getFileName());                if (Debug.debugging("dted")) {                    Debug.output("DTEDAdmin copying " + file.getAbsolutePath()                            + " to " + outputFile.getAbsolutePath());                }                BinaryBufferedFile input = new BinaryBufferedFile(file);                RandomAccessFile output = new RandomAccessFile(outputFile, "rw");                byte[] bytes = new byte[4096];                int numBytes = input.read(bytes);                while (numBytes > 0) {                    output.write(bytes, 0, numBytes);                    numBytes = input.read(bytes);                }                input.close();                output.close();            } catch (FormatException fe) {                continue;            } catch (IOException ioe) {                continue;            }        }        return true;    }    /**     * Delete the DTED files that meet the internal file list     * parameters.     *      * @return true if everything went OK, false if not enough     *         information is available to create a source file list.     */    public boolean remove() {        return remove(getFrameList());    }    /**     * Delete the DTED files that meet the internal file list     * parameters.     *      * @param files the LinkedList of File objects representing DTED     *        frame files.     * @return true if everything went OK, false if not enough     *         information is available to create a source file list.     */    protected boolean remove(LinkedList files) {        if (files == null) {            Debug.error("No files configured for removal!");            return false;        }        Iterator it = files.iterator();        while (it.hasNext()) {            File file = (File) it.next();            Debug.output("DTEDAdmin deleting " + file.getAbsolutePath());            file.delete();        }        return true;    }    /**     * Print out a list of DTED files that meet the current internal     * parameters.     */    public boolean query() {        return query(getFrameList());    }    /**     * Print out a list of DTED files that are on the provided list of     * File objects.     */    protected boolean query(LinkedList files) {        if (files == null) {            Debug.error("No files configured for query!");            return false;        }        Iterator it = files.iterator();        while (it.hasNext()) {            File file = (File) it.next();            Debug.output("  " + file.getAbsolutePath());        }        return true;    }    /**     * Run DTEDAdmin from the command line.     */    public static void main(String[] argv) {        Debug.init();        ArgParser ap = new ArgParser("DTEDAdmin");        ap.add("boundary", "upper lat, left lon, lower lat, right lon", 4, true);        ap.add("copy", "Copy files to DTED directory.", 1);        ap.add("level",                "DTED level to consider (0, 1, 2), 0 is default.  Needs to be set for other levels.",                1);        ap.add("outside", "Use files outside boundary.");        ap.add("query", "Print out files that meet parameters.");        ap.add("remove", "Delete DTED files.");        ap.add("source", "The source DTED directory path.", 1);        ap.add("verbose", "Print out progress.");        if (!ap.parse(argv)) {            ap.printUsage();            System.exit(0);        }        String arg[];        String sourceDir = null;        arg = ap.getArgValues("source");        if (arg != null) {            sourceDir = arg[0];        }        boolean inside = true;        arg = ap.getArgValues("outside");        if (arg != null) {            inside = false;        }        int level = 0;        arg = ap.getArgValues("level");        if (arg != null) {            try {                level = Integer.parseInt(arg[0]);            } catch (NumberFormatException nfe) {                level = 0;            }        }        arg = ap.getArgValues("verbose");        if (arg != null) {            Debug.put("dted");        }        DTEDAdmin admin = null;        double ullat = 89;        double ullon = -180;        double lrlat = -90;        double lrlon = 179;        arg = ap.getArgValues("boundary");        if (arg != null) {            try {                ullat = Double.parseDouble(arg[0]);                ullon = Double.parseDouble(arg[1]);                lrlat = Double.parseDouble(arg[2]);                lrlon = Double.parseDouble(arg[3]);            } catch (NumberFormatException nfe1) {                Debug.error("DTEDAdmin: boundary coordinates not valid:\n"                        + "  " + arg[0] + "\n  " + arg[1] + "\n  " + arg[2]                        + "\n  " + arg[3]);                System.exit(0);            }        }        if (sourceDir != null) {            admin = new DTEDAdmin(sourceDir, ullat, ullon, lrlat, lrlon, level, inside, DTEDAdmin.DTED_EQUAL_LEVELS);        }        arg = ap.getArgValues("copy");        if (arg != null) {            if (admin != null) {                admin.copyTo(arg[0]);            } else {                Debug.error("DTEDAdmin:  frame parameters not set for copy.  Need source directory");                System.exit(0);            }        }        arg = ap.getArgValues("query");        if (arg != null) {            if (admin != null) {                Debug.output("DTED frame files found:");                admin.query();            } else {                Debug.error("DTEDAdmin:  frame parameters not set for query.  Need source directory");                System.exit(0);            }        }        arg = ap.getArgValues("remove");        if (arg != null) {            if (admin != null) {                Debug.output("These files will be deleted:");                admin.query();                Debug.output("Are you sure you want to delete them? [y/N]");                int answer = 'n';                try {                    answer = System.in.read();                } catch (IOException ioe) {                }                if (answer == 'Y' || answer == 'y') {                    admin.remove();                } else {                    Debug.output("File removal aborted.");                }            } else {                Debug.error("DTEDAdmin:  frame parameters not set for copy.  Need source directory");                System.exit(0);            }        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -