GEOS 3.14.0dev
RelateSegmentString.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (c) 2024 Martin Davis
7 * Copyright (C) 2024 Paul Ramsey <pramsey@cleverelephant.ca>
8 *
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
13 *
14 **********************************************************************/
15
16#pragma once
17
18#include <geos/noding/BasicSegmentString.h>
19#include <geos/export.h>
20
21
22#include <string>
23#include <sstream>
24
25
26// Forward declarations
27namespace geos {
28namespace geom {
29 class CoordinateXY;
30 class CoordinateSequence;
31 class Geometry;
32}
33namespace operation {
34namespace relateng {
35 class RelateGeometry;
36 class NodeSection;
37}
38}
39}
40
41namespace geos { // geos.
42namespace operation { // geos.operation
43namespace relateng { // geos.operation.relateng
44
45
46
47class GEOS_DLL RelateSegmentString : public geos::noding::BasicSegmentString {
48 using BasicSegmentString = geos::noding::BasicSegmentString;
49 using Geometry = geos::geom::Geometry;
50 using CoordinateXY = geos::geom::CoordinateXY;
51 using CoordinateSequence = geos::geom::CoordinateSequence;
52
53private:
54
55 // Members
56 bool m_isA;
57 int m_dimension;
58 int m_id;
59 int m_ringId;
60 const RelateGeometry* m_inputGeom;
61 const Geometry* m_parentPolygonal = nullptr;
62
63 // Constructor
64 RelateSegmentString(
65 const CoordinateSequence* pts,
66 bool isA,
67 int dimension,
68 int id,
69 int ringId,
70 const Geometry* poly,
71 const RelateGeometry* inputGeom)
72 : BasicSegmentString(const_cast<CoordinateSequence*>(pts), nullptr)
73 , m_isA(isA)
74 , m_dimension(dimension)
75 , m_id(id)
76 , m_ringId(ringId)
77 , m_inputGeom(inputGeom)
78 , m_parentPolygonal(poly)
79 {}
80
81
82 // Methods
83
84 static const RelateSegmentString* createSegmentString(
85 const CoordinateSequence* pts,
86 bool isA, int dim, int elementId, int ringId,
87 const Geometry* poly, const RelateGeometry* parent);
88
96 const CoordinateXY* prevVertex(
97 std::size_t segIndex,
98 const CoordinateXY* pt) const;
99
106 const CoordinateXY* nextVertex(
107 std::size_t segIndex,
108 const CoordinateXY* pt) const;
109
110
111public:
112
113 static const RelateSegmentString* createLine(
114 const CoordinateSequence* pts,
115 bool isA, int elementId,
116 const RelateGeometry* parent);
117
118 static const RelateSegmentString* createRing(
119 const CoordinateSequence* pts,
120 bool isA, int elementId, int ringId,
121 const Geometry* poly, const RelateGeometry* parent);
122
123 inline bool isA() const {
124 return m_isA;
125 }
126
127 inline const RelateGeometry* getGeometry() const {
128 return m_inputGeom;
129 }
130
131 inline const Geometry* getPolygonal() const {
132 return m_parentPolygonal;
133 }
134
135 NodeSection* createNodeSection(std::size_t segIndex, const CoordinateXY intPt) const;
136
151 bool isContainingSegment(std::size_t segIndex, const CoordinateXY* pt) const;
152
153};
154
155} // namespace geos.operation.relateng
156} // namespace geos.operation
157} // namespace geos
158
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:197
Represents a list of contiguous line segments, and supports noding the segments.
Definition BasicSegmentString.h:44
Basic namespace for all GEOS functionalities.
Definition geos.h:39