Class Polygon


  • public class Polygon
    extends Object
    Contains any number of vertex coordinates (Points).
    • Constructor Detail

      • Polygon

        public Polygon​(Collection<List<Double>> coordinates)
        Create a Polygon from a list of a list of floats.
      • Polygon

        public Polygon​(List<Point> coordinates)
        Create a Polygon from a list of Points.
    • Method Detail

      • getAsBbox

        public Bbox getAsBbox()
        Get the polygon as a Bbox.
      • getBoundingBox

        public Polygon getBoundingBox()
        Get a bounding box that encloses the Polygon.
      • getCentroid

        public Point getCentroid()
        Get the central coordinates (centroid) of the Polygon.
      • getMinMaxY

        public MinMax getMinMaxY()
        Get the maximum and minimum Y coordinates.
      • getMinMaxX

        public MinMax getMinMaxX()
        Get the maximum and minimum Y coordinates.
      • isEmpty

        public boolean isEmpty()
        Returns true if there are no coordinates.
      • toString

        public String toString()
        Default string representation.
        Overrides:
        toString in class Object
      • toStringPrecise

        public String toStringPrecise()
        String representation with precise coordinates.
      • compareOnY

        public int compareOnY​(Polygon polygon2)
        Compare two polygons based on their Y coordinates. Useful for sorting lists.
      • compareOnX

        public int compareOnX​(Polygon polygon2)
        Compare two polygons based on their X coordinates. Useful for sorting lists.
      • combine

        public Polygon combine​(Polygon target)
        Merge the coordinates of the two polygons.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getCoordinates

        public List<Point> getCoordinates()
        Position information as a list of points in clockwise order.