ArcGIS Enterprise SDK
IRelationResult Interface
ArcGIS Enterprise SDK Developer Help > ArcGIS Enterprise SDK API Reference > ArcGIS Enterprise SDK .NET Namespaces > ESRI.Server.Geometry > Interfaces > IR > IRelationResult Interface
ArcGIS Developer Help (ESRI.ArcGIS.Geometry)

IRelationResult Interface

Provides access to members that meet the specific relation between two sets of geometries. Not currently implemented for geometries containing elliptic arcs.

Members

Name Description
Method Add Add elements of other Relation to the end of this Relations, and the set is re-sorted.
Method FlipRelations Flips the left and right indexes of all the elements of the relation.
Method Intersect Construct the set with only those elements that exist in both relation sets.
Read-only property RelationElement The ith element of the relation. The indexes refer to elements of the left and right operand geometry bags.
Read-only property RelationElementCount The number of pairs of geometries in the relation.
Method SetRelationElement The ith element of the relation. The indexes refer to elements of the left and right operand geometry bags.
Method SetRelationElements Sets RelationResult with an array of relations.
Method SortLeft Sort the set according to the left index.
Method SortRight Sort the set according to the right index.
Method Subtract Finds elements existing in another relation set and delete them from this set.

Classes that implement IRelationResult

Classes Description
RelationResult The indexes of geometrybag elements that are in a specified relation.
[C#]

        void DemoIRelationResult(IFeatureClass featClsPolygon0, IFeatureClass featClsPolyline0)
        {
            try
            {
                object obj = Type.Missing;
                IGeometryCollection geomCollGon = new GeometryBagClass() as IGeometryCollection;
                IFeatureCursor featCur = featClsPolygon0.Search(null, false);
                IFeature feat = featCur.NextFeature();
                while (feat != null)
                {
                    geomCollGon.AddGeometry(feat.ShapeCopy, ref obj, ref obj);
                    feat = featCur.NextFeature();
                }
                IGeometryCollection geomCollLine = new GeometryBagClass() as IGeometryCollection;
                featCur = featClsPolyline0.Search(null, false);
                feat = featCur.NextFeature();
                while (feat != null)
                {
                    geomCollLine.AddGeometry(feat.ShapeCopy, ref obj, ref obj);
                    feat = featCur.NextFeature();
                }
                IRelationalOperatorNxM relOpNxM = geomCollGon as IRelationalOperatorNxM;
                IRelationResult relRes = relOpNxM.Crosses(geomCollLine as IGeometryBag);

                int count = relRes.RelationElementCount;
                int left, right;

                for (int i = 0; i < count; i++)
                {
                    relRes.RelationElement(i, out left, out right);
                    IGeometry geomGon = geomCollGon.get_Geometry(left);
                    IGeometry geomLine = geomCollLine.get_Geometry(right);
                    //geomGon crosses geomLine
                }

            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }

[Visual Basic .NET]

    Sub Test(ByVal featClsPolygon0 As IFeatureClass, ByVal featClsPolyline0 As IFeatureClass)
        Dim geomCollGon As IGeometryCollection
        geomCollGon = New GeometryBagClass()
        Dim featCur As IFeatureCursor
        featCur = featClsPolygon0.Search(Nothing, False)
        Dim feat As IFeature
        feat = featCur.NextFeature()
        While (Not feat Is Nothing)
            geomCollGon.AddGeometry(feat.ShapeCopy)
            feat = featCur.NextFeature()
        End While

        Dim geomCollLine As IGeometryCollection
        geomCollLine = New GeometryBagClass()
        featCur = featClsPolyline0.Search(Nothing, False)
        feat = featCur.NextFeature()
        While (Not feat Is Nothing)
            geomCollLine.AddGeometry(feat.ShapeCopy)
            feat = featCur.NextFeature()
        End While

        Dim relOpNxM As IRelationalOperatorNxM
        relOpNxM = geomCollGon
        Dim relRes As IRelationResult
        relRes = relOpNxM.Crosses(geomCollLine)

        Dim count As Integer
        count = relRes.RelationElementCount
        Dim left As Integer, right As Integer, i As Integer
        Dim geomGon As IGeometry, geomLine As IGeometry

        For i = 0 To count - 1
            relRes.RelationElement(i, left, right)
            geomGon = geomCollGon.Geometry(left)
            geomLine = geomCollLine.Geometry(right)
            'geomGon crosses geomLine
        Next i
    End Sub