Record locations of walk/run tracks
This commit is contained in:
parent
bd2cef2768
commit
d4dd016038
74
init.org
74
init.org
|
@ -2417,31 +2417,55 @@ What if...
|
|||
(defun my-chronometrist-copy-exercise-data ()
|
||||
"Add exercise data from OsmAnd tracks to Chronometrist."
|
||||
(interactive)
|
||||
(if-let* ((date-iso (read-string "Date (ISO-8601): " (format-time-string "%F")))
|
||||
(date (parse-iso8601-time-string date-iso))
|
||||
(dir (concat "/media/data/phone/contrapunctus/Nokia 6.1/Android/data/net.osmand.plus/files/tracks/rec/"
|
||||
(format-time-string "%+4Y-%m/" date)))
|
||||
(dir-check (file-exists-p dir))
|
||||
(plists (cl-loop with activity
|
||||
for file in (directory-files dir)
|
||||
when (and (string-match-p (format-time-string "^%F_" date)
|
||||
file)
|
||||
(or (and (string-match-p "(walk)" file)
|
||||
(setq activity :walking))
|
||||
(and (string-match-p "(run)" file)
|
||||
(setq activity :running))))
|
||||
collect
|
||||
(with-current-buffer
|
||||
(get-buffer-create
|
||||
(find-file-noselect (concat dir file)))
|
||||
(append '(:name "Exercise")
|
||||
`(,activity (,(floor (my-gpx-distance file)) . "meters"))
|
||||
(my-get-gpx-timestamps))
|
||||
;; (chronometrist-insert (chronometrist-active-backend))
|
||||
)))
|
||||
(string (mapconcat (lambda (plist)
|
||||
(chronometrist-plist-pp plist))
|
||||
plists "\n")))
|
||||
;; Date for which to get data
|
||||
(if-let*
|
||||
((date-iso (read-string "Date (ISO-8601): " (format-time-string "%F")))
|
||||
(date (parse-iso8601-time-string date-iso))
|
||||
(dir (concat
|
||||
"/media/data/phone/contrapunctus/"
|
||||
"Nokia 6.1/Android/data/net.osmand.plus/files/tracks/rec/"
|
||||
(format-time-string "%+4Y-%m/" date)))
|
||||
(dir-check (file-exists-p dir))
|
||||
(plists (cl-loop with activity
|
||||
for file in (directory-files dir)
|
||||
when (and (string-match-p (format-time-string "^%F_" date)
|
||||
file)
|
||||
(or (and (string-match-p "(walk)" file)
|
||||
(setq activity :walking))
|
||||
(and (string-match-p "(run)" file)
|
||||
(setq activity :running))))
|
||||
collect
|
||||
(-let* ((file-name file)
|
||||
((from to)
|
||||
(progn
|
||||
(string-match
|
||||
(rx (group (+? num) "-" (= 2 num) "-" (= 2 num)
|
||||
"_" (= 2 num) "-" (= 2 num)
|
||||
"_" (= 3 (any alpha)))
|
||||
" "
|
||||
(group "(" (or "walk" "run") ")")
|
||||
" "
|
||||
(group (+? (any printing)))
|
||||
(group "\.gpx"))
|
||||
file-name)
|
||||
(split-string
|
||||
(match-string 3 file-name) " - "))))
|
||||
(with-current-buffer
|
||||
(get-buffer-create
|
||||
(find-file-noselect (concat dir file)))
|
||||
(append '(:name "Exercise")
|
||||
(list activity
|
||||
(cons (floor (my-gpx-distance file))
|
||||
"meters"))
|
||||
(if to
|
||||
(list :from from :to to)
|
||||
(list :location from))
|
||||
(my-get-gpx-timestamps))
|
||||
;; (chronometrist-insert (chronometrist-active-backend))
|
||||
))))
|
||||
(string (mapconcat (lambda (plist)
|
||||
(chronometrist-plist-pp plist))
|
||||
plists "\n")))
|
||||
(progn (kill-new string)
|
||||
(message "Copied %s to kill ring" string))
|
||||
(message "No suitable GPX files found")))
|
||||
|
|
Loading…
Reference in New Issue