00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GEOS_IDX_QUADTREE_QUADTREE_H
00021 #define GEOS_IDX_QUADTREE_QUADTREE_H
00022
00023 #include <geos/index/SpatialIndex.h>
00024 #include <geos/index/quadtree/Root.h>
00025
00026 #include <vector>
00027 #include <string>
00028
00029
00030 namespace geos {
00031 namespace geom {
00032 class Envelope;
00033 }
00034 namespace index {
00035 namespace quadtree {
00036
00037 }
00038 }
00039 }
00040
00041 namespace geos {
00042 namespace index {
00043 namespace quadtree {
00044
00067 class Quadtree: public SpatialIndex {
00068
00069 private:
00070
00071 std::vector<geom::Envelope *> newEnvelopes;
00072
00073 void collectStats(const geom::Envelope *itemEnv);
00074
00075 Root *root;
00076
00088 double minExtent;
00089
00090 public:
00098 static geom::Envelope* ensureExtent(const geom::Envelope *itemEnv,
00099 double minExtent);
00100
00105 Quadtree()
00106 :
00107 root(new Root()),
00108 minExtent(1.0)
00109 {}
00110
00111 ~Quadtree();
00112
00114 int depth();
00115
00117 int size();
00118
00119 void insert(const geom::Envelope *itemEnv, void *item);
00120
00121 void query(const geom::Envelope *searchEnv, std::vector<void*>& ret);
00122
00123 void query(const geom::Envelope *searchEnv, ItemVisitor& visitor) {
00124
00125
00126
00127
00128 root->visit(searchEnv, visitor);
00129 }
00130
00138 bool remove(const geom::Envelope* itemEnv, void* item);
00139
00141 std::vector<void*>* queryAll();
00142
00143 std::string toString() const;
00144
00145 };
00146
00147
00148 }
00149 }
00150 }
00151
00152 #endif // GEOS_IDX_QUADTREE_QUADTREE_H
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163