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:
-
Field Summary
Fields inherited from class io.github.sebasbaumh.postgis.Geometry
UNKNOWN_SRID
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
PolygonBase
(int type, Class<U> clazzRing) Constructor for subclasses.protected
PolygonBase
(int type, Class<U> clazzRing, Iterable<V> rings) Constructor for subclasses.protected
PolygonBase
(int type, U lsOuterRing) Constructor for subclasses. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a ring.boolean
Do some internal consistency checks on the geometry.void
Clears all rings.boolean
java.lang.Object equals implementationGets the coordinates of thisGeometry
.Gets the end point.int
Gets the number of coordinates of thisGeometry
.int
Gets the number of rings.Gets the outer ring/boundary of the polygon.getRings()
Gets all inner rings.Gets the start point.int
hashCode()
boolean
Returns whether we have a measure (4th dimension)boolean
is3d()
Checks if thisGeometry
is 3d.boolean
Checks if this polygon is oriented in clockwise direction.boolean
isClosed()
Checks if this line is closed, so the last coordinate is the same as the first coordinate.boolean
isEmpty()
Ist thisGeometry
empty, so does it contain no coordinates or other geometries?iterator()
double
length()
Gets the length of this line.void
setOuterRing
(T ls) Sets the outer ring/boundary of the polygon.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
-
Constructor Details
-
PolygonBase
Constructor for subclasses.- Parameters:
type
- has to be given by all subclassesclazzRing
- class of the ring
-
PolygonBase
Constructor for subclasses.- Parameters:
type
- has to be given by all subclassesclazzRing
- class of the ringrings
- rings
-
PolygonBase
protected PolygonBase(int type, U lsOuterRing) Constructor for subclasses.- Parameters:
type
- has to be given by all subclasseslsOuterRing
- outer ring
-
-
Method Details
-
addRing
Adds a ring.- Parameters:
ring
- ring
-
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.
-
clearRings
public void clearRings()Clears all rings. -
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
-
getNumberOfRings
public int getNumberOfRings()Gets the number of rings.- Returns:
- number of rings.
-
getOuterRing
Gets the outer ring/boundary of the polygon.- Returns:
- outer ring
-
getRings
Gets all inner rings.- Returns:
- inner rings
-
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. -
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:LineBasedGeometry
Checks if this line is closed, so the last coordinate is the same as the first coordinate.- Specified by:
isClosed
in interfaceLineBasedGeometry
- Returns:
- true on success, else false
-
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
-
setOuterRing
Sets the outer ring/boundary of the polygon.- Parameters:
ls
- outer ring
-
toString
-