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)
69 std::size_t size()
const {
74 std::size_t getSize()
const override{
75 return seq->size() - 1;
78 template<
typename CoordType = geom::Coordinate>
79 const CoordType& getCoordinate(std::size_t i)
const {
80 return seq->getAt<CoordType>(i);
83 double getLength()
const override {
84 return algorithm::Length::ofLine(seq.get());
90 const std::shared_ptr<const geom::CoordinateSequence>&
getCoordinates()
const override {
94 void setCoordinates(
const std::shared_ptr<const geom::CoordinateSequence>& newSeq) {
107 if (index >= size() - 1) {
110 return safeOctant(seq->getAt<geom::CoordinateXY>(index),
111 seq->getAt<geom::CoordinateXY>(index + 1));
114 static int getSegmentOctant(
const SegmentString& ss, std::size_t index) {
126 const geom::CoordinateXY&
nextInRing(std::size_t index)
const
128 std::size_t nextIndex = index + 1;
129 if (nextIndex > size() - 1) {
132 return getCoordinate(nextIndex);
143 const geom::CoordinateXY&
prevInRing(std::size_t index)
const
145 std::size_t prevIndex;
147 prevIndex = size() - 2;
149 prevIndex = index - 1;
150 return getCoordinate( prevIndex );
154 bool isClosed()
const {
155 return seq->front<geom::CoordinateXY>().equals(seq->back<geom::CoordinateXY>());
158 static std::vector<SegmentString*> toRawPointerVector(
const std::vector<std::unique_ptr<SegmentString>> & segStrings);
160 static std::vector<SegmentString*> toRawPointerVector(
const std::vector<std::unique_ptr<PathString>> & segStrings);
162 virtual std::ostream& print(std::ostream& os)
const;
165 std::shared_ptr<const geom::CoordinateSequence> seq;
168 static int safeOctant(
const geom::CoordinateXY& p0,
const geom::CoordinateXY& p1)
170 if(p0.equals2D(p1)) {
173 return Octant::octant(p0, p1);
177 SegmentString(
const SegmentString& other) =
delete;
178 SegmentString& operator=(
const SegmentString& rhs) =
delete;
181std::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:90
const geom::CoordinateXY & nextInRing(std::size_t index) const
Definition SegmentString.h:126
int getSegmentOctant(std::size_t index) const
Gets the octant of the segment starting at vertex index.
Definition SegmentString.h:105
const geom::CoordinateXY & prevInRing(std::size_t index) const
Definition SegmentString.h:143
Basic namespace for all GEOS functionalities.
Definition geos.h:38