XQuery/SMS tracker

Motivation
BrightKite provides a service to micro-blog your location and message to a service to geocode the address, map it, find other tweeters nearby and forward to other micro-blogs.

However for UK users the service lacks the availability of an SMS service. The following scripts provide a basic SMS tracker service, allowing a user to text an address and a message to an SMS service and see that location on a generated map. This simple application does not provide the social aspects of BrightKite, being confined to creating a simple track.

eXist-db Modules

 * xmldb - to update the track
 * datetime - for date formatting
 * util - serialize to convert XML to CDATA

Other

 * an SMS two-way service
 * GoogleGeocoding service
 * kml-based mapping such as GoogleMap or GoogleEarth

The Track structure
Each track is represented as a single XML file, containing a unique name, a title, one or more mobile phone numbers and a list of events. Each event is time-stamped and contains the original address, its latitude and longitude when geo-coded and a message. A local namespace is used for the XML data and for associated functions. Full address geo-coding is not supported in the UK due to copyright restrictions on full addresses and postcodes.

In-bound messages
Inbound messages have the structure:

geo {address} ! {message}

SMS messages are sent to the UWE SMS two-way service described in here. The router uses the first word to route the message to the associate service, in this case track2sms.xq. This service is invoked viat HTTP, passing the prefix (prefix), the originating mobile number (from) and the text of the message (text') following the prefix.

The script uses the originating mobile number to find the associated track. If there is one, the message is parsed into the address and message text. The address is passed to the Google geocoding service. If the address is recognised, a new event is created and appended to the rest of the events in the track and a confirmation returned to the originator (via the SMS two-way service).

Generating the Map
The track is identified by name and a KML file of the events on the track is generated.

Example Map
Google Map

Note that one address has been miscoded but the feedback allowed the address to be changed and resent.

To do

 * 1) edit track to remove or correct  bad geo-coding
 * 2) add events from a browser