Discussing software, the web, politics, sexuality and the unending supply of human stupidity.

Hack notes: OpenCheckin from OSM

Today, I’ve been working hard on building a checkin service, an open alternative to services like Foursquare and Facebook.

I’ve been building it as a separate application in Scala. I’ll probably use Scalatra (although the choice of web microframework is kind of irrelevant). The reasons I chose Scala are simple:

  • it’s faster than Ruby
  • the language level XML support is quite nifty
  • Java web deployment is pretty straightforward: should now be possible to use on Heroku, AppEngine, Elastic Beanstalk or anywhere that takes a WAR file
  • the collections framework is mostly quite nice
  • Java but better

Today, I’ve built the basic API calling code (which calls out to the Overpass API, specifically the XAPI endpoint): it will end up just taking a latitude and longitude and returning a list of venues ordered by closeness. What’s a “venue”? Well, a venue is whatever you might want to check in to. I’m taking hotels, bars, pubs, cafes and restaurants as pretty much prototypical venues. You share these because you are enjoying yourself (or not) or want others to come join you or whatever.

There’s plenty of other things that count as venues. Community centres, churches/places of worship, museums, galleries, beaches, shops, railway stations, airports, sports stadiums, offices, parks and so on.

For inspiration, here is a list of all the venue types on Foursquare, and here is the defaultpresets.xml file from JOSM, the Java OpenStreetMap editor.

In terms of libraries, currently I’m using Databinder Dispatch, which is great… but the documentation is still utterly cryptic. I’m also using Java Geocalc, which is a very simple library. Sadly, despite the claims on the website, it isn’t in a Maven repository, so I had to download it from Git and compile it myself.1

In the process of hacking, I compiled a list of the most used tags in London. This takes a 3km bounding box around a point I chose fairly randomly in Soho, and filters on tags found only on objects with names. It’s still quite interesting how there’s such a power law distribution to the tags.

The next job is to take the data that the API is returning for the area I’m sampling, write some rules to filter the uninteresting objects that (I think) people won’t check into (roads and bus stops, for instance) and then keep on building the formatter, which spits out both JSON and HTML. The HTML is a little div for each entry with a microformat (hCard, geo etc.). It just maps the data from OpenStreetMap as naturally as possible to the various HTML constructs. For instance, the phone tag can become a tel: link (which tapping on most smartphones will result in calling that number).

All an indie web site needs to do is call the OpenCheckin API and it’ll give back a list of the 30 closest venues.

Formatting is still something I’m thinking about.

British Library


96 Euston Road, NW1 2DB

Wikipedia website

Wheelchair access available.

That’ll be something to improve over time. Eventually, I’d like to include some kind of icon: that may start as a simple, generic icon (hopefully all public domain and stored over on Commons) and might then evolve into favicon-style logos.

Anyway, I need to go to bed. More soon.

  1. And fix a Maven issue. And some SBT issues. Programming sure is fun when you actually get around to doing it.