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

Function Init

alg/zonal.cpp:343–575  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

341
342 private:
343 bool Init()
344 {
345#if !(GEOS_GRID_INTERSECTION_AVAILABLE)
346 if (m_options.pixels == GDALZonalStatsOptions::FRACTIONAL)
347 {
348 CPLError(CE_Failure, CPLE_AppDefined,
349 "Fractional pixel coverage calculation requires a GDAL "
350 "build against GEOS >= 3.14");
351 return false;
352 }
353#endif
354
355 if (m_options.bands.empty())
356 {
357 const int nBands = m_src.GetRasterCount();
358 if (nBands == 0)
359 {
360 CPLError(CE_Failure, CPLE_AppDefined,
361 "GDALRasterZonalStats: input dataset has no bands");
362 return false;
363 }
364 m_options.bands.resize(nBands);
365 for (int i = 0; i < nBands; i++)
366 {
367 m_options.bands[i] = i + 1;
368 }
369 }
370 else
371 {
372 for (int nBand : m_options.bands)
373 {
374 if (nBand <= 0 || nBand > m_src.GetRasterCount())
375 {
376 CPLError(CE_Failure, CPLE_AppDefined,
377 "GDALRasterZonalStats: Invalid band number: %d",
378 nBand);
379 return false;
380 }
381 }
382 }
383
384 {
385 const auto eSrcType = m_src.GetRasterBand(m_options.bands.front())
386 ->GetRasterDataType();
387 if (GDALDataTypeIsConversionLossy(eSrcType, m_workingDataType))
388 {
389 CPLError(CE_Failure, CPLE_AppDefined,
390 "GDALRasterZonalStats: Source data type %s is not "
391 "supported",
392 GDALGetDataTypeName(eSrcType));
393 return false;
394 }
395 }
396
397 if (m_weights)
398 {
399 if (m_options.weights_band > m_weights->GetRasterCount())
400 {

Callers 15

OGRMVTLayerMethod · 0.85
OpenMethod · 0.85
ResetReadingMethod · 0.85
SetNextByIndexMethod · 0.85
GetFeatureCountMethod · 0.85
DeleteFieldMethod · 0.85
ReorderFieldsMethod · 0.85
AlterFieldDefnMethod · 0.85
GetNextFeatureMethod · 0.85
CreateFieldMethod · 0.85
GetFeatureMethod · 0.85
ISetFeatureMethod · 0.85

Calls 15

CPLErrorFunction · 0.85
GetStatFunction · 0.85
IsWeightedFunction · 0.85
ZonesAreFeatureFunction · 0.85
frontMethod · 0.80
ListMethod · 0.80
emptyMethod · 0.45
GetRasterCountMethod · 0.45
resizeMethod · 0.45
GetRasterDataTypeMethod · 0.45
GetRasterBandMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected