I am trying to emulate the Near (analysis) ArcGIS tool in ArcObjects. http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00080000001q000000
I want to use Mixed Feature Types. I have a point, polygon and line feature class and I want to use Near to compare all three of them with each other. This can be done one featureclass at a time like so (pseudocode logic):
-
Create IFeatureIndex
-
Store my feature class in IFeatureIndex.FeatureClass
-
Use IIndexQuery.NearestFeature for every IGeometry in a feature class to get distance to the nearest feature
The problem I am running into is that I can only store one feature class in IFeatureIndex. I need to store three different feature classes (points, lines and polygons) to be able to properly execute my comparison. How can I do this? ESRI's feature that I linked above has managed to do this but there is unfortunately no way to peek at the code behind the geoprocessing tool that I know of.
Edit: I have solved this. See the answer below.
Best Answer
You might consider using a spatial cache via ISpatialCacheManager3. The documentation doesn't say if all the featureclasses in the cache need to be in the same workspace, see the Using spatial caching to optimize spatial queries section. I'd be very curious if that is the case.
Here's a snippet from that page: