flatten method

FeatureCollection flatten()

Breaks the MultiPolygon into a FeatureCollection containing each Polygons. Also, copies the properties of the MultiPolygon to each Polygon.

Example:

MultiPolygon([
  [
    LinearRing([Coordinate(1, 2), Coordinate(3, 4), Coordinate(5, 6), Coordinate(1, 2)])
  ],
  [
    LinearRing([Coordinate(7, 8), Coordinate(9, 10), Coordinate(11, 12), Coordinate(7, 8)])
  ]
]).flatten(); // FeatureCollection([Polygon([LinearRing([Coordinate(1, 2), Coordinate(3, 4), Coordinate(5, 6), Coordinate(1, 2)])]),Polygon([LinearRing([Coordinate(7, 8), Coordinate(9, 10), Coordinate(11, 12), Coordinate(7, 8)])])])

Implementation

FeatureCollection flatten() {
  return FeatureCollection(coordinates
      .map((poly) => Polygon(poly, properties: properties))
      .toList());
}