When performing a reverse geocode in nominatim the response consists of address jsonObject, are the keys in this json ordered based on the address hierarchy ? Eg: http://nominatim.openstreetmap.org/reverse?format=json&limit=1&lat=12.8441574&lon=80.0599055 This responds with display name : "display_name":"D3 Guduvancheri Police Station, Grand Southern Trunk Road, Guduvancheri, Potheri, Kanchipuram district, Tamil Nadu, 603202, India" The address json is : "address":{"police":"D3 Guduvancheri Police Station","road":"Grand Southern Trunk Road","suburb":"Guduvancheri","village":"Potheri","state_district":"Kanchipuram district","state":"Tamil Nadu","postcode":"603202","country":"India","country_code":"in"} I see the order is preserved. I wanted to know if this can be assumed to work with any input, i.e is this the intended way? Thanks in advance for any help! asked 11 May '17, 14:50 Arun Gowtham |
It's more coincidence since PHP's hash table implementation keeps the order of elements when inserted (http://nikic.github.io/2014/12/22/PHPs-new-hashtable-implementation.html) and not guaranteed. If you want to order the elements you can have a look at this list of keys https://github.com/OpenCageData/address-formatting/blob/master/conf/components.yaml (where anything not in the list should go in the first position) answered 11 May '17, 15:42 mtmail |