[gdal-dev] point within polygon c++ API problem
Ran, Limei
lran at email.unc.edu
Tue Dec 18 12:21:21 PST 2012
Hello,
I am working on a C++ codes which reads polygon from polygon shapefile to see whether a point is within a polygon. But, I got segmentation fault for pt.within (poGeometry). Could you tell me where I may have errors.
1. GDAL 1.9.1 is compiled with currect GEOS 3.3.6
2. My c++ program compiled with GDAL.
3. Here are my codes:
......
float x = grid.x[col];
float y = grid.y[row];
OGRPoint pt;
pt.setX( x );
pt.setY( y );
printf ("\tSet point\n");
OGRFeature *poFeature;
poLayer->ResetReading();
while( (poFeature = poLayer->GetNextFeature()) != NULL )
{
OGRFeatureDefn *poFDefn = poLayer->GetLayerDefn();
int iField;
OGRGeometry *poGeometry;
poGeometry = poFeature->GetGeometryRef();
if( poGeometry != NULL && ( poGeometry->getGeometryType() ) == wkbPolygon )
{
printf ("\tGot polygon\n");
if ( pt.Within ( poGeometry ) )
{ //find the polygon where point is within and get item values
printf ("\tpoint in polygon\n");
.........
I got segmentation fault when processing gets: if ( pt.Within ( poGeometry ) )
Thank you,
Limei
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20121218/bbb23095/attachment.html>
More information about the gdal-dev
mailing list