GEOS 3.13.1
MinimumAreaRectangle.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2023 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#pragma once
16
17#include <geos/export.h>
18
19#include <vector>
20#include <memory>
21
22// Forward declarations
23namespace geos {
24 namespace geom {
26 class CoordinateXY;
27 class Geometry;
28 class GeometryFactory;
29 class LineSegment;
30 class LineString;
31 class Polygon;
32 }
33}
34
36using geos::geom::CoordinateXY;
42
43
44namespace geos {
45namespace algorithm { // geos::algorithm
46
47
67class GEOS_DLL MinimumAreaRectangle {
68
69private:
70
71 // Members
72 const Geometry* m_inputGeom;
73 bool m_isConvex;
74
75 // Methods
76 std::unique_ptr<Geometry> getMinimumRectangle();
77
78 std::unique_ptr<Geometry> computeConvex(const Geometry* convexGeom);
79
88 std::unique_ptr<Polygon> computeConvexRing(const CoordinateSequence* ring);
89
90 std::size_t findFurthestVertex(
91 const CoordinateSequence* pts,
92 const LineSegment& baseSeg,
93 std::size_t startIndex,
94 int orient);
95
96 bool isFurtherOrEqual(double d1, double d2, int orient);
97
98 static double orientedDistance(
99 const LineSegment& seg,
100 const CoordinateXY& p,
101 int orient);
102
103 static std::size_t getNextIndex(
104 const CoordinateSequence* ring,
105 std::size_t index);
106
113 static std::unique_ptr<LineString> computeMaximumLine(
114 const CoordinateSequence* pts,
115 const GeometryFactory* factory);
116
117
118public:
119
126 : m_inputGeom(inputGeom)
127 , m_isConvex(false)
128 {};
129
139 MinimumAreaRectangle(const Geometry* inputGeom, bool isConvex)
140 : m_inputGeom(inputGeom)
141 , m_isConvex(isConvex)
142 {};
143
152 static std::unique_ptr<Geometry> getMinimumRectangle(const Geometry* geom);
153
154};
155
156
157} // namespace geos::algorithm
158} // namespace geos
159
Definition MinimumAreaRectangle.h:67
MinimumAreaRectangle(const Geometry *inputGeom, bool isConvex)
Definition MinimumAreaRectangle.h:139
MinimumAreaRectangle(const Geometry *inputGeom)
Definition MinimumAreaRectangle.h:125
static std::unique_ptr< Geometry > getMinimumRectangle(const Geometry *geom)
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:70
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:197
Definition LineSegment.h:61
Definition LineString.h:66
Represents a linear polygon, which may include holes.
Definition Polygon.h:61
Basic namespace for all GEOS functionalities.
Definition geos.h:39