GEOS 3.4.2

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

- Class List
- Class Hierarchy
- Class Members

Public Types | Static Public Member Functions | List of all members
geos::algorithm::CGAlgorithms Class Reference

Specifies and implements various fundamental Computational Geometric algorithms. The algorithms supplied in this class are robust for double-precision floating point. More...

`#include <CGAlgorithms.h>`

## Public Types
enum | { CLOCKWISE =-1, COLLINEAR, COUNTERCLOCKWISE }
enum | { RIGHT =-1, LEFT, STRAIGHT }

## Static Public Member Functions
static bool | isPointInRing (const geom::Coordinate &p, const geom::CoordinateSequence *ring)
| Tests whether a point lies inside a ring.
static bool | isPointInRing (const geom::Coordinate &p, const std::vector< const geom::Coordinate * > &ring)
| Same as above, but taking a vector of const Coordinates (faster)
static int | locatePointInRing (const geom::Coordinate &p, const geom::CoordinateSequence &ring)
| Determines whether a point lies in the interior, on the boundary, or in the exterior of a ring.
static int | locatePointInRing (const geom::Coordinate &p, const std::vector< const geom::Coordinate * > &ring)
| Same as above, but taking a vector of const Coordinates.
static bool | isOnLine (const geom::Coordinate &p, const geom::CoordinateSequence *pt)
| Test whether a point lies on the given line segment.
static bool | isCCW (const geom::CoordinateSequence *ring)
| Computes whether a ring defined by an array of Coordinate is oriented counter-clockwise.
static int | computeOrientation (const geom::Coordinate &p1, const geom::Coordinate &p2, const geom::Coordinate &q)
| Computes the orientation of a point q to the directed line segment p1-p2.
static double | distancePointLine (const geom::Coordinate &p, const geom::Coordinate &A, const geom::Coordinate &B)
| Computes the distance from a point p to a line segment AB.
static double | distancePointLinePerpendicular (const geom::Coordinate &p, const geom::Coordinate &A, const geom::Coordinate &B)
| Computes the perpendicular distance from a point p to the (infinite) line containing the points AB.
static double | distanceLineLine (const geom::Coordinate &A, const geom::Coordinate &B, const geom::Coordinate &C, const geom::Coordinate &D)
| Computes the distance from a line segment AB to a line segment CD.
static double | signedArea (const geom::CoordinateSequence *ring)
| Returns the signed area for a ring. The area is positive if the ring is oriented CW.
static double | length (const geom::CoordinateSequence *pts)
| Computes the length of a linestring specified by a sequence of points.
static int | orientationIndex (const geom::Coordinate &p1, const geom::Coordinate &p2, const geom::Coordinate &q)
| Returns the index of the direction of the point `q` relative to a vector specified by `p1-p2`.

## Detailed Description

Specifies and implements various fundamental Computational Geometric algorithms. The algorithms supplied in this class are robust for double-precision floating point.

## Member Function Documentation

static int geos::algorithm::CGAlgorithms::computeOrientation | ( | const geom::Coordinate & | p1,
|  | const geom::Coordinate & | p2,
|  | const geom::Coordinate & | q
| ) |  |
| static

Computes the orientation of a point q to the directed line segment p1-p2.

The orientation of a point relative to a directed line segment indicates which way you turn to get to q after travelling from p1 to p2.

Returns
  1 if q is counter-clockwise from p1-p2
  -1 if q is clockwise from p1-p2
  0 if q is collinear with p1-p2

static double geos::algorithm::CGAlgorithms::distanceLineLine | ( | const geom::Coordinate & | A,
|  | const geom::Coordinate & | B,
|  | const geom::Coordinate & | C,
|  | const geom::Coordinate & | D
| ) |  |
| static

Computes the distance from a line segment AB to a line segment CD.

Note: NON-ROBUST!

Parameters

  A | a point of one line
  B | the second point of (must be different to A)
  C | one point of the line
  D | another point of the line (must be different to A)

static double geos::algorithm::CGAlgorithms::distancePointLine | ( | const geom::Coordinate & | p,
|  | const geom::Coordinate & | A,
|  | const geom::Coordinate & | B
| ) |  |
| static

Computes the distance from a point p to a line segment AB.

Note: NON-ROBUST!

Parameters

  p | the point to compute the distance for
  A | one point of the line
  B | another point of the line (must be different to A)

Returns
  the distance from p to line segment AB

static double geos::algorithm::CGAlgorithms::distancePointLinePerpendicular | ( | const geom::Coordinate & | p,
|  | const geom::Coordinate & | A,
|  | const geom::Coordinate & | B
| ) |  |
| static

Computes the perpendicular distance from a point p to the (infinite) line containing the points AB.

Parameters

  p | the point to compute the distance for
  A | one point of the line
  B | another point of the line (must be different to A)

Returns
  the distance from p to line AB

static bool geos::algorithm::CGAlgorithms::isCCW | ( | const geom::CoordinateSequence * | ring | ) |
| static

Computes whether a ring defined by an array of Coordinate is oriented counter-clockwise.

- The list of points is assumed to have the first and last points equal.
- This will handle coordinate lists which contain repeated points.

This algorithm is only guaranteed to work with valid rings. If the ring is invalid (e.g. self-crosses or touches), the computed result may not be correct.

Parameters

  ring | an array of coordinates forming a ring

Returns
  `true` if the ring is oriented counter-clockwise.

static bool geos::algorithm::CGAlgorithms::isOnLine | ( | const geom::Coordinate & | p,
|  | const geom::CoordinateSequence * | pt
| ) |  |
| static

Test whether a point lies on the given line segment.

Returns
  true true if the point is a vertex of the line or lies in the interior of a line segment in the linestring

static bool geos::algorithm::CGAlgorithms::isPointInRing | ( | const geom::Coordinate & | p,
|  | const geom::CoordinateSequence * | ring
| ) |  |
| static

Tests whether a point lies inside a ring.

The ring may be oriented in either direction. A point lying exactly on the ring boundary is considered to be inside the ring.

This algorithm does not first check the point against the envelope of the ring.

Parameters

  p | point to check for ring inclusion
  ring | is assumed to have first point identical to last point

Returns
  `true` if p is inside ring

See Also
  locatePointInRing

static double geos::algorithm::CGAlgorithms::length | ( | const geom::CoordinateSequence * | pts | ) |
| static

Computes the length of a linestring specified by a sequence of points.

Parameters

  pts | the points specifying the linestring

Returns
  the length of the linestring

static int geos::algorithm::CGAlgorithms::locatePointInRing | ( | const geom::Coordinate & | p,
|  | const geom::CoordinateSequence & | ring
| ) |  |
| static

Determines whether a point lies in the interior, on the boundary, or in the exterior of a ring.

The ring may be oriented in either direction.

This method does not first check the point against the envelope of the ring.

Parameters

  p | point to check for ring inclusion
  ring | an array of coordinates representing the ring (which must have first point identical to last point)

Returns
  the Location of p relative to the ring

static int geos::algorithm::CGAlgorithms::orientationIndex | ( | const geom::Coordinate & | p1,
|  | const geom::Coordinate & | p2,
|  | const geom::Coordinate & | q
| ) |  |
| static

Returns the index of the direction of the point `q` relative to a vector specified by `p1-p2`.

Parameters

  p1 | the origin point of the vector
  p2 | the final point of the vector
  q | the point to compute the direction to

Returns
  1 if q is counter-clockwise (left) from p1-p2
  -1 if q is clockwise (right) from p1-p2
  0 if q is collinear with p1-p2

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

- CGAlgorithms.h