17#include <geos/geom/Coordinate.h>
18#include <geos/simplify/LinkedRing.h>
19#include <geos/index/VertexSequencePackedRtree.h>
58 RingHull(
const LinearRing* p_ring,
bool p_isOuter);
60 void setMinVertexNum(std::size_t minVertexNum);
62 void setMaxAreaDelta(
double maxAreaDelta);
64 const Envelope* getEnvelope()
const;
66 std::unique_ptr<LinearRing> getHull(RingHullIndex& hullIndex);
68 static bool isConvex(
const LinkedRing& vertexRing, std::size_t index);
70 static double area(
const LinkedRing& vertexRing, std::size_t index);
72 void compute(RingHullIndex& hullIndex);
74 std::unique_ptr<Polygon> toGeometry()
const;
92 Corner(std::size_t p_idx, std::size_t p_prev, std::size_t p_next,
double p_area)
99 inline int compareTo(
const Corner& rhs)
const {
100 if (area == rhs.getArea()) {
101 if (index == rhs.getIndex())
103 else return index < rhs.getIndex() ? -1 : 1;
105 else return area < rhs.getArea() ? -1 : 1;
108 inline bool operator< (
const Corner& rhs)
const {
109 return compareTo(rhs) < 0;
112 inline bool operator> (
const Corner& rhs)
const {
113 return compareTo(rhs) > 0;
116 inline bool operator==(
const Corner& rhs)
const {
117 return compareTo(rhs) == 0;
120 bool isVertex(std::size_t p_index)
const;
121 std::size_t getIndex()
const;
122 double getArea()
const;
123 void envelope(
const LinkedRing& ring, Envelope& env)
const;
124 bool intersects(
const Coordinate& v,
const LinkedRing& ring)
const;
125 bool isRemoved(
const LinkedRing& ring)
const;
126 std::unique_ptr<LineString> toLineString(
const LinkedRing& ring);
129 inline bool operator()(
const Corner & a,
const Corner & b)
const {
134 using PriorityQueue = std::priority_queue<Corner, std::vector<Corner>, Corner::Greater>;
140 const LinearRing* inputRing;
141 double targetVertexNum = -1.0;
142 double targetAreaDelta = -1.0;
149 std::unique_ptr<CoordinateSequence> vertex;
150 std::unique_ptr<LinkedRing> vertexRing;
151 double areaDelta = 0;
158 std::unique_ptr<VertexSequencePackedRtree> vertexIndex;
160 Corner::PriorityQueue cornerQueue;
163 void init(CoordinateSequence& ring,
bool isOuter);
164 void addCorner(std::size_t i, Corner::PriorityQueue& cornerQueue);
165 bool isAtTarget(
const Corner& corner);
176 void removeCorner(
const Corner& corner, Corner::PriorityQueue& cornerQueue);
177 bool isRemovable(
const Corner& corner,
const RingHullIndex& hullIndex)
const;
188 bool hasIntersectingVertex(
189 const Corner& corner,
190 const Envelope& cornerEnv,
191 const RingHull* hull)
const;
193 const Coordinate& getCoordinate(std::size_t index)
const;
196 const Envelope& cornerEnv,
197 std::vector<std::size_t>& result)
const;
199 void queryHull(
const Envelope& queryEnv, std::vector<Coordinate>& pts);
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
Definition LineString.h:66
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple.
Definition LinearRing.h:54
Represents a linear polygon, which may include holes.
Definition Polygon.h:61
Definition VertexSequencePackedRtree.h:49
Basic namespace for all GEOS functionalities.
Definition geos.h:39