17#include <geos/noding/Noder.h>
18#include <geos/noding/SegmentString.h>
19#include <geos/geom/LineSegment.h>
20#include <geos/noding/BasicSegmentString.h>
22#include <unordered_set>
27class CoordinateSequence;
31class NodedSegmentString;
61 class BoundaryChainMap {
67 std::vector<bool> isBoundary;
71 std::size_t startIndex,
76 std::size_t findChainStart(std::size_t index)
const;
77 std::size_t findChainEnd(std::size_t index)
const;
83 isBoundary.resize(ss->size()-1,
false);
86 void setBoundarySegment(std::size_t index);
87 void createChains(std::vector<SegmentString*>& chains,
bool constructZ,
bool constructM);
93 BoundaryChainMap& segMap,
98 , m_flip(seq.
getAt<geom::CoordinateXY>(index).compareTo(seq.
getAt<geom::CoordinateXY>(index + 1)) < 0)
101 const geom::CoordinateXY& p0()
const {
102 return m_seq.getAt<geom::CoordinateXY>(m_flip ? m_index : m_index + 1);
105 const geom::CoordinateXY& p1()
const {
106 return m_seq.getAt<geom::CoordinateXY>(m_flip ? m_index + 1 : m_index);
109 void markBoundary()
const {
110 m_segMap.setBoundarySegment(m_index);
113 bool operator==(
const Segment& other)
const {
114 return p0().equals2D(other.p0()) && p1().equals2D(other.p1());
118 std::size_t operator()(
const Segment& s)
const {
119 std::size_t h = std::hash<double>{}(s.p0().x);
120 h ^= (std::hash<double>{}(s.p0().y) << 1);
121 h ^= (std::hash<double>{}(s.p1().x) << 1);
122 h ^= (std::hash<double>{}(s.p1().y) << 1);
129 BoundaryChainMap& m_segMap;
137 using SegmentSet = std::unordered_set<Segment, Segment::HashCode>;
140 : m_chainList(
nullptr)
141 , m_constructZ(
false)
142 , m_constructM(
false)
147 void computeNodes(std::vector<SegmentString*>* inputSegStrings)
override;
153 std::vector<SegmentString*>* m_chainList;
154 std::vector<std::unique_ptr<geom::CoordinateSequence>> m_substrings;
159 void addSegments(std::vector<SegmentString*>* segStrings,
161 std::vector<BoundaryChainMap>& includedSegs);
164 BoundaryChainMap& segInclude,
167 static bool segSetContains(
168 SegmentSet& segSet, Segment& seg);
170 static void markBoundarySegments(SegmentSet& segSet);
172 std::vector<SegmentString*>* extractChains(std::vector<BoundaryChainMap>& sections)
const;
174 Coordinate::UnorderedSet findNodePts(
175 const std::vector<SegmentString*>* segStrings)
const;
177 std::vector<SegmentString*>* nodeChains(
178 const std::vector<SegmentString*>* chains,
179 const Coordinate::UnorderedSet& nodePts);
183 const Coordinate::UnorderedSet& nodePts,
184 std::vector<SegmentString*>* nodedChains);
186 std::size_t findNodeIndex(
189 const Coordinate::UnorderedSet& nodePts)
const;
193 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
Represents a list of contiguous line segments, and supports noding the segments.
Definition: BasicSegmentString.h:44
Definition: BoundaryChainNoder.h:56
std::vector< SegmentString * > * getNodedSubstrings() const override
Returns a collection of fully noded SegmentStrings. The SegmentStrings have the same context as their...
void computeNodes(std::vector< SegmentString * > *inputSegStrings) override
Computes the noding for a collection of SegmentStrings.
Computes all intersections between segments in a set of SegmentString.
Definition: Noder.h:46
An interface for classes which represent a sequence of contiguous line segments.
Definition: SegmentString.h:47
const T & getAt(std::size_t i) const
Returns a read-only reference to Coordinate at position i.
Definition: CoordinateSequence.h:249
Basic namespace for all GEOS functionalities.
Definition: geos.h:38