JuliaGeometry / JuliaGeometry/GeometryBasics.jl
Can't construct a `LineString` from a view of a point vector
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 215
- Forks
- 64
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 2
Description
In v0.5,
using GeometryBasics
points = rand(Point2f, 10)
LineString(view(points, 1:5))
errors with:
ERROR: MethodError: no method matching LineString(::SubArray{Point{2, Float32}, 1, Vector{Point{2, Float32}}, Tuple{UnitRange{Int64}}, true})
The type `LineString` exists, but no method is defined for this combination of argument types when trying to construct it.
Closest candidates are:
LineString(::Array{Point{Dim, T}, 1}) where {Dim, T<:Real}
@ GeometryBasics ~/.julia/dev/GeometryBasics/src/basic_types.jl:347
Stacktrace:
[1] top-level scope
@ REPL[50]:1
It looks like the array type in LineString is now restrictive. Should we allow any abstract vector in there, and add an extra type parameter? Or is there some other way this should be done?
I ask because it's pretty hard to minimize allocations with this approach. If the issue is purely in the type printing, then it's easy enough to fix that to not show the last type parameter (the array type).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the example using Point2f, view(points, 1:5), and LineString, then inspect src/basic_types.jl around line 347. Determine whether the constructor should accept an abstract vector or use another representation. Done means the reported view-based construction works while addressing the allocation concern.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100