




已阅读5页,还剩57页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
GIS软件设计与实现实验报告姓名: 王兴平 班级: 测绘1103班 学号: 0145110620 指导老师: 李光强 2015/1/5实验一 数据加载与图层控制一、实验目的1.了解组件ArcEngine9.3开发环境的构建,以及相关软件的安装;2.掌握AE组件实现数据加载、缩放、平移等简单的功能;3.掌握程序代码实现数据加载、缩放、平移、拉窗放大等功能;4.掌握使用程序代码控制图层可视性、图层移动、图层移除等操作。二、实验准备完成时间:2学时预备知识:实验的操作系统环境为 Windows XP以上操作系统,要基于ArcEngine进行应用开发,系统中需要安装有:ArcGIS 9.3、ArcEngine 9.3和C#2005以上版本相应软件。实验数据:文件夹“中国地图”三、实验步骤及方法1 创建C#工程,添加窗体及相关AE组件,窗体设计如下图所示:运行程序,并点击工具栏上按钮,记录各功能按钮的操作。2.利用程序代码添加SHP文件,并完成SHP加载、地图缩放、全图、平移、拉窗放大等操作,设计界面如下图所示:要求:1)工具栏上的“打开”按钮,功能是通过打开文件对话框,允许一次加载多个SHP文件,而且在对话框中仅显示SHP文件;2)平移、放大、缩小功能按钮的操作顺序过程必须是用户先点击按钮,然后再点击地图时才完成相应功能操作;3)工具栏上的最后一个按钮为拉窗放大,即用户点击该按钮时,在地图可以画出一个矩形,然后将矩形内的地图放大。3.使用程序代码控制图层可见性及移动图层,界面设计如下图所示:注意:1)工具栏后四个按钮依次为:上移选中图层、下移选中图层、移除选中图层操作;2)图层列表里,依据图层是否选中而设置图层的可见性。4为地图添加右键菜单,在右键菜单中实现全图、平移、放大、缩小、信息(identity)功能,使用鼠标中键实现地图平移。五实验主要代码private void LoadFile_Click(object sender, EventArgs e) OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = Shape file(*.shp)|*.shp; dlg.Title = 打开 Shape数据文档; dlg.Multiselect = true; /定义存放打开 IFeatureClass 的字符串数组 string FilePath; if (dlg.ShowDialog() = DialogResult.OK) FilePath = new stringdlg.FileNames.Length; FilePath = dlg.FileNames; if (FilePath.Length 0) string WorkSpacePath = System.IO.Path.GetDirectoryName(FilePath0); string ShapeFilePath = new stringFilePath.Length; /获得打开 IFeatureClass 的字符串数组 for (int i = 0; i FilePath.Length; i+) ShapeFilePathi = System.IO.Path.GetFileName(FilePathi); IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactoryClass(); IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(WorkSpacePath, 0); IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace; for (int i = 0; i ShapeFilePath.Length; i+) IFeatureClass pFeatureClass = pFeatureWorkspace.OpenFeatureClass(ShapeFilePathi); IDataset pDataset = pFeatureClass as IDataset; IFeatureLayer pFeatureLayer = new FeatureLayerClass(); pFeatureLayer.FeatureClass = pFeatureClass; pFeatureLayer.Name = pDataset.Name; ILayer pLayer = pFeatureLayer as ILayer; this.axMapControl1.Map.AddLayer(pLayer); this.axMapControl2.Map.AddLayer(pLayer); 实验2 地图符号化与专题制图一、实验目的1.掌握图层的符号化操作;2.掌握专题制图的常用方法以及基本算法。二、实验准备完成时间:2学时预备知识:实验的操作系统环境为 Windows XP以上操作系统,要基于ArcEngine进行应用开发,系统中需要安装有:ArcGIS 9.3、ArcEngine 9.3和C#2005以上版本相应软件。学习C#中的ListView控件的使用方法和颜色拾取对话框的使用,以及ArcEngine中的颜色定义的方法。实验数据:文件夹“中国地图”三、实验步骤及方法2 利用程序代码实现点状要素图层的符号化,界面如图1所示:图1要求:1) 点击“点符号化”按钮时需要判断当前选中的图层是否为点状图层;2) 选中的图层为点状图层以后,弹出如图2所示符号设置对话框:图2提示:符号列表框为ListView控件,点击颜色按钮时,弹出颜色拾取对话框,如图3:图33) 在符号选择器中,点击确定后,将根据设置完成点图层的符号化。2.在图1所示的界面中,点击“面符号化”,完成所选择面状要素图层的符号化。要求:1) 在点击事件中,需要判断当前选择的图层是否为面图层;2) 在程序代码中实现指定符号填充和颜色设定。3.完成单值渲染操作,如图4。图44.完成分级渲染操作,如图5。图55.选做:在TOC控件中添加快捷菜单,并在其中添加“图层属性”选项,在点击该选项时,弹出如图6所示的图层属性对话框,并在其中的Symbol选项卡中完成专题制图设置工作。四实验主要代码MapOperations mapOp; private IBasicMap pBasicMap = new Map() as IBasicMap; private ILayer pLayer = new FeatureLayer(); object oLegendGroup = new object(); object oIndex = new object(); esriTOCControlItem pTocItem = new esriTOCControlItem(); public Form1() InitializeComponent(); private void toolStripButton1_Click(object sender, EventArgs e) IWorkspaceFactory pWorkspaceFactory; IFeatureWorkspace pFeatureWorkspace; IFeatureLayer pFeatureLayer; /获取当前路径和文件名 OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = *.SHP|*.shp; dlg.Multiselect = true; dlg.ShowDialog(); string strFullPath; this.lblInfor.Text = 正在加载数据.; this.statusStrip1.Refresh(); for (int i = 0; i dlg.FileNames.Length; i+) strFullPath = dlg.FileNamesi; if (strFullPath = ) return; int Index = strFullPath.LastIndexOf(); string filePath = strFullPath.Substring(0, Index); string fileName = strFullPath.Substring(Index + 1); /打开工作空间并添加shp文件 pWorkspaceFactory = new ShapefileWorkspaceFactory(); /注意此处的路径是不能带文件名的 pFeatureWorkspace = (IFeatureWorkspace)pWorkspaceFactory.OpenFromFile(filePath, 0); pFeatureLayer = new FeatureLayer(); /注意这里的文件名是不能带路径的 pFeatureLayer.FeatureClass = pFeatureWorkspace.OpenFeatureClass(fileName); pFeatureLayer.Name = pFeatureLayer.FeatureClass.AliasName; axMapControl1.Map.AddLayer(pFeatureLayer); axMapControl1.ActiveView.Refresh(); this.lblInfor.Text = 已加载了 + dlg.FileNames.Length.ToString() + 个图层!; #region 图层操作 private void toolStripButton2_Click(object sender, EventArgs e) this.axMapControl1.Extent = this.axMapControl1.FullExtent; private void toolStripButton3_Click(object sender, EventArgs e) this.mapOp = MapOperations.Pan; private void toolStripButton4_Click(object sender, EventArgs e) IEnvelope pEnvelope; pEnvelope = axMapControl1.Extent; pEnvelope.Expand(0.5, 0.5, true); axMapControl1.Extent = pEnvelope; axMapControl1.Refresh(); private void toolStripButton5_Click(object sender, EventArgs e) IEnvelope pEnvelope; pEnvelope = axMapControl1.Extent; pEnvelope.Expand(1.5, 1.5, true); axMapControl1.Extent = pEnvelope; axMapControl1.Refresh(); private void toolStripButton6_Click(object sender, EventArgs e) this.mapOp = MapOperations.ZoomRectangle; IEnvelope pEnvelope; private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) if (mapOp = MapOperations.ZoomRectangle) pEnvelope = this.axMapControl1.TrackRectangle(); axMapControl1.Extent = pEnvelope; axMapControl1.Refresh(); else if (mapOp = MapOperations.Pan) this.axMapControl1.Pan(); #endregion / / 点符号化 / / / private void toolStripButton7_Click(object sender, EventArgs e) try if (pLayer = null) MessageBox.Show(请选择要素图层以后才能进行符号化操作!, 提示, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; IFeatureLayer lyr = (IFeatureLayer)this.pLayer; if (lyr.FeatureClass.ShapeType != esriGeometryType.esriGeometryPoint) MessageBox.Show(当前选择的要素图层不是点状要素!, 提示, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; ISimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbol(); ; ISimpleRenderer pSimpleRenderer = new SimpleRenderer(); IRgbColor pRgbColor = new RgbColor(); pRgbColor.Red = 255; pMarkerSymbol.Color = pRgbColor; pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSSquare; pSimpleRenderer.Symbol = (ISymbol)pMarkerSymbol; IGeoFeatureLayer oLyr = (IGeoFeatureLayer)lyr; oLyr.Renderer = (IFeatureRenderer)pSimpleRenderer; this.axMapControl1.Refresh(); catch (Exception ex) private void axMapControl1_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e) IPoint pnt = this.axMapControl1.ToMapPoint(e.x, e.y); this.lblCoord.Text = x= + pnt.X.ToString(F4) + ,y= + pnt.Y.ToString(F4); private void axTOCControl1_OnMouseDown_1(object sender, ITOCControlEvents_OnMouseDownEvent e) axTOCControl1.HitTest(e.x, e.y, ref pTocItem, ref pBasicMap, ref pLayer, ref oLegendGroup, ref oIndex); if (e.button = 1) if (pTocItem = esriTOCControlItem.esriTOCControlItemMap) lblInfor.Text = 当前单击的是地图: + pBasicMap.Name + 地图中图层数为: + pBasicMap.LayerCount.ToString(); else if (pTocItem = esriTOCControlItem.esriTOCControlItemLayer) lblInfor.Text = 当前单击的图层: + pLayer.Name; else if (pTocItem = esriTOCControlItem.esriTOCControlItemLegendClass) lblInfor.Text = 当前单击的图层符号,图层名称: + pLayer.Name; else if (pTocItem = esriTOCControlItem.esriTOCControlItemNone) lblInfor.Text = 当前单击为空白区域; private void axTOCControl1_OnDoubleClick(object sender, ITOCControlEvents_OnDoubleClickEvent e) axTOCControl1.HitTest(e.x, e.y, ref pTocItem, ref pBasicMap, ref pLayer, ref oLegendGroup, ref oIndex); if (e.button = 1) if (pTocItem = esriTOCControlItem.esriTOCControlItemLegendClass) /取得图例 ILegendClass pLegendClass = (ILegendGroup)oLegendGroup).get_Class(int)oIndex); /创建符号选择器SymbolSelector实例 SymbolSelectorFrm SymbolSelectorFrm = new SymbolSelectorFrm(pLegendClass, pLayer); if (SymbolSelectorFrm.ShowDialog() = DialogResult.OK) /局部更新主Map控件 this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); /设置新的符号 pLegendClass.Symbol = SymbolSelectorFrm.pSymbol; /更新主Map控件和图层控件 this.axMapControl1.ActiveView.Refresh(); this.axTOCControl1.Refresh(); this.axMapControl1.Refresh(); / / 线符号化 / / / private void toolStripButton8_Click(object sender, EventArgs e) try if (pLayer = null) MessageBox.Show(请选择要素图层以后才能进行符号化操作!, 提示, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; IFeatureLayer lyr = (IFeatureLayer)this.pLayer; if (lyr.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolyline) MessageBox.Show(当前选择的要素图层不是线状要素!, 提示, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; ISimpleLineSymbol pMarkerSymbol = new SimpleLineSymbol(); ; ISimpleRenderer pSimpleRenderer = new SimpleRenderer(); IRgbColor pRgbColor = new RgbColor(); pRgbColor.Red = 255; pMarkerSymbol.Color = pRgbColor; pMarkerSymbol.Style = esriSimpleLineStyle.esriSLSDashDotDot; pMarkerSymbol.Width = 5; pSimpleRenderer.Symbol = (ISymbol)pMarkerSymbol; IGeoFeatureLayer oLyr = (IGeoFeatureLayer)lyr; oLyr.Renderer = (IFeatureRenderer)pSimpleRenderer; this.axMapControl1.Refresh(); catch (Exception ex) private void toolStripButton10_Click(object sender, EventArgs e) pLayer = (IFeatureLayer)this.axMapControl1.get_Layer(0); if (pLayer.Name != Provinces) MessageBox.Show(当前请加载省界面图层!, 提示, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; IGeoFeatureLayer geoLayer = pLayer as IGeoFeatureLayer; createUniqueValueRander(geoLayer, NAME, esriSimpleFillStyle.esriSFSNull, 34); this.axMapControl1.Refresh(); / / 单一值渲染(单字段) / / 图层名 / 渲染字段 / 填充样式 / 字段的唯一值个数 public void createUniqueValueRander(IGeoFeatureLayer geoFeatureLayer, string RenderField, esriSimpleFillStyle FillStyle, int valueCount) IUniqueValueRenderer uniqueValueRenderer = new UniqueValueRenderer(); /可以设置多个字段 uniqueValueRenderer.FieldCount = 1;/0-3个 uniqueValueRenderer.set_Field(0, RenderField); /简单填充符号 ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol(); simpleFillSymbol.Style = FillStyle; IFeatureCursor featureCursor = geoFeatureLayer.FeatureClass.Search(null, false); IFeature feature; if (featureCursor != null) IEnumColors enumColors = CreateAlgorithmicColorRamp(valueCount).Colors; int fieldIndex = geoFeatureLayer.FeatureClass.Fields.FindField(RenderField); for (int i = 0; i valueCount; i+) feature = featureCursor.NextFeature(); string nameValue = feature.get_Value(fieldIndex).ToString(); simpleFillSymbol = new SimpleFillSymbol(); simpleFillSymbol.Color = enumColors.Next(); uniqueValueRenderer.AddValue(nameValue, RenderField, simpleFillSymbol as ISymbol); geoFeatureLayer.Renderer = uniqueValueRenderer as IFeatureRenderer; / / 单一值渲染(多字段) / / 图层名 / 多字段名 / 样式 / 每个字段中唯一值的个数 public void createUniqueValueRander(IGeoFeatureLayer geoFeatureLayer, string RenderField, esriSimpleFillStyle FillStyle, int valueCount) IUniqueValueRenderer uniqueValueRenderer = new UniqueValueRenderer(); /可以设置多个字段 uniqueValueRenderer.FieldCount = RenderField.Length;/0-3个 for (int i = 0; i RenderField.Length; i+) uniqueValueRenderer.set_Field(i, RenderFieldi); /简单填充符号 ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol(); simpleFillSymbol.Style = FillStyle; IFeatureCursor featureCursor = geoFeatureLayer.FeatureClass.Search(null, false); IFeature feature; if (featureCursor != null) for (int i = 0; i RenderField.Length; i+) IEnumColors enumColors = CreateAlgorithmicColorRamp(valueCounti).Colors; int fieldIndex = geoFeatureLayer.FeatureClass.Fields.FindField(RenderFieldi); for (int j = 0; j valueCounti; j+) feature = featureCursor.NextFeature(); string nameValue = feature.get_Value(fieldIndex).ToString(); simpleFillSymbol = new SimpleFillSymbol(); simpleFillSymbol.Color = enumColors.Next(); uniqueValueRenderer.AddValue(nameValue, RenderFieldi, simpleFillSymbol as ISymbol); geoFeatureLayer.Renderer = uniqueValueRenderer as IFeatureRenderer; /生成颜色带 public IColorRamp CreateAlgorithmicColorRamp(int count) /IUniqueValueRenderer pUniqueValueR; IEnumColors pEnumRamp; AlgorithmicColorRamp pColorRamp; /pUnique
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 高级卫生专业技术资格-副高(骨外科学)真题库-4
- 高级卫生专业技术资格-副高级(中药学)真题库-18
- 六年级语文上册第七单元《伯牙鼓琴》教学设计
- 高效备考护士资格证试题及答案
- 适应卫生管理考试的思路试题及答案
- 课题申报书:基于学习者画像的混合式教学模式构建与应用研究
- 逻辑思维试题及答案高中
- 课题申报书:基于差异化评价的安全工程实验教学研究与实践
- 2025届辽宁省重点高中协作校高三第三次模拟考试物理试卷含解析
- 全国18名校2025届高三下学期期末考试物理试题仿真(B)卷
- 《我不是药神》剧本
- JJF 1101-2019《环境试验设备温度、湿度校准规范》规程
- GB/T 6451-2023油浸式电力变压器技术参数和要求
- 幼儿园中班绘本《城市里最漂亮的巨人》课件
- 医院廉洁行医廉政教育专题课件
- 医务人员职业健康安全健康-课件
- 安全组织机构图
- 旧石器时代考古-基础知识课件
- 江苏省建设工程现场安全文明施工措施费计价管理办法
- 病区药品规范化管理与问题对策黄池桃
- 螺纹塞规操作规程
评论
0/150
提交评论