众所周知,建立索引可以提高查询的效率,当对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();
博客指出当对FeatureClass某列频繁查找且数据量大时,建立索引可提高查询效率,并介绍用ArcGIS Engine建立属性索引。还提到使用几何包对象过滤时,为ISpatialFilter对象设置Geometry属性前,对几何包对象创建空间索引能提升效率,给出了创建空间索引的示例代码。
——提高查询效率&spm=1001.2101.3001.5002&articleId=95754241&d=1&t=3&u=6e301419acc44dceb93c0cf91739f31c)
1万+

被折叠的 条评论
为什么被折叠?



