Build your own tracking app

The Web App

The Geofix web app is based on the Python Bottle framework that was covered in a previous issue [6], so to get a grasp of the framework's basics, it's a good idea to peruse that article first.

Geofix is not exactly a complex web app, and it consists of three key components: the main.py Python script, which is the core of the app, several .tpl template files, and a CSS stylesheet that controls the overall appearance of the app. The main.py script has four functions responsible for retrieving data from the gefix.sqlite database, displaying the obtained data, together with the accompanying photos as a web page, showing an individual photo, and deleting photos.

Again, if you read the Bottle article first, you should have no problems figuring out how the Geofix web app works. The app's main page is not overloaded with features and information (Figure 1). The only thing you need to know is that the ID number of each entry links to the delete page, whereas the map marker points to the OpenStreetMap map showing the exact geographical position of the selected entry.

Figure 1: Geofix web app in action.

Practicalities

The Geofix app doesn't resize photos; instead, it shrinks them to thumbnail size on the fly. Adding a lot of photos taken at the maximum resolution supported by your Android device's camera to the Geofix web app will dramatically increase load time and generate a lot of unnecessary traffic. You can solve this problem in several ways; for example, you can configure the default camera app to take photos at a lower resolution (e.g., 640x480).

Alternatively, you can use Termux to resize the photos with the ImageMagick mogrify tool (to install it in Termux, use the apt install imagemagick command). The following command resizes all JPG images in the current directory to 600px on the longest side:

mogrify -resize "800x800>" *.jpg

If you use the geofix.sh script, you can add the command below to resize the photo automatically after it has been taken:

mogrify -resize "800x800>" $geofix_dir"/snapshots/"$dt.jpg

To make use of the Geofix web app, you need to copy the geofix.sqlite database and all accompanying photos from the Geofix directory on your Android device to the static directory inside the web app. You have several options here, including a dedicated synchronization tool like Syncthing [7]. Alternatively, you can opt for running rsync in Termux.

Conclusion

Despite its simplicity, a tool like Geofix can handle a variety of useful tasks: from tracking your trips and recording interesting places to helping you geotag photos. With a bit of tweaking, you can put Geofix to other practical uses, too. For example, you can add a description field and modify the web app to transform it into a no-frills travel diary. If you integrate the geocoder Python library [8] into the web app, you can use Geofix for reverse geocoding.

In short, with a bit of creative thinking, you can make Geofix do all kinds of useful and clever tricks.

Infos

  1. SL4A on GitHub: http://github.com/kuri65536/sl4a
  2. Python for Android on GitHub: http://github.com/kuri65536/python-for-android
  3. Bottle: http://bottlepy.org/docs/dev/index.html
  4. Geofix on GitHub: https://github.com/dmpop/geofix
  5. Termux: http://termux.com
  6. "Using the Bottle Framework to Build Python Apps" by Dmitri Popov. Linux Magazine, issue 174, May 2015, pg. 80, http://www.linux-magazine.com/Issues/2015/174/Workspace-Bottle
  7. Syncthing: http://syncthing.net
  8. Geocoder Python library: http://pypi.python.org/pypi/geocoder

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95

News