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

- File List

# IntervalRTreeNode.h

    00001 /**********************************************************************
    00002  * $Id: IntervalRTreeNode.h 2554 2009-06-06 21:14:51Z 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
    00017 #ifndef GEOS_INDEX_INTERVALRTREE_INTERVALRTREENODE_H
    00018 #define GEOS_INDEX_INTERVALRTREE_INTERVALRTREENODE_H
    00019
    00020 #include <geos/platform.h>
    00021 #include <vector>
    00022 #include <limits>
    00023
    00024 // forward declarations
    00025 namespace geos {
    00026         namespace index {
    00027                 class ItemVisitor;
    00028         }
    00029 }
    00030
    00031
    00032 namespace geos {
    00033 namespace index {
    00034 namespace intervalrtree {
    00035
    00036 class IntervalRTreeNode
    00037 {
    00038 private:
    00039 protected:
    00040         double min;
    00041         double max;
    00042
    00043         bool intersects( double queryMin, double queryMax) const
    00044         {
    00045                 if (min > queryMax || max < queryMin)
    00046                         return false;
    00047
    00048                 return true;
    00049         }
    00050
    00051 public:
    00052         typedef std::vector<const IntervalRTreeNode *> ConstVect;
    00053
    00054         IntervalRTreeNode()
    00055         :       min( DoubleInfinity ),
    00056                 max( DoubleNegInfinity )
    00057         { }
    00058
    00059         IntervalRTreeNode( double min, double max)
    00060         :       min( min ),
    00061                 max( max )
    00062         { }
    00063
    00064         virtual ~IntervalRTreeNode()
    00065         { }
    00066
    00067         double getMin() const
    00068         {
    00069                 return min;
    00070         }
    00071
    00072         double getMax() const
    00073         {
    00074                 return max;
    00075         }
    00076
    00077         virtual void query( double queryMin, double queryMax, ItemVisitor * visitor) const =0;
    00078
    00079         //std::string toString()
    00080         //{
    00081         //      return WKTWriter.toLineString(new Coordinate(min, 0), new Coordinate(max, 0));
    00082         //}
    00083
    00084
    00085         //class NodeComparator
    00086         //{
    00087         //public:
    00088                 static bool compare( const IntervalRTreeNode * n1, const IntervalRTreeNode * n2)
    00089                 {
    00090                         //IntervalRTreeNode * n1 = dynamic_cast<IntervalRTreeNode *>( o1);
    00091                         //IntervalRTreeNode * n2 = dynamic_cast<IntervalRTreeNode *>( o2);
    00092
    00093                         double mid1 = (n1->getMin() + n1->getMax()) / 2;
    00094                         double mid2 = (n2->getMin() + n2->getMax()) / 2;
    00095
    00096                         //if (mid1 < mid2) return -1;
    00097                         //if (mid1 > mid2) return 1;
    00098                         //return 0;
    00099
    00100                         return mid1 > mid2;
    00101                 }
    00102         //};
    00103
    00104 };
    00105
    00106 } // geos::index::intervalrtree
    00107 } // geos::index
    00108 } // geos
    00109
    00110 #endif // GEOS_INDEX_INTERVALRTREE_INTERVALRTREENODE_H
    00111 /**********************************************************************
    00112  * $Log$
    00113  **********************************************************************/
    00114