Class Polygon

java.lang.Object
com.mongodb.client.model.geojson.Geometry
com.mongodb.client.model.geojson.Polygon

public final class Polygon extends Geometry
A representation of a GeoJSON Polygon.
Since:
3.1
  • Constructor Details

    • Polygon

      @SafeVarargs public Polygon(List<Position> exterior, List<Position>... holes)
      Construct an instance with the given coordinates.
      Parameters:
      exterior - the exterior ring of the polygon
      holes - optional interior rings of the polygon
    • Polygon

      public Polygon(List<Position> exterior, List<List<Position>> holes)
      Construct an instance with the given coordinates.
      Parameters:
      exterior - the exterior ring of the polygon
      holes - optional interior rings of the polygon
      Since:
      4.3
    • Polygon

      public Polygon(PolygonCoordinates coordinates)
      Construct an instance with the given coordinates.
      Parameters:
      coordinates - the coordinates
    • Polygon

      public Polygon(@Nullable CoordinateReferenceSystem coordinateReferenceSystem, PolygonCoordinates coordinates)
      Construct an instance with the given coordinates and coordinate reference system.
      Parameters:
      coordinateReferenceSystem - the coordinate reference system
      coordinates - the coordinates
  • Method Details

    • getType

      public GeoJsonObjectType getType()
      Description copied from class: Geometry
      Gets the GeoJSON object type.
      Specified by:
      getType in class Geometry
      Returns:
      the type
    • getCoordinates

      public PolygonCoordinates getCoordinates()
      Gets the GeoJSON coordinates of the polygon
      Returns:
      the coordinates, which must have at least one element
    • getExterior

      public List<Position> getExterior()
      Gets the exterior coordinates.
      Returns:
      the exterior coordinates
    • getHoles

      public List<List<Position>> getHoles()
      Get the holes in this polygon.
      Returns:
      the possibly-empty list of holes
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Geometry
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Geometry
    • toString

      public String toString()
      Overrides:
      toString in class Object