ArcEngine C# 二次开发 PolyLine 多次打断操作
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了ArcEngine C# 二次开发 PolyLine 多次打断操作,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2742字,纯文字阅读大概需要4分钟。
内容图文
![ArcEngine C# 二次开发 PolyLine 多次打断操作](/upload/InfoBanner/zyjiaocheng/1108/ad894d0a35e247329c4dc86e8fce827a.jpg)
一条线(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); 8if (!geometry2.IsEmpty) 9 { 10 IPointCollection points2 = geometry2 as IPointCollection; 11for(int i = 0; i < points2.PointCount; i++) 12 { 13 point = points2.get_Point(i); 14 ISet set = (feature as IFeatureEdit).Split(point); 15set.Reset(); 16for (IFeature feature2 = set.Next() as IFeature; feature2 != null; feature2 = set.Next() as IFeature) 17 { 18if (!IsSplitOk(feature2,other)) 19 { 20 feature = feature2; 21 } 22else 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; 31this.pMapControl.FlashShape(feature2.Shape, 1, 450, symbol as ISymbol); 32 pMapControl.ActiveView.FocusMap.SelectFeature(pCurrentLayer, feature2); 33 } 34 35 } 36 37 } 38 } 39 } 40catch (Exception) 41 { 42return ; 43 } 44 45 } 46 47publicbool IsSplitOk(IFeature feature, IGeometry splitLine) 48 { 49bool ok = false; 50try 51 { 52 ITopologicalOperator shape = feature.Shape as ITopologicalOperator; 53 IGeometry geometry = shape.Intersect(splitLine, esriGeometryDimension.esriGeometry0Dimension); 54if (!geometry.IsEmpty) 55 { 56 IPointCollection points = geometry as IPointCollection; 57if(points.PointCount==1) 58 { 59 IPoint point = points.get_Point(0); 60if (IsLineStartEndPoint(feature,point)) 61 { 62 ok = true; 63 } 64 65 } 66elseif (points.PointCount == 2) 67 { 68 IPoint point1 = points.get_Point(0); 69 IPoint point2 = points.get_Point(1); 70if (IsLineStartEndPoint(feature, point1) && IsLineStartEndPoint(feature, point2)) 71 { 72 ok = true; 73 } 74 } 75 76 } 77return ok; 78 } 79catch (Exception) 80 { 81returnfalse; 82 } 83 } 84 85 86publicbool IsLineStartEndPoint(IFeature feature,IPoint point) 87 { 88bool yes = false; 89try 90 { 91 IPolyline line = feature.Shape as IPolyline; 92double len = line.Length; 93 IPoint pStart = line.FromPoint; 94if (Math.Abs(pStart.X - point.X) < 0.1 && Math.Abs(pStart.Y - point.Y) < 0.1) 95 { 96 yes = true; 97 } 98else 99 { 100 IPoint pEnd = line.ToPoint; 101if (Math.Abs(pEnd.X - point.X) < 0.1 && Math.Abs(pEnd.Y - point.Y) < 0.1) 102 { 103 yes = true; 104 } 105 } 106return yes; 107 } 108catch (Exception) 109 { 110returnfalse; 111 } 112 }
原文:http://www.cnblogs.com/shizhenkun/p/5556478.html
内容总结
以上是互联网集市为您收集整理的ArcEngine C# 二次开发 PolyLine 多次打断操作全部内容,希望文章能够帮你解决ArcEngine C# 二次开发 PolyLine 多次打断操作所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。