Interface ITopologicalOperator
Provides access to members for constructing new geometries based upon topological relationships between existing geometries.
[Guid("1B077911-38C5-11D0-92D2-00805F7C28B0")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface ITopologicalOperator
Remarks
Buffer, Clip, and Simplify are the only methods of ITopologicalOperator supported on GeometryBags.
ITopologicalOperator methods must be applied on high-level geometries only. High-Level geometries are point, multipoint, polyline and polygon. To use this interface with low-level geometries such as segments (Line, Circular Arc, Elliptic Arc, Bezier Curve), paths or rings, they must be wrapped into high-level geometry types.
For multipatch geometries, generally the footprint or envelope is used.
Every Geometry created within ArcGIS should be assigned a spatial reference. Always attach well-defined spatial references to new geometries. This improves processing efficiency, in particular, when using ITopologicalOperator on geometries that contain curved segments (circular arcs, bezier curves, elliptical arcs). New geometries include any geometry that is created in memory. It does not matter whether it will be stored in a feature class or not. Well-defined as applied to a spatial reference means that it not only has its coordinate system (projection) defined, but also its coordinate grid. The coordinate grid consists of the xy domain, xy resolution, and xy cluster tolerance properties of a spatial reference. If the Geometry includes z or m values, the z or m domains, z or m resolutions, and z or m cluster tolerance properties must also be defined. The cluster tolerance and resolutions can be quickly and easily set using SetDefault methods on ISpatialReferenceResolution and ISpatialReferenceTolerance interfaces.
//The following
code shows to wrap a line segment into a polyline in C#
//Assume a line (line1 as ILine) is already created
object obj = Type.Missing;
ISegmentCollection segCollection = new PolylineClass() as ISegmentCollection;
segCollection.AddSegment((ISegment)line1, ref obj, ref obj);
//Set the spatial reference on the new polyline
//The spatial reference is not transfered automatically from the segments
IGeometry geom = segCollection as IGeometry;
geom.SpatialReference = spatialRef;
//Can now be used with ITopologicalOperator3 methods
Properties
Boundary
The boundary of this geometry. A polygon's boundary is a polyline. A polyline's boundary is a multipoint. A point or multipoint's boundary is an empty point or multipoint.
IGeometry Boundary { get; }
Property Value
Remarks
ITopologicalOperator methods must be applied on high-level geometries only. High-Level geometries are point, multipoint, polyline and polygon. To use this method with low-level geometries such as segments (Line, Circular Arc, Elliptic Arc, Bézier Curve), paths or rings, they must be wrapped into high-level geometries types.
This method does not support GeometryBags.

//The following code shows to wrap a line segment into a polyline in C#
//Assume a line (line1 as ILine) is already created
object obj = Type.Missing;
ISegmentCollection segCollection = new PolylineClass() as ISegmentCollection;
segCollection.AddSegment((ISegment)line1, ref obj, ref obj);
//Set the spatial reference on the new polyline
//The spatial reference is not transfered automatically from the segments
IGeometry geom = segCollection as IGeometry;
geom.SpatialReference = spatialRef;
//Can now be used with ITopologicalOperator methods
IsKnownSimple
Indicates whether this geometry is known (or assumed) to be topologically correct.
bool IsKnownSimple { get; }
Property Value
Remarks
Here is the status of the IsKnownSimple flag in some common situations:
IsKnownSimple = 'False'
- A non-empty newly created geometry. For example, creating a polygon using IPointCollection sets the flag IsKnownSimple = 'false' on that geometry.
- Geometry after projection (IGeometry::Project )
- Geometry after generalization (IPolycurve::Generalize ) or smoothing(IPolycurve::Smooth )
- …
IsKnownSimple = 'True'
- A geometry coming directly from a feature class
- An empty geometry
- Output geometry of any method on ITopologicalOperator
- …
This method does not support GeometryBags.
IsSimple
Indicates whether this geometry is known (or assumed) to be topologically correct, after explicitly determining this if the geometry is not already known (or assumed) to be simple.
bool IsSimple { get; }
Property Value
Remarks
ITopologicalOperator methods must be applied on high-level geometries only. High-Level geometries are point, multipoint, polyline and polygon. To use this method with low-level geometries such as segments (Line, Circular Arc, Elliptic Arc, Bézier Curve), paths or rings, they must be wrapped into high-level geometries types.
The xy cluster tolerance value of the geometry's associated spatial reference is used by this method. If the goal of this method is to determine if a geometry can be persisted in an sde (or other integer-based) layer without alteration, you may wish to use the minimum xy cluster tolerance value (ISpatialReferenceTolerance::SetMinimumXYTolerance) before applying this method (don't forget to set it back).
This method does not support GeometryBags.



