diff --git a/include/mapnik/util/conversions.hpp b/include/mapnik/util/conversions.hpp index 3e4193abc..ad15627ae 100644 --- a/include/mapnik/util/conversions.hpp +++ b/include/mapnik/util/conversions.hpp @@ -68,7 +68,11 @@ struct double_policy : boost::spirit::karma::real_policies { typedef boost::spirit::karma::real_policies base_type; static int floatfield(T n) { return base_type::fmtflags::fixed; } - static unsigned precision(T n) { return 16 ;} + static unsigned precision(T n) { return 15 - trunc(log10(n)); } + template + static bool dot(OutputIterator& sink, T n, unsigned precision) { + return n ? *sink = '.', true : false; + } }; @@ -77,7 +81,7 @@ template <> inline bool to_string(std::string & str, double value) { namespace karma = boost::spirit::karma; - typedef boost::spirit::karma::real_generator > double_type; + typedef karma::real_generator > double_type; std::back_insert_iterator sink(str); return karma::generate(sink, double_type(), value); }