About simplifying a feature geometry
When making changes to an existing feature, or when creating a feature, it is essential that the geometry that is stored with the feature be topologically correct (simple). ArcGIS assumes geometry retrieved from a feature is simple.
Geometry has a number of methods available to evaluate and force simplification of a geometry. Some of these methods are specific to a given geometry type, others perform a more specialized type of simplification.
The following code example takes an input geometry, simplifies the geometry based on its type, and returns the simplified geometry:
[C#]
public IGeometry SimplifyGeometry(IGeometry geometry)
{
if (geometry == null)
return null;
//Set the IsKnownSimple property to false, otherwise simplification will not take place.
ITopologicalOperator2 topoOp = geometry as ITopologicalOperator2;
topoOp.IsKnownSimple_2 = true;
switch (geometry.GeometryType)
{
case esriGeometryType.esriGeometryMultipoint:
topoOp.Simplify();
break;
case esriGeometryType.esriGeometryPolygon:
((IPolygon)geometry).SimplifyPreserveFromTo();
break;
case esriGeometryType.esriGeometryPolyline:
if (geometry is IPolyline6)
((IPolyline6)geometry).SimplifyNonPlanar();
else
((IPolyline)geometry).SimplifyNetwork();
break;
default:
break;
}
return geometry;
}
[VB.NET]
Public Function SimplifyGeometry(ByVal geometry As IGeometry) As IGeometry
If geometry Is Nothing Then
Return Nothing
End If
'Set the IsKnownSimple property to false, otherwise simplification will not take place.
Dim topoOp As ITopologicalOperator2 = TryCast(geometry, ITopologicalOperator2)
topoOp.IsKnownSimple_2 = True
Select Case geometry.GeometryType
Case esriGeometryType.esriGeometryMultipoint
topoOp.Simplify()
Exit Select
Case esriGeometryType.esriGeometryPolygon
DirectCast(geometry, IPolygon).SimplifyPreserveFromTo()
Exit Select
Case esriGeometryType.esriGeometryPolyline
If TypeOf geometry Is IPolyline6 Then
DirectCast(geometry, IPolyline6).SimplifyNonPlanar()
Else
DirectCast(geometry, IPolyline).SimplifyNetwork()
End If
Exit Select
Case Else
Exit Select
End Select
Return geometry
End Function
See Also:
Calling the Simplify methodSimplifying a geometry
To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing | Deployment licensing |
---|---|
ArcGIS for Desktop Advanced | ArcGIS for Desktop Advanced |
ArcGIS for Desktop Standard | ArcGIS for Desktop Standard |
ArcGIS for Desktop Basic | ArcGIS for Desktop Basic |