public class RayCrossingCounter extends Object implements Visitor<LineSegment>
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
| Constructor and Description |
|---|
RayCrossingCounter(double x,
double y) |
RayCrossingCounter(Point point) |
| Modifier and Type | Method and Description |
|---|---|
void |
countSegment(double x1,
double y1,
double x2,
double y2) |
void |
countSegment(Point p1,
Point p2)
For each segment, check if it crosses a horizontal ray running from the
test point in the positive x direction.
|
void |
countSegment(Segment segment) |
Location |
getLocation()
Gets the
Location of the point relative to
the ring, polygon
or multipolygon from which the processed segments were provided. |
double |
getX() |
double |
getY() |
boolean |
isOnSegment()
Reports whether the point lies exactly on one of the supplied segments.
|
boolean |
isPointInPolygon()
Tests whether the point lies in or on
the ring, polygon
or multipolygon from which the processed segments were provided.
|
static Location |
locatePointInRing(Point coordinates,
LineString ring)
Determines the
Location of a point in a ring. |
static Location |
locatePointInRing(Point p,
Point[] ring)
Determines the
Location of a point in a ring. |
void |
setPointOnSegment(boolean pointOnSegment) |
boolean |
visit(LineSegment segment)
Visit an item of type T, performing some operation on the item.
|
public RayCrossingCounter(double x,
double y)
public RayCrossingCounter(Point point)
public static Location locatePointInRing(Point coordinates, LineString ring)
Location of a point in a ring.p - the point to testring - a coordinate sequence forming a ringpublic static Location locatePointInRing(Point p, Point[] ring)
Location of a point in a ring.
This method is an exemplar of how to use this class.p - the point to testring - an array of Point forming a ringpublic void countSegment(double x1,
double y1,
double x2,
double y2)
public void countSegment(Point p1, Point p2)
p1 - an endpoint of the segmentp2 - another endpoint of the segmentpublic void countSegment(Segment segment)
public Location getLocation()
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.
public double getX()
public double getY()
public boolean isOnSegment()
public boolean isPointInPolygon()
This method only determines the correct location if all relevant segments must have been processed.
public void setPointOnSegment(boolean pointOnSegment)
public boolean visit(LineSegment segment)
Visitorvisit in interface Visitor<LineSegment>segment - The item to process.Copyright © 2015 Revolution Systems Inc.. All rights reserved.