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;
60 class BoundarySegmentMap {
66 std::vector<bool> isBoundary;
70 std::size_t startIndex,
75 std::size_t findChainStart(std::size_t index)
const;
76 std::size_t findChainEnd(std::size_t index)
const;
82 isBoundary.resize(ss->size()-1,
false);
85 void setBoundarySegment(std::size_t index);
86 void createChains(std::vector<SegmentString*>& chainList,
bool constructZ,
bool constructM);
92 BoundarySegmentMap& segMap,
97 , m_flip(seq.
getAt<geom::CoordinateXY>(index).compareTo(seq.
getAt<geom::CoordinateXY>(index + 1)) < 0)
100 const geom::CoordinateXY& p0()
const {
101 return m_seq.getAt<geom::CoordinateXY>(m_flip ? m_index : m_index + 1);
104 const geom::CoordinateXY& p1()
const {
105 return m_seq.getAt<geom::CoordinateXY>(m_flip ? m_index + 1 : m_index);
108 void markInBoundary()
const {
109 m_segMap.setBoundarySegment(m_index);
112 bool operator==(
const Segment& other)
const {
113 return p0().equals2D(other.p0()) && p1().equals2D(other.p1());
117 std::size_t operator()(
const Segment& s)
const {
118 std::size_t h = std::hash<double>{}(s.p0().x);
119 h ^= (std::hash<double>{}(s.p0().y) << 1);
120 h ^= (std::hash<double>{}(s.p1().x) << 1);
121 h ^= (std::hash<double>{}(s.p1().y) << 1);
128 BoundarySegmentMap& m_segMap;
134 using SegmentSet = std::unordered_set<Segment, Segment::HashCode>;
136 BoundaryChainNoder() : chainList(
nullptr), m_constructZ(
false), m_constructM(
false) {};
140 void computeNodes(std::vector<SegmentString*>* inputSegStrings)
override;
146 std::vector<SegmentString*>* chainList;
151 void addSegments(std::vector<SegmentString*>* segStrings,
153 std::vector<BoundarySegmentMap>& includedSegs);
156 BoundarySegmentMap& segInclude,
159 static void markBoundarySegments(SegmentSet& segSet);
161 std::vector<SegmentString*>* extractChains(std::vector<BoundarySegmentMap>& sections)
const;
163 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:217
Definition: BoundaryChainNoder.h:55
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