areson
路人甲
路人甲
  • 注册日期2005-03-13
  • 发帖数8
  • QQ
  • 铜币119枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1581回复:2

[求助]Engine中如何获取一条线上任意两点的距离

楼主#
更多 发布于:2005-07-11 20:16
<P>是线上的距离。</P>
喜欢0 评分0
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
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>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
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>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
游客

返回顶部