校园监控设施查询系统实习进程书.docx_第1页
校园监控设施查询系统实习进程书.docx_第2页
校园监控设施查询系统实习进程书.docx_第3页
校园监控设施查询系统实习进程书.docx_第4页
校园监控设施查询系统实习进程书.docx_第5页
已阅读5页,还剩31页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

实习进程计划书一 系统实施计划9月19日:选定课题,大体定下系统的结构和功能。9月20日:实现图层基本操作功能,如放大、缩小、漫游、全图等。9月21日:补写概要设计说明书和任务计划书。9月22日:制定监控设施查询系统的查询功能的大致思路,改善之前的系统功能,增改基本控件。9月23日:实现点击查询。9月24日:实现属性查图。9月25日: 实现查看图层属性表。9月26日:准备实施监控设施查询。9月27日:实施监控设施查询。9月28日:查漏补缺,总体优化。二 系统界面和代码1. 系统界面图一 初始界面图二 查询界面2.文件打开功能点击“文件”菜单,在下拉菜单中选择“打开SHP”或“打开MXD”,通过相应路径即可添加相应图层数据(默认打开文件为MXD)。图三 选择图层数据代码:/打开SHP文件 private void 打开aSHPToolStripMenuItem_Click(object sender, EventArgs e) string filePath = string.Empty; OpenFileDialog addShape = new OpenFileDialog(); addShape.Filter = Add Shape File|*.shp; addShape.Title = Add Shape; /点击确定按钮 if (addShape.ShowDialog() = DialogResult.OK) /构造ShapeWorkspace工厂 IWorkspaceFactory factory = new ShapefileWorkspaceFactory(); /利用工厂建立Workspace IFeatureWorkspace fileSpace = factory.OpenFromFile(addShape.FileName.Replace(addShape.SafeFileName, string.Empty), 0) as IFeatureWorkspace; /打开aworkspace中的一个图层(FeatureClass) IFeatureClass featureClass = fileSpace.OpenFeatureClass(addShape.SafeFileName); /建立一个Layer,并初始化 IFeatureLayer layer = new FeatureLayer(); layer.FeatureClass = featureClass; layer.Name = featureClass.AliasName; /将Layer加载到Mapcontrol中 this.axMapControl1.Map.AddLayer(layer); /刷新mapcontrol this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null); /打开MXD文件 private void 打开aMXDToolStripMenuItem_Click(object sender, EventArgs e) OpenFileDialog openfiledialog = new OpenFileDialog(); openfiledialog.Title = 打开地图文档;/名称 openfiledialog.Filter = map documents(*.mxd)|*.mxd;/过滤 openfiledialog.ShowDialog();/显示对话框 string filepath = openfiledialog.FileName; if (axMapControl1.CheckMxFile(filepath) axMapControl1.MousePointer = esriControlsMousePointer.esriPointerArrowHourglass; axMapControl1.LoadMxFile(filepath, 0, Type.Missing); axMapControl1.MousePointer = esriControlsMousePointer.esriPointerDefault; else MessageBox.Show(filepath + 不是有效的地图文档); 3.图层基本操作功能在查询界面,点击“图层操作”菜单,在下拉菜单中选择“放大”、“缩小”、“漫游”、“全图”即可进行相应操作。图四 图层基本操作图五 放大操作代码:private void 放大ToolStripMenuItem_Click_1(object sender, EventArgs e) axMapControl1.MousePointer = esriControlsMousePointer.esriPointerZoomIn; flag = 2; flg = 1; 图六 缩小操作代码:private void 缩小ToolStripMenuItem_Click(object sender, EventArgs e) axMapControl1.MousePointer = esriControlsMousePointer.esriPointerZoomOut; flag = 1; flg = 1; 图七 漫游操作代码:private void 漫游ToolStripMenuItem_Click(object sender, EventArgs e) axMapControl1.MousePointer = esriControlsMousePointer.esriPointerPagePan; flag = 3; flg = 1; 图八 全图操作private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) if (flg = 1) IEnvelope ipEnv; if (flag = 2) ipEnv = axMapControl1.TrackRectangle(); axMapControl1.Extent = ipEnv; else if (flag = 1) ipEnv = axMapControl1.TrackRectangle(); ipEnv = axMapControl1.Extent; ipEnv.Expand(2, 2, true); axMapControl1.Extent = ipEnv; else if (flag = 3) ipEnv = axMapControl1.Extent; axMapControl1.Pan(); else if (flg = 2) ILayer pLayer; IFeatureLayer pFL; IFeatureSelection pFeatureSelection; IEnvelope pEnv; IGeometry pGeometry; ISpatialFilter pSpatialFilter; ISelectionSet pSelectionSet; IEnumIDs pEnumIDs; IFeature pFeature; pEnv = new EnvelopeClass(); double ext = 0; IEnvelope mapExt = this.axMapControl1.Extent; int mapWidth = this.axMapControl1.Right - this.axMapControl1.Left; ext = 5 * (mapExt.XMax - mapExt.XMin) / mapWidth; pEnv.PutCoords(e.mapX - ext, e.mapY - ext, e.mapX + ext, e.mapY + ext); pGeometry = pEnv as IGeometry; pSpatialFilter = new SpatialFilterClass(); pSpatialFilter.Geometry = pGeometry; pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; Form4 frmShowAttribute = Form4.CreateForm(); frmShowAttribute.Show(); frmShowAttribute.AttributeTreeView.Nodes.Clear(); frmShowAttribute.AttributeTreeView.ShowLines = true; frmShowAttribute.AttributeTreeView.ShowPlusMinus = true; TreeNode rootNode = new TreeNode(); rootNode.Text = 属性信息; Font font = new Font(黑体, 10); rootNode.NodeFont = font; frmShowAttribute.AttributeTreeView.Nodes.Add(rootNode); for (int i = 0; i 0) TreeNode layerNameNode = new TreeNode(); layerNameNode.ForeColor = Color.Green; layerNameNode.Text = 图层名: + pFL.Name; rootNode.Nodes.Add(layerNameNode); pEnumIDs = pSelectionSet.IDs; long id = pEnumIDs.Next(); while (id != -1) pFeature = pFL.FeatureClass.GetFeature(int)id); for (int j = 0; j pFeature.Fields.FieldCount; j+) if (j != 1) TreeNode fieldInfoNode = new TreeNode(); fieldInfoNode.Text = pFeature.Fields.get_Field(j).Name + : + pFeature.get_Value(j).ToString(); layerNameNode.Nodes.Add(fieldInfoNode); else TreeNode fieldInfoNode = new TreeNode(); fieldInfoNode.Text = pFeature.Fields.get_Field(j).Name + : + pFeature.Shape.GeometryType.ToString(); layerNameNode.Nodes.Add(fieldInfoNode); frmShowAttribute.AttributeTreeView.ExpandAll(); id = pEnumIDs.Next(); axMapControl1.ActiveView.Refresh(); 4.点击查询功能点击“查询”菜单,在下拉菜单中选择“点击查询”和“属性查询”即可进行相应操作。图九 点击查询和属性查询图十 点击查询实现代码:private void 点击查询ToolStripMenuItem_Click(object sender, EventArgs e) axMapControl1.MousePointer = esriControlsMousePointer.esriPointerDefault; flg = 2; private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) if (flg = 1) IEnvelope ipEnv; if (flag = 2) ipEnv = axMapControl1.TrackRectangle(); axMapControl1.Extent = ipEnv; else if (flag = 1) ipEnv = axMapControl1.TrackRectangle(); ipEnv = axMapControl1.Extent; ipEnv.Expand(2, 2, true); axMapControl1.Extent = ipEnv; else if (flag = 3) ipEnv = axMapControl1.Extent; axMapControl1.Pan(); else if (flg = 2) ILayer pLayer; IFeatureLayer pFL; IFeatureSelection pFeatureSelection; IEnvelope pEnv; IGeometry pGeometry; ISpatialFilter pSpatialFilter; ISelectionSet pSelectionSet; IEnumIDs pEnumIDs; IFeature pFeature; pEnv = new EnvelopeClass(); double ext = 0; IEnvelope mapExt = this.axMapControl1.Extent; int mapWidth = this.axMapControl1.Right - this.axMapControl1.Left; ext = 5 * (mapExt.XMax - mapExt.XMin) / mapWidth; pEnv.PutCoords(e.mapX - ext, e.mapY - ext, e.mapX + ext, e.mapY + ext); pGeometry = pEnv as IGeometry; pSpatialFilter = new SpatialFilterClass(); pSpatialFilter.Geometry = pGeometry; pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; Form4 frmShowAttribute = Form4.CreateForm(); frmShowAttribute.Show(); frmShowAttribute.AttributeTreeView.Nodes.Clear(); frmShowAttribute.AttributeTreeView.ShowLines = true; frmShowAttribute.AttributeTreeView.ShowPlusMinus = true; TreeNode rootNode = new TreeNode(); rootNode.Text = 属性信息; Font font = new Font(黑体, 10); rootNode.NodeFont = font; frmShowAttribute.AttributeTreeView.Nodes.Add(rootNode); for (int i = 0; i 0) TreeNode layerNameNode = new TreeNode(); layerNameNode.ForeColor = Color.Green; layerNameNode.Text = 图层名: + pFL.Name; rootNode.Nodes.Add(layerNameNode); pEnumIDs = pSelectionSet.IDs; long id = pEnumIDs.Next(); while (id != -1) pFeature = pFL.FeatureClass.GetFeature(int)id); for (int j = 0; j pFeature.Fields.FieldCount; j+) if (j != 1) TreeNode fieldInfoNode = new TreeNode(); fieldInfoNode.Text = pFeature.Fields.get_Field(j).Name + : + pFeature.get_Value(j).ToString(); layerNameNode.Nodes.Add(fieldInfoNode); else TreeNode fieldInfoNode = new TreeNode(); fieldInfoNode.Text = pFeature.Fields.get_Field(j).Name + : + pFeature.Shape.GeometryType.ToString(); layerNameNode.Nodes.Add(fieldInfoNode); frmShowAttribute.AttributeTreeView.ExpandAll(); id = pEnumIDs.Next(); axMapControl1.ActiveView.Refresh(); 图十一 属性插图窗体代码:private void comboBoxlayer_SelectedIndexChanged(object sender, EventArgs e) listBoxField.Items.Clear(); listBoxValue.Items.Clear(); textBoxFilter.Clear(); string sLayerName = comboBoxLayer.Text; AxMapControl axMap = pMainFrm.getMapControl(); IFeatureLayer pFeatLyr = null; IRasterLayer pRsLayer = null; listBoxField.Items.Clear(); try for (int i = 0; i = axMap.LayerCount - 1; i+) ILayer pLyr = axMap.get_Layer(i); if (pLyr.Name = sLayerName) if (pLyr is IFeatureLayer) pFeatLyr = pLyr as IFeatureLayer; m_pFeatCls = pFeatLyr.FeatureClass; for (int j = 0; j = m_pFeatCls.Fields.FieldCount - 1; j+) listBoxField.Items.Add(m_pFeatCls.Fields.get_Field(j).Name); if(j=m_pFeatCls.FindField(Shape) listBoxField.Items.RemoveAt(j); else pRsLayer = pLyr as IRasterLayer; IRaster pInRaster = pRsLayer.Raster; m_pRaster = pInRaster; IRasterBandCollection pBandCol = pInRaster as IRasterBandCollection; IRasterBand pBand = pBandCol.Item(0); bool HasTable; pBand.HasTable(out HasTable); if (HasTable = true) m_pTable = pBand.AttributeTable; IFields pFields = m_pTable.Fields; for (i = 0; i = pFields.FieldCount - 1; i+) listBoxField.Items.Add(pFields.get_Field(i).Name); catch (Exception ex) MessageBox.Show(ex.Message); private void listBoxField_SelectedIndexChanged(object sender, EventArgs e) string sFieldName = listBoxField.Text; bool bLayerType = GetLayerType(comboBoxLayer.Text); listBoxValue.Items.Clear(); int iFieldIndex = 0; int i = 0;if (bLayerType = true) IFeatureCursor pFeatCursor = m_pFeatCls.Search(null, true); IFeature pFeat = pFeatCursor.NextFeature(); iFieldIndex = m_pFeatCls.FindField(sFieldName); while (pFeat != null) listBoxValue.Items.Add(pFeat.get_Value(iFieldIndex); pFeat = pFeatCursor.NextFeature(); else iFieldIndex = m_pTable.FindField(sFieldName); for (i = 0; i = m_pTable.RowCount(null) - 1; i+) IRow pRow = m_pTable.GetRow(i); listBoxValue.Items.Add(pRow.get_Value(iFieldIndex); /判断选择的图层是特征类还是栅格类private bool GetLayerType(string sLayerName) AxMapControl axMap = pMainFrm.getMapControl(); bool LayerType = false; for (int i = 0; i = axMap.LayerCount - 1; i+) ILayer pLyr = axMap.get_Layer(i); if (pLyr.Name = sLayerName) if (pLyr is IFeatureLayer) LayerType = true; else LayerType = false; return LayerType;private void listBoxField_DoubleClick(object sender, EventArgs e) textBoxFilter.SelectedText = listBoxField.SelectedItem.ToString() + ;private void listBoxValue_DoubleClick(object sender, EventArgs e) AxMapControl axMap = pMainFrm.getMapControl(); bool pLayerType = GetLayerType(comboBoxLayer.Text);if (pLayerType = tru

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论