Arcgis根据一个属性值查询feature,下面的语句可以:
IFeatureClass featureCls=....
IFeatureCursor ifc1 = featureCls.search(null, false);
但下面用法就不行,报异常:
String queryString = "\"EstateId\"=50";
IQueryFilter queryFilter = new QueryFilter();
queryFilter.setWhereClause(queryString);
IFeatureCursor ifc = featureCls.search(queryFilter, false);
改成SpatialFilter,用下面的用法,好了:
String queryString = "\"EstateId\"=50";
SpatialFilter queryFilter = (SpatialFilter) serverContext
.createObject(SpatialFilter.getClsid());
.createObject(SpatialFilter.getClsid());
queryFilter.setWhereClause(queryString);
IFeatureCursor ifc = featureCls.search(queryFilter, false);
看来对于IFeatureClass的search,不管是不是用空间查询,都要使用SpatialFilter,或者使用serverContext.createObject。
转载于:https://blog.51cto.com/zbtech/192164