From 5518745e8be3575a81fdecc32f74bbfbb2c36f6d Mon Sep 17 00:00:00 2001 From: Skylar Gering Date: Fri, 12 Jan 2024 09:50:23 -0800 Subject: [PATCH] Update comments and cleanup tests --- src/transformations/simplify.jl | 5 +++-- test/transformations/simplify.jl | 10 ++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/transformations/simplify.jl b/src/transformations/simplify.jl index a7fbf0ce6..bb47f05cc 100644 --- a/src/transformations/simplify.jl +++ b/src/transformations/simplify.jl @@ -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 @@ -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) diff --git a/test/transformations/simplify.jl b/test/transformations/simplify.jl index 35e4a0d9b..75ceeec09 100644 --- a/test/transformations/simplify.jl +++ b/test/transformations/simplify.jl @@ -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] @@ -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])