photon icon indicating copy to clipboard operation
photon copied to clipboard

Provide countryCode and stateCode in response

Open vmeurisse opened this issue 9 years ago • 4 comments

Today the json returned contain the country name and state name but not the codes.

It would be really nice to have the codes as well as a lot of services using addresses require them. This would also help for #175 as the user could simply postfilter the result for a given country.

vmeurisse avatar Aug 25 '15 14:08 vmeurisse

This would be a great addition and would cover my issue completely! I tried looking into fixing it myself (even though my knowledge of Java is really limited), but it seems that the dataset in elasticsearch doesn't have the data either (correct me if I'm wrong), so I think the data needs to be added in the Nomatim import?

I guess we could do that ourselves, but then we can't profit from the ready to use search index provided by graphhopper.

Aleksio avatar Jan 30 '16 09:01 Aleksio

Hello!

Any news about this? Is it possible to get the country code in some way?

Thank you very much, Vanessa

ghost avatar Feb 13 '18 19:02 ghost

We love to receive pull requests :) !

karussell avatar Feb 13 '18 20:02 karussell

Hehe, I would love to help but I probably won't find the time soon :P However, if it is useful to anyone, I found these libraries that might help:

https://pypi.python.org/pypi/pycountry https://github.com/tuneinc/pycountry-convert

I use them as:

import pycountry_convert country_name = result_raw['properties']['country'] country_code = pycountry_convert.country_name_to_country_alpha2(country_name, cn_name_format="default")

Cheers and thanks for your answer! Vanessa

ghost avatar Feb 13 '18 20:02 ghost