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()
aColor.Red = 133
aColor.Green = 135
aColor.Blue = 43
Dim parFeat As IFeature, soilsFeat As IFeature
Dim pGeom As IGeometry5
Dim soilsPoly As IPolygon5
Dim pTopoOp As ITopologicalOperator5 = New PolygonClass()
Dim outPoly As IPolygon
pSelSet.Search(Nothing, False, pFCur)
parFeat = pFCur.NextFeature
Try
Do Until parFeat Is Nothing
pGeom = parFeat.ShapeCopy
pSoilsCur = PerformSpatialQuery(pSoilsFC, pGeom, esriSpatialRelEnum.esriSpatialRelIntersects, Nothing)
soilsFeat = pSoilsCur.NextFeature
Do Until soilsFeat Is Nothing
soilsPoly = soilsFeat.ShapeCopy
pTopoOp = soilsPoly
pTopoOp.Intersect(pGeom, esriGeometryDimension.esriGeometry2Dimension)
outPoly = pTopoOp
'FlashGeometry(pTopoOp, aColor, screenDisplay, 1500)
soilsFeat = pSoilsCur.NextFeature
Loop
parFeat = pFCur.NextFeature
Loop
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
At this point, it doesn't seem to be doing anything. I figured if I could get it to flash the geometries of the 'intersected' polys, I would be on my way.
Please help!!!