Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic JuliaFormatter.jl run #412

Merged
merged 1 commit into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/raster/rasterio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,10 @@ function rasterio!(
return buffer
end

function read!(rb::AbstractRasterBand, buffer::T)::T where {T<:AbstractMatrix{<:Any}}
function read!(
rb::AbstractRasterBand,
buffer::T,
)::T where {T<:AbstractMatrix{<:Any}}
rasterio!(rb, buffer, GF_Read)
return buffer
end
Expand Down Expand Up @@ -348,7 +351,10 @@ function read!(
return buffer
end

function read!(dataset::AbstractDataset, buffer::T)::T where {T<:AbstractArray{<:Any,3}}
function read!(
dataset::AbstractDataset,
buffer::T,
)::T where {T<:AbstractArray{<:Any,3}}
nband = nraster(dataset)
@assert size(buffer, 3) == nband
rasterio!(dataset, buffer, collect(Cint, 1:nband), GF_Read)
Expand Down
28 changes: 14 additions & 14 deletions test/test_rasterio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,14 @@ import ArchGDAL as AG
end
end


@testset "Non standard buffer rasterio " begin
AG.read("ospy/data4/aster.img") do ds
@testset "version 1" begin
band = AG.getband(ds, 1)
count = 0
total = 0
abuffer = Array{AG.pixeltype(band)}(undef, AG.blocksize(band)..., 1)
buffer = view(abuffer, :,:,:)
buffer = view(abuffer, :, :, :)
for (cols, rows) in AG.windows(band)
AG.rasterio!(ds, buffer, [1], rows, cols)
data = buffer[1:length(cols), 1:length(rows)]
Expand All @@ -300,7 +299,7 @@ end
count = 0
total = 0
abuffer = Array{AG.pixeltype(band)}(undef, AG.blocksize(band)..., 1)
buffer = view(abuffer, :,:,:)
buffer = view(abuffer, :, :, :)

for (cols, rows) in AG.windows(band)
AG.read!(ds, buffer, [1], rows, cols)
Expand All @@ -318,7 +317,7 @@ end
count = 0
total = 0
abuffer = Matrix{AG.pixeltype(band)}(undef, AG.blocksize(band)...)
buffer = view(abuffer, :,:)
buffer = view(abuffer, :, :)

for (cols, rows) in AG.windows(band)
AG.read!(ds, buffer, 1, rows, cols)
Expand All @@ -336,7 +335,7 @@ end
count = 0
total = 0
abuffer = Matrix{AG.pixeltype(band)}(undef, AG.blocksize(band)...)
buffer = view(abuffer, :,:)
buffer = view(abuffer, :, :)

for (cols, rows) in AG.windows(band)
AG.read!(band, buffer, rows, cols)
Expand All @@ -355,7 +354,7 @@ end
total = 0
xbsize, ybsize = AG.blocksize(band)
abuffer = Matrix{AG.pixeltype(band)}(undef, ybsize, xbsize)
buffer = view(abuffer, :,:)
buffer = view(abuffer, :, :)

for ((i, j), (nrows, ncols)) in AG.blocks(band)
# AG.rasterio!(ds,buffer,[1],i,j,nrows,ncols)
Expand All @@ -372,8 +371,9 @@ end

@testset "version 6" begin
band = AG.getband(ds, 1)
abuffer = Array{AG.pixeltype(band)}(undef, AG.width(ds), AG.height(ds), 1)
buffer = view(abuffer, :,:,:)
abuffer =
Array{AG.pixeltype(band)}(undef, AG.width(ds), AG.height(ds), 1)
buffer = view(abuffer, :, :, :)

AG.rasterio!(ds, buffer, [1])
count = sum(buffer .> 0)
Expand All @@ -387,7 +387,7 @@ end
band = AG.getband(ds, 1)
abuffer =
Matrix{AG.pixeltype(band)}(undef, AG.width(ds), AG.height(ds))
buffer = view(abuffer, :,:)
buffer = view(abuffer, :, :)

AG.read!(band, buffer)
count = sum(buffer .> 0)
Expand All @@ -401,9 +401,9 @@ end
band = AG.getband(ds, 1)
abuffer =
Matrix{AG.pixeltype(band)}(undef, AG.width(ds), AG.height(ds))
buffer = view(abuffer, :,:)
buffer = view(abuffer, :, :)

AG.read!(ds, buffer, 1)
AG.read!(ds, buffer, 1)
count = sum(buffer .> 0)
total = sum(buffer)
@test buffer isa SubArray
Expand All @@ -415,7 +415,7 @@ end
band = AG.getband(ds, 1)
abuffer =
Array{AG.pixeltype(band)}(undef, AG.width(ds), AG.height(ds), 1)
buffer = view(abuffer, :,:,:)
buffer = view(abuffer, :, :, :)

AG.read!(ds, buffer, [1])
count = sum(buffer .> 0)
Expand All @@ -429,7 +429,7 @@ end
band = AG.getband(ds, 1)
abuffer =
Array{AG.pixeltype(band)}(undef, AG.width(ds), AG.height(ds), 3)
buffer = view(abuffer, :,:, :)
buffer = view(abuffer, :, :, :)

AG.read!(ds, buffer)
count = sum(buffer[:, :, 1] .> 0)
Expand All @@ -445,7 +445,7 @@ end
count = 0
total = 0
abuffer = Array{AG.pixeltype(band)}(undef, AG.blocksize(band)..., 1)
buffer = view(abuffer, :,:,:)
buffer = view(abuffer, :, :, :)

for (cols, rows) in AG.windows(band)
AG.rasterio!(ds, buffer, (1,), rows, cols)
Expand Down