• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
静水流深cherry
博客园    首页    新随笔    联系   管理    订阅  订阅

AO中用点选的方式选择点、线、面等(转)

AO中用点选的方式选择点、线、面等

void CWzjGISView:ointSelect(double mapX, double mapY)//这个函数用于点选择
...{
     IMapPtr ipMap;
     ipMap=m_MapControl.GetMap();
    //获取点图层
     IFeatureLayerPtr ipFeatlyr;
     ILayerPtr ipLayer;
     ipMap->get_Layer(0,&ipLayer);
     ipFeatlyr=ipLayer;
    //获取鼠标点击点
     IPointPtr ipPoint(CLSID_Point);
     ipPoint->PutCoords(mapX,mapY);
     IGeometryPtr ipGeometry;
     ipGeometry=ipPoint;
     IFeatureClassPtr ipFeatClass;
     ipFeatlyr->get_FeatureClass(&ipFeatClass);
     ITopologicalOperatorPtr ipTopo;
     ipTopo=ipGeometry;
    //设定缓冲区距离
    double length;
     length=ConvertPixelToMapUnits(ipMap,5);
    //得到缓冲区多边形pBuffer:
     IGeometryPtr ipBuffer;
     ipTopo->Buffer(length,&ipBuffer);
    //得到缓冲区的包络线
//     ipBuffer->get_Envelope(&ipGeometry);
     IEnvelopePtr ipGeoEnv;
     ipBuffer->get_Envelope(&ipGeoEnv);
     ipGeometry = ipGeoEnv;
//     ipGeometry->
   
     ISpatialFilterPtr ipSpatialFilter(CLSID_SpatialFilter);
     ipSpatialFilter->putref_Geometry(ipGeometry);
     esriGeometryType Type;
     ipFeatClass->get_ShapeType(&Type);
    switch(Type)
    ...{
        case esriGeometryPoint:
         ipSpatialFilter->put_SpatialRel(esriSpatialRelContains);
        break;
    case esriGeometryPolyline:
         ipSpatialFilter->put_SpatialRel(esriSpatialRelCrosses);
        break;
    case esriGeometryPolygon:
         ipSpatialFilter->put_SpatialRel(esriSpatialRelIntersects);
    default:
        break;
     }
     BSTR bstrshfName;
     ipFeatClass->get_ShapeFieldName(&bstrshfName);
     ipSpatialFilter->put_GeometryField(bstrshfName);
     IFeatureCursorPtr ipCursor;
     ipFeatClass->Search(ipSpatialFilter,false,&ipCursor);
   
    /**//*
     得到空间过滤运算的结果要素
    */
//         IFeaturePtr m_ipFea;
     ipCursor->NextFeature(&m_ipFea);
   
    //下面把选择到的要素显示出来
   
     IRgbColorPtr ipColor(CLSID_RgbColor);
     ipColor->put_Blue(145);
     ipColor->put_Red(110);
     ipColor->put_Green(120);
     ISimpleMarkerSymbolPtr ipMarkSym(CLSID_SimpleMarkerSymbol);
     ipMarkSym->put_Style(esriSMSCircle);
     ipMarkSym->put_OutlineSize(10);
     ipMarkSym->put_OutlineColor(ipColor);
     ISymbolPtr ipSymbol;
     ipSymbol=ipMarkSym;
    if (m_ipFea)
    ...{
         m_ipFea->get_Shape(&shape);
         ipMap->SelectFeature(ipFeatlyr,m_ipFea);            
         vSym = ipSymbol;
        
         ipCursor->NextFeature(&m_ipFea);
     }
     IActiveViewPtr ipActView = m_MapControl.GetActiveView();
     ipActView->Refresh();
}
posted @ 2009-12-16 11:05  静水流深cherry  阅读(701)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3