[gdal-dev] Hangs on OGRLayer ResetReading
Matthew Denno
mgdenno at gmail.com
Sat Dec 19 13:53:42 EST 2009
Hi,
I was wondering if someone could help me out. I have been working on
a little piece of code here and seems to be stuck. The piece is very
close to one of the examples on the website so I would think that it
would be right...maybe I have missed something simple. Anyway below
is the code. It seems like it hangs on "poLayer->ResetReading();".
It successfully prints out the number of features then dies.
Thanks,
Matt
CODE:
int z_shape_to_delaunay(Delaunay &dt,
QString myLayerPath,
bool useAnalysisMask,
QString analysisMaskPath)
{
qDebug("z_shape_to_delaunay");
OGRRegisterAll();
OGRDataSource *poDS;
poDS = OGRSFDriverRegistrar::Open( myLayerPath, FALSE );
if( poDS == NULL )
{
qDebug( "Shapefile failed to open" );
exit( 1 );
}
OGRLayer *poLayer;
poLayer = poDS->GetLayer( 0 );
qDebug() << "Number of Features: " << poLayer->GetFeatureCount(1);
if (poLayer = NULL)
{
qDebug( "Layer ID was out of range" );
exit( 1 );
}
OGRFeature *poFeature;
poLayer->ResetReading();
qDebug("start loop");
while( (poFeature = poLayer->GetNextFeature()) != NULL )
{
OGRGeometry *poGeometry;
poGeometry = poFeature->GetGeometryRef();
qDebug("in loop");
if (!poGeometry)
{
continue;
}
if( poGeometry != NULL && poGeometry->getGeometryType() == wkbPoint25D )
{
OGRPoint *poPoint = (OGRPoint *) poGeometry;
Point pt = Point(poPoint->getX(), poPoint->getY(), poPoint->getZ());
dt.insert(pt);
}
else
{
qDebug( "no point geometry" );
}
}
}
return (0);
}
More information about the gdal-dev
mailing list