GEOS  3.9.1dev
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
geos::algorithm::RayCrossingCounterDD Class Reference

Counts the number of segments crossed by a horizontal ray extending to the right from a given point, in an incremental fashion. More...

#include <RayCrossingCounterDD.h>

Collaboration diagram for geos::algorithm::RayCrossingCounterDD:
[legend]

Public Member Functions

 RayCrossingCounterDD (const geom::Coordinate &p_point)
 
void countSegment (const geom::Coordinate &p1, const geom::Coordinate &p2)
 Counts a segment. More...
 
bool isOnSegment ()
 Reports whether the point lies exactly on one of the supplied segments. More...
 
geom::Location getLocation ()
 Gets the Location of the point relative to the ring, polygon or multipolygon from which the processed segments were provided. More...
 
bool isPointInPolygon ()
 Tests whether the point lies in or on the ring, polygon or multipolygon from which the processed segments were provided. More...
 

Static Public Member Functions

static geom::Location locatePointInRing (const geom::Coordinate &p, const geom::CoordinateSequence &ring)
 Determines the Location of a point in a ring. This method is an exemplar of how to use this class. More...
 
static geom::Location locatePointInRing (const geom::Coordinate &p, const std::vector< const geom::Coordinate * > &ring)
 Semantically equal to the above, just different args encoding. More...
 
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. More...
 

Private Member Functions

 RayCrossingCounterDD (const RayCrossingCounterDD &other)=delete
 
RayCrossingCounterDDoperator= (const RayCrossingCounterDD &rhs)=delete
 

Private Attributes

const geom::Coordinatepoint
 
int crossingCount
 
bool isPointOnSegment
 

Detailed Description

Counts the number of segments crossed by a horizontal ray extending to the right from a given point, in an incremental fashion.

This can be used to determine whether a point lies in a polygonal geometry. The class determines the situation where the point lies exactly on a segment. When being used for Point-In-Polygon determination, this case allows short-circuiting the evaluation.

This class handles polygonal geometries with any number of shells and holes. The orientation of the shell and hole rings is unimportant. In order to compute a correct location for a given polygonal geometry, it is essential that all segments are counted which

The only exception is when the point-on-segment situation is detected, in which case no further processing is required. The implication of the above rule is that segments which can be a priori determined to not touch the ray (i.e. by a test of their bounding box or Y-extent) do not need to be counted. This allows for optimization by indexing.

Definition at line 64 of file RayCrossingCounterDD.h.

Constructor & Destructor Documentation

geos::algorithm::RayCrossingCounterDD::RayCrossingCounterDD ( const RayCrossingCounterDD other)
privatedelete
geos::algorithm::RayCrossingCounterDD::RayCrossingCounterDD ( const geom::Coordinate p_point)
inline

Definition at line 109 of file RayCrossingCounterDD.h.

Member Function Documentation

void geos::algorithm::RayCrossingCounterDD::countSegment ( const geom::Coordinate p1,
const geom::Coordinate p2 
)

Counts a segment.

Parameters
p1an endpoint of the segment
p2another endpoint of the segment
geom::Location geos::algorithm::RayCrossingCounterDD::getLocation ( )

Gets the Location of the point relative to the ring, polygon or multipolygon from which the processed segments were provided.

This method only determines the correct location if all relevant segments must have been processed.

Returns
the Location of the point
bool geos::algorithm::RayCrossingCounterDD::isOnSegment ( )
inline

Reports whether the point lies exactly on one of the supplied segments.

This method may be called at any time as segments are processed. If the result of this method is true, no further segments need be supplied, since the result will never change again.

Returns
true if the point lies exactly on a segment

Definition at line 134 of file RayCrossingCounterDD.h.

bool geos::algorithm::RayCrossingCounterDD::isPointInPolygon ( )

Tests whether the point lies in or on the ring, polygon or multipolygon from which the processed segments were provided.

This method only determines the correct location if all relevant segments must have been processed.

Returns
true if the point lies in or on the supplied polygon
static geom::Location geos::algorithm::RayCrossingCounterDD::locatePointInRing ( const geom::Coordinate p,
const geom::CoordinateSequence ring 
)
static

Determines the Location of a point in a ring. This method is an exemplar of how to use this class.

Parameters
pthe point to test
ringan array of Coordinates forming a ring
Returns
the location of the point in the ring
static geom::Location geos::algorithm::RayCrossingCounterDD::locatePointInRing ( const geom::Coordinate p,
const std::vector< const geom::Coordinate * > &  ring 
)
static

Semantically equal to the above, just different args encoding.

RayCrossingCounterDD& geos::algorithm::RayCrossingCounterDD::operator= ( const RayCrossingCounterDD rhs)
privatedelete
static int geos::algorithm::RayCrossingCounterDD::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
p1the origin point of the vector
p2the final point of the vector
qthe 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

Member Data Documentation

int geos::algorithm::RayCrossingCounterDD::crossingCount
private

Definition at line 68 of file RayCrossingCounterDD.h.

bool geos::algorithm::RayCrossingCounterDD::isPointOnSegment
private

Definition at line 71 of file RayCrossingCounterDD.h.

const geom::Coordinate& geos::algorithm::RayCrossingCounterDD::point
private

Definition at line 66 of file RayCrossingCounterDD.h.


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