Class LineString

All Implemented Interfaces:
LineBasedGeometry, Serializable, Iterable<Point>
Direct Known Subclasses:
CircularString, LinearRing

@NonNullByDefault public class LineString extends Curve implements Iterable<Point>
Linestring.
Author:
Sebastian Baumhekel
See Also:
  • Field Details

    • TYPE

      public static final int TYPE
      The OGIS geometry type number for lines.
      See Also:
  • Constructor Details

    • LineString

      public LineString()
      Constructs an instance.
    • LineString

      protected LineString(int type)
      Constructor for subclasses.
      Parameters:
      type - has to be given by all subclasses.
    • LineString

      protected LineString(int type, Iterable<Point> points)
      Constructor for subclasses.
      Parameters:
      type - has to be given by all subclasses.
      points - Points
    • LineString

      public LineString(Iterable<Point> points)
      Constructs an instance.
      Parameters:
      points - points
  • Method Details

    • add

      public void add(Point p)
      Adds the given point.
      Parameters:
      p - point
    • addAll

      public final void addAll(Iterable<Point> geoms)
      Adds all given points.
      Parameters:
      geoms - points
    • checkConsistency

      public boolean checkConsistency()
      Description copied from class: Geometry
      Do some internal consistency checks on the geometry. Currently, all Geometries must have a valid dimension (2 or 3) and a valid type. Composed geometries must have all equal SRID, dimensionality and measures, as well as that they do not contain NULL or inconsistent subgeometries. BinaryParser and WKTParser should only generate consistent geometries. BinaryWriter may produce invalid results on inconsistent geometries.
      Overrides:
      checkConsistency in class Geometry
      Returns:
      true if all checks are passed.
    • close

      public void close()
      Closes this LineString if the last coordinate is not already the same as the first coordinate.
      Specified by:
      close in class Curve
    • equals

      public boolean equals(@Nullable Object other)
      Description copied from class: Geometry
      java.lang.Object equals implementation
      Overrides:
      equals in class Geometry
      Parameters:
      other - geometry to compare
      Returns:
      true if equal, false otherwise
    • getCoordinates

      public Iterable<Point> getCoordinates()
      Description copied from class: Geometry
      Gets the coordinates of this Geometry.
      Specified by:
      getCoordinates in class Geometry
      Returns:
      coordinates
    • getEndPoint

      @Nullable public Point getEndPoint()
      Description copied from interface: LineBasedGeometry
      Gets the end point.
      Specified by:
      getEndPoint in interface LineBasedGeometry
      Returns:
      Point on success, else null
    • getNumberOfCoordinates

      public int getNumberOfCoordinates()
      Description copied from class: Geometry
      Gets the number of coordinates of this Geometry.
      Specified by:
      getNumberOfCoordinates in class Geometry
      Returns:
      number of coordinates
    • getStartPoint

      @Nullable public Point getStartPoint()
      Description copied from interface: LineBasedGeometry
      Gets the start point.
      Specified by:
      getStartPoint in interface LineBasedGeometry
      Returns:
      Point on success, else null
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Geometry
    • hasMeasure

      public boolean hasMeasure()
      Description copied from class: Geometry
      Returns whether we have a measure (4th dimension)
      Specified by:
      hasMeasure in class Geometry
      Returns:
      true if the geometry has a measure, false otherwise
    • is3d

      public boolean is3d()
      Description copied from class: Geometry
      Checks if this Geometry is 3d.
      Specified by:
      is3d in class Geometry
      Returns:
      true on success, else false
    • isEmpty

      public boolean isEmpty()
      Description copied from class: Geometry
      Ist this Geometry empty, so does it contain no coordinates or other geometries?
      Specified by:
      isEmpty in class Geometry
      Returns:
      true on success, else false
    • iterator

      public Iterator<Point> iterator()
      Specified by:
      iterator in interface Iterable<Point>
    • length

      public double length()
      Description copied from interface: LineBasedGeometry
      Gets the length of this line.
      Specified by:
      length in interface LineBasedGeometry
      Returns:
      length
    • reverse

      public void reverse()
      Reverses this linestring.
      Specified by:
      reverse in class Curve