/// <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. Ryu基本操作的REST API调用演示样例

    import urllib2 import json def get_all_switches(): url = "http://127.0.0.1:8080/v1.0/topology/s ...

  2. 漫谈linux之文件IO篇(SSD写性能和机械硬盘差不多,读是4到10倍)

    前同事的文章,觉得写得很清晰,收藏了. http://blog.chinaunix.net/uid-27105712-id-3270102.html 在Linux 开发中,有几个关系到性能的东西,技术 ...

  3. [C++] upper_bound和lower_bound

    upper_bound 源码 template <class ForwardIterator, class T> ForwardIterator upper_bound (ForwardI ...

  4. Adobe Photoshop CC 2015(PS CC 2015)看图不说话

  5. python ftp

    #fpt_server.py#__*__ encoding=utf-8 __*__ import socket ,os class MyClass(object): def __init__(self ...

  6. hp服务器安装exsi5.5

    启动按f8进入raid制造页面: 1.  插入exsi5.5光盘 2.  按下开机键(开机比较慢需要等待一段时间) 3.  进入启动项目界面(插入光盘后启动会让你选择启动项.选择1光盘启动) 接下来按 ...

  7. @synchronized 再考察

    核心是:将标示对象与锁建立关联. 线程 锁 标识: 异常: NSString *test = @"test"; @try {     // Allocates a lock for ...

  8. 4、Go for循环

    package main import "fmt" func main(){ //for 循环是go语言唯一的循环结构,分为三种类型 //第一种 类似while i:=1 for ...

  9. iOS开发—— UIMenuController的使用

     UIMenuController的展现需要基于一个View视图,其交互则需要基于其所在View视图的Responder.举例来说,如果一个UIMenuController展现在当前ViewContr ...

  10. 删除小脚本 srm

    提示:只能删除当前路径下的目录或文件 #!/bin/bash #将测试好的脚本,拷贝到 $PATH 能够搜索到目录下.并且改名 例如: /usr/local/bin cp /test/srm.sh / ...