GEOS: STRtree.h Source File

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

# STRtree.h

    00001 /**********************************************************************
    00002  * $Id: STRtree.h 2556 2009-06-06 22:22:28Z strk $
    00003  *
    00004  * GEOS - Geometry Engine Open Source
    00005  * http://geos.refractions.net
    00006  *
    00007  * Copyright (C) 2006 Refractions Research Inc.
    00008  *
    00009  * This is free software; you can redistribute and/or modify it under
    00010  * the terms of the GNU Lesser General Public Licence as published
    00011  * by the Free Software Foundation.
    00012  * See the COPYING file for more information.
    00013  *
    00014  **********************************************************************
    00015  *
    00016  * Last port: index/strtree/STRtree.java rev. 1.11
    00017  *
    00018  **********************************************************************/
    00019
    00020 #ifndef GEOS_INDEX_STRTREE_STRTREE_H
    00021 #define GEOS_INDEX_STRTREE_STRTREE_H
    00022
    00023 #include <geos/export.h>
    00024
    00025 #include <geos/index/strtree/AbstractSTRtree.h> // for inheritance
    00026 #include <geos/index/SpatialIndex.h> // for inheritance
    00027 #include <geos/geom/Envelope.h> // for inlines
    00028
    00029 #include <vector>
    00030
    00031 // Forward declarations
    00032 namespace geos {
    00033         namespace index {
    00034                 namespace strtree {
    00035                         class Boundable;
    00036                 }
    00037         }
    00038 }
    00039
    00040
    00041 namespace geos {
    00042 namespace index { // geos::index
    00043 namespace strtree { // geos::index::strtree
    00044
    00060 class GEOS_DLL STRtree: public AbstractSTRtree, public SpatialIndex
    00061 {
    00062 using AbstractSTRtree::insert;
    00063 using AbstractSTRtree::query;
    00064
    00065 private:
    00066         class STRIntersectsOp: public AbstractSTRtree::IntersectsOp {
    00067                 public:
    00068                         bool intersects(const void* aBounds, const void* bBounds);
    00069         };
    00070
    00078         std::auto_ptr<BoundableList> createParentBoundables(BoundableList* childBoundables, int newLevel);
    00079
    00080         std::auto_ptr<BoundableList> createParentBoundablesFromVerticalSlices(std::vector<BoundableList*>* verticalSlices, int newLevel);
    00081
    00082         STRIntersectsOp intersectsOp;
    00083
    00084         std::auto_ptr<BoundableList> sortBoundables(const BoundableList* input);
    00085
    00086         std::auto_ptr<BoundableList> createParentBoundablesFromVerticalSlice(
    00087                         BoundableList* childBoundables,
    00088                         int newLevel);
    00089
    00095         std::vector<BoundableList*>* verticalSlices(
    00096                         BoundableList* childBoundables,
    00097                         size_t sliceCount);
    00098
    00099
    00100 protected:
    00101
    00102         AbstractNode* createNode(int level);
    00103
    00104         IntersectsOp* getIntersectsOp() {
    00105                 return &intersectsOp;
    00106         };
    00107
    00108 public:
    00109
    00110         ~STRtree();
    00111
    00116         STRtree(size_t nodeCapacity=10);
    00117
    00118         void insert(const geom::Envelope *itemEnv,void* item);
    00119
    00120         //static double centreX(const geom::Envelope *e);
    00121
    00122         static double avg(double a, double b) {
    00123                 return (a + b) / 2.0;
    00124         }
    00125
    00126         static double centreY(const geom::Envelope *e) {
    00127                 return STRtree::avg(e->getMinY(), e->getMaxY());
    00128         }
    00129
    00130         void query(const geom::Envelope *searchEnv, std::vector<void*>& matches) {
    00131                 AbstractSTRtree::query(searchEnv, matches);
    00132         }
    00133
    00134         void query(const geom::Envelope *searchEnv, ItemVisitor& visitor) {
    00135                 return AbstractSTRtree::query(searchEnv, visitor);
    00136         }
    00137
    00138         bool remove(const geom::Envelope *itemEnv, void* item) {
    00139                 return AbstractSTRtree::remove(itemEnv, item);
    00140         }
    00141 };
    00142
    00143 } // namespace geos::index::strtree
    00144 } // namespace geos::index
    00145 } // namespace geos
    00146
    00147 #endif // GEOS_INDEX_STRTREE_STRTREE_H
    00148
    00149 /**********************************************************************
    00150  * $Log$
    00151  * Revision 1.3  2006/06/12 10:49:43  strk
    00152  * unsigned int => size_t
    00153  *
    00154  * Revision 1.2  2006/04/03 08:43:09  strk
    00155  * Added port info, minor cleanups
    00156  *
    00157  * Revision 1.1  2006/03/21 10:47:34  strk
    00158  * indexStrtree.h split
    00159  *
    00160  **********************************************************************/
    00161