Hi folks!
I’ve been working on a new version of Weather for the last few weeks.
The version currently hosted on Github is outdated and uses the now discontinbued Yahoo API. There is a PR which aimed to implement MetaWeather API but it has never been merged and Meta Weather is now offline.
I have made significant changes to the code to support Open Meteo besides a few fixes that hopefully will avoid some memory leaks.
It is not perfect but I hope it’s a good starting point for further improvements.
For the time being, you can find it here. Please test it and provide some feedback.
The Tracker replicants seem to work fine and I am able to create as many as I wish with different locations. The Deskbar replicant is broken, though.
My plan for the future is to fix some potential bugs and the Deskbar replicant then merge the code on HaikuArchive.
I would like to revamp it completely for a hypothetical v2 and make it look like the new Weather app on MacOS Ventura, adding more information like wind, hourly forecast, etc. These are subject to availability in the Open Meteo API, though.
Enjoy!
36 Likes
Any chance on up-streaming your work to HaikuArchives?
1 Like
I just wanted to do some testing and getting feedback, before merging. Yet, sure I can commit directly and considering that Weather is not currently working at all, I don’t see any blocker
6 Likes
Thanks for taking care of this application
2 Likes
Hey Nexus-6, Thanks for working on this!
I have tried to compile the version you provided (the master branch of https://github.com/nexus6-haiku/Weather)
but this failed for me. Here is the log : )
I am using 64bit haiku on hrev56194+7
~/proj/Weather make
mkdir -p objects.x86_64-cc11-debug; \
mkdepend -ISource/ -Iobjects.x86_64-cc11-debug/ -p .cpp:objects.x86_64-cc11-debug/%n.o -m -f "objects.x86_64-cc11-debug/Util.d" Source/Util.cpp
mkdir -p objects.x86_64-cc11-debug; \
mkdepend -ISource/ -Iobjects.x86_64-cc11-debug/ -p .cpp:objects.x86_64-cc11-debug/%n.o -m -f "objects.x86_64-cc11-debug/CitiesListSelectionWindow.d" Source/CitiesListSelectionWindow.cpp
mkdir -p objects.x86_64-cc11-debug; \
mkdepend -ISource/ -Iobjects.x86_64-cc11-debug/ -p .cpp:objects.x86_64-cc11-debug/%n.o -m -f "objects.x86_64-cc11-debug/ForecastDeskbarView.d" Source/ForecastDeskbarView.cpp
mkdir -p objects.x86_64-cc11-debug; \
mkdepend -ISource/ -Iobjects.x86_64-cc11-debug/ -p .cpp:objects.x86_64-cc11-debug/%n.o -m -f "objects.x86_64-cc11-debug/ForecastView.d" Source/ForecastView.cpp
mkdir -p objects.x86_64-cc11-debug; \
mkdepend -ISource/ -Iobjects.x86_64-cc11-debug/ -p .cpp:objects.x86_64-cc11-debug/%n.o -m -f "objects.x86_64-cc11-debug/ForecastDayView.d" Source/ForecastDayView.cpp
mkdir -p objects.x86_64-cc11-debug; \
mkdepend -ISource/ -Iobjects.x86_64-cc11-debug/ -p .cpp:objects.x86_64-cc11-debug/%n.o -m -f "objects.x86_64-cc11-debug/SelectionWindow.d" Source/SelectionWindow.cpp
mkdir -p objects.x86_64-cc11-debug; \
mkdepend -ISource/ -Iobjects.x86_64-cc11-debug/ -p .cpp:objects.x86_64-cc11-debug/%n.o -m -f "objects.x86_64-cc11-debug/PreferencesWindow.d" Source/PreferencesWindow.cpp
mkdir -p objects.x86_64-cc11-debug; \
mkdepend -ISource/ -Iobjects.x86_64-cc11-debug/ -p .cpp:objects.x86_64-cc11-debug/%n.o -m -f "objects.x86_64-cc11-debug/MainWindow.d" Source/MainWindow.cpp
mkdir -p objects.x86_64-cc11-debug; \
mkdepend -ISource/ -Iobjects.x86_64-cc11-debug/ -p .cpp:objects.x86_64-cc11-debug/%n.o -m -f "objects.x86_64-cc11-debug/WSOpenMeteo.d" Source/WSOpenMeteo.cpp
mkdir -p objects.x86_64-cc11-debug; \
mkdepend -ISource/ -Iobjects.x86_64-cc11-debug/ -p .cpp:objects.x86_64-cc11-debug/%n.o -m -f "objects.x86_64-cc11-debug/LabelView.d" Source/LabelView.cpp
mkdir -p objects.x86_64-cc11-debug; \
mkdepend -ISource/ -Iobjects.x86_64-cc11-debug/ -p .cpp:objects.x86_64-cc11-debug/%n.o -m -f "objects.x86_64-cc11-debug/App.d" Source/App.cpp
g++ -c Source/App.cpp -iquote./ -iquoteSource/ -iquoteobjects.x86_64-cc11-debug/ -isystem/system/develop/headers/private/shared -isystem/system/develop/headers/private/interface -isystem/system/develop/headers/private/netservices -O0 -g -DLIBNETAPI_DEPRECATED -o "objects.x86_64-cc11-debug/App.o"
g++ -c Source/LabelView.cpp -iquote./ -iquoteSource/ -iquoteobjects.x86_64-cc11-debug/ -isystem/system/develop/headers/private/shared -isystem/system/develop/headers/private/interface -isystem/system/develop/headers/private/netservices -O0 -g -DLIBNETAPI_DEPRECATED -o "objects.x86_64-cc11-debug/LabelView.o"
g++ -c Source/WSOpenMeteo.cpp -iquote./ -iquoteSource/ -iquoteobjects.x86_64-cc11-debug/ -isystem/system/develop/headers/private/shared -isystem/system/develop/headers/private/interface -isystem/system/develop/headers/private/netservices -O0 -g -DLIBNETAPI_DEPRECATED -o "objects.x86_64-cc11-debug/WSOpenMeteo.o"
g++ -c Source/MainWindow.cpp -iquote./ -iquoteSource/ -iquoteobjects.x86_64-cc11-debug/ -isystem/system/develop/headers/private/shared -isystem/system/develop/headers/private/interface -isystem/system/develop/headers/private/netservices -O0 -g -DLIBNETAPI_DEPRECATED -o "objects.x86_64-cc11-debug/MainWindow.o"
g++ -c Source/PreferencesWindow.cpp -iquote./ -iquoteSource/ -iquoteobjects.x86_64-cc11-debug/ -isystem/system/develop/headers/private/shared -isystem/system/develop/headers/private/interface -isystem/system/develop/headers/private/netservices -O0 -g -DLIBNETAPI_DEPRECATED -o "objects.x86_64-cc11-debug/PreferencesWindow.o"
g++ -c Source/SelectionWindow.cpp -iquote./ -iquoteSource/ -iquoteobjects.x86_64-cc11-debug/ -isystem/system/develop/headers/private/shared -isystem/system/develop/headers/private/interface -isystem/system/develop/headers/private/netservices -O0 -g -DLIBNETAPI_DEPRECATED -o "objects.x86_64-cc11-debug/SelectionWindow.o"
g++ -c Source/ForecastDayView.cpp -iquote./ -iquoteSource/ -iquoteobjects.x86_64-cc11-debug/ -isystem/system/develop/headers/private/shared -isystem/system/develop/headers/private/interface -isystem/system/develop/headers/private/netservices -O0 -g -DLIBNETAPI_DEPRECATED -o "objects.x86_64-cc11-debug/ForecastDayView.o"
g++ -c Source/ForecastView.cpp -iquote./ -iquoteSource/ -iquoteobjects.x86_64-cc11-debug/ -isystem/system/develop/headers/private/shared -isystem/system/develop/headers/private/interface -isystem/system/develop/headers/private/netservices -O0 -g -DLIBNETAPI_DEPRECATED -o "objects.x86_64-cc11-debug/ForecastView.o"
g++ -c Source/ForecastDeskbarView.cpp -iquote./ -iquoteSource/ -iquoteobjects.x86_64-cc11-debug/ -isystem/system/develop/headers/private/shared -isystem/system/develop/headers/private/interface -isystem/system/develop/headers/private/netservices -O0 -g -DLIBNETAPI_DEPRECATED -o "objects.x86_64-cc11-debug/ForecastDeskbarView.o"
g++ -c Source/CitiesListSelectionWindow.cpp -iquote./ -iquoteSource/ -iquoteobjects.x86_64-cc11-debug/ -isystem/system/develop/headers/private/shared -isystem/system/develop/headers/private/interface -isystem/system/develop/headers/private/netservices -O0 -g -DLIBNETAPI_DEPRECATED -o "objects.x86_64-cc11-debug/CitiesListSelectionWindow.o"
g++ -c Source/Util.cpp -iquote./ -iquoteSource/ -iquoteobjects.x86_64-cc11-debug/ -isystem/system/develop/headers/private/shared -isystem/system/develop/headers/private/interface -isystem/system/develop/headers/private/netservices -O0 -g -DLIBNETAPI_DEPRECATED -o "objects.x86_64-cc11-debug/Util.o"
cat Source/Weather.rdef | cc -E -iquote./ -iquoteSource/ -iquoteobjects.x86_64-cc11-debug/ -isystem/system/develop/headers/private/shared -isystem/system/develop/headers/private/interface -isystem/system/develop/headers/private/netservices -O0 -g -DLIBNETAPI_DEPRECATED - | grep -av '^#' | rc -I Source/ -o "objects.x86_64-cc11-debug/Weather.rsrc" -
cc -o "objects.x86_64-cc11-debug/Weather" objects.x86_64-cc11-debug/App.o objects.x86_64-cc11-debug/LabelView.o objects.x86_64-cc11-debug/WSOpenMeteo.o objects.x86_64-cc11-debug/WSOpenMeteo.o objects.x86_64-cc11-debug/MainWindow.o objects.x86_64-cc11-debug/PreferencesWindow.o objects.x86_64-cc11-debug/SelectionWindow.o objects.x86_64-cc11-debug/ForecastDayView.o objects.x86_64-cc11-debug/ForecastView.o objects.x86_64-cc11-debug/ForecastDeskbarView.o objects.x86_64-cc11-debug/CitiesListSelectionWindow.o objects.x86_64-cc11-debug/Util.o -g -Xlinker -soname=_APP_ -LSource/ -Lobjects.x86_64-cc11-debug/ -lbe -lbnetapi -llocalestub -lshared -ltranslation -lstdc++ -lsupc++
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: objects.x86_64-cc11-debug/WSOpenMeteo.o: in function `WSOpenMeteo::WSOpenMeteo(BHandler*, RequestType)':
/boot/home/proj/Weather/Source/WSOpenMeteo.cpp:21: multiple definition of `WSOpenMeteo::WSOpenMeteo(BHandler*, RequestType)'; objects.x86_64-cc11-debug/WSOpenMeteo.o:/boot/home/proj/Weather/Source/WSOpenMeteo.cpp:21: first defined here
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: objects.x86_64-cc11-debug/WSOpenMeteo.o: in function `WSOpenMeteo::WSOpenMeteo(BHandler*, RequestType)':
/boot/home/proj/Weather/Source/WSOpenMeteo.cpp:21: multiple definition of `WSOpenMeteo::WSOpenMeteo(BHandler*, RequestType)'; objects.x86_64-cc11-debug/WSOpenMeteo.o:/boot/home/proj/Weather/Source/WSOpenMeteo.cpp:21: first defined here
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: objects.x86_64-cc11-debug/WSOpenMeteo.o: in function `WSOpenMeteo::~WSOpenMeteo()':
/boot/home/proj/Weather/Source/WSOpenMeteo.cpp:30: multiple definition of `WSOpenMeteo::~WSOpenMeteo()'; objects.x86_64-cc11-debug/WSOpenMeteo.o:/boot/home/proj/Weather/Source/WSOpenMeteo.cpp:30: first defined here
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: objects.x86_64-cc11-debug/WSOpenMeteo.o: in function `WSOpenMeteo::~WSOpenMeteo()':
/boot/home/proj/Weather/Source/WSOpenMeteo.cpp:30: multiple definition of `WSOpenMeteo::~WSOpenMeteo()'; objects.x86_64-cc11-debug/WSOpenMeteo.o:/boot/home/proj/Weather/Source/WSOpenMeteo.cpp:30: first defined here
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: objects.x86_64-cc11-debug/WSOpenMeteo.o: in function `WSOpenMeteo::~WSOpenMeteo()':
/boot/home/proj/Weather/Source/WSOpenMeteo.cpp:30: multiple definition of `WSOpenMeteo::~WSOpenMeteo()'; objects.x86_64-cc11-debug/WSOpenMeteo.o:/boot/home/proj/Weather/Source/WSOpenMeteo.cpp:30: first defined here
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: objects.x86_64-cc11-debug/WSOpenMeteo.o: in function `WSOpenMeteo::ResponseStarted(BUrlRequest*)':
/boot/home/proj/Weather/Source/WSOpenMeteo.cpp:37: multiple definition of `WSOpenMeteo::ResponseStarted(BUrlRequest*)'; objects.x86_64-cc11-debug/WSOpenMeteo.o:/boot/home/proj/Weather/Source/WSOpenMeteo.cpp:37: first defined here
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: objects.x86_64-cc11-debug/WSOpenMeteo.o: in function `WSOpenMeteo::DataReceived(BUrlRequest*, char const*, long, long)':
/boot/home/proj/Weather/Source/WSOpenMeteo.cpp:43: multiple definition of `WSOpenMeteo::DataReceived(BUrlRequest*, char const*, long, long)'; objects.x86_64-cc11-debug/WSOpenMeteo.o:/boot/home/proj/Weather/Source/WSOpenMeteo.cpp:43: first defined here
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: objects.x86_64-cc11-debug/WSOpenMeteo.o: in function `WSOpenMeteo::RequestCompleted(BUrlRequest*, bool)':
/boot/home/proj/Weather/Source/WSOpenMeteo.cpp:52: multiple definition of `WSOpenMeteo::RequestCompleted(BUrlRequest*, bool)'; objects.x86_64-cc11-debug/WSOpenMeteo.o:/boot/home/proj/Weather/Source/WSOpenMeteo.cpp:52: first defined here
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: objects.x86_64-cc11-debug/WSOpenMeteo.o: in function `WSOpenMeteo::_ProcessWeatherData(bool)':
/boot/home/proj/Weather/Source/WSOpenMeteo.cpp:81: multiple definition of `WSOpenMeteo::_ProcessWeatherData(bool)'; objects.x86_64-cc11-debug/WSOpenMeteo.o:/boot/home/proj/Weather/Source/WSOpenMeteo.cpp:81: first defined here
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: objects.x86_64-cc11-debug/WSOpenMeteo.o: in function `WSOpenMeteo::_ProcessCityData(bool)':
/boot/home/proj/Weather/Source/WSOpenMeteo.cpp:300: multiple definition of `WSOpenMeteo::_ProcessCityData(bool)'; objects.x86_64-cc11-debug/WSOpenMeteo.o:/boot/home/proj/Weather/Source/WSOpenMeteo.cpp:300: first defined here
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: objects.x86_64-cc11-debug/WSOpenMeteo.o: in function `std::string __gnu_cxx::__to_xstring<std::string, char>(int (*)(char*, unsigned long, char const*, __va_list_tag*), unsigned long, char const*, ...)':
/boot/home/proj/Weather/Source/WSOpenMeteo.cpp:62: multiple definition of `WSOpenMeteo::GetUrl(double, double)'; objects.x86_64-cc11-debug/WSOpenMeteo.o:/boot/home/proj/Weather/Source/WSOpenMeteo.cpp:62: first defined here
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: objects.x86_64-cc11-debug/WSOpenMeteo.o: in function `WSOpenMeteo::SerializeBMessage(BMessage*, BString)':
/boot/home/proj/Weather/Source/WSOpenMeteo.cpp:285: multiple definition of `WSOpenMeteo::SerializeBMessage(BMessage*, BString)'; objects.x86_64-cc11-debug/WSOpenMeteo.o:/boot/home/proj/Weather/Source/WSOpenMeteo.cpp:285: first defined here
collect2: error: ld returned 1 exit status
/boot/system/develop/etc/makefile-engine:249: recipe for target 'objects.x86_64-cc11-debug/Weather' failed
make: *** [objects.x86_64-cc11-debug/Weather] Error 1
Hey! I have just fixed and committed the makefile. Please try again now!
I have recently switched to Paladin as it speeds up my workflow but I have left something behind in the makefile. You may also find the Paladin project files if you find it convenient.
Thank you so much for trying it and providing feedback, much appreciated!
Hey, I don’t mind using paladin. The readme didn’t say anything about it : D
Did you push the commit?
Regards
Thanks!
Okay, some feedback.
- The name of the locality may be broken by elipsis (…); normally to avoid this I would resize the replicant by resizing the window bigger before it becomes a replicant, but the window is unresizable.
- Some localtions are hard to differenciate, for example if searching for “Berlin” There are 7 entries for “Berlin, United States” one for “Berlin, Germany”, one for “East Berlin, United States” and one for “Berlin, Russia”. In this example the one in Germany is fairly unambigious, but anyone living in a city called Berlin in the US would have a hard time figuring out which one is correct.
- The “Country” shouldn’t neccesarily be displayed in the desktop replicant, the city name is fine but the country is in most cases not needed for differenciation at all
- The search for cities window should probably add the list for cities to search below the entry, for easy editing of mistakes and such (and it is less visually noisy than a new window opening)
I hope this feedback helps a bit! As for the actuall functionality it seems to run nice, and the icons and such look great.
Edit: Switching from celsius to fahrenheit made it display “20°F” Instead of “20°C” for my location, probably not intended : D
2 Likes
Thank you, I value your input.
As said it’s WIP and there are a number of things to fix/improve especially since the overall architecture of the application was originally intended for a different API.
I have all your points in my to do list and thanks for the hint about resizing the BView.
The unit measure problem should have been fixed as of now. If I switch from °C to °F I get a new HTTP request triggered as this is now managed by Open Meteo API.
Would you mind sharing your location?
I used Berlin, Germany as an example. I don’t see any http requests when changing the temperature format for any of them. (I have netservices debug logging)
For the other temperature units it seems to recalculate them itself, that is the number values do change, but without any http request. (And this shouldn’t be neccesary I think, since these can be easily calculated with known formulas)
Edit: changing to °F and explicitly refreshing does not have any change in behaviour, still the same numbers as with Celsius
Correct, it’s not necessary but Open Meteo offers the possibility to request the forecast in a specific unit measure and also yields a HTTP response that brings the unit measure back to the caller.
By triggering a new request, chances are that the forecast has changed since the last request and you may get an update on the weather condition. IMHO, I personally experienced that and I have found it convenient.
I’ve checked and I can confirm that changing the unit measure calls the Reload() method of the ForecastView which in turn calls the API.
I also have positive feedback from @Andrea that changing the unit measure works like a charm. Nevertheless, I’ve just pushed a small change that could potentially prevent some edge cases. Please test it again when you have time.
Thanks!
Thanks for working on Weather!
Is changing units actually necessary? Why not just use the system’s locale setting?
I opened issue #79 about that.
1 Like
I can confirm that changing the temperatures units never triggers a network request on my machine, the temperature is displayed correctly afterwards. The only odd one out here is fahrenheit.
In any case, there is no reason to request this from the Api, this is even more fingerprintable data than the city already provides : ).
I can also confirm that, when fahrenheit is set, any subsequent requests don’t ask for fahrenheit at all. Here is an example for Berlin again:
GET /v1/forecast?latitude=52.524370&longitude=13.410530&daily=weathercode,temperature_2m_max,temperature_2m_min¤t_weather=true&timeformat=unixtime&timezone=Europe%2FBerlin HTTP/1.1
For this request also please don’t leak the users timezone : /
I’ll look into this problem, it looks like there is something wrong in the latest commits.
Re. the timezone is currently hardcoded to Berlin (which is my timezone as I live in Italy). It should be changed to the local timezone of the city I’m requesting the forecast of. It is necessary in order to take into account some edge cases. With the timezone parameter set, Open Meteo responds with timestamps as local-times, providing the correct forecast when the day changes (at midnight).
Any chance of adding weather data from yr.no?
https://developer.yr.no/doc/
And please have a look at this article in Norwegian: Yr.no brukes av lokalbefolkning over hele verden - Tu.no
Successfully built on hrev56238 x86_64!
4 Likes