GEOS 3.2.1
|
00001 /********************************************************************** 00002 * $Id: Node.h 2556 2009-06-06 22:22:28Z strk $ 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/Node.java rev 1.8 (JTS-1.10) 00017 * 00018 **********************************************************************/ 00019 00020 #ifndef GEOS_IDX_QUADTREE_NODE_H 00021 #define GEOS_IDX_QUADTREE_NODE_H 00022 00023 #include <geos/export.h> 00024 #include <geos/index/quadtree/NodeBase.h> // for inheritance 00025 #include <geos/geom/Coordinate.h> // for composition 00026 #include <geos/geom/Envelope.h> // for inline 00027 00028 #include <string> 00029 #include <memory> 00030 00031 // Forward declarations 00032 namespace geos { 00033 namespace geom { 00034 //class Coordinate; 00035 class Envelope; 00036 } 00037 } 00038 00039 namespace geos { 00040 namespace index { // geos::index 00041 namespace quadtree { // geos::index::quadtree 00042 00051 class GEOS_DLL Node: public NodeBase { 00052 00053 private: 00054 00056 std::auto_ptr<geom::Envelope> env; 00057 00058 geom::Coordinate centre; 00059 00060 int level; 00061 00068 Node* getSubnode(int index); 00069 00070 std::auto_ptr<Node> createSubnode(int index); 00071 00072 protected: 00073 00074 bool isSearchMatch(const geom::Envelope& searchEnv) const { 00075 return env->intersects(searchEnv); 00076 } 00077 00078 public: 00079 00080 // Create a node computing level from given envelope 00081 static std::auto_ptr<Node> createNode(const geom::Envelope& env); 00082 00084 // 00088 static std::auto_ptr<Node> createExpanded(std::auto_ptr<Node> node, 00089 const geom::Envelope& addEnv); 00090 00091 Node(std::auto_ptr<geom::Envelope> nenv, int nlevel) 00092 : 00093 env(nenv), 00094 centre((env->getMinX()+env->getMaxX())/2, 00095 (env->getMinY()+env->getMaxY())/2), 00096 level(nlevel) 00097 { 00098 } 00099 00100 virtual ~Node() {} 00101 00104 geom::Envelope* getEnvelope() { return env.get(); } 00105 00111 Node* getNode(const geom::Envelope *searchEnv); 00112 00117 NodeBase* find(const geom::Envelope *searchEnv); 00118 00119 void insertNode(std::auto_ptr<Node> node); 00120 00121 std::string toString() const; 00122 00123 }; 00124 00125 } // namespace geos::index::quadtree 00126 } // namespace geos::index 00127 } // namespace geos 00128 00129 #endif // GEOS_IDX_QUADTREE_NODE_H 00130 00131 /********************************************************************** 00132 * $Log$ 00133 * Revision 1.1 2006/03/22 12:22:50 strk 00134 * indexQuadtree.h split 00135 * 00136 **********************************************************************/ 00137