GEOS  3.14.0dev
Public Types | Public Member Functions | Static Public Member Functions | List of all members
geos::geom::CoordinateSequence Class Reference

The internal representation of a list of coordinates inside a Geometry. More...

#include <geos.h>

Public Types

enum  { X , Y , Z , M }
 Standard ordinate index values.
 
using iterator = CoordinateSequenceIterator< CoordinateSequence, Coordinate >
 
using const_iterator = CoordinateSequenceIterator< const CoordinateSequence, const Coordinate >
 
typedef std::unique_ptr< CoordinateSequencePtr
 

Public Member Functions

 CoordinateSequence ()
 
 CoordinateSequence (std::size_t size, std::size_t dim=0)
 
 CoordinateSequence (std::size_t size, bool hasz, bool hasm, bool initialize=true)
 
 CoordinateSequence (const std::initializer_list< Coordinate > &)
 
 CoordinateSequence (const std::initializer_list< CoordinateXY > &)
 
 CoordinateSequence (const std::initializer_list< CoordinateXYM > &)
 
 CoordinateSequence (const std::initializer_list< CoordinateXYZM > &)
 
std::unique_ptr< CoordinateSequenceclone () const
 Returns a heap-allocated deep copy of this CoordinateSequence.
 
Envelope getEnvelope () const
 
std::size_t getSize () const
 Returns the number of Coordinates.
 
size_t size () const
 Returns the number of Coordinates.
 
bool isEmpty () const
 Returns true if list contains no coordinates.
 
bool isRing () const
 Tests whether an a CoordinateSequence forms a ring, by checking length and closure. Self-intersection is not checked. More...
 
std::size_t getDimension () const
 
bool hasZ () const
 
bool hasM () const
 
bool hasRepeatedPoints () const
 Returns true if contains any two consecutive points.
 
bool hasRepeatedOrInvalidPoints () const
 Returns true if contains any NaN/Inf coordinates.
 
CoordinateType getCoordinateType () const
 
template<typename T = Coordinate>
const T & getAt (std::size_t i) const
 Returns a read-only reference to Coordinate at position i.
 
template<typename T = Coordinate>
T & getAt (std::size_t i)
 Returns a reference to Coordinate at position i.
 
template<typename T >
void getAt (std::size_t i, T &c) const
 Write Coordinate at position i to given Coordinate.
 
void getAt (std::size_t i, CoordinateXY &c) const
 
const Coordinateoperator[] (std::size_t i) const
 
Coordinateoperator[] (std::size_t i)
 
double getOrdinate (std::size_t index, std::size_t ordinateIndex) const
 
double getX (std::size_t index) const
 
double getY (std::size_t index) const
 
template<typename T = Coordinate>
const T & back () const
 Return last Coordinate in the sequence.
 
template<typename T = Coordinate>
T & back ()
 Return last Coordinate in the sequence.
 
template<typename T = Coordinate>
const T & front () const
 Return first Coordinate in the sequence.
 
template<typename T = Coordinate>
T & front ()
 Return first Coordinate in the sequence.
 
void toVector (std::vector< Coordinate > &coords) const
 Pushes all Coordinates of this sequence into the provided vector.
 
void toVector (std::vector< CoordinateXY > &coords) const
 
template<typename T >
void setAt (const T &c, std::size_t pos)
 Copy Coordinate c to position pos.
 
void setOrdinate (std::size_t index, std::size_t ordinateIndex, double value)
 
void setPoints (const std::vector< Coordinate > &v)
 Substitute Coordinate list with a copy of the given vector.
 
template<typename T = Coordinate>
void add (const T &c)
 
template<typename T >
void add (const T &c, bool allowRepeated)
 
template<typename T >
void add (const T &c, std::size_t pos)
 Inserts the specified coordinate at the specified position in this sequence. If multiple coordinates are to be added, a multiple- insert method should be used for best performance. More...
 
template<typename T >
void add (std::size_t i, const T &coord, bool allowRepeated)
 Inserts the specified coordinate at the specified position in this list. More...
 
void add (double x, double y)
 
void add (const CoordinateSequence &cs)
 
void add (const CoordinateSequence &cs, bool allowRepeated)
 
void add (const CoordinateSequence &cl, bool allowRepeated, bool forwardDirection)
 
void add (const CoordinateSequence &cs, std::size_t from, std::size_t to)
 
void add (const CoordinateSequence &cs, std::size_t from, std::size_t to, bool allowRepeated)
 
template<typename T , typename... Args>
void add (T begin, T end, Args... args)
 
template<typename T >
void add (std::size_t i, T from, T to)
 
void clear ()
 
void reserve (std::size_t capacity)
 
void resize (std::size_t capacity)
 
void pop_back ()
 
std::string toString () const
 Get a string representation of CoordinateSequence.
 
const CoordinateXY * minCoordinate () const
 Returns lower-left Coordinate in list.
 
bool equalsIdentical (const CoordinateSequence &other) const
 Returns true if the two sequences are identical (pointwise equal in all dimensions, with NaN == NaN).
 
void reverse ()
 Reverse Coordinate order in given CoordinateSequence.
 
void sort ()
 
void expandEnvelope (Envelope &env) const
 
void closeRing (bool allowRepeated=false)
 
template<typename Filter >
void apply_rw (const Filter *filter)
 
template<typename Filter >
void apply_ro (Filter *filter) const
 
template<typename F >
auto applyAt (size_t i, F &&fun) const
 
template<typename F >
void forEach (F &&fun) const
 
template<typename T , typename F >
void forEach (F &&fun) const
 
template<typename T , typename F >
void forEach (std::size_t from, std::size_t to, F &&fun) const
 
template<typename T >
Coordinates< typename std::add_const< T >::type > items () const
 
template<typename T >
Coordinates< T > items ()
 
double * data ()
 
const double * data () const
 

Static Public Member Functions

static CoordinateSequence XY (std::size_t size)
 
static CoordinateSequence XYZ (std::size_t size)
 
static CoordinateSequence XYZM (std::size_t size)
 
static CoordinateSequence XYM (std::size_t size)
 
static CoordinateSequenceatLeastNCoordinatesOrNothing (std::size_t n, CoordinateSequence *c)
 Returns either the given CoordinateSequence if its length is greater than the given amount, or an empty CoordinateSequence.
 
static std::size_t indexOf (const CoordinateXY *coordinate, const CoordinateSequence *cl)
 Return position of a Coordinate. More...
 
static bool equals (const CoordinateSequence *cl1, const CoordinateSequence *cl2)
 Returns true if the two arrays are identical, both null, or pointwise equal in two dimensions.
 
static void scroll (CoordinateSequence *cl, const CoordinateXY *firstCoordinate)
 Scroll given CoordinateSequence so to start with given Coordinate.
 
static int increasingDirection (const CoordinateSequence &pts)
 Determines which orientation of the Coordinate array is (overall) increasing. More...
 

Detailed Description

The internal representation of a list of coordinates inside a Geometry.

A CoordinateSequence is capable of storing XY, XYZ, XYM, or XYZM Coordinates. For efficient storage, the dimensionality of the CoordinateSequence should be specified at creation using the constructor with hasz and hasm arguments. Currently most of the GEOS code base stores 2D Coordinates and accesses using the Coordinate type. Sequences used by these parts of the code must be created with constructors without hasz and hasm arguments.

If a high-dimension Coordinate coordinate is read from a low-dimension CoordinateSequence, the higher dimensions will be populated with incorrect values or a segfault may occur.


The documentation for this class was generated from the following file: