Skip to content

Plotting extent_to_polygon fails due to conversion from static vector to generic array #384

@henrik-wolf

Description

@henrik-wolf

Using Makie, I am trying to plot (as an MWE) some points, their bounding box as well as the extent of the box. While the first two work great:

import GeometryOps as GO
import GeoInterface as GI
using GeometryBasics
using CairoMakie
a = [Point(rand(), rand()) for i = 1:100]
b = GO.convex_hull(a)

f = Figure()
ax = Axis(f[1, 1])

# works as expected
scatter!(ax, a)
lines!(ax, b)

f

I am having some trouble getting the extent to work.

c = GI.extent(b)
lines!(ax, c)

does not work directly (see rafaqz/Extents.jl#40)

however, converting and plotting the extent using

d = GO.extent_to_polygon(c)
lines!(ax, d)

fails somewhere down in GeoInterface with:

ERROR: MethodError: no method matching LineString(::StaticArraysCore.SizedVector{5, Point{2, Float64}, Vector{Point{2, Float64}}})
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/packages/GeometryBasics/yB1f1/src/basic_types.jl:304

Stacktrace:
  [1] convert(::Type{…}, type::GeoInterface.LineStringTrait, geom::GeoInterface.Wrappers.LinearRing{…})
    @ GeometryBasicsGeoInterfaceExt ~/.julia/packages/GeometryBasics/yB1f1/ext/GeometryBasicsGeoInterfaceExt.jl:123
  [2] convert(::Type{…}, type::GeoInterface.PolygonTrait, geom::GeoInterface.Wrappers.Polygon{…})
    @ GeometryBasicsGeoInterfaceExt ~/.julia/packages/GeometryBasics/yB1f1/ext/GeometryBasicsGeoInterfaceExt.jl:128
  [3] convert(package::Module, t::GeoInterface.PolygonTrait, geom::GeoInterface.Wrappers.Polygon{…})
    @ GeoInterface ~/.julia/packages/GeoInterface/X1jn3/src/fallbacks.jl:160
  [4] convert
    @ ~/.julia/packages/GeoInterface/X1jn3/src/fallbacks.jl:156 [inlined]
  [5] _makie_convert_arguments(t::Type, geom::GeoInterface.Wrappers.Polygon{…})
    @ GeoInterfaceMakieExt ~/.julia/packages/GeoInterface/X1jn3/ext/GeoInterfaceMakieExt.jl:10
  [6] convert_arguments(p::Type{…}, geom::GeoInterface.Wrappers.Polygon{…}; kw::@Kwargs{})
    @ GeoInterfaceMakieExt ~/.julia/packages/GeoInterface/X1jn3/src/plotting.jl:74
  [7] convert_arguments(p::Type{…}, geom::GeoInterface.Wrappers.Polygon{…})
    @ GeoInterfaceMakieExt ~/.julia/packages/GeoInterface/X1jn3/src/plotting.jl:73
  [8] _register_argument_conversions!(::Type{Lines}, attr::ComputePipeline.ComputeGraph, user_kw::Dict{Symbol, Any})
    @ Makie ~/.julia/packages/Makie/Vn16E/src/compute-plots.jl:496
  [9] register_arguments!
    @ ~/.julia/packages/Makie/Vn16E/src/compute-plots.jl:382 [inlined]
 [10] (Lines)(user_args::Tuple{GeoInterface.Wrappers.Polygon{…}}, user_attributes::Dict{Symbol, Any})
    @ Makie ~/.julia/packages/Makie/Vn16E/src/compute-plots.jl:769
 [11] _create_plot!(::Function, ::Dict{…}, ::Axis, ::GeoInterface.Wrappers.Polygon{…})
    @ Makie ~/.julia/packages/Makie/Vn16E/src/figureplotting.jl:403
 [12] lines!(::Axis, ::Vararg{Any}; kw::@Kwargs{})
    @ Makie ~/.julia/packages/Makie/Vn16E/src/recipes.jl:534
 [13] lines!(::Axis, ::Vararg{Any})
    @ Makie ~/.julia/packages/Makie/Vn16E/src/recipes.jl:532

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions