Skip to content

Commit d6eadb9

Browse files
Remove conflicting simplify() method definition (#325)
1 parent 067abe0 commit d6eadb9

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

src/transformations/simplify.jl

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ RadialDistance
1414
1515
## What is Geometry Simplification?
1616
17-
Geometry simplification reduces the number of points in a geometry while preserving its essential shape.
18-
This is usually done by specifying some tolerance.
17+
Geometry simplification reduces the number of points in a geometry while preserving its essential shape.
18+
This is usually done by specifying some tolerance.
1919
20-
GeometryOps provides three simplification algorithms: [`VisvalingamWhyatt`](@ref), [`DouglasPeucker`](@ref),
21-
and [`RadialDistance`](@ref), listed in order of decreasing quality but increasing performance.
20+
GeometryOps provides three simplification algorithms: [`VisvalingamWhyatt`](@ref), [`DouglasPeucker`](@ref),
21+
and [`RadialDistance`](@ref), listed in order of decreasing quality but increasing performance.
2222
2323
The default algorithm is [`DouglasPeucker`](@ref), which is also available through the GEOS extension.
2424
2525
In GeometryOps' algorithms, you can specify
2626
`tol`, `number` of points, or `ratio` of points after simplification to points in the input geometry.
2727
28-
The GEOS extension (activated by loading [LibGEOS.jl](https://github.com/JuliaGeo/LibGEOS.jl)) also allows for GEOS's topology preserving simplification
28+
The GEOS extension (activated by loading [LibGEOS.jl](https://github.com/JuliaGeo/LibGEOS.jl)) also allows for GEOS's topology preserving simplification
2929
as well as Douglas-Peucker simplification implemented in GEOS. Call this by
3030
passing [`GEOS(; method = :TopologyPreserve)`](@ref GEOS) or [`GEOS(; method = :DouglasPeucker)`](@ref GEOS)
3131
to the algorithm.
@@ -71,7 +71,7 @@ const MIN_POINTS = 3
7171
const SIMPLIFY_ALG_KEYWORDS = """
7272
## Keywords
7373
74-
- `ratio`: the fraction of points that should remain after `simplify`.
74+
- `ratio`: the fraction of points that should remain after `simplify`.
7575
Useful as it will generalise for large collections of objects.
7676
- `number`: the number of points that should remain after `simplify`.
7777
Less useful for large collections of mixed size objects.
@@ -89,9 +89,9 @@ Abstract type for simplification algorithms.
8989
9090
## API
9191
92-
For now, the algorithm must hold the `number`, `ratio` and `tol` properties.
92+
For now, the algorithm must hold the `number`, `ratio` and `tol` properties.
9393
94-
Simplification algorithm types can hook into the interface by implementing
94+
Simplification algorithm types can hook into the interface by implementing
9595
the `_simplify(trait, alg, geom)` methods for whichever traits are necessary.
9696
"""
9797
abstract type SimplifyAlg end
@@ -100,11 +100,11 @@ abstract type SimplifyAlg end
100100
simplify(obj; kw...)
101101
simplify(::SimplifyAlg, obj; kw...)
102102
103-
Simplify a geometry, feature, feature collection,
103+
Simplify a geometry, feature, feature collection,
104104
or nested vectors or a table of these.
105105
106-
[`RadialDistance`](@ref), [`DouglasPeucker`](@ref), or
107-
[`VisvalingamWhyatt`](@ref) algorithms are available,
106+
[`RadialDistance`](@ref), [`DouglasPeucker`](@ref), or
107+
[`VisvalingamWhyatt`](@ref) algorithms are available,
108108
listed in order of increasing quality but decreasing performance.
109109
110110
`PoinTrait` and `MultiPointTrait` are returned unchanged.
@@ -161,7 +161,6 @@ GI.npoint(simple)
161161
```
162162
"""
163163
simplify(alg::SimplifyAlg, data; kw...) = _simplify(alg, data; kw...)
164-
simplify(alg::GEOS, data; kw...) = _simplify(alg, data; kw...)
165164

166165
# Default algorithm is DouglasPeucker
167166
simplify(
@@ -218,7 +217,7 @@ $SIMPLIFY_ALG_KEYWORDS
218217
219218
Note: user input `tol` is squared to avoid unnecessary computation in algorithm.
220219
"""
221-
@kwdef struct RadialDistance <: SimplifyAlg
220+
@kwdef struct RadialDistance <: SimplifyAlg
222221
number::Union{Int64,Nothing} = nothing
223222
ratio::Union{Float64,Nothing} = nothing
224223
tol::Union{Float64,Nothing} = nothing
@@ -395,7 +394,7 @@ $SIMPLIFY_ALG_KEYWORDS
395394
its neighboring points.
396395
Note: user input `tol` is doubled to avoid unnecessary computation in algorithm.
397396
"""
398-
@kwdef struct VisvalingamWhyatt <: SimplifyAlg
397+
@kwdef struct VisvalingamWhyatt <: SimplifyAlg
399398
number::Union{Int,Nothing} = nothing
400399
ratio::Union{Float64,Nothing} = nothing
401400
tol::Union{Float64,Nothing} = nothing
@@ -488,9 +487,9 @@ function _get_points(alg, points, tolerances)
488487
tol = alg.tol
489488
number = alg.number
490489
ratio = alg.ratio
491-
bit_indices = if !isnothing(tol)
490+
bit_indices = if !isnothing(tol)
492491
_tol_indices(alg.tol::Float64, points, tolerances)
493-
elseif !isnothing(number)
492+
elseif !isnothing(number)
494493
_number_indices(alg.number::Int64, points, tolerances)
495494
else
496495
_ratio_indices(alg.ratio::Float64, points, tolerances)
@@ -506,7 +505,7 @@ function _number_indices(n, points, tolerances)
506505
tol = partialsort(tolerances, length(points) - n + 1)
507506
bit_indices = _tol_indices(tol, points, tolerances)
508507
nselected = sum(bit_indices)
509-
## If there are multiple values exactly at `tol` we will get
508+
## If there are multiple values exactly at `tol` we will get
510509
## the wrong output length. So we need to remove some.
511510
while nselected > n
512511
min_tol = Inf
@@ -521,7 +520,7 @@ function _number_indices(n, points, tolerances)
521520
nselected -= 1
522521
bit_indices[min_i] = false
523522
end
524-
return bit_indices
523+
return bit_indices
525524
end
526525

527526
function _ratio_indices(r, points, tolerances)
@@ -539,7 +538,7 @@ function _flat_tolerances(f, points)::Vector{Float64}
539538
return result
540539
end
541540

542-
function _remove!(s, i)
541+
function _remove!(s, i)
543542
for j in i:lastindex(s)-1
544543
s[j] = s[j+1]
545544
end

0 commit comments

Comments
 (0)