From ba1139a580e30a590bfc3fefe05dca856dfe30b1 Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Wed, 27 Dec 2023 16:18:53 +0100 Subject: [PATCH] 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