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