Skip to content

Commit 98452ad

Browse files
authored
Avoid passing coast=none to coast which result in a needless warning. (#1794)
1 parent efbdb9a commit 98452ad

2 files changed

Lines changed: 16 additions & 15 deletions

File tree

src/utils_project.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ function worldrectangular(GI::GItype; proj::StrSymb="+proj=vandg +over", pm=0, l
150150
cl = (isempty(coastlines)) ? pscoast(dump=:true, res=res, region=lims_geog) : coastlines
151151
cl = lonlat2xy(cl, t_srs=_proj)
152152
else
153-
cl = worldrectcoast(proj=_proj, res=res, coastlines=coastlines, limits=lims_geog)
153+
_res = (res == "none") ? "crude" : res # To shut up a pscoast warning
154+
cl = worldrectcoast(proj=_proj, res=_res, coastlines=coastlines, limits=lims_geog)
154155
end
155156
return (res != "none" || !isempty(coastlines)) ? (G, cl) : G
156157
end

src/utils_types.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ function helper_set_crs(d)
184184
(prj != "" && !startswith(prj, "+proj=")) && (prj = "+proj=" * prj)
185185
wkt = hlp_desnany_str(d, [:wkt])
186186
(prj == "" && wkt != "") && (prj = wkt2proj(wkt))
187-
epsg::Int = ((ep = find_in_dict(d, [:epsg])[1]) !== nothing) ? ep : 0
187+
epsg::Int = ((ep = hlp_desnany_int(d, [:epsg])) !== -999) ? ep : 0
188188
(prj == "" && wkt == "" && epsg != 0) && (prj = epsg2proj(epsg))
189189
return prj, wkt, epsg, ref_attrib, ref_coln
190190
end
@@ -212,12 +212,12 @@ function _mat2ds(mat::Array{T,N}, txt::Union{String,Vector{String}}, hdr::Vector
212212
return Dt
213213
end
214214

215-
is3D = (find_in_dict(d, [:is3D])[1] === nothing) ? false : true # Should account for is3D == false?
215+
is3D = (is_in_dict(d, [:is3D]; del=true) === nothing) ? false : true # Should account for is3D == false?
216216
isa(mat, Vector) && (mat = reshape(mat, length(mat), 1))
217217

218218
val = find_in_dict(d, [:multi :multicol])[1]
219219
multi = (val === nothing) ? false : ((val) ? true : false) # Like this it will error if val is not Bool
220-
segnan = (find_in_dict(d, [:segnan :nanseg])[1] !== nothing) ? true : false # A classic GMT multi-segment sep with NaNs
220+
segnan = (is_in_dict(d, [:segnan :nanseg]; del=true) !== nothing) ? true : false # A classic GMT multi-segment sep with NaNs
221221
segnan && (multi = true)
222222

223223
if ((x = find_in_dict(d, [:x])[1]) !== nothing)
@@ -405,7 +405,7 @@ function _mat2ds(mat::Array{T,N}, txt::Union{String,Vector{String}}, hdr::Vector
405405
CTRL.pocket_d[1] = d # Store d that may be not empty with members to use in other functions
406406
set_dsBB!(D) # Compute and set the global BoundingBox for this dataset
407407
#return (find_in_kwargs(kwargs, [:letsingleton])[1] !== nothing) ? D : (length(D) == 1 && !multi) ? D[1] : D
408-
return (find_in_dict(d, [:letsingleton])[1] !== nothing) ? D : (length(D) == 1 && !multi) ? D[1] : D
408+
return (is_in_dict(d, [:letsingleton]; del=true) !== nothing) ? D : (length(D) == 1 && !multi) ? D[1] : D
409409
end
410410

411411
# ---------------------------------------------------------------------------------------------------
@@ -617,11 +617,11 @@ function ds2ds(D::GMTdataset{T,2}, is3D::Bool, d::Dict)::Vector{<:GMTdataset{T,2
617617
#multi = 'r' # Default split by rows
618618
#if ((val = find_in_dict(d, [:multi :multicol], false)[1]) !== nothing) multi = 'c' end # Then by columns
619619
# Split by rows or columns
620-
multi = ((find_in_dict(d, [:multi :multicol], false)[1]) !== nothing) ? 'c' : 'r'
620+
multi = ((is_in_dict(d, [:multi :multicol]; del=false)) !== nothing) ? 'c' : 'r'
621621
_fill = (multi == 'r') ? helper_ds_fill(d) : String[] # In the columns case all is dealt in mat2ds.
622622

623623
n_colors = length(_fill)
624-
if ((val = find_in_dict(d, [:color_wrap])[1]) !== nothing) # color_wrap is a kind of private option for bar-stack
624+
if ((val = hlp_desnany_int(d, [:color_wrap])) !== -999) # color_wrap is a kind of private option for bar-stack
625625
n_colors::Int = Int(val)
626626
end
627627

@@ -1304,9 +1304,9 @@ function helper_mat2img(mat, x::Vector{Float64}, y::Vector{Float64}, v::Vector{F
13041304
end
13051305

13061306
mem_layout = (size(mat,3) == 1) ? "TCBa" : "TCBa" # Just to have something. Likely wrong for 3D
1307-
((val = find_in_dict(d, [:layout :mem_layout])[1]) !== nothing) && (mem_layout = string(val)::String)
1308-
_names::Vector{String} = ((val = find_in_dict(d, [:names])[1]) !== nothing) ? val : String[]
1309-
_meta::Vector{String} = ((val = find_in_dict(d, [:metadata])[1]) !== nothing) ? val : String[]
1307+
((val = hlp_desnany_str(d, [:layout :mem_layout])) !== "") && (mem_layout = val)
1308+
_names::Vector{String} = hlp_desnany_vstr(d, [:names])
1309+
_meta::Vector{String} = hlp_desnany_vstr(d, [:metadata])
13101310

13111311
GMTimage(proj4, wkt, 0, -1, hdr[1:6], [x_inc, y_inc], reg, NaN32, color_interp, _meta, _names,
13121312
x,y,v,mat, colormap, labels, n_colors, Array{UInt8,2}(undef,1,1), mem_layout, 0)
@@ -1381,7 +1381,7 @@ function mat2img(mat::Union{AbstractMatrix{UInt16},AbstractArray{UInt16,3}}; x=F
13811381
d = KW(kw)
13821382
x::Vector{Float64} = vec(x); y::Vector{Float64} = vec(y); v::Vector{Float64} = vec(v);
13831383
hdr::Vector{Float64} = vec(hdr)
1384-
if ((val = find_in_dict(d, [:noconv])[1]) !== nothing) # No conversion to UInt8 is wished
1384+
if ((is_in_dict(d, [:noconv])) !== nothing) # No conversion to UInt8 is wished
13851385
return mat2img16(mat; x=x, y=y, v=v, hdr=hdr, proj4=proj4, wkt=wkt, d...)
13861386
end
13871387

@@ -2543,13 +2543,13 @@ function hlp_desnany_arg2str(d, s, del=true)::String
25432543
end
25442544

25452545
# ---------------------------------------------------------------------------------------------------
2546-
function hlp_desnany_vstr(d, s)::Vector{String}
2547-
((val = find_in_dict(d, s)[1]) === nothing) ? String[] : (isa(val, String) ? [val] : val)
2546+
function hlp_desnany_vstr(d, s, del=true)::Vector{String}
2547+
((val = find_in_dict(d, s, del)[1]) === nothing) ? String[] : (isa(val, String) ? [val] : val)
25482548
end
25492549

25502550
# ---------------------------------------------------------------------------------------------------
2551-
function hlp_desnany_int(d, s, default::Int=-999)::Int
2552-
((val = find_in_dict(d, s)[1]) === nothing) ? default : (isa(val, Real) ? round(Int, val) : parse(Int, val))
2551+
function hlp_desnany_int(d, s, default::Int=-999; del=false)::Int
2552+
((val = find_in_dict(d, s, del)[1]) === nothing) ? default : (isa(val, Real) ? round(Int, val) : parse(Int, val))
25532553
end
25542554

25552555
# ---------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)