Railway network graph exporter

Got an idea for OpenTTD? Post it here!

Moderator: OpenTTD Developers

Post Reply
[OpenTTD]Johannes
Engineer
Engineer
Posts: 18
Joined: 04 Feb 2012 10:28

Railway network graph exporter

Post by [OpenTTD]Johannes »

Hi,

on my current OpenTTD map, I lost overview of which trains run through which stations. What I need is a graphical, simple representation of a railway network. Like this here, e.g.:

Image

Is there already an exporter of an openttd map into a graph format, like e.g. ".dot"? If not, I would volunteer to write one myself.

Right now, I have many interesting ideas, like "only display the passenger network" or "discard express trains from the network".

Regards,
Johannes
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Railway network graph exporter

Post by planetmaker »

There is no exporter that I know of. All maps like that which I've seen and which are based on games seem to have used hand-exported data. You probably could abuse / re-use the linkgraph thing as used already for cargodist.
[OpenTTD]Johannes
Engineer
Engineer
Posts: 18
Joined: 04 Feb 2012 10:28

Re: Railway network graph exporter

Post by [OpenTTD]Johannes »

planetmaker wrote:You probably could abuse / re-use the linkgraph thing as used already for cargodist.
The linkgraph files look very helpful. Thanks.
User avatar
Redirect Left
Tycoon
Tycoon
Posts: 7249
Joined: 22 Jan 2005 19:31
Location: Wakefield, West Yorkshire

Re: Railway network graph exporter

Post by Redirect Left »

That'd be quite a sexy thing if you could come up with some sort of automated network graph!
Image
Need some good tested AI? - Unofficial AI Tester, list of good stuff & thread is here.
Plord
Engineer
Engineer
Posts: 65
Joined: 28 Nov 2014 16:19

Re: Railway network graph exporter

Post by Plord »

I also like the idea, and not so difficult to do.

for exported data:
with tools like d3.js you could make some owesome graphs and with little to no time.
the problem would be to export the information. (which information)

to in-game graph.
the Best approach is linkgraph, but wouldn´t be as "beautiful" as you may think.
Eddi
Tycoon
Tycoon
Posts: 8269
Joined: 17 Jan 2007 00:14

Re: Railway network graph exporter

Post by Eddi »

there might be ancient patches that hacked a .dot exporter together. i think Celestar had one once upon a time.
[OpenTTD]Johannes
Engineer
Engineer
Posts: 18
Joined: 04 Feb 2012 10:28

Re: Railway network graph exporter

Post by [OpenTTD]Johannes »

I think I'll just make a simple C++ exporter for

.sav -> .dot

One interesting question is whether the exporter should be called from ingame, or just be an external program. I'd suggest the latter, since this seems more useful (and more easy to code) to me. If there should be interest to have the functionality from ingame, one could probably simply reuse the function that creates the .dot file.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Railway network graph exporter

Post by Alberth »

Perhaps first try whether you're happy with a .dot file?
In my experience, while Graphviz gives you a picture of the graph with pretty much zero effort, but the amount of effort is also reflected in the quality of the output.

If you are happy with the quality, great. If not, maybe first try some other solution before you code it 'for real'?
Being a retired OpenTTD developer does not mean I know what I am doing.
User avatar
prissi
Chief Executive
Chief Executive
Posts: 647
Joined: 15 Nov 2004 19:46
Location: Berlin, Germany
Contact:

Re: Railway network graph exporter

Post by prissi »

There had been something like that added to simutrans. Since it is OS, one could adapt it to OpenTTD with little effort. A simnple one may look like Image
I like to look at great maps and see how things flow. A little like a finished model railway, but it is evolving and actually never finished. http://www.simutrans.com
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Railway network graph exporter

Post by Alberth »

At first sight, looks like replace station with big dot, if station A is directly connected with station B, draw a diagonal + horizontal or vertical line.
Being a retired OpenTTD developer does not mean I know what I am doing.
User avatar
Redirect Left
Tycoon
Tycoon
Posts: 7249
Joined: 22 Jan 2005 19:31
Location: Wakefield, West Yorkshire

Re: Railway network graph exporter

Post by Redirect Left »

prissi wrote:There had been something like that added to simutrans. Since it is OS, one could adapt it to OpenTTD with little effort. A simnple one may look like Image
Even something as basic as that would be a nice starting point. If viewable in the ingame map overview, then a simple screenshot (ctrl+s) would cover the exporting out of the gmae.
Image
Need some good tested AI? - Unofficial AI Tester, list of good stuff & thread is here.
[OpenTTD]Johannes
Engineer
Engineer
Posts: 18
Joined: 04 Feb 2012 10:28

Re: Railway network graph exporter

Post by [OpenTTD]Johannes »

Ok, I'd like to present my plans for an exporter:

Ingame Exporter

The exporter is implemented in the openttd game as a video driver. It will be named "graph" driver and inherit the "null" driver. It will just scan all stations and order list and output a dot-formatted graph to stdout.

So the call would be:

Code: Select all

