![GIS實(shí)驗(yàn)報(bào)告[共14頁(yè)]_第1頁(yè)](http://file1.renrendoc.com/fileroot_temp2/2021-1/21/941b00cb-363d-409c-9412-8b7ee260e018/941b00cb-363d-409c-9412-8b7ee260e0181.gif)
![GIS實(shí)驗(yàn)報(bào)告[共14頁(yè)]_第2頁(yè)](http://file1.renrendoc.com/fileroot_temp2/2021-1/21/941b00cb-363d-409c-9412-8b7ee260e018/941b00cb-363d-409c-9412-8b7ee260e0182.gif)
![GIS實(shí)驗(yàn)報(bào)告[共14頁(yè)]_第3頁(yè)](http://file1.renrendoc.com/fileroot_temp2/2021-1/21/941b00cb-363d-409c-9412-8b7ee260e018/941b00cb-363d-409c-9412-8b7ee260e0183.gif)
![GIS實(shí)驗(yàn)報(bào)告[共14頁(yè)]_第4頁(yè)](http://file1.renrendoc.com/fileroot_temp2/2021-1/21/941b00cb-363d-409c-9412-8b7ee260e018/941b00cb-363d-409c-9412-8b7ee260e0184.gif)
![GIS實(shí)驗(yàn)報(bào)告[共14頁(yè)]_第5頁(yè)](http://file1.renrendoc.com/fileroot_temp2/2021-1/21/941b00cb-363d-409c-9412-8b7ee260e018/941b00cb-363d-409c-9412-8b7ee260e0185.gif)
版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、實(shí)驗(yàn)報(bào)告GIS應(yīng)用軟件開(kāi)發(fā)專(zhuān) 業(yè): 測(cè)繪工程 班 級(jí): 10級(jí)測(cè)繪三班姓 名: 學(xué) 號(hào): 指導(dǎo)教師: 胡 亞 撰寫(xiě)時(shí)間:2013年5月20日星期一目錄一、程序運(yùn)行演示2二、問(wèn)題及解決方案3三、源程序代碼3四、心得體會(huì)3一、程序運(yùn)行演示1. 新建項(xiàng)目文件,并實(shí)現(xiàn)file中的基本功能,顯示地圖基本要素。如圖1圖12. 在工具欄加載按鈕,按鈕功能是對(duì)當(dāng)前視圖縮小3倍;在工具欄加載工具,工具功能在地圖上標(biāo)注當(dāng)前日期。如圖2圖2按鈕實(shí)現(xiàn)縮小3倍功能操作,如圖3圖33. 點(diǎn)擊地圖節(jié)點(diǎn),彈出如圖4,圖5菜單并實(shí)現(xiàn)菜單中的內(nèi)容:圖4圖54. 點(diǎn)擊圖層節(jié)點(diǎn),彈出如圖6菜單并需要實(shí)現(xiàn)菜單中的內(nèi)容圖65. 點(diǎn)擊Le
2、gend Class,彈出符號(hào)選擇對(duì)話框,該對(duì)話框供用戶(hù)按需要選擇符號(hào)并進(jìn)行更改。如圖7圖76. 打開(kāi)圖層屬性表,用戶(hù)選擇某條記錄,可彈出如圖8,9所示的右鍵菜單,并實(shí)現(xiàn)右鍵菜單中的內(nèi)容圖8圖9二、問(wèn)題及解決方案問(wèn)題1.VS2008與2010之間要進(jìn)行格式轉(zhuǎn)換,按照所導(dǎo)向的步驟進(jìn)行,否則程序?qū)o(wú)法正常運(yùn)行,出現(xiàn)錯(cuò)誤問(wèn)題2.構(gòu)建好基本框架后,地圖文檔中要素顯示出現(xiàn)問(wèn)題。此問(wèn)題要添加licence控件,否則無(wú)法顯示地圖要素。問(wèn)題3.使用Toolbar和Toc功能時(shí)無(wú)法進(jìn)行操作此問(wèn)題應(yīng)在屬性設(shè)置時(shí)建立關(guān)聯(lián)功能。問(wèn)題4.程序Program文件中要添加相應(yīng)功能鍵語(yǔ)句,否則將無(wú)法實(shí)現(xiàn)功能。問(wèn)題5.引用接口
3、,方法,例如ADF,要添加相應(yīng)的引用,否則程序出現(xiàn)錯(cuò)誤。問(wèn)題6. 在實(shí)現(xiàn)兩個(gè)自定義按鈕與工具時(shí),遇到的問(wèn)題:先直接引用現(xiàn)有項(xiàng)未實(shí)現(xiàn),發(fā)現(xiàn)缺少一些東西,后自己直接創(chuàng)建的Basetool和Basecommand類(lèi);在代碼中報(bào)錯(cuò),重新生成解決方案后順利解決這個(gè)問(wèn)題。問(wèn)題7. 在實(shí)現(xiàn)地圖和圖層節(jié)點(diǎn)的右鍵功能時(shí),遇到瑣碎的問(wèn)題,在這個(gè)過(guò)程中直接引用老師所給的幾個(gè)類(lèi),但是報(bào)錯(cuò),是因?yàn)槊臻g未做修改;缺少引用,需要根據(jù)錯(cuò)誤提示添加相應(yīng)的引用三、源程序代碼using System;using System.Collections.Generic;using System.ComponentModel;usi
4、ng System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.IO;using System.Runtime.InteropServices;using ESRI.ArcGIS.esriSystem;using ESRI.ArcGIS.Carto;using ESRI.ArcGIS.Controls;using ESRI.ArcGIS.ADF;using ESRI.ArcGIS.SystemUI;using ESRI.ArcGIS.D
5、isplay;namespace WindowsFormsApplication2 public partial class MainForm : Form #region class private members private IMapControl3 m_mapControl = null; private string m_mapDocumentName = string.Empty; #endregion IMapDocument m_MapDocument = new MapDocument(); #region class constructor private ITOCCon
6、trol2 m_tocControl; private IToolbarMenu m_menuMap; private IToolbarMenu m_menuLayer; private ZoomIn3XCMD1 test = new ZoomIn3XCMD1(); public MainForm() InitializeComponent(); private void newDocumentToolStripMenuItem_Click(object sender, EventArgs e) ICommand command = new CreateNewDocument(); comma
7、nd.OnCreate(m_mapControl.Object); command.OnClick(); private void openDocumentToolStripMenuItem_Click(object sender, EventArgs e) openFileDialog1.Title = Save Map Document As; openFileDialog1.Filter = Map Documents (*.mxd)|*.mxd; openFileDialog1.ShowDialog(); string sFilePath = openFileDialog1.FileN
8、ame; if (axMapControl1.CheckMxFile(sFilePath) axMapControl1.MousePointer = esriControlsMousePointer.esriPointerHourglass; axMapControl1.LoadMxFile(sFilePath, 0, Type.Missing); axMapControl1.MousePointer = esriControlsMousePointer.esriPointerDefault; else MessageBox.Show(sFilePath + is not a valid Ar
9、cMap document); return; private void MainForm_Load(object sender, EventArgs e) /get the MapControl m_mapControl = (IMapControl3)axMapControl1.Object; /disable the Save menu (since there is no document yet) this.menuSaveDoc.Enabled = false; /定義地圖右鍵菜單,圖層右鍵菜單 m_tocControl = (ITOCControl2)axTOCControl1.
10、Object; m_mapControl = (IMapControl3)axMapControl1.Object; /添加菜單到地圖節(jié)點(diǎn) m_menuMap = new ToolbarMenu(); m_menuMap.AddItem(esriControls.ControlsAdddataCommand, -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuMap.AddItem(new LayerVisibility(), 1, 1, false, esriCommandStyles.esriCommandSt
11、yleTextOnly); m_menuMap.AddItem(new LayerVisibility(), 2, 2, false, esriCommandStyles.esriCommandStyleTextOnly); /添加菜單到圖層節(jié)點(diǎn) m_menuLayer = new ToolbarMenu(); m_menuLayer.AddItem(new OpenAttributeTableCmd(), -1, 0, false, esriCommandStyles.esriCommandStyleIconAndText);/右鍵添加屬性表 m_menuLayer.AddItem(new
12、RemoveLayer(), 1, 1, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new RemoveLayer(), 1, 2, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ScaleThresholds(), 2, 3, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new ScaleT
13、hresholds(), 3, 4, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new LayerSelectable(), 1, 5, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new LayerSelectable(), 2, 6, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new Zoom
14、ToLayer(), -1, 7, true, esriCommandStyles.esriCommandStyleTextOnly); /Set the hook of each menu m_menuLayer.SetHook(m_mapControl); m_menuMap.SetHook(m_mapControl); axToolbarControl1.AddItem(test, -1, -1, true, 0, esriCommandStyles.esriCommandStyleIconAndText); axToolbarControl1.AddItem(new AddDateTo
15、ol(), -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconAndText); private void saveDocumentToolStripMenuItem_Click(object sender, EventArgs e) /execute Save Document command if (m_mapControl.CheckMxFile(m_mapDocumentName) /create a new instance of a MapDocument IMapDocument mapDoc = new MapDoc
16、ument(); mapDoc.Open(m_mapDocumentName, string.Empty); /Make sure that the MapDocument is not readonly if (mapDoc.get_IsReadOnly(m_mapDocumentName) MessageBox.Show(Map document is read only!); mapDoc.Close(); return; /Replace its contents with the current map mapDoc.ReplaceContents(IMxdContents)m_ma
17、pControl.Map); /save the MapDocument in order to persist it mapDoc.Save(mapDoc.UsesRelativePaths, false); /close the MapDocument mapDoc.Close(); #endregion private void saveAsToolStripMenuItem_Click(object sender, EventArgs e) /execute SaveAs Document command ICommand command = new ControlsSaveAsDoc
18、Command(); command.OnCreate(m_mapControl); command.OnClick(); private void exitToolStripMenuItem_Click(object sender, EventArgs e) Application.Exit(); private void axMapControl1_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e) statusBarXY.Text = string.Format(0, 1 2, e.mapX.ToString
19、(#.#), e.mapY.ToString(#.#), axMapControl1.MapUnits.ToString().Substring(4); private void axMapControl1_OnMapReplaced(object sender, IMapControlEvents2_OnMapReplacedEvent e) test.m_activeView = this.axMapControl1.ActiveView;/添加兩個(gè)工具時(shí)添加 /get the current document name from the MapControl m_mapDocumentN
20、ame = m_mapControl.DocumentFilename; /if there is no MapDocument, diable the Save menu and clear the statusbar if (m_mapDocumentName = string.Empty) menuSaveDoc.Enabled = false; statusBarXY.Text = string.Empty; else /enable the Save manu and write the doc name to the statusbar menuSaveDoc.Enabled =
21、true; statusBarXY.Text = Path.GetFileName(m_mapDocumentName); private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) if (e.button = 1) /IBasicMap map = new Map(); IMap Map = new Map(); IBasicMap map = (IBasicMap)Map; ILayer layer = new FeatureLayer(); object othe
22、r = new object(); object index = new object(); esriTOCControlItem item = new esriTOCControlItem(); /Determine what kind of item has been clicked on axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); /QI to IFeatureLayer and IGeoFeatuerLayer interface if (layer = nul
23、l) return; IFeatureLayer featureLayer = layer as IFeatureLayer; if (featureLayer = null) return; IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer)featureLayer; ILegendClass legendClass = new LegendClass(); ISymbol symbol = null; if (other is ILegendGroup & (int)index != -1) legendClass = (ILegen
24、dGroup)other).get_Class(int)index); symbol = legendClass.Symbol; if (symbol = null) return; symbol = GetSymbolByControl(symbol); /symbol = GetSymbolBySymbolSelector(symbol); if (symbol = null) return; legendClass.Symbol = symbol; this.Activate(); /Fire contents changed event that the TOCControl list
25、ens to axMapControl1.ActiveView.ContentsChanged(); /Refresh the display axMapControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null); axTOCControl1.Update(); if (e.button = 2) esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; IBasicMap map = null; ILayer layer = null; ob
26、ject other = null; object index = null; /Determine what kind of item is selected m_tocControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); /Ensure the item gets selected if (item = esriTOCControlItem.esriTOCControlItemMap) m_tocControl.SelectItem(map, null); else m_tocContr
27、ol.SelectItem(layer, null); / Set the layer into the CustomProperty (this is used by the custom layer commands) m_mapControl.CustomProperty = layer; /Popup the correct context menu if (item = esriTOCControlItem.esriTOCControlItemMap) m_menuMap.PopupMenu(e.x, e.y, m_tocControl.hWnd); if (item = esriTOCControlItem.esriTOCControlItemLayer) m_menuLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd); private ISymbol GetSymbolByControl(ISymbol symbolType) ISymbol symbol = null; IStyleGalleryItem styleGalleryItem = null; esriSymbologyStyleClass styleC
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 異地戀情侶合約協(xié)議書(shū)
- 《國(guó)際市場(chǎng)營(yíng)銷(xiāo)》課件-第8章 國(guó)際市場(chǎng)分銷(xiāo)渠道策略
- 車(chē)聯(lián)網(wǎng)環(huán)境下車(chē)輛信息智能管理與維護(hù)方案設(shè)計(jì)
- 太陽(yáng)能電池行業(yè)分析報(bào)告
- 建設(shè)項(xiàng)目可行性研究報(bào)告可概括為
- 人力資源行業(yè)區(qū)塊鏈技術(shù)應(yīng)用與實(shí)踐
- 學(xué)校綜合樓項(xiàng)目可行性研究報(bào)告
- 家居行業(yè)智能家居產(chǎn)品設(shè)計(jì)與銷(xiāo)售方案
- 醫(yī)療機(jī)構(gòu)疫情防控及醫(yī)療安全預(yù)案
- 新興產(chǎn)業(yè)發(fā)展趨勢(shì)與政策研究
- 高等教育數(shù)字化轉(zhuǎn)型心得體會(huì)
- 2025年安徽財(cái)貿(mào)職業(yè)學(xué)院?jiǎn)握新殬I(yè)技能測(cè)試題庫(kù)及答案1套
- 2025年安徽職業(yè)技術(shù)學(xué)院?jiǎn)握新殬I(yè)技能測(cè)試題庫(kù)及答案1套
- 典范英語(yǔ)6-12玉米片硬幣英文原文及重點(diǎn)短語(yǔ)和句子演示教學(xué)
- 日式保潔培訓(xùn)課件大全
- 2025年廣東省深圳市高考語(yǔ)文一模試卷
- 2025年陜西工商職業(yè)學(xué)院?jiǎn)握新殬I(yè)技能測(cè)試題庫(kù)學(xué)生專(zhuān)用
- 2025年福建省高職單招職業(yè)適應(yīng)性測(cè)試題庫(kù)及答案解析
- 自媒體運(yùn)營(yíng)實(shí)戰(zhàn)教程(抖音版) 課件 第7章 短視頻運(yùn)營(yíng)-自媒體中級(jí)
- 2025時(shí)事政治必考題庫(kù)含參考答案
- 保潔管理安全培訓(xùn)課件
評(píng)論
0/150
提交評(píng)論