[ArcGIS Engine][MFC/VS2008]判断图层是点图层、线图层还是面图层的方法

在图层上做图之前,必须先了解需要做图的图层是属于点图层、线图层还是面图层,以便绘上相应的对象。要知道,我们无法在点图层画线,也无法在线图层画多边形。判断图层类型的方法很简单,主要用到IFeatureClassPtr接口的get_ShapeType方法,下面直接上代码:

 
  

//对话框的MapControl的变量名为m_MapCtrl

HRESULT hr = 0;

ILayerPtr pILayer = m_MapCtrl.get_Layer(0); IFeatureLayerPtr pIFeatureLayer = (IFeatureLayerPtr)pILayer; IFeatureClassPtr pIFeatureClass; hr = pIFeatureLayer->get_FeatureClass(&pIFeatureClass); esriGeometryType LayarShapeType; pIFeatureClass->get_ShapeType(&LayarShapeType); if(LayarShapeType == esriGeometryPoint) { MessageBox(_T("Layer of point")); } else if(LayarShapeType == esriGeometryMultipoint) { MessageBox(_T("Layer of multipoint")); } else if(LayarShapeType == esriGeometryPolyline) { MessageBox(_T("Layer of polyline")); } else if(LayarShapeType == esriGeometryMultiPatch) { MessageBox(_T("Layer of multiPatch")); } else if(LayarShapeType == esriGeometryPolygon) { MessageBox(_T("Layer of polygon")); }

转载于:http://celerysoft.blog.163.com/blog/static/213525082201499103324297/

你可能感兴趣的:(ArcGIS,Engine)