explode method

FeatureCollection explode()

Creates a FeatureCollection of Points from the geometries of the Features contained within.

Example:

FeatureCollection([
  LineString([Coordinate(1, 2), Coordinate(3, 4)]),
  LineString([Coordinate(3, 4), Coordinate(5, 6)])
]).explode(); // FeatureCollection([Point(Coordinate(1, 2)), Point(Coordinate(3, 4)), Point(Coordinate(3, 4)), Point(Coordinate(5, 6))])

Implementation

FeatureCollection explode() {
  final explodedFeatures = <Point>[];
  for (final feature in features) {
    explodedFeatures.addAll(feature.explode());
  }
  return FeatureCollection(explodedFeatures);
}