rkoc

Passing IFeature(s) to IRelationalOperator for Comparison...

Discussion created by rkoc on Jun 23, 2010
Latest reply on Jun 24, 2010 by rkoc
Hi,

I am trying to write a VB.Net extension for ArcMap which takes two polyline features from different feature classes and checks to see if they have matching geometry.

I belive that the comparison of two shapes can be undertaken by the IRelationalOperator interface. And have found the following example of its use: http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esrigeometry/IRelationalOperator_Example.htm

This example however builds its lines from points generated in the code, where I want to pass two existing polylines for comparison.

My question is how does one pass polylines (as IFeature) to the IRelationalOperator interface?

Below is my attempt at modifying the above example �?? it crashes ArcMap and produces a VS MDA �??LoaderLock �??error.

Any help would be greatly appreciated.

Regards. Rob.

Public Sub RelationalOperatorsDemo(ByVal pFeature As IFeature, ByVal pFeature_H As IFeature)
        Dim pLine1 As ILine
        Dim pLine2 As ILine
        Dim pBase As ISegmentCollection
        Dim pComparison As ISegmentCollection
        pBase = New Polyline
        pComparison = New Polyline
        Dim pRelOp As IRelationalOperator
        pRelOp = pBase
        Dim pBaseGeom As IGeometry
        Dim pCompGeom As IGeometry
        pBaseGeom = pBase
        pCompGeom = pComparison
        pLine1 = New Line
        pLine2 = New Line
        
'both the following lines crash ArcMap when uncommented
       'pLine1 = pFeature.ShapeCopy
       'pLine1.Equals(pFeature.ShapeCopy)

        'Wrap lines in a polyline which supports the IRelationalOperator interface 
        pBase.AddSegment(pLine1)  'Base polyline 
        pComparison.AddSegment(pLine2)  'Comparison polyline 

        'If the Base and the Comparison are equal 
        MsgBox("Equals: " & pRelOp.Equals(pComparison))

       
    End Sub

Outcomes