[gdal-dev] GDAL 3.11 broke part of the Julia wrapper

Joaquim Manuel Freire Luís jluis at ualg.pt
Sun May 11 17:26:57 PDT 2025


OK, with the help of your GDALGetRasterCount() hint I fixed it. The problem was that before #12124<https://github.com/OSGeo/gdal/pull/12124>

Gdal.OGRGetDriverByName(Gdal.shortname(getdriver(dataset))) returned NULL for raster types, but from #12124 on it returns a non-NULL pointer, and the code flow went to wrong branches.

Uff, that tricky. Thanks

From: Joaquim Manuel Freire Luís <jluis at ualg.pt>
Sent: Monday, May 12, 2025 12:39 AM
To: Joaquim Manuel Freire Luís <jluis at ualg.pt>; Even Rouault <even.rouault at spatialys.com>; gdal-dev <gdal-dev at lists.osgeo.org>
Subject: RE: [gdal-dev] GDAL 3.11 broke part of the Julia wrapper

Sorry, forgot to pass the pointer. Also here it says the layer count is zero

ccall((:GDALDatasetGetLayerCount, libgdal), Cint, (Ptr{Cvoid},), ds.ptr)
0



From: gdal-dev <gdal-dev-bounces at lists.osgeo.org<mailto:gdal-dev-bounces at lists.osgeo.org>> On Behalf Of Joaquim Manuel Freire Luís via gdal-dev
Sent: Monday, May 12, 2025 12:34 AM
To: Even Rouault <even.rouault at spatialys.com<mailto:even.rouault at spatialys.com>>; gdal-dev <gdal-dev at lists.osgeo.org<mailto:gdal-dev at lists.osgeo.org>>
Subject: Re: [gdal-dev] GDAL 3.11 broke part of the Julia wrapper

Right. But I do that I get another error that I’m not sure how to interpret. It comes from some Julia internal

ccall((:GDALGetRasterCount, libgdal), Cint, (Ptr{Cvoid},), ds)
Internal Error: MethodError: no method matching unsafe_convert(::Type{Ptr{Nothing}}, ::GMT.Gdal.IDataset)


From: Even Rouault <even.rouault at spatialys.com<mailto:even.rouault at spatialys.com>>
Sent: Monday, May 12, 2025 12:15 AM
To: Joaquim Manuel Freire Luís <jluis at ualg.pt<mailto:jluis at ualg.pt>>; gdal-dev <gdal-dev at lists.osgeo.org<mailto:gdal-dev at lists.osgeo.org>>
Subject: Re: [gdal-dev] GDAL 3.11 broke part of the Julia wrapper



Le 12/05/2025 à 01:04, Joaquim Manuel Freire Luís via gdal-dev a écrit :
Hi,

I’m afraid this one is not going to be easy, and I don’t know how much help I can provide to find the issue. The think is that https://github.com/OSGeo/gdal/pull/12124 (which is a very big PR) broke my Julia wrapper.

For example, this used to write a png image but now it errors with

julia> gdalwrite("lixo.png", mat2img(UInt8.([1 2 3; 4 5 6; 7 8 9])))
ERROR 1: Cannot guess driver for lixo.png

But maybe more concrete is this failure where it tries to extract info from a gdal dataset (a pointer )


Gdal.GDALGetRasterYSize(dataset.ptr)
49
Gdal.GDALGetRasterCount(dataset.ptr)
1
Gdal.GDALDatasetGetLayerCount(dataset.ptr)
0

Here, first two are correct be the third is now wrong.

Why is GDALDatasetGetLayerCount() == 0 wrong on a raster dataset ? It looks like the expected result

If I'm looking at the correct source code https://github.com/GenericMappingTools/GMT.jl/blob/94649db2b48d3223c8b8628b6fac4d3df60b8938/src/gdal_utils.jl#L859 , then this line is fragile. Rather than testing if OGRGetDriverByName() returns a non null pointer to guess if that dataset is raster or vector, you could indeed test GDALGetRasterCount() != 0 to infer this is a raster dataset.

--

http://www.spatialys.com

My software is free, but my time generally not.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20250512/da6b0871/attachment.htm>


More information about the gdal-dev mailing list