Class GeoPolygon

  • All Implemented Interfaces:
    java.io.Serializable

    public final class GeoPolygon
    extends GeoObject
    A polygon is one or more linear rings and a linear ring is a LineString meeting the following constraints:
    • Has four or more closed positions.
    • First and last positions are equivalent, and must contain identical values; their representation should also be identical.
    • Is a boundary of a surface or the boundary of a hole in a surface.
    • Must follow the right-hand rule with respect to the area it bounds, i.e., exterior rings are counterclockwise, and holes are clockwise.
    (Note: GeoJSON Format Specification (June, 2008) did not discuss linear ring winding order. For backwards compatibility, parsers should not reject Polygons that do not follow the right-hand rule.)

    Although a linear ring is not explicitly represented as a GeoJSON geometry type, it leads to a canonical formulation of the Polygon geometry type definition as follows:

    • For type "Polygon", the "coordinates" member must be an array of linear rings.
    • For Polygons with more than one of these rings, the first must be the exterior ring, and any others must be interior rings. The exterior ring bounds the surface, and the interior rings (if present) bound holes within the surface.
    Note: GeoPolygon does not enforce the linear rings requirement. This means that an invalid set of LineStrings which do not form linear rings may be entered. If you wish to transmit a random list of line strings please use GeoLineString instead.
    Author:
    Charles W. Rapp
    See Also:
    GeoMultiLineString, Serialized Form
    • Field Detail

      • linearRings

        public final LineString[] linearRings
        Array of one or more linear rings defining polygon.
    • Method Detail

      • toString

        public java.lang.String toString()
        Returns text containing linear rings defining the polygon.
        Overrides:
        toString in class GeoObject
        Returns:
        polygon as human-readable text.
      • equals

        public boolean equals​(java.lang.Object o)
        Returns true if o is a non-nuull GeoPolygon with a lineear ring array equaling this GeoPolygo linear ring array. Otherwise returns false.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - comparison object.
        Returns:
        true if o equals this object.
      • hashCode

        public int hashCode()
        Returns hash code based on contained linear rings.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        linear rings hash code.
      • builder

        public static GeoPolygon.Builder builder()
        Returns a new GeoJSON polygon builder instance.
        Returns:
        new polygon builder instance.