Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label of float8 data shows to many digits #430

Closed
artemp opened this issue Oct 11, 2011 · 5 comments
Closed

Label of float8 data shows to many digits #430

artemp opened this issue Oct 11, 2011 · 5 comments
Milestone

Comments

@artemp
Copy link
Member

artemp commented Oct 11, 2011

In quantumnik, I use a postgis layer and set its label to a float8 attribute. QGIS shows one of the labels as "24.6", but when quantumnik is turned on this label displays "24.60000000000001".

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[springmeyer] hardcoded right here:

http://trac.mapnik.org/browser/trunk/include/mapnik/value.hpp#L553

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[springmeyer] this (http://173.255.217.246:8000/mapnik_trac/attachment/ticket/430/control_precision.patch) patch implements flexibility needed to control the precision when converting doubles to unicode text. If this is a decent approach we could then expose as a text_symbolizer param:

(should also likely consider exposing fixed vs scientific formatting, and apply same fix to to_string())

#!diff
Index: src/agg/process_text_symbolizer.cpp
===================================================================
--- src/agg/process_text_symbolizer.cpp (revision 2046)
+++ src/agg/process_text_symbolizer.cpp (working copy)
@@ -45,7 +45,7 @@
     expression_ptr name_expr = sym.get_name();
     if (!name_expr) return;
     value_type result = boost::apply_visitor(evaluate<Feature,value_type>(feature),*name_expr);
-    UnicodeString text = result.to_unicode();
+    UnicodeString text = result.to_unicode(sym.get_precision());

     if ( sym.get_text_convert() == TOUPPER)
     {

strk pushed a commit to strk/mapnik that referenced this issue Dec 6, 2012
Fixes precision digits, closing mapnik#430
Also avoids forcing a trailing '.0', closing mapnik#1627
strk pushed a commit to strk/mapnik that referenced this issue Dec 6, 2012
Fixes precision digits, closing mapnik#430
Also avoids forcing a trailing '.0', closing mapnik#1627
@strk
Copy link
Contributor

strk commented Dec 6, 2012

The pull requests #1631 (for 2.1 branch) and #1632 (for master) fix the precision used by to_string(), effectively fixing the issue reported in the title of this ticket.

Maybe there should be another ticket for "Controlling floating point formatting in label symbolizers" and this one should be closed as fixed ?

@artemp
Copy link
Member Author

artemp commented Dec 6, 2012

@strk - thanks, will check it out asap!

strk pushed a commit to strk/mapnik that referenced this issue Dec 11, 2012
The testcase is ready to host more conversion tests but is currently
really only targetting the double-to-string.

refs mapnik#430, mapnik#1632
@springmeyer
Copy link
Member

thanks @strk, you are right, so closing this as fixed and opened a new one for user control during symbolization: #1695

PetrDlouhy pushed a commit to PetrDlouhy/mapnik that referenced this issue Aug 22, 2013
Fixes precision digits, closing mapnik#430
Also avoids forcing a trailing '.0', closing mapnik#1627
PetrDlouhy pushed a commit to PetrDlouhy/mapnik that referenced this issue Aug 22, 2013
The testcase is ready to host more conversion tests but is currently
really only targetting the double-to-string.

refs mapnik#430, mapnik#1632
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants