[Gdal-dev] 2 layers in postgis; getnextfeature(); C++

Thomas Windholz thomw00 at yahoo.com
Wed Oct 19 09:55:13 EDT 2005


Hello List,
 
I would like to handle two ogrlayers from a postgres database. When using getnextfeature or executesql in nested loops it fails. I am not sure if it is that either ogr is supposed to work this way or if it's just me ...
 
any help is appreciated!
 
Thanks,
Thomas
 
the counter returns the correct record number of 242 if I exclude the nested while loop (getnext on layer2), but it returns 1 as it is ...
 
here is a basic version of the code:
 

OGRLayer *poLayer1;

OGRLayer *poLayer2;

int counter=0;

OGRRegisterAll(); 

poDS = OGRSFDriverRegistrar::Open( "PG:user=postgres password=*** dbname=*** host=localhost port=5432", TRUE );

poLayer1 = poDS->GetLayerByName("test242");

poLayer2 = poDS->GetLayerByName("test3");

OGRFeature *poFeatureL1;

poLayer1->ResetReading();

while( (poFeatureL1 = poLayer1->GetNextFeature()) != NULL )

{

OGRFeature *poFeatureL2; 

poLayer2->ResetReading();

while( (poFeatureL2 = poLayer2->GetNextFeature()) != NULL )

{



}

counter++; 

}

cout << counter;

 

same thing happens if I use executesql instead of the second while loop :

poLayer2 = poDS->ExecuteSQL("SELECT * FROM temp2",NULL,NULL);)



		
---------------------------------
 Yahoo! Music Unlimited - Access over 1 million songs. Try it free.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20051019/e93e04e1/attachment.html


More information about the Gdal-dev mailing list