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

Method RunStep

apps/gdalalg_materialize.cpp:59–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57/************************************************************************/
58
59bool GDALMaterializeRasterAlgorithm::RunStep(GDALPipelineStepRunContext &ctxt)
60{
61 auto pfnProgress = ctxt.m_pfnProgress;
62 auto pProgressData = ctxt.m_pProgressData;
63
64 auto poSrcDS = m_inputDataset[0].GetDatasetRef();
65 CPLAssert(poSrcDS);
66 CPLAssert(!m_outputDataset.GetDatasetRef());
67
68 std::string filename = m_outputDataset.GetName();
69 if (m_format.empty())
70 {
71 if (filename.empty())
72 {
73 m_format = "GTiff";
74 }
75 else
76 {
77 const auto aosFormats =
78 CPLStringList(GDALGetOutputDriversForDatasetName(
79 filename.c_str(), GDAL_OF_RASTER,
80 /* bSingleMatch = */ true,
81 /* bWarn = */ true));
82 if (aosFormats.size() != 1)
83 {
84 ReportError(CE_Failure, CPLE_AppDefined,
85 "Cannot guess driver for %s", filename.c_str());
86 return false;
87 }
88 m_format = aosFormats[0];
89 }
90 }
91
92 auto poDrv = GetGDALDriverManager()->GetDriverByName(m_format.c_str());
93 if (!poDrv)
94 {
95 ReportError(CE_Failure, CPLE_AppDefined, "Driver %s does not exist",
96 m_format.c_str());
97 return false;
98 }
99
100 const bool autoDeleteFile = !m_reopenAndDoNotEarlyDelete &&
101 filename.empty() &&
102 !EQUAL(m_format.c_str(), "MEM");
103 if (filename.empty() && !EQUAL(m_format.c_str(), "MEM"))
104 {
105 filename = CPLGenerateTempFilenameSafe(nullptr);
106
107 const char *pszExt = poDrv->GetMetadataItem(GDAL_DMD_EXTENSIONS);
108 if (pszExt)
109 {
110 filename += '.';
111 filename += CPLStringList(CSLTokenizeString(pszExt))[0];
112 }
113 }
114
115 CPLStringList aosOptions(m_creationOptions);
116 if (EQUAL(m_format.c_str(), "GTiff"))

Callers

nothing calls this directly

Calls 15

GetGDALDriverManagerFunction · 0.85
CSLTokenizeStringFunction · 0.85
moveFunction · 0.85
GDALVectorTranslateFunction · 0.85
FetchNameValueMethod · 0.80
SetNameValueMethod · 0.80
ListMethod · 0.80

Tested by

no test coverage detected