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的要素来显示缓冲区域,参数为缓冲距离)
ITopologicalOperator接口的第五个方法Clip (clipperEnvelope ) (方法,输入一个IEnvelope类型的变量,来获取被这个边框剪切的要素,并将切割后的变量返回给调用方法的变量)
ITopologicalOperator接口的第六个方法QueryClipped (clipperEnvelope, clippedGeometry ) (方法,与Clip类似,但是第二个参数为剪切后返回输出的参数,本身不会改变)
ITopologicalOperator接口的第七个方法ConvexHull(方法,构造一个Geometry,大部分为Polygon类型的几何要素,该要素为调用此方法的ITopologicalOperator类型的变量最小的外边框)
ITopologicalOperator接口的第八个方法SymmetricDifference (other ) (方法,并集减去交集的部分,调用次方法的变量为第一个参数,other为第二个参数,最后返回变量到一个Geometry类型的变量,该变量的范围均在两个参数范围内,但不在两个参数相交的部分)。
26. IHitTest(esriGeometry)
这个接口只有一个HitTest方法,public bool HitTest ( IPoint QueryPoint,double searchRadius, esriGeometryHitPartType geometryPart,IPoint hitPoint, ref double hitDistance, ref int hitPartIndex, ref int hitSegmentIndex, ref bool bRightSide)
用来访问指定的几何体的最接近点击位置的一部分pHitTest = (IHitTest)pGeom; esriGeometryHitPartType 是用来确定该部分是节点还是其他点
Constant esriGeometryPartNone esriGeometryPartVertex Value 0 1 Description Not used. Locates a vertex of the geometry closest to the query point. esriGeometryPartBoundary 4 Locates a point anywhere on the boundary of a polygon, or anywhere on a polyline, that is closest to the query point. esriGeometryPartMidpoint 8 Locates a midpoint of a segment belonging to a polygon or polyline that is closest to the query point. esriGeometryPartCentroid 32 Locates the geometric centroid of a polygon or the center of an envelope closest to the query point. esriGeometryPartEndpoint 16 Locates an endpoint of the polyline closest to the query point.

