You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The simplify routine removes incorrect points due to 2 errors in the simplify_polyline function in geo.py.
The algorithm accepts a list of 'points' with points[0] and points[-1] being begin and end. The first task is to find the point furthest away from the line between 'begin' and 'end' so we should check all points between begin and end.
for point_no in range(len(points[1:-1])):
point = points[point_no]
This starts at points[0] (begin) and ends at points[-3] skipping 'end' and one before 'end'. Instead, we should use: for point_no in points[1:-1]:
or for point_no in range(1,len(points)-1):
The second error is in the recursive call. return (simplify_polyline(points[:tmp_max_distance_position + 2], max_distance) + simplify_polyline(points[tmp_max_distance_position + 1:], max_distance)[1:])
We want to call the function from (begin to anchor) and (anchor to end), removing one of the anchors during concatenation. The anchor point is tmp_max_distance_position and because of slicing we have to +1 (and +0), but in the code it was +2 (and +1), so not using the furthest point as an anchor, but whatever point came after that. What we want is:
The simplify routine removes incorrect points due to 2 errors in the simplify_polyline function in geo.py.
The algorithm accepts a list of 'points' with points[0] and points[-1] being begin and end. The first task is to find the point furthest away from the line between 'begin' and 'end' so we should check all points between begin and end.
This starts at points[0] (begin) and ends at points[-3] skipping 'end' and one before 'end'. Instead, we should use:
for point_no in points[1:-1]:
or
for point_no in range(1,len(points)-1):
The second error is in the recursive call.
return (simplify_polyline(points[:tmp_max_distance_position + 2], max_distance) + simplify_polyline(points[tmp_max_distance_position + 1:], max_distance)[1:])
We want to call the function from (begin to anchor) and (anchor to end), removing one of the anchors during concatenation. The anchor point is tmp_max_distance_position and because of slicing we have to +1 (and +0), but in the code it was +2 (and +1), so not using the furthest point as an anchor, but whatever point came after that. What we want is:
return (simplify_polyline(points[:tmp_max_distance_position+1], max_distance) + simplify_polyline(points[tmp_max_distance_position:], max_distance)[1:])
The text was updated successfully, but these errors were encountered: