May 11th, 2009

Getting public transport routing to work with openstreetmap & navit

First, you'll need timetables for your city in .tt format. .tt is very
simple text format, basically specifying when and where bus/tram lines
go. timetab projects has tools
for working with those, and can get the data for czech cities, trains
and long distance busses.

.tt file consists of many records such as these:

# 491
         6:37           0.000000        Mukarov
         6:39           0.000000        Mukarov, skola
         6:41           0.000000        Mukarov, Zernovka
         6:44           0.000000        Stihlice, Doubravcicka
         6:46           0.430000        Doubravcice, Cihadla
         6:48           0.430000        Doubravcice
         6:49           0.430000        Doubravcice, bytovky
         6:53           0.430000        Mrzky
         6:55           1.830000        Tismice, MS
         6:56           1.830000        Tismice, bytovky
         6:59           1.830000        Cesky Brod, sidliste
         7:00           1.830000        Cesky Brod, Na Bulance
         7:01           3.560000        Cesky Brod, Jungmannova
         7:01           3.560000        Cesky Brod, Jana Kouly
         7:03           3.560000        Cesky Brod,
D2009-03-02 121 17:1f

As you can probably decipher, bus 491 goes at 6:37 from Mukarov to
Cesky Brod,, where it is at 7:03. The strange D line at the
end is a (RLE-compressed) bitmap of days when this bus goes; this one
goes Mo-Fr, with no exceptions.

Then, you can use tools in timetab project (navit/
directory) and .osm source data to create .osm file combining map and
time tables. Public transport connections are then represented by
records such as: (I'm using ( instead of <, and final version will
differ quite a bit; opening_hours will have to be in proper format for
osm; highway will probably get special tag such as "public transport",

(way id='1107')
  (nd ref='355322132' /)
  (nd ref='319063834' /)
  (tag k='highway' v='path' /)
  (tag k='travel_time' v='2' /)
  (tag k='name' v=' 491' /)
  (tag k='opening_hours' v='teleport 6:25 6:27!2009-03-02 121 17:3f' /)

Now, all you need is to convert merged .osm file into .bin file,
and run modified navit
from public_transport branch. Because the way
search works (completely backwards), you have to specify time when you
want to be at destination at the command line -- such as

navit/navit -D 29.4.2009 -T 15:45
, and you have to select
Vehicle=Demo Pedestrian in the menu before selecting destination. Then
you select destination and current postion, and routing should work --
including public transport -- as long as you have right timetables and
as long as osm contains bus/tram/train stops around area you are