CamelCode
A tech demo built on top of Play framework 2 that imports the CodePoint Open UK postcode dataset and offers a Geocoding RESTful API and a map. It also demonstrates how Google Guice can be integrated in a Play 2 Java application.
Prerequisites: MongoDB and Play framework 2.0.3.
Development sponsored by Coen Recruitment. Follow @analytically on Twitter for updates.
Setup
Edit conf/application.conf
and point it to a MongoDB installation, and execute
play run
Then put the CodePoint Open CSVs (scroll halfway down, 20mb)
in the codepointopen
directory.
After they are processed, they will be moved to the codepointopen/done
directory.
Then visit http://localhost:9000/ and you should see the welcome screen. Visit http://localhost:9000/servermetrics for server metrics.
JSON
GET http://localhost:9000/latlng/POSTCODE to geocode a UK postcode. Response will be JSON:
{"latitude":51.505615,"longitude":-2.6120315}
Technology
- Play framework 2.0, thank god for this!
- Apache Camel to process and monitor the
codepointopen
directory and to tell the actors about the postcodes (split(body())) - Akka 2.0 provides a nice concurrent model to process the 1.7 million postcodes in under one minute on modern hardware
- GeoTools 8 converts the eastings/northings to latitude/longitude
- Guice for Dependency Injection (not too much to inject yet though)
- Metrics for metrics
- MongoDB as database with two-dimensional geospatial indexes (see Geospatial Indexing)
- Morphia for 'Object-Document Mapping'
- Leaflet for the map
- Twitter Bootstrap and Font Awesome for the UI
License
Licensed under the WTFPL.
This data contains Ordnance Survey data © Crown copyright and database right 2012. Code-Point Open contains Royal Mail data © Royal Mail copyright and database right 2012. Code-Point Open and ONSPD contains National Statistics data © Crown copyright and database right 2012.
OS data may be used under the terms of the OS OpenData licence.