Incorporating GeoNames
For the last five months we’ve been working on a travel based social network, TravelScoops. Some of the key features of the site include being able to plan your trips and see where your friends are right now, based on the trip they’re currently on. Back at conception, we researched and toyed around with a few geomapping tools but only one provided enough data and versatility, and that was Geonames. Geonames is a collaboratively produced online geographic database, available under the Creative Commons licence. It’s one of those projects, like OpenStreetMap, whose community achievements just will just awe you. You’d be hard struck coming up with a location that’s either missing or incorrect (and if you do, fix it!)
So back to the project. We needed a data source that provided location names from village-level up to, but not including, country level. It needed to be fast, and capable of handling the number of requests from our site. Understandably, the GeoNames API has a rate limit. However the database can be downloaded to host locally which, with a bit of work, you can tweak to fit your needs.
The next hurdle was the search algorithm and data structure, which needed to efficiently search a 6.5 million row table with joins. With a database of this size you’d be best off going with a full-text search engine such as Lucene or Sphinx, however if that’s not possible, indexing the right fields and using MySQL’s full-text features will do a reasonably good job. Re-organising the GeoNames data into a structure that suits your project’s needs is recommended, alongside producing a script to automate updates from GeoNames.org.
Things to consider when producing your search algorithm;
- If population is a factor, know that a lot of places are lacking that data in GeoNames.
- London’s country is ‘United Kingdom’. If your result has anything in between (say, ‘England’) you’ll find it in the relevant administrative subdivision data (adminCodes).
- Do some research and have a fiddle with filtering by class and code. London is class P; a city, while Greater London is class A; a state. Islands are class T and have a code of ISL. Make sure you know exactly what types of location you’re algorithm should find!
GeoNames’ GeoTree is a handy tool to help understand how their data is structured.
So, GeoNames is a fantastic data source, but combining that with search and mapping can lead to a lot of work. Today’s problem in social media is getting users to be more open with their location (personally, I think Google Latitude was launched a little early in that respect) – the result is that geomapping is becoming more prevalent every day, so we’re seeing a lot of activity regarding geomapping frameworks and development tools.
With the combination of OpenStreetMap’s up-to-the-minute data and CloudMade’s fantastic development tools, 2009’s going to be an exciting year for geomapping!


The Co-Creation Hub Launches in London
We're hiring again!
Social Media for Brands: Part 3 – Whats the ROI?
Ding Dong Merrily on High
Social Media for Brands: Part 2 – How can you engage?