湘潭市雨湖区酒店分布电子地图软件设计报告.docx
- 文档编号:9204695
- 上传时间:2023-02-03
- 格式:DOCX
- 页数:15
- 大小:366.94KB
湘潭市雨湖区酒店分布电子地图软件设计报告.docx
《湘潭市雨湖区酒店分布电子地图软件设计报告.docx》由会员分享,可在线阅读,更多相关《湘潭市雨湖区酒店分布电子地图软件设计报告.docx(15页珍藏版)》请在冰豆网上搜索。
湘潭市雨湖区酒店分布电子地图软件设计报告
湘潭市雨湖区酒店分布电子地图软件设计实习报告
实习目的
了解地图的功能和地图软件制作的方法,实现简单的地图制作。
实习内容
制作一个简单的地图软件,实现地图的导航和查询统计功能。
实习步骤
1.准备矢量化完成湘潭市雨湖区酒店分布的电子地图,如下图:
2.安装好Arcengine9.3运行时和Arcengine9.3SDKfor.Net,在VisualStudio2008中新建一个Windows应用程序,完成主界面Form1如下图,并设置好各种属性:
3.添加一个窗体Form2,作为查询和统计的信息输入对话框,如下图所示:
4.编写程序实现功能。
代码如下:
Form1的代码:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
usingESRI.ArcGIS.Carto;
usingESRI.ArcGIS.Controls;
usingESRI.ArcGIS.Display;
usingESRI.ArcGIS.Geometry;
usingESRI.ArcGIS.esriSystem;
usingESRI.ArcGIS.Output;
usingESRI.ArcGIS.SystemUI;
usingESRI.ArcGIS.Analyst3D;
usingESRI.ArcGIS.GlobeCore;
usingESRI.ArcGIS.DisplayUI;
usingESRI.ArcGIS.GeoAnalyst;
usingESRI.ArcGIS.Geodatabase;
namespaceHotelMap
{
publicpartialclassForm1:
Form
{
publicForm1()
{
InitializeComponent();
}
privatevoidForm1_Load(objectsender,EventArgse)
{
this.Text="湘潭市雨湖区酒店分布电子地图";
this.axToolbar.Height=this.axMap.Height-2;
this.axTOC.SetBuddyControl(this.axMap);
this.axToolbar.SetBuddyControl(this.axMap);
this.axMap.LoadMxFile("F:
\\map\\hotel.mxd");
}
//地图导航工具条长度变化
privatevoidaxMap_Resize(objectsender,EventArgse)
{
//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;
}
//打开地图
privatevoidOpenmapItem_Click(objectsender,EventArgse)
{
OpenFileDialogf=newOpenFileDialog();
f.Title="打开地图";
f.Multiselect=false;
f.Filter="Arcmap地图文档(*.mxd)|*.mxd";
if(f.ShowDialog()==DialogResult.OK)
{
try
{
this.axMap.LoadMxFile(f.FileName);
}
catch(Exceptionex)
{
MessageBox.Show(ex.Message);
}
}
}
//保存地图
privatevoidSavemapItem_Click(objectsender,EventArgse)
{
if(this.axMap.LayerCount==0)
{
return;
}
SaveFileDialogs=newSaveFileDialog();
s.Title="保存地图";
s.DefaultExt=".mxd";
s.AddExtension=true;
s.CheckFileExists=true;
if(s.ShowDialog()==DialogResult.OK)
{
IMxdContentspMxdC;
pMxdC=this.axMap.MapasIMxdContents;
IMapDocumentpMapDocument=newMapDocumentClass();
pMapDocument.New(s.FileName);
IActiveViewpActiveView=this.axMap.MapasIActiveView;
pMapDocument.ReplaceContents(pMxdC);
pMapDocument.Save(true,true);
}
}
//退出程序
privatevoidExitappItem_Click(objectsender,EventArgse)
{
Application.Exit();
}
//关于对话框
privatevoidAboutItem_Click(objectsender,EventArgse)
{
AboutBox1a=newAboutBox1();
a.ShowDialog();
}
//酒店统计
privatevoidHotelcntItem_Click(objectsender,EventArgse)
{
Form2f=newForm2
(2);
f.ShowDialog();
if(f.QueryString!
=string.Empty)
{
IActiveViewpActiveView=this.axMap.MapasIActiveView;
pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection,this.axMap.get_Layer(0),null);
this.axMap.Map.ClearSelection();
pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection,this.axMap.get_Layer(0),null);
IFeatureLayerpFeatLyr=(IFeatureLayer)this.axMap.get_Layer(0);
IQueryFilterpQueryFilter=newQueryFilterClass();
pQueryFilter.WhereClause=f.QueryString;
IFeatureSelectionpFeatSel=pFeatLyrasIFeatureSelection;
pFeatSel.SelectFeatures(pQueryFilter,esriSelectionResultEnum.esriSelectionResultNew,false);
intk=pFeatSel.SelectionSet.Count;
if(k==0)
{
MessageBox.Show("没有查询到符合条件的酒店.");
}
else
{
MessageBox.Show("共查询到"+k.ToString()+"个符合条件的酒店.");
}
}
}
//酒店查询
privatevoidHotelfindItem_Click(objectsender,EventArgse)
{
Form2f=newForm2
(1);
f.ShowDialog();
if(f.QueryString!
=string.Empty)
{
IActiveViewpActiveView=this.axMap.MapasIActiveView;
pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection,this.axMap.get_Layer(0),null);
this.axMap.Map.ClearSelection();
pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection,this.axMap.get_Layer(0),null);
IFeatureLayerpFeatLyr=(IFeatureLayer)this.axMap.get_Layer(0);
IQueryFilterpQueryFilter=newQueryFilterClass();
pQueryFilter.WhereClause="Name="+f.QueryString;
IFeatureSelectionpFeatSel=pFeatLyrasIFeatureSelection;
pFeatSel.SelectFeatures(pQueryFilter,esriSelectionResultEnum.esriSelectionResultNew,false);
intk=pFeatSel.SelectionSet.Count;
if(k==0)
{
MessageBox.Show("不存在此酒店.");
}
}
}
}
}
Form2的代码:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
namespaceHotelMap
{
publicpartialclassForm2:
Form
{
privatestringquerystring;
privateintk;
publicForm2(inti)
{
InitializeComponent();
this.querystring="";
this.k=i;
}
privatevoidForm2_Load(objectsender,EventArgse)
{
this.Text="酒店查询";
if(this.k==1)
{
this.label1.Text="请输入你要查询的酒店的名称:
";
}
else
{
this.label1.Text="请输入你要查询的酒店的条件:
";
}
}
privatevoidbtnOK_Click(objectsender,EventArgse)
{
if(this.textBox1.Text!
=string.Empty)
{
this.querystring=this.textBox1.Text;
}
else
{
MessageBox.Show("请输入酒店名称.");
}
}
privatevoidbtnCancel_Click(objectsender,EventArgse)
{
this.Close();
}
publicstringQueryString
{
get
{
returnthis.querystring;
}
}
}
}
应用程序的入口代码:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Windows.Forms;
namespaceHotelMap
{
staticclassProgram
{
///
///应用程序的主入口点。
///
[STAThread]
staticvoidMain()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(newForm1());
}
}
}
5.下面是程序运行界面的展示:
程序载入目的地图
程序打开地图文档的对话框
程序根据酒店名称查询酒店
程序保存地图文档的对话框
程序根据条件统计酒店个数
程序的关于对话框
实习总结
此次实习是制作一个简单的小地图系统。
湘潭市雨湖区的酒店分布地图从网上截得的图片在ArcMap中矢量化得到,分为四个矢量图层。
我负责所在组的软件制作。
由于有以前的经验,做起来也比较得顺手,相对来说也比较的简单了。
很多的东西像地图导航工具条都是系统提供的,不用自己去处理。
像查询和统计是用矢量图层的要素条件检索即可得出,并在地图上可以高亮显示或者说是选中吧。
其实一个简单的系统不难,难的是那些复杂的功能,看来我必须在这一方面努力了。
此次实习,收获很大。
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 湘潭市 湖区 酒店 分布 电子地图 软件设计 报告