From 3838e938642712cf8a98c52df5937dcfdb19221e Mon Sep 17 00:00:00 2001 From: mathieu17g <72861595+mathieu17g@users.noreply.github.com> Date: Sun, 10 Oct 2021 15:12:19 +0200 Subject: [PATCH] run gdalallregister during module initialisation (#124) * Added `gdaldestroy` at exit and commented `cplseterrorhandler(C_NULL)` and trial wih `gdaldumpopendatasets` at exit * Suppressed comments in epilogue.jl * put changes into GDAL.jl, bump patch version * run gdalallregister in init Co-authored-by: Martijn Visser --- Project.toml | 2 +- README.md | 4 +--- gen/epilogue.jl | 4 +++- src/GDAL.jl | 1 + test/tutorial_raster.jl | 3 --- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Project.toml b/Project.toml index f53a0d8..835763d 100644 --- a/Project.toml +++ b/Project.toml @@ -3,7 +3,7 @@ uuid = "add2ef01-049f-52c4-9ee2-e494f65e021a" keywords = ["GDAL", "IO"] license = "MIT" desc = "Wrapper for GDAL - Geospatial Data Abstraction Library" -version = "1.2.4" +version = "1.2.5" [deps] CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82" diff --git a/README.md b/README.md index 617f20c..28d845a 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,7 @@ Julia wrapper for [GDAL - Geospatial Data Abstraction Library](http://gdal.org/). This package is a binding to the C API of GDAL/OGR. It provides only a C style usage, where -resources must be closed manually, and datasets are pointers. *Note: this also means that -before being able to use any drivers (for input/output of different formats), they must be -registered first using `GDAL.gdalallregister()`.* +resources must be closed manually, and datasets are pointers. Other packages can build on top of this to provide a more Julian user experience. See for example [ArchGDAL.jl](https://github.com/yeesian/ArchGDAL.jl). diff --git a/gen/epilogue.jl b/gen/epilogue.jl index 171a30e..026d4e6 100644 --- a/gen/epilogue.jl +++ b/gen/epilogue.jl @@ -8,7 +8,6 @@ function __init__() # register custom error handler funcptr = @cfunction(gdaljl_errorhandler, Ptr{Cvoid}, (CPLErr, Cint, Cstring)) cplseterrorhandler(funcptr) - atexit(() -> cplseterrorhandler(C_NULL)) # get GDAL version number versionstring = gdalversioninfo("RELEASE_NAME") @@ -31,4 +30,7 @@ function __init__() # set PROJ_LIB location, this overrides setting the environment variable PROJ_LIB[] = joinpath(PROJ_jll.artifact_dir, "share", "proj") osrsetprojsearchpaths([PROJ_LIB[]]) + + # register all known configured GDAL drivers + gdalallregister() end diff --git a/src/GDAL.jl b/src/GDAL.jl index 1c7481e..9abf1d8 100644 --- a/src/GDAL.jl +++ b/src/GDAL.jl @@ -33010,6 +33010,7 @@ function __init__() end PROJ_LIB[] = joinpath(PROJ_jll.artifact_dir, "share", "proj") osrsetprojsearchpaths([PROJ_LIB[]]) + gdalallregister() end end diff --git a/test/tutorial_raster.jl b/test/tutorial_raster.jl index 8c5f991..4ec1cc1 100644 --- a/test/tutorial_raster.jl +++ b/test/tutorial_raster.jl @@ -5,9 +5,6 @@ using GDAL utmsmall = joinpath(@__DIR__, "data/utmsmall.tif") utmsmall_copy = joinpath(@__DIR__, "tmp/utmsmall.tif") -# needed to actually load tifs -GDAL.gdalallregister() - # Opening the File dataset = GDAL.gdalopen(utmsmall, GDAL.GA_ReadOnly) # file from GDAL SVN