• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List

STRtree.h

00001 /**********************************************************************
00002  * $Id: STRtree.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/strtree/STRtree.java rev. 1.11
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> // for inheritance
00025 #include <geos/index/SpatialIndex.h> // for inheritance
00026 #include <geos/geom/Envelope.h> // for inlines
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 // Forward declarations
00036 namespace geos {
00037         namespace index { 
00038                 namespace strtree { 
00039                         class Boundable;
00040                 }
00041         }
00042 }
00043 
00044 namespace geos {
00045 namespace index { // geos::index
00046 namespace strtree { // geos::index::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         //static double centreX(const geom::Envelope *e);
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 } // namespace geos::index::strtree
00147 } // namespace geos::index
00148 } // namespace geos
00149 
00150 
00151 #ifdef _MSC_VER
00152 #pragma warning(pop)
00153 #endif
00154 
00155 #endif // GEOS_INDEX_STRTREE_STRTREE_H
00156 
00157 /**********************************************************************
00158  * $Log$
00159  * Revision 1.3  2006/06/12 10:49:43  strk
00160  * unsigned int => size_t
00161  *
00162  * Revision 1.2  2006/04/03 08:43:09  strk
00163  * Added port info, minor cleanups
00164  *
00165  * Revision 1.1  2006/03/21 10:47:34  strk
00166  * indexStrtree.h split
00167  *
00168  **********************************************************************/
00169 

Generated on Thu Aug 2 2012 15:56:09 for GEOS by  doxygen 1.7.2