[OSM-talk] Finding what country something is in (new website)

Claudius claudius.h at gmx.de
Thu Jul 30 20:27:48 BST 2009


Am 30.07.2009 20:59, OJ W:
> I put a wrapper around the rather excellent
> http://wiki.openstreetmap.org/wiki/OSM_Server_Side_Script which can
> tell you which town/county/state/country something is in:
>
> http://dev.openstreetmap.org/~ojw/WhatCountry/?lat=51.51&lon=-0.05
>
>   - which replies that the specified numbers are in Tower Hamlets and
> London and the UK
>
>
> It does mean you can get all the admin levels for a place using just
> one line of PHP:
>
> $MyArray = explode("\n",
> file_get_contents(sprintf("http://dev.openstreetmap.org/~ojw/WhatCountry/?lat=%f&lon=%f",
> 51.51, -0.05)));
>
> (so $MyArray[1] would then contain the country name. Apparently this
> is ISO 3166-1)
>
>
> Results are cached, so hopefully it doesn't hit 78.46.81.38 again if
> you download the same place many times.  I assume most people will be
> using this to lookup OSM place nodes, so it might manage to cache a
> few results if everyone is asking what country London is in...
>
>
> Tagging-wise, we seem to be missing a few minor places, like the United States:
>
> http://dev.openstreetmap.org/~ojw/WhatCountry/?lat=29.4&lon=-98.5

Cool. Any idea why it's failing for cities in Iran [1]? Missing country 
polygon?

Claudius

[1] http://dev.openstreetmap.org/~ojw/WhatCountry/?lat=36.303&lon=59.606





More information about the talk mailing list