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();
查看全文
相关阅读:
ASP.NET Repeater的用法初探
ADO.NET 数据查询和数据操作
ASP.NET 一般处理程序基础1(Get Post 表单提交 Http协议 Nvelocity模板引擎)
接口继承
《需求工程》阅读笔记2
《需求工程》阅读笔记1
Python3.0中的strip方法失效问题以及re.sub方法无法执行问题
使用Python爬取豆瓣电影详细数据
《软件方法》阅读笔记——3
基于layui实现了将查询出的数据分页显示
原文地址:https://www.cnblogs.com/renji/p/978029.html
最新文章
单例模式
Eclipse创建jsp web项目
String int 变量互相转化
static
vector erase的错误用法
[pat]A1072 Gas Station
1021 Deepest Root
fill和memset的区别
leetcode34. Find First and Last Position of Element in Sorted Array
leetcode473 Matchsticks to Square
热门文章
leetcode 22括号生成
leetcode 93 复原IP地址
leetcode 108
关于二叉树结点删除引出的小问题
截屏到相册
课堂笔记——从StroryBoard里读取ViewControlller
SVProgressHUD
课堂笔记—— post 上传
POST网络访问
ISO 网络访问
Copyright © 2011-2022 走看看