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 | |
---|---|---|
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. |
IRelationResult.Add Method
Add elements of other Relation to the end of this Relations, and the set is re-sorted.
Public Sub Add ( _
ByVal pRelations As IRelationResult _
)
public void Add (
IRelationResult pRelations
);
IRelationResult.FlipRelations Method
Flips the left and right indexes of all the elements of the relation.
Public Sub FlipRelations ( _
)
public void FlipRelations (
);
IRelationResult.Intersect Method
Construct the set with only those elements that exist in both relation sets.
Public Sub Intersect ( _
ByVal pRelations As IRelationResult _
)
public void Intersect (
IRelationResult pRelations
);
IRelationResult.RelationElement Property
The ith element of the relation. The indexes refer to elements of the left and right operand geometry bags.
Public Sub RelationElement ( _
ByVal i As Integer, _
ByRef left As Integer, _
ByRef right As Integer _
)
public void RelationElement (
int i,
ref int left,
ref int right
);
void DemoRelationElement(IGeomtryCollection geomColl1, IGeometryCollection geomColl2)
{
IRelationalOperatorNxM relOpNxM = geomColl1 as IRelationalOperatorNxM;
IRelationResult relRes = relOpNxM.Within(geomColl2 as IGeometryBag);
int count = relRes.RelationElementCount;
int left, right;
for (int i = 0; i < count; i++)
{
relRes.RelationElement(i, out left, out right);
IGeometry geom1 = geomColl1.get_Geometry(left);
IGeometry geom2 = geomColl2.get_Geometry(right);
//geom1 of geomColl1 is Within geom2 of geomColl2
}
}
IRelationResult.RelationElementCount Property
The number of pairs of geometries in the relation.
Public ReadOnly Property RelationElementCount As Integer
public int RelationElementCount {get;}
IRelationResult.SetRelationElement Method
The ith element of the relation. The indexes refer to elements of the left and right operand geometry bags.
Public Sub SetRelationElement ( _
ByVal i As Integer, _
ByVal left As Integer, _
ByVal right As Integer _
)
public void SetRelationElement (
int i,
int left,
int right
);
IRelationResult.SetRelationElements Method
Sets RelationResult with an array of relations.
Public Sub SetRelationElements ( _
ByVal cPairs As Integer, _
ByRef Pairs As esriRelationPair _
)
public void SetRelationElements (
int cPairs,
ref esriRelationPair Pairs
);
IRelationResult.SortLeft Method
Sort the set according to the left index.
Public Sub SortLeft ( _
)
public void SortLeft (
);
IRelationResult.SortRight Method
Sort the set according to the right index.
Public Sub SortRight ( _
)
public void SortRight (
);
IRelationResult.Subtract Method
Finds elements existing in another relation set and delete them from this set.
Public Sub Subtract ( _
ByVal pRelations As IRelationResult _
)
public void Subtract (
IRelationResult pRelations
);
Classes that implement IRelationResult
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