GEOS: Quadtree.h Source File

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

- File List

# Quadtree.h

    00001 /**********************************************************************
    00002  * $Id: Quadtree.h 3255 2011-03-01 17:56:10Z mloskot $
    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/quadtree/Quadtree.java rev. 1.16 (JTS-1.10)
    00017  *
    00018  **********************************************************************/
    00019
    00020 #ifndef GEOS_IDX_QUADTREE_QUADTREE_H
    00021 #define GEOS_IDX_QUADTREE_QUADTREE_H
    00022
    00023 #include <geos/export.h>
    00024 #include <geos/index/SpatialIndex.h> // for inheritance
    00025 #include <geos/index/quadtree/Root.h> // for composition
    00026
    00027 #include <vector>
    00028 #include <string>
    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 // Forward declarations
    00036 namespace geos {
    00037         namespace geom {
    00038                 class Envelope;
    00039         }
    00040         namespace index {
    00041                 namespace quadtree {
    00042                         // class Root;
    00043                 }
    00044         }
    00045 }
    00046
    00047 namespace geos {
    00048 namespace index { // geos::index
    00049 namespace quadtree { // geos::index::quadtree
    00050
    00073 class GEOS_DLL Quadtree: public SpatialIndex {
    00074
    00075 private:
    00076
    00077         std::vector<geom::Envelope *> newEnvelopes;
    00078
    00079         void collectStats(const geom::Envelope& itemEnv);
    00080
    00081         Root root;
    00082
    00094         double minExtent;
    00095
    00096 public:
    00104         static geom::Envelope* ensureExtent(const geom::Envelope *itemEnv,
    00105                         double minExtent);
    00106
    00111         Quadtree()
    00112                 :
    00113                 root(),
    00114                 minExtent(1.0)
    00115         {}
    00116
    00117         ~Quadtree();
    00118
    00120         int depth();
    00121
    00123         int size();
    00124
    00125         void insert(const geom::Envelope *itemEnv, void *item);
    00126
    00144         void query(const geom::Envelope *searchEnv, std::vector<void*>& ret);
    00145
    00146
    00163         void query(const geom::Envelope *searchEnv, ItemVisitor& visitor)
    00164         {
    00165                 /*
    00166                  * the items that are matched are the items in quads which
    00167                  * overlap the search envelope
    00168                  */
    00169                 root.visit(searchEnv, visitor);
    00170         }
    00171
    00179         bool remove(const geom::Envelope* itemEnv, void* item);
    00180
    00182         std::vector<void*>* queryAll();
    00183
    00184         std::string toString() const;
    00185
    00186 };
    00187
    00188 } // namespace geos::index::quadtree
    00189 } // namespace geos::index
    00190 } // namespace geos
    00191
    00192 #ifdef _MSC_VER
    00193 #pragma warning(pop)
    00194 #endif
    00195
    00196 #endif // GEOS_IDX_QUADTREE_QUADTREE_H
    00197
    00198 /**********************************************************************
    00199  * $Log$
    00200  * Revision 1.2  2006/04/03 08:29:30  strk
    00201  * Added port info, cleaned up log message, minor assertion checking.
    00202  *
    00203  * Revision 1.1  2006/03/22 12:22:50  strk
    00204  * indexQuadtree.h split
    00205  *
    00206  **********************************************************************/
    00207