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 = PolylineBuilder.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