Class LineString<P extends Position>

  • All Implemented Interfaces:
    Serializable, Linear<P>, Simple
    Direct Known Subclasses:
    LinearRing

    public class LineString<P extends Position>
    extends Geometry<P>
    implements Linear<P>, Simple
    A LineString is a 1-dimensional Geometry consisting of the LineSegments defined by consecutive pairs of Points of a PointSequence.
    Author:
    Karel Maesen, Geovise BVBA, 2011
    See Also:
    Serialized Form
    • Constructor Detail

      • LineString

        protected LineString​(LineString<P> base)
        This constructor has been added to speed up object creation of LinearRings
        Parameters:
        base -
      • LineString

        public LineString​(PositionSequence<P> positions,
                          CoordinateReferenceSystem<P> crs)
        Constructs a LineString from the specified positions and ProjectedGeometryOperations implementation.
        Parameters:
        positions - the PositionSequence that determines this geometry
        Throws:
        IllegalArgumentException - if the passed PointSequence is non-empty and of size < 2
    • Method Detail

      • getStartPosition

        public P getStartPosition()
        Returns the first Position of this LineString.
        Specified by:
        getStartPosition in interface Linear<P extends Position>
        Returns:
        the first Position of this LineString.
      • getEndPosition

        public P getEndPosition()
        Returns the last Position of this LineString.
        Specified by:
        getEndPosition in interface Linear<P extends Position>
        Returns:
        the last Position of this LineString.
      • isClosed

        public boolean isClosed()
        Checks whether this LineString is closed, i.e. the first Point equals the last.
        Returns:
        true if this LineString is closed.
      • isRing

        public boolean isRing()
        Checks whether this LineString is a ring, i.e. is closed and non-empty.

        Note that this implementation allows rings thate are non-simple.

        Returns:
        true if this LineString is a ring.
      • getDimension

        public int getDimension()
        Description copied from class: Geometry
        Returns the topological dimension of this instance. In non-homogenous collections, this will return the largest topological dimension of the contained Geometries.
        Specified by:
        getDimension in class Geometry<P extends Position>
        Returns:
        the topological dimension of this instance
      • accept

        public void accept​(GeometryVisitor<P> visitor)
        Description copied from class: Geometry
        Accepts a GeometryVisitor.

        If this Geometry instance is a GeometryCollection then it will pass the visitor to its contained Geometries.

        Specified by:
        accept in class Geometry<P extends Position>