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

📄 coveragetable.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
    }    /**     * This function gets the thematic index from the FeatureClassInfo     * object, and uses it to look up the tiles that contain the     * currentFeature. Then, that tile is checked to see if it is on     * the map. If it is, then that row in the thematic index is read     * to get the feature id numbers. The feature table is referenced     * for the feature ID number in the tile, and then the feature is     * drawn.     *      * @param fci the FeatureClassInfo (feature table)     * @param warehouse the VPFFeatureGraphicWarehouse to use to draw     *        the graphics.     * @param ll1 the upper left corner of the map.     * @param ll2 the lower right corner of the map.     * @param dpplat degrees per pixel latitude direction.     * @param dpplon degrees per pixel longitude direction.     * @param currentFeature the feature string (roadl)     * @param featureType the CoverageTable letter representation of     *        the feature type.     */    protected boolean drawFeaturesFromThematicIndex(                                                    FeatureClassInfo fci,                                                    VPFFeatureWarehouse warehouse,                                                    TableHolder tables,                                                    LatLonPoint ll1,                                                    LatLonPoint ll2,                                                    float dpplat, float dpplon,                                                    String currentFeature,                                                    char featureType) {        if (!fci.initThematicIndex(tablepath)) {            return false;        }        List v = new ArrayList(); // hold fci row contents        try {            int primitiveIdColIndex = fci.getTilePrimitiveIdColIndex();            DcwThematicIndex thematicIndex = fci.getThematicIndex();            Object[] indexes = thematicIndex.getValueIndexes();            fci.reopen(1);            // We just know that these values are tile IDs.            for (int i = 0; i < indexes.length; i++) {                int tileID = VPFUtil.objectToInt(indexes[i]);                TileDirectory currentTile = cat.getTileWithID(tileID);                if (currentTile == null) {                    Debug.error("VPFLayer|CoverageTable.drawFeatures: null tile from bogus ID ("                            + tileID                            + ") from "                            + fci.filename                            + ", skipping...");                    continue;                }                if (currentTile.inRegion(ll1.getLatitude(),                        ll2.getLatitude(),                        ll2.getLongitude(),                        ll1.getLongitude())) {                    tables.setTables(featureType, currentTile);                    tables.findYourself(fci);                    int[] featureID = thematicIndex.get(indexes[i]);                    if (Debug.debugging("vpf.tile")) {                        Debug.output("Drawing " + featureID.length + " "                                + featureType + " features for " + tileID + " "                                + currentTile);                    }                    if (!warehouse.needToFetchTileContents(currentFeature,                            currentTile)) {                        if (Debug.debugging("vpf")) {                            Debug.output("Loaded Cached List for "                                    + currentFeature + " and "                                    + currentTile.getPath());                        }                        continue;                    }                    for (int j = 0; j < featureID.length; j++) {                        if (!fci.getRow(v, featureID[j])) {                            //couldn't get row for some reason                            continue;                        }                        int primitiveID = VPFUtil.objectToInt(v.get(primitiveIdColIndex));                        tables.drawFeature(primitiveID,                                warehouse,                                ll1,                                ll2,                                dpplat,                                dpplon,                                currentFeature);                    }                    tables.close();                } else {                    if (Debug.debugging("vpf.tile")) {                        Debug.output("Skipping " + featureType                                + " features for " + tileID + ", not on map");                    }                }            }            return true;        } catch (FormatException f) {            if (Debug.debugging("vpf.FormatException")) {                Debug.output("CoverageTable.DFFTI: Format Exception creating features: "                        + f.getClass() + " " + f.getMessage());            }            return false;        } finally {            fci.close();        }    }    /**     * Given a feature type name, figure out if the warehouse thinks     * it should *NOT* be drawn.     *      * @param warehouse the warehouse to build the graphics.     * @param featureName the VPF name of the feature (polbndl, for     *        example).     * @return SKIP_FEATURETYPE if the feature should not be drawn.     */    protected char whatFeatureType(VPFWarehouse warehouse, String featureName) {        // Test for the feature kind (edge, area, text, points) and        // don't continue if that type is not needed.        char featureType = SKIP_FEATURETYPE;        // Get the feature class for this feature type.        FeatureClassInfo fci = getFeatureClassInfo(featureName);        if (fci == null) {            return featureType;        }        char type = fci.getFeatureType();        if ((type == AREA_FEATURETYPE && warehouse.drawAreaFeatures())                || (type == TEXT_FEATURETYPE && warehouse.drawTextFeatures())                || (type == EDGE_FEATURETYPE && warehouse.drawEdgeFeatures())                || (type == EPOINT_FEATURETYPE && warehouse.drawEPointFeatures())                || (type == CPOINT_FEATURETYPE && warehouse.drawCPointFeatures())) {            featureType = type;        }        return featureType;    }    /**     * Feature Type Information read from VPF fca files.     */    public static class FeatureClassRec {        /** the name of the feature class */        final public String feature_class;        /** the type of the feature */        final public char type;        /** a short text description */        final public String description;        /**         * Construct an instance of the class         *          * @param fclass the feature class name         * @param type the feature type         * @param desc the feature description         */        public FeatureClassRec(String fclass, char type, String desc) {            feature_class = fclass;            this.type = type;            description = desc;        }    }    /**     * Returns a map from feature name to FeatureClassRec     */    public Hashtable getFeatureTypeInfo() {        if (featureTypeInfo == null) {            featureTypeInfo = new Hashtable();            String path = getDataPath();            boolean addSlash = true;            //          if (path.endsWith(File.separator)) {            if (path.endsWith("/") || path.endsWith(File.separator)) {                addSlash = false;            }            String fca = path + (addSlash ? "/" : "") + "fca";            if (!BinaryFile.exists(fca)) {                fca = fca + ".";            }            if (BinaryFile.exists(fca)) {                try {                    DcwRecordFile fcadesc = new DcwRecordFile(fca);                    int fclass = fcadesc.whatColumn("fclass");                    int type = fcadesc.whatColumn("type");                    int descr = fcadesc.whatColumn("descr");                    for (ArrayList al = new ArrayList(fcadesc.getColumnCount()); fcadesc.parseRow(al);) {                        String fname = ((String) al.get(fclass)).toLowerCase()                                .intern();                        char ftype = ((String) al.get(type)).charAt(0);                        String fdesc = (String) al.get(descr);                        FeatureClassRec fcr = new FeatureClassRec(fname, ftype, fdesc);                        featureTypeInfo.put(fname, fcr);                    }                    fcadesc.close();                } catch (FormatException fe) {                    //nevermind, skip it                }            }        }        return featureTypeInfo;    }    public static void main(String[] args) {        if (args.length != 5) {            System.out.println("This main() is just assorted test code.");            System.out.println("Usage: java classname librarypath coveragename");            System.out.println("    tablename attribute value");            System.out.println("Result: Prints the corresponding value in int.vdt");        } else {            CoverageTable ct = new CoverageTable(args[0], args[1]);            String desc = ct.getDescription(args[2],                    args[3],                    Integer.parseInt(args[4]));            System.out.println(desc);        }    }}/** * The TableHolder is a utility class that manages the EdgeTable, * TextTable and AreaTable that are needed by the CoverageTable to use * the warehouse to create graphics. */class TableHolder {    EdgeTable edg = null;    TextTable tft = null;    AreaTable aft = null;    NodeTable ent = null;    NodeTable cnt = null;    /** Used as a preallocated list to read feature tables. */    List primitiveVector = new ArrayList();    CoverageTable coverageTable;    /**     * Construct the TableHandler with the CoverageTable it is     * helping.     */    protected TableHolder(CoverageTable ct) {        coverageTable = ct;    }    /**     * When drawing features (CoverageTable.drawFeatures()), sets up     * the TableHolder tables so that the right types are used.     *      * @param featureType from the CoverageTable, either     *        AREA_FEATURETYPE, EDGE_FEATURETYPE or TEXT_FEATURETYPE.     * @param tile the tile directory that needs to be     *        used when fetching graphics from the appropriate files.     */    protected void setTables(char featureType, TileDirectory tile)            throws FormatException {        if (featureType == CoverageTable.EDGE_FEATURETYPE) {            edg = new EdgeTable(coverageTable, tile);        }        if (featureType == CoverageTable.TEXT_FEATURETYPE) {            tft = new TextTable(coverageTable, tile);        }        if (featureType == CoverageTable.AREA_FEATURETYPE) {            aft = new AreaTable(coverageTable, null, tile);            edg = null;        }        if (featureType == CoverageTable.EPOINT_FEATURETYPE) {            ent = new NodeTable(coverageTable, tile, true);        }        if (featureType == CoverageTable.CPOINT_FEATURETYPE) {            cnt = new NodeTable(coverageTable, tile, false);        }    }    /**     * Should be called once per FeatureClassInfo, after the tables     * have been set. Lets the tables figure out which columns to use     * as an index.     */    protected void findYourself(FeatureClassInfo fci) {        if (aft != null) {            fci.findYourself(aft);        } else if (tft != null) {            fci.findYourself(tft);        } else if (edg != null) {            fci.findYourself(edg);        } else if (ent != null) {            fci.findYourself(ent);        }    }

⌨️ 快捷键说明

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