The web site http://nominatim.openstreetmap.org/ offers a search service http://nominatim.openstreetmap.org/search/ that when given a street name will return occurrences of such street name, each one with characterizing information such as longitude and latitude. In this challenge, you should write an expression that returns a collection of location using for example a pair whose key is the description of the location and the value its latitude and longitude.
For example we did a query with Rue de Paris and we selected two results and they are as follows:
{
'La Rue de Paris, Lainsecq, Auxerre, Yonne, Bourgogne-Franche-Comte, France metropolitaine, 89520, France'->(47.5612874@3.2933713) .
'Rue de Paris, Boulogne-Billancourt, Hauts-de-Seine, Ile-de-France, France metropolitaine, 92100, France'->(48.8416645@2.236876) .
}
STON
class->
to build a pair. | query result entries |
query := UIManager default request: 'Find location for:'.
result := STON fromString:
(ZnClient new
url: 'http://nominatim.openstreetmap.org/search/', query;
queryAt: 'format' put: 'jsonv2';
queryAt: 'limit' put: '10';
get;
contents).
(result collect: [ :dct |
(dct at: 'display_name') ->
((dct at: 'lat') asNumber @ (dct at: 'lon') asNumber)
]) inspect