News, ideas and randomness

The Open Elm Project

Posted: October 24th, 2011 | Author: Andrew Gleave | Filed under: Django, Uncategorized, couchdb, mobile app, portfolio | No Comments »

This is a blog post which is well overdue.

In April we launched the Open Elm Project which, in collaboration with the Isle of Man Department of Environment, Food & Agriculture, enables the public to monitor and record the Isle of Man’s Elm tree population and report potential outbreaks of Dutch Elm Disease.

Unlike the UK, the Island has been largely unaffected by Dutch Elm Disease and has a population of ~200,000 trees. Unfortunately, the disease is on the rise and although the Isle of Man Government has done a sterling job of controlling and mitigating it’s impact, budget constraints have reduced the funds available for regular professional tree surveys meaning little is known about how quickly or to where the disease is spreading.

Early in the year we approached the Government with a concept: give the public simple tools which they can use to help the fight against the disease and report suspected outbreaks. The idea comprised of a website and two apps for iPhone and Android devices which can be used to find out information about Dutch Elm Disease and record sightings of diseased (or healthy) trees. To our delight, the Government jumped at the chance to participate in the project.

We build a site which enables people to get information about Elm trees and about Dutch Elm Disease itself, and learn how to spot the signs of the disease. We also build two mobile apps (another first for the IoM Government), which enables people to record sightings while they’re out in the countryside.

Using the apps users can take a picture of the tree(s), choose whether it requires inspection and submit it for review by the DEFA team. The records are automatically geotagged by the phone’s GPS radio, so the team can see where the tree is to an accuracy of ~10m on the site’s Google Map – much better than a grid reference!

All reports are first reviewed by the DEFA team and are then made public on the site’s report map and in the mobile apps themselves.

From the off, we wanted this project to be the Isle of Man’s first Open Data project and we released all the source code, and have documented how to get direct access to the database – everything about the project is fully open and transparent.

The project was build entirely using Open Source technology: Django, CouchDB, PhoneGap, jQuery Mobile and the source code is licensed under the GPL. We encourage others who think this type of project could be beneficial to their cause to use the code as they see fit.

The project announcement proved a hit with it being reported by the BBC and by numerous sources in the US and we’ve had a great uptake for such a new project.

Since the disease is hard to spot during the winter months, we’ll be promoting the project with urgency next spring and hope to get a loyal band of contributors to help preserve these trees.


PhoneGap CouchDB Attachment Plugin

Posted: March 14th, 2011 | Author: Andrew Gleave | Filed under: couchdb, iphone, mobile | No Comments »

I’m working on a cool new project which makes use of a lot of exciting new tech: jQuery Mobile, PhoneGap, CouchDB (Couchbase) and Django, and I wanted to enable the iPhone and Android PhoneGap apps to push binary attachments directly to CouchDB, without having to proxy through Django.

All access to CouchDB is performed via its RESTful JSON API which is awesome because it means you can to talk directly to the database using javascript! It’s also great because, in this case, there isn’t much going on in the middleware (Django) layer so implementing Python API endpoints to proxy to a standard database wouldn’t be worth it when I can get CouchDB to do the heavy lifting for free.

I had a look around and couldn’t find any existing plugins which could upload binary attachments to CouchDB (I could have used an XHR request to post the photo data, but I didn’t want to Base64-encode the photos as it can cause Out of Memory exceptions on devices with high-res cameras and increases the file size by ~1.4x), so I decided to write a quick Objective-C plugin.  PhoneGap has a simple plugin system which enables native code plugins to be exposed to DOM which means I can call my upload method, pass it the photo’s file URI, and let the plugin handle uploading the content.

The plugin is up on GitHub. Feel free to fork and send pull requests.