1、湘潭市雨湖区酒店分布电子地图软件设计报告湘潭市雨湖区酒店分布电子地图软件设计实习报告实习目的了解地图的功能和地图软件制作的方法,实现简单的地图制作。实习内容制作一个简单的地图软件,实现地图的导航和查询统计功能。实习步骤1. 准备矢量化完成湘潭市雨湖区酒店分布的电子地图,如下图:2. 安装好Arcengine 9.3 运行时和Arcengine 9.3 SDK for .Net,在Visual Studio 2008中新建一个Windows应用程序,完成主界面Form1如下图,并设置好各种属性:3. 添加一个窗体Form2,作为查询和统计的信息输入对话框,如下图所示:4. 编写程序实现功能。代码
2、如下:Form1的代码:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using ESRI.ArcGIS.Carto;using ESRI.ArcGIS.Controls;using ESRI.ArcGIS.Display;using ESRI.ArcGIS.Geometry;using ES
3、RI.ArcGIS.esriSystem;using ESRI.ArcGIS.Output;using ESRI.ArcGIS.SystemUI;using ESRI.ArcGIS.Analyst3D;using ESRI.ArcGIS.GlobeCore;using ESRI.ArcGIS.DisplayUI;using ESRI.ArcGIS.GeoAnalyst;using ESRI.ArcGIS.Geodatabase;namespace HotelMap public partial class Form1 : Form public Form1() InitializeCompon
4、ent(); private void Form1_Load(object sender, EventArgs e) this.Text = 湘潭市雨湖区酒店分布电子地图; this.axToolbar.Height = this.axMap.Height - 2; this.axTOC.SetBuddyControl(this.axMap); this.axToolbar.SetBuddyControl(this.axMap); this.axMap.LoadMxFile(F:maphotel.mxd); /地图导航工具条长度变化 private void axMap_Resize(obje
5、ct sender, EventArgs e) /this.axToolbar.Location.X = this.axMap.Location.X + 1; /this.axToolbar.Location.Y = this.axMap.Location.Y + 1; this.axToolbar.Height = this.axMap.Height - 20; /打开地图 private void OpenmapItem_Click(object sender, EventArgs e) OpenFileDialog f = new OpenFileDialog(); f.Title =
6、打开地图; f.Multiselect = false; f.Filter = Arcmap地图文档(*.mxd)|*.mxd; if (f.ShowDialog() = DialogResult.OK) try this.axMap.LoadMxFile(f.FileName); catch (Exception ex) MessageBox.Show(ex.Message); /保存地图 private void SavemapItem_Click(object sender, EventArgs e) if (this.axMap.LayerCount = 0) return; Save
7、FileDialog s = new SaveFileDialog(); s.Title = 保存地图; s.DefaultExt = .mxd; s.AddExtension = true; s.CheckFileExists = true; if (s.ShowDialog() = DialogResult.OK) IMxdContents pMxdC; pMxdC = this.axMap.Map as IMxdContents; IMapDocument pMapDocument = new MapDocumentClass(); pMapDocument.New(s.FileName
8、); IActiveView pActiveView = this.axMap.Map as IActiveView; pMapDocument.ReplaceContents(pMxdC); pMapDocument.Save(true, true); /退出程序 private void ExitappItem_Click(object sender, EventArgs e) Application.Exit(); /关于对话框 private void AboutItem_Click(object sender, EventArgs e) AboutBox1 a = new About
9、Box1(); a.ShowDialog(); /酒店统计 private void HotelcntItem_Click(object sender, EventArgs e) Form2 f = new Form2(2); f.ShowDialog(); if (f.QueryString != string.Empty) IActiveView pActiveView = this.axMap.Map as IActiveView; pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, this.axMap.
10、get_Layer(0), null); this.axMap.Map.ClearSelection(); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, this.axMap.get_Layer(0), null); IFeatureLayer pFeatLyr = (IFeatureLayer)this.axMap.get_Layer(0); IQueryFilter pQueryFilter = new QueryFilterClass(); pQueryFilter.WhereClause = f.Q
11、ueryString; IFeatureSelection pFeatSel = pFeatLyr as IFeatureSelection; pFeatSel.SelectFeatures(pQueryFilter, esriSelectionResultEnum.esriSelectionResultNew, false); int k = pFeatSel.SelectionSet.Count; if (k = 0) MessageBox.Show(没有查询到符合条件的酒店.); else MessageBox.Show(共查询到 + k.ToString() + 个符合条件的酒店.);
12、 /酒店查询 private void HotelfindItem_Click(object sender, EventArgs e) Form2 f = new Form2(1); f.ShowDialog(); if (f.QueryString != string.Empty) IActiveView pActiveView = this.axMap.Map as IActiveView; pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, this.axMap.get_Layer(0), null); t
13、his.axMap.Map.ClearSelection(); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, this.axMap.get_Layer(0), null); IFeatureLayer pFeatLyr = (IFeatureLayer)this.axMap.get_Layer(0); IQueryFilter pQueryFilter = new QueryFilterClass(); pQueryFilter.WhereClause = Name= + f.QueryString; IF
14、eatureSelection pFeatSel = pFeatLyr as IFeatureSelection; pFeatSel.SelectFeatures(pQueryFilter, esriSelectionResultEnum.esriSelectionResultNew, false); int k = pFeatSel.SelectionSet.Count; if (k = 0) MessageBox.Show(不存在此酒店.); Form2的代码:using System;using System.Collections.Generic;using System.Compon
15、entModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace HotelMap public partial class Form2 : Form private string querystring; private int k; public Form2(int i) InitializeComponent(); this.querystring = ; this.k = i; private void Form
16、2_Load(object sender, EventArgs e) this.Text = 酒店查询; if (this.k = 1) this.label1.Text = 请输入你要查询的酒店的名称:; else this.label1.Text = 请输入你要查询的酒店的条件:; private void btnOK_Click(object sender, EventArgs e) if (this.textBox1.Text != string.Empty) this.querystring = this.textBox1.Text; else MessageBox.Show(请输入
17、酒店名称.); private void btnCancel_Click(object sender, EventArgs e) this.Close(); public string QueryString get return this.querystring; 应用程序的入口代码:using System;using System.Collections.Generic;using System.Linq;using System.Windows.Forms;namespace HotelMap static class Program / / 应用程序的主入口点。 / STAThrea
18、d static void Main() Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1(); 5. 下面是程序运行界面的展示:程序载入目的地图程序打开地图文档的对话框程序根据酒店名称查询酒店程序保存地图文档的对话框程序根据条件统计酒店个数程序的关于对话框实习总结此次实习是制作一个简单的小地图系统。湘潭市雨湖区的酒店分布地图从网上截得的图片在ArcMap中矢量化得到,分为四个矢量图层。我负责所在组的软件制作。由于有以前的经验,做起来也比较得顺手,相对来说也比较的简单了。很多的东西像地图导航工具条都是系统提供的,不用自己去处理。像查询和统计是用矢量图层的要素条件检索即可得出,并在地图上可以高亮显示或者说是选中吧。其实一个简单的系统不难,难的是那些复杂的功能,看来我必须在这一方面努力了。此次实习,收获很大。