C# ArcGIS Engine /AO 线打断 方法
2018-01-31 11:31
706 查看
// <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 = 0; i < pGeometryCollection.GeometryCount; i++) { //生成新的要素 workspaceEdit.StartEditing(false); workspaceEdit.StartEditOperation(); pNewFeature = pFeatureClass.CreateFeature(); IGeometryCollection pline = new PolylineClass(); IGeometry pGeo = pGeometryCollection.get_Geometry(i); pline.AddGeometries(1, 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(); } }
相关文章推荐
- ArcgisEngine+C#开发中,对一个图层进行过滤,并只显示符合条件的要素
- ArcGIS runtime/engine/desktop 10安装及授权方法
- ArcGIS Engine中空间参照(地理坐标)相关方法总结
- 基于ArcGIS Engine+C#的二次开发---电子校园管理信息系统(1)
- c#+arcgisengine&nbsp;对属性表创…
- c#+ ArcgisEngine 定制要素编辑工具
- C# SkinEngine控件 给窗体添加皮肤的方法
- 基于ArcGIS10.0和Oracle10g的空间数据管理平台(C#开发)-ArcGIS_Engine中的数据访问
- C#与ArcGIS Engine生产面状图形
- ArcGIS Engine + C# 开发过程中,鼠标在地图上滑过时,显示地图相关信息
- C#+Arcgis Engine开发-点选查询
- C# ArcgisEngine开发中,对一个图层进行过滤,只显示符合条件的要素
- ArcGIS Engine + C# 实例开发教程:第八讲 属性数据表的查询显示
- 《ArcGIS Engine+C#实例开发教程》第二讲 菜单的添加及其实现
- 基于ArcGIS Engine+C#开发问题(4)
- 基于ArcGIS Engine+C#的二次开发---电子校园管理信息系统(2)
- ArcGIS10.0和Oracle10g的空间数据管理平台(C#开发)-ArcGIS_Engine中的数据访问
- ArcGIS Engine+C#实例开发教程
- ESRI.Arcgis.esrisystem.AoInitializeClass编译错误解决方法
- 提取Modis数据的指定层数据,C# ArcGISEngine