featureCollection function

Future<Map<String, dynamic>> featureCollection(
  1. Stream<List<int>> shp, {
  2. Stream<List<int>>? dbf,
  3. Encoding encoding = utf8,
})

Returns a future that yields a GeoJSON feature collection for specified shapefile shp and dBASE table file dbf.

The meaning of the arguments is the same as features. This is a convenience API for reading an entire shapefile in one go; use this method if you don’t mind putting the whole shapefile in memory. The yielded collection has a bbox property representing the bounding box of all records in this shapefile. The bounding box is specified as [xmin, ymin, xmax, ymax], where x and y represent longitude and latitude in spherical coordinates.

The coordinate reference system of the feature collection is not specified. This library does not support parsing coordinate reference system specifications (.prj); see Proj4js for parsing well-known text (WKT) specifications.

Implementation

Future<Map<String, dynamic>> featureCollection(Stream<List<int>> shp,
    {Stream<List<int>>? dbf, Encoding encoding = utf8}) async {
  var collection = <String, dynamic>{
    "type": "FeatureCollection",
  };
  collection["features"] = await features(shp,
      dbf: dbf, forBbox: (bbox) => collection["bbox"] = bbox).toList();
  return collection;
}