Skip to content

Commit 4545e06

Browse files
committed
Add Anaglyph program.
2 parents ec6e115 + 42281bb commit 4545e06

6 files changed

Lines changed: 27 additions & 21 deletions

File tree

src/GMT.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ export
188188
Ginnerjoin, Gouterjoin, Gleftjoin, Grightjoin, Gcrossjoin, Gsemijoin, Gantijoin, spatialjoin,
189189
groupby, stats,
190190

191+
anaglyph,
191192
lazinfo, lazread, lazwrite, lasread, laswrite,
192193
okada,
193194
haralick,
@@ -337,6 +338,7 @@ include("xyz2grd.jl")
337338
include("utils.jl")
338339
include("utils_project.jl")
339340
include("choropleth_utils.jl")
341+
include("extras/anaglyph.jl")
340342
include("extras/hampel_outliers.jl")
341343
include("extras/isoutlier.jl")
342344
include("extras/lowess.jl")

src/common_options.jl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,25 +1321,25 @@ function consolidate_Baxes(opt_B::String)::String
13211321
end
13221322

13231323
# ---------------------------------------------------------------------------------------------------
1324-
title(; str::AbstractString="", font=nothing, offset=0) = titles_e_comp(str, font, offset)
1325-
subtitle(; str::AbstractString="", font=nothing, offset=0) = titles_e_comp(str, font, offset, "s")
1326-
xlabel(; str::AbstractString="", font=nothing, offset=0) = titles_e_comp(str, font, offset, "x")
1327-
ylabel(; str::AbstractString="", font=nothing, offset=0) = titles_e_comp(str, font, offset, "y")
1328-
zlabel(; str::AbstractString="", font=nothing, offset=0) = titles_e_comp(str, font, offset, "z")
1329-
function titles_e_comp(str::AbstractString, fnt, offset, tipo::String="")::Tuple{String, String}
1330-
f::String = (fnt !== nothing) ? font(fnt) : ""
1324+
title(; str::AbstractString="", font="", offset=0) = titles_e_comp(str, font, offset, "")
1325+
subtitle(; str::AbstractString="", font="", offset=0) = titles_e_comp(str, font, offset, "s")
1326+
xlabel(; str::AbstractString="", font="", offset=0) = titles_e_comp(str, font, offset, "x")
1327+
ylabel(; str::AbstractString="", font="", offset=0) = titles_e_comp(str, font, offset, "y")
1328+
zlabel(; str::AbstractString="", font="", offset=0) = titles_e_comp(str, font, offset, "z")
1329+
function titles_e_comp(str::AbstractString, fnt, offset, tipo::String)::Tuple{String, String}
1330+
f::String = (fnt !== "") ? font(fnt) : ""
13311331
o::String = (offset != 0) ? string(offset) : ""
1332-
(str == "") && return str, ""
1333-
if (tipo == "")
1334-
r2 = (f != "") ? " --FONT_TITLE=" * f : ""
1335-
(o != "") && (r2 *= " --MAP_TITLE_OFFSET=" * o)
1332+
(str === "") && return str, ""
1333+
if (tipo === "")
1334+
r2 = (f !== "") ? " --FONT_TITLE=" * f : ""
1335+
(o !== "") && (r2 *= " --MAP_TITLE_OFFSET=" * o)
13361336
elseif (tipo == "s")
1337-
r2 = (f != "") ? " --FONT_SUBTITLE=" * f : ""
1337+
r2 = (f !== "") ? " --FONT_SUBTITLE=" * f : ""
13381338
else
1339-
r2 = (f != "") ? " --FONT_LABEL=" * f : ""
1340-
(o != "") && (r2 *= " --MAP_LABEL_OFFSET=" * o)
1339+
r2 = (f !== "") ? " --FONT_LABEL=" * f : ""
1340+
(o !== "") && (r2 *= " --MAP_LABEL_OFFSET=" * o)
13411341
end
1342-
replace(str_with_blancs(str), ' '=>'\x7f'), r2
1342+
return replace(str_with_blancs(str), ' ' => '\x7f'), r2
13431343
end
13441344

