OpenStreetMap Forum

The Free Wiki World Map

You are not logged in.

#1 2018-07-06 20:55:34

sterfanrg
Member
Registered: 2018-07-05
Posts: 26

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

Last edited by sterfanrg (2018-07-06 20:57:07)

Offline

#2 2018-08-04 00:02:49

ENT8R
Member
Registered: 2017-12-09
Posts: 36
Website

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

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

Offline

#3 2018-08-04 08:14:32

escada
Moderator
Registered: 2011-08-13
Posts: 1,373

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

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.

Offline

#4 2018-08-04 08:26:32

ENT8R
Member
Registered: 2017-12-09
Posts: 36
Website

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

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

Offline

#5 2018-08-04 12:09:25

mmd
Member
Registered: 2010-11-06
Posts: 1,497

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

ENT8R wrote:

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...

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

Last edited by mmd (2018-08-05 08:09:20)

Offline

#6 2018-09-05 08:41:05

sterfanrg
Member
Registered: 2018-07-05
Posts: 26

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

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 sad

escada wrote:

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

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.

Last edited by sterfanrg (2018-09-05 15:41:33)

Offline

Board footer

Powered by FluxBB