阅读:1581回复:2
[求助]Engine中如何获取一条线上任意两点的距离
<P>是线上的距离。</P>
|
|
1楼#
发布于:2005-07-14 13:43
<PRE><FONT face=宋体>这个代码可以实现哈</FONT></PRE><PRE><FONT face=宋体>Public Function GetPointSide(pPolyline As IPolyline, pPoint As IPoint) As Boolean</FONT></PRE><PRE><FONT face=宋体> Dim pCurve As ICurve</FONT></PRE><PRE><FONT face=宋体> Dim outPoint As IPoint</FONT></PRE><PRE><FONT face=宋体> Dim dAlong As Double, dFrom As Double</FONT></PRE><PRE><FONT face=宋体> Dim bRight As Boolean</FONT></PRE><PRE><FONT face=宋体> On Error GoTo EH</FONT></PRE><PRE><FONT face=宋体> Set pCurve = pPolyline</FONT></PRE><PRE><FONT face=宋体> pCurve.QueryPointAndDistance 0, pPoint, False, outPoint, dAlong, dFrom, bRight</FONT></PRE><PRE><FONT face=宋体> GetPointSide = bRight</FONT></PRE><PRE><FONT face=宋体> Set pCurve = Nothing</FONT></PRE><PRE><FONT face=宋体> Set outPoint = Nothing</FONT></PRE><PRE><FONT face=宋体> Exit Function</FONT></PRE><PRE><FONT face=宋体>EH:</FONT></PRE><PRE><FONT face=宋体> MsgBox Err.Description</FONT></PRE><PRE><FONT face=宋体>End Function</FONT></PRE><PRE><p><FONT face=宋体> </FONT></p></PRE><PRE><FONT face=宋体>Sub test()</FONT></PRE><PRE><FONT face=宋体> Dim pCol As IPointCollection</FONT></PRE><PRE><FONT face=宋体> Dim pPolyline As IPolyline</FONT></PRE><PRE><FONT face=宋体> Dim pPoint As IPoint</FONT></PRE><PRE><FONT face=宋体> Dim i As Long</FONT></PRE><PRE><FONT face=宋体> Dim dLength As Double</FONT></PRE><PRE><FONT face=宋体> Dim dMaxLength As Double</FONT></PRE><PRE><FONT face=宋体> dMaxLength = 0</FONT></PRE><PRE><FONT face=宋体> For i = 0 To pCol.PointCount - 1</FONT></PRE><PRE><FONT face=宋体> Set pPoint = pCol.Point(i)</FONT></PRE><PRE><FONT face=宋体> dLength = GetPointPosition(pPolyline, pPoint)</FONT></PRE><PRE><FONT face=宋体> If dLength > dMaxLength Then</FONT></PRE><PRE><FONT face=宋体> dMaxLength = dLength</FONT></PRE><PRE><FONT face=宋体> End If</FONT></PRE><PRE><FONT face=宋体> Next i</FONT></PRE><PRE><FONT face=宋体>End sub</FONT></PRE><PRE><p><FONT face=宋体> </FONT></p></PRE>
|
|
|
2楼#
发布于:2005-07-12 09:54
<P>Call ICurve.QueryPointAndDistance on the curve using each of the two points. One of the values returned by QueryPointAndDistance is distanceAlongCurve. The absolute value of the difference between these two distances is the length along the curve between the two points. </P>
<P><IMG src="http://forums.esri.com/Attachments/5095.jpg"><BR></P> |
|
|