Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't construct a LineString from a view of a point vector #231

Open
asinghvi17 opened this issue Dec 14, 2024 · 0 comments
Open

Can't construct a LineString from a view of a point vector #231

asinghvi17 opened this issue Dec 14, 2024 · 0 comments

Comments

@asinghvi17
Copy link
Contributor

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant