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
Initial alpha of Skysight weather integration #182
Conversation
XCSoar developers are welcome to contact me (matthew .(at). skysight.io) if you need a SkySight account to work on or with this integration. |
Before we even begin: please note that linking XCSoar with OpenSSL is illegal, because the OpenSSL license is incompatible with the GPL. This means that you can be sued for copyright violation for distributing your build: http://jfwhome.com/XCSoar-debug.apk - please take it down quickly! Now if you really enable CURL's https features, please make that a separate commit. (And of course, choose a TLS library which is compatible with the GPL.) The OpenSSL/GPL situation is very unfortunate, but that's what it is, and we need to obey copyright law and licenses. Keep your branch rebased on the official master branch. Do not merge! No "Merge remote-tracking branch 'upstream/master'" commits! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start for this PR, but there are many many quirks and problems. I've left you a whole bunch of comments in the first round, for things that seemed obvious to me.
|
||
uint64_t elapsed = BrokenDateTime::NowUTC().ToUnixTimeUTC() - m.mtime; | ||
|
||
second_row.Format(_("Data from %04u/%02u/%02u %02u:%02u to %04u/%02u/%02u %02u:%02u. Updated %s ago"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't roll your own date formatter.
|
||
SkysightActiveMetric a = skysight->GetActiveMetric(index); | ||
if(!skysight->DownloadActiveMetric(a.metric->id)) | ||
ShowMessageBox(_("Couldn't update data."), _("Update Error"), MB_OK); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use C++ exceptions to propagate error details and show them here?
std::map<tstring, tstring> GetRegions() { | ||
return api.regions; | ||
} | ||
tstring GetRegion() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allocates a std::string
copy for no reason. Please keep the bloat in your code smaller!
bool MetricExists(const tstring id) { | ||
return api.MetricExists(id); | ||
} | ||
int NumMetrics() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this a signed integer?
Timer::Cancel(); | ||
} | ||
|
||
SkysightMetric SkysightAPI::GetMetric(int index) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this a signed integer?
|
||
|
||
int SkysightAPI::NumMetrics() { | ||
return (int)metrics.size(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why cast to signed?
|
||
struct BrokenDateTime; | ||
|
||
class SkysightAPI final : public Timer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this class? What is a SkysightAPI?
Thanks. I'll hive off the Android changes into a separate commit for now, assuming that most people can build/test on machines that have curl libraries with SSL support. Shame about OpenSSL (it looks like https support was removed from the codebase and I had wondered why). I must admit I had tried LibreSSL as getitng openSSL to compile was a bit of a pain. No luck. It looks like there are a few options: OpenSSL 3.0 (unstable), LibreSSL, BoringSSL and GnuTLS. I'll probably try them in reverse order, unless anyone has any experience or preferences that suggest otherwise. Thanks very much for the additional comments and pointers. |
Since both LibreSSL and BoringSSL are OpenSSL forks (IIRC), I think they share the licensing problem. |
The next major version of OpenSSL 3.0 is supposed to be released under the Apache 2.0 license which is compatible with the GPL.
However I did not find any hint when this version is going to be released. I would not hold my breath while waiting on it.
|
Thanks. It does seem a bit early to use v3. I'm trying to get GnuTLS to compile. It depends on Nettle which in turn needs GMP. I can get GnuTLS and Nettle (without GMP) to compile using libs.py/Automake, but I can't (yet) get GMP to pass the "configure" step as it fails on various compiler tests. Looks like it might be messy. |
What are the error messages? GMP is a prerequisite for compiling GCC. I don't care to remember how often I configured and compiled GMP over that course. You may send me a message directly. |
I've got a working compile with WolfSSL replacing openSSL. Sorry for the force-push mess. The code is not ready for review yet -- I have more changes to make, and to clean up the commits. Hopefully within the next couple of weeks. |
So I got this to compile on Debian stable. The following changes where necessary for the UNIX target on Debian: apt install libnetcdf-dev libnetcdf-c++4-dev diff --git a/src/Weather/Skysight/CDFDecoder.cpp b/src/Weather/Skysight/CDFDecoder.cpp -#include <geotiffio.h> The files where not found in the search path as they are indeed in the subdirectory on debian. I'm not sure how one does this correctly. diff --git a/build/netcdf.mk b/build/netcdf.mk For some reason the hdf5_hl library ends with _cpp in debian. |
Thanks so much for testing! I'm not sure about the correct approach for the first issue, but for the second, I know that my NETCDF_LDLIBS lines that manually specifies the packages are temporary kludges. The pkg_config line above it should be doing the trick (I'm not sure what else needs to be done to make it so!) |
So I'm still working on compiling the android version. Since the netcdf library is not in the toolchain, I think it needs to be added to the thirdparty.mk in the build directory. But I haven't yet managed to compile it. |
Any progress on the implementation? :) |
No progress, closing for now |
closes XCSoar#222 original implementation by jfwells in XCSoar#182
closes XCSoar#222 original implementation by jfwells in XCSoar#182
This is almost identical to the code submitted in XCSoar#182. The following was changed: - no changes to thirdparty builds - remove dead includes that made the build fail
closes XCSoar#222 original implementation by jfwells in XCSoar#182
This is almost identical to the code submitted in XCSoar#182. The following was changed: - no changes to thirdparty builds - remove dead includes that made the build fail
This is almost identical to the code submitted in XCSoar#182. The following was changed: - no changes to thirdparty builds - remove dead includes that made the build fail
This is almost identical to the code submitted in XCSoar#182. The following was changed: - no changes to thirdparty builds - remove dead includes that made the build fail
This is almost identical to the code submitted in XCSoar#182. The following was changed: - no changes to thirdparty builds - remove dead includes that made the build fail
This is almost identical to the code submitted in XCSoar#182. The following was changed: - no changes to thirdparty builds - remove dead includes that made the build fail
This is almost identical to the code submitted in XCSoar#182. The following was changed: - no changes to thirdparty builds - remove dead includes that made the build fail
This is almost identical to the code submitted in XCSoar#182. The following was changed: - no changes to thirdparty builds - remove dead includes that made the build fail
This is almost identical to the code submitted in XCSoar#182. The following was changed: - no changes to thirdparty builds - remove dead includes that made the build fail
This is almost identical to the code submitted by jfwells in XCSoar#182. The following was changed: - no changes to thirdparty builds - remove dead includes that made the build fail Further code refactoring: - Change queues to std::queue - Implement API requests as deque - Remove rvalues in SkysightCallback - Skysight/Metrics: timestamps as unsigned - Rename metric to layer for consistency - Use auto for iterator types - SkysightImageFile: remove redundant filepath - Remove SkysightImageFile - Remove LoadFromFile - Include geotiff in CDFDecoder compilation - Change datatype of displayed layer to unsigned - Remove timer inheritance - Refactored DownloadStandbyLayer and removed SetStandbyLayerUpdateState - Use new ResponseHandler implementation - CDFDecoder: Allocate arrays on heap
This is almost identical to the code submitted by jfwells in XCSoar#182. The following was changed: - no changes to thirdparty builds - remove dead includes that made the build fail Further code refactoring: - Change queues to std::queue - Implement API requests as deque - Remove rvalues in SkysightCallback - Skysight/Metrics: timestamps as unsigned - Rename metric to layer for consistency - Use auto for iterator types - SkysightImageFile: remove redundant filepath - Remove SkysightImageFile - Remove LoadFromFile - Include geotiff in CDFDecoder compilation - Change datatype of displayed layer to unsigned - Remove timer inheritance - Refactored DownloadStandbyLayer and removed SetStandbyLayerUpdateState - Use new ResponseHandler implementation - CDFDecoder: Allocate arrays on heap - CDFDecoder: Remove duplicate code
This is almost identical to the code submitted by jfwells in XCSoar#182. The following was changed: - no changes to thirdparty builds - remove dead includes that made the build fail Further code refactoring: - Change queues to std::queue - Implement API requests as deque - Remove rvalues in SkysightCallback - Skysight/Metrics: timestamps as unsigned - Rename metric to layer for consistency - Use auto for iterator types - SkysightImageFile: remove redundant filepath - Remove SkysightImageFile - Remove LoadFromFile - Include geotiff in CDFDecoder compilation - Change datatype of displayed layer to unsigned - Remove timer inheritance - Refactored DownloadStandbyLayer and removed SetStandbyLayerUpdateState - Use new ResponseHandler implementation - CDFDecoder: Allocate arrays on heap
This is almost identical to the code submitted by jfwells in XCSoar#182. The following was changed: - no changes to thirdparty builds - remove dead includes that made the build fail Further code refactoring: - Change queues to std::queue - Implement API requests as deque - Remove rvalues in SkysightCallback - Skysight/Metrics: timestamps as unsigned - Rename metric to layer for consistency - Use auto for iterator types - SkysightImageFile: remove redundant filepath - Remove SkysightImageFile - Remove LoadFromFile - Include geotiff in CDFDecoder compilation - Change datatype of displayed layer to unsigned - Remove timer inheritance - Refactored DownloadStandbyLayer and removed SetStandbyLayerUpdateState - Use new ResponseHandler implementation - CDFDecoder: Allocate arrays on heap
Hi, this is still work in progress and not yet ready to pull, but would appreciate some feedback and advice at this stage. Let me know if there's a better place for this.
In particular, but not limited to:
I have had to make some kludges in order to get the additional libraries to build for Android (curl with SSL support, and netcdf4 and C++ bindings). For example:
I use the main "render" loop to trigger updates in Skysight (should the forecast data be updated, should the overlay be advanced). I've copied the approach used by the RASP implementation here. I'm not clear if this is the right approach, or if a timer would be better here. One particular problem is that on the ground, the initial overlay is not displayed until a render is triggered, which can be some time if GPS is not yet connected. On the flip side, when in flight, or if the map is being manipulated, the render loop gets called far more frequently than is necessary for my needs. Data downloads in background threads, but as these cannot access the map safely I need an asynchronous trigger from the main thread somewhere.
The overlays in Android and Unix are pretty much identical, but they display quite differently. The images are fairly low-res, but when zoomed seem to be interpolated nicely on Unix. On Android they just show as larger, blocky pixels. Screenshot comparison on the forum. Any points as to why this might be would be much appreciated.
There are other stylistic issues to fix (not happy with the Metric/ActiveMetric/DisplayedMetric model, and I have an over-reliance on unneeded std::strings for a start). I also need to add documentaion, but I will fix those in the next round.
Note that this requires netcdf4 and netcdfcxx4 (development) libraries to compile. On Arch these are netcdf and netcdf-cxx.
Instructions for using the implementation are here: https://forum.xcsoar.org/viewtopic.php?f=7&t=3227&p=19689#p19689
Thanks in advance for any help/advice/review.