返回首页
当前位置: 主页 > 网络编程 > 其他实例教程 >

AE中2种方式overlay概述

时间:2011-04-09 20:45来源:知行网www.zhixing123.cn 编辑:麦田守望者

方法一:利用ITopology接口:
void COverlayDlg::Overlay(ILayerPtr inputLayer, ILayerPtr OverlayLayer,IFeatureClassPtr ipNewClass)
{
int mode=m_modeCombo.GetCurSel();
IFeatureLayerPtr ipPutlayer(inputLayer);
IFeatureClassPtr ipPutClass;
ipPutlayer->get_FeatureClass(&ipPutClass);
IFeatureClassPtr ipOutClass;
IFeatureLayerPtr ipOverlayer(OverlayLayer);
ipOverlayer->get_FeatureClass(&ipOutClass);

IQueryFilterPtr ipQF(CLSID_QueryFilter);
long number1,number2;
ipPutClass->FeatureCount(ipQF,&number1);
ipPutClass->FeatureCount(ipQF,&number2);

IActiveViewPtr ipView=p_View->m_ctrlMap.GetActiveView();
ITopologicalOperatorPtr ipTo;
IFeaturePtr ipFeature1,ipFeature2;
IGeometryPtr ipGeo1,ipGeo2,ipNew;
for(long i=0;i<number1;i++)
for(long j=0;j<number2;j++)
{
ipPutClass->GetFeature(i,&ipFeature1);
ipOutClass->GetFeature(j,&ipFeature2);
ipFeature1->get_Shape(&ipGeo1);
ipFeature2->get_Shape(&ipGeo2);
ipTo=ipGeo1;
switch(mode)
{
case 0:
ipTo->Intersect(ipGeo2,esriGeometry2Dimension,&ipNew);
break;
case 1:
ipTo->Union(ipGeo2,&ipNew);
break;
case 2:
ipTo->Difference(ipGeo2,&ipNew);
}
IFeaturePtr ipFeature;
ipNewClass->CreateFeature(&ipFeature);
ipFeature->putref_Shape(ipNew);
ipFeature->Store();
}
ipView->Refresh();
}
这种方法是一个一个feature的创建,存入featureclass接口中。

方法二:利用IBasicGeoprocess接口

//把第一个图层和第0个图层叠置

IFeatureLayerPtr ipFeaLay;
IFeatureClassPtr ipFeaCls;
HRESULT hr;

ILayerPtr ipLay;
IMapPtr ipMap(m_ctrlMap.GetMap());
hr=ipMap->get_Layer(0,&ipLay);
ipFeaLay=ipLay;
if(ipFeaLay)
{
hr=ipFeaLay->get_FeatureClass(&ipFeaCls);
if (FAILED(hr)) return;
}
ITablePtr ipInPutTable(ipLay);
hr=ipMap->get_Layer(1,&ipLay);

ipFeaLay=ipLay;
if(ipFeaLay!=0)
hr=ipFeaLay->get_FeatureClass(&ipFeaCls);

ITablePtr ipOverlayTable(ipLay);
hr=ipDatasetName->putref_WorkspaceName(ipWSName);
if(FAILED(hr)) return;
IBasicGeoprocessorPtr ipBGP(CLSID_BasicGeoprocessor);
IFeatureClassPtr ipOutputFeaCls;
hr=ipBGP->Intersect(ipInPutTable,VARIANT_FALSE,ipOverlayTable,VARIANT_FALSE,double(0),ipFeaClsName,&ipOutputFeaCls);

IFeatureLayerPtr ipOutputFeaLay(CLSID_FeatureLayer);
ipOutputFeaLay->putref_FeatureClass(ipOutputFeaCls);
BSTR OutFeaClsAliName;
hr=ipOutputFeaCls->get_AliasName(&OutFeaClsAliName);
if(FAILED(hr)) return;
hr=ipOutputFeaLay->put_Name(OutFeaClsAliName);
if(FAILED(hr)) return;
hr=ipMap->AddLayer(ipOutputFeaLay);
if(FAILED(hr)) return;
IActiveViewPtr ipAV(ipMap);
ipAV->Refresh();
 

------分隔线----------------------------
标签(Tag):Arcgis Arcgis开发 Arcgis开发教程 Arcgis程序代码
------分隔线----------------------------
推荐内容
猜你感兴趣
博聚网