ArcGIS接口总结(6)

2019-03-15 21:00

public void IWorkspaceFactory_Create_Example_Access() {

//create a new Access workspace factory IWorkspaceFactory workspaceFactory=new

ESRI.ArcGIS.DataSourcesGDB.AccessWorkspaceFactoryClass(); //Create a workspacename with the workspace factory IWorkspaceName

workspaceName=workspaceFactory.Create(\ //Cast for IName

ESRI.ArcGIS.esriSystem.IName name=(ESRI.ArcGIS.esriSystem.IName)workspaceName; //Open a reference to the access workspace through the name object IWorkspace pGDB_workspace=(IWorkspace)name.Open();

Console.WriteLine(\{1}\}

public void IWorkspaceFactory_Create_Example_FileGDB() {

//create a new FileGDB workspace factory IWorkspaceFactory workspaceFactory=new

ESRI.ArcGIS.DataSourcesGDB.FileGDBWorkspaceFactoryClass(); //Create a workspacename with the workspace factory IWorkspaceName

workspaceName=workspaceFactory.Create(\ //Cast for IName

ESRI.ArcGIS.esriSystem.IName name=(ESRI.ArcGIS.esriSystem.IName)workspaceName; //Open a reference to the FileGDB workspace through the name object IWorkspace fileGDB_workspace=(IWorkspace)name.Open();

Console.WriteLine(\

{1}\}

public void IWorkspaceFactory_Create_Example_ArcSDE() {

ESRI.ArcGIS.esriSystem.IPropertySet propertySet=new ESRI.ArcGIS.esriSystem.PropertySetClass(); propertySet.SetProperty(\ propertySet.SetProperty(\ propertySet.SetPropert(\ propertySet.SetProperty(\

propertySet.SetProperty(\

//Create a workspacename with the workspace factory IWorkspaceFactory workspaceFactory=new

ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactoryClass(); //Create a workspacename with the workspace factory IWorkspaceName

workspaceName=workspaceFactory.Create(\t,0);

//Cast for IName

ESRI.ArcGIS.esriSystem.IName name=(ESRI.ArcGIS.esriSystem.IName)workspaceName; //Open a reference to the sde workspace through the name object IWorkspace sde_workspace=(IWorkspace)name.Open(); //the path returned in this case weill be for the sde connection

Console.WriteLine(\}

24.3、IWorkspaceFactory.GetWorkspaceName方法

[C#]

public IWorkspaceName GetWorkspaceName(string parentDirectory,IFileNames filenames); Example [C#]

public void IWorkspaceFactory_GetWorkspaceName_Example() {

ESRI.ArcGIS.esriSystem.IFileNames fileNames=new ESRI.ArcGIS.esriSystem.FileNamesClass(); fileNames.Add(\

fileNames.Add(\

fileNames.Add(\

IWorkspaceFactory workspaceFactory=new

ESRI.ArcGIS.DataSourcesGDB.AccessWorkspaceFactoryClass(); IWorkspaceName

workspaceName=workspaceFactory.GetWorkspaceName(\

Console.WriteLine(workspaceName.PathName);

fileNames.Reset();

string fn=fileNames.Next(); while(fn!=null) {

Console.WriteLine(fn); fn=fileNames.Next(); }

ESRI.ArcGIS.esriSystem.IName name=(ESRI.ArcGIS.esriSystem.IName)workspaceName; IWorkspace workspace=(IWorkspace)name.Open(); }

24.4、IWorkspaceFactory.Open方法

[C#]

public IWorkspace Open(IPropertySet ConnectionProperties,int hWnd); Example [C#]

Public IWorkspace IWorkspaceFactory_Open_Example(String server,String instance,String user,String password,String database,String version) {

ESRI.ArcGIS.esriSystem.IPropertySet propertySet=new ESRI.ArcGIS.esriSystem.PropertySetClass(); propertySet.SetProperty(“SERVER”,server);

propertySet.SetProperty(“INSTANCE”,instance); propertySet.SetProperty(“DATABASE”,database); propertySet.SetProperty(“USER”,user);

propertySet.SetProperty(“PASSWORD”,password); propertySet.SetProperty(“VERSION”,version);

IWorkspaceFactory worspaceFactory=new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactoryClass(); Return workspaceFactory.Open(propertySet,0); }

24.5、IWorkspaceFactory.OpenFromFile方法

[C#]

public IWorkspace OpenFromFile(string fileName,int hWnd);

OpenFromFile采用表示FileSystemWorkspace或LocalDatabaseWorkspace,或是

RemoteDatabaseWorkspace的connection文件的参数,并返回一个指定workspace的接口。这些方法的客户然后就可以打开和访问workspace中的数据集。调用这些方法时,如果属性不足,将提供一个连接对话框提示需要其他属性。

hWnd引数是父窗体或应用程序窗体,确保connection对话框有正确的父窗体。 Example [C#]

//e.g.,nameOfFile=\

public IWorkspace IWorkspaceFactory_OpenFromFile_Example_Access(string nameOfFile) {

IWorkspaceFactory workspaceFactory=new

ESRI.ArcGIS.DataSourcesGDB.AccessWorkspaceFactoryClass(); return workspaceFactory.OpenFromFile(nameOfFile,0); }

//e.g.,nameOfFile=\

public IWorspace IWorkspaceFactory_OpenFromFile_Example_FileGDB(string nameOfFile) {

IWorkspaceFactory workspaceFactory=new

ESRI.ArcGIS.DataSourcesGDB.FileGDBWorkspaceFactoryClass(); return workspaceFactory.OpenFromFile(nameOfFile,0); }

//e.g.,nameOfFile=\

public IWorkspace IWorkspaceFactory_OpenFromFile_Example_ArcSDE(string nameOfFile) {

IWorkspaceFactory workspaceFactory=new

ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactoryClass(); return workspaceFactory.OpenFromFile(nameOfFile,0); }

//The connection string for a shapefile should be the full path //to the shapfile's folder(e.g.,\

//Note:location cannot be relative path \

public IWorkspace IWorkspaceFactory_OpenFromFile_Example_Shapefile(string nameOfFile) {

IWorkspaceFactory workspaceFactory=new

ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactoryClass(); return workspaceFactory.OpenFromFile(nameOfFile,0); }

WorkspaceFactory负责管理workspace,允许用户通过一系列connection properties连接workspace。一个workspace表示包含一个或多个数据集的数据库。Dataset包括tables,feature classes和relationship classes。一个workspaceFactory是可以单独创建的。一个WorkspaceFactory包括应用程序引用的当前连接的活动的workspaces。使用PropertySet指定Connection属性,并且可以存到connection文件中。WorkspaceFactory也支持浏览和管理file system Workspaces,以及管理remot database workspaces。

25. ITopologicalOperator接口(esriGeometry)

可以将一个Polygon类型的数据或者Polyline的数据赋值给该接口的变量,如: Set pUnionedPolylines =NewPolyline Set pTopOp = pUnionedPolylines

ITopologicalOperator接口的第一个方法ConstructUnion(geometries ) (方法,合并图形的工具,输入的参数是一个IEnumGeometry类型的参数,此方法效率甚高)

ITopologicalOperator接口的第二个方法Cut(cutter, leftGeom, rightGeom) (方法,剪切图形,第一个参数为剪切的线要素,为IPloyline类型,第二个第三个参数均为剪切后的图形,为输出参数)

ITopologicalOperator接口的第三个方法Boundary(方法,获取一个图形的边框,一个Polygon的boundary是一个Polyline类型的要素,一个Polyline的boundary是一个nultipoint类型的要素,一个Point的boundary是为空的)

ITopologicalOperator接口的第四个方法Buffer(distance) (方法,创造一个Polygon的要素来显示缓冲区域,参数为缓冲距离)


ArcGIS接口总结(6).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:药品经营企业GSP试题库(2)-单选题

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: