Railnet

The railnet tool (just called "railnet") is a schematic railroad network map exporter for (a special kind of) OpenTTD savegame dumps.

It consists of three components: the railnet video driver (compiled inside OpenTTD), the railnet-filter utility and the railnet2dot utility.

Contents

Introduction

OpenTTD maps can get large sometimes. It can be hard to keep an overview of all lines. Also, while changes on a map are made, trains can take other routes without the player noticing.

Railnet shall help solving these problems by generating a schematic railroad network map. These kinds of networks are often offered by suburban railways for their customers. While the connectivity of stations is being preserved, the geometry is often stretched in order to make the map more readable.

The three steps

The production chain is like this:

                                                      ===<===railnet-filter===<========
                                                     |                            ^   ^
                                                     V                            |   |
openttd savegame ===railnet video-driver==> json railnet dump ===>==========>=====|   |
                                                     |                                |
                                                     |<-------------<------------user-defined
                                                     |                            parameters
                                                railnet2dot
                                                     |
                                                     V
                      pdf-file <==dot-utility=== .dot-file

About the 4 file types:

Railnet Video Driver

The railnet video driver is an ingame video driver. It computes the "railnet dump" and renders it to stdout. There is no "real video" rendered.

You can not pass any parameters to the video driver.

The video driver does the following:

Cargo merging

Whenever a train has the same or reverse (this happens only for cyclic order lists) order list of another one (this includes "shifted" order lists), the cargo is being "merged" to that other train's cargo. The following examples illustrate it:

Train A: wood + passengers + mail
Train B: passengers + mail + oil + goods
A + B have the same directions

This would result in three trains:

C: passengers + mail,
D: wood,
E: oil + goods

Another example:

Train A: wood + passengers + mail
Train B: passengers + mail + oil + goods
B is in the reverse direction of A

This would result in the same thre trains, however, with different directions:

C: passengers + mail, (forward + backward)
D: wood, (forward)
E: oil + goods (reverse)

Note that in the code and the json file, trains C, D and E are stored in one "train", but in different "slices" of it.

Railnet filter

The railnet filter takes json files and outputs them with filters specified by user defined parameters.

Railnet 2 pdf

The railnet2pdf tool takes the json railnet dump and converts it into a .dot file.

You can pass parameters to the converter in order to make the graph look as desired. E.g., you can set the stretch factor for the distance of the nodes. Try --help for more options.

dot-utility

The dot-utility is no part of OpenTTD.

A practical example

This prints the railway network graph into a PDF file 'map.pdf', discarding superset and express trains and all other cargo than passengers, and applying a stretch of 4.

/where/you/installed/openttd -g your_savegame.sav -v railnet \
  | ./railnet-filter -s -e -c "PASS" | ./railnet2dot -s 4 | dot -Kneato -Tpdf > map.pdf

Weblinks

https://github.com/JohannesLorenz/railnet - Railnet project page