I’ve been going over this algorithm and it seams pretty straight forward. I am, however, confused as to how to use it in a enclosed polygons. ALL of the examples I have seen deal with a line/curve with open ends. If i’m visualizing the process correctly drawing a single line and then iterating over it to re-capture the detail of a polygon wont work because it will always leave at least on side of the polygon open.
I’m thinking about writing an implementation that first makes 4 points (the farthest topLeft, TopRight, Bottomright, and BottomLeft points) and then runs the algorithm on vertices in between these to points indices.
So if the bottom line has an index of 40 and 80 in the original path array then I will iterate there and capture the likeness of that line on just points 40-80 them move onto the next side until all for sides are done.
I’ve been known to make a fool myself and way overcomplicate tings so I was wondering if this was a reasonable implementation?
I’m basicaly trying to replication the GPX data reduction impmentation seen below:


After a quick reading of the algorithm on Wikipedia, it seems that you can capture the simplified shape of the enclosed loop in a simple way.
Call the method with the start-point ‘A’ and end-point ‘Z’ being the same.
Modify the algorithm, so that if ‘A’ and ‘Z’ are the same point that instead of finding the farthest point perpendicular to the line AZ that it just looks for the point farthest away according to Euclidean distance from the Start/End point.
Now the algorithm recurses on A->M and M->Z where M is the point farthest from A (which is also Z). Now the algorithm can run normally.