| 1336 | |
| 1337 | #ifndef HAVE_GEOS |
| 1338 | bool ProcessVectorZonesByChunk(GDALProgressFunc, void *) |
| 1339 | { |
| 1340 | CPLError(CE_Failure, CPLE_AppDefined, |
| 1341 | "The GEOS library is required to iterate over blocks of the " |
| 1342 | "input rasters. Processing can be performed by iterating over " |
| 1343 | "the input features instead."); |
| 1344 | return false; |
| 1345 | #else |
| 1346 | bool ProcessVectorZonesByChunk(GDALProgressFunc pfnProgress, |
| 1347 | void *pProgressData) |
| 1348 | { |
| 1349 | if (!Init()) |
| 1350 | { |
| 1351 | return false; |
| 1352 | } |
| 1353 | |
| 1354 | std::unique_ptr<GDALDataset> poAlignedWeightsDS; |
| 1355 | // Align the weighting dataset to the values. |
| 1356 | if (m_weights) |
| 1357 | { |
| 1358 | bool resampled = false; |
| 1359 | poAlignedWeightsDS = GetVRT(*m_weights, m_src, resampled); |
| 1360 | if (!poAlignedWeightsDS) |
| 1361 | { |
| 1362 | return false; |
| 1363 | } |
| 1364 | if (resampled) |
| 1365 | { |
| 1366 | CPLError(CE_Warning, CPLE_AppDefined, |
| 1367 | "Resampled weights to match source raster using " |
| 1368 | "average resampling."); |
| 1369 | } |
| 1370 | } |
| 1371 | |
| 1372 | auto TreeDeleter = [this](GEOSSTRtree *tree) |
| 1373 | { GEOSSTRtree_destroy_r(m_geosContext, tree); }; |
| 1374 | |
| 1375 | std::unique_ptr<GEOSSTRtree, decltype(TreeDeleter)> tree( |
| 1376 | GEOSSTRtree_create_r(m_geosContext, 10), TreeDeleter); |
| 1377 | |
| 1378 | std::vector<std::unique_ptr<OGRFeature>> features; |
| 1379 | std::map<int, std::vector<gdal::RasterStats<double>>> statsMap; |
| 1380 | |
| 1381 | // Construct spatial index of all input features, storing the index |
| 1382 | // of the feature. |
| 1383 | { |
| 1384 | OGREnvelope oGeomExtent; |
| 1385 | for (auto &poFeatureIn : *std::get<OGRLayer *>(m_zones)) |
| 1386 | { |
| 1387 | features.emplace_back(poFeatureIn.release()); |
| 1388 | |
| 1389 | const OGRGeometry *poGeom = features.back()->GetGeometryRef(); |
| 1390 | |
| 1391 | if (poGeom == nullptr || poGeom->IsEmpty()) |
| 1392 | { |
| 1393 | continue; |
| 1394 | } |
| 1395 |
no test coverage detected