Select to view content in your preferred language

Geometry from featureCursor (Spatial Query)

924
3
01-26-2012 06:26 AM
DanielLaidlaw
Deactivated User
I�??m trying to run a intersect spatial query (Feaure2) based on the attribute query results of my first feature (Feature1)

I do an attribute search on my first feature , What I am returned from my attribute search is FeatureCursor, I how do I get the geomentry from a featureCursor to pass as my spatial query geometry.


The is the function I want to pass my attribute geometry results into http://edndoc.esri.com/arcobjects/9.2/java/engine_samples/geodatabase.accessing_data.performspatialq...


Appreciate the help.
VB
0 Kudos
3 Replies
sapnas
by
Frequent Contributor
 IFeature pFeature = featureCursor.NextFeature(); 

IGeometry pGeometry = pFeature.Shape;

0 Kudos
DanielLaidlaw
Deactivated User
You�??re partially right as that will just give me the last value of the shape geometry in the cursor, how do I union them when I have more than one record in my cursor result.
0 Kudos
sapnas
by
Frequent Contributor
using featureCursor.NextFeature() in a loop will retrieve all the features. Use ITopologicalOperator.ConstructUnion method to merge the geometries.


IGeometryCollection unionCol = new GeometryBag() as IGeometryCollection;
ITopologicalOperator unionPoly = new PolygonClass() as ITopologicalOperator;
object Missing = Type.Missing;

IFeature pFeature = featureCursor.NextFeature(); 

while(pFeature!=null)
{

    IGeometry pGeometry = pFeature.Shape;
    unionCol.AddGeometry(pGeometry , ref Missing, ref Missing);
    pFeature = featureCursor.NextFeature(); 

}
 unionPoly.ConstructUnion((IEnumGeometry)unionCol);

0 Kudos