GEOS  3.8.0dev
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/constants.h>
20 #include <vector>
21 #include <limits>
22 
23 // forward declarations
24 namespace geos {
25 namespace index {
26 class ItemVisitor;
27 }
28 }
29 
30 
31 namespace geos {
32 namespace index {
33 namespace intervalrtree {
34 
35 class IntervalRTreeNode {
36 private:
37 protected:
38  double min;
39  double max;
40 
41  bool
42  intersects(double queryMin, double queryMax) const
43  {
44  if(min > queryMax || max < queryMin) {
45  return false;
46  }
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 p_min, double p_max)
60  : min(p_min),
61  max(p_max)
62  { }
63 
64  virtual
65  ~IntervalRTreeNode()
66  { }
67 
68  double
69  getMin() const
70  {
71  return min;
72  }
73 
74  double
75  getMax() const
76  {
77  return max;
78  }
79 
80  virtual void query(double queryMin, double queryMax, ItemVisitor* visitor) const = 0;
81 
82  //std::string toString()
83  //{
84  // return WKTWriter.toLineString(new Coordinate(min, 0), new Coordinate(max, 0));
85  //}
86 
87 
88  //class NodeComparator
89  //{
90  //public:
91  static bool
92  compare(const IntervalRTreeNode* n1, const IntervalRTreeNode* n2)
93  {
94  double mid1 = n1->getMin() + n1->getMax();
95  double mid2 = n2->getMin() + n2->getMax();
96 
97  return mid1 > mid2;
98  }
99  //};
100 
101 };
102 
103 } // geos::index::intervalrtree
104 } // geos::index
105 } // geos
106 
107 #endif // GEOS_INDEX_INTERVALRTREE_INTERVALRTREENODE_H
108 
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25