三调管理信息系统
三调管理信息系统基于Visual Studio2015、ArcEngine10.4平台、数据库平台采用ArcSde+MS SqlServer2014,使用C#语言开发。实现了对地图的基本操作、数据库管理(数据入库、数据导出、查看数据及SQL统计分析、数据库备份与还原)、数据处理(矢量数据空间分析与处理、坐标转换、栅格处理)、质量检查(矢量数据拓扑检查、矢量数据空间质量及属性质量检查)、统计分析与地图出图等功能。系统框架如下图所示:
1、系统主界面
补充1:SDE数据库管理(包括新建SDE数据库,数据入库、数据库导出、打开数据库、DLTB属性计算、SQL查询统计、删除数据库、数据库备份与还原)
补充2:矢量质量检查(折刺角检查、面节点密度检查、复合要素检查、相邻面检查、接边检查)
2、系统详细功能介绍
2.1.1基本操作-打开数据
2.1.2 基本操作-地图操作与测量
地图操作与测量包括 放大、缩小、全图、逐级放大、逐级缩小、漫游、视图前进、视图后退、地图测量等功能。
2.1.3 基本操作-图层查询与选择
图层查询与选择包括模糊查询、坐标定位、按属性选择、按位置选择、清除选择、地图交互查询(矩形选择、多边形选择、园选择、线选择、点选择选择设置、选择导出)等功能。
2.1.3 基本操作-其他
包括地图标注、图层透明度、显示视图、编辑工具、三维模块。
2.2.1 地图工具-矢量空间分析与处理
包括矢量数据转换、缓冲分析、叠置分析(相交、裁剪、擦除、交集取反、更新)、图层字段标准化、外部数据展点(Excel转点、txt转点)
2.2.2 地图工具-坐标转换
坐标转换包括图框坐标设置、图层坐标设置、坐标转换。
2.2.3 地图工具-栅格数据处理
包括栅格格式转换、栅格裁剪、获取影像边界。
2.2.4 地图工具-矢量检查
矢量检查包括面重叠检查、面缝隙检查、折刺角检查、相互覆盖检查、面节点密度检查、线伪节点检查、自定义检查(单要素检查、双要素检查)。
2.2.5 地图工具-DLTB(地类图斑)属性一致性检查
2.3.1 统计分析-地类图斑统计分析
2.3.2统计分析-叠加统计统计分析
包括矢量叠加统计分析、流量分析
2.3.3统计分析-其他
包括 椭球面积计算、投影面积计算等。
2.4.1 地图出图-地类图斑配图
2.4.2 地图出图-土地利用现状出图
2.4.3 地图出图-地图符号化及专题图
2.4.4 地图出图-地图整饰与输出
2.5.1设置
部分源码
部分源码-数据添加
//添加ShapeFile
public static void AddShapefile(AxMapControl mapControl)
{
OpenFileDialog pOpenFileDialog = new OpenFileDialog();
pOpenFileDialog.CheckFileExists = true;
pOpenFileDialog.Title = "打开Shape文件";
pOpenFileDialog.Filter = "Shape文件(*.shp)|*.shp";
pOpenFileDialog.Multiselect = true;
if (pOpenFileDialog.ShowDialog()==DialogResult.OK)
{
string[] strShapeFiles = pOpenFileDialog.FileNames;
for (int i = 0; i < strShapeFiles.Length; i++)
{
IWorkspaceFactory pWorkspaceFactory;
IFeatureWorkspace pFeatureWorkspace;
IFeatureLayer pFeatureLayer;
string pFullPath = strShapeFiles[i];
int pIndex = pFullPath.LastIndexOf("\\");
string pFilePath = pFullPath.Substring(0, pIndex); //文件路径
string pFileName = pFullPath.Substring(pIndex + 1); //文件名
//实例化ShapefileWorkspaceFactory工作空间,打开Shape文件
pWorkspaceFactory = new ShapefileWorkspaceFactory();
pFeatureWorkspace = (IFeatureWorkspace)pWorkspaceFactory.OpenFromFile(pFilePath, 0);
//创建并实例化要素集
IFeatureClass pFeatureClass = pFeatureWorkspace.OpenFeatureClass(pFileName);
pFeatureLayer = new FeatureLayer();
pFeatureLayer.FeatureClass = pFeatureClass;
pFeatureLayer.Name = pFeatureLayer.FeatureClass.AliasName;
mapControl.Map.AddLayer(pFeatureLayer);
mapControl.ActiveView.Refresh();
}
}
}
//添加栅格文件
public static void AddRasterfile(AxMapControl mapControl)
{
OpenFileDialog pOpenFileDialog = new OpenFileDialog();
pOpenFileDialog.CheckFileExists = true;
pOpenFileDialog.Title = "打开Raster文件";
pOpenFileDialog.Filter = "栅格文件 (*.*)|*.bmp;*.tif;*.jpg;*.img|(*.bmp)|*.bmp|(*.tif)|*.tif|(*.jpg)|*.jpg|(*.img)|*.img";
pOpenFileDialog.Multiselect = true;
if (pOpenFileDialog.ShowDialog()==DialogResult.OK)
{
string[] strRasterArr = pOpenFileDialog.FileNames;
for (int i = 0; i < strRasterArr.Length; i++)
{
string pRasterFileName = strRasterArr[i];
string pPath = System.IO.Path.GetDirectoryName(pRasterFileName);
string pFileName = System.IO.Path.GetFileName(pRasterFileName);
IWorkspaceFactory pWorkspaceFactory = new RasterWorkspaceFactory();
IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(pPath, 0);
IRasterWorkspace pRasterWorkspace = pWorkspace as IRasterWorkspace;
IRasterDataset pRasterDataset = pRasterWorkspace.OpenRasterDataset(pFileName);
//影像金字塔判断与创建
IRasterPyramid3 pRasPyrmid;
pRasPyrmid = pRasterDataset as IRasterPyramid3;
if (pRasPyrmid != null)
{
if (!(pRasPyrmid.Present))
{
pRasPyrmid.Create(); //创建金字塔
}
}
IRaster pRaster;
pRaster = pRasterDataset.CreateDefaultRaster();
IRasterLayer pRasterLayer;
pRasterLayer = new RasterLayerClass();
pRasterLayer.CreateFromRaster(pRaster);
ILayer pLayer = pRasterLayer as ILayer;
mapControl.AddLayer(pLayer, 0);
mapControl.ActiveView.Refresh();
}
}
}
//添加CAD文件
public static void AddCADByLayer(AxMapControl mapControl)
{
IWorkspaceFactory pWorkspaceFactory;
IFeatureWorkspace pFeatureWorkspace;
IFeatureLayer pFeatureLayer;
IFeatureClass pFeatureClass;
OpenFileDialog pOpenFileDialog = new OpenFileDialog();
pOpenFileDialog.Filter = "CAD(*.dwg)|*.dwg";
pOpenFileDialog.Title = "打开CAD数据文件";
pOpenFileDialog.Multiselect = false;
if (pOpenFileDialog.ShowDialog()==DialogResult.OK)
{
string pFullPath = pOpenFileDialog.FileName;
//获取文件名和文件路径
int pIndex = pFullPath.LastIndexOf("\\");
string pFilePath = pFullPath.Substring(0, pIndex);
string pFileName = pFullPath.Substring(pIndex + 1);
pWorkspaceFactory = new CadWorkspaceFactory();
pFeatureWorkspace = (IFeatureWorkspace)pWorkspaceFactory.OpenFromFile(pFilePath, 0);
//加载CAD文件中的线文件
pFeatureClass = pFeatureWorkspace.OpenFeatureClass(pFileName + ":polyline");
pFeatureLayer = new FeatureLayerClass();
pFeatureLayer.Name = pFileName;
pFeatureLayer.FeatureClass = pFeatureClass;
mapControl.Map.AddLayer(pFeatureLayer);
mapControl.ActiveView.Refresh();
}
}
//添加GDB
private void BTN_OpenGDB_ItemClick(object sender, ItemClickEventArgs e)
{
MyFolderBrowserDialog mfbd = new MyFolderBrowserDialog();
if (mfbd.ShowDialog(this) == DialogResult.OK)
{
listFLayer = new List<IFeatureLayer>();
axMapControl1.ClearLayers();//清空地图
TabCt_AddAttributes.TabPages.Clear();//清空属性表
string strGDB_Path = mfbd.DirectoryPath;
//strZHQSelGDBPath = mfbd.DirectoryPath;
FileGDBWorkspaceFactory fac = new FileGDBWorkspaceFactory();
IFeatureWorkspace pFtWS = (IFeatureWorkspace)fac.OpenFromFile(strGDB_Path, 0);
IWorkspace pWork = (IWorkspace)pFtWS;
IEnumDataset pEnumDs = pWork.get_Datasets(esriDatasetType.esriDTFeatureClass);
IDataset pDs = pEnumDs.Next();
axMapControl1.Map.ClearLayers();
//tslbStatus.Text = "正在加载要素…";
statusStrip1.Refresh();
while (pDs != null)
{
IFeatureClass temp = pDs as IFeatureClass;
IFeatureLayer tempLayer = new FeatureLayer();
tempLayer.FeatureClass = temp;
tempLayer.Name = tempLayer.FeatureClass.AliasName;
listFLayer.Add(tempLayer);
axMapControl1.AddLayer(tempLayer);
axTOCControl1.Refresh();
//listBox_unck_FtLy.Items.Add(tempLayer.FeatureClass.AliasName);
//tspCombx_unck_SFZ.Items.Add(tempLayer.FeatureClass.AliasName);
pDs = pEnumDs.Next();
}
//tslbStatus.Text = "加载完成!";
tlSpStLb_GDBPath.Caption = "当前数据库:" + strGDB_Path;
//tlSpStLb.Text += " 当前数据库:" + Path.GetFileName(strGDB_Path);
statusStrip1.Refresh();
}
}
部分源码-打开属性表(动态添加属性表控件)
public partial class UCFormAttribute : DevExpress.XtraEditors.XtraUserControl
{
public UCFormAttribute()
{
InitializeComponent();
}
IFeatureLayer pTocFeatureLayer = null;
public void InitData(IFeatureLayer pTocFtLayer)
{
gridControl1.DataSource = null;
pTocFeatureLayer = pTocFtLayer;
gridControl1.DataSource= FeatureLayterToDataTable(pTocFeatureLayer.FeatureClass);
// groupControl1.Text = pTocFeatureLayer.FeatureClass.AliasName;
}
public IMap pMap = null;
public AxMapControl pMapControl = null;
private DataTable FeatureLayterToDataTable(IFeatureClass pFeatCls)
{
DataTable dt = new DataTable();
IFeature pFeature = null;
DataTable pFeatDT = new DataTable(); //创建数据表
DataRow pDataRow = null; //数据表行变量
DataColumn pDataCol = null; //数据表列变量
IField pField = null;
for (int i = 0; i < pFeatCls.Fields.FieldCount; i++)
{
pDataCol = new DataColumn();
pField = pFeatCls.Fields.get_Field(i);
pDataCol.ColumnName = pField.Name; //获取字段名作为列标题
pDataCol.DataType = Type.GetType("System.Object");//定义列字段类型
pFeatDT.Columns.Add(pDataCol); //在数据表中添加字段信息
}
IFeatureCursor pFeatureCursor = pFeatCls.Search(null, true);
pFeature = pFeatureCursor.NextFeature();
while (pFeature != null)
{
pDataRow = pFeatDT.NewRow();
//获取字段属性
for (int k = 0; k < pFeatDT.Columns.Count; k++)
{
pDataRow[k] = pFeature.get_Value(k);
}
pFeatDT.Rows.Add(pDataRow); //在数据表中添加字段属性信息
pFeature = pFeatureCursor.NextFeature();
}
//释放指针
System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);
dt = pFeatDT;
return dt;
}
int selObjID= -1;
private void gridView1_MouseUp(object sender, MouseEventArgs e)
{
int selectindex = gridView1.SelectedRowsCount;
if (e.Button == MouseButtons.Right && selectindex == 1)
{
DataRow dr = gridView1.GetDataRow(gridView1.FocusedRowHandle);
selObjID = Convert.ToInt32(dr[0].ToString());
popupMenu1.ShowPopup(Control.MousePosition);
}
}
private void TSMenuIt_Panto_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
IFeature pFeature =pTocFeatureLayer.FeatureClass.GetFeature(selObjID);
clsFlashFeatureClass.PanToFeature(pFeature, pMapControl);
}
private void TSMenuIt_Zoomto_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
IFeature pFeature = pTocFeatureLayer.FeatureClass.GetFeature(selObjID);
clsFlashFeatureClass.ZoomToFeature(pFeature, pMapControl);
}
private void TSMenuIt_Flash_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
IFeature pFeature = pTocFeatureLayer.FeatureClass.GetFeature(selObjID);
clsFlashFeatureClass.FlashFeature(pFeature, pMapControl);
}
}
部分源码-创建mdb gdb
public static class clsCreateDataBaseHelper
{
/// <summary>
/// 创建mdb数据库,返回其工作空间
/// </summary>
/// <param name="strMdbPath"></param>
/// <returns></returns>
private static IWorkspace CreateMdb(string strMdbPath)
{
string sPathFloder = System.IO.Path.GetDirectoryName(strMdbPath);
string sPathName = System.IO.Path.GetFileName(strMdbPath);
//string sFileExtension = System.IO.Path.GetExtension(strMdbPath).ToUpper();
IWorkspaceName pWorkspaceName = null;
string sWorkspaceId = "esriDataSourcesGDB.AccessWorkspaceFactory";
pWorkspaceName = ((IWorkspaceFactory)Activator.CreateInstance(Type.GetTypeFromProgID(sWorkspaceId))).Create(sPathFloder, sPathName, null, 0);
IName name = (IName)pWorkspaceName;
IWorkspace workspace = (IWorkspace)name.Open();
return workspace;
}
/// <summary>
/// 创建gdb数据库,返回其工作空间
/// </summary>
/// <param name="strGdbPath"></param>
/// <returns></returns>
private static IWorkspace CreateGdb(string strGdbPath)
{
string sPathFloder = System.IO.Path.GetDirectoryName(strGdbPath);
string sPathName = System.IO.Path.GetFileName(strGdbPath);
string sWorkspaceId = "esriDataSourcesGDB.FileGDBWorkspaceFactory";
IWorkspaceName pWorkspaceName = null;
pWorkspaceName = ((IWorkspaceFactory)Activator.CreateInstance(Type.GetTypeFromProgID(sWorkspaceId))).Create(sPathFloder, sPathName, null, 0);
IName name = (IName)pWorkspaceName;
IWorkspace workspace = (IWorkspace)name.Open();
return workspace;
}
public static IWorkspace CreateMdb()
{
IWorkspace workspace = null;
SaveFileDialog ofd = new SaveFileDialog();
ofd.Filter = "mdb文件(*.mdb)|*.mdb";
ofd.AddExtension = true;
ofd.Title = "新建mdb数据库";
if (ofd.ShowDialog() == DialogResult.OK)
{
workspace = CreateMdb(ofd.FileName);
}
return workspace;
}
public static IWorkspace CreateGdb()
{
IWorkspace workspace = null;
FolderBrowserDialog fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() == DialogResult.OK)
{
string foldername = fbd.SelectedPath;
string strGDBPath = foldername + ".gdb";
//string gdbName = Path.GetFileName(strGDBPath);
//Computer computer = new Computer();
//computer.FileSystem.RenameDirectory(fbd.SelectedPath, gdbName);
workspace = CreateGdb(strGDBPath);
DirectoryInfo di = new DirectoryInfo(foldername);
di.Delete(false);
}
return workspace;
}
}
欢迎交流:18798835893