Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store location OSM country code (e.g. FR) #292

Closed
monsieurtanuki opened this issue May 20, 2024 · 3 comments
Closed

Store location OSM country code (e.g. FR) #292

monsieurtanuki opened this issue May 20, 2024 · 3 comments
Labels
✨ enhancement New feature or request 📍 Location

Comments

@monsieurtanuki
Copy link

Problem

In "prices" locations, we have the country name (e.g. 'Italia'), but we don't have the country code (e.g. 'IT').
That means that if we want to do something serious with the country data (and not just displaying the country name in some language), we need to maintain some kind of translation/code map.

Proposed solution

In OSM they provide the country code. We could store it in "prices" location.

Additional context

Very specific immediate use-case: displaying the country flag. It's very easy from the country code.
There are obviously more data-related use-cases, e.g. comparing prices among countries.

@raphodn
Copy link
Member

raphodn commented May 20, 2024

Hi @monsieurtanuki

good idea to store the country code, as Nominatim & Photon seem to have different 'country' formats.

for the emoji, we already use something similar in the frontend : https://github.com/openfoodfacts/open-prices-frontend/blob/master/src/data/countries-with-emoji.json

@raphodn raphodn added ✨ enhancement New feature or request 📍 Location labels May 20, 2024
@raphodn raphodn mentioned this issue May 20, 2024
4 tasks
@raphodn raphodn changed the title Country code (e.g. FR) in the location Store location OSM country code (e.g. FR) May 20, 2024
@raphodn
Copy link
Member

raphodn commented May 20, 2024

OSM's list of country codes, and their related name(s) : https://wiki.openstreetmap.org/wiki/Nominatim/Country_Codes

@monsieurtanuki
Copy link
Author

Thank you @raphodn!

Actually we already have a country referential based on ISO 3166-1 codes: https://github.com/openfoodfacts/openfoodfacts-dart/blob/master/lib/src/utils/country_helper.dart

Regarding the flags, we may use a map like your .json, but the emoji code is basically a combination of the first letter and the second letter of the country code. Cf. https://emojipedia.org/flag-italy:

The Flag: Italy emoji is a flag sequence combining 🇮 Regional Indicator Symbol Letter I and 🇹 Regional Indicator Symbol Letter T. These display as a single emoji on supported platforms.

@raphodn raphodn linked a pull request May 20, 2024 that will close this issue
@github-project-automation github-project-automation bot moved this from Backlog to Done in 💸 Open Prices May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request 📍 Location
Projects
Archived in project
Development

No branches or pull requests

2 participants