23#include <geos/export.h>
24#include <geos/geom/Coordinate.h>
25#include <geos/geom/CoordinateSequence.h>
26#include <geos/noding/Octant.h>
49 typedef std::vector<const SegmentString*> ConstVect;
50 typedef std::vector<SegmentString*> NonConstVect;
52 friend std::ostream& operator<< (std::ostream& os,
60 SegmentString(
const void* newContext,
const std::shared_ptr<const geom::CoordinateSequence>& newSeq)
91 std::size_t size()
const {
95 template<
typename CoordType = geom::Coordinate>
96 const CoordType& getCoordinate(std::size_t i)
const {
97 return seq->getAt<CoordType>(i);
107 void setCoordinates(
const std::shared_ptr<const geom::CoordinateSequence>& newSeq) {
120 if (index >= size() - 1) {
123 return safeOctant(seq->getAt<geom::CoordinateXY>(index),
124 seq->getAt<geom::CoordinateXY>(index + 1));
127 static int getSegmentOctant(
const SegmentString& ss, std::size_t index) {
139 const geom::CoordinateXY&
nextInRing(std::size_t index)
const
141 std::size_t nextIndex = index + 1;
142 if (nextIndex > size() - 1) {
145 return getCoordinate(nextIndex);
156 const geom::CoordinateXY&
prevInRing(std::size_t index)
const
158 std::size_t prevIndex;
160 prevIndex = size() - 2;
162 prevIndex = index - 1;
163 return getCoordinate( prevIndex );
167 bool isClosed()
const {
168 return seq->front<geom::CoordinateXY>().equals(seq->back<geom::CoordinateXY>());
171 static std::vector<SegmentString*> toRawPointerVector(
const std::vector<std::unique_ptr<SegmentString>> & segStrings);
173 virtual std::ostream& print(std::ostream& os)
const;
176 std::shared_ptr<const geom::CoordinateSequence> seq;
181 static int safeOctant(
const geom::CoordinateXY& p0,
const geom::CoordinateXY& p1)
183 if(p0.equals2D(p1)) {
186 return Octant::octant(p0, p1);
190 SegmentString(
const SegmentString& other) =
delete;
191 SegmentString& operator=(
const SegmentString& rhs) =
delete;
194std::ostream& operator<< (std::ostream& os,
const SegmentString& ss);
An interface for classes which represent a sequence of contiguous line segments.
Definition SegmentString.h:47
SegmentString(const void *newContext, const std::shared_ptr< const geom::CoordinateSequence > &newSeq)
Construct a SegmentString.
Definition SegmentString.h:60
const geom::CoordinateXY & nextInRing(std::size_t index) const
Definition SegmentString.h:139
const void * getData() const
Gets the user-defined data for this segment string.
Definition SegmentString.h:75
int getSegmentOctant(std::size_t index) const
Gets the octant of the segment starting at vertex index.
Definition SegmentString.h:118
const std::shared_ptr< const geom::CoordinateSequence > & getCoordinates() const
Return a pointer to the CoordinateSequence associated with this SegmentString.
Definition SegmentString.h:103
const geom::CoordinateXY & prevInRing(std::size_t index) const
Definition SegmentString.h:156
void setData(const void *data)
Sets the user-defined data for this segment string.
Definition SegmentString.h:86
Basic namespace for all GEOS functionalities.
Definition geos.h:38