spatialindexhandler.java

来自「OpenMap是一个基于JavaBeansTM的开发工具包。利用OpenMap你」· Java 代码 · 共 517 行 · 第 1/2 页

JAVA
517
字号
        // .class?        // What should I use as requestor field when calling        // i18n.get(...) ? DFD - use the ShapeLayer class, so you        // only have to modify one properties file with the        // translation.        interString = i18n.get(ShapeLayer.class,                ShapeLayer.shapeFileProperty,                I18n.TOOLTIP,                "Location of Shape file - .shp (File, URL or relative file path).");        props.put(ShapeLayer.shapeFileProperty, interString);        interString = i18n.get(ShapeLayer.class,                ShapeLayer.shapeFileProperty,                ShapeLayer.shapeFileProperty);        props.put(ShapeLayer.shapeFileProperty + LabelEditorProperty,                interString);        props.put(ShapeLayer.shapeFileProperty + ScopedEditorProperty,                "com.bbn.openmap.util.propertyEditor.FUPropertyEditor");        interString = i18n.get(ShapeLayer.class,                ShapeLayer.spatialIndexProperty,                I18n.TOOLTIP,                "Location of Spatial Index file - .ssx (File, URL or relative file path).");        props.put(ShapeLayer.spatialIndexProperty, interString);        interString = i18n.get(ShapeLayer.class,                ShapeLayer.spatialIndexProperty,                ShapeLayer.spatialIndexProperty);        props.put(ShapeLayer.spatialIndexProperty + LabelEditorProperty,                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;    }    public GeoCoordTransformation getCoordTranslator() {        return coordTranslator;    }    public void setCoordTranslator(GeoCoordTransformation coordTranslator) {        this.coordTranslator = coordTranslator;    }    /**     * 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,                (OMGraphicList) null,                (Projection) 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 {        return getGraphics(xmin, ymin, xmax, ymax, list, (Projection) 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.     * @param proj the projection to use to generate the OMGraphics.     * @return OMGraphicList containing the new OMGraphics.     */    public OMGraphicList getGraphics(double xmin, double ymin, double xmax,                                     double ymax, OMGraphicList list,                                     Projection proj) throws IOException,            FormatException {        if (list == null) {            list = new OMGraphicList();        }        if (!buffered) {            // Clean up if buffering turned off.            if (bufferedList != null) {                bufferedList = null;            }            spatialIndex.getOMGraphics(xmin,                    ymin,                    xmax,                    ymax,                    list,                    drawingAttributes,                    proj,                    coordTranslator);        } else {            if (bufferedList == null) {                bufferedList = getWholePlanet(coordTranslator);            }            checkSpatialIndexEntries(xmin, ymin, xmax, ymax, list, proj);        }        return list;    }    protected void checkSpatialIndexEntries(double xmin, double ymin,                                            double xmax, double ymax,                                            OMGraphicList retList,                                            Projection proj) {        // There should be the same number of objects in both iterators.        Iterator entryIt = spatialIndex.entries.iterator();        Iterator omgIt = bufferedList.iterator();        while (entryIt.hasNext() && omgIt.hasNext()) {            Entry entry = (Entry) entryIt.next();            OMGraphic omg = (OMGraphic) omgIt.next();            omg.generate(proj);            if (entry.intersects(xmin, ymin, xmax, ymax)) {                drawingAttributes.setTo(omg);                retList.add(omg);            }        }    }    /**     * Master list for buffering. Only used if buffering is enabled.     */    protected OMGraphicList bufferedList = null;    /**     * Get the graphics for the entire planet.     */    protected OMGraphicList getWholePlanet() throws IOException,            FormatException {        return getWholePlanet((GeoCoordTransformation) null);    }    /**     * Get the graphics for the entire planet.     */    protected OMGraphicList getWholePlanet(GeoCoordTransformation dataTransform)            throws IOException, FormatException {        return spatialIndex.getOMGraphics(-180,                -90,                180,                90,                (OMGraphicList) null,                drawingAttributes,                (Projection) null,                dataTransform);    }    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 + =
减小字号Ctrl + -
显示快捷键?