Skip to content

Commit 45315ee

Browse files
authored
Docstring and apply reduce fixes (#101)
* Eagerly call `booltype` in `segmentize` * Add .DS_Store to gitignore * Fix error in `applyreduce` when passing iterable * Fix apply docstring
1 parent 8d8070a commit 45315ee

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/Manifest.toml
22
/docs/build/
33
/docs/src/source/
4-
.vscode/
4+
.vscode/
5+
.DS_Store

src/primitives.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ complexity involved with handling complex geometry structures.
1919
For example, a simple way to flip the x and y coordinates of a geometry is:
2020
2121
```julia
22-
flipped_geom = GO.apply(GI.PointTrait, geom) do p
22+
flipped_geom = GO.apply(GI.PointTrait(), geom) do p
2323
(GI.y(p), GI.x(p))
2424
end
2525
```
@@ -157,7 +157,7 @@ by passing the keyword argument `threaded=true` to `apply`.
157157
=#
158158

159159
"""
160-
apply(f, target::Type{<:AbstractTrait}, obj; kw...)
160+
apply(f, target::Union{TraitTarget, GI.AbstractTrait}, obj; kw...)
161161
162162
Reconstruct a geometry, feature, feature collection, or nested vectors of
163163
either using the function `f` on the `target` trait.
@@ -334,7 +334,7 @@ for T in (
334334
end
335335

336336
"""
337-
applyreduce(f, op, target::Type{<:AbstractTrait}, obj; threaded)
337+
applyreduce(f, op, target::Union{TraitTarget, GI.AbstractTrait}, obj; threaded)
338338
339339
Apply function `f` to all objects with the `target` trait,
340340
and reduce the result with an `op` like `+`.
@@ -363,7 +363,7 @@ end
363363
if Tables.istable(iterable)
364364
_applyreduce_table(f, op, target, iterable; threaded, init)
365365
else
366-
applyreduce_iterable(i) = _applyreduce(f, op, target, x; threaded=_False(), init)
366+
applyreduce_iterable(i) = _applyreduce(f, op, target, i; threaded=_False(), init)
367367
if threaded isa _True # Try to `collect` and reduce over the vector with threads
368368
_applyreduce(f, op, target, collect(iterable); threaded, init)
369369
else

src/transformations/segmentize.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ This is useful for plotting geometries with a limited number of vertices, or for
169169
Returns a geometry of similar type to the input geometry, but resampled.
170170
"""
171171
function segmentize(geom; max_distance, threaded::Union{Bool, BoolsAsTypes} = _False())
172-
return segmentize(LinearSegments(; max_distance), geom; threaded)
172+
return segmentize(LinearSegments(; max_distance), geom; threaded = _booltype(threaded))
173173
end
174174
function segmentize(method::SegmentizeMethod, geom; threaded::Union{Bool, BoolsAsTypes} = _False())
175175
@assert method.max_distance > 0 "`max_distance` should be positive and nonzero! Found $(method.max_distance)."

0 commit comments

Comments
 (0)