If you have ever tried to display data from OpenStreetMap in a web map such as leaflet you have probably used the overpass-api to query the database. Leaflet makes it very easy to publish data in the geojson format but unfortunately the overpass api returns the data in a different format.
Because I wanted to be able to quickly load data into leaflet without having
to do the conversion manually I explored AWS Lambda which allows you to write ‘serverless’ code.
Essentially this means they start a small instance for every request, run your code and shut it down again. This was perfect for my usecase.
So I sat down and wrote (very little) code to mirror the overpass-api by accepting
POST requests, forwarding them to the overapss api
(more specifically the rambler.ru instance)), passing the results to
osmtogeojson and returning the converted geojson.
You can find and use it at https://giluifm80f.execute-api.us-west-2.amazonaws.com/dev/overPassGeoJson
Check out the plnkr for an example using leaflet.
The code that runs on lambda can be found in this repository.
If you have any questions let me know on twitter.
Also let me know if you plan to use this a lot because after a certain amount of free requests I will have to pay for it 😉 💸