(SDE、personal/File、ShapeFile、CAD数据、影像图、影像数据集)
ArcEngine 可以接受多种数据源。在开发过程中我们使用了如下几种数据源
1.企业数据库(SDE)
企业数据库需要使用SDE来管理,所以需要使用SDE的Workspace来表示连接。在AE接口中,Workspace是由Factory打开的。代码如下: // //准备连接参数
ESRI.ArcGIS.esriSystem.IPropertySet pPropSet=new PropertySetClass();
pPropSet.SetProperty("server","服务器机器名" );
pPropSet.SetProperty("instance","SDE运行的端口号");
pPropSet.SetProperty("user","用户名");
pPropSet.SetProperty("password","口令" );
pPropSet.SetProperty("version","版本");
SdeWorkspaceFactory sdeWkspFact=new SdeWorkspaceFactoryClass();
IFeatureWorkspace pFeaWksp=(IFeatureWorkspace)sdeWkspFact.Open(pPropSet,0);
其中唯一需要解释的可能就是版本(version).对于没有使用版本或者第一次连接(没有建立空间数据库,当然没有版本了). 该处使用sde.DEFAULT这个版本。这是默认的版本。
iPropertySet:: setProperty
public void setProperty(string name,object value)
2.个人数据库(PersonalGeodatabase、FileGeodatabase)
ArcEngine中个人数据库为Access。
string filePath="E:\\tt.mdb";
AccessWorkspaceFactory fac=new AccessWorkspaceFactoryClass();
IFeatureWorkspace space=(IFeatureWorkspace)fac.OpenFromFile(filePath,0); 这是用的最多的一种方式.
如果是FileGeodatabasse,则将
FileGDBWorkspaceFactory pWSF = New FileGDBWorkspaceFactory;
IFeatureWorkspace pWS1= pWSF.OpenFromFile(sPath, 0);
如果用I