[gdal-dev] NewDataset and SetBand error

Seung Ae Lim salim at pixoneer.co.kr
Thu Nov 7 16:17:27 PST 2013


I build GDAL library just opening "makegdal10.sln".
My test program is just simple console application with VS2010 without any added configuration.
GDAL :f:\gdal-1.10.0\
Test program include config :f:\gdal-1.10.0\port\;f:\gdal-1.10.0\gcore;f:\gdal-1.10.0\ogr;f:\gdal-1.10.0\frmts;
Test program link path :f:\gdal-1.10.0\gdal_i.lib

In my thought, my program may use same sources with GDAL.

Is there any GDAL configuration for my program?

Thanks.
Seung Ae


----- Original Message -----
From:Frank Warmerdam [warmerdam at pobox.com]
To:Seung Ae Lim [salim at pixoneer.co.kr]
Cc:gdal dev [gdal-dev at lists.osgeo.org]
Sent:Fri , November 08, 2013 01:31 AM
Subject:Re: [gdal-dev] NewDataset and SetBand error




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/20131108/55d88a90/attachment-0001.html>


More information about the gdal-dev mailing list