[OSM-talk] Finding what country something is in (new website)
OJ W
ojwlists at googlemail.com
Thu Jul 30 19:59:56 BST 2009
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
More information about the talk
mailing list