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:
  • Field Details

  • Constructor Details

    • 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, Iterable<? extends T> geoms)
      Constructs an instance with the specified type and geometries.
      Parameters:
      type - int value corresponding to the geometry type
      geoms - geometries
  • Method Details

    • 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 class Geometry
      Returns:
      true if all checks are passed.
    • equals

      public boolean equals(@Nullable Object other)
      Description copied from class: Geometry
      java.lang.Object equals implementation
      Overrides:
      equals in class Geometry
      Parameters:
      other - geometry to compare
      Returns:
      true if equal, false otherwise
    • getCoordinates

      public Iterable<Point> getCoordinates()
      Description copied from class: Geometry
      Gets the coordinates of this Geometry.
      Specified by:
      getCoordinates in class Geometry
      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 this Geometry.
      Specified by:
      getNumberOfCoordinates in class Geometry
      Returns:
      number of coordinates
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Geometry
    • hasMeasure

      public boolean hasMeasure()
      Description copied from class: Geometry
      Returns whether we have a measure (4th dimension)
      Specified by:
      hasMeasure in class Geometry
      Returns:
      true if the geometry has a measure, false otherwise
    • is3d

      public boolean is3d()
      Description copied from class: Geometry
      Checks if this Geometry is 3d.
      Specified by:
      is3d in class Geometry
      Returns:
      true on success, else false
    • isEmpty

      public boolean isEmpty()
      Checks, if there are no sub-geometries.
      Specified by:
      isEmpty in class Geometry
      Returns:
      true on success, else false
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T extends Geometry>
    • setSrid

      public void setSrid(int srid)
      Description copied from class: Geometry
      Recursively sets the srid on this geometry and all contained subgeometries
      Overrides:
      setSrid in class Geometry
      Parameters:
      srid - the SRID for this geometry
    • size

      public int size()
      Gets the number of contained geometries.
      Returns:
      number of contained geometries
    • toString

      public String toString()
      Overrides:
      toString in class Object