Skip to content

Commit

Permalink
Sg/debug simplifies (#48)
Browse files Browse the repository at this point in the history
* Don't oversimplify small polygons

* Remove magic number
  • Loading branch information
skygering authored Jan 18, 2024
1 parent 5c78897 commit 9b07731
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/transformations/simplify.jl
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ function _simplify(alg::DouglasPeucker, points::Vector, preserve_endpoint)
i = 2 # already have first and last point added
start_idx, end_idx = 1, npoints
max_idx, max_dist = _find_max_squared_dist(points, start_idx, end_idx)
while i < max_points && max_dist > max_tol
while i min(MIN_POINTS + 1, max_points) || (i < max_points && max_dist > max_tol)
# Add next point to results
i += 1
results[i] = max_idx
Expand Down Expand Up @@ -309,7 +309,7 @@ end
by conencting the points at start_idx and end_idx. Note that the first index of maximum
value will be used, which might cause differences in results from other algorithms.=#
function _find_max_squared_dist(points, start_idx, end_idx)
max_idx = 0
max_idx = start_idx
max_dist = zero(Float64)
for i in (start_idx + 1):(end_idx - 1)
d = _squared_distance_line(Float64, points[i], points[start_idx], points[end_idx])
Expand Down

0 comments on commit 9b07731

Please sign in to comment.