GEOS 3.14.0dev
CoverageEdge.h
1
2
3
4/**********************************************************************
5 *
6 * GEOS - Geometry Engine Open Source
7 * http://geos.osgeo.org
8 *
9 * Copyright (C) 2022 Paul Ramsey <pramsey@cleverelephant.ca>
10 *
11 * This is free software; you can redistribute and/or modify it under
12 * the terms of the GNU Lesser General Public Licence as published
13 * by the Free Software Foundation.
14 * See the COPYING file for more information.
15 *
16 **********************************************************************/
17
18#pragma once
19
20#include <geos/geom/CoordinateSequence.h>
21#include <geos/geom/LineSegment.h>
22#include <geos/util.h>
23
24// Forward declarations
25namespace geos {
26namespace geom {
27class Coordinate;
28class LinearRing;
29class LineString;
30class MultiLineString;
31class GeometryFactory;
32}
33}
34
35namespace geos { // geos.
36namespace coverage { // geos.coverage
37
46class GEOS_DLL CoverageEdge {
54
55
56private:
57
58 // Members
59 std::unique_ptr<CoordinateSequence> m_pts;
60 std::size_t m_ringCount ;
61 bool m_isFreeRing = true;
62
63 // Methods
64
65 static std::unique_ptr<CoordinateSequence>
66 extractEdgePoints(const CoordinateSequence& ring,
67 std::size_t start, std::size_t end);
68
69 static const Coordinate&
70 findDistinctPoint(
71 const CoordinateSequence& pts,
72 std::size_t index,
73 bool isForward,
74 const Coordinate& pt);
75
76
77public:
78
79 CoverageEdge(std::unique_ptr<CoordinateSequence> && pts, bool isFreeRing)
80 : m_pts(pts ? std::move(pts) : detail::make_unique<CoordinateSequence>())
81 , m_ringCount(0)
82 , m_isFreeRing(isFreeRing)
83 {}
84
94 const CoordinateSequence& ring);
95
105 const CoordinateSequence& ring,
106 std::size_t start,
107 std::size_t end);
108
109 static std::unique_ptr<CoverageEdge> createEdge(
110 const CoordinateSequence& ring);
111
112 static std::unique_ptr<CoverageEdge> createEdge(
113 const CoordinateSequence& ring,
114 std::size_t start,
115 std::size_t end);
116
117 static std::unique_ptr<MultiLineString> createLines(
118 const std::vector<CoverageEdge*>& edges,
119 const GeometryFactory* geomFactory);
120
121 std::unique_ptr<LineString> toLineString(
122 const GeometryFactory* geomFactory);
123
124 /* public */
125 void incRingCount()
126 {
127 m_ringCount++;
128 }
129
130 /* public */
131 std::size_t getRingCount() const
132 {
133 return m_ringCount;
134 }
135
142 bool isFreeRing() const
143 {
144 return m_isFreeRing;
145 }
146
147 void setCoordinates(const CoordinateSequence* pts)
148 {
149 m_pts = pts->clone();
150 }
151
152 const CoordinateSequence* getCoordinates() const
153 {
154 return m_pts.get();
155 }
156
157 const Coordinate& getEndCoordinate() const
158 {
159 return m_pts->getAt(m_pts->size() - 1);
160 }
161
162 const Coordinate& getStartCoordinate() const
163 {
164 return m_pts->getAt(0);
165 }
166
167
168};
169
170} // namespace geos.coverage
171} // namespace geos
Definition CoverageEdge.h:46
static LineSegment key(const CoordinateSequence &ring)
bool isFreeRing() const
Definition CoverageEdge.h:142
static LineSegment key(const CoordinateSequence &ring, std::size_t start, std::size_t end)
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
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:70
Definition LineSegment.h:61
Definition LineString.h:66
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple.
Definition LinearRing.h:54
Models a collection of LineStrings.
Definition MultiLineString.h:49
Basic namespace for all GEOS functionalities.
Definition geos.h:39