Skip to content

Commit 0922779

Browse files
committed
Enable readblock of a GDALBand into subarrays
This uses dispatch to use the previous version on proper Matrix aout and to use similar to construct a Matrix and to then use the Matrix based method.
1 parent 59f9af5 commit 0922779

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/datasets/archgdal.jl

+15-5
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,23 @@ end
1919
Base.size(b::GDALBand) = b.size
2020
DiskArrays.eachchunk(b::GDALBand) = b.cs
2121
DiskArrays.haschunks(::GDALBand) = DiskArrays.Chunked()
22-
function DiskArrays.readblock!(b::GDALBand, aout, r::AbstractUnitRange...)
23-
AG.read(b.filename) do ds
24-
AG.getband(ds, b.band) do bh
25-
DiskArrays.readblock!(bh, aout, r...)
22+
23+
function DiskArrays.readblock!(b::GDALBand, aout::Matrix, r::AbstractUnitRange...)
24+
AG.read(b.filename) do ds
25+
AG.getband(ds, b.band) do bh
26+
DiskArrays.readblock!(bh, aout, r...)
27+
2628
end
2729
end
28-
end
30+
end
31+
32+
function DiskArrays.readblock!(b::GDALBand, aout, r::AbstractUnitRange...)
33+
aout2 = similar(aout)
34+
DiskArrays.readblock!(b, aout2, r)
35+
aout .= aout2
36+
end
37+
38+
2939
function DiskArrays.writeblock!(b::GDALBand, ain, r::AbstractUnitRange...)
3040
AG.read(b.filename, flags=AG.OF_Update) do ds
3141
AG.getband(ds, b.band) do bh

0 commit comments

Comments
 (0)