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

# Node.h

    00001 /**********************************************************************
    00002  * $Id: Node.h 1820 2006-09-06 16:54:23Z 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 #ifndef GEOS_IDX_QUADTREE_NODE_H
    00017 #define GEOS_IDX_QUADTREE_NODE_H
    00018
    00019 #include <geos/index/quadtree/NodeBase.h> // for inheritance
    00020 #include <geos/geom/Coordinate.h> // for composition
    00021 #include <geos/geom/Envelope.h> // for inline
    00022
    00023 #include <string>
    00024
    00025 // Forward declarations
    00026 namespace geos {
    00027         namespace geom {
    00028                 //class Coordinate;
    00029                 class Envelope;
    00030         }
    00031 }
    00032
    00033 namespace geos {
    00034 namespace index { // geos::index
    00035 namespace quadtree { // geos::index::quadtree
    00036
    00045 class Node: public NodeBase {
    00046
    00047 private:
    00048
    00049         geom::Envelope *env;
    00050
    00051         geom::Coordinate centre;
    00052
    00053         int level;
    00054
    00055         Node* getSubnode(int index);
    00056
    00057         Node* createSubnode(int index);
    00058
    00059 protected:
    00060
    00061         bool isSearchMatch(const geom::Envelope *searchEnv) {
    00062                 return env->intersects(searchEnv);
    00063         }
    00064
    00065 public:
    00066
    00067         static Node* createNode(geom::Envelope *env);
    00068
    00069         static Node* createExpanded(Node *node,
    00070                         const geom::Envelope *addEnv);
    00071
    00072         // Takes ownership of envelope
    00073         Node(geom::Envelope *nenv, int nlevel)
    00074                 :
    00075                 env(nenv),
    00076                 centre((nenv->getMinX()+nenv->getMaxX())/2,
    00077                         (nenv->getMinY()+nenv->getMaxY())/2),
    00078                 level(nlevel)
    00079         {
    00080         }
    00081
    00082         virtual ~Node() { delete env; }
    00083
    00084         geom::Envelope* getEnvelope() { return env; }
    00085
    00091         Node* getNode(const geom::Envelope *searchEnv);
    00092
    00097         NodeBase* find(const geom::Envelope *searchEnv);
    00098
    00099         void insertNode(Node *node);
    00100
    00101         std::string toString() const;
    00102
    00103 };
    00104
    00105 } // namespace geos::index::quadtree
    00106 } // namespace geos::index
    00107 } // namespace geos
    00108
    00109 #endif // GEOS_IDX_QUADTREE_NODE_H
    00110
    00111 /**********************************************************************
    00112  * $Log$
    00113  * Revision 1.1  2006/03/22 12:22:50  strk
    00114  * indexQuadtree.h split
    00115  *
    00116  **********************************************************************/
    00117