| 302 | /************************************************************************/ |
| 303 | |
| 304 | static CPLErr ProcessLayer(OGRLayer *poSrcLayer, GDALDataset *poDstDS, |
| 305 | const OGRGeometry *poClipSrc, int nXSize, int nYSize, |
| 306 | int nBand, bool &bIsXExtentSet, bool &bIsYExtentSet, |
| 307 | double &dfXMin, double &dfXMax, double &dfYMin, |
| 308 | double &dfYMax, const std::string &osBurnAttribute, |
| 309 | const double dfIncreaseBurnValue, |
| 310 | const double dfMultiplyBurnValue, GDALDataType eType, |
| 311 | GDALGridAlgorithm eAlgorithm, void *pOptions, |
| 312 | bool bQuiet, GDALProgressFunc pfnProgress, |
| 313 | void *pProgressData) |
| 314 | |
| 315 | { |
| 316 | /* -------------------------------------------------------------------- */ |
| 317 | /* Get field index, and check. */ |
| 318 | /* -------------------------------------------------------------------- */ |
| 319 | int iBurnField = -1; |
| 320 | |
| 321 | if (!osBurnAttribute.empty()) |
| 322 | { |
| 323 | iBurnField = |
| 324 | poSrcLayer->GetLayerDefn()->GetFieldIndex(osBurnAttribute.c_str()); |
| 325 | if (iBurnField == -1) |
| 326 | { |
| 327 | printf("Failed to find field %s on layer %s, skipping.\n", |
| 328 | osBurnAttribute.c_str(), poSrcLayer->GetName()); |
| 329 | return CE_Failure; |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | /* -------------------------------------------------------------------- */ |
| 334 | /* Collect the geometries from this layer, and build list of */ |
| 335 | /* values to be interpolated. */ |
| 336 | /* -------------------------------------------------------------------- */ |
| 337 | GDALGridGeometryVisitor oVisitor; |
| 338 | oVisitor.poClipSrc = poClipSrc; |
| 339 | oVisitor.iBurnField = iBurnField; |
| 340 | oVisitor.dfIncreaseBurnValue = dfIncreaseBurnValue; |
| 341 | oVisitor.dfMultiplyBurnValue = dfMultiplyBurnValue; |
| 342 | |
| 343 | for (auto &&poFeat : poSrcLayer) |
| 344 | { |
| 345 | const OGRGeometry *poGeom = poFeat->GetGeometryRef(); |
| 346 | if (poGeom) |
| 347 | { |
| 348 | if (iBurnField >= 0) |
| 349 | { |
| 350 | if (!poFeat->IsFieldSetAndNotNull(iBurnField)) |
| 351 | { |
| 352 | continue; |
| 353 | } |
| 354 | oVisitor.dfBurnValue = poFeat->GetFieldAsDouble(iBurnField); |
| 355 | } |
| 356 | |
| 357 | poGeom->accept(&oVisitor); |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | if (oVisitor.adfX.empty()) |
no test coverage detected