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/export.h>
00024
00025 #include <geos/index/strtree/AbstractSTRtree.h>
00026 #include <geos/index/SpatialIndex.h>
00027 #include <geos/geom/Envelope.h>
00028
00029 #include <vector>
00030
00031
00032 namespace geos {
00033 namespace index {
00034 namespace strtree {
00035 class Boundable;
00036 }
00037 }
00038 }
00039
00040
00041 namespace geos {
00042 namespace index {
00043 namespace 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
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 }
00144 }
00145 }
00146
00147 #endif // GEOS_INDEX_STRTREE_STRTREE_H
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161