IRelationalOperator Interface

Provides access to members that determine if a certain spatial relationship exists between two geometries.

Description

Relational Operators compare two geometries and return a boolean indicating whether or not the desired relationship exists. Some relationships require that the input geometries be of the same dimension while other have more flexible dimensional constraints. Most of the predefined Relational Operators are mutually exclusive Clementini operators. Please see the "Shape Comparison Language" topic in the Technical Documents section in the help.

When To Use

Relational Operators are used to determine whether or not a specific relationship exists between two geometries.

Members

Name Description
Method Contains Indicates if this geometry contains the other geometry.
Method Crosses Indicates if the two geometries intersect in a geometry of lesser dimension.
Method Disjoint Indicates if the two geometries share no points in common. Negate this result to compute the Intersect relation.
Method Equals Indicates if the two geometries are of the same type and define the same set of points in the plane.
Method Overlaps Indicates if the intersection of the two geometries has the same dimension as one of the input geometries.
Method Relation Indicates if the defined relationship exists.
Method Touches Indicates if the boundaries of the geometries intersect.
Method Within Indicates if this geometry is contained (is within) another geometry.

IRelationalOperator.Contains Method

Indicates if this geometry contains the other geometry.

Public Function Contains ( _
    ByVal other As IGeometry _
) As Boolean
public bool Contains (
    IGeometry other
);

Description

The base geometry contains the comparison geometry (other) if the comparison geometry is a subset of the base geometry and the intersection of their interiors is not empty. Therefore a polygon does not contain any part of its 1D boundary. Contains is the opposite operator of Within.

Remarks

Only geometries that support the IRelationalOperator interface can be used as input geometries.

If geometry1 Contains geometry2, then geometry2 is Within geometry1.

An empty geometry does not contain another geometry. On the other hand, an empty geometry is contained in another geometry, unless the other geometry is empty.

Contains examples. Only "true" relationships are showed in this picture.

IRelationalOperator.Crosses Method

Indicates if the two geometries intersect in a geometry of lesser dimension.

Public Function Crosses ( _
    ByVal other As IGeometry _
) As Boolean
public bool Crosses (
    IGeometry other
);

Description

Two polylines cross if they share only points in common, at least one of which is not an endpoint. A polyline and an polygon cross if they share a polyline or a point (for vertical line) in common on the interior of the polygon which is not equivalent to the entire polyline. Cross is a Clementini operator.

Remarks

Only geometries that support the IRelationalOperator interface can be used as input geometries.

Cross only applies to polyline/polyline, polyline/polygon, or polygon/polyline relations.

If either one of the geometries is empty, the geometries do not cross.

Crosses examples. Only "true" relationships are showed in this picture.

IRelationalOperator.Disjoint Method

Indicates if the two geometries share no points in common. Negate this result to compute the Intersect relation.

Public Function Disjoint ( _
    ByVal other As IGeometry _
) As Boolean
public bool Disjoint (
    IGeometry other
);

Description

Two geometries are disjoint if their intersection is empty. Two geometries intersect if disjoint is "false". Disjoint is a Clementini operator.

Remarks

Only geometries that support the IRelationalOperator interface can be used as input geometries.

Two geometries are disjoint if either one is empty.

Disjoint example. Only "true" relationships are showed in this picture.

IRelationalOperator.Equals Method

Indicates if the two geometries are of the same type and define the same set of points in the plane.

Public Function Equals ( _
    ByVal other As IGeometry _
) As Boolean
public bool Equals (
    IGeometry other
);

Description

For polylines and polygons, two geometries are equal when their symmetric difference is the empty set. Note, orientation and M/Z attributes are not considered here. Equals is not a Clementini operator. For multipoints, IRelationalOperator::Equals delegates to IClone::IsEqual.

Remarks

Only geometries that support the IRelationalOperator interface can be used as input geometries. GeometryBags are not supported. IRelationalOperator::Equals delegates to ITopologicalOperatorSymmetricDifference and returns true when that method returns an empty geometry; M's and Z's are ignored. Please use IClone::IsEqual if M's and Z's need to be compared.

