From f5e5435fd5071d550e0d13f7a5d71e09c1fab2c0 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 8 Jan 2019 16:22:15 +0100 Subject: ISO19111: remove PROJ.5 specific format for CRS (refs #1214) As discussed in https://github.com/OSGeo/proj.4/issues/1214#issuecomment-452084720, the introduction of a new PROJ.5 format to export CRS using pipeline/unitconvert/axisswap as an attempt of improving the PROJ.4 format used by GDAL and other products is likely a dead-end since it is still lossy in many aspects and can cause confusion with coodinate operations. Consequently the PROJ_5 convention will be identical to PROJ_4 for CRS export. Note: on the import side, I've kept the code that could parse unitconvert and axisswap when building a CRS definition from a pipeline. It is there as a hidden feature as it was kind of a tear to remove that code in case it might still be useful... --- src/apps/projinfo.cpp | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) (limited to 'src/apps/projinfo.cpp') diff --git a/src/apps/projinfo.cpp b/src/apps/projinfo.cpp index b418bc57..0540a0f9 100644 --- a/src/apps/projinfo.cpp +++ b/src/apps/projinfo.cpp @@ -61,7 +61,6 @@ namespace { // anonymous namespace struct OutputOptions { bool quiet = false; bool PROJ5 = false; - bool PROJ4 = false; bool WKT2_2018 = false; bool WKT2_2018_SIMPLIFIED = false; bool WKT2_2015 = false; @@ -100,7 +99,7 @@ static void usage() { << std::endl; std::cerr << std::endl; std::cerr << "-o: formats is a comma separated combination of: " - "all,default,PROJ4,PROJ,WKT_ALL,WKT2_2015,WKT2_2018,WKT1_GDAL," + "all,default,PROJ,WKT_ALL,WKT2_2015,WKT2_2018,WKT1_GDAL," "WKT1_ESRI" << std::endl; std::cerr << " Except 'all' and 'default', other format can be preceded " @@ -255,30 +254,12 @@ static void outputObject(DatabaseContextPtr dbContext, BaseObjectNNPtr obj, bool alreadyOutputed = false; if (projStringExportable) { if (outputOpt.PROJ5) { - try { - if (!outputOpt.quiet) { - std::cout << "PROJ string:" << std::endl; - } - std::cout << projStringExportable->exportToPROJString( - PROJStringFormatter::create( - PROJStringFormatter::Convention::PROJ_5, - dbContext) - .get()) - << std::endl; - } catch (const std::exception &e) { - std::cerr << "Error when exporting to PROJ string: " << e.what() - << std::endl; - } - alreadyOutputed = true; - } - - if (outputOpt.PROJ4) { try { if (alreadyOutputed) { std::cout << std::endl; } if (!outputOpt.quiet) { - std::cout << "PROJ.4 string:" << std::endl; + std::cout << "PROJ string:" << std::endl; } auto crs = nn_dynamic_pointer_cast(obj); @@ -295,7 +276,7 @@ static void outputObject(DatabaseContextPtr dbContext, BaseObjectNNPtr obj, std::cout << objToExport->exportToPROJString( PROJStringFormatter::create( - PROJStringFormatter::Convention::PROJ_4, + PROJStringFormatter::Convention::PROJ_5, dbContext) .get()) << std::endl; @@ -651,23 +632,15 @@ int main(int argc, char **argv) { for (auto format : formats) { if (ci_equal(format, "all")) { outputOpt.PROJ5 = true; - outputOpt.PROJ4 = true; outputOpt.WKT2_2018 = true; outputOpt.WKT2_2015 = true; outputOpt.WKT1_GDAL = true; outputOpt.WKT1_ESRI = true; } else if (ci_equal(format, "default")) { outputOpt.PROJ5 = true; - outputOpt.PROJ4 = false; outputOpt.WKT2_2018 = false; outputOpt.WKT2_2015 = true; outputOpt.WKT1_GDAL = false; - } else if (ci_equal(format, "PROJ4") || - ci_equal(format, "PROJ.4")) { - outputOpt.PROJ4 = true; - } else if (ci_equal(format, "-PROJ4") || - ci_equal(format, "-PROJ.4")) { - outputOpt.PROJ4 = false; } else if (ci_equal(format, "PROJ")) { outputOpt.PROJ5 = true; } else if (ci_equal(format, "-PROJ")) { @@ -929,7 +902,7 @@ int main(int argc, char **argv) { } if (outputOpt.quiet && - (outputOpt.PROJ5 + outputOpt.PROJ4 + outputOpt.WKT2_2018 + + (outputOpt.PROJ5 + outputOpt.WKT2_2018 + outputOpt.WKT2_2015 + outputOpt.WKT1_GDAL) != 1) { std::cerr << "-q can only be used with a single output format" << std::endl; -- cgit v1.2.3 From a6899c98a6455dc022bdd6785af3e528488422b8 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 8 Jan 2019 17:44:49 +0100 Subject: projinfo: use PROJ.4 label for CRS, and PROJ otherwise. Add test case for CRS with towgs84 keyword --- src/apps/projinfo.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/apps/projinfo.cpp') diff --git a/src/apps/projinfo.cpp b/src/apps/projinfo.cpp index 0540a0f9..446a1e9e 100644 --- a/src/apps/projinfo.cpp +++ b/src/apps/projinfo.cpp @@ -258,11 +258,15 @@ static void outputObject(DatabaseContextPtr dbContext, BaseObjectNNPtr obj, if (alreadyOutputed) { std::cout << std::endl; } + auto crs = nn_dynamic_pointer_cast(obj); if (!outputOpt.quiet) { - std::cout << "PROJ string:" << std::endl; + if( crs ) { + std::cout << "PROJ.4 string:" << std::endl; + } else { + std::cout << "PROJ string:" << std::endl; + } } - auto crs = nn_dynamic_pointer_cast(obj); std::shared_ptr objToExport; if (crs) { objToExport = -- cgit v1.2.3