From 11ff758c38b7ed8ee0d7d794d30d710d56255802 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Tue, 2 Mar 2021 17:07:13 +0000 Subject: [PATCH] Add proj_transform::definition() method --- include/mapnik/proj_transform.hpp | 1 + src/proj_transform.cpp | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/mapnik/proj_transform.hpp b/include/mapnik/proj_transform.hpp index daf84b52c..2287ef74f 100644 --- a/include/mapnik/proj_transform.hpp +++ b/include/mapnik/proj_transform.hpp @@ -54,6 +54,7 @@ public: bool backward (box2d & box) const; bool forward (box2d & box, std::size_t points) const; bool backward (box2d & box, std::size_t points) const; + std::string definition() const; private: PJ_CONTEXT* ctx_ = nullptr; PJ* transform_ = nullptr; diff --git a/src/proj_transform.cpp b/src/proj_transform.cpp index 380b55b3a..5f391bb0d 100644 --- a/src/proj_transform.cpp +++ b/src/proj_transform.cpp @@ -28,7 +28,7 @@ #include #include #include - +#include // boost #include @@ -451,4 +451,25 @@ bool proj_transform::forward(box2d& env, std::size_t points) const return true; } +std::string proj_transform::definition() const +{ +#ifdef MAPNIK_USE_PROJ + if (transform_) + { + PJ_PROJ_INFO info = proj_pj_info(transform_); + return mapnik::util::trim_copy(info.definition); + } + else +#endif + if (wgs84_to_merc_) + { + return "wgs84 => merc"; + } + else if (merc_to_wgs84_) + { + return "merc => wgs84"; + } + return "unknown"; + } + }