Package io.github.sebasbaumh.postgis
Class MultiGeometry<T extends Geometry>
- java.lang.Object
-
- io.github.sebasbaumh.postgis.Geometry
-
- io.github.sebasbaumh.postgis.MultiGeometry<T>
-
- Type Parameters:
T
-Geometry
type
- All Implemented Interfaces:
Serializable
,Iterable<T>
- Direct Known Subclasses:
GeometryCollection
,MultiCurve
,MultiLineString
,MultiPoint
,MultiPolygon
,MultiSurface
@NonNullByDefault public abstract class MultiGeometry<T extends Geometry> extends Geometry implements Iterable<T>
Base class for multi geometries.- Author:
- Sebastian Baumhekel
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected ArrayList<T>
subgeoms
Sub geometries.-
Fields inherited from class io.github.sebasbaumh.postgis.Geometry
UNKNOWN_SRID
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
MultiGeometry(int type)
Constructs an instance with the specified type.protected
MultiGeometry(int type, Iterable<? extends T> geoms)
Constructs an instance with the specified type and geometries.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(T geom)
Adds a geometry.void
addAll(Iterable<? extends T> geoms)
Adds all given geometries.boolean
checkConsistency()
Do some internal consistency checks on the geometry.boolean
equals(Object other)
java.lang.Object equals implementationIterable<Point>
getCoordinates()
Gets the coordinates of thisGeometry
.Collection<T>
getGeometries()
Gets all geometries.int
getNumberOfCoordinates()
Gets the number of coordinates of thisGeometry
.int
hashCode()
boolean
hasMeasure()
Returns whether we have a measure (4th dimension)boolean
is3d()
Checks if thisGeometry
is 3d.boolean
isEmpty()
Checks, if there are no sub-geometries.Iterator<T>
iterator()
void
setSrid(int srid)
Recursively sets the srid on this geometry and all contained subgeometriesint
size()
Gets the number of contained geometries.String
toString()
-
Methods inherited from class io.github.sebasbaumh.postgis.Geometry
getDimension, getSrid, getType, numPoints
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
add
public void add(T geom)
Adds a geometry.- Parameters:
geom
- geometry
-
addAll
public void addAll(Iterable<? extends T> geoms)
Adds all given geometries.- Parameters:
geoms
- geometries
-
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.
-
equals
public boolean equals(@Nullable Object other)
Description copied from class:Geometry
java.lang.Object equals implementation
-
getCoordinates
public Iterable<Point> getCoordinates()
Description copied from class:Geometry
Gets the coordinates of thisGeometry
.- Specified by:
getCoordinates
in classGeometry
- Returns:
- coordinates
-
getGeometries
public Collection<T> getGeometries()
Gets all geometries.- Returns:
- geometries
-
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
-
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
-
isEmpty
public boolean isEmpty()
Checks, if there are no sub-geometries.
-
setSrid
public void setSrid(int srid)
Description copied from class:Geometry
Recursively sets the srid on this geometry and all contained subgeometries
-
size
public int size()
Gets the number of contained geometries.- Returns:
- number of contained geometries
-
-