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

📄 rpfutil.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        return ret;    }    /**     * Create an A.TOC file for the provided RPF directory.     *      * @param rpfDir     * @return true if it works.     */    public boolean maketoc(String rpfDir) {        boolean ret = false;        MakeToc mt = new MakeToc();        String[] paths = new String[] { rpfDir };        // paths is going to be reset to list all of the RPF frame        // file paths.        paths = mt.searchForRpfFiles(paths);        try {            mt.create(paths,                    rpfDir + "/" + RpfTocHandler.RPF_TOC_FILE_NAME,                    false);            ret = true;        } catch (MakeTocException mte) {            Debug.error("Problem creating A.TOC file: \n" + mte.getMessage());        }        return ret;    }    /**     * Delete the files in the provided RPF directory that match the     * current scale and boundary settings.     *      * @param rpfDir     * @return true if it works.     */    public boolean delete(String rpfDir) {        boolean ret = false;        List frameList = organizeFrames(rpfDir);        if (frameList != null) {            for (Iterator it = frameList.iterator(); it.hasNext();) {                String relativeFilePath = "/" + (String) it.next();                File fromFile = new File(rpfDir + relativeFilePath);                if (fromFile.exists() && fromFile.delete() && verbose) {                    Debug.output("Deleting " + fromFile.getPath());                }            }            ret = true;        }        return ret;    }    /**     * Store the contents of the toBeZippedName directory into a zip     * file with the provided name. If the zip file name doesn't end     * in .zip, it will.     *      * @param zipLocation     * @param toBeZippedName     * @return true if it works.     */    public boolean zip(String zipLocation, String toBeZippedName) {        boolean ret = false;        if (verbose)            Debug.put("zip");        File toBeZipped = new File(toBeZippedName);        if (toBeZipped.exists()) {            try {                FileUtils.saveZipFile(zipLocation, toBeZipped);                ret = true;            } catch (FileNotFoundException e) {                e.printStackTrace();            } catch (IOException e) {                e.printStackTrace();            }        }        return ret;    }    /**     * Just run a query on the provided directory, listing the names     * of the frames that will be affected by the current scale and     * boundary settings.     *      * @param rpfDir     */    public void query(String rpfDir) {        List frameList = organizeFrames(rpfDir);        if (frameList != null) {            for (Iterator it = frameList.iterator(); it.hasNext();) {                Debug.output(it.next().toString());            }        }    }    /**     * The RpfUtil class can be run as a java program. This program     * will allow commands to be stacked, but will execute them in     * this order - copy, delete, maketoc, zip. Only one version of     * each argument is allowed per execution.     *      * @param args     */    public static void main(String[] args) {        Debug.init();        ArgParser ap = new ArgParser("RpfUtil");        ap.add("copy",                "Copy RPF data from one RPF directory to another. (-copy from to)",                2);        ap.add("delete",                "Delete RPF data from a RPF directory. (-delete from)",                1);        ap.add("maketoc",                "Create an A.TOC file in a RPF directory. (-maketoc from).",                1);        ap.add("zip",                "Create a zip file from a RPF directory. (-zip zipFileName from)",                2);        ap.add("query",                "Print the paths of files that fit the criteria, but do nothing",                1);        ap.add("scale",                "The scale to use for criteria in matching chart types, followed by a letter describing the relationship of matching frame scales to give scale ('g'reater than, 'l'ess than, 'n'ot equal to, 'e'qual to). (optional)",                2);        ap.add("boundary",                "Coordinates of bounding box (upper lat, left lon, lower lat, right lon) (optional)",                4,                true);        ap.add("inside",                "Flag to manage RPF frames inside bounding box. (default, optional)");        ap.add("outside",                "Flag to manage RPF frames outside bounding box. (optional)");        ap.add("verbose", "Print out progress");        ap.add("extraverbose", "Print out ALL progress");        if (!ap.parse(args)) {            ap.printUsage();            System.exit(0);        }        float ulat = 90f;        float llat = -90f;        float llon = -180f;        float rlon = 180f;        String arg[];        arg = ap.getArgValues("boundary");        if (arg != null) {            boolean boundaryCoordinateProblem = true;            try {                ulat = Float.parseFloat(arg[0]);                llon = Float.parseFloat(arg[1]);                llat = Float.parseFloat(arg[2]);                rlon = Float.parseFloat(arg[3]);                boundaryCoordinateProblem = ulat > 90 || llon < -180                        || llat < -90 || rlon > 180 || ulat <= llat                        || llon >= rlon;            } catch (NumberFormatException nfe) {                Debug.error("Parsing error for boundary coordinates");            }            if (boundaryCoordinateProblem) {                Debug.error("Boundary coordinates are screwy...");                ap.printUsage();                System.exit(0);            }        }        RpfUtil rpfUtil = new RpfUtil(ulat, llon, llat, rlon);        rpfUtil.verbose = (ap.getArgValues("verbose") != null);        arg = ap.getArgValues("outside");        if (arg != null) {            rpfUtil.setBoundaryLimits(RpfUtil.OUTSIDE);        }        arg = ap.getArgValues("inside");        if (arg != null) {            rpfUtil.setBoundaryLimits(RpfUtil.INSIDE);        }        arg = ap.getArgValues("scale");        if (arg != null) {            try {                rpfUtil.setScale(Float.parseFloat(arg[0]));                rpfUtil.setScaleDelim(arg[1].charAt(0));            } catch (NumberFormatException nfe) {                Debug.error("Scale value is screwy...");                ap.printUsage();                System.exit(0);            }        }        arg = ap.getArgValues("query");        if (arg != null) {            rpfUtil.query(arg[0]);            System.exit(0);        }        arg = ap.getArgValues("copy");        if (arg != null) {            rpfUtil.setRpfDir(arg[0]);            if (!rpfUtil.copy(arg[1])) {                Debug.output("Problem copying frames");            }        }        arg = ap.getArgValues("delete");        if (arg != null && !rpfUtil.delete(arg[0])) {            Debug.output("Problem deleting files.");        }        arg = ap.getArgValues("maketoc");        if (arg != null && !rpfUtil.maketoc(arg[0])) {            Debug.output("Problem creating A.TOC file for frames.");        }        arg = ap.getArgValues("zip");        if (arg != null && !rpfUtil.zip(arg[0], arg[1])) {            Debug.output("Problem creating zip file: " + arg[0]);        }    }    public int getBoundaryLimits() {        return boundaryLimits;    }    /**     * Set whether the frames need to be INSIDE, OUTSIDE or inside and     * touching the BOUNDARY of the geographical area set in the     * RpfUtil object.     *      * @param boundaryLimits     */    public void setBoundaryLimits(int boundaryLimits) {        this.boundaryLimits = boundaryLimits;    }    public List getFrameList() {        return frameList;    }    public void setFrameList(List frameList) {        this.frameList = frameList;    }    public float getLeftLon() {        return leftLon;    }    public void setLeftLon(float leftLon) {        this.leftLon = leftLon;    }    public float getLowerLat() {        return lowerLat;    }    public void setLowerLat(float lowerLat) {        this.lowerLat = lowerLat;    }    public float getRightLon() {        return rightLon;    }    public void setRightLon(float rightLon) {        this.rightLon = rightLon;    }    public String getRpfDir() {        return rpfDir;    }    /**     * Creates the list of frames matching the geographical and scale     * parameters of the frames within the directory.     *      * @param rpfDir     */    public void setRpfDir(String rpfDir) {        this.rpfDir = rpfDir;        if (rpfDir != null) {            frameList = organizeFrames(rpfDir);        }    }    public float getScale() {        return scale;    }    public void setScale(float scale) {        this.scale = scale;    }    public char getScaleDelim() {        return scaleDelim;    }    /**     * Set whether the frames considered should have scale numbers     * greater than (g), less than (l), not equal to (n) or equal to     * (e). Equal to is the default, and that's set if any other value     * os provided.     *      * @param scaleDelim     */    public void setScaleDelim(char scaleDelim) {        if (scaleDelim == SCALE_NOTEQUALS || scaleDelim == SCALE_GREATERTHAN                || scaleDelim == SCALE_LESSTHAN) {            this.scaleDelim = scaleDelim;        } else {            this.scaleDelim = SCALE_EQUALS;        }    }    public float getUpperLat() {        return upperLat;    }    public void setUpperLat(float upperLat) {        this.upperLat = upperLat;    }}

⌨️ 快捷键说明

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