andy00031
路人甲
路人甲
  • 注册日期2005-01-28
  • 发帖数8
  • QQ
  • 铜币129枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:2064回复:2

求助:判断点和多边形的关系(包含与否)

楼主#
更多 发布于:2006-10-31 20:44
<P>怎么判断一个点和多边形的关系啊?</P>
<P>我在AE里面找了个例子,</P>
<P>Dim pBase As ISegmentCollection <BR>   Dim pComparison As ISegmentCollection <BR>   Set pBase = New Polyline <BR>   Set pComparison = New Polyline <BR>   Dim pRelOp As IRelationalOperator <BR>   Set pRelOp = pBase <BR>   Dim pBaseGeom As IGeometry <BR>   Dim pCompGeom As IGeometry <BR>   Set pBaseGeom = pBase <BR>   Set pCompGeom = pComparison <BR>'Example of Contains <BR>   pPoints(0).PutCoords 20, 20 <BR>   pPoints(1).PutCoords 80, 80 <BR>   pLine2.PutCoords pPoints(0), pPoints(1) <BR>   <BR>   pBase.AddSegment pLine1          '(0,0) to (100,100) <BR>   pComparison.AddSegment pLine2    '(20,20) to (80,80) <BR>   <BR>   If pRelOp.Contains(pComparison) Then <BR>      MsgBox "Contained" <BR>   Else <BR>      MsgBox "Not Contained" <BR>   End If <BR>   <BR>   pBaseGeom.SetEmpty <BR>   pCompGeom.SetEmpty </P>
<P>是判断线与线之间的关系的,改成点和多边形之后提示类型不匹配,而按照说明应该是可以判断点和多边形关系的</P>
<P>各位大侠有没有做过这东东???<BR></P><img src="images/post/smile/dvbbs/em03.gif" />
喜欢0 评分0
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2006-11-01 10:52
<P>这个函数可以完成你的判断</P><PRE>Function IsPointIn(pPolygon As IPolygon, pPoint As IPoint) As Boolean
    ' assumes projections of point and polygon match
    Dim pRelOp As IRelationalOperator
    Set pRelOp = pPolygon
    IsPointIn = pRelOp.Contains(pPoint)
End Function
</PRE>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
andy00031
路人甲
路人甲
  • 注册日期2005-01-28
  • 发帖数8
  • QQ
  • 铜币129枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2006-11-02 11:26
<P>谢谢GIS大侠,我试试看··`~~~~</P>
举报 回复(0) 喜欢(0)     评分
游客

返回顶部