Comment 5 for bug 1508169

Revision history for this message
Zhang Enwei (zhangew401) wrote :

Thank you very much, Kyle.
I met other obstacles and need your advice.
1. The returned values from Nominatim API seems not standard and they used a lot of items to specify one location. I took some examples for your reference. What I want to use is the value of "address".
{"place_id":"2576701262","licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"way","osm_id":"334026024","lat":"52.5714773","lon":"19.8971761","display_name":"Płocka, Radzanowo, gmina Radzanowo, powiat płocki, Masovian Voivodeship, 09-451, Poland","address":{"road":"Płocka","village":"Radzanowo","county":"gmina Radzanowo","state":"Masovian Voivodeship","postcode":"09-451","country":"Poland","country_code":"pl"}}

{"place_id":"66454177","licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"way","osm_id":"48121662","lat":"45.011207","lon":"20.018092","display_name":"126, Indjija Municipality, Syrmia District, Vojvodina, 22321, Serbia","address":{"road":"126","city":"Indjija Municipality","county":"Syrmia District","state":"Vojvodina","postcode":"22321","country":"Serbia","country_code":"rs"}}

{"place_id":"801104","licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"node","osm_id":"271373068","lat":"52.5167951","lon":"13.38312","display_name":"S+U Brandenburger Tor, Under the linden trees, Mitte, Berlin, 10117, Germany","address":{"bus_stop":"S+U Brandenburger Tor","road":"Under the linden trees","suburb":"Mitte","city_district":"Mitte","city":"Berlin","state":"Berlin","postcode":"10117","country":"Germany","country_code":"de"}}

{"place_id":"2144230998","licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","lat":"35.8620926077602","lon":"-84.4592530653989","display_name":"199, Little Johnston Valley Road, Lawnville, Roane County, Tennessee, 37763, United States of America","address":{"house_number":"199","road":"Little Johnston Valley Road","hamlet":"Lawnville","county":"Roane County","state":"Tennessee","postcode":"37763","country":"United States of America","country_code":"us"}}

{"place_id":"56837758","licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"way","osm_id":"20206256","lat":"51.6479763","lon":"-0.3947587","display_name":"Wiggenhall Road, Watford Heath, Watford, Hertfordshire, East of England, England, United Kingdom","address":{"road":"Wiggenhall Road","suburb":"Watford Heath","town":"Watford","county":"Hertfordshire","state_district":"East of England","state":"England","country":"United Kingdom","country_code":"gb"}}
I didn't find any document from Nominatim about the dictionary they used. It seems difficult to map this variety of items into the standard locale address format if I cannot get the rule for transformation.

2. In http://man7.org/linux/man-pages/man5/locale.5.html, it seems "town" has the same meaning with "city"
but in fact, "town" means an administrative unit below county(which is below city).

3. It seems the locale address format returned from C is not correct at least for China.
"%c%N%T%N%s %h %e %r%N%b%N%d%N%f%N%a%N"

{"place_id":"2592148164","licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"node","osm_id":"3626208893","lat":"38.5878385","lon":"117.0269886","display_name":"金牛镇, Qing, Cangzhou City, Hebei, China","address":{"town":"金牛镇","county":"Qing","state_district":"Cangzhou City","state":"Hebei","country":"China","country_code":"cn"}}

For this example, it will be "China 金牛镇", and it is worse than the display_name(which is used for current code).
The correct one will be "China Hebei Cangzhou Qing 金牛镇".