RayCrossingCounter class

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 {@link 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

  • touch the ray
  • lie in in any ring which may contain the point
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.

This implementation uses the extended-precision orientation test, to provide maximum robustness and consistency within other algorithms.

@author Martin Davis

Constructors

RayCrossingCounter(Coordinate p)

Properties

crossingCount int
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
isPointOnSegment bool
getter/setter pair
p Coordinate
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

countSegment(Coordinate p1, Coordinate p2) → void
Counts a segment
getLocation() int
Gets the {@link Location} of the point relative to the ring, polygon or multipolygon from which the processed segments were provided.
isOnSegment() bool
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.
isPointInPolygon() bool
Tests whether the point lies in or on the ring, polygon or multipolygon from which the processed segments were provided.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

locatePointInRing(Coordinate p, CoordinateSequence ring) int
Determines the {@link Location} of a point in a ring.
locatePointInRingList(Coordinate p, List<Coordinate> ring) int
Determines the {@link Location} of a point in a ring. This method is an exemplar of how to use this class.