提取拓扑错误并导出

将Arcengine拓扑错误的要素提取出来并导出为shape文件

拓扑错误提取:

[csharp]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. private void PRV_GetErrorFeature(ITopologyRule IN_TopologyRule)  
  2.       {  
  3.           IEnvelope Temp_Envolope = (TP_MainTopology as IGeoDataset).Extent;  
  4.           IErrorFeatureContainer Temp_ErrorContainer = TP_MainTopology as IErrorFeatureContainer;  
  5.           //获取该种错误所有的错误要素  
  6.           IEnumTopologyErrorFeature Temp_EnumErrorFeature = Temp_ErrorContainer.get_ErrorFeatures(((IGeoDataset)FDS_MainFeatureDataset).SpatialReference, IN_TopologyRule, Temp_Envolope, truetrue);  
  7.           //提取一个错误要素  
  8.           ITopologyErrorFeature Temp_ErrorFeature = Temp_EnumErrorFeature.Next();  
  9.           if (Temp_ErrorFeature != null)  
  10.           {  
  11.               //作为搭建模型的要素  
  12.               IFeature Temp_MoudleFeature = Temp_ErrorFeature as IFeature;  
  13.               //生成要素类需要CLSID和EXCLSID  
  14.               IFeatureClassDescription Temp_FeatureClassDescription = new FeatureClassDescriptionClass();  
  15.               IObjectClassDescription Temp_ObjectClassDescription = (IObjectClassDescription)Temp_FeatureClassDescription;  
  16.               //以模型要素为模板构建一个要素类  
  17.               FDS_MainFeatureDataset.CreateFeatureClass(IN_TopologyRule.ToString(), Temp_MoudleFeature.Fields, Temp_ObjectClassDescription.InstanceCLSID, Temp_ObjectClassDescription.ClassExtensionCLSID, Temp_MoudleFeature.FeatureType, "Shape""");  
  18.               //打开生成的目标要素类并加入集合留待输出时使用  
  19.               IFeatureClass Temp_TargetFeatureClass = (FDS_MainFeatureDataset.Workspace as IFeatureWorkspace).OpenFeatureClass(IN_TopologyRule.ToString());  
  20.               LI_TopoErrorFeatureClass.Add(Temp_TargetFeatureClass);  
  21.               //将所有错误要素添加进目标要素类  
  22.               IWorkspaceEdit Temp_WorkspaceEdit = (IWorkspaceEdit)FDS_MainFeatureDataset.Workspace;  
  23.               Temp_WorkspaceEdit.StartEditing(true);  
  24.               Temp_WorkspaceEdit.StartEditOperation();  
  25.               IFeatureBuffer Temp_FeatureBuffer = Temp_TargetFeatureClass.CreateFeatureBuffer();  
  26.               //在目标要素类中插入所有错误要素  
  27.               IFeatureCursor featureCursor = Temp_TargetFeatureClass.Insert(true); ;  
  28.               while (Temp_ErrorFeature != null)  
  29.               {  
  30.                   IFeature Temp_Feature = Temp_ErrorFeature as IFeature;  
  31.                   //给目标要素附属性  
  32.                   Temp_FeatureBuffer.set_Value(1, Temp_ErrorFeature.OriginClassID);  
  33.                   Temp_FeatureBuffer.set_Value(2, Temp_ErrorFeature.OriginOID);  
  34.                   Temp_FeatureBuffer.set_Value(5, Temp_ErrorFeature.TopologyRuleType);  
  35.                   Temp_FeatureBuffer.Shape = Temp_Feature.Shape;  
  36.                   object featureOID = featureCursor.InsertFeature(Temp_FeatureBuffer);  
  37.                   featureCursor.Flush();//保存要素  
  38.                   Temp_ErrorFeature = Temp_EnumErrorFeature.Next();  
  39.               }  
  40.               Temp_WorkspaceEdit.StopEditOperation();  
  41.               Temp_WorkspaceEdit.StopEditing(true);  
  42.               System.Runtime.InteropServices.Marshal.ReleaseComObject(featureCursor);  
  43.           }  
  44.       }  

其中:

TP_MainTopology为验证后的拓扑,类行为ITopology

  LI_TopoErrorFeatureClass为记录所有拓扑错误要素类的集合,类型为  List<IFeatureClass> LI_TopoErrorFeatureClass

FDS_MainFeatureDataset为存储要素类的要素数据集,类型为FeatureDataset


输出shape文件


[csharp]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. private void PRV_OutPutToShape()  
  2. {  
  3.     FeatureClassToShapefile GP_FeatureClassToShape = new FeatureClassToShapefile();  
  4.     foreach (IFeatureClass Each_FeatureClass in LI_TopoErrorFeatureClass)  
  5.     {  
  6.         GP_FeatureClassToShape.Input_Features = Each_FeatureClass;  
  7.         GP_FeatureClassToShape.Output_Folder = "E:\\";  
  8.         GP_Tool.Execute(GP_FeatureClassToShape,null);  
  9.     }  
  10.               
  11. }  
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值