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
Linestring.
- Author:
- Sebastian Baumhekel
- See Also:
-
Field Summary
FieldsFields inherited from class io.github.sebasbaumh.postgis.Geometry
UNKNOWN_SRID
-
Constructor Summary
ConstructorsModifierConstructorDescriptionConstructs an instance.protected
LineString
(int type) Constructor for subclasses.protected
LineString
(int type, Iterable<Point> points) Constructor for subclasses.LineString
(Iterable<Point> points) Constructs an instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the given point.final void
Adds all given points.boolean
Do some internal consistency checks on the geometry.void
close()
Closes thisLineString
if the last coordinate is not already the same as the first coordinate.boolean
java.lang.Object equals implementationGets the coordinates of thisGeometry
.Gets the end point.int
Gets the number of coordinates of thisGeometry
.Gets the start point.int
hashCode()
boolean
Returns whether we have a measure (4th dimension)boolean
is3d()
Checks if thisGeometry
is 3d.boolean
isEmpty()
Ist thisGeometry
empty, so does it contain no coordinates or other geometries?iterator()
double
length()
Gets the length of this line.void
reverse()
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 Details
-
TYPE
public static final int TYPEThe 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
Constructor for subclasses.- Parameters:
type
- has to be given by all subclasses.points
-Point
s
-
LineString
Constructs an instance.- Parameters:
points
- points
-
-
Method Details
-
add
Adds the given point.- Parameters:
p
- point
-
addAll
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 classGeometry
- Returns:
- true if all checks are passed.
-
close
public void close()Closes thisLineString
if the last coordinate is not already the same as the first coordinate. -
equals
Description copied from class:Geometry
java.lang.Object equals implementation -
getCoordinates
Description copied from class:Geometry
Gets the coordinates of thisGeometry
.- Specified by:
getCoordinates
in classGeometry
- Returns:
- coordinates
-
getEndPoint
Description copied from interface:LineBasedGeometry
Gets the end point.- Specified by:
getEndPoint
in interfaceLineBasedGeometry
- Returns:
Point
on success, else null
-
getNumberOfCoordinates
public int getNumberOfCoordinates()Description copied from class:Geometry
Gets the number of coordinates of thisGeometry
.- Specified by:
getNumberOfCoordinates
in classGeometry
- Returns:
- number of coordinates
-
getStartPoint
Description copied from interface:LineBasedGeometry
Gets the start point.- Specified by:
getStartPoint
in interfaceLineBasedGeometry
- Returns:
Point
on success, else null
-
hashCode
public int hashCode() -
hasMeasure
public boolean hasMeasure()Description copied from class:Geometry
Returns whether we have a measure (4th dimension)- Specified by:
hasMeasure
in classGeometry
- Returns:
- true if the geometry has a measure, false otherwise
-
is3d
public boolean is3d()Description copied from class:Geometry
Checks if thisGeometry
is 3d. -
isEmpty
public boolean isEmpty()Description copied from class:Geometry
Ist thisGeometry
empty, so does it contain no coordinates or other geometries? -
iterator
-
length
public double length()Description copied from interface:LineBasedGeometry
Gets the length of this line.- Specified by:
length
in interfaceLineBasedGeometry
- Returns:
- length
-
reverse
public void reverse()Reverses this linestring.
-