Hello all. I'm needing some help with intersecting polygons using itopologicaloperator. I've given it a good shot, but cannot get it to work. The idea is for a button where the user selects a polygon, then hits a button, which intersects the selected poly with an underlying soils layer, eventually providing a subset and various statistics therein. Here' the code so far:
Public Overrides Sub OnClick()
Dim pMxDoc As IMxDocument pMxDoc = m_application.Document
Dim pActView As IActiveView = pMxDoc.ActiveView Dim screenDisplay As IScreenDisplay = pActView.ScreenDisplay
Dim pEditor As IEditor Dim editorUID As ESRI.ArcGIS.esriSystem.UID = New ESRI.ArcGIS.esriSystem.UIDClass() editorUID.Value = "esriEditor.Editor" pEditor = m_application.FindExtensionByCLSID(editorUID)
If pEditor.EditState <> esriEditState.esriStateEditing Then MsgBox("You must be in <EDIT> mode to use this tool!") Exit Sub End If
Dim pMap As IMap = pMxDoc.FocusMap Dim pParPolyLayer As IFeatureLayer2 = FindLayer(pMap, "parcel_polygons") Dim pParFC As IFeatureClass = pParPolyLayer.FeatureClass
Dim pParPolyFSel As IFeatureSelection = pParPolyLayer Dim pSelSet As ISelectionSet2 = pParPolyFSel.SelectionSet
Dim pSoilsLayer As IFeatureLayer2 = FindLayer(pMap, "Soils") Dim pSoilsFC As IFeatureClass = pSoilsLayer.FeatureClass
Dim pFCur As IFeatureCursor = Nothing 'Dim pQF As IQueryFilter2 'pQF = New QueryFilter
Dim pSoilsCur As IFeatureCursor = Nothing
Dim aColor As IRgbColor aColor = New RgbColorClass()
Hi I suppose the first question is whether your cursors are pointing to any features or not. Are you actually getting to the line pTopoOp.Intersect(pGeom, esriGeometryDimension.esriGeometry2Dimension) with a valid geometry? Or is this not being reached?
It seems that the ITopologicalOperator5 interface is implemented on the Polyline class and not the Polygon class, whereas ITopologicalOperator4 is implemented on the Polygon class. I'm not sure whether the documentation is correct as it seems a bit odd, and it does recommend using ITopologicalOperator5 instead of ITopologicalOperator4. Might be worth casting to ITopologicalOperator4 instead though and see if that makes any difference.