[gdal-dev] NewDataset and SetBand error

Frank Warmerdam warmerdam at pobox.com
Thu Nov 7 08:31:40 PST 2013


Seung,

If the fields, like papoBands in the dataset seem ok before stepping into
SetBand(), and corrupt once you are inside I would suspect that GDAL and
your application have been built with different gdal_priv.h include files
*or* with different structure alighnments flags for Visual Studio.  Did you
build GDAL from source using the same configuration you are building your
application with?

Best regards,
Frank



On Thu, Nov 7, 2013 at 1:03 AM, Seung Ae Lim <salim at pixoneer.co.kr> wrote:

>   Dear,
>
>
>
>  I make a console application with VS2010 linking "gdal_i.lib".
>
>  The steps are :
>
> * 1. Create New Dataset and Band in main.cpp*
> class XXDataset : public GDALPamDataset
> {
> public:
>  XXDataset() {};
>  ~XXDataset() {};
>
>  static GDALDataset* Open(GDALOpenInfo*);
> };
>
> class XXRasterBand : public GDALPamRasterBand
> {
> public:
>  XXRasterBand( GDALDataset*, int, GDALDataType );
>  ~XXRasterBand() {};
> };
>
>
> GDALDataset* XXDataset::Open(GDALOpenInfo* pOpenInfo)
> {
>  XXDataset* poDS = new XXDataset();
>  poDS- >nRasterXSize = 100;
>  poDS- >nRasterYSize = 200;
>  poDS- >eAccess = GA_Update;
>  poDS- >nBands = 3;
>
>  int iBand = 0;
>  for(iBand = 1; iBand < = 3; iBand++ )
>  {
>  XXRasterBand* band = new XXRasterBand( poDS, iBand, GDT_Byte);
>  poDS- >SetBand( iBand, band );
>  }
>
>  return poDS;
> }
>
> XXRasterBand::XXRasterBand( GDALDataset *poDS, int nBand, GDALDataType
> eType)
> {
>  this- >poDS = poDS;
>  this- >nBand = nBand;
>  this- >eDataType = eType;
>  nRasterXSize = 100;
>  nRasterYSize = 200;
>  nBlockXSize = nRasterXSize;
>  nBlockYSize = nRasterYSize;
> }
>
> *2. Add the code in main function*
> void main()
> {
>
>
>         GDALDataset* pDSTemp = XXDataset::Open(NULL);
>  if (pDSTemp) GDALClose(pDSTemp);
> }
>
>
> I compile and try to debug this app.
> But in "poDS->SetBand" line of "XXDataset::Open", the app is broken when
> the first band is ready to set.
> In XXDataset::Open, all value of parameters is right.
> But When stepping into the "SetBand" function, the values may be corrupted.
> "papobands" of GDALDataset is not null and it make an error.
>
> Please let me know the reason or some tips.
>
> Thanks.
>
>
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>



-- 
---------------------------------------+--------------------------------------
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 Software Developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20131107/98e9bb19/attachment.html>


More information about the gdal-dev mailing list