Search Results for

    Show / Hide Table of Contents

    Class LineIntersector

    A LineIntersector is an algorithm that can both test whether two line segments intersect and compute the intersection point(s) if they do.

    There are three possible outcomes when determining whether two line segments intersect:

    • NoIntersection - the segments do not intersect
    • PointIntersection - the segments intersect in a single point
    • CollinearIntersection - the segments are collinear and they intersect in a line segment

    For segments which intersect in a single point, the point may be either an endpoint or in the interior of each segment. If the point lies in the interior of both segments, this is termed a proper intersection. The property IsProper test for this situation.

    The intersection point(s) may be computed in a precise or non-precise manner. Computing an intersection point precisely involves rounding it via a supplied PrecisionModel.

    LineIntersectors do not perform an initial envelope intersection test to determine if the segments are disjoint. This is because this class is likely to be used in a context where envelope overlap is already known to occur (or be likely).

    Inheritance
    object
    LineIntersector
    RobustLineIntersector
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: NetTopologySuite.Algorithm
    Assembly: NetTopologySuite.dll
    Syntax
    public abstract class LineIntersector

    Constructors

    | Edit this page View Source

    LineIntersector()

    Creates an instance of this class

    Declaration
    protected LineIntersector()

    Fields

    | Edit this page View Source

    CollinearIntersection

    Indicates that line segments intersect in a line segment

    Declaration
    public const int CollinearIntersection = 2
    Field Value
    Type Description
    int
    | Edit this page View Source

    InputLines

    Array of coordinate arrays forming the lines

    Declaration
    protected Coordinate[][] InputLines
    Field Value
    Type Description
    Coordinate[][]
    | Edit this page View Source

    IntersectionLineIndex

    The indexes of the endpoints of the intersection lines, in order along the corresponding line

    Declaration
    protected int[] IntersectionLineIndex
    Field Value
    Type Description
    int[]
    | Edit this page View Source

    IntersectionPoint

    Array of

    Declaration
    protected Coordinate[] IntersectionPoint
    Field Value
    Type Description
    Coordinate[]
    | Edit this page View Source

    NoIntersection

    Indicates that line segments do not intersect

    Declaration
    public const int NoIntersection = 0
    Field Value
    Type Description
    int
    | Edit this page View Source

    PointIntersection

    Indicates that line segments intersect in a single point

    Declaration
    public const int PointIntersection = 1
    Field Value
    Type Description
    int
    | Edit this page View Source

    Result

    A value indicating the intersection result

    Possible values are:
    • NoIntersection
    • PointIntersection
    • CollinearIntersection
    Declaration
    protected int Result
    Field Value
    Type Description
    int

    Properties

    | Edit this page View Source

    HasIntersection

    Tests whether the input geometries intersect.

    Declaration
    public bool HasIntersection { get; }
    Property Value
    Type Description
    bool

    true if the input geometries intersect.

    | Edit this page View Source

    IntersectionNum

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

    Declaration
    public int IntersectionNum { get; }
    Property Value
    Type Description
    int

    The number of intersection points found (0, 1, or 2)

    | Edit this page View Source

    IsCollinear

    Gets a value indicating if the computed intersection is collinear

    Declaration
    protected bool IsCollinear { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    IsEndPoint

    Gets a value indicating if the intersection is an end-point intersection

    Declaration
    protected bool IsEndPoint { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    IsProper

    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).

    Declaration
    public bool IsProper { get; protected set; }
    Property Value
    Type Description
    bool

    true if the intersection is proper.

    | Edit this page View Source

    Pa

    Alias the IntersectionPoint[0] for ease of reference

    Declaration
    protected Coordinate Pa { get; }
    Property Value
    Type Description
    Coordinate
    | Edit this page View Source

    Pb

    Alias the IntersectionPoint[1] for ease of reference

    Declaration
    protected Coordinate Pb { get; }
    Property Value
    Type Description
    Coordinate
    | Edit this page View Source

    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.

    Declaration
    public PrecisionModel PrecisionModel { get; set; }
    Property Value
    Type Description
    PrecisionModel

    Methods

    | Edit this page View Source

    ComputeEdgeDistance(Coordinate, Coordinate, Coordinate)

    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 distance 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.

    Declaration
    public static double ComputeEdgeDistance(Coordinate p, Coordinate p0, Coordinate p1)
    Parameters
    Type Name Description
    Coordinate p
    Coordinate p0
    Coordinate p1
    Returns
    Type Description
    double
    | Edit this page View Source

    ComputeIntLineIndex()

    Computes the IntersectionLineIndex values.

    Declaration
    protected void ComputeIntLineIndex()
    | Edit this page View Source

    ComputeIntLineIndex(int)

    Computes the intersection line index

    Declaration
    protected void ComputeIntLineIndex(int segmentIndex)
    Parameters
    Type Name Description
    int segmentIndex

    The segment index

    | Edit this page View Source

    ComputeIntersect(Coordinate, Coordinate, Coordinate, Coordinate)

    Computes the intersection of two line segments, one defined by p1 and p2, the other by q1 and q2.

    Declaration
    public abstract int ComputeIntersect(Coordinate p1, Coordinate p2, Coordinate q1, Coordinate q2)
    Parameters
    Type Name Description
    Coordinate p1

    The 1st point of the 1st segment

    Coordinate p2

    The 2nd point of the 1st segment

    Coordinate q1

    The 1st point of the 2nd segment

    Coordinate q2

    The 2nd point of the 2nd segment

    Returns
    Type Description
    int
    Remarks

    Don't use this function directly, it is not meant for public use. Please call ComputeIntersection(Coordinate, Coordinate, Coordinate, Coordinate) and test HasIntersection or IsCollinear along with IsProper and IsEndPoint.

    | Edit this page View Source

    ComputeIntersection(Coordinate, Coordinate, Coordinate)

    Compute the intersection of a point p and the line p1-p2. This function computes the bool value of the hasIntersection test. The actual value of the intersection (if there is one) is equal to the value of p.

    Declaration
    public abstract void ComputeIntersection(Coordinate p, Coordinate p1, Coordinate p2)
    Parameters
    Type Name Description
    Coordinate p
    Coordinate p1
    Coordinate p2
    | Edit this page View Source

    ComputeIntersection(Coordinate, Coordinate, Coordinate, Coordinate)

    Computes the intersection of the lines p1-p2 and p3-p4. This function computes both the bool value of the hasIntersection test and the (approximate) value of the intersection point itself (if there is one).

    Declaration
    public void ComputeIntersection(Coordinate p1, Coordinate p2, Coordinate p3, Coordinate p4)
    Parameters
    Type Name Description
    Coordinate p1

    The 1st point of the 1st segment

    Coordinate p2

    The 2nd point of the 1st segment

    Coordinate p3

    The 1st point of the 2nd segment

    Coordinate p4

    The 2nd point of the 2nd segment

    | Edit this page View Source

    GetEdgeDistance(int, int)

    Computes the "edge distance" of an intersection point along the specified input line segment.

    Declaration
    public double GetEdgeDistance(int segmentIndex, int intIndex)
    Parameters
    Type Name Description
    int segmentIndex

    is 0 or 1.

    int intIndex

    is 0 or 1.

    Returns
    Type Description
    double

    The edge distance of the intersection point.

    | Edit this page View Source

    GetEndpoint(int, int)

    Gets an endpoint of an input segment.

    Declaration
    public Coordinate GetEndpoint(int segmentIndex, int ptIndex)
    Parameters
    Type Name Description
    int segmentIndex

    the index of the input segment (0 or 1)

    int ptIndex

    the index of the endpoint (0 or 1)

    Returns
    Type Description
    Coordinate

    The specified endpoint

    | Edit this page View Source

    GetIndexAlongSegment(int, int)

    Computes the index (order) of the intIndex'th intersection point in the direction of a specified input line segment.

    Declaration
    public int GetIndexAlongSegment(int segmentIndex, int intIndex)
    Parameters
    Type Name Description
    int segmentIndex

    is 0 or 1.

    int intIndex

    is 0 or 1.

    Returns
    Type Description
    int

    The index of the intersection point along the segment (0 or 1).

    | Edit this page View Source

    GetIntersection(int)

    Returns the intIndex'th intersection point.

    Declaration
    public Coordinate GetIntersection(int intIndex)
    Parameters
    Type Name Description
    int intIndex

    is 0 or 1.

    Returns
    Type Description
    Coordinate

    The intIndex'th intersection point.

    | Edit this page View Source

    GetIntersectionAlongSegment(int, int)

    Computes the intIndex'th intersection point in the direction of a specified input line segment.

    Declaration
    public Coordinate GetIntersectionAlongSegment(int segmentIndex, int intIndex)
    Parameters
    Type Name Description
    int segmentIndex

    is 0 or 1.

    int intIndex

    is 0 or 1.

    Returns
    Type Description
    Coordinate

    The intIndex'th intersection point in the direction of the specified input line segment.

    | Edit this page View Source

    IsInteriorIntersection()

    Tests whether either intersection point is an interior point of one of the input segments.

    Declaration
    public bool IsInteriorIntersection()
    Returns
    Type Description
    bool

    true if either intersection point is in the interior of one of the input segment.

    | Edit this page View Source

    IsInteriorIntersection(int)

    Tests whether either intersection point is an interior point of the specified input segment.

    Declaration
    public bool IsInteriorIntersection(int inputLineIndex)
    Parameters
    Type Name Description
    int inputLineIndex
    Returns
    Type Description
    bool

    true if either intersection point is in the interior of the input segment.

    | Edit this page View Source

    IsIntersection(Coordinate)

    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.

    Declaration
    public bool IsIntersection(Coordinate pt)
    Parameters
    Type Name Description
    Coordinate pt
    Returns
    Type Description
    bool

    true if the input point is one of the intersection points.

    | Edit this page View Source

    NonRobustComputeEdgeDistance(Coordinate, Coordinate, Coordinate)

    This function is non-robust, since it may compute the square of large numbers. Currently not sure how to improve this.

    Declaration
    public static double NonRobustComputeEdgeDistance(Coordinate p, Coordinate p1, Coordinate p2)
    Parameters
    Type Name Description
    Coordinate p
    Coordinate p1
    Coordinate p2
    Returns
    Type Description
    double
    | Edit this page View Source

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    string
    Overrides
    object.ToString()
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX