[gdal-dev] Potential bug with the create function for the
"GTiff" driver
Frank Warmerdam
warmerdam at pobox.com
Thu Jul 9 10:18:15 EDT 2009
Adeel Raza wrote:
> Hi,
>
> I'm using gdal 1.6.1 for MSVC9.0 on Windows XP (32-bit platform). I'm
> trying to create a .tif file according to the following code:
>
> GDALDriver *tifDriver;
> GDALDataset *srcDataset;
>
> tifDriver = (GDALDriver *)GDALGetDriverByName("GTiff");
> assert(tifDriver != NULL);
> srcDataset = tifDriver->Create("srcDataset.tif", nCols, nRows, 1,
> GDALDataType::GDT_Float32, NULL);
> assert(srcDataset != NULL);
>
>
> "nCols" is defined as an unsigned short and has a value of 2460.
> Similarly "nRows" is also defined as an unsigned short and has a value
> of 2430.
> When I run the code shown above the asserts do not fail. The returned
> dataset however, has wrong values assigned to its data members. The
> values for the data members of "srcDataset" are as follows:
>
> eAccess = 2460;
> nRasterXSize = 2430;
> nRasterYSize = 1;
> nBands = 19035560;
> papoBands = 0X00000000;
> bForceCahcedIO = 1
> nRefCount = 0;
> bShared = 0;
>
> The values for nRasterXSize, nRasterYSize, and nBands are wrong (I'm not
> sure about the other data members), and should be as follows:
> nRasterXSize = 2460;
> nRasterYSize = 2430;
> nBands = 1;
>
> Is this a bug in the create function for the "GTiff" driver or am I
> doing something wrong?
Adeel,
I presume you inspected the member values in the visual studio
debugging environment? I suspect you have some sort of versioning
mixup - perhaps you have compiled your mainline using a different
version of the include files than correctly apply to the DLL you
end up invoking. Alternatively, the debugger is getting confused
due to different structure packing options being used in your
main project compared to what was used in building GDAL itself.
Is the created TIFF correct (if you close it)? If you are having
trouble getting compatible build options between your application
and the underlying library you may find it safer to use only the
GDAL C API instead of the C++ API in order to avoid subtle issues.
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