ArcGIS Engine将圆弧转为加密的线段

文章目录

代码

/// <summary>
/// 将面状图层的圆弧转为加密的线段
/// </summary>
/// <param name="pWorkspace">工作空间(FileGDB)</param>
/// <param name="sPolygonFeatureClassName">面状要素类名称</param>
/// <param name="nSegLength">加密线段每段的参考长度</param>
private static void CircularArcToDensifiedLines(IFeatureWorkspace pWorkspace, string sPolygonFeatureClassName, int nSegLength = 10)
{
	try
	{
		var pFeatureClass = pWorkspace.OpenFeatureClass(sPolygonFeatureClassName);
		var pFeatureCursor = pFeatureClass.Search(null, false);
		var bChange = false;
		IFeature pFeature;
		while (null != (pFeature = pFeatureCursor.NextFeature()))
		{
			var pGeoCol = pFeature.ShapeCopy as IGeometryCollection;
			for (int i = pGeoCol.GeometryCount - 1; i >= 0; i--)
			{
				var pGeo = pGeoCol.Geometry[i];
				if (pGeo.GeometryType == esriGeometryType.esriGeometryRing)
				{
					var pSegCol = pGeo as ISegmentCollection;
					var nCount = pSegCol.SegmentCount;
					for (int j = nCount - 1; j >= 0; j--)
					{
						var pSeg = pSegCol.Segment[j];
						if (pSeg.GeometryType != esriGeometryType.esriGeometryCircularArc)
						{
							continue;
						}
						var pCircularArc = pSeg as ICircularArc;
						var nLength = pCircularArc.Length;
						var nShareCount = (int)(nLength / nSegLength) + 1;
						if (nShareCount < 3)
						{
							nShareCount = 3;
						}
						int nNum = 0;
						var lstLine = new ILine[nShareCount];
						IGeometryBridge2 geometryBridge2 = new GeometryEnvironmentClass();
						geometryBridge2.Densify(pSeg, 0.1, ref nNum, ref lstLine);
						var pGeometryBag = new GeometryBagClass();
						ISegmentCollection pGeometryCollection = new PolygonClass();
						lstLine.ToList().ForEach(p => pGeometryCollection.AddSegment(p as ISegment));
						bChange = true;
						if (bChange)
						{
							pSegCol.RemoveSegments(j, 1, false);
							pSegCol.InsertSegmentCollection(j, pGeometryCollection);
						}
					}
				}
			}
			if (bChange)
			{
				pFeature.Shape = pGeoCol as IGeometry;
				pFeature.Store();
			}
		}
	}
	catch { }
}
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值