Skip to content

Commit 43d8567

Browse files
committed
Avoid use of raw GEOS API
1 parent 1631a82 commit 43d8567

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

src/analysis/vector/qgszonalstatistics.cpp

+5-17
Original file line numberDiff line numberDiff line change
@@ -397,21 +397,12 @@ void QgsZonalStatistics::statisticsFromMiddlePointTest( const QgsGeometry &poly,
397397
cellCenterY = rasterBBox.yMaximum() - pixelOffsetY * cellSizeY - cellSizeY / 2;
398398
stats.reset();
399399

400-
geos::unique_ptr polyGeos( QgsGeos::asGeos( poly ) );
401-
if ( !polyGeos )
400+
std::unique_ptr< QgsGeometryEngine > polyEngine( QgsGeometry::createGeometryEngine( poly.constGet( ) ) );
401+
if ( !polyEngine )
402402
{
403403
return;
404404
}
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();
415406

416407
QgsRectangle featureBBox = poly.boundingBox().intersect( &rasterBBox );
417408
QgsRectangle intersectBBox = rasterBBox.intersect( &featureBBox );
@@ -425,11 +416,8 @@ void QgsZonalStatistics::statisticsFromMiddlePointTest( const QgsGeometry &poly,
425416
double pixelValue = block->value( i, j );
426417
if ( validPixel( pixelValue ) )
427418
{
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 ) )
433421
{
434422
stats.addValue( pixelValue );
435423
}

0 commit comments

Comments
 (0)