[OSM-dev] Too many decimal places in permalinks
Robert (Jamie) Munro
rjmunro at arjam.net
Tue Oct 16 15:51:35 BST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I noticed the other day that the permalinks on the view tab of
www.openstreetmap.org have way more decimal places than is useful.
Below is a little (untested) patch to site.js that should make the links
much shorter. It rounds the numbers to the (current zoom level)/3
decimal places, which at zoom level 2 (the worst case) is accurate to
less than 3 pixels - zoom level 2 is:
(1024 pixels wide)/(360 degrees)= 2.8 pixels/degree.
Robert (Jamie) Munro
- --- site.js.orig 2007-10-16 14:32:15.000000000 +0000
+++ site.js 2007-10-16 14:36:11.000000000 +0000
@@ -4,8 +4,9 @@
node = document.getElementById("viewanchor");
if (node) {
var args = getArgs(node.href);
- - args["lat"] = lat;
- - args["lon"] = lon;
+ var decimals = Math.pow(10,Math.floor(zoom/3));
+ args["lat"] = Math.round(lat*decimals)/decimals;
+ args["lon"] = Math.round(lon*decimals)/decimals;
args["zoom"] = zoom;
args["layers"] = layers;
node.href = setArgs(node.href, args);
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHFM/zz+aYVHdncI0RAm35AKDJmKs6URKUR87DWHNgDdkhXAvkKgCg6LUn
UVh0jQQl09kRGeVsm3I0ZmY=
=/Ums
-----END PGP SIGNATURE-----
More information about the dev
mailing list