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

📄 maketoc.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            paths = ap.getRest();        }        if (paths == null || paths.length == 0) {            Debug.output("MakeToc: need a path to start searching for RPF frames.");            System.exit(0);        }        MakeToc mt = new MakeToc();        // If the -nw argument was not used, add a progress gauge.        arg = ap.getArgValues("nw");        if (arg == null) {            try {                mt.addProgressListener(new com.bbn.openmap.gui.ProgressListenerGauge("RPF A.TOC File Creation"));            } catch (RuntimeException re) {            }        }        boolean argFlagged = false;        arg = ap.getArgValues("absolute");        if (arg != null) {            argFlagged = true;        }        arg = ap.getArgValues("producer");        if (arg != null) {            mt.setProducer(arg[0]);        }        if (paths.length > 1 || argFlagged) {            Debug.output("MakeToc:  creating A.TOC with absolute path names.");            mt.setRelativeFramePaths(false);        }        arg = ap.getArgValues("boundary");        int max_side = DEFAULT_MAX_SIDE;        if (arg != null) {            try {                max_side = Integer.parseInt(arg[0]);                if (max_side <= DEFAULT_MAX_SIDE) {                    Debug.output("MakeToc: Boundary number specified ("                            + max_side                            + ") is too small.  Using default of 200.");                    max_side = DEFAULT_MAX_SIDE;                }            } catch (NumberFormatException nfe) {                Debug.output("MakeToc: Tried to pass a bogus integer ("                        + arg[0]                        + ") as a boundary limit.  Using default of 200.");                max_side = DEFAULT_MAX_SIDE;            }        }        mt.setMaxSide(max_side);        mt.fireProgressUpdate(ProgressEvent.START,                "Searching for RPF frames",                0,                100);        paths = mt.searchForRpfFiles(paths);        try {            mt.create(paths, outputFile, Dchum);        } catch (MakeTocException mte) {            Debug.error("Problem creating A.TOC file: \n" + mte.getMessage());        }        System.exit(0);    }    /**     * Create a A.TOC file specificed by the frame file list, at the     * location specified.     *      * @param rpfFilePaths An array of all RPF Frame file paths. If     *        these paths are relative, the MakeToc class should be     *        set for that.     * @param outputFile the complete pathname to an A.TOC file to be     *        written.     * @exception MakeTocException if anything goes wrong.     */    public void create(String[] rpfFilePaths, String outputFile)            throws MakeTocException {        create(rpfFilePaths, outputFile, false);    }    /**     * Create a A.TOC file specificed by the frame file list, at the     * location specified.     *      * @param rpfFilePaths An array of all RPF Frame file paths. If     *        these paths are relative, the MakeToc class should be     *        set for that.     * @param outputFile the complete pathname to an A.TOC file to be     *        written.     * @param dchum If dchum is present, all frames get placed in     *        their own group. False is default. Dchum are replacement     *        subframes.     * @exception MakeTocException if anything goes wrong.     */    public void create(String[] rpfFilePaths, String outputFile, boolean dchum)            throws MakeTocException {        RpfHeader head = new RpfHeader();        Vector frames = new Vector(rpfFilePaths.length);        Vector groups = new Vector();        fireProgressUpdate(ProgressEvent.UPDATE, "Organizing frames", 0, 100);        organizeFrames(rpfFilePaths, head, frames);        if (head.standardNumber == null) {            throw new MakeTocException("MakeToc: No RPF frames found.");        }        groupFrames(frames, groups, dchum);        fireProgressUpdate(ProgressEvent.UPDATE, "Writing A.TOC file", 100, 100);        writeTOCFile(outputFile, head, frames, groups);        fireProgressUpdate(ProgressEvent.DONE, "A.TOC file complete", 100, 100);    }    /**     * Look for RPF frame files, given a bunch of places to start     * looking. The output of this can be passed to the create method.     *      * @param startDirs Directory paths.     * @return an array of strings representing path names to RPF     *         frame files.     */    public String[] searchForRpfFiles(String[] startDirs) {        RpfFileSearch search = new RpfFileSearch();        for (int i = 0; i < startDirs.length; i++) {            search.handleEntry(startDirs[i]);        }        return search.getFiles();    }    /**     * Set whether to use relative frame paths in the A.TOC file.     */    public void setRelativeFramePaths(boolean setting) {        relativeFramePaths = setting;    }    public boolean getRelativeFramePaths() {        return relativeFramePaths;    }    /**     * Set the 5 letter producer code for the frames. If you didn't     * make the frames, they DMA probably did, so the default is     * applicable - DMAAC. There are a bunch of accepted codes in the     * MIL-STD-2411 for producers.     */    public void setProducer(String setting) {        if (setting.length() != 5) {            if (setting.length() >= 5) {                producer = setting.substring(0, 5);            } else {                producer = setting + createPadding(5 - setting.length(), false);            }        } else {            producer = setting;        }    }    /** Get the producer code currently set. */    public String getProducer() {        return producer;    }    /**     * Set the Maximum number of frames along a group boundary edge.     * Don't change this after starting to group the frames.     */    protected void setMaxSide(int set) {        maxSide = set;    }    /**     * Get the Maximum number of frames along a group boundary edge.     */    protected int getMaxSide() {        return maxSide;    }    /** A little function to tell of one edge is near another. */    protected boolean near(double a, double b, double eps) {        return (Math.abs(a - b) < eps); /* EPS was 0.0001 */    }    /**     * Get all the frame paths, and sort through them. This method     * sets up the frames vector and loads each Frame with it's     * attributes, so it can be grouped with its neighbors.     *      * @param framePaths the array of RPF file paths.     * @param head an RpfHeader object to load with production     *        information, that will be put into the A.TOC file.     * @param frames the frame vector to load.     */    public void organizeFrames(String[] framePaths, RpfHeader head,                               Vector frames) {        int tail;        int i;        /* New, DKS */        //boolean Cib = false; /* CIB data flag: 1:I1(10M); 2:I2(5M) */        //boolean Cdted = false; /* CDTED data flag: 1: DT1(100M) */        boolean isoverview = false;        boolean islegend = false;        Frame frame;        RpfFileSections.RpfCoverageSection coverage;        Debug.message("maketoc",                "MakeToc.organizeFrames: *** initial look at frames ***");        /* # of frames = # of pathname records = #files */        int nFrames = framePaths.length;        if (Debug.debugging("maketoc")) {            Debug.output("Number of frames: " + nFrames);        }        /* for each frame file */        for (i = 0; i < nFrames; i++) {            isoverview = false;            islegend = false;            String framePath = framePaths[i];            if (Debug.debugging("maketoc")) {                Debug.output("MakeToc: frame number " + i + ", " + framePath);            }            try {                BinaryFile binFile = new BinaryBufferedFile(framePath);                // Frame file names are 8.3 notation, might want to                // check                // that here, to blow off dummy files.                String fn = binFile.getName();                if (fn.length() != 12) {                    // Not a RPF Frame file                    if (Debug.debugging("maketoc")) {                        Debug.error("MakeToc: " + framePath                                + " is not a RPF image file - ignoring");                    }                    continue;                }                RpfFileSections rfs = new RpfFileSections();                binFile.seek(0);                if (!head.read(binFile)) {                    // Not a RPF Frame file                    if (Debug.debugging("maketoc")) {                        Debug.error("MakeToc: " + framePath                                + " is not a RPF image file - ignoring");                    }                    continue;                }                binFile.seek(head.locationSectionLocation);                rfs.parse(binFile);                coverage = rfs.parseCoverageSection(binFile);                if (coverage == null) {                    Debug.error("MakeToc: error reading coverage section for "                            + framePath + ", (file " + i + ") skipping");                    binFile.close();                    continue;                }                if (Debug.debugging("maketocframedetail")) {                    Debug.output("MakeToc.organizeFrames: coverage section for "                            + framePath + ", " + coverage);                }                binFile.close();                binFile = null;            } catch (FileNotFoundException e) {                Debug.error("MakeToc: " + framePath                        + " not found, being ignored.");                continue;            } catch (IOException ioe) {                Debug.error("MakeToc: File IO Error during read of: "                        + framePath + "! Being ignored. \n" + ioe);                continue;            }            frame = new Frame();            frames.add(frame);            frame.filename = framePath;            // This will be the actual file name, without parental            // path.            String framename;            tail = frame.filename.lastIndexOf(File.separatorChar);            if (tail == -1) {                framename = frame.filename;            } else {                framename = frame.filename.substring(++tail);            }            if (framename.length() != 12) {                Debug.error("filename must be 12 chars long - " + framename);                return;            }            // 9 is the character after the period.            isoverview = (framename.charAt(9) == 'O');            if (!isoverview) {                islegend = framename.regionMatches(true, 9, "LG", 0, 2);            }            // Check and see of the file thinks it's name is the same            // as it acutally is. If they differ, rule in favor of            // what the frame thinks it is.            //  Let's just be passive here, and name it to whatever it            //  is. If we found the frame, then we'll find it later,            //  too. -DFD            //          if (!framename.equals(head.filename)) { /* DKS */            //              File file = new File(frame.filename);            //              File newFile = new File(frame.filename.substring(0,            // tail),            //                                      head.filename);            //              file.renameTo(newFile);            //              framename = head.filename;

⌨️ 快捷键说明

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