Package io.github.sebasbaumh.postgis
Class PolygonBase<T extends Curve>
- java.lang.Object
-
- io.github.sebasbaumh.postgis.Geometry
-
- io.github.sebasbaumh.postgis.PolygonBase<T>
-
- Type Parameters:
T- type of the ring geometries
- All Implemented Interfaces:
LineBasedGeometry,Serializable,Iterable<T>
- Direct Known Subclasses:
CurvePolygon,Polygon
@NonNullByDefault public abstract class PolygonBase<T extends Curve> extends Geometry implements Iterable<T>, LineBasedGeometry
Base class for a polygon to allow similar handling of straight and circular polygons.- Author:
- Sebastian Baumhekel
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class io.github.sebasbaumh.postgis.Geometry
UNKNOWN_SRID
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPolygonBase(int type, Class<U> clazzRing)Constructor for subclasses.protectedPolygonBase(int type, Class<U> clazzRing, Iterable<V> rings)Constructor for subclasses.protectedPolygonBase(int type, U lsOuterRing)Constructor for subclasses.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRing(T ring)Adds a ring.booleancheckConsistency()Do some internal consistency checks on the geometry.voidclearRings()Clears all rings.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.intgetNumberOfRings()Gets the number of rings.TgetOuterRing()Gets the outer ring/boundary of the polygon.Iterable<T>getRings()Gets all inner rings.PointgetStartPoint()Gets the start point.booleanhasMeasure()Returns whether we have a measure (4th dimension)booleanis3d()Checks if thisGeometryis 3d.booleanisClockwise()Checks if this polygon is oriented in clockwise direction.booleanisClosed()Checks if this line is closed, so the last coordinate is the same as the first coordinate.booleanisEmpty()Ist thisGeometryempty, so does it contain no coordinates or other geometries?Iterator<T>iterator()doublelength()Gets the length of this line.voidsetOuterRing(T ls)Sets the outer ring/boundary of the polygon.StringtoString()-
Methods inherited from class io.github.sebasbaumh.postgis.Geometry
getDimension, getSrid, getType, hashCode, numPoints, setSrid
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
PolygonBase
protected PolygonBase(int type, Class<U> clazzRing)Constructor for subclasses.- Parameters:
clazzRing- class of the ringtype- has to be given by all subclasses
-
PolygonBase
protected PolygonBase(int type, Class<U> clazzRing, Iterable<V> rings)Constructor for subclasses.- Parameters:
clazzRing- class of the ringtype- has to be given by all subclassesrings- rings
-
PolygonBase
protected PolygonBase(int type, U lsOuterRing)Constructor for subclasses.- Parameters:
type- has to be given by all subclasseslsOuterRing- outer ring
-
-
Method Detail
-
addRing
public void addRing(T ring)
Adds a ring.- Parameters:
ring- ring
-
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.
-
clearRings
public void clearRings()
Clears all rings.
-
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
-
getNumberOfRings
public int getNumberOfRings()
Gets the number of rings.- Returns:
- number of rings.
-
getOuterRing
public T getOuterRing()
Gets the outer ring/boundary of the polygon.- Returns:
- outer ring
-
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
-
isClockwise
public boolean isClockwise()
Checks if this polygon is oriented in clockwise direction. Is false for the outer polygon and true for its holes.- Returns:
- true on success, else false
-
isClosed
public boolean isClosed()
Description copied from interface:LineBasedGeometryChecks if this line is closed, so the last coordinate is the same as the first coordinate.- Specified by:
isClosedin interfaceLineBasedGeometry- Returns:
- true on success, else false
-
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
-
setOuterRing
public void setOuterRing(T ls)
Sets the outer ring/boundary of the polygon.- Parameters:
ls- outer ring
-
-