Skip to content

Commit 5c9873c

Browse files
committed
More robust GEOS pointOnSurface calculation (fix #13787)
1 parent 18744b4 commit 5c9873c

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/core/geometry/qgsgeos.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,20 +1371,20 @@ bool QgsGeos::pointOnSurface( QgsPointV2& pt, QString* errorMsg ) const
13711371
try
13721372
{
13731373
geos.reset( GEOSPointOnSurface_r( geosinit.ctxt, mGeos ) );
1374-
}
1375-
CATCH_GEOS_WITH_ERRMSG( false );
13761374

1377-
if ( !geos )
1378-
{
1379-
return false;
1380-
}
1375+
if ( !geos || GEOSisEmpty_r( geosinit.ctxt, geos.get() ) != 0 )
1376+
{
1377+
return false;
1378+
}
13811379

1382-
double x, y;
1383-
GEOSGeomGetX_r( geosinit.ctxt, geos.get(), &x );
1384-
GEOSGeomGetY_r( geosinit.ctxt, geos.get(), &y );
1380+
double x, y;
1381+
GEOSGeomGetX_r( geosinit.ctxt, geos.get(), &x );
1382+
GEOSGeomGetY_r( geosinit.ctxt, geos.get(), &y );
13851383

1386-
pt.setX( x );
1387-
pt.setY( y );
1384+
pt.setX( x );
1385+
pt.setY( y );
1386+
}
1387+
CATCH_GEOS_WITH_ERRMSG( false );
13881388

13891389
return true;
13901390
}

0 commit comments

Comments
 (0)