Skip to content

Polygon(::AbstractVector) method not working on v0.5 for non base Vector types #236

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

Closed
favba opened this issue Jan 17, 2025 · 0 comments · Fixed by #237
Closed

Polygon(::AbstractVector) method not working on v0.5 for non base Vector types #236

favba opened this issue Jan 17, 2025 · 0 comments · Fixed by #237

Comments

@favba
Copy link
Contributor

favba commented Jan 17, 2025

In v0.5 :

julia> using GeometryBasics, StaticArrays

julia> p = SA[Point(1.,1.), Point(2.,2.), Point(0.2,2.)]
3-element SVector{3, Point{2, Float64}} with indices SOneTo(3):
 [1.0, 1.0]
 [2.0, 2.0]
 [0.2, 2.0]

julia> Polygon(p)
ERROR: MethodError: no method matching Polygon(::SVector{3, Point{2, Float64}}, ::Vector{Vector{Point{2, Float64}}})
The type `Polygon` exists, but no method is defined for this combination of argument types when trying to construct it.

Closest candidates are:
  Polygon(::Array{Point{Dim, T}, 1}, ::Array{Array{Point{Dim, T}, 1}, 1}) where {Dim, T<:Real}
   @ GeometryBasics ~/.julia/packages/GeometryBasics/ebuW5/src/basic_types.jl:279
  Polygon(::AbstractArray{Point{Dim, T}, 1}, ::AbstractArray{AbstractArray{Point{Dim, T}, 1}, 1}) where {Dim, T}
   @ GeometryBasics ~/.julia/packages/GeometryBasics/ebuW5/src/basic_types.jl:289
  Polygon(::AbstractArray{Point{N, T}, 1}) where {N, T}
   @ GeometryBasics ~/.julia/packages/GeometryBasics/ebuW5/src/basic_types.jl:296
  ...

Stacktrace:
 [1] Polygon(exterior::SVector{3, Point{2, Float64}})
   @ GeometryBasics ~/.julia/packages/GeometryBasics/ebuW5/src/basic_types.jl:296
 [2] top-level scope
   @ REPL[40]:1

julia> Polygon(Array(p))
Polygon{2, Float64}(Point{2, Float64}[[1.0, 1.0], [2.0, 2.0], [0.2, 2.0]], Vector{Point{2, Float64}}[])
favba added a commit to favba/GeometryBasics.jl that referenced this issue Jan 18, 2025
SimonDanisch pushed a commit that referenced this issue Jan 24, 2025
* Fix Polygon constructor type signature

* Add test for issue #236 fix
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

Successfully merging a pull request may close this issue.

1 participant