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

Plotting empty MultiLineString is broken #97

Open
simeonschaub opened this issue Jan 27, 2025 · 1 comment
Open

Plotting empty MultiLineString is broken #97

simeonschaub opened this issue Jan 27, 2025 · 1 comment

Comments

@simeonschaub
Copy link

Not sure if this is the right repo, but the following code errors:

julia> using GeoMakie, CairoMakie, GeoJSON

julia> lines(GeoJSON.MultiLineString(; coordinates = Vector{Tuple{Float32, Float32}}[]))
[...]

julia> show(err)
1-element ExceptionStack:
MethodError: no method matching GeometryBasics.MultiLineString(::Vector{Any})
The type `GeometryBasics.MultiLineString` exists, but no method is defined for this combination of argument types when trying to construct it.

Closest candidates are:
  GeometryBasics.MultiLineString(::A) where {Dim, T<:Real, Element<:(GeometryBasics.LineString{Dim, T, P, V} where {P<:GeometryBasics.AbstractPoint, V<:(AbstractVector{<:GeometryBasics.Ngon{Dim, T, 2, P}})}), A<:AbstractVector{Element}}
   @ GeometryBasics ~/.julia/packages/GeometryBasics/ebXl0/src/basic_types.jl:331
  GeometryBasics.MultiLineString(::AbstractVector{L}; kw...) where {Dim, T, P, L<:AbstractArray{GeometryBasics.Ngon{Dim, T, 2, P}, 1}}
   @ GeometryBasics ~/.julia/packages/GeometryBasics/ebXl0/src/basic_types.jl:334

Stacktrace:
  [1] convert(::Type{GeometryBasics.MultiLineString}, type::GeoInterface.MultiLineStringTrait, geom::GeoJSON.MultiLineString{2, Float32})
    @ GeometryBasics ~/.julia/packages/GeometryBasics/ebXl0/src/geointerface.jl:145
  [2] convert(package::Module, geom::GeoJSON.MultiLineString{2, Float32})
    @ GeoInterface ~/.julia/packages/GeoInterface/4tyIo/src/fallbacks.jl:152
  [3] _convert_arguments(t::Type, geom::GeoJSON.MultiLineString{2, Float32})
    @ GeoInterfaceMakie ~/.julia/packages/GeoInterfaceMakie/vxpgB/src/GeoInterfaceMakie.jl:23
  [4] #convert_arguments#7
    @ ~/.julia/packages/GeoInterfaceMakie/vxpgB/src/GeoInterfaceMakie.jl:109 [inlined]
  [5] convert_arguments(p::Type{Lines}, geom::GeoJSON.MultiLineString{2, Float32})
    @ GeoJSONMakieExt ~/.julia/packages/GeoInterfaceMakie/vxpgB/src/GeoInterfaceMakie.jl:108
  [6] conversion_pipeline(P::Type{Lines}, used_attrs::Tuple{}, args::Tuple{GeoJSON.MultiLineString{2, Float32}}, kw_obs::Observable{Vector{Pair{Symbol, Any}}}, args_obs::Tuple{Observable{Any}}, user_attributes::Dict{Symbol, Any}, deregister::Vector{Observables.ObserverFunction}, recursion::Int64)
    @ Makie ~/.julia/packages/Makie/Y3ABD/src/interfaces.jl:227
  [7] conversion_pipeline(P::Type{Lines}, used_attrs::Tuple{}, args::Tuple{GeoJSON.MultiLineString{2, Float32}}, kw_obs::Observable{Vector{Pair{Symbol, Any}}}, args_obs::Tuple{Observable{Any}}, user_attributes::Dict{Symbol, Any}, deregister::Vector{Observables.ObserverFunction})
    @ Makie ~/.julia/packages/Makie/Y3ABD/src/interfaces.jl:218
  [8] (Lines)(user_args::Tuple{GeoJSON.MultiLineString{2, Float32}}, user_attributes::Dict{Symbol, Any})
    @ Makie ~/.julia/packages/Makie/Y3ABD/src/interfaces.jl:278
  [9] _create_plot(F::Function, attributes::Dict{Symbol, Any}, args::GeoJSON.MultiLineString{2, Float32})
    @ Makie ~/.julia/packages/Makie/Y3ABD/src/figureplotting.jl:316
 [10] #lines#48
    @ ~/.julia/packages/MakieCore/EU17Y/src/recipes.jl:510 [inlined]
 [11] lines(args::GeoJSON.MultiLineString{2, Float32})
    @ MakieCore ~/.julia/packages/MakieCore/EU17Y/src/recipes.jl:508
 [12] top-level scope
    @ REPL[4]:1

Encountered when trying to plot NaturalEarth.naturalearth("rivers_lake_centerlines", 50)

@rafaqz
Copy link
Member

rafaqz commented Jan 27, 2025

Maybe that's a GeometryBasice bug, empty vectors are not properly handled.

But I guess we need to merge the GeoInterface.jl coordtype PR and implement it everywhere to fix it. Empty things are not currently well implemented.

You may also find they are not well implemented in Makie, even if we fix the geometry part.

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

2 participants