Logo preload
close Logo

GPSLogger for Android

August 18, 2015

Fulcrum users often inquire if and when the Fulcrum mobile apps might support GPS tracklog functionality. We are focusing all our energy into building the best platform for structured data collection, and as such, this feature is currently fairly low on the priority list. One of the reasons we have not prioritized this is due to the fact that there are several excellent solutions already available for handling this.

If you need a feature packed app for creating GPS tracks, we highly recommend checking out the Locus Map app for Android. Coleman wrote an excellent review of this app back in May and it continues to impress with every new release. While Locus is a powerful “utility belt” mapping app, it does have a bit of a learning curve that may turn off more casual users.

Lightweight, Battery Efficient GPS Logger

GPSLogger

If you simply need to log a GPS “breadcrumb trail” to record the locations of your team as they are out collecting data in the field, I recommend taking a look at GPSLogger for Android. This is a freely available, actively maintained open source app with powerful functionality and a user friendly interface.

GPSLogger for Android bills itself as “A lightweight, battery efficient GPS Logger”, which is exactly what it is. This app will log your GPS data at specified intervals locally on your device, with the ability to auto upload to various web services or log to a custom URL. Unlike many of the popular activity tracking apps, which are designed for short periods of active use, GPSLogger is designed to run in the background for longer durations without draining your battery.

GPSLogger Features

  • Writes to several standard geospatial file formats, including GPX, KML, and CSV.
  • Logs location, timestamp, speed, direction and altitude if available.
  • Optionally start logging on phone boot.
  • Automatically upload or email the log files at set intervals to destinations such as Email, FTP, Dropbox, Google Docs, and OpenStreetMap.
  • Can log data to a custom URL as it is recorded.
  • Selectively choose network, gps and passive location providers.
  • Configurable filters for granular control over location quality.
GPSLogger Filters

Configurable Filters

GPSLogger allows you to configure several quality settings via the “Performance” menu. These settings include:

  • Limiting which location providers you want to use (GPS, Network, Passive)
  • Setting the time interval (in seconds) between logs
  • Setting the minimum distance (in meters) between consecutive points
  • Pausing logging if you are not moving
  • Setting an accuracy filter (in meters)

The ability to control these various parameters means that your GPS log will be a much cleaner dataset, without a lot of overlapping and unnecessary data points.

Logging to a Custom URL

One of the best features of this app is the ability to log your real-time data to a custom URL endpoint. Essentially, you point the app at a script sitting on a web server, which parses the data values as simple HTTP GET parameters. This script can then insert these values into a database or integrate with other web services, such as Fulcrum or CARTO.

Custom URL Settings

Logging to CARTO

Logging directly to CARTO is extremely straightforward, and doesn’t even require any external scripts or servers. Simply open the “Logging details” menu and tap on the “Log to custom URL” option. You will be presented with a screen showing the properties available as well as a URL input. Once you’ve created your table in CARTO, you can build your URL with the pertinent data parameters to insert your GPS log records via CARTO’s SQL API.

https://your-username.cartodb.com/api/v2/sql?q=INSERT+INTO+gps_logger+(accuracy,altitude,android_id,battery,description,direction,provider,satellites,serial_no,speed,time,the_geom)+VALUES+(%ACC,%ALT,$$%AID$$,%BATT,$$%DESC$$,%DIR,$$%PROV$$,%SAT,$$%SER$$,%SPD,$$%TIME$$,ST_SetSRID(ST_MakePoint(%LON,%LAT),4326))&api_key=your-api-key

Note that the above example uses Postgres dollar quoting for string readability. Be sure to replace placeholders with your CARTO username and API Key.

Logging to Fulcrum

Logging to Fulcrum requires a script to build the record JSON object for POSTing to the records API. I’ve built a simple Fulcrum app to accept this GPS log data with a companion Google Apps Script (see below) to handle the API POST. I’m using Apps Script for simplicity, but you could put together something similar in any scripting language of your choice. The basic concept is to transform the data from the HTTP GET URL parameters into a proper Fulcrum record object, which includes defining your form ID and providing your API Key.

Code.gs (Apps Script)

function doGet(e) {
 var record = {
   “record”: {
     “form_id”: “your-form-id”,
     “latitude”: e.parameter.lat,
     “longitude”: e.parameter.lon,
     “form_values”: {
       “bc7d”: e.parameter.desc,
       “d81c”: e.parameter.sat,
       “85fc”: e.parameter.alt,
       “8ce4”: e.parameter.spd,
       “e4b6”: e.parameter.acc,
       “7cdd”: e.parameter.dir,
       “8c2c”: e.parameter.prov,
       “3ade”: e.parameter.time,
       “bd4c”: e.parameter.batt,
       “db4d”: e.parameter.aid,
       “ab93”: e.parameter.ser
     }
   }
 };
 var options = {
   “method”: “POST”,
   “contentType”: “application/json”,
   “payload”: JSON.stringify(record),
   “headers”: {
     “X-ApiToken” : “your-api-key”
   }
 };
 var response = UrlFetchApp.fetch(“https://api.fulcrumapp.com/api/v2/records.json”, options);
}

This script can be deployed as a web app and you will be provided with a URL to use in the GPSLogger app. Once the script has been published, you can build your URL by passing the GPS data as parameters. You should end up with a URL similar to this:

https://script.google.com/macros/s/AKfycbx8C_pKc8tSJMPwsARmOHNNxo9LAMtg7yiq43_12Ng_QmfXePv/exec?lat=%LAT&lon=%LON&desc=%DESC&sat=%SAT&alt=%ALT&spd=%SPD&acc=%ACC&dir=%DIR&prov=%PROV&time=%TIME&batt=%BATT&aid=%AID&ser=%SER

Conclusion

GPSLogger for Android is a handy standalone app for logging your location history. It’s simple, free, and easy to use. With a little creative scripting, you can easily post your realtime location history to the mapping service of your choice. This is another great example demonstrating how powerful integrating with an open API can be. If you’d like to share your own Fulcrum integration techniques, Tweet us @fulcrumapp with the #integration hashtag.