--- author: email: mail@petermolnar.net image: https://petermolnar.net/favicon.jpg name: Peter Molnar url: https://petermolnar.net copies: - http://web.archive.org/web/20180928133438/https://petermolnar.net/location-tracking-without-server/ lang: en published: '2018-09-27T11:05:00+01:00' summary: My pipeline of tracking where I've been using and Android phone, Backitude, python, and cron tags: - android title: GPS tracking without a server --- Nearly all self-hosted location tracking Android applications are based on server-client architecture: the one on the phone collects only a small points, if not only one, and sends it to a configured server. Traccar[^1], Owntracks[^2], etc. While this setup is useful, it doesn't fit in my static, unless it hurts[^3] approach, and it needs data connectivity, which can be tricky during abroad trips. The rare occasions in rural Scotland and Wales tought me data connectivity is not omnipresent at all. There used to be a magnificent little location tracker, which, besides the server-client approach, could store the location data in CSV and KML files locally: Backitude[^4]. The program is gone from Play store, I have no idea, why, but I have a copy of the last APK of it[^5]. My flow is the following: - Backitude saves the CSV files - Syncthing[^6] syncs the phone and the laptop - the laptop has a Python script that imports the CSV into SQLite to eliminate duplicates - the same script queries against Bing to get altitude information for missing altitudes - as a final step, the script exports daily GPX files - on the laptop, GpsPrune helps me visualize and measure trips ## Backitude configuration These are the modified setting properties: - Enable backitude: yes - Settings - Standard Mode Settings - Time Interval Selection: 1 minute - Location Polling Timeout: 5 minutes - Display update message: no - Wifi Mode Settings - Wi-Fi Mode Enabled: yes - Time Interval Options: 1 hour - Location Polling Timeout: 5 minutes - Update Settings - Minimum Change in Distance: 10 meters - Accuracy Settings - Minimum GPS accuracy: 12 meters - Minimum Wi-Fi accuracy: 20 meters - Internal Memory Storage Options - KML and CSV - Display Failure Notifications: no I have an exported preferences file available[^7]. ## Syncthing The syncthing configuration is optional; it could be simple done by manual transfers from the phone. It's also not the most simple thing to do, so I'll let the Syncting Documentation[^8] take care of describing the how-tos. ## Python script Before jumping to the script, there are 3 Python modules it needs: ``` {.bash} pip3 install --user arrow gpxpy requests ``` And the script itself - please replace the `INBASE`, `OUTBASE`, and `BINGKEY` properties. To get a Bing key, visit Bing[^9]. ``` {.python} import os import sqlite3 import csv import glob import arrow import re import gpxpy.gpx import requests INBASE="/path/to/your/syncthing/gps/files" OUTBASE="/path/for/sqlite/and/gpx/output" BINGKEY="get a bing maps key and insert it here" def parse(row): DATE = re.compile( r'^(?P[0-9]{4})-(?P[0-9]{2})-(?P[0-9]{2})T' r'(?P