//The following code shows to wrap a line segment into a polyline in C#
//Assume a line (line1 as ILine) is already created
object obj = Type.Missing;
ISegmentCollection segCollection = new PolylineClass() as ISegmentCollection;
segCollection.AddSegment((ISegment)line1, ref obj, ref obj);
//Set the spatial reference on the new polyline
//The spatial reference is not transfered automatically from the segments
IGeometry geom = segCollection as IGeometry;
geom.SpatialReference = spatialRef;
//Can now be used with ITopologicalOperator methods
Methods
Buffer(double)
Constructs a polygon that is the locus of points at a distance less than or equal to a specified distance from this geometry.
IGeometry Buffer(double distance)
Parameters
distancedouble
Returns
Remarks
The buffer distance is in the same units as the source shape that
is being buffered.
A negative distance can be specified to produce a buffer inside the original polygon. This cannot be used with polyline.
ITopologicalOperator methods must be applied on top-level geometries only. Top-Level geometries are point, multipoint, polyline and polygon. To use this method with segments (Line, Circular Arc, Elliptic Arc, Bézier Curve), paths or rings, they must be wrapped with a top-level type.
A buffer distance of 0 will generate an empty polygon with the input geometry being a polyline and multipoint. However, if the input geometry is a point, the output will be the original point.

