Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.vividsolutions.jts.algorithm
Class CGAlgorithms

    java.lang.Object
      com.vividsolutions.jts.algorithm.CGAlgorithms

Direct Known Subclasses:
  NonRobustCGAlgorithms, RobustCGAlgorithms

public class CGAlgorithms
extends java.lang.Object

Specifies and implements various fundamental Computational Geometric algorithms. The algorithms supplied in this class are robust for double-precision floating point.

Version:
  1.7

Field Summary
`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 Summary
`CGAlgorithms()`

Method Summary
`static int` | `computeOrientation(Coordinate p1, Coordinate p2, Coordinate q)` Computes the orientation of a point q to the directed line segment p1-p2.
`static double` | `distanceLineLine(Coordinate A, Coordinate B, Coordinate C, Coordinate D)` Computes the distance from a line segment AB to a line segment CD Note: NON-ROBUST!
`static double` | `distancePointLine(Coordinate p, Coordinate A, Coordinate B)` Computes the distance from a point p to a line segment AB Note: NON-ROBUST!
`static double` | `distancePointLinePerpendicular(Coordinate p, Coordinate A, Coordinate B)` Computes the perpendicular distance from a point p to the (infinite) line containing the points AB
`static boolean` | `isCCW(Coordinate[] ring)` Computes whether a ring defined by an array of `Coordinate` is oriented counter-clockwise.
`static boolean` | `isOnLine(Coordinate p, Coordinate[] pt)` Test whether a point lies on the line segments defined by a list of coordinates.
`static boolean` | `isPointInRing(Coordinate p, Coordinate[] ring)` Test whether a point lies inside a ring.
`static double` | `length(CoordinateSequence pts)` Computes the length of a linestring specified by a sequence of points.
`static int` | `orientationIndex(Coordinate p1, Coordinate p2, Coordinate q)` Returns the index of the direction of the point `q` relative to a vector specified by `p1-p2`.
`static double` | `signedArea(Coordinate[] ring)` Returns the signed area for a ring.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### CLOCKWISE

    public static final int CLOCKWISE

  A value that indicates an orientation of clockwise, or a right turn.

  See Also:
    Constant Field Values

### RIGHT

    public static final int RIGHT

See Also:
  Constant Field Values

### COUNTERCLOCKWISE

    public static final int COUNTERCLOCKWISE

  A value that indicates an orientation of counterclockwise, or a left turn.

  See Also:
    Constant Field Values

### LEFT

    public static final int LEFT

See Also:
  Constant Field Values

### COLLINEAR

    public static final int COLLINEAR

  A value that indicates an orientation of collinear, or no turn (straight).

  See Also:
    Constant Field Values

### STRAIGHT

    public static final int STRAIGHT

See Also:
  Constant Field Values

Constructor Detail

### CGAlgorithms

    public CGAlgorithms()

Method Detail

### orientationIndex

    public static int orientationIndex(Coordinate p1,
                                       Coordinate p2,
                                       Coordinate q)

  Returns the index of the direction of the point `q` relative to a vector specified by `p1-p2`.

  Parameters:
    `p1` - the origin point of the vector
    `p2` - the final point of the vector
    `q` - the point to compute the direction to
  Returns:
    1 if q is counter-clockwise (left) from p1-p2

### isPointInRing

    public static boolean isPointInRing(Coordinate p,
                                        Coordinate[] ring)

  Test whether a point lies inside a ring. The ring may be oriented in either direction. If the point lies on the ring boundary the result of this method is unspecified.

  This algorithm does not attempt to first check the point against the envelope of the ring.

  Parameters:
    `p` - point to check for ring inclusion
    `ring` - assumed to have first point identical to last point
  Returns:
    `true` if p is inside ring

### isOnLine

    public static boolean isOnLine(Coordinate p,
                                   Coordinate[] pt)

  Test whether a point lies on the line segments defined by a list of coordinates.

  Returns:
    true true if the point is a vertex of the line or lies in the interior of a line segment in the linestring

### isCCW

    public static boolean isCCW(Coordinate[] ring)

  Computes whether a ring defined by an array of `Coordinate` is oriented counter-clockwise.
  - The list of points is assumed to have the first and last points equal.
  - This will handle coordinate lists which contain repeated points.
  This algorithm is only guaranteed to work with valid rings. If the ring is invalid (e.g. self-crosses or touches), the computed result may not be correct.

  Parameters:
    `ring` - an array of coordinates forming a ring
  Returns:
    `true` if the ring is oriented counter-clockwise.

### computeOrientation

    public static int computeOrientation(Coordinate p1,
                                         Coordinate p2,
                                         Coordinate q)

  Computes the orientation of a point q to the directed line segment p1-p2. The orientation of a point relative to a directed line segment indicates which way you turn to get to q after travelling from p1 to p2.

  Returns:
    1 if q is counter-clockwise from p1-p2

### distancePointLine

    public static double distancePointLine(Coordinate p,
                                           Coordinate A,
                                           Coordinate B)

  Computes the distance from a point p to a line segment AB Note: NON-ROBUST!

  Parameters:
    `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)
  Returns:
    the distance from p to line segment AB

### distancePointLinePerpendicular

    public static double distancePointLinePerpendicular(Coordinate p,
                                                        Coordinate A,
                                                        Coordinate B)

  Computes the perpendicular distance from a point p to the (infinite) line containing the points AB

  Parameters:
    `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)
  Returns:
    the distance from p to line AB

### distanceLineLine

    public static double distanceLineLine(Coordinate A,
                                          Coordinate B,
                                          Coordinate C,
                                          Coordinate D)

  Computes the distance from a line segment AB to a line segment CD Note: NON-ROBUST!

  Parameters:
    `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)

### signedArea

    public static double signedArea(Coordinate[] ring)

  Returns the signed area for a ring. The area is positive if the ring is oriented CW.

### length

    public static double length(CoordinateSequence pts)

  Computes the length of a linestring specified by a sequence of points.

  Parameters:
    `pts` - the points specifying the linestring
  Returns:
    the length of the linestring

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD