Class PolygonUtils


  • public final class PolygonUtils
    extends Object
    Methods for working with Polygons.
    • Method Detail

      • getFrom

        public static Polygon getFrom​(List<List<Double>> polygon)
        Create a Polygon from a list of a list of floats.
      • getCentroid

        public static Point getCentroid​(List<Point> vertices)
        Get the central coordinates (centroid) of a list of Points.
      • CompareOnY

        public static int CompareOnY​(Polygon polygon1,
                                     Polygon polygon2)
        Compare two polygons based on their Y coordinates. Useful for sorting lists.
      • CompareOnX

        public static int CompareOnX​(Polygon polygon1,
                                     Polygon polygon2)
        Compare two polygons based on their X coordinates. Useful for sorting lists.
      • getMinMaxY

        public static MinMax getMinMaxY​(List<Point> vertices)
        Get the maximum and minimum Y coordinates in a given list of Points.
      • getMinMaxX

        public static MinMax getMinMaxX​(List<Point> vertices)
        Get the maximum and minimum X coordinates in a given list of Points.
      • isPointInY

        public static boolean isPointInY​(Point centroid,
                                         Double yMin,
                                         Double yMax)
        Determine if a Point is within two Y coordinates.
      • isPointInPolygonY

        public static boolean isPointInPolygonY​(Point centroid,
                                                Polygon polygon)
        Determine if a Point is within a Polygon's Y axis.
      • getMinYCoordinate

        public static Double getMinYCoordinate​(Polygon polygon)
      • getMaxYCoordinate

        public static Double getMaxYCoordinate​(Polygon polygon)
      • getMinXCoordinate

        public static Double getMinXCoordinate​(Polygon polygon)
      • getMaxXCoordinate

        public static Double getMaxXCoordinate​(Polygon polygon)
      • combine

        public static Polygon combine​(Polygon base,
                                      Polygon target)
        Merge the coordinates of the two polygons.