GEOS 3.14.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#pragma once
20
21#include <geos/export.h>
22#include <geos/geom/Coordinate.h>
23#include <geos/geom/CoordinateSequence.h>
24#include <geos/geom/Geometry.h>
25#include <geos/geom/Point.h>
26#include <geos/geom/Triangle.h>
27
28#include <vector>
29
30// Forward declarations
31// namespace geos {
32// namespace geom {
33// class GeometryCollection;
34// }
35// }
36
37
38namespace geos {
39namespace algorithm { // geos::algorithm
40
41class GEOS_DLL MinimumBoundingCircle {
42
43private:
44
45 // member variables
46 const geom::Geometry* input;
47 std::vector<geom::CoordinateXY> extremalPts;
48 geom::CoordinateXY centre;
49 double radius;
50
51 void computeCentre();
52 void compute();
53 void computeCirclePoints();
54 geom::CoordinateXY lowestPoint(std::vector<geom::CoordinateXY>& pts);
55 geom::CoordinateXY pointWitMinAngleWithX(std::vector<geom::CoordinateXY>& pts, geom::CoordinateXY& P);
56 geom::CoordinateXY pointWithMinAngleWithSegment(std::vector<geom::CoordinateXY>& pts,
57 geom::CoordinateXY& P, geom::CoordinateXY& Q);
58 std::vector<geom::CoordinateXY> farthestPoints(std::vector<geom::CoordinateXY>& pts);
59
60
61public:
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> getMaximumDiameter();
97
106 std::unique_ptr<geom::Geometry> getDiameter();
107
116 std::vector<geom::CoordinateXY> getExtremalPoints();
117
124 geom::CoordinateXY getCentre();
125
131 double getRadius();
132
133};
134
135} // namespace geos::algorithm
136} // namespace geos
137
Basic namespace for all GEOS functionalities.
Definition geos.h:39