public class CGAlgorithms extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
CLOCKWISE
A value that indicates an orientation of clockwise, or a right turn.
|
static int |
COLLINEAR
A value that indicates an orientation of collinear, or no turn (straight).
|
static int |
COUNTERCLOCKWISE
A value that indicates an orientation of counterclockwise, or a left turn.
|
static int |
LEFT
|
static int |
RIGHT
|
static int |
STRAIGHT
|
| Constructor and Description |
|---|
CGAlgorithms()
|
| Modifier and Type | Method and Description |
|---|---|
static int |
computeOrientation(Coordinate
Computes the orientation of a point q to the directed line segment p1-p2.
|
static double |
distanceLineLine(Coordinate
Computes the distance from a line segment AB to a line segment CD Note: NON-ROBUST!
|
static double |
distancePointLine(Coordinate
Computes the distance from a point to a sequence of line segments.
|
static double |
distancePointLine(Coordinate
Computes the distance from a point p to a line segment AB Note: NON-ROBUST!
|
static double |
distancePointLinePerpendicular(Coordinate
Computes the perpendicular distance from a point p to the (infinite) line containing the points AB
|
static boolean |
isCCW(Coordinate
Computes whether a ring defined by an array of
Coordinates is oriented counter-clockwise.
|
static boolean |
isOnLine(Coordinate
Tests whether a point lies on the line segments defined by a list of coordinates.
|
static boolean |
isPointInRing(Coordinate
Tests whether a point lies inside or on a ring.
|
static double |
length(CoordinateSequence
Computes the length of a linestring specified by a sequence of points.
|
static int |
locatePointInRing(Coordinate
Determines whether a point lies in the interior, on the boundary, or in the exterior of a ring.
|
static int |
orientationIndex(Coordinate
Returns the index of the direction of the point
q relative to a vector specified by
p1-p2.
|
static double |
signedArea(Coordinate
Computes the signed area for a ring.
|
static double |
signedArea(CoordinateSequence
Computes the signed area for a ring.
|
public static final int CLOCKWISE
public static final int RIGHT
public static final int COUNTERCLOCKWISE
public static final int LEFT
public static final int COLLINEAR
public static final int STRAIGHT
public static int orientationIndex(Coordinatep1, Coordinate p2, Coordinate q)
q relative to a vector specified by
p1-p2.
p1 - the origin point of the vector
p2 - the final point of the vector
q - the point to compute the direction to
public static boolean isPointInRing(Coordinatep, Coordinate [] ring)
This method does not first check the point against the envelope of the ring.
p - point to check for ring inclusion
ring - an array of coordinates representing the ring (which must have first point identical to last point)
locatePointInRing
public static int locatePointInRing(Coordinatep, Coordinate [] ring)
This method does not first check the point against the envelope of the ring.
p - point to check for ring inclusion
ring - an array of coordinates representing the ring (which must have first point identical to last point)
Location of p relative to the ring
public static boolean isOnLine(Coordinatep, Coordinate [] pt)
public static boolean isCCW(Coordinate[] ring)
Coordinates is oriented counter-clockwise.
ring - an array of Coordinates forming a ring
IllegalArgumentException - if there are too few points to determine orientation (< 3)
public static int computeOrientation(Coordinatep1, Coordinate p2, Coordinate q)
public static double distancePointLine(Coordinatep, Coordinate A, Coordinate B)
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)
public static double distancePointLinePerpendicular(Coordinatep, Coordinate A, Coordinate B)
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)
public static double distancePointLine(Coordinatep, Coordinate [] line)
p - a point
line - a sequence of contiguous line segments defined by their vertices
public static double distanceLineLine(CoordinateA, Coordinate B, Coordinate C, Coordinate D)
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)
public static double signedArea(Coordinate[] ring)
ring - the coordinates forming the ring
public static double signedArea(CoordinateSequencering)
ring - the coordinates forming the ring
public static double length(CoordinateSequencepts)
pts - the points specifying the linestring