Polygon

@Serializable(with = PolygonSerializer::class)
data class Polygon @JvmOverloads constructor(val coordinates: List<List<Position>>, val bbox: BoundingBox? = null) : SingleGeometry, PolygonGeometry(source)

A Polygon geometry represents a surface in coordinate space bounded by linear rings.

To specify a constraint specific to Polygon objects, it is useful to introduce the concept of a linear ring:

  • A linear ring is a closed LineString with four or more Position objects.

  • The first and last Position objects are equivalent, and they MUST contain identical values; their representation SHOULD also be identical.

  • A linear ring is the boundary of a surface or the boundary of a hole in a surface.

  • A linear ring MUST follow the right-hand rule with respect to the area it bounds, i.e., exterior rings are counterclockwise, and holes are clockwise.

See RFC 7946 Section 3.1.6 for the full specification.

See also

Throws

if the coordinates are empty or any of the Position lists representing a LineString is either not closed or contains fewer than 4 Position objects.

Constructors

Link copied to clipboard
constructor(coordinates: List<List<Position>>, bbox: BoundingBox? = null)
constructor(vararg coordinates: List<Position>, bbox: BoundingBox? = null)

Create a Polygon by a number of linear rings.

constructor(vararg lineStrings: LineString, bbox: BoundingBox? = null)

Create a Polygon by a number of closed LineString objects.

constructor(coordinates: Array<Array<DoubleArray>>, bbox: BoundingBox? = null)

Create a Polygon by arrays (= polygon rings) of arrays (= Position objects) where each Position is represented by a DoubleArray.

Types

Link copied to clipboard
object Companion

Factory methods for creating and serializing Polygon objects.

Properties

Link copied to clipboard
open override val bbox: BoundingBox?

The BoundingBox of this Polygon.

Link copied to clipboard

The coordinates of this Polygon. A list (= polygon rings) of lists of Position objects that represent this Polygon. The first ring represents the exterior ring while any others are interior rings (= holes).