diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 82eb70cb8..e8269f320 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/src/blendimg.jl b/src/blendimg.jl index 89aff88eb..94a97e662 100644 --- a/src/blendimg.jl +++ b/src/blendimg.jl @@ -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) diff --git a/src/makecpt.jl b/src/makecpt.jl index 8857f41c0..744bc8cc0 100644 --- a/src/makecpt.jl +++ b/src/makecpt.jl @@ -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 @@ -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)