GEOS 3.11.1
LinearIterator.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2005-2006 Refractions Research Inc.
7 * Copyright (C) 2001-2002 Vivid Solutions Inc.
8 *
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
13 *
14 **********************************************************************
15 *
16 * Last port: linearref/LinearIterator.java r463
17 *
18 **********************************************************************/
19
20#pragma once
21
22#include <string>
23
24#include <geos/geom/Coordinate.h>
25#include <geos/geom/Geometry.h>
26#include <geos/geom/LineSegment.h>
27#include <geos/linearref/LinearLocation.h>
28
29namespace geos {
30namespace linearref {
31
50public:
57
65 LinearIterator(const geom::Geometry* linear, const LinearLocation& start);
66
75 LinearIterator(const geom::Geometry* linear, std::size_t componentIndex, std::size_t vertexIndex);
76
81 bool hasNext() const;
82
83
87 void next();
88
95 bool isEndOfLine() const;
96
101 std::size_t getComponentIndex() const;
102
107 std::size_t getVertexIndex() const;
108
113 const geom::LineString* getLine() const;
114
121
130
131private:
132
133 static std::size_t segmentEndVertexIndex(const LinearLocation& loc);
134
135 const geom::LineString* currentLine;
136 std::size_t vertexIndex;
137 std::size_t componentIndex;
138 const geom::Geometry* linear;
139 const std::size_t numLines;
140
147 void loadCurrentLine();
148
149 // Declare type as noncopyable
150 LinearIterator(const LinearIterator& other) = delete;
151 LinearIterator& operator=(const LinearIterator& rhs) = delete;
152};
153
154}
155} // namespace geos::linearref
156
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:58
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:186
Definition: LineString.h:66
An iterator over the components and coordinates of a linear geometry (LineString or MultiLineString).
Definition: LinearIterator.h:49
bool hasNext() const
Tests whether there are any vertices left to iterator over.
geom::Coordinate getSegmentEnd() const
Gets the second geom::Coordinate of the current segment. (the coordinate of the next vertex)....
std::size_t getVertexIndex() const
The vertex index of the vertex the iterator is currently at.
LinearIterator(const geom::Geometry *linear)
Creates an iterator initialized to the start of a linear Geometry.
geom::Coordinate getSegmentStart() const
Gets the first geom::Coordinate of the current segment. (the coordinate of the current vertex).
std::size_t getComponentIndex() const
The component index of the vertex the iterator is currently at.
bool isEndOfLine() const
Checks whether the iterator cursor is pointing to the endpoint of a component geom::LineString.
LinearIterator(const geom::Geometry *linear, const LinearLocation &start)
Creates an iterator starting at a LinearLocation on a linear geom::Geometry.
LinearIterator(const geom::Geometry *linear, std::size_t componentIndex, std::size_t vertexIndex)
Creates an iterator starting at a component and vertex in a linear geom::Geometry.
const geom::LineString * getLine() const
Gets the geom::LineString component the iterator is current at.
void next()
Moves the iterator ahead to the next vertex and (possibly) linear component.
Represents a location along a LineString or MultiLineString.
Definition: LinearLocation.h:43
Basic namespace for all GEOS functionalities.
Definition: geos.h:39