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 #include <geos/index/strtree/AbstractSTRtree.h>
00025 #include <geos/index/SpatialIndex.h>
00026 #include <geos/geom/Envelope.h>
00027
00028 #include <vector>
00029
00030 #ifdef _MSC_VER
00031 #pragma warning(push)
00032 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
00033 #endif
00034
00035
00036 namespace geos {
00037 namespace index {
00038 namespace strtree {
00039 class Boundable;
00040 }
00041 }
00042 }
00043
00044 namespace geos {
00045 namespace index {
00046 namespace strtree {
00047
00063 class GEOS_DLL STRtree: public AbstractSTRtree, public SpatialIndex
00064 {
00065 using AbstractSTRtree::insert;
00066 using AbstractSTRtree::query;
00067
00068 private:
00069 class GEOS_DLL STRIntersectsOp: public AbstractSTRtree::IntersectsOp {
00070 public:
00071 bool intersects(const void* aBounds, const void* bBounds);
00072 };
00073
00081 std::auto_ptr<BoundableList> createParentBoundables(BoundableList* childBoundables, int newLevel);
00082
00083 std::auto_ptr<BoundableList> createParentBoundablesFromVerticalSlices(std::vector<BoundableList*>* verticalSlices, int newLevel);
00084
00085 STRIntersectsOp intersectsOp;
00086
00087 std::auto_ptr<BoundableList> sortBoundables(const BoundableList* input);
00088
00089 std::auto_ptr<BoundableList> createParentBoundablesFromVerticalSlice(
00090 BoundableList* childBoundables,
00091 int newLevel);
00092
00098 std::vector<BoundableList*>* verticalSlices(
00099 BoundableList* childBoundables,
00100 size_t sliceCount);
00101
00102
00103 protected:
00104
00105 AbstractNode* createNode(int level);
00106
00107 IntersectsOp* getIntersectsOp() {
00108 return &intersectsOp;
00109 };
00110
00111 public:
00112
00113 ~STRtree();
00114
00119 STRtree(std::size_t nodeCapacity=10);
00120
00121 void insert(const geom::Envelope *itemEnv,void* item);
00122
00123
00124
00125 static double avg(double a, double b) {
00126 return (a + b) / 2.0;
00127 }
00128
00129 static double centreY(const geom::Envelope *e) {
00130 return STRtree::avg(e->getMinY(), e->getMaxY());
00131 }
00132
00133 void query(const geom::Envelope *searchEnv, std::vector<void*>& matches) {
00134 AbstractSTRtree::query(searchEnv, matches);
00135 }
00136
00137 void query(const geom::Envelope *searchEnv, ItemVisitor& visitor) {
00138 return AbstractSTRtree::query(searchEnv, visitor);
00139 }
00140
00141 bool remove(const geom::Envelope *itemEnv, void* item) {
00142 return AbstractSTRtree::remove(itemEnv, item);
00143 }
00144 };
00145
00146 }
00147 }
00148 }
00149
00150
00151 #ifdef _MSC_VER
00152 #pragma warning(pop)
00153 #endif
00154
00155 #endif // GEOS_INDEX_STRTREE_STRTREE_H
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169