Converter from osm format to the Openlayers tabbed file format

Does anyone know if there’s a conversion routine for Windows somewhere that will take an osm format file (from XAPI, say) and convert it into the tab separated file format used by the Openlayers Layer.Text as described here?

I’m having to convert them manually at the moment, which is ok (just about) for a dozen or two, but needs automating for more regular use.


Don’t know if such a program exists. Now what should it do exactly? You did not tell.

In the textfile.txt of the openlayers example are colums:
lat lon title description icon iconSize iconOffset

Please tell us exactly from which nodes, tags or what else every colum should come from an .osm file or xapi result.

A quick hack might be available with gpsbabel, which can read OSM XML format files. One delimited option available is Garmin MapSource delimited text which could then be massaged into the OpenLayers format.

I’ve been trying to do just this myself.
Using GPSBabel, you can set it to output in “? Character Separated Values (xcsv)”. See
With this, you can use a custom style file, to specify the layout of the output. I have made one here, for Openlayers.Layer.Text format:
And it seems to work OK for me. Though note the icon file is specified in the style file, so all nodes will have the same icon.

The main problem with this is GPSBabel’s input for OSM format seems to be rather limited. I think it only reads in the coordinates and the name tag, all other tags are ignored. Which is rather annoying, if I want to output the description / operator / addr tags in OpenLayers format.
I don’t know if there’s any way to change this, and make GPSBabel process more OSM tags?

Thanks Vclaw I’ll try this. I had a quick look at GPSBabel before I posted my question and the tabbed output is little more than a list of node IDs.

GPSBabel certainly seems the natural place to start, shame it doesn’t do it.

I was thinking that I might try something in Excel as its import and export functions are good. Did I say Excel? I meant OpenOffice, naturally! Can’t be using non-open source stuff round here!! :wink:

Seventy7, could you please explain how you get ?

Another option for converting from OSM to OpenLayers Layer.Text format is OSM Library.
It can output as CSV, you can set it to lay it out as Layers.Text. It should be able to read in any OSM tags, and output them however you like.
Though it can be bit tricky to install and setup, probably easiest to install on Ubuntu as you can get most of the parts from the repositories (see the instructions ).
Also for processing, you have to write it as a Ruby script, but its not too hard to learn. You could just modify one of the examples.

I’m using it for this map here:
The Ruby script I’m using is here: