@@ -422,8 +422,8 @@ struct GDALVectorTranslateOptions
422422 /* ! set to true to prevent overwriting existing dataset */
423423 bool bNoOverwrite = false ;
424424
425- /* ! set to true to prevent if called from "gdal vector convert" */
426- bool bInvokedFromGdalVectorConvert = false ;
425+ /* ! set to true to customize error messages when called from "new" (GDAL 3.11) CLI or Algorithm API */
426+ bool bInvokedFromGdalAlgorithm = false ;
427427};
428428
429429struct TargetLayerInfo
@@ -2636,10 +2636,21 @@ GDALDatasetH GDALVectorTranslate(const char *pszDest, GDALDatasetH hDstDS,
26362636 }
26372637 if (bError)
26382638 {
2639- CPLError (CE_Failure, CPLE_IllegalArg,
2640- " -nln name must be specified combined with "
2641- " a single source layer name,\n or a -sql statement, and "
2642- " name must be different from an existing layer." );
2639+ if (psOptions->bInvokedFromGdalAlgorithm )
2640+ {
2641+ CPLError (CE_Failure, CPLE_IllegalArg,
2642+ " --output-layer name must be specified combined with "
2643+ " a single source layer name and it "
2644+ " must be different from an existing layer." );
2645+ }
2646+ else
2647+ {
2648+ CPLError (
2649+ CE_Failure, CPLE_IllegalArg,
2650+ " -nln name must be specified combined with "
2651+ " a single source layer name,\n or a -sql statement, and "
2652+ " name must be different from an existing layer." );
2653+ }
26432654 return nullptr ;
26442655 }
26452656 }
@@ -2753,7 +2764,7 @@ GDALDatasetH GDALVectorTranslate(const char *pszDest, GDALDatasetH hDstDS,
27532764 if (aoDrivers.empty ())
27542765 {
27552766 if (CPLGetExtensionSafe (pszDest).empty () &&
2756- !psOptions->bInvokedFromGdalVectorConvert )
2767+ !psOptions->bInvokedFromGdalAlgorithm )
27572768 {
27582769 psOptions->osFormat = " ESRI Shapefile" ;
27592770 }
@@ -2902,7 +2913,7 @@ GDALDatasetH GDALVectorTranslate(const char *pszDest, GDALDatasetH hDstDS,
29022913 }
29032914 bNewDataSource = true ;
29042915
2905- if (psOptions->bInvokedFromGdalVectorConvert && !bSingleLayer &&
2916+ if (psOptions->bInvokedFromGdalAlgorithm && !bSingleLayer &&
29062917 !bOutputDirectory &&
29072918 (!poODS->TestCapability (ODsCCreateLayer) ||
29082919 !poDriver->GetMetadataItem (GDAL_DCAP_MULTIPLE_VECTOR_LAYERS)))
@@ -3198,7 +3209,7 @@ GDALDatasetH GDALVectorTranslate(const char *pszDest, GDALDatasetH hDstDS,
31983209 }
31993210 else if (!poResultSet->TestCapability (OLCFastFeatureCount))
32003211 {
3201- if (!psOptions->bInvokedFromGdalVectorConvert )
3212+ if (!psOptions->bInvokedFromGdalAlgorithm )
32023213 {
32033214 CPLError (
32043215 CE_Warning, CPLE_AppDefined,
@@ -3488,7 +3499,7 @@ GDALDatasetH GDALVectorTranslate(const char *pszDest, GDALDatasetH hDstDS,
34883499 nullptr , psOptions.get ())) &&
34893500 !psOptions->bSkipFailures )
34903501 {
3491- if (psOptions->bInvokedFromGdalVectorConvert )
3502+ if (psOptions->bInvokedFromGdalAlgorithm )
34923503 {
34933504 CPLError (
34943505 CE_Failure, CPLE_AppDefined,
@@ -3664,7 +3675,7 @@ GDALDatasetH GDALVectorTranslate(const char *pszDest, GDALDatasetH hDstDS,
36643675 {
36653676 if (!poLayer->TestCapability (OLCFastFeatureCount))
36663677 {
3667- if (!psOptions->bInvokedFromGdalVectorConvert )
3678+ if (!psOptions->bInvokedFromGdalAlgorithm )
36683679 {
36693680 CPLError (
36703681 CE_Warning, CPLE_NotSupported,
@@ -3773,7 +3784,7 @@ GDALDatasetH GDALVectorTranslate(const char *pszDest, GDALDatasetH hDstDS,
37733784 pProgressArg.get (), psOptions.get ())) &&
37743785 !psOptions->bSkipFailures )
37753786 {
3776- if (psOptions->bInvokedFromGdalVectorConvert )
3787+ if (psOptions->bInvokedFromGdalAlgorithm )
37773788 {
37783789 CPLError (CE_Failure, CPLE_AppDefined,
37793790 " Failed to write layer '%s'. Use --skip-errors to "
@@ -5228,7 +5239,7 @@ SetupTargetLayer::Setup(OGRLayer *poSrcLayer, const char *pszNewLayerName,
52285239 /* -------------------------------------------------------------------- */
52295240 else if (!bAppend && !m_bNewDataSource)
52305241 {
5231- if (psOptions->bInvokedFromGdalVectorConvert )
5242+ if (psOptions->bInvokedFromGdalAlgorithm )
52325243 {
52335244 CPLError (CE_Failure, CPLE_AppDefined,
52345245 " Layer %s already exists, and --append not specified. "
@@ -8460,9 +8471,9 @@ static std::unique_ptr<GDALArgumentParser> GDALVectorTranslateOptionsGetParser(
84608471 .store_into (psOptions->bNoOverwrite )
84618472 .hidden ();
84628473
8463- // Undocumented option used by gdal vector convert
8464- argParser->add_argument (" --invoked-from-gdal-vector-convert " )
8465- .store_into (psOptions->bInvokedFromGdalVectorConvert )
8474+ // Undocumented option used by gdal vector * algorithms
8475+ argParser->add_argument (" --invoked-from-gdal-algorithm " )
8476+ .store_into (psOptions->bInvokedFromGdalAlgorithm )
84668477 .hidden ();
84678478
84688479 if (psOptionsForBinary)
0 commit comments