C# ArcGIS Engine 线打断
/// <summary>
/// 打断线,用于在点击点处,打断该条线
/// </summary>
/// <param name="t_pLineFeatureClass">线图层</param>
/// <param name="t_pPoint">点击的点</param>
public static void SplitePolylineByHitPoint(IFeatureClass t_pLineFeatureClass, IPoint t_pPoint)
{ IFeatureClass pFeatureClass = t_pLineFeatureClass;
IFeatureCursor pFeatureCursor;
IFeature pFeature;
pFeatureCursor = pFeatureClass.Search(null, false);
pFeature = pFeatureCursor.NextFeature(); IDataset dataset = (IDataset)pFeatureClass;
IWorkspace workspace = dataset.Workspace;
IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace; IRelationalOperator pRelationalOperator;
//遍历featureClass找到点中的那条线
while (pFeature != null)
{
pRelationalOperator = (IRelationalOperator) pFeature.Shape;
bool bHasCrosses = pRelationalOperator.Contains(t_pPoint);
if (bHasCrosses)
{
//对那条线在点击点处,进行打断
IPolycurve pPolycurve = (IPolycurve) pFeature.Shape;
bool HasSplitHappened;
int newPartIndex;
int newSegmentIndex;
//打断
pPolycurve.SplitAtPoint(t_pPoint, false, true, out HasSplitHappened, out newPartIndex,
out newSegmentIndex);
if (HasSplitHappened)
{
//从GeometryCollection中分离出打断后的要素,并生成新的要素,并赋于属性
IFeature pNewFeature;
IGeometryCollection pGeometryCollection = (IGeometryCollection) pPolycurve; for (int i = ; i < pGeometryCollection.GeometryCount; i++)
{
//生成新的要素
workspaceEdit.StartEditing(false);
workspaceEdit.StartEditOperation();
pNewFeature = pFeatureClass.CreateFeature();
IGeometryCollection pline = new PolylineClass();
IGeometry pGeo = pGeometryCollection.get_Geometry(i);
pline.AddGeometries(, ref pGeo);
pNewFeature.Shape = (IPolyline) pline;
pNewFeature.Store();
workspaceEdit.StopEditOperation();
workspaceEdit.StopEditing(true);
#region 属性复制(注释掉)
//IRow pRow = (IRow) pFeature;
//int intIndex = pRow.Fields.FindField("CRoadID");
//进行属性复制
//for (int k = 2; k < pRow.Fields.FieldCount - 3; k++) //前后几个属性字段不添加
//{
// if (pRow.Fields.get_Field(k).Name == "Shape_Length")
// {
// continue;
// }
// if (k != intIndex)
// {
// if (!pRow.get_Value(k).ToString().Equals(""))
// { // pNewFeature.set_Value(k, pRow.get_Value(k));
// }
// }
// else
// {
// if (k == 0)
// {
// if (!pRow.get_Value(k).ToString().Equals(""))
// {
// pNewFeature.set_Value(k, pRow.get_Value(k));
// }
// }
// else
// { // if (!pRow.get_Value(k).ToString().Equals(""))
// {
// int intNO = System.Convert.ToInt32(pRow.get_Value(k).ToString()) + 1000*i;
// pNewFeature.set_Value(k, intNO);
// }
// }
// }
//}
//pNewFeature.Store();
#endregion
}
pFeature.Delete();
}
}
pFeature = pFeatureCursor.NextFeature();
}
}
C# ArcGIS Engine 线打断的更多相关文章
- ArcGIS Engine中添加点、线、面元素
转自原文 ArcGIS Engine中添加点.线.面元素 此种方式为IElement的方式在axMapControl的GraphicsContainer中好绘制图形. //画点 IPoint pt = ...
- ArcGIS Engine开发之图形查询
图形查询是以用户通过鼠标操作生成的图形几何体为输入条件进行查询的查询,其查询结果为该几何体空间范围内的所有要素.常用的查询方式包括点选.线选.多边形选择.圆形选择和矩形选择等. 相关类与接口 图像查询 ...
- ArcGIS Engine开发之地图基本操作(3)
地图数据的加载 一.加载Shapefile数据 Shapefile文件是目前主流的一种空间数据的文件存储方式,也是不同GIS软件进行数据格式转换常用的中间格式.加载Shapefile数据的方式有两种: ...
- 【转载】Python与ArcGIS Engine的集成
本文转载自Fransico<Python与ArcGIS Engine的集成> 1 在Python中调用AO类库 1.1 准备工作 本文所使用环境:ArcGIS 10.0.Python ...
- ArcGIS Engine环境下创建自定义的ArcToolbox Geoprocessing工具
在上一篇日志中介绍了自己通过几何的方法合并断开的线要素的ArcGIS插件式的应用程序.但是后来考虑到插件式的程序的配置和使用比较繁琐,也没有比较好的错误处理机制,于是我就把之前的程序封装成一个类似于A ...
- ArcGIS Engine开发之旅05---空间数据库
原文:ArcGIS Engine开发之旅05---空间数据库 1 Geodatabase概念 Geodatabase是ArcInfo8引入的一种全新的面向对象的空间数据模型,是建立在DBMS之上的统 ...
- ArcGIS Engine开发之旅04---ARCGIS接口详细说明
原文:ArcGIS Engine开发之旅04---ARCGIS接口详细说明 ArcGIS接口详细说明... 1 1. IField接口(esriGeoDatabase)... 2 2. ...
- ArcGIS Engine开发之旅02--ArcGIS Engine中的类库
原文:ArcGIS Engine开发之旅02--ArcGIS Engine中的类库 System类库 System类库是ArcGIS体系结构中最底层的类库.System类库包含给构成ArcGIS的其他 ...
- [转载]ArcGIS Engine 中的多线程使用
ArcGIS Engine 中的多线程使用 原文链接 http://anshien.blog.163.com/blog/static/169966308201082441114173/ 一直都想写 ...
随机推荐
- python之路-------字符串与正則表達式
1.1.#####去掉字符串中的转义符string.strip() print "hello\tworld\n" >>> word="\thello w ...
- 文件共享服务器nfs搭建过程
网络文件共享服务器192. yum install -y nfs-utils 在exports文件中添加的从机范围 vim /etc/exports /home/nfs/ (rw,sync,fsid= ...
- 机器学习规则:ML工程最佳实践----rules_of_ml section 1【翻译】
作者:黄永刚 机器学习规则:ML工程最佳实践 本文旨在指引具有机器学习基础知识的工程师等人,更好的从机器学习的实践中收益.介绍一些应用机器学习需要遵循的规则,类似于Google C++ 风格指南等流行 ...
- MFC 创建新项目
本文主要介绍如何是使用vc++创建MFC项目,并简单介绍整个项目的基本框架.文件–>新建,会弹出以下新建文件(项目)类型的界面,如下 按上图的步骤u,创建一个MFC工程.其中步骤3中的CardD ...
- 文本域内容在div中带换行显示
function ReplaceSeperator(mobiles) { var i; var result = ""; var c; for (i = 0; i < mob ...
- git rebase 的使用 (用于撤销某次commit)
Q: I wrote the wrong thing in a commit message. Alternatively, I've forgotten to include some files. ...
- 用Google Chrome 浏览器打开Unity打包的WebGL
方法一: 直接build and run 方法二: 步骤: 1.打开浏览器的属性 2.在目标的位置添加--allow-file-access-from-files, 注意--allow-file-ac ...
- 水池接雨水的经典问题I&II
https://leetcode.com/problems/trapping-rain-water https://leetcode.com/problems/trapping-rain-water- ...
- Codeforces Round #316 (Div. 2) B. Simple Game
思路:把n分成[1,n/2],[n/2+1,n],假设m在左区间.a=m+1,假设m在右区间,a=m-1.可是我居然忘了处理1,1这个特殊数据.被人hack了. 总结:下次一定要注意了,提交前一定要看 ...
- Codeforces--602A--Two Bases(水)
Two Bases Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit St ...