日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ArcGISEngine二次开发(4):属性查询(2)

發布時間:2024/3/26 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ArcGISEngine二次开发(4):属性查询(2) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

屬性查詢(2)

使用IGeometry接口TrackPolygon方法建立對象實現屬性查詢
使用ISpatialFilter接口SpatialRel屬性定義Intersects取交集為查詢對象
之后將查詢到的(FindField方法)屬性顯示在新的windowsform中的listbox中顯示屬性字段
單擊Listbox中的屬性字段,地圖高亮顯示對應多邊形


添加引用:

using System; using System.Collections.Generic; using System.Linq; using System.Text; using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.SystemUI; using ESRI.ArcGIS.esriSystem; using ESRI.ArcGIS.Controls; using ESRI.ArcGIS.Geometry; using ESRI.ArcGIS.Geodatabase; using ESRI.ArcGIS.DataSourcesFile;

添加ToolTripButton,添加Click事件代碼如下

ICommand spatialqueryintersect = new spatialquery(); spatialqueryintersect.OnCreate(axMapControl1.Object); spatialqueryintersect.OnClick(); ITool ptool = spatialqueryintersect as ITool; axMapControl1.CurrentTool = ptool;



新建windowsform窗體,并在里邊添加Listbox,Modifiers屬性Public,否則在其他窗體的事件代碼中不能檢測到該控件,事件代碼如下

//定義全局變量 public IMapControlDefault spaqury;//必須添加public關鍵字,因為要從新建的類中傳來Imapcontrol對象 //private void listBox1_Click(object sender, EventArgs e){IFeatureLayer pFeatureLayer = spaqury.get_Layer(0) as IFeatureLayer;IQueryFilter pqueryfilter = new QueryFilterClass();pqueryfilter.SubFields = "*";pqueryfilter.WhereClause = "NAME" + "=" + "'" + this.listBox1.SelectedItem.ToString() + "'";IFeatureCursor pfeaturecursor = pFeatureLayer.Search(pqueryfilter, false);IFeature pfeature = pfeaturecursor.NextFeature();spaqury.FlashShape(pfeature.Shape, 3, 500, null);return; }

新建類庫,手動實現Icommand,ITool 接口,定義全局變量:

IMapControlDefault m_app; //Onclick函數設為空,因為單擊Button沒有立刻開始畫多邊形,而是在單擊axmapcontrol對象以后開始畫 public void OnClick(){} //傳入ImapControl對象 public void OnCreate(object Hook){m_app = Hook as IMapControlDefault;} //其他接口置為空 public void OnMouseDown(int button, int shift, int x, int y){IGeometry pGeometry = m_app.TrackPolygon();IFeatureLayer pfeatureLayer = m_app.get_Layer(0) as IFeatureLayer;ISpatialFilter pSpatialfilter =new SpatialFilterClass();pSpatialfilter.SubFields="*";pSpatialfilter.GeometryField="shape";//所畫圖形類型pSpatialfilter.Geometry=pGeometry;pSpatialfilter.SpatialRel=esriSpatialRelEnum.esriSpatialRelIntersects;//空間交集IFeatureCursor pfeaturecursor = pfeatureLayer.Search(pSpatialfilter, false);IFeature pfeature = pfeaturecursor.NextFeature();int ifname = pfeaturecursor.FindField("NAME");//屬性查詢字段SpatialQueryListBox listboxwindows = new SpatialQueryListBox();//SpatialQueryListBox為新建的windowsform窗體listboxwindows.spaqury = m_app;//該窗體中的全局變量while (pfeature != null){listboxwindows.listBox1.Items.Add(pfeature.get_Value(ifname).ToString());m_app.FlashShape(pfeature.Shape, 3, 500, null);pfeature = pfeaturecursor.NextFeature();}listboxwindows.Show();}

總結

以上是生活随笔為你收集整理的ArcGISEngine二次开发(4):属性查询(2)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。