Skip to content

Commit 32cdd85

Browse files
committed
More robust GEOS pointOnSurface calculation (fix #13787)
(cherry-picked from 5c9873c)
1 parent 3201700 commit 32cdd85

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/core/geometry/qgsgeos.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -1333,20 +1333,20 @@ bool QgsGeos::pointOnSurface( QgsPointV2& pt, QString* errorMsg ) const
13331333
try
13341334
{
13351335
geos.reset( GEOSPointOnSurface_r( geosinit.ctxt, mGeos ) );
1336-
}
1337-
CATCH_GEOS_WITH_ERRMSG( false );
13381336

1339-
if ( !geos )
1340-
{
1341-
return false;
1342-
}
1337+
if ( !geos || GEOSisEmpty_r( geosinit.ctxt, geos.get() ) != 0 )
1338+
{
1339+
return false;
1340+
}
13431341

1344-
double x, y;
1345-
GEOSGeomGetX_r( geosinit.ctxt, geos.get(), &x );
1346-
GEOSGeomGetY_r( geosinit.ctxt, geos.get(), &y );
1342+
double x, y;
1343+
GEOSGeomGetX_r( geosinit.ctxt, geos.get(), &x );
1344+
GEOSGeomGetY_r( geosinit.ctxt, geos.get(), &y );
13471345

1348-
pt.setX( x );
1349-
pt.setY( y );
1346+
pt.setX( x );
1347+
pt.setY( y );
1348+
}
1349+
CATCH_GEOS_WITH_ERRMSG( false );
13501350

13511351
return true;
13521352
}

0 commit comments

Comments
 (0)