Add proj_transform::definition() method

This commit is contained in:
Artem Pavlenko 2021-03-02 17:07:13 +00:00
parent a149ebed16
commit 11ff758c38
2 changed files with 23 additions and 1 deletions

View file

@ -54,6 +54,7 @@ public:
bool backward (box2d<double> & box) const; bool backward (box2d<double> & box) const;
bool forward (box2d<double> & box, std::size_t points) const; bool forward (box2d<double> & box, std::size_t points) const;
bool backward (box2d<double> & box, std::size_t points) const; bool backward (box2d<double> & box, std::size_t points) const;
std::string definition() const;
private: private:
PJ_CONTEXT* ctx_ = nullptr; PJ_CONTEXT* ctx_ = nullptr;
PJ* transform_ = nullptr; PJ* transform_ = nullptr;

View file

@ -28,7 +28,7 @@
#include <mapnik/proj_transform.hpp> #include <mapnik/proj_transform.hpp>
#include <mapnik/coord.hpp> #include <mapnik/coord.hpp>
#include <mapnik/util/is_clockwise.hpp> #include <mapnik/util/is_clockwise.hpp>
#include <mapnik/util/trim.hpp>
// boost // boost
#include <boost/geometry/algorithms/envelope.hpp> #include <boost/geometry/algorithms/envelope.hpp>
@ -451,4 +451,25 @@ bool proj_transform::forward(box2d<double>& env, std::size_t points) const
return true; 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";
}
} }