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 src/finish_PS_nested.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function add_opt_module_barr1(nt::NamedTuple, symb::Symbol)::Union{String, Vecto
!contains(r, " -B") && (r = replace(r, "psscale" => "psscale -Baf")) # Add -B if not present
elseif (symb == :clip) # Need lots of little shits to parse the clip options
if ((isa(nt, NamedTuple) && (isa(nt[1], String) || isa(nt[1], Symbol))) || isa(nt[1], NamedTuple))
r = (isa(nt, NamedTuple)) ? coast!(""; Vd=2, E=nt) : coast!(""; Vd=2, nt...)
r = (isa(nt, NamedTuple)) ? coast!(; Vd=2, E=nt) : coast!(; Vd=2, nt...)
opt_E = scan_opt(r, "-E") # We are clipping so opt_E must contain eith +c or +C. If not, add +c
startswith(opt_E, "=land") && (r = replace(r, " -E"*opt_E => " -Gc")) # Stupid user mistakes. Try to recover
startswith(opt_E, "=ocean") && (r = replace(r, " -E"*opt_E => " -Sc"))
Expand Down
10 changes: 6 additions & 4 deletions src/psclip.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@ clip!(cmd0::String; kwargs...) = clip_helper(cmd0, nothing; first=false, kwargs.
clip!(arg1; kwargs...) = clip_helper("", arg1; first=false, kwargs...)
clip!(; kwargs...) = clip_helper("", nothing; first=false, kwargs...)
clip(; kwargs...) = clip_helper("", nothing; first=false, kwargs...) # For when user forgot to use clip! instead of clip
function clip_helper(cmd0::String, arg1; first=true, kw...)
d, K, O = init_module(first, kw...) # Also checks if the user wants ONLY the HELP mode
clip_helper(cmd0, arg1, O, K, d)
end

# ---------------------------------------------------------------------------------------------------
function clip_helper(cmd0::String, arg1; first=true, kwargs...)
function clip_helper(cmd0::String, arg1, O::Bool, K::Bool, d::Dict{Symbol, Any})

proggy = (IamModern[]) ? "clip " : "psclip "

d, K, O = init_module(first, kwargs...) # Also checks if the user wants ONLY the HELP mode

cmd, _, _, opt_R = parse_BJR(d, "", "", O, " -JX" * split(DEF_FIG_SIZE, '/')[1] * "/0")
cmd, = parse_common_opts(d, cmd, [:UVXY :JZ :c :e :f :g :p :t :yx :params]; first=first)
cmd, = parse_common_opts(d, cmd, [:UVXY :JZ :c :e :f :g :p :t :yx :params]; first=!O)
cmd = parse_these_opts(cmd, d, [[:A :steps :straightlines], [:C :endclip], [:N :invert], [:T :clipregion :clip_limits]])
cmd *= add_opt_pen(d, [:W :pen], opt="W")

Expand Down
28 changes: 14 additions & 14 deletions src/pscoast.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
"""
coast(cmd0::String=""; kwargs...)
coast(; kwargs...)

Plot continents, shorelines, rivers, and borders on maps.

Plots grayshaded, colored, or textured land-masses [or water-masses] on
maps and [optionally] draws coastlines, rivers, and political
boundaries. A map projection must be supplied.
maps and [optionally] draws coastlines, rivers, and political boundaries.

Parameters
----------
Expand Down Expand Up @@ -75,11 +74,13 @@ Parameters

To see the full documentation type: ``@? coast``
"""
function coast(cmd0::String=""; clip::StrSymb="", first=true, kwargs...)
dbg_cmd, d, cmd, K, O, finish, get_largest, toTrack = coast_parser(first, string(clip); kwargs...)
function coast(; clip::StrSymb="", first=true, kwargs...)
d, K, O = init_module(first, kwargs...) # Also checks if the user wants ONLY the HELP mode
dbg_cmd, d, cmd, O, finish, get_largest, toTrack = coast_parser(first==1, string(clip), O, d)
(dbg_cmd !== nothing) && return dbg_cmd

# Have a big possible break here to allow PS_nested call only the parsing part and hence fck the Julia recompilation eagerness
coast(cmd, K, O, finish, get_largest, toTrack, d)
end
function coast(cmd::Vector{String}, K::Bool, O::Bool, finish::Bool, get_largest::Bool, toTrack, d::Dict{Symbol, Any})

# Don't call finish_PS_module if -M because it returns a GDtype instead of a PS
R = (length(cmd) == 1 && contains(cmd[1], " -M")) ? gmt(cmd[1]) : prep_and_call_finish_PS_module(d, cmd, "", K, O, finish)
Expand All @@ -105,14 +106,13 @@ function coast(cmd0::String=""; clip::StrSymb="", first=true, kwargs...)
R
end

function coast_parser(first::Bool, clip::String; kwargs...)
function coast_parser(first::Bool, clip::String, O::Bool, d::Dict{Symbol, Any})

d, K, O = init_module(first, kwargs...) # Also checks if the user wants ONLY the HELP mode
gmt_proggy = (IamModern[]) ? "coast " : "pscoast "

if ((val = hlp_desnany_str(d, [:getR :getregion :get_region], false)) !== "")
t::String = string(gmt_proggy, " -E", val)
resto = d, "", K, O, true, false, ""
resto = d, "", O, true, false, ""
((Vd = hlp_desnany_int(d, [:Vd])) !== -999) && (Vd == 1 ? println(t) : Vd > 1 ? (return t, resto...) : nothing)
t = parse_V(d::Dict, t)
return gmt(t).text[1]::String, resto...
Expand All @@ -124,7 +124,7 @@ function coast_parser(first::Bool, clip::String; kwargs...)
twoORfour = have_opt_M && contains(cmd, "+z") && contains(cmd, '.') ? "4" : "2" # To use in gmt_main to decide CODE attrib
if (cmd != "") # Check for a minimum of points that segments must have
if ((val = hlp_desnany_str(d, [:minpts])) !== "") POSTMAN[]["minpts"] = val
elseif (get(POSTMAN[], "minpts", "") != "") delete!(POSTMAN[], "minpts")
elseif (get(POSTMAN[], "minpts", "") != "") delete!(POSTMAN[], "minpts")
end
end

Expand All @@ -135,7 +135,7 @@ function coast_parser(first::Bool, clip::String; kwargs...)
POSTMAN[]["DCWnames"] = twoORfour # When dumping, we want to add the country name as attribute
if ((val = find_in_dict(d, [:Z])[1]) !== nothing)
toTrack = (isa(val, GMTgrid) || (isa(val, String) && length(val) > 4)) ? val : ""
toTrack == "" && (POSTMAN[]["plusZzero"] = "y")# If toTrack the extra column is added by the grdtrack call below
toTrack == "" && (POSTMAN[]["plusZzero"] = "y") # If toTrack the extra column is added by the grdtrack call below
end
end

Expand Down Expand Up @@ -193,7 +193,7 @@ function coast_parser(first::Bool, clip::String; kwargs...)
end

r = check_dbg_print_cmd(d, _cmd)
return r, d, _cmd, K, O, finish, get_largest, toTrack
return r, d, _cmd, O, finish, get_largest, toTrack
end

# ---------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -293,7 +293,7 @@ function parse_dcw(val::Tuple)::String
end

# ---------------------------------------------------------------------------------------------------
coast!(cmd0::String=""; clip::StrSymb="", kw...) = coast(cmd0; clip=clip, first=false, kw...)
coast!(; clip::StrSymb="", kw...) = coast(; clip=clip, first=false, kw...)

const pscoast = coast # Alias
const pscoast! = coast!
Expand Down
4 changes: 2 additions & 2 deletions src/subplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function subplot(fim::String, stop::Bool, d::Dict{Symbol, Any})
end

do_set = false; do_show = false
if (fim !== nothing)
if (fim !== "")
if (fim == "end" || fim == "stop") stop = true
elseif (fim == "show") stop, do_show = true, true
elseif (fim == "set") do_set = true
Expand All @@ -82,7 +82,7 @@ function subplot(fim::String, stop::Bool, d::Dict{Symbol, Any})
do_show = (d[:show] != 0)
stop = true
else
if (!stop && has_options) stop = true end # To account for the subplot() call case
if (!stop && !has_options) stop = true end # To account for the subplot() call case
end
# ------------------------------ End parsing inputs --------------------------------

Expand Down
Loading