zoukankan      html  css  js  c++  java
  • Arcengine合并面要素

    问题:对两个进行合并的过程中(比如面A和面B),发现无论怎么合并最后的结果总是A要素的区域。

    解决方法:

    使用ITopologicalOperator.Union()方法对A、B俩个面要素进行合并,后来发现是没有获取union操作的结果 ,当时的错误代码是这样的:

    ITopologicalOperator2 unionTopo = geometryFirst as ITopologicalOperator2;                       
    IGeometry secondFeaGeo = secondFea.ShapeCopy;
    unionTopo.Union(secondFeaGeo);
    unionFea.Shape =unionTopo as IGeometry ;//这种获取union操作的结果的方法是错误的
    

    后来在网友帮助下改正代码如下:

                            IFeature unionFea = areaFeaClass.CreateFeature();
    
                            IFeature firstFea = areaFeaClass.GetFeature(unionFeaGroupList[i][0]);
                            IFeature secondFea = areaFeaClass.GetFeature(unionFeaGroupList[i][1]);
    
                            IGeometry geometryFirst = firstFea.ShapeCopy;
                            ITopologicalOperator2 unionTopo = geometryFirst as ITopologicalOperator2;                       
    
                            IGeometry secondFeaGeo = secondFea.ShapeCopy;
                         
                            unionFea.Shape = unionTopo.Union(secondFeaGeo);//正确获得结果的方式
                            unionFea.set_Value(feastateIndex, "0");
                            unionFea.Store();
    
                            firstFea.Delete();
                            secondFea.Delete();
    

    合并结果就正确了。也可以将合并好的结果赋给第一个要素并保存,然后删除第二个要素,这样便避免了创建新要素然后再删除两个要素的麻烦。

  • 相关阅读:
    PTA(Advanced Level)1009.Product of Polynomials
    PTA(Advanced Level)1002.A+B for Polynomials
    PTA(Advanced Level)1065.A+B and C
    PTA(Advanced Level)1046.Shortest Distance
    PTA(Advanced Level)1042.Shuffling Machine
    PTA(Basic Level)1046.划拳
    PTA(Basic Level)1060.爱丁顿数
    PTA(Basic Level)1053.住房空置率
    PTA(Basic Level)1023.组个最小数
    DOM4J熟知
  • 原文地址:https://www.cnblogs.com/lettet/p/4365996.html
Copyright © 2011-2022 走看看