cl991036
管理员
管理员
  • 注册日期2003-07-25
  • 发帖数5917
  • QQ14265545
  • 铜币29669枚
  • 威望217点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • GIS帝国铁杆
阅读:991回复:0

如何调用ITopologicalOperator.Union方法进行地merge polygon

楼主#
更多 发布于:2007-12-02 10:17
<DIV class=postText>ITopologicalOperator的方法是bug非常多的,在90%的情况下能够按照你预想的工作,但是在10%的情况下,既不报错也不工作。</DIV>
<DIV class=postText>      ICursor pCursor;<BR>      featureSelect.SelectionSet.Search(null, false, out pCursor);</DIV>
<DIV class=postText>      IFeatureCursor pFeatureCursor = pCursor as IFeatureCursor;<BR>      IFeature pFeatureFirst = pFeatureCursor.NextFeature();</DIV>
<DIV class=postText>      // 开始一个编辑操作,以能够撤销<BR>      m_EditWorkspace.StartEditOperation();</DIV>
<DIV class=postText>      IGeometry pGeometryFirst = pFeatureFirst.Shape;<BR>      ITopologicalOperator2 topo_oper = (ITopologicalOperator2)pGeometryFirst;</DIV>
<DIV class=postText>      //ITopologicalOperator的操作是bug很多的,先强制的检查下面三个步骤,再进行操作<BR>      //成功的可能性大一些<BR>      topo_oper.IsKnownSimple_2 = false;<BR>      topo_oper.Simplify();<BR>      pGeometryFirst.SnapToSpatialReference();</DIV>
<DIV class=postText>      //这是准备合并的图斑使用的<BR>      ITopologicalOperator2 topo_oper2;<BR>      IGeometry pGeometryNext;<BR>      IFeature pFeatureNext = pFeatureCursor.NextFeature();</DIV>
<DIV class=postText>      while (pFeatureNext != null)<BR>      {<BR>        pGeometryNext = pFeatureNext.ShapeCopy;</DIV>
<DIV class=postText>        //与上面的同理<BR>        topo_oper2 = pGeometryNext as ITopologicalOperator2;<BR>        topo_oper2.IsKnownSimple_2 = false;<BR>        topo_oper2.Simplify();<BR>        pGeometryNext.SnapToSpatialReference();</DIV>
<DIV class=postText>        //这才是合并图斑的关键<BR>        pGeometryFirst = topo_oper.Union(pGeometryNext);<BR>        pFeatureNext.Delete();</DIV>
<DIV class=postText>        pFeatureNext = pFeatureCursor.NextFeature();<BR>      }<BR>      topo_oper.IsKnownSimple_2 = false;<BR>      topo_oper.Simplify();<BR>      pFeatureFirst.Shape = pGeometryFirst;<BR>      pFeatureFirst.Store();<BR>      m_EditWorkspace.StopEditOperation();<BR></DIV>
喜欢0 评分0
没钱又丑,农村户口。头可断,发型一定不能乱。 邮箱:gisempire@qq.com
游客

返回顶部