GEOS 3.10.1
NodedSegmentString.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 * Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
8 * Copyright (C) 2006 Refractions Research Inc.
9 * Copyright (C) 2001-2002 Vivid Solutions Inc.
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 *
19 * Last port: noding/NodedSegmentString.java r320 (JTS-1.12)
20 *
21 **********************************************************************/
22
23#ifndef GEOS_NODING_NODEDSEGMENTSTRING_H
24#define GEOS_NODING_NODEDSEGMENTSTRING_H
25
26#include <geos/inline.h>
27#include <geos/export.h>
28#include <geos/noding/NodableSegmentString.h> // for inheritance
29#include <geos/geom/CoordinateSequence.h> // for inlines
30#include <geos/algorithm/LineIntersector.h>
31#include <geos/noding/SegmentNode.h>
32#include <geos/noding/SegmentNodeList.h>
33#include <geos/noding/SegmentString.h>
34#include <geos/geom/Coordinate.h>
35
36#include <cstddef>
37
38#ifdef _MSC_VER
39#pragma warning(push)
40#pragma warning(disable: 4251 4355) // warning C4355: 'this' : used in base member initializer list
41#endif
42
43namespace geos {
44namespace noding { // geos::noding
45
59public:
60
61 // TODO: provide a templated method using an output iterator
62 template <class II>
63 static void
64 getNodedSubstrings(II from, II too_far,
65 SegmentString::NonConstVect* resultEdgelist)
66 {
67 for(II i = from; i != too_far; ++i) {
68 NodedSegmentString* nss = dynamic_cast<NodedSegmentString*>(*i);
69 assert(nss);
70 nss->getNodeList().addSplitEdges(resultEdgelist);
71 }
72 }
73
74 template <class C>
75 static void
76 getNodedSubstrings(C* segStrings,
77 SegmentString::NonConstVect* resultEdgelist)
78 {
79 getNodedSubstrings(segStrings->begin(), segStrings->end(), resultEdgelist);
80 }
81
82 static void getNodedSubstrings(const SegmentString::NonConstVect& segStrings,
83 SegmentString::NonConstVect* resultEdgeList);
84
86 static SegmentString::NonConstVect* getNodedSubstrings(
87 const SegmentString::NonConstVect& segStrings);
88
89 std::vector<geom::Coordinate> getNodedCoordinates();
90
91
101 NodedSegmentString(geom::CoordinateSequence* newPts, const void* newContext)
102 : NodableSegmentString(newContext)
103 , nodeList(this)
104 , pts(newPts)
105 {}
106
108 : NodableSegmentString(ss->getData())
109 , nodeList(this)
110 , pts(ss->getCoordinates()->clone())
111 {}
112
113 ~NodedSegmentString() override = default;
114
115 SegmentNodeList& getNodeList();
116
117 const SegmentNodeList& getNodeList() const;
118
119 size_t
120 size() const override
121 {
122 return pts->size();
123 }
124
125 const geom::Coordinate& getCoordinate(std::size_t i) const override;
126
128 geom::CoordinateSequence* releaseCoordinates();
129
130 bool isClosed() const override;
131
132 std::ostream& print(std::ostream& os) const override;
133
134
142 int getSegmentOctant(std::size_t index) const;
143
150 std::size_t segmentIndex, std::size_t geomIndex);
151
160 std::size_t segmentIndex,
161 std::size_t geomIndex, std::size_t intIndex);
162
171 std::size_t segmentIndex);
172
173
174private:
175
176 SegmentNodeList nodeList;
177
178 std::unique_ptr<geom::CoordinateSequence> pts;
179
180 static int safeOctant(const geom::Coordinate& p0, const geom::Coordinate& p1);
181
182};
183
184} // namespace geos::noding
185} // namespace geos
186
187#ifdef _MSC_VER
188#pragma warning(pop)
189#endif
190
191#ifdef GEOS_INLINE
192#include "geos/noding/NodedSegmentString.inl"
193#endif
194
195#endif // GEOS_NODING_NODEDSEGMENTSTRING_H
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition: LineIntersector.h:50
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
An interface for classes which support adding nodes to a segment string.
Definition: NodableSegmentString.h:37
Represents a list of contiguous line segments, and supports noding the segments.
Definition: NodedSegmentString.h:58
static SegmentString::NonConstVect * getNodedSubstrings(const SegmentString::NonConstVect &segStrings)
Returns allocated object.
void addIntersection(algorithm::LineIntersector *li, std::size_t segmentIndex, std::size_t geomIndex, std::size_t intIndex)
Add an SegmentNode for intersection intIndex.
NodedSegmentString(geom::CoordinateSequence *newPts, const void *newContext)
Creates a new segment string from a list of vertices.
Definition: NodedSegmentString.h:101
void addIntersections(algorithm::LineIntersector *li, std::size_t segmentIndex, std::size_t geomIndex)
Add SegmentNodes for one or both intersections found for a segment of an edge to the edge intersectio...
void addIntersection(const geom::Coordinate &intPt, std::size_t segmentIndex)
Add an SegmentNode for intersection intIndex.
geom::CoordinateSequence * getCoordinates() const override
Return a pointer to the CoordinateSequence associated with this SegmentString.
int getSegmentOctant(std::size_t index) const
Gets the octant of the segment starting at vertex index.
A list of the SegmentNode present along a NodedSegmentString.
Definition: SegmentNodeList.h:56
void addSplitEdges(std::vector< SegmentString * > &edgeList)
An interface for classes which represent a sequence of contiguous line segments.
Definition: SegmentString.h:46
Basic namespace for all GEOS functionalities.
Definition: geos.h:40