3. Dim pConnectionProperties As IPropertySet 4.
5. Set pConnectionProperties = New PropertySet 6. With pConnectionProperties
7. .SetProperty \8. .SetProperty \9. .SetProperty \10. .SetProperty \11. .SetProperty \12. End With 13.
14. Set pSdeWorkspaceFactory = New SdeWorkspaceFactory
15. Set pSdeWorkspace = pSdeWorkspaceFactory.Open(pConnectionProperties, 0) IWorkspaceFactory接口的第二个方法OpenFromFile (fileName, hWnd ) (方法,从一个路径打开一个工作空间,并返回IWorkspace类型的变量) 例子代码:
1. Dim pSdeWorkspaceFactory As IWorkspaceFactory 2. Dim pSdeWorkspace As IWorkspace 3.
4. Set pSdeWorkspaceFactory = New SdeWorkspaceFactory 5. Set
pSdeWorkspace
=
pSdeWorkspaceFactory.OpenFromFile(\
23. 关于ITopologicalOperator接口(esriGeometry) 例子代码:
1. Share a line segment
2. This sample uses ITopologicalOperator::Intersect to do the equivalent of a
select by location with the share a line segment operator. 3. Public Sub ShareLineSegment() 4.
5. Dim pMxDoc As IMxDocument 6. Set pMxDoc = ThisDocument 7. Dim pMap As IMap
8. Set pMap = pMxDoc.FocusMap
9. Dim pFL1 As IFeatureLayer, pFL2 As IFeatureLayer 10. Set pFL1 = pMap.Layer(0) ' first layer of map 11. Set pFL2 = pMap.Layer(1) ' second layer 12. Dim pF1 As IFeature, pF2 As IFeature
13. Set pF1 = pFL1.FeatureClass.GetFeature(1) ' get feature with ID=1 in first
layer's feature class 14.
15. Dim pfs As IFeatureSelection 16. Set pfs = pFL2 17. Dim id As Long
18. id = pfs.SelectionSet.IDs.Next ' get first id in selection set an
actual function would probably loop over the selection 19.
20. Set pF2 = pFL2.FeatureClass.GetFeature(id) ' this is line 2 21.
22. 'is there an intersection bw the two features 23. Dim pTopo As ITopologicalOperator
24. Set pTopo = pF1.Shape ' store the line 1 shape in the topo op 25. If Not pTopo.IsSimple Then pTopo.Simplify 26. Dim pGeom As IGeometry
27. Set pGeom = pTopo.Intersect(pF2.Shape, esriGeometry1Dimension) ' get
intersection with line 2 28. If pGeom.IsEmpty Then
29. MsgBox \
points\30. Exit Sub 31. End If
32. ' pGeom now contains the intersection of pf1 and pf2
33. ' because dimension = esriGeometry1Dimension 34. ' it is a geometry of type polyline
35. ' if the intersection of the two features consisted of a point or points pgeom
would be empty
36. ' we could use ITopologicalOperator::Intersect with 0 dimension to find about
those points 37.
38. 'if pGeom contains only two vertices then the intersection is a simple line
segment
39. '3 vertices means it's a polyline with two successive segments
40. '>3 means we have several segments or a polyline or a combination of these 41. Dim ppc1 As IPointCollection 42. Set ppc1 = pGeom 43. Dim l As Long, g As Long 44. l = ppc1.PointCount 45. If l = 2 Then
46. MsgBox \47. ElseIf l = 3 Then
48. MsgBox \
of 2 segments\49. ElseIf l > 3 Then
50. Dim pGeomColl As IGeometryCollection 51. Set pGeomColl = pGeom 52. g = pGeomColl.GeometryCount
53. MsgBox \
polyline(s)and/or segment(s)\54. End If 55. End Sub
可以讲一个Polygon类型的数据或者Polyline的数据赋值给该接口的变量,如: 1. Set pUnionedPolylines = New Polyline 2. 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的要素来显示缓冲区域,参数为缓冲距离) 例子代码:
1. 'This example demonstrates how to use ITopologicalOperator::Buffer 2. Sub exampleITopologicalOperator_Buffer()
3. Dim ptc As IPointCollection, i As Long, pa As IArea, ptopo As
ITopologicalOperator
4. Dim pt(4) As IPoint, poutPoly As IPolygon 5. Set ptc = New Polygon
6. 'The spatial reference should be set here using IGeometry::SpatialReference
(Code skipped here) 7. For i = 0 To 4
8. Set pt(i) = New Point 9. Next
10. pt(0).PutCoords 0, 0 11. pt(1).PutCoords 0, 10 12. pt(2).PutCoords 10, 10 13. pt(3).PutCoords 10, 0 14. pt(4).PutCoords 0, 0 15. ptc.AddPoints 5, pt(0) 16. Set pa = ptc
17. Debug.Print \18. Set ptopo = ptc
19. Set poutPoly = ptopo.Buffer(1) 'Outside buffer
20. Set pa = poutPoly
21. Debug.Print \22. Set poutPoly = ptopo.Buffer(-1) 'Inside buffer 23. Set pa = poutPoly
24. Debug.Print \25. End Sub
ITopologicalOperator接口的第五个方法Clip (clipperEnvelope ) (方法,输入一个IEnvelope类型的变量,来获取被这个边框剪切的要素,并将切割后的变量返回给调用方法的变量)
ITopologicalOperator
接口的第六个方法
QueryClipped (clipperEnvelope,
clippedGeometry ) (方法,与Clip类似,但是第二个参数为剪切后返回输出的参数,本身不会改变)
ITopologicalOperator接口的第七个方法ConvexHull(方法,构造一个Geometry,大部分为Polygon类型的几何要素,该要素为调用此方法的ITopologicalOperator类型的变量最小的外边框)
ITopologicalOperator接口的第八个方法SymmetricDifference (other ) (方法,并集减去交集的部分,调用次方法的变量为第一个参数,other为第二个参数,最后返回变量到一个Geometry类型的变量,该变量的范围均在两个参数范围内,但不在两个参数相交的部分)
24. 创建Buffer并选择里面的要素
======================================================== 怎样创建buffer:(来源于管网线处理删除冗余节点)
======================================================== 1. Dim pTopOper As ITopologicalOperator 2. Set pTopOper = pfeature.Shape 3. Dim pGeometry As IGeometry 4. Set pGeometry = pTopOper.Buffer(1)
(注意,这个pfeature是在前面定义的pfeature=pFeatureCursor.NextFeature,不用重新定义一个)
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库ArcEngine - 开发接口集(9)在线全文阅读。
相关推荐: