gisempire100
捉鬼专家
捉鬼专家
  • 注册日期2004-08-13
  • 发帖数552
  • QQ
  • 铜币2462枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1492回复:0

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

楼主#
更多 发布于:2009-12-16 21:52
AO中用点选的方式选择点、线、面等<br><br>void CWzjGISView:<img alt="" src="http://bbs.esrichina-bj.cn/ESRI/images/smilies/default/tongue.gif" smilieid="8" border="0">ointSelect(double mapX, double mapY)//这个函数用于点选择<br>...{<br>     IMapPtr ipMap;<br>     ipMap=m_MapControl.GetMap();<br>    //获取点图层<br>     IFeatureLayerPtr ipFeatlyr;<br>     ILayerPtr ipLayer;<br>     ipMap->get_Layer(0,;ipLayer);<br>     ipFeatlyr=ipLayer;<br>    //获取鼠标点击点<br>     IPointPtr ipPoint(CLSID_Point);<br>     ipPoint->PutCoords(mapX,mapY);<br>     IGeometryPtr ipGeometry;<br>     ipGeometry=ipPoint;<br>     IFeatureClassPtr ipFeatClass;<br>     ipFeatlyr->get_FeatureClass(;ipFeatClass);<br>     ITopologicalOperatorPtr ipTopo;<br>     ipTopo=ipGeometry;<br>    //设定缓冲区距离<br>    double length;<br>     length=ConvertPixelToMapUnits(ipMap,5);<br>    //得到缓冲区多边形pBuffer:<br>     IGeometryPtr ipBuffer;<br>     ipTopo->Buffer(length,;ipBuffer);<br>    //得到缓冲区的包络线<br>//     ipBuffer->get_Envelope(;ipGeometry);<br>     IEnvelopePtr ipGeoEnv;<br>     ipBuffer->get_Envelope(;ipGeoEnv);<br>     ipGeometry = ipGeoEnv;<br>//     ipGeometry-><br>    <br>     ISpatialFilterPtr ipSpatialFilter(CLSID_SpatialFilter);<br>     ipSpatialFilter->putref_Geometry(ipGeometry);<br>     esriGeometryType Type;<br>     ipFeatClass->get_ShapeType(;Type);<br>    switch(Type) <br>    ...{<br>        case esriGeometryPoint:<br>         ipSpatialFilter->put_SpatialRel(esriSpatialRelContains);<br>        break;<br>    case esriGeometryPolyline:<br>         ipSpatialFilter->put_SpatialRel(esriSpatialRelCrosses);<br>        break;<br>    case esriGeometryPolygon:<br>         ipSpatialFilter->put_SpatialRel(esriSpatialRelIntersects);<br>    default:<br>        break;<br>     }<br>     BSTR bstrshfName;<br>     ipFeatClass->get_ShapeFieldName(;bstrshfName);<br>     ipSpatialFilter->put_GeometryField(bstrshfName);<br>     IFeatureCursorPtr ipCursor;<br>     ipFeatClass->Search(ipSpatialFilter,false,;ipCursor);<br>    <br>    /**//*<br>     得到空间过滤运算的结果要素<br>    */<br>//         IFeaturePtr m_ipFea;<br>     ipCursor->NextFeature(;m_ipFea);<br>    <br>    //下面把选择到的要素显示出来<br>    <br>     IRgbColorPtr ipColor(CLSID_RgbColor);<br>     ipColor->put_Blue(145);<br>     ipColor->put_Red(110);<br>     ipColor->put_Green(120);<br>     ISimpleMarkerSymbolPtr ipMarkSym(CLSID_SimpleMarkerSymbol);<br>     ipMarkSym->put_Style(esriSMSCircle);<br>     ipMarkSym->put_OutlineSize(10);<br>     ipMarkSym->put_OutlineColor(ipColor);<br>     ISymbolPtr ipSymbol;<br>     ipSymbol=ipMarkSym;<br>    if (m_ipFea) <br>    ...{<br>         m_ipFea->get_Shape(;shape);<br>         ipMap->SelectFeature(ipFeatlyr,m_ipFea);            <br>         vSym = ipSymbol;<br>        <br>         ipCursor->NextFeature(;m_ipFea);<br>     }<br>     IActiveViewPtr ipActView = m_MapControl.GetActiveView();<br>     ipActView->Refresh();<br>}
喜欢0 评分0
A friend is never known till a man has need. ...CL
游客

返回顶部