GEOS 3.3.4

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

- File List

IntervalRTreeNode.h
1 /**********************************************************************
2 * $Id: IntervalRTreeNode.h 2554 2009-06-06 21:14:51Z strk $
3 *
4 * GEOS - Geometry Engine Open Source
5 * http://geos.refractions.net
6 *
7 * Copyright (C) 2006 Refractions Research Inc.
8 *
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
13 *
14 *
15 **********************************************************************/
16
17 #ifndef GEOS_INDEX_INTERVALRTREE_INTERVALRTREENODE_H
18 #define GEOS_INDEX_INTERVALRTREE_INTERVALRTREENODE_H
19
20 #include <geos/platform.h>
21 #include <vector>
22 #include <limits>
23
24 // forward declarations
25 namespace geos {
26 namespace index {
27 class ItemVisitor;
28 }
29 }
30
31
32 namespace geos {
33 namespace index {
34 namespace intervalrtree {
35
36 class IntervalRTreeNode
37 {
38 private:
39 protected:
40 double min;
41 double max;
42
43 bool intersects( double queryMin, double queryMax) const
44 {
45 if (min > queryMax || max < queryMin)
46 return false;
47
48 return true;
49 }
50
51 public:
52 typedef std::vector<const IntervalRTreeNode *> ConstVect;
53
54 IntervalRTreeNode()
55 : min( DoubleInfinity ),
56 max( DoubleNegInfinity )
57 { }
58
59 IntervalRTreeNode( double min, double max)
60 : min( min ),
61 max( max )
62 { }
63
64 virtual ~IntervalRTreeNode()
65 { }
66
67 double getMin() const
68 {
69 return min;
70 }
71
72 double getMax() const
73 {
74 return max;
75 }
76
77 virtual void query( double queryMin, double queryMax, ItemVisitor * visitor) const =0;
78
79 //std::string toString()
80 //{
81 // return WKTWriter.toLineString(new Coordinate(min, 0), new Coordinate(max, 0));
82 //}
83
84
85 //class NodeComparator
86 //{
87 //public:
88 static bool compare( const IntervalRTreeNode * n1, const IntervalRTreeNode * n2)
89 {
90 //IntervalRTreeNode * n1 = dynamic_cast<IntervalRTreeNode *>( o1);
91 //IntervalRTreeNode * n2 = dynamic_cast<IntervalRTreeNode *>( o2);
92
93 double mid1 = (n1->getMin() + n1->getMax()) / 2;
94 double mid2 = (n2->getMin() + n2->getMax()) / 2;
95
96 //if (mid1 < mid2) return -1;
97 //if (mid1 > mid2) return 1;
98 //return 0;
99
100 return mid1 > mid2;
101 }
102 //};
103
104 };
105
106 } // geos::index::intervalrtree
107 } // geos::index
108 } // geos
109
110 #endif // GEOS_INDEX_INTERVALRTREE_INTERVALRTREENODE_H
111 /**********************************************************************
112 * $Log$
113 **********************************************************************/
114