GEOS  3.9.1dev
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
geos::geom::CoordinateSequence Class Referenceabstract

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

#include <geos.h>

Inheritance diagram for geos::geom::CoordinateSequence:
[legend]

Public Types

enum  { X, Y, Z, M }
 Standard ordinate index values. More...
 
typedef std::unique_ptr< CoordinateSequencePtr
 

Public Member Functions

virtual ~CoordinateSequence ()
 
virtual std::unique_ptr< CoordinateSequenceclone () const =0
 Returns a deep copy of this collection. More...
 
virtual const CoordinategetAt (std::size_t i) const =0
 Returns a read-only reference to Coordinate at position i. More...
 
const Coordinateback () const
 Return last Coordinate in the sequence. More...
 
const Coordinatefront () const
 Return first Coordinate in the sequence. More...
 
const Coordinateoperator[] (std::size_t i) const
 
virtual Envelope getEnvelope () const
 
virtual void getAt (std::size_t i, Coordinate &c) const =0
 Write Coordinate at position i to given Coordinate. More...
 
virtual std::size_t getSize () const =0
 Returns the number of Coordinates (actual or otherwise, as this implementation may not store its data in Coordinate objects). More...
 
size_t size () const
 
virtual void toVector (std::vector< Coordinate > &coords) const =0
 
virtual bool isEmpty () const =0
 Returns true it list contains no coordinates. More...
 
virtual void setAt (const Coordinate &c, std::size_t pos)=0
 Copy Coordinate c to position pos. More...
 
std::string toString () const
 Get a string representation of CoordinateSequence. More...
 
virtual void setPoints (const std::vector< Coordinate > &v)=0
 Substitute Coordinate list with a copy of the given vector. More...
 
bool hasRepeatedPoints () const
 Returns true if contains any two consecutive points. More...
 
const CoordinateminCoordinate () const
 Returns lower-left Coordinate in list. More...
 
virtual std::size_t getDimension () const =0
 
bool hasZ () const
 
virtual double getOrdinate (std::size_t index, std::size_t ordinateIndex) const
 
virtual double getX (std::size_t index) const
 
virtual double getY (std::size_t index) const
 
virtual void setOrdinate (std::size_t index, std::size_t ordinateIndex, double value)=0
 
virtual void expandEnvelope (Envelope &env) const
 
virtual void apply_rw (const CoordinateFilter *filter)=0
 
virtual void apply_ro (CoordinateFilter *filter) const =0
 
template<class T >
void applyCoordinateFilter (T &f)
 Apply a filter to each Coordinate of this sequence. The filter is expected to provide a .filter(Coordinate&) method. More...
 

Static Public Member Functions

static bool hasRepeatedPoints (const CoordinateSequence *cl)
 Returns true if given CoordinateSequence contains any two consecutive Coordinate. More...
 
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. More...
 
static size_t indexOf (const Coordinate *coordinate, const CoordinateSequence *cl)
 
static bool equals (const CoordinateSequence *cl1, const CoordinateSequence *cl2)
 Returns true if the two arrays are identical, both null, or pointwise equal. More...
 
static void scroll (CoordinateSequence *cl, const Coordinate *firstCoordinate)
 Scroll given CoordinateSequence so to start with given Coordinate. More...
 
static int increasingDirection (const CoordinateSequence &pts)
 Determines which orientation of the Coordinate array is (overall) increasing. More...
 
static bool isRing (const CoordinateSequence *pts)
 Tests whether an array of Coordinates forms a ring, by checking length and closure. Self-intersection is not checked. More...
 
static void reverse (CoordinateSequence *cl)
 Reverse Coordinate order in given CoordinateSequence. More...
 

Protected Member Functions

 CoordinateSequence ()
 
 CoordinateSequence (const CoordinateSequence &)
 

Detailed Description

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

There are some cases in which you might want Geometries to store their points using something other than the GEOS Coordinate class. For example, you may want to experiment with another implementation, such as an array of Xs and an array of Ys. or you might want to use your own coordinate class, one that supports extra attributes like M-values.

You can do this by implementing the CoordinateSequence and CoordinateSequenceFactory interfaces. You would then create a GeometryFactory parameterized by your CoordinateSequenceFactory, and use this GeometryFactory to create new Geometries. All of these new Geometries will use your CoordinateSequence implementation.

Definition at line 58 of file CoordinateSequence.h.

Member Typedef Documentation

Definition at line 68 of file CoordinateSequence.h.

Member Enumeration Documentation

anonymous enum

Standard ordinate index values.

Enumerator

Definition at line 215 of file CoordinateSequence.h.

Constructor & Destructor Documentation

