This document is archived and information here might be outdated. Recommended version. |
ArcObjects Help for .NET developers > ArcObjects namespaces > Geometry > ESRI.ArcGIS.Geometry > Interfaces > IR > IRelationResult Interface (ArcObjects .NET 10.5 SDK) |
Provides access to members that meet the specific relation between two sets of geometries. Not currently implemented for geometries containing elliptic arcs.
Description | ||
---|---|---|
Add | Add elements of other Relation to the end of this Relations, and the set is re-sorted. | |
FlipRelations | Flips the left and right indexes of all the elements of the relation. | |
Intersect | Construct the set with only those elements that exist in both relation sets. | |
RelationElement | The ith element of the relation. The indexes refer to elements of the left and right operand geometry bags. | |
RelationElementCount | The number of pairs of geometries in the relation. | |
SetRelationElement | The ith element of the relation. The indexes refer to elements of the left and right operand geometry bags. | |
SetRelationElements | Sets RelationResult with an array of relations. | |
SortLeft | Sort the set according to the left index. | |
SortRight | Sort the set according to the right index. | |
Subtract | Finds elements existing in another relation set and delete them from this set. |
CoClasses and Classes | Description |
---|---|
RelationResult | The indexes of geometrybag elements that are in a specified relation. |
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);
}
}
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