ArcGIS Engine 创建索引(属性索引)——提高查询效率

Posted 杨千羽

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ArcGIS Engine 创建索引(属性索引)——提高查询效率相关的知识,希望对你有一定的参考价值。

众所周知,建立索引可以提高查询的效率,当对FeatureClass中的某一列频繁的查找,且数据量比较大时,建立索引是非常有必要的。

这里介绍一下,用 ArcGIS Engine 来建立一个属性索引。

    IIndex pIndex = new IndexClass();  
    IIndexEdit pIndexEdit = pIndex as IIndexEdit;  
    IFields pFields = new FieldsClass();  
    IFieldsEdit pFieldsEdit = pFields as IFieldsEdit;  
    int feildindex = pFeatureClass.Fields.FindField("Name");  
    IField pField = pFeatureClass.Fields.Field[feildindex];  
    pFieldsEdit.FieldCount_2 = 1;  
    pFieldsEdit.set_Field(0, pField);  
    pIndexEdit.Fields_2 = pFields;  
    pIndexEdit.Name_2 = zidField;  
    pIndexEdit.IsAscending_2 = true;  
    pFeatureClass.AddIndex(pIndex);  

 

 

如果使用几何包对象作为过滤的几何图形,在为ISpatialFilter对象设置Geometry属性之前,先对几何包对象创建空间索引,这样能大大提高查询的效率,下面是创建空间索引的示例代码:

// 将几何包对象转换到ISpatialIndex对象上去
ISpatialIndex spatialIndex = (ISpatialIndex)geometryBag;
spatialIndex.AllowIndexing = true;
spatialIndex.Invalidate();
 

以上是关于ArcGIS Engine 创建索引(属性索引)——提高查询效率的主要内容,如果未能解决你的问题,请参考以下文章