Skip to content

Commit 14b92da

Browse files
authored
forward metadata methods for RasterDataset (#186)
1 parent 1dc8ca8 commit 14b92da

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/raster/array.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,16 @@ end
4040
# for raster-like datasets.
4141
for f in (:getgeotransform, :nraster, :getband, :getproj,
4242
:width, :height, :destroy, :getdriver, :filelist, :listcapability,
43-
:ngcp, :copy, :write, :testcapability, :setproj!, :buildoverviews!)
43+
:ngcp, :copy, :write, :testcapability, :setproj!, :buildoverviews!,
44+
:metadata, :metadatadomainlist)
4445
eval(:($(f)(x::RasterDataset, args...; kwargs...) = $(f)(x.ds, args...; kwargs...)))
4546
end
4647

48+
# Here we need to special-case, to avoid a method ambiguity
49+
function metadataitem(obj::RasterDataset, name::AbstractString; kwargs...)
50+
return metadataitem(obj.ds, name; kwargs...)
51+
end
52+
4753
# Here we need to special-case, because source and dest might be rasters
4854
copywholeraster(x::RasterDataset,y::AbstractDataset;kwargs...) = copywholeraster(x.ds,y;kwargs...)
4955
copywholeraster(x::RasterDataset,y::RasterDataset;kwargs...) = copywholeraster(x.ds,y.ds;kwargs...)

test/test_gdal_tutorials.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import ArchGDAL; const AG = ArchGDAL
4848

4949
@test AG.metadatadomainlist(dataset) == ["IMAGE_STRUCTURE", "", "DERIVED_SUBDATASETS"]
5050
@test AG.metadata(dataset) == ["AREA_OR_POINT=Area"]
51+
@test AG.metadataitem(dataset, "AREA_OR_POINT") == "Area"
5152
@test AG.metadata(dataset, domain = "IMAGE_STRUCTURE") == ["INTERLEAVE=BAND"]
5253
@test AG.metadata(dataset, domain = "") == ["AREA_OR_POINT=Area"]
5354
@test AG.metadata(dataset, domain = "DERIVED_SUBDATASETS") == [
@@ -56,6 +57,14 @@ import ArchGDAL; const AG = ArchGDAL
5657
]
5758
end
5859

60+
# Get metadata from a RasterDataset
61+
AG.readraster("data/utmsmall.tif") do dataset
62+
# interestingly the list order below is different from the order above
63+
@test AG.metadatadomainlist(dataset) == ["IMAGE_STRUCTURE", "DERIVED_SUBDATASETS", ""]
64+
@test AG.metadata(dataset) == ["AREA_OR_POINT=Area"]
65+
@test AG.metadataitem(dataset, "AREA_OR_POINT") == "Area"
66+
end
67+
5968
# Techniques for Creating Files
6069
@test GDAL.gdalgetmetadataitem(driver.ptr, "DCAP_CREATE", "") == "YES"
6170
@test GDAL.gdalgetmetadataitem(driver.ptr, "DCAP_CREATECOPY", "") == "YES"

0 commit comments

Comments
 (0)