00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GEOS_INDEX_STRTREE_STRTREE_H
00021 #define GEOS_INDEX_STRTREE_STRTREE_H
00022
00023 #include <geos/index/strtree/AbstractSTRtree.h>
00024 #include <geos/index/SpatialIndex.h>
00025 #include <geos/geom/Envelope.h>
00026
00027 #include <vector>
00028
00029
00030 namespace geos {
00031 namespace index {
00032 namespace strtree {
00033 class Boundable;
00034 }
00035 }
00036 }
00037
00038
00039 namespace geos {
00040 namespace index {
00041 namespace strtree {
00042
00058 class STRtree: public AbstractSTRtree, public SpatialIndex
00059 {
00060 using AbstractSTRtree::insert;
00061 using AbstractSTRtree::query;
00062
00063 private:
00064 class STRIntersectsOp: public AbstractSTRtree::IntersectsOp {
00065 public:
00066 bool intersects(const void* aBounds, const void* bBounds);
00067 };
00068
00076 std::auto_ptr<BoundableList> createParentBoundables(BoundableList* childBoundables, int newLevel);
00077
00078 std::auto_ptr<BoundableList> createParentBoundablesFromVerticalSlices(std::vector<BoundableList*>* verticalSlices, int newLevel);
00079
00080 STRIntersectsOp intersectsOp;
00081
00082 std::auto_ptr<BoundableList> sortBoundables(const BoundableList* input);
00083
00084 std::auto_ptr<BoundableList> createParentBoundablesFromVerticalSlice(
00085 BoundableList* childBoundables,
00086 int newLevel);
00087
00093 std::vector<BoundableList*>* verticalSlices(
00094 BoundableList* childBoundables,
00095 size_t sliceCount);
00096
00097
00098 protected:
00099
00100 AbstractNode* createNode(int level);
00101
00102 IntersectsOp* getIntersectsOp() {
00103 return &intersectsOp;
00104 };
00105
00106 public:
00107
00108 ~STRtree();
00109
00114 STRtree(size_t nodeCapacity=10);
00115
00116 void insert(const geom::Envelope *itemEnv,void* item);
00117
00118
00119
00120 static double avg(double a, double b) {
00121 return (a + b) / 2.0;
00122 }
00123
00124 static double centreY(const geom::Envelope *e) {
00125 return STRtree::avg(e->getMinY(), e->getMaxY());
00126 }
00127
00128 void query(const geom::Envelope *searchEnv, std::vector<void*>& matches) {
00129 AbstractSTRtree::query(searchEnv, matches);
00130 }
00131
00132 void query(const geom::Envelope *searchEnv, ItemVisitor& visitor) {
00133 return AbstractSTRtree::query(searchEnv, visitor);
00134 }
00135
00136 bool remove(const geom::Envelope *itemEnv, void* item) {
00137 return AbstractSTRtree::remove(itemEnv, item);
00138 }
00139 };
00140
00141 }
00142 }
00143 }
00144
00145 #endif // GEOS_INDEX_STRTREE_STRTREE_H
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159