『公告』 预祝您龙年大吉,万事如意, 过节期间, 大家如需数据服务,请拨打400 或直接添加客服微信,再祝大家龙年,心想事成。
关注我们 新浪 腾讯

ArcGIS Engine 10 开发手册(4-20)空间查询

ArcGIS Engine 10 开发手册(4-20)空间查询
空间查询可以说是两步过滤,属性过滤和空间过滤,既然有空间过滤, 空间查询体 现 在 ISpatialFilter。

     空间查询可以说是两步过滤,属性过滤和空间过滤,既然有空间过滤, 空间查询体 ISpatialFilter.Geometry ISpatialFilter.SpatialRel 上,那么这个接口的 Geometry spatialrel 性是必须的。众所周知 ArcMap 的空间查询是非常丰富的,而 ArcGIS Engine 可以毫无保留的实现 ArcMap 所能提供的全部空间查询,对于 ArcGIS Engine 来说这些空间查询只是 ISpatialFilter 的参数,而这些参 数都是常量,如下表所示:

     查询矩形范围内的点要素(示例)

public ESRI.ArcGIS.Geodatabase.IFeatureCursor GetAllFeaturesFromPointSearchInGeoFeatureLayer (ESRI.ArcGIS.Geometry.IEnvelope pEnvelope, IPoint pPoint, IFeatureClass pFeatureClass)

{

  if (pPoint == null || pFeatureClass == null)

  {

    return null;

  }

 

  //ITopologicalOperator pTopo = pPoint as ITopologicalOperator;

 

  //IGeometry pGeo = pTopo.Buffer(pSearchTolerance);

 

  System.String pShapeFieldName = pFeatureClass.ShapeFieldName;

  ESRI.ArcGIS.Geodatabase.ISpatialFilter pSpatialFilter = new ESRI.ArcGIS.Geodatabase.SpatialFilterClass ();

  pSpatialFilter.Geometry = pEnvelope;

 

  pSpatialFilter.SpatialRel = ESRI.ArcGIS.Geodatabase.esriSpatialRelEnum.esriSpatialRelEnvelopeIntersects;

 

  pSpatialFilter.GeometryField = pShapeFieldName;

 

  ESRI.ArcGIS.Geodatabase.IFeatureCursor pFeatureCursor = pFeatureClass.Search (pSpatialFilter, false);

 

  return pFeatureCursor;

}

 

IMap map = this.axMapControl1.Map;

ISelection selection = map.FeatureSelection;

 

IEnumFeatureSetup pEnumFeatureSetup = (IEnumFeatureSetup) selection;

pEnumFeatureSetup.AllFields = true;

 

IEnumFeature pEnumFeature = (IEnumFeature) selection;

IFeature feature = pEnumFeature.Next ();

 

while (feature != null)

{

  string a = Convert.ToString (feature.get_Value (feature.Fields.FindField ("dfd")));

  feature = pEnumFeature.Next ();

}

      京ICP备08100627号-22 京公网安备 11010802030428号