I have the situation where I am doing a large number of intersections and I need to do them fast. The situation is I have a iMap with 1 or more layers and a series of envelopes, lots of envelopes. I have tried the following:
long nFeatureCount;
iExtent->PutCoords(ulX, ulY, lrX, lrY);
// I created an array of all the layers feature classes at the outset
for(int i=0; i<nFeatureClassCount; i++)
{
iSpatialFilter->putref_Geometry(iExtent);
iFeatureClasses[i]->FeatureCount(iSpatialFilter, &nFeatureCount);
if(nFeatureCount > 0)
{
return true; //we have an intersection
}
}
I also tried doing a select at the map level like so:
long nFeatureCount;
iExtent->PutCoords(ulX, ulY, lrX, lrY);
ipMap->ClearSelection();
ipMap->SelectByShape(iExtent, NULL, VARIANT_TRUE);
ipMap->get_SelectionCount(&nFeatureCount);
if(nFeatureCount == 0)
{
return false;
}
else
{
return true;
}
Both of these work and the iMap
seems to be a bit faster when I have 5 or so layers. I was just thinking someone had encountered this and might have a faster way. I saw someone had the idea of throwing all the geometries in a IGeometryBag
but wouldn't that negate the spatial indexing?