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

Method GDALMDArrayFromDataset

gcore/gdaldataset.cpp:11863–12156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11861
11862 protected:
11863 GDALMDArrayFromDataset(GDALDataset *poDS, CSLConstList papszOptions)
11864 : GDALAbstractMDArray(std::string(),
11865 std::string(poDS->GetDescription())),
11866 GDALMDArray(std::string(), std::string(poDS->GetDescription())),
11867 m_poDS(poDS), m_dt(GDALExtendedDataType::Create(
11868 poDS->GetRasterBand(1)->GetRasterDataType())),
11869 m_osFilename(poDS->GetDescription()), m_aosOptions(papszOptions)
11870 {
11871 m_poDS->Reference();
11872
11873 const int nBandCount = poDS->GetRasterCount();
11874 for (int i = 1; i <= nBandCount; ++i)
11875 {
11876 const auto poBand = poDS->GetRasterBand(i);
11877 if (i == 1)
11878 m_osUnit = poBand->GetUnitType();
11879 else if (m_osUnit != poBand->GetUnitType())
11880 m_osUnit.clear();
11881
11882 std::vector<GByte> abyNoData;
11883 int bHasNoData = false;
11884 switch (poBand->GetRasterDataType())
11885 {
11886 case GDT_Int64:
11887 {
11888 const auto nNoData =
11889 poBand->GetNoDataValueAsInt64(&bHasNoData);
11890 if (bHasNoData)
11891 {
11892 abyNoData.resize(m_dt.GetSize());
11893 GDALCopyWords64(&nNoData, GDT_Int64, 0, &abyNoData[0],
11894 m_dt.GetNumericDataType(), 0, 1);
11895 }
11896 break;
11897 }
11898
11899 case GDT_UInt64:
11900 {
11901 const auto nNoData =
11902 poBand->GetNoDataValueAsUInt64(&bHasNoData);
11903 if (bHasNoData)
11904 {
11905 abyNoData.resize(m_dt.GetSize());
11906 GDALCopyWords64(&nNoData, GDT_UInt64, 0, &abyNoData[0],
11907 m_dt.GetNumericDataType(), 0, 1);
11908 }
11909 break;
11910 }
11911
11912 default:
11913 {
11914 const auto dfNoData = poBand->GetNoDataValue(&bHasNoData);
11915 if (bHasNoData)
11916 {
11917 abyNoData.resize(m_dt.GetSize());
11918 GDALCopyWords64(&dfNoData, GDT_Float64, 0,
11919 &abyNoData[0],
11920 m_dt.GetNumericDataType(), 0, 1);

Callers

nothing calls this directly

Calls 15

moveFunction · 0.85
CSLFetchNameValueDefFunction · 0.85
CPLSPrintfFunction · 0.85
CPLAtofFunction · 0.85
GetAxesCountMethod · 0.80
GetAxisMethod · 0.80
maxFunction · 0.70
EQUALFunction · 0.50
CPL_IGNORE_RET_VALFunction · 0.50
GetDescriptionMethod · 0.45
GetRasterDataTypeMethod · 0.45

Tested by

no test coverage detected