![開源SharpMap實(shí)例講解(三)剖析課件_第1頁](http://file4.renrendoc.com/view/6450f99aca7be8ce3e8d6b3b50673eb5/6450f99aca7be8ce3e8d6b3b50673eb51.gif)
![開源SharpMap實(shí)例講解(三)剖析課件_第2頁](http://file4.renrendoc.com/view/6450f99aca7be8ce3e8d6b3b50673eb5/6450f99aca7be8ce3e8d6b3b50673eb52.gif)
![開源SharpMap實(shí)例講解(三)剖析課件_第3頁](http://file4.renrendoc.com/view/6450f99aca7be8ce3e8d6b3b50673eb5/6450f99aca7be8ce3e8d6b3b50673eb53.gif)
![開源SharpMap實(shí)例講解(三)剖析課件_第4頁](http://file4.renrendoc.com/view/6450f99aca7be8ce3e8d6b3b50673eb5/6450f99aca7be8ce3e8d6b3b50673eb54.gif)
![開源SharpMap實(shí)例講解(三)剖析課件_第5頁](http://file4.renrendoc.com/view/6450f99aca7be8ce3e8d6b3b50673eb5/6450f99aca7be8ce3e8d6b3b50673eb55.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、開源SharpMap實(shí)例講解(三)要素查詢實(shí)例一:拉框查詢要素屬性實(shí)例二:點(diǎn)擊查詢要素屬性實(shí)例三:屬性查詢實(shí)例一:拉框查詢要素屬性代碼剖析1、單擊事件中調(diào)用代碼2、QueryMapByClick函數(shù)3、ExecuteIntersectionQuery函數(shù)41、單擊事件中調(diào)用代碼在 圖形的ImgMap_Click事件單擊,查詢要素屬性,所調(diào)用的代碼SharpMap.Geometries.Point ClickPnt = myMap.ImageToWorld(new System.Drawing.Point(e.X, e.Y);SharpMap.Data.FeatureDataSet dsResu
2、lt; dsResult = QueryMapByClick(ClickPnt2, ClickPnt); if (dsResult.Tables.Count 0) SessionTHETABLE = dsResult; SessionTABLENUM = 1; string strNames = ;/如何獲取選中要素的屬性數(shù)據(jù) foreach (DataRow dr in dsResult.Tables0.Rows) strNames = strNames + dr0.ToString() + ,; .1、單擊事件中調(diào)用代碼./打開顯示站點(diǎn)屬性的頁面if (strNames.Length 0)
3、 strNames = strNames.Substring(0, strNames.Length - 1); string strURL = StationInfo.aspx?StationName= + strNames; string strPage = window.open( + strURL + ,站點(diǎn)屬性,height=450,width=470,status=no,toolbar=no,menubar=no,scrollbars=yes,location=no); Response.Write(strPage); 1、單擊事件中調(diào)用代碼 /將選中的要素產(chǎn)生一個(gè)新的圖層,高亮度顯
4、示 SharpMap.Layers.VectorLayer laySelected = new SharpMap.Layers.VectorLayer(Selection); SharpMap.Data.Providers.GeometryProvider objGeoPrd = new SharpMap.Data.Providers.GeometryProvider(dsResult.Tables0); laySelected.DataSource = objGeoPrd; laySelected.Style.Symbol = new Bitmap(HttpContext.Current.S
5、erver.MapPath(App_dataStation2.bmp); laySelected.Style.SymbolScale = 0.8f; myMap.Layers.Add(laySelected);/刷新地圖 注意需重點(diǎn)掌握 QueryMapByClick函數(shù) 如何提取查詢結(jié)果信息 foreach (DataRow dr in dsResult.Tables0.Rows) 如何構(gòu)建新的選擇集圖層,并設(shè)置符號(hào),高亮度顯示2、QueryMapByClick函數(shù)private SharpMap.Data.FeatureDataSet QueryMapByClick(SharpMap.Ge
6、ometries.Point clickPoint1, SharpMap.Geometries.Point clickPoint2) SharpMap.Data.FeatureDataSet ds = new SharpMap.Data.FeatureDataSet(); SharpMap.Geometries.BoundingBox objBounds; if (clickPoint1.X != clickPoint2.X) objBounds = new SharpMap.Geometries.BoundingBox(clickPoint1.X, clickPoint1.Y, clickP
7、oint2.X, clickPoint2.Y); else objBounds = new SharpMap.Geometries.BoundingBox(clickPoint1.X - 0.01, clickPoint1.Y - 0.01, clickPoint1.X + 0.01, clickPoint1.Y + 0.01); 2、QueryMapByClick函數(shù). /Execute click-query on first layer in layers collection SharpMap.Layers.VectorLayer objVLyr = myMap.Layers站點(diǎn) as
8、 SharpMap.Layers.VectorLayer; if (!objVLyr.DataSource.IsOpen) objVLyr.DataSource.Open(); objVLyr.DataSource.ExecuteIntersectionQuery(objBounds, ds); if (ds.Tables.Count 0) /We have a result return ds; 3、ExecuteIntersectionQuery函數(shù) public void ExecuteIntersectionQuery(SharpMap.Geometries.BoundingBox b
9、ox, FeatureDataSet ds) FeatureDataTable fdt = new FeatureDataTable(); fdt = _features.Clone(); foreach (FeatureDataRow fdr in _features) if (fdr.Geometry.GetBoundingBox().Intersects(box) fdt.LoadDataRow(fdr.ItemArray, false); (fdt.Rowsfdt.Rows.Count - 1 as FeatureDataRow).Geometry = fdr.Geometry; ds
10、.Tables.Add(fdt); /private FeatureDataTable _features;ExecuteIntersectionQuery函數(shù)為sharpmap內(nèi)部函數(shù),僅需了解實(shí)例二:點(diǎn)擊查詢要素屬性代碼剖析1、單擊事件中調(diào)用代碼2、QueryMapByClick函數(shù)3、ExecuteIntersectionQuery函數(shù) if (rblMapTools.SelectedValue = 3) SharpMap.Geometries.Point ClickPnt = myMap.ImageToWorld(new System.Drawing.Point(e.X, e.Y);
11、SharpMap.Data.FeatureDataSet dsResult; dsResult = QueryMapByClick(ClickPnt); if (dsResult.Tables.Count 0) lblProperty.Text = ; foreach (System.Data.DataRow dr in dsResult.Tables0.Rows) lblProperty.Text += 屬性:; for (int i = 0; i dsResult.Tables0.Columns.Count; i+) lblProperty.Text += + dsResult.Table
12、s0.Columnsi.ColumnName; lblProperty.Text += + dri.ToString() + ; lblProperty.Text += ; lblProperty.Visible = true; 1、單擊事件中調(diào)用代碼在 圖形的ImgMap_Click事件單擊,查詢要素屬性,所調(diào)用的代碼。 for (int i = 0; i dsResult.Tables0.Columns.Count; i+) lblProperty.Text += + dsResult.Tables0.Columnsi.ColumnName; lblProperty.Text += + d
13、ri.ToString() + ; lblProperty.Text += ; lblProperty.Visible = true; 1、單擊事件中調(diào)用代碼在 圖形的ImgMap_Click事件單擊,查詢要素屬性,所調(diào)用的代碼2、QueryMapByClick函數(shù)private SharpMap.Data.FeatureDataSet QueryMapByClick(SharpMap.Geometries.Point clickPoint) SharpMap.Data.FeatureDataSet ds = new SharpMap.Data.FeatureDataSet(); SharpM
14、ap.Layers.VectorLayer objVLyr = myMap.Layers0 as SharpMap.Layers.VectorLayer; if (!objVLyr.DataSource.IsOpen) objVLyr.DataSource.Open(); SharpMap.Geometries.BoundingBox objBounds = new SharpMap.Geometries.BoundingBox(clickPoint.X - 0.01, clickPoint.Y - 0.01, clickPoint.X + 0.01, clickPoint.Y + 0.01)
15、; objVLyr.DataSource.ExecuteIntersectionQuery(objBounds, ds); / objVLyr.DataSource.ExecuteIntersectionQuery(clickPoint, ds); if (ds.Tables.Count 0) /We have a result /Add clicked features to a new selection layer SharpMap.Layers.VectorLayer laySelected = new SharpMap.Layers.VectorLayer(Selection); l
16、aySelected.DataSource = new SharpMap.Data.Providers.GeometryProvider(ds.Tables0); laySelected.Style.Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Yellow); myMap.Layers.Add(laySelected); return ds; 2、QueryMapByClick函數(shù)。 laySelected.DataSource = new SharpMap.Data.Providers.GeometryProvider(
17、ds.Tables0); laySelected.Style.Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Yellow); myMap.Layers.Add(laySelected); return ds; 3、ExecuteIntersectionQuery函數(shù) 為sharpMap內(nèi)部函數(shù),與上同實(shí)例三:屬性查詢依據(jù)查詢條件,查詢要素獲取該要素的屬性高亮度顯示該要素private void QueryFeatureByAttri(string sLayerName, string sFieldName, string s
18、FieldValue) SharpMap.Data.FeatureDataSet ds = new SharpMap.Data.FeatureDataSet(); SharpMap.Layers.VectorLayer objVLyr = myMap.LayerssLayerName as SharpMap.Layers.VectorLayer; if (objVLyr != null) long count = objVLyr.DataSource.GetFeatureCount(); if (!objVLyr.DataSource.IsOpen) objVLyr.DataSource.Op
19、en(); SharpMap.Data.FeatureDataRow tempFeat; for (uint i = 0; i count; i+) tempFeat = objVLyr.DataSource.GetFeature(i); lblProperty.Text = tempFeatsFieldName.ToString();/判斷字段值是否相等,若相等,則查詢到該要素 if (tempFeatsFieldName.ToString() = sFieldValue) /高亮度顯示該要素 SharpMap.Data.FeatureDataTable tempTable = new Sh
20、arpMap.Data.FeatureDataTable(); tempTable = (tempFeat.Table as SharpMap.Data.FeatureDataTable).Clone(); tempTable.LoadDataRow(tempFeat.ItemArray, false); FeatureDataRow tempRow; tempRow = tempTable.RowstempTable.Rows.Count - 1 as FeatureDataRow; tempRow.Geometry = tempFeat.Geometry; SharpMap.Layers.
21、VectorLayer laySelected = new SharpMap.Layers.VectorLayer(Selection); laySelected.DataSource = new SharpMap.Data.Providers.GeometryProvider(tempTable); laySelected.Style.Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Yellow); myMap.Layers.Add(laySelected); /顯示該要素的其他屬性 lblProperty.Text = ;
22、 lblProperty.Text += 屬性:; for (int j = 0; j tempFeat.Table.Columns.Count; j+) / lblProperty.Text += tempFeat.Table.Columnsi.ColumnName+ +tempFeati.ToString()+ lblProperty.Text += + tempFeat.Table.Columnsj.ColumnName; lblProperty.Text += + tempFeatj.ToString() + ; lblProperty.Visible = true; break; /
23、判斷字段值是否相等,若相等,則查詢到該要素 if (tempFeatsFieldName.ToString() = sFieldValue) /高亮度顯示該要素 SharpMap.Data.FeatureDataTable tempTable = new SharpMap.Data.FeatureDataTable(); tempTable = (tempFeat.Table as SharpMap.Data.FeatureDataTable).Clone(); tempTable.LoadDataRow(tempFeat.ItemArray, false); FeatureDataRow t
24、empRow; tempRow = tempTable.RowstempTable.Rows.Count - 1 as FeatureDataRow; tempRow.Geometry = tempFeat.Geometry; SharpMap.Layers.VectorLayer laySelected = new SharpMap.Layers.VectorLayer(Selection); laySelected.DataSource = new SharpMap.Data.Providers.GeometryProvider(tempTable); laySelected.Style.Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Yellow); myMap.Layers.Add(laySelected); /顯示該要素的其他屬性 lblProperty.Text = ; lblProperty.Text += 屬性:; for (int j = 0; j tempFeat.Table.Columns.Coun
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 全方位保安服務(wù)合同模板2025年
- 2025年體育中心使用租賃合同書
- 2025年合伙發(fā)展戰(zhàn)略投資合同
- 2025年協(xié)議離婚權(quán)益策劃保障
- 2025年重癥監(jiān)護(hù)臨床信息系統(tǒng)項(xiàng)目立項(xiàng)申請報(bào)告模稿
- 2025年個(gè)人融資合同策劃(含利息標(biāo)準(zhǔn))
- 2025年產(chǎn)品質(zhì)保跟蹤服務(wù)協(xié)議范本
- 2025年小型機(jī)床項(xiàng)目提案報(bào)告模范
- 2025年專利權(quán)使用許可合同示范文本
- 2025年機(jī)動(dòng)車購買合同簡化版
- 醫(yī)院標(biāo)準(zhǔn)化運(yùn)營管理課件
- 音樂考級(jí)-音程識(shí)別(基本樂科三級(jí))考試備考題庫(附答案)
- 《行政組織學(xué)通論》配套教學(xué)課件
- 霍山石斛教學(xué)課件
- 物業(yè)服務(wù)投標(biāo)文件
- 《數(shù)值分析》配套教學(xué)課件
- 山西省衛(wèi)生院社區(qū)衛(wèi)生服務(wù)中心信息名單目錄
- 排污口要求規(guī)范化整治施工設(shè)計(jì)
- 二手閑置物品交易平臺(tái)研究報(bào)告
- DBJ∕T45-093-2019 混凝土超高泵送施工技術(shù)規(guī)程
- 蘇州地圖高清矢量可填充編輯PPT模板(精美)
評(píng)論
0/150
提交評(píng)論