Class LatLonPolygon2D

    • Field Detail

      • crossesDateline

        protected boolean crossesDateline
    • Constructor Detail

      • LatLonPolygon2D

        public LatLonPolygon2D()
    • Method Detail

      • lineTo

        public void lineTo​(LatLonPoint2D point)
        Adds the LatLonPoint2D to the end of the polygon
        Parameters:
        point -
      • lineTo

        public void lineTo​(Point2D point)
      • getArea

        public abstract double getArea()
      • lineTo

        public abstract void lineTo​(double lat,
                                    double lon)
        Adds the point specified by the provided lat and lon to the end of the polygon
        Parameters:
        lat - the latitude of the point to add
        lon - the longitude of the point to add
      • getCentroid

        public abstract LatLonPoint2D getCentroid()
        Calculates the geometric center of this LatLonPolygon2D
        Returns:
        the center point
      • contains

        public boolean contains​(LatLonPoint2D point)
        Determines if the LatLonPoint2D is within this polygon
        Parameters:
        point - the point to test
        Returns:
        true if the point is contained within this polygon; false otherwise
      • contains

        public abstract boolean contains​(double lat,
                                         double lon)
        Determines if the point represented by lat, lon is within this polygon
        Parameters:
        lat - the latitude (y) of the point to test
        lon - the longitude (x) of the point to test
        Returns:
        true if the point is contained within this polygon; false otherwise
      • contains

        public boolean contains​(LatLonRectangle2D rect)
        Determines if the specified LatLonRectangle2D is COMPLETELY contained within this LatLonPolygon2D
        Parameters:
        rect - the LatLonRectangle2D to check
        Returns:
        true if the LatLonRectangle2D is COMPLETELY contained in this polygon; false otherwise
      • contains

        public boolean contains​(LatLonPolygon2D poly)
        Determines if the specified LatLonPolygon2D is COMPLETELY contained within this LatLonPolygon2D
        Parameters:
        poly - the LatLonPolygon2D to check
        Returns:
        true if the LatLonPolygon2D is COMPLETELY contained in this polygon; false otherwise
      • intersects

        public abstract boolean intersects​(LatLonPolygon2D poly)
      • intersects

        public boolean intersects​(LatLonPoint2D point)
      • intersects

        public abstract boolean intersects​(LatLonPoint2D point,
                                           boolean crossesDateline)
      • distanceSq

        public abstract double distanceSq​(LatLonPoint2D p)
      • getVertices

        public abstract List<LatLonPoint2D> getVertices()
        Gets a list of LatLonPoint2D vertices in this polygon
        Returns:
        the vertices
      • getVertexCount

        public abstract int getVertexCount()
      • getLonCoords

        public abstract double[] getLonCoords()
      • getLatCoords

        public abstract double[] getLatCoords()
      • getBouningLatLonRectangle2D

        public abstract LatLonRectangle2D getBouningLatLonRectangle2D()
      • getBoundingLatLonValues

        public abstract double[] getBoundingLatLonValues()
        Calculates the bounding box of this LatLonPolygon2D and returns the coordinates as a double array with a length of 4. The coordinates are arranged in the order of western lon, southern lat, eastern lon, and northern lat.

        In terms of points where LL = lower left and UR = upper right, this is equivalent to the arrangement of double[] {lly, llx, ury, urx}.
        Returns:
        a double array with a length of 4 containing the lat/lon points of the bounding box of this LatLonPolygon2D. If this object contains no vertices null is returned.
      • crossesDateline

        public boolean crossesDateline()
      • copy

        public LatLonPolygon2D copy()
        Copies this LatLonPolygon2D to a new LatLonPolygon2D
        Returns:
        a copy of this polygon
      • toString

        public String toString()
        Return a string representation of the polygon.
        Overrides:
        toString in class Object
      • calculateLLArrayArea

        public static double calculateLLArrayArea​(double[] latLonValues)
        Calculates the area of a polygon bounding box for an array of doubles in the orientation of: LLy, LLx, URy, URx
        Parameters:
        latLonValues - an array of doubles in the orientation of: LLy, LLx, URy, URx
        Returns:
        the area of the given bounding box
      • linesIntersect

        public static boolean linesIntersect​(double p0x,
                                             double p0y,
                                             double p1x,
                                             double p1y,
                                             double p2x,
                                             double p2y,
                                             double p3x,
                                             double p3y)
        Checks if the line segment drawn from p0 to p1 intersects the line drawn from p2 to p3. This is an optimized variation of Line2D.linesIntersect(double, double, double, double, double, double, double, double)
        Parameters:
        p0x - the first points x value
        p0y - the first points y value
        p1x - the second points x value
        p1y - the second point's y value
        p2x - the third point's x value
        p2y - the third point's y value
        p3x - the fourth point's x value
        p3y - the fourth point's y value
        Returns:
        true if the lines created from the given points intersect, otherwise false
      • lineIntersectsPoint

        public static boolean lineIntersectsPoint​(double e0x,
                                                  double e0y,
                                                  double e1x,
                                                  double e1y,
                                                  double p1x,
                                                  double p1y)
        Checks if the point given by p1x, p1y is intersected by the line segment given by e0, e1
        Parameters:
        e0x - the line segment's first endpoint's x value
        e0y - the line segment's first endpoint's y value
        e1x - the line segment's second endpoint's x value
        e1y - the line segment's second endpoint's y value
        p1x - the point's x value
        p1y - the point's y value
        Returns:
        true if the point is intersected by the given line segment, otherwise false