diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2018-11-30 21:38:31 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2018-12-01 17:53:15 +0100 |
| commit | 872751c6734487bf1a222f2358678aa27ceeab4f (patch) | |
| tree | 64115f04eeb286da7bda88c7809107404d438429 /src | |
| parent | 9d19d5578705e06990fb716adcb9e6a1529424aa (diff) | |
| download | PROJ-872751c6734487bf1a222f2358678aa27ceeab4f.tar.gz PROJ-872751c6734487bf1a222f2358678aa27ceeab4f.zip | |
projinfo: add a --single-line option
Diffstat (limited to 'src')
| -rw-r--r-- | src/projinfo.cpp | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/src/projinfo.cpp b/src/projinfo.cpp index dbbcdae2..8ed8e14a 100644 --- a/src/projinfo.cpp +++ b/src/projinfo.cpp @@ -65,6 +65,7 @@ struct OutputOptions { bool WKT1_GDAL = false; bool WKT1_ESRI = false; bool c_ify = false; + bool singleLine = false; }; // --------------------------------------------------------------------------- @@ -86,6 +87,7 @@ static void usage() { << " [--main-db-path path] [--aux-db-path path]*" << std::endl << " [--identify]" << std::endl + << " [--c-ify] [--single-line]" << std::endl << " {object_definition} | (-s {srs_def} -t {srs_def})" << std::endl; std::cerr << std::endl; @@ -263,9 +265,12 @@ static void outputObject(DatabaseContextPtr dbContext, BaseObjectNNPtr obj, if (!outputOpt.quiet) { std::cout << "WKT2_2015 string: " << std::endl; } - auto wkt = wktExportable->exportToWKT( - WKTFormatter::create(WKTFormatter::Convention::WKT2_2015) - .get()); + auto formatter = + WKTFormatter::create(WKTFormatter::Convention::WKT2_2015); + if (outputOpt.singleLine) { + formatter->setMultiLine(false); + } + auto wkt = wktExportable->exportToWKT(formatter.get()); if (outputOpt.c_ify) { wkt = c_ify_string(wkt); } @@ -285,10 +290,12 @@ static void outputObject(DatabaseContextPtr dbContext, BaseObjectNNPtr obj, if (!outputOpt.quiet) { std::cout << "WKT2_2015_SIMPLIFIED string: " << std::endl; } - auto wkt = wktExportable->exportToWKT( - WKTFormatter::create( - WKTFormatter::Convention::WKT2_2015_SIMPLIFIED) - .get()); + auto formatter = WKTFormatter::create( + WKTFormatter::Convention::WKT2_2015_SIMPLIFIED); + if (outputOpt.singleLine) { + formatter->setMultiLine(false); + } + auto wkt = wktExportable->exportToWKT(formatter.get()); if (outputOpt.c_ify) { wkt = c_ify_string(wkt); } @@ -308,9 +315,12 @@ static void outputObject(DatabaseContextPtr dbContext, BaseObjectNNPtr obj, if (!outputOpt.quiet) { std::cout << "WKT2_2018 string: " << std::endl; } - auto wkt = wktExportable->exportToWKT( - WKTFormatter::create(WKTFormatter::Convention::WKT2_2018) - .get()); + auto formatter = + WKTFormatter::create(WKTFormatter::Convention::WKT2_2018); + if (outputOpt.singleLine) { + formatter->setMultiLine(false); + } + auto wkt = wktExportable->exportToWKT(formatter.get()); if (outputOpt.c_ify) { wkt = c_ify_string(wkt); } @@ -330,10 +340,12 @@ static void outputObject(DatabaseContextPtr dbContext, BaseObjectNNPtr obj, if (!outputOpt.quiet) { std::cout << "WKT2_2018_SIMPLIFIED string: " << std::endl; } - auto wkt = wktExportable->exportToWKT( - WKTFormatter::create( - WKTFormatter::Convention::WKT2_2018_SIMPLIFIED) - .get()); + auto formatter = WKTFormatter::create( + WKTFormatter::Convention::WKT2_2018_SIMPLIFIED); + if (outputOpt.singleLine) { + formatter->setMultiLine(false); + } + auto wkt = wktExportable->exportToWKT(formatter.get()); if (outputOpt.c_ify) { wkt = c_ify_string(wkt); } @@ -364,9 +376,12 @@ static void outputObject(DatabaseContextPtr dbContext, BaseObjectNNPtr obj, objToExport = wktExportable; } - auto wkt = objToExport->exportToWKT( - WKTFormatter::create(WKTFormatter::Convention::WKT1_GDAL) - .get()); + auto formatter = + WKTFormatter::create(WKTFormatter::Convention::WKT1_GDAL); + if (outputOpt.singleLine) { + formatter->setMultiLine(false); + } + auto wkt = objToExport->exportToWKT(formatter.get()); if (outputOpt.c_ify) { wkt = c_ify_string(wkt); } @@ -684,6 +699,8 @@ int main(int argc, char **argv) { outputOpt.quiet = true; } else if (arg == "--c-ify") { outputOpt.c_ify = true; + } else if (arg == "--single-line") { + outputOpt.singleLine = true; } else if (arg == "--summary") { summary = true; } else if (ci_equal(arg, "--boundcrs-to-wgs84")) { |
