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
13 changes: 6 additions & 7 deletions src/GMT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ else
const GMTdevdate = Date(devdate, dateformat"y.m.d") # 'devdate' comes from reading 'deps.jl'
end

const global G_API = [C_NULL]
const G_API = Ref{Ptr{Cvoid}}(C_NULL)
const PSname = Ref{String}("") # The PS file (filled in __init__) where, in classic mode, all lands.
const global TMPDIR_USR = [tempdir(), "", ""] # Save the tmp dir and user name (also filled in __init__)
const global TESTSDIR = joinpath(dirname(pathof(GMT))[1:end-4], "test", "") # To have easy access to test files
Expand All @@ -78,7 +78,7 @@ const noGrdCopy = Ref{Bool}(false) # If true, grids are sent without transpos
const GMTCONF = Ref{Bool}(false) # Flag if gmtset was used and must be 'unused'
const FMT = Ref{String}("png") # The default plot format
const BOX_STR = Ref{String}("") # Used in plotyy to know -R of first call
const global POSTMAN = [Dict{String,String}()] # To pass messages to functions (start with get_dataset)
const POSTMAN = Ref{Dict{String,String}}(Dict{String,String}()) # To pass messages to functions (start with get_dataset)
#const global SACO = [Dict{String,Union{AbstractArray, Vector{AbstractArray}}}()] # When funs (fillsinks) want to return extra data but not via the return mechanism
const DEF_FIG_SIZE = "15c/10c" # Default fig size for plot like programs. Approx 16/11
const DEF_FIG_AXES_BAK = " -Baf -BWSen" # Default fig axes for plot like programs
Expand Down Expand Up @@ -219,13 +219,13 @@ include("gdal/gdal.jl")
include("gdal_utils.jl")
include("proj_utils.jl")
const global MatGDsGd = Union{Matrix{<:AbstractFloat}, GMTdataset, Vector{<:GMTdataset}, Gdal.AbstractDataset}
const global CURRENT_CPT = [GMTcpt()] # To store the current palette
const CURRENT_CPT = Ref{GMTcpt}(GMTcpt()) # To store the current palette

include("gmt_main.jl")
include("utils_types.jl")
include("grd_operations.jl")
include("common_options.jl")
const global LEGEND_TYPE = [legend_bag()] # To store Legends info
const LEGEND_TYPE = Ref{legend_bag}(legend_bag()) # To store Legends info
include("beziers.jl")
include("circfit.jl")
include("crop.jl")
Expand Down Expand Up @@ -380,15 +380,14 @@ include("windbarbs/windbarbs.jl")
include("zscale.jl")
include("get_enums.jl")


using .Gdal
using .Laszip

#include("ImageFeatures/ImageFeatures.jl")
#using .ImageFeatures

@compile_workload begin
G_API[1] = GMT_Create_Session("GMT", 2, GMT_SESSION_BITFLAGS)
G_API[] = GMT_Create_Session("GMT", 2, GMT_SESSION_BITFLAGS)
#GMT.parse_B(Dict{Symbol, Any}(:frame => (annot=10, title="Ai Ai"), :grid => (pen=2, x=10, y=20)), "", " -Baf -BWSen");
#GMT.parse_R(Dict{Symbol, Any}(:xlim => (1,2), :ylim => (3,4), :zlim => (5,6)), "");
#GMT.parse_J(Dict{Symbol, Any}(:J => "X", :scale => "1:10"), "");
Expand Down Expand Up @@ -462,7 +461,7 @@ end

function __init__(test::Bool=false)
clear_sessions(3600) # Delete stray sessions dirs older than 1 hour
G_API[1] = GMT_Create_Session("GMT", 2, GMT_SESSION_BITFLAGS) # (0.010179 sec)
G_API[] = GMT_Create_Session("GMT", 2, GMT_SESSION_BITFLAGS) # (0.010179 sec)
theme_modern() # Set the MODERN theme and some more gmtlib_setparameter() calls
haskey(ENV, "JULIA_GMT_IMGFORMAT") && (FMT[] = ENV["JULIA_GMT_IMGFORMAT"])
f = joinpath(GMTuserdir[1], "theme_jl.txt")
Expand Down
2 changes: 1 addition & 1 deletion src/blendimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ function lelandshade(G::GMTgrid; detail=1.0, contrast=2.0, uint16=false, intensi
_cpt = iscptmaster ? cmap : nothing
if (cmap != "")
cpt = cmap
isa(cpt, GMTcpt) && (CURRENT_CPT[1] = cpt)
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
Expand Down
4 changes: 2 additions & 2 deletions src/choropleth_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ function cpt4dcw(codes::Vector{<:AbstractString}, vals::Vector{<:Real}; kwargs..
while(_vals[k] > C.minmax[2] && k > 0) c[k] = false; k -= 1 end
_codes, _vals = _codes[c], _vals[c]

P::Ptr{GMT_PALETTE} = palette_init(G_API[1], C) # A pointer to a GMT CPT
P::Ptr{GMT_PALETTE} = palette_init(G_API[], C) # A pointer to a GMT CPT

Ccat::GMTcpt = gmt("makecpt -T"*join(_codes, ","))
rgb = [0.0, 0.0, 0.0, 0.0];
_rgb = [0.0, 0.0, 0.0, 0.0];

inc = (C.minmax[2] - C.minmax[1]) / size(Ccat.cpt, 1)
for k = 1:size(Ccat.cpt, 1)
gmt_get_rgb_from_z(G_API[1], P, _vals[k], rgb)
gmt_get_rgb_from_z(G_API[], P, _vals[k], rgb)
Ccat.colormap[k, 1], Ccat.colormap[k, 2], Ccat.colormap[k, 3] = rgb[1], rgb[2], rgb[3]
_rgb[1], _rgb[2], _rgb[3] = rgb[1], rgb[2], rgb[3]
[Ccat.cpt[k, n+1] = copy(_rgb[(n % 3) + 1]) for n = 0:5] # cpt = [rgb rgb]
Expand Down
Loading
Loading