首页 ArcGIS engine实现查询闪烁

ArcGIS engine实现查询闪烁

举报
开通vip

ArcGIS engine实现查询闪烁实现查询闪烁 frmInputQueryInfo myQueryInfo = new frmInputQueryInfo(); myQueryInfo.ShowDialog(); string strBusLineName = myQueryInfo.getQueryKey(); if(strBusLineName.Equals(“”)){return;} IFeatureLayer pFeatureLayer = axMapControl1.get_Layer(1) as IFeatureLayer I...

ArcGIS engine实现查询闪烁
实现查询闪烁 frmInputQueryInfo myQueryInfo = new frmInputQueryInfo(); myQueryInfo.ShowDialog(); string strBusLineName = myQueryInfo.getQueryKey(); if(strBusLineName.Equals(“”)){return;} IFeatureLayer pFeatureLayer = axMapControl1.get_Layer(1) as IFeatureLayer IQueryFilter pQueryFilter = new QueryFilter(); pQueryFilter.WhereClause = “[BusLineName]=’”+strBusLineName+”’”; IFeatureCursor pFeatureCur = pFeatureLayer.Search(pQueryFilter,false); IFeature pFeature = null; pFeature = pFeatureCur.NextFeature(); if(null==pFeature) return; IEnvelope pEnvelope = pFeature.Shape.Envelope; axMapControl1.Extent = pEnvelope; axMapControl1.ActiveView.Refresh(); Aplication.DoEvent(); axMapControl1.FlashShape(pFeature.Shape,3,800,null); 向上移动图层: If(nIndex == 0) return; ILayer pLayer = m_pMap.get_Layer(nIndex); M_pMap.MoveLayer(pLayer,nIndex – 1) 向下移动图层 If(nIndex == m_pMap.get_LayerCount - 1) return; ILayer pLayer = m_pMap.get_Layer(nIndex); M_pMap.MoveLayer(pLayer,nIndex – 1) 实现可视化 m_pMap.get_Layer(nIndex).Visible = bVisible; IActiveView pActiveView = m_pMap as IActiveView; pActiveView.Refresh(); AddFeature publicoverridevoid OnCreate(object hook) { try { m_hookHelper = new HookHelperClass(); m_hookHelper.Hook = hook; if (m_hookHelper.ActiveView == null) {m_hookHelper = null;}} catch{m_hookHelper = null;} if (m_hookHelper == null) base.m_enabled = false; else base.m_enabled = true; publicoverridevoid OnClick() {// 弹出对话框,问是否选择已有图层还是创建新的图层 frmAddFeature addFtrForm = new frmAddFeature(this.m_hookHelper.FocusMap as IMap); addFtrForm.ShowDialog(); m_pCurFtrLyr = addFtrForm.m_pCurrentLayer as IFeatureLayer; if (m_pCurFtrLyr == null)//有可能选择的不是要素图层 {MessageBox.Show("未选择图层或图层不是要素图层,请重新择!");} } publicoverridevoid OnMouseDown(int Button, int Shift, int X, int Y) { if (m_pCurFtrLyr == null) { MessageBox.Show("未选择图层或图层不是要素图层,请重新选择!”);return; } IPoint pPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); m_pOptFtr.CreatePointFeature(m_pCurFtrLyr, pPoint); m_hookHelper.ActiveView.Refresh(); } publicoverridevoid OnKeyDown(int keyCode, int Shift) {if (keyCode == 46)//删除键 {if (m_pCurFeature == null || m_pCurFtrLyr == null){ return; } System.Diagnostics.Trace.WriteLine("开始编辑操作,准备删除"); //删除要素? m_pCurFeature.Delete(); m_pCurFeature = null; m_hookHelper.ActiveView.Refresh(); } else { base.OnKeyDown(keyCode, Shift); } } 移动对象到当前鼠标位置 m_MovePointFeedback.MoveTo(pPoint); 设置显示对象,并启动移动 m_MovePointFeedback.Display = m_hookHelper.ActiveView.ScreenDisplay; m_MovePointFeedback.Start(m_pCurFeature.Shape as IPoint, pPoint); 移动要素 IPoint centerPoint = new PointClass { X = (m_pElement.Geometry.Envelope.LowerLeft.X + m_pElement.Geometry.Envelope.LowerRight.X) / 2, Y = (m_pElement.Geometry.Envelope.LowerLeft.Y + m_pElement.Geometry.Envelope.UpperRight.Y) / 2 }; if (m_pElement is AnnotationElement) { //如果旧点为空,则赋 MouseDown事件所获取的点值 if (m_oldPoint == null) m_oldPoint = m_pPoint; publicoverridevoid OnMouseUp(int Button, int Shift, int X, int Y) {//鼠标点击填起则表示新的点要素的位置 if (Button != 1 || m_pCurFeature == null || m_pCurFtrLyr == null) return; IGeometry resultGeometry = null; if (m_pCurFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint) { //停止移动 resultGeometry = m_MovePointFeedback.Stop() as IGeometry; m_pCurFeature.Shape = resultGeometry; } elseif (m_pCurFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline) { //停止移动 resultGeometry = m_MoveLineFeedback.Stop() as IGeometry; m_pCurFeature.Shape = resultGeometry; } elseif (m_pCurFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon) {//停止移动 resultGeometry = m_MovePolygonFeedback.Stop() as IGeometry; m_pCurFeature.Shape = resultGeometry;} //开始存储新的点 IDataset dataset = m_pCurFtrLyr.FeatureClass as IDataset; IWorkspace workspace = dataset.Workspace; IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit; //开始编辑 workspaceEdit.StartEditing(true); workspaceEdit.StartEditOperation(); //保存实体 m_pCurFeature.Store(); //结束编辑 workspaceEdit.StopEditOperation(); workspaceEdit.StopEditing(true); m_hookHelper.ActiveView.Refresh(); m_hookHelper.FocusMap.ClearSelection(); 根据注记的参考坐标调整字体显示大小【修正部分】? IAnnotationClassExtension pAnnotationClassExtension = AnnotationLayer.FeatureClass.Extension as IAnnotationClassExtension; publicoverridevoid OnMouseDown(int Button, int Shift, int X, int Y) { //在当前位置生成一个Element IMarkerElement pMarkerElement; pMarkerElement = new MarkerElementClass(); //创建一个新的元素 ISimpleMarkerSymbol pMarkerSym; pMarkerSym = new SimpleMarkerSymbolClass(); //创建新符号 pMarkerSym.Style = esriSimpleMarkerStyle.esriSMSDiamond; //指定符号的样式风格 pMarkerSym.Color = Uitility.GetRGB(0,255,0); //符号的颜色设为红色 pMarkerElement.Symbol = pMarkerSym; //把符号赋给元素 IElement pElement = pMarkerElement as IElement; IPoint pPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); pElement.Geometry = pPoint; m_hookHelper.ActiveView.GraphicsContainer.AddElement(pElement,0); m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } 缓冲区分析 publicoverridevoid OnMouseDown(int Button, int Shift, int X, int Y) { if (Button != 1 || m_hookHelper.FocusMap.LayerCount <= 0) return; IActiveView pActiveView = m_hookHelper.ActiveView; IGraphicsContainer pGraCont = (IGraphicsContainer)pActiveView; //删除地图上添加的所有DElement pGraCont.DeleteAllElements(); //获得点击位置并转化为点图形要素? IPoint pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); //获得地图中图层? IFeatureLayer pFeatureLayer = m_hookHelper.FocusMap.get_Layer(0) as IFeatureLayer; if (pFeatureLayer == null) { return; } //先创建一个点的缓冲区? ITopologicalOperator pTop = pPoint as ITopologicalOperator; double len = Uitility.ConvertPixelsToMapUnits(pActiveView, 5); IGeometry pBuffer = pTop.Buffer(len); IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass; //进行点击查询图层要素 ISpatialFilter pSpatialFilter = new SpatialFilterClass(); pSpatialFilter.Geometry = pBuffer.Envelope;//pPoint; switch (pFeatureClass.ShapeType) { case esriGeometryType.esriGeometryPoint: pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains; break; case esriGeometryType.esriGeometryPolyline: pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelCrosses; break; case esriGeometryType.esriGeometryPolygon: pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; break; default: break; } IFeatureCursor featureCursor = pFeatureClass.Search(pSpatialFilter, false); //获得点击查询的要素 IFeature pFeature = featureCursor.NextFeature(); if (pFeature != null ) { IGeometry pGeometry = pFeature.Shape as IGeometry; //通过接口进行多边形的简化处理 ITopologicalOperator pTopoOpe = (ITopologicalOperator)pGeometry; pTopoOpe.Simplify(); //通过创建缓冲区相关 double length = Uitility.ConvertPixelsToMapUnits(pActiveView, 10); IGeometry pBufferGeo = pTopoOpe.Buffer(length); //创建多边形符号样式并添加到地图上 IScreenDisplay pdisplay = pActiveView.ScreenDisplay; ISimpleFillSymbol pSymbol = new SimpleFillSymbolClass(); pSymbol.Style = esriSimpleFillStyle.esriSFSCross; RgbColor pColor = new RgbColorClass(); pColor.Blue = 200; pColor.Red = 211; pColor.Green = 100; pSymbol.Color = (IColor)pColor; //创建多边形渲染效果的 Element IFillShapeElement pFillShapeElm = new PolygonElementClass(); IElement pElm = (IElement)pFillShapeElm; pElm.Geometry = pBufferGeo; pFillShapeElm.Symbol = pSymbol; //将渲染之后的多边形Element添加到地图IGraphicsContainer层中 pGraCont.AddElement((IElement)pFillShapeElm, 0); } //刷新地图 pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } 矢量分析 publicoverridevoid OnMouseDown(int Button, int Shift, int X, int Y) { if (Button != 1 || m_hookHelper.FocusMap.LayerCount <= 0) return; IActiveView pActiveView = m_hookHelper.ActiveView; IGraphicsContainer pGraCont = (IGraphicsContainer)pActiveView; //删除地图上添加的所有Element pGraCont.DeleteAllElements(); //获得点击位置并转化为点图形要素? IPoint pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); //获得地图中图层? IFeatureLayer pFeatureLayer = m_hookHelper.FocusMap.get_Layer(0) as IFeatureLayer; if (pFeatureLayer == null) { return; } IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass; //进行点击查询图层要素? ISpatialFilter pSpatialFilter = new SpatialFilterClass(); pSpatialFilter.Geometry = pPoint; pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; IFeatureCursor featureCursor = pFeatureClass.Search(pSpatialFilter, false); //获得点击查询的要素 IFeature pFeature = featureCursor.NextFeature(); if (pFeature != null&& pFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon) { IGeometry pGeometry = pFeature.Shape as IGeometry; ITopologicalOperator pTopoOpe = (ITopologicalOperator)pGeometry; //获取边界 IGeometry pBoundary = pTopoOpe.Boundary; ILineElement pLineEle = new LineElementClass(); ISimpleLineSymbol pSLS = new SimpleLineSymbol(); IRgbColor pColor = new RgbColor(); pColor.Red = 0; pColor.Green = 255; pColor.Blue = 0; pSLS.Color = pColor; pSLS.Width = 5; pLineEle.Symbol = pSLS; IElement pElement = pLineEle as IElement; pElement.Geometry = pBoundary; pGraCont.AddElement(pElement, 0); //显示边界} //刷新地图 pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
本文档为【ArcGIS engine实现查询闪烁】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_321635
暂无简介~
格式:doc
大小:39KB
软件:Word
页数:0
分类:互联网
上传时间:2019-09-20
浏览量:23