由于系统将频繁在各个分矿区间加载切换,因此需要自定义一个公共的空间数据加载类,用以随时随地地加载空间地物图层,加载数据库 Geodatabase. cs 执行过程中,实例化分色类 Renderer. cs 代码如下:using System;using System. Collections. Generic;using System. Text;using ESRI. ArcGIS. esriSystem;usi...
系统编程需注意的问题
为了增加程序的可读性、可维护性和扩展性,在编写矿区突水态势评价监测系统时,应尽量使用模块。
C Sharp 是完全的面向对象,同一解决方案项目内可以随心所欲地实例化对象库或是自定义的类。整个解决方案项目中的任何地方都可以调用类中公用的方法,可以灵活的重载、重写类,并可以方便灵活的继承接口。充分利用 C Sharp 这些优势可以极大地提高代码的效率。
由于系统将频繁在各个分矿区间加载切换,因此需要自定义一个公共的空间数据加载类,用以随时随地地加载空间地物图层,加载数据库 Geodatabase. cs 执行过程中,实例化分色类 Renderer. cs 代码如下:
using System;
using System. Collections. Generic;
using System. Text;
using ESRI. ArcGIS. esriSystem;
using ESRI. ArcGIS. Carto;
using ESRI. ArcGIS. Controls;
using ESRI. ArcGIS. DataSourcesGDB;
using ESRI. ArcGIS. Geodatabase;
namespace EvalWaterIrush. Symbolization
{
class Geodatabase
{
private IPropertySet pPropertySet = new PropertySetClass( ) ;
private IWorkspaceFactory pWorkspaceFactory =new AccessWorkspaceFactoryClass( ) ;
private IFeatureWorkspace pfeatureWorkspace;
private IFeatureDataset pFeatureDataset;
private IFeatureClassContainer pFeatureClassContainer;
private IFeatureClass pFeatureClass;
#region 遍历加载空间数据库要素图层
/ / 函数重载
/ / 从要素数据集中读取要素图层数据
public Geodatabase( AxMapControl axmapcontrol1,AxMapControl axmapcontrol2,string strdb,string strdbset)
{
/ / int ig = 0;
/ / pPropertySet. SetProperty( " geodatabase" ,strdb) ;
… …
… …
… …
renderer = new Renderer( 0,255,0,0,3,255,pFeatureLayer) ;
axmapcontrol1. Map. AddLayer( pFeatureLayer) ;
axmapcontrol1. ActiveView. Refresh( ) ;
}
/ / 函数重载
/ / 从空间数据中读取要素图层数据
public Geodatabase( AxMapControl axmapcontrol1,AxMapControl axmapcontrol2,string strdb,string strfeaclass,int i) / / 函数的重载
{
/ / pPropertySet. SetProperty( " geodatabase" ,strdb) ;
……
……
……
pFeatureClass = pFeatureClassContainer. get_Class( 5) ;
pFeatureLayer. FeatureClass = pFeatureClass;
pFeatureLayer. Name = pFeatureClass. AliasName;
renderer = new Renderer( 0,255,0,0,1. 2,255,pFeatureLayer) ;
/ / axmapcontrol1 = " donghuantuo" ;
axmapcontrol1. Map. AddLayer( pFeatureLayer) ;
axmapcontrol1. ActiveView. Refresh( ) ;
}
#endregion
}
}
2020-01-14