featuresFromGeoJsonFile function

Future<GeoJsonFeatureCollection> featuresFromGeoJsonFile(
  1. File file, {
  2. String? nameProperty,
  3. bool verbose = false,
})

Get a feature collection from a geojson file

Implementation

Future<GeoJsonFeatureCollection> featuresFromGeoJsonFile(File file,
    {String? nameProperty, bool verbose = false}) async {
  final featureCollection = GeoJsonFeatureCollection();
  final geojson = GeoJson();
  geojson.endSignal.listen((_) => geojson.dispose());
  try {
    await geojson.parseFile(file.path,
        nameProperty: nameProperty, verbose: verbose);
  } catch (e) {
    rethrow;
  }
  geojson.features.forEach((f) => featureCollection.collection.add(f));
  return featureCollection;
}