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

Location names in multiple countries #56

Closed
neilswann80 opened this issue Oct 5, 2023 · 13 comments
Closed

Location names in multiple countries #56

neilswann80 opened this issue Oct 5, 2023 · 13 comments
Labels
enhancement New feature or request

Comments

@neilswann80
Copy link

neilswann80 commented Oct 5, 2023

Less common scenario to consider...

Birmingham for example exists in the UK and the US. If you search simply for "Birmingham" without specifying the country, a weather report is generated but it's not immediately clear for which country.

Could the location name written to the screen be extracted from the OpenWeather data payload (with country included) rather than writing the user input to the screen, so the exact location/country is clear?

@orontee orontee added the enhancement New feature or request label Oct 5, 2023
@orontee
Copy link
Owner

orontee commented Oct 6, 2023

The fix will be done in two steps:

  • Quick fix: Complete user input with the country information of the first location returned by the Geocoding API (the location currently used to request weather conditions)
  • Offer user a choice of locations built from the locations returned by the Geocoding API when there's not a unique location

First step

$ curl "https://api.openweathermap.org/geo/1.0/direct?q=Saint%20Malo,France&lang=fr&appid=${OWM_API_KEY}"
[{"name":"Saint-Malo","local_names":{"ko":"생말로","br":"Sant-Maloù","fr":"Saint-Malo"},"lat":48.649518,"lon":-2.0260409,"country":"FR","state":"Brittany"}]

Remarks:

  • Note that the name can differ from the "town" entered by the user: Here "Saint Malo" becomes "Saint-Malo" ; looks good.
  • Note that the country is a code, not the full name. I guess it's ok to display that code and not the exact user input.
  • One should choose to display the local name corresponding to current language if any
  • Side effect: The model Location should be changed from a structure with town and country to a structure with longitude, latitude and localized name (should be kept for what locale ?).

Second step

Good occasion to experiment with:
void OpenList(const char *title, const ibitmap *background, int itemw, int itemh, int itemcount, int cpos, iv_listhandler hproc);

@neilswann80
Copy link
Author

neilswann80 commented Oct 6, 2023

Excellent start!

  • Note that the country is a code, not the full name. I guess it's ok to display that code and not the exact user input.

If it's just the two-letter ISO-3166-1 country codes it would be easy enough to use an alias file to write the full country name.

Country Codes
Source: ub.io/core/country-list#data

I guess the complication would be multi-language support.

Perhaps only show the country code in the scenario where the user did not manually enter a country?

@neilswann80
Copy link
Author

neilswann80 commented Oct 6, 2023

This looks like a useful resource... country codes with countries listed in different languages:
https://github.com/umpirsky/country-list

@orontee
Copy link
Owner

orontee commented Oct 8, 2023

Work is ongoing on this topic but unfortunately don't expect to much from Geocoding API...

$ curl "https://api.openweathermap.org/geo/1.0/direct?q=Saint,France&lang=fr&appid=${OWM_API_KEY}"
[{"name":"Saint","local_names":{"hi":"सैंत"},"lat":27.370281,"lon":77.3582553,"country":"IN","state":"Rajasthan"}]

I am not even able to find a query with multiple answers... Oh I see, one has to add the limit query parameter:

$ curl "https://api.openweathermap.org/geo/1.0/direct?q=birmingham&limit=5&lang=fr&appid=${OWM_API_KEY}" | jq -r  'length' 
5

orontee added a commit that referenced this issue Oct 8, 2023
orontee added a commit that referenced this issue Oct 8, 2023
orontee added a commit that referenced this issue Oct 9, 2023
@orontee
Copy link
Owner

orontee commented Oct 9, 2023

Current implementation doesn't try to display local names, nor transform country codes into full country names.

Let see whether we need those refinements; It's not clear to me.

https://github.com/orontee/taranis/releases/tag/v1.2.0-rc5

Small bugs:

  • When the application starts for the first time, no default location is set.
  • Empty location can be added to history.
  • Impossible to distinguish some locations. Should longitude and latitude be displayed in location list?
  • Sometime state appears as empty: (), seen with "kobe" search string.

@neilswann80
Copy link
Author

Works nicely here. Surprising how many location names appear in other parts of the world! 😃

Just having the country code is likely sufficient, no? Most people are used to seeing this from webforms and the like.

Couldn't hurt to have the longitude and latitude in the location list.

orontee added a commit that referenced this issue Oct 9, 2023
orontee added a commit that referenced this issue Oct 9, 2023
@orontee
Copy link
Owner

orontee commented Oct 9, 2023

Works nicely here.

Thanks for the feedback!

Surprising how many location names appear in other parts of the world! 😃

Yes. And I am not sure the Geocoding API is that precise and of good quality...

Just having the country code is likely sufficient, no? Most people are used to seeing this from webforms and the like.

Right.

Couldn't hurt to have the longitude and latitude in the location list.

Yes, I'll make list items spread over two lines, the second being dedicated to longitude and latitude.

@orontee orontee added this to the Winter 2023 version milestone Oct 9, 2023
orontee added a commit that referenced this issue Oct 9, 2023
orontee added a commit that referenced this issue Oct 9, 2023
@orontee
Copy link
Owner

orontee commented Oct 9, 2023

screenshot

@neilswann80
Copy link
Author

neilswann80 commented Oct 9, 2023

Great work! It's actually much quicker now to simply type just the town/city and then select the exact location from the drop-down. No having type a comma and country etc. And having the country code visible gives me confidence that the report is for the exact location I need.

@orontee
Copy link
Owner

orontee commented Oct 9, 2023

Yes, the user experience has improved a lot!

I'll will release this soon. Other awaiting issues are stucked and I suspect they won't progress in a short delay.

https://github.com/orontee/taranis/releases/tag/untagged-4b2ea7b438c0120ebc5d

Let's wait for few days to see whether day to day use are ok, and I'll post about that release on mobileread.com.

@orontee orontee closed this as completed Oct 9, 2023
@orontee
Copy link
Owner

orontee commented Oct 10, 2023 via email

@neilswann80
Copy link
Author

Or if you change view to 8-day I presume?

@orontee
Copy link
Owner

orontee commented Oct 10, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants