[OSM-dev] New tiling code

Christopher Schmidt crschmidt at crschmidt.net
Wed Jun 28 14:06:51 BST 2006


Currently, the OpenStreetMap tile.js code does not round its values.
This results in bounding boxes that are off by very very very small
values when you're at high zooms, and probably depend on client-specific
rounding errors. This is bad because then you've missed your cache for
that file. 

Assuming that:

// make a key
var key = this.url + "?WIDTH="+(this.tilewidth)+"&HEIGHT="+
    (this.tileheight)+"&BBOX="+lt+","+tp+","+rt+","+bt;

Is where the url comes from, one could change this to be:

lt = Math.round(lt*1000000) / 1000000;
tp = Math.round(tp*1000000) / 1000000;
rt = Math.round(rt*1000000) / 1000000;
bt = Math.round(bt*1000000) / 1000000;

6 decimal places gets you within pixel error ranges on everything you'd
need, while at the same time preventing the 17th decimal place rounding
errors that cause you to blow your cache. 

If you want more explanation, or can point to an svn copy of tile.js so
I make an actual patch, please let me know.

Regards, 

-- 
Christopher Schmidt
Web Developer




More information about the dev mailing list