geos::geom::CoordinateSequence::CoordinateSequence ( )
inlineprotected

Definition at line 62 of file CoordinateSequence.h.

geos::geom::CoordinateSequence::CoordinateSequence ( const CoordinateSequence )
inlineprotected

Definition at line 64 of file CoordinateSequence.h.

virtual geos::geom::CoordinateSequence::~CoordinateSequence ( )
inlinevirtual

Definition at line 71 of file CoordinateSequence.h.

Member Function Documentation

virtual void geos::geom::CoordinateSequence::apply_ro ( CoordinateFilter filter) const
pure virtual
virtual void geos::geom::CoordinateSequence::apply_rw ( const CoordinateFilter filter)
pure virtual
template<class T >
void geos::geom::CoordinateSequence::applyCoordinateFilter ( T &  f)
inline

Apply a filter to each Coordinate of this sequence. The filter is expected to provide a .filter(Coordinate&) method.

TODO: accept a Functor instead, will be more flexible. actually, define iterators on Geometry

Definition at line 298 of file CoordinateSequence.h.

References GEOS_DLL, geos::geom::operator!=(), geos::geom::operator<<(), and geos::geom::operator==().

Here is the call graph for this function:

static CoordinateSequence* geos::geom::CoordinateSequence::atLeastNCoordinatesOrNothing ( std::size_t  n,
CoordinateSequence c 
)
static

Returns either the given CoordinateSequence if its length is greater than the given amount, or an empty CoordinateSequence.

const Coordinate& geos::geom::CoordinateSequence::back ( ) const
inline

Return last Coordinate in the sequence.

Definition at line 88 of file CoordinateSequence.h.

Referenced by geos::operation::buffer::OffsetSegmentString::closeRing(), and geos::operation::buffer::OffsetSegmentString::isRedundant().

Here is the caller graph for this function:

virtual std::unique_ptr<CoordinateSequence> geos::geom::CoordinateSequence::clone ( ) const
pure virtual
static bool geos::geom::CoordinateSequence::equals ( const CoordinateSequence cl1,
const CoordinateSequence cl2 
)
static

Returns true if the two arrays are identical, both null, or pointwise equal.

virtual void geos::geom::CoordinateSequence::expandEnvelope ( Envelope env) const
virtual

Expands the given Envelope to include the coordinates in the sequence. Allows implementing classes to optimize access to coordinate values.

Parameters
envthe envelope to expand

Reimplemented in geos::geom::CoordinateArraySequence.

const Coordinate& geos::geom::CoordinateSequence::front ( ) const
inline

Return first Coordinate in the sequence.

Definition at line 95 of file CoordinateSequence.h.

Referenced by geos::operation::buffer::OffsetSegmentString::closeRing().

Here is the caller graph for this function:

virtual const Coordinate& geos::geom::CoordinateSequence::getAt ( std::size_t  i) const
pure virtual

Returns a read-only reference to Coordinate at position i.

Whether or not the Coordinate returned is the actual underlying Coordinate or merely a copy depends on the implementation.

Implemented in geos::geom::CoordinateArraySequence.

virtual void geos::geom::CoordinateSequence::getAt ( std::size_t  i,
Coordinate c 
) const
pure virtual

Write Coordinate at position i to given Coordinate.

Implemented in geos::geom::CoordinateArraySequence.

virtual std::size_t geos::geom::CoordinateSequence::getDimension ( ) const
pure virtual

Returns the dimension (number of ordinates in each coordinate) for this sequence.

Returns
the dimension of the sequence.

Implemented in geos::geom::CoordinateArraySequence, geos::geom::FixedSizeCoordinateSequence< N >, and geos::geom::FixedSizeCoordinateSequence< 1 >.

virtual Envelope geos::geom::CoordinateSequence::getEnvelope ( ) const
virtual
virtual double geos::geom::CoordinateSequence::getOrdinate ( std::size_t  index,
std::size_t  ordinateIndex 
) const
virtual

Returns the ordinate of a coordinate in this sequence. Ordinate indices 0 and 1 are assumed to be X and Y. Ordinates indices greater than 1 have user-defined semantics (for instance, they may contain other dimensions or measure values).

Parameters
indexthe coordinate index in the sequence
ordinateIndexthe ordinate index in the coordinate (in range [0, dimension-1])
virtual std::size_t geos::geom::CoordinateSequence::getSize ( ) const
pure virtual

Returns the number of Coordinates (actual or otherwise, as this implementation may not store its data in Coordinate objects).

Implemented in geos::geom::CoordinateArraySequence, geos::geom::FixedSizeCoordinateSequence< N >, and geos::geom::FixedSizeCoordinateSequence< 1 >.

