ArcObjects Library Reference  (Geometry)    

IGeometryBridge_QueryGeometries_Example

[C#]
public void QueryGeometries()
{
  int inputLength = 10;
  IGeometry[] inputGeometryArray = new IGeometry[inputLength];
  for (int i = 0; i < inputLength; i++)
  {
    IPoint point = new PointClass();
    point.PutCoords(i * 10, i * 10);
    inputGeometryArray[i] = point as IGeometry;
  }
  IGeometryBridge geometryBridge = new GeometryEnvironmentClass();
  IGeometryCollection geometryCollection = new MultipointClass();
  //add geometries
  geometryBridge.AddGeometries(geometryCollection, ref inputGeometryArray);
  //query geometries starting from position 1
  int startIndex = 5;
  IGeometry[] outputGeometryArray = new IGeometry[inputLength - startIndex];
  for (int i = 0; i < outputGeometryArray.Length; i++)
  {
    outputGeometryArray[i] = new PointClass() as IGeometry;
  }
  geometryBridge.QueryGeometries(geometryCollection, startIndex, ref outputGeometryArray);
  for (int i = 0; i < outputGeometryArray.Length; i++)
  {
    //we know that the Geometry is a Point
    IPoint currentPoint = outputGeometryArray[i] as IPoint;
    System.Windows.Forms.MessageBox.Show("X = " + currentPoint.X + ", Y = " + currentPoint.Y);
  }
}

[Visual Basic 6.0, Visual Basic .NET, C++]
No example is available for Visual Basic 6.0, Visual Basic .NET, or C++. To view a C# example, click the Language Filter button Language Filter in the upper-left corner of the page.