bufferCollection static method

List<Polygon> bufferCollection({
  1. required List<Geometry> geometries,
  2. required List<double> distances,
  3. required bool unionResult,
})

Creates a buffer or buffers relative to the given collection of geometries. This is a planar buffer operation. Use GeometryEngine.bufferGeodetic to produce geodetic buffers.

This planar measurement uses 2D Cartesian mathematics to compute the buffer areas. It is based upon the SpatialReference of the input geometries. If the input geometries do not use an 'area preserving' spatial reference, the results can be inaccurate. You have two options available to calculate a more accurate results:

If unionResult is true, the output collection contains a single result. If geometries is empty, an empty array is returned.

Supports true curves as input, producing a densified curve as output where applicable.

This method allows you to create different-sized buffers for each input in a geometry collection using corresponding values in a distance collection. Typically, there's a one-to-one correspondence of input geometries to the input buffer distances. However, you may have fewer input buffer distances than input geometries. In that case, the last distance value in the buffer distances collection is applied to the remaining geometries. If needed, you could also specify a single buffer value in the input buffer distances collection to apply to all items in the input geometries collection.

Parameters:

  • geometries — A collection of geometries.
  • distances — The distance to buffer each geometry, expressed as a List of double. If the size of the distances collection is less than the number of geometries, the last distance value is used for the rest of geometries.
  • unionResult — Returns a single geometry that buffers all the geometries (true), or one buffer for each in the given collection (false).

Return Value: A collection of polygons representing buffers at the defined distance(s) relative to the input geometries.

Implementation

static List<Polygon> bufferCollection({
  required List<Geometry> geometries,
  required List<double> distances,
  required bool unionResult,
}) {
  _initializeArcGISEnvironmentIfNeeded();
  final coreGeometries = geometries.toMutableArray(
    valueType: _ElementType.geometry,
  );
  final coreDistances = distances.toMutableArray(
    valueType: _ElementType.float64,
  );
  final arrayHandle = _withThrowingErrorHandler((errorHandler) {
    return runtimecore.RT_GeometryEngine_bufferCollection(
      coreGeometries._handle,
      coreDistances._handle,
      unionResult,
      errorHandler,
    );
  });
  return arrayHandle.toList();
}