Getting UK GeoCode Data with YQL and ColdFusion

On July 16, 2010, in ColdFusion, by Anuj Gakhar

I stumbled across YQL today and although I had heard about it in the past, today was the first time, I actually sat down and read the documentation and went through some of the example apps. I am amazed at how powerful it is and am just imagining the wonderful applications that can be built using YQL. It opens up the doors to pretty much anything using a SQL like syntax.

It took me literally 2 mins to come up with the following code which takes a UK postcode and returns you the latitude and longitude for it. Ok, getting this information is not a big deal, but the point is, how easy it is to do this stuff with YQL.

Here is the code for those who are interested.

<cfset _query = 'select postcode, lat, lon from ukgeocode where postcode = "hp13 6bj";' />
<cfset _url  = "http://query.yahooapis.com/v1/public/yql?format=json&env=http://datatables.org/alltables.env&q=#urlencodedformat(_query)#" />
<cfhttp url="#_url#" result="_data" />
<cfset _geo_code_data = deSerializeJson(_data.filecontent) />
<cfdump var = "#_geo_code_data#">

This is what I get when I run the above code

I dont think it can get any easier than this ?

I am going to dig deeper into YQL and explore all the options whenever I get some spare time.

Tagged with:  

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 445 other subscribers

© 2011 Anuj Gakhar
%d bloggers like this: