@@ -397,21 +397,12 @@ void QgsZonalStatistics::statisticsFromMiddlePointTest( const QgsGeometry &poly,
397
397
cellCenterY = rasterBBox.yMaximum () - pixelOffsetY * cellSizeY - cellSizeY / 2 ;
398
398
stats.reset ();
399
399
400
- geos ::unique_ptr polyGeos ( QgsGeos::asGeos ( poly ) );
401
- if ( !polyGeos )
400
+ std ::unique_ptr< QgsGeometryEngine > polyEngine ( QgsGeometry::createGeometryEngine ( poly. constGet ( ) ) );
401
+ if ( !polyEngine )
402
402
{
403
403
return ;
404
404
}
405
-
406
- GEOSContextHandle_t geosctxt = QgsGeos::getGEOSHandler ();
407
- geos::prepared_unique_ptr polyGeosPrepared ( GEOSPrepare_r ( geosctxt, polyGeos.get () ) );
408
- if ( !polyGeosPrepared )
409
- {
410
- return ;
411
- }
412
-
413
- GEOSCoordSequence *cellCenterCoords = nullptr ;
414
- geos::unique_ptr currentCellCenter;
405
+ polyEngine->prepareGeometry ();
415
406
416
407
QgsRectangle featureBBox = poly.boundingBox ().intersect ( &rasterBBox );
417
408
QgsRectangle intersectBBox = rasterBBox.intersect ( &featureBBox );
@@ -425,11 +416,8 @@ void QgsZonalStatistics::statisticsFromMiddlePointTest( const QgsGeometry &poly,
425
416
double pixelValue = block->value ( i, j );
426
417
if ( validPixel ( pixelValue ) )
427
418
{
428
- cellCenterCoords = GEOSCoordSeq_create_r ( geosctxt, 1 , 2 );
429
- GEOSCoordSeq_setX_r ( geosctxt, cellCenterCoords, 0 , cellCenterX );
430
- GEOSCoordSeq_setY_r ( geosctxt, cellCenterCoords, 0 , cellCenterY );
431
- currentCellCenter.reset ( GEOSGeom_createPoint_r ( geosctxt, cellCenterCoords ) );
432
- if ( GEOSPreparedContains_r ( geosctxt, polyGeosPrepared.get (), currentCellCenter.get () ) )
419
+ QgsPoint cellCenter ( cellCenterX, cellCenterY );
420
+ if ( polyEngine->contains ( &cellCenter ) )
433
421
{
434
422
stats.addValue ( pixelValue );
435
423
}
0 commit comments