private List<int> GetIdsOfContainedFeatureCentroids(IRecordSet recordset, IPolygon tilePolygon)
{
List<int> ids = new List<int>();
IFeatureCursor cursor = recordset.get_Cursor(true) as IFeatureCursor;
IFeature feature = cursor.NextFeature();
if (feature == null)
{
return ids;
}
if (feature.ShapeCopy.GeometryType != esriGeometryType.esriGeometryMultipoint && feature.ShapeCopy.GeometryType != esriGeometryType.esriGeometryPolygon)
{
throw new ArgumentException("Only multipoint and polygon geometry types are supported by this method.");
}
this.tracePolygon(tilePolygon);
IRelationalOperator2 relationalOperator = tilePolygon as IRelationalOperator2;
try
{
// Envelope must contain centriod
IPoint centroid = null;
while (feature != null)
{
centroid = (feature.ShapeCopy as IArea).Centroid;
if (relationalOperator.Contains(centroid))
{
this.tracePolygonContainsPoint(tilePolygon, centroid, feature.OID);
ids.Add(feature.OID);
}
feature = cursor.NextFeature();
}
if (ids.Count > 0)
{
System.Diagnostics.Debug.WriteLine("OIDs with centroids contained: " + ids.ToDelimitedString<int>(","));
}
return ids;
}
finally
{
this.ReleaseComObject(cursor);
cursor = null;
}
}