GEOS  3.7.1
BoundablePair.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2016 Daniel Baston
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  * Last port: index/strtree/BoundablePair.java (JTS-1.14)
16  *
17  **********************************************************************/
18 
19 #ifndef GEOS_INDEX_STRTREE_BOUNDABLEPAIR_H
20 #define GEOS_INDEX_STRTREE_BOUNDABLEPAIR_H
21 
22 #include <geos/index/strtree/Boundable.h>
23 #include <geos/index/strtree/ItemDistance.h>
24 #include <queue>
25 
39 namespace geos {
40 namespace index {
41 namespace strtree {
42 
43 class BoundablePair {
44  private:
45  const Boundable* boundable1;
46  const Boundable* boundable2;
47  ItemDistance* itemDistance;
48  double mDistance;
49 
50  public:
51  struct BoundablePairQueueCompare {
52  bool operator()(const BoundablePair* a, const BoundablePair* b) {
53  return a->getDistance() > b->getDistance();
54  }
55  };
56 
57  typedef std::priority_queue<BoundablePair*, std::vector<BoundablePair*>, BoundablePairQueueCompare> BoundablePairQueue;
58  BoundablePair(const Boundable* boundable1, const Boundable* boundable2, ItemDistance* itemDistance);
59 
67  const Boundable* getBoundable(int i) const;
68 
78  double distance() const;
79 
90  double getDistance() const;
91 
97  bool isLeaves() const;
98 
99  static bool isComposite(const Boundable* item);
100 
101  static double area(const Boundable* b);
102 
103  void expandToQueue(BoundablePairQueue &, double minDistance);
104  void expand(const Boundable* bndComposite, const Boundable* bndOther, BoundablePairQueue & priQ, double minDistance);
105 };
106 }
107 }
108 }
109 
110 #endif
111