polygon method

  1. @override
void polygon(
  1. Iterable<PositionSeries> rings, {
  2. String? name,
  3. Box? bounds,
})
override

Writes a polygon geometry with one exterior and 0 to N interior rings.

The rings iterable must be non-empty. The first element is the exterior ring, and any other rings are interior rings (or holes). All rings must be closed linear rings. As specified by GeoJSON, they should "follow the right-hand rule with respect to the area it bounds, i.e., exterior rings are counterclockwise, and holes are clockwise".

Use an optional name to specify a name for a geometry (when applicable).

An optional bounds can used set a minimum bounding box for a geometry written. A writer implementation may use it or ignore it.

An example to write a polygon geometry with one linear ring containing 4 points:

 content.polygon(
     // an array of linear rings
     [
       // a linear ring as a flat structure with four (x, y) points
       [
         10.1, 10.1,
         5.0, 9.0,
         12.0, 4.0,
         10.1, 10.1,
       ].positions(Coords.xy),
     ],
 );

Implementation

@override
void polygon(
  Iterable<PositionSeries> rings, {
  String? name,
  Box? bounds,
}) {
  if (rings.isEmpty) {
    // note: ignore empty geometries for this implementation
  }
  _add(
    Polygon(
      rings is List<PositionSeries> ? rings : rings.toList(growable: false),
      bounds: bounds,
    ),
    name: name,
  );
}