| 3497 | */ |
| 3498 | |
| 3499 | GDALDatasetH GDALDEMProcessing(const char *pszDest, GDALDatasetH hSrcDataset, |
| 3500 | const char *pszProcessing, |
| 3501 | const char *pszColorFilename, |
| 3502 | const GDALDEMProcessingOptions *psOptionsIn, |
| 3503 | int *pbUsageError) |
| 3504 | { |
| 3505 | if (hSrcDataset == nullptr) |
| 3506 | { |
| 3507 | CPLError(CE_Failure, CPLE_AppDefined, "No source dataset specified."); |
| 3508 | |
| 3509 | if (pbUsageError) |
| 3510 | *pbUsageError = TRUE; |
| 3511 | return nullptr; |
| 3512 | } |
| 3513 | if (pszDest == nullptr) |
| 3514 | { |
| 3515 | CPLError(CE_Failure, CPLE_AppDefined, "No target dataset specified."); |
| 3516 | |
| 3517 | if (pbUsageError) |
| 3518 | *pbUsageError = TRUE; |
| 3519 | return nullptr; |
| 3520 | } |
| 3521 | if (pszProcessing == nullptr) |
| 3522 | { |
| 3523 | CPLError(CE_Failure, CPLE_AppDefined, "No target dataset specified."); |
| 3524 | |
| 3525 | if (pbUsageError) |
| 3526 | *pbUsageError = TRUE; |
| 3527 | return nullptr; |
| 3528 | } |
| 3529 | |
| 3530 | Algorithm eUtilityMode = GetAlgorithm(pszProcessing); |
| 3531 | if (eUtilityMode == INVALID) |
| 3532 | { |
| 3533 | CPLError(CE_Failure, CPLE_IllegalArg, "Invalid processing mode: %s", |
| 3534 | pszProcessing); |
| 3535 | if (pbUsageError) |
| 3536 | *pbUsageError = TRUE; |
| 3537 | return nullptr; |
| 3538 | } |
| 3539 | |
| 3540 | if (eUtilityMode == COLOR_RELIEF && |
| 3541 | (pszColorFilename == nullptr || strlen(pszColorFilename) == 0)) |
| 3542 | { |
| 3543 | CPLError(CE_Failure, CPLE_AppDefined, "pszColorFilename == NULL."); |
| 3544 | |
| 3545 | if (pbUsageError) |
| 3546 | *pbUsageError = TRUE; |
| 3547 | return nullptr; |
| 3548 | } |
| 3549 | else if (eUtilityMode != COLOR_RELIEF && pszColorFilename != nullptr && |
| 3550 | strlen(pszColorFilename) > 0) |
| 3551 | { |
| 3552 | CPLError(CE_Failure, CPLE_AppDefined, "pszColorFilename != NULL."); |
| 3553 | |
| 3554 | if (pbUsageError) |
| 3555 | *pbUsageError = TRUE; |
| 3556 | return nullptr; |