openttd -g my_savegame.sav -v graph
This means: Load the game "my_savegame" into openttd, then run the video renderer "graph", which only renders the graph into a .dot file and dump it to stdout.

How will this graph look?
  • Stations are nodes, waypoints and depots are not drawn
  • The station nodes are positioned as in the savegame's map, preserving the geometry
  • Each ordered list is one "railway line", and if two ordered lists are equal (except of where the trains start, except waypoints and depots), they are put together as one railway line
Example:
exported.png
(85.88 KiB) Not downloaded yet
.

External Tool

The latter rendered graph will be basic and have no options, since options would have to go through the openttd argument parser. So, additionally, there will be an external graph tool which then converts the exported graph to a user defined graph (.dot to .dot). It will provide options, be written in C++ and maybe have an additional library dependency (boost::graph).

The external tool will allow
  • to restrict the graph to some cargo types (only passengers, only coal and steel, etc.)
  • to draw the graph octilinear and modifying the geometry a bit
  • options, like, e.g. that order lists that have a subset of stations of another order list are being put into the same railway line.
  • options, like, e.g. that express trains (e.g. railway lines that are like another railway line, but pass through some of the stations) are being discarded.
An example (Linux and similar)

Export my_savegame.sav to a basic graph.

Code: Select all

openttd -g my_savegame.sav -v graph > exported_graph.dot
Extract only passenger lines, and discard "subset railways" and "express railways" (see above)

Code: Select all

cat exported_graph.dot | openttd-graph-conv -cargo "passengers" -no-subset-railways -no-express-railways > my_savegame.dot
Create a PDF file

Code: Select all

dot -Tpdf my_savegame.dot > my_savegame.pdf
Or, more simple:

Code: Select all

openttd -g my_savegame.sav -v graph | openttd-graph-conv -cargo "passengers" -no-subset-railways -no-express-railways | dot -Tpdf > my_savegame.pdf
Other OS
Should not be a problem, since all Code is written in C++.

Any thoughts/comments about this plan?
[OpenTTD]Johannes
Engineer
Engineer
Posts: 18
Joined: 04 Feb 2012 10:28

Re: Railway network graph exporter

Post by [OpenTTD]Johannes »

Hello,

two more questions:
  1. Should the tools that converts the OpenTTD JSON dump into other formats (PDF, LaTeX etc) be inside the OpenTTD git repo, or should they be in separate projects? IIRC some people suggested to make them external.
  2. Is it acceptable if the part of OpenTTD which will add a new video driver (next to the SDL etc. drivers) will be in C++11? I know OpenTTD is currently not using C++11. However, C++11 would make the code a lot nicer. As long as it's just for this one video driver, I'd suggest that openttd compiles it exactly if the compiler is C++11-ready. If it is not compiled into OpenTTD, you can not export graphs, but use everything else as usual. Is this acceptable?
Also some news:
  • The exporter will use JSON instead of binary dumps. This is almost working now.
Thanks for your suggestions/answers!
Translink
Traffic Manager
Traffic Manager
Posts: 233
Joined: 20 Oct 2015 19:05

Re: Railway network graph exporter

Post by Translink »

It's not exportable but it's easy to use:

http://www.beno.org.uk/metromapcreator

I find it absolutely fabulous for the creation of metro-styled maps; you get a nice clean map and it is very easy to use.
[OpenTTD]Johannes
Engineer
Engineer
Posts: 18
Joined: 04 Feb 2012 10:28

Re: Railway network graph exporter

Post by [OpenTTD]Johannes »

The first release is ready for testing! (linux only, no programming knowledge required)

Installation instructions: https://github.com/JohannesLorenz/railnet
Details on how it works: https://wiki.openttd.org/Railnet

Please try it on any of your maps and report bugs + feature requests: https://github.com/JohannesLorenz/railnet/issues .
Please don't supply feature requests about the bad design - this will be changed soon.

Hopefully it works, good luck!
mrjack2
Engineer
Engineer
Posts: 74
Joined: 21 Jan 2016 23:04

Re: Railway network graph exporter

Post by mrjack2 »

I'm not in a position currently to contribute to testing or anything, but i hope you (and others) keep on with this as it sounds fantastic! Unless you want a savegame or something to apply it to -- I have a relatively advanced passenger network game running atm. Do you have any examples of some network graphs you can get out of your tool?
User avatar
Leanden
Tycoon
Tycoon
Posts: 2613
Joined: 19 Mar 2009 19:25
Location: Kent

Re: Railway network graph exporter

Post by Leanden »

[OpenTTD]Johannes wrote:The first release is ready for testing! (linux only, no programming knowledge required)

Installation instructions: https://github.com/JohannesLorenz/railnet
Details on how it works: https://wiki.openttd.org/Railnet

Please try it on any of your maps and report bugs + feature requests: https://github.com/JohannesLorenz/railnet/issues .
Please don't supply feature requests about the bad design - this will be changed soon.

Hopefully it works, good luck!
Could you upload a binary for those of those of us who want to test but arent comfortable compiling Openttd :D
Image
Post Reply

Return to “OpenTTD Suggestions”

Who is online

Users browsing this forum: No registered users and 14 guests