Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
#- '1.7' # Leave this line unchanged. '1' will automatically expand to the latest stable 1.x release of Julia.
- '~1.10.0-0'
#- '~1.11.0-0'
#- '~1.12.0-0'
- '~1.12.0-0'
#- '~1.13.0-0'
- 'nightly'
os:
Expand Down
4 changes: 1 addition & 3 deletions src/blendimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,8 @@ function lelandshade(G::GMTgrid; detail=1.0, contrast=2.0, uint16=false, intensi
if (cmap != "")
cpt = cmap
isa(cpt, GMTcpt) && (CURRENT_CPT[] = cpt)
elseif (equalize == 0)
cpt = makecpt(G; C=_cpt, Vd=-1, kw...) # The 'nothing' branch will pick G's cpt
else
cpt = (equalize == 1) ? grd2cpt(G, C=_cpt, kw...) : grd2cpt(G, T="$equalize", C=_cpt, Vd=-1, kw...)
cpt = (equalize == 0) ? makecpt(G, C=_cpt, kw...) : makecpt(G, C=_cpt, equalize=equalize, kw...)
end
color = gdaldem(G, "color-relief"; color=cpt, kw...)
blendimg!(I1, Ihill, transparency=transparency)
Expand Down
27 changes: 15 additions & 12 deletions src/makecpt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,25 +89,28 @@ function makecpt(w::wrapDatasets, d::Dict)::Union{String, GMTcpt}
return r
end

function makecpt(G::GMTgrid; kw...) # A version that works on grids.
d = KW(kw...)
have_equalize = (is_in_kwargs(kw, [:equalize]) && d[:equalize] == 1) # Because equalize=true escapes detection in parse_opt_range
opt_T = parse_opt_range(d, "")[1]
!isempty(opt_T) && (d[:T] = opt_T)
makecpt(G::GMTgrid, have_equalize || !isempty(opt_T), d)
end

function makecpt(G::GMTgrid; equalize=false, kw...) # A version that works on grids.
function makecpt(G::GMTgrid, have_equalize, d) # A version that works on grids.
# equalize = true uses default grd2cpt. equalize=n uses grd2cpt -Tn
# The kw... are those of makecpt or grd2cpt depending on 'equalize'.

val, symb = find_in_kwargs(kw, CPTaliases)
val = find_in_dict(d, CPTaliases)[1]
cpt = (val === nothing) ? ((G.cpt != "") ? G.cpt : :turbo) : nothing
d = Dict{Symbol, Any}()
if (equalize == 0 && symb != Symbol() && val === nothing && cpt !== nothing)
# It means kw have a -C, but it can be a C=nothing. Remove the duplicate that was in kw.
d = KW(kw...); delete!(d, symb) # This confusion is due to the crazziness possible in lelandshade()
end
if (equalize == 0)
t = isempty(d) ? kw : d
d[:C] = cpt
if (!have_equalize)
range::Vector{Float64} = G.range
loc_eps = 0.0004
makecpt(; T=@sprintf("%.12g/%.12g/256+n", range[5] - loc_eps*abs(range[5]), range[6] + loc_eps*abs(range[6])), C=cpt, t...)
d[:T] = @sprintf("%.12g/%.12g/256+n", range[5] - loc_eps*abs(range[5]), range[6] + loc_eps*abs(range[6]))
makecpt(wrapDatasets("", nothing), d)
else
(equalize == 1) ? grd2cpt(G, C=cpt, kw...) : grd2cpt(G, T="$equalize", C=cpt, kw...)
grd2cpt_helper(wrapGrids("", G), d)
end
end

Expand Down Expand Up @@ -138,7 +141,7 @@ end

# -------------------------------------------------------------------------------------------
function parse_opt_range(d::Dict, cmd::String, opt::String="")::Tuple{String, Vector{Float64}}
symbs = [:T :range :inc :bin]
symbs = [:T :range :inc :bin :equalize]
(SHOW_KWARGS[]) && return print_kwarg_opts(symbs, "Tuple | Array | String | Number"), Float64[] # Just print the options
Tvec::Vector{Float64} = Float64[]
if ((val = find_in_dict(d, symbs)[1]) !== nothing)
Expand Down
Loading