[Gdal-dev] Calling OGRLayer member functions from MFC::OnDraw

Ricardo ricardoluis at ufs.br
Mon Sep 11 16:24:50 EDT 2006


Hi,

I'm trying to call OGRLayer member functions from MFC::OnDraw and it was 
returning to me an Access violation reading location.

It was working well for OGRDataSource member functions, with that I can 
count the number of layers and other functions works well, but nothing can 
be done with OGRLayer member functions or atributes.

I'm using Visual Studio .NET 2003, with GDAL 1.3.2 compiled by me. I compile 
it because my data are in a PostGIS data base. My source code was able to 
return some information from  the data source, but nothing can be done with 
the OGRLayer objects.

That is my source:
///////////////////////////////////////////////////////////////////////////

CChildView::CChildView()
{

const char *conexao = "PG:user=postgres password=postgres dbname=testegis 
host=10.0.0.62 port=5432";

OGRRegisterAll();
CPLPushErrorHandler( CPLQuietErrorHandler );

CPLSetConfigOption("GML_FIELDTYPES","ALWAYS_STRING");

   
 char szPath[100] = "";


char *pszDSName = NULL;
pszDSName = CPLStrdup(conexao);
char **papszTokens = NULL;
papszTokens = CSLTokenizeStringComplex( conexao, ",", TRUE, FALSE );
if( CSLCount(papszTokens) > 0 )
      pszDSName = CPLStrdup( papszTokens[0] );
CSLDestroy(papszTokens);
 if( pszDSName == NULL )
  {
      exit( 1 );
  }
#ifdef USE_SHARED_ACCESS
     poDS = OGRSFDriverRegistrar::GetRegistrar()->OpenShared( pszDSName );
#else
      poDS = OGRSFDriverRegistrar::Open( pszDSName );
#endif


poOGRLayer = poDS->GetLayer(13); //until here it works well.


poOGRLayer->ResetReading(); // it causes a  Access violation reading location


}
//////////////////////////////////////////////////////////////////////


Some has a clue?
Thank you all.

Ricardo Luís




More information about the Gdal-dev mailing list