Skip to content

Commit

Permalink
Simplify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eschnett committed Jul 24, 2024
1 parent b85b5d5 commit 6b0721f
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 344 deletions.
1 change: 1 addition & 0 deletions src/ArchGDAL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ include("ogr/featuredefn.jl")
include("ogr/fielddefn.jl")
include("ogr/styletable.jl")
include("mdarray/types.jl")
include("mdarray/dimension.jl")
include("mdarray/global.jl")
include("mdarray/group.jl")
include("mdarray/mdarray.jl")
Expand Down
3 changes: 2 additions & 1 deletion src/context.jl
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ for gdalfunc in (
:getgeom,
:getgridded,
:getindex,
:getindexingvariable,
:getlayer,
:getmask,
:getmaskband,
Expand All @@ -265,7 +266,7 @@ for gdalfunc in (
:newspatialref,
:nextfeature,
:open,
# :opendimensionfromfullname,
:opendimensionfromfullname,
:opengroup,
:opengroupfromfullname,
:openmdarray,
Expand Down
57 changes: 57 additions & 0 deletions src/mdarray/dimension.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# GDALDimension

function getname(dimension::AbstractDimension)::AbstractString
@assert !isnull(dimension)
return GDAL.gdaldimensiongetname(dimension)
end

function getfullname(dimension::AbstractDimension)::AbstractString
@assert !isnull(dimension)
return GDAL.gdaldimensiongetfullname(dimension)
end

function gettype(dimension::AbstractDimension)::AbstractString
@assert !isnull(dimension)
return GDAL.gdaldimensiongettype(dimension)
end

function getdirection(dimension::AbstractDimension)::AbstractString
@assert !isnull(dimension)
return GDAL.gdaldimensiongetdirection(dimension)
end

function getsize(dimension::AbstractDimension)::Int
@assert !isnull(dimension)
return Int(GDAL.gdaldimensiongetsize(dimension))
end

function unsafe_getindexingvariable(
dimension::AbstractDimension,
)::AbstractMDArray
@assert !isnull(dimension)
return MDArray(
GDAL.gdaldimensiongetindexingvariable(dimension),
dimension.dataset.value,
)
end

function getindexingvariable(dimension::AbstractDimension)::AbstractMDArray
@assert !isnull(dimension)
return IMDArray(
GDAL.gdaldimensiongetindexingvariable(dimension),
dimension.dataset.value,
)
end

function setindexingvariable!(
dimension::AbstractDimension,
indexingvariable::AbstractMDArray,
)::Bool
@assert !isnull(dimension)
return GDAL.gdaldimensionsetindexingvariable(dimension, indexingvariable)
end

function rename!(dimension::AbstractDimension, newname::AbstractString)::Bool
@assert !isnull(dimension)
return GDAL.gdaldimensionrename(dimension, newname)
end
32 changes: 22 additions & 10 deletions src/mdarray/global.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ function unsafe_createmultidimensional(
name::AbstractString,
rootgroupoptions::OptionList = nothing,
options::OptionList = nothing,
;
hard_close::Bool = true,
)::AbstractDataset
@assert !isnull(driver)
return Dataset(
Expand All @@ -14,7 +16,7 @@ function unsafe_createmultidimensional(
CSLConstListWrapper(rootgroupoptions),
CSLConstListWrapper(options),
),
hard_close = true,
hard_close = hard_close,
)
end

Expand All @@ -23,6 +25,8 @@ function createmultidimensional(
name::AbstractString,
rootgroupoptions::OptionList = nothing,
options::OptionList = nothing,
;
hard_close::Bool = true,
)::AbstractDataset
@assert !isnull(driver)
return IDataset(
Expand All @@ -32,7 +36,7 @@ function createmultidimensional(
CSLConstListWrapper(rootgroupoptions),
CSLConstListWrapper(options),
),
hard_close = true,
hard_close = hard_close,
)
end

Expand All @@ -42,10 +46,14 @@ function unsafe_open(
alloweddrivers::OptionList,
openoptions::OptionList,
siblingfiles::OptionList,
hard_close::Union{Nothing,Bool} = nothing,
)::AbstractDataset
# We hard-close the dataset if it is a writable multidim dataset
want_hard_close =
(openflags & OF_MULTIDIM_RASTER != 0) && (openflags & OF_UPDATE != 0)
if hard_close === nothing
# We hard-close the dataset if it is a writable multidim dataset
hard_close =
(openflags & OF_MULTIDIM_RASTER != 0) &&
(openflags & OF_UPDATE != 0)
end
return Dataset(
GDAL.gdalopenex(
filename,
Expand All @@ -54,7 +62,7 @@ function unsafe_open(
CSLConstListWrapper(openoptions),
CSLConstListWrapper(siblingfiles),
),
hard_close = want_hard_close,
hard_close = hard_close,
)
end

Expand All @@ -64,10 +72,14 @@ function open(
alloweddrivers::OptionList,
openoptions::OptionList,
siblingfiles::OptionList,
hard_close::Union{Nothing,Bool} = nothing,
)::AbstractDataset
# We hard-close the dataset if it is a writable multidim dataset
want_hard_close =
(openflags & OF_MULTIDIM_RASTER != 0) && (openflags & OF_UPDATE != 0)
if hard_close === nothing
# We hard-close the dataset if it is a writable multidim dataset
hard_close =
(openflags & OF_MULTIDIM_RASTER != 0) &&
(openflags & OF_UPDATE != 0)
end
return IDataset(
GDAL.gdalopenex(
filename,
Expand All @@ -76,7 +88,7 @@ function open(
CSLConstListWrapper(openoptions),
CSLConstListWrapper(siblingfiles),
),
hard_close = want_hard_close,
hard_close = hard_close,
)
end

Expand Down
Loading

0 comments on commit 6b0721f

Please sign in to comment.