Arcengine obtains the distance between any two points on the curve.

Source: Internet
Author: User

The actual distance between two waste bins on the road is required for the waste bin service capability detection function. Because the road uses a line element, considering the precision of the collected data, I suppose there may be garbage bins on both sides of the road on the map. Therefore, finding this distance is indeed a difficult problem. Later, I thought about many methods, all of which were negated one by one.

Later, I saw a post on the Forum. It was written in VB and changed to C #. In fact, it was quite simple. I mainly used the querypointanddistance method that came with ipolympus, it returns the distance from the starting point to the line, and then subtract the two distances to obtain the distance between the two points.

Icurve. querypointanddistance method: finds the point on the curve closest to inpoint, then copies that point to outpoint; optionally calculates related items.

/// <Summary>
/// Get the distance between two waste bins on the road
/// </Summary>
/// <Param name = "pnt1"> waste bin 1 </param>
/// <Param name = "pnt2"> waste bin 2 </param>
/// <Param name = "roadfeature"> path </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>
/// Distance from the waste bin to the road start point
/// </Summary>
/// <Param name = "Ppoint"> </param>
/// <Param name = "pfeature"> </param>
/// <Returns> </returns>
Public double distancefromstartpoint (ipoint Ppoint, ifeature pfeature)
{
Ipolympus line ppolyline = pfeature. Shape as ipolympus line;
Ipoint outpoint = new pointclass ();
Double distancealongcurve = 0; // distance between the point closest to the curve and the starting point of the curve
Double distancefromcurve = 0; // The linear distance from this point to the curve
Bool Brightside = false;
Ppolyline. querypointanddistance (esrisegmentextension. esrinoextension, Ppoint, false, outpoint, ref distancealongcurve, ref distancefromcurve, ref Brightside );
Return distancealongcurve;
}

From http://hi.baidu.com/llinkin_park/blog/item/1200cb3cc5a15f3070cf6cb4.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.