diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2018-12-06 22:10:57 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2018-12-06 23:42:16 +0100 |
| commit | 67ca5c199dfe62fc0738a808f3142af2e77eafd7 (patch) | |
| tree | 9245d9a9c1f5f9e529636fb3e9d93906f6c8a3c0 | |
| parent | f06045c2f0145ec2290913fa144cd690e70736fd (diff) | |
| download | PROJ-67ca5c199dfe62fc0738a808f3142af2e77eafd7.tar.gz PROJ-67ca5c199dfe62fc0738a808f3142af2e77eafd7.zip | |
projinfo: display deprecation info
| -rw-r--r-- | include/proj/common.hpp | 12 | ||||
| -rw-r--r-- | src/projinfo.cpp | 26 | ||||
| -rwxr-xr-x | test/cli/testprojinfo | 4 | ||||
| -rw-r--r-- | test/cli/testprojinfo_out.dist | 45 |
4 files changed, 81 insertions, 6 deletions
diff --git a/include/proj/common.hpp b/include/proj/common.hpp index f1e683e7..91756c62 100644 --- a/include/proj/common.hpp +++ b/include/proj/common.hpp @@ -277,9 +277,9 @@ using IdentifiedObjectNNPtr = util::nn<IdentifiedObjectPtr>; * * \remark Implements IdentifiedObject from \ref ISO_19111_2018 */ -class IdentifiedObject : public util::BaseObject, - public util::IComparable, - public io::IWKTExportable { +class PROJ_GCC_DLL IdentifiedObject : public util::BaseObject, + public util::IComparable, + public io::IWKTExportable { public: //! @cond Doxygen_Suppress PROJ_DLL ~IdentifiedObject() override; @@ -311,14 +311,14 @@ class IdentifiedObject : public util::BaseObject, //! @cond Doxygen_Suppress void formatID(io::WKTFormatter *formatter) const; - void formatRemarks(io::WKTFormatter *formatter) const; + PROJ_INTERNAL void formatRemarks(io::WKTFormatter *formatter) const; - bool + PROJ_INTERNAL bool _isEquivalentTo(const util::IComparable *other, util::IComparable::Criterion criterion = util::IComparable::Criterion::STRICT) const override; - bool + PROJ_INTERNAL bool _isEquivalentTo(const IdentifiedObject *other, util::IComparable::Criterion criterion = util::IComparable::Criterion::STRICT) PROJ_CONST_DECL; diff --git a/src/projinfo.cpp b/src/projinfo.cpp index ddcc09da..ba19b8d2 100644 --- a/src/projinfo.cpp +++ b/src/projinfo.cpp @@ -37,6 +37,7 @@ #include "projects.h" +#include <proj/common.hpp> #include <proj/coordinateoperation.hpp> #include <proj/crs.hpp> #include <proj/io.hpp> @@ -45,6 +46,7 @@ #include "proj/internal/internal.hpp" // for split +using namespace NS_PROJ::common; using namespace NS_PROJ::crs; using namespace NS_PROJ::io; using namespace NS_PROJ::metadata; @@ -201,6 +203,30 @@ static BaseObjectNNPtr buildObject(DatabaseContextPtr dbContext, static void outputObject(DatabaseContextPtr dbContext, BaseObjectNNPtr obj, const OutputOptions &outputOpt) { + + auto identified = dynamic_cast<const IdentifiedObject *>(obj.get()); + if (!outputOpt.quiet && identified && identified->isDeprecated()) { + std::cout << "Warning: object is deprecated" << std::endl; + auto crs = dynamic_cast<const CRS *>(obj.get()); + if (crs && dbContext) { + try { + auto list = crs->getNonDeprecated(NN_NO_CHECK(dbContext)); + if (!list.empty()) { + std::cout << "Alternative non-deprecated CRS:" << std::endl; + } + for (const auto &altCRS : list) { + const auto &ids = altCRS->identifiers(); + if (!ids.empty()) { + std::cout << " " << *(ids[0]->codeSpace()) << ":" + << ids[0]->code() << std::endl; + } + } + } catch (const std::exception &) { + } + } + std::cout << std::endl; + } + auto projStringExportable = nn_dynamic_pointer_cast<IPROJStringExportable>(obj); bool alreadyOutputed = false; diff --git a/test/cli/testprojinfo b/test/cli/testprojinfo index 90829fdd..ea0dcc2d 100755 --- a/test/cli/testprojinfo +++ b/test/cli/testprojinfo @@ -74,6 +74,10 @@ echo "Testing projinfo -s EPSG:4230 -t EPSG:4258 --area WRONG:CODE --summary" >> $EXE -s EPSG:4230 -t EPSG:4258 --area WRONG:CODE --summary >>${OUT} 2>&1 echo "" >>${OUT} +echo "Testing deprecated CRS: projinfo EPSG:26591" >> ${OUT} +$EXE EPSG:26591 >>${OUT} 2>&1 +echo "" >>${OUT} + # do 'diff' with distribution results echo "diff ${OUT} with testprojinfo_out.dist" diff -u ${OUT} ${TEST_CLI_DIR}/testprojinfo_out.dist diff --git a/test/cli/testprojinfo_out.dist b/test/cli/testprojinfo_out.dist index 4a760c67..40035489 100644 --- a/test/cli/testprojinfo_out.dist +++ b/test/cli/testprojinfo_out.dist @@ -478,3 +478,48 @@ No area of use matching provided name Testing projinfo -s EPSG:4230 -t EPSG:4258 --area WRONG:CODE --summary Area of use retrieval failed: area not found +Testing deprecated CRS: projinfo EPSG:26591 +Warning: object is deprecated +Alternative non-deprecated CRS: + EPSG:3003 + +PROJ string: ++proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +inv +proj=longlat +ellps=intl +pm=rome +step +proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=1500000 +y_0=0 +ellps=intl +pm=rome + +WKT2_2015 string: +PROJCRS["Monte Mario (Rome) / Italy zone 1", + BASEGEODCRS["Monte Mario (Rome)", + DATUM["Monte Mario (Rome)", + ELLIPSOID["International 1924",6378388,297, + LENGTHUNIT["metre",1]]], + PRIMEM["Rome",12.4523333333333, + ANGLEUNIT["degree",0.0174532925199433]]], + CONVERSION["Italy zone 1", + METHOD["Transverse Mercator", + ID["EPSG",9807]], + PARAMETER["Latitude of natural origin",0, + ANGLEUNIT["degree",0.0174532925199433], + ID["EPSG",8801]], + PARAMETER["Longitude of natural origin",9, + ANGLEUNIT["degree",0.0174532925199433], + ID["EPSG",8802]], + PARAMETER["Scale factor at natural origin",0.9996, + SCALEUNIT["unity",1], + ID["EPSG",8805]], + PARAMETER["False easting",1500000, + LENGTHUNIT["metre",1], + ID["EPSG",8806]], + PARAMETER["False northing",0, + LENGTHUNIT["metre",1], + ID["EPSG",8807]]], + CS[Cartesian,2], + AXIS["easting (X)",east, + ORDER[1], + LENGTHUNIT["metre",1]], + AXIS["northing (Y)",north, + ORDER[2], + LENGTHUNIT["metre",1]], + AREA["Italy - west of 12°E"], + BBOX[36.53,5.94,47.04,12], + ID["EPSG",26591]] + |
