andrewr
路人甲
路人甲
  • 注册日期2005-02-21
  • 发帖数32
  • QQ
  • 铜币244枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:4015回复:19

selectfeature问题(急!)

楼主#
更多 发布于:2006-08-18 10:55
<P>以下是用鼠标选择feature的方法,当运行到selectfeature之后,在刷新时查看imap的selectioncount是0,是我的代码有问题吗??请大侠们指点一二!        </P>
<P>private void SelectByMouse(double mapX,double mapY)<BR>        {<BR>            IFeatureLayer editLayer = (IFeatureLayer)m_layer;<BR>            IFeatureClass featClass=editLayer.FeatureClass;</P>
<P>            IPoint pnt = new PointClass();<BR>            pnt.PutCoords(mapX, mapY);<BR>            IGeometry geom = (IGeometry)pnt;<BR>            ITopologicalOperator topoOper = (ITopologicalOperator)geom;<BR>            IGeometry buffGeom = topoOper.Buffer(20);<BR>            ISpatialFilter spatFilter = new SpatialFilterClass();<BR>            spatFilter.Geometry = buffGeom;</P>
<P>            switch (featClass.ShapeType)<BR>            { <BR>                case esriGeometryType.esriGeometryMultipoint:<BR>                case esriGeometryType.esriGeometryPoint:<BR>                    spatFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;<BR>                    break;<BR>                case esriGeometryType.esriGeometryPolyline:<BR>                    spatFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelCrosses;<BR>                    break;<BR>                case esriGeometryType.esriGeometryPolygon:<BR>                    spatFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;<BR>                    break;<BR>            }<BR>            spatFilter.GeometryField = featClass.ShapeFieldName;</P>
<P>            IQueryFilter filter = (IQueryFilter)spatFilter;<BR>            IFeatureCursor featCursor = editLayer.Search(filter, false);</P>
<P>            IFeature feat = featCursor.NextFeature();<BR>            if (feat == null)<BR>                return;<BR>            do<BR>            {<BR>                m_map.Map.SelectFeature((ILayer)editLayer, feat);<BR>                feat = featCursor.NextFeature();<BR>            }<BR>            while (feat != null);<BR>            IActiveView mapView = m_map.ActiveView;<BR>            mapView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);<BR>        }</P>
喜欢0 评分0
hsghxm
路人甲
路人甲
  • 注册日期2004-10-27
  • 发帖数517
  • QQ4604052
  • 铜币1枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2006-08-18 11:04

<P>该成这样试试</P>
<P>           IActiveView mapView = m_map.ActiveView;<BR></P>
<P>           if (feat == null)<BR>                return;<BR>            do<BR>            {<BR>               mapView .FocusMap.SelectFeature((ILayer)editLayer, feat);<BR>                feat = featCursor.NextFeature();<BR>            }<BR>            while (feat != null);<BR>            mapView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);<BR>        }</P>
MSN:hsghxm@163.com QQ:4604052 (很少用,最好别加) Email:hsghxm@163.com 我的BOLG:http://www.gisempire.com/blog/user1/864/index.htm
举报 回复(0) 喜欢(0)     评分
andrewr
路人甲
路人甲
  • 注册日期2005-02-21
  • 发帖数32
  • QQ
  • 铜币244枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2006-08-18 11:09
大侠,还是不行啊!!selectioncount还是0!!
举报 回复(0) 喜欢(0)     评分
hsghxm
路人甲
路人甲
  • 注册日期2004-10-27
  • 发帖数517
  • QQ4604052
  • 铜币1枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2006-08-18 11:12