virtual double geos::geom::CoordinateSequence::getX ( std::size_t  index) const
inlinevirtual

Returns ordinate X (0) of the specified coordinate.

Parameters
index
Returns
the value of the X ordinate in the index'th coordinate

Definition at line 248 of file CoordinateSequence.h.

virtual double geos::geom::CoordinateSequence::getY ( std::size_t  index) const
inlinevirtual

Returns ordinate Y (1) of the specified coordinate.

Parameters
index
Returns
the value of the Y ordinate in the index'th coordinate

Definition at line 260 of file CoordinateSequence.h.

bool geos::geom::CoordinateSequence::hasRepeatedPoints ( ) const

Returns true if contains any two consecutive points.

static bool geos::geom::CoordinateSequence::hasRepeatedPoints ( const CoordinateSequence cl)
static

Returns true if given CoordinateSequence contains any two consecutive Coordinate.

bool geos::geom::CoordinateSequence::hasZ ( ) const
inline

Definition at line 225 of file CoordinateSequence.h.

static int geos::geom::CoordinateSequence::increasingDirection ( const CoordinateSequence pts)
static

Determines which orientation of the Coordinate array is (overall) increasing.

In other words, determines which end of the array is "smaller" (using the standard ordering on Coordinate). Returns an integer indicating the increasing direction. If the sequence is a palindrome, it is defined to be oriented in a positive direction.

Parameters
ptsthe array of Coordinates to test
Returns
1 if the array is smaller at the start or is a palindrome, -1 if smaller at the end

NOTE: this method is found in CoordinateArrays class for JTS

static size_t geos::geom::CoordinateSequence::indexOf ( const Coordinate coordinate,
const CoordinateSequence cl 
)
static

Return position of a Coordinate, or -1 if not found

FIXME: return std::size_t, using numeric_limits<std::size_t>::max as 'not found' value.

virtual bool geos::geom::CoordinateSequence::isEmpty ( ) const
pure virtual
static bool geos::geom::CoordinateSequence::isRing ( const CoordinateSequence pts)
static

Tests whether an array of Coordinates forms a ring, by checking length and closure. Self-intersection is not checked.

Parameters
ptsan array of Coordinates
Returns
true if the coordinate form a ring.
const Coordinate* geos::geom::CoordinateSequence::minCoordinate ( ) const

Returns lower-left Coordinate in list.

const Coordinate& geos::geom::CoordinateSequence::operator[] ( std::size_t  i) const
inline

Definition at line 101 of file CoordinateSequence.h.

static void geos::geom::CoordinateSequence::reverse ( CoordinateSequence cl)
static

Reverse Coordinate order in given CoordinateSequence.

static void geos::geom::CoordinateSequence::scroll ( CoordinateSequence cl,
const Coordinate firstCoordinate 
)
static

Scroll given CoordinateSequence so to start with given Coordinate.

virtual void geos::geom::CoordinateSequence::setAt ( const Coordinate c,
std::size_t  pos 
)
pure virtual

Copy Coordinate c to position pos.

Implemented in geos::geom::CoordinateArraySequence.

virtual void geos::geom::CoordinateSequence::setOrdinate ( std::size_t  index,
std::size_t  ordinateIndex,
double  value 
)
pure virtual

Sets the value for a given ordinate of a coordinate in this sequence.

Parameters
indexthe coordinate index in the sequence
ordinateIndexthe ordinate index in the coordinate (in range [0, dimension-1])
valuethe new ordinate value

Implemented in geos::geom::CoordinateArraySequence.

virtual void geos::geom::CoordinateSequence::setPoints ( const std::vector< Coordinate > &  v)
pure virtual
size_t geos::geom::CoordinateSequence::size ( ) const
inline

Definition at line 120 of file CoordinateSequence.h.

Referenced by geos::operation::buffer::OffsetSegmentString::addPts(), geos::operation::buffer::OffsetSegmentString::closeRing(), geos::operation::buffer::OffsetSegmentString::isRedundant(), and geos::operation::buffer::OffsetSegmentString::size().

Here is the caller graph for this function:

std::string geos::geom::CoordinateSequence::toString ( ) const

Get a string representation of CoordinateSequence.

virtual void geos::geom::CoordinateSequence::toVector ( std::vector< Coordinate > &  coords) const
pure virtual

Pushes all Coordinates of this sequence into the provided vector.

This method is a port of the toCoordinateArray() method of JTS.

Implemented in geos::geom::FixedSizeCoordinateSequence< N >, geos::geom::FixedSizeCoordinateSequence< 1 >, and geos::geom::CoordinateArraySequence.


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