GEOS 3.14.0dev
CoverageRing.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2022 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/noding/BasicSegmentString.h>
18
19#include <deque>
20
21// Forward declarations
22namespace geos {
23namespace geom {
24class Coordinate;
25class CoordinateSequence;
26class Geometry;
27class GeometryFactory;
28class LineString;
29class LinearRing;
30class Polygon;
31}
32}
33
34namespace geos { // geos.
35namespace coverage { // geos.coverage
36
37class GEOS_DLL CoverageRing : public noding::BasicSegmentString {
38 using Coordinate = geos::geom::Coordinate;
39 using CoordinateSequence = geos::geom::CoordinateSequence;
40 using Geometry = geos::geom::Geometry;
41 using GeometryFactory = geos::geom::GeometryFactory;
42 using Polygon = geos::geom::Polygon;
43 using LineString = geos::geom::LineString;
44 using LinearRing = geos::geom::LinearRing;
45
46private:
47
48 // Members
49 bool m_isInteriorOnRight;
50 std::vector<bool> m_isInvalid;
51 std::vector<bool> m_isMatched;
52
53 std::size_t findInvalidStart(std::size_t index);
54
55 std::size_t findInvalidEnd(std::size_t index);
56
57 std::size_t nextMarkIndex(std::size_t index);
58
68 std::unique_ptr<LineString> createLine(
69 std::size_t startIndex,
70 std::size_t endIndex,
71 const GeometryFactory* geomFactory);
72
73 std::unique_ptr<CoordinateSequence> extractSection(
74 std::size_t startIndex, std::size_t endIndex);
75
76 std::unique_ptr<CoordinateSequence> extractSectionWrap(
77 std::size_t startIndex, std::size_t endIndex);
78
79public:
80
81 CoverageRing(CoordinateSequence* pts, bool interiorOnRight);
82
83 CoverageRing(const LinearRing* ring, bool isShell);
84
85 geom::Envelope getEnvelope(std::size_t start, std::size_t end);
86
94 static bool isKnown(std::vector<CoverageRing*>& rings);
95
102 bool isInteriorOnRight() const;
103
109 void markInvalid(std::size_t index);
110
116 void markMatched(std::size_t index);
117
124 bool isKnown() const;
125
132 bool isInvalid(std::size_t i) const;
133
139 bool isInvalid() const;
140
146 bool hasInvalid() const;
147
154 bool isKnown(std::size_t i) const;
155
164 const Coordinate& findVertexPrev(std::size_t index, const Coordinate& pt) const;
165
174 const Coordinate& findVertexNext(std::size_t index, const Coordinate& pt) const;
175
182 std::size_t prev(std::size_t index) const;
183
190 std::size_t next(std::size_t index) const;
191
192 void createInvalidLines(
193 const GeometryFactory* geomFactory,
194 std::vector<std::unique_ptr<LineString>>& lines);
195
196};
197
198} // namespace geos.coverage
199} // namespace geos
200
201
202
203
204
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
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:197
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
Basic namespace for all GEOS functionalities.
Definition geos.h:39