GEOS  3.9.0dev
MinimumBoundingCircle.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2019 Paul Ramsey <pramsey@cleverelephant.ca>
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: algorithm/MinimumBoundingCircle.java 2019-01-23
16  *
17  **********************************************************************/
18 
19 #ifndef GEOS_ALGORITHM_MINIMUMBOUNDINGCIRCLE_H
20 #define GEOS_ALGORITHM_MINIMUMBOUNDINGCIRCLE_H
21 
22 #include <geos/export.h>
23 #include <geos/geom/Coordinate.h>
24 #include <geos/geom/CoordinateSequence.h>
25 #include <geos/geom/Geometry.h>
26 #include <geos/geom/Point.h>
27 #include <geos/geom/Triangle.h>
28 
29 #include <vector>
30 
31 // Forward declarations
32 // namespace geos {
33 // namespace geom {
34 // class GeometryCollection;
35 // }
36 // }
37 
38 
39 namespace geos {
40 namespace algorithm { // geos::algorithm
41 
42 class GEOS_DLL MinimumBoundingCircle {
43 
44 private:
45 
46  // member variables
47  const geom::Geometry* input;
48  std::vector<geom::Coordinate> extremalPts;
49  geom::Coordinate centre;
50  double radius;
51 
52  void computeCentre();
53  void compute();
54  void computeCirclePoints();
55  geom::Coordinate lowestPoint(std::vector<geom::Coordinate>& pts);
56  geom::Coordinate pointWitMinAngleWithX(std::vector<geom::Coordinate>& pts, geom::Coordinate& P);
57  geom::Coordinate pointWithMinAngleWithSegment(std::vector<geom::Coordinate>& pts,
58  geom::Coordinate& P, geom::Coordinate& Q);
59 
60 
61 public:
62 
63  MinimumBoundingCircle(const geom::Geometry* geom):
64  input(nullptr),
65  radius(0.0)
66  {
67  input = geom;
68  centre.setNull();
69  }
70 
71  ~MinimumBoundingCircle() {};
72 
84  std::unique_ptr<geom::Geometry> getCircle();
85 
96  std::unique_ptr<geom::Geometry> getFarthestPoints();
97 
106  std::unique_ptr<geom::Geometry> getDiameter();
107 
116  std::vector<geom::Coordinate> getExtremalPoints();
117 
124  geom::Coordinate getCentre();
125 
131  double getRadius();
132 
133 };
134 
135 } // namespace geos::algorithm
136 } // namespace geos
137 
138 #endif // GEOS_ALGORITHM_MINIMUMBOUNDINGCIRCLE_H
139 
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26