envelope property

Polygon get envelope

Returns the BoundingBox's Polygon of the FeatureCollection. If the FeatureCollection is empty, returns a Polygon([]).

Example:

FeatureCollection([
  LineString([Coordinate(1, 2), Coordinate(3, 4)]),
  LineString([Coordinate(5, 6), Coordinate(7, 8)])
]).envelope;

Implementation

Polygon get envelope {
  if (features.isEmpty) {
    return Polygon([]);
  }

  List<Point> points = (explode().features as List<Point>);
  return BoundingBox.fromPoints(points).toPolygon();
}