@@ -386,7 +386,18 @@ function parse_JZ(d::Dict, cmd::String, del::Bool=true; O::Bool=false, is3D::Boo
386
386
(o == " " ) && (o = " " ) # When scaning a string with only -J (i.e., no args), do not error
387
387
(o[1 ] != ' X' || o[end ] == ' d' ) && @warn (" aspect3 works only in linear projections (and no geog), ignoring it." )
388
388
if (o[1 ] == ' X' && o[end ] != ' d' && length (o) > 1 )
389
- opt_J = " -JZ" * split (o[2 : end ],' /' )[1 ]; seek_JZ = false
389
+ s_val:: String = string (val)
390
+ if (contains (s_val, ' :' )) # An explicit aspect ratio, e.g. 3:2
391
+ dims = parse .(Float64, split (s_val, ' :' ))
392
+ t = split (o[2 : end ],' /' )[1 ]
393
+ isletter (t[end ]) && (t = t[1 : end - 1 ]) # Remove the letter 'x' which hopefully a 'c'
394
+ w = parse (Float64, t)
395
+ h = w * dims[2 ] / dims[1 ] # Apply the aspect ratio
396
+ opt_J = string (" -JZ" , h)
397
+ else
398
+ opt_J = " -JZ" * split (o[2 : end ],' /' )[1 ];
399
+ end
400
+ seek_JZ = false
390
401
cmd *= opt_J
391
402
end
392
403
end
@@ -602,9 +613,12 @@ function append_figsize(d::Dict, opt_J::String, width::String="", scale::Bool=fa
602
613
return opt_J
603
614
end
604
615
605
- set_aspect_ratio (aspect:: Nothing , width:: String , def_fig:: Bool = false , is_aspect3:: Bool = false ):: String = set_aspect_ratio (" " , width, def_fig, is_aspect3)
606
- set_aspect_ratio (aspect:: Symbol , width:: String , def_fig:: Bool = false , is_aspect3:: Bool = false ):: String = set_aspect_ratio (string (aspect), width, def_fig, is_aspect3)
607
- set_aspect_ratio (aspect:: Real , width:: String , def_fig:: Bool = false , is_aspect3:: Bool = false ):: String = set_aspect_ratio (string (aspect, " :1" ), width, def_fig, is_aspect3)
616
+ set_aspect_ratio (aspect:: Nothing , width:: String , def_fig:: Bool = false , is_aspect3:: Bool = false ):: String =
617
+ set_aspect_ratio (" " , width, def_fig, is_aspect3)
618
+ set_aspect_ratio (aspect:: Symbol , width:: String , def_fig:: Bool = false , is_aspect3:: Bool = false ):: String =
619
+ set_aspect_ratio (string (aspect), width, def_fig, is_aspect3)
620
+ set_aspect_ratio (aspect:: Real , width:: String , def_fig:: Bool = false , is_aspect3:: Bool = false ):: String =
621
+ set_aspect_ratio (string (aspect, " :1" ), width, def_fig, is_aspect3)
608
622
function set_aspect_ratio (aspect:: String , width:: String , def_fig:: Bool = false , is_aspect3:: Bool = false ):: String
609
623
# Set the aspect ratio. ASPECT can be "equal", "eq"; "square", "sq" or a ratio in the form "4:3", "16:12", etc.
610
624
def_fig && (width = split (DEF_FIG_SIZE, ' /' )[1 ])
@@ -3711,6 +3725,7 @@ function _read_data(d::Dict, cmd::String, arg, opt_R::String="", is3D::Bool=fals
3711
3725
if (! occursin (" ?" , opt_R) && ! is_onecol) # is_onecol is true for DateTime data
3712
3726
dx:: Float64 = (wesn_f64[2 ] - wesn_f64[1 ]) * 0.005 ; dy:: Float64 = (wesn_f64[4 ] - wesn_f64[3 ]) * 0.005 ;
3713
3727
wesn_f64[1 ] -= dx; wesn_f64[2 ] += dx; wesn_f64[3 ] -= dy; wesn_f64[4 ] += dy;
3728
+ length (wesn_f64) == 6 && (dz:: Float64 = (wesn_f64[6 ] - wesn_f64[5 ]) * 0.005 ; wesn_f64[5 ] -= dz; wesn_f64[6 ] += dz;)
3714
3729
wesn_f64 = round_wesn (wesn_f64, is_geo) # Add a pad if not-tight
3715
3730
if (isGMTdataset (arg)) # Needed for the guess_proj case
3716
3731
if ((wesn_f64[3 ] < - 90 || wesn_f64[4 ] > 90 ) || ((wesn_f64[2 ] - wesn_f64[1 ]) > 360 ))
@@ -3779,8 +3794,10 @@ function round_wesn(_wesn::Vector{Float64}, geo::Bool=false, pad=zeros(2))::Vect
3779
3794
dy = (wesn[4 ] - wesn[3 ]) * pad[2 ]
3780
3795
wesn[1 : 4 ] = [wesn[1 ]- dx, wesn[2 ]+ dx, wesn[3 ]- dy, wesn[4 ]+ dy]
3781
3796
end
3782
- set:: Vector{Bool} = zeros (Bool, 2 )
3783
- range:: Vector{Float64} = [0.0 , 0.0 ]
3797
+ set = zeros (Bool, 3 )
3798
+ range = [0.0 , 0.0 , 0.0 ]
3799
+ n_axe = (length (wesn) == 6 ) ? 3 : 2
3800
+
3784
3801
if (wesn[1 ] == wesn[2 ])
3785
3802
wesn[1 ] -= abs (wesn[1 ]) * 0.05 ; wesn[2 ] += abs (wesn[2 ]) * 0.05
3786
3803
if (wesn[1 ] == wesn[2 ]) wesn[1 ] = - 0.1 ; wesn[2 ] = 0.1 ; end # x was = 0
@@ -3791,6 +3808,7 @@ function round_wesn(_wesn::Vector{Float64}, geo::Bool=false, pad=zeros(2))::Vect
3791
3808
end
3792
3809
range[1 ] = wesn[2 ] - wesn[1 ]
3793
3810
range[2 ] = wesn[4 ] - wesn[3 ]
3811
+ (n_axe == 3 ) && (range[3 ] = wesn[6 ] - wesn[5 ])
3794
3812
if (geo) # Special checks due to periodicity
3795
3813
if (range[1 ] > 306.0 ) # If within 15% of a full 360 we promote to 360
3796
3814
if ((wesn[1 ] + wesn[2 ]) / 2 < 100 ) wesn[1 ] = - 180. ; wesn[2 ] = 180.
@@ -3806,14 +3824,14 @@ function round_wesn(_wesn::Vector{Float64}, geo::Bool=false, pad=zeros(2))::Vect
3806
3824
3807
3825
_log10 (x) = log (x) / 2.30258509299 # Compute log10 with ln because JET & SnoopCompile acuse it of "failed to optimize"
3808
3826
item = 1
3809
- for side = 1 : 2
3827
+ for side = 1 : n_axe
3810
3828
set[side] && continue # Done above */
3811
3829
mag:: Float64 = round (_log10 (range[side])) - 1.0
3812
3830
inc = exp10 (mag)
3813
3831
if ((range[side] / inc) > 10.0 ) inc *= 2.0 end # Factor of 2 in the rounding
3814
3832
if ((range[side] / inc) > 10.0 ) inc *= 2.5 end # Factor of 5 in the rounding
3815
3833
s = 1.0
3816
- if (geo) # Use arc integer minutes or seconds if possible
3834
+ if (geo && side < 3 ) # Use arc integer minutes or seconds if possible
3817
3835
if (inc < 1.0 && inc > 0.05 ) # Nearest arc minute
3818
3836
s, inc = 60.0 , 1.0
3819
3837
if ((s * range[side] / inc) > 10.0 ) inc *= 2.0 end # 2 arcmin
@@ -3897,12 +3915,13 @@ end
3897
3915
3898
3916
# ---------------------------------------------------------------------------------------------------
3899
3917
"""
3900
- isFV(D::Vector{<:GMTdataset} )::Bool
3918
+ isFV(D)::Bool
3901
3919
3902
- Check if D, a vector of GMTdataset, is a Face-Vertices ensemble.
3920
+ Check if D is a Face-Vertices ensemble (a 2 elements vector of GMTdataset) .
3903
3921
"""
3904
- function isFV (D:: Vector{<:GMTdataset} ):: Bool
3905
- length (D) == 2 && (D[1 ]. geom == wkbPoint || D[1 ]. geom == wkbPointZ) && eltype (D[2 ]. data) <: Integer
3922
+ function isFV (D):: Bool
3923
+ (isa (D, Vector{<: GMTdataset }) && length (D) > 1 ) &&
3924
+ (D[1 ]. geom == wkbPoint || D[1 ]. geom == wkbPointZ) && eltype (D[2 ]. data) <: Integer
3906
3925
end
3907
3926
3908
3927
# ---------------------------------------------------------------------------------------------------
0 commit comments