GPS Logging using GPSLogger and CouchDB
One of the valuable features of Google maps app is GPS logging. It keeps track of where you have been so you can take action if required later. I wanted an open-source, self-hosted version of that. There are a few options.
Table of Contents
Options
- μlogger by Avatar Bartek Fabiszewski . It includes an Android app and server component for location logging and sync. It comes with multi-user support, authentication, etc.
- OwnTracks is a set of tools, including Android, iOS, Protocol, and Server side App, making it easy to log locations. It's used to maintain a private location diary or share it with family and friends. It has an open protocol on both HTTP and MQTT.
- Overland By Aaron Parecki. It is a set of tools that includes an Android APP, an iOS app, and an HTTP Protocol/API for location sync. It uses the GeoJSON format. The protocol is open, and hence there are multiple server-side services written by the community. You can write on if required. And it can store the data while App is offline and send it to the server later in batches.
- GPSLogger by mendhak. It is an Android app and protocol which allows the user to log the GPS spots. And send them to predetermined files or HTTP endpoints. The protocol supports all kinds of gis file formats if you store them locally. It can also send it to a remote location using an open HTTP endpoint. It can store the data while App is offline and send it to server when you are back online.
Requirements
My choice was between Overland and GPSLogger—both look great and have all the features I need. I choose GPSLogger because of the open HTTP format. It works like a webhook; you can configure the endpoint, headers, payload, etc. Unlike Overland, where the payload is fixed.
It also has the bonus of storing the points locally as a file and sending them to HTTP endpoint; who doesn't like a backup?
Since I also plan to use it for mapping. It has a feature where I can set up preset annotations that I can send by just pressing a button. It goes as a regular point along with the annotation text.
I used CouchDB because CouchDB is HTTP/Web native. I can directly post from the App to CouchDB using standard rest APIs. Also, I have a running CouchDB.
Data
I create a new document in CouchDB for each point (POST). The JSON document looks like this
{
"_id": "bangalore-solo|1678571085",
"_rev": "1-737ffe46460e0b12e902763dc5af83a6",
"dt": "2023-03-11T21:44:45.000Z",
"lat": 10.532646798016538,
"lon": 76.20109005751452,
"acc": 4,
"alt": -75.88035197722026,
"desc": "",
"track": "bangalore-solo"
}
_id
: is unique and is made up of track name (FILENAME) and timestamp (TIMESTAMP). Together they make a point of uniquedesc
is the description of the point that the user has explicitly sent or is the annotation texttrack
is FILENAME. I create a new file every time I start logging in.- The rest of them are self-explanatory
- There are other variables too. But currently, I am not interested.
The App HTTP Body template looks like this
{
"_id":"%FILENAME|%TIMESTAMP",
"dt":"%TIME",
"lat":%LAT,
"lon":%LON,
"acc":%ACC,
"alt":%ALT,
"desc":"%DESC",
"track":"%FILENAME"
}
On CouchDB
- Assuming you already have CouchDB, create a new DB, call it gpslogging
- Your db url will be
{{couchdb_url}}/gpslogging
- Create a new user, gpslog_user and give a password
- Add the gpslog_user as a user and admin to the database gpslogging
On GPSLogger App
- Create a new profile
- Enable "Log to custom URL"
- URL: Your CouchDB database URL
- HTTP Body - Check the HTTP Body Template body discussed above
- HTTP Headers
- Content-Type: application/json
- HTTP Method
- POST
- Authentication - Basic Authentication
- Give CouchDB username and password
- Enable GPX or GeoJSON logging (as a backup)
- I also enable
- New file creation
- Ask for a file name on every start
- I use the file name as track name
I did a trial run of 1000 kms ( ~ 18 hours) involving walking, driving, multiple annotations, network off and on, and various combinations of these parameters. The App and syncing were rock solid.
My next step would be to take some actions based on annotations.
1 Response
[…] Previous Post GPS Logging using GPSLogger and CouchDB https://thejeshgn.com/2023/03/14/gps-logging-using-gpslogger-and-couchdb/ via @thej Posted on March 15, 2023 by @thej in […]