Arcgis---使用sql数据库中的数据刷新图层
来源:互联网 发布:淘宝消保30元的条件 编辑:程序博客网 时间:2024/06/05 05:38
使用sql语句select需要的数据,通过Arcgis的API插入到相应图层文件中,插入的数据可以在.dbf文件中查看,最后使用Arcgis的API刷新图层即可
using System;using System.Collections;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;using ESRI.ArcGIS.esriSystem;using ESRI.ArcGIS.Carto;using ESRI.ArcGIS.Controls;using ESRI.ArcGIS.SystemUI;using ESRI.ArcGIS.Geometry;using ESRI.ArcGIS.Geodatabase;using ESRI.ArcGIS.DataSourcesFile;using ESRI.ArcGIS.Display;using ESRI.ArcGIS.Analyst3D;using Wellcomm.DBUtility.Ibatis; // 自定义using Wellcomm.Model; // 自定义namespace Wellcomm.BLL.GIS{ /// <summary> /// 覆盖网格,gxid,gyid,enodeb,ci,cellname /// </summary> public class OperateCoverGirdLayer { private IFeatureLayer pFeatureLayer; private IFeatureClass pFeatureClass; private int RecePowerIndex; private int PathLossIndex; private int GXIDIndex; private int GYIDIndex; private int cellNameIndex; private int eNodeBIndex; private int CIIndex; // 列名 public OperateCoverGirdLayer() { pFeatureLayer = GISMapApplication.Instance.GetLayer("覆盖") as IFeatureLayer; pFeatureClass=pFeatureLayer.FeatureClass; this.RecePowerIndex=pFeatureClass.FindField("RecePower"); this.PathLossIndex=pFeatureClass.FindField("PathLoss"); this.GXIDIndex = pFeatureClass.FindField("GXID"); this.GYIDIndex = pFeatureClass.FindField("GYID"); this.cellNameIndex = pFeatureClass.FindField("CellName"); this.eNodeBIndex = pFeatureClass.FindField("eNodeB"); this.CIIndex = pFeatureClass.FindField("CI"); } /// <summary> /// 删除图层所有要素 /// </summary> public void ClearLayer() { FeatureUtilities.DeleteFeatureLayerFeatrues(this.pFeatureLayer); } /// <summary> /// 构造小区覆盖网格 /// </summary> /// <param name="cellname"></param> /// <param name="enodeb"></param> /// <param name="ci"></param> public void constuctCellGrids(string cellname, int enodeb, int ci) { DataTable gridTable = new DataTable(); Hashtable ht = new Hashtable(); ht["eNodeB"] = enodeb; ht["CI"] = ci; gridTable = IbatisHelper.ExecuteQueryForDataTable("GetSpecifiedCellGrids", ht); /* * 通过xml读取数据库 * <!--获取指定小区名称的网格--> <select id="GetSpecifiedCellGrids" parameterClass="Hashtable"> select a.GXID, a.GYID, b.MinLong, b.MinLat, b.MaxLong, b.MaxLat, a.ReceivedPowerdbm, a.PathLoss * from tbGridPathloss a, tbGridDem b * where a.GXID = b.GXID and a.GYID = b.GYID * and a.eNodeB = '$eNodeB$' and a.CI = '$CI$' * and a.ReceivedPowerdbm > -130 </select> */ IDataset dataset = (IDataset)pFeatureLayer.FeatureClass; IWorkspace workspace = dataset.Workspace; IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace; workspaceEdit.StartEditing(true); workspaceEdit.StartEditOperation(); IFeatureCursor pFeatureCursor = pFeatureClass.Insert(true); IFeatureBuffer pFeatureBuffer; int gxid, gyid; float x1, y1, x2, y2; float recePower, pathLoss; //循环添加 foreach (DataRow dataRow in gridTable.Rows) { gxid = int.Parse(dataRow[0].ToString()); gyid = int.Parse(dataRow[1].ToString()); if (!(float.TryParse(dataRow[2].ToString(), out x1) && float.TryParse(dataRow[3].ToString(), out y1) && float.TryParse(dataRow[4].ToString(), out x2) && float.TryParse(dataRow[5].ToString(), out y2) && float.TryParse(dataRow[6].ToString(), out recePower) && float.TryParse(dataRow[7].ToString(), out pathLoss))) continue; IPoint pointA = GeometryUtilities.ConstructPoint2D(x1, y1); IPoint pointB = GeometryUtilities.ConstructPoint2D(x2, y1); IPoint pointC = GeometryUtilities.ConstructPoint2D(x2, y2); IPoint pointD = GeometryUtilities.ConstructPoint2D(x1, y2); IGeometryCollection pGeometryColl = GeometryUtilities.ConstructPolygon(new IPoint[] { pointA, pointB, pointC, pointD }); pFeatureBuffer = pFeatureClass.CreateFeatureBuffer(); pFeatureBuffer.Shape = pGeometryColl as IGeometry; // 形状 pFeatureBuffer.set_Value(this.GXIDIndex, gxid); pFeatureBuffer.set_Value(this.GYIDIndex, gyid); pFeatureBuffer.set_Value(this.eNodeBIndex, enodeb); pFeatureBuffer.set_Value(this.CIIndex, ci); pFeatureBuffer.set_Value(this.cellNameIndex, cellname); pFeatureBuffer.set_Value(this.RecePowerIndex, recePower); pFeatureBuffer.set_Value(this.PathLossIndex, pathLoss); pFeatureCursor.InsertFeature(pFeatureBuffer); } //一次性提交 pFeatureCursor.Flush(); //stop editing workspaceEdit.StopEditOperation(); workspaceEdit.StopEditing(true); GISMapApplication.Instance.RefreshLayer(pFeatureLayer); }
using System;using System.Collections.Generic;using System.Text;using System.Windows.Forms;using ESRI.ArcGIS.Controls;using ESRI.ArcGIS.SystemUI;using ESRI.ArcGIS.Carto;using ESRI.ArcGIS.Analyst3D;using ESRI.ArcGIS.Geometry;using ESRI.ArcGIS.Geodatabase;namespace Wellcomm.BLL.GIS{ /// <summary> /// GIS的入口操作(采用单例模式) /// </summary> public class GISMapApplication { private static GISMapApplication instance = null; //当前对象的实例 private AxSceneControl m_axSceneControl = null; private ISceneControl m_sceneControl = null; public AxSceneControl AxSceneControl { get { return m_axSceneControl; } set { m_axSceneControl = value; } } /// <summary> /// 地图控件的引用 /// </summary> public ISceneControl SceneControl { get { return m_sceneControl; } set { m_sceneControl = value; } } /// <summary> /// 初始化的一些方法 /// </summary> public void Init(AxSceneControl axSceneControl) { if (axSceneControl != null) { this.m_axSceneControl = axSceneControl; m_sceneControl = axSceneControl.Object as ISceneControl; } } /// <summary> /// 当前实例对象(单例模式) /// </summary> public static GISMapApplication Instance { get { if (instance == null) { lock (m_syncObject) { if (instance == null) { instance = new GISMapApplication(); } } } return instance; } } /// <summary> /// 刷新指定图层 /// </summary> /// <param name="pObject"></param> public void RefreshLayer(object pObject) { if (this.m_sceneControl == null) return; ISceneGraph pSceneGragh = m_sceneControl.SceneGraph; pSceneGragh.Invalidate(pObject, true, false); pSceneGragh.ActiveViewer.Redraw(true); pSceneGragh.RefreshViewers(); } }
using System;using System.Linq;using System.Collections.Generic;using Wellcomm.BLL.Geometric;using ESRI.ArcGIS.Geometry;namespace Wellcomm.BLL.GIS{ public static class GeometryUtilities { public static IGeometryCollection ConstructPolygon(IPoint[] pointArray) { //创建一个Ring对象,通过ISegmentCollection接口向其中添加Segment对象 object o = Type.Missing; ISegmentCollection pSegCollection = new RingClass(); for (int i = 0; i < pointArray.Length-1; i++) { IPoint from = pointArray[i]; IPoint to = pointArray[i+1]; ILine pLine = new LineClass(); //设置Line对象的起始终止点 pLine.PutCoords(from, to); //QI到ISegment ISegment pSegment = pLine as ISegment; pSegCollection.AddSegment(pSegment, ref o, ref o); } //QI到IRing接口封闭Ring对象,使其有效 IRing pRing = pSegCollection as IRing; pRing.Close(); //使用Ring对象构建Polygon对象 IGeometryCollection pGeometryColl = new PolygonClass(); pGeometryColl.AddGeometry(pRing, ref o, ref o); return pGeometryColl; } }}
0 0
- Arcgis---使用sql数据库中的数据刷新图层
- Arcgis Server JSAPI中的图层消息
- 不刷新页面筛选数据库中的数据
- 不刷新页面筛选数据库中的数据
- 不刷新页面筛选数据库中的数据
- 自己写的数据访问层(使用ini文件加密存储sql数据库登陆信息)
- sql导出数据库中的数据
- ArcGIS Engine中实现图层属性数据的显示
- Arcgis图层分组
- arcgis 动态图层
- ArcGIS图层介绍
- ARCGIS Engine 图层
- ArcGis发布图层
- arcgis 图层概念
- ArcGIS动态图层
- 动态图层在ArcGIS 10中的一些改进
- ArcGIS中的 .tpk数据
- ArcGIS中的三维数据
- 强引用,软引用,弱引用和虚引用
- Android app 上传到google play,需要设置 隐私政策声明
- 使用facebook messenger做外贸推广的优势
- 编译驱动ko文件
- c1240瘦ap转胖ap
- Arcgis---使用sql数据库中的数据刷新图层
- 陶陶摘苹果
- JAVA NIO Scatter/Gather(矢量IO)
- MySql慢查询日志查看
- ASP.NET中页面之间的数据传递问题
- [程序员面试金典]元素查找
- 2440超详细uboot移植笔记(四)------剪裁uboot
- 解析eclipse控制台
- mysql 5.7 主从同步配置(windows)