ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Core.Geometry Namespace / GeometryBagBuilderEx Class / GeometryBagBuilderEx Constructor / GeometryBagBuilderEx Constructor(IEnumerable<Geometry>,SpatialReference)
The list of geometries to create the GeometryBag.
(Optional) The SpatialReference. The default value is null. The spatial reference of each geometry is ignored.
Example

In This Topic
    GeometryBagBuilderEx Constructor(IEnumerable<Geometry>,SpatialReference)
    In This Topic
    Creates a new instance of the GeometryBagBuilderEx class.
    Syntax

    Parameters

    geometries
    The list of geometries to create the GeometryBag.
    spatialReference
    (Optional) The SpatialReference. The default value is null. The spatial reference of each geometry is ignored.
    Exceptions
    ExceptionDescription
    geometries is null.
    A geometry in geometries is null. You cannot insert a null geometry into GeometryBag.
    A geometry in geometries is GeometryBag. You cannot insert a GeometryBag into another GeometryBag.
    Index must be equal to -1 or less than or equal to the number of geometries in the builder.
    Remarks
    An Envelope that is inserted into the builder is converted to a Polygon when the GeometryBag is created. As a result, when retrieving an Envelope from a GeometryBag, it will be a Polygon.
    Example
    Construct GeometryBag - from an enumeration of geometries
    // Use a builder convenience method or use a builder constructor.
    
    MapPoint point = MapPointBuilderEx.CreateMapPoint(10, 20);
    List<Coordinate2D> coords = new List<Coordinate2D>() { new Coordinate2D(50, 60), new Coordinate2D(-120, -70), new Coordinate2D(40, 60) };
    Multipoint multipoint = MultipointBuilderEx.CreateMultipoint(coords, SpatialReferences.WebMercator);
    Polyline polyline = PolylineBuilderEx.CreatePolyline(coords);
    
    string json = "{\"rings\":[[[0,0],[0,1],[1,1],[1,0],[0,0]],[[3,0],[3,1],[4,1],[4,0],[3,0]]]}";
    Polygon polygon = PolygonBuilderEx.FromJson(json);
    
    var geometries = new List<Geometry>() { point, multipoint, polyline, polygon };
    
    // Builder convenience methods don't need to run on the MCT.
    //At 2.x - GeometryBag bag = GeometryBagBuilder.CreateGeometryBag(geometries, SpatialReferences.WGS84);
    var bag = GeometryBagBuilderEx.CreateGeometryBag(geometries, SpatialReferences.WGS84);
    
    //At 2.x - using (var builder = new GeometryBagBuilder(geometries, SpatialReferences.WGS84)) 
    var builder = new GeometryBagBuilderEx(geometries, SpatialReferences.WGS84);
    // do something with the builder
    bag = builder.ToGeometry();
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also