GEOS 3.15.0dev
OverlayEdgeRing.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2020 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/algorithm/locate/IndexedPointInAreaLocator.h>
18#include <geos/geom/CoordinateSequence.h>
19#include <geos/geom/LinearRing.h>
20#include <geos/export.h>
21
22// Forward declarations
23namespace geos {
24namespace algorithm {
25namespace locate {
26class PointOnGeometryLocator;
27}
28}
29namespace geom {
30class Coordinate;
31class CoordinateXY;
32class CoordinateSequence;
33class GeometryFactory;
34class LinearRing;
35class Polygon;
36}
37namespace operation {
38namespace overlayng {
39class OverlayEdge;
40}
41}
42}
43
44namespace geos { // geos.
45namespace operation { // geos.operation
46namespace overlayng { // geos.operation.overlayng
47
48class GEOS_DLL OverlayEdgeRing {
49 using Coordinate = geos::geom::Coordinate;
50 using CoordinateXY = geos::geom::CoordinateXY;
51 using CoordinateSequence = geos::geom::CoordinateSequence;
52 using GeometryFactory = geos::geom::GeometryFactory;
53 using LinearRing = geos::geom::LinearRing;
54 using Polygon = geos::geom::Polygon;
55 using PointOnGeometryLocator = algorithm::locate::PointOnGeometryLocator;
56 using IndexedPointInAreaLocator = algorithm::locate::IndexedPointInAreaLocator;
57
58private:
59
60 // Members
61 OverlayEdge* startEdge;
62 std::unique_ptr<LinearRing> ring;
63 bool m_isHole;
64 mutable std::unique_ptr<IndexedPointInAreaLocator> locator;
65 OverlayEdgeRing* shell;
66 // a list of EdgeRings which are holes in this EdgeRing
67 std::vector<OverlayEdgeRing*> holes;
68
69 // Methods
70 void computeRingPts(OverlayEdge* start, CoordinateSequence& pts);
71 void computeRing(const std::shared_ptr<CoordinateSequence> & ringPts, const GeometryFactory* geometryFactory);
72
78 const CoordinateSequence& getCoordinates() const;
79 PointOnGeometryLocator* getLocator() const;
80 static void closeRing(CoordinateSequence& pts);
81 bool contains(const OverlayEdgeRing& otherRing) const;
82 bool isPointInOrOut(const OverlayEdgeRing& otherRing) const;
83
84
85public:
86
87 OverlayEdgeRing(OverlayEdge* start, const GeometryFactory* geometryFactory);
88
89 std::unique_ptr<LinearRing> getRing();
90 const LinearRing* getRingPtr() const;
91
92 const geom::Envelope& getEnvelope() const;
93
98 bool isHole() const;
99
105 void setShell(OverlayEdgeRing* p_shell);
106
112 bool hasShell() const;
113
119 const OverlayEdgeRing* getShell() const;
120
121 void addHole(OverlayEdgeRing* ring);
122
123 geom::Location locate(const CoordinateXY& pt) const;
124
125 const Coordinate& getCoordinate() const;
126
131 std::unique_ptr<Polygon> toPolygon(const GeometryFactory* factory);
132
133 OverlayEdge* getEdge();
134
153 OverlayEdgeRing* findEdgeRingContaining(const std::vector<OverlayEdgeRing*>& erList) const;
154
155
156};
157
158
159} // namespace geos.operation.overlayng
160} // namespace geos.operation
161} // namespace geos
162
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:71
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:38