Class: LineIntersector

jsts.algorithm.LineIntersector

new LineIntersector()

A LineIntersector is an algorithm that can both test whether two line segments intersect and compute the intersection point if they do. The intersection point may be computed in a precise or non-precise manner. Computing it precisely involves rounding it to an integer. (This assumes that the input coordinates have been made precise by scaling them to an integer grid.)
Source:

Members

(static) COLLINEAR_INTERSECTION :int

Indicates that line segments intersect in a line segment
• int
Source:

(static) NO_INTERSECTION :int

Indicates that line segments do not intersect
• int
Source:

(static) POINT_INTERSECTION :int

Indicates that line segments intersect in a single point
• int
Source:

• boolean
Source:

(protected) inputLines :Array.<Array.<Coordinate>>

Type:
• Array.<Array.<Coordinate>>
Source:

(protected) intLineIndex :Array.<Array.<int>>

Type:
• Array.<Array.<int>>
Source:

(protected) intPt :Array.<Coordinate>

Type:
• Array.<Coordinate>
Source:

• Coordinate
Source:

• Coordinate
Source:

(protected) precisionModel :PrecisionModel

Type:
• PrecisionModel
Source:

• int
Source:

Methods

(static) computeEdgeDistance(p, p0, p1) → {double}

Computes the "edge distance" of an intersection point p along a segment. The edge distance is a metric of the point along the edge. The metric used is a robust and easy to compute metric function. It is not equivalent to the usual Euclidean metric. It relies on the fact that either the x or the y ordinates of the points in the edge are unique, depending on whether the edge is longer in the horizontal or vertical direction.

NOTE: This function may produce incorrect distances for inputs where p is not precisely on p1-p2 (E.g. p = (139,9) p1 = (139,10), p2 = (280,1) produces distanct 0.0, which is incorrect.

My hypothesis is that the function is safe to use for points which are the result of rounding points which lie on the line, but not safe to use for truncated points.

Parameters:
Name Type Description
`p` Coordinate
`p0` Coordinate
`p1` Coordinate
Source:
Type
double

(static) nonRobustComputeEdgeDistance(p, p0, p1) → {double}

This function is non-robust, since it may compute the square of large numbers. Currently not sure how to improve this.
Parameters:
Name Type Description
`p` Coordinate
`p0` Coordinate
`p1` Coordinate
Source:
Type
double

(protected) computeIntersect(p1, p2, q1, q2) → {int}

Parameters:
Name Type Description
`p1` Coordinate
`p2` Coordinate
`q1` Coordinate
`q2` Coordinate
Source:
Type
int

computeIntersection(p1, p2, p3, p4)

Computes the intersection of the lines p1-p2 and p3-p4. This function computes both the boolean value of the hasIntersection test and the (approximate) value of the intersection point itself (if there is one).
Parameters:
Name Type Description
`p1` Coordinate
`p2` Coordinate
`p3` Coordinate
`p4` Coordinate
Source:

computeIntersection(p, p1, p2)

Compute the intersection of a point p and the line p1-p2. This function computes the boolean value of the hasIntersection test. The actual value of the intersection (if there is one) is equal to the value of `p`.
Parameters:
Name Type Description
`p` Coordinate
`p1` Coordinate
`p2` Coordinate
Source:

Source:

(protected) computeIntLineIndex(segmentIndex)

Parameters:
Name Type Description
`segmentIndex` int
Source:

getEdgeDistance(segmentIndex, intIndex) → {double}

Computes the "edge distance" of an intersection point along the specified input line segment.
Parameters:
Name Type Description
`segmentIndex` int is 0 or 1.
`intIndex` int is 0 or 1.
Source:
Returns:
the edge distance of the intersection point.
Type
double

getEndpoint(segmentIndex, ptIndex)

Gets an endpoint of an input segment.
Parameters:
Name Type Description
`segmentIndex` the index of the input segment (0 or 1).
`ptIndex` the index of the endpoint (0 or 1).
Source:
Returns:
the specified endpoint.

getIndexAlongSegment(segmentIndex, intIndex) → {int}

Computes the index of the intIndex'th intersection point in the direction of a specified input line segment
Parameters:
Name Type Description
`segmentIndex` int is 0 or 1.
`intIndex` int is 0 or 1.
Source:
Returns:
the index of the intersection point along the segment (0 or 1).
Type
int

getIntersection(intIndex) → {Coordinate}

Returns the intIndex'th intersection point
Parameters:
Name Type Description
`intIndex` int is 0 or 1.
Source:
Returns:
the intIndex'th intersection point.
Type
Coordinate

getIntersectionAlongSegment(segmentIndex, intIndex) → {Coordinate}

Computes the intIndex'th intersection point in the direction of a specified input line segment
Parameters:
Name Type Description
`segmentIndex` int is 0 or 1.
`intIndex` int is 0 or 1.
Source:
Returns:
the intIndex'th intersection point in the direction of the specified input line segment.
Type
Coordinate

getIntersectionNum() → {int}

Returns the number of intersection points found. This will be either 0, 1 or 2.
Source:
Type
int

hasIntersection() → {boolean}

Tests whether the input geometries intersect.
Source:
Returns:
true if the input geometries intersect.
Type
boolean

Source:
Type
boolean

Source:
Type
boolean

isInteriorIntersection() → {boolean}

Tests whether either intersection point is an interior point of one of the input segments.
Source:
Returns:
`true` if either intersection point is in the interior of one of the input segments.
Type
boolean

isInteriorIntersection2(inputLineIndex) → {boolean}

Tests whether either intersection point is an interior point of the specified input segment.
Parameters:
Name Type Description
`inputLineIndex`
Source:
Returns:
`true` if either intersection point is in the interior of the input segment.
Type
boolean

isIntersection(pt) → {boolean}

Test whether a point is a intersection point of two line segments. Note that if the intersection is a line segment, this method only tests for equality with the endpoints of the intersection segment. It does not return true if the input point is internal to the intersection segment.
Parameters:
Name Type Description
`pt` Coordinate
Source:
Returns:
true if the input point is one of the intersection points.
Type
boolean

isProper() → {boolean}

Tests whether an intersection is proper.
The intersection between two line segments is considered proper if they intersect in a single point in the interior of both segments (e.g. the intersection is a single point and is not equal to any of the endpoints).

The intersection between a point and a line segment is considered proper if the point lies in the interior of the segment (e.g. is not equal to either of the endpoints).

Source:
Returns:
true if the intersection is proper.
Type
boolean

setPrecisionModel(precisionModel)

Force computed intersection to be rounded to a given precision model. No getter is provided, because the precision model is not required to be specified.
Parameters:
Name Type Description
`precisionModel`
Source: