AE开发技术文档--8种数据访问方法

转自原文 AE开发技术文档--8种数据访问方法

1、shapefile

IWorkspaceFactory pWorkspaceFactory;
pWorkspaceFactory = new ShapefileWorkspaceFactoryClass();
IFeatureWorkspace pFeatWS;
pFeatWS = pWorkspaceFactory.OpenFromFile(@"D:\Data", 0) as IFeatureWorkspace;

//打开一个要素类
IFeatureClass pFeatureClass = pFeatWS.OpenFeatureClass("Cities");

2、coverage

Coverage 是一个集合,它可以包含一个或多个要素类。Coverage 数据的工作空间也是它所在的文件夹;由于Coverage 可以包含多个要素类,得到工作空间后在打开具体的要素类时可以用“Coverage 名称:要素类名称”,例如下面代码中的“basin:polygon”。

IWorkspaceFactory pFactory = new ArcInfoWorkspaceFactoryClass();
IWorkspace pWorkspace = pFactory.OpenFromFile(@"D:\ArcTutor\TopologyData", 0);
IFeatureWorkspace pFeatWorkspace = pWorkspace as IFeatureWorkspace;
IFeatureClass pFeatureClass = pFeatWorkspace.OpenFeatureClass("basin:polygon");

3、Geodatabase

   Personal Geodatabase 数据的工作空间指的是扩展名为mdb 的文件。以下是打开位于Monto.mdb 中的Water 要素类的代码。

IWorkspaceFactory pFactory = new AccessWorkspaceFactoryClass();
IWorkspace pWorkspace = pFactory.OpenFromFile(@"D:\ArcTutor\Monto.mdb", 0);
IFeatureWorkspace pFeatWorkspace = pWorkspace as IFeatureWorkspace;
IFeatureClass pFeatureClass = pFeatWorkspace.OpenFeatureClass("Water")

4、ArcSDE(Enterprise Geodatabase)

IWorkspaceFactory pWorkspaceFactory = new SdeWorkspaceFactoryClass();
IPropertySet propSet = new PropertySetClass();
propSet.SetProperty("SERVER", "actc");
propSet.SetProperty("INSTANCE", "5151");
propSet.SetProperty("USER", "apdm");
propSet.SetProperty("ASSWORD", "apdm");
propSet.SetProperty("VERSION", "SDE.DEFAULT");
IWorkspace pWorkspace = pWorkspaceFactory.Open(propSet, 0);
IFeatureWorkspace pFeatWS = pWorkspace as IFeatureWorkspace;
IFeatureClass pFeatureClass= pFeatWS.OpenFeatureClass("ControlPoint");

5、Tin

IWorkspaceFactory pWSFact = new TinWorkspaceFactoryClass();
IWorkspace pWS = pWSFact.OpenFromFile(@"D:\ArcTutor\3DAnalyst", 0);
ITinWorkspace pTinWS = pWS as ITinWorkspace;
ITin pTin = pTinWS.OpenTin("mal");

6、栅格数据

IWorkspaceFactory rasterWorkspaceFactory = new RasterWorkspaceFactoryClass();
IRasterWorkspace rasterWorkspace =rasterWorkspaceFactory.OpenFromFile(@"D:\data\grid", 0) as IRasterWorkspace;
IRasterDataset rasterDataset= rasterWorkspace.OpenRasterDataset("ca_hillshade");

7、CAD

以下代码是打开位于D:\ArcTutor\Editor\ExerciseData\EditingFeatures 文件夹下的buildings.dxf 中的
多边形要素类。

IWorkspaceFactory pCadwf = new CadWorkspaceFactoryClass();
IWorkspace pWS =
pCadwf.OpenFromFile(@"D:\ArcTutor\Editor\ExerciseData\EditingFeatures", 0);
IFeatureWorkspace pCadFWS = pWS as IFeatureWorkspace;
IFeatureClass pFeatClass = pCadFWS.OpenFeatureClass("buildings.dxf:polygon");

8、一般关系表

//创建一个连接
IPropertySet pPropset;
pPropset = new PropertySetClass();
pPropset.SetProperty("CONNECTSTRING",
@"rovider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Company.mdbersist Security
Info=False");
//创建一个新的OleDB工作空间并打开
IWorkspaceFactory pWorkspaceFact;
IFeatureWorkspace pFeatWorkspace;
pWorkspaceFact = new OLEDBWorkspaceFactoryClass();
pFeatWorkspace = pWorkspaceFact.Open(pPropset, 0) as IFeatureWorkspace;
ITable pTTable = pFeatWorkspace.OpenTable("Custom");

 

没有整理与归纳的知识,一文不值!高度概括与梳理的知识,才是自己真正的知识与技能。 永远不要让自己的*、好奇、充满创造力的想法被现实的框架所束缚,让创造力*成长吧! 多花时间,关心他(她)人,正如别人所关心你的。理想的腾飞与实现,没有别人的支持与帮助,是万万不能的。





    本文转自wenglabs博客园博客,原文链接:http://www.cnblogs.com/arxive/p/6110106.html,如需转载请自行联系原作者


上一篇:在IIS上搭建WebSocket服务器(二)


下一篇:ASP.NET Core MVC中构建Web API