MCPcopy Create free account
hub / github.com/OSGeo/gdal / ProcessLayer

Function ProcessLayer

apps/gdal_grid_lib.cpp:304–521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

302/************************************************************************/
303
304static 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())

Callers 3

GDALGridFunction · 0.70
DefaultApplyMethod · 0.50

Calls 15

CPLprintfFunction · 0.85
PrintAlgorithmAndOptionsFunction · 0.85
CPLDebugFunction · 0.85
VSIMalloc3Function · 0.85
CPLErrorFunction · 0.85
DIV_ROUND_UPFunction · 0.85
GDALGridContextCreateFunction · 0.85
GDALGridContextProcessFunction · 0.85
IsFieldSetAndNotNullMethod · 0.80
swapFunction · 0.50
emptyMethod · 0.45
GetFieldIndexMethod · 0.45

Tested by

no test coverage detected