13451345
# ---------------------------------------------------------------------------------------------------
@@ -4162,7 +4162,7 @@ Finish the PostScript file and convert&display the figure.
41624162
- `figname`: To create a figure in local directory and with a name `figname`. If `figname` has an extension,
41634163
that is used to select the fig format. *e.g.* `figname=fig.pdf` creates a PDF file localy called 'fig.pdf'
41644164
"""
4165-
function showfig(d::Dict, fname_ps::String, fname_ext::String, opt_T::String, K::Bool=false, fname::String="")
4165+
function showfig(d::Dict{Symbol, Any}, fname_ps::String, fname_ext::String, opt_T::String, K::Bool=false, fname::String="")
41664166
# Take a PS file, convert it with psconvert (unless opt_T == "" meaning file is PS)
41674167
# and display it in default system viewer
41684168
# FNAME_EXT holds the extension when not PS

src/extras/anaglyph.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ An anaglyph image suitable for viewing with red-cyan glasses.
1717
1818
### Example
1919
```julia
20-
I = anaglyph("@earth_relief_01d.grd", region="-13/-5.5/35/44")
20+
I = anaglyph("@earth_relief_30s", region="-13/-5.5/35/44")
2121
```
2222
"""
2323
function anaglyph(fname::String, vscale=1, sscale=2; kw...)

src/gdal.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,7 +1824,8 @@ end
18241824
gdalvectortranslate([ds], opts; dest=dest, gdataset=gdataset, save=save)
18251825
gdalvectortranslate(ds::IDataset, opts::Vector{String}=String[]; dest="/vsimem/tmp", gdataset=false, save="") =
18261826
gdalvectortranslate([Dataset(ds.ptr)], opts; dest=dest, gdataset=gdataset, save=save)
1827-
gdalvectortranslate(ds::GMTdataset, opts::Vector{String}=String[]; dest="/vsimem/tmp", gdataset=false, save="") = gdalvectortranslate([ds], opts; dest=dest, gdataset=gdataset, save=save)
1827+
gdalvectortranslate(ds::GMTdataset, opts::Vector{String}=String[]; dest="/vsimem/tmp", gdataset=false, save="") =
1828+
gdalvectortranslate([ds], opts; dest=dest, gdataset=gdataset, save=save)
18281829
function gdalvectortranslate(ds::Vector{GMTdataset}, opts::Vector{String}=String[]; dest="/vsimem/tmp", gdataset=false, save="")
18291830
o = gdalvectortranslate(gmt2gd(ds), opts; dest=dest, gdataset=gdataset, save=save)
18301831
(!isa(o, GDtype) && dest == "/vsimem/tmp") && deletedatasource(o, "/vsimem/tmp") # WTF do I need to do this?
@@ -2643,7 +2644,7 @@ end
26432644

26442645
export
26452646
bwareaopen, getband, getdriver, getlayer, getproj, getgeom, getgeotransform, toPROJ4, toWKT, importPROJ4,
2646-
importWKT, importEPSG, gdalinfo, gdalwarp, gdaldem, gdaltranslate, gdalgrid, gdalvectortranslate, ogr2ogr,
2647+
importWKT, importEPSG, gdalinfo, gdalwarp, gdaldem, gdaltranslate, gdalgrid, ogr2ogr, gdalvectortranslate,
26472648
gdalrasterize, gdalbuildvrt, readraster, setgeotransform!, setproj!, destroy, arcellipse, arccircle,
26482649
delaunay, dither, buffer, centroid, intersection, intersects, polyunion, fromWKT, fillnodata!, fillnodata,
26492650
concavehull, convexhull, difference, symdifference, distance, geomarea, geodesicarea, pointalongline, polygonize,

src/grdgradient.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ end
5151
# ---------------------------------------------------------------------------------------------------
5252
function parse_Q_grdgrad(d::Dict, symbs::Array{<:Symbol}, cmd::String)
5353
(SHOW_KWARGS[1]) && return print_kwarg_opts(symbs, "String")
54-
if ((val = find_in_dict(d, symbs)[1]) !== nothing)
55-
val = string(val)[1]
54+
if ((val_ = hlp_desnany_str(d, symbs)) !== "")
55+
val = val_[1]
5656
(val == 's') && (val = 'c')
5757
(val == 'c' || val == 'r' || val == 'R') && (cmd *= " -Q" * val)
5858
end

test/test_imgfuns.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,7 @@
4141
I = gmtread(GMT.TESTSDIR * "assets/coins.jpg");
4242
binarize(I, band=1);
4343
binarize(I, [30, 80]);
44+
45+
# Anaglyph
46+
anaglyph("@earth_relief_10m", region=(-10.5, -5, 35, 44));
4447
end

0 commit comments

Comments
 (0)