From f3a3ce04dbc11270e0139ccf530c567a52b7a57d Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Wed, 20 Feb 2008 12:44:34 +0000 Subject: [PATCH] convert to degrees if projection is geographic --- src/projection.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/projection.cpp b/src/projection.cpp index 7a0eb6548..511b2d673 100644 --- a/src/projection.cpp +++ b/src/projection.cpp @@ -82,6 +82,11 @@ namespace mapnik { p = pj_fwd(p,proj_); x = p.u; y = p.v; + if (pj_is_latlong(proj_)) + { + x *=RAD_TO_DEG; + y *=RAD_TO_DEG; + } } void projection::inverse(double & x,double & y) const @@ -89,12 +94,17 @@ namespace mapnik { #ifdef MAPNIK_THREADSAFE mutex::scoped_lock lock(mutex_); #endif - projUV p; - p.u = x; - p.v = y; - p = pj_inv(p,proj_); - x = RAD_TO_DEG * p.u; - y = RAD_TO_DEG * p.v; + if (pj_is_latlong(proj_)) + { + x *=DEG_TO_RAD; + y *=DEG_TO_RAD; + } + projUV p; + p.u = x; + p.v = y; + p = pj_inv(p,proj_); + x = RAD_TO_DEG * p.u; + y = RAD_TO_DEG * p.v; } projection::~projection()