ArcGIS接口详细说明 下载本文

可以将一个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的要素来显示缓冲区域,参数为缓冲距离)

例子代码:

'This example demonstrateshowtouseITopologicalOperator::Buffer Sub exampleITopologicalOperator_Buffer()

Dim ptc AsIPointCollection,iAsLong,paAsIArea,ptopoAsITopologicalOperator Dim pt(4) AsIPoint,poutPolyAsIPolygon Set ptc = NewPolygon

'The spatial referenceshouldbesethereusingIGeometry::SpatialReference(Codeskippedhere) For i = 0To4

Set pt(i) =NewPoint

Next

pt(0).PutCoords0,0 pt(1).PutCoords0,10 pt(2).PutCoords10,10 pt(3).PutCoords10,0 pt(4).PutCoords0,0 ptc.AddPoints5,pt(0) Set pa = ptc

Debug.Print \ originalpolygon: \ pa.Area Set ptopo = ptc

Set poutPoly = ptopo.Buffer(1)'Outsidebuffer Set pa = poutPoly

Debug.Print \ polygonpositivedistance: \ pa.Area Set poutPoly = ptopo.Buffer(-1)'Insidebuffer

Set pa = poutPoly

Debug.Print \ polygonnegativedistance: \ pa.Area End Sub

ITopologicalOperator接口的第五个方法Clip (clipperEnvelope ) (方法,输入一个IEnvelope类型的变量,来获取被这个边框剪切的要素,并将切割后的变量返回给调用方法的变量)

ITopologicalOperator接口的第六个方法QueryClipped (clipperEnvelope, clippedGeometry ) (方法,与Clip类似,但是第二个参数为剪切后返回输出的参数,本身不会改变)

ITopologicalOperator接口的第七个方法ConvexHull(方法,构造一个Geometry,大部分为Polygon类型的几何要素,该要素为调用此方法的ITopologicalOperator类型的变量最小的外边框)

ITopologicalOperator接口的第八个方法SymmetricDifference (other ) (方法,并集减去交集的部分,调用次方法的变量为第一个参数,other为第二个参数,最后返回变量到一个Geometry类型的变量,该变量的范围均在两个参数范围内,但不在两个参数相交的部分)

25. 创建Buffer并选择里面的要素 ===============================

怎样创建buffer:(来源于管网线处理删除冗余节点) ===============================

Dim pTopOper As ITopologicalOperator Set pTopOper = pfeature.Shape Dim pGeometry As IGeometry Set pGeometry = pTopOper.Buffer(1)

(注意,这个pfeature是在前面定义的pfeature=pFeatureCursor.NextFeature,不用重新定义一个)

=============================== 怎样在buffer里面选择要素: ===============================

Dim pSpFilter AsISpatialFilter Set pSpFilter = NewSpatialFilter

Dim pTopOper AsITopologicalOperator Set pTopOper = pfeature.Shape Dim pGeometry AsIGeometry Set pGeometry = pTopOper.Buffer(1)

Set pSpFilter.Geometry =pGeometry pSpFilter.SpatialRel= esriSpatialRelContains

'(esriSpatialRelContains是ISpatialFilter里面SpatialRel的一种参数esriSpatialRelEnum,值为8,代表在这个区域内包含的要素)

Set m_pSelGW_D = pLyr_D

m_pSelGW_D.SelectFeaturespSpFilter, esriSelectionResultNew, False '(m_pSelGW_D是IfeatureSelection类型的变量) pSpFilter.SpatialRel= esriSpatialRelIntersects

Set m_pSelGW_X = pLyr

m_pSelGW_X.SelectFeaturespSpFilter,esriSelectionResultNew,False

26. Merge要素Union要素

Vb语言: Private Sub UnionSelected() Dim pMxDoc AsIMxDocument Dim pFtrLyr AsIFeatureLayer Dim pFtrCls AsIFeatureClass Dim pFtrSel AsIFeatureSelection Dim pFtr AsIFeature Dim pEnumGeom AsIEnumGeometry Dim pEnumGeomBind AsIEnumGeometryBind Dim pTopOp AsITopologicalOperator Dim pUnionedPolylinesAsIPolyline

' Getareftotheselectedpolylinesinthe1stlayer Set pMxDoc =ThisDocument

Set pFtrLyr =pMxDoc.FocusMap.Layer(0) Set pFtrSel =pFtrLyr

Set pFtrCls =pFtrLyr.FeatureClass

' Createanenumerationoftheselectedpolyines Set pEnumGeom =NewEnumFeatureGeometry Set pEnumGeomBind =pEnumGeom

pEnumGeomBind.BindGeometrySource Nothing,pFtrSel.SelectionSet

pEnumGeom.Reset

' Unionthepolylines

Set pUnionedPolylines= New Polyline Set pTopOp =pUnionedPolylines pTopOp.ConstructUnion pEnumGeom

' Addthisnewunionedpolylinetothefeatureclass Set pFtr =pFtrCls.CreateFeature Set pFtr.Shape =pUnionedPolylines pFtr.Store

End Sub

C#语言:

if(pFC.ShapeType== ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon) {

IEnumGeometry pEnumGeom;

IEnumGeometryBindpEnumGeomBind= new EnumFeatureGeometryClass(); IFeatureLayer pLyr =newFeatureLayerClass(); pLyr.FeatureClass = pFC;

IFeatureSelectionpFeatSel =(IFeatureSelection)pLyr;

IQueryFilter pQfliter =newQueryFilterClass(); pQfliter.WhereClause = this.SQLText.Text;

pFeatSel.SelectFeatures(pQfliter, esriSelectionResultEnum.esriSelectionResultNew,false);

pEnumGeomBind.BindGeometrySource(null,pFeatSel.SelectionSet); pEnumGeom = (IEnumGeometry)pEnumGeomBind; ITopologicalOperatorpTopo =newPolygonClass(); pTopo.ConstructUnion(pEnumGeom); pGeom = (IGeometry)pTopo;

} returnpGeom;

=============================== 怎样从Table中获取具体需求值的Row: ===============================

ITable pTable = (ITable)pFC;

intindex =pTable.Fields.FindField(\ IQueryFilter pQFilter = newQueryFilterClass(); ICursor pCur;

pCur =pTable.Search(pQFilter,false); IRow pRow = new Row();

IRow pAnswerRow = new Row(); pRow =pCur.NextRow(); while (pRow != null) {

stringValue = pRow.get_Value(index).ToString();

if (Value == \ {

pAnswerRow = pRow; break; }

pRow = pCur.NextRow(); } =============================== 怎样ZoomInCenter:

===============================

Public Sub ZoomInCenter() Dim pMxDocumentAsIMxDocument Dim pActiveViewAsIActiveView

Dim pDisplayTransformAsIDisplayTransformation Dim pEnvelopeAsIEnvelope Dim pCenterPointAsIPoint

Set pMxDocument = Application.Document

Set pActiveView = pMxDocument.FocusMap

Set pDisplayTransform =pActiveView.ScreenDisplay.DisplayTransformation Set pEnvelope = pDisplayTransform.VisibleBounds