-
Notifications
You must be signed in to change notification settings - Fork 25
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
user-defined weather data sources #86
Comments
I had a look on the conversation in #85 and would like to share my ideas. In my opinion, a good starting point would be the decomposition of the hard-coded URL in The query URL should be made into a template, in the long term. Template processors could then assemble the actual URL from the given data. In case that the provided information is insufficient, a missing API key, for instance, the current API should be the fallback solution in order to avoid the application breaking on an incorrectly configured API. The application should furthermore generate a warning message that the respective configuration is incorrect and, if possible, which fields are affected. |
Great! I guess the most challenging part will be that the data structures of the API responses differ. We will need a standardized struct which holds all the required fields for the rendered elements. |
A trait might be an option, as well. Instead of defining one monolithic super struct for all responses, there might be one struct per API response with each of these specialised structs implementing a special trait, let us name it The trait-based design would simplify the maintenance, in my opinion. If a new API is supported, it only needs to implement the already existing trait. With the monolithic super struct, major adjustments would be required if new fields become available due to the new API. The only thing I am rather unsure about is the performance; the super struct might have the better performance for few supported APIs but I assume that the more APIs are supported, the trait approach would amortise. There should be benchmarks for both approaches in an early step. If flexibility is more important than performance -- even in the long term --, we should directly focus on the trait approach. |
I am experimenting with such a trait approach for a file IO project, at the moment, thus, I mentioned the performance aspect. I made the read data implement such a trait for easier processing and uniform write-back afterwards. The key point for performance is that the read data might be either a For a text editor I previously contributed to, there was a related discussion on how to optimise the saving of the currently edited buffer if a certain post-processing shall be performed. Benchmark tests had shown that my suggested solution involving expensive type conversions between the text buffer types took about twice the time the recent procedure required. For the IO project, I do not assume to have too large input files in the average case, so I can focus on the functionality and try to enhance the performance afterwards. Furthermore, for the API responses, most fields can be expected to not differ too much in their representation such that type conversions should not be (too) critical. But still, type conversions could be required, after all, and we need to take into account that the compiler would include further instructions to detect the actual type of the given data at runtime. Both could become a bottleneck. |
Sorry for taking so long to come back to this. I must have unknowingly marked the notification as solved as I didn't notice your last two replies. A trait approach could be the optimal solution to this problem. Thanks for your work! If you have any new insights, please feel free to share them or submit a draft that we can work with :) |
Okay, I will prepare a draft with some initial suggestions. 👍 |
I am sorry, for some reasons, the forking does not work, at the moment. I will retry later. |
Okay, the forking worked, so far, now. |
Hey @kevinmatthes, Sorry for taking a few days. Thanks again for the recent PRs! I think we can continue the enhancement of the weather API in this issue 🙂. Struct fields that are not used to display wthrr's forecasts are removed in #105. What is left in Fields in the Currently, data keeps it's open-meteos API response structure throughout the app. It could clear things up to organize the data based on wthrrs displayed output if we add more API providers. But there would be our "super structs" I guess. I'll check other API providers to see how things can be better documented and structured on my end and will leave an update here. Any input is welcome 👍 |
Looked into openweathermap.org/forecast5. It's available with a free api key after registration. It provides all necessary data for 5 days.
|
Sorry for the late reaction, it has been a busy week. A basic option we have is to try converting any other API's data into an Open Meteo instance using the From / TryFrom traits. That way, we can pass API response data of any API to functions and methods expecting Open Meteo data by appending a call to Due to the differences you outlined, a conversion based on the received data might be difficult, however. Do you see any options to grab the data from somewhere else, @tobealive? |
Okay, grabbing the missing data from other APIs is not required in this case. In general, we should consider this possibility for further APIs where we cannot avoid doing so. The |
Yes, we should keep that in mind. Personally, I wouldn't take too many steps towards supporting potential cases until one of them emerges. Very nice! There probably will be some pitfalls but I'm exited how they will be solved 😊! |
Originally posted in #85
The text was updated successfully, but these errors were encountered: