diff --git a/apps/dumpoverviews.cpp b/apps/dumpoverviews.cpp index 702ca65dfcfc..457febbcd7fb 100644 --- a/apps/dumpoverviews.cpp +++ b/apps/dumpoverviews.cpp @@ -41,7 +41,7 @@ static bool DumpBand(GDALDatasetH hBaseDS, GDALRasterBandH hBand, static void Usage() { - printf("Usage: dumpoverviews [-masks] [overview]*\n"); + printf("Usage: dumpoverviews [-masks] []...\n"); exit(1); } diff --git a/apps/gdal_contour.cpp b/apps/gdal_contour.cpp index b0b2f5e10b24..88f61e0c3a17 100644 --- a/apps/gdal_contour.cpp +++ b/apps/gdal_contour.cpp @@ -51,17 +51,18 @@ static bool ArgIsNumeric(const char *pszArg) /* Usage() */ /************************************************************************/ -static void Usage(const char *pszErrorMsg = nullptr) +static void Usage(bool bIsError, const char *pszErrorMsg = nullptr) { - printf( + fprintf( + bIsError ? stderr : stdout, "Usage: gdal_contour [--help] [--help-general]\n" " [-b ] [-a ] [-amin " "] [-amax ]\n" - " [-3d] [-inodata] [-snodata n] [-f ] " + " [-3d] [-inodata] [-snodata ] [-f ] " "[-i ]\n" - " [[-dsco ] ...] [[-lco ] " - "...]\n" + " [-dsco =]... " + "[-lco =]...\n" " [-off ] [-fl ...] [-e " "]\n" " [-nln ] [-q] [-p]\n" @@ -70,7 +71,7 @@ static void Usage(const char *pszErrorMsg = nullptr) if (pszErrorMsg != nullptr) fprintf(stderr, "\nFAILURE: %s\n", pszErrorMsg); - exit(1); + exit(bIsError ? 1 : 0); } static void CreateElevAttrib(const char *pszElevAttrib, OGRLayerH hLayer) @@ -92,8 +93,8 @@ static void CreateElevAttrib(const char *pszElevAttrib, OGRLayerH hLayer) do \ { \ if (i + nExtraArg >= argc) \ - Usage(CPLSPrintf("%s option requires %d argument(s)", argv[i], \ - nExtraArg)); \ + Usage(true, CPLSPrintf("%s option requires %d argument(s)", \ + argv[i], nExtraArg)); \ } while (false) MAIN_START(argc, argv) @@ -152,7 +153,7 @@ MAIN_START(argc, argv) return 0; } else if (EQUAL(argv[i], "--help")) - Usage(); + Usage(false); else if (EQUAL(argv[i], "-a")) { CHECK_HAS_ENOUGH_ADDITIONAL_ARGS(1); @@ -196,8 +197,8 @@ MAIN_START(argc, argv) else if (EQUAL(argv[i], "-fl")) { if (i >= argc - 1) - Usage(CPLSPrintf("%s option requires at least 1 argument", - argv[i])); + Usage(true, CPLSPrintf("%s option requires at least 1 argument", + argv[i])); while (i < argc - 1 && nFixedLevelCount < static_cast(sizeof(adfFixedLevels) / sizeof(double)) && @@ -263,22 +264,22 @@ MAIN_START(argc, argv) pszDstFilename = argv[i]; } else - Usage("Too many command options."); + Usage(true, "Too many command options."); } if (dfInterval == 0.0 && nFixedLevelCount == 0 && dfExpBase == 0.0) { - Usage("Neither -i nor -fl nor -e are specified."); + Usage(true, "Neither -i nor -fl nor -e are specified."); } if (pszSrcFilename == nullptr) { - Usage("Missing source filename."); + Usage(true, "Missing source filename."); } if (pszDstFilename == nullptr) { - Usage("Missing destination filename."); + Usage(true, "Missing destination filename."); } if (strcmp(pszDstFilename, "/vsistdout/") == 0 || diff --git a/apps/gdal_create.cpp b/apps/gdal_create.cpp index c638e1c087aa..14741757b5aa 100644 --- a/apps/gdal_create.cpp +++ b/apps/gdal_create.cpp @@ -37,26 +37,27 @@ #include #include -static void Usage() +static void Usage(bool bIsError) { - printf( + fprintf( + bIsError ? stderr : stdout, "Usage: gdal_create [--help] [--help-general]\n" " [-of ]\n" - " [-outsize ]\n" + " [-outsize ]\n" " [-bands ]\n" - " [-burn ]*\n" + " [-burn ]...\n" " [-ot " "{Byte/Int8/Int16/UInt16/UInt32/Int32/UInt64/Int64/Float32/Float64/\n" " CInt16/CInt32/CFloat32/CFloat64}] [-strict]\n" " [-a_srs ] [-a_ullr ] " "[-a_nodata ]\n" - " [-mo \"META-TAG=VALUE\"]* [-q]\n" - " [-co \"NAME=VALUE\"]*\n" + " [-mo =]... [-q]\n" + " [-co =]...\n" " [-if ]\n" " \n"); - exit(1); + exit(bIsError ? 1 : 0); } /************************************************************************/ @@ -124,7 +125,7 @@ MAIN_START(argc, argv) } else if (EQUAL(argv[i], "--help")) { - Usage(); + Usage(false); } else if (i < argc - 1 && (EQUAL(argv[i], "-of") || EQUAL(argv[i], "-f"))) @@ -237,7 +238,7 @@ MAIN_START(argc, argv) CPLError(CE_Failure, CPLE_NotSupported, "Unknown option name '%s'", argv[i]); CSLDestroy(argv); - Usage(); + Usage(true); } else if (pszFilename == nullptr) { @@ -248,13 +249,13 @@ MAIN_START(argc, argv) CPLError(CE_Failure, CPLE_NotSupported, "Too many command options '%s'", argv[i]); CSLDestroy(argv); - Usage(); + Usage(true); } } if (pszFilename == nullptr) { CSLDestroy(argv); - Usage(); + Usage(true); } double adfGeoTransform[6] = {0, 1, 0, 0, 0, 1}; diff --git a/apps/gdal_footprint_bin.cpp b/apps/gdal_footprint_bin.cpp index 3845ac3af40b..343465ed0f3d 100644 --- a/apps/gdal_footprint_bin.cpp +++ b/apps/gdal_footprint_bin.cpp @@ -37,23 +37,25 @@ /* Usage() */ /************************************************************************/ -static void Usage(const char *pszErrorMsg = nullptr) +static void Usage(bool bIsError, const char *pszErrorMsg = nullptr) { - printf("Usage: gdal_footprint [--help] [--help-general]\n" - " [-b band]* [-combine_bands union|intersection]\n" - " [-oo NAME=VALUE]* [-ovr ]\n" - " [-srcnodata \"value [value...]\"]\n" - " [-t_cs pixel|georef] [-t_srs ] [-split_polys]\n" - " [-convex_hull] [-densify ] [-simplify ]\n" - " [-min_ring_area ] [-max_points |unlimited]\n" - " [-of ogr_format] [-lyr_name dst_layername]\n" - " [-dsco name=value]* [-lco name=value]* [-overwrite] [-q]\n" - " \n"); + fprintf(bIsError ? stderr : stdout, + "Usage: gdal_footprint [--help] [--help-general]\n" + " [-b ]... [-combine_bands union|intersection]\n" + " [-oo =]... [-ovr ]\n" + " [-srcnodata \"[ ]...\"]\n" + " [-t_cs pixel|georef] [-t_srs ] [-split_polys]\n" + " [-convex_hull] [-densify ] [-simplify ]\n" + " [-min_ring_area ] [-max_points |unlimited]\n" + " [-of ] [-lyr_name ]\n" + " [-dsco =]... [-lco =]... " + "[-overwrite] [-q]\n" + " \n"); if (pszErrorMsg != nullptr) fprintf(stderr, "\nFAILURE: %s\n", pszErrorMsg); - exit(1); + exit(bIsError ? 1 : 0); } /************************************************************************/ @@ -88,7 +90,7 @@ MAIN_START(argc, argv) } else if (EQUAL(argv[i], "--help")) { - Usage(); + Usage(false); } } @@ -100,7 +102,7 @@ MAIN_START(argc, argv) if (psOptions == nullptr) { - Usage(); + Usage(true); } if (!(sOptionsForBinary.bQuiet)) @@ -109,10 +111,10 @@ MAIN_START(argc, argv) } if (sOptionsForBinary.osSource.empty()) - Usage("No input file specified."); + Usage(true, "No input file specified."); if (!sOptionsForBinary.bDestSpecified) - Usage("No output file specified."); + Usage(true, "No output file specified."); /* -------------------------------------------------------------------- */ /* Open input file. */ @@ -218,7 +220,7 @@ MAIN_START(argc, argv) GDALDatasetH hRetDS = GDALFootprint(sOptionsForBinary.osDest.c_str(), hDstDS, hInDS, psOptions, &bUsageError); if (bUsageError == TRUE) - Usage(); + Usage(true); int nRetCode = hRetDS ? 0 : 1; GDALClose(hInDS); diff --git a/apps/gdal_grid_bin.cpp b/apps/gdal_grid_bin.cpp index d2e470d81976..fa685dca9765 100644 --- a/apps/gdal_grid_bin.cpp +++ b/apps/gdal_grid_bin.cpp @@ -35,25 +35,30 @@ /* Usage() */ /************************************************************************/ -static void Usage(const char *pszErrorMsg = nullptr) +static void Usage(bool bIsError, const char *pszErrorMsg = nullptr) { - printf( + fprintf( + bIsError ? stderr : stdout, "Usage: gdal_grid [--help] [--help-general]\n" - " [-oo NAME=VALUE]*\n" + " [-oo =]...\n" " [-ot {Byte/Int16/UInt16/UInt32/Int32/Float32/Float64/\n" " CInt16/CInt32/CFloat32/CFloat64}]\n" - " [-of format] [-co \"NAME=VALUE\"]\n" - " [-zfield field_name] [-z_increase increase_value] [-z_multiply " - "multiply_value]\n" - " [-a_srs srs_def] [-spat xmin ymin xmax ymax]\n" - " [-clipsrc |WKT|datasource|spat_extent]\n" - " [-clipsrcsql sql_statement] [-clipsrclayer layer]\n" - " [-clipsrcwhere expression]\n" - " [-l layername]* [-where expression] [-sql select_statement]\n" - " [-txe xmin xmax] [-tye ymin ymax] [-tr xres yres] [-outsize xsize " - "ysize]\n" - " [-a algorithm[:parameter1=value1]*]" + " [-of ] [-co =]...\n" + " [-zfield ] [-z_increase ] " + "[-z_multiply " + "]\n" + " [-a_srs ] [-spat ]\n" + " [-clipsrc " + "|||spat_extent]\n" + " [-clipsrcsql ] [-clipsrclayer ]\n" + " [-clipsrcwhere ]\n" + " [-l ]... [-where ] [-sql " + "]\n" + " [-txe ] [-tye ] [-tr ] " + "[-outsize " + "]\n" + " [-a [:=]...]" " [-q]\n" " \n" "\n" @@ -88,7 +93,7 @@ static void Usage(const char *pszErrorMsg = nullptr) fprintf(stderr, "\nFAILURE: %s\n", pszErrorMsg); GDALDestroyDriverManager(); - exit(1); + exit(bIsError ? 1 : 0); } /************************************************************************/ @@ -123,7 +128,7 @@ MAIN_START(argc, argv) } else if (EQUAL(argv[i], "--help")) { - Usage(); + Usage(false); } } @@ -135,7 +140,7 @@ MAIN_START(argc, argv) if (psOptions == nullptr) { - Usage(); + Usage(true); } if (!(sOptionsForBinary.bQuiet)) @@ -144,9 +149,9 @@ MAIN_START(argc, argv) } if (sOptionsForBinary.osSource.empty()) - Usage("No input file specified."); + Usage(true, "No input file specified."); if (!sOptionsForBinary.bDestSpecified) - Usage("No output file specified."); + Usage(true, "No output file specified."); /* -------------------------------------------------------------------- */ /* Open input file. */ @@ -163,7 +168,7 @@ MAIN_START(argc, argv) GDALDatasetH hOutDS = GDALGrid(sOptionsForBinary.osDest.c_str(), hInDS, psOptions, &bUsageError); if (bUsageError == TRUE) - Usage(); + Usage(true); int nRetCode = hOutDS ? 0 : 1; GDALClose(hInDS); diff --git a/apps/gdal_rasterize_bin.cpp b/apps/gdal_rasterize_bin.cpp index 144d21072356..797b81d45585 100644 --- a/apps/gdal_rasterize_bin.cpp +++ b/apps/gdal_rasterize_bin.cpp @@ -36,30 +36,33 @@ /* Usage() */ /************************************************************************/ -static void Usage(const char *pszErrorMsg = nullptr) +static void Usage(bool bIsError, const char *pszErrorMsg = nullptr) { - printf( + fprintf( + bIsError ? stderr : stdout, "Usage: gdal_rasterize [--help] [--help-general]\n" - " [-b band]* [-i] [-at]\n" - " [-oo NAME=VALUE]*\n" - " {[-burn value]* | [-a attribute_name] | [-3d]} [-add]\n" - " [-l layername]* [-where expression] " - "[-sql select_statement|@filename]\n" - " [-dialect dialect] [-of format] [-a_srs srs_def] [-to " - "\"NAME=VALUE\"]*\n" - " [-co \"NAME=VALUE\"]* [-a_nodata value] [-init value]*\n" - " [-te xmin ymin xmax ymax] [-tr xres yres] [-tap] [-ts width " - "height]\n" + " [-b ]... [-i] [-at]\n" + " [-oo =]...\n" + " {[-burn ]... | [-a ] | [-3d]} [-add]\n" + " [-l ]... [-where ] " + "[-sql |@]\n" + " [-dialect ] [-of ] [-a_srs ] [-to " + "=]...\n" + " [-co =]... [-a_nodata ] [-init " + "]...\n" + " [-te ] [-tr ] [-tap] " + "[-ts " + "]\n" " [-ot " "{Byte/Int8/Int16/UInt16/UInt32/Int32/UInt64/Int64/Float32/Float64/\n" " CInt16/CInt32/CFloat32/CFloat64}] [-optim " - "{[AUTO]/VECTOR/RASTER}] [-q]\n" + "{AUTO|VECTOR|RASTER}] [-q]\n" " \n"); if (pszErrorMsg != nullptr) fprintf(stderr, "\nFAILURE: %s\n", pszErrorMsg); - exit(1); + exit(bIsError ? 1 : 0); } /************************************************************************/ @@ -94,7 +97,7 @@ MAIN_START(argc, argv) } else if (EQUAL(argv[i], "--help")) { - Usage(); + Usage(false); } } @@ -106,7 +109,7 @@ MAIN_START(argc, argv) if (psOptions == nullptr) { - Usage(); + Usage(true); } if (!(sOptionsForBinary.bQuiet)) @@ -115,10 +118,10 @@ MAIN_START(argc, argv) } if (sOptionsForBinary.osSource.empty()) - Usage("No input file specified."); + Usage(true, "No input file specified."); if (!sOptionsForBinary.bDestSpecified) - Usage("No output file specified."); + Usage(true, "No output file specified."); /* -------------------------------------------------------------------- */ /* Open input file. */ @@ -186,7 +189,7 @@ MAIN_START(argc, argv) GDALDatasetH hRetDS = GDALRasterize(sOptionsForBinary.osDest.c_str(), hDstDS, hInDS, psOptions, &bUsageError); if (bUsageError == TRUE) - Usage(); + Usage(true); int nRetCode = hRetDS ? 0 : 1; GDALClose(hInDS); diff --git a/apps/gdal_translate_bin.cpp b/apps/gdal_translate_bin.cpp index 4ecf5fe26b35..748dcea98e4d 100644 --- a/apps/gdal_translate_bin.cpp +++ b/apps/gdal_translate_bin.cpp @@ -38,38 +38,41 @@ /* Usage() */ /* ******************************************************************** */ -static void Usage(const char *pszErrorMsg = nullptr, - int bShort = TRUE) CPL_NO_RETURN; +static void Usage(bool bIsError, const char *pszErrorMsg = nullptr, + bool bShort = true) CPL_NO_RETURN; -static void Usage(const char *pszErrorMsg, int bShort) +static void Usage(bool bIsError, const char *pszErrorMsg, bool bShort) { - printf( + fprintf( + bIsError ? stderr : stdout, "Usage: gdal_translate [--help] [--help-general] [--long-usage]\n" " [-ot " "{Byte/Int8/Int16/UInt16/UInt32/Int32/UInt64/Int64/Float32/Float64/\n" " CInt16/CInt32/CFloat32/CFloat64}] [-strict]\n" - " [-if format]* [-of format]\n" - " [-b band] [-mask band] [-expand {gray|rgb|rgba}]\n" - " [-outsize xsize[%%]|0 ysize[%%]|0] [-tr xres yres]\n" - " [-ovr level|AUTO|AUTO-n|NONE]\n" + " [-if ]... [-of ]\n" + " [-b ] [-mask ] [-expand {gray|rgb|rgba}]\n" + " [-outsize [%%]|0 [%%]|0] [-tr ]\n" + " [-ovr |AUTO|AUTO-|NONE]\n" " [-r " "{nearest,bilinear,cubic,cubicspline,lanczos,average,mode}]\n" - " [-unscale] [-scale[_bn] [src_min src_max [dst_min dst_max]]]* " - "[-exponent[_bn] exp_val]*\n" - " [-srcwin xoff yoff xsize ysize] [-epo] [-eco]\n" - " [-projwin ulx uly lrx lry] [-projwin_srs srs_def]\n" - " [-a_srs srs_def] [-a_coord_epoch epoch]\n" - " [-a_ullr ulx uly lrx lry] [-a_nodata value]\n" - " [-a_gt gt0 gt1 gt2 gt3 gt4 gt5]\n" - " [-a_scale value] [-a_offset value]\n" - " [-nogcp] [-gcp pixel line easting northing [elevation]]*\n" + " [-unscale] [-scale[_bn] [ [ " + "]]]... " + "[-exponent[_bn] ]...\n" + " [-srcwin ] [-epo] [-eco]\n" + " [-projwin ] [-projwin_srs ]\n" + " [-a_srs ] [-a_coord_epoch ]\n" + " [-a_ullr ] [-a_nodata ]\n" + " [-a_gt ]\n" + " [-a_scale ] [-a_offset ]\n" + " [-nogcp] [-gcp " + "[]]...\n" " |-colorinterp{_bn} {red|green|blue|alpha|gray|undefined}]\n" " |-colorinterp {red|green|blue|alpha|gray|undefined},...]\n" - " [-mo \"META-TAG=VALUE\"]* [-q] [-sds]\n" - " [-co \"NAME=VALUE\"]* [-stats] [-norat] [-noxmp]\n" - " [-oo NAME=VALUE]*\n" - " src_dataset dst_dataset\n"); + " [-mo =]... [-q] [-sds]\n" + " [-co =]... [-stats] [-norat] [-noxmp]\n" + " [-oo =]...\n" + " \n"); if (!bShort) { @@ -96,7 +99,7 @@ static void Usage(const char *pszErrorMsg, int bShort) if (pszErrorMsg != nullptr) fprintf(stderr, "\nFAILURE: %s\n", pszErrorMsg); - exit(1); + exit(bIsError ? 1 : 0); } /************************************************************************/ @@ -161,11 +164,11 @@ MAIN_START(argc, argv) } else if (EQUAL(argv[i], "--help")) { - Usage(nullptr); + Usage(false, nullptr); } else if (EQUAL(argv[i], "--long-usage")) { - Usage(nullptr, FALSE); + Usage(false, nullptr, FALSE); } } @@ -196,17 +199,17 @@ MAIN_START(argc, argv) if (psOptions == nullptr) { - Usage(nullptr); + Usage(true, nullptr); } if (psOptionsForBinary->pszSource == nullptr) { - Usage("No source dataset specified."); + Usage(true, "No source dataset specified."); } if (psOptionsForBinary->pszDest == nullptr) { - Usage("No target dataset specified."); + Usage(true, "No target dataset specified."); } if (strcmp(psOptionsForBinary->pszDest, "/vsistdout/") == 0) @@ -374,7 +377,7 @@ MAIN_START(argc, argv) } if (bUsageError == TRUE) - Usage(); + Usage(true); GDALClose(hDataset); GDALTranslateOptionsFree(psOptions); GDALTranslateOptionsForBinaryFree(psOptionsForBinary); @@ -390,7 +393,7 @@ MAIN_START(argc, argv) hOutDS = GDALTranslate(psOptionsForBinary->pszDest, hDataset, psOptions, &bUsageError); if (bUsageError == TRUE) - Usage(); + Usage(true); int nRetCode = hOutDS ? 0 : 1; /* Close hOutDS before hDataset for the -f VRT case */ diff --git a/apps/gdal_viewshed.cpp b/apps/gdal_viewshed.cpp index 05ef32e6660a..08180fab49cc 100644 --- a/apps/gdal_viewshed.cpp +++ b/apps/gdal_viewshed.cpp @@ -40,25 +40,27 @@ /* Usage() */ /************************************************************************/ -static void Usage(const char *pszErrorMsg = nullptr) +static void Usage(bool bIsError, const char *pszErrorMsg = nullptr) { - printf("Usage: gdal_viewshed [--help] [--help-general]\n" - " [-b ]\n" - " [-a_nodata ] [-f ]\n" - " [-oz ] [-tz ] " - "[-md ]\n" - " -ox -oy \n" - " [-vv ] [-iv ]\n" - " [-ov ] [-cc ]\n" - " [[-co NAME=VALUE] ...]\n" - " [-q] [-om ]\n" - " \n"); + fprintf( + bIsError ? stderr : stdout, + "Usage: gdal_viewshed [--help] [--help-general]\n" + " [-b ]\n" + " [-a_nodata ] [-f ]\n" + " [-oz ] [-tz ] " + "[-md ]\n" + " -ox -oy \n" + " [-vv ] [-iv ]\n" + " [-ov ] [-cc ]\n" + " [-co =]...\n" + " [-q] [-om ]\n" + " \n"); if (pszErrorMsg != nullptr) fprintf(stderr, "\nFAILURE: %s\n", pszErrorMsg); - exit(1); + exit(bIsError ? 1 : 0); } static double CPLAtofTaintedSuppressed(const char *pszVal) @@ -75,8 +77,8 @@ static double CPLAtofTaintedSuppressed(const char *pszVal) do \ { \ if (i + nExtraArg >= argc) \ - Usage(CPLSPrintf("%s option requires %d argument(s)", argv[i], \ - nExtraArg)); \ + Usage(true, CPLSPrintf("%s option requires %d argument(s)", \ + argv[i], nExtraArg)); \ } while (false) MAIN_START(argc, argv) @@ -124,7 +126,7 @@ MAIN_START(argc, argv) return 0; } else if (EQUAL(argv[i], "--help")) - Usage(); + Usage(false); else if (EQUAL(argv[i], "-f") || EQUAL(argv[i], "-of")) { CHECK_HAS_ENOUGH_ADDITIONAL_ARGS(1); @@ -212,27 +214,27 @@ MAIN_START(argc, argv) pszDstFilename = argv[i]; } else - Usage("Too many command options."); + Usage(true, "Too many command options."); } if (pszSrcFilename == nullptr) { - Usage("Missing source filename."); + Usage(true, "Missing source filename."); } if (pszDstFilename == nullptr) { - Usage("Missing destination filename."); + Usage(true, "Missing destination filename."); } if (!bObserverXSpecified) { - Usage("Missing -ox."); + Usage(true, "Missing -ox."); } if (!bObserverYSpecified) { - Usage("Missing -oy."); + Usage(true, "Missing -oy."); } if (!bQuiet) @@ -264,7 +266,7 @@ MAIN_START(argc, argv) } else { - Usage("-om must be either NORMAL, DEM or GROUND"); + Usage(true, "-om must be either NORMAL, DEM or GROUND"); } } diff --git a/apps/gdaladdo.cpp b/apps/gdaladdo.cpp index 27246fc99dfc..a76b462e5ba0 100644 --- a/apps/gdaladdo.cpp +++ b/apps/gdaladdo.cpp @@ -39,20 +39,23 @@ /* Usage() */ /************************************************************************/ -static void Usage(const char *pszErrorMsg = nullptr) +static void Usage(bool bIsError, const char *pszErrorMsg = nullptr) { - printf( + fprintf( + bIsError ? stderr : stdout, "Usage: gdaladdo [--help] [--help-general]\n" " [-r " - "{nearest,average,rms,gauss,cubic,cubicspline,lanczos,average_mp," - "average_magphase,mode}]\n" - " [-ro] [-clean] [-q] [-oo NAME=VALUE]* [-minsize val]\n" + "{nearest|average|rms|gauss|cubic|cubicspline|lanczos|average_mp|" + "average_magphase|mode}]\n" + " [-ro] [-clean] [-q] [-oo =]... [-minsize " + "]\n" " [--partial-refresh-from-source-timestamp]\n" - " [--partial-refresh-from-projwin ulx uly lrx lry]\n" + " [--partial-refresh-from-projwin " + "]\n" " [--partial-refresh-from-source-extent " - "filename1,...,filenameN]\n" - " [levels]\n" + "[,]...]\n" + " []...\n" "\n" " -r : choice of resampling method (default: nearest)\n" " -ro : open the dataset in read-only mode, in order to generate\n" @@ -88,7 +91,7 @@ static void Usage(const char *pszErrorMsg = nullptr) if (pszErrorMsg != nullptr) fprintf(stderr, "\nFAILURE: %s\n", pszErrorMsg); - exit(1); + exit(bIsError ? 1 : 0); } /************************************************************************/ @@ -608,8 +611,8 @@ static bool PartialRefreshFromProjWin( do \ { \ if (iArg + nExtraArg >= nArgc) \ - Usage(CPLSPrintf("%s option requires %d argument(s)", \ - papszArgv[iArg], nExtraArg)); \ + Usage(true, CPLSPrintf("%s option requires %d argument(s)", \ + papszArgv[iArg], nExtraArg)); \ } while (false) MAIN_START(nArgc, papszArgv) @@ -671,7 +674,7 @@ MAIN_START(nArgc, papszArgv) } else if (EQUAL(papszArgv[iArg], "--help")) { - Usage(); + Usage(false); } else if (EQUAL(papszArgv[iArg], "-r")) { @@ -698,9 +701,8 @@ MAIN_START(nArgc, papszArgv) const int nBand = atoi(pszBand); if (nBand < 1) { - printf("Unrecognizable band number (%s).\n", - papszArgv[iArg + 1]); - Usage(); + Usage(true, CPLSPrintf("Unrecognizable band number (%s).\n", + papszArgv[iArg + 1])); } iArg++; @@ -743,7 +745,8 @@ MAIN_START(nArgc, papszArgv) } else if (papszArgv[iArg][0] == '-') { - Usage(CPLSPrintf("Unknown option name '%s'", papszArgv[iArg])); + Usage(true, + CPLSPrintf("Unknown option name '%s'", papszArgv[iArg])); } else if (pszFilename == nullptr) { @@ -763,19 +766,19 @@ MAIN_START(nArgc, papszArgv) } else { - Usage("Too many command options."); + Usage(true, "Too many command options."); } } if (pszFilename == nullptr) - Usage("No datasource specified."); + Usage(true, "No datasource specified."); if (((bClean) ? 1 : 0) + ((bPartialRefreshFromSourceTimestamp) ? 1 : 0) + ((bPartialRefreshFromProjWin) ? 1 : 0) + ((bPartialRefreshFromSourceExtent) ? 1 : 0) > 1) { - Usage("Mutually exclusive options used"); + Usage(true, "Mutually exclusive options used"); } /* -------------------------------------------------------------------- */ diff --git a/apps/gdalasyncread.cpp b/apps/gdalasyncread.cpp index a6d3ba2f1785..68c451931fb7 100644 --- a/apps/gdalasyncread.cpp +++ b/apps/gdalasyncread.cpp @@ -43,12 +43,12 @@ static void Usage() printf("Usage: gdalasyncread [--help] [--help-general]\n" " [-ot {Byte/Int16/UInt16/UInt32/Int32/Float32/Float64/\n" " CInt16/CInt32/CFloat32/CFloat64}]\n" - " [-of format] [-b band]\n" - " [-outsize xsize[%%] ysize[%%]]\n" - " [-srcwin xoff yoff xsize ysize]\n" - " [-co \"NAME=VALUE\"]* [-ao \"NAME=VALUE\"]\n" - " [-to timeout] [-multi]\n" - " src_dataset dst_dataset\n\n"); + " [-of ] [-b ]\n" + " [-outsize [%%] [%%]]\n" + " [-srcwin ]\n" + " [-co =]... [-ao =]...\n" + " [-to ] [-multi]\n" + " \n\n"); printf("%s\n\n", GDALVersionInfo("--version")); printf("The following format drivers are configured and support output:\n"); diff --git a/apps/gdalbuildvrt_bin.cpp b/apps/gdalbuildvrt_bin.cpp index 662390a09220..84feff19088d 100644 --- a/apps/gdalbuildvrt_bin.cpp +++ b/apps/gdalbuildvrt_bin.cpp @@ -37,30 +37,33 @@ /* Usage() */ /************************************************************************/ -static void Usage(const char *pszErrorMsg = nullptr) CPL_NO_RETURN; +static void Usage(bool bIsError, + const char *pszErrorMsg = nullptr) CPL_NO_RETURN; -static void Usage(const char *pszErrorMsg) +static void Usage(bool bIsError, const char *pszErrorMsg) { fprintf( - stdout, "%s", + bIsError ? stderr : stdout, "%s", "Usage: gdalbuildvrt [--help] [--help-general]\n" - " [-tileindex field_name]\n" + " [-tileindex ]\n" " [-resolution {highest|lowest|average|user}]\n" - " [-te xmin ymin xmax ymax] [-tr xres yres] [-tap]\n" - " [-separate] [-b band]* [-sd subdataset]\n" + " [-te ] [-tr " + "] [-tap]\n" + " [-separate] [-b ]... [-sd ]\n" " [-allow_projection_difference] [-q]\n" " [-addalpha] [-hidenodata]\n" - " [-srcnodata \"value [value...]\"] [-vrtnodata " - "\"value [value...]\"] \n" + " [-srcnodata \"[ ]...\"] [-vrtnodata " + "\"[ ]...\"\n" " [-ignore_srcmaskband]\n" - " [-a_srs srs_def]\n" + " [-a_srs ]\n" " [-r " - "{nearest,bilinear,cubic,cubicspline,lanczos,average,mode}]\n" - " [-oo NAME=VALUE]*\n" - " [-input_file_list my_list.txt] [-overwrite]\n" + "{nearest|bilinear|cubic|cubicspline|lanczos|average|mode}]\n" + " [-oo =]...\n" + " [-input_file_list ] [-overwrite]\n" " [-strict | -non_strict]\n" - " output.vrt [gdalfile]*\n" + " " + "[]...\n" "\n" "e.g.\n" " % gdalbuildvrt doq_index.vrt doq/*.tif\n" @@ -98,7 +101,7 @@ static void Usage(const char *pszErrorMsg) if (pszErrorMsg != nullptr) fprintf(stderr, "\nFAILURE: %s\n", pszErrorMsg); - exit(1); + exit(bIsError ? 1 : 0); } /************************************************************************/ @@ -156,7 +159,7 @@ MAIN_START(argc, argv) } else if (EQUAL(argv[i], "--help")) { - Usage(nullptr); + Usage(false, nullptr); } } @@ -169,12 +172,12 @@ MAIN_START(argc, argv) if (psOptions == nullptr) { - Usage(nullptr); + Usage(true, nullptr); } if (psOptionsForBinary->pszDstFilename == nullptr) { - Usage("No target filename specified."); + Usage(true, "No target filename specified."); } if (!(psOptionsForBinary->bQuiet)) @@ -208,7 +211,7 @@ MAIN_START(argc, argv) psOptionsForBinary->pszDstFilename, GDALGetDriverShortName(hDriver), psOptionsForBinary->pszDstFilename); - Usage(); + Usage(true); } } } @@ -218,7 +221,7 @@ MAIN_START(argc, argv) psOptionsForBinary->pszDstFilename, psOptionsForBinary->nSrcFiles, nullptr, psOptionsForBinary->papszSrcFiles, psOptions, &bUsageError); if (bUsageError) - Usage(); + Usage(true); int nRetCode = (hOutDS) ? 0 : 1; GDALBuildVRTOptionsFree(psOptions); diff --git a/apps/gdaldem_bin.cpp b/apps/gdaldem_bin.cpp index 5f5154d1260a..ca91ec80d6ca 100644 --- a/apps/gdaldem_bin.cpp +++ b/apps/gdaldem_bin.cpp @@ -41,70 +41,69 @@ /* Usage() */ /************************************************************************/ -static void Usage(const char *pszErrorMsg = nullptr) +static void Usage(bool bIsError, const char *pszErrorMsg = nullptr) { - printf( + fprintf( + bIsError ? stderr : stdout, " Usage: [--help] [--help-general]\n" " - To generate a shaded relief map from any GDAL-supported elevation " "raster : \n\n" - " gdaldem hillshade input_dem output_hillshade \n" - " [-z ZFactor (default=1)] [-s scale* (default=1)] \n" - " [-az Azimuth (default=315)] [-alt Altitude " - "(default=45)]\n" + " gdaldem hillshade \n" + " [-z ] [-s ] \n" + " [-az ] [-alt ]\n" " [-alg ZevenbergenThorne] [-combined | " "-multidirectional | -igor]\n" - " [-compute_edges] [-b Band (default=1)] [-of format] " - "[-co \"NAME=VALUE\"]* [-q]\n" + " [-compute_edges] [-b ] [-of ] " + "[-co =]... [-q]\n" "\n" " - To generates a slope map from any GDAL-supported elevation raster " ":\n\n" - " gdaldem slope input_dem output_slope_map \n" - " [-p use percent slope (default=degrees)] [-s scale* " - "(default=1)]\n" + " gdaldem slope \n" + " [-p] [-s ]\n" " [-alg ZevenbergenThorne]\n" - " [-compute_edges] [-b Band (default=1)] [-of format] " - "[-co \"NAME=VALUE\"]* [-q]\n" + " [-compute_edges] [-b ] [-of ] " + "[-co =]... [-q]\n" "\n" " - To generate an aspect map from any GDAL-supported elevation " "raster\n" " Outputs a 32-bit float tiff with pixel values from 0-360 " "indicating azimuth :\n\n" - " gdaldem aspect input_dem output_aspect_map \n" + " gdaldem aspect \n" " [-trigonometric] [-zero_for_flat]\n" " [-alg ZevenbergenThorne]\n" - " [-compute_edges] [-b Band (default=1)] [-of format] " - "[-co \"NAME=VALUE\"]* [-q]\n" + " [-compute_edges] [-b ] [-of format] " + "[-co =]... [-q]\n" "\n" " - To generate a color relief map from any GDAL-supported elevation " "raster\n" - " gdaldem color-relief input_dem color_text_file " - "output_color_relief_map\n" + " gdaldem color-relief " + "\n" " [-alpha] [-exact_color_entry | " "-nearest_color_entry]\n" - " [-b Band (default=1)] [-of format] [-co " - "\"NAME=VALUE\"]* [-q]\n" + " [-b ] [-of format] " + "[-co =]... [-q]\n" " where color_text_file contains lines of the format " "\"elevation_value red green blue\"\n" "\n" " - To generate a Terrain Ruggedness Index (TRI) map from any " "GDAL-supported elevation raster\n" - " gdaldem TRI input_dem output_TRI_map\n" + " gdaldem TRI \n" " [-alg Wilson|Riley]\n" - " [-compute_edges] [-b Band (default=1)] [-of format] " - "[-co \"NAME=VALUE\"]* [-q]\n" + " [-compute_edges] [-b ] [-of ] " + "[-co =]... [-q]\n" "\n" " - To generate a Topographic Position Index (TPI) map from any " "GDAL-supported elevation raster\n" - " gdaldem TPI input_dem output_TPI_map\n" - " [-compute_edges] [-b Band (default=1)] [-of format] " - "[-co \"NAME=VALUE\"]* [-q]\n" + " gdaldem TPI \n" + " [-compute_edges] [-b ] [-of ] " + "[-co =]... [-q]\n" "\n" " - To generate a roughness map from any GDAL-supported elevation " "raster\n" - " gdaldem roughness input_dem output_roughness_map\n" - " [-compute_edges] [-b Band (default=1)] [-of format] " - "[-co \"NAME=VALUE\"]* [-q]\n" + " gdaldem roughness \n" + " [-compute_edges] [-b ] [-of ] " + "[-co =]... [-q]\n" "\n" " Notes : \n" " Scale is the ratio of vertical units to horizontal\n" @@ -114,7 +113,7 @@ static void Usage(const char *pszErrorMsg = nullptr) if (pszErrorMsg != nullptr) fprintf(stderr, "\nFAILURE: %s\n", pszErrorMsg); - exit(1); + exit(bIsError ? 1 : 0); } /************************************************************************/ @@ -165,7 +164,7 @@ MAIN_START(argc, argv) argc = GDALGeneralCmdLineProcessor(argc, &argv, 0); if (argc < 2) { - Usage("Not enough arguments."); + Usage(true, "Not enough arguments."); } if (EQUAL(argv[1], "--utility_version") || @@ -178,7 +177,7 @@ MAIN_START(argc, argv) return 0; } else if (EQUAL(argv[1], "--help")) - Usage(); + Usage(false); GDALDEMProcessingOptionsForBinary *psOptionsForBinary = GDALDEMProcessingOptionsForBinaryNew(); @@ -189,7 +188,7 @@ MAIN_START(argc, argv) if (psOptions == nullptr) { - Usage(); + Usage(true); } if (!(psOptionsForBinary->bQuiet)) @@ -200,16 +199,16 @@ MAIN_START(argc, argv) if (psOptionsForBinary->pszSrcFilename == nullptr) { - Usage("Missing source."); + Usage(true, "Missing source."); } if (EQUAL(psOptionsForBinary->pszProcessing, "color-relief") && psOptionsForBinary->pszColorFilename == nullptr) { - Usage("Missing color file."); + Usage(true, "Missing color file."); } if (psOptionsForBinary->pszDstFilename == nullptr) { - Usage("Missing destination."); + Usage(true, "Missing destination."); } // Open Dataset and get raster band. @@ -230,7 +229,7 @@ MAIN_START(argc, argv) psOptionsForBinary->pszProcessing, psOptionsForBinary->pszColorFilename, psOptions, &bUsageError); if (bUsageError) - Usage(); + Usage(true); const int nRetCode = hOutDS ? 0 : 1; GDALClose(hSrcDataset); diff --git a/apps/gdalenhance.cpp b/apps/gdalenhance.cpp index 6e11b4b1fa47..b632d1d8fa74 100644 --- a/apps/gdalenhance.cpp +++ b/apps/gdalenhance.cpp @@ -63,7 +63,7 @@ static void Usage() { printf("Usage: gdalenhance [--help] [--help-general]\n" - " [-of format] [-co \"NAME=VALUE\"]*\n" + " [-of ] [-co =]...\n" " [-ot {Byte/Int16/UInt16/UInt32/Int32/Float32/Float64/\n" " CInt16/CInt32/CFloat32/CFloat64}]\n" // " [-src_scale[_n] src_min src_max]\n" @@ -72,8 +72,8 @@ static void Usage() // " [-s_nodata[_n] value]\n" // " [-stddev multiplier]\n" " [-equalize]\n" - " [-config filename]\n" - " src_dataset dst_dataset\n\n"); + " [-config ]\n" + " \n\n"); printf("%s\n\n", GDALVersionInfo("--version")); exit(1); } diff --git a/apps/gdalflattenmask.c b/apps/gdalflattenmask.c index 08838240aa0e..37a52f27cc5a 100644 --- a/apps/gdalflattenmask.c +++ b/apps/gdalflattenmask.c @@ -37,10 +37,10 @@ static void Usage() { printf("Usage: gdalflattenmask [--help] [--help-general] [-of " - "output_format] \n" - " [-co \"NAME=VALUE\"]* [-set_alpha] " - "[-a_nodata val] \n" - " srcdatasetname dstdatasetname\n" + "] \n" + " [-co =]... [-set_alpha] " + "[-a_nodata ] \n" + " \n" "\n" "This utility is intended to produce a new file that merges regular " "data\n" diff --git a/apps/gdalinfo_bin.cpp b/apps/gdalinfo_bin.cpp index fe4d0d3fa8b5..b7515725e593 100644 --- a/apps/gdalinfo_bin.cpp +++ b/apps/gdalinfo_bin.cpp @@ -38,21 +38,24 @@ /* Usage() */ /************************************************************************/ -static void Usage(const char *pszErrorMsg = nullptr) +static void Usage(bool bIsError, const char *pszErrorMsg = nullptr) { - printf("Usage: gdalinfo [--help] [--help-general]\n" - " [-json] [-mm] [-stats | -approx_stats] [-hist]\n" - " [-nogcp] [-nomd] [-norat] [-noct] [-nofl]\n" - " [-checksum] [-listmdd] [-mdd domain|`all`]\n" - " [-proj4] [-wkt_format WKT1|WKT2|...]*\n" - " [-sd subdataset] [-oo NAME=VALUE]* [-if format]*\n" - " datasetname\n"); + fprintf( + bIsError ? stderr : stdout, + "Usage: gdalinfo [--help] [--help-general]\n" + " [-json] [-mm] [-stats | -approx_stats] [-hist]\n" + " [-nogcp] [-nomd] [-norat] [-noct] [-nofl]\n" + " [-checksum] [-listmdd] [-mdd |all]\n" + " [-proj4] [-wkt_format {WKT1|WKT2|}]...\n" + " [-sd ] [-oo =]... [-if " + "]...\n" + " \n"); if (pszErrorMsg != nullptr) fprintf(stderr, "\nFAILURE: %s\n", pszErrorMsg); - exit(1); + exit(bIsError ? 1 : 0); } /************************************************************************/ @@ -108,7 +111,7 @@ MAIN_START(argc, argv) } else if (EQUAL(argv[i], "--help")) { - Usage(); + Usage(false); } } argv = CSLAddString(argv, "-stdout"); @@ -119,10 +122,10 @@ MAIN_START(argc, argv) GDALInfoOptions *psOptions = GDALInfoOptionsNew(argv + 1, psOptionsForBinary); if (psOptions == nullptr) - Usage(); + Usage(true); if (psOptionsForBinary->pszFilename == nullptr) - Usage("No datasource specified."); + Usage(true, "No datasource specified."); /* -------------------------------------------------------------------- */ /* Open dataset. */ diff --git a/apps/gdallocationinfo.cpp b/apps/gdallocationinfo.cpp index d821927e340d..24a3790b3880 100644 --- a/apps/gdallocationinfo.cpp +++ b/apps/gdallocationinfo.cpp @@ -45,15 +45,17 @@ /* Usage() */ /************************************************************************/ -static void Usage() +static void Usage(bool bIsError) { - printf("Usage: gdallocationinfo [--help] [--help-general]\n" - " [-xml] [-lifonly] [-valonly]\n" - " [-b band]* [-overview overview_level]\n" - " [-l_srs srs_def] [-geoloc] [-wgs84]\n" - " [-oo NAME=VALUE]* srcfile x y\n" - "\n"); + fprintf( + bIsError ? stderr : stdout, + "Usage: gdallocationinfo [--help] [--help-general]\n" + " [-xml] [-lifonly] [-valonly]\n" + " [-b ]... [-overview ]\n" + " [-l_srs ] [-geoloc] [-wgs84]\n" + " [-oo =]... [ ]\n" + "\n"); exit(1); } @@ -120,7 +122,7 @@ MAIN_START(argc, argv) } else if (EQUAL(argv[i], "--help")) { - Usage(); + Usage(false); } else if (i < argc - 1 && EQUAL(argv[i], "-b")) { @@ -165,7 +167,7 @@ MAIN_START(argc, argv) papszOpenOptions = CSLAddString(papszOpenOptions, argv[++i]); } else if (argv[i][0] == '-' && !isdigit(argv[i][1])) - Usage(); + Usage(true); else if (pszSrcFilename == nullptr) pszSrcFilename = argv[i]; @@ -177,11 +179,11 @@ MAIN_START(argc, argv) pszLocY = argv[i]; else - Usage(); + Usage(true); } if (pszSrcFilename == nullptr || (pszLocX != nullptr && pszLocY == nullptr)) - Usage(); + Usage(true); /* -------------------------------------------------------------------- */ /* Open source file. */ diff --git a/apps/gdalmanage.cpp b/apps/gdalmanage.cpp index d8e177bc6861..f64ef82eb6f7 100644 --- a/apps/gdalmanage.cpp +++ b/apps/gdalmanage.cpp @@ -38,15 +38,16 @@ /* Usage() */ /************************************************************************/ -static void Usage() +static void Usage(bool bIsError) { - printf("Usage: gdalmanage [--help] [--help-general]\n" - " or gdalmanage identify [-r|-fr] [-u] files*\n" - " or gdalmanage copy [-f driver] oldname newname\n" - " or gdalmanage rename [-f driver] oldname newname\n" - " or gdalmanage delete [-f driver] datasetname\n"); - exit(1); + fprintf(bIsError ? stderr : stdout, + "Usage: gdalmanage [--help] [--help-general]\n" + " or gdalmanage identify [-r|-fr] [-u] *\n" + " or gdalmanage copy [-f ] \n" + " or gdalmanage rename [-f ] \n" + " or gdalmanage delete [-f ] \n"); + exit(bIsError ? 1 : 0); } /************************************************************************/ @@ -116,7 +117,7 @@ static void Identify(int nArgc, char **papszArgv) else if (EQUAL(papszArgv[0], "-u")) bReportFailures = true; else - Usage(); + Usage(true); papszArgv++; nArgc--; @@ -142,7 +143,7 @@ static void Delete(GDALDriverH hDriver, int nArgc, char **papszArgv) { if (nArgc != 1) - Usage(); + Usage(true); GDALDeleteDataset(hDriver, papszArgv[0]); } @@ -156,7 +157,7 @@ static void Copy(GDALDriverH hDriver, int nArgc, char **papszArgv, { if (nArgc != 2) - Usage(); + Usage(true); if (EQUAL(pszOperation, "copy")) GDALCopyDatasetFiles(hDriver, papszArgv[1], papszArgv[0]); @@ -192,8 +193,16 @@ MAIN_START(argc, argv) if (argc < 1) exit(-argc); + for (int i = 0; argv != nullptr && argv[i] != nullptr; i++) + { + if (EQUAL(argv[i], "--help")) + { + Usage(false); + } + } + if (argc < 3) - Usage(); + Usage(true); if (EQUAL(argv[1], "--utility_version")) { @@ -242,7 +251,7 @@ MAIN_START(argc, argv) Delete(hDriver, nRemainingArgc, papszRemainingArgv); else - Usage(); + Usage(true); /* -------------------------------------------------------------------- */ /* Cleanup */ diff --git a/apps/gdalmdiminfo_bin.cpp b/apps/gdalmdiminfo_bin.cpp index 2c3652572f41..727f4681d9ee 100644 --- a/apps/gdalmdiminfo_bin.cpp +++ b/apps/gdalmdiminfo_bin.cpp @@ -37,20 +37,22 @@ /* Usage() */ /************************************************************************/ -static void Usage(const char *pszErrorMsg = nullptr) +static void Usage(bool bIsError, const char *pszErrorMsg = nullptr) { - printf( + fprintf( + bIsError ? stderr : stdout, "Usage: gdalmdiminfo [--help] [--help-general]\n" - " [-oo NAME=VALUE]* [-arrayoption ]*\n" + " [-oo =]... [-arrayoption " + "=]...\n" " [-detailed] [-nopretty] [-array ]\n" - " [-limit ] [-stats] [-if ]*\n" + " [-limit ] [-stats] [-if ]...\n" " \n"); if (pszErrorMsg != nullptr) fprintf(stderr, "\nFAILURE: %s\n", pszErrorMsg); - exit(1); + exit(bIsError ? 1 : 0); } /************************************************************************/ @@ -80,7 +82,7 @@ MAIN_START(argc, argv) } else if (EQUAL(argv[i], "--help")) { - Usage(); + Usage(false); } } argv = CSLAddString(argv, "-stdout"); @@ -90,10 +92,10 @@ MAIN_START(argc, argv) GDALMultiDimInfoOptions *psOptions = GDALMultiDimInfoOptionsNew(argv + 1, &sOptionsForBinary); if (psOptions == nullptr) - Usage(); + Usage(true); if (sOptionsForBinary.osFilename.empty()) - Usage("No datasource specified."); + Usage(true, "No datasource specified."); GDALDatasetH hDataset = GDALOpenEx(sOptionsForBinary.osFilename.c_str(), diff --git a/apps/gdalmdimtranslate_bin.cpp b/apps/gdalmdimtranslate_bin.cpp index 349736bdaa42..52e41066c16d 100644 --- a/apps/gdalmdimtranslate_bin.cpp +++ b/apps/gdalmdimtranslate_bin.cpp @@ -36,22 +36,24 @@ /* Usage() */ /************************************************************************/ -static void Usage(const char *pszErrorMsg = nullptr) +static void Usage(bool bIsError, const char *pszErrorMsg = nullptr) { - printf("Usage: gdalmdimtranslate [--help] [--help-general]\n" - " [-if format]* [-of format]\n" - " [-co \"NAME=VALUE\"]*\n" - " [-array ]*\n" - " [-group ]* \n" - " [-subset ]* \n" - " [-scaleaxes ] \n" - " [-oo NAME=VALUE]*\n" - " \n"); + fprintf(bIsError ? stderr : stdout, + "Usage: gdalmdimtranslate [--help] [--help-general]\n" + " [-if ]... [-of ]\n" + " [-co =]...\n" + " [-array ]...\n" + " [-group ]...\n" + " [-subset ]...\n" + " [-scaleaxes ]\n" + " [-oo =]...\n" + " \n"); if (pszErrorMsg != nullptr) fprintf(stderr, "\nFAILURE: %s\n", pszErrorMsg); - exit(1); + + exit(bIsError ? 1 : 0); } /************************************************************************/ @@ -86,7 +88,7 @@ MAIN_START(argc, argv) } else if (EQUAL(argv[i], "--help")) { - Usage(); + Usage(false); } } @@ -98,7 +100,7 @@ MAIN_START(argc, argv) if (psOptions == nullptr) { - Usage(); + Usage(true); } if (!(sOptionsForBinary.bQuiet)) @@ -108,10 +110,10 @@ MAIN_START(argc, argv) } if (sOptionsForBinary.osSource.empty()) - Usage("No input file specified."); + Usage(true, "No input file specified."); if (sOptionsForBinary.osDest.empty()) - Usage("No output file specified."); + Usage(true, "No output file specified."); /* -------------------------------------------------------------------- */ /* Open input file. */ @@ -144,7 +146,7 @@ MAIN_START(argc, argv) GDALMultiDimTranslate(sOptionsForBinary.osDest.c_str(), hDstDS, 1, &hInDS, psOptions, &bUsageError); if (bUsageError == TRUE) - Usage(); + Usage(true); int nRetCode = hRetDS ? 0 : 1; if (GDALClose(hRetDS) != CE_None) diff --git a/apps/gdalsrsinfo.cpp b/apps/gdalsrsinfo.cpp index bb82fafd48ed..949c767abb14 100644 --- a/apps/gdalsrsinfo.cpp +++ b/apps/gdalsrsinfo.cpp @@ -49,38 +49,39 @@ void PrintSRSOutputTypes(const OGRSpatialReference &oSRS, /* Usage() */ /************************************************************************/ -static void Usage(const char *pszErrorMsg = nullptr) +static void Usage(bool bIsError, const char *pszErrorMsg = nullptr) { - printf("\nUsage: gdalsrsinfo [options] srs_def\n" - "\n" - "srs_def may be the filename of a dataset supported by GDAL/OGR " - "from which to extract SRS information\n" - "OR any of the usual GDAL/OGR forms " - "(complete WKT, PROJ.4, EPSG:n or a file containing the SRS)\n" - "\n" - "Options: \n" - " [--help-general] Show help on general options and exit\n" - " [--help] [-h] Show help and exit\n" - " [--single-line] Print WKT on single line\n" - " [-V] Validate SRS\n" - " [-e] Search for EPSG number(s) corresponding " - "to SRS\n" - " [-o out_type] Output type { default, all, wkt_all,\n" + fprintf(bIsError ? stderr : stdout, + "Usage: gdalsrsinfo [options] \n" + "\n" + "srs_def may be the filename of a dataset supported by GDAL/OGR " + "from which to extract SRS information\n" + "OR any of the usual GDAL/OGR forms " + "(complete WKT, PROJ.4, EPSG:n or a file containing the SRS)\n" + "\n" + "Options: \n" + " [--help-general] Show help on general options and exit\n" + " [--help] [-h] Show help and exit\n" + " [--single-line] Print WKT on single line\n" + " [-V] Validate SRS\n" + " [-e] Search for EPSG number(s) corresponding " + "to SRS\n" + " [-o ] Output type { default, all, wkt_all,\n" #if PROJ_VERSION_MAJOR > 6 || PROJ_VERSION_MINOR >= 2 - " PROJJSON, proj4, epsg,\n" + " PROJJSON, proj4, epsg,\n" #else - " proj4, epsg,\n" + " proj4, epsg,\n" #endif - " wkt1, wkt_simple, " - "wkt_noct, wkt_esri,\n" - " wkt2, wkt2_2015, " - "wkt2_2019, mapinfo, xml }\n\n"); + " wkt1, wkt_simple, " + "wkt_noct, wkt_esri,\n" + " wkt2, wkt2_2015, " + "wkt2_2019, mapinfo, xml }\n\n"); if (pszErrorMsg != nullptr) fprintf(stderr, "\nFAILURE: %s\n", pszErrorMsg); - exit(1); + exit(bIsError ? 1 : 0); } /************************************************************************/ @@ -91,8 +92,8 @@ static void Usage(const char *pszErrorMsg = nullptr) do \ { \ if (i + nExtraArg >= argc) \ - Usage(CPLSPrintf("%s option requires %d argument(s)", argv[i], \ - nExtraArg)); \ + Usage(true, CPLSPrintf("%s option requires %d argument(s)", \ + argv[i], nExtraArg)); \ } while (false) MAIN_START(argc, argv) @@ -142,7 +143,7 @@ MAIN_START(argc, argv) return 0; } else if (EQUAL(argv[i], "-h") || EQUAL(argv[i], "--help")) - Usage(); + Usage(false); else if (EQUAL(argv[i], "-e")) bFindEPSG = true; else if (EQUAL(argv[i], "-o")) @@ -158,7 +159,7 @@ MAIN_START(argc, argv) bValidate = true; else if (argv[i][0] == '-') { - Usage(CPLSPrintf("Unknown option name '%s'", argv[i])); + Usage(true, CPLSPrintf("Unknown option name '%s'", argv[i])); } else pszInput = argv[i]; @@ -167,7 +168,7 @@ MAIN_START(argc, argv) if (pszInput == nullptr) { CSLDestroy(argv); - Usage("No input specified."); + Usage(true, "No input specified."); } /* Search for SRS */ diff --git a/apps/gdaltindex.cpp b/apps/gdaltindex.cpp index f43dde2d79f8..36bb77c5b1f2 100644 --- a/apps/gdaltindex.cpp +++ b/apps/gdaltindex.cpp @@ -42,19 +42,19 @@ /* Usage() */ /************************************************************************/ -static void Usage(const char *pszErrorMsg) +static void Usage(bool bIsError, const char *pszErrorMsg) { fprintf( - stdout, "%s", - "\n" + bIsError ? stderr : stdout, "%s", "Usage: gdaltindex [--help] [--help-general]\n" - " [-f format] [-tileindex field_name] " + " [-f ] [-tileindex ] " "[-write_absolute_path] \n" - " [-skip_different_projection] [-t_srs target_srs]\n" + " [-skip_different_projection] [-t_srs ]\n" " [-src_srs_name field_name] [-src_srs_format " - "[AUTO|WKT|EPSG|PROJ]\n" - " [-lyr_name name] index_file [gdal_file]*\n" + "{AUTO|WKT|EPSG|PROJ}]\n" + " [-lyr_name ] " + "[]...\n" "\n" "e.g.\n" " % gdaltindex doq_index.shp doq/*.tif\n" @@ -83,7 +83,7 @@ static void Usage(const char *pszErrorMsg) if (pszErrorMsg != nullptr) fprintf(stderr, "\nFAILURE: %s\n", pszErrorMsg); - exit(1); + exit(bIsError ? 1 : 0); } /************************************************************************/ @@ -94,8 +94,8 @@ static void Usage(const char *pszErrorMsg) do \ { \ if (iArg + nExtraArg >= argc) \ - Usage(CPLSPrintf("%s option requires %d argument(s)", argv[iArg], \ - nExtraArg)); \ + Usage(true, CPLSPrintf("%s option requires %d argument(s)", \ + argv[iArg], nExtraArg)); \ } while (false) typedef enum @@ -156,7 +156,7 @@ MAIN_START(argc, argv) return 0; } else if (EQUAL(argv[iArg], "--help")) - Usage(nullptr); + Usage(false, nullptr); else if ((strcmp(argv[iArg], "-f") == 0 || strcmp(argv[iArg], "-of") == 0)) { @@ -208,7 +208,7 @@ MAIN_START(argc, argv) eSrcSRSFormat = FORMAT_PROJ; } else if (argv[iArg][0] == '-') - Usage(CPLSPrintf("Unknown option name '%s'", argv[iArg])); + Usage(true, CPLSPrintf("Unknown option name '%s'", argv[iArg])); else if (index_filename == nullptr) { index_filename = argv[iArg]; @@ -218,12 +218,12 @@ MAIN_START(argc, argv) } if (index_filename == nullptr) - Usage("No index filename specified."); + Usage(true, "No index filename specified."); if (iArg == argc) - Usage("No file to index specified."); + Usage(true, "No file to index specified."); if (bSrcSRSFormatSpecified && pszSrcSRSName == nullptr) - Usage("-src_srs_name must be specified when -src_srs_format is " - "specified."); + Usage(true, "-src_srs_name must be specified when -src_srs_format is " + "specified."); /* -------------------------------------------------------------------- */ /* Create and validate target SRS if given. */ diff --git a/apps/gdaltransform.cpp b/apps/gdaltransform.cpp index ea07a5a70a42..fe2a5cb2509b 100644 --- a/apps/gdaltransform.cpp +++ b/apps/gdaltransform.cpp @@ -56,21 +56,24 @@ /* Usage() */ /************************************************************************/ -static void Usage(const char *pszErrorMsg = nullptr) +static void Usage(bool bIsError, const char *pszErrorMsg = nullptr) { - printf("Usage: gdaltransform [--help] [--help-general]\n" - " [-i] [-s_srs srs_def] [-t_srs srs_def] [-to \"NAME=VALUE\"]\n" - " [-s_coord_epoch epoch] [-t_coord_epoch epoch]\n" - " [-ct proj_string] [-order n] [-tps] [-rpc] [-geoloc] \n" - " [-gcp pixel line easting northing [elevation]]* [-output_xy]\n" - " [srcfile [dstfile]]\n" - "\n"); + fprintf(bIsError ? stderr : stdout, + "Usage: gdaltransform [--help] [--help-general]\n" + " [-i] [-s_srs ] [-t_srs ] [-to " + ">NAME>=]...\n" + " [-s_coord_epoch ] [-t_coord_epoch ]\n" + " [-ct ] [-order ] [-tps] [-rpc] [-geoloc] \n" + " [-gcp [elevation]]... " + "[-output_xy]\n" + " [srcfile [dstfile]]\n" + "\n"); if (pszErrorMsg != nullptr) fprintf(stderr, "\nFAILURE: %s\n", pszErrorMsg); - exit(1); + exit(bIsError ? 1 : 0); } /************************************************************************/ @@ -106,8 +109,8 @@ static bool IsValidSRS(const char *pszUserInput) do \ { \ if (i + nExtraArg >= argc) \ - Usage(CPLSPrintf("%s option requires %d argument(s)", argv[i], \ - nExtraArg)); \ + Usage(true, CPLSPrintf("%s option requires %d argument(s)", \ + argv[i], nExtraArg)); \ } while (false) MAIN_START(argc, argv) @@ -160,7 +163,7 @@ MAIN_START(argc, argv) } else if (EQUAL(argv[i], "--help")) { - Usage(); + Usage(false); } else if (EQUAL(argv[i], "-t_srs")) { @@ -277,7 +280,7 @@ MAIN_START(argc, argv) } else if (argv[i][0] == '-') { - Usage(CPLSPrintf("Unknown option name '%s'", argv[i])); + Usage(true, CPLSPrintf("Unknown option name '%s'", argv[i])); } else if (pszSrcFilename == nullptr) { @@ -289,7 +292,7 @@ MAIN_START(argc, argv) } else { - Usage("Too many command options."); + Usage(true, "Too many command options."); } } diff --git a/apps/gdalwarp_bin.cpp b/apps/gdalwarp_bin.cpp index 9d7025ec9ce6..f3a51f64f333 100644 --- a/apps/gdalwarp_bin.cpp +++ b/apps/gdalwarp_bin.cpp @@ -62,31 +62,35 @@ static int GDALExit(int nCode) /* Usage() */ /************************************************************************/ -static void Usage(const char *pszErrorMsg = nullptr) +static void Usage(bool bIsError, const char *pszErrorMsg = nullptr) { - printf( + fprintf( + bIsError ? stderr : stdout, "Usage: gdalwarp [--help] [--help-general] [--formats]\n" - " [-b|-srcband n]* [-dstband n]*\n" - " [-s_srs srs_def] [-t_srs srs_def] [-ct string]\n" - " [-to \"NAME=VALUE\"]* [-vshift | -novshift]\n" - " [-s_coord_epoch epoch] [-t_coord_epoch epoch]\n" - " [-order n | -tps | -rpc | -geoloc] [-et err_threshold]\n" - " [-refine_gcps tolerance [minimum_gcps]]\n" - " [-te xmin ymin xmax ymax] [-te_srs srs_def]\n" - " [-tr xres yres]|[-tr square] [-tap] [-ts width height]\n" - " [-ovr level|AUTO|AUTO-n|NONE] [-wo \"NAME=VALUE\"] [-ot " + " [-b|-srcband ]... [-dstband ]...\n" + " [-s_srs ] [-t_srs ] [-ct ]\n" + " [-to =]... [-vshift | -novshift]\n" + " [-s_coord_epoch ] [-t_coord_epoch ]\n" + " [-order n | -tps | -rpc | -geoloc] [-et ]\n" + " [-refine_gcps []]\n" + " [-te ] [-te_srs ]\n" + " [-tr ]|[-tr square] [-tap] [-ts ]\n" + " [-ovr |AUTO|AUTO-|NONE] [-wo =]... [-ot " "Byte/Int16/...] [-wt Byte/Int16]\n" - " [-srcnodata \"value [value...]\"]" - "[-dstnodata \"value [value...]\"]\n" + " [-srcnodata \"[ ...]\"]" + "[-dstnodata \"[ ...]\"]\n" " [-srcalpha|-nosrcalpha] [-dstalpha]\n" - " [-r resampling_method] [-wm memory_in_mb] [-multi] [-q]\n" - " [-cutline datasource] [-cl layer] [-cwhere expression]\n" - " [-csql statement] [-cblend dist_in_pixels] [-crop_to_cutline]\n" - " [-if format]* [-of format] [-co \"NAME=VALUE\"]* [-overwrite]\n" - " [-nomd] [-cvmd meta_conflict_value] [-setci] [-oo NAME=VALUE]*\n" - " [-doo NAME=VALUE]*\n" - " srcfile* dstfile\n" + " [-r ] [-wm ] [-multi] [-q]\n" + " [-cutline ] [-cl ] [-cwhere ]\n" + " [-csql ] [-cblend ] " + "[-crop_to_cutline]\n" + " [-if ]... [-of ] [-co =]... " + "[-overwrite]\n" + " [-nomd] [-cvmd ] [-setci] [-oo " + "=]...\n" + " [-doo =]...\n" + " ... \n" "\n" "Available resampling methods:\n" " near (default), bilinear, cubic, cubicspline, lanczos, average, " @@ -96,7 +100,7 @@ static void Usage(const char *pszErrorMsg = nullptr) if (pszErrorMsg != nullptr) fprintf(stderr, "\nFAILURE: %s\n", pszErrorMsg); - GDALExit(1); + GDALExit(bIsError ? 1 : 0); } /************************************************************************/ @@ -183,7 +187,7 @@ MAIN_START(argc, argv) } else if (EQUAL(argv[i], "--help")) { - Usage(nullptr); + Usage(false, nullptr); } } @@ -215,12 +219,12 @@ MAIN_START(argc, argv) if (psOptions == nullptr) { - Usage(nullptr); + Usage(true, nullptr); } if (psOptionsForBinary->pszDstFilename == nullptr) { - Usage("No target filename specified."); + Usage(true, "No target filename specified."); } if (CSLCount(psOptionsForBinary->papszSrcFiles) == 1 && @@ -380,7 +384,7 @@ MAIN_START(argc, argv) GDALWarp(psOptionsForBinary->pszDstFilename, hDstDS, nSrcCount, pahSrcDS, psOptions, &bUsageError); if (bUsageError) - Usage(); + Usage(true); int nRetCode = (hOutDS) ? 0 : 1; GDALWarpAppOptionsFree(psOptions); diff --git a/apps/gdalwarpsimple.c b/apps/gdalwarpsimple.c index 20e01963bb46..136caec00009 100644 --- a/apps/gdalwarpsimple.c +++ b/apps/gdalwarpsimple.c @@ -50,11 +50,12 @@ static int nForcePixels = 0, nForceLines = 0; static void Usage() { - printf( - "Usage: gdalwarpsimple [--version] [--formats]\n" - " [-s_srs srs_def] [-t_srs srs_def] [-order n] [-et err_threshold]\n" - " [-te xmin ymin xmax ymax] [-tr xres yres] [-ts width height]\n" - " [-of format] [-co \"NAME=VALUE\"]* srcfile dstfile\n"); + printf("Usage: gdalwarpsimple [--version] [--formats]\n" + " [-s_srs ] [-t_srs ] [-order ] [-et " + "]\n" + " [-te ] [-tr ] [-ts " + " ]\n" + " [-of ] [-co =]... \n"); exit(1); } diff --git a/apps/gnmanalyse.cpp b/apps/gnmanalyse.cpp index bbb482530db2..7d93387e57d8 100644 --- a/apps/gnmanalyse.cpp +++ b/apps/gnmanalyse.cpp @@ -44,18 +44,20 @@ enum operation /************************************************************************/ /* Usage() */ /************************************************************************/ -static void Usage(const char *pszAdditionalMsg, int bShort = TRUE) +static void Usage(bool bIsError, const char *pszAdditionalMsg = nullptr, + bool bShort = true) { - printf( + fprintf( + bIsError ? stderr : stdout, "Usage: gnmanalyse [--help][--help-general][-q][-quiet][--long-usage]\n" - " [dijkstra start_gfid end_gfid [[-alo NAME=VALUE] " - "...]]\n" - " [kpaths start_gfid end_gfid k [[-alo NAME=VALUE] " - "...]]\n" - " [resource [[-alo NAME=VALUE] ...]]\n" - " [-ds ds_name][-f ds_format][-l layer_name]\n" - " [[-dsco NAME=VALUE] ...][-lco NAME=VALUE]\n" - " gnm_name\n"); + " [dijkstra =]...]\n" + " [kpaths " + "[-alo NAME=VALUE]...]\n" + " [resource [-alo =]...]\n" + " [-ds ][-f ][-l ]\n" + " [-dsco =]... [-lco =]...\n" + " \n"); if (bShort) { @@ -65,39 +67,35 @@ static void Usage(const char *pszAdditionalMsg, int bShort = TRUE) exit(1); } - printf("\n dijkstra start_gfid end_gfid: calculates the best path " - "between two points using Dijkstra algorithm from start_gfid point " - "to end_gfid point\n" - " kpaths start_gfid end_gfid k: calculates k (up to 10) best " - "paths between two points using Yen\'s algorithm (which internally " - "uses Dijkstra algorithm for single path calculating) from " - "start_gfid point to end_gfid point\n" - " resource: calculates the \"resource distribution\". The " - "connected components search is performed using breadth-first " - "search and starting from that features which are marked by rules " - "as \'EMITTERS\'\n" - " -ds ds_name: the name&path of the dataset to save the layer " - "with resulting paths. Not need to be existed dataset\n" - " -f ds_format: define this to set the format of newly created " - "dataset\n" - " -l layer_name: the name of the resulting layer. If the layer " - "exists already - it will be rewritten. For K shortest paths " - "several layers are created in format layer_nameN, where N - is " - "number of the path (0 - is the most shortest one)\n" - " -dsco NAME=VALUE: Dataset creation option (format specific)\n" - " -lco NAME=VALUE: Layer creation option (format specific)\n" - " -alo NAME=VALUE: Algorithm option (format specific)\n" - " gnm_name: the network to work with (path and name)\n"); + fprintf(bIsError ? stderr : stdout, + "\n dijkstra start_gfid end_gfid: calculates the best path " + "between two points using Dijkstra algorithm from start_gfid point " + "to end_gfid point\n" + " kpaths start_gfid end_gfid k: calculates k (up to 10) best " + "paths between two points using Yen\'s algorithm (which internally " + "uses Dijkstra algorithm for single path calculating) from " + "start_gfid point to end_gfid point\n" + " resource: calculates the \"resource distribution\". The " + "connected components search is performed using breadth-first " + "search and starting from that features which are marked by rules " + "as \'EMITTERS\'\n" + " -ds ds_name: the name&path of the dataset to save the layer " + "with resulting paths. Not need to be existed dataset\n" + " -f ds_format: define this to set the format of newly created " + "dataset\n" + " -l layer_name: the name of the resulting layer. If the layer " + "exists already - it will be rewritten. For K shortest paths " + "several layers are created in format layer_nameN, where N - is " + "number of the path (0 - is the most shortest one)\n" + " -dsco NAME=VALUE: Dataset creation option (format specific)\n" + " -lco NAME=VALUE: Layer creation option (format specific)\n" + " -alo NAME=VALUE: Algorithm option (format specific)\n" + " gnm_name: the network to work with (path and name)\n"); if (pszAdditionalMsg) fprintf(stderr, "\nFAILURE: %s\n", pszAdditionalMsg); - exit(1); -} - -static void Usage(int bShort = TRUE) -{ - Usage(nullptr, bShort); + exit(bIsError ? 1 : 0); } /************************************************************************/ @@ -366,8 +364,8 @@ static void ReportOnLayer(OGRLayer *poLayer, int bVerbose) do \ { \ if (iArg + nExtraArg >= nArgc) \ - Usage(CPLSPrintf("%s option requires %d argument(s)", \ - papszArgv[iArg], nExtraArg)); \ + Usage(true, CPLSPrintf("%s option requires %d argument(s)", \ + papszArgv[iArg], nExtraArg)); \ } while (false) MAIN_START(nArgc, papszArgv) @@ -426,12 +424,12 @@ MAIN_START(nArgc, papszArgv) else if (EQUAL(papszArgv[iArg], "--help")) { - Usage(); + Usage(false); } else if (EQUAL(papszArgv[iArg], "--long-usage")) { - Usage(FALSE); + Usage(false, nullptr, false); } else if (EQUAL(papszArgv[iArg], "-q") || @@ -497,7 +495,8 @@ MAIN_START(nArgc, papszArgv) } else if (papszArgv[iArg][0] == '-') { - Usage(CPLSPrintf("Unknown option name '%s'", papszArgv[iArg])); + Usage(true, + CPLSPrintf("Unknown option name '%s'", papszArgv[iArg])); } else if (pszDataSource == nullptr) @@ -510,10 +509,10 @@ MAIN_START(nArgc, papszArgv) if (stOper == op_dijkstra) { if (pszDataSource == nullptr) - Usage("No network dataset provided"); + Usage(true, "No network dataset provided"); if (nFromFID == -1 || nToFID == -1) - Usage("Invalid input from or to identificators"); + Usage(true, "Invalid input from or to identificators"); // open poDS = cpl::down_cast(static_cast( @@ -546,10 +545,10 @@ MAIN_START(nArgc, papszArgv) else if (stOper == op_kpaths) { if (pszDataSource == nullptr) - Usage("No network dataset provided"); + Usage(true, "No network dataset provided"); if (nFromFID == -1 || nToFID == -1) - Usage("Invalid input from or to identificators"); + Usage(true, "Invalid input from or to identificators"); // open poDS = cpl::down_cast(static_cast( @@ -590,7 +589,7 @@ MAIN_START(nArgc, papszArgv) else if (stOper == op_resource) { if (pszDataSource == nullptr) - Usage("No network dataset provided"); + Usage(true, "No network dataset provided"); // open poDS = cpl::down_cast(static_cast( @@ -623,9 +622,10 @@ MAIN_START(nArgc, papszArgv) } else { - printf( - "\nNeed an operation. See help what you can do with gnmanalyse:\n"); - Usage(); + fprintf( + stderr, + "Need an operation. See help what you can do with gnmanalyse:\n"); + Usage(true); } exit: diff --git a/apps/gnmmanage.cpp b/apps/gnmmanage.cpp index 8e4d9268cd05..d70adf7d5c2e 100644 --- a/apps/gnmmanage.cpp +++ b/apps/gnmmanage.cpp @@ -56,39 +56,44 @@ enum operation /* Usage() */ /************************************************************************/ -static void Usage(const char *pszAdditionalMsg, - int bShort = TRUE) CPL_NO_RETURN; +static void Usage(bool bIsError, const char *pszAdditionalMsg = nullptr, + bool bShort = true) CPL_NO_RETURN; -static void Usage(const char *pszAdditionalMsg, int bShort) +static void Usage(bool bIsError, const char *pszAdditionalMsg, bool bShort) { - printf( + fprintf( + bIsError ? stderr : stdout, "Usage: gnmmanage [--help][--help-general][-q][-quiet][--long-usage]\n" " [info]\n" - " [create [-f format_name] [-t_srs srs_name] [-dsco " - "NAME=VALUE]... ]\n" - " [import src_dataset_name] [-l layer_name]\n" - " [connect gfid_src gfid_tgt gfid_con [-c cost] " - "[-ic inv_cost] [-dir dir]]\n" - " [disconnect gfid_src gfid_tgt gfid_con]\n" - " [rule rule_str]\n" - " [autoconnect tolerance]\n" + " [create [-f ] [-t_srs ] " + "[-dsco " + "=]... ]\n" + " [import ] [-l ]\n" + " [connect [-c " + "] " + "[-ic ] [-dir ]]\n" + " [disconnect ]\n" + " [rule ]\n" + " [autoconnect ]\n" " [delete]\n" - " [change [-bl gfid][-unbl gfid][-unblall]]\n" - " gnm_name [layer [layer ...]]\n"); + " [change [-bl ][-unbl ][-unblall]]\n" + " [ []...]\n"); if (bShort) { - printf("\nNote: gnmmanage --long-usage for full help.\n"); + fprintf(bIsError ? stderr : stdout, + "\nNote: gnmmanage --long-usage for full help.\n"); if (pszAdditionalMsg) fprintf(stderr, "\nFAILURE: %s\n", pszAdditionalMsg); exit(1); } - printf("\n info: different information about network: system and class " - "layers, network metadata, network spatial reference\n" - " create: create network\n" - " -f format_name: output file format name, possible values " - "are:\n"); + fprintf(bIsError ? stderr : stdout, + "\n info: different information about network: system and class " + "layers, network metadata, network spatial reference\n" + " create: create network\n" + " -f format_name: output file format name, possible values " + "are:\n"); int nGNMDriverCounter = 1; for (int iDr = 0; iDr < GDALGetDriverCount(); iDr++) @@ -123,12 +128,14 @@ static void Usage(const char *pszAdditionalMsg, int bShort) else pszSubdatasets = ""; - printf(" %d. %s (%s%s%s%s): %s\n", nGNMDriverCounter++, - GDALGetDriverShortName(hDriver), pszRFlag, pszWFlag, - pszVirtualIO, pszSubdatasets, GDALGetDriverLongName(hDriver)); + fprintf(bIsError ? stderr : stdout, " %d. %s (%s%s%s%s): %s\n", + nGNMDriverCounter++, GDALGetDriverShortName(hDriver), pszRFlag, + pszWFlag, pszVirtualIO, pszSubdatasets, + GDALGetDriverLongName(hDriver)); } - printf( + fprintf( + bIsError ? stderr : stdout, " -t_srs srs_name: spatial reference input\n" " -dsco NAME=VALUE: network creation option set as pair=value\n" " import src_dataset_name: import external layer where " @@ -159,12 +166,7 @@ static void Usage(const char *pszAdditionalMsg, int bShort) if (pszAdditionalMsg) fprintf(stderr, "\nFAILURE: %s\n", pszAdditionalMsg); - exit(1); -} - -static void Usage(int bShort = TRUE) -{ - Usage(nullptr, bShort); + exit(bIsError ? 1 : 0); } /************************************************************************/ @@ -175,8 +177,8 @@ static void Usage(int bShort = TRUE) do \ { \ if (iArg + nExtraArg >= nArgc) \ - Usage(CPLSPrintf("%s option requires %d argument(s)", \ - papszArgv[iArg], nExtraArg)); \ + Usage(true, CPLSPrintf("%s option requires %d argument(s)", \ + papszArgv[iArg], nExtraArg)); \ } while (false) MAIN_START(nArgc, papszArgv) @@ -240,12 +242,12 @@ MAIN_START(nArgc, papszArgv) else if (EQUAL(papszArgv[iArg], "--help")) { - Usage(); + Usage(false); } else if (EQUAL(papszArgv[iArg], "--long-usage")) { - Usage(FALSE); + Usage(false, nullptr, false); } else if (EQUAL(papszArgv[iArg], "-q") || @@ -390,7 +392,8 @@ MAIN_START(nArgc, papszArgv) else if (papszArgv[iArg][0] == '-') { - Usage(CPLSPrintf("Unknown option name '%s'", papszArgv[iArg])); + Usage(true, + CPLSPrintf("Unknown option name '%s'", papszArgv[iArg])); } else if (pszDataSource == nullptr) @@ -405,7 +408,7 @@ MAIN_START(nArgc, papszArgv) if (stOper == op_info) { if (pszDataSource == nullptr) - Usage("No network dataset provided"); + Usage(true, "No network dataset provided"); // TODO for output: // stats about graph and blocked features @@ -524,7 +527,7 @@ MAIN_START(nArgc, papszArgv) const char *pszNetworkName = CSLFetchNameValue(papszDSCO, GNM_MD_NAME); if (pszDataSource == nullptr) - Usage("No network dataset provided"); + Usage(true, "No network dataset provided"); // the DSCO have priority on input keys if (nullptr == pszNetworkName) @@ -539,7 +542,7 @@ MAIN_START(nArgc, papszArgv) } if (pszNetworkName == nullptr) - Usage("No dataset name provided"); + Usage(true, "No dataset name provided"); const char *pszFinalSRS = CSLFetchNameValue(papszDSCO, GNM_MD_SRS); if (nullptr == pszFinalSRS) @@ -549,22 +552,22 @@ MAIN_START(nArgc, papszArgv) } if (nullptr == pszFinalSRS) - Usage("No spatial reference provided"); + Usage(true, "No spatial reference provided"); if (pszFormat == nullptr) - Usage("No output format provided"); + Usage(true, "No output format provided"); GDALDriver *poDriver = GetGDALDriverManager()->GetDriverByName(pszFormat); if (poDriver == nullptr) { - Usage(CPLSPrintf("%s driver not available", pszFormat)); + Usage(true, CPLSPrintf("%s driver not available", pszFormat)); } else { char **papszMD = poDriver->GetMetadata(); if (!CPLFetchBool(papszMD, GDAL_DCAP_GNM, false)) - Usage("not a GNM driver"); + Usage(true, "not a GNM driver"); poDS = cpl::down_cast( poDriver->Create(pszPath, 0, 0, 0, GDT_Unknown, papszDSCO)); @@ -591,10 +594,10 @@ MAIN_START(nArgc, papszArgv) else if (stOper == op_import) { if (pszDataSource == nullptr) - Usage("No network dataset provided"); + Usage(true, "No network dataset provided"); if (pszInputDataset == nullptr) - Usage("No input dataset name provided"); + Usage(true, "No input dataset name provided"); // open poDS = cpl::down_cast(static_cast( @@ -672,7 +675,7 @@ MAIN_START(nArgc, papszArgv) else if (stOper == op_connect) { if (pszDataSource == nullptr) - Usage("No network dataset provided"); + Usage(true, "No network dataset provided"); // open poDS = cpl::down_cast(static_cast( @@ -714,7 +717,7 @@ MAIN_START(nArgc, papszArgv) else if (stOper == op_disconnect) { if (pszDataSource == nullptr) - Usage("No network dataset provided"); + Usage(true, "No network dataset provided"); // open poDS = cpl::down_cast(static_cast( @@ -755,7 +758,7 @@ MAIN_START(nArgc, papszArgv) else if (stOper == op_rule) { if (pszDataSource == nullptr) - Usage("No network dataset provided"); + Usage(true, "No network dataset provided"); // open poDS = cpl::down_cast(static_cast( @@ -795,7 +798,7 @@ MAIN_START(nArgc, papszArgv) else if (stOper == op_autoconnect) { if (pszDataSource == nullptr) - Usage("No network dataset provided"); + Usage(true, "No network dataset provided"); // open poDS = cpl::down_cast(static_cast( @@ -855,7 +858,7 @@ MAIN_START(nArgc, papszArgv) else if (stOper == op_delete) { if (pszDataSource == nullptr) - Usage("No network dataset provided"); + Usage(true, "No network dataset provided"); // open poDS = cpl::down_cast(static_cast( @@ -901,7 +904,7 @@ MAIN_START(nArgc, papszArgv) else if (stOper == op_change_st) { if (pszDataSource == nullptr) - Usage("No dataset in input"); + Usage(true, "No dataset in input"); // open poDS = cpl::down_cast(static_cast( @@ -974,9 +977,10 @@ MAIN_START(nArgc, papszArgv) } else { - printf( - "\nNeed an operation. See help what you can do with gnmmanage:\n"); - Usage(); + fprintf( + stderr, + "Need an operation. See help what you can do with gnmmanage:\n"); + Usage(true); } exit: diff --git a/apps/nearblack_bin.cpp b/apps/nearblack_bin.cpp index 026554cdc103..5ff9a1fbc544 100644 --- a/apps/nearblack_bin.cpp +++ b/apps/nearblack_bin.cpp @@ -35,18 +35,20 @@ /* Usage() */ /************************************************************************/ -static void Usage(const char *pszErrorMsg = nullptr) +static void Usage(bool bIsError, const char *pszErrorMsg = nullptr) { - printf("nearblack [--help] [--help-general]\n" - " [-of format] [-white | [-color c1,c2,c3...cn]*]\n" - " [-near dist] [-nb non_black_pixels]\n" - " [-setalpha] [-setmask] [-alg twopasses|floodfill]\n" - " [-o outfile] [-q] [-co \"NAME=VALUE\"]* infile\n"); + fprintf(bIsError ? stderr : stdout, + "Usage: nearblack [--help] [--help-general]\n" + " [-of ] [-white | [-color " + ",,...]...]\n" + " [-near ] [-nb ]\n" + " [-setalpha] [-setmask] [-alg twopasses|floodfill]\n" + " [-o ] [-q] [-co =]... \n"); if (pszErrorMsg != nullptr) fprintf(stderr, "\nFAILURE: %s\n", pszErrorMsg); - exit(1); + exit(bIsError ? 1 : 0); } /************************************************************************/ @@ -108,7 +110,7 @@ MAIN_START(argc, argv) } else if (EQUAL(argv[i], "--help")) { - Usage(); + Usage(false); } } @@ -120,7 +122,7 @@ MAIN_START(argc, argv) if (psOptions == nullptr) { - Usage(); + Usage(true); } if (!(psOptionsForBinary->bQuiet)) @@ -129,7 +131,7 @@ MAIN_START(argc, argv) } if (psOptionsForBinary->pszInFile == nullptr) - Usage("No input file specified."); + Usage(true, "No input file specified."); if (psOptionsForBinary->pszOutFile == nullptr) psOptionsForBinary->pszOutFile = @@ -161,7 +163,7 @@ MAIN_START(argc, argv) GDALDatasetH hRetDS = GDALNearblack(psOptionsForBinary->pszOutFile, hOutDS, hInDS, psOptions, &bUsageError); if (bUsageError) - Usage(); + Usage(true); int nRetCode = hRetDS ? 0 : 1; if (GDALClose(hInDS) != CE_None) diff --git a/apps/ogr2ogr_bin.cpp b/apps/ogr2ogr_bin.cpp index e673b129265b..b0d708697561 100644 --- a/apps/ogr2ogr_bin.cpp +++ b/apps/ogr2ogr_bin.cpp @@ -62,58 +62,65 @@ static bool StringCISortFunction(const CPLString &a, const CPLString &b) return STRCASECMP(a.c_str(), b.c_str()) < 0; } -static void Usage(const char *pszAdditionalMsg = nullptr, bool bShort = true) +static void Usage(bool bIsError, const char *pszAdditionalMsg = nullptr, + bool bShort = true) { - printf( + fprintf( + bIsError ? stderr : stdout, "Usage: ogr2ogr [--help] [--help-general]\n" " [-skipfailures] [-append | -upsert] [-update]\n" - " [-select field_list] [-where " - "restricted_where|@filename]\n" - " [-progress] [-sql |@filename] [-dialect " - "dialect]\n" - " [-preserve_fid] [-fid FID] [-limit nb_features]\n" - " [-spat xmin ymin xmax ymax] [-spat_srs srs_def] " - "[-geomfield field]\n" - " [-a_srs srs_def] [-t_srs srs_def] [-s_srs srs_def] " - "[-ct string]\n" - " [-f format_name] [-overwrite] [[-dsco NAME=VALUE] " - "...]\n" - " dst_datasource_name src_datasource_name\n" - " [-lco NAME=VALUE] [-nln name] \n" + " [-select ] [-where " + "|@]\n" + " [-progress] [-sql |@] " + "[-dialect " + "]\n" + " [-preserve_fid] [-fid ] [-limit ]\n" + " [-spat ] [-spat_srs " + "] " + "[-geomfield ]\n" + " [-a_srs ] [-t_srs ] [-s_srs " + "] " + "[-ct ]\n" + " [-f ] [-overwrite] " + "[-dsco =]...\n" + " [-lco =]... [-nln ] \n" " [-nlt " - "type|PROMOTE_TO_MULTI|CONVERT_TO_LINEAR|CONVERT_TO_CURVE]\n" - " [-dim XY|XYZ|XYM|XYZM|layer_dim] [layer [layer ...]]\n" + "|PROMOTE_TO_MULTI|CONVERT_TO_LINEAR|CONVERT_TO_CURVE]\n" + " [-dim XY|XYZ|XYM|XYZM|]\n" + " \n" + " [ [...]]\n" "\n" "Advanced options :\n" " [-gt n] [-ds_transaction]\n" - " [[-oo NAME=VALUE] ...] [[-doo NAME=VALUE] ...]\n" - " [-clipsrc [xmin ymin xmax " - "ymax]|WKT|datasource|spat_extent]\n" - " [-clipsrcsql sql_statement] [-clipsrclayer layer]\n" - " [-clipsrcwhere expression]\n" - " [-clipdst [xmin ymin xmax ymax]|WKT|datasource]\n" - " [-clipdstsql sql_statement] [-clipdstlayer layer]\n" - " [-clipdstwhere expression]\n" - " [-wrapdateline][-datelineoffset val]\n" - " [[-simplify tolerance] | [-segmentize max_dist]]\n" + " [-oo =]... [-doo =]...\n" + " [-clipsrc {[ ]||" + "|spat_extent}]\n" + " [-clipsrcsql ] [-clipsrclayer ]\n" + " [-clipsrcwhere ]\n" + " [-clipdst {[ " + "]||}]\n" + " [-clipdstsql ] [-clipdstlayer ]\n" + " [-clipdstwhere ]\n" + " [-wrapdateline][-datelineoffset ]\n" + " [[-simplify ] | [-segmentize ]]\n" " [-makevalid]\n" " [-addfields] [-unsetFid] [-emptyStrAsNull]\n" " [-relaxedFieldNameMatch] [-forceNullable] " "[-unsetDefault]\n" - " [-fieldTypeToString All|(type1[,type2]*)] " + " [-fieldTypeToString {All|{[,]}...}] " "[-unsetFieldWidth]\n" " [-mapFieldType " - "srctype|All=dsttype[,srctype2=dsttype2]*]\n" - " [-dateTimeTo UTC|UTC(+|-)HH|UTC(+|-)HH:MM]]\n" - " [-fieldmap identity | index1[,index2]*]\n" - " [-splitlistfields] [-maxsubfields val]\n" + "{|All=[,=]...}]\n" + " [-dateTimeTo {UTC|UTC(+|-)|UTC(+|-):}]\n" + " [-fieldmap {identity|{[,]...}]\n" + " [-splitlistfields] [-maxsubfields ]\n" " [-resolveDomains]\n" - " [-explodecollections] [-zfield field_name]\n" - " [-gcp ungeoref_x ungeoref_y georef_x georef_y " - "[elevation]]* [-order n | -tps]\n" - " [-s_coord_epoch epoch] [-t_coord_epoch epoch] " - "[-a_coord_epoch epoch]\n" - " [-nomd] [-mo \"META-TAG=VALUE\"]* [-noNativeData]\n"); + " [-explodecollections] [-zfield ]\n" + " [-gcp " + "[]]... [[-order ]|[-tps]]\n" + " [-s_coord_epoch ] [-t_coord_epoch ] " + "[-a_coord_epoch ]\n" + " [-nomd] [-mo =]... [-noNativeData]\n"); if (bShort) { @@ -297,12 +304,14 @@ MAIN_START(nArgc, papszArgv) } else if (EQUAL(papszArgv[iArg], "--help")) { - Usage(); + Usage(false); + nRetCode = 0; goto exit; } else if (EQUAL(papszArgv[iArg], "--long-usage")) { - Usage(nullptr, false); + Usage(false, nullptr, false); + nRetCode = 0; goto exit; } } @@ -313,7 +322,7 @@ MAIN_START(nArgc, papszArgv) if (psOptions == nullptr) { - Usage(); + Usage(true); GDALVectorTranslateOptionsForBinaryFree(psOptionsForBinary); goto exit; } @@ -322,9 +331,9 @@ MAIN_START(nArgc, papszArgv) psOptionsForBinary->pszDestDataSource == nullptr) { if (psOptionsForBinary->pszDestDataSource == nullptr) - Usage("no target datasource provided"); + Usage(true, "no target datasource provided"); else - Usage("no source datasource provided"); + Usage(true, "no source datasource provided"); GDALVectorTranslateOptionsFree(psOptions); GDALVectorTranslateOptionsForBinaryFree(psOptionsForBinary); goto exit; @@ -446,7 +455,7 @@ MAIN_START(nArgc, papszArgv) hDstDS = GDALVectorTranslate(psOptionsForBinary->pszDestDataSource, hODS, 1, &hDS, psOptions, &bUsageError); if (bUsageError) - Usage(); + Usage(true); else nRetCode = hDstDS ? 0 : 1; } diff --git a/apps/ogrinfo_bin.cpp b/apps/ogrinfo_bin.cpp index a3fb6c66363a..c637db890724 100644 --- a/apps/ogrinfo_bin.cpp +++ b/apps/ogrinfo_bin.cpp @@ -40,27 +40,31 @@ /* Usage() */ /************************************************************************/ -static void Usage(const char *pszErrorMsg = nullptr) +static void Usage(bool bIsError, const char *pszErrorMsg = nullptr) { - printf("Usage: ogrinfo [--help] [--help-general]\n" - " [-json] [-ro] [-q] [-where " - "restricted_where|@filename]\n" - " [-spat xmin ymin xmax ymax] [-geomfield field] " - "[-fid fid]\n" - " [-sql statement|@filename] [-dialect sql_dialect] " - "[-al] [-rl]\n" - " [-so|-features] [-fields={YES/NO}]]\n" - " [-geom={YES/NO/SUMMARY}] [[-oo NAME=VALUE] ...]\n" - " [-nomd] [-listmdd] [-mdd domain|`all`]*\n" - " [-nocount] [-noextent] [-nogeomtype] [-wkt_format " - "WKT1|WKT2|...]\n" - " [-fielddomain name]\n" - " datasource_name [layer [layer ...]]\n"); + fprintf(bIsError ? stderr : stdout, + "Usage: ogrinfo [--help] [--help-general]\n" + " [-json] [-ro] [-q] [-where " + "|@f]\n" + " [-spat ] [-geomfield " + "] " + "[-fid ]\n" + " [-sql |@] [-dialect " + "] " + "[-al] [-rl]\n" + " [-so|-features] [-fields={YES|NO}]]\n" + " [-geom={YES|NO|SUMMARY|WKT|ISO_WKT}] " + "[-oo =]...\n" + " [-nomd] [-listmdd] [-mdd {|all}]...\n" + " [-nocount] [-noextent] [-nogeomtype] [-wkt_format " + "WKT1|WKT2|]\n" + " [-fielddomain ]\n" + " [ [ ...]]\n"); if (pszErrorMsg != nullptr) fprintf(stderr, "\nFAILURE: %s\n", pszErrorMsg); - exit(1); + exit(bIsError ? 1 : 0); } /************************************************************************/ @@ -94,7 +98,7 @@ MAIN_START(argc, argv) } else if (EQUAL(argv[i], "--help")) { - Usage(); + Usage(false); } } argv = CSLAddString(argv, "-stdout"); @@ -105,10 +109,10 @@ MAIN_START(argc, argv) GDALVectorInfoOptions *psOptions = GDALVectorInfoOptionsNew(argv + 1, psOptionsForBinary.get()); if (psOptions == nullptr) - Usage(); + Usage(true); if (psOptionsForBinary->osFilename.empty()) - Usage("No datasource specified."); + Usage(true, "No datasource specified."); /* -------------------------------------------------------------------- */ /* Open dataset. */ diff --git a/apps/ogrlineref.cpp b/apps/ogrlineref.cpp index eef67e042032..03042117e266 100644 --- a/apps/ogrlineref.cpp +++ b/apps/ogrlineref.cpp @@ -74,37 +74,42 @@ typedef struct _curve_data /************************************************************************/ /* Usage() */ /************************************************************************/ -static void Usage(const char *pszAdditionalMsg, +static void Usage(bool bIsError, const char *pszAdditionalMsg = nullptr, bool bShort = true) CPL_NO_RETURN; -static void Usage(const char *pszAdditionalMsg, bool bShort) +static void Usage(bool bIsError, const char *pszAdditionalMsg, bool bShort) { OGRSFDriverRegistrar *poR = OGRSFDriverRegistrar::GetRegistrar(); - printf("Usage: ogrlineref [--help] [--help-general] [-progress] [-quiet]\n" - " [-f format_name] [[-dsco NAME=VALUE] ...] [[-lco " - "NAME=VALUE]...]\n" - " [-create]\n" - " [-l src_line_datasource_name] [-ln layer_name] [-lf " - "field_name]\n" - " [-p src_repers_datasource_name] [-pn layer_name] " - "[-pm pos_field_name] [-pf field_name]\n" - " [-r src_parts_datasource_name] [-rn layer_name]\n" - " [-o dst_datasource_name] [-on layer_name] [-of " - "field_name] [-s step]\n" - " [-get_pos] [-x long] [-y lat]\n" - " [-get_coord] [-m position] \n" - " [-get_subline] [-mb position] [-me position]\n"); + fprintf( + bIsError ? stderr : stdout, + "Usage: ogrlineref [--help] [--help-general] [-progress] [-quiet]\n" + " [-f ] [-dsco =]... [-lco " + "=]...\n" + " [-create]\n" + " [-l ] [-ln ] " + "[-lf " + "]\n" + " [-p ] [-pn ] " + "[-pm ] [-pf ]\n" + " [-r ] [-rn ]\n" + " [-o ] [-on ] [-of " + "] [-s ]\n" + " [-get_pos] [-x ] [-y ]\n" + " [-get_coord] [-m ] \n" + " [-get_subline] [-mb ] [-me ]\n"); if (bShort) { - printf("\nNote: ogrlineref --long-usage for full help.\n"); + fprintf(bIsError ? stderr : stdout, + "\nNote: ogrlineref --long-usage for full help.\n"); if (pszAdditionalMsg) fprintf(stderr, "\nFAILURE: %s\n", pszAdditionalMsg); exit(1); } - printf( + fprintf( + bIsError ? stderr : stdout, "\n -f format_name: output file format name, possible values are:\n"); for (int iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++) @@ -113,40 +118,37 @@ static void Usage(const char *pszAdditionalMsg, bool bShort) if (CPLTestBool(CSLFetchNameValueDef(poDriver->GetMetadata(), GDAL_DCAP_CREATE, "FALSE"))) - printf(" -f \"%s\"\n", poDriver->GetDescription()); + fprintf(bIsError ? stderr : stdout, " -f \"%s\"\n", + poDriver->GetDescription()); } - printf(" -progress: Display progress on terminal. Only works if input " - "layers have the \n" - " \"fast feature count\" " - "capability\n" - " -dsco NAME=VALUE: Dataset creation option (format specific)\n" - " -lco NAME=VALUE: Layer creation option (format specific)\n" - " -l src_line_datasource_name: Datasource of line path name\n" - " -ln layer_name: Layer name in datasource (optional)\n" - " -lf field_name: Field name for unique paths in layer (optional)\n" - " -p src_repers_datasource_name: Datasource of repers name\n" - " -pn layer_name: Layer name in datasource (optional)\n" - " -pm pos_field_name: Line position field name\n" - " -pf field_name: Field name for correspondence repers of separate " - "paths in layer (optional)\n" - " -r src_parts_datasource_name: Parts datasource name\n" - " -rn layer_name: Layer name in datasource (optional)\n" - " -o dst_datasource_name: Parts datasource name\n" - " -on layer_name: Layer name in datasource (optional)\n" - " -of field_name: Field name for correspondence parts of separate " - "paths in layer (optional)\n" - " -s step: part size in m\n"); + fprintf(bIsError ? stderr : stdout, + " -progress: Display progress on terminal. Only works if input " + "layers have the \n" + " \"fast feature count\" " + "capability\n" + " -dsco NAME=VALUE: Dataset creation option (format specific)\n" + " -lco NAME=VALUE: Layer creation option (format specific)\n" + " -l src_line_datasource_name: Datasource of line path name\n" + " -ln layer_name: Layer name in datasource (optional)\n" + " -lf field_name: Field name for unique paths in layer (optional)\n" + " -p src_repers_datasource_name: Datasource of repers name\n" + " -pn layer_name: Layer name in datasource (optional)\n" + " -pm pos_field_name: Line position field name\n" + " -pf field_name: Field name for correspondence repers of separate " + "paths in layer (optional)\n" + " -r src_parts_datasource_name: Parts datasource name\n" + " -rn layer_name: Layer name in datasource (optional)\n" + " -o dst_datasource_name: Parts datasource name\n" + " -on layer_name: Layer name in datasource (optional)\n" + " -of field_name: Field name for correspondence parts of separate " + "paths in layer (optional)\n" + " -s step: part size in m\n"); if (pszAdditionalMsg) fprintf(stderr, "\nFAILURE: %s\n", pszAdditionalMsg); - exit(1); -} - -static void Usage(bool bShort = true) -{ - Usage(nullptr, bShort); + exit(bIsError ? 1 : 0); } /************************************************************************/ @@ -1262,8 +1264,8 @@ static OGRErr GetCoordinates(OGRLayer *const poPkLayer, double dfPos, do \ { \ if (iArg + nExtraArg >= nArgc) \ - Usage(CPLSPrintf("%s option requires %d argument(s)", \ - papszArgv[iArg], nExtraArg)); \ + Usage(true, CPLSPrintf("%s option requires %d argument(s)", \ + papszArgv[iArg], nExtraArg)); \ } while (false) MAIN_START(nArgc, papszArgv) @@ -1338,11 +1340,11 @@ MAIN_START(nArgc, papszArgv) } else if (EQUAL(papszArgv[iArg], "--help")) { - Usage(); + Usage(false); } else if (EQUAL(papszArgv[iArg], "--long-usage")) { - Usage(false); + Usage(false, nullptr, false); } else if (EQUAL(papszArgv[iArg], "-q") || @@ -1548,7 +1550,8 @@ MAIN_START(nArgc, papszArgv) } else if (papszArgv[iArg][0] == '-') { - Usage(CPLSPrintf("Unknown option name '%s'", papszArgv[iArg])); + Usage(true, + CPLSPrintf("Unknown option name '%s'", papszArgv[iArg])); } } @@ -1556,15 +1559,15 @@ MAIN_START(nArgc, papszArgv) { #ifdef HAVE_GEOS if (pszOutputDataSource == nullptr) - Usage("no output datasource provided"); + Usage(true, "no output datasource provided"); else if (pszLineDataSource == nullptr) - Usage("no path datasource provided"); + Usage(true, "no path datasource provided"); else if (pszPicketsDataSource == nullptr) - Usage("no repers datasource provided"); + Usage(true, "no repers datasource provided"); else if (pszPicketsMField == nullptr) - Usage("no position field provided"); + Usage(true, "no position field provided"); else if (dfStep == -100000000.0) - Usage("no step provided"); + Usage(true, "no step provided"); /* -------------------------------------------------------------------- */ @@ -1745,9 +1748,9 @@ MAIN_START(nArgc, papszArgv) { #ifdef HAVE_GEOS if (pszPartsDataSource == nullptr) - Usage("no parts datasource provided"); + Usage(true, "no parts datasource provided"); else if (dfX == -100000000.0 || dfY == -100000000.0) - Usage("no coordinates provided"); + Usage(true, "no coordinates provided"); GDALDataset *poPartsDS = GDALDataset::FromHandle( OGROpen(pszPartsDataSource, FALSE, nullptr)); @@ -1799,9 +1802,9 @@ MAIN_START(nArgc, papszArgv) else if (stOper == op_get_coord) { if (pszPartsDataSource == nullptr) - Usage("no parts datasource provided"); + Usage(true, "no parts datasource provided"); else if (dfPos == -100000000.0) - Usage("no position provided"); + Usage(true, "no position provided"); GDALDataset *poPartsDS = GDALDataset::FromHandle( OGROpen(pszPartsDataSource, FALSE, nullptr)); @@ -1847,13 +1850,13 @@ MAIN_START(nArgc, papszArgv) else if (stOper == op_get_subline) { if (pszOutputDataSource == nullptr) - Usage("no output datasource provided"); + Usage(true, "no output datasource provided"); else if (pszPartsDataSource == nullptr) - Usage("no parts datasource provided"); + Usage(true, "no parts datasource provided"); else if (dfPosBeg == -100000000.0) - Usage("no begin position provided"); + Usage(true, "no begin position provided"); else if (dfPosEnd == -100000000.0) - Usage("no end position provided"); + Usage(true, "no end position provided"); // Open data source. GDALDataset *poPartsDS = GDALDataset::FromHandle( @@ -1951,7 +1954,7 @@ MAIN_START(nArgc, papszArgv) } else { - Usage("no operation provided"); + Usage(true, "no operation provided"); } CSLDestroy(papszArgv); diff --git a/apps/ogrtindex.cpp b/apps/ogrtindex.cpp index 26dd01216d95..92bbfb7f8f84 100644 --- a/apps/ogrtindex.cpp +++ b/apps/ogrtindex.cpp @@ -52,54 +52,65 @@ typedef enum /* Usage() */ /************************************************************************/ -static void Usage() +static void Usage(bool bIsError) { - printf( + fprintf( + bIsError ? stderr : stdout, "Usage: ogrtindex [--help] [--help-general]\n" - " [-lnum n]... [-lname name]... [-f output_format]\n" + " [-lnum ]... [-lname ]... [-f " + "]\n" " [-write_absolute_path] [-skip_different_projection]\n" - " [-t_srs target_srs]\n" - " [-src_srs_name field_name] [-src_srs_format " - "[AUTO|WKT|EPSG|PROJ]\n" + " [-t_srs ]\n" + " [-src_srs_name ] [-src_srs_format " + "{AUTO|WKT|EPSG|PROJ}]\n" " [-accept_different_schemas]\n" - " output_dataset src_dataset...\n"); - printf("\n"); - printf(" -lnum n: Add layer number 'n' from each source file\n" - " in the tile index.\n"); - printf(" -lname name: Add the layer named 'name' from each source file\n" - " in the tile index.\n"); - printf(" -f output_format: Select an output format name.\n"); - printf(" -tileindex field_name: The name to use for the dataset name.\n" - " Defaults to LOCATION.\n"); - printf( + " ...\n"); + fprintf(bIsError ? stderr : stdout, "\n"); + fprintf(bIsError ? stderr : stdout, + " -lnum n: Add layer number 'n' from each source file\n" + " in the tile index.\n"); + fprintf(bIsError ? stderr : stdout, + " -lname name: Add the layer named 'name' from each source file\n" + " in the tile index.\n"); + fprintf(bIsError ? stderr : stdout, + " -f output_format: Select an output format name.\n"); + fprintf(bIsError ? stderr : stdout, + " -tileindex field_name: The name to use for the dataset name.\n" + " Defaults to LOCATION.\n"); + fprintf( + bIsError ? stderr : stdout, " -write_absolute_path: Filenames are written with absolute paths.\n"); - printf( + fprintf( + bIsError ? stderr : stdout, " -skip_different_projection: Only layers with same projection ref \n" " as layers already inserted in the tileindex will be " "inserted.\n"); - printf(" -accept_different_schemas: by default ogrtindex checks that all " - "layers inserted\n" - " into the index have the same " - "attribute schemas. If you\n" - " specify this option, this test will " - "be disabled. Be aware that\n" - " resulting index may be incompatible " - "with MapServer!\n"); - printf(" - If -t_srs is specified, geometries of input files will be " - "transformed to the desired\n" - " target coordinate reference system.\n" - " Note that using this option generates files that are NOT " - "compatible with MapServer < 7.2.\n" - " - Simple rectangular polygons are generated in the same " - "coordinate reference system\n" - " as the vectors, or in target reference system if the -t_srs " - "option is used.\n"); - printf("\n"); - printf("If no -lnum or -lname arguments are given it is assumed that\n" - "all layers in source datasets should be added to the tile index\n" - "as independent records.\n"); - exit(1); + fprintf(bIsError ? stderr : stdout, + " -accept_different_schemas: by default ogrtindex checks that all " + "layers inserted\n" + " into the index have the same " + "attribute schemas. If you\n" + " specify this option, this test will " + "be disabled. Be aware that\n" + " resulting index may be incompatible " + "with MapServer!\n"); + fprintf(bIsError ? stderr : stdout, + " - If -t_srs is specified, geometries of input files will be " + "transformed to the desired\n" + " target coordinate reference system.\n" + " Note that using this option generates files that are NOT " + "compatible with MapServer < 7.2.\n" + " - Simple rectangular polygons are generated in the same " + "coordinate reference system\n" + " as the vectors, or in target reference system if the -t_srs " + "option is used.\n"); + fprintf(bIsError ? stderr : stdout, "\n"); + fprintf(bIsError ? stderr : stdout, + "If no -lnum or -lname arguments are given it is assumed that\n" + "all layers in source datasets should be added to the tile index\n" + "as independent records.\n"); + exit(bIsError ? 1 : 0); } /************************************************************************/ @@ -150,7 +161,7 @@ MAIN_START(nArgc, papszArgv) } else if (EQUAL(papszArgv[iArg], "--help")) { - Usage(); + Usage(false); } else if (iArg < nArgc - 1 && (EQUAL(papszArgv[iArg], "-f") || EQUAL(papszArgv[iArg], "-of"))) @@ -205,7 +216,7 @@ MAIN_START(nArgc, papszArgv) } else if (papszArgv[iArg][0] == '-') { - Usage(); + Usage(true); } else if (pszOutputName == nullptr) { @@ -218,14 +229,14 @@ MAIN_START(nArgc, papszArgv) } if (pszOutputName == nullptr || nFirstSourceDataset == -1) - Usage(); + Usage(true); if (bSrcSRSFormatSpecified && pszSrcSRSName == nullptr) { fprintf(stderr, "-src_srs_name must be specified when -src_srs_format is " "specified.\n"); - Usage(); + Usage(true); } /* -------------------------------------------------------------------- */ diff --git a/apps/sozip.cpp b/apps/sozip.cpp index c8118bc84568..10524132c1de 100644 --- a/apps/sozip.cpp +++ b/apps/sozip.cpp @@ -39,26 +39,27 @@ /* Usage() */ /************************************************************************/ -static void Usage(const char *pszErrorMsg = nullptr) +static void Usage(bool bIsError, const char *pszErrorMsg = nullptr) { - printf("Usage: sozip [--help] [--help-general] [--quiet|--verbose]\n" - " [[-g|--grow] | [--overwrite]]\n" - " [-r|--recurse-paths]\n" - " [-j|--junk]\n" - " [-l|--list]\n" - " [--validate]\n" - " [--optimize-from=input.zip]\n" - " [--enable-sozip=auto/yes/no]\n" - " [--sozip-chunk-size=value]\n" - " [--sozip-min-file-size=value]\n" - " [--content-type=value]\n" - " zip_filename [filename]*\n"); + fprintf(bIsError ? stderr : stdout, + "Usage: sozip [--help] [--help-general] [--quiet|--verbose]\n" + " [[-g|--grow] | [--overwrite]]\n" + " [-r|--recurse-paths]\n" + " [-j|--junk]\n" + " [-l|--list]\n" + " [--validate]\n" + " [--optimize-from=input.zip]\n" + " [--enable-sozip={auto|yes|no}]\n" + " [--sozip-chunk-size=]\n" + " [--sozip-min-file-size=]\n" + " [--content-type=]\n" + " []...\n"); if (pszErrorMsg) fprintf(stderr, "\nFAILURE: %s\n", pszErrorMsg); - exit(1); + exit(bIsError ? 1 : 0); } /************************************************************************/ @@ -393,7 +394,7 @@ MAIN_START(nArgc, papszArgv) } else if (strcmp(papszArgv[iArg], "--help") == 0) { - Usage(); + Usage(false); } else if (strcmp(papszArgv[iArg], "--quiet") == 0) { @@ -489,7 +490,7 @@ MAIN_START(nArgc, papszArgv) } else if (papszArgv[iArg][0] == '-') { - Usage(CPLSPrintf("Unhandled option %s", papszArgv[iArg])); + Usage(true, CPLSPrintf("Unhandled option %s", papszArgv[iArg])); } else if (pszZipFilename == nullptr) { @@ -503,7 +504,7 @@ MAIN_START(nArgc, papszArgv) if (!pszZipFilename) { - Usage("Missing zip filename"); + Usage(true, "Missing zip filename"); return 1; } @@ -511,20 +512,21 @@ MAIN_START(nArgc, papszArgv) (pszOptimizeFrom != nullptr ? 1 : 0) > 1) { - Usage("--validate, --list, --optimize-from and create/append modes are " + Usage(true, + "--validate, --list, --optimize-from and create/append modes are " "mutually exclusive"); return 1; } if (!bList && !bValidate && pszOptimizeFrom == nullptr && aosFiles.empty()) { - Usage("Missing source filename(s)"); + Usage(true, "Missing source filename(s)"); return 1; } if (!EQUAL(CPLGetExtension(pszZipFilename), "zip")) { - Usage("Extension of zip filename should be .zip"); + Usage(true, "Extension of zip filename should be .zip"); return 1; } diff --git a/doc/source/programs/gdal2tiles.rst b/doc/source/programs/gdal2tiles.rst index 46a2eb939956..abc29fc71dd6 100644 --- a/doc/source/programs/gdal2tiles.rst +++ b/doc/source/programs/gdal2tiles.rst @@ -17,12 +17,12 @@ Synopsis gdal2tiles.py [--help] [--help-general] - [-p profile] [-r resampling] [-s srs] [-z zoom] - [-e] [-a nodata] [-v] [-q] [-h] [-k] [-n] [-u url] - [-w webviewer] [-t title] [-c copyright] - [--processes=NB_PROCESSES] [--mpi] [--xyz] - [--tilesize=PIXELS] [--tmscompatible] - [-g googlekey] [-b bingkey] input_file [output_dir] [COMMON_OPTIONS] + [-p ] [-r resampling] [-s ] [-z ] + [-e] [-a nodata] [-v] [-q] [-h] [-k] [-n] [-u ] + [-w ] [-t ] [-c <copyright>] + [--processes=<NB_PROCESSES>] [--mpi] [--xyz] + [--tilesize=<PIXELS>] [--tmscompatible] + [-g <googlekey] [-b <bingkey>] <input_file> [<output_dir>] [<COMMON_OPTIONS>] Description ----------- diff --git a/doc/source/programs/gdal2xyz.rst b/doc/source/programs/gdal2xyz.rst index db66bab9a275..a3dc4738e959 100644 --- a/doc/source/programs/gdal2xyz.rst +++ b/doc/source/programs/gdal2xyz.rst @@ -16,13 +16,13 @@ Synopsis .. code-block:: gdal2xyz [--help] [--help-general] - [-skip factor] - [-srcwin xoff yoff xsize ysize] - [-b band]* [-allbands] + [-skip <factor>] + [-srcwin <xoff> <yoff> <xsize> <ysize>] + [-b <band>]... [-allbands] [-skipnodata] [-csv] - [-srcnodata value] [-dstnodata value] - src_dataset [dst_dataset] + [-srcnodata <value>] [-dstnodata <value>] + <src_dataset> [<dst_dataset>] Description ----------- diff --git a/doc/source/programs/gdal_calc.rst b/doc/source/programs/gdal_calc.rst index bd444abe84a6..92808f389207 100644 --- a/doc/source/programs/gdal_calc.rst +++ b/doc/source/programs/gdal_calc.rst @@ -16,8 +16,8 @@ Synopsis .. code-block:: gdal_calc.py [--help] [--help-general] - --calc=expression --outfile=out_filename [-A filename] - [--A_band=n] [-B...-Z filename] [other_options] + --calc=expression --outfile=<out_filename> [-A <filename>] + [--A_band=<n>] [-B...-Z <filename>] [<other_options>] .. rubric:: DESCRIPTION :name: description @@ -30,7 +30,7 @@ but no projection checking is performed (unless projectionCheck option is used). .. include:: options/help_and_help_general.rst -.. option:: --calc=expression +.. option:: --calc=<expression> Calculation in numpy syntax using ``+``, ``-``, ``/``, ``*``, or any numpy array functions (i.e. ``log10()``). Multiple ``--calc`` options can be listed to produce a multiband file (GDAL >= 3.2). diff --git a/doc/source/programs/gdal_contour.rst b/doc/source/programs/gdal_contour.rst index 57ae8e9b63f7..07bbaa336d2b 100644 --- a/doc/source/programs/gdal_contour.rst +++ b/doc/source/programs/gdal_contour.rst @@ -17,9 +17,8 @@ Synopsis gdal_contour [--help] [--help-general] [-b <band>] [-a <attribute_name>] [-amin <attribute_name>] [-amax <attribute_name>] - [-3d] [-inodata] - [-snodata n] [-i <interval>] - [-f <formatname>] [[-dsco NAME=VALUE] ...] [[-lco NAME=VALUE] ...] + [-3d] [-inodata] [-snodata <n>] [-f <formatname>] [-i <interval>] + [-dsco <NAME>=<VALUE>]... [-lco <NAME>=<VALUE>]... [-off <offset>] [-fl <level> <level>...] [-e <exp_base>] [-nln <outlayername>] [-q] [-p] <src_filename> <dst_filename> @@ -84,11 +83,11 @@ be on the right, i.e. a line string goes clockwise around a top. If not specified, the format is guessed from the extension (previously was ESRI Shapefile). -.. option:: -dsco <NAME=VALUE> +.. option:: -dsco <NAME>=<VALUE> Dataset creation option (format specific) -.. option:: -lco <NAME=VALUE> +.. option:: -lco <NAME>=<VALUE> Layer creation option (format specific) diff --git a/doc/source/programs/gdal_create.rst b/doc/source/programs/gdal_create.rst index a5faa757fe0c..eaa36776eed0 100644 --- a/doc/source/programs/gdal_create.rst +++ b/doc/source/programs/gdal_create.rst @@ -19,17 +19,17 @@ Synopsis gdal_create [--help] [--help-general] - [-of format] - [-outsize xsize ysize] - [-bands count] - [-burn value]* + [-of <format>] + [-outsize <xsize> <ysize>] + [-bands <count>] + [-burn <value>]... [-ot {Byte/Int8/Int16/UInt16/UInt32/Int32/UInt64/Int64/Float32/Float64/ CInt16/CInt32/CFloat32/CFloat64}] [-strict] - [-a_srs srs_def] [-a_ullr ulx uly lrx lry] [-a_nodata value] - [-mo "META-TAG=VALUE"]* [-q] - [-co "NAME=VALUE"]* - [-if input_dataset] - out_dataset + [-a_srs <srs_def>] [-a_ullr <ulx> <uly> <lrx> <lry>] [-a_nodata <value>] + [-mo <META-TAG>=<VALUE>]... [-q] + [-co <NAME>=<VALUE>]... + [-if <input_dataset>] + <out_dataset> Description ----------- @@ -75,7 +75,7 @@ like creating a PDF file from a XML composition file. Assign a specified nodata value to output bands. -.. option:: -mo META-TAG=VALUE +.. option:: -mo <META-TAG>=<VALUE> Passes a metadata key and value to set on the output dataset if possible. diff --git a/doc/source/programs/gdal_edit.rst b/doc/source/programs/gdal_edit.rst index e1911bbd731c..6bc0bbe07deb 100644 --- a/doc/source/programs/gdal_edit.rst +++ b/doc/source/programs/gdal_edit.rst @@ -15,15 +15,16 @@ Synopsis .. code-block:: - gdal_edit [--help] [--help-general] [-ro] [-a_srs srs_def] - [-a_ullr ulx uly lrx lry] [-a_ulurll ulx uly urx ury llx lly] - [-tr xres yres] [-unsetgt] [-unsetrpc] [-a_nodata value] [-unsetnodata] + gdal_edit [--help] [--help-general] [-ro] [-a_srs <srs_def>] + [-a_ullr <ulx> <uly> <lrx> <lry>] [-a_ulurll <ulx> <uly> <urx> <ury> <llx> <lly>] + [-tr <xres> <yres>] [-unsetgt] [-unsetrpc] [-a_nodata <value>] [-unsetnodata] [-unsetstats] [-stats] [-approx_stats] - [-setstats min max mean stddev] - [-scale value] [-offset value] [-units value] - [-colorinterp_X red|green|blue|alpha|gray|undefined]* - [-gcp pixel line easting northing [elevation]]* - [-unsetmd] [-oo NAME=VALUE]* [-mo "META-TAG=VALUE"]* datasetname + [-setstats <min> <max> <mean> <stddev>] + [-scale <value>] [-offset <value>] [-units <value>] + [-colorinterp_<X> {red|green|blue|alpha|gray|undefined}]... + [-gcp <pixel> <line> <easting> <northing> [<elevation>]]... + [-unsetmd] [-oo <NAME>=<VALUE>]... [-mo <META-TAG>=<VALUE>]... + <datasetname> Description ----------- @@ -57,11 +58,11 @@ It works only with raster formats that support update access to existing dataset coordinate system will be removed (for TIFF/GeoTIFF, might not be well supported besides that). -.. option:: -a_ullr ulx uly lrx lry: +.. option:: -a_ullr <ulx> <uly> <lrx> <lry> Assign/override the georeferenced bounds of the dataset. -.. option:: -a_ulurll ulx uly urx ury llx lly: +.. option:: -a_ulurll <ulx> <uly> <urx> <ury> <llx> <lly> Assign/override the georeferenced bounds of the dataset from three points: upper-left, upper-right and lower-left. Unlike :option:`-a_ullr`, this also @@ -96,7 +97,7 @@ It works only with raster formats that support update access to existing dataset .. versionadded:: 2.0 -.. option:: -setstats min max mean stddev +.. option:: -setstats <min> <max> <mean> <stddev> Store user-defined values for band statistics (minimum, maximum, mean and standard deviation). If any of the values is set to None, @@ -154,14 +155,14 @@ It works only with raster formats that support update access to existing dataset .. versionadded:: 3.1 -.. option:: -colorinterp_X red|green|blue|alpha|gray|undefined +.. option:: -colorinterp_<X> {red|green|blue|alpha|gray|undefined} Change the color interpretation of band X (where X is a valid band number, starting at 1). .. versionadded:: 2.3 -.. option:: -gcp pixel line easting northing [elevation] +.. option:: -gcp pixel <line> <easting> <northing> [<elevation>] Add the indicated ground control point to the dataset. This option may be provided multiple times to provide a set of GCPs. @@ -173,13 +174,13 @@ It works only with raster formats that support update access to existing dataset .. versionadded:: 2.0 -.. option:: -mo META-TAG=VALUE +.. option:: -mo <META-TAG>=<VALUE> Passes a metadata key and value to set on the output dataset if possible. This metadata is added to the existing metadata items, unless :option:`-unsetmd` is also specified. -.. option:: -oo NAME=VALUE +.. option:: -oo <NAME>=<VALUE> Open option (format specific). diff --git a/doc/source/programs/gdal_footprint.rst b/doc/source/programs/gdal_footprint.rst index a6d4b565ec1f..8d624c48a647 100644 --- a/doc/source/programs/gdal_footprint.rst +++ b/doc/source/programs/gdal_footprint.rst @@ -19,14 +19,14 @@ Synopsis gdal_footprint [--help] [--help-general] - [-b band]* [-combine_bands union|intersection] - [-oo NAME=VALUE]* [-ovr <index>] - [-srcnodata \"value [value...]\"] + [-b <band>]... [-combine_bands union|intersection] + [-oo <NAME>=<VALUE>]... [-ovr <index>] + [-srcnodata "<value>[ <value>]..."] [-t_cs pixel|georef] [-t_srs <srs_def>] [-split_polys] [-convex_hull] [-densify <value>] [-simplify <value>] [-min_ring_area <value>] [-max_points <value>|unlimited] - [-of ogr_format] [-lyr_name dst_layername] - [-dsco name=value]* [-lco name=value]* [-q] [-overwrite] + [-of <ogr_format>] [-lyr_name <dst_layername>] + [-dsco <name>=<value>]... [-lco <name>=<value>]... [-overwrite] [-q] <src_filename> <dst_filename> @@ -69,7 +69,7 @@ proper mask bands. used. The index is 0-based, that is 0 means the first overview level. This option is mutually exclusive with :option:`-srcnodata`. -.. option:: -srcnodata "<value> [<value>...]" +.. option:: -srcnodata "<value>[ <value>]..." Set nodata values for input bands (different values can be supplied for each band). If a single value is specified, it applies to all selected bands. @@ -139,7 +139,7 @@ proper mask bands. Suppress progress monitor and other non-error output. -.. option:: -oo NAME=VALUE +.. option:: -oo <NAME>=<VALUE> Dataset open option (format specific) @@ -148,11 +148,11 @@ proper mask bands. Select the output format. Use the short format name. Guessed from the file extension if not specified -.. option:: -lco NAME=VALUE +.. option:: -lco <NAME>=<VALUE> Layer creation option (format specific) -.. option:: -dsco NAME=VALUE +.. option:: -dsco <NAME>=<VALUE> Dataset creation option (format specific) diff --git a/doc/source/programs/gdal_grid.rst b/doc/source/programs/gdal_grid.rst index b0ad0930b77d..cd233a119627 100644 --- a/doc/source/programs/gdal_grid.rst +++ b/doc/source/programs/gdal_grid.rst @@ -18,16 +18,16 @@ Synopsis gdal_grid [--help] [--help-general] [-ot {Byte/Int16/UInt16/UInt32/Int32/Float32/Float64/ CInt16/CInt32/CFloat32/CFloat64}] - [-oo NAME=VALUE]* - [-of format] [-co "NAME=VALUE"] - [-zfield field_name] [-z_increase increase_value] [-z_multiply multiply_value] - [-a_srs srs_def] [-spat xmin ymin xmax ymax] - [-clipsrc <xmin ymin xmax ymax>|WKT|datasource|spat_extent] - [-clipsrcsql sql_statement] [-clipsrclayer layer] - [-clipsrcwhere expression] - [-l layername]* [-where expression] [-sql select_statement] - [-txe xmin xmax] [-tye ymin ymax] [-tr xres yres] [-outsize xsize ysize] - [-a algorithm[:parameter1=value1]*] [-q] + [-oo <NAME>=<VALUE>]... + [-of <format>] [-co <NAME>=<VALUE>]... + [-zfield <field_name>] [-z_increase <increase_value>] [-z_multiply <multiply_value>] + [-a_srs <srs_def>] [-spat <xmin> <ymin> <xmax> <ymax>] + [-clipsrc <xmin> <ymin> <xmax> <ymax>|<WKT>|<datasource>|spat_extent] + [-clipsrcsql <sql_statement>] [-clipsrclayer <layer>] + [-clipsrcwhere <expression>] + [-l <layername>]... [-where <expression>] [-sql <select_statement>] + [-txe <xmin> <xmax>] [-tye <ymin> <ymax>] [-tr <xres> <yres>] [-outsize <xsize> <ysize>] + [-a {<algorithm>[[:<parameter1>=<value1>]...]}] [-q] <src_datasource> <dst_filename> Description @@ -65,7 +65,7 @@ computer. .. versionadded:: 3.2 -.. option:: -outsize <xsize ysize> +.. option:: -outsize <xsize> <ysize> Set the size of the output file in pixels and lines. Note that :option:`-outsize` cannot be used with :option:`-tr` @@ -98,7 +98,7 @@ computer. elevation to depth. The result value will be (Z value + Z increase value) * Z multiply value. The default value is 1. -.. option:: -a <[algorithm[:parameter1=value1][:parameter2=value2]...]> +.. option:: -a {<algorithm>[[:<parameter1>=<value1>]...]} Set the interpolation algorithm or data metric name and (optionally) its parameters. See the `Interpolation algorithms`_ and `Data metrics`_ @@ -110,7 +110,7 @@ computer. to select only features contained within the bounding box described by (xmin, ymin) - (xmax, ymax). -.. option:: -clipsrc [xmin ymin xmax ymax]|WKT|datasource|spat_extent +.. option:: -clipsrc [<xmin> <ymin> <xmax> <ymax>]|<WKT>|<datasource>|spat_extent Adds a spatial filter to select only features contained within the specified bounding box (expressed in source SRS), WKT geometry (POLYGON or @@ -149,7 +149,7 @@ computer. An SQL statement to be evaluated against the datasource to produce a virtual layer of features to be processed. -.. option:: -oo <NAME=VALUE> +.. option:: -oo <NAME>=<VALUE> .. versionadded:: 3.7 diff --git a/doc/source/programs/gdal_merge.rst b/doc/source/programs/gdal_merge.rst index c9d28966d476..e928a97dcb9f 100644 --- a/doc/source/programs/gdal_merge.rst +++ b/doc/source/programs/gdal_merge.rst @@ -16,11 +16,11 @@ Synopsis .. code-block:: gdal_merge.py [--help] [--help-general] - [-o out_filename] [-of out_format] [-co NAME=VALUE]* - [-ps pixelsize_x pixelsize_y] [-tap] [-separate] [-q] [-v] [-pct] - [-ul_lr ulx uly lrx lry] [-init "value [value...]"] - [-n nodata_value] [-a_nodata output_nodata_value] - [-ot datatype] [-createonly] input_files + [-o <out_filename>] [-of <out_format>] [-co <NAME>=<VALUE>]... + [-ps <pixelsize_x> <pixelsize_y>] [-tap] [-separate] [-q] [-v] [-pct] + [-ul_lr <ulx> <uly> <lrx> <lry>] [-init "<value>[ <value>]..."] + [-n <nodata_value>] [-a_nodata <output_nodata_value>] + [-ot <datatype>] [-createonly] <intput_file> [<intput_file>]... Description ----------- diff --git a/doc/source/programs/gdal_pansharpen.rst b/doc/source/programs/gdal_pansharpen.rst index 01ec0812181b..d4368988e1a9 100644 --- a/doc/source/programs/gdal_pansharpen.rst +++ b/doc/source/programs/gdal_pansharpen.rst @@ -18,12 +18,14 @@ Synopsis .. code-block:: gdal_pansharpen [--help] [--help-general] - pan_dataset {spectral_dataset[,band=num]}+ out_dataset - [-of format] [-b band]* [-w weight_val]* - [-r {nearest,bilinear,cubic,cubicspline,lanczos,average}] - [-threads {ALL_CPUS|number}] [-bitdepth val] [-nodata val] - [-spat_adjust {union,intersection,none,nonewithoutwarning}] - [-co NAME=VALUE]* [-q] + <pan_dataset> + <spectral_dataset>[,band=<num>] [<spectral_dataset>[,band=<num>]]... + <out_dataset> + [-of <format>] [-b <band>]... [-w <weight_val>]... + [-r {nearest|bilinear|cubic|cubicspline|lanczos|average}] + [-threads {ALL_CPUS|<number>}] [-bitdepth <val>] [-nodata <val>] + [-spat_adjust {union|intersection|none|nonewithoutwarning}] + [-co <NAME>=<VALUE>]... [-q] Description ----------- @@ -36,7 +38,7 @@ More details can be found in the :ref:`gdal_vrttut_pansharpen` section. .. include:: options/help_and_help_general.rst -.. option:: -of <format>: +.. option:: -of <format> Select the output format. Starting with GDAL 2.3, if not specified, the format is guessed from the extension (previously was ``GTiff``). Use @@ -54,14 +56,14 @@ More details can be found in the :ref:`gdal_vrttut_pansharpen` section. Specify a weight for the computation of the pseudo panchromatic value. There must be as many -w switches as input spectral bands. -.. option:: -r {nearest,bilinear,cubic (default),cubicspline,lanczos,average} +.. option:: -r {nearest|bilinear|cubic|cubicspline|lanczos|average} - Select a resampling algorithm. + Select a resampling algorithm. ``cubic`` is the default. -.. option:: -threads {ALL_CPUS,number} +.. option:: -threads {ALL_CPUS|<number>} Specify number of threads to use to do the resampling and - pan-sharpening itself. Can be an integer number or ALL_CPUS. + pan-sharpening itself. Can be an integer number or ``ALL_CPUS``. .. option:: -bitdepth <val> @@ -75,10 +77,11 @@ More details can be found in the :ref:`gdal_vrttut_pansharpen` section. pan-sharpening computation itself. If not set, deduced from the input bands, provided they have a consistent setting. -.. option:: -spat_adjust {union(default),intersection,none,nonewithoutwarning} +.. option:: -spat_adjust {union|intersection|none|nonewithoutwarning} Select behavior when bands have not the same extent. See *SpatialExtentAdjustment* documentation in :ref:`gdal_vrttut_pansharpen` + ``union`` is the default. .. include:: options/co.rst @@ -90,7 +93,7 @@ More details can be found in the :ref:`gdal_vrttut_pansharpen` section. Dataset with panchromatic band (first band will be used). -.. option:: <spectral_dataset>[,band=num] +.. option:: <spectral_dataset>[,band=<num>] Dataset with one or several spectral bands. If the band option is not specified, all bands of the datasets are taken into account. diff --git a/doc/source/programs/gdal_polygonize.rst b/doc/source/programs/gdal_polygonize.rst index cb7fc276ae11..a720f0c25467 100644 --- a/doc/source/programs/gdal_polygonize.rst +++ b/doc/source/programs/gdal_polygonize.rst @@ -16,9 +16,9 @@ Synopsis .. code-block:: gdal_polygonize.py [--help] [--help-general] - [-8] [-o name=value]* [-nomask] [-mask filename] <raster_file> [-b band] - [-q] [-f ogr_format] [-lco name=value]* [-overwrite] - <out_file> [layer] [fieldname] + [-8] [-o <name>=<value>]... [-nomask] [-mask <filename>] <raster_file> [-b <band>] + [-q] [-f <ogr_format>] [-lco <name>=<value>]... [-overwrite] + <out_file> [<layer>] [<fieldname>] Description ----------- @@ -69,13 +69,13 @@ details on the algorithm. GDAL 2.3, if not specified, the format is guessed from the extension (previously was GML). Use the short format name -.. option:: -o NAME=VALUE +.. option:: -o <NAME>=<VALUE> .. versionadded:: 3.7 Polygonize option. See ::cpp:func:`GDALPolygonize` documentation. -.. option:: -lco NAME=VALUE +.. option:: -lco <NAME>=<VALUE> .. versionadded:: 3.7 diff --git a/doc/source/programs/gdal_proximity.rst b/doc/source/programs/gdal_proximity.rst index 99d0558f4769..acbe31125891 100644 --- a/doc/source/programs/gdal_proximity.rst +++ b/doc/source/programs/gdal_proximity.rst @@ -16,12 +16,12 @@ Synopsis .. code-block:: gdal_proximity.py [--help] [--help-general] - <srcfile> <dstfile> [-srcband n] [-dstband n] - [-of format] [-co name=value]* + <srcfile> <dstfile> [-srcband <n>] [-dstband <n>] + [-of <format>] [-co <name>=<value>]... [-ot Byte/UInt16/UInt32/Float32/etc] - [-values n,n,n] [-distunits PIXEL/GEO] - [-maxdist n] [-nodata n] [-use_input_nodata YES/NO] - [-fixed-buf-val n] + [-values <n>,<n>,<n>] [-distunits {PIXEL|GEO}] + [-maxdist <n>] [-nodata <n>] [-use_input_nodata {YES|NO}] + [-fixed-buf-val <n>] Description ----------- @@ -68,7 +68,7 @@ raster for which the raster pixel value is in the set of target pixel values. A list of target pixel values in the source image to be considered target pixels. If not specified, all non-zero pixels will be considered target pixels. -.. option:: -distunits PIXEL|GEO +.. option:: -distunits {PIXEL|GEO} Indicate whether distances generated should be in pixel or georeferenced coordinates (default PIXEL). @@ -85,7 +85,7 @@ raster for which the raster pixel value is in the set of target pixel values. Specify a nodata value to use for the destination proximity raster. -.. option:: -use_input_nodata YES/NO +.. option:: -use_input_nodata {YES|NO} Indicate whether nodata pixels in the input raster should be nodata in the output raster (default NO). diff --git a/doc/source/programs/gdal_rasterize.rst b/doc/source/programs/gdal_rasterize.rst index 00164ac506d7..b94b6bcbf2f5 100644 --- a/doc/source/programs/gdal_rasterize.rst +++ b/doc/source/programs/gdal_rasterize.rst @@ -15,16 +15,16 @@ Synopsis .. code-block:: - gdal_rasterize [--help] [--help-general] [-b band]* [-i] [-at] - [-oo NAME=VALUE]* - {[-burn value]* | [-a attribute_name] | [-3d]} [-add] - [-l layername]* [-where expression] [-sql select_statement|@filename] - [-dialect dialect] [-of format] [-a_srs srs_def] [-to NAME=VALUE]* - [-co "NAME=VALUE"]* [-a_nodata value] [-init value]* - [-te xmin ymin xmax ymax] [-tr xres yres] [-tap] [-ts width height] + gdal_rasterize [--help] [--help-general] + [-b <band>]... [-i] [-at] + [-oo <NAME>=<VALUE>]... + {[-burn <value>]... | [-a <attribute_name>] | [-3d]} [-add] + [-l <layername>]... [-where <expression>] [-sql <select_statement>|@<filename>] + [-dialect <dialect>] [-of <format>] [-a_srs <srs_def>] [-to <NAME>=<VALUE>]... + [-co <NAME>=<VALUE>]... [-a_nodata <value>] [-init <value>]... + [-te <xmin> <ymin> <xmax> <ymax>] [-tr <xres> <yres>] [-tap] [-ts <width> <height>] [-ot {Byte/Int8/Int16/UInt16/UInt32/Int32/UInt64/Int64/Float32/Float64/ - CInt16/CInt32/CFloat32/CFloat64}] - [-optim {[AUTO]/VECTOR/RASTER}] [-q] + CInt16/CInt32/CFloat32/CFloat64}] [-optim {AUTO|VECTOR|RASTER}] [-q] <src_datasource> <dst_filename> Description @@ -129,7 +129,7 @@ raster data is only supported since GDAL 2.1.0. The <srs_def> may be any of the usual GDAL/OGR forms, complete WKT, PROJ.4, EPSG:n or a file containing the WKT. -.. option:: -to NAME=VALUE +.. option:: -to <NAME>=<VALUE> set a transformer option suitable to pass to :cpp:func:`GDALCreateGenImgProjTransformer2`. This is @@ -167,7 +167,7 @@ raster data is only supported since GDAL 2.1.0. Force the output bands to be of the indicated data type. Defaults to ``Float64`` -.. option:: -optim {[AUTO]/VECTOR/RASTER}} +.. option:: -optim {AUTO|VECTOR|RASTER} Force the algorithm used (results are identical). The raster mode is used in most cases and optimise read/write operations. The vector mode is useful with a decent amount of input @@ -177,7 +177,7 @@ raster data is only supported since GDAL 2.1.0. .. versionadded:: 2.3 -.. option:: -oo <NAME=VALUE> +.. option:: -oo <NAME>=<VALUE> .. versionadded:: 3.7 diff --git a/doc/source/programs/gdal_retile.rst b/doc/source/programs/gdal_retile.rst index 43dfe5103b46..7b89aeeebdf0 100644 --- a/doc/source/programs/gdal_retile.rst +++ b/doc/source/programs/gdal_retile.rst @@ -16,17 +16,17 @@ Synopsis .. code-block:: gdal_retile.py [--help] [--help-general] - [-v] [-co NAME=VALUE]* [-of out_format] [-ps pixelWidth pixelHeight] - [-overlap val_in_pixel] + [-v] [-co <NAME>=<VALUE>]... [-of <out_format>] [-ps <pixelWidth> <pixelHeight>] + [-overlap <val_in_pixel>] [-ot {Byte/Int8/Int16/UInt16/UInt32/Int32/Float32/Float64/ CInt16/CInt32/CFloat32/CFloat64}]' - [ -tileIndex tileIndexName [-tileIndexField tileIndexFieldName]] - [ -csv fileName [-csvDelim delimiter]] - [-s_srs srs_def] [-pyramidOnly] - [-r {near/bilinear/cubic/cubicspline/lanczos}] - -levels numberoflevels + [ -tileIndex <tileIndexName> [-tileIndexField <tileIndexFieldName>]] + [-csv <fileName> [-csvDelim <delimiter>]] + [-s_srs <srs_def>] [-pyramidOnly] + [-r {near|bilinear|cubic|cubicspline|lanczos}] + -levels <numberoflevels> [-useDirForEachRow] [-resume] - -targetDir TileDirectory input_files + -targetDir <TileDirectory> <input_file> <input_file>... Description ----------- @@ -63,7 +63,7 @@ If your number of input tiles exhausts the command line buffer, use the general Pixel size to be used for the output file. If not specified, 256 x 256 is the default -.. option:: -overlap< <val_in_pixel> +.. option:: -overlap <val_in_pixel> Overlap in pixels between consecutive tiles. If not specified, 0 is the default diff --git a/doc/source/programs/gdal_translate.rst b/doc/source/programs/gdal_translate.rst index 95a31c5ec7d8..c6479fef0d82 100644 --- a/doc/source/programs/gdal_translate.rst +++ b/doc/source/programs/gdal_translate.rst @@ -16,28 +16,28 @@ Synopsis .. code-block:: - gdal_translate [--help] [--help-general] - [-ot {Byte/Int8/Int16/UInt16/UInt32/Int32/UInt64/Int64/Float32/Float64/ - CInt16/CInt32/CFloat32/CFloat64}] [-strict] - [-if format]* [-of format] - [-b band]* [-mask band] [-expand {gray|rgb|rgba}] - [-outsize xsize[%]|0 ysize[%]|0] [-tr xres yres] - [-ovr level|AUTO|AUTO-n|NONE] - [-r {nearest,bilinear,cubic,cubicspline,lanczos,average,rms,mode}] - [-unscale] [-scale[_bn] [src_min src_max [dst_min dst_max]]]* [-exponent[_bn] exp_val]* - [-srcwin xoff yoff xsize ysize] [-epo] [-eco] - [-projwin ulx uly lrx lry] [-projwin_srs srs_def] - [-a_srs srs_def] [-a_coord_epoch <epoch>] - [-a_ullr ulx uly lrx lry] [-a_nodata value] - [-a_gt gt0 gt1 gt2 gt3 gt4 gt5] - [-a_scale value] [-a_offset value] - [-nogcp] [-gcp pixel line easting northing [elevation]]* - |-colorinterp{_bn} {red|green|blue|alpha|gray|undefined}] - |-colorinterp {red|green|blue|alpha|gray|undefined},...] - [-mo "META-TAG=VALUE"]* [-q] [-sds] - [-co "NAME=VALUE"]* [-stats] [-norat] [-noxmp] - [-oo NAME=VALUE]* - src_dataset dst_dataset + gdal_translate [--help] [--help-general] [--long-usage] + [-ot {Byte/Int8/Int16/UInt16/UInt32/Int32/UInt64/Int64/Float32/Float64/ + CInt16/CInt32/CFloat32/CFloat64}] [-strict] + [-if <format>]... [-of <format>] + [-b <band>] [-mask <band>] [-expand {gray|rgb|rgba}] + [-outsize <xsize>[%]|0 <ysize>[%]|0] [-tr <xres> <yres>] + [-ovr <level>|AUTO|AUTO-<n>|NONE] + [-r {nearest,bilinear,cubic,cubicspline,lanczos,average,mode}] + [-unscale] [-scale[_bn] [<src_min> <src_max> [<dst_min> <dst_max>]]]... [-exponent[_bn] <exp_val>]... + [-srcwin <xoff> <yoff> <xsize> <ysize>] [-epo] [-eco] + [-projwin <ulx> <uly> <lrx> <lry>] [-projwin_srs <srs_def>] + [-a_srs <srs_def>] [-a_coord_epoch <epoch>] + [-a_ullr <ulx> <uly> <lrx> <lry>] [-a_nodata <value>] + [-a_gt <gt0> <gt1> <gt2> <gt3> <gt4> <gt5>] + [-a_scale <value>] [-a_offset <value>] + [-nogcp] [-gcp <pixel> <line> <easting> <northing> [<elevation>]]... + |-colorinterp{_bn} {red|green|blue|alpha|gray|undefined}] + |-colorinterp {red|green|blue|alpha|gray|undefined},...] + [-mo <META-TAG>=<VALUE>]... [-q] [-sds] + [-co <NAME>=<VALUE>]... [-stats] [-norat] [-noxmp] + [-oo <NAME>=<VALUE>]... + <src_dataset> <dst_dataset> Description ----------- @@ -100,7 +100,7 @@ resampling, and rescaling pixels in the process. Both must be positive values. This is mutually exclusive with :option:`-outsize`, :option:`-a_ullr`, and :option:`-a_gt`. -.. option:: -ovr <level|AUTO|AUTO-n|NONE> +.. option:: -ovr {<level>|AUTO|AUTO-<n>|NONE} .. versionadded:: 3.6 @@ -122,11 +122,11 @@ resampling, and rescaling pixels in the process. Similarly when using :option:`-outsize` with percentage values, they refer to the size of the full resolution source dataset. -.. option:: -r {nearest (default),bilinear,cubic,cubicspline,lanczos,average,rms,mode} +.. option:: -r {nearest|bilinear|cubic|cubicspline|lanczos|average|rms|mode} Select a resampling algorithm. - ``nearest`` applies a nearest neighbour (simple sampling) resampler + ``nearest`` (default) applies a nearest neighbour (simple sampling) resampler ``average`` computes the average of all non-NODATA contributing pixels. Starting with GDAL 3.1, this is a weighted average taking into account properly the weight of source pixels not contributing fully to the target pixel. @@ -142,7 +142,7 @@ resampling, and rescaling pixels in the process. ``mode`` selects the value which appears most often of all the sampled points. -.. option:: -scale [src_min src_max [dst_min dst_max]] +.. option:: -scale [<src_min> <src_max> [<dst_min> <dst_max>]] Rescale the input pixels values from the range **src_min** to **src_max** to the range **dst_min** to **dst_max**. @@ -296,18 +296,18 @@ resampling, and rescaling pixels in the process. .. versionadded:: 2.3 -.. option:: -colorinterp <red|green|blue|alpha|gray|undefined[,red|green|blue|alpha|gray|undefined]*> +.. option:: -colorinterp {red|green|blue|alpha|gray|undefined},... Override the color interpretation of all specified bands. For example -colorinterp red,green,blue,alpha for a 4 band output dataset. .. versionadded:: 2.3 -.. option:: -mo META-TAG=VALUE +.. option:: -mo <META-TAG>=<VALUE> Passes a metadata key and value to set on the output dataset if possible. -.. option:: -co <NAME=VALUE> +.. option:: -co <NAME>=<VALUE> .. WARNING: if modifying the 2 below paragraphs, please edit options/co.rst too @@ -367,7 +367,7 @@ resampling, and rescaling pixels in the process. Do not copy the GCPs in the source dataset to the output dataset. -.. option:: -gcp <pixel> <line> <easting> <northing> <elevation> +.. option:: -gcp <pixel> <line> <easting> <northing> [<elevation>] Add the indicated ground control point to the output dataset. This option may be provided multiple times to provide a set of GCPs. @@ -395,7 +395,7 @@ resampling, and rescaling pixels in the process. .. versionadded:: 3.2 -.. option:: -oo NAME=VALUE +.. option:: -oo <NAME>=<VALUE> Dataset open option (format specific) diff --git a/doc/source/programs/gdal_viewshed.rst b/doc/source/programs/gdal_viewshed.rst index ff1b067c11f9..c732ffded8c5 100644 --- a/doc/source/programs/gdal_viewshed.rst +++ b/doc/source/programs/gdal_viewshed.rst @@ -23,7 +23,7 @@ Synopsis -ox <observer_x> -oy <observer_y> [-vv <visibility>] [-iv <invisibility>] [-ov <out_of_range>] [-cc <curvature_coef>] - [[-co NAME=VALUE] ...] + [-co <NAME>=<VALUE>]... [-q] [-om <output mode>] <src_filename> <dst_filename> diff --git a/doc/source/programs/gdaladdo.rst b/doc/source/programs/gdaladdo.rst index f433bfafa585..cefe899b76b4 100644 --- a/doc/source/programs/gdaladdo.rst +++ b/doc/source/programs/gdaladdo.rst @@ -16,12 +16,12 @@ Synopsis .. code-block:: gdaladdo [--help] [--help-general] - [-r {nearest,average,rms,bilinear,gauss,cubic,cubicspline,lanczos,average_magphase,mode}] - [-b band]* [-minsize val] + [-r {nearest|average|rms|gauss|cubic|cubicspline|lanczos|average_mp|average_magphase|mode}] + [-ro] [-clean] [-q] [-oo <NAME>=<VALUE>]... [-minsize <val>] [--partial-refresh-from-source-timestamp] [--partial-refresh-from-projwin <ulx> <uly> <lrx> <lry>] - [--partial-refresh-from-source-extent <filename1,...,filenameN>] - [-ro] [-clean] [-oo NAME=VALUE]* <filename> [levels] + [--partial-refresh-from-source-extent <filename1>[,<filenameN>]...] + <filename> [<levels>]... Description ----------- @@ -33,11 +33,11 @@ most supported file formats with one of several downsampling algorithms. .. include:: options/help_and_help_general.rst -.. option:: -r {nearest (default),average,rms,gauss,cubic,cubicspline,lanczos,average_magphase,mode} +.. option:: -r {nearest|average|rms|gauss|cubic|cubicspline|lanczos|average_magphase|mode} Select a resampling algorithm. - ``nearest`` applies a nearest neighbour (simple sampling) resampler + ``nearest`` applies a nearest neighbour (simple sampling) resampler (default) ``average`` computes the average of all non-NODATA contributing pixels. Starting with GDAL 3.1, this is a weighted average taking into account properly the weight of source pixels not contributing fully to the target pixel. @@ -75,7 +75,7 @@ most supported file formats with one of several downsampling algorithms. remove all overviews. -.. option:: -oo NAME=VALUE +.. option:: -oo <NAME>=<VALUE> Dataset open option (format specific) @@ -110,7 +110,7 @@ most supported file formats with one of several downsampling algorithms. By default all existing overview levels will be refreshed, unless explicit levels are specified. -.. option:: --partial-refresh-from-source-extent <filename1,...,filenameN> +.. option:: --partial-refresh-from-source-extent <filename1>[,<filenameN>]... .. versionadded:: 3.8 diff --git a/doc/source/programs/gdalbuildvrt.rst b/doc/source/programs/gdalbuildvrt.rst index cd58cd163efd..09b0a923b5de 100644 --- a/doc/source/programs/gdalbuildvrt.rst +++ b/doc/source/programs/gdalbuildvrt.rst @@ -16,20 +16,20 @@ Synopsis .. code-block:: gdalbuildvrt [--help] [--help-general] - [-tileindex field_name] - [-resolution {highest|lowest|average|user}] - [-te xmin ymin xmax ymax] [-tr xres yres] [-tap] - [-separate] [-b band]* [-sd subdataset] - [-allow_projection_difference] [-q] - [-addalpha] [-hidenodata] - [-srcnodata "value [value...]"] [-vrtnodata "value [value...]"] - [-ignore_srcmaskband] - [-a_srs srs_def] - [-r {nearest,bilinear,cubic,cubicspline,lanczos,average,mode}] - [-oo NAME=VALUE]* - [-input_file_list my_list.txt] [-overwrite] - [-strict | -non_strict] - <output.vrt> [<gdalfile>]* + [-tileindex <field_name>] + [-resolution {highest|lowest|average|user}] + [-te <xmin> <ymin> <xmax> <ymax>] [-tr <xres> <yres>] [-tap] + [-separate] [-b <band>]... [-sd <subdataset>] + [-allow_projection_difference] [-q] + [-addalpha] [-hidenodata] + [-srcnodata "<value>[ <value>]..."] [-vrtnodata "<value>[ <value>]..." + [-ignore_srcmaskband] + [-a_srs <srs_def>] + [-r {nearest|bilinear|cubic|cubicspline|lanczos|average|mode}] + [-oo <NAME>=<VALUE>]... + [-input_file_list <filename>] [-overwrite] + [-strict | -non_strict] + <output_filename.vrt> <input_raster> [<input_raster>]... Description ----------- @@ -96,7 +96,7 @@ changed in later versions. such that the aligned extent includes the minimum extent. Alignment means that xmin / resx, ymin / resy, xmax / resx and ymax / resy are integer values. -.. option:: -te xmin ymin xmax ymax +.. option:: -te <xmin> <ymin> <xmax> <ymax> Set georeferenced extents of VRT file. The values must be expressed in georeferenced units. If not specified, the extent of the VRT is the minimum bounding box of the set of source rasters. @@ -117,7 +117,7 @@ changed in later versions. dataset which doesn't report nodata value but is transparent in areas with no data. -.. option:: -srcnodata <value> [<value>...] +.. option:: -srcnodata "<value>[ <value>]..." Set nodata values for input bands (different values can be supplied for each band). If more than one value is supplied all values should be quoted to keep them @@ -152,7 +152,7 @@ changed in later versions. number (starting from 1). This is an alternative of giving the full subdataset name as an input. -.. option:: -vrtnodata <value> [<value>...] +.. option:: -vrtnodata "<value>[ <value>]..." Set nodata values at the VRT band level (different values can be supplied for each band). If more than one value is supplied all values should be quoted to keep them together @@ -178,17 +178,17 @@ changed in later versions. Override the projection for the output file. The <srs_def> may be any of the usual GDAL/OGR forms, complete WKT, PROJ.4, EPSG:n or a file containing the WKT. No reprojection is done. -.. option:: -r {nearest (default),bilinear,cubic,cubicspline,lanczos,average,mode} +.. option:: -r {nearest|bilinear|cubic|cubicspline|lanczos|average|mode} - Select a resampling algorithm. + Select a resampling algorithm. Nearest is the default -.. option:: -oo NAME=VALUE +.. option:: -oo <NAME>=<VALUE> Dataset open option (format specific) .. versionadded:: 2.2 -.. option:: -input_file_list <mylist.txt> +.. option:: -input_file_list <filename> To specify a text file with an input filename on each line diff --git a/doc/source/programs/gdaldem.rst b/doc/source/programs/gdaldem.rst index 63b42d9b3de8..80ef91aa7088 100644 --- a/doc/source/programs/gdaldem.rst +++ b/doc/source/programs/gdaldem.rst @@ -21,38 +21,39 @@ Generate a shaded relief map from any GDAL-supported elevation raster: .. code-block:: - gdaldem hillshade input_dem output_hillshade - [-z ZFactor (default=1)] [-s scale* (default=1)] - [-az Azimuth (default=315)] [-alt Altitude (default=45)] - [-alg Horn|ZevenbergenThorne] [-combined | -multidirectional | -igor] - [-compute_edges] [-b Band (default=1)] [-of format] [-co "NAME=VALUE"]* [-q] + gdaldem hillshade <input_dem> <output_hillshade> + [-z <zfactor>] [-s <scale>] + [-az <azimuth>] [-alt <altitude>] + [-alg ZevenbergenThorne] [-combined | -multidirectional | -igor] + [-compute_edges] [-b <Band>] [-of <format>] [-co <NAME>=<VALUE>]... [-q] Generate a slope map from any GDAL-supported elevation raster: .. code-block:: - gdaldem slope input_dem output_slope_map - [-p use percent slope (default=degrees)] [-s scale* (default=1)] - [-alg Horn|ZevenbergenThorne] - [-compute_edges] [-b Band (default=1)] [-of format] [-co "NAME=VALUE"]* [-q] + gdaldem slope <input_dem> <output_slope_map> + [-p] [-s <scale>] + [-alg ZevenbergenThorne] + [-compute_edges] [-b <band>] [-of <format>] [-co <NAME>=<VALUE>]... [-q] Generate an aspect map from any GDAL-supported elevation raster, outputs a 32-bit float raster with pixel values from 0-360 indicating azimuth: .. code-block:: - gdaldem aspect input_dem output_aspect_map - [-trigonometric] [-zero_for_flat] - [-alg Horn|ZevenbergenThorne] - [-compute_edges] [-b Band (default=1)] [-of format] [-co "NAME=VALUE"]* [-q] + gdaldem aspect <input_dem> <output_aspect_map> + [-trigonometric] [-zero_for_flat] + [-alg ZevenbergenThorne] + [-compute_edges] [-b <band>] [-of format] [-co <NAME>=<VALUE>]... [-q] Generate a color relief map from any GDAL-supported elevation raster: .. code-block:: - gdaldem color-relief input_dem color_text_file output_color_relief_map - [-alpha] [-exact_color_entry | -nearest_color_entry] - [-b Band (default=1)] [-of format] [-co "NAME=VALUE"]* [-q] + gdaldem color-relief <input_dem> <color_text_file> <output_color_relief_map> + [-alpha] [-exact_color_entry | -nearest_color_entry] + [-b <band>] [-of format] [-co <NAME>=<VALUE>]... [-q] + where color_text_file contains lines of the format "elevation_value red green blue" Generate a Terrain Ruggedness Index (TRI) map from any GDAL-supported elevation raster: @@ -67,15 +68,15 @@ Generate a Topographic Position Index (TPI) map from any GDAL-supported elevatio .. code-block:: - gdaldem TPI input_dem output_TPI_map - [-compute_edges] [-b Band (default=1)] [-of format] [-q] + gdaldem TPI <input_dem> <output_TPI_map> + [-compute_edges] [-b <band>] [-of <format>] [-co <NAME>=<VALUE>]... [-q] Generate a roughness map from any GDAL-supported elevation raster: .. code-block:: - gdaldem roughness input_dem output_roughness_map - [-compute_edges] [-b Band (default=1)] [-of format] [-q] + gdaldem roughness <input_dem> <output_roughness_map> + [-compute_edges] [-b <band>] [-of <format>] [-co <NAME>=<VALUE>]... [-q] Description ----------- @@ -126,11 +127,11 @@ The following general options are available: .. include:: options/help_and_help_general.rst -.. option:: input_dem +.. option:: <input_dem> The input DEM raster to be processed -.. option:: output_xxx_map +.. option:: <output_xxx_map> The output raster produced diff --git a/doc/source/programs/gdalinfo.rst b/doc/source/programs/gdalinfo.rst index 207e55e7cc37..e1a0cfa4d9b0 100644 --- a/doc/source/programs/gdalinfo.rst +++ b/doc/source/programs/gdalinfo.rst @@ -18,9 +18,10 @@ Synopsis gdalinfo [--help] [--help-general] [-json] [-mm] [-stats | -approx_stats] [-hist] [-nogcp] [-nomd] [-norat] [-noct] [-nofl] - [-checksum] [-listmdd] [-mdd domain|`all`]* - [-proj4] [-wkt_format WKT1|WKT2|...] - [-sd subdataset] [-oo NAME=VALUE]* [-if format]* <datasetname> + [-checksum] [-listmdd] [-mdd <domain>|all] + [-proj4] [-wkt_format {WKT1|WKT2|<other_format>}]... + [-sd <subdataset>] [-oo <NAME>=<VALUE>]... [-if <format>]... + <datasetname> Description ----------- @@ -127,7 +128,7 @@ The following command line parameters can appear in any order Report a PROJ.4 string corresponding to the file's coordinate system. -.. option:: -oo <NAME=VALUE> +.. option:: -oo <NAME>=<VALUE> Dataset open option (format specific). diff --git a/doc/source/programs/gdallocationinfo.rst b/doc/source/programs/gdallocationinfo.rst index 8358c4552ed4..8814cced6f75 100644 --- a/doc/source/programs/gdallocationinfo.rst +++ b/doc/source/programs/gdallocationinfo.rst @@ -17,9 +17,10 @@ Synopsis Usage: gdallocationinfo [--help] [--help-general] [-xml] [-lifonly] [-valonly] - [-b band]* [-overview overview_level] - [-l_srs srs_def] [-geoloc] [-wgs84] - [-oo NAME=VALUE]* srcfile [x y] + [-b <band>]... [-overview <overview_level>] + [-l_srs <srs_def>] [-geoloc] [-wgs84] + [-oo <NAME>=<VALUE>]... <srcfile> [<x> <y>] + Description ----------- @@ -69,7 +70,7 @@ reporting options are provided. Indicates input x,y points are WGS84 long, lat. -.. option:: -oo NAME=VALUE +.. option:: -oo <NAME>=<VALUE> Dataset open option (format specific) diff --git a/doc/source/programs/gdalmdiminfo.rst b/doc/source/programs/gdalmdiminfo.rst index 71ad502f080d..e8287d8e3b86 100644 --- a/doc/source/programs/gdalmdiminfo.rst +++ b/doc/source/programs/gdalmdiminfo.rst @@ -18,9 +18,9 @@ Synopsis .. code-block:: gdalmdiminfo [--help] [--help-general] - [-oo NAME=VALUE]* [-arrayoption NAME=VALUE]* + [-oo <NAME>=<VALUE>]... [-arrayoption <NAME>=<VALUE>]... [-detailed] [-nopretty] [-array <array_name>] [-limit <number>] - [-stats] [-if format]* <datasetname> + [-stats] [-if <format>]... <datasetname> Description ----------- @@ -53,12 +53,12 @@ The following command line parameters can appear in any order array values. By default, unlimited. Only taken into account if used with -detailed. -.. option:: -oo <NAME=VALUE> +.. option:: -oo <NAME>=<VALUE> Dataset open option (format specific). This option may be used several times. -.. option:: -arrayoption <NAME=VALUE> +.. option:: -arrayoption <NAME>=<VALUE> Option passed to :cpp:func:`GDALGroup::GetMDArrayNames` to filter reported arrays. Such option is format specific. Consult driver documentation. diff --git a/doc/source/programs/gdalmdimtranslate.rst b/doc/source/programs/gdalmdimtranslate.rst index a351844bab5e..6d1b74afaa66 100644 --- a/doc/source/programs/gdalmdimtranslate.rst +++ b/doc/source/programs/gdalmdimtranslate.rst @@ -18,14 +18,14 @@ Synopsis .. code-block:: gdalmdimtranslate [--help] [--help-general] - [-co "NAME=VALUE"]* - [-if format]* [-of format] - [-array <array_spec>]* - [-group <group_spec>]* - [-subset <subset_spec>]* - [-scaleaxes <scaleaxes_spec>]* - [-oo NAME=VALUE]* - <src_filename> <dst_filename> + [-if <format>]... [-of <format>] + [-co <NAME>=<VALUE>]... + [-array <array_spec>]... + [-group <group_spec>]... + [-subset <subset_spec>]... + [-scaleaxes <scaleaxes_spec>] + [-oo <NAME>=<VALUE>]... + <src_filename> <dst_filename> Description @@ -51,7 +51,7 @@ The following command line parameters can appear in any order. not specified, the format is guessed when possible from the extension of the destination filename. -.. option:: -co <NAME=VALUE> +.. option:: -co <NAME>=<VALUE> Many formats have one or more optional creation options that can be used to control particulars about the file created. @@ -130,11 +130,11 @@ The following command line parameters can appear in any order. `OGC WCS 2.0 Scaling Extension <https://portal.opengeospatial.org/files/12-039>`__, but limited to integer scale factors. - That is dim1_name(scale_factor)[,dim2_name(scale_factor)]* + That is <dim1_name>(<scale_factor>)[,<dim2_name>(<scale_factor>)]... Using -scaleaxes is incompatible of specifying a *view* option in -array. -.. option:: -oo <NAME=VALUE> +.. option:: -oo <NAME>=<VALUE> .. versionadded:: 3.4 diff --git a/doc/source/programs/gdaltindex.rst b/doc/source/programs/gdaltindex.rst index ddf2cd061c2e..cbf7ff169382 100644 --- a/doc/source/programs/gdaltindex.rst +++ b/doc/source/programs/gdaltindex.rst @@ -18,8 +18,8 @@ Synopsis gdaltindex [--help] [--help-general] [-f <format>] [-tileindex <field_name>] [-write_absolute_path] [-skip_different_projection] [-t_srs <target_srs>] - [-src_srs_name <field_name>] [-src_srs_format [AUTO|WKT|EPSG|PROJ] - [-lyr_name <name>] <index_file> [<gdal_file>]* + [-src_srs_name <field_name>] [-src_srs_format {AUTO|WKT|EPSG|PROJ}] + [-lyr_name <name>] <index_file> <gdal_file> [<gdal_file>]... Description ----------- @@ -56,7 +56,7 @@ tileindex. will be inserted (unless :option:`-t_srs` is specified). Default does not check projection and accepts all inputs. -.. option:: -t_srs <target_srs>: +.. option:: -t_srs <target_srs> Geometries of input files will be transformed to the desired target coordinate reference system. @@ -68,10 +68,10 @@ tileindex. The name of the field to store the SRS of each tile. This field name can be used as the value of the TILESRS keyword in MapServer -.. option:: -src_srs_format <type> +.. option:: -src_srs_format {AUTO|WKT|EPSG|PROJ} The format in which the SRS of each tile must be written. Types can be - AUTO, WKT, EPSG, PROJ. + ``AUTO``, ``WKT``, ``EPSG``, ``PROJ``. .. option:: -lyr_name <name> diff --git a/doc/source/programs/gdaltransform.rst b/doc/source/programs/gdaltransform.rst index 13dc993414c2..6411c2d6ea43 100644 --- a/doc/source/programs/gdaltransform.rst +++ b/doc/source/programs/gdaltransform.rst @@ -16,12 +16,13 @@ Synopsis .. code-block:: gdaltransform [--help] [--help-general] - [-i] [-s_srs srs_def] [-t_srs srs_def] [-to "NAME=VALUE"] - [-s_coord_epoch epoch] [-t_coord_epoch epoch] - [-ct proj_string] [-order n] [-tps] [-rpc] [-geoloc] - [-gcp pixel line easting northing [elevation]]* [-output_xy] + [-i] [-s_srs <srs_def>] [-t_srs <srs_def>] [-to >NAME>=<VALUE>]... + [-s_coord_epoch <epoch>] [-t_coord_epoch <epoch>] + [-ct <proj_string>] [-order <n>] [-tps] [-rpc] [-geoloc] + [-gcp <pixel> <line> <easting> <northing> [elevation]]... [-output_xy] [srcfile [dstfile]] + Description ----------- @@ -80,7 +81,7 @@ projection,including GCP-based transformations. .. versionadded:: 3.0 -.. option:: -to NAME=VALUE +.. option:: -to <NAME>=<VALUE> set a transformer option suitable to pass to :cpp:func:`GDALCreateGenImgProjTransformer2`. diff --git a/doc/source/programs/gdalwarp.rst b/doc/source/programs/gdalwarp.rst index b78014550e36..463113ede342 100644 --- a/doc/source/programs/gdalwarp.rst +++ b/doc/source/programs/gdalwarp.rst @@ -16,24 +16,25 @@ Synopsis .. code-block:: gdalwarp [--help] [--help-general] [--formats] - [-b|-srcband n]* [-dstband n]* - [-s_srs srs_def] [-t_srs srs_def] [-ct string] - [-to "NAME=VALUE"]* [-vshift | -novshift] - [-s_coord_epoch epoch] [-t_coord_epoch epoch] - [-order n | -tps | -rpc | -geoloc] [-et err_threshold] - [-refine_gcps tolerance [minimum_gcps]] - [-te xmin ymin xmax ymax] [-te_srs srs_def] - [-tr xres yres]|[-tr square] [-tap] [-ts width height] - [-ovr level|AUTO|AUTO-n|NONE] [-wo "NAME=VALUE"] [-ot Byte/Int16/...] [-wt Byte/Int16] - [-srcnodata "value [value...]"] [-dstnodata "value [value...]"] + [-b|-srcband <n>]... [-dstband <n>]... + [-s_srs <srs_def>] [-t_srs <srs_def>] [-ct <string>] + [-to <NAME>=<VALUE>]... [-vshift | -novshift] + [-s_coord_epoch <epoch>] [-t_coord_epoch <epoch>] + [-order n | -tps | -rpc | -geoloc] [-et <err_threshold>] + [-refine_gcps <tolerance> [<minimum_gcps>]] + [-te <xmin> <ymin> <xmax> <ymax>] [-te_srs <srs_def>] + [-tr <xres> <yres>]|[-tr square] [-tap] [-ts <width> <height>] + [-ovr <level>|AUTO|AUTO-<n>|NONE] [-wo <NAME>=<VALUE>]... [-ot Byte/Int16/...] [-wt Byte/Int16] + [-srcnodata "<value>[ <value>...]"][-dstnodata "<value>[ <value>...]"] [-srcalpha|-nosrcalpha] [-dstalpha] - [-r resampling_method] [-wm memory_in_mb] [-multi] [-q] - [-cutline datasource] [-cl layer] [-cwhere expression] - [-csql statement] [-cblend dist_in_pixels] [-crop_to_cutline] - [-if format]* [-of format] [-co "NAME=VALUE"]* [-overwrite] - [-nomd] [-cvmd meta_conflict_value] [-setci] [-oo NAME=VALUE]* - [-doo NAME=VALUE]* - srcfile* dstfile + [-r <resampling_method>] [-wm <memory_in_mb>] [-multi] [-q] + [-cutline <datasource>] [-cl <layer>] [-cwhere <expression>] + [-csql <statement>] [-cblend <dist_in_pixels>] [-crop_to_cutline] + [-if <format>]... [-of <format>] [-co <NAME>=<VALUE>]... [-overwrite] + [-nomd] [-cvmd <meta_conflict_value>] [-setci] [-oo <NAME>=<VALUE>]... + [-doo <NAME>=<VALUE>]... + <srcfile>... <dstfile> + Description ----------- @@ -156,7 +157,7 @@ with control information. .. versionadded:: 3.0 -.. option:: -to <NAME=VALUE> +.. option:: -to <NAME>=<VALUE> Set a transformer option suitable to pass to :cpp:func:`GDALCreateGenImgProjTransformer2`. See :cpp:func:`GDALCreateRPCTransformerV2()` for RPC specific options. @@ -202,7 +203,7 @@ with control information. option is specified, in which case, an exact transformer, i.e. err_threshold=0, will be used). -.. option:: -refine_gcps <tolerance minimum_gcps> +.. option:: -refine_gcps <tolerance> [<minimum_gcps>] Refines the GCPs by automatically eliminating outliers. Outliers will be eliminated until minimum_gcps are left or when no outliers can be detected. @@ -211,7 +212,7 @@ with control information. The tolerance is in pixel units if no projection is available, otherwise it is in SRS units. If minimum_gcps is not provided, the minimum GCPs according to the polynomial model is used. -.. option:: -te <xmin ymin xmax ymax> +.. option:: -te <xmin> <ymin> <xmax> <ymax> Set georeferenced extents of output file to be created (in target SRS by default, or in the SRS specified with :option:`-te_srs`) @@ -255,7 +256,7 @@ with control information. the other dimension will be guessed from the computed resolution. Note that :option:`-ts` cannot be used with :option:`-tr` -.. option:: -ovr <level|AUTO|AUTO-n|NONE> +.. option:: -ovr <level>|AUTO|AUTO-<n>|NONE To specify which overview level of source files must be used. The default choice, AUTO, will select the overview level whose resolution is the closest to the @@ -266,7 +267,7 @@ with control information. generated with a low quality resampling method, and the warping is done using a higher quality resampling method). -.. option:: -wo `"NAME=VALUE"` +.. option:: -wo <NAME>=<VALUE> Set a warp option. The :cpp:member:`GDALWarpOptions::papszWarpOptions` docs show all options. Multiple :option:`-wo` options may be listed. @@ -322,7 +323,7 @@ with control information. those situations to use the :option:`-ovr` ``NONE`` option to prevent existing overviews to be used. -.. option:: -srcnodata <value [value...]> +.. option:: -srcnodata "<value>[ <value>]..." Set nodata masking values for input bands (different values can be supplied for each band). If more than one value is supplied all values should be quoted @@ -339,7 +340,7 @@ with control information. they will be taken into account, with ``UNIFIED_SRC_NODATA`` at ``PARTIAL`` by default. -.. option:: -dstnodata <value [value...]> +.. option:: -dstnodata "<value>[ <value>]..." Set nodata values for output bands (different values can be supplied for each band). If more @@ -446,11 +447,11 @@ with control information. Set the color interpretation of the bands of the target dataset from the source dataset. -.. option:: -oo <NAME=VALUE> +.. option:: -oo <NAME>=<VALUE> Dataset open option (format specific) -.. option:: -doo <NAME=VALUE> +.. option:: -doo <NAME>=<VALUE> Output dataset open option (format specific) diff --git a/doc/source/programs/gnmanalyse.rst b/doc/source/programs/gnmanalyse.rst index 3a0e107d30ae..60ba5b215ada 100644 --- a/doc/source/programs/gnmanalyse.rst +++ b/doc/source/programs/gnmanalyse.rst @@ -16,12 +16,12 @@ Synopsis .. code-block:: gnmanalyse [--help] [--help-general] [-q] [-quiet] [--long-usage] - [dijkstra <start_gfid> <end_gfid> [[-alo NAME=VALUE] ...]]] - [kpaths <start_gfid> <end_gfid> <k> [[-alo NAME=VALUE] ...]]] - [resource [[-alo NAME=VALUE] ...]]] - [-ds <ds_name>][-f <ds_format>][-l <layer_name>] - [[-dsco NAME=VALUE] ...][-lco NAME=VALUE] - <gnm_name> + [dijkstra <start_gfid> <end_gfid [-alo <NAME>=<VALUE>]...] + [kpaths <start_gfid> <end_gfid> <k> [-alo <NAME>=<VALUE>]...] + [resource [-alo <NAME>=<VALUE>]...] + [-ds <ds_name>][-f <ds_format>][-l <layer_name>] + [-dsco <NAME>=<VALUE>]... [-lco <NAME>=<VALUE>]... + <gnm_name> Description ----------- @@ -60,14 +60,14 @@ The :program:`gnmanalyse` program provides analysing capabilities of geographica The network to work with (path and name). -.. option:: -dsco NAME=VALUE +.. option:: -dsco <NAME>=<VALUE> Dataset creation option (format specific) -.. option:: -lco NAME=VALUE +.. option:: -lco <NAME>=<VALUE> Layer creation option (format specific) -.. option:: -alo NAME=VALUE +.. option:: -alo <NAME>=<VALUE> Algorithm option (format specific) diff --git a/doc/source/programs/gnmmanage.rst b/doc/source/programs/gnmmanage.rst index d1379256f950..37414f0b7165 100644 --- a/doc/source/programs/gnmmanage.rst +++ b/doc/source/programs/gnmmanage.rst @@ -16,17 +16,16 @@ Synopsis .. code-block:: gnmmanage [--help] [--help-general] [-q] [-quiet] [--long-usage] - [info] - [create [-f <format_name>] [-t_srs <srs_name>] [-dsco NAME=VALUE]... ] - [import src_dataset_name] [-l layer_name] - [connect <gfid_src> <gfid_tgt> <gfid_con> [-c <cost>] [-ic <inv_cost>] [-dir <dir>]] - [disconnect <gfid_src> <gfid_tgt> <gfid_con>] - [rule <rule_str>] - [autoconnect <tolerance>] - [delete] - [change [-bl gfid][-unbl gfid][-unblall]] - <gnm_name> [<layer> [<layer> ...]] - + [info] + [create [-f <format_name>] [-t_srs <srs_name>] [-dsco <NAME>=<VALUE>]... ] + [import <src_dataset_name>] [-l <layer_name>] + [connect <gfid_src> <gfid_tgt> <gfid_con> [-c <cost>] [-ic <inv_cost>] [-dir <dir>]] + [disconnect <gfid_src> <gfid_tgt> <gfid_con>] + [rule <rule_str>] + [autoconnect <tolerance>] + [delete] + [change [-bl <gfid>][-unbl <gfid>][-unblall]] + <gnm_name> [<layer> [<layer>]...] Description ----------- @@ -53,7 +52,7 @@ The :program:`gnmmanage` program can perform various managing operations on geog Spatial reference input. - .. option:: -dsco NAME=VALUE + .. option:: -dsco <NAME>=<VALUE> Network creation option set as pair name=value. @@ -61,9 +60,9 @@ The :program:`gnmmanage` program can perform various managing operations on geog Import layer with dataset name to copy. - .. option:: -l layer_name + .. option:: -l <layer_name> - Layer name in dataset. If unset, 0 layer is copied. + Layer name in dataset. If unset, 0 layer is copied. .. option:: connect <gfid_src> <gfid_tgt> <gfid_con> diff --git a/doc/source/programs/nearblack.rst b/doc/source/programs/nearblack.rst index b7d0985be4b9..378ebfd07ae3 100644 --- a/doc/source/programs/nearblack.rst +++ b/doc/source/programs/nearblack.rst @@ -16,10 +16,10 @@ Synopsis .. code-block:: nearblack [--help] [--help-general] - [-of format] [-white | [-color c1,c2,c3...cn]*] + [-of <format>] [-white | [-color <c1>,<c2>,<c3>...<cn>]...] [-near <dist>] [-nb <non_black_pixels>] - [-setalpha] [-setmask] [-o <outfile>] [-q] [-alg twopasses|floodfill] - [-co "NAME=VALUE"]* <infile> + [-setalpha] [-setmask] [-alg twopasses|floodfill] + [-o <outfile>] [-q] [-co <NAME>=<VALUE>]... <infile> Description ----------- @@ -45,7 +45,7 @@ if either alpha band or mask band is not set. was ERDAS Imagine .img). Use the short format name (GTiff for GeoTIFF for example). -.. option:: -co `"NAME=VALUE"` +.. option:: -co <NAME>=<VALUE> Passes a creation option to the output format driver. Multiple :option:`-co` options may be listed. See :ref:`raster_drivers` format @@ -57,7 +57,7 @@ if either alpha band or mask band is not set. Search for nearly white (255) pixels instead of nearly black pixels. -.. option:: -color <c1,c2,c3...cn> +.. option:: -color <c1>,<c2>,<c3>...<cn> Search for pixels near the specified color. May be specified multiple times. When -color is specified, the pixels that are considered as the collar are set to 0. diff --git a/doc/source/programs/ogr2ogr.rst b/doc/source/programs/ogr2ogr.rst index 84d3b2d38a52..6054802d1b20 100644 --- a/doc/source/programs/ogr2ogr.rst +++ b/doc/source/programs/ogr2ogr.rst @@ -15,42 +15,45 @@ Synopsis .. code-block:: - ogr2ogr [--help-general] [-skipfailures] [-append | -upsert] [-update] - [-select field_list] [-where restricted_where|@filename] - [-progress] [-sql <sql statement>|@filename] [-dialect dialect] - [-preserve_fid] [-fid FID] [-limit nb_features] - [-spat xmin ymin xmax ymax] [-spat_srs srs_def] [-geomfield field] - [-a_srs srs_def] [-t_srs srs_def] [-s_srs srs_def] [-ct string] - [-f format_name] [-overwrite] [[-dsco NAME=VALUE] ...] - dst_datasource_name src_datasource_name - [-lco NAME=VALUE] [-nln name] - [-nlt type|PROMOTE_TO_MULTI|CONVERT_TO_LINEAR|CONVERT_TO_CURVE] - [-dim XY|XYZ|XYM|XYZM|2|3|layer_dim] [layer [layer ...]] + ogr2ogr [--help] [--help-general] + [-skipfailures] [-append | -upsert] [-update] + [-select <field_list>] [-where <restricted_where>|@<filename>] + [-progress] [-sql <sql statement>|@<filename>] [-dialect <dialect>] + [-preserve_fid] [-fid <FID>] [-limit <nb_features>] + [-spat <xmin> <ymin> <xmax> <ymax>] [-spat_srs <srs_def>] [-geomfield <field>] + [-a_srs <srs_def>] [-t_srs <srs_def>] [-s_srs <srs_def>] [-ct <string>] + [-f <format_name>] [-overwrite] [-dsco <NAME>=<VALUE>]... + [-lco <NAME>=<VALUE>]... [-nln <name>] + [-nlt <type>|PROMOTE_TO_MULTI|CONVERT_TO_LINEAR|CONVERT_TO_CURVE] + [-dim XY|XYZ|XYM|XYZM|<layer_dim>] + <dst_datasource_name> <src_datasource_name> + [<layer> [<layer>...]] # Advanced options - [-gt n] - [[-oo NAME=VALUE] ...] [[-doo NAME=VALUE] ...] - [-clipsrc [xmin ymin xmax ymax]|WKT|datasource|spat_extent] - [-clipsrcsql sql_statement] [-clipsrclayer layer] - [-clipsrcwhere expression] - [-clipdst [xmin ymin xmax ymax]|WKT|datasource] - [-clipdstsql sql_statement] [-clipdstlayer layer] - [-clipdstwhere expression] - [-wrapdateline] [-datelineoffset val] - [[-simplify tolerance] | [-segmentize max_dist]] + [-gt n] [-ds_transaction] + [-oo <NAME>=<VALUE>]... [-doo <NAME>=<VALUE>]... + [-clipsrc {[<xmin> <ymin> <xmax> <ymax>]|<WKT>|<datasource>|spat_extent}] + [-clipsrcsql <sql_statement>] [-clipsrclayer <layer>] + [-clipsrcwhere <expression>] + [-clipdst {[<xmin> <ymin> <xmax> <ymax>]|<WKT>|<datasource>}] + [-clipdstsql <sql_statement>] [-clipdstlayer <layer>] + [-clipdstwhere <expression>] + [-wrapdateline][-datelineoffset <val>] + [[-simplify <tolerance>] | [-segmentize <max_dist>]] [-makevalid] [-addfields] [-unsetFid] [-emptyStrAsNull] [-relaxedFieldNameMatch] [-forceNullable] [-unsetDefault] - [-fieldTypeToString All|(type1[,type2]*)] [-unsetFieldWidth] - [-mapFieldType type1|All=type2[,type3=type4]*] - [-dateTimeTo UTC|UTC(+|-)HH|UTC(+|-)HH:MM]] - [-fieldmap identity | index1[,index2]*] - [-splitlistfields] [-maxsubfields val] + [-fieldTypeToString {All|{<type1>[,<type2>]}...}] [-unsetFieldWidth] + [-mapFieldType {<srctype>|All=<dsttype>[,<srctype2>=<dsttype2>]...}] + [-dateTimeTo {UTC|UTC(+|-)<HH>|UTC(+|-)<HH>:<MM>}] + [-fieldmap {identity|{<index1>[,<index2>]...}] + [-splitlistfields] [-maxsubfields <val>] [-resolveDomains] - [-explodecollections] [-zfield field_name] - [-gcp ungeoref_x ungeoref_y georef_x georef_y [elevation]]* [-order n | -tps] - [-s_coord_epoch epoch] [-t_coord_epoch epoch] [-a_coord_epoch epoch] - [-nomd] [-mo "META-TAG=VALUE"]* [-noNativeData] + [-explodecollections] [-zfield <field_name>] + [-gcp <ungeoref_x> <ungeoref_y> <georef_x> <georef_y> [<elevation>]]... [-order <n> | -tps] + [-s_coord_epoch <epoch>] [-t_coord_epoch <epoch>] [-a_coord_epoch <epoch>] + [-nomd] [-mo <META-TAG>=<VALUE>]... [-noNativeData] + Description ----------- @@ -132,7 +135,7 @@ output coordinate system or even reprojecting the features during translation. The :ref:`sql_sqlite_dialect` dialect can be select with the ``SQLITE`` and ``INDIRECT_SQLITE`` dialect values, and this can be used with any datasource. -.. option:: -where restricted_where +.. option:: -where <restricted_where> Attribute query (like SQL WHERE). Starting with GDAL 2.1, the ``@filename`` syntax can be used to indicate that the content is in the pointed filename. @@ -156,11 +159,11 @@ output coordinate system or even reprojecting the features during translation. Name of the geometry field on which the spatial filter operates on. -.. option:: -dsco NAME=VALUE +.. option:: -dsco <NAME>=<VALUE> Dataset creation option (format specific) -.. option:: -lco NAME=VALUE +.. option:: -lco <NAME>=<VALUE> Layer creation option (format specific) @@ -278,7 +281,7 @@ output coordinate system or even reprojecting the features during translation. column will be used and source feature IDs will be attempted to be preserved. This behavior can be disabled by setting ``-unsetFid``. -.. option:: -fid fid +.. option:: -fid <fid> If provided, only the feature with the specified feature id will be processed. Operates exclusive of the spatial or attribute queries. Note: if @@ -286,19 +289,19 @@ output coordinate system or even reprojecting the features during translation. use the fact the 'fid' is a special field recognized by OGR SQL. So, `-where "fid in (1,3,5)"` would select features 1, 3 and 5. -.. option:: -limit nb_features +.. option:: -limit <nb_features> Limit the number of features per layer. -.. option:: -oo NAME=VALUE +.. option:: -oo <NAME>=<VALUE> Input dataset open option (format specific). -.. option:: -doo NAME=VALUE +.. option:: -doo <NAME>=<VALUE> Destination dataset open option (format specific), only valid in -update mode. -.. option:: -gt n +.. option:: -gt <n> Group n features per transaction (default 100 000). Increase the value for better performance when writing into DBMS drivers that have transaction @@ -311,7 +314,7 @@ output coordinate system or even reprojecting the features during translation. mechanism), especially for drivers such as FileGDB that only support dataset level transaction in emulation mode. -.. option:: -clipsrc [xmin ymin xmax ymax]|WKT|datasource|spat_extent +.. option:: -clipsrc [<xmin> <ymin> <xmax> <ymax>]|WKT|<datasource>|spat_extent Clip geometries to one of the following: @@ -335,7 +338,7 @@ output coordinate system or even reprojecting the features during translation. Restrict desired geometries from the source clip layer based on an attribute query. -.. option:: -clipdst [<xmin> <ymin> <xmax> <ymax>]|WKT|datasource +.. option:: -clipdst [<xmin> <ymin> <xmax> <ymax>]|<WKT>|<datasource> Clip geometries to one of the following: @@ -385,25 +388,26 @@ output coordinate system or even reprojecting the features during translation. .. versionadded: 3.1 (requires GEOS 3.8 or later) -.. option:: -fieldTypeToString type1,... +.. option:: -fieldTypeToString All|<type1>[,<type2>]... Converts any field of the specified type to a field of type string in the - destination layer. Valid types are : Integer, Integer64, Real, String, - Date, Time, DateTime, Binary, IntegerList, Integer64List, RealList, - StringList. Special value All can be used to convert all fields to strings. + destination layer. Valid types are : ``Integer``, ``Integer64``, ``Real``, ``String``, + ``Date``, ``Time``, ``DateTime``, ``Binary``, ``IntegerList``, ``Integer64List``, ``RealList``, + ``StringList``. Special value ``All`` can be used to convert all fields to strings. This is an alternate way to using the CAST operator of OGR SQL, that may avoid typing a long SQL query. Note that this does not influence the field types used by the source driver, and is only an afterwards conversion. Also note that this option is without effects on fields whose presence and type is hard-coded in the output driver (e.g KML, GPX) -.. option:: -mapFieldType srctype|All=dsttype,... +.. option:: -mapFieldType {<srctype>|All=<dsttype>[,<srctype2>=<dsttype2>]...} Converts any field of the specified type to another type. Valid types are : - Integer, Integer64, Real, String, Date, Time, DateTime, Binary, - IntegerList, Integer64List, RealList, StringList. Types can also include - subtype between parenthesis, such as Integer(Boolean), Real(Float32), ... - Special value All can be used to convert all fields to another type. This + ``Integer``, ``Integer64``, ``Real``, ``String``, + ``Date``, ``Time``, ``DateTime``, ``Binary``, ``IntegerList``, ``Integer64List``, ``RealList``, + ``StringList``. Types can also include + subtype between parenthesis, such as ``Integer(Boolean)``, ``Real(Float32)``, ... + Special value ``All`` can be used to convert all fields to another type. This is an alternate way to using the CAST operator of OGR SQL, that may avoid typing a long SQL query. This is a generalization of -fieldTypeToString. Note that this does not influence the field types used by the source @@ -411,7 +415,7 @@ output coordinate system or even reprojecting the features during translation. Also note that this option is without effects on fields whose presence and type is hard-coded in the output driver (e.g KML, GPX) -.. option:: -dateTimeTo UTC|UTC(+|-)HH|UTC(+|-)HH:MM] +.. option:: -dateTimeTo {UTC|UTC(+|-)<HH>|UTC(+|-)<HH>:<MM>} .. versionadded: 3.7 @@ -444,7 +448,7 @@ output coordinate system or even reprojecting the features during translation. Uses the specified field to fill the Z coordinate of geometries. -.. option:: -gcp <ungeoref_x> <ungeoref_y> <georef_x> <georef_y> <elevation> +.. option:: -gcp <ungeoref_x> <ungeoref_y> <georef_x> <georef_y> [<elevation>] Add the indicated ground control point. This option may be provided multiple times to provide a set of GCPs. @@ -519,7 +523,7 @@ output coordinate system or even reprojecting the features during translation. To disable copying of metadata from source dataset and layers into target dataset and layers, when supported by output driver. -.. option:: -mo META-TAG=VALUE +.. option:: -mo <META-TAG>=<VALUE> Passes a metadata key and value to set on the output dataset, when supported by output driver. diff --git a/doc/source/programs/ogr_layer_algebra.rst b/doc/source/programs/ogr_layer_algebra.rst index 07ff11808622..a89685a16f70 100644 --- a/doc/source/programs/ogr_layer_algebra.rst +++ b/doc/source/programs/ogr_layer_algebra.rst @@ -19,13 +19,13 @@ Synopsis ogr_layer_algebra.py [--help] [--help-general] Union|Intersection|SymDifference|Identity|Update|Clip|Erase - -input_ds name [-input_lyr name] - -method_ds [-method_lyr name] - -output_ds name [-output_lyr name] [-overwrite] - [-opt NAME=VALUE]* - [-f format_name] [-dsco NAME=VALUE]* [-lco NAME=VALUE]* - [-input_fields NONE|ALL|fld1,fl2,...fldN] [-method_fields NONE|ALL|fld1,fl2,...fldN] - [-nlt geom_type] [-a_srs srs_def] + -input_ds <path> [-input_lyr <name>] + -method_ds <path> [-method_lyr <name>] + -output_ds <path> [-output_lyr <name>] [-overwrite] + [-opt <NAME>=<VALUE>]... + [-f <format_name>] [-dsco <NAME>=<VALUE>]... [-lco <NAME>=<VALUE>]... + [-input_fields {NONE|ALL|<fld1>,<fl2>,...<fldN>}] [-method_fields {NONE|ALL|<fld1>,<fl2>,...<fldN>}] + [-nlt <geom_type>] [-a_srs <srs_def>] Description ----------- @@ -104,7 +104,7 @@ input source , a method source and generates the output of the operation in the Indicates whether the ``output_ds`` have to be overwritten with the generated result of ogr_layer_algebra -.. option:: -opt <NAME=VALUE> +.. option:: -opt <NAME>=<VALUE> Attributes for which the operation has to run on ``input_ds`` and ``method_ds`` @@ -114,20 +114,20 @@ input source , a method source and generates the output of the operation in the the format is guessed from the extension (previously was ESRI Shapefile). Use the short format name -.. option:: -dsco <NAME=VALUE> +.. option:: -dsco <NAME>=<VALUE> Dataset creation option (format specific) -.. option:: -lco <NAME=VALUE> +.. option:: -lco <NAME>=<VALUE> Layer creation option (format specific) -.. option:: -input_fields <NONE|ALL|fld1,fld2,fld3...> +.. option:: -input_fields {NONE|ALL|<fld1>,<fl2>,...<fldN>} Comma-delimited list of fields from input layer to copy to the output layer , if eligible according to the operation -.. option:: -method_fields <NONE|ALL|fld1,fld2,fld3...> +.. option:: -method_fields {NONE|ALL|<fld1>,<fl2>,...<fldN>} Comma-delimited list of fields from method layer to copy to the output layer , if eligible according to the operation diff --git a/doc/source/programs/ogrinfo.rst b/doc/source/programs/ogrinfo.rst index 79b93b5bbfb6..c5cc9a061399 100644 --- a/doc/source/programs/ogrinfo.rst +++ b/doc/source/programs/ogrinfo.rst @@ -17,14 +17,14 @@ Synopsis .. code-block:: ogrinfo [--help] [--help-general] - [-json] [-ro] [-q] [-where restricted_where|@filename] - [-spat xmin ymin xmax ymax] [-geomfield field] [-fid fid] - [-sql statement|@filename] [-dialect dialect] [-al] [-rl] - [-so|-features] [-fields={YES/NO}] - [-geom={YES/NO/SUMMARY/WKT/ISO_WKT}] [--formats] [[-oo NAME=VALUE] ...] - [-nomd] [-listmdd] [-mdd domain|`all`]* - [-nocount] [-noextent] [-nogeomtype] [-wkt_format WKT1|WKT2|...] - [-fielddomain name] + [-json] [-ro] [-q] [-where <restricted_where>|@f<ilename>] + [-spat <xmin> <ymin> <xmax> <ymax>] [-geomfield <field>] [-fid <fid>] + [-sql <statement>|@<filename>] [-dialect <sql_dialect>] [-al] [-rl] + [-so|-features] [-fields={YES|NO}]] + [-geom={YES|NO|SUMMARY|WKT|ISO_WKT}] [-oo <NAME>=<VALUE>]... + [-nomd] [-listmdd] [-mdd <domain>|all]... + [-nocount] [-noextent] [-nogeomtype] [-wkt_format WKT1|WKT2|<other_values>] + [-fielddomain <name>] <datasource_name> [<layer> [<layer> ...]] Description @@ -127,7 +127,7 @@ edit data. fact the 'fid' is a special field recognized by OGR SQL. So, `-where "fid in (1,3,5)"` would select features 1, 3 and 5. -.. option:: -fields=YES|NO: +.. option:: -fields=YES|NO If set to ``NO``, the feature dump will not display field values. Default value is ``YES``. @@ -147,7 +147,7 @@ edit data. value is ``YES``. (WKT and ``ISO_WKT`` are available starting with GDAL 2.1, which also changes the default to ISO_WKT) -.. option:: -oo NAME=VALUE +.. option:: -oo <NAME>=<VALUE> Dataset open option (format-specific) diff --git a/doc/source/programs/ogrlineref.rst b/doc/source/programs/ogrlineref.rst index e5adfbcfa171..5e3da1288680 100644 --- a/doc/source/programs/ogrlineref.rst +++ b/doc/source/programs/ogrlineref.rst @@ -16,15 +16,15 @@ Synopsis .. code-block:: ogrlineref [--help] [--help-general] [-progress] [-quiet] - [-f format_name] [[-dsco NAME=VALUE] ...] [[-lco NAME=VALUE]...] - [-create] - [-l src_line_datasource_name] [-ln layer_name] [-lf field_name] - [-p src_repers_datasource_name] [-pn layer_name] [-pm pos_field_name] [-pf field_name] - [-r src_parts_datasource_name] [-rn layer_name] - [-o dst_datasource_name] [-on layer_name] [-of field_name] [-s step] - [-get_pos] [-x long] [-y lat] - [-get_coord] [-m position] - [-get_subline] [-mb position] [-me position] + [-f <format_name>] [-dsco <NAME>=<VALUE>]... [-lco <NAME>=<VALUE>]... + [-create] + [-l <src_line_datasource_name>] [-ln <layer_name>] [-lf <field_name>] + [-p <src_repers_datasource_name>] [-pn <layer_name>] [-pm <pos_field_name>] [-pf <field_name>] + [-r <src_parts_datasource_name>] [-rn <layer_name>] + [-o <dst_datasource_name>] [-on <layer_name>] [-of <field_name>] [-s <step>] + [-get_pos] [-x <long>] [-y <lat>] + [-get_coord] [-m <position>] + [-get_subline] [-mb <position>] [-me <position>] Description ----------- @@ -63,11 +63,11 @@ Also some information is written to the stdout. Select an output format name. The default is to create a shapefile. -.. option:: -dsco <NAME=VALUE> +.. option:: -dsco <NAME>=<VALUE> Dataset creation option (format specific) -.. option:: -lco <NAME=VALUE> +.. option:: -lco <NAME>=<VALUE> Layer creation option (format specific). diff --git a/doc/source/programs/ogrmerge.rst b/doc/source/programs/ogrmerge.rst index f2b63d321535..15fe78cfca44 100644 --- a/doc/source/programs/ogrmerge.rst +++ b/doc/source/programs/ogrmerge.rst @@ -16,12 +16,12 @@ Synopsis .. code-block:: ogrmerge.py [--help] [--help-general] - -o <out_dsname> <src_dsname> [<src_dsname>]* - [-f format] [-single] [-nln layer_name_template] + -o <out_dsname> <src_dsname> [<src_dsname>]... + [-f format] [-single] [-nln <layer_name_template>] [-update | -overwrite_ds] [-append | -overwrite_layer] - [-src_geom_type geom_type_name[,geom_type_name]*] - [-dsco NAME=VALUE]* [-lco NAME=VALUE]* - [-s_srs srs_def] [-t_srs srs_def | -a_srs srs_def] + [-src_geom_type <geom_type_name>[,<geom_type_name>]...] + [-dsco <NAME>=<VALUE>]... [-lco <NAME>=<VALUE>]... + [-s_srs <srs_def>] [-t_srs <srs_def> | -a_srs <srs_def>] [-progress] [-skipfailures] [--help-general] Options specific to the :ref:`-single <ogrmerge_single_option>` option: @@ -29,8 +29,8 @@ Options specific to the :ref:`-single <ogrmerge_single_option>` option: .. code-block:: [-field_strategy FirstLayer|Union|Intersection] - [-src_layer_field_name name] - [-src_layer_field_content layer_name_template] + [-src_layer_field_name <name>] + [-src_layer_field_content <layer_name_template>] Description ----------- @@ -116,7 +116,7 @@ potential manual editing of it and :program:`ogr2ogr` can be done. already exist, replace their content with the one of the input layer. -.. option:: -src_geom_type <geom_type_name[,geom_type_name]\*]> +.. option:: -src_geom_type <geom_type_name>[,<geom_type_name>]... Only take into account input layers whose geometry type match the type(s) specified. Valid values for geom_type_name are GEOMETRY, @@ -124,11 +124,11 @@ potential manual editing of it and :program:`ogr2ogr` can be done. GEOMETRYCOLLECTION, CIRCULARSTRING, CURVEPOLYGON, MULTICURVE, MULTISURFACE, CURVE, SURFACE, TRIANGLE, POLYHEDRALSURFACE and TIN. -.. option:: -dsco <NAME=VALUE> +.. option:: -dsco <NAME>=<VALUE> Dataset creation option (format specific) -.. option:: -lco <NAME=VALUE> +.. option:: -lco <NAME>=<VALUE> Layer creation option (format specific) diff --git a/doc/source/programs/ogrtindex.rst b/doc/source/programs/ogrtindex.rst index ff1e22f5fa88..feea3f68cd56 100644 --- a/doc/source/programs/ogrtindex.rst +++ b/doc/source/programs/ogrtindex.rst @@ -16,12 +16,13 @@ Synopsis .. code-block:: ogrtindex [--help] [--help-general] - [-lnum n]... [-lname name]... [-f output_format] + [-lnum <n>]... [-lname <name>]... [-f <output_format>] [-write_absolute_path] [-skip_different_projection] - [-t_srs target_srs] - [-src_srs_name field_name] [-src_srs_format [AUTO|WKT|EPSG|PROJ] + [-t_srs <target_srs>] + [-src_srs_name <field_name>] [-src_srs_format {AUTO|WKT|EPSG|PROJ}] [-accept_different_schemas] - <output_dataset> <src_dataset>... + <output_dataset> <src_dataset> <src_dataset>... + Description ----------- @@ -78,7 +79,7 @@ the OGR connection type. .. versionadded:: 2.2.0 -.. option:: -src_srs_format <format> +.. option:: -src_srs_format {AUTO|WKT|EPSG|PROJ} The format in which the SRS of each tile must be written. Available formats are: ``AUTO``, ``WKT``, ``EPSG``, ``PROJ``. diff --git a/doc/source/programs/options/co.rst b/doc/source/programs/options/co.rst index f3de85dfc191..9268315f1518 100644 --- a/doc/source/programs/options/co.rst +++ b/doc/source/programs/options/co.rst @@ -1,6 +1,6 @@ .. WARNING: if modifying that file, please edit gdal_translate.rst too -.. option:: -co <NAME=VALUE> +.. option:: -co <NAME>=<VALUE> Many formats have one or more optional creation options that can be used to control particulars about the file created. For instance, diff --git a/doc/source/programs/sozip.rst b/doc/source/programs/sozip.rst index 9912b78ff417..4913a37ac9af 100644 --- a/doc/source/programs/sozip.rst +++ b/doc/source/programs/sozip.rst @@ -25,11 +25,11 @@ Synopsis [-l|--list] [--optimize-from=<input.zip>] [--validate] - [--enable-sozip=auto/yes/no] - [--sozip-chunk-size=value] - [--sozip-min-file-size=value] - [--content-type=value] - zip_filename [filename]* + [--enable-sozip={auto|yes|no}] + [--sozip-chunk-size=<value>] + [--sozip-min-file-size=<value>] + [--content-type=<value>] + <zip_filename> [<filename>]... Description @@ -94,20 +94,20 @@ The :program:`sozip` utility can be used to: :option:`--enable-sozip`, :option:`--sozip-chunk-size` and :option:`--sozip-min-file-size` may be used in that mode. -.. option:: --enable-sozip=auto/yes/no +.. option:: --enable-sozip={auto|yes|no} In ``auto`` mode, a file is seek-optimized only if its size is above the value of :option:`--sozip-chunk-size`. In ``yes`` mode, all input files will be seek-optimized. In ``no`` mode, no input files will be seek-optimized. -.. option:: --sozip-chunk-size +.. option:: --sozip-chunk-size=<value> Chunk size for a seek-optimized file. Defaults to 32768 bytes. The value is specified in bytes, or K and M suffix can be respectively used to specify a value in kilo-bytes or mega-bytes. -.. option:: --sozip-min-file-size +.. option:: --sozip-min-file-size=<value> Minimum file size to decide if a file should be seek-optimized, in --enable-sozip=auto mode. Defaults to 1 MB byte. The value diff --git a/swig/python/gdal-utils/README.rst b/swig/python/gdal-utils/README.rst index ee02320a2c48..6027c71ecf43 100644 --- a/swig/python/gdal-utils/README.rst +++ b/swig/python/gdal-utils/README.rst @@ -86,9 +86,9 @@ When called without arguments script should return a message prefixed 'Usage: ` and use return code ``2``.:: ยป gdal_edit - Usage: gdal_edit [--help-general] [-ro] [-a_srs srs_def] + Usage: gdal_edit [--help-general] [-ro] [-a_srs <srs_def>] ... - [-unsetmd] [-oo NAME=VALUE]* [-mo "META-TAG=VALUE"]* datasetname + [-unsetmd] [-oo <NAME>=<VALUE>]... [-mo <META-TAG>=<VALUE>]... <datasetname> Edit in place various information of an existing GDAL dataset. diff --git a/swig/python/gdal-utils/osgeo_utils/gdal_edit.py b/swig/python/gdal-utils/osgeo_utils/gdal_edit.py index 1bd9963bc885..6d760207fc7e 100644 --- a/swig/python/gdal-utils/osgeo_utils/gdal_edit.py +++ b/swig/python/gdal-utils/osgeo_utils/gdal_edit.py @@ -34,25 +34,38 @@ from osgeo import gdal, osr -def Usage(): - print("Usage: gdal_edit [--help] [--help-general] [-ro] [-a_srs srs_def]") +def Usage(isError): + f = sys.stderr if isError else sys.stdout + print("Usage: gdal_edit [--help] [--help-general] [-ro] [-a_srs <srs_def>]", file=f) print( - " [-a_ullr ulx uly lrx lry] [-a_ulurll ulx uly urx ury llx lly]" + " [-a_ullr <ulx> <uly> <lrx> <lry>] [-a_ulurll <ulx> <uly> <urx> <ury> <llx> <lly>]", + file=f, ) print( - " [-tr xres yres] [-unsetgt] [-unsetrpc] [-a_nodata value] [-unsetnodata]" + " [-tr <xres> <yres>] [-unsetgt] [-unsetrpc] [-a_nodata <value>] [-unsetnodata]", + file=f, ) - print(" [-offset value] [-scale value] [-units value]") - print(" [-colorinterp_X red|green|blue|alpha|gray|undefined]*") - print(" [-unsetstats] [-stats] [-approx_stats]") - print(" [-setstats min max mean stddev]") - print(" [-gcp pixel line easting northing [elevation]]*") print( - ' [-unsetmd] [-oo NAME=VALUE]* [-mo "META-TAG=VALUE"]* datasetname' + " [-offset <value>] [-scale <value>] [-units <value>]", file=f ) - print("") - print("Edit in place various information of an existing GDAL dataset.") - return 2 + print( + " [-colorinterp_<X> {red|green|blue|alpha|gray|undefined]]...", + file=f, + ) + print(" [-unsetstats] [-stats] [-approx_stats]", file=f) + print(" [-setstats <min> <max> <mean> <stddev>]", file=f) + print( + " [-gcp <pixel> <line> <easting> <northing> [<elevation>]]...", + file=f, + ) + print( + " [-unsetmd] [-oo <NAME>=<VALUE>]... [-mo <META-TAG>=<VALUE>]...", + file=f, + ) + print(" <dataset_name>", file=f) + print("", file=f) + print("Edit in place various information of an existing GDAL dataset.", file=f) + return 2 if isError else 0 def ArgIsNumeric(s): @@ -112,7 +125,7 @@ def gdal_edit(argv): argc = len(argv) while i < argc: if argv[i] == "--help": - return Usage() + return Usage(isError=False) elif argv[i] == "-ro": ro = True elif argv[i] == "-a_srs" and i < len(argv) - 1: @@ -242,26 +255,27 @@ def gdal_edit(argv): elif val.lower() == "undefined": val = gdal.GCI_Undefined else: - sys.stderr.write( + print( "Unsupported color interpretation %s.\n" % val - + "Only red, green, blue, alpha, gray, undefined are supported.\n" + + "Only red, green, blue, alpha, gray, undefined are supported.\n", + file=sys.stderr, ) - return Usage() + return Usage(isError=True) colorinterp[band] = val i = i + 1 elif argv[i][0] == "-": - sys.stderr.write("Unrecognized option : %s\n" % argv[i]) - return Usage() + print("Unrecognized option : %s\n" % argv[i], file=sys.stderr) + return Usage(isError=True) elif datasetname is None: datasetname = argv[i] else: - sys.stderr.write("Unexpected option : %s\n" % argv[i]) - return Usage() + print("Unexpected option : %s\n" % argv[i], file=sys.stderr) + return Usage(isError=True) i = i + 1 if datasetname is None: - return Usage() + return Usage(isError=True) if ( srs is None @@ -282,9 +296,9 @@ def gdal_edit(argv): and offset is None and not unsetrpc ): - print("No option specified") - print("") - return Usage() + print("No option specified", file=sys.stderr) + print("", file=sys.stderr) + return Usage(isError=True) exclusive_option = 0 if lry is not None: @@ -296,19 +310,25 @@ def gdal_edit(argv): if unsetgt: exclusive_option = exclusive_option + 1 if exclusive_option > 1: - print("-a_ullr, -a_ulurll, -tr and -unsetgt options are exclusive.") - print("") - return Usage() + print( + "-a_ullr, -a_ulurll, -tr and -unsetgt options are exclusive.", + file=sys.stderr, + ) + print("", file=sys.stderr) + return Usage(isError=True) if unsetstats and stats: - print("-unsetstats and either -stats or -approx_stats options are exclusive.") - print("") - return Usage() + print( + "-unsetstats and either -stats or -approx_stats options are exclusive.", + file=sys.stderr, + ) + print("", file=sys.stderr) + return Usage(isError=True) if unsetnodata and nodata: - print("-unsetnodata and -nodata options are exclusive.") - print("") - return Usage() + print("-unsetnodata and -nodata options are exclusive.", file=sys.stderr) + print("", file=sys.stderr) + return Usage(isError=True) if open_options is not None: if ro: @@ -330,20 +350,22 @@ def gdal_edit(argv): scale = scale * ds.RasterCount elif len(scale) != ds.RasterCount: print( - "If more than one scale value is provided, their number must match the number of bands." + "If more than one scale value is provided, their number must match the number of bands.", + file=sys.stderr, ) - print("") - return Usage() + print("", file=sys.stderr) + return Usage(isError=True) if offset: if len(offset) == 1: offset = offset * ds.RasterCount elif len(offset) != ds.RasterCount: print( - "If more than one offset value is provided, their number must match the number of bands." + "If more than one offset value is provided, their number must match the number of bands.", + file=sys.stderr, ) - print("") - return Usage() + print("", file=sys.stderr) + return Usage(isError=True) wkt = None if srs == "" or srs == "None": @@ -351,7 +373,7 @@ def gdal_edit(argv): elif srs is not None: sr = osr.SpatialReference() if sr.SetFromUserInput(srs) != 0: - print("Failed to process SRS definition: %s" % srs) + print("Failed to process SRS definition: %s" % srs, file=sys.stderr) return -1 wkt = sr.ExportToWkt() if not gcp_list: diff --git a/swig/python/gdal-utils/osgeo_utils/gdal_merge.py b/swig/python/gdal-utils/osgeo_utils/gdal_merge.py index e84a9882678e..72f64ffba9a3 100644 --- a/swig/python/gdal-utils/osgeo_utils/gdal_merge.py +++ b/swig/python/gdal-utils/osgeo_utils/gdal_merge.py @@ -364,18 +364,32 @@ def copy_into(self, t_fh, s_band=1, t_band=1, nodata_arg=None, verbose=0): # ============================================================================= -def Usage(): - print("Usage: gdal_merge.py [--help] [--help-general]") - print(" [-o out_filename] [-of out_format] [-co NAME=VALUE]*") +def Usage(isError): + f = sys.stderr if isError else sys.stdout + print("Usage: gdal_merge.py [--help] [--help-general]", file=f) print( - " [-ps pixelsize_x pixelsize_y] [-tap] [-separate] [-q] [-v] [-pct]" + " [-o <out_filename>] [-of <out_format>] [-co <NAME>=<VALUE>]...", + file=f, ) - print(' [-ul_lr ulx uly lrx lry] [-init "value [value...]"]') - print(" [-n nodata_value] [-a_nodata output_nodata_value]") - print(" [-ot datatype] [-createonly] input_files") - print(" [--help-general]") - print("") - return 2 + print( + " [-ps <pixelsize_x> <pixelsize_y>] [-tap] [-separate] [-q] [-v] [-pct]", + file=f, + ) + print( + ' [-ul_lr <ulx> <uly> <lrx> <lry>] [-init "<value>[ <value>]..."]', + file=f, + ) + print( + " [-n <nodata_value>] [-a_nodata <output_nodata_value>]", + file=f, + ) + print( + " [-ot <datatype>] [-createonly] <input_file> [<input_file>]...", + file=f, + ) + print(" [--help-general]", file=f) + print("", file=f) + return 2 if isError else 0 def gdal_merge(argv=None): @@ -410,7 +424,7 @@ def gdal_merge(argv=None): arg = argv[i] if arg == "--help": - return Usage() + return Usage(isError=False) elif arg == "-o": i = i + 1 @@ -480,7 +494,7 @@ def gdal_merge(argv=None): elif arg[:1] == "-": print("Unrecognized command option: %s" % arg) - return Usage() + return Usage(isError=True) else: names.append(arg) @@ -489,7 +503,7 @@ def gdal_merge(argv=None): if not names: print("No input files selected.") - return Usage() + return Usage(isError=True) if driver_name is None: driver_name = GetOutputDriverFor(out_file) diff --git a/swig/python/gdal-utils/osgeo_utils/gdal_pansharpen.py b/swig/python/gdal-utils/osgeo_utils/gdal_pansharpen.py index 08c1e8fb5c30..b9bd8cc1477f 100644 --- a/swig/python/gdal-utils/osgeo_utils/gdal_pansharpen.py +++ b/swig/python/gdal-utils/osgeo_utils/gdal_pansharpen.py @@ -40,25 +40,32 @@ from osgeo_utils.auxiliary.util import GetOutputDriverFor -def Usage(): - print("Usage: gdal_pansharpen [--help] [--help-general]") +def Usage(isError): + f = sys.stderr if isError else sys.stdout + print("Usage: gdal_pansharpen [--help] [--help-general]", file=f) print( - " pan_dataset {spectral_dataset[,band=num]}+ out_dataset" + " <pan_dataset> {<spectral_dataset>[,band=<num>]} {<spectral_dataset>[,band=<num>]}... <out_dataset>", + file=f, ) - print(" [-of format] [-b band]* [-w weight]*") print( - " [-r {nearest,bilinear,cubic,cubicspline,lanczos,average}]" + " [-of <format>] [-b <band>]... [-w <weight>]...", file=f ) print( - " [-threads {ALL_CPUS|number}] [-bitdepth val] [-nodata val]" + " [-r {nearest|bilinear|cubic|cubicspline|lanczos|average}]", + file=f, ) print( - " [-spat_adjust {union,intersection,none,nonewithoutwarning}]" + " [-threads {ALL_CPUS|<number>}] [-bitdepth <val>] [-nodata <val>]", + file=f, ) - print(" [-verbose_vrt] [-co NAME=VALUE]* [-q]") - print("") - print("Create a dataset resulting from a pansharpening operation.") - return 2 + print( + " [-spat_adjust {union|intersection|none|nonewithoutwarning}]", + file=f, + ) + print(" [-verbose_vrt] [-co <NAME>=<VALUE>]... [-q]", file=f) + print("", file=f) + print("Create a dataset resulting from a pansharpening operation.", file=f) + return 2 if isError else 0 def main(argv=sys.argv): @@ -117,10 +124,10 @@ def main(argv=sys.argv): elif argv[i] == "-verbose_vrt": verbose_vrt = True elif argv[i] == "--help": - return Usage() + return Usage(isError=False) elif argv[i][0] == "-": sys.stderr.write("Unrecognized option : %s\n" % argv[i]) - return Usage() + return Usage(isError=True) elif pan_name is None: pan_name = argv[i] else: @@ -129,7 +136,7 @@ def main(argv=sys.argv): i = i + 1 if pan_name is None or len(spectral_names) < 2: - return Usage() + return Usage(isError=True) dst_filename = spectral_names.pop() return gdal_pansharpen( diff --git a/swig/python/gdal-utils/osgeo_utils/gdal_proximity.py b/swig/python/gdal-utils/osgeo_utils/gdal_proximity.py index 08098c73b11b..ab9059cf23dc 100644 --- a/swig/python/gdal-utils/osgeo_utils/gdal_proximity.py +++ b/swig/python/gdal-utils/osgeo_utils/gdal_proximity.py @@ -38,18 +38,20 @@ from osgeo_utils.auxiliary.util import GetOutputDriverFor -def Usage(): +def Usage(isError): + f = sys.stderr if isError else sys.stdout print( """ Usage: gdal_proximity.py [--help] [--help-general] - <srcfile> <dstfile> [-srcband n] [-dstband n] - [-of format] [-co name=value]* - [-ot Byte/UInt16/UInt32/Float32/etc] - [-values n,n,n] [-distunits PIXEL/GEO] - [-maxdist n] [-nodata n] [-use_input_nodata YES/NO] - [-fixed-buf-val n] [-q] """ + <srcfile> <dstfile> [-srcband <n>] [-dstband <n>] + [-of <format>] [-co <name>=<value>]... + [-ot {Byte|UInt16|UInt32|Float32|etc}] + [-values <n>,<n>,<n>] [-distunits {PIXEL|GEO}] + [-maxdist <n>] [-nodata <n>] [-use_input_nodata {YES|NO}] + [-fixed-buf-val <n>] [-q] """, + file=f, ) - return 2 + return 2 if isError else 0 def main(argv=sys.argv): @@ -73,7 +75,7 @@ def main(argv=sys.argv): arg = argv[i] if arg == "--help": - return Usage() + return Usage(isError=False) elif arg == "-of" or arg == "-f": i = i + 1 @@ -124,7 +126,7 @@ def main(argv=sys.argv): elif arg[0] == "-": sys.stderr.write("Unrecognized option : %s\n" % argv[i]) - return Usage() + return Usage(isError=True) elif src_filename is None: src_filename = argv[i] @@ -133,17 +135,17 @@ def main(argv=sys.argv): dst_filename = argv[i] else: - return Usage() + return Usage(isError=True) i = i + 1 if src_filename is None: sys.stderr.write("Missing <srcfile>\n") - return Usage() + return Usage(isError=True) if dst_filename is None: sys.stderr.write("Missing <dstfile>\n") - return Usage() + return Usage(isError=True) return gdal_proximity( src_filename=src_filename, diff --git a/swig/python/gdal-utils/osgeo_utils/gdal_retile.py b/swig/python/gdal-utils/osgeo_utils/gdal_retile.py index 2a58cc935421..2c697b055f1b 100644 --- a/swig/python/gdal-utils/osgeo_utils/gdal_retile.py +++ b/swig/python/gdal-utils/osgeo_utils/gdal_retile.py @@ -83,7 +83,7 @@ def get(self, name): return self.dict[name] result = gdal.Open(name) if result is None: - print("Error opening: %s" % NameError) + print("Error opening: %s" % NameError, file=sys.stderr) return 1 if len(self.queue) == self.cacheSize: toRemove = self.queue.pop(0) @@ -555,7 +555,7 @@ def createPyramidTile( t_fh = g.MemDriver.Create("", width, height, bands, bt) if t_fh is None: - print("Creation failed, terminating gdal_tile.") + print("Creation failed, terminating gdal_tile.", file=sys.stderr) return 1 t_fh.SetGeoTransform(geotransform) @@ -575,7 +575,10 @@ def createPyramidTile( # reproject source filehandle to target filehandle res = gdal.ReprojectImage(s_fh, t_fh, None, None, g.ResamplingMethod) if res != 0: - print("Reprojection failed for %s, error %d" % (temp_tilename, res)) + print( + "Reprojection failed for %s, error %d" % (temp_tilename, res), + file=sys.stderr, + ) return 1 levelMosaicInfo.closeDataSet(s_fh) @@ -674,7 +677,7 @@ def createTile( t_fh = g.MemDriver.Create("", width, height, bands, bt) if t_fh is None: - print("Creation failed, terminating gdal_tile.") + print("Creation failed, terminating gdal_tile.", file=sys.stderr) return 1 t_fh.SetGeoTransform(geotransform) @@ -725,7 +728,7 @@ def createTile( def createTileIndex(Verbose, dsName, fieldName, srs, driverName): OGRDriver = ogr.GetDriverByName(driverName) if OGRDriver is None: - print("ESRI Shapefile driver not found") + print("ESRI Shapefile driver not found", file=sys.stderr) return 1 OGRDataSource = OGRDriver.Open(dsName) @@ -737,22 +740,22 @@ def createTileIndex(Verbose, dsName, fieldName, srs, driverName): OGRDataSource = OGRDriver.CreateDataSource(dsName) if OGRDataSource is None: - print("Could not open datasource " + dsName) + print("Could not open datasource " + dsName, file=sys.stderr) return 1 OGRLayer = OGRDataSource.CreateLayer("index", srs, ogr.wkbPolygon) if OGRLayer is None: - print("Could not create Layer") + print("Could not create Layer", file=sys.stderr) return 1 OGRFieldDefn = ogr.FieldDefn(fieldName, ogr.OFTString) if OGRFieldDefn is None: - print("Could not create FieldDefn for " + fieldName) + print("Could not create FieldDefn for " + fieldName, file=sys.stderr) return 1 OGRFieldDefn.SetWidth(256) if OGRLayer.CreateField(OGRFieldDefn) != 0: - print("Could not create Field for " + fieldName) + print("Could not create Field for " + fieldName, file=sys.stderr) return 1 return OGRDataSource @@ -762,7 +765,7 @@ def addFeature(TileIndexFieldName, OGRDataSource, location, xlist, ylist): OGRLayer = OGRDataSource.GetLayer() OGRFeature = ogr.Feature(OGRLayer.GetLayerDefn()) if OGRFeature is None: - print("Could not create Feature") + print("Could not create Feature", file=sys.stderr) return 1 OGRFeature.SetField(TileIndexFieldName, location) @@ -780,7 +783,7 @@ def addFeature(TileIndexFieldName, OGRDataSource, location, xlist, ylist): ) OGRGeometry = ogr.CreateGeometryFromWkt(wkt, OGRLayer.GetSpatialRef()) if OGRGeometry is None: - print("Could not create Geometry") + print("Could not create Geometry", file=sys.stderr) return 1 OGRFeature.SetGeometryDirectly(OGRGeometry) @@ -920,20 +923,21 @@ def UsageFormat(): # ============================================================================= -def Usage(): - print("Usage: gdal_retile.py [--help] [--help-general]") - print(" [-v] [-q] [-co NAME=VALUE]* [-of out_format]") - print(" [-ps pixelWidth pixelHeight]") - print(" [-overlap val_in_pixel]") - print(" [-ot {Byte/Int8/Int16/UInt16/UInt32/Int32/Float32/Float64/") - print(" CInt16/CInt32/CFloat32/CFloat64}]") - print(" [ -tileIndex tileIndexName [-tileIndexField fieldName]]") - print(" [ -csv fileName [-csvDelim delimiter]]") - print(" [-s_srs srs_def] [-pyramidOnly] -levels numberoflevels") - print(" [-r {near/bilinear/cubic/cubicspline/lanczos}]") - print(" [-useDirForEachRow] [-resume]") - print(" -targetDir TileDirectory input_files") - return 2 +def Usage(isError): + f = sys.stderr if isError else sys.stdout + print("Usage: gdal_retile.py [--help] [--help-general]", file=f) + print(" [-v] [-q] [-co <NAME>=<VALUE>]... [-of <out_format>]", file=f) + print(" [-ps <pixelWidth> <pixelHeight>]", file=f) + print(" [-overlap <val_in_pixel>]", file=f) + print(" [-ot {Byte|Int8|Int16|UInt16|UInt32|Int32|Float32|Float64|", file=f) + print(" CInt16|CInt32|CFloat32|CFloat64}]", file=f) + print(" [-tileIndex <tileIndexName> [-tileIndexField <fieldName>]]", file=f) + print(" [-csv <fileName> [-csvDelim <delimiter>]]", file=f) + print(" [-s_srs <srs_def>] [-pyramidOnly] -levels <numberoflevels>", file=f) + print(" [-r {near|bilinear|cubic|cubicspline|lanczos}]", file=f) + print(" [-useDirForEachRow] [-resume]", file=f) + print(" -targetDir <TileDirectory> <input_file> [<input_file>]...", file=f) + return 2 if isError else 0 def main(args=None, g=None): @@ -952,7 +956,7 @@ def main(args=None, g=None): arg = argv[i] if arg == "--help": - return Usage() + return Usage(isError=False) elif arg == "-of" or arg == "-f": i += 1 g.Format = argv[i] @@ -960,7 +964,7 @@ def main(args=None, g=None): i += 1 g.BandType = gdal.GetDataTypeByName(argv[i]) if g.BandType == gdal.GDT_Unknown: - print("Unknown GDAL data type: %s" % argv[i]) + print("Unknown GDAL data type: %s" % argv[i], file=sys.stderr) return 1 elif arg == "-co": i += 1 @@ -976,7 +980,7 @@ def main(args=None, g=None): g.TargetDir = argv[i] if not os.path.exists(g.TargetDir): - print("TargetDir " + g.TargetDir + " does not exist") + print("TargetDir " + g.TargetDir + " does not exist", file=sys.stderr) return 1 if g.TargetDir[len(g.TargetDir) - 1 :] != os.sep: g.TargetDir = g.TargetDir + os.sep @@ -1046,8 +1050,8 @@ def main(args=None, g=None): elif arg == "-resume": g.Resume = True elif arg[:1] == "-": - print("Unrecognized command option: %s" % arg) - return Usage() + print("Unrecognized command option: %s" % arg, file=sys.stderr) + return Usage(isError=True) else: g.Names.append(arg) @@ -1055,18 +1059,21 @@ def main(args=None, g=None): if not g.Names: print("No input files selected.") - return Usage() + return Usage(isError=True) if g.TileWidth == 0 or g.TileHeight == 0: - print("Invalid tile dimension %d,%d" % (g.TileWidth, g.TileHeight)) + print( + "Invalid tile dimension %d,%d" % (g.TileWidth, g.TileHeight), + file=sys.stderr, + ) return 1 if g.TileWidth - g.Overlap <= 0 or g.TileHeight - g.Overlap <= 0: - print("Overlap too big w.r.t tile height/width") + print("Overlap too big w.r.t tile height/width", file=sys.stderr) return 1 if g.TargetDir is None: - print("Missing Directory for Tiles -targetDir") - return Usage() + print("Missing Directory for Tiles -targetDir", file=sys.stderr) + return Usage(isError=True) # create level 0 directory if needed if g.UseDirForEachRow and not g.PyramidOnly: @@ -1082,14 +1089,17 @@ def main(args=None, g=None): continue os.mkdir(leveldir) if not os.path.exists(leveldir): - print("Cannot create level dir: %s" % leveldir) + print("Cannot create level dir: %s" % leveldir, file=sys.stderr) return 1 if g.Verbose: - print("Created level dir: %s" % leveldir) + print("Created level dir: %s" % leveldir, file=sys.stderr) g.Driver = gdal.GetDriverByName(g.Format) if g.Driver is None: - print("Format driver %s not found, pick a supported driver." % g.Format) + print( + "Format driver %s not found, pick a supported driver." % g.Format, + file=sys.stderr, + ) return UsageFormat() DriverMD = g.Driver.GetMetadata() @@ -1099,7 +1109,7 @@ def main(args=None, g=None): tileIndexDS = getTileIndexFromFiles(g) if tileIndexDS is None: - print("Error building tile index") + print("Error building tile index", file=sys.stderr) return 1 minfo = mosaic_info(g.Names[0], tileIndexDS) ti = tile_info(minfo.xsize, minfo.ysize, g.TileWidth, g.TileHeight, g.Overlap) @@ -1107,7 +1117,7 @@ def main(args=None, g=None): if g.Source_SRS is None and minfo.projection: g.Source_SRS = osr.SpatialReference() if g.Source_SRS.SetFromUserInput(minfo.projection) != 0: - print("invalid projection " + minfo.projection) + print("invalid projection " + minfo.projection, file=sys.stderr) return 1 if g.Verbose: diff --git a/swig/python/gdal-utils/osgeo_utils/ogr_layer_algebra.py b/swig/python/gdal-utils/osgeo_utils/ogr_layer_algebra.py index 28d78260bef6..1dd43e71b6d5 100644 --- a/swig/python/gdal-utils/osgeo_utils/ogr_layer_algebra.py +++ b/swig/python/gdal-utils/osgeo_utils/ogr_layer_algebra.py @@ -37,20 +37,21 @@ ############################################################################### -def Usage(): +def Usage(isError): print( """ Usage: ogr_layer_algebra.py [--help] [--help-general] Union|Intersection|SymDifference|Identity|Update|Clip|Erase - -input_ds name [-input_lyr name] - -method_ds [-method_lyr name] - -output_ds name [-output_lyr name] [-overwrite] - [-opt NAME=VALUE]* - [-f format_name] [-dsco NAME=VALUE]* [-lco NAME=VALUE]* - [-input_fields NONE|ALL|fld1,fl2,...fldN] [-method_fields NONE|ALL|fld1,fl2,...fldN] - [-nlt geom_type] [-a_srs srs_def]""" + -input_ds <path> [-input_lyr <name>] + -method_ds <path> [-method_lyr <name>] + -output_ds <path> [-output_lyr name] [-overwrite] + [-opt <NAME>=<VALUE>]... + [-f <format_name>] [-dsco <NAME>=<VALUE>]... [-lco <NAME>=<VALUE>]... + [-input_fields {NONE|ALL|<fld1>,<fl2>,...<fldN>}] [-method_fields {NONE|ALL|<fld1>,<fl2>,...<fldN>}] + [-nlt <geom_type>] [-a_srs <srs_def>]""", + file=sys.stderr if isError else sys.stdout, ) - return 2 + return 2 if isError else 0 ############################################################################### @@ -78,7 +79,7 @@ def CreateLayer( output_lyr = output_ds.CreateLayer(output_lyr_name, srs, geom_type, lco) if output_lyr is None: - print('Cannot create layer "%s"' % output_lyr_name) + print('Cannot create layer "%s"' % output_lyr_name, file=sys.stderr) return None if input_fields == "ALL" and method_fields == "ALL": @@ -102,7 +103,8 @@ def CreateLayer( if output_lyr.CreateField(fld_defn) != 0: print( 'Cannot create field "%s" in layer "%s"' - % (fld_defn.GetName(), output_lyr.GetName()) + % (fld_defn.GetName(), output_lyr.GetName()), + file=sys.stderr, ) elif input_fields != "NONE": @@ -111,7 +113,9 @@ def CreateLayer( idx = layer_defn.GetFieldIndex(fld) if idx < 0: print( - 'Cannot find field "%s" in layer "%s"' % (fld, layer_defn.GetName()) + 'Cannot find field "%s" in layer "%s"' + % (fld, layer_defn.GetName()), + file=sys.stderr, ) continue fld_defn = layer_defn.GetFieldDefn(idx) @@ -121,7 +125,8 @@ def CreateLayer( if output_lyr.CreateField(fld_defn) != 0: print( 'Cannot create field "%s" in layer "%s"' - % (fld, output_lyr.GetName()) + % (fld, output_lyr.GetName()), + file=sys.stderr, ) if method_fields == "ALL": @@ -134,7 +139,8 @@ def CreateLayer( if output_lyr.CreateField(fld_defn) != 0: print( 'Cannot create field "%s" in layer "%s"' - % (fld_defn.GetName(), output_lyr.GetName()) + % (fld_defn.GetName(), output_lyr.GetName()), + file=sys.stderr, ) elif method_fields != "NONE": @@ -143,7 +149,9 @@ def CreateLayer( idx = layer_defn.GetFieldIndex(fld) if idx < 0: print( - 'Cannot find field "%s" in layer "%s"' % (fld, layer_defn.GetName()) + 'Cannot find field "%s" in layer "%s"' + % (fld, layer_defn.GetName()), + file=sys.stderr, ) continue fld_defn = layer_defn.GetFieldDefn(idx) @@ -153,7 +161,8 @@ def CreateLayer( if output_lyr.CreateField(fld_defn) != 0: print( 'Cannot create field "%s" in layer "%s"' - % (fld, output_lyr.GetName()) + % (fld, output_lyr.GetName()), + file=sys.stderr, ) return output_lyr @@ -163,11 +172,6 @@ def CreateLayer( def main(argv=sys.argv): - version_num = int(gdal.VersionInfo("VERSION_NUM")) - if version_num < 1100000: - print("ERROR: Python bindings of GDAL 1.10 or later required") - return 1 - driver_name = "ESRI Shapefile" quiet = False input_ds_name = None @@ -197,7 +201,7 @@ def main(argv=sys.argv): arg = argv[i] if arg == "--help": - return Usage() + return Usage(isError=False) elif arg == "-f" and i + 1 < len(argv): i = i + 1 @@ -296,7 +300,7 @@ def main(argv=sys.argv): elif EQUAL(val, "MULTIPOLYGON25D"): geom_type = ogr.wkbMultiPolygon25D else: - print("-nlt %s: type not recognised." % val) + print("-nlt %s: type not recognised." % val, file=sys.stderr) return 1 elif arg == "-a_srs" and i + 1 < len(argv): @@ -331,7 +335,7 @@ def main(argv=sys.argv): quiet = True else: - return Usage() + return Usage(isError=True) i = i + 1 @@ -341,7 +345,7 @@ def main(argv=sys.argv): or output_ds_name is None or op_str is None ): - return Usage() + return Usage(isError=True) if method_fields is None: if op_str in ("Update", "Clip", "Erase"): @@ -351,47 +355,50 @@ def main(argv=sys.argv): if input_fields == "NONE" and method_fields == "NONE": print( - "Warning: -input_fields NONE and -method_fields NONE results in all fields being added" + "Warning: -input_fields NONE and -method_fields NONE results in all fields being added", + file=sys.stderr, ) # Input layer input_ds = ogr.Open(input_ds_name) if input_ds is None: - print("Cannot open input dataset : %s" % input_ds_name) + print("Cannot open input dataset : %s" % input_ds_name, file=sys.stderr) return 1 if input_lyr_name is None: cnt = input_ds.GetLayerCount() if cnt != 1: print( - "Input datasource has not a single layer, so you should specify its name with -input_lyr" + "Input datasource has not a single layer, so you should specify its name with -input_lyr", + file=sys.stderr, ) return 1 input_lyr = input_ds.GetLayer(0) else: input_lyr = input_ds.GetLayerByName(input_lyr_name) if input_lyr is None: - print('Cannot find input layer "%s"' % input_lyr_name) + print('Cannot find input layer "%s"' % input_lyr_name, file=sys.stderr) return 1 # Method layer method_ds = ogr.Open(method_ds_name) if method_ds is None: - print("Cannot open method dataset : %s" % method_ds_name) + print("Cannot open method dataset : %s" % method_ds_name, file=sys.stderr) return 1 if method_lyr_name is None: cnt = method_ds.GetLayerCount() if cnt != 1: print( - "Method datasource has not a single layer, so you should specify its name with -method_lyr" + "Method datasource has not a single layer, so you should specify its name with -method_lyr", + file=sys.stderr, ) return 1 method_lyr = method_ds.GetLayer(0) else: method_lyr = method_ds.GetLayerByName(method_lyr_name) if method_lyr is None: - print('Cannot find method layer "%s"' % method_lyr_name) + print('Cannot find method layer "%s"' % method_lyr_name, file=sys.stderr) return 1 # SRS @@ -399,20 +406,27 @@ def main(argv=sys.argv): if not EQUAL(srs_name, "NULL") and not EQUAL(srs_name, "NONE"): srs = osr.SpatialReference() if srs.SetFromUserInput(srs_name) != 0: - print("Failed to process SRS definition: %s" % srs_name) + print( + "Failed to process SRS definition: %s" % srs_name, file=sys.stderr + ) return 1 else: srs = input_lyr.GetSpatialRef() srs2 = method_lyr.GetSpatialRef() if srs is None and srs2 is not None: - print("Warning: input layer has no SRS defined, but method layer has one.") + print( + "Warning: input layer has no SRS defined, but method layer has one.", + file=sys.stderr, + ) elif srs is not None and srs2 is None: print( - "Warning: input layer has a SRS defined, but method layer has not one." + "Warning: input layer has a SRS defined, but method layer has not one.", + file=sys.stderr, ) elif srs is not None and srs2 is not None and srs.IsSame(srs2) != 1: print( - "Warning: input and method layers have SRS defined, but they are not identical. No on-the-fly reprojection will be done." + "Warning: input and method layers have SRS defined, but they are not identical. No on-the-fly reprojection will be done.", + file=sys.stderr, ) # Result layer @@ -424,18 +438,19 @@ def main(argv=sys.argv): if output_ds is not None: print( 'Output datasource "%s" exists, but cannot be opened in update mode' - % output_ds_name + % output_ds_name, + file=sys.stderr, ) return 1 drv = ogr.GetDriverByName(driver_name) if drv is None: - print("Cannot find driver %s" % driver_name) + print("Cannot find driver %s" % driver_name, file=sys.stderr) return 1 output_ds = drv.CreateDataSource(output_ds_name, options=dsco) if output_ds is None: - print('Cannot create datasource "%s"' % output_ds_name) + print('Cannot create datasource "%s"' % output_ds_name, file=sys.stderr) return 1 # Special case @@ -447,7 +462,7 @@ def main(argv=sys.argv): output_lyr_name = os.path.splitext(os.path.basename(output_ds_name))[0] if output_lyr_name is None: - print("-output_lyr should be specified") + print("-output_lyr should be specified", file=sys.stderr) return 1 output_lyr = CreateLayer( @@ -471,7 +486,8 @@ def main(argv=sys.argv): cnt = output_ds.GetLayerCount() if cnt != 1: print( - "Result datasource has not a single layer, so you should specify its name with -output_lyr" + "Result datasource has not a single layer, so you should specify its name with -output_lyr", + file=sys.stderr, ) return 1 output_lyr = output_ds.GetLayer(0) @@ -490,7 +506,8 @@ def main(argv=sys.argv): ): print( 'Cannot create layer "%s" in a shapefile called "%s"' - % (output_lyr_name, output_ds_name) + % (output_lyr_name, output_ds_name), + file=sys.stderr, ) return 1 @@ -518,7 +535,10 @@ def main(argv=sys.argv): break if iLayer != cnt: if output_ds.DeleteLayer(iLayer) != 0: - print("DeleteLayer() failed when overwrite requested.") + print( + "DeleteLayer() failed when overwrite requested.", + file=sys.stderr, + ) return 1 output_lyr = CreateLayer( @@ -547,7 +567,7 @@ def main(argv=sys.argv): output_ds = None if ret != 0: - print("An error occurred during %s operation" % op_str) + print("An error occurred during %s operation" % op_str, file=sys.stderr) return 1 return 0 diff --git a/swig/python/gdal-utils/osgeo_utils/ogrmerge.py b/swig/python/gdal-utils/osgeo_utils/ogrmerge.py index a12d502fc7fe..cc930926adea 100644 --- a/swig/python/gdal-utils/osgeo_utils/ogrmerge.py +++ b/swig/python/gdal-utils/osgeo_utils/ogrmerge.py @@ -41,31 +41,38 @@ from osgeo_utils.auxiliary.util import GetOutputDriverFor -def Usage(): - print("Usage: ogrmerge.py [--help] [--help-general]") - print(" -o <out_dsname> <src_dsname> [<src_dsname>]*") - print(" [-f format] [-single] [-nln layer_name_template]") - print(" [-update | -overwrite_ds] [-append | -overwrite_layer]") - print(" [-src_geom_type geom_type_name[,geom_type_name]*]") - print(" [-dsco NAME=VALUE]* [-lco NAME=VALUE]*") - print(" [-s_srs srs_def] [-t_srs srs_def | -a_srs srs_def]") - print(" [-progress] [-skipfailures] [--help-general]") - print("") - print("Options specific to -single:") - print(" [-field_strategy FirstLayer|Union|Intersection]") - print(" [-src_layer_field_name name]") - print(" [-src_layer_field_content layer_name_template]") - print("") - print("* layer_name_template can contain the following substituable " "variables:") - print(" {AUTO_NAME} : {DS_BASENAME}_{LAYER_NAME} if they are " "different") - print(" or {LAYER_NAME} if they are identical") - print(" {DS_NAME} : name of the source dataset") - print(" {DS_BASENAME}: base name of the source dataset") - print(" {DS_INDEX} : index of the source dataset") - print(" {LAYER_NAME} : name of the source layer") - print(" {LAYER_INDEX}: index of the source layer") - - return 2 +def Usage(isError): + f = sys.stderr if isError else sys.stdout + print("Usage: ogrmerge.py [--help] [--help-general]", file=f) + print(" -o <out_dsname> <src_dsname> [<src_dsname>]...", file=f) + print(" [-f <format>] [-single] [-nln <layer_name_template>]", file=f) + print(" [-update | -overwrite_ds] [-append | -overwrite_layer]", file=f) + print(" [-src_geom_type <geom_type_name>[,<geom_type_name>]...]", file=f) + print(" [-dsco <NAME>=<VALUE>]... [-lco <NAME>=<VALUE>]...", file=f) + print(" [-s_srs <srs_def>] [-t_srs <srs_def>|-a_srs <srs_def>]", file=f) + print(" [-progress] [-skipfailures] [--help-general]", file=f) + print("", file=f) + print("Options specific to -single:", file=f) + print(" [-field_strategy {FirstLayer|Union|Intersection}]", file=f) + print(" [-src_layer_field_name <name>]", file=f) + print(" [-src_layer_field_content <layer_name_template>]", file=f) + print("", file=f) + print( + "* layer_name_template can contain the following substituable " "variables:", + file=f, + ) + print( + " {AUTO_NAME} : {DS_BASENAME}_{LAYER_NAME} if they are " "different", + file=f, + ) + print(" or {LAYER_NAME} if they are identical", file=f) + print(" {DS_NAME} : name of the source dataset", file=f) + print(" {DS_BASENAME}: base name of the source dataset", file=f) + print(" {DS_INDEX} : index of the source dataset", file=f) + print(" {LAYER_NAME} : name of the source layer", file=f) + print(" {LAYER_INDEX}: index of the source layer", file=f) + + return 2 if isError else 0 ############################################################################# @@ -163,7 +170,7 @@ def close_element(self, closing_name=None): def process(argv, progress=None, progress_arg=None): if not argv: - return Usage() + return Usage(isError=True) dst_filename = None driver_name = None @@ -191,7 +198,7 @@ def process(argv, progress=None, progress_arg=None): while i < len(argv): arg = argv[i] if arg == "--help": - return Usage() + return Usage(isError=False) elif (arg == "-f" or arg == "-of") and i + 1 < len(argv): i = i + 1 driver_name = argv[i] @@ -250,12 +257,15 @@ def process(argv, progress=None, progress_arg=None): for src_geom_type_name in src_geom_type_names: src_geom_type = _GetGeomType(src_geom_type_name) if src_geom_type is None: - print("ERROR: Unrecognized geometry type: %s" % src_geom_type_name) + print( + "ERROR: Unrecognized geometry type: %s" % src_geom_type_name, + file=sys.stderr, + ) return 1 src_geom_types.append(src_geom_type) elif arg[0] == "-": - print("ERROR: Unrecognized argument : %s" % arg) - return Usage() + print("ERROR: Unrecognized argument : %s" % arg, file=sys.stderr) + return Usage(isError=True) else: if "*" in arg: src_datasets += glob.glob(arg) @@ -264,7 +274,7 @@ def process(argv, progress=None, progress_arg=None): i = i + 1 if dst_filename is None: - print("Missing -o") + print("Missing -o", file=sys.stderr) return 1 return ogrmerge( @@ -331,7 +341,8 @@ def _build_layer_name_non_single_mode( print( "ERROR: Layer name template %s " "includes {DS_BASENAME} " - "but %s is not a file" % (layer_name_template, src_dsname) + "but %s is not a file" % (layer_name_template, src_dsname), + file=sys.stderr, ) return None layer_name = layer_name.replace("{DS_NAME}", "%s" % src_dsname) @@ -501,7 +512,7 @@ def _gpkg_ogrmerge( driver_name = "GPKG" drv = gdal.GetDriverByName(driver_name) if drv is None: - print("ERROR: Invalid driver: %s" % driver_name) + print("ERROR: Invalid driver: %s" % driver_name, file=sys.stderr) return 1 dst_ds = drv.Create(dst_filename, 0, 0, 0, gdal.GDT_Unknown, dsco) if dst_ds is None: @@ -543,7 +554,7 @@ def stop(self): for src_ds_idx, src_dsname in enumerate(src_datasets): src_ds = ogr.Open(src_dsname) if src_ds is None: - print("ERROR: Cannot open %s" % src_dsname) + print("ERROR: Cannot open %s" % src_dsname, file=sys.stderr) if skip_failures: continue return 1 @@ -712,7 +723,8 @@ def get_normalized_field_names(ds, lyr): if src_feature_count >= 0 and num_rows_inserted != src_feature_count: print( "Warning: %d rows inserted into %s whereas %d expected" - % (num_rows_inserted, lyr.GetName(), src_feature_count) + % (num_rows_inserted, lyr.GetName(), src_feature_count), + file=sys.stderr, ) dst_ds.ExecuteSQL( "INSERT OR REPLACE INTO gpkg_ogr_contents VALUES('%s',%d)" @@ -856,10 +868,10 @@ def ogrmerge( lco = lco or [] if update: if driver_name is not None: - print("ERROR: -f incompatible with -update") + print("ERROR: -f incompatible with -update", file=sys.stderr) return 1 if dsco: - print("ERROR: -dsco incompatible with -update") + print("ERROR: -dsco incompatible with -update", file=sys.stderr) return 1 driver_name = "" else: @@ -878,12 +890,13 @@ def ogrmerge( ): print( "ERROR: Non-single layer mode incompatible with non-directory " - "shapefile output" + "shapefile output", + file=sys.stderr, ) return 1 if not src_datasets: - print("ERROR: No source datasets") + print("ERROR: No source datasets", file=sys.stderr) return 1 if layer_name_template is None: @@ -912,7 +925,10 @@ def are_sources_gpkg(): for src_lyr in src_ds: if src_lyr.GetLayerDefn().GetGeomFieldCount() > 1: # shouldn't happen for now... - print("Code is not ready for multi-geometry column GPKG") + print( + "Code is not ready for multi-geometry column GPKG", + file=sys.stderr, + ) return False else: return False @@ -950,7 +966,8 @@ def are_sources_gpkg(): if not update and not overwrite_ds: print( "ERROR: Destination dataset already exists, " - + "but -update nor -overwrite_ds are specified" + + "but -update nor -overwrite_ds are specified", + file=sys.stderr, ) return 1 if overwrite_ds: @@ -962,12 +979,12 @@ def are_sources_gpkg(): else: drv.Delete(dst_filename) elif update: - print("ERROR: Destination dataset does not exist") + print("ERROR: Destination dataset does not exist", file=sys.stderr) return 1 if dst_ds is None: drv = gdal.GetDriverByName(driver_name) if drv is None: - print("ERROR: Invalid driver: %s" % driver_name) + print("ERROR: Invalid driver: %s" % driver_name, file=sys.stderr) return 1 dst_ds = drv.Create(dst_filename, 0, 0, 0, gdal.GDT_Unknown, dsco) if dst_ds is None: @@ -978,14 +995,15 @@ def are_sources_gpkg(): if gdal.VSIStatL(dst_filename) and not overwrite_ds: print( "ERROR: Destination dataset already exists, " - + "but -overwrite_ds are specified" + + "but -overwrite_ds are specified", + file=sys.stderr, ) return 1 vrt_filename = dst_filename f = gdal.VSIFOpenL(vrt_filename, "wb") if f is None: - print("ERROR: Cannot create %s" % vrt_filename) + print("ERROR: Cannot create %s" % vrt_filename, file=sys.stderr) return 1 writer = XMLWriter(f) @@ -998,7 +1016,7 @@ def are_sources_gpkg(): for src_ds_idx, src_dsname in enumerate(src_datasets): src_ds = ogr.Open(src_dsname) if src_ds is None: - print("ERROR: Cannot open %s" % src_dsname) + print("ERROR: Cannot open %s" % src_dsname, file=sys.stderr) if skip_failures: continue gdal.VSIFCloseL(f) @@ -1097,7 +1115,7 @@ def are_sources_gpkg(): for src_ds_idx, src_dsname in enumerate(src_datasets): src_ds = ogr.Open(src_dsname) if src_ds is None: - print("ERROR: Cannot open %s" % src_dsname) + print("ERROR: Cannot open %s" % src_dsname, file=sys.stderr) if skip_failures: continue gdal.VSIFCloseL(f) diff --git a/swig/python/gdal-utils/osgeo_utils/samples/gdal_lut.py b/swig/python/gdal-utils/osgeo_utils/samples/gdal_lut.py index 803d80178a1d..6c9c0df4f561 100644 --- a/swig/python/gdal-utils/osgeo_utils/samples/gdal_lut.py +++ b/swig/python/gdal-utils/osgeo_utils/samples/gdal_lut.py @@ -65,7 +65,7 @@ def Usage(): print( """ Usage: gdal_lut.py src_file [-srcband] [dst_file] [-dstband] -lutfile filename - [-of format] [-co name=value]* + [-of format] [-co name=value]... If dst_file is not specified, the result will be applied back to src_file. The text file specified with -lutfile should have one line per LUT entry diff --git a/swig/python/gdal-utils/osgeo_utils/samples/gdalinfo.py b/swig/python/gdal-utils/osgeo_utils/samples/gdalinfo.py index 9d443031da36..ed65ac82fb08 100644 --- a/swig/python/gdal-utils/osgeo_utils/samples/gdalinfo.py +++ b/swig/python/gdal-utils/osgeo_utils/samples/gdalinfo.py @@ -44,7 +44,7 @@ def Usage(): print( "Usage: gdalinfo [--help-general] [-mm] [-stats] [-hist] [-nogcp] [-nomd]\n" - + " [-norat] [-noct] [-nofl] [-checksum] [-mdd domain]* datasetname" + + " [-norat] [-noct] [-nofl] [-checksum] [-mdd domain]... datasetname" ) return 2 diff --git a/swig/python/gdal-utils/osgeo_utils/samples/loslas2ntv2.py b/swig/python/gdal-utils/osgeo_utils/samples/loslas2ntv2.py index 9e8a7efca68e..82a6b6510fad 100644 --- a/swig/python/gdal-utils/osgeo_utils/samples/loslas2ntv2.py +++ b/swig/python/gdal-utils/osgeo_utils/samples/loslas2ntv2.py @@ -55,7 +55,7 @@ def Usage(): print(" [-system_f name] [-system_t name] [-version version]") print(" [-major_f axis] [-minor_f axis]") print(" [-major_t axis] [-minor_t axis]") - print(" [-negate] [src_file.los]* dst_file.gsb ") + print(" [-negate] [src_file.los]... dst_file.gsb ") print("") print(" -a: append to existing NTv2 file.") print(" -auto: process a whole directory of nad27/hpgn los/las files.") diff --git a/swig/python/gdal-utils/osgeo_utils/samples/ogr2ogr.py b/swig/python/gdal-utils/osgeo_utils/samples/ogr2ogr.py index 90aef16e9d93..6cd4136ec250 100644 --- a/swig/python/gdal-utils/osgeo_utils/samples/ogr2ogr.py +++ b/swig/python/gdal-utils/osgeo_utils/samples/ogr2ogr.py @@ -1169,7 +1169,7 @@ def Usage(): + " [-a_srs srs_def] [-t_srs srs_def] [-s_srs srs_def]\n" + " [-f format_name] [-overwrite] [[-dsco NAME=VALUE] ...]\n" + " [-simplify tolerance]\n" - + " [-fieldTypeToString All|(type1[,type2]*)] [-explodecollections] \n" # // " [-segmentize max_dist] [-fieldTypeToString All|(type1[,type2]*)]\n" + \ + + " [-fieldTypeToString All|(type1[,type2]...)] [-explodecollections] \n" # // " [-segmentize max_dist] [-fieldTypeToString All|(type1[,type2]...)]\n" + \ + " dst_datasource_name src_datasource_name\n" + " [-lco NAME=VALUE] [-nln name] [-nlt type] [-dim 2|3] [layer [layer ...]]\n" + "\n" diff --git a/swig/python/gdal-utils/osgeo_utils/samples/ogr_dispatch.py b/swig/python/gdal-utils/osgeo_utils/samples/ogr_dispatch.py index 264d8a30c808..481eddf6b991 100644 --- a/swig/python/gdal-utils/osgeo_utils/samples/ogr_dispatch.py +++ b/swig/python/gdal-utils/osgeo_utils/samples/ogr_dispatch.py @@ -39,7 +39,7 @@ def Usage(): print("Usage: ogr_dispatch.py [-f format] -src name -dst name [-field field]+") print(" [-25D_as_2D] [-multi_as_single]") print(" [-remove_dispatch_fields] [-prefix_with_layer_name]") - print(" [-dsco KEY=VALUE]* [-lco KEY=VALUE]* [-a_srs srs_def]") + print(" [-dsco KEY=VALUE]... [-lco KEY=VALUE]... [-a_srs srs_def]") print( " [-style_as_field] [-where restricted_where] [-gt n] [-quiet]" )