Looking for a way to get the country code with an overpass-api request

Hello everyone,

I am working for a little project, a map that shows markets, farmshops and vending machines in middle europe. You can find the (german) map on https://farmshops.eu , we are planing to translate the map to other languages in the future. The map uses opening_hours.js to find out if a feature is open or closed. This only works with opening hours that do not contain holidays.

We experimented with the Nominatim api. It is possible to get the country id for one node from there, but not for all 7000 nodes in the map at once. If we use this we have to send a request everytime someone opens a popup, wich is okay, but not ideal cause we are planing to at a “open right now” feature that hides al closed points in the map.

Is there a native way query for the country code of a feature in the overpass api?

Are there any other ways to include the information in the data? We are using a Script to import the data, we could easily add the information there.

Thanks for any help,
Stefan

So just to get that right: do you want to get an ISO 3166 country code for a given coodinate?

This query is one of the example queries from OverpassTurbo.
It shows a.o. the country in which the center point is located.

Please note that in some countries there are holidays that are not defined on the national level. e.g. In Belgium, there is a separate holiday for the Flemish and Walloon communities.

Also school holidays can be different within a country, I think this is also the case for Germany.

So you might need more detail info for your POIs than just country codes. But the above query should cover that.

But you would have to do 7000 requests to overpass everyday if you include this step in your update script. This would be a quite intense task… I thought there was some other (JavaScript) method/library to get a country code by some coordinates… Similar to this library for Java: https://github.com/westnordost/countryboundaries

…and are probably wasting quite some Overpass server resources, as not every POI changes every day.

Thanks everyone for all the suggestions. You are right, I should’t use to much resources on the overpass server. The countryboundaries library looks promising but it is written in Java :frowning:

Thats true, what I need is the federal state.

EDIT: maybe it is easier to have a seperate query for every federal state and add the ID based on that?

EDIT2: https://github.com/hlaw/codegrid-js looks good, I am not sure if it gives more than the country though.