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  std::vector<geom::Coordinate> farthestPoints(std::vector<geom::Coordinate>& pts);
60 
61 
62 public:
63 
64  MinimumBoundingCircle(const geom::Geometry* geom):
65  input(nullptr),
66  radius(0.0)
67  {
68  input = geom;
69  centre.setNull();
70  }
71 
72  ~MinimumBoundingCircle() {};
73 
85  std::unique_ptr<geom::Geometry> getCircle();
86 
97  std::unique_ptr<geom::Geometry> getMaximumDiameter();
98 
107  std::unique_ptr<geom::Geometry> getDiameter();
108 
117  std::vector<geom::Coordinate> getExtremalPoints();
118 
125  geom::Coordinate getCentre();
126 
132  double getRadius();
133 
134 };
135 
136 } // namespace geos::algorithm
137 } // namespace geos
138 
139 #endif // GEOS_ALGORITHM_MINIMUMBOUNDINGCIRCLE_H
140 
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26