Opened 8 years ago

Closed 5 years ago

#6437 closed defect (wontfix)

Missing typemaps in C# binding for Gdal

Reported by: ccjklppp Owned by: tamas
Priority: highest Milestone: closed_because_of_github_migration
Component: CSharpBindings Version: unspecified
Severity: major Keywords:
Cc:

Description (last modified by ccjklppp)

I'm using the c# binding.all methods that should get as argument Dataset[], actually expects type SWIGTYPE_p_p_GDALDatasetShadow instead. this happens in the following methods:
Gdal.CreatePansharpenedVRT(...)
Gdal.wrapper_GDALBuildVRT_objects(...)
Gdal.wrapper_GDALWarpDestDS(...)
Gdal.wrapper_GDALWarpDestName(...)

moreover, the method Gdal.wrapper_GDALVectorTranslateDestDS(...) expect to get Datasets (src & dst) while it should get Datasource (vector) isn't it?

Attachments (1)

gdal.i (45.0 KB ) - added by ccjklppp 8 years ago.
swig\include\gdal.i

Download all attachments as: .zip

Change History (15)

comment:1 by ccjklppp, 8 years ago

Version: unspecified
Last edited 8 years ago by ccjklppp (previous) (diff)

comment:2 by ccjklppp, 8 years ago

Description: modified (diff)

comment:3 by Even Rouault, 8 years ago

Summary: Gdal utilities as a libraryMissing typemaps in C# binding for Gdal.wrapper_GDALWarpDestName

Tamas, will you be able to work on that for 2.1.0 ?

comment:4 by ccjklppp, 8 years ago

anyone??

comment:5 by ccjklppp, 8 years ago

Milestone: 2.1.02.1.1

comment:6 by ccjklppp, 8 years ago

I have made a workaround to the problem:
I've changed the gdalwarp interfaces so it will be like the gdalbuildvrt interfaces -
one method gets the input/output file names and another method gets the input/output dataset objects

All the changes I've made are in the file: swig\include\gdal.i
and this is the changed part:

//************************************************************************
// gdal.Warp()
//************************************************************************

#ifdef SWIGJAVA
%rename (WarpOptions) GDALWarpAppOptions;
#endif
struct GDALWarpAppOptions {
%extend {
    GDALWarpAppOptions(char** options) {
        return GDALWarpAppOptionsNew(options, NULL);
    }

    ~GDALWarpAppOptions() {
        GDALWarpAppOptionsFree( self );
    }
}
};

#ifdef SWIGJAVA
%rename (Warp) wrapper_GDALWarp_objects;
#endif

/* Note: we must use 2 distinct names due to different ownership of the result */

%inline %{
int wrapper_GDALWarp_objects( GDALDatasetShadow* dstDS,
                            int object_list_count, GDALDatasetShadow** poObjects,
                            GDALWarpAppOptions* options,
                            GDALProgressFunc callback=NULL,
                            void* callback_data=NULL)
{
    int usageError; /* ignored */
    bool bFreeOptions = false;
    if( callback )
    {
        if( options == NULL )
        {
            bFreeOptions = true;
            options = GDALWarpAppOptionsNew(NULL, NULL);
        }
        GDALWarpAppOptionsSetProgress(options, callback, callback_data);
    }
    int bRet = (GDALWarp(NULL, dstDS, object_list_count, poObjects, options, &usageError) != NULL);
    if( bFreeOptions )
        GDALWarpAppOptionsFree(options);
    return bRet;
}
%}

#ifdef SWIGJAVA
%rename (Warp) wrapper_GDALWarp_names;
#endif

%newobject wrapper_GDALWarp_names;
%apply (char **options) {char** source_filenames};
%inline %{
GDALDatasetShadow* wrapper_GDALWarp_names( const char* dest,
                                             char ** source_filenames,
                                             GDALWarpAppOptions* options,
                                             GDALProgressFunc callback=NULL,
                                             void* callback_data=NULL)
{
    int usageError; /* ignored */
    bool bFreeOptions = false;
    if( callback )
    {
        if( options == NULL )
        {
            bFreeOptions = true;
            options = GDALWarpAppOptionsNew(NULL, NULL);
        }
        GDALWarpAppOptionsSetProgress(options, callback, callback_data);
    }
	
	int nInputFiles = CSLCount(source_filenames);
	GDALDatasetH* poObjects = (GDALDatasetH*) CPLMalloc(nInputFiles * sizeof(GDALDatasetH));
	for(int i=0;i<nInputFiles;i++)
    {
		poObjects[i] = GDALOpen(source_filenames[i], GA_ReadOnly );
    }
	
    GDALDatasetH hDSRet = GDALWarp(dest, NULL, nInputFiles, poObjects, options, &usageError);
	
	for(int i=0;i<nInputFiles;i++)
    {
		GDALClose(poObjects[i]);
    }
	CPLFree(poObjects);

    if( bFreeOptions )
        GDALWarpAppOptionsFree(options);
    return hDSRet;
}
%}


the full file is attached.
I would appreciate if you put the changes to the trunk version...

by ccjklppp, 8 years ago

Attachment: gdal.i added

swig\include\gdal.i

comment:7 by Even Rouault, 8 years ago

The proposed gdal.i would break the Python bindings. I guess what is needed is a typemap for (int object_list_count, GDALDatasetShadow poObjects) in swig/include/csharp/typemaps_csharp.i

comment:8 by Even Rouault, 8 years ago

Removing target milestone as it corresponds to a now closed milestone.

comment:9 by ccjklppp, 8 years ago

Milestone: 2.1.12.1.2

comment:10 by ccjklppp, 7 years ago

Description: modified (diff)
Milestone: 2.1.22.2.0
Summary: Missing typemaps in C# binding for Gdal.wrapper_GDALWarpDestNameMissing typemaps in C# binding for Gdal

comment:11 by Even Rouault, 6 years ago

Milestone: 2.2.02.3.0

Postponing to later milestone

comment:12 by Even Rouault, 6 years ago

Milestone: 2.3.0

Ticket retargeted after milestone closed

comment:13 by Franik, 6 years ago

Is this issue planned for the next release? It would be really helpful. This seems to keep getting postponed even though it has the highest priority. Any info on the current state would be appreciated.

comment:14 by Even Rouault, 5 years ago

Milestone: closed_because_of_github_migration
Resolution: wontfix
Status: newclosed

This ticket has been automatically closed because Trac is no longer used for GDAL bug tracking, since the project has migrated to GitHub. If you believe this ticket is still valid, you may file it to https://github.com/OSGeo/gdal/issues if it is not already reported there.

Note: See TracTickets for help on using tickets.