23#include <geos/export.h>
24#include <geos/algorithm/Length.h>
25#include <geos/geom/Coordinate.h>
26#include <geos/geom/CoordinateSequence.h>
27#include <geos/noding/Octant.h>
28#include <geos/noding/PathString.h>
51 typedef std::vector<const SegmentString*> ConstVect;
52 typedef std::vector<SegmentString*> NonConstVect;
54 friend std::ostream& operator<< (std::ostream& os,
62 SegmentString(
const void* newContext,
const std::shared_ptr<const geom::CoordinateSequence>& newSeq)
93 std::size_t size()
const {
98 std::size_t getSize()
const override{
99 return seq->size() - 1;
102 template<
typename CoordType = geom::Coordinate>
103 const CoordType& getCoordinate(std::size_t i)
const {
104 return seq->getAt<CoordType>(i);
107 double getLength()
const override {
108 return algorithm::Length::ofLine(seq.get());
114 const std::shared_ptr<const geom::CoordinateSequence>&
getCoordinates()
const override {
118 void setCoordinates(
const std::shared_ptr<const geom::CoordinateSequence>& newSeq) {
131 if (index >= size() - 1) {
134 return safeOctant(seq->getAt<geom::CoordinateXY>(index),
135 seq->getAt<geom::CoordinateXY>(index + 1));
138 static int getSegmentOctant(
const SegmentString& ss, std::size_t index) {
150 const geom::CoordinateXY&
nextInRing(std::size_t index)
const
152 std::size_t nextIndex = index + 1;
153 if (nextIndex > size() - 1) {
156 return getCoordinate(nextIndex);
167 const geom::CoordinateXY&
prevInRing(std::size_t index)
const
169 std::size_t prevIndex;
171 prevIndex = size() - 2;
173 prevIndex = index - 1;
174 return getCoordinate( prevIndex );
178 bool isClosed()
const {
179 return seq->front<geom::CoordinateXY>().equals(seq->back<geom::CoordinateXY>());
182 static std::vector<SegmentString*> toRawPointerVector(
const std::vector<std::unique_ptr<SegmentString>> & segStrings);
184 static std::vector<SegmentString*> toRawPointerVector(
const std::vector<std::unique_ptr<PathString>> & segStrings);
186 virtual std::ostream& print(std::ostream& os)
const;
189 std::shared_ptr<const geom::CoordinateSequence> seq;
194 static int safeOctant(
const geom::CoordinateXY& p0,
const geom::CoordinateXY& p1)
196 if(p0.equals2D(p1)) {
199 return Octant::octant(p0, p1);
203 SegmentString(
const SegmentString& other) =
delete;
204 SegmentString& operator=(
const SegmentString& rhs) =
delete;
207std::ostream& operator<< (std::ostream& os,
const SegmentString& ss);
Definition PathString.h:31
An interface for classes which represent a sequence of contiguous line segments.
Definition SegmentString.h:49
SegmentString(const void *newContext, const std::shared_ptr< const geom::CoordinateSequence > &newSeq)
Construct a SegmentString.
Definition SegmentString.h:62
const std::shared_ptr< const geom::CoordinateSequence > & getCoordinates() const override
Return a pointer to the CoordinateSequence associated with this SegmentString.
Definition SegmentString.h:114
const geom::CoordinateXY & nextInRing(std::size_t index) const
Definition SegmentString.h:150
const void * getData() const
Gets the user-defined data for this segment string.
Definition SegmentString.h:77
int getSegmentOctant(std::size_t index) const
Gets the octant of the segment starting at vertex index.
Definition SegmentString.h:129
const geom::CoordinateXY & prevInRing(std::size_t index) const
Definition SegmentString.h:167
void setData(const void *data)
Sets the user-defined data for this segment string.
Definition SegmentString.h:88
Basic namespace for all GEOS functionalities.
Definition geos.h:38