id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
3467	OGRPolygon::PointOnSurface craches on self-intersecting polygon	ftrastour	chaitanya	"The function OGRPolygon::PointOnSurface crashes on ""butterfly"" polygons ( self intersecting ). 
It crashes because the call to GEOSPointOnSurface returns null when the polygon is self intersecting ans the following createFromGEOS failed.

Here is a fix :


{{{

int OGRPolygon::PointOnSurface( OGRPoint *poPoint ) const

{
    if( poPoint == NULL )
        return OGRERR_FAILURE;
 
#ifndef HAVE_GEOS
    return OGRERR_FAILURE;
#else
    GEOSGeom hThisGeosGeom = NULL;
    GEOSGeom hOtherGeosGeom = NULL;
     
    hThisGeosGeom = exportToGEOS();
 
    if( hThisGeosGeom != NULL )
    {
     	hOtherGeosGeom = GEOSPointOnSurface( hThisGeosGeom );

        //Check if the function has find a such point.
	if( ! hOtherGeosGeom ) {
          // GEOSPointOnSurface sometimes failed on degenerated polygons.
	  GEOSGeom_destroy( hThisGeosGeom ) ;
	  return OGRERR_FAILURE ;
	}

        ...


}}}
"	defect	closed	normal		OGR_SF	unspecified	normal	fixed	GEOS	warmerdam
