Converting permalink to bounding box

I am trying to extract data for a custom app and the easiest way is to use zoom on the slippymap then use the permalink value to do the extract but I cannot find the formula to do the conversion to a bounding box values.

If someone here could point me in the right direction that would be great.


AFAIK There is no such formula on the wiki, and it all depends on what accuracy you need.

method 1: JOSM uses URLs like you want to do, so check out the JOSM code.

method 2: If you have the URL and window size in pixels, then you can figure out how many tiles there are in the window and with that you can get the bbx.

method 3: You can also make a javascript bookmarklet that helps you, e.g. here is the code for up-to-date which does some openlayers+javascript magic to interface with the openstreetmap code. Cleaning up that code is left as an exercise.

EDIT: this is probably what you want.
var bounds = map.getExtent();

 if (map.getLayersByName) {
ls = map.getLayersByName("Up-to-Date");
} else { for (var i = 0;
 i < map.layers.length;
 i++) { 
if (map.layers[i].name == "Up-to-Date") { ls.push(map.layers[i]);
for(var i = 0; i < ls.length; i++) { 
var bounds = map.getExtent();
var size = map.getSize();
var l = new OpenLayers.Layer.Image("Up-to-Date", ""+bounds.toBBOX()+"&width="+size.w+"&height="+size.h + "&_salt="+Math.random(),
            maxExtent: map.baseLayer.maxExtent,
            maxResolution: map.baseLayer.maxResolution,
            isBaseLayer: false
 map.setLayerIndex(l, 0)})()

a quick look at the JOSM code answered my questions

care to post the solution?

The total area covered is:
size = 180.0 / Math.pow(2, Zoom Level)
Then as the coordinates in the url are the center of the screen then subtract half the size from for the one set points then add half the size to get the other.
This assumes a square area but is close enough for what I am doing and also JOSM.

FYI, What I am making is a Java App that for a given area, lists all the tags used and the values on those tags. You will then be able to select the object and open it in JOSM and fix what you need and upload. It has an ignore list so tags like “source”
This will make it easier to see everything you have done is spelt correctly.

I got the idea from TagWatch,, where I saw many typos listed in Australia where I started to fix them, but as it’s only updated 3 times a week so I needed to wait for the update to see where I was up to.

If you think it maybe useful I can host is somewhere for download when complete ( Just need to launch JOSM now and set up preferences)