Skip to content

Commit

Permalink
Add scale parameter for generate_map
Browse files Browse the repository at this point in the history
  • Loading branch information
hanakl committed Nov 21, 2024
1 parent fb9972c commit 78a5ff7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 13 additions & 6 deletions ext/QuantumSavoryGeoMakie/QuantumSavoryGeoMakie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@ module QuantumSavoryGeoMakie
import Makie, GeoMakie
using GeoMakie: GeoAxis, image!, poly!, naturalearth

"""Generates a default map with country and state boundaries and returns a GeoAxis. The returned GeoAxis can be used as an input for registernetplot_axis."""
function generate_map(subfig::Makie.GridPosition)
"""
Generates a default map with country and state boundaries and returns a GeoAxis. The returned GeoAxis can be used as an input for registernetplot_axis.
For borders, the optional `scale` parameter can be set to 10, 50, or 110, corresponding to Natural Earth resolutions of 1:10m, 1:50m, and 1:110m.
"""
function generate_map(subfig::Makie.GridPosition, scale::Int=110)
if scale (10, 50, 110)
error("Invalid scale value: scale must be 10, 50, or 110.")

Check warning on line 13 in ext/QuantumSavoryGeoMakie/QuantumSavoryGeoMakie.jl

View check run for this annotation

Codecov / codecov/patch

ext/QuantumSavoryGeoMakie/QuantumSavoryGeoMakie.jl#L11-L13

Added lines #L11 - L13 were not covered by tests
end
ax = GeoAxis(subfig; limits=((-180, 180), (-90, 90)), dest="+proj=longlat +datum=WGS84")
countries = naturalearth("admin_0_countries", 50)
states = naturalearth("admin_1_states_provinces_lakes", 50)
countries = naturalearth("admin_0_countries", scale)
states = naturalearth("admin_1_states_provinces_lakes", scale)
image!(ax, (-180, 180), (-90, 90), GeoMakie.earth() |> rotr90; interpolate=false, inspectable=false)
poly!(ax, GeoMakie.land(); color=:lightyellow, strokecolor=:black, strokewidth=1, inspectable=false)
poly!(ax, GeoMakie.land(); color=:lightyellow, strokecolor=:transparent, inspectable=false)
poly!(ax, GeoMakie.to_multipoly.(countries.geometry), color=:transparent, strokecolor=:black, strokewidth=1, inspectable=false)
poly!(ax, GeoMakie.to_multipoly.(states.geometry); color=:transparent, strokecolor=:grey, strokewidth=0.7, inspectable=false)
return ax

Check warning on line 22 in ext/QuantumSavoryGeoMakie/QuantumSavoryGeoMakie.jl

View check run for this annotation

Codecov / codecov/patch

ext/QuantumSavoryGeoMakie/QuantumSavoryGeoMakie.jl#L15-L22

Added lines #L15 - L22 were not covered by tests
end

function generate_map()
fig = Makie.Figure(size=(800,400))
fig = Makie.Figure()
generate_map(fig[1, 1])

Check warning on line 27 in ext/QuantumSavoryGeoMakie/QuantumSavoryGeoMakie.jl

View check run for this annotation

Codecov / codecov/patch

ext/QuantumSavoryGeoMakie/QuantumSavoryGeoMakie.jl#L25-L27

Added lines #L25 - L27 were not covered by tests
end

Expand Down
2 changes: 1 addition & 1 deletion ext/QuantumSavoryMakie/QuantumSavoryMakie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ function registernetplot_axis(subfig::Makie.GridPosition, registersobservable; i
end

function registernetplot_axis(registersobservable; infocli=true, datainspector=true, kwargs...)
fig = Figure(size=(800,400))
fig = Figure()
ax = Axis(fig[1, 1])
registernetplot_axis(ax, registersobservable; infocli, datainspector, kwargs...)

Check warning on line 320 in ext/QuantumSavoryMakie/QuantumSavoryMakie.jl

View check run for this annotation

Codecov / codecov/patch

ext/QuantumSavoryMakie/QuantumSavoryMakie.jl#L317-L320

Added lines #L317 - L320 were not covered by tests
end
Expand Down

0 comments on commit 78a5ff7

Please sign in to comment.