Class Line

All Implemented Interfaces:
Serializable

public final class Line extends Segment implements Serializable
A straight line between a pair of points.
See Also:
  • Constructor Details

    • Line

      public Line()
      Creates a line segment.
    • Line

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

    • 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.
    • isCurve

      public boolean isCurve()
      Indicates if the line segment is a curve.
    • 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.
    • 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.
    • 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.
    • 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
    • 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).
    • 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
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Segment
    • 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.
    • toString

      public 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