MaxRev-Dev / gdal.netcore

GDAL 3.x C#/F# bindings for .NET apps
MIT License
161 stars 36 forks source link

GDALGetCacheMax64 #88

Closed KubaSzostak closed 1 year ago

KubaSzostak commented 1 year ago

Is your feature request related to a problem? Please describe.

Currently the library exposes int Gdal.GetCacheMax() and Gdal.SetCacheMax(int nBytes) methods. The unit of the cache size is byte. Due to the use of an Int32 type as cache size, the the maximum value is 2GB.

Describe the solution you'd like or your ideas here

GDAL has also GDALSetCacheMax64() and GDALGetCacheMax64() methods, but they are note exposed by the library. Would it be possible to to expose those methods in the library?

Additional context

Currently calling the Gdal.GetCacheMax() method on machine having 64 GB RAM causes warning message to be displayed in console application.

Sample code

static void Main(params string[] args)
{
    MaxRev.Gdal.Core.GdalBase.ConfigureAll();
    Console.WriteLine(Gdal.GetCacheMax());
    Console.WriteLine(Gdal.GetCacheMax() == int.MaxValue);
}

Output

Warning 1: Cache max value doesn't fit on a 32 bit integer. Call GDALGetCacheMax64() instead
2147483647
True
MaxRev-Dev commented 1 year ago

It can be defined by exposing swig bindings to C#. Before generating bindings, we can apply a patch to this file.
But it's worth checking whether it can be applied harmlessly before trying and the reason why the API was encapsulated this way. I can't give you any warranty that this will work as expected. It's better to ask the maintainers of the GDAL library why they didn't expose those methods and what can be done in this case.