Class Line

  • All Implemented Interfaces:
    java.io.Serializable

    public final class Line
    extends Segment
    implements java.io.Serializable
    A straight line between a pair of points.
    See Also:
    Serialized Form
    • Constructor Detail

      • Line

        public Line()
        Creates a line segment.
      • Line

        public Line​(double x1,
                    double y1,
                    double x2,
                    double y2)
    • Method Detail

      • getType

        public Geometry.Type getType()
        Description copied from class: Geometry
        Returns the geometry type.
        Specified by:
        getType in class Geometry
        Returns:
        Returns the geometry type.
      • estimateMemorySize

        public long estimateMemorySize()
        Description copied from class: Geometry
        Returns an estimate of this object size in bytes.

        This estimate doesn't include the size of the VertexDescription object because instances of VertexDescription are shared among geometry objects.

        Specified by:
        estimateMemorySize in class Geometry
        Returns:
        Returns an estimate of this object size in bytes.
      • calculateLength2D

        public double calculateLength2D()
        Description copied from class: Geometry
        Calculates the length of the geometry. If the spatial reference is a Geographic Coordinate System (a system where coordinates are defined using angular units such as longitude and latitude) then the 2D distance calculation is returned in angular units. In cases where length must be calculated on a Geographic Coordinate System consider the using the geodeticLength method on the GeometryEngine
        Overrides:
        calculateLength2D in class Geometry
        Returns:
        A double value representing the 2D length of the geometry.
      • isDegenerate

        boolean isDegenerate​(double tolerance)
        Description copied from class: Segment
        Returns True if the segment is degenerate to a point with relation to the given tolerance. For Lines this means the line length is not longer than the tolerance. For the curves, the distance between the segment endpoints should not be longer than the tolerance and the distance from the line, connecting the endpoints to the furtherst point on the segment is not larger than the tolerance.
        Specified by:
        isDegenerate in class Segment
      • isCurve

        public boolean isCurve()
        Indicates if the line segment is a curve.
        Specified by:
        isCurve in class Segment
      • _isDegenerate

        boolean _isDegenerate​(double tolerance)
        Specified by:
        _isDegenerate in class Segment
      • queryEnvelope

        public void queryEnvelope​(Envelope env)
        Description copied from class: Geometry
        Returns the axis aligned bounding box of the geometry.
        Specified by:
        queryEnvelope in class Geometry
        Parameters:
        env - The envelope to return the result in.
      • queryEnvelope2D

        public void queryEnvelope2D​(Envelope2D env)
        Description copied from class: Geometry
        Returns tight bbox of the Geometry in X, Y plane.
        Specified by:
        queryEnvelope2D in class Geometry
        Parameters:
        env - The envelope to return the result in.
      • queryEnvelope3D

        void queryEnvelope3D​(Envelope3D env)
        Description copied from class: Geometry
        Returns tight bbox of the Geometry in 3D.
        Specified by:
        queryEnvelope3D in class Geometry
        Parameters:
        env - The envelope to return the result in.
      • applyTransformation

        public void applyTransformation​(Transformation2D transform)
        Description copied from class: Geometry
        Applies 2D affine transformation in XY plane.
        Specified by:
        applyTransformation in class Geometry
        Parameters:
        transform - The affine transformation to be applied to this geometry.
      • applyTransformation

        void applyTransformation​(Transformation3D transform)
        Description copied from class: Geometry
        Applies 3D affine transformation. Adds Z attribute if it is missing.
        Specified by:
        applyTransformation in class Geometry
        Parameters:
        transform - The affine transformation to be applied to this geometry.
      • createInstance

        public Geometry createInstance()
        Description copied from class: Geometry
        Creates an instance of an empty geometry of the same type.
        Specified by:
        createInstance in class Geometry
        Returns:
        The new instance.
      • _calculateArea2DHelper

        double _calculateArea2DHelper​(double xorg,
                                      double yorg)
        Description copied from class: Segment
        A helper function for area calculation. Calculates the Integral(y(t) * x'(t) * dt) for t = [0, 1]. The area of a ring is caluclated as a sum of the results of CalculateArea2DHelper.
        Specified by:
        _calculateArea2DHelper in class Segment
      • tToLength

        double tToLength​(double t)
        Description copied from class: Segment
        Converts curves parameter t to the curve length. Can be expensive for curves.
        Specified by:
        tToLength in class Segment
      • lengthToT

        double lengthToT​(double len)
        Specified by:
        lengthToT in class Segment
      • getCoordX_

        double getCoordX_​(double t)
      • getCoordY_

        double getCoordY_​(double t)
      • getCoord2D

        public void getCoord2D​(double t,
                               Point2D pt)
        Description copied from class: Segment
        Returns the coordinate of the point on this segment for the given parameter value (segments are parametric curves).
        Specified by:
        getCoord2D in class Segment
        Parameters:
        t - the parameter coordinate along the segment from 0.0 to 1.0. Value of 0 returns the start point, 1 returns end point.
        pt - the coordinate where result will be placed.
      • cut

        public Segment cut​(double t1,
                           double t2)
        Description copied from class: Segment
        Returns subsegment between parameters t1 and t2. The attributes are interpolated along the length of the curve.
        Specified by:
        cut in class Segment
      • cut

        void cut​(double t1,
                 double t2,
                 SegmentBuffer subSegmentBuffer)
        Description copied from class: Segment
        Calculates the subsegment between parameters t1 and t2, and stores the result in subSegmentBuffer. The attributes are interpolated along the length of the curve.
        Specified by:
        cut in class Segment
      • getAttributeAsDbl

        public double getAttributeAsDbl​(double t,
                                        int semantics,
                                        int ordinate)
        Description copied from class: Segment
        Returns the attribute on the segment for the given parameter value. The interpolation of attribute is given by the attribute interpolation type.
        Specified by:
        getAttributeAsDbl in class Segment
      • getClosestCoordinate

        public double getClosestCoordinate​(Point2D inputPt,
                                           boolean bExtrapolate)
        Description copied from class: Segment
        Finds a closest coordinate on this segment.
        Specified by:
        getClosestCoordinate in class Segment
        Parameters:
        inputPt - The 2D point to find the closest coordinate on this segment.
        bExtrapolate - TRUE if the segment is extrapolated at the end points along the end point tangents. Otherwise the result is limited to values between 0 and 1.
        Returns:
        The parametric coordinate t on the segment (0 corresponds to the start point, 1 corresponds to the end point). Use getCoord2D to obtain the 2D coordinate on the segment from t. To find the distance, call (inputPoint.sub(seg.getCoord2D(t))).length();
      • intersectionWithAxis2D

        public int intersectionWithAxis2D​(boolean b_axis_x,
                                          double ordinate,
                                          double[] result_ordinates,
                                          double[] parameters)
        Description copied from class: Segment
        Calculates intersection points of this segment with an infinite line, parallel to one of the axes.
        Specified by:
        intersectionWithAxis2D in class Segment
        Parameters:
        b_axis_x - TRUE if the function works with the line parallel to the axis X.
        ordinate - The ordinate value of the line (x for axis Y, y for axis X).
        result_ordinates - The value of ordinate in the intersection points One ordinate is equal to the ordinate parameter. This parameter can be NULL.
        parameters - The value of the parameter in the intersection points (between 0 and 1). This parameter can be NULL.
        Returns:
        The number of intersection points, 0 when no intersection points exist, -1 when the segment coincides with the line (infinite number of intersection points).
      • intersectionWithEnvelope2D

        int intersectionWithEnvelope2D​(Envelope2D clipEnv2D,
                                       boolean includeEnvBoundary,
                                       double[] segParams,
                                       double[] envelopeDistances)
      • intersectionOfYMonotonicWithAxisX

        double intersectionOfYMonotonicWithAxisX​(double y,
                                                 double x_parallel)
        Description copied from class: Segment
        Calculates intersection point of this segment with an infinite line, parallel to axis X. This segment must be to be y-monotonic (or horizontal).
        Specified by:
        intersectionOfYMonotonicWithAxisX in class Segment
        Parameters:
        y - The y coordinate of the line.
        x_parallel - For segments, that are horizontal, and have y coordinate, this value is returned.
        Returns:
        X coordinate of the intersection, or NaN, if no intersection.
      • _isIntersectingPoint

        boolean _isIntersectingPoint​(Point2D pt,
                                     double tolerance,
                                     boolean bExcludeExactEndpoints)
        Specified by:
        _isIntersectingPoint in class Segment
      • isIntersecting

        public boolean isIntersecting​(Point2D pt,
                                      double tolerance)
        Returns True if point and the segment intersect (not disjoint) for the given tolerance.
        Overrides:
        isIntersecting in class Segment
      • orientBottomUp_

        void orientBottomUp_()
      • _side

        int _side​(double ptX,
                  double ptY)
      • _intersection

        double _intersection​(Point2D pt,
                             double tolerance,
                             boolean bExcludeExactEndPoints)
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • equals

        boolean equals​(Line other)
      • _projectionIntersectHelper

        boolean _projectionIntersectHelper​(Line other,
                                           Point2D v,
                                           boolean bStart)
      • _projectionIntersect

        boolean _projectionIntersect​(Line other)
      • _isIntersectingHelper

        static boolean _isIntersectingHelper​(Line line1,
                                             Line line2)
      • _intersectHelper1

        static Point2D _intersectHelper1​(Line line1,
                                         Line line2,
                                         double tolerance)
      • _isIntersectingLineLine

        static int _isIntersectingLineLine​(Line line1,
                                           Line line2,
                                           double tolerance,
                                           boolean bExcludeExactEndpoints)
      • _intersectLineLineExact

        int _intersectLineLineExact​(Line line1,
                                    Line line2,
                                    Point2D[] intersectionPoints,
                                    double[] param1,
                                    double[] param2)
      • _intersectLineLine

        static int _intersectLineLine​(Line line1,
                                      Line line2,
                                      Point2D[] intersectionPoints,
                                      double[] param1,
                                      double[] param2,
                                      double tolerance)
      • replaceNaNs

        public void replaceNaNs​(int semantics,
                                double value)
        Description copied from class: Geometry
        Replaces NaNs in the attribute with the given value. If the geometry is not empty, it adds the attribute if geometry does not have it yet, and replaces the values. If the geometry is empty, it adds the attribute and does not set any values.
        Specified by:
        replaceNaNs in class Geometry
        Parameters:
        semantics - The semantics for which to replace the NaNs.
        value - The value to replace NaNs with.
      • getYMonotonicParts

        int getYMonotonicParts​(SegmentBuffer[] monotonicSegments)
        Description copied from class: Segment
        Splits this segment into Y monotonic parts and places them into the input array.
        Specified by:
        getYMonotonicParts in class Segment
        Parameters:
        monotonicSegments - The in/out array of SegmentBuffer structures that will be filled with the monotonic parts. The monotonicSegments array must contain at least 3 elements.
        Returns:
        The number of monotonic parts if the split had happened. Returns 0 if the segment is already monotonic.
      • toString

        public java.lang.String toString()
        The output of this method can be only used for debugging. It is subject to change without notice.
        Overrides:
        toString in class Geometry