Overpass vs. specific API for static web site?

Dear community,
I am fairly new to OSM and the Overpass API. I am working on a quite static web site that lists features of train stations like taxi stands, ticket machines, ticket offices, bike and ride station and so on.

At the moment I am maintaing a REST API for that web site and a back end that consists of osm2pgsql and a pgSQL database to serve the web site with the respective data.

I am wondering if this setup is to much overhead for the purpose at hand. It might be more reasonable to maintain a pgSQL database and an Overpass API.

However, I am not sure if the Overpass API is a good fit for this use case.

Imagine I provide an API with this train station.

At the moment I am using SQL queries together with pgsql and postgis to return features like B±R, P+R or ticket office that are inside a certain distance to the train station. The web site presents the response of the HTTP GET request as a list of train station features.

Do you recommend to continue this way or is this a use case for the Overpass API?

Are there any best practices for this use case?

Cheers!

When working at a small scale, direct overpass request will suffice and will be very easy to maintain. At medium or high scale I would recommend coding some background service for periodical refresh from Overpass (so there is no delay for the users) and serve only cached data. You will most likely fit all information in memory so using a secondary database is redundant. Sure, startup maybe slightly slower (when you need to query full data again) but you will save yourself a lot of headache this way.

1 Like

Cheers for the prompt and helpful reply. Are you aware of any example queries for this use case?

I think you are looking for something like this:

[out:json][timeout:SOMETHING];
nwr[railway=station][train=yes](BBOX_COORDINATES_HERE);
out body center qt;

And here’s the overpass query language documentation (with examples):
https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL

Or if you require an even simpler system to query whole Germany at once:

[out:json][timeout:60];
relation(51477);
map_to_area;
nwr[railway=station][train=yes](area);
out body center qt;

This could be performed once, on the page load.

If my memory serves me right, the reply is a list of train stations inside of the provided bounding box. Correct?

I am looking for a different use case. I am providing

  • the id or coordinates of a train station and
  • the radius of the train station to be considered

in the hope to get a list of the above mentioned features as a reply.

Is the Overpass API capable of that use case?

In those examples I set search range to 50km (50000 meters).

[out:json][timeout:60];
nwr[railway=station][train=yes](around:50000,52.2915287,12.9845109);
out body center qt;
[out:json][timeout:60];
node(27396840);
nwr[railway=station][train=yes](around:50000);
out body center qt;
[out:json][timeout:60];
node[uic_ref=8000413];
nwr[railway=station][train=yes](around:50000);
out body center qt;
1 Like