[Gdal-dev] OGR code examples

Chapman, Martin MChapman at sanz.com
Wed Jul 14 16:38:43 EDT 2004


Michele,

Also, Here is some code to open the datasource as well, where
m_pDatasource is an OGRDataSource*:

COgrDataSource::COgrDataSource(string sConnectString, int nUpdate)
{
	try
	{
		m_pDatasource = NULL;
		m_sConnectString = sConnectString;
		OGRRegisterAll();
		OpenDataSource(m_sConnectString, nUpdate);
	}
	catch(exception e)	
		{throw e;}
	catch(char* e)	
		{throw e;}
	catch(...)	
		{throw "An unexpected error occurred in
COgrDataSource::COgrDataSource().";}
}

int COgrDataSource::OpenDataSource(string sConnectString, int nUpdate)
{
	try
	{
		CloseDataSource();
		m_sConnectString = sConnectString;
		m_pDatasource =
OGRSFDriverRegistrar::Open(m_sConnectString.c_str(), nUpdate);
		if (m_pDatasource == NULL) throw (char*)
CPLGetLastErrorMsg();
		return 0;
	}
	catch(exception e)
		{throw e;}
	catch(char* e)
		{throw e;}
	catch(...)
		{throw "An unexpected error occurred in
COgrDataSource::OpenDataSource().";}
}

-----Original Message-----
From: Frank Warmerdam [mailto:warmerdam at pobox.com] 
Sent: Wednesday, July 14, 2004 2:30 PM
To: Sanges Michele
Cc: gdal-dev at xserve.flids.com
Subject: Re: [Gdal-dev] OGR code examples


Sanges Michele wrote:
> Are there some code examples of how reading data files by means the 
> OGR library, in C++? Thanks.

Hi,

I am not aware of C++ examples other than the utility programs like
ogrinfo.cpp and ogr2ogr.cpp.

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

_______________________________________________
Gdal-dev mailing list
Gdal-dev at xserve.flids.com
http://xserve.flids.com/mailman/listinfo/gdal-dev



More information about the Gdal-dev mailing list