Location names in multiple countries
neilswann80 opened this issue · 13 comments
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?
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 withtown
andcountry
to a structure withlongitude
,latitude
andlocalized 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);
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?
This looks like a useful resource... country codes with countries listed in different languages:
https://github.com/umpirsky/country-list
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
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.
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.
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.
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.
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.
Or if you change view to 8-day I presume?