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. 

Options

  1. μ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. 
  2. 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. 
  3. 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.
  4. 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"
}
  1. _id : is unique and is made up of track name (FILENAME) and timestamp (TIMESTAMP). Together they make a point of unique
  2. desc is the description of the point that the user has explicitly sent or is the annotation text
  3. track is FILENAME. I create a new file every time I start logging in. 
  4. The rest of them are self-explanatory
  5. 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"
}
GpsLogger syncing to CouchDB

On CouchDB

  1. Assuming you already have CouchDB, create a new DB, call it gpslogging
  2. Your db url will be {{couchdb_url}}/gpslogging
  3. Create a new user, gpslog_user and give a password
  4. Add the gpslog_user as a user and admin to the database gpslogging

On GPSLogger App

  1. Create a new profile
  2. Enable "Log to custom URL"
    1. URL: Your CouchDB database URL
    2. HTTP Body - Check the HTTP Body Template body discussed above
    3. HTTP Headers
      1. Content-Type: application/json
    4. HTTP Method
      1. POST
    5. Authentication - Basic Authentication
    6. Give CouchDB username and password
  3. Enable GPX or GeoJSON logging (as a backup)
  4. I also enable
    1. New file creation
    2. Ask for a file name on every start
      1. 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.


You can read this blog using RSS Feed. But if you are the person who loves getting emails, then you can join my readers by signing up.

Join 2,241 other subscribers

1 Response

  1. March 15, 2023

    […] 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 […]