Package io.github.sebasbaumh.postgis
Class LineString
- java.lang.Object
-
- io.github.sebasbaumh.postgis.Geometry
-
- io.github.sebasbaumh.postgis.Curve
-
- io.github.sebasbaumh.postgis.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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static intTYPEThe OGIS geometry type number for lines.-
Fields inherited from class io.github.sebasbaumh.postgis.Geometry
UNKNOWN_SRID
-
-
Constructor Summary
Constructors Modifier Constructor Description LineString()Constructs an instance.protectedLineString(int type)Constructor for subclasses.protectedLineString(int type, Iterable<Point> points)Constructor for subclasses.LineString(Iterable<Point> points)Constructs an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Point p)Adds the given point.voidaddAll(Iterable<Point> geoms)Adds all given points.booleancheckConsistency()Do some internal consistency checks on the geometry.voidclose()Closes thisLineStringif the last coordinate is not already the same as the first coordinate.booleanequals(Object other)java.lang.Object equals implementationIterable<Point>getCoordinates()Gets the coordinates of thisGeometry.PointgetEndPoint()Gets the end point.intgetNumberOfCoordinates()Gets the number of coordinates of thisGeometry.PointgetStartPoint()Gets the start point.inthashCode()booleanhasMeasure()Returns whether we have a measure (4th dimension)booleanis3d()Checks if thisGeometryis 3d.booleanisEmpty()Ist thisGeometryempty, so does it contain no coordinates or other geometries?Iterator<Point>iterator()doublelength()Gets the length of this line.voidreverse()Reverses this linestring.-
Methods inherited from class io.github.sebasbaumh.postgis.Curve
isClockwise, isClosed, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
TYPE
public static final int TYPE
The OGIS geometry type number for lines.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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
-
-
Method Detail
-
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:GeometryDo 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:
checkConsistencyin classGeometry- Returns:
- true if all checks are passed.
-
close
public void close()
Closes thisLineStringif the last coordinate is not already the same as the first coordinate.
-
equals
public boolean equals(@Nullable Object other)Description copied from class:Geometryjava.lang.Object equals implementation
-
getCoordinates
public Iterable<Point> getCoordinates()
Description copied from class:GeometryGets the coordinates of thisGeometry.- Specified by:
getCoordinatesin classGeometry- Returns:
- coordinates
-
getEndPoint
@Nullable public Point getEndPoint()
Description copied from interface:LineBasedGeometryGets the end point.- Specified by:
getEndPointin interfaceLineBasedGeometry- Returns:
Pointon success, else null
-
getNumberOfCoordinates
public int getNumberOfCoordinates()
Description copied from class:GeometryGets the number of coordinates of thisGeometry.- Specified by:
getNumberOfCoordinatesin classGeometry- Returns:
- number of coordinates
-
getStartPoint
@Nullable public Point getStartPoint()
Description copied from interface:LineBasedGeometryGets the start point.- Specified by:
getStartPointin interfaceLineBasedGeometry- Returns:
Pointon success, else null
-
hasMeasure
public boolean hasMeasure()
Description copied from class:GeometryReturns whether we have a measure (4th dimension)- Specified by:
hasMeasurein classGeometry- Returns:
- true if the geometry has a measure, false otherwise
-
isEmpty
public boolean isEmpty()
Description copied from class:GeometryIst thisGeometryempty, so does it contain no coordinates or other geometries?
-
length
public double length()
Description copied from interface:LineBasedGeometryGets the length of this line.- Specified by:
lengthin interfaceLineBasedGeometry- Returns:
- length
-
-