There are two parts in total:
1. Method Overview
2. C # distance between the start point and the line segment
Part 1
Http://www.gispower.org/article/arcgis/ao/2008/122/081222025470KDK5965183CCA19ABJ5.html
We often need to calculate the distance between any two points on a linear geometric element (which can be a straight line iline, ipolympus, or icurve or iring. For a straight line, we only need to use the linear distance formula between two points to obtain it, but for the curve, AE does not provide the method and attribute for direct acquisition. After the experiment, I found a method for finding any one or two points on the curve and shared it with you, hoping to improve it together.
Method 1:
In AE, there is a method querypointanddistance (icurve as an example). Through this method, we can obtain the distance between the last point of space and the closest point on the curve and the data starting point. In this way, we can use this method to transfer the points in the space to the two points at the required distance, that is to say, we regard the two points on the curve for distance as any two points in space. The querypointanddistance method is used to obtain the distance between the two closest points on the curve and the two data starting points.
* Note *: in fact, the last two points we get are actually the two points that require distance.
Assume that PTB is a two-point PTA on the curve, and the calculated distance is dispta and disptb.
Dispta-disptb is the distance between the two points on the curve we want to obtain.
Dim outpt1 as ipoint
Set outpt1 = new point
Dim disalong1 as double
Dim dis1 as double
Pcurve. querypointanddistance esriextendtangentatfrom, pt1, false, outpt1, disalong1, dis1, false
Dim outpt2 as ipoint
Set outpt2 = new point
Dim disalong2 as double
Dim dis2 as double
Pcurve. querypointanddistance esriextendtangentatfrom, pt2, false, outpt2, disalong2, dis2, false
''Curve Distance between two points
Resultdis = disalong2-disalong2
Method 2:
Another method is to use the getsubcurve method to crop A subcurve curve between the two points on the curve, and then use the length method of the icurve interface to obtain it directly. However, this method is difficult to implement.
Method 3:
If we want to query the two points on the distance, then we can use the distancealongcurve method under the ienumpointanddistance interface to directly obtain the distance from a point to the reference point (the reference point is generally the starting point of the curve frompoint ), then, subtract the obtained two distances to obtain the Curve Distance between two points.
Note: This method must be available only for nodes.
Part 2
Http://hi.baidu.com/llinkin_park/blog/item/1200cb3cc5a15f3070cf6cb4.html
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;
Bool asratio = false; // asratio: byval mode, bool type, indicating whether the length given by the preceding two parameters is given in absolute distance or proportion to the total length of the curve
Ppolyline. querypointanddistance (esrisegmentextension. esrinoextension, Ppoint, asratio, outpoint, ref distancealongcurve, ref distancefromcurve, ref Brightside );
Return distancealongcurve;
}