zoukankan      html  css  js  c++  java
  • ArcEngine获取曲线上任意两点间的距离 .

    在做垃圾桶服务能力检测功能时,需要求两个垃圾桶之间在道路上的实际距离,由于道路使用的是线要素,而考虑到采集数据的精度问题,我假设在地图上道路两边都有可能出现垃圾桶。所以求这个距离的确是个难题。后来想了很多种方法,都一一否定了。

    后来在论坛上看见一个帖子,他是使用的vb写的,被我改成c#了,其实也挺简单的,主要使用了IPolyline自带的QueryPointAndDistance方法,它能返回一个点至线的起始点的距离,然后通过这两个距离相减,就得到两点之间的距离了。

    ICurve.QueryPointAndDistance MethodFinds the point on the curve closest to inPoint, then copies that point to outPoint; optionally calculates related items。

             /// <summary>
            /// 得到两个垃圾桶在道路上的距离
            /// </summary>
            /// <param name="pnt1">垃圾桶1</param>
            /// <param name="pnt2">垃圾桶2</param>
            /// <param name="roadFeature">所在道路</param>
            /// <returns></returns>
            public double getDistanceOfTwoPoint(IPoint pnt1, IPoint pnt2, IFeature roadFeature)
            {
                double distanceOfpnt1 = distanceFromStartPoint(pnt1, roadFeature);
                double distanceOfpnt2 = distanceFromStartPoint(pnt2, roadFeature);
                return distanceOfpnt2 - distanceOfpnt1;
            }
            /// <summary>
            /// 垃圾桶到道路起点的距离
            /// </summary>
            /// <param name="pPoint"></param>
            /// <param name="pFeature"></param>
            /// <returns></returns>
            public double distanceFromStartPoint(IPoint pPoint, IFeature pFeature)
            {
                IPolyline pPolyline = pFeature.Shape as IPolyline;
                IPoint outPoint = new PointClass();
                double distanceAlongCurve = 0;//该点在曲线上最近的点距曲线起点的距离
                double distanceFromCurve = 0;//该点到曲线的直线距离
                bool bRightSide = false;
                pPolyline.QueryPointAndDistance(esriSegmentExtension.esriNoExtension, pPoint, false, outPoint, ref distanceAlongCurve, ref distanceFromCurve,ref bRightSide);
                return distanceAlongCurve;
            }

    来自http://hi.baidu.com/llinkin_park/blog/item/1200cb3cc5a15f3070cf6cb4.html
  • 相关阅读:
    mini2440 UBoot启动过程完全分析
    Linux Shell常用命令学习(1)
    S3C6410启动模式介绍
    漫画与新媒体的传播思考
    注册表修改启动项
    邮件主题是乱码的原因gbk 在utf8 显示问题
    移动 电话费 套餐
    java 异常的问题讨论
    领结的打法
    c# 字符之间的转换
  • 原文地址:https://www.cnblogs.com/gisoracle/p/2404145.html
Copyright © 2011-2022 走看看