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