17 #include <geos/noding/Noder.h>
18 #include <geos/noding/SegmentString.h>
19 #include <geos/geom/LineSegment.h>
21 #include <unordered_set>
26 class CoordinateSequence;
30 class NodedSegmentString;
61 class BoundarySegmentMap {
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*>& chainList,
bool constructZ,
bool constructM);
93 BoundarySegmentMap& 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 markInBoundary()
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 BoundarySegmentMap& m_segMap;
135 using SegmentSet = std::unordered_set<Segment, Segment::HashCode>;
137 BoundaryChainNoder() : chainList(
nullptr), m_constructZ(
false), m_constructM(
false) {};
141 void computeNodes(std::vector<SegmentString*>* inputSegStrings)
override;
147 std::vector<SegmentString*>* chainList;
152 void addSegments(std::vector<SegmentString*>* segStrings,
154 std::vector<BoundarySegmentMap>& includedSegs);
157 BoundarySegmentMap& segInclude,
160 static void markBoundarySegments(SegmentSet& segSet);
162 std::vector<SegmentString*>* extractChains(std::vector<BoundarySegmentMap>& sections)
const;
164 static bool segSetContains(SegmentSet& segSet, Segment& seg);
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:216
Definition: BoundaryChainNoder.h:57
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: Angle.h:25