Interface IGeometryCollection

Namespace
ESRI.ArcGIS.Geometry
Assembly
ESRI.Server.Geometry.dll

Provides access to members that can be used for accessing, adding and removing individual geometries of a multi-part geometry (Multipoint, Polyline, Polygon, MultiPatch, and GeometryBag).

[Guid("C801565E-99CA-11D0-82F7-0000F8034032")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IGeometryCollection

Remarks

Every Geometry created within ArcGIS should be assigned a spatial reference. Always attach well-defined spatial references to new geometries. This improves processing efficiency, in particular, when using ITopologicalOperator on geometries that contain curved segments (circular arcs, bezier curves, elliptical arcs). New geometries include any geometry that is created in memory. It does not matter whether it will be stored in a feature class or not. Well-defined as applied to a spatial reference means that it not only has its coordinate system (projection) defined, but also its coordinate grid. The coordinate grid consists of the xy domain, xy resolution, and xy cluster tolerance properties of a spatial reference. If the Geometry includes z or m values, the z or m domains, z or m resolutions, and z or m cluster tolerance properties must also be defined. The cluster tolerance and resolutions can be quickly and easily set using SetDefault methods on ISpatialReferenceResolution and ISpatialReferenceTolerance interfaces.

[C#]

    //The example shows a GeometryCollection for MultiPoint.
    public void ShowGeometries()
    {
        IGeometryCollection geometryCollection = new MultipointClass();
        //add 10 points in a loop
        object missing = Type.Missing;
        for (int i = 0; i < 10; i++)
        {
            IPoint point = new PointClass();
            point.PutCoords(i * 10, i * 2);








            geometryCollection.AddGeometry(point as IGeometry, ref missing, ref missing);
        }

        int geometryCount = geometryCollection.GeometryCount;
        System.Windows.Forms.MessageBox.Show("GeometryCount = " + geometryCount);
        for (int i = 0; i < geometryCount; i++)
        {
            IGeometry currentGeometry = geometryCollection.get_Geometry(i);
            IPoint point = currentGeometry as IPoint;
            //we know that there are IPoints only in the Geometrycollection.
            //But this is the safe and recommended way
            if (point != null)
            {
                System.Windows.Forms.MessageBox.Show("X = " + point.X + ", Y = " + point.Y);
            }
        }
    }












Properties

Geometry[int]

A reference to the ith geometry.

IGeometry Geometry[int Index] { get; }

Parameters

Index int

Property Value

IGeometry

Remarks

Note: The GeometryType returned by the Geometry method depends on which object type points the IGeometryCollection pointer.

IGeometryCollection Object GeometryType Returned Object GeometryType
Polygon
Rings
Polyline
Paths
Multipoint
Points
Multipatch
TriangleFans or TriangleStrips or Rings
TriangleFan
Points
TriangleStrip
Points
Geometry Bag
Any type of IGeometry

GeometryCount

The number of geometries in this collection.

int GeometryCount { get; }

Property Value

int

Methods

AddGeometries(int, ref IGeometry)

Adds references to the specified geometries. This method is intended for internal use only.

void AddGeometries(int Count, ref IGeometry newGeometries)

Parameters

Count int
newGeometries IGeometry

Remarks


The geometries are added last in the list. Use an array of geometries (IGeometry) and the exact number (count ) of elements in the array. Exceeding the boundary of the array will cause an application error. If you don't want to place the geometries last in the collection then use the InsertGeometries method.



[C#]

When using C# you must use the IGeometryBridge interface to call this method.

[Visual Basic .NET]

When using VBNET you must use the IGeometryBridge interface to call this method.

AddGeometry(IGeometry, ref object, ref object)

Adds a reference to the input geometry either at the end, or before, or after the specified index.

void AddGeometry(IGeometry inGeometry, ref object before, ref object after)

Parameters

inGeometry IGeometry
before object
after object

Remarks

When applying the AddGeometry method give either the before or after index and not both. Adding a Geometry to the collection as the first one is done by setting the before index as 0.

The spatial reference of the GeometryCollection is transferred (objects projected if necessary) to any objects added to it. However the spatial reference of the added geometry is not transferred to the GeometryCollection. Always make sure to set the spatial reference on the object GeometryCollection prior to add other geometries to it to avoid creating invalid geometry. For example, adding geometry objects to a GeometryBag that doesn't have a well-defined spatial reference will set an undefined spatial reference to all the objects added to the bag. Using this GeometryBag may cause unexpected behavior with the ITopologicalOperator::ConstructUnion method.

 
[C#]

IPoint pnt = new PointClass();

pnt.PutCoords(x, y);

IGeometryCollection geomColl = new MultipointClass() as IGeometryCollection;

object obj = Type.Missing;

geomColl.AddGeometry(pnt, ref obj, ref obj);

AddGeometryCollection(IGeometryCollection)

Adds references to geometries in the input collection.

void AddGeometryCollection(IGeometryCollection newGeometries)

Parameters

newGeometries IGeometryCollection

GeometriesChanged()

Tells this geometry collection that some of its geometries have been altered. Use this method on polylines, polygons and multipatches after directly editing one of its parts.

void GeometriesChanged()

InsertGeometries(int, int, ref IGeometry)

Inserts at the specified index references to some number of geometries in the input array. This method is intended for internal use only.

void InsertGeometries(int Index, int Count, ref IGeometry newGeometries)

Parameters

Index int
Count int
newGeometries IGeometry

Remarks

The geometries are inserted before the ith (index) element in the list. Use an array of geometries and give the exact number (count ) of elements in the array. A too large value for the count parameter causes exceeding the boundary of the array and will cause an application error. To place the geometries last in the collection then use the addGeometries method.

 

[C#]

When using C# you must use the IGeometryBridge interface to call this method.

[Visual Basic .NET]

When using VBNET you must use the IGeometryBridge interface to call this method.

InsertGeometryCollection(int, IGeometryCollection)

Inserts at the specified index references to all if the geometries in the input collection.

void InsertGeometryCollection(int Index, IGeometryCollection newGeometries)

Parameters

Index int
newGeometries IGeometryCollection

Remarks

InsertGeometryCollection merges one GeometryCollection within another at a specified index.

[C#]
//C# Example: Insert GeometryCollection geomColl2 within geomColl at index 3.
geomColl.InsertGeometryCollection(3, geomColl2);

QueryGeometries(int, int, out IGeometry)

Populates the array with references to a sub-sequence of geometries. This method is intended for internal use only.

void QueryGeometries(int Index, int Count, out IGeometry geometries)

Parameters

Index int
Count int
geometries IGeometry

Remarks

Note: The GeometryType returned by the QueryGeometries method depends on which object type points the IGeometryCollection pointer.

IGeometryCollection Object GeometryType Returned Object GeometryType
Polygon
Rings
Polyline
Paths
Multipoint
Points
Multipatch
TriangleFans or TriangleStrips or Rings
TriangleFan
Points
TriangleStrip
Points
Geometry Bag
Any type of IGeometry

[C#]

When using C# you must use the IGeometryBridge interface to call this method.

[Visual Basic .NET]

When using VBNET you must use the IGeometryBridge interface to call this method.

RemoveGeometries(int, int)

Removes references to some geometries from this collection.

void RemoveGeometries(int Index, int Count)

Parameters

Index int
Count int

Remarks

RemoveGeometries deletes count number of geometries from the index location.

SetGeometries(int, ref IGeometry)

Replaces all geometries in the collection with the specified number of references to those in the input array. This method is intended for internal use only.

void SetGeometries(int Count, ref IGeometry newGeometries)

Parameters

Count int
newGeometries IGeometry

Remarks

SetGeometries is used to reset the references of the geometries within the GeometryCollection . The result is that all references are changed to point only at the geometries contained within the specified array. Note that the GeometryCount changes accordingly also.

 

[C#]

When using C# you must use the IGeometryBridge interface to call this method.

[Visual Basic .NET]

When using VBNET you must use the IGeometryBridge interface to call this method.

SetGeometryCollection(IGeometryCollection)

Replaces all geometries in the collection with references to geometries from the input collection.

void SetGeometryCollection(IGeometryCollection newParts)

Parameters

newParts IGeometryCollection

Remarks

SetGeometryCollection copies the geometry references from one GeometryCollection to another.

VB Example: Set GeometryCollection m_pGeoColl_A as m_pGeoColl_B


  m_pGeoColl_A.SetGeometryCollection m_pGeoColl_B