获取Polyline两点间的线段
/// <summary>
/// 创建区间线段
/// </summary>
/// <param name=”pLine”>输入的线图形</param>
/// <param name=”p1″>插入的其中一个点</param>
/// <param name=”p2″>插入的一种一个点</param>
/// <returns>这两点间的线段</returns>
/// 创建人 : 懒羊羊
private IPolyline BuildLine(IPolyline pLine, IPoint p1, IPoint p2)
{
bool isSplit;
int splitIndex, segIndex;
//插入第一点,segIndex记录插入点的相对线的节点位置
pLine.SplitAtPoint(p1, true, false, out isSplit, out splitIndex, out segIndex);
int fIndex = segIndex;
//插入第二点
pLine.SplitAtPoint(p2, true, false, out isSplit, out splitIndex, out segIndex);
int sIndex = segIndex;
//比较一下插入第一点和第二点的节点次序
if (fIndex > sIndex)
{
int temp = fIndex;
fIndex = sIndex;
sIndex = temp;
}
IPointCollection pPointCol = new PolylineClass();
object o = Type.Missing;
//利用两点区间,获取线上区间所在的点,并将其转换为线
IPointCollection LineCol = pLine as IPointCollection;
for (int i = fIndex; i <= sIndex; i++)
{
pPointCol.AddPoint(LineCol.get_Point(i), ref o, ref o);
}
return pPointCol as IPolyline;
}
转载自:https://blog.csdn.net/GISSTAR/article/details/3776470