aboutsummaryrefslogtreecommitdiffstats
path: root/core/gpslocation.cpp
AgeCommit message (Collapse)Author
2021-01-23mobile/debugging: copy GPS fixes to clipboardGravatar Dirk Hohndel
The goal is to enable a user experiencing crashes when applying GPS data to their dive log to make all necessary data available to the developers. Hopefully the clipboard is large enough to hold all the data. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-13mobile/GPS: fix two errors in the GPS handlingGravatar Dirk Hohndel
First, the time zone adjustment was wrong - this as written could only ever have worked in UTC or by pure chance. Second, the order of alerting the UI of the availability of a GPS fix was also incorrect creating a race between the UI and our data structures. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-02mobile: turn GpsLocation into a regular singleton constructGravatar Dirk Hohndel
Simply move the initialization of the logging function into its own method and call that in the QMLManager constructor. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-09-29gps: remove unused member functionGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-07-11mobile/location-service: stop using broken adjustment functionGravatar Dirk Hohndel
gettimezoneoffset() returns incorrect values when called with a time_t. Since we only accept the value here if it is within 5 minutes of 'now', using the current timezone offset is a fair approximation. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-07-11mobile/location-service: fix timezone issue in GPS timestampsGravatar Dirk Hohndel
For some reason we suddenly started logging the GPS fixes in UTC instead of local time. Which caused the matching algorithm to fail (unless you happened to be diving in UTC). Unclear what broke this, but this seems like an easy enough fix, since the GPS fix being reported is by definition "right around now". So using gettimezoneoffset() with the current time seems "good enough". I don't know when gettimezoneoffset() with an argument got broken, TBH. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-22cleanup: create common QDateTime -> timestamp conversion functionGravatar Berthold Stoeger
In analogy to the timestamp -> QDateTime conversion, create a common function. 1) For symmetry with the opposite conversion. 2) To remove numerous inconsistencies. 3) To remove use of the deprecated QDateTime::toTime_t() function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-22cleanup: move timestampToDateTime() to qthelper.cppGravatar Berthold Stoeger
Move this function from maintab.cpp to qthelper.cpp. Since the functionality was used in numerous places, use the helper function there as well. This removes a number of inconsistencies. For example, sometime setTimeSpec(Qt::UTC) was called, even though the QDateTime object was already created with that time spec. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01cleanup: move dive_table from dive.h to divelist.hGravatar Berthold Stoeger
This allows us to decouple dive.h and divelist.h, a small step in include disentangling. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-19cleanup: remove unnecessary includeGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-09mobile: use undo-command to apply gps fixesGravatar Berthold Stoeger
The goal is to send the signal for the correct dives / divesites and thus not having to reload the whole model. Right now the mobile UI does not yet catch the diveSiteChanged signals. [Dirk Hohndel: small fix to ensure that we trigger a save to storage] Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09GPS fixes: split collecting GPS fixes into own functionGravatar Berthold Stoeger
This finishes the spliting of the GPS fix application: One function for collecting the fixes, one for application. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-09cleanup: use QStringLiterals in core/gpslocation.cppGravatar Berthold Stoeger
Not that this would make any noticeable difference, but out of principle, let's use Qt's string-literal macro for string-literals. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-09GPS fixes: collect fixes first, apply laterGravatar Berthold Stoeger
Make the application of the GPS fixes in two runs: first collect dives and fixes, then apply the fixes. This will simplify turning the application of GPS fixes into an undo-command. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-13mobile/gps: make sure updated GPS data are savedGravatar Dirk Hohndel
If we change the gps location of a dive that didn't have a dive site associated before (which is the normal case when a dive was just downloaded from a dive computer), a new dive site is created with that GPS fix and added to the dive. We need to mark that dive as changed in order for the changes to be saved to storage. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-26Mobile: provide better tracking of applied GPS fixesGravatar Dirk Hohndel
Also reset the page stack to make sure we don't end up with stale data. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-02Avoid duplicate debug output from GPS moduleGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-27Revert the singleton PRGravatar Dirk Hohndel
It turns out that this isn't working the way it was intended to. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-25Cleanup: remove GpsLocation::instance() functionGravatar Berthold Stoeger
The last user was removed in 8576edd8d611f06fcbd452d88bbc3d46c39d1b9f. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-25Cleanup: remove GpsLocation::hasInstance()Gravatar Berthold Stoeger
This function was not used anywhere. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08Cleanup: move error reporting function declarations to errorhelper.hGravatar Berthold Stoeger
Move the declarations of the "report_error()" and "set_error_cb()" functions and the "verbose" variable to errorhelper.h. Thus, error-reporting translation units don't have to import the big dive.h header file. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18Cleanup: remove includes from qthelper.hGravatar Berthold Stoeger
To reduce interdependencies, remove the dive.h and divelist.h includes in qthelper.h Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: add dive site ref-countingGravatar Berthold Stoeger
Instead of setting dive->dive_site directly, call the add_dive_to_dive_site() and unregister_dive_from_dive_site() functions. In the parser this turned out to be a bit tricky. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive sites: prepare for dive site ref-countingGravatar Berthold Stoeger
Add a dive site table to each dive site to keep track of dives that have been added to a dive site. Add two functions to add dives to / remove dives from dive sites. Since dive sites now contain a dive table, the order of includes had to be changed: "divesite.h" now includes "dive.h" and not vice-versa. This caused some include churn. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: set UUID only on save or loadGravatar Berthold Stoeger
Since the UUID will be overwritten on save and is only used on save and load, set it only on save or load. For other created dive sites, leave the UUID field uninitialized. This means that the UUID will change between saves. Let's see how the git saver handles that. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: add dive site table parameter to dive site functionsGravatar Berthold Stoeger
To enable undo of dive site functions, it is crucial to work with different dive site tables. Therefore add a dive site table parameter to dive site functions. For now, always pass the global dive site table. Thus, this commit shouldn't alter any functionality. After this change, a simple search for dive_site_table reveals all places where the global dive site table is accessed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-03-27Cleanup: provide printGPSCoords in C and C++ versionsGravatar Berthold Stoeger
printGPSCoords() returned a newly allocated C-style string. Most callers simply made a QString out of it and freed the C-style string. This is paradoxical, as printGPSCoords internally works with QStrings and converts them to C-style on return. Therefore, let printGPSCoords() return a QString and create a printGPSCoordsC() wrapper for the two C-callers. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-03-24Cleanup: fix printGPSCoords signature and leaksGravatar Berthold Stoeger
The printGPSCoords() function returns a copied C-style string. Since the owndership is transferred to the caller, the correct return type is "char *" instead of "const char *". Thus a number of casts when calling free can be removed. Moreover a number of callers didn't free the string and thus were leaking memory. Fix them. Ultimately we might want two versions of the function: one for QString, one for C-style strings. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-29Dive site: replace dive->dive_site_uuid by dive_siteGravatar Berthold Stoeger
Replace the UUID reference of struct dive by a pointer to dive_site. This commit is rather large in lines, but nevertheless quite simple since most of the UUID->pointer work was done in previous commits. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-29Dive site: return pointer to dive_site in create_dive_site_*()Gravatar Berthold Stoeger
This changes more of the dive-site interface to return pointers instead of UUIDs. Currently, most call sites directly extract UUIDs afterwards. Ultimately, the UUIDs will be generally replaced by pointers, which will then simplify these callers. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-21Add 'location_t' data structureGravatar Linus Torvalds
Instead of having people treat latitude and longitude as separate things, just add a 'location_t' data structure that contains both. Almost all cases want to always act on them together. This is really just prep-work for adding a few more locations that we track: I want to add a entry/exit location to each dive (independent of the dive site) because of how the Garmin Descent gives us the information (and hopefully, some day, other dive computers too). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-09-24cleanup: remove more GPS webservice codeGravatar Jan Mulder
And remove some includes and defines that are not used any more after removal of the GPS webservice code. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-24core: fix connect callGravatar Jan Mulder
Fix multiple run-time errors in connect call introduced in 504e9125126. 1) Set the proper signature of the signal. 2) make the used slot a real slot (so move it to the proper section in the header) and 3) set the proper signature for the slot. Highly unlikely that normal users notice the runtime errors and possibly unwantend behavior, as this all deals with the subtile GPS service update threshold. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-12core: connect qPref..::time_thresholdChanged to setGpsTimeThresholdGravatar jan Iversen
Automate calling of setGpsTimeThreshold when qPref..::time_threshold changes and thus avoiding the need to call setGpsTimeThreshold directly. Signed-off-by: Jan Iversen <jani@apache.org>
2018-09-11cleanup[4/6], mobile: remove superfluous code from gpslocationGravatar Jan Mulder
Despite the fast that this code is sitting in core, its used mainly from mobile. In 987e221f8e6b7b, the buttons to interact with the GPS webservice were deleted from the UI. Now, delete all the code that was used under these buttons. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-06-04Cleanup: fold core/helpers.h into core/qthelper.hGravatar Berthold Stoeger
helpers.h included qthelper.h and all functions declared in helpers.h were defined in qthelper.h. Therefore fold the former into the latter, since the split seems completely arbitrary. While doing so, change the return-type of get_dc_nichname from "const QString" to "QString". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-21core: Change Q_UNUSED to no parameter nameGravatar jan Iversen
C++ permits use of parameters without name, which signals unused Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-14Core: remove dive.h from files that don't need itGravatar Dirk Hohndel
Of course, quite a few of them indirectly get it through other header files. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-15Qt: don't use member function that requires Qt 5.8Gravatar Dirk Hohndel
This should have been caught by our build check, but it turns out that that one isn't correctly reflected in its Travis status. Oops. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-14GPS: untangle the timestamp comparisonGravatar Dirk Hohndel
And calculate the correct time since last fix. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-14GPS: add signal to show that a new fix has been acquiredGravatar Dirk Hohndel
This way if we don't have a current enough position we can wait for a current fix to be acquired. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-14QML UI: better debug messages for getting current locationGravatar Dirk Hohndel
Also, show GPS refresh interval in seconds; it's confusing if this is reported in ms. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-03-14Cleanup: consistently use toUtf8() instead of toLocal8Bit()Gravatar Berthold Stoeger
These do the same, since the text-codex is set to UTF-8 on startup. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10GpsLocation::clearGpsData() is only used in SUBSURFACE_MOBILEGravatar Jan Mulder
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-25Use correct date formatGravatar Jan Mulder
A very very trival fix, for a mysterious issue. When loading GPS fix data from the server, the string date was parsed with the format "yyy-M-d". And no, the "yyy" is no typo here, but was the reason that data from the read from server got a 1/1/1970 data. And when a user decided to upload that data to the server again, we ended up with 2 copies of the GPS fix. One with correct data (as originally saved), and one new with the bogus date. In order to het rid of those weird 1/1/1970 GPS fixes, users will have to remove them by hand. Fixes: #567 Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-21Make QMap<> access in deleteGpsFix() more idiomaticGravatar Berthold Stoeger
To access a QMap<> entry, the value() function is used with a sentinel as default value. If the sentinel is returned, the code assumes that the searched for entry doesn't exist. Make this code more idiomatic by using an iterator and testing for end(). This fixes a compiler warning, because only one of the elements of the sentinel was initialized, but the remaining elements were copied. Harmless, because the code would exit early if it found the sentinel. Still not nice. While redoing this function, the entry-not-found message was improved (adding of function name, space between massage and timestamp) and elevated from debug to warning level. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-13applying gps fixes: group repetitive code under a macroGravatar Jan Mulder
See 2182167b533b4c. Keep the dupicated code in sync. Originally-by: Salvador Cuñat <salvador.cunat@gmail.com> Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-13Do not prefer gps fixes just for being into dive timeGravatar Jan Mulder
See commit 6f42ab46da1b5956. Unfortunately, this code is duplicated (and an obvious candidate for code cleanup). So replicate the mentioned commit here. In fact, the mentioned issue #666 talkes about the mobile app, and the fix was only done for the desktop. Originally-by: Salvador Cuñat <salvador.cunat@gmail.com> Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-10-09Use lrint() for all degrees_t related roundingGravatar Lubomir I. Ivanov
In certain places the '(int)' cast is used, while in other the llrint() or lrint() functions. Make the conversation from degrees in the 'double' form to the 'int' degrees_t consistent using lrint(). lrint() is the function which should give the best results, because it accepts a 'double' and results in a 'long' even if degrees_t is 'int'. If the truncation from 'long' to 'int' is discarding some of the precision then the next step would be to turn degrees_t into a 64bit signed integer type. Possible fix for #625. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-10-01Use helper function dive_endtime() where apropriateGravatar Stefan Fuchs
Calculating dive.when + dive.duration doesn't always give the correct endtime of a dive especially when a dive has surface interval(s) in the middle. Using the helper function dive_endtime() fixes this issue. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>