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.
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
- SL4A on GitHub: http://github.com/kuri65536/sl4a
- Python for Android on GitHub: http://github.com/kuri65536/python-for-android
- Bottle: http://bottlepy.org/docs/dev/index.html
- Geofix on GitHub: https://github.com/dmpop/geofix
- Termux: http://termux.com
- "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
- Syncthing: http://syncthing.net
- Geocoder Python library: http://pypi.python.org/pypi/geocoder
« Previous 1 2
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
So Long Neofetch and Thanks for the Info
Today is a day that every Linux user who enjoys bragging about their system(s) will mourn, as Neofetch has come to an end.
-
Ubuntu 24.04 Comes with a “Flaw"
If you're thinking you might want to upgrade from your current Ubuntu release to the latest, there's something you might want to consider before doing so.
-
Canonical Releases Ubuntu 24.04
After a brief pause because of the XZ vulnerability, Ubuntu 24.04 is now available for install.
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.