Class CFPolygon

  • All Implemented Interfaces:
    Polygon, SimpleGeometry

    public class CFPolygon
    extends Object
    implements Polygon
    A CF 1.8 compliant Polygon for use with Simple Geometries. Can also represent multipolygons.
    • Constructor Summary

      Constructors 
      Constructor Description
      CFPolygon()
      Constructs an empty polygon with nothing in it using an Array List.
      CFPolygon​(List<Point> points)
      Constructs a new polygon whose points constitute the points passed in.
    • Constructor Detail

      • CFPolygon

        public CFPolygon()
        Constructs an empty polygon with nothing in it using an Array List.
      • CFPolygon

        public CFPolygon​(List<Point> points)
        Constructs a new polygon whose points constitute the points passed in.
        Parameters:
        points - which make up the Polygon
    • Method Detail

      • getGeometryType

        public GeometryType getGeometryType()
        Get the geometry the data is associated with.
      • getPoints

        public List<Point> getPoints()
        Get the list of points which constitute the polygon.
        Specified by:
        getPoints in interface Polygon
        Returns:
        points
      • getNext

        public Polygon getNext()
        Get the next polygon in the sequence of multi-polygons
        Specified by:
        getNext in interface Polygon
        Returns:
        next polygon in the same multipolygon if any, otherwise null
      • getPrev

        public Polygon getPrev()
        Get the previous polygon in the sequence of multi-polygons
        Specified by:
        getPrev in interface Polygon
        Returns:
        previous polygon in the same multipolygon if any, otherwise null
      • getInteriorRing

        public boolean getInteriorRing()
        Get whether or not this polygon is an interior ring
        Specified by:
        getInteriorRing in interface Polygon
        Returns:
        true if an interior ring, false if not
      • addPoint

        public void addPoint​(double x,
                             double y)
        Add a point to this polygon's points list
        Specified by:
        addPoint in interface Polygon
      • setData

        public void setData​(Array data)
        Set the data associated with this Polygon
        Specified by:
        setData in interface Polygon
        Specified by:
        setData in interface SimpleGeometry
        Parameters:
        data - - array of data to set to
      • setNext

        public void setNext​(Polygon next)
        Sets the next polygon which make up the multipolygon which this polygon is a part of. If next is a CFPolygon, automatically connects the other polygon to this polygon as well.
        Specified by:
        setNext in interface Polygon
        Parameters:
        next - Polygon to set
      • setNext

        protected void setNext​(CFPolygon next)
        Sets the next polygon which make up the multipolygon which this polygon is a part of. Automatically connects the other polygon to this polygon as well.
      • setPrev

        public void setPrev​(Polygon prev)
        Sets the previous polygon which makes up the multipolygon which this polygon is a part of. If prev is a CFPolygon, automatically connect the other polygon to this polygon as well.
        Specified by:
        setPrev in interface Polygon
        Parameters:
        prev - Polygon to set
      • setPrev

        public void setPrev​(CFPolygon prev)
        Sets the previous polygon which makes up the multipolygon which this polygon is a part of. Automatically connect the other polygon to this polygon as well.
      • setInteriorRing

        public void setInteriorRing​(boolean interior)
        Sets whether or not this polygon is an interior ring.
        Specified by:
        setInteriorRing in interface Polygon
        Parameters:
        interior - ring or not
      • setupPolygon

        public Polygon setupPolygon​(NetcdfDataset dataset,
                                    Variable polyvar,
                                    int index)
        Given a dataset, variable and index, automatically sets up a previously constructed polygon. If the specified polygon is not found in the dataset, returns null
        Specified by:
        setupPolygon in interface Polygon
        Parameters:
        dataset - which the variable is a part of
        polyvar - the variable which has a geometry attribute
        index - of the polygon within the variable
        Returns:
        the constructed Polygon with associated data
      • getBBUpper

        public double[] getBBUpper()
        Gets the upper bounding box coordinate on the polygon.
        Specified by:
        getBBUpper in interface SimpleGeometry
        Returns:
        double array = (x, y)
      • getBBLower

        public double[] getBBLower()
        Gets the lower bounding box coordinate on the polygon.
        Specified by:
        getBBLower in interface SimpleGeometry
        Returns:
        double array = (x, y)