| 6219 | /************************************************************************/ |
| 6220 | |
| 6221 | bool GDALAlgorithm::Run(GDALProgressFunc pfnProgress, void *pProgressData) |
| 6222 | { |
| 6223 | WarnIfDeprecated(); |
| 6224 | |
| 6225 | if (m_selectedSubAlg) |
| 6226 | { |
| 6227 | if (m_calledFromCommandLine) |
| 6228 | m_selectedSubAlg->m_calledFromCommandLine = true; |
| 6229 | return m_selectedSubAlg->Run(pfnProgress, pProgressData); |
| 6230 | } |
| 6231 | |
| 6232 | if (m_helpRequested || m_helpDocRequested) |
| 6233 | { |
| 6234 | if (m_calledFromCommandLine) |
| 6235 | printf("%s", GetUsageForCLI(false).c_str()); /*ok*/ |
| 6236 | return true; |
| 6237 | } |
| 6238 | |
| 6239 | if (m_JSONUsageRequested) |
| 6240 | { |
| 6241 | if (m_calledFromCommandLine) |
| 6242 | printf("%s", GetUsageAsJSON().c_str()); /*ok*/ |
| 6243 | return true; |
| 6244 | } |
| 6245 | |
| 6246 | if (!ValidateArguments()) |
| 6247 | return false; |
| 6248 | |
| 6249 | if (m_alreadyRun) |
| 6250 | { |
| 6251 | ReportError(CE_Failure, CPLE_AppDefined, |
| 6252 | "Run() can be called only once per algorithm instance"); |
| 6253 | return false; |
| 6254 | } |
| 6255 | m_alreadyRun = true; |
| 6256 | |
| 6257 | switch (ProcessGDALGOutput()) |
| 6258 | { |
| 6259 | case ProcessGDALGOutputRet::GDALG_ERROR: |
| 6260 | return false; |
| 6261 | |
| 6262 | case ProcessGDALGOutputRet::GDALG_OK: |
| 6263 | return true; |
| 6264 | |
| 6265 | case ProcessGDALGOutputRet::NOT_GDALG: |
| 6266 | break; |
| 6267 | } |
| 6268 | |
| 6269 | if (m_executionForStreamOutput) |
| 6270 | { |
| 6271 | if (!CheckSafeForStreamOutput()) |
| 6272 | { |
| 6273 | return false; |
| 6274 | } |
| 6275 | } |
| 6276 | |
| 6277 | return RunImpl(pfnProgress, pProgressData); |
| 6278 | } |