Skip to content

Commit

Permalink
Update comments and cleanup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
skygering committed Jan 12, 2024
1 parent d872f8a commit 5518745
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/transformations/simplify.jl
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ Note: user input `tol` is squared to avoid uneccesary computation in algorithm.
end

#= Simplify using the DouglasPeucker algorithm - nice gif of process on wikipedia:
(https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm) =#
(https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm). =#
function _simplify(alg::DouglasPeucker, points::Vector, preserve_endpoint)
npoints = length(points)
npoints <= MIN_POINTS && return points
Expand Down Expand Up @@ -306,7 +306,8 @@ function _simplify(alg::DouglasPeucker, points::Vector, preserve_endpoint)
end

#= find maximum distance of any point between the start_idx and end_idx to the line formed
by conencting the points at start_idx and end_idx. =#
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_dist = zero(Float64)
Expand Down
10 changes: 4 additions & 6 deletions test/transformations/simplify.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using Test
# import GeoInterface as GI
# import GeometryOps as GO
import GeoJSON
import JLD2

@testset "simplify" begin
datadir = realpath(joinpath(dirname(pathof(GO)), "../test/data"))
datadir = realpath(joinpath(dirname(pathof(GO)), "../test/data"))
@testset "RadialDistance and VisvalingamWhyatt" begin
fc = GeoJSON.read(joinpath(datadir, "simplify.geojson"))
fc2 = GeoJSON.read(joinpath(datadir, "simplify2.geojson"))
fcs = [fc for i in 1:100]
Expand All @@ -16,7 +13,8 @@ import JLD2
GO.simplify(T(tol=0.001), fc; threaded=true, calc_extent=true)
GO.simplify(T(tol=0.001), fcs; threaded=true, calc_extent=true)
end

end
@testset "DouglasPeucker" begin
poly_coords = JLD2.jldopen(joinpath(datadir, "complex_polygons.jld2"))["verts"][1:4]
for c in poly_coords
npoints = length(c[1])
Expand Down

0 comments on commit 5518745

Please sign in to comment.