IClone::IsEqual simply iterates over each segment in each geometry, in index order, and compares their types and coordinates (but using the spatial reference's cluster tolerances to determine equality of coordinates).

Only "true" relationships are showed in this picture.

The RCW for the IRelationalOperator inherits from System.Object, as do all reference types in .NET. The System.Object type has a method called Equals, which results in the IRelationalOperator RCW having two overloaded versions of the Equals method. Ensure that you are not using the Equals method inherited from the System.Object class by mistake, by making sure you pass in an IGeometry reference to the Equals method. For example, the following extract of code from a C# console application demonstrates calling Equals correctly.

IRelationalOperator.Overlaps Method

Indicates if the intersection of the two geometries has the same dimension as one of the input geometries.

Public Function Overlaps ( _
    ByVal other As IGeometry _
) As Boolean
public bool Overlaps (
    IGeometry other
);

Description

Two geometries overlap if the region of their intersection is of the same dimension as the geometries involved and is not equivalent to either of the geometries. Overlaps is a Clementini operator.

Remarks

Only geometries that support the IRelationalOperator interface can be used as input geometries.

Overlaps only applies to polyline/polyline, polygon/polygon and multipoint/multipoint relations.

Two geometries do not overlap if either one is empty.

Overlaps examples. Only "true" relationships are showed in this picture.

IRelationalOperator.Relation Method

Indicates if the defined relationship exists.

Public Function Relation ( _
    ByVal other As IGeometry, _
    ByVal relationDescription As String _
) As Boolean
public bool Relation (
    IGeometry other,
    string relationDescription
);

Description

Relation allows a general relation defined using the Shape Comparison Language to be determined between two input geometries. The Shape Comparison Language is based on the Calculus-Based Method (CBM), as described and defined by Clementini and Felice, but has some extensions specific to working with vertex-based geometries and is fully described in the Technical Documents section of the ArcObjects Developer Help. Please refer to the Shape Comparison Language documentation for proper syntax and available functionality.

Note that at the current release, Relation only operates with straight lines.

Remarks

Here is a VBA example of using the "RELATE" function to detect overlapping polylines. It assumes two polyline features are selected. G1 and G2 are placeholders for, in this example, the VBA variables r1 and r2.

Option Explicit

Public Sub overlapstest()Dim ef As IEnumFeatureDim d As IMxDocumentSet d = ThisDocumentSet ef = d.FocusMap.FeatureSelectionDim r1 As IRelationalOperator, r2 As IRelationalOperatorSet r1 = ef.Next.ShapeSet r2 = ef.Next.Shape

Debug.Print "relation:", r1.Relation(r2, "RELATE(G1, G2, ""1********"")")

End Sub

IRelationalOperator.Touches Method

Indicates if the boundaries of the geometries intersect.

Public Function Touches ( _
    ByVal other As IGeometry _
) As Boolean
public bool Touches (
    IGeometry other
);

Description

Two geometries are said to touch when the intersection of the geometries is non-empty, but the intersection of their interiors is empty. Touches is a Clementini operator. For example, a point touches a polyline only if the point is coincident with one of the polyline end points.

Touches examples. Only "true" relationships are showed in this picture.

Remarks

Only geometries that support the IRelationalOperator interface can be used as input geometries.

Touch does not apply for point/point comparison.

If either one of the two geometries is empty, the geometries are not touched.

IRelationalOperator.Within Method

Indicates if this geometry is contained (is within) another geometry.

Public Function Within ( _
    ByVal other As IGeometry _
) As Boolean
public bool Within (
    IGeometry other
);

Description

The base geometry is within the comparison geometry if the base geometry is the intersection of the geometries and the intersection of their interiors is not empty. Within is a Clementini operator. Within is the opposite operator of contains.

Remarks

Only geometries that support the IRelationalOperator interface can be used as input geometries.

If geometry1 is Within geometry2, then geometry2 Contains geometry1.

An empty geometry is within another geometry, unless the other geometry is empty.

Within examples. Only "true" relationships are showed in this picture.

Classes that implement IRelationalOperator

Classes Description
Envelope A rectangle with sides parallel to a coordinate system defining the extent of another geometry; optionally has min and max measure, height and ID attributes.
GeometryBag An ordered collection of objects that support the IGeometry interface.
MultiPatch A collection of surface patches.
Multipoint An ordered collection of points; optionally has measure, height and ID attributes.
Point A two dimensional point, optionally with measure, height, and ID attributes.
Polygon A collection of rings ordered by their containment relationship; optionally has measure, height and ID attributes.
Polyline An ordered collection of paths; optionally has measure, height and ID attributes.

Remarks

Only geometries that support the IRelationalOperator interface can be used as input geometries.

RelationalOperator Boundary/Interior Example

Relational operators has now been extended to support 3D polylines and that process can be generalized in three steps:

  • The polyline is converted to a 2D hybrid polyline.
  • Each of the base inputs is related to some parts of the comparison input.
  • The resulting relations are collected, and a rule is applied to determine the overall result relation.

Please refer to the topic "Working with Vertical Segments" in "Learning ArcObject" section in the help.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.