ArcEngine C# 二次开发 PolyLine 多次打断操作
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ArcEngine C# 二次开发 PolyLine 多次打断操作相关的知识,希望对你有一定的参考价值。
一条线(Polyline)被另外一条线多次(Polyline)切割,也就是说打断的点有多个,而AE中的IFeatureEdit.Split()只能是一个点一个点的处理,这样就涉及到了循环操作,现在将本人自己写具体的操作函数附上,大家一同学习。
1 public void LineSplit(IFeature feature, IGeometry other) 2 { 3 try 4 { 5 ITopologicalOperator shape = feature.Shape as ITopologicalOperator; 6 IPoint point = new PointClass(); 7 IGeometry geometry2 = shape.Intersect(other, esriGeometryDimension.esriGeometry0Dimension); 8 if (!geometry2.IsEmpty) 9 { 10 IPointCollection points2 = geometry2 as IPointCollection; 11 for(int i = 0; i < points2.PointCount; i++) 12 { 13 point = points2.get_Point(i); 14 ISet set = (feature as IFeatureEdit).Split(point); 15 set.Reset(); 16 for (IFeature feature2 = set.Next() as IFeature; feature2 != null; feature2 = set.Next() as IFeature) 17 { 18 if (!IsSplitOk(feature2,other)) 19 { 20 feature = feature2; 21 } 22 else 23 { 24 ISimpleLineSymbol symbol = new SimpleLineSymbolClass(); 25 IRgbColor color = new RgbColorClass 26 { 27 RGB = Color.FromArgb(0xff, 0, 0).ToArgb() 28 }; 29 symbol.Color = color; 30 symbol.Width = 2.0; 31 this.pMapControl.FlashShape(feature2.Shape, 1, 450, symbol as ISymbol); 32 pMapControl.ActiveView.FocusMap.SelectFeature(pCurrentLayer, feature2); 33 } 34 35 } 36 37 } 38 } 39 } 40 catch (Exception) 41 { 42 return ; 43 } 44 45 } 46 47 public bool IsSplitOk(IFeature feature, IGeometry splitLine) 48 { 49 bool ok = false; 50 try 51 { 52 ITopologicalOperator shape = feature.Shape as ITopologicalOperator; 53 IGeometry geometry = shape.Intersect(splitLine, esriGeometryDimension.esriGeometry0Dimension); 54 if (!geometry.IsEmpty) 55 { 56 IPointCollection points = geometry as IPointCollection; 57 if(points.PointCount==1) 58 { 59 IPoint point = points.get_Point(0); 60 if (IsLineStartEndPoint(feature,point)) 61 { 62 ok = true; 63 } 64 65 } 66 else if (points.PointCount == 2) 67 { 68 IPoint point1 = points.get_Point(0); 69 IPoint point2 = points.get_Point(1); 70 if (IsLineStartEndPoint(feature, point1) && IsLineStartEndPoint(feature, point2)) 71 { 72 ok = true; 73 } 74 } 75 76 } 77 return ok; 78 } 79 catch (Exception) 80 { 81 return false; 82 } 83 } 84 85 86 public bool IsLineStartEndPoint(IFeature feature,IPoint point) 87 { 88 bool yes = false; 89 try 90 { 91 IPolyline line = feature.Shape as IPolyline; 92 double len = line.Length; 93 IPoint pStart = line.FromPoint; 94 if (Math.Abs(pStart.X - point.X) < 0.1 && Math.Abs(pStart.Y - point.Y) < 0.1) 95 { 96 yes = true; 97 } 98 else 99 { 100 IPoint pEnd = line.ToPoint; 101 if (Math.Abs(pEnd.X - point.X) < 0.1 && Math.Abs(pEnd.Y - point.Y) < 0.1) 102 { 103 yes = true; 104 } 105 } 106 return yes; 107 } 108 catch (Exception) 109 { 110 return false; 111 } 112 }
以上是关于ArcEngine C# 二次开发 PolyLine 多次打断操作的主要内容,如果未能解决你的问题,请参考以下文章
在arcengine里面如何用GP工具实现addjoin .用C#