Hello Even,

Since you helped me on GEOS compiling with GDAL, I think you may have ideas on 
what went wrong with my codes in the following.  Could you tell me what you 
think on my segmentation fault error?

Thank you,

Limei


From: Ran, Limei
Sent: Tuesday, December 18, 2012 3:21 PM
To: [email protected]
Subject: point within polygon c++ API problem

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


_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to