Polygon constructor
const
Polygon(
- List<
PositionSeries> rings, { - Box? bounds,
A polygon geometry with one exterior and 0 to N interior rings
.
An optional bounds
can used set a minimum bounding box for a geometry.
Each ring in the polygon is represented by a PositionSeries
instance.
An empty polygon has no rings.
For "normal" polygons the rings
list 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".
Examples:
// a polygon (with an exterior ring only) from 2D positions
Polygon(
[
// an exterior ring with values of five (x, y) positions
[
10.0, 20.0,
12.5, 22.5,
15.0, 25.0,
11.5, 27.5,
10.0, 20.0,
].positions(Coords.xy),
],
);
// a polygon (with an exterior and one interior ring) from 2D positions
Polygon(
[
// an exterior ring with values of five (x, y) positions
[
10.0, 20.0,
12.5, 22.5,
15.0, 25.0,
11.5, 27.5,
10.0, 20.0,
].positions(Coords.xy),
// an interior ring with values of four (x, y) positions
[
12.5, 23.0,
11.5, 24.0,
12.5, 24.0,
12.5, 23.0,
].positions(Coords.xy),
],
);
// a polygon (with an exterior ring only) from 3D positions
Polygon(
[
// an exterior ring with values of five (x, y, z) positions
[
10.0, 20.0, 30.0,
12.5, 22.5, 32.5,
15.0, 25.0, 35.0,
11.5, 27.5, 37.5,
10.0, 20.0, 30.0,
].positions(Coords.xyz),
],
);
// a polygon (with an exterior ring only) from measured 2D positions
Polygon(
[
// an exterior ring with values of five (x, y, m) positions
[
10.0, 20.0, 40.0,
12.5, 22.5, 42.5,
15.0, 25.0, 45.0,
11.5, 27.5, 47.5,
10.0, 20.0, 40.0,
].positions(Coords.xym),
],
);
// a polygon (with an exterior ring only) from measured 3D positions
Polygon(
[
// an exterior ring with values of five (x, y, z, m) positions
[
10.0, 20.0, 30.0, 40.0,
12.5, 22.5, 32.5, 42.5,
15.0, 25.0, 35.0, 45.0,
11.5, 27.5, 37.5, 47.5,
10.0, 20.0, 30.0, 40.0,
].positions(Coords.xyzm),
],
);
Implementation
const Polygon(List<PositionSeries> rings, {super.bounds}) : _rings = rings;