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

Function GDALDatasetGetBestOverviewLevel

gcore/rasterio.cpp:4863–4937  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4861/************************************************************************/
4862
4863static int GDALDatasetGetBestOverviewLevel(GDALDataset *poDS, int &nXOff,
4864 int &nYOff, int &nXSize, int &nYSize,
4865 int nBufXSize, int nBufYSize,
4866 int nBandCount,
4867 const int *panBandMap,
4868 GDALRasterIOExtraArg *psExtraArg)
4869{
4870 int nOverviewCount = 0;
4871 GDALRasterBand *poFirstBand = nullptr;
4872
4873 /* -------------------------------------------------------------------- */
4874 /* Check that all bands have the same number of overviews and */
4875 /* that they have all the same size and block dimensions */
4876 /* -------------------------------------------------------------------- */
4877 for (int iBand = 0; iBand < nBandCount; iBand++)
4878 {
4879 GDALRasterBand *poBand = poDS->GetRasterBand(panBandMap[iBand]);
4880 if (poBand == nullptr)
4881 return -1;
4882 if (iBand == 0)
4883 {
4884 poFirstBand = poBand;
4885 nOverviewCount = poBand->GetOverviewCount();
4886 }
4887 else if (nOverviewCount != poBand->GetOverviewCount())
4888 {
4889 CPLDebug("GDAL", "GDALDataset::GetBestOverviewLevel() ... "
4890 "mismatched overview count, use std method.");
4891 return -1;
4892 }
4893 else
4894 {
4895 for (int iOverview = 0; iOverview < nOverviewCount; iOverview++)
4896 {
4897 GDALRasterBand *poOvrBand = poBand->GetOverview(iOverview);
4898 GDALRasterBand *poOvrFirstBand =
4899 poFirstBand->GetOverview(iOverview);
4900 if (poOvrBand == nullptr || poOvrFirstBand == nullptr)
4901 continue;
4902
4903 if (poOvrFirstBand->GetXSize() != poOvrBand->GetXSize() ||
4904 poOvrFirstBand->GetYSize() != poOvrBand->GetYSize())
4905 {
4906 CPLDebug("GDAL",
4907 "GDALDataset::GetBestOverviewLevel() ... "
4908 "mismatched overview sizes, use std method.");
4909 return -1;
4910 }
4911 int nBlockXSizeFirst = 0;
4912 int nBlockYSizeFirst = 0;
4913 poOvrFirstBand->GetBlockSize(&nBlockXSizeFirst,
4914 &nBlockYSizeFirst);
4915
4916 int nBlockXSizeCurrent = 0;
4917 int nBlockYSizeCurrent = 0;
4918 poOvrBand->GetBlockSize(&nBlockXSizeCurrent,
4919 &nBlockYSizeCurrent);
4920

Callers 1

BlockBasedRasterIOMethod · 0.85

Calls 8

CPLDebugFunction · 0.85
GetRasterBandMethod · 0.45
GetOverviewCountMethod · 0.45
GetOverviewMethod · 0.45
GetXSizeMethod · 0.45
GetYSizeMethod · 0.45
GetBlockSizeMethod · 0.45

Tested by

no test coverage detected