[gdal-dev] Question about GDALDriverManager + gdal2wktraster

Frank Warmerdam warmerdam at pobox.com
Tue Jul 7 00:32:58 EDT 2009


Jorge Arévalo wrote:
> Hello,
> 
> I have two versions of GDAL in my machine:
> 
> - GDAL 1.7.0 from SVN
> - GDAL 1.7.0 with the WKT Raster driver I'm developing
> 
> Today, I've updated the wktraster code from svn. I have the revision 
> 4256. The last one. With this revision, there is a new version of 
> gdal2wktraster script.
...
> /* -------------------------------------------------------------------- */
> /*      If it is already registered, just return the existing           */
> /*      index.                                                          */
> /* -------------------------------------------------------------------- */
>     if( GetDriverByName( poDriver->GetDescription() ) != NULL )
>     {
>         int             i;
> 
>         for( i = 0; i < nDrivers; i++ )
>         {
>             if( papoDrivers[i] == poDriver )
>             {
>                 return i;
>             }
>         }
> 
>         CPLAssert( FALSE ); // -------> THE LINE THAT CAUSES THE CRASH 
> *******************************************
...
> 
> So, basically, with the base 1.7.0 version of GDAL, I can load the TIFF 
> file. With my version, crash in the previous method. Clearly, it's my 
> driver's problem, but I don't know why. I have a test code to create a 
> dataset using my driver and works... Why could the application crash 
> when trying to list the registered drivers while loading a TIFF file? I 
> have the TIFF driver loaded in my GDAL version.

Jorge,

It sounds very much to me like there is more than one driver registered
with a given name (description).

What do you do in your driver for the poDriver->SetDescription() call?
It is imperative that each driver have a unique short driver name for
this.

Looking at:

   http://www.gis4free.org/gdal_wktraster/frmts/wktraster/wktrasterdataset.cpp

I see:

     if( GDALGetDriverByName( "WKTRaster" ) == NULL )
     {
         poDriver = new GDALDriver();

         poDriver->SetDescription( "WKT Raster driver" );

OK, so the problem is that your GetDriverByName() call is
not checking for the short name you set as the description.
Even though it is called Description this is really the
driver short name and it should be a well behaved short
keyword.  So please change it to:

    poDriver->SetDescription( "WKTRaster" );

If you find the driver writing tutorial is unclear on this point please
propose a change to the tutorial.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the gdal-dev mailing list