Archive for the 'Geocoding' Category

TwitterWhere - Filter Tweets by Location

Inspired by a post over at Silicon Florist about following local people on Twitter, I investigated whether it was possible to follow someone in a geographic area. The closest I found was TwitterVision, which is a great idea, but doesn’t exactly do what I want. So I ended up taking a few hours and developed TwitterWhere, an aggregator that watches the Twitter public timeline and geocodes what it finds. From there anyone can generate an RSS or XML feed that will pull only Tweets within a set radius around an area. Now you can have a feed of Tweets within 50 miles or Portland, or 5 miles of Manhattan, New York.

For anyone who is interested, here’s how I pulled it off…

I wrote the app in Ruby on Rails, utilizing my favorite gem of all time, Graticule (geocoding and spatial search), Hpricot (parsing the public timeline on Twitter), and a couple custom geocoding libraries I already had cooked up for Unthirsty and Knitmap.

Every minute I query the Twitter public timeline XML file and the results. If a new user is entered into the system it is geocoded and any Tweets added by that user from that point inherit the coordinates. Any users with an invalid location are thrown out and not cached. I also cache geocode queries locally. Both of these measures are in place so I don’t overload the geocoding services I use (especially considering I have two other fairly heavy traffic sites using geocoding services).

On the front end, feeds are not exactly ‘generated’, it’s more of a verification that the location someone has entered is geocodable. Once the location is verified a link is presented to the user that points to RSS or XML feeds. If this ends up getting more traffic, I’ll consider using caching for each unique feed, but right now when you visit a feed URL, it is generated from the database in real time, every time.
TwitterWhere runs on my good old Dual 1.8GHz Powermac G5 at our co-location facility, using a custom compiled Apache 2.2, mod_proxy_balancer and 5 mongrels.

Okay, I’m done geeking. Here are few mentions of TwitterWhere from around the web. Thanks for the write-ups!

P.S. Apologies to TwitterWhere.com, I didn’t even think to check if the domain existed, let alone to see if there was something there! We don’t exactly do the same thing (TwitterWhere.com allows you to easily update your current location on Twitter), so hopefully there isn’t too much confusion.

Yahoo! Geocoding now supports UK

I was working on Unthirsty last night when I came across an example of using a particular geocoding plugin. The addresses they were using were in the UK, and I was puzzled because last I checked the UK wasn’t available in any free geocoding API that I could find. So I tried out geocoding a pub in London and what do you know? Yahoo! came up with an accurate result with precision down to the address. So I tried a few more, and they all worked. This is great news, because it allows us to catalog happy hours in the motherland of pubs. I thought I’d share because apparently this has been around for a while and I didn’t even know about it. Anyone looking around for a free geocoding service for the UK, check out the Yahoo! Geocoding API. Also, if your Rails app needs geocoding support, check out Graticule, and see my snippet to make Graticule failover to multiple geocoding services.