From d9910bae89aecf1772ac99a7364b12c095fe5213 Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Wed, 27 Dec 2023 16:08:50 +0100 Subject: [PATCH 1/6] add Makie extension for plotting --- Project.toml | 11 +++++++++++ test/table.jl | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index 1ddf9f1..2a75258 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,15 +19,25 @@ 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" + +[weakdeps] +Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" + +[extensions] +ShapefileMakie = "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" 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" From ba1139a580e30a590bfc3fefe05dca856dfe30b1 Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Wed, 27 Dec 2023 16:18:53 +0100 Subject: [PATCH 2/6] add Makie extension --- Project.toml | 1 - ext/ShapefileMakie.jl | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 ext/ShapefileMakie.jl diff --git a/Project.toml b/Project.toml index 2a75258..840eef0 100644 --- a/Project.toml +++ b/Project.toml @@ -27,7 +27,6 @@ RecipesBase = "1" Tables = "0.2, 1" julia = "1.6" - [weakdeps] Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" diff --git a/ext/ShapefileMakie.jl b/ext/ShapefileMakie.jl new file mode 100644 index 0000000..78d8c81 --- /dev/null +++ b/ext/ShapefileMakie.jl @@ -0,0 +1,22 @@ +module ShapefileMakie +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 From ac5650b3d1b19f65ab07e61856c21cfbfc507d0c Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Wed, 27 Dec 2023 17:05:07 +0100 Subject: [PATCH 3/6] add Makie to targets --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 840eef0..8ae6ba7 100644 --- a/Project.toml +++ b/Project.toml @@ -42,4 +42,4 @@ 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"] From 8c5b700c6b710c95ca55f378b6e64bef4f509b42 Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Wed, 27 Dec 2023 18:10:22 +0100 Subject: [PATCH 4/6] better extension name --- Project.toml | 2 +- ext/{ShapefileMakie.jl => ShapefileMakieEx.jl} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename ext/{ShapefileMakie.jl => ShapefileMakieEx.jl} (96%) diff --git a/Project.toml b/Project.toml index 8ae6ba7..daa8bd0 100644 --- a/Project.toml +++ b/Project.toml @@ -31,7 +31,7 @@ julia = "1.6" Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" [extensions] -ShapefileMakie = "Makie" +ShapefileMakieExt = "Makie" [extras] ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3" diff --git a/ext/ShapefileMakie.jl b/ext/ShapefileMakieEx.jl similarity index 96% rename from ext/ShapefileMakie.jl rename to ext/ShapefileMakieEx.jl index 78d8c81..1ff486b 100644 --- a/ext/ShapefileMakie.jl +++ b/ext/ShapefileMakieEx.jl @@ -1,4 +1,4 @@ -module ShapefileMakie +module ShapefileMakieExt using GeoInterfaceMakie: GeoInterfaceMakie using Shapefile: Shapefile using Makie: Makie From 0f6be7f6f0c2dc5d002d08bc06938e50ac4d0b49 Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Wed, 27 Dec 2023 18:25:20 +0100 Subject: [PATCH 5/6] fix extension path --- ext/{ShapefileMakieEx.jl => ShapefileMakieExt.jl} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ext/{ShapefileMakieEx.jl => ShapefileMakieExt.jl} (100%) diff --git a/ext/ShapefileMakieEx.jl b/ext/ShapefileMakieExt.jl similarity index 100% rename from ext/ShapefileMakieEx.jl rename to ext/ShapefileMakieExt.jl From 9e89561810aa3e723979122cafb969acb990bb7a Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Wed, 27 Dec 2023 23:34:15 +0100 Subject: [PATCH 6/6] stop supporting < 1.9 --- .github/workflows/CI.yml | 2 +- Project.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 daa8bd0..00e2abf 100644 --- a/Project.toml +++ b/Project.toml @@ -25,7 +25,7 @@ Makie = "0.20" OrderedCollections = "1" RecipesBase = "1" Tables = "0.2, 1" -julia = "1.6" +julia = "1.9" [weakdeps] Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"