zoukankan      html  css  js  c++  java
  • 获取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 (sIndex <= fIndex)                       //红色为增加判断部分
                    fIndex++;
                //比较一下插入第一点和第二点的节点次序
                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;
            }

    这样,无论两点的次序是顺线节点次序还是逆线节点次序,都不会出错了。
  • 相关阅读:
    <Redis> 入门六 主从复制方式的集群
    <Redis> 入门五 持久化RBD/AOF
    <Redis> 入门四 Jedis操作Redis
    <Redis> 入门三 事务
    <Redis> 入门X 分布式锁
    <Redis> 入门二 五种数据类型的操作、通用key的操作、发布订阅
    <Redis> 入门一 概念安装
    <Linux> 下安装和卸载JDK
    <ActiveMQ>
    <linux>入门
  • 原文地址:https://www.cnblogs.com/gisoracle/p/1542437.html
Copyright © 2011-2022 走看看