//The following code shows to wrap a line segment into a polyline in C#
//Assume a line (line1 as ILine) is already created
object obj = Type.Missing;
ISegmentCollection segCollection = new PolylineClass() as ISegmentCollection;
segCollection.AddSegment((ISegment)line1, ref obj, ref obj);
//Set the spatial reference on the new polyline
//The spatial reference is not transfered automatically from the segments
IGeometry geom = segCollection as IGeometry;
geom.SpatialReference = spatialRef;
//Can now be used with ITopologicalOperator methods
[C#]//This example demonstrates how to use
ITopologicalOperator::Buffer
private void BufferArea()
{
IPoint[] points = new IPoint[5];
//The spatial reference should be set here using
IGeometry::SpatialReference (Code skipped here)
for(int i = 0; i < points.Length; i++)
{
points[i] = new PointClass();
}
points[0].PutCoords(0, 0);
points[1].PutCoords(0, 10);
points[2].PutCoords(10, 10);
points[3].PutCoords(10, 0);
points[4].PutCoords(0, 0);
IPointCollection4 pointCollection = new PolygonClass();
IGeometryBridge geometryBride = new
GeometryEnvironmentClass();
geometryBride.AddPoints(pointCollection, ref points);
IArea area = pointCollection as IArea;
System.Windows.Forms.MessageBox.Show("Area original polygon
: " + area.Area);
ITopologicalOperator topologicalOperator = pointCollection
as ITopologicalOperator;
//Outside buffer
IPolygon polygon = topologicalOperator.Buffer(1) as
IPolygon;
area = polygon as IArea;
System.Windows.Forms.MessageBox.Show( "Area polygon positive
distance : " + area.Area);
//Inside buffer
polygon = topologicalOperator.Buffer(-1) as IPolygon;
area = polygon as IArea;
System.Windows.Forms.MessageBox.Show("Area polygon negative
distance : " + area.Area);
}
Sub exampleITopologicalOperator_Buffer()
Dim ptc As
ESRI.ArcGIS.Geometry.IPointCollection, i As Long, pa As
ESRI.ArcGIS.Geometry.IArea, ptopo As
ESRI.ArcGIS.Geometry.ITopologicalOperator
ptc = New
ESRI.ArcGIS.Geometry.Polygon
Dim pt(4) As
ESRI.ArcGIS.Geometry.IPoint, poutPoly As
ESRI.ArcGIS.Geometry.IPolygon
'The spatial reference
should be set here using IGeometry::SpatialReference (Code skipped
here)
For i = 0 To 4
pt(i) = New ESRI.ArcGIS.Geometry.Point
Next
pt(0).PutCoords(0,
0)
pt(1).PutCoords(0,
10)
pt(2).PutCoords(10,
10)
pt(3).PutCoords(10,
0)
pt(4).PutCoords(0,
0)
Dim geometryBride As
ESRI.ArcGIS.Geometry.IGeometryBridge
geometryBride = New
ESRI.ArcGIS.Geometry.GeometryEnvironmentClass()
geometryBride.AddPoints(ptc, pt)
pa = ptc
Debug.Print("Area
original polygon : " & pa.Area)
ptopo = ptc
poutPoly =
ptopo.Buffer(1) 'Outside buffer
pa = poutPoly
Debug.Print("Area
polygon positive distance : " & pa.Area)
poutPoly =
ptopo.Buffer(-1) 'Inside buffer
pa = poutPoly
Debug.Print("Area
polygon negative distance : " & pa.Area)
End Sub
Clip(IEnvelope)
Constructs the intersection of this geometry and the specified envelope.
void Clip(IEnvelope clipperEnvelope)
Parameters
clipperEnvelopeIEnvelope
Remarks
Use QueryClipped or QueryClippedDense methods to send the results to a different polygon.
ITopologicalOperator methods must be applied on high-level
geometries only. High-Level geometries are point, multipoint,
polyline and polygon. To use this method with
low-level geometries such as segments (Line, Circular Arc, Elliptic
Arc, Bézier Curve), paths or rings, they must be wrapped
into high-level geometries types.

//The following code shows to wrap a line segment into a polyline in C#
//Assume a line (line1 as ILine) is already created
object obj = Type.Missing;
ISegmentCollection segCollection = new PolylineClass() as ISegmentCollection;
segCollection.AddSegment((ISegment)line1, ref obj, ref obj);
//Set the spatial reference on the new polyline
//The spatial reference is not transfered automatically from the segments
IGeometry geom = segCollection as IGeometry;
geom.SpatialReference = spatialRef;
//Can now be used with ITopologicalOperator methods
ClipDense(IEnvelope, double)
Constructs the intersection of this geometry and the specified envelope; densifies lines in output contributed by the clipping envelope.
void ClipDense(IEnvelope clipperEnvelope, double denseDistance)
Parameters
Remarks
ITopologicalOperator methods must be applied on high-level geometries only. High-Level geometries are point, multipoint, polyline and polygon. To use this method with low-level geometries such as segments (Line, Circular Arc, Elliptic Arc, Bézier Curve), paths or rings, they must be wrapped into high-level geometries types.
This method does not support GeometryBags.
ConstructUnion(IEnumGeometry)
Defines this geometry to be the union of the inputs. More efficient for unioning multiple geometries than calling Union repeatedly.
void ConstructUnion(IEnumGeometry geometries)
Parameters
geometriesIEnumGeometry
Remarks
ITopologicalOperator methods must be applied on high-level geometries only. High-Level geometries are point, multipoint, polyline and polygon. To use this method with low-level geometries such as segments (Line, Circular Arc, Elliptic Arc, Bézier Curve), paths or rings, they must be wrapped into high-level geometries types.
This method does not support GeometryBags.
Temproray files might be created. If environment variable
"ARCTMPDIR" exists, then the files are written to the path,
otherwise written to current directory or system temp
directory.
//The following code shows to wrap a line segment into a polyline in C#
//Assume a line (line1 as ILine) is already created
object obj = Type.Missing;
ISegmentCollection segCollection = new PolylineClass() as ISegmentCollection;
segCollection.AddSegment((ISegment)line1, ref obj, ref obj);
//Set the spatial reference on the new polyline
//The spatial reference is not transfered automatically from the segments
IGeometry geom = segCollection as IGeometry;
geom.SpatialReference = spatialRef;
//Can now be used with ITopologicalOperator methods
ConvexHull()
Constructs the convex hull of this geometry.
IGeometry ConvexHull()
Returns
Remarks
ITopologicalOperator methods must be applied on high-level geometries only. High-Level geometries are point, multipoint, polyline and polygon. To use this method with low-level geometries such as segments (Line, Circular Arc, Elliptic Arc, Bézier Curve), paths or rings, they must be wrapped into high-level geometries types.
This method does not support GeometryBags.
ConvexHull method does not deal with Z attribute now.

Cut(IPolyline, out IGeometry, out IGeometry)
Splits this geometry into a part left of the cutting polyline, and a part right of it.
void Cut(IPolyline cutter, out IGeometry leftGeom, out IGeometry rightGeom)
Parameters
Remarks
ITopologicalOperator methods must be applied on high-level geometries only. High-Level geometries are point, multipoint, polyline and polygon. To use this method with low-level geometries such as segments (Line, Circular Arc, Elliptic Arc, Bézier Curve), paths or rings, they must be wrapped into high-level geometries types.
When a polyline/polygon is cut, it is split where it intersects the cutter polyline. Each piece is classified as ‘left of’ or ‘right of’ the cutter. This classification is based on the orientation of the cutter line. Parts of the target polyline that do not intersect the cutting polyline are returned as part of the ‘right of’ result for that input polyline. If a geometry is not cut, the left geometry will be empty.
When using a multi-part polyline to cut a single ring of a polyline, the orientation of the polyline paths is important. The cut piece of the ring must be on the same side of each cutting path as defined by the orientation of each path.
This method does not support GeometryBags.

//The following code shows to wrap a line segment into a polyline in C#
//Assume a line (line1 as ILine) is already created
object obj = Type.Missing;
ISegmentCollection segCollection = new PolylineClass() as ISegmentCollection;
segCollection.AddSegment((ISegment)line1, ref obj, ref obj);
//Set the spatial reference on the new polyline
//The spatial reference is not transfered automatically from the segments
IGeometry geom = segCollection as IGeometry;
geom.SpatialReference = spatialRef;
//Can now be used with ITopologicalOperator methods
Difference(IGeometry)
Constructs the geometry containing points from this geometry but not the other geometry.
IGeometry Difference(IGeometry other)
Parameters
otherIGeometry
Returns
Remarks
ITopologicalOperator methods must be applied on high-level geometries only. High-Level geometries are point, multipoint, polyline and polygon. To use this method with low-level geometries such as segments (Line, Circular Arc, Elliptic Arc, Bézier Curve), paths or rings, they must be wrapped into high-level geometries types.
This method does not support GeometryBags.

//The following code shows to wrap a line segment into a polyline in C#
//Assume a line (line1 as ILine) is already created
object obj = Type.Missing;
ISegmentCollection segCollection = new PolylineClass() as ISegmentCollection;
segCollection.AddSegment((ISegment)line1, ref obj, ref obj);
//Set the spatial reference on the new polyline
//The spatial reference is not transfered automatically from the segments
IGeometry geom = segCollection as IGeometry;
geom.SpatialReference = spatialRef;
//Can now be used with ITopologicalOperator methods
Intersect(IGeometry, esriGeometryDimension)
Constructs the geometry that is the set-theoretic intersection of the input geometries. Use different resultDimension values to generate results of different dimensions.
IGeometry Intersect(IGeometry other, esriGeometryDimension resultDimension)
Parameters
otherIGeometryresultDimensionesriGeometryDimension
Returns
Remarks
Intersection is basically an AND between input geometries.
ITopologicalOperator methods must be applied on high-level geometries only. High-Level geometries are point, multipoint, polyline and polygon. To use this method with low-level geometries such as segments (Line, Circular Arc, Elliptic Arc, Bézier Curve), paths or rings, they must be wrapped into high-level geometries types.
Note that when esriGeometryNoDimension is specified as resultDimension, the output will be in the dimension of the minimum dimension of the input geometries.
This method does not support GeometryBags.
Since ArcGIS 9.2, Intersect has a larger cost - it takes longer to run the method. Therefore, it is a better approach to test if the two geometries are disjoint before calling Intersect.

//The following code shows to wrap a line segment into a polyline in C#
//Assume a line (line1 as ILine) is already created
object obj = Type.Missing;
ISegmentCollection segCollection = new PolylineClass() as ISegmentCollection;
segCollection.AddSegment((ISegment)line1, ref obj, ref obj);
//Set the spatial reference on the new polyline
//The spatial reference is not transfered automatically from the segments
IGeometry geom = segCollection as IGeometry;
geom.SpatialReference = spatialRef;
//Can now be used with ITopologicalOperator methods
QueryClipped(IEnvelope, IGeometry)
Redefines clippedGeometry to be the intersection of this geometry and the clipping envelope.
void QueryClipped(IEnvelope clipperEnvelope, IGeometry clippedGeometry)
Parameters
Remarks
ITopologicalOperator methods must be applied on high-level geometries only. High-Level geometries are point, multipoint, polyline and polygon. To use this method with low-level geometries such as segments (Line, Circular Arc, Elliptic Arc, Bézier Curve), paths or rings, they must be wrapped into high-level geometries types.
The other geometry must be an high-level geometry. High-Level geometries are point, multipoint, polyline and polygon. To use it with low-level geometries such as segments (Line, Circular Arc, Elliptic Arc, Bézier Curve), path or ring they must be wrapped into high-level geometries type. The output geometry must be co-created prior to the query. The output geometry is not co-created by the method; it is populated. This can be used in performance critical situations. For example, creating the geometry only once outside a loop and use the query method could improve performance.
This method does not support GeometryBags.

//The following code shows to wrap a line segment into a polyline in C#
//Assume a line (line1 as ILine) is already created
object obj = Type.Missing;
ISegmentCollection segCollection = new PolylineClass() as ISegmentCollection;
segCollection.AddSegment((ISegment)line1, ref obj, ref obj);
//Set the spatial reference on the new polyline
//The spatial reference is not transfered automatically from the segments
IGeometry geom = segCollection as IGeometry;
geom.SpatialReference = spatialRef;
//Can now be used with ITopologicalOperator methods
QueryClippedDense(IEnvelope, double, IGeometry)
Redefines clippedGeometry to be the intersection of this geometry and the clipping envelope; densifies lines in the output contributed by the clipping envelope.
void QueryClippedDense(IEnvelope clipperEnvelope, double denseDistance, IGeometry clippedGeometry)
Parameters
Remarks
ITopologicalOperator methods must be applied on high-level geometries only. High-Level geometries are point, multipoint, polyline and polygon. To use this method with low-level geometries such as segments (Line, Circular Arc, Elliptic Arc, Bézier Curve), paths or rings, they must be wrapped into high-level geometries types.
The other geometry must be an high-level geometry. High-Level geometries are point, multipoint, polyline and polygon. To use it with low-level geometries such as segments (Line, Circular Arc, Elliptic Arc, Bézier Curve), path or ring they must be wrapped into high-level geometries type. The output geometry must be co-created prior to the query. The output geometry is not co-created by the method; it is populated. This can be used in performance critical situations. For example, creating the geometry only once outside a loop and use the query method could improve performance.
This method does not support GeometryBags.
Simplify()
Makes this geometry topologically correct.
void Simplify()
Remarks
This method first looks at the ITopologicalOperator::IsKnownSimple flag before starting processing. If the flag is 'true' then operation is interrupted and the geometry is considered simple. If the flag is 'false' then the geometry consistency is checked and the geometry is updated as needed.
ITopologicalOperator methods must be applied on high-level geometries only. High-Level geometries are point, multipoint, polyline and polygon. To use this method with low-level geometries such as segments (Line, Circular Arc, Elliptic Arc, Bézier Curve), paths or rings, they must be wrapped into high-level geometries types.



SymmetricDifference(IGeometry)
Constructs the geometry that contains points from either but not both input geometries.
IGeometry SymmetricDifference(IGeometry other)
Parameters
otherIGeometry
Returns
Remarks
SymmetricDifference is basically an XOR between the input geometries.
SymmetricDifference of G1 and G2 can also be described as the Union(Difference(G1, G2), Difference(G2, G1)).
ITopologicalOperator methods must be applied on high-level geometries only. High-Level geometries are point, multipoint, polyline and polygon. To use this method with low-level geometries such as segments (Line, Circular Arc, Elliptic Arc, Bézier Curve), paths or rings, they must be wrapped into high-level geometries types.
This method does not support GeometryBags.

//The following code shows to wrap a line segment into a polyline in C#
//Assume a line (line1 as ILine) is already created
object obj = Type.Missing;
ISegmentCollection segCollection = new PolylineClass() as ISegmentCollection;
segCollection.AddSegment((ISegment)line1, ref obj, ref obj);
//Set the spatial reference on the new polyline
//The spatial reference is not transfered automatically from the segments
IGeometry geom = segCollection as IGeometry;
geom.SpatialReference = spatialRef;
//Can now be used with ITopologicalOperator methods
TopologyCache(out long)
Provides a handle to the TopologyCache.
void TopologyCache(out long topologyCacheHandle)
Parameters
topologyCacheHandlelong
Union(IGeometry)
Constructs the geometry that is the set-theoretic union of the input geometries.
IGeometry Union(IGeometry other)
Parameters
otherIGeometry
Returns
Remarks
The Union is basically an OR between the input geometries.
ITopologicalOperator methods must be applied on high-level geometries only. High-Level geometries are point, multipoint, polyline and polygon. To use this method with low-level geometries such as segments (Line, Circular Arc, Elliptic Arc, Bézier Curve), paths or rings, they must be wrapped into high-level geometries types.
This method does not support GeometryBags.

//The following code shows to wrap a line segment into a polyline in C#
//Assume a line (line1 as ILine) is already created
object obj = Type.Missing;
ISegmentCollection segCollection = new PolylineClass() as ISegmentCollection;
segCollection.AddSegment((ISegment)line1, ref obj, ref obj);
//Set the spatial reference on the new polyline
//The spatial reference is not transfered automatically from the segments
IGeometry geom = segCollection as IGeometry;
geom.SpatialReference = spatialRef;
//Can now be used with ITopologicalOperator methods