diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d940eba..834b098 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -13,7 +13,7 @@ jobs: fail-fast: true matrix: version: - - '1.7' + - '1.9' - '1' os: - ubuntu-latest diff --git a/Project.toml b/Project.toml index 1ddf9f1..00e2abf 100644 --- a/Project.toml +++ b/Project.toml @@ -8,6 +8,7 @@ DBFTables = "75c7ada1-017a-5fb6-b8c7-2125ff2d6c93" Extents = "411431e0-e8b7-467b-b5e0-f676ba4f2910" GeoFormatTypes = "68eda718-8dee-11e9-39e7-89f7f65f511f" GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f" +GeoInterfaceMakie = "0edc0954-3250-4c18-859d-ec71c1660c08" GeoInterfaceRecipes = "0329782f-3d07-4b52-b9f6-d3137cf03c7a" OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" @@ -18,18 +19,27 @@ DBFTables = "1.2" Extents = "0.1" GeoFormatTypes = "0.4" GeoInterface = "1.0" +GeoInterfaceMakie = "0.1" GeoInterfaceRecipes = "1.0" +Makie = "0.20" OrderedCollections = "1" RecipesBase = "1" Tables = "0.2, 1" -julia = "1.6" +julia = "1.9" + +[weakdeps] +Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" + +[extensions] +ShapefileMakieExt = "Makie" [extras] ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3" DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" +Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" RemoteFiles = "cbe49d4c-5af1-5b60-bb70-0a60aa018e1b" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["ArchGDAL", "DataFrames", "Plots", "RemoteFiles", "Test"] +test = ["ArchGDAL", "DataFrames", "Makie", "Plots", "RemoteFiles", "Test"] diff --git a/ext/ShapefileMakieExt.jl b/ext/ShapefileMakieExt.jl new file mode 100644 index 0000000..1ff486b --- /dev/null +++ b/ext/ShapefileMakieExt.jl @@ -0,0 +1,22 @@ +module ShapefileMakieExt +using GeoInterfaceMakie: GeoInterfaceMakie +using Shapefile: Shapefile +using Makie: Makie + +GeoInterfaceMakie.@enable Shapefile.AbstractShape +GeoInterfaceMakie.@enable Shapefile.SubPolygon +GeoInterfaceMakie.@enable Shapefile.LinearRing + +Makie.plottype(tbl::Shapefile.Table) = Makie.plottype(Shapefile.shapes(tbl)) +Makie.plottype(shp::Shapefile.Handle) = Makie.plottype(Shapefile.shapes(shp)) + +for T in (Any, Union{Type{Any}, Type{<:Makie.AbstractPlot}}, Type{<:Makie.Poly}, Type{<:Makie.Lines}, Makie.PointBased) + @eval begin + Makie.convert_arguments(t::$T, tbl::Shapefile.Table) = + Makie.convert_arguments(t, Shapefile.shapes(tbl)) + Makie.convert_arguments(t::$T, shp::Shapefile.Handle) = + Makie.convert_arguments(t, Shapefile.shapes(shp)) + end +end + +end diff --git a/test/table.jl b/test/table.jl index 095a702..3fef2e7 100644 --- a/test/table.jl +++ b/test/table.jl @@ -2,6 +2,7 @@ using Shapefile using Test using RemoteFiles using Plots +using Makie import DBFTables import Tables import DataFrames @@ -198,10 +199,37 @@ for shx_path in ne_shx end end -@testset "plot tables" begin - plot(ne_land) - plot(ne_coastline) - plot(ne_cities) + +@testset "plot tables with Plots.jl" begin + # Tables + Plots.plot(ne_land) + Plots.plot(ne_coastline) + Plots.plot(ne_cities) + # Handles + Plots.plot(getfield(ne_land, :shp)) + Plots.plot(getfield(ne_coastline, :shp)) + Plots.plot(getfield(ne_cities, :shp)) +end + +@testset "plot tables with Makie.jl" begin + # Tables + p = Makie.plot(ne_land) + # Makie doesn't actually plot vectors of multiline string: + # Makie.plot(ne_coastline) + # So we do it manually + for geom in Shapefile.shapes(ne_coastline) + Makie.plot!(p.axis, geom) + end + Makie.plot!(p.axis, ne_cities) + # Handles + p = Makie.plot(getfield(ne_land, :shp)) + # Makie doesn't actually plot vectors of multiline string: + # Makie.plot(ne_coastline) + # So we do it manually + for geom in Shapefile.shapes(getfield(ne_coastline, :shp)) + Makie.plot!(p.axis, geom) + end + Makie.plot!(p.axis, getfield(ne_cities, :shp)) end end # testset "Tables interface"