All Implemented Interfaces:
Serializable

public class PolygonFeature extends Feature
A convenience class for displaying a polygon on the map.

Technically this is a Feature that uses a Polygon geometry for representation.

See Also:
  • Constructor Details

    • PolygonFeature

      public PolygonFeature()
      Creates a new polygon feature with the default style.
    • PolygonFeature

      public PolygonFeature(List<Coordinate> coordinates)
      Creates a new polygon feature with the default style using the provided coordinates. The provided coordinate list defines a linear ring, where the first coordinate and the last should be equivalent to ensure a closed ring. This ring specifies the outer boundary or surface of the polygon without any holes.

      Coordinates must be specified in the map's user projection, which by default is EPSG:4326, also referred to as GPS coordinates.

      Parameters:
      coordinates - the list of coordinates that define the vertices of the polygon
  • Method Details

    • getCoordinates

      public Coordinate[][] getCoordinates()
      The coordinates where the polygon is located, as a two-dimensional array. The first array represents the outer boundary of the polygon as a linear ring of coordinates. Each subsequent array represents a linear ring defining a hole in the polygon's surface. A linear ring is defined as an array of coordinates where the first and the last coordinates are identical.
      Returns:
      the current coordinates
    • setCoordinates

      public void setCoordinates(List<Coordinate> coordinates)
      Sets the coordinates that define the polygon. The provided coordinate list defines a linear ring, where the first coordinate and the last should be equivalent to ensure a closed ring. This ring specifies the outer boundary or surface of the polygon without any holes.

      Coordinates must be specified in the map's user projection, which by default is EPSG:4326, also referred to as GPS coordinates.

      Parameters:
      coordinates - the new coordinates
    • setCoordinates

      public void setCoordinates(Coordinate[][] coordinates)
      Sets the coordinates that define the polygon as a two-dimensional array. The first array represents the outer boundary of the polygon as a linear ring of coordinates. Each subsequent array represents a linear ring defining a hole in the polygon's surface. A linear ring is defined as an array of coordinates where the first and the last coordinates are identical.

      Coordinates must be specified in the map's user projection, which by default is EPSG:4326, also referred to as GPS coordinates.

      Parameters:
      coordinates - the new coordinates
    • getGeometry

      public Polygon getGeometry()
      The Polygon geometry representing this feature.
      Overrides:
      getGeometry in class Feature
      Returns:
      the current polygon geometry
    • setGeometry

      public void setGeometry(SimpleGeometry geometry)
      Sets the geometry representing this feature. This must be a Polygon geometry.
      Overrides:
      setGeometry in class Feature
      Parameters:
      geometry - the new geometry, not null
      Throws:
      IllegalArgumentException - if the geometry is not an instance of Polygon