Skip to content

Commit c6a2039

Browse files
committed
Fix tests
1 parent 05427da commit c6a2039

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

src/YAXArrayBase.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ function __init__()
3131

3232
@require AxisIndices="f52c9ee2-1b1c-4fd8-8546-6350938c7f11" include("axisarrays/axisindices.jl")
3333

34-
@require ArchGDAL="c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3" include("axisarrays/archgdal.jl")
35-
36-
@require ArchGDAL="c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3" include("datasets/archgdal.jl")
34+
@require ArchGDAL="c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3" begin
35+
include("axisarrays/archgdal.jl")
36+
include("datasets/archgdal.jl")
37+
end
3738

3839

3940
@require Zarr="0a941bbe-ad1d-11e8-39d9-ab76183a1d99" include("datasets/zarr.jl")

src/datasets/archgdal.jl

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ function GDALDataset(filename)
4848
allbands = map(1:nb) do iband
4949
b = AG.getband(r, iband)
5050
gb = GDALBand(b, filename, iband)
51-
name = AG.getname(AG.getcolorinterp(b))
51+
name = AG.GDAL.gdalgetdescription(b.ptr)
52+
if isempty(name)
53+
name = AG.getname(AG.getcolorinterp(b))
54+
end
5255
name => gb
5356
end
5457
proj = AG.getproj(r)
@@ -76,7 +79,17 @@ end
7679

7780
get_varnames(ds::GDALDataset) = collect(keys(ds.bands))
7881

79-
get_var_dims(ds::GDALDataset, _) = ("X", "Y")
82+
function get_var_dims(ds::GDALDataset, d)
83+
if d === "X"
84+
return ("X",)
85+
elseif d==="Y"
86+
return ("Y",)
87+
else
88+
return ("X", "Y")
89+
end
90+
end
91+
92+
get_global_attrs(ds::GDALDataset) = Dict("projection"=>ds.projection)
8093

8194
function get_var_attrs(ds::GDALDataset, name)
8295
if name in ("Y", "X")
@@ -96,7 +109,7 @@ isy(s) = uppercase(s) == "Y"
96109
function totransform(x, y)
97110
xstep = diff(x)
98111
ystep = diff(y)
99-
if !all(isapprox(first(xstep)), xstep) && !all(isapprox(first(ystep)), ystep)
112+
if !all(isapprox(first(xstep)), xstep) || !all(isapprox(first(ystep)), ystep)
100113
throw(ArgumentError("Grid must have regular spacing"))
101114
end
102115
Float64[first(x), first(xstep), 0.0, first(y), 0.0, first(ystep)]
@@ -173,6 +186,7 @@ function create_dataset(
173186
else
174187
AG.setcolorinterp!(b, AG.GDAL.GDALColorInterp(icol - 1))
175188
end
189+
AG.GDAL.gdalsetdescription(b.ptr, varnames[i])
176190
atts = varattrs[i]
177191
haskey(atts, "missing_value") && AG.setnodatavalue!(b, atts["missing_value"])
178192
if haskey(atts, "labels")

test/arrays.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ end
7474
@test YAXArrayBase.iscontdim(r,1) == true
7575
@test YAXArrayBase.iscontdim(r,2) == true
7676
@test YAXArrayBase.iscontdim(r,3) == true
77-
@test YAXArrayBase.getattributes(r)["projection"] == "+proj=cea +lat_ts=33.75 +lon_0=-117.333333333333 +x_0=0 +y_0=0 +datum=NAD27 +units=m +no_defs"
77+
@test YAXArrayBase.getattributes(r)["projection_PROJ4"] == "+proj=cea +lat_ts=33.75 +lon_0=-117.333333333333 +x_0=0 +y_0=0 +datum=NAD27 +units=m +no_defs"
7878
b = AG.getband(r,1)
7979
@test YAXArrayBase.dimnames(b) == (:Y, :X)
8080
@test YAXArrayBase.dimname(b,1) == :Y
@@ -85,5 +85,5 @@ end
8585
@test_throws Exception YAXArrayBase.dimvals(b,3)
8686
@test YAXArrayBase.iscontdim(b,1) == true
8787
@test YAXArrayBase.iscontdim(b,2) == true
88-
@test YAXArrayBase.getattributes(b)["projection"] == "+proj=cea +lat_ts=33.75 +lon_0=-117.333333333333 +x_0=0 +y_0=0 +datum=NAD27 +units=m +no_defs"
88+
@test YAXArrayBase.getattributes(b)["projection_PROJ4"] == "+proj=cea +lat_ts=33.75 +lon_0=-117.333333333333 +x_0=0 +y_0=0 +datum=NAD27 +units=m +no_defs"
8989
end

0 commit comments

Comments
 (0)