This document is archived and information here might be outdated.  Recommended version.


Calling the Simplify method (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Managing data > Working with geometry > Modifying geometries > Calling the Simplify method

Calling the Simplify method


In this topic


About calling the Simplify method

The Simplify method must be applied to 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 - the geometries must be wrapped into high-level geometry types. See the following code example:
[C#]
//The following code shows how to wrap a line segment into a polyline in C#.
//Assume a line (line1 as ILine) is already created.
ILine line1=new LineClass();
ISpatialReference spatialRef=null;
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 transferred automatically from the segments.
IGeometry geom=segCollection as IGeometry;
geom.SpatialReference=spatialRef;
//Can now be used with ITopologicalOperator methods.
[VB.NET]
' The following code shows how to wrap a line segment into a polyline in VB .NET.
' Assume a line (line1 as ILine) is already created.
Dim line1 As ILine=New LineClass
Dim spatialRef As ISpatialReference=Nothing
Dim obj As Object=Type.Missing
Dim segCollection As ISegmentCollection=CType(New PolylineClass, ISegmentCollection)
segCollection.AddSegment(CType(line1, ISegment), obj, obj)

' Set the spatial reference on the new polyline.
' The spatial reference is not transferred automatically from the segments.
Dim geom As IGeometry=CType(segCollection, IGeometry)
geom.SpatialReference=spatialRef

Determining if the geometry is simple

The Simplify method permanently alters the input geometry, making its definition topologically legal with respect to its geometry type. Before explicitly calling Simplify, determine if the geometry is simple. A geometry is known or assumed to be simple if it is an empty geometry, a geometry directly from a feature class, or output of any method of ITopologicalOperator.
A geometry is known or assumed to be not simple if it is not a new empty geometry or a geometry after projection (IGeometry.Project), generalization (IPolycurve.Generalize), or smoothing (IPolycurve.Smooth).
By setting the IsKnownSimple property to false, you can explicitly determine if the geometry is not already known or assumed to be simple. Running the IsSimple method indicates whether this geometry is topologically correct (simple). Calling IsSimple makes the IsSimple state known to the geometry. Topologically altering the geometry makes the IsKnownSimple state false until the IsSimple state is checked again. See the following code example:
[C#]
topoOp2.IsKnownSimple_2=false;
bool bIsSimple=topoOp2.IsSimple;
[VB.NET]
topoOp2.IsKnownSimple_2=False
Dim bIsSimple As Boolean=topoOp2.IsSimple
As with the IsSimple method, Simplify first checks the ITopologicalOperator.IsKnownSimple flag before processing. If the flag is true, operation is interrupted and the geometry is considered simple. If the flag is false, the geometry consistency is checked and the geometry is updated as needed. After calling Simplify, the IsKnownSimple flag is set to true. See the following code example:
[C#]
topoOp2.IsKnownSimple_2=false;
topoOp2.Simplify();
[VB.NET]
topoOp2.IsKnownSimple_2=False
topoOp2.Simplify()


See Also:

Simplifying a geometry