This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

country code in q= or in countryCodes=

0

For geocoding, to search for the Mainstreet 12, Amsterdam, Netherlands, (doesn't exist) we can call either

http://nominatim.openstreetmap.org/search?q=12,Mainstreet,Amsterdam,NL&format=xml

or

http://nominatim.openstreetmap.org/search?q=12,Mainstreet,Amsterdam&countryCodes=NL&format=xml

Which format is preferred? With country code appended in the q=, or with using countryCodes=

asked 24 Feb '12, 08:38

msol's gravatar image

msol
1334
accept rate: 0%

edited 24 Feb '12, 08:55

stephan75's gravatar image

stephan75
12.6k556210


One Answer:

3

There is a slight difference in how Nominatim handles these two queries. In the first query, it will check for all occurrences of 'NL' in the database, so in very rare cases you may end up with unexpected results. Given the second form with the countryCodes parameter, it restricts the search to places within the country right from the start.

So, both query forms are perfectly legitimate and give the same results in most cases. If you know you have search requests for a specific country, the second form might be more efficient. But if you are not sure, there is no need to parse and format the query. Just go with the first form then.

answered 26 Feb '12, 21:06

lonvia's gravatar image

lonvia
6.2k25789
accept rate: 40%

Source code available on GitHub .