[JT] Jochen Topf's Blog
Thu 2011-03-03 00:00

A NodeJS Tileserver for Tirex

I have wanted to play around with NodeJS for a while. I had some time on the weekend so I implemented a small tileserver for Tirex using NodeJS.

NodeJS is a Javascript framework for writing Internet servers (mostly HTTP servers) in a non-blocking style. It uses Googles V8 Javascript engine. It has all the low-level code for creating a web server and, as it turns out, its pretty easy to use that to write a tileserver. (Well, Tirex does all the heavy lifting already, all it does is replace the Apache/mod_tile part.)

I wrote some code to parse the URL to find out what tile is needed, it then finds the right metatile file on disk, gets the tile image out of there and sends it to the client. If the tile isn’t there it sends a request to the Tirex master to get it rendered and waits for it to get rendered.

I have checked the code into the OSM SVN [Update: no longer available]. It is not really ready for production, it needs logging and timeouts need to be handles properly, but it basically works.

Tags: dev · javascript · nodejs · openstreetmap · tileserver · tirex