<P>问楼主一个问题,在讨论的关于MXD连接数据源发生变化时候,MXD是否要一个一个设置的问题中,你说只要放在一个配置文件里就可以解决??请教一下,如果当前MXD连接的数据源已经关闭了,在配置文件里设置了另外一个服务器的IP,我该怎样去把原先MXD的层自动连接到新的服务器上??</P><img src="images/post/smile/dvbbs/em02.gif" />
MSN:hsghxm@163.com QQ:4604052 (很少用,最好别加) Email:hsghxm@163.com 我的BOLG:http://www.gisempire.com/blog/user1/864/index.htm
举报 回复(0) 喜欢(0)     评分
andrewr
路人甲
路人甲
  • 注册日期2005-02-21
  • 发帖数32
  • QQ
  • 铜币244枚
  • 威望0点
  • 贡献值0点
  • 银元0个
4楼#
发布于:2006-08-18 11:17
我没做过,但如果用配置文件的话,就应该不是加载mxd文件的了,用配置文件记录图层的显示方式和服务器的信息!
举报 回复(0) 喜欢(0)     评分
hsghxm
路人甲
路人甲
  • 注册日期2004-10-27
  • 发帖数517
  • QQ4604052
  • 铜币1枚
  • 威望0点
  • 贡献值0点
  • 银元0个
5楼#
发布于:2006-08-18 11:19
哦,我以为是加载MXD用配置文件的<img src="images/post/smile/dvbbs/em02.gif" />
MSN:hsghxm@163.com QQ:4604052 (很少用,最好别加) Email:hsghxm@163.com 我的BOLG:http://www.gisempire.com/blog/user1/864/index.htm
举报 回复(0) 喜欢(0)     评分
hsghxm
路人甲
路人甲
  • 注册日期2004-10-27
  • 发帖数517
  • QQ4604052
  • 铜币1枚
  • 威望0点
  • 贡献值0点
  • 银元0个
6楼#
发布于:2006-08-18 11:23
<P>selectioncount还是0?? 那我问你,在这执行完后地图上有被选种的东西吗?</P>
<P>这个代码:if (feat == null)<BR>                return;<BR>            do<BR>            {<BR>               mapView .FocusMap.SelectFeature((ILayer)editLayer, feat);<BR>                feat = featCursor.NextFeature();<BR>            }<BR>            while (feat != null);<BR>你跟过吗?共计循环了几次??</P>
MSN:hsghxm@163.com QQ:4604052 (很少用,最好别加) Email:hsghxm@163.com 我的BOLG:http://www.gisempire.com/blog/user1/864/index.htm
举报 回复(0) 喜欢(0)     评分
zjfsch
路人甲
路人甲
  • 注册日期2005-10-11
  • 发帖数12
  • QQ
  • 铜币150枚
  • 威望0点
  • 贡献值0点
  • 银元0个
7楼#
发布于:2006-08-18 11:24
<P>我以为应该这样:</P>
<P>spatFilter.Geometry = buffGeom.Envelope as IGeometry;</P>
<P>或者IGeometry buffGeom = topoOper.Buffer(20);<BR>中的20是否应该转换为地图坐标的单位</P>
举报 回复(0) 喜欢(0)     评分
hsghxm
路人甲
路人甲
  • 注册日期2004-10-27
  • 发帖数517
  • QQ4604052
  • 铜币1枚
  • 威望0点
  • 贡献值0点
  • 银元0个
8楼#
发布于:2006-08-18 11:29
20的话在经纬度下已经很大了,应该有选中的东西,先看看那个循环有没有执行,如没执行,那说明根本没选到东西,那就是其他代码的问题了,或者你点的点就没落到其他几何要素上
MSN:hsghxm@163.com QQ:4604052 (很少用,最好别加) Email:hsghxm@163.com 我的BOLG:http://www.gisempire.com/blog/user1/864/index.htm
举报 回复(0) 喜欢(0)     评分
andrewr
路人甲
路人甲
  • 注册日期2005-02-21
  • 发帖数32
  • QQ
  • 铜币244枚
  • 威望0点
  • 贡献值0点
  • 银元0个
9楼#
发布于:2006-08-18 11:30
<P>地图上没有选中的东西,循环走过一次,我的确选中一个feature,执行了selectfeature方法也没问题,但就没有选中显示,selectioncount位0!</P>
举报 回复(0) 喜欢(0)     评分
上一页
游客

返回顶部