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-Geometrytype
- All Implemented Interfaces:
java.io.Serializable,java.lang.Iterable<T>
- Direct Known Subclasses:
GeometryCollection,MultiCurve,MultiLineString,MultiPoint,MultiPolygon,MultiSurface
@NonNullByDefault public abstract class MultiGeometry<T extends Geometry> extends Geometry implements java.lang.Iterable<T>
Base class for multi geometries.- Author:
- Sebastian Baumhekel
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.ArrayList<T>subgeomsSub geometries.-
Fields inherited from class io.github.sebasbaumh.postgis.Geometry
UNKNOWN_SRID
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedMultiGeometry(int type)Constructs an instance with the specified type.protectedMultiGeometry(int type, java.lang.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 voidadd(T geom)Adds a geometry.voidaddAll(java.lang.Iterable<? extends T> geoms)Adds all given geometries.booleancheckConsistency()Do some internal consistency checks on the geometry.booleanequals(java.lang.Object other)java.lang.Object equals implementationjava.lang.Iterable<Point>getCoordinates()Gets the coordinates of thisGeometry.java.util.Collection<T>getGeometries()Gets all geometries.intgetNumberOfCoordinates()Gets the number of coordinates of thisGeometry.inthashCode()booleanhasMeasure()Returns whether we have a measure (4th dimension)booleanis3d()Checks if thisGeometryis 3d.booleanisEmpty()Checks, if there are no sub-geometries.java.util.Iterator<T>iterator()voidsetSrid(int srid)Recursively sets the srid on this geometry and all contained subgeometriesintsize()Gets the number of contained geometries.-
Methods inherited from class io.github.sebasbaumh.postgis.Geometry
getDimension, getSrid, getType, numPoints
-
-
-
-
Constructor Detail
-
MultiGeometry
protected MultiGeometry(int type)
Constructs an instance with the specified type.- Parameters:
type- int value corresponding to the geometry type
-
MultiGeometry
protected MultiGeometry(int type, java.lang.Iterable<? extends T> geoms)Constructs an instance with the specified type and geometries.- Parameters:
type- int value corresponding to the geometry typegeoms- geometries
-
-
Method Detail
-
add
public void add(T geom)
Adds a geometry.- Parameters:
geom- geometry
-
addAll
public void addAll(java.lang.Iterable<? extends T> geoms)
Adds all given geometries.- Parameters:
geoms- geometries
-
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.
-
equals
public boolean equals(@Nullable java.lang.Object other)Description copied from class:Geometryjava.lang.Object equals implementation
-
getCoordinates
public java.lang.Iterable<Point> getCoordinates()
Description copied from class:GeometryGets the coordinates of thisGeometry.- Specified by:
getCoordinatesin classGeometry- Returns:
- coordinates
-
getGeometries
public java.util.Collection<T> getGeometries()
Gets all geometries.- Returns:
- geometries
-
getNumberOfCoordinates
public int getNumberOfCoordinates()
Description copied from class:GeometryGets the number of coordinates of thisGeometry.- Specified by:
getNumberOfCoordinatesin classGeometry- Returns:
- number of coordinates
-
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()
Checks, if there are no sub-geometries.
-
iterator
public java.util.Iterator<T> iterator()
-
setSrid
public void setSrid(int srid)
Description copied from class:GeometryRecursively 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
-
-