diff --git a/docs/source/apps/projinfo.rst b/docs/source/apps/projinfo.rst index 13e2231f7a..05184ef99a 100644 --- a/docs/source/apps/projinfo.rst +++ b/docs/source/apps/projinfo.rst @@ -260,8 +260,8 @@ The following control parameters can appear in any order: .. option:: --single-line - Output WKT or PROJJSON strings on a single line, instead of multiple intended lines by - default. + Output PROJ, WKT or PROJJSON strings on a single line, instead of multiple + indented lines by default. .. option:: --searchpaths diff --git a/include/proj/io.hpp b/include/proj/io.hpp index 9a4c7f9d1d..20dcedfe06 100644 --- a/include/proj/io.hpp +++ b/include/proj/io.hpp @@ -387,6 +387,10 @@ class PROJ_GCC_DLL PROJStringFormatter { PROJ_DLL ~PROJStringFormatter(); //! @endcond + PROJ_DLL PROJStringFormatter &setMultiLine(bool multiLine) noexcept; + PROJ_DLL PROJStringFormatter &setIndentationWidth(int width) noexcept; + PROJ_DLL PROJStringFormatter &setMaxLineLength(int maxLineLength) noexcept; + PROJ_DLL void setUseApproxTMerc(bool flag); PROJ_DLL const std::string &toString() const; diff --git a/scripts/reference_exported_symbols.txt b/scripts/reference_exported_symbols.txt index 8f225b3b56..72db3fd352 100644 --- a/scripts/reference_exported_symbols.txt +++ b/scripts/reference_exported_symbols.txt @@ -406,6 +406,9 @@ osgeo::proj::io::PROJStringFormatter::ingestPROJString(std::string const&) osgeo::proj::io::PROJStringFormatter::~PROJStringFormatter() osgeo::proj::io::PROJStringFormatter::setCRSExport(bool) osgeo::proj::io::PROJStringFormatter::setCurrentStepInverted(bool) +osgeo::proj::io::PROJStringFormatter::setIndentationWidth(int) +osgeo::proj::io::PROJStringFormatter::setMaxLineLength(int) +osgeo::proj::io::PROJStringFormatter::setMultiLine(bool) osgeo::proj::io::PROJStringFormatter::setUseApproxTMerc(bool) osgeo::proj::io::PROJStringFormatter::startInversion() osgeo::proj::io::PROJStringFormatter::stopInversion() diff --git a/src/apps/projinfo.cpp b/src/apps/projinfo.cpp index 966de03dd1..ee48a69c50 100644 --- a/src/apps/projinfo.cpp +++ b/src/apps/projinfo.cpp @@ -350,11 +350,11 @@ static void outputObject( objToExport = projStringExportable; } - std::cout << objToExport->exportToPROJString( - PROJStringFormatter::create( - PROJStringFormatter::Convention::PROJ_5, - dbContext) - .get()) + auto formatter = PROJStringFormatter::create( + PROJStringFormatter::Convention::PROJ_5, dbContext); + formatter->setMultiLine(!outputOpt.singleLine && + crs == nullptr); + std::cout << objToExport->exportToPROJString(formatter.get()) << std::endl; } catch (const std::exception &e) { std::cerr << "Error when exporting to PROJ string: " << e.what() @@ -376,9 +376,7 @@ static void outputObject( } auto formatter = WKTFormatter::create(WKTFormatter::Convention::WKT2_2015); - if (outputOpt.singleLine) { - formatter->setMultiLine(false); - } + formatter->setMultiLine(!outputOpt.singleLine); formatter->setStrict(outputOpt.strict); auto wkt = wktExportable->exportToWKT(formatter.get()); if (outputOpt.c_ify) { diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp index cad764313f..8d77437ab9 100644 --- a/src/iso19111/c_api.cpp +++ b/src/iso19111/c_api.cpp @@ -1504,9 +1504,16 @@ const char *proj_as_wkt(PJ_CONTEXT *ctx, const PJ *obj, PJ_WKT_TYPE type, * @param obj Object (must not be NULL) * @param type PROJ String version. * @param options NULL-terminated list of strings with "KEY=VALUE" format. or - * NULL. - * The currently recognized option is USE_APPROX_TMERC=YES to add the +approx - * flag to +proj=tmerc or +proj=utm + * NULL. Currently supported options are: + * * @return a string, or NULL in case of error. */ const char *proj_as_proj_string(PJ_CONTEXT *ctx, const PJ *obj, @@ -1542,9 +1549,21 @@ const char *proj_as_proj_string(PJ_CONTEXT *ctx, const PJ *obj, auto dbContext = getDBcontextNoException(ctx, __FUNCTION__); try { auto formatter = PROJStringFormatter::create(convention, dbContext); - if (options != nullptr && options[0] != nullptr) { - if (ci_equal(options[0], "USE_APPROX_TMERC=YES")) { - formatter->setUseApproxTMerc(true); + for (auto iter = options; iter && iter[0]; ++iter) { + const char *value; + if ((value = getOptionValue(*iter, "MULTILINE="))) { + formatter->setMultiLine(ci_equal(value, "YES")); + } else if ((value = getOptionValue(*iter, "INDENTATION_WIDTH="))) { + formatter->setIndentationWidth(std::atoi(value)); + } else if ((value = getOptionValue(*iter, "MAX_LINE_LENGTH="))) { + formatter->setMaxLineLength(std::atoi(value)); + } else if ((value = getOptionValue(*iter, "USE_APPROX_TMERC="))) { + formatter->setUseApproxTMerc(ci_equal(value, "YES")); + } else { + std::string msg("Unknown option :"); + msg += *iter; + proj_log_error(ctx, __FUNCTION__, msg.c_str()); + return nullptr; } } obj->lastPROJString = exportable->exportToPROJString(formatter.get()); diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index c464b7245a..7a107f96c1 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -6722,6 +6722,10 @@ struct PROJStringFormatter::Private { bool coordOperationOptimizations_ = false; bool crsExport_ = false; bool legacyCRSToCRSContext_ = false; + bool multiLine_ = false; + int indentWidth_ = 2; + int indentLevel_ = 0; + int maxLineLength_ = 80; std::string result_{}; @@ -6780,6 +6784,36 @@ void PROJStringFormatter::setUseApproxTMerc(bool flag) { // --------------------------------------------------------------------------- +/** \brief Whether to use multi line output or not. */ +PROJStringFormatter & +PROJStringFormatter::setMultiLine(bool multiLine) noexcept { + d->multiLine_ = multiLine; + return *this; +} + +// --------------------------------------------------------------------------- + +/** \brief Set number of spaces for each indentation level (defaults to 2). + */ +PROJStringFormatter & +PROJStringFormatter::setIndentationWidth(int width) noexcept { + d->indentWidth_ = width; + return *this; +} + +// --------------------------------------------------------------------------- + +/** \brief Set the maximum size of a line (when multiline output is enable). + * Can be set to 0 for unlimited length. + */ +PROJStringFormatter & +PROJStringFormatter::setMaxLineLength(int maxLineLength) noexcept { + d->maxLineLength_ = maxLineLength; + return *this; +} + +// --------------------------------------------------------------------------- + /** \brief Returns the PROJ string. */ const std::string &PROJStringFormatter::toString() const { @@ -7308,28 +7342,56 @@ const std::string &PROJStringFormatter::toString() const { pj_double_quote_string_param_if_needed(paramValue.value); } } + + if (d->multiLine_) { + d->indentLevel_++; + } } for (const auto &step : d->steps_) { + std::string curLine; if (!d->result_.empty()) { - d->appendToResult("+step"); + if (d->multiLine_) { + curLine = std::string(d->indentLevel_ * d->indentWidth_, ' '); + curLine += "+step"; + } else { + curLine = " +step"; + } } if (step.inverted) { - d->appendToResult("+inv"); + curLine += " +inv"; } if (!step.name.empty()) { - d->appendToResult(step.isInit ? "+init=" : "+proj="); - d->result_ += step.name; + if (!curLine.empty()) + curLine += ' '; + curLine += step.isInit ? "+init=" : "+proj="; + curLine += step.name; } for (const auto ¶mValue : step.paramValues) { - d->appendToResult("+"); - d->result_ += paramValue.key; + std::string newKV = "+"; + newKV += paramValue.key; if (!paramValue.value.empty()) { - d->result_ += '='; - d->result_ += + newKV += '='; + newKV += pj_double_quote_string_param_if_needed(paramValue.value); } + if (d->maxLineLength_ > 0 && d->multiLine_ && + curLine.size() + newKV.size() > + static_cast(d->maxLineLength_)) { + if (d->multiLine_ && !d->result_.empty()) + d->result_ += '\n'; + d->result_ += curLine; + curLine = std::string( + d->indentLevel_ * d->indentWidth_ + strlen("+step "), ' '); + } else { + if (!curLine.empty()) + curLine += ' '; + } + curLine += newKV; } + if (d->multiLine_ && !d->result_.empty()) + d->result_ += '\n'; + d->result_ += curLine; } if (d->result_.empty()) { diff --git a/test/cli/testprojinfo b/test/cli/testprojinfo index 9896e23ab5..19d9673569 100755 --- a/test/cli/testprojinfo +++ b/test/cli/testprojinfo @@ -50,8 +50,8 @@ echo "Testing projinfo -o ALL EPSG:4326" >> ${OUT} $EXE -o ALL EPSG:4326 >>${OUT} echo "" >>${OUT} -echo "Testing projinfo -s EPSG:4326 -t EPSG:32631" >> ${OUT} -$EXE -s EPSG:4326 -t EPSG:32631 >>${OUT} +echo "Testing projinfo -s EPSG:4326 -t EPSG:32631 --single-line" >> ${OUT} +$EXE -s EPSG:4326 -t EPSG:32631 --single-line >>${OUT} echo "" >>${OUT} echo "Testing projinfo -s NAD27 -t NAD83" >> ${OUT} diff --git a/test/cli/testprojinfo_out.dist b/test/cli/testprojinfo_out.dist index 14856a685b..b4d19002de 100644 --- a/test/cli/testprojinfo_out.dist +++ b/test/cli/testprojinfo_out.dist @@ -182,7 +182,7 @@ PROJJSON: } } -Testing projinfo -s EPSG:4326 -t EPSG:32631 +Testing projinfo -s EPSG:4326 -t EPSG:32631 --single-line Candidate operations found: 1 ------------------------------------- Operation No. 1: @@ -193,25 +193,7 @@ PROJ string: +proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=utm +zone=31 +ellps=WGS84 WKT2:2019 string: -CONVERSION["UTM zone 31N", - METHOD["Transverse Mercator", - ID["EPSG",9807]], - PARAMETER["Latitude of natural origin",0, - ANGLEUNIT["degree",0.0174532925199433], - ID["EPSG",8801]], - PARAMETER["Longitude of natural origin",3, - ANGLEUNIT["degree",0.0174532925199433], - ID["EPSG",8802]], - PARAMETER["Scale factor at natural origin",0.9996, - SCALEUNIT["unity",1], - ID["EPSG",8805]], - PARAMETER["False easting",500000, - LENGTHUNIT["metre",1], - ID["EPSG",8806]], - PARAMETER["False northing",0, - LENGTHUNIT["metre",1], - ID["EPSG",8807]], - ID["EPSG",16031]] +CONVERSION["UTM zone 31N",METHOD["Transverse Mercator",ID["EPSG",9807]],PARAMETER["Latitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8801]],PARAMETER["Longitude of natural origin",3,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["Scale factor at natural origin",0.9996,SCALEUNIT["unity",1],ID["EPSG",8805]],PARAMETER["False easting",500000,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]],ID["EPSG",16031]] Testing projinfo -s NAD27 -t NAD83 Candidate operations found: 1 @@ -289,7 +271,12 @@ Operation No. 1: DERIVED_FROM(EPSG):1312, NAD27 to NAD83 (3), 2.0 m, Canada - onshore and offshore - Alberta; British Columbia; Manitoba; New Brunswick; Newfoundland and Labrador; Northwest Territories; Nova Scotia; Nunavut; Ontario; Prince Edward Island; Quebec; Saskatchewan; Yukon. PROJ string: -+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=hgridshift +grids=ca_nrc_ntv1_can.tif +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1 ++proj=pipeline + +step +proj=axisswap +order=2,1 + +step +proj=unitconvert +xy_in=deg +xy_out=rad + +step +proj=hgridshift +grids=ca_nrc_ntv1_can.tif + +step +proj=unitconvert +xy_in=rad +xy_out=deg + +step +proj=axisswap +order=2,1 WKT2:2019 string: COORDINATEOPERATION["NAD27 to NAD83 (3)", @@ -338,7 +325,12 @@ Operation No. 2: DERIVED_FROM(EPSG):1313, NAD27 to NAD83 (4), 1.5 m, Canada - onshore - Alberta; British Columbia; Manitoba; New Brunswick; Newfoundland and Labrador; Northwest Territories; Nova Scotia; Nunavut; Ontario; Prince Edward Island; Quebec; Saskatchewan; Yukon; offshore east coast. PROJ string: -+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=hgridshift +grids=ca_nrc_ntv2_0.tif +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1 ++proj=pipeline + +step +proj=axisswap +order=2,1 + +step +proj=unitconvert +xy_in=deg +xy_out=rad + +step +proj=hgridshift +grids=ca_nrc_ntv2_0.tif + +step +proj=unitconvert +xy_in=rad +xy_out=deg + +step +proj=axisswap +order=2,1 WKT2:2019 string: COORDINATEOPERATION["NAD27 to NAD83 (4)", @@ -387,7 +379,12 @@ Operation No. 3: DERIVED_FROM(EPSG):1241, NAD27 to NAD83 (1), 0.15 m, United States (USA) - CONUS including EEZ -onshore and offshore - Alabama; Arizona; Arkansas; California; Colorado; Connecticut; Delaware; Florida; Georgia; Idaho; Illinois; Indiana; Iowa; Kansas; Kentucky; Louisiana; Maine; Maryland; Massachusetts; Michigan; Minnesota; Mississippi; Missouri; Montana; Nebraska; Nevada; New Hampshire; New Jersey; New Mexico; New York; North Carolina; North Dakota; Ohio; Oklahoma; Oregon; Pennsylvania; Rhode Island; South Carolina; South Dakota; Tennessee; Texas; Utah; Vermont; Virginia; Washington; West Virginia; Wisconsin; Wyoming. US Gulf of Mexico (GoM) OCS. PROJ string: -+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=hgridshift +grids=us_noaa_conus.tif +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1 ++proj=pipeline + +step +proj=axisswap +order=2,1 + +step +proj=unitconvert +xy_in=deg +xy_out=rad + +step +proj=hgridshift +grids=us_noaa_conus.tif + +step +proj=unitconvert +xy_in=rad +xy_out=deg + +step +proj=axisswap +order=2,1 WKT2:2019 string: COORDINATEOPERATION["NAD27 to NAD83 (1)", @@ -436,7 +433,12 @@ Operation No. 4: DERIVED_FROM(EPSG):1243, NAD27 to NAD83 (2), 0.5 m, United States (USA) - Alaska including EEZ. PROJ string: -+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=hgridshift +grids=us_noaa_alaska.tif +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1 ++proj=pipeline + +step +proj=axisswap +order=2,1 + +step +proj=unitconvert +xy_in=deg +xy_out=rad + +step +proj=hgridshift +grids=us_noaa_alaska.tif + +step +proj=unitconvert +xy_in=rad +xy_out=deg + +step +proj=axisswap +order=2,1 WKT2:2019 string: COORDINATEOPERATION["NAD27 to NAD83 (2)", @@ -485,7 +487,12 @@ Operation No. 5: DERIVED_FROM(EPSG):1573, NAD27 to NAD83 (6), 1.5 m, Canada - Quebec. PROJ string: -+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=hgridshift +grids=ca_que_mern_na27na83.tif +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1 ++proj=pipeline + +step +proj=axisswap +order=2,1 + +step +proj=unitconvert +xy_in=deg +xy_out=rad + +step +proj=hgridshift +grids=ca_que_mern_na27na83.tif + +step +proj=unitconvert +xy_in=rad +xy_out=deg + +step +proj=axisswap +order=2,1 WKT2:2019 string: COORDINATEOPERATION["NAD27 to NAD83 (6)", @@ -534,7 +541,12 @@ Operation No. 6: EPSG:1462, NAD27 to NAD83 (5), 2.0 m, Canada - Quebec. PROJ string: -+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=hgridshift +grids=GS2783v1.QUE +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1 ++proj=pipeline + +step +proj=axisswap +order=2,1 + +step +proj=unitconvert +xy_in=deg +xy_out=rad + +step +proj=hgridshift +grids=GS2783v1.QUE + +step +proj=unitconvert +xy_in=rad +xy_out=deg + +step +proj=axisswap +order=2,1 WKT2:2019 string: COORDINATEOPERATION["NAD27 to NAD83 (5)", @@ -586,7 +598,12 @@ Operation No. 7: EPSG:9111, NAD27 to NAD83 (9), 1.5 m, Canada - Saskatchewan. PROJ string: -+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=hgridshift +grids=SK27-83.gsb +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1 ++proj=pipeline + +step +proj=axisswap +order=2,1 + +step +proj=unitconvert +xy_in=deg +xy_out=rad + +step +proj=hgridshift +grids=SK27-83.gsb + +step +proj=unitconvert +xy_in=rad +xy_out=deg + +step +proj=axisswap +order=2,1 WKT2:2019 string: COORDINATEOPERATION["NAD27 to NAD83 (9)", @@ -906,7 +923,12 @@ Operation No. 1: INVERSE(DERIVED_FROM(PROJ)):EPSG_4977_TO_EPSG_5613, Inverse of SWEREF99 to RH2000 height, unknown accuracy, Sweden - onshore. PROJ string: -+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=vgridshift +grids=se_lantmateriet_SWEN17_RH2000.tif +multiplier=1 +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1 ++proj=pipeline + +step +proj=axisswap +order=2,1 + +step +proj=unitconvert +xy_in=deg +xy_out=rad + +step +proj=vgridshift +grids=se_lantmateriet_SWEN17_RH2000.tif +multiplier=1 + +step +proj=unitconvert +xy_in=rad +xy_out=deg + +step +proj=axisswap +order=2,1 WKT2:2019 string: COORDINATEOPERATION["Inverse of SWEREF99 to RH2000 height", @@ -954,7 +976,12 @@ Operation No. 1: unknown id, Inverse of NAD83(2011) to NAVD88 height (3), 0.015 m, United States (USA) - CONUS onshore - Alabama; Arizona; Arkansas; California; Colorado; Connecticut; Delaware; Florida; Georgia; Idaho; Illinois; Indiana; Iowa; Kansas; Kentucky; Louisiana; Maine; Maryland; Massachusetts; Michigan; Minnesota; Mississippi; Missouri; Montana; Nebraska; Nevada; New Hampshire; New Jersey; New Mexico; New York; North Carolina; North Dakota; Ohio; Oklahoma; Oregon; Pennsylvania; Rhode Island; South Carolina; South Dakota; Tennessee; Texas; Utah; Vermont; Virginia; Washington; West Virginia; Wisconsin; Wyoming. PROJ string: -+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=vgridshift +grids=us_noaa_g2018u0.tif +multiplier=1 +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1 ++proj=pipeline + +step +proj=axisswap +order=2,1 + +step +proj=unitconvert +xy_in=deg +xy_out=rad + +step +proj=vgridshift +grids=us_noaa_g2018u0.tif +multiplier=1 + +step +proj=unitconvert +xy_in=rad +xy_out=deg + +step +proj=axisswap +order=2,1 ------------------------------------- Operation No. 2: @@ -962,7 +989,12 @@ Operation No. 2: unknown id, Inverse of NAD83(2011) to NAVD88 height (2), 0.02 m, United States (USA) - Alaska. PROJ string: -+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=vgridshift +grids=us_noaa_g2012ba0.tif +multiplier=1 +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1 ++proj=pipeline + +step +proj=axisswap +order=2,1 + +step +proj=unitconvert +xy_in=deg +xy_out=rad + +step +proj=vgridshift +grids=us_noaa_g2012ba0.tif +multiplier=1 + +step +proj=unitconvert +xy_in=rad +xy_out=deg + +step +proj=axisswap +order=2,1 Testing NGF IGN69 height to RGF93: projinfo -s EPSG:5720 -t EPSG:4965 -o PROJ Candidate operations found: 1 @@ -972,7 +1004,12 @@ Operation No. 1: INVERSE(DERIVED_FROM(EPSG)):8885, Inverse of RGF93 to NGF-IGN69 height (3), 0.01 m, France - mainland onshore. PROJ string: -+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=vgridshift +grids=fr_ign_RAF18.tif +multiplier=1 +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1 ++proj=pipeline + +step +proj=axisswap +order=2,1 + +step +proj=unitconvert +xy_in=deg +xy_out=rad + +step +proj=vgridshift +grids=fr_ign_RAF18.tif +multiplier=1 + +step +proj=unitconvert +xy_in=rad +xy_out=deg + +step +proj=axisswap +order=2,1 Testing EPSG:32631 --3d PROJ.4 string: @@ -1039,7 +1076,11 @@ unknown id, Ballpark geocentric translation from ETRS89 to WGS 84, unknown accur INVERSE(EPSG):9225, Inverse of WGS 84 to ETRS89 (2), 0.1 m, Germany - offshore North Sea. Netherlands - offshore east of 5E. Testing -s +proj=longlat +datum=WGS84 +geoidgrids=@foo.gtx +type=crs -t EPSG:4326 -o PROJ -q -+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=vgridshift +grids=@foo.gtx +multiplier=1 +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1 ++proj=pipeline + +step +proj=unitconvert +xy_in=deg +xy_out=rad + +step +proj=vgridshift +grids=@foo.gtx +multiplier=1 + +step +proj=unitconvert +xy_in=rad +xy_out=deg + +step +proj=axisswap +order=2,1 Testing -s "GDA94" -t "WGS 84 (G1762)" --spatial-test intersects --summary. Should include transformations through ITRF2008 and GDA2020 Candidate operations found: 7 @@ -1083,7 +1124,12 @@ Operation No. 1: DERIVED_FROM(EPSG):5656, GDA94 to AHD height (49), 0.15 m, Australia - Australian Capital Territory; New South Wales; Northern Territory; Queensland; South Australia; Western Australia; Victoria. PROJ string: -+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +inv +proj=vgridshift +grids=au_ga_AUSGeoid09_V1.01.tif +multiplier=1 +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1 ++proj=pipeline + +step +proj=axisswap +order=2,1 + +step +proj=unitconvert +xy_in=deg +xy_out=rad + +step +inv +proj=vgridshift +grids=au_ga_AUSGeoid09_V1.01.tif +multiplier=1 + +step +proj=unitconvert +xy_in=rad +xy_out=deg + +step +proj=axisswap +order=2,1 Testing -s "GDA2020" -t "AHD height" --grid-check none -o PROJ --spatial-test intersects Candidate operations found: 1 @@ -1093,7 +1139,13 @@ Operation No. 1: DERIVED_FROM(EPSG):8451, GDA2020 to AHD height (1), 0.15 m, Australia - Australian Capital Territory, New South Wales, Northern Territory, Queensland, South Australia, Tasmania, Western Australia and Victoria - onshore. Christmas Island - onshore. Cocos and Keeling Islands - onshore. PROJ string: -+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +inv +proj=vgridshift +grids=au_ga_AUSGeoid2020_20180201.tif +multiplier=1 +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1 ++proj=pipeline + +step +proj=axisswap +order=2,1 + +step +proj=unitconvert +xy_in=deg +xy_out=rad + +step +inv +proj=vgridshift +grids=au_ga_AUSGeoid2020_20180201.tif + +multiplier=1 + +step +proj=unitconvert +xy_in=rad +xy_out=deg + +step +proj=axisswap +order=2,1 Testing -k ellipsoid WGS84 PROJ string: @@ -1128,23 +1180,92 @@ DATUM["World Geodetic System 1984", ID["EPSG",6326]] Testing -k operation EPSG:8457 -o PROJ -q -+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=push +v_3 +step +proj=cart +ellps=bessel +step +proj=helmert +x=674.374 +y=15.056 +z=405.346 +step +inv +proj=cart +ellps=WGS84 +step +proj=pop +v_3 +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1 ++proj=pipeline + +step +proj=axisswap +order=2,1 + +step +proj=unitconvert +xy_in=deg +xy_out=rad + +step +proj=push +v_3 + +step +proj=cart +ellps=bessel + +step +proj=helmert +x=674.374 +y=15.056 +z=405.346 + +step +inv +proj=cart +ellps=WGS84 + +step +proj=pop +v_3 + +step +proj=unitconvert +xy_in=rad +xy_out=deg + +step +proj=axisswap +order=2,1 Testing -s NZGD2000 -t ITRF96 -o PROJ -q -+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=axisswap +order=2,1 +step +proj=defmodel +model=nz_linz_nzgd2000-20180701.json +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=rad +xy_out=deg ++proj=pipeline + +step +proj=unitconvert +xy_in=deg +xy_out=rad + +step +proj=axisswap +order=2,1 + +step +proj=defmodel +model=nz_linz_nzgd2000-20180701.json + +step +proj=axisswap +order=2,1 + +step +proj=unitconvert +xy_in=rad +xy_out=deg Testing -s NZGD2000 -t ITRF97 -o PROJ -q -+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=axisswap +order=2,1 +step +proj=defmodel +model=nz_linz_nzgd2000-20180701.json +step +proj=cart +ellps=GRS80 +step +inv +proj=helmert +x=0 +y=-0.00051 +z=0.01553 +rx=-0.00016508 +ry=0.00026897 +rz=5.984e-05 +s=-0.00151099 +dx=0.00069 +dy=-0.0001 +dz=0.00186 +drx=-1.347e-05 +dry=1.514e-05 +drz=-2.7e-07 +ds=-0.00019201 +t_epoch=2000 +convention=position_vector +step +inv +proj=cart +ellps=GRS80 +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1 ++proj=pipeline + +step +proj=unitconvert +xy_in=deg +xy_out=rad + +step +proj=axisswap +order=2,1 + +step +proj=defmodel +model=nz_linz_nzgd2000-20180701.json + +step +proj=cart +ellps=GRS80 + +step +inv +proj=helmert +x=0 +y=-0.00051 +z=0.01553 +rx=-0.00016508 + +ry=0.00026897 +rz=5.984e-05 +s=-0.00151099 +dx=0.00069 +dy=-0.0001 + +dz=0.00186 +drx=-1.347e-05 +dry=1.514e-05 +drz=-2.7e-07 +ds=-0.00019201 + +t_epoch=2000 +convention=position_vector + +step +inv +proj=cart +ellps=GRS80 + +step +proj=unitconvert +xy_in=rad +xy_out=deg + +step +proj=axisswap +order=2,1 Testing -s NZGD2000 -t ITRF2000 -o PROJ -q -+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=axisswap +order=2,1 +step +proj=defmodel +model=nz_linz_nzgd2000-20180701.json +step +proj=cart +ellps=GRS80 +step +inv +proj=helmert +x=0.0067 +y=0.00379 +z=-0.00717 +rx=-0.00016508 +ry=0.00026897 +rz=0.00011984 +s=6.901e-05 +dx=0.00069 +dy=-0.0007 +dz=0.00046 +drx=-1.347e-05 +dry=1.514e-05 +drz=1.973e-05 +ds=-0.00018201 +t_epoch=2000 +convention=position_vector +step +inv +proj=cart +ellps=GRS80 +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1 ++proj=pipeline + +step +proj=unitconvert +xy_in=deg +xy_out=rad + +step +proj=axisswap +order=2,1 + +step +proj=defmodel +model=nz_linz_nzgd2000-20180701.json + +step +proj=cart +ellps=GRS80 + +step +inv +proj=helmert +x=0.0067 +y=0.00379 +z=-0.00717 +rx=-0.00016508 + +ry=0.00026897 +rz=0.00011984 +s=6.901e-05 +dx=0.00069 +dy=-0.0007 + +dz=0.00046 +drx=-1.347e-05 +dry=1.514e-05 +drz=1.973e-05 +ds=-0.00018201 + +t_epoch=2000 +convention=position_vector + +step +inv +proj=cart +ellps=GRS80 + +step +proj=unitconvert +xy_in=rad +xy_out=deg + +step +proj=axisswap +order=2,1 Testing -s NZGD2000 -t ITRF2005 -o PROJ -q -+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=axisswap +order=2,1 +step +proj=defmodel +model=nz_linz_nzgd2000-20180701.json +step +proj=cart +ellps=GRS80 +step +inv +proj=helmert +x=0.0068 +y=0.00299 +z=-0.01297 +rx=-0.00016508 +ry=0.00026897 +rz=0.00011984 +s=0.00046901 +dx=0.00049 +dy=-0.0006 +dz=-0.00134 +drx=-1.347e-05 +dry=1.514e-05 +drz=1.973e-05 +ds=-0.00010201 +t_epoch=2000 +convention=position_vector +step +inv +proj=cart +ellps=GRS80 +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1 ++proj=pipeline + +step +proj=unitconvert +xy_in=deg +xy_out=rad + +step +proj=axisswap +order=2,1 + +step +proj=defmodel +model=nz_linz_nzgd2000-20180701.json + +step +proj=cart +ellps=GRS80 + +step +inv +proj=helmert +x=0.0068 +y=0.00299 +z=-0.01297 +rx=-0.00016508 + +ry=0.00026897 +rz=0.00011984 +s=0.00046901 +dx=0.00049 +dy=-0.0006 + +dz=-0.00134 +drx=-1.347e-05 +dry=1.514e-05 +drz=1.973e-05 + +ds=-0.00010201 +t_epoch=2000 +convention=position_vector + +step +inv +proj=cart +ellps=GRS80 + +step +proj=unitconvert +xy_in=rad +xy_out=deg + +step +proj=axisswap +order=2,1 Testing -s NZGD2000 -t ITRF2008 -o PROJ -q -+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=axisswap +order=2,1 +step +proj=defmodel +model=nz_linz_nzgd2000-20180701.json +step +proj=cart +ellps=GRS80 +step +inv +proj=helmert +x=0.0048 +y=0.00209 +z=-0.01767 +rx=-0.00016508 +ry=0.00026897 +rz=0.00011984 +s=0.00140901 +dx=0.00079 +dy=-0.0006 +dz=-0.00134 +drx=-1.347e-05 +dry=1.514e-05 +drz=1.973e-05 +ds=-0.00010201 +t_epoch=2000 +convention=position_vector +step +inv +proj=cart +ellps=GRS80 +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1 ++proj=pipeline + +step +proj=unitconvert +xy_in=deg +xy_out=rad + +step +proj=axisswap +order=2,1 + +step +proj=defmodel +model=nz_linz_nzgd2000-20180701.json + +step +proj=cart +ellps=GRS80 + +step +inv +proj=helmert +x=0.0048 +y=0.00209 +z=-0.01767 +rx=-0.00016508 + +ry=0.00026897 +rz=0.00011984 +s=0.00140901 +dx=0.00079 +dy=-0.0006 + +dz=-0.00134 +drx=-1.347e-05 +dry=1.514e-05 +drz=1.973e-05 + +ds=-0.00010201 +t_epoch=2000 +convention=position_vector + +step +inv +proj=cart +ellps=GRS80 + +step +proj=unitconvert +xy_in=rad +xy_out=deg + +step +proj=axisswap +order=2,1 Testing -s NZGD2000 -t ITRF2014 -o PROJ -q -+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=axisswap +order=2,1 +step +proj=defmodel +model=nz_linz_nzgd2000-20180701.json +step +proj=cart +ellps=GRS80 +step +inv +proj=helmert +x=0.0064 +y=0.00399 +z=-0.01427 +rx=-0.00016508 +ry=0.00026897 +rz=0.00011984 +s=0.00108901 +dx=0.00079 +dy=-0.0006 +dz=-0.00144 +drx=-1.347e-05 +dry=1.514e-05 +drz=1.973e-05 +ds=-7.201e-05 +t_epoch=2000 +convention=position_vector +step +inv +proj=cart +ellps=GRS80 +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1 ++proj=pipeline + +step +proj=unitconvert +xy_in=deg +xy_out=rad + +step +proj=axisswap +order=2,1 + +step +proj=defmodel +model=nz_linz_nzgd2000-20180701.json + +step +proj=cart +ellps=GRS80 + +step +inv +proj=helmert +x=0.0064 +y=0.00399 +z=-0.01427 +rx=-0.00016508 + +ry=0.00026897 +rz=0.00011984 +s=0.00108901 +dx=0.00079 +dy=-0.0006 + +dz=-0.00144 +drx=-1.347e-05 +dry=1.514e-05 +drz=1.973e-05 +ds=-7.201e-05 + +t_epoch=2000 +convention=position_vector + +step +inv +proj=cart +ellps=GRS80 + +step +proj=unitconvert +xy_in=rad +xy_out=deg + +step +proj=axisswap +order=2,1 diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp index c0db38803e..f6371cc3f3 100644 --- a/test/unit/test_c_api.cpp +++ b/test/unit/test_c_api.cpp @@ -3764,16 +3764,26 @@ TEST_F(CApi, proj_coordoperation_create_inverse) { ObjectKeeper keeper_Pinversed(Pinversed); ASSERT_NE(Pinversed, nullptr); - auto projstr = proj_as_proj_string(m_ctxt, Pinversed, PJ_PROJ_5, nullptr); + const char *options[] = {"MULTILINE=YES", "INDENTATION_WIDTH=4", + "MAX_LINE_LENGTH=40", nullptr}; + auto projstr = proj_as_proj_string(m_ctxt, Pinversed, PJ_PROJ_5, options); ASSERT_NE(projstr, nullptr); - EXPECT_EQ(std::string(projstr), - "+proj=pipeline +step +proj=axisswap +order=2,1 +step " - "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=push +v_3 " - "+step +proj=cart +ellps=WGS84 +step +inv +proj=helmert +x=293 " - "+y=836 +z=318 +rx=0.5 +ry=1.6 +rz=-2.8 +s=2.1 " - "+convention=position_vector +step +inv +proj=cart " - "+ellps=evrst30 +step +proj=pop +v_3 +step +proj=unitconvert " - "+xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1"); + const char *expected_projstr = "+proj=pipeline\n" + " +step +proj=axisswap +order=2,1\n" + " +step +proj=unitconvert +xy_in=deg\n" + " +xy_out=rad\n" + " +step +proj=push +v_3\n" + " +step +proj=cart +ellps=WGS84\n" + " +step +inv +proj=helmert +x=293\n" + " +y=836 +z=318 +rx=0.5 +ry=1.6\n" + " +rz=-2.8 +s=2.1\n" + " +convention=position_vector\n" + " +step +inv +proj=cart +ellps=evrst30\n" + " +step +proj=pop +v_3\n" + " +step +proj=unitconvert +xy_in=rad\n" + " +xy_out=deg\n" + " +step +proj=axisswap +order=2,1"; + EXPECT_EQ(std::string(projstr), expected_projstr); } // --------------------------------------------------------------------------- diff --git a/travis/install.sh b/travis/install.sh index 9bea1ba58b..8897f823b6 100755 --- a/travis/install.sh +++ b/travis/install.sh @@ -21,7 +21,7 @@ export MAKEFLAGS="-j ${NPROC}" mkdir build_autoconf cd build_autoconf ../configure -make dist-all +make dist-all >/dev/null # Check consistency of generated tarball TAR_FILENAME=`ls *.tar.gz` TAR_DIRECTORY=`basename $TAR_FILENAME .tar.gz` @@ -36,7 +36,7 @@ mkdir build_autoconf cd build_autoconf ../configure --prefix=/tmp/proj_autoconf_install_from_dist_all -make +make >/dev/null if [ "$(uname)" == "Linux" -a -f src/.libs/libproj.so ]; then if objdump -TC "src/.libs/libproj.so" | grep "elf64-x86-64">/dev/null; then @@ -80,7 +80,7 @@ jsonschema -i out.json /tmp/proj_autoconf_install_from_dist_all/share/proj/projj diff -u out.json out2.json # Test make clean target -make clean +make clean > /dev/null cd .. @@ -105,8 +105,8 @@ if [ "$BUILD_NAME" != "linux_gcc8" ]; then cd build_cmake cmake --version cmake .. -DCMAKE_INSTALL_PREFIX=/tmp/proj_cmake_install - VERBOSE=1 make - make install + VERBOSE=1 make >/dev/null + make install >/dev/null ctest find /tmp/proj_cmake_install if [ $BUILD_NAME = "linux_gcc" ] || [ $BUILD_NAME = "osx" ]; then @@ -138,7 +138,7 @@ if [ "$BUILD_NAME" != "linux_gcc8" ]; then else ./configure fi - make + make >/dev/null make check if [ "$BUILD_NAME" != "linux_clang" ]; then