RSS feed

Linkedin Profile

Tags:
economy
programming
seattle
things that bug me
wall art

Posts by month: 12/08 (2)
10/08 (2)
08/08 (1)
06/08 (2)
05/08 (1)
03/08 (3)
02/08 (1)
01/08 (2)
12/07 (2)
11/07 (1)
07/07 (1)
05/07 (2)
02/07 (1)
01/07 (1)
12/06 (1)
11/06 (1)
10/06 (1)
08/06 (1)
07/06 (1)
06/06 (2)
05/06 (1)
04/06 (2)
02/06 (1)
01/06 (2)
12/05 (3)
11/05 (2)
09/05 (5)
08/05 (5)
07/05 (7)
06/05 (3)
05/05 (6)
04/05 (8)
03/05 (7)
02/05 (7)
01/05 (6)
12/04 (2)
11/04 (3)
10/04 (5)
09/04 (3)
08/04 (5)
07/04 (5)
06/04 (4)
05/04 (4)
04/04 (9)
03/04 (4)
02/04 (3)
01/04 (5)
12/03 (1)
11/03 (14)
10/03 (8)


Kareem
2008-03-15

I once saw Kareem Abdul-Jabbar play. It was some time around 1989 or 1990, in my native Brisbane, Australia. Kareem was making a valedictory tour with a team of old guys (Bob McAdoo!) playing against some Aussies including a young Lobo called Luc Longley.

Just recently Kareem has started blogging on the latimes site. The dude is deep! I was blown away by this post, which shows a young Kareem, with hair, and his head up around the rim. The man was once young.

Kareem

Stonehenge
2008-03-12
Stonehenge

KML
2008-03-12

I have done a little GPS hacking in the last year and am part-time interested in location, so as part of my Ruby blog re-write I implemented a KML feed. This lets me tag my blog posts with location coordinates. If this excites you then read on! If you aren't sure if you should be excited or not, then reading this introduction to KML will help you decide.

You can see my feed here here. Now check out this map overlay here. Sweet!

Here are my three step guide to rolling your own KML feed in Rails. I did this as part of my own blogging software, but these steps are generally applicable.

First up, get some location data. I did this by putting an extra string field onto my blog entry. Then fill this field with data of the format "{longitude}, {latitude}".

Next, write some view code to spit out data as KML. My .rhtml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
	<Document>
<% for thing in @things 
	if thing and 
		thing.location and 
		thing.location.length > 0 then
%>
		<Placemark>
			<name><%=thing.title -%></name>
			<description>
			<![CDATA[
				<%= thing.content%>
			]]>
			</description>
			<Point>
				<coordinates>
					<%= thing.location -%>
				</coordinates>
			</Point>
		</Placemark>
<%	end 
end %>
	</Document>
</kml>

Lastly, set the HTTP content type header like so:

response.headers["type"] = "application/vnd.google-earth.kml-xml"

Easy!

Tags: programming

Back to weblog