How to use ITopologicalOperator with vb.net?

1980
2
02-18-2016 11:23 PM
karthikm
New Contributor

Dear all,

            I am using arcmap 9.3 with VB.Net. I need to get the adjacent building so i am using the Itopological operator for get the building. i am doing following coding but i am not complete the coding i have struggle please any one help me for complete the coding.

Sub exampleITopologicalOperator_Buffer(ByVal x As Double, ByVal y As Double)

  Dim featureCursor As IFeatureCursor

        Dim ptc As ESRI.ArcGIS.Geometry.IPointCollection, i As Long, pa As ESRI.ArcGIS.Geometry.IArea, ptopo As ESRI.ArcGIS.Geometry.ITopologicalOperator

  

        ptc = New ESRI.ArcGIS.Geometry.Polygon

        Dim pt(4) As ESRI.ArcGIS.Geometry.IPoint, poutPoly As ESRI.ArcGIS.Geometry.IPolygon

        'The spatial reference should be set here using IGeometry::SpatialReference (Code skipped here) 344011.132111 6300045.490245

        For i = 0 To 4

            pt(i) = New ESRI.ArcGIS.Geometry.Point

        Next

        pt(0).PutCoords(x + 0.5, y)

        pt(1).PutCoords(x, y + 0.5)

        pt(2).PutCoords(x - 0.5, y)

        pt(3).PutCoords(x, y - 0.5)

        pt(4).PutCoords(x + 0.5, y)

        Dim geometryBride As ESRI.ArcGIS.Geometry.IGeometryBridge

        geometryBride = New ESRI.ArcGIS.Geometry.GeometryEnvironmentClass()

        geometryBride.AddPoints(ptc, pt)

        pa = ptc 

        ptopo = ptc

        poutPoly = ptopo.Buffer(-1) 'inside buffer

        pa = poutPoly

      

        Dim SpatialFilter As ISpatialFilter

        SpatialFilter.Geometry = poutPoly

        SpatialFilter.SpatialRel = ESRI.ArcGIS.Geodatabase.esriSpatialRelEnum.esriSpatialRelOverlaps       

    End Sub

0 Kudos
2 Replies
nicogis
MVP Frequent Contributor

when you have your polygon you can use a spatial relationship with a shape comparison language string for select polygon adjacent:

use F***T****  9IM    F => interior-interior (false) e T => boundary-boundary (true)    * =>  not tested (not need for your comparision)

for details 9IM Shape comparison Language

' Get the feature with the known oid

Dim caFeature As IFeature = featureClass.GetFeature(4) 
Dim caGeometry As IGeometry = caFeature.Shape
 ' Create a spatial filter with a 9IM spatial relationship. 
Dim spatialFilter As ISpatialFilter = New SpatialFilterClass() 
spatialFilter.Geometry = caGeometry 
spatialFilter.GeometryField = featureClass.ShapeFieldName 
spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelRelation 
spatialFilter.SpatialRelDescription = "F***T****" 
spatialFilter.SubFields ="yourfield1, ..." ' Execute the query. 
Dim selectionSet As ISelectionSet = featureClass.Select(spatialFilter, esriSelectionType.esriSelectionTypeSnapshot, _                                     esriSelectionOption.esriSelectionOptionNormal, Nothing)
0 Kudos
karthikm
New Contributor

Dear Domenico,

                     Thank you for your response it will be helpful for me thanks so much.

0 Kudos