Saturday, 26 January 2008

Playing with KML

The Idea

When I came back from holidays, I thought about creating a map of the journey in a way that I could share with friends. So I decided to try to do that using KML, the description language used by Google Earth. Google has tutorials and reference documentation about KML that got me started. In practice, what I wanted to do was very simple: lines showing the route and location pins showing the places I had visited on the way.

Document Structure

KML is a fairly straightforward XML dialect and the basic structure is very simple:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="">
    Content goes here


For the route, I wanted lines that would roughly follow the route I had taken. To do this in KML is simple: add a Placemark tag containing a LineString tag that itself contains the coordinates of the different points on the line. So a simple straight line from London to Hamburg looks something like this:

  <name>Outward flight</name>
    <coordinates> -0.1261270000000025,51.50896699999998

The name tag is not essential but this is what will show in the side bar in Google Earth so it's better to have one. The clampToGround value in the altitudeMode tag tells Google Earth that each point on the line is on the ground so you don't have to specify the altitude in the coordinates. In the coordinates tag is a space separated list of coordinates. In this case, each point is specified by a longitude and a latitude separated by a comma, the altitude being implied. Longitude is specified with positive values East of the Greenwich meridian and negative values West of it. Latitude is specified with positive values North of the equator and negative values South of it.

That's good but another thing I wanted to do was specify different colours for the different types of transport I used during my holidays. KML has the ability to define styles that you can then apply to Placemark tags. This is done by adding a number of Style tags at the beginning of the document. You then have to specify the style using a styleUrl tag. Applying this to the simple line above, we get:

<Style id="planeJourney">

  <name>Outward flight</name>
    <coordinates> -0.1261270000000025,51.50896699999998

Note that the value for the color tag in the LineStyle is the concatenation of 4 hexadecimal bytes. The first byte is the Alpha value, that is how opaque is the colour, in our case the value ff specifies it is completely opaque. The next three bytes represent the Red, Green and Blue values, in our case a simple green.


For places, I wanted a simple marker that showed more information when you clicked on it. This is also very simple in KML: a Placemark tag containing a name, a description and a Point tags. The name needs to be a simple string but the description can contain a full blown HTML snippet inside a CDATA node so you can include images, links and all sorts of things. Note that the box that will pop up when you select the place mark is quite small so don't overdo it. Here is an example for London:

  <description><![CDATA[<p><img src="some URL" /></p>
<p><a href="some URL">More photos...</a></p>]]></description>

Note that the coordinates here include the altitude as well as the longitude and latitude. You could also apply a style to the location place marks, in the same way as was done for the lines.


Once you've created your file, you need to save it with a .kml extension. You can then open it in Google Earth. When you're happy with it, you can also zip it and rename it with a .kmz extension: Google Earth will be able to load it as easily but the file will be smaller. Both files can also be used with Google Maps and can be shared online. So here is my complete holiday map built with KML.

Tips and Tricks

Getting the exact coordinates of a particular place can be cumbersome. To make it easy, just find the place in Google Earth, create a temporary place mark if there is none you can use, copy it with the Edit > Copy > Copy menu option and paste it in your text editor: you'll get the KML that defines the placemark, with exact coordinates.

The clampToGround option in the altitudeMode tag specifies that the points you define in the coordinates are at ground level. The line between two points will be straight, irrespective of what lays between said points. So if you have a mountain range in between, you will see your line disappear through the mountains. To correct this, you should insert intermediary points where the highest points are located. This is why on my map the flight between Izmir and Paris has intermediary points so that the line can go past the Alps without being broken.

If you want to do more complex stuff, be careful that Google Maps only supports a subset of KML. Of course, the whole shebang is supported by Google Earth.


KML is a nice and simple XML dialect to describe geographical data and share it online. It certainly beats writing postcards to show your friends and family where you've been and it doesn't get lost in the post.

Silent Server

A few months ago I set up a home server using an old box. Unfortunately that old box died shortly afterwards. Furthermore, it was quite noisy as it had been originally spec'ed as a high end workstation. So I went in search of a replacement, with a view to have a server that would be as silent and energy efficient at possible.

In this quest, I came across VIA, a Taiwanese company that specialises in low power x86 compatible processors and motherboards. You can get most of their hardware in the UK from But I'm not good at building a box from scratch so I really needed something already assembled. I found that at Tranquil PC, a small company based in Manchester. Here is the configuration I ordered from them:

  • An entry T2e chassis with DVD-R drive, colour black.
  • A VIA EN15000 motherboard. I choose this one as it is the only one that they offer that comes with a Gigabit Ethernet port and the new 1.5GHz VIA C7 processor, which is one of the most power-efficient.
  • 1GB RAM. Experience tells me that this is more than I need but having extra RAM should enable the machine to take on more tasks in the future.
  • A 100GB 2.5" HDD. I could have gone for a larger 3.5" HDD but I don't currently need the extra space and laptop drives are significantly more energy efficient and silent than desktop ones.

I received my T2e a week or so later. Unfortunately, it had been damaged in transit and the DVD drive was not working properly anymore. The support people at Tranquil PC were very nice and very efficient and arranged for the machine to be collected and sent back to them. It came back a week later in full working order.

I replicated the original install that I had done on the old server. Having done it once, it went very smoothly, everything working first time. The obvious difference from the start was how little noise the T2e makes. In fact, the only audible noise came from the DVD drive spinning the installation CD. Otherwise, it's as if the machine was switched off. Impressive! And it looks really cool with the blue glow coming out of the front panel. As I have a plug-in energy meter, I decided to check how much power this machine drew. So, once the installation was finished and the machine was up and running, I restarted everything with the meter in between the wall socket and the PC's plug. Results:

  • Max power consumption when starting up: 30 Watts.
  • Standard power consumption once in operation: 25 Watts.

In other words, this machine consumes about the same as a small standard light bulb without ACPI enabled. Once I've enabled ACPI and tweaked it somewhat, I should manage to make it consume even less.

This proves that a server doesn't have to be a big power hungry and noisy box, it can be a small machine that is so silent you forget it's switched on. There are currently few suppliers for that sort of hardware but my guess is that it will become more common. In the meantime, head to Tranquil PC to find one of those.

Sunday, 6 January 2008

More Music, Less DRM

According to Wired, Sony BMG have decided to start offering their music online without DRM. This makes them the last of the major labels to do so.

This is good news for everybody as it means we will start seeing more music sold online without DRM. Then again, music is not limited to major labels, there are lots of Indie labels out there that produce great music. And there are more and more online outfits that enable artists to distribute their music. Check out Magnatune, Amie Street or Jamendo for a few examples.