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

JSON, JSONP and CORS for OSM API #3911

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

JSON, JSONP and CORS for OSM API #3911

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

Comments

@openstreetmap-trac
Copy link

Reporter: cbenz
[Submitted to the original trac issue database at 11.33am, Sunday, 17th July 2011]

I would like to access the OSM API with JSON / JSONP instead of XML to use data from a full-JavaScript client.

For modern browsers, it would be useful to implement CORS (cross-origin resource sharing) : http://enable-cors.org/

I did not find any discussion about it on the mailing list or in another ticket.

API v0.7 mentions geoJSON [1]. I think that outputting the same schema in JSON than XML is possible, but geoJSON is not the same problem. I would like simple JSON (and JSONP) that mimics the XML schema.

[1] http://wiki.openstreetmap.org/wiki/API_v0.7#Format_agnosticism

@openstreetmap-trac
Copy link
Author

Author: TomH
[Added to the original trac issue at 1.54pm, Monday, 18th July 2011]

And I'd like a Pony - are you offering to provide one?

If your proposing to offer patches to implement this then fine, if you're not then this is basically just you begging somebody else to do a whole lot of work to make your life easier and isn't really helpful.

I'm also a bit confused by the CORS thing - that site implies that all major browsers already support it but my understanding was that the attempt to standardise cross domain access for XHR had faltered and Firefox at least has never supported it in any release version. It was supported in some betas or something I think but was never released.

@openstreetmap-trac
Copy link
Author

Author: TomH
[Added to the original trac issue at 1.55pm, Monday, 18th July 2011]

Oh I should also add that the API 0.7 page you reference is basically a giant joke and should in no circumstances be read as a serious discussion of what might be in API 0.7 although support for alternative output formats is actually a reasonable candidate. Indeed that doesn't even need to wait for a new API version.

@openstreetmap-trac
Copy link
Author

Author: cbenz
[Added to the original trac issue at 4.02pm, Monday, 18th July 2011]

Great ! So you seem to accept a patch doing JSON / JSONP. I was afraid this idea was rejected so I wanted to ask first.

Someone made some work in 2009 : . The patches, as far as I can see, was never merged. I don't know whether he submitted his patches.

By the way I don't ask anyone to do the job, I just use the bugtracker to register a wish. I surely could implement it, even if my rails skills are nearly null :-)

About CORS, according to wikipedia (http://en.wikipedia.org/wiki/Cross-Origin_Resource_Sharing), it is implemented in Gecko 1.9.1 (Firefox 3.5). But I agree that for the moment it is quite experimental.

Thanks for the information about the API 0.7 wiki page. Is there any more relevant information source ?

@openstreetmap-trac
Copy link
Author

Author: cbenz
[Added to the original trac issue at 4.06pm, Monday, 18th July 2011]

Oops, here is the link : http://unterbahn.com/2009/07/serving-osm-json-alongside-xml-from-the-openstreetmap-rails-port/

It outputs a result like that : http://unterbahn.com/wp-content/uploads/2009/09/dr5ru0.json

What do you think about these patches ?

If it fits, I'll create a git branch directly mergeable.

@openstreetmap-trac
Copy link
Author

Author: TomH
[Added to the original trac issue at 4.11pm, Monday, 18th July 2011]

Well that page appears to document adding it to (a) the map call, which is no longer handled in ruby and (b) a "geohash" call which does not exist, and never has existed, in our code base.

For the map call any work needs to be done in cgimap, though for compatibility we may want to make the ruby code do it as well. Note that Matt Amos has already been working on multi-format output for cgimap though so you should talk to him about that.

For other calls the work would (for now) need to be in the rails code, although many of the read calls are likely to move to cgimap in due course.

@openstreetmap-trac
Copy link
Author

Author: amm
[Added to the original trac issue at 4.52pm, Thursday, 4th August 2011]

In case it helps, Matt's work on the multi-format cgimap can be found at https://github.com/zerebubuth/openstreetmap-cgimap/tree/content-types in the content-types branch.

That branch also already contains a number of further read calls (although not all), but non of that is deployed yet.

@openstreetmap-trac
Copy link
Author

Author: iandees
[Added to the original trac issue at 11.20pm, Monday, 9th September 2013]

CORS headers have been added in the appropriate places. JSON is coming in the near future.

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