Skip to content

Commit 9dc82cd

Browse files
authored
Fix several CoreBox (but with no apparent gain) (#1870)
1 parent 4286f3d commit 9dc82cd

File tree

7 files changed

+45
-28
lines changed

7 files changed

+45
-28
lines changed

src/GMT.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export
137137
rose!, sample1d, scatter, scatter!, scatter3, scatter3!, solar, solar!, spectrum1d, sphdistance, sphinterpolate,
138138
sphtriangulate, surface, ternary, ternary!, text, text!, text_record, trend1d, trend2d, triangulate, gmtsplit,
139139
decorated, vector_attrib, wiggle, wiggle!, xyz2grd, gmtbegin, gmtend, gmthelp, subplot, gmtfig, inset, showfig,
140-
earthtide, gravfft, gmtgravmag3d, gravmag3d, grdgravmag3d, gravprisms, grdseamount, parkermag, parkergrav,
140+
earthtide, gmt2grd, gravfft, gmtgravmag3d, gravmag3d, grdgravmag3d, gravprisms, grdseamount, parkermag, parkergrav,
141141
pscoupe, pscoupe!, coupe, coupe!, psmeca, psmeca!, meca, meca!, psvelo, psvelo!, velo, velo!, gmtisf, getbyattrib,
142142
inpolygon, inwhichpolygon, pcolor, pcolor!, triplot, triplot!, trisurf, trisurf!, grdrotater, imagesc, upGMT, boxes,
143143
stereonet, stereonet!,
@@ -162,8 +162,8 @@ export
162162
importPROJ4, importWKT, importEPSG, gdalinfo, gdalwarp, gdaldem, gdaltranslate, gdalgrid, gdalvectortranslate,
163163
ogr2ogr, gdalrasterize, gdalbuildvrt, readgeom, readraster, setgeotransform!, setnodata!, setproj!, destroy,
164164
delaunay, dither, buffer, centroid, intersection, intersects, polyunion, overlaps, fromWKT, fillnodata!, fillnodata,
165-
concavehull, convexhull, difference, symdifference, distance, geodesicarea, geomarea, pointalongline, polygonize, simplify,
166-
boundary, crosses, disjoint, envelope, envelope3d, equals, touches, uniqueind, within,
165+
concavehull, convexhull, difference, symdifference, distance, geodesicarea, geomarea, geomlength, pointalongline,
166+
polygonize, simplify, boundary, crosses, disjoint, envelope, envelope3d, equals, touches, within,
167167

168168
wkbUnknown, wkbPoint, wkbPointZ, wkbLineString, wkbLineStringZ, wkbPolygon, wkbPolygonZM, wkbMultiPoint, wkbMultiPointZ,
169169
wkbMultiLineString, wkbMultiPolygon, wkbGeometryCollection, wkbPoint25D, wkbLineString25D, wkbPolygon25D, wkbMultiPoint25D,
@@ -195,7 +195,7 @@ export
195195

196196
findpeaks, makeDCWs, mksymbol, circfit,
197197

198-
gunique, sortslicesperm,
198+
gunique, uniqueind, sortslicesperm,
199199
hampel, hampel!, lowess, whittaker,
200200

201201
Ginnerjoin, Gouterjoin, Gleftjoin, Grightjoin, Gcrossjoin, Gsemijoin, Gantijoin, spatialjoin, groupby, stats,

src/gdal_utils.jl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,10 @@ function gd2gmt(dataset::Gdal.AbstractDataset)
277277
while ((feature = Gdal.nextfeature(layer)) !== nothing)
278278
n = Gdal.nfield(feature)
279279
attrib = DictSvS()
280-
[attrib[Gdal.getname(Gdal.getfielddefn(feature, i))] = string(Gdal.getfield(feature, i)) for i = 0:n-1]
280+
#[attrib[Gdal.getname(Gdal.getfielddefn(feature, i))] = string(Gdal.getfield(feature, i)) for i = 0:n-1]
281+
for i = 0:n-1
282+
attrib[Gdal.getname(Gdal.getfielddefn(feature, i))] = string(Gdal.getfield(feature, i))
283+
end
281284

282285
for j = 0:Gdal.ngeom(feature)-1
283286
geom = Gdal.getgeom(feature, j)
@@ -757,15 +760,18 @@ function gmt2gd(D::Vector{<:GMTdataset}; save::String="", geometry::String="")
757760
for k = 1:length(D)
758761
x,y,z = helper_gmt2gd_xyz(D[k], n_cols)
759762
if (n_cols == 2)
760-
[Gdal.addgeom!(geom, Gdal.createpoint(x[n], y[n])) for n = 1:lastindex(x)]
763+
#[Gdal.addgeom!(geom, Gdal.createpoint(x[n], y[n])) for n = 1:lastindex(x)]
764+
for n = 1:lastindex(x) Gdal.addgeom!(geom, Gdal.createpoint(x[n], y[n])) end
761765
else
762-
[Gdal.addgeom!(geom, Gdal.createpoint(x[n], y[n], z[n])) for n = 1:lastindex(x)]
766+
#[Gdal.addgeom!(geom, Gdal.createpoint(x[n], y[n], z[n])) for n = 1:lastindex(x)]
767+
for n = 1:lastindex(x) Gdal.addgeom!(geom, Gdal.createpoint(x[n], y[n], z[n])) end
763768
end
764769
end
765770
elseif (D[1].geom == wkbMultiPointZ || D[1].geom == Gdal.wkbMultiPoint25D)
766771
for k = 1:length(D)
767772
x,y,z = helper_gmt2gd_xyz(D[k], n_cols)
768-
[Gdal.addgeom!(geom, Gdal.createpoint(x[n], y[n], z[n])) for n = 1:lastindex(x)]
773+
#[Gdal.addgeom!(geom, Gdal.createpoint(x[n], y[n], z[n])) for n = 1:lastindex(x)]
774+
for n = 1:lastindex(x) Gdal.addgeom!(geom, Gdal.createpoint(x[n], y[n], z[n])) end
769775
end
770776
else
771777
x,y,z = helper_gmt2gd_xyz(D[1], n_cols)

src/grdview.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,18 @@ end
119119
function parse_G_grdview(d::Dict, symbs::Array{<:Symbol}, cmd0::String, cmd::String, arg1, arg2, arg3, arg4, arg5)
120120
(SHOW_KWARGS[]) && return print_kwarg_opts(symbs, "GMTgrid | Tuple | String"), arg1, arg2, arg3, arg4, arg5
121121
if ((val = find_in_dict(d, symbs)[1]) !== nothing)
122+
122123
function intern!(cmd, val, arg1, arg2, arg3, arg4)
123124
opt = isa(val, GMTgrid) ? 'G' : 'z' # 'z' is the fake option that works as a backdoor for images
124-
cmd, N_used = put_in_slot(cmd, opt, arg1, arg2, arg3, arg4)
125-
if (N_used == 1) arg1 = val
126-
elseif (N_used == 2) arg2 = val
127-
elseif (N_used == 3) arg3 = val
128-
elseif (N_used == 4) arg4 = val
125+
cmd, _N_used = put_in_slot(cmd, opt, arg1, arg2, arg3, arg4)
126+
if (_N_used == 1) arg1 = val
127+
elseif (_N_used == 2) arg2 = val
128+
elseif (_N_used == 3) arg3 = val
129+
elseif (_N_used == 4) arg4 = val
129130
end
130131
return cmd, arg1, arg2, arg3, arg4
131132
end
133+
132134
if (isa(val, String) || isa(val, GMTimage))
133135
val_str::String = isa(val, String) ? val : ""
134136
val_I::GMTimage = (val_str == "") ? val : GMTimage()

src/pcolor.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,19 @@ function pcolor(X_::VMr, Y_::VMr, C::Union{Nothing, AbstractMatrix{<:Real}}, fir
100100
if (isvector(X) && gridreg) # Expand X,Y to make them pix reg
101101
X,Y = copy(X_), copy(Y_)
102102
xinc, yinc = X[2]-X[1], Y[2]-Y[1]; xinc2, yinc2 = xinc/2, yinc/2
103-
[X[k] -= xinc2 for k = 1:numel(X)]; append!(X, X[end]+xinc)
104-
[Y[k] -= yinc2 for k = 1:numel(Y)]; append!(Y, Y[end]+yinc)
103+
for k = 1:numel(X)
104+
X[k] -= xinc2; Y[k] -= yinc2
105+
end
106+
append!(X, X[end]+xinc); append!(Y, Y[end]+yinc)
105107
end
106108

107109
D, k = Vector{GMTdataset{Float64,2}}(undef, length(C)), 0
108110
if (isvector(X))
109111
for col = 1:length(X)-1, row = 1:length(Y)-1 # Gdal.wkbPolygon = 3
110112
if (k == 0)
111113
D[k+=1] = mat2ds([X[col] Y[row]; X[col] Y[row+1]; X[col+1] Y[row+1]; X[col+1] Y[row]; X[col] Y[row]]; geom=3, d...)
112-
else D[k+=1] = mat2ds([X[col] Y[row]; X[col] Y[row+1]; X[col+1] Y[row+1]; X[col+1] Y[row]; X[col] Y[row]]; geom=3)
114+
else
115+
D[k+=1] = mat2ds([X[col] Y[row]; X[col] Y[row+1]; X[col+1] Y[row+1]; X[col+1] Y[row]; X[col] Y[row]]; geom=3)
113116
end
114117
end
115118
D[1].ds_bbox = [X[1], X[end], Y[1], Y[end]]

src/plot.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,7 +1717,7 @@ function parse_B4ternary!(d::Dict, first::Bool=true)
17171717
opt_Bs = split(opt_B) # This drops the leading ' '
17181718
x::String = (opt_Bs[1][3] == 'p') ? opt_Bs[1][4:end] : opt_Bs[1][3:end]
17191719
d[:B] = " -Ba$(x)+l" * string(val[1])::String * " -Bb$(x)+l" * string(val[2])::String * " -Bc$(x)+l" * string(val[3])::String
1720-
[d[:B] *= " " * opt_Bs[k] for k = 2:numel(opt_Bs)] # Append the remains, if any.
1720+
for k = 2:numel(opt_Bs) d[:B] *= " " * opt_Bs[k] end # Append the remains, if any.
17211721
else # Ui, try to parse a string like this: " -Bpag8+u\" %\" -Ba+la -Bb+lb -Bc+lc"
17221722
(!first && opt_B == " -Bafg") && return # Do not use the default -B on overlays.
17231723
opt_Bs = split(opt_B, " -B")[2:end] # 2:end because surprisingly the first is = ""
@@ -1727,7 +1727,7 @@ function parse_B4ternary!(d::Dict, first::Bool=true)
17271727
else
17281728
x = opt_Bs[1][2:end]
17291729
d[:B] = " -Ba$(x)" * opt_Bs[2][2:end] * " -Bb$(x)" * opt_Bs[3][2:end] * " -Bc$(x)" * opt_Bs[4][2:end]
1730-
[d[:B] *= " -B" * opt_Bs[k] for k = 5:numel(opt_Bs)] # Append the remains, if any.
1730+
for k = 5:numel(opt_Bs) d[:B] *= " -B" * opt_Bs[k] end # Append the remains, if any.
17311731
end
17321732
end
17331733
end

src/sample1d.jl

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,20 @@ function sample1d_helper(cmd0::String, arg1, d::Dict{Symbol,Any})
122122
tmp = tempname() * ".dat"
123123
cmd = cmd * opt_g * " > " * tmp
124124
gmt(cmd)
125-
r = gmtread(tmp)
125+
o = gmtread(tmp)
126126
rm(tmp); (input_tmp != "") && rm(input_tmp)
127127
if (have_nonans) # Remove NaNs if requested
128-
if isa(r, GMTdataset)
129-
indNaN = isnan.(view(r.data, :, 2))
130-
any(indNaN) && (r = mat2ds(r.data, (.!indNaN, :)))
128+
if isa(o, GMTdataset)
129+
indNaN = isnan.(view(o.data, :, 2))
130+
any(indNaN) && (o = mat2ds(o.data, (.!indNaN, :)))
131131
else
132-
for k = 1:numel(r)
133-
indNaN = isnan.(view(r[k].data, :, 2))
134-
any(indNaN) && (r[k] = mat2ds(r[k], (.!indNaN, :)))
132+
for k = 1:numel(o)
133+
indNaN = isnan.(view(o[k].data, :, 2))
134+
any(indNaN) && (o[k] = mat2ds(o[k], (.!indNaN, :)))
135135
end
136136
end
137137
end
138-
return r
138+
return o
139139
end
140140

141141
# Tricky this one. If we use defaults, sample1d will not interpolate through NaNs. Need to use --IO_NAN_RECORDS=skip
@@ -164,7 +164,13 @@ function sample1d_helper(cmd0::String, arg1, d::Dict{Symbol,Any})
164164
end
165165
colnames = isa(arg1, GMTdataset) ? arg1.colnames : arg1[1].colnames
166166
have_cumdist && append!(colnames, ["cumdist"])
167-
isa(arg1, GMTdataset) ? (r.attrib = arg1.attrib) : [r[k].attrib = arg1[1].attrib for k = 1:numel(r)] # Keep the attribs
167+
if (isa(arg1, GMTdataset))
168+
r.attrib = arg1.attrib # Keep the attribs
169+
else
170+
for k = 1:numel(r)
171+
r[k].attrib = arg1[1].attrib
172+
end
173+
end
168174
else # Input was a file name
169175
nc = isa(r, GMTdataset) ? size(r, 2) : size(r[1], 2)
170176
colnames = [@sprintf("Z%d", k) for k = 1:nc]

src/utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ end
12341234

12351235
# ------------------------------------------------------------------------------------------------------
12361236
"""
1237-
getattribs(D::GDtype)::Vector{String}
1237+
att = getattribs(D::GDtype) -> Vector{String}
12381238
12391239
Extract attribute keys from a GMT data object as a vector of strings.
12401240

0 commit comments

Comments
 (0)