zoukankan
html css js c++ java
如何调用ITopologicalOperator.Union方法成功地merge polygon
为什么题目要加个“成功地”,因为
ITopologicalOperator
的方法是bug非常多的,在90%的情况下能够按照你预想的工作,但是在10%的情况下,既不报错也不工作。这个merge的操作,成功地折磨了我两天。终于找到了解决的方法。
ICursor pCursor;
featureSelect.SelectionSet.Search(
null
,
false
,
out
pCursor);
IFeatureCursor pFeatureCursor
=
pCursor
as
IFeatureCursor;
IFeature pFeatureFirst
=
pFeatureCursor.NextFeature();
//
开始一个编辑操作,以能够撤销
m_EditWorkspace.StartEditOperation();
IGeometry pGeometryFirst
=
pFeatureFirst.Shape;
ITopologicalOperator2 topo_oper
=
(ITopologicalOperator2)pGeometryFirst;
//
ITopologicalOperator的操作是bug很多的,先强制的检查下面三个步骤,再进行操作
//
成功的可能性大一些
topo_oper.IsKnownSimple_2
=
false
;
topo_oper.Simplify();
pGeometryFirst.SnapToSpatialReference();
//
这是准备合并的图斑使用的
ITopologicalOperator2 topo_oper2;
IGeometry pGeometryNext;
IFeature pFeatureNext
=
pFeatureCursor.NextFeature();
while
(pFeatureNext
!=
null
)
{
pGeometryNext
=
pFeatureNext.ShapeCopy;
//
与上面的同理
topo_oper2
=
pGeometryNext
as
ITopologicalOperator2;
topo_oper2.IsKnownSimple_2
=
false
;
topo_oper2.Simplify();
pGeometryNext.SnapToSpatialReference();
//
这才是合并图斑的关键
pGeometryFirst
=
topo_oper.Union(pGeometryNext);
pFeatureNext.Delete();
pFeatureNext
=
pFeatureCursor.NextFeature();
}
topo_oper.IsKnownSimple_2
=
false
;
topo_oper.Simplify();
pFeatureFirst.Shape
=
pGeometryFirst;
pFeatureFirst.Store();
m_EditWorkspace.StopEditOperation();
查看全文
相关阅读:
架构之路(六):把框架拉出来
读取mdb文件
基类、子类之间的类型转换
WPF Trigger
WPF 打开txt文件
C# 匿名方法
自定义显隐式类型转换
枚举获得Description扩展方法
IFormattable和IFormatProvider
WPF DataGrid下滑动态加载数据
原文地址:https://www.cnblogs.com/renji/p/978029.html
最新文章
在window上使用 linux shell 删除文件夹递归地
shell 命令使用笔记
lua 设置文件运行的环境
Lua 函数链功能
lua 立即执行函数
LazyMan的Promise解法
由LazyMan联想到的
ReactiveX编程范式
Programming paradigms
AOP programming paradiag
热门文章
lua UT测试工具
LuaSrcDiet工具介绍(lua源码处理软件)
架构之路:从管理者的角度看问题
《七年失败的程序之路》读后感续:积累和包装
《七年失败的程序之路》读后感
有些事必须去做——写在离职之后创业之前
我放浪形骸的2016
架构之路(九)Session Per Request
架构之路(八)从CurrentUser说起
架构之路(七)MVC点滴
Copyright © 2011-2022 走看看