GEOS: geos::CoordinateSequence Class Reference

- Main Page
- Namespaces
- Classes
- Files
- Related Pages

- Class List
- Class Hierarchy
- Class Members

# geos::CoordinateSequence Class Reference

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

`#include <geos.h>`

Inheritance diagram for geos::CoordinateSequence:

List of all members.

## Public Types
enum |
| Standard ordinate index values.
## Public Member Functions
virtual CoordinateSequence * | clone () const =0
| Returns a deep copy of this collection.
virtual const Coordinate & | getAt (int i) const =0
| Returns a read-only reference to Coordinate at position i.
virtual int | getSize () const =0
| Returns the number of Coordinates (actual or otherwise, as this implementation may not store its data in Coordinate objects).
virtual const vector < Coordinate > * | toVector () const =0
| Returns a read-only vector with the Coordinates in this collection.
void | add (const vector< Coordinate > *vc, bool allowRepeated)
| Add an array of coordinates.
void | add (const CoordinateSequence *cl, bool allowRepeated, bool direction)
| Add an array of coordinates.
void | add (const Coordinate &c, bool allowRepeated)
| Add a coordinate.
virtual bool | isEmpty () const =0
| Returns `true` it list contains no coordinates.
virtual void | add (const Coordinate &c)=0
| Add a Coordinate to the list.
virtual void | setAt (const Coordinate &c, int pos)=0
| Get a reference to Coordinate at position pos.
virtual void | deleteAt (int pos)=0
| Delete Coordinate at position pos (list will shrink).
virtual string | toString () const =0
| Get a string rapresentation of CoordinateSequence.
virtual void | setPoints (const vector< Coordinate > &v)=0
| Substitute Coordinate list with a copy of the given vector.
bool | hasRepeatedPoints () const
| Returns true if contains any two consecutive points.
const Coordinate * | minCoordinate () const
| Returns lower-left Coordinate in list.
virtual unsigned int | getDimension () const =0
| Get number of dimensions.
## Static Public Member Functions
static CoordinateSequence * | removeRepeatedPoints (const CoordinateSequence *cl)
| Returns a new CoordinateSequence being a copy of the input with any consecutive equal Coordinate removed.
static bool | hasRepeatedPoints (const CoordinateSequence *cl)
| Returns true if given CoordinateSequence contains any two consecutive Coordinate.
static CoordinateSequence * | atLeastNCoordinatesOrNothing (int n, CoordinateSequence *c)
| Returns either the given CoordinateSequence if its length is greater than the given amount, or an empty CoordinateSequence.
static const Coordinate * | minCoordinate (CoordinateSequence *cl)
| Returns lower-left Coordinate in given CoordinateSequence. This is actually the Coordinate with lower X (and Y if needed) ordinate.
static int | indexOf (const Coordinate *coordinate, const CoordinateSequence *cl)
| Return position of a Coordinate, or -1 if not found.
static bool | equals (CoordinateSequence *cl1, CoordinateSequence *cl2)
| Returns true if the two arrays are identical, both null, or pointwise equal.
static void | scroll (CoordinateSequence *cl, const Coordinate *firstCoordinate)
| Scroll given CoordinateSequence so to start with given Coordinate.
static void | reverse (CoordinateSequence *cl)
| Reverse Coordinate order in given 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.

## Member Function Documentation

virtual const Coordinate& geos::CoordinateSequence::getAt | ( | int | 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::DefaultCoordinateSequence.

virtual const vector<Coordinate>* geos::CoordinateSequence::toVector | ( |  | ) | const`[pure virtual]`

Returns a read-only vector with the Coordinates in this collection.

Whether or not the Coordinates returned are the actual underlying Coordinates or merely copies depends on the implementation. Note that if this implementation does not store its data as an array of Coordinates, this method will incur a performance penalty because the array needs to be built from scratch.

Implemented in geos::DefaultCoordinateSequence.

void geos::CoordinateSequence::add | ( | const vector< Coordinate > * | vc,
|  | bool | allowRepeated |
| ) |  |  |

Add an array of coordinates.

Parameters:

  | vc | The coordinates
  | allowRepeated | if set to false, repeated coordinates are collapsed

Returns:
  true (as by general collection contract)

Add an array of coordinates

Parameters:

  | vc | The coordinates
  | allowRepeated | if set to false, repeated coordinates are collapsed

Returns:
  true (as by general collection contract)

void geos::CoordinateSequence::add | ( | const CoordinateSequence * | cl,
|  | bool | allowRepeated,
|  | bool | direction |
| ) |  |  |

Add an array of coordinates.

Parameters:

  | cl | The coordinates
  | allowRepeated | if set to false, repeated coordinates are collapsed
  | direction | if false, the array is added in reverse order

Returns:
  true (as by general collection contract)

Add an array of coordinates

Parameters:

  | cl | The coordinates
  | allowRepeated | if set to false, repeated coordinates are collapsed
  | direction | if false, the array is added in reverse order

Returns:
  true (as by general collection contract)

void geos::CoordinateSequence::add | ( | const Coordinate & | c,
|  | bool | allowRepeated |
| ) |  |  |

Add a coordinate.

Parameters:

  | c | The coordinate to add
  | allowRepeated | if set to false, repeated coordinates are collapsed

Returns:
  true (as by general collection contract)

Add a coordinate

Parameters:

  | c | The coordinate to add
  | allowRepeated | if set to false, repeated coordinates are collapsed

Returns:
  true (as by general collection contract)

virtual void geos::CoordinateSequence::setAt | ( | const Coordinate & | c,
|  | int | pos |
| ) |  |  | `[pure virtual]`

Get a reference to Coordinate at position pos.

Copy Coordinate c to position pos

Implemented in geos::DefaultCoordinateSequence.

CoordinateSequence * geos::CoordinateSequence::removeRepeatedPoints | ( | const CoordinateSequence * | cl | ) | `[static]`

Returns a new CoordinateSequence being a copy of the input with any consecutive equal Coordinate removed.

This function allocates space for a CoordinateSequence object being a copy of the input once with consecutive equal points removed.

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

- geom.h
- CoordinateSequence.cpp