SimplifyPolyline Method (GeometryEngine)
Use either planar, nonplanar, or network simplify regardless of M-awareness.
Parameters
- polyline
- The polyline to simplify.
- simplifyType
- The type of simplify to perform.
- forceSimplify
-
(Optional) The default value is false. When true, it forces the simplification code to be applied to
the geometry even if the geometry comes from a trusted source or has already been
simplified. When false, the method will do nothing if called on the same geometry a second time.
Return Value
The simplified polyline.
Simplify a polyline with intersections, overlaps
List<Coordinate2D> coords = new List<Coordinate2D>()
{
new Coordinate2D(8, 0),
new Coordinate2D(8, 4),
new Coordinate2D(6, 4),
new Coordinate2D(8, 4),
new Coordinate2D(10, 4),
new Coordinate2D(8, 4)
};
SpatialReference sr = SpatialReferences.WGS84;
// build a line that has segments that cross over each other
Polyline polyline = PolylineBuilderEx.CreatePolyline(coords, sr);
// polyline.PartCount = 1
ReadOnlyPartCollection parts = polyline.Parts;
ReadOnlySegmentCollection segments = parts[0];
// segments.Count = 5
// note there is a difference between SimpleAsFeature (doesn't detect intersections and overlaps, determines if it's simple enough for gdb storage)
// and SimplifyPolyline (does detect intersections etc)
bool isSimple = GeometryEngine.Instance.IsSimpleAsFeature(polyline, false);
// isSimple = true
// simplify it (with force = false)
// because it has already been deemed 'simple' (previous IsSimpleAsFeature call) no detection of intersections, overlaps occur
Polyline simplePolyline = GeometryEngine.Instance.SimplifyPolyline(polyline, SimplifyType.Planar, false);
// simplePolyline.PartCount = 1
ReadOnlyPartCollection simpleParts = simplePolyline.Parts;
ReadOnlySegmentCollection simpleSegments = simpleParts[0];
// simpleSegments.Count = 5
// simplify it (with force = true)
// detection of intersections, overlaps occur
simplePolyline = GeometryEngine.Instance.SimplifyPolyline(polyline, SimplifyType.Planar, true);
// simplePolyline.PartCount = 3
simpleParts = simplePolyline.Parts;
simpleSegments = simpleParts[0];
// simpleSegments.Count = 1
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.