orontee / taranis

Local weather data on your PocketBook e-book reader.
GNU General Public License v3.0
22 stars 0 forks source link

Location names in multiple countries #56

Closed neilswann80 closed 12 months ago

neilswann80 commented 1 year ago

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 commented 1 year ago

The fix will be done in two steps:

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:

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 commented 1 year ago

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 commented 1 year ago

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

orontee commented 12 months ago

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 commented 12 months ago

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:

neilswann80 commented 12 months ago

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 commented 12 months ago

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 commented 12 months ago

screenshot

neilswann80 commented 12 months ago

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 commented 12 months ago

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 commented 12 months ago

You're right. Most recent item in history is used (Toulouse if history is empty).

The config file should be created after a change of unit for example.

Matthias

Le mar. 10 oct. 2023, 06:35, Swanny @.***> a écrit :

Just wanted to check... taranis.cfg is no longer created. Does Tarnis now use the first entry in the .json file as the location to load on app launch?

— Reply to this email directly, view it on GitHub https://github.com/orontee/taranis/issues/56#issuecomment-1754354579, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPYMIWBVDPF4LETMUGFKN3X6TGBRAVCNFSM6AAAAAA5UEUGF6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJUGM2TINJXHE . You are receiving this because you modified the open/close state.Message ID: @.***>

neilswann80 commented 12 months ago

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

orontee commented 12 months ago

Yes. But this should change in the future because it's more related to the application state than a configuration...

Matthias

Le mar. 10 oct. 2023, 07:18, Swanny @.***> a écrit :

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

— Reply to this email directly, view it on GitHub https://github.com/orontee/taranis/issues/56#issuecomment-1754402122, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPYMIWQ5XB6EES5TG7B6FTX6TLBXAVCNFSM6AAAAAA5UEUGF6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJUGQYDEMJSGI . You are receiving this because you modified the open/close state.Message ID: @.***>