gzstyxb
路人甲
路人甲
  • 注册日期2004-09-22
  • 发帖数358
  • QQ
  • 铜币1045枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1844回复:3

ISelectionPtr 接口问题

楼主#
更多 发布于:2007-11-05 15:45
<P ><FONT face="Times New Roman">       ISelectionPtr ipSelection;<p></p></FONT></P>
<P ><FONT face="Times New Roman">       IMapPtr ipMap = GetMapControlObject()->GetMap();<p></p></FONT></P>
<P ><FONT face="Times New Roman">       HRESULT result = ipMap->get_FeatureSelection(;ipSelection);<p></p></FONT></P>
<P ><FONT face="Times New Roman">       if (FAILED(result) || NULL == ipSelection) <p></p></FONT></P>
<P ><FONT face="Times New Roman">              return;<p></p></FONT></P>
<P ><FONT face="Times New Roman">       <p></p></FONT></P>
<P ><FONT face="Times New Roman">       IEnumFeaturePtr ipEnumFeature = ipSelection;<p></p></FONT></P>
<P ><FONT face="Times New Roman">       if (NULL == ipEnumFeature) <p></p></FONT></P>
<P ><FONT face="Times New Roman">              return;<p></p></FONT></P>
<P ><FONT face="Times New Roman">       <p></p></FONT></P>
<P ><FONT face="Times New Roman">       ipEnumFeature->Reset();<p></p></FONT></P>
<P ><FONT face="Times New Roman">       <p></p></FONT></P>
<P ><FONT face="Times New Roman">       IFeaturePtr ipFeature;<p></p></FONT></P>
<P ><FONT face="Times New Roman">       while (SUCCEEDED(ipEnumFeature->Next(;ipFeature))<p></p></FONT></P>
<P ><FONT face="Times New Roman">              ;; NULL != ipFeature) {<p></p></FONT></P>
<P ><FONT face="Times New Roman">              // </FONT>在这里查询属性<p></p></P>
<P ><FONT face="Times New Roman">       }     </FONT></P>
<P>以上代码,实现当前地图上选择的图形属性查询。现在遇到问题是,被选择的图形数量少的时候,没有任何问题。当图形数量多时候,属性查询统统返回NULL值,也就是无法正常查询属性。</P>
<P>有明白的,请指点指点故障出在那里。</P>
喜欢0 评分0
由爱故生忧, 由爱故生怖. 若离于爱者, 无忧亦无怖.
gzstyxb
路人甲
路人甲
  • 注册日期2004-09-22
  • 发帖数358
  • QQ
  • 铜币1045枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2007-11-05 16:21
<P>自己找到原因了。</P>
<P>Note, only the shape field is guaranteed with the selection. This is the default and exists for performance reasons. The IMap::FeatureSelection property is typically used to draw the map selection, not access feature attributes. This is particularly noticeable with shapefiles and coverage but also in geodatabases if the selection is large enough. Use <B><a>IEnumFeatureSetup::AllFields</A></B> to set a flag indicating all fields be returned with the selection. If you want to loop through the map selection to perform an operation, it is typically best to access each layer's selection rather than the entire map's selection. See the example for a sample of each.</P>
由爱故生忧, 由爱故生怖. 若离于爱者, 无忧亦无怖.
举报 回复(0) 喜欢(0)     评分
追风浪子
路人甲
路人甲
  • 注册日期2004-06-08
  • 发帖数166
  • QQ
  • 铜币782枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2007-11-05 19:59
举报 回复(0) 喜欢(0)     评分
追风浪子
路人甲
路人甲
  • 注册日期2004-06-08
  • 发帖数166
  • QQ
  • 铜币782枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2007-11-06 13:49

<P>一起讨论</P>
[此贴子已经被作者于2007-11-7 15:25:57编辑过]
举报 回复(0) 喜欢(0)     评分
游客

返回顶部