Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

API feature request: /map take centre point and width,height, or zoom level #2410

Closed
openstreetmap-trac opened this issue Jul 23, 2021 · 5 comments

Comments

@openstreetmap-trac
Copy link

Reporter: Ed Avis
[Submitted to the original trac issue database at 7.41pm, Friday, 30th October 2009]

Currently to fetch data with /api/map you specify a bounding box with two longitudes and two latitudes. It would be easier for some uses to give a centre point plus the width and height in metres of the area to be fetched, e.g.

/api/0.6/map?centre=50.812279,-3.033383;width=1000;height=1000

This would calculate the bounding box for you and return the same results as

/api/0.6/map?bbox=-3.04051192352175,50.8077744954955,-3.02625407647825,50.8167835045045

Of course clients can calculate these for themselves, to reasonable accuracy, using a couple of constants and a cosine. So this wouldn't make the API any more powerful, just a bit more convenient for some uses.

Further, it would be useful to fetch the same map area as a particular slippy map display, as

/api/0.6/map?centre=50.812279,-3.033383;zoom=18;screen_width=800;screen_height=600

This would compute the width and height based on the zoom level, location, and screen size given.
Again, clients can compute this with a few lines of code provided they have a lookup of what
the zoom factors are, but it would be a useful builtin. If screen_width and screen_height are
omitted, some default such as 800x600 could be assumed.

@openstreetmap-trac
Copy link
Author

Author: tom[at]compton.nu
[Added to the original trac issue at 1.05pm, Sunday, 1st November 2009]

Can you elaborate on what sort of uses this would help with?

Incidentally, screen_width and screen_height are clearly the wrong names unless you're going to tell us what percentage of the width and height of the screen are being used to display the map. It would be better just to name them width and height (or map_width and map_height or something).

Of course strictly speaking you would also need to tell us what projection you're using ;-)

@openstreetmap-trac
Copy link
Author

Author: Ed Avis
[Added to the original trac issue at 3.08pm, Sunday, 1st November 2009]

I was thinking of when you want to quickly use the API to look at the XML for a particular map area. The slippy map interface uses (lat, lon, zoom) rather than a bounding box and this triple is sometimes used as a kind of OSM bookmark - e.g. in Merkaartor you can paste in a link to the slippy map to choose the area to download. Merkaartor has its own code to turn that into a bbox.

As for the pixel width and height, perhaps viewport_width and viewport_height would be better names.

@openstreetmap-trac
Copy link
Author

Author: tom[at]compton.nu
[Added to the original trac issue at 3.44pm, Sunday, 1st November 2009]

So you don't actually have a concrete use for this? It just seemed like a good idea so you thought you ask somebody to spend time implementing it in case somebody later decided they would like to use it...

@openstreetmap-trac
Copy link
Author

Author: Ed Avis
[Added to the original trac issue at 4.15pm, Sunday, 1st November 2009]

Yes, this is just a feature request. The concrete use is as I mentioned, and is something I wrote code for, but thought it might make sense to have implemented in the API instead.

@openstreetmap-trac
Copy link
Author

Author: mmd
[Added to the original trac issue at 5.55pm, Tuesday, 19th May 2020]

This has never been requested again in the last 9 years. Closing because requirement is too niche.
If you're looking for objects around a center point with a given radius, you can use Overpass API around: filter instead.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant