Quantcast
Channel: Forums - ArcObjects SDKs
Viewing all articles
Browse latest Browse all 1374

Spatial Index is lost but never found unless I restart Arcmap

$
0
0
All,

Odd problem here and I have not found a solution to it. I'm using ArcGIS 10.1, VB .net and the source data is a shapefile.At some point in my tool I add a field using the IFeatureClass.AddField method and populate it with values but when I add this field it drops the spatial index on the dataset. In ArcMap if I open the Attribute table I see the * in the Shape field which suggests its still there but I know its not. Later on in my tool I test if a dataset has a spatial index, if not I add one. I test if the dataset has a spatial index with the following code:

Code:

Dim pFeatureClass As IFeatureClass
 pFeatureClass = m_pFeatureLayer_River.FeatureClass
 Dim pIndexes As IIndexes
Dim pEnumIndex As IEnumIndex
pIndexes = pFeatureClass.Indexes
pEnumIndex = pIndexes.FindIndexesByFieldName(pFeatureClass.ShapeFieldName)
Dim pIndex As IIndex
pIndex = pEnumIndex.Next
If pIndex Is Nothing Then
  ' Add Spatial Index
End If

This always fails suggesting the spatial index exists but I know it does not as another tool runs very slowly without it.Only when I restart ArcMap, load the shapefile, open attribute table do I see that the * in the shape field has disappeared.So my question is knowing that I use the IFeatureClass.AddField method to add a field how do I "refresh" ArcMap to pick up on the fact that the spatial index has been lost and allow my check for spatial index code to work?

Duncan

Viewing all articles
Browse latest Browse all 1374

Trending Articles