MaxRev-Dev / gdal.netcore

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

Feature: Update for GDAL wrapper functions #97

Closed MaxRev-Dev closed 1 year ago

MaxRev-Dev commented 1 year ago

It needs to be apparent how to use several wrappers in GDAL. Proper implementation in the SWIG interface will be able to call GDAL functions without writing additional methods. This issue will be linked to a PR in GDAL repo for implementing required bindings.

The current implementation of Gdal.BuildVRT looks like this:


public static Dataset GDALBuildVRT(string destPath, Dataset[] datasets,
    GDALBuildVRTOptions options,
    Gdal.GDALProgressFuncDelegate? callback = null,
    string? callback_data = null)
{
    var ptrArr = datasets.Select(x => Dataset.getCPtr(x).Handle).ToArray();
    var gcHandle = GCHandle.Alloc(ptrArr, GCHandleType.Pinned);
    try
    {
        return Gdal.wrapper_GDALBuildVRT_objects(destPath, datasets.Length, gcHandle.AddrOfPinnedObject(), options, callback, callback_data);
    }
    finally
    {
        gcHandle.Free();
    }
}