项目里用到的一些基本的AE开发功能:

项目里用到的一些基本的AE开发功能:

//返回指定距离打断线之后的打断点
        public static IPoint BreakPoint(IPolyline iPolyline, double interv)
        {
            if (iPolyline.Length <= interv)
            {
                return null;
            }
            IPoint p = new PointClass();
            bool isSplit;
            int splitIndex, segIndex;
            object o = Type.Missing;
            ESRI.ArcGIS.esriSystem.IClone pl = (iPolyline as ESRI.ArcGIS.esriSystem.IClone).Clone();
            (pl as IPolyline).SplitAtDistance(interv, false, false, out isSplit, out splitIndex, out segIndex);
            
            if (isSplit)
            {
                IPolyline frontLine = new PolylineClass();
                ISegmentCollection lineSegCol = (ISegmentCollection)pl;
                lineSegCol.RemoveSegments(segIndex, lineSegCol.SegmentCount - segIndex, true);
                lineSegCol.SegmentsChanged();
                frontLine = lineSegCol as IPolyline;
                p = frontLine.ToPoint;
            }
            return p;
        }


//将一条线以间隔距离interv分割为N等分
<span style="font-family: Arial, Helvetica, sans-serif;">public static List<IPolyline> DivideLine2NParts(IPolyline iPolyline, double interv)</span>
        {
            if (iPolyline.Length < interv)
            {
                return null;
            }

            ISegmentCollection tmpLineSegCol = (ISegmentCollection)iPolyline;
            int num = (int)Math.Ceiling(iPolyline.Length / interv);
            List<IPolyline> list = new List<IPolyline>();
            
            for (int i = 0; i < num - 1; i++)
            {
                bool isSplit;
                int splitIndex, segIndex;
                object o = Type.Missing;
                iPolyline.SplitAtDistance(interv, false, false, out isSplit, out splitIndex, out segIndex);

                if (isSplit)
                {
                    IPolyline frontLine = new PolylineClass();
                    IPolyline backLine = new PolylineClass();
                    ISegmentCollection lineSegCol = (ISegmentCollection)iPolyline;
                    ISegmentCollection backSegCol = (ISegmentCollection)backLine;
                    for (int j = segIndex; j < lineSegCol.SegmentCount; j++)
                    {
                        backSegCol.AddSegment(lineSegCol.get_Segment(j), ref o, ref o);
                    }

                    backSegCol.SegmentsChanged();
                    lineSegCol.RemoveSegments(segIndex, lineSegCol.SegmentCount - segIndex, true);
                    lineSegCol.SegmentsChanged();
                    frontLine = lineSegCol as IPolyline;
                    backLine = backSegCol as IPolyline;
                    list.Add(frontLine);
                    iPolyline = backLine;
                }      
            }
            list.Add(iPolyline);
            iPolyline = tmpLineSegCol as IPolyline;
            return list;
        }

//计算指定点到线之间的最小距离
        public static double MinDistance(IPolyline iPolyline, IPoint iPoint)
        {
            double minDist = 0;
            if (iPoint!=null && !iPoint.IsEmpty)
            {
                IPoint outPoint = new PointClass();
                double distAlongCurveFrom = 0;
                double distFromCurve = 0;
                bool isRightSide = false;
                iPolyline.QueryPointAndDistance(esriSegmentExtension.esriNoExtension, iPoint,
                    false, outPoint, ref distAlongCurveFrom, ref distFromCurve, ref isRightSide);
                minDist = distFromCurve;
            }
            return minDist;
        }

//获取两条线要素交点
        public static IPointCollection GetIntersectPoint(IPolyline iPolyline1, IPolyline iPolyline2)
        {
            IPointCollection pPC = null;
            ITopologicalOperator topoOperator = iPolyline1 as ITopologicalOperator;
            IGeometry geo = topoOperator.Intersect(iPolyline2, esriGeometryDimension.esriGeometry0Dimension);
            if (!geo.IsEmpty)
            {
                IPointCollection pc = geo as IPointCollection;
                pPC = pc;
            }
            return pPC;
        }


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值