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

📄 spatialindexhandler.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                interString);        props.put(ShapeLayer.spatialIndexProperty + ScopedEditorProperty,                "com.bbn.openmap.util.propertyEditor.FUPropertyEditor");        interString = i18n.get(ShapeLayer.class,                ShapeLayer.pointImageURLProperty,                I18n.TOOLTIP,                "Image file to use for map location of point data (optional).");        props.put(ShapeLayer.pointImageURLProperty, interString);        interString = i18n.get(ShapeLayer.class,                ShapeLayer.pointImageURLProperty,                ShapeLayer.pointImageURLProperty);        props.put(ShapeLayer.pointImageURLProperty + LabelEditorProperty,                interString);        props.put(ShapeLayer.pointImageURLProperty + ScopedEditorProperty,                "com.bbn.openmap.util.propertyEditor.FUPropertyEditor");        if (drawingAttributes != null) {            drawingAttributes.getPropertyInfo(props);        } else {            DrawingAttributes.DEFAULT.getPropertyInfo(props);        }        interString = i18n.get(SpatialIndexHandler.class,                EnabledProperty,                I18n.TOOLTIP,                "Show file contents");        props.put(EnabledProperty, interString);        interString = i18n.get(SpatialIndexHandler.class,                EnabledProperty,                EnabledProperty);        props.put(EnabledProperty + LabelEditorProperty, interString);        props.put(EnabledProperty + ScopedEditorProperty,                "com.bbn.openmap.util.propertyEditor.YesNoPropertyEditor");        interString = i18n.get(SpatialIndexHandler.class,                BufferedProperty,                I18n.TOOLTIP,                "Read and hold entire file contents (may be faster)");        props.put(BufferedProperty, interString);        interString = i18n.get(SpatialIndexHandler.class,                BufferedProperty,                BufferedProperty);        props.put(BufferedProperty + LabelEditorProperty, interString);        props.put(BufferedProperty + ScopedEditorProperty,                "com.bbn.openmap.util.propertyEditor.YesNoPropertyEditor");        return props;    }    /**     * Create the OMGraphics out of the records that fall inside the     * bounding box.     *      * @param xmin double for the min horizontal limit of the bounding     *        box.     * @param ymin double for the min vertical limit of the bounding     *        box.     * @param xmax double for the max horizontal limit of the bounding     *        box.     * @param ymax double for the max vertical limit of the bounding     *        box.     */    public OMGraphicList getGraphics(double xmin, double ymin, double xmax,                                     double ymax) throws IOException,            FormatException {        return getGraphics(xmin, ymin, xmax, ymax, null);    }    /**     * Given a bounding box, create OMGraphics from the ESRI records     * in the shape file.     *      * @param xmin double for the min horizontal limit of the bounding     *        box.     * @param ymin double for the min vertical limit of the bounding     *        box.     * @param xmax double for the max horizontal limit of the bounding     *        box.     * @param ymax double for the max vertical limit of the bounding     *        box.     * @param list OMGraphic list to add the new OMGraphics too. If     *        null, a new OMGraphicList will be created.     * @return OMGraphicList containing the new OMGraphics.     */    public OMGraphicList getGraphics(double xmin, double ymin, double xmax,                                     double ymax, OMGraphicList list)            throws IOException, FormatException {        if (list == null) {            list = new OMGraphicList();        }        if (!buffered) {            // Clean up if buffering turned off.            if (masterList != null) {                masterList = null;            }            OMGeometryList geometrys = new OMGeometryList();            drawingAttributes.setTo(geometrys);            list.add(geometrys);            ESRIRecord records[] = spatialIndex.locateRecords(xmin,                    ymin,                    xmax,                    ymax);            int nRecords = records.length;            for (int i = 0; i < nRecords; i++) {                ESRIRecord rec = records[i];                OMGeometry geom = records[i].addOMGeometry(geometrys);                geom.setAppObject(new NumAndBox(rec.getRecordNumber(), rec.getBoundingBox()));            }        } else {            // grab local refs            ESRIPoint min, max;            if (masterList == null) {                getWholePlanet();            }            drawingAttributes.setTo(masterList);            list.add(masterList);            Iterator iterator = masterList.iterator();            while (iterator.hasNext()) {                OMGeometry geom = (OMGeometry) iterator.next();                Object obj = geom.getAppObject();                // If you can test for bounding box intersections,                // then use the check to see if you can eliminate the                // object from being drawn. Otherwise, just draw it                // and let Java clip it.                geom.setVisible(true);                if (obj != null && obj instanceof NumAndBox) {                    NumAndBox nab = (NumAndBox) obj;                    min = nab.getBoundingBox().min;                    max = nab.getBoundingBox().max;                    if (!SpatialIndex.intersects(xmin,                            ymin,                            xmax,                            ymax,                            min.x,                            min.y,                            max.x,                            max.y)) {                        geom.setVisible(false);                    }                }            }        }        return list;    }    /**     * Gets the record graphics for a record with multiple graphics.     *      * @return OMGraphicList     */    protected OMGraphicList RecordList(ESRIRecord rec,                                       DrawingAttributes drawingAttributes) {        int recNumber = rec.getRecordNumber();        OMGraphicList recList = new OMGraphicList(10);        if (drawingAttributes == null) {            drawingAttributes = new DrawingAttributes();        }        rec.addOMGraphics(recList, drawingAttributes);        // Remember recordNumber to work with .dbf file        recList.setAppObject(new Integer(recNumber));        return recList;    }    /**     * Master list for buffering. Only used if buffering is enabled.     */    protected OMGeometryList masterList = null;    /**     * Get the graphics for the entire planet.     */    protected void getWholePlanet() throws FormatException {        masterList = new OMGeometryList();        if (Debug.debugging("shape")) {            Debug.output(prettyName                    + "|SpatialIndexHolder.getWholePlanet(): fetching all graphics.");        }        try {            ESRIRecord records[] = spatialIndex.locateRecords(-180d,                    -90d,                    180d,                    90d);            int nRecords = records.length;            for (int i = 0; i < nRecords; i++) {                OMGeometry geom = records[i].addOMGeometry(masterList);                geom.setAppObject(new NumAndBox(records[i].getRecordNumber(), records[i].getBoundingBox()));            }        } catch (java.io.IOException ex) {            ex.printStackTrace();            return;        } catch (java.lang.NullPointerException npe) {            Debug.error(prettyName + "|SpatialIndexHolder can't access files.");            return;        }        if (Debug.debugging("shape")) {            Debug.output(prettyName                    + "|SpatialIndexHolder.getWholePlanet(): finished fetch.");        }    }    public void setPrettyName(String set) {        prettyName = set;    }    public String getPrettyName() {        return prettyName;    }    public void setBuffered(boolean set) {        buffered = set;    }    public boolean getBuffered() {        return buffered;    }    public void setDrawingAttributes(DrawingAttributes set) {        drawingAttributes = set;    }    public DrawingAttributes getDrawingAttributes() {        return drawingAttributes;    }    public void setEnabled(boolean set) {        enabled = set;    }    public boolean getEnabled() {        return enabled;    }    public boolean close(boolean done) {        if (spatialIndex != null) {            return spatialIndex.close(done);        }        return false;    }}

⌨️ 快捷键说明

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