multiPolygon method
- Iterable<
Iterable< polygons, {PositionSeries> > - String? name,
- Box? bounds,
Writes a multi polygon with an array of polygons
(each with an array of
rings).
Each polygon is represented by Iterable<PositionSeries>
instances
containing one exterior and 0 to N interior rings. 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".
Each ring in the polygon is represented by PositionSeries
objects.
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 multi polygon geometry with two polygons:
content.multiPolygon(
// an array of polygons
[
// an array of linear rings of the first polygon
[
// 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),
],
// an array of linear rings of the second polygon
[
// a linear ring as a flat structure with four (x, y) points
[
110.1, 110.1,
15.0, 19.0,
112.0, 14.0,
110.1, 110.1,
].positions(Coords.xy),
],
],
);
Implementation
@override
void multiPolygon(
Iterable<Iterable<PositionSeries>> polygons, {
String? name,
Box? bounds,
}) {
_add(
MultiPolygon(
polygons is List<List<PositionSeries>>
? polygons
: polygons
.map(
(polygon) => polygon is List<PositionSeries>
? polygon
: polygon.toList(growable: false),
)
.toList(growable: false),
bounds: bounds,
),
name: name,
);
}