# Polyline simplification optimization strategy

Is there a way to simplify a polyline faster than using simplify curve? I have large amounts of polylines with straight segments made up of multiple segments. I’m looking for the fastest way to simplify straight sections into a single segment. Is there a way to take advantage of the input curve being a polyline (rather than a curve) ?

Have you tried with [Discontinuity] ?

If your problem is about the speed of the solution, using discontinuity instead of simplify should give you some valuable “speed-up”…

polylines_2019Jul13a.gh (8.7 KB)

P.S. Same as Riccardo’s but with visual aids.

Awesome, measuring now…

50% performance improvement!
The L (Level) setting is important:
L=1 is a bit slower
L=2 is 50% faster

1 Like

BEWARE! I never paid attention to the ‘L’ input of Discontinuity but just discovered something that is not good about using ‘L=2’ (curvature).

A standard trick to get the center of a rectangle is to take the Average of its discontinuity points. This is much faster than Area ‘C’ (Centroid) and can make a huge difference when dealing with hundreds or thousands of rectangles.

Having seen your post, I tried ‘L=2’ and discovered to my horror that it returns only three points instead of four!?!? Naturally, the Average of three is different than four so the “center” points are all shifted.

‘L = 1’ (tangency) or ‘L = 3’ (analytic):

‘L = 2’ (curvature):

This could be bad. I have no idea why this is so? But will avoid using ‘L = 2’ like the plague.

Strange… I did some small tests before my first reply and I was having greatly fastest solutions with discontinuity (L=1) than simplify.
Can you attach your geometries? It will be interesting to try different methods…

A standard trick to get the center of a rectangle is to take the Average of its discontinuity points. This is much faster than Area ‘C’ (Centroid) and can make a huge difference when dealing with hundreds or thousands of rectangles.

Just use the Polygon Center component.

2 Likes