To learn some new stuff about cool databases and geo-aware services we started fiddling with GeoCouch, a CouchDB extension. To have a real scenario we could work on, we designed a small project: A CouchDB database contains documents with descriptions of fastfood restaurants. We agreed on 3 types of restaurants: KFC, Mc Donalds & Burgerking. We gave them some additonal information, namely opening and closing times and a boolean called “supersize”.

Our goal was to provide a google map with a route search, which then should return all restaurants near the route. We designed an application only depending on CouchDB and a modern Browser as a client. Using jQuery, underscore.js, the Google route boxer and loads of thinking we created that: http://vserver.nedeco.de/nedeco/_design/geoLocate/index.html .

What happens during a request

When the user hits the “calculate” button a series of things start:

  1. Google Maps calculates the route
  2. Google Maps Autoboxer calculates the boxes arround the route that contain points in the user-chosen distance to the route
  3. Our code fires bounding box requests towards the CouchDB GeoCouch handler
  4. GeoCouch returns lists of restaurants in the given boxes
  5. Our code collects all those restaurants, paints them to the map and saves them for later use ( filtering )
  6. We have a nice map, some statistics about our request and the database as well as the option to filter all the received points on client side
Performance
To improve the good performance of GeoCouch even further we decided to cluster three of our servers behind a Varnish caching reverse proxy. Varnish caches our client side code (index.html, severals js & css files) as well as our GeoCouch queries (they return 304 Not Modified when they didn’t change), so repeating requests perform extremly well (< 1S for ~60 requests).
Filtering
To provide our users some additional features we added client side filtering. There we pass our list of restaurants matching our corridor through underscore.js’ select function. The filtering happens so fast you can’t really see it, so we are extremely satisfied with this function.
UI
Last but not least we spent some time ramping up a cool user interface. Luckily Twitter released their Boostrap framework which we integrated just days after the release. They provide some nice defaults for your UI, and we happily used them.

Like it ?

 

2 Responses to First experiences with GeoCouch

  1. Thanks for the blog post! It’s good to see GeoCouch nicely integration into a whole chain of tools/libraries in this mini real world use-case.

    Cheers,
    Volker

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>