Class LineString

All Implemented Interfaces:
Comparable<Geometry>

public final class LineString extends Curve
A line string geometry representing a sequence of connected line segments. LineStrings are immutable.
Since:
4.0.0
  • Method Details

    • of

      public static LineString of(Point... points)
      Creates a line string from an array of points. All points must have the same SRID and z-dimension flag, and none may be empty. A line string must have at least 2 points; use empty() or empty(Model) for an empty line string.
      Parameters:
      points - the points, at least 2 of them
      Returns:
      the line string
      Throws:
      IllegalArgumentException - if points is null, if it holds fewer than 2 points, if any element is null, if any element is an empty point, or if the points do not all have the same SRID and the same z dimension
      Since:
      4.0.0
    • empty

      public static LineString empty()
      Creates an empty line string with Model.CARTESIAN model.
      Returns:
      an empty line string
      Since:
      4.0.0
    • empty

      public static LineString empty(Model model)
      Creates an empty line string with the specified model.
      Parameters:
      model - Model.CARTESIAN or Model.GEOGRAPHIC
      Returns:
      an empty line string
      Throws:
      IllegalArgumentException - if model is Model.OTHER or null
      Since:
      4.0.0
    • points

      public List<Point> points()
      Returns an unmodifiable list of points in this line string.
      Returns:
      the points, an empty list when this line string is empty
      Since:
      4.0.0
    • isEmpty

      public boolean isEmpty()
      Description copied from class: Geometry
      Returns true if this geometry is empty (has no coordinates). For collections, returns true if all parts are empty.
      Specified by:
      isEmpty in class Geometry
      Returns:
      true if empty
    • equals

      public boolean equals(Object o)
      Description copied from class: Geometry
      Exact equality: same type, same SRID, same coordinates (including z flag). Coordinates are compared numerically, so -0.0 equals 0.0.
      Specified by:
      equals in class Geometry
    • hashCode

      public int hashCode()
      Description copied from class: Geometry
      Hash code consistent with equals. Zero values are normalized so -0.0 and 0.0 hash alike.
      Specified by:
      hashCode in class Geometry