Package org.meteoinfo.jts.algorithm
Class RayCrossingCounter
- java.lang.Object
-
- org.meteoinfo.jts.algorithm.RayCrossingCounter
-
public class RayCrossingCounter extends java.lang.ObjectCounts 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 aPolygonalgeometry. 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
-
-
Constructor Summary
Constructors Constructor Description RayCrossingCounter(Coordinate p)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcountSegment(Coordinate p1, Coordinate p2)Counts a segmentintgetLocation()Gets theLocationof the point relative to the ring, polygon or multipolygon from which the processed segments were provided.booleanisOnSegment()Reports whether the point lies exactly on one of the supplied segments.booleanisPointInPolygon()Tests whether the point lies in or on the ring, polygon or multipolygon from which the processed segments were provided.static intlocatePointInRing(Coordinate p, Coordinate[] ring)Determines theLocationof a point in a ring.static intlocatePointInRing(Coordinate p, CoordinateSequence ring)Determines theLocationof a point in a ring.
-
-
-
Constructor Detail
-
RayCrossingCounter
public RayCrossingCounter(Coordinate p)
-
-
Method Detail
-
locatePointInRing
public static int locatePointInRing(Coordinate p, Coordinate[] ring)
Determines theLocationof a point in a ring. This method is an exemplar of how to use this class.- Parameters:
p- the point to testring- an array of Coordinates forming a ring- Returns:
- the location of the point in the ring
-
locatePointInRing
public static int locatePointInRing(Coordinate p, CoordinateSequence ring)
Determines theLocationof a point in a ring.- Parameters:
p- the point to testring- a coordinate sequence forming a ring- Returns:
- the location of the point in the ring
-
countSegment
public void countSegment(Coordinate p1, Coordinate p2)
Counts a segment- Parameters:
p1- an endpoint of the segmentp2- another endpoint of the segment
-
isOnSegment
public boolean isOnSegment()
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
-
getLocation
public int getLocation()
Gets theLocationof 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
-
isPointInPolygon
public boolean 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
-
-