bfabiszewski / ulogger-server

μlogger • web viewer for tracks uploaded with μlogger mobile client
GNU General Public License v3.0
522 stars 85 forks source link

Timestamps incorrect #160

Closed gnusupport closed 3 years ago

gnusupport commented 3 years ago

Hello,

I can see this error since quite some time. You can observe it below. Though the track names say they were made in 2021, the actual timestamp is in 2001. This has been obtained by downloading the GPX from the server. Now where is exactly the error, I do not know. Maybe the mobile application makes the error, maybe server, maybe download of GPX makes the error with timestamps.

<?xml version="1.0" encoding="UTF-8"?>
 <gpx xmlns="http://www.topografix.com/GPX/1/1" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://w
  <metadata>
   <name>Auto_2021.01.22_07.27.47</name>
   <time>2001-06-08T04:28:37Z</time>
  </metadata>
  <trk>
   <name>Auto_2021.01.22_07.27.47</name>
   <trkseg>
    <trkpt lat="2.59098908" lon="33.7561254">
     <ele>1130</ele>
     <time>2001-06-08T04:28:37Z</time>
     <name>1</name>
     <extensions>
bfabiszewski commented 3 years ago

Please export same track directly from mobile device and post here.

gnusupport commented 3 years ago

I have tried it, now I see that time is correctly recorded. But this is definitely not always. This is track that I did not yet finish.

Track directly from mobile device:

<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>

Auto_2021.03.12_07.54.06 Auto_2021.03.12_07.54.06 1203.0 1 77.0 gps 1198.0 2 Server export: ============== Auto_2021.03.12_07.54.06 Auto_2021.03.12_07.54.06 1203 1 0 0 77 gps Previous track that I finished recording has incorrect times: ============================================================= Auto_2021.03.09_14.09.21 Auto_2021.03.09_14.09.21 1124 1 0 0 55 gps Any other randomly exported track has incorrect times: ====================================================== Auto_2021.02.07_11.35.50 Auto_2021.02.07_11.35.50 1420 1 6.75 248.80000305176 14 gps 1416 2 0 0 18 gps 1424 3 I cannot find a track that I export that has not get 2001 in the name. Only latest one had the right times.
bfabiszewski commented 3 years ago

We still don't know if it happens on the client or on the server. Next time you encounter incorrect timestamps on server check the timestamps in client export.

This could be old GPS chipset rollover bug. Generally it shouldn't happen as I fixed it in version 3.3. Maybe the fix does not work in all cases? Was your last test track (with good timestamps) recorded on the same device as previous ones?

gnusupport commented 3 years ago

Last test track was recorded from same device, but now I am uploading from other devices, I used Motorola E and E LTE mobile phones. What I think is that I maybe did not update the software from F-Droid, and that after update it started working well.

Do you know formula to use to add time to incorrect times? Should I just add 20 years? I will experiment with it.

Please keep this issue open until I confirm that in new versions of µlogger I do not get this problem.

bfabiszewski commented 3 years ago

You must add exactly 1024 weeks. The problem was most probably not updated version of µlogger.

gnusupport commented 3 years ago

I have made some Emacs Lisp functions to add 1024 weeks, and to replace the line with it. Then it can be automated by using macro F4, F4, and there could be different other ways to replace it with sed for example or other tools.

You may close this issue as now I do not see problem taking place any more.

(defun rcd-sql-time-add-1024-weeks (timestamp) (let ((sql (format "SELECT '%s'::timestamp + interval '1024 weeks'" timestamp))) (rcd-sql-first sql cf)))

(defun rcd-gpx-replace-time () (interactive) (let ((line (thing-at-point 'line t)) (match (string-match " ((start (+ 6 (string-match "" line))) (when (and start end) (let* ((timestamp (substring line start end)) (new-time (rcd-sql-time-add-1024-weeks timestamp)) (first-part (substring line 0 start)) (last-part (substring line end (length line))) (new-string (string-trim (concat first-part new-time last-part)))) (beginning-of-line) (kill-line) (insert new-string)))))))