@@ -575,8 +575,12 @@ Example: write the GMTgrid 'G' object into a nc file called 'lixo.grd'
575575"""
576576gmtwrite (data; kwargs... ) = gmtwrite (" " , data; kwargs... )
577577function gmtwrite (fname:: AbstractString , data; kwargs... )
578-
579578 d = init_module (false , kwargs... )[1 ] # Also checks if the user wants ONLY the HELP mode
579+ gmtwrite (fname:: AbstractString , data, d)
580+ end
581+
582+ function gmtwrite (fname:: AbstractString , data, d:: Dict{Symbol, Any} )
583+
580584 cmd, = parse_R (d, " " )
581585 cmd, = parse_common_opts (d, cmd, [:V_params :f ])
582586 if (fname == " " )
@@ -587,7 +591,7 @@ function gmtwrite(fname::AbstractString, data; kwargs...)
587591 _, opt_f = parse_f (d, " " )
588592
589593 if (isa (data, GMTgrid))
590- (endswith (fname, " .laz" ) || endswith (fname, " .LAZ" )) && return lazwrite (fname, data; kwargs ... ) # Lasz
594+ (endswith (fname, " .laz" ) || endswith (fname, " .LAZ" )) && return lazwrite (fname, data; d ... ) # Lasz
591595
592596 # GMT doesn't write correct CF nc grids that are referenced but non-geographic. So, use GDAL in those cases
593597 fmt = parse_grd_format (d) # See if we have format requests
@@ -608,14 +612,14 @@ function gmtwrite(fname::AbstractString, data; kwargs...)
608612 CTRL. proj_linear[1 ] = true # To force pad=0 and julia memory (no dup) in image_init()
609613 transpcmap! (data, true )
610614 elseif (isa (data, GDtype))
611- isa (data, Vector) && (endswith (fname, " .stl" ) || endswith (fname, " .STL" )) && return write_stl (fname, data; kwargs ... ) # STL
612- (endswith (fname, " .laz" ) || endswith (fname, " .LAZ" )) && return lazwrite (fname, data; kwargs ... ) # Lasz
615+ isa (data, Vector) && (endswith (fname, " .stl" ) || endswith (fname, " .STL" )) && return write_stl (fname, data; d ... ) # STL
616+ (endswith (fname, " .laz" ) || endswith (fname, " .LAZ" )) && return lazwrite (fname, data; d ... ) # Lasz
613617 opt_T = " -Td"
614618 cmd, = parse_bo (d, cmd) # Write to binary file
615619 cmd = isa (data, GMTdataset) ? set_fT (data, cmd, opt_f) : set_fT (data[1 ], cmd, opt_f)
616620 elseif (isa (data, GMTfv))
617621 (endswith (fname, " .obj" ) || endswith (fname, " .OBJ" )) && return write_obj (fname, data)
618- (endswith (fname, " .stl" ) || endswith (fname, " .STL" )) && return write_stl (fname, data; kwargs ... )
622+ (endswith (fname, " .stl" ) || endswith (fname, " .STL" )) && return write_stl (fname, data; d ... )
619623 elseif (isa (data, GMTcpt))
620624 opt_T = " -Tc"
621625 elseif (isa (data, GMTps))
@@ -631,7 +635,7 @@ function gmtwrite(fname::AbstractString, data; kwargs...)
631635 opt_T = " -Ti"
632636 end
633637 elseif (isa (data, AbstractArray))
634- (endswith (fname, " .laz" ) || endswith (fname, " .LAZ" )) && return dat2las (fname, data; kwargs ... ) # Lasz
638+ (endswith (fname, " .laz" ) || endswith (fname, " .LAZ" )) && return dat2las (fname, data; d ... ) # Lasz
635639 fmt = parse_grd_format (d) # See if we have format requests
636640 if (fmt == " " ) # If no format, write a dataset
637641 opt_T = " -Td"
0 commit comments