[gdal-dev] OGRGeometry::Intersection returns NULL

Even Rouault even.rouault at mines-paris.org
Wed Oct 10 11:21:52 PDT 2012


Le mercredi 10 octobre 2012 19:48:07, Alisson Barbosa a écrit :
> Hello, guys!
> 
> I'm truggling through a rough moment here...
> I have this piece of code in a project that I work on:
> 
> if(basinPolygon->Intersects(luPolygon))
> {
>         OGRGeometry *result = basinPolygon->Intersection(luPolygon);
>         if(result)
>                 newLayer.push_back(result);
> }
> 
> Somehow, the Intersects function returns true for those polygons
> (basinPolygon and luPolygon) (i.e. there is a intersection area between
> them), but
> 
>     basinPolygon->Intersection(luPolygon);
> 
> Always returns NULL! why is it returning NULL if Intersects returns true?!
> This is a mistery for me!

The likely cause is documented in the page you quoted

About Intersection(): "This method is built on the GEOS library, check it for 
the definition of the geometry operation. If OGR is built without the GEOS 
library, this method will always fail, issuing a CPLE_NotSupported error."

About Intersects(): "If GEOS is enabled, then this is done in rigerous fashion 
otherwise TRUE is returned if the envelopes (bounding boxes) of the two 
features overlap."

Take your symptoms and the above highlighted precisions, and you should have 
the answer.



More information about the gdal-dev mailing list