zoukankan      html  css  js  c++  java
  • 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:ArcTutorTopologyData", 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:ArcTutorMonto.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:ArcTutor3DAnalyst", 0);
    ITinWorkspace pTinWS = pWS as ITinWorkspace;
    ITin pTin = pTinWS.OpenTin("mal");

    6、栅格数据

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

    7、CAD

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

    IWorkspaceFactory pCadwf = new CadWorkspaceFactoryClass();
    IWorkspace pWS =
    pCadwf.OpenFromFile(@"D:ArcTutorEditorExerciseDataEditingFeatures", 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");

  • 相关阅读:
    MongoDB查询语句 (增、删、改、查)
    MongoDB简单查询语句
    jquery Select Change事件
    c# 远程监控(4) 接收端 RTP包重组 分屏显示
    c# 远程监控(3) RTP协议 RTP.NET.DLL
    c# 远程监控(1) 大纲
    c# 远程监控(2) 摄像头调研及模拟
    TortoiseGit记住用户名和密码
    winform ListView和DataGridView实现分页
    制作符合平台的CodeSmith代码生产模版
  • 原文地址:https://www.cnblogs.com/arxive/p/6110106.html
Copyright © 2011-2022 走看看