[Chameleon-dev] [Bug 1031] Round attribute for Scale widget

bugzilla-daemon at maptools.org bugzilla-daemon at maptools.org
Mon May 16 08:08:04 EDT 2005


------- Additional Comments From bartvde at xs4all.nl  2005-05-16 08:08 -------
I wanted to do this with javascript in Scale.widget.php:

{$this->mszHTMLForm}.SCALE.value = Math.round(goCWCJSAPI.oMap.scale); 

but apparently javascript has no way to round to a certain number of decimals.
Maybe Chameleon has a function for this, otherwise there are scripts on the web, eg:

function roundit(Num, Places) {
   if (Places > 0) {
      if ((Num.toString().length - Num.toString().lastIndexOf('.')) > (Places +
1)) {
         var Rounder = Math.pow(10, Places);
         return Math.round(Num * Rounder) / Rounder;
      else return Num;
   else return Math.round(Num);

Ie a NUMBEROFDECIMALS attribute (or maybe we should call it precision?). But
ideally I would not want a solution which loses precision in the calculations
being made by scale, just display. But the form variable is used for
calculations in jsapi mode, so this is not the nicest of solutions.

Paul do you have thoughts on how this could be implemented in a way that it does
not affect the precision of calculations, merely for display purposes?

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

Please do NOT reply to this email, use the link above instead to 
login to bugzilla and submit your comment. Any email reply to this
address will be lost.

More information about the Chameleon-dev mailing list