Class: CGAlgorithms

jsts.algorithm.CGAlgorithms

new CGAlgorithms()

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

Members

(static) CLOCKWISE

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

(static) COLLINEAR

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

(static) COUNTERCLOCKWISE

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

(static) LEFT

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

(static) RIGHT

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

(static) STRAIGHT

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

Methods

(static) computeLength(pts) → {Number}

Computes the length of a linestring specified by a sequence of points. NOTE: This is renamed from length() to computeLength() because 'length' is a reserved keyword in javascript.
Parameters:
Name Type Description
`pts`
Source:
Returns:
the length of the linestring.
Type
Number

(static) computeOrientation(p1, p2, q) → {Number|Number|Number}

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.
Parameters:
Name Type Description
`p1` jsts.geom.Coordinate First coordinate of the linesegment.
`p2` jsts.geom.Coordinate Second coordinate of the linesegment.
`q` jsts.geom.Coordinate The point to calculate orientation of.
Source:
Returns:
• 1 if q is counter-clockwise from p1-p2.
Type
Number
• -1 if q is clockwise from p1-p2.
Type
Number
• 0 if q is collinear with p1-p2.
Type
Number

(static) distanceLineLine(A, B, C, D) → {Number}

Computes the distance from a line segment AB to a line segment CD Note: NON-ROBUST!
Parameters:
Name Type Description
`A` jsts.geom.Coordinate a point of one line.
`B` jsts.geom.Coordinate the second point of (must be different to A).
`C` jsts.geom.Coordinate one point of the line.
`D` jsts.geom.Coordinate another point of the line (must be different to A).
Source:
the distance.
Type
Number

(static) distancePointLine(p, A, B) → {Number}

Computes the distance from a point p to a line segment AB Note: NON-ROBUST!
Parameters:
Name Type Description
`p` jsts.geom.Coordinate the point to compute the distance for.
`A` jsts.geom.Coordinate one point of the line.
`B` jsts.geom.Coordinate another point of the line (must be different to A).
Source:
Returns:
the distance from p to line segment AB.
Type
Number

(static) distancePointLine2(p, line) → {Number}

Computes the distance from a point to a sequence of line segments.
Parameters:
Name Type Description
`p` jsts.geom.Coordinate a point.
`line`
Source:
Returns:
the minimum distance between the point and the line segments.
Type
Number

(static) distancePointLinePerpendicular(p, A, B) → {Number}

Computes the perpendicular distance from a point p to the (infinite) line containing the points AB
Parameters:
Name Type Description
`p` jsts.geom.Coordinate the point to compute the distance for.
`A` jsts.geom.Coordinate one point of the line.
`B` jsts.geom.Coordinate another point of the line (must be different to A).
Source:
Returns:
the distance from p to line AB.
Type
Number

(static) isCCW(ring) → {Boolean}

Computes whether a ring defined by an array of Coordinates 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:
Name Type Description
`ring`
Source:
Throws:
IllegalArgumentException if there are too few points to determine orientation (< 3)
Returns:
true if the ring is oriented counter-clockwise.
Type
Boolean

(static) isOnLine(p, pt) → {Boolean}

Tests whether a point lies on the line segments defined by a list of coordinates.
Parameters:
Name Type Description
`p` jsts.geom.Coordinate the coordinate to test.
`pt`
Source:
Returns:
true if the point is a vertex of the line or lies in the interior of a line segment in the linestring.
Type
Boolean

(static) isPointInRing(p, ring) → {Boolean}

Tests whether a point lies inside or on a ring. The ring may be oriented in either direction. A point lying exactly on the ring boundary is considered to be inside the ring.

This method does not first check the point against the envelope of the ring.

Parameters:
Name Type Description
`p` jsts.geom.Coordinate point to check for ring inclusion.
`ring`
Source:
See:
• locatePointInRing
Returns:
true if p is inside ring.
Type
Boolean

(static) length()

Source:
See:
• {jsts.algorithm.CGAlgorithms.computeLength} Since 'length' is a reserved keyword in javascript this function does not act as a function. Please use 'computeLength' instead.

(static) locatePointInRing(p, ring) → {jsts.geom.Location}

Determines whether a point lies in the interior, on the boundary, or in the exterior of a ring. The ring may be oriented in either direction.

This method does not first check the point against the envelope of the ring.

Parameters:
Name Type Description
`p` jsts.geom.Coordinate point to check for ring inclusion.
`ring`
Source:
Returns:
the Location of p relative to the ring.
Type
jsts.geom.Location

(static) orientationIndex(p1, p2, q) → {Number|Number|Number}

Returns the index of the direction of the point `q` relative to a vector specified by `p1-p2`.
Parameters:
Name Type Description
`p1` jsts.geom.Coordinate the origin point of the vector.
`p2` jsts.geom.Coordinate the final point of the vector.
`q` jsts.geom.Coordinate the point to compute the direction to.
Source:
Returns:
• 1 if q is counter-clockwise (left) from p1-p2.
Type
Number
• -1 if q is clockwise (right) from p1-p2.
Type
Number
• 0 if q is collinear with p1-p2.
Type
Number

(static) signedArea(ring) → {Number}

Computes the signed area for a ring. The signed area is:
• positive if the ring is oriented CW
• negative if the ring is oriented CCW
• zero if the ring is degenerate or flat
Parameters:
Name Type Description
`ring`
Source:
Returns:
the signed area of the ring.
Type
Number

(static) signedArea(ring) → {Number}

Computes the signed area for a ring. The signed area is positive if the ring is oriented CW, negative if the ring is oriented CCW, and zero if the ring is degenerate or flat.
Parameters:
Name Type Description
`ring`
Source:
Returns:
the signed area of the ring.
Type
Number