属性查询代码.doc_第1页
属性查询代码.doc_第2页
属性查询代码.doc_第3页
属性查询代码.doc_第4页
属性查询代码.doc_第5页
已阅读5页,还剩16页未读 继续免费阅读

下载本文档

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

文档简介

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using QueryAttri;using ESRI.ArcGIS.Geodatabase;using ESRI.ArcGIS.Geometry;using ESRI.ArcGIS.SystemUI;using ESRI.ArcGIS.DataSourcesFile;using ESRI.ArcGIS.Carto;using ESRI.ArcGIS.Controls;using ESRI.ArcGIS.Display;using System.IO;using System.Data.OleDb;namespace 属性查询 public partial class Form1 : Form public Form1() InitializeComponent(); string layername; string fieldname; private ILayer m_curLayer; private ICursor m_fetureSelCursor; private IMap m_map; private IActiveView m_activeView; private QueryAttri.UserControl1 UserControl11; private System.Windows.Forms.ToolBarButton ToolBarButton2; private void Form1_Load(object sender, EventArgs e) m_map = axMapControl1.Map ; m_curLayer = axMapControl1.Map.get_Layer(0); private double ConvertPixelsToMapUnits(IMap pMap, double pixelUnits) double temp; IActiveView pActiveView; pActiveView = pMap as IActiveView; double realWorldDisplayExtent; int pixelExtent; double sizeOfOnePixel; tagRECT ptR; ptR = pActiveView.ScreenDisplay.DisplayTransformation.get_DeviceFrame(); pixelExtent = ptR.right - ptR.left; realWorldDisplayExtent = pActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds.Width; sizeOfOnePixel = realWorldDisplayExtent / pixelExtent; temp = pixelUnits * sizeOfOnePixel; return temp; private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) m_map.ClearSelection(); switch (axMapControl1.MousePointer) case esriControlsMousePointer.esriPointerIdentify: IFeatureLayer pFeatureLayer; IFeatureClass pFeatureClass; ISpatialFilter pSpatialFilter; IQueryFilter pFilter; IActiveView pActiveView; IGeometry pGeometry; IPoint pPoint; if (m_curLayer = null) return; pFeatureLayer = m_curLayer as FeatureLayer; pFeatureClass = pFeatureLayer.FeatureClass; if (pFeatureClass = null) return; /*屏幕坐标转换为地图坐标 m_activeView = m_map as IActiveView; pPoint = m_activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y); pGeometry = pPoint; /*生成4个像素单位缓冲区 double pLength; pLength = ConvertPixelsToMapUnits(m_map, 16); ITopologicalOperator pTopologicalOperator; pTopologicalOperator = pGeometry as ITopologicalOperator; IGeometry pBuffer; pBuffer = pTopologicalOperator.Buffer(pLength); pGeometry = pBuffer.Envelope; /*清除前一个选择 m_map.ClearSelection(); /UnShowAllVertex() m_activeView.Refresh(); /m_activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); /*设置空间过滤 pSpatialFilter = new SpatialFilter(); pSpatialFilter.Geometry = pGeometry; switch (pFeatureClass.ShapeType) case esriGeometryType.esriGeometryPoint: pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains; break; case esriGeometryType.esriGeometryLine: pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; break; case esriGeometryType.esriGeometryPolyline: pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; break; case esriGeometryType.esriGeometryPolygon: pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIndexIntersects; break; pSpatialFilter.GeometryField = pFeatureClass.ShapeFieldName; pFilter = pSpatialFilter; /*空间查询 IFeatureCursor pCursor; pCursor = pFeatureLayer.Search(pFilter, false); /*在地图上选择特征 IFeature pFeature; pFeature = pCursor.NextFeature(); /如果没有选中地物 if (pFeature = null) m_map.ClearSelection(); m_activeView.Refresh(); /*高亮显示 while (pFeature != null) m_map.SelectFeature(m_curLayer, pFeature); pFeature = pCursor.NextFeature(); /*地图刷新esriViewGeoSelection m_activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); if (this.UserControl11 = null) this.UserControl11 = new QueryAttri.UserControl1(axMapControl1.Object); /this.UserControl11.Load(); (System.ComponentModel.ISupportInitialize)this.axMapControl1).BeginInit(); this.UserControl11.Location = new System.Drawing.Point(480, 32); this.UserControl11.Name = UserControl11; this.UserControl11.Size = new System.Drawing.Size(480, 360); this.UserControl11.TabIndex = 5; this.Controls.Add(this.UserControl11); else this.UserControl11.initSelectFeatures(); return; private void toolStrip

温馨提示

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

评论

0/150

提交评论