阅读:1568回复:1
[求助]〔求助〕关于AO中的SpatialFilter问题!!!!!!!!!
<DIV ><FONT size=4><FONT color=sienna> 我现在在做VBA+AO的开发,现在要完成一个功能是这样的:选择地图上已经存在的一个多边形,点击工具栏上的按钮就可以统计出这个多边形内的所有要素。我知道自己画多边形或矩形来选择其中的设备是将所画的多边形作为一个SpatialFilter对象,然后用IFeatureSelection接口的SelectFeatures方法来选择要素。不知道对于地图上已经存在的多边形用什么语句可以将它作为一个SpatialFilter,也用同样的方法来选择它。还是要用其他的方法,请高手指点,不胜感激!!!!</FONT></FONT></DIV>
|
|
1楼#
发布于:2007-06-09 11:21
<P>获取到你画的矩形或者多边形,然后仿照下面的方法就行了</P>
<P>The following code excerpt shows how to get a reference to an ISpatialFilter interface, set the necessary values and execute the search.</P> <P>NOTE: All three of the ISpatialFilter methods Geometry, GeometryField and SpatialEnum are required.</P> <P>Create a point to use for the search:</P><PRE><CODE> Dim pPoint As IPoint Set pPoint = New esriGeometry.Point pPoint.PutCoords -117.946, 35.823</PRE></CODE> <P>Getting a reference:</P><CODE><PRE> Dim pFilter As IspatialFilter Set pFilter = New SpatialFilter </PRE></CODE> <P>Setting the Geometry, GeometryField and SpatialRel parameters:</P><CODE><PRE> With pFilter Set .Geometry = pPoint .GeometryField = "SHAPE" .SpatialRel = esriSpatialRelIntersects End With </PRE></CODE> <P>Execute the filter:</P><CODE><PRE> Dim pFeatureCursor As IfeatureCursor Set pFeatureCursor = pFeatureClass.Search(pFilter, False) </PRE></CODE> |
|
|