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

Roland Olbricht roland.olbricht at gmx.de
Fri Jul 31 18:26:48 BST 2009


Dear OJ,

> 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/?l
>at=%f&lon=%f", 51.51, -0.05)));
>
> (so $MyArray[1] would then contain the country name. Apparently this
> is ISO 3166-1)

first of all, thank you for concise way of getting country information.

After some playing around, I get some error messages with
http://dev.openstreetmap.org/~ojw/WhatCountry/?lat=-34.7758269&lon=149.6918631
(should be somewhere in Australia)

---8<---

<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in 
<b>/home/ojw/public_html/WhatCountry/index.php</b> on line <b>45</b><br />










--->8---

If the problem is on the OSM3S side, I'll try to fix things as fast as 
possible.

Cheers,
Roland




More information about the talk mailing list