/// <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 线打断的更多相关文章

  1. ArcGIS Engine中添加点、线、面元素

    转自原文 ArcGIS Engine中添加点.线.面元素 此种方式为IElement的方式在axMapControl的GraphicsContainer中好绘制图形. //画点 IPoint pt = ...

  2. ArcGIS Engine开发之图形查询

    图形查询是以用户通过鼠标操作生成的图形几何体为输入条件进行查询的查询,其查询结果为该几何体空间范围内的所有要素.常用的查询方式包括点选.线选.多边形选择.圆形选择和矩形选择等. 相关类与接口 图像查询 ...

  3. ArcGIS Engine开发之地图基本操作(3)

    地图数据的加载 一.加载Shapefile数据 Shapefile文件是目前主流的一种空间数据的文件存储方式,也是不同GIS软件进行数据格式转换常用的中间格式.加载Shapefile数据的方式有两种: ...

  4. 【转载】Python与ArcGIS Engine的集成

    本文转载自Fransico<Python与ArcGIS Engine的集成>   1 在Python中调用AO类库 1.1  准备工作 本文所使用环境:ArcGIS 10.0.Python ...

  5. ArcGIS Engine环境下创建自定义的ArcToolbox Geoprocessing工具

    在上一篇日志中介绍了自己通过几何的方法合并断开的线要素的ArcGIS插件式的应用程序.但是后来考虑到插件式的程序的配置和使用比较繁琐,也没有比较好的错误处理机制,于是我就把之前的程序封装成一个类似于A ...

  6. ArcGIS Engine开发之旅05---空间数据库

    原文:ArcGIS Engine开发之旅05---空间数据库 1  Geodatabase概念 Geodatabase是ArcInfo8引入的一种全新的面向对象的空间数据模型,是建立在DBMS之上的统 ...

  7. ArcGIS Engine开发之旅04---ARCGIS接口详细说明

    原文:ArcGIS Engine开发之旅04---ARCGIS接口详细说明 ArcGIS接口详细说明... 1 1.      IField接口(esriGeoDatabase)... 2 2.    ...

  8. ArcGIS Engine开发之旅02--ArcGIS Engine中的类库

    原文:ArcGIS Engine开发之旅02--ArcGIS Engine中的类库 System类库 System类库是ArcGIS体系结构中最底层的类库.System类库包含给构成ArcGIS的其他 ...

  9. [转载]ArcGIS Engine 中的多线程使用

    ArcGIS Engine 中的多线程使用 原文链接 http://anshien.blog.163.com/blog/static/169966308201082441114173/   一直都想写 ...

随机推荐

  1. A. Ilya and Diplomas( Codeforces Round #311 (Div. 2) )

    A. Ilya and Diplomas time limit per test 1 second memory limit per test 256 megabytes input standard ...

  2. IPS

    转自:http://www.ithome.com.tw/node/79293 企業中網路環境的防護,通常都是先有防火牆,再搭配IPS.但是,實際上買得起IPS防護的企業有限,這是因為IPS的價格很昂貴 ...

  3. 9. IntelliJ Idea 集成svn 和使用

    转自:http://www.cnblogs.com/zhanghaoliang/p/6206948.html 最近公司的很多同事开始使用IntelliJ Idea,便尝试了一下,虽然快捷键与eclip ...

  4. sicily 1000. LinkedList

    Description template <typename E> class LinkedList { private:     // inner class: linked-list ...

  5. AngularJs轻松入门(四)模块化

    在前面几节教程中,代码比较少,为了方便说明问题笔者將控制器代码都写在了HTML页面中,实际上这并不是什么好的编程习惯,而且可维护性差.通常的做法都是將处理业务逻辑的代码写在一个单独的JS文件中,然后在 ...

  6. 用fcntl锁一个文件来保护操作

    int testfd; /* fd for test*/ if((testfd = open("/usr/local/pgsql/bin/test_fd",O_RDWR|O_CRE ...

  7. php函数: call_user_func()和call_user_func_array() 使用详解

    call_user_func 该函数允许直接调用自己写的函数,可以直接传入一些参数. 使用方法1:给自己写的函数传入参数,一个特别的调用函数的方法. <?php funciotn test1($ ...

  8. Functor& Monad解读

    整体上代表封装的概念,重点是函数的封装,及函数运行的上下文环境.trait Functor[F[_]] Functor:代表整体封装: F[_]:代表封装后的目标域. A.B:代表普通的对象:f:代表 ...

  9. Debian9.5 系统配置FTP

    FTP 是File Transfer Protocol(文件传输协议)的英文简称,而中文简称为“文传协议”.用于Internet上的控制文件的双向传输.同时,它也是一个应用程序(Application ...

  10. 为什么 linux 上不能用 localhost 链接数据库?

         因为 linux 连接的时候不是通过 tcp 协议,而是通过 sockect 来连接.所以 写localhost 之后就会默认去找 sockect 链接[此文件在 /var/lib/mysq ...