Railway network graph exporter
Moderator: OpenTTD Developers
-
- Engineer
- Posts: 18
- Joined: 04 Feb 2012 10:28
Railway network graph exporter
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.:
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
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.:
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
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: Railway network graph exporter
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: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
-
- Engineer
- Posts: 18
- Joined: 04 Feb 2012 10:28
Re: Railway network graph exporter
The linkgraph files look very helpful. Thanks.planetmaker wrote:You probably could abuse / re-use the linkgraph thing as used already for cargodist.
- Redirect Left
- Tycoon
- Posts: 7249
- Joined: 22 Jan 2005 19:31
- Location: Wakefield, West Yorkshire
Re: Railway network graph exporter
That'd be quite a sexy thing if you could come up with some sort of automated network graph!
Re: Railway network graph exporter
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.
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.
Re: Railway network graph exporter
there might be ancient patches that hacked a .dot exporter together. i think Celestar had one once upon a time.
-
- Engineer
- Posts: 18
- Joined: 04 Feb 2012 10:28
Re: Railway network graph exporter
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.
.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.
Re: Railway network graph exporter
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'?
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.
Re: Railway network graph exporter
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
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
Re: Railway network graph exporter
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.
- Redirect Left
- Tycoon
- Posts: 7249
- Joined: 22 Jan 2005 19:31
- Location: Wakefield, West Yorkshire
Re: Railway network graph exporter
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.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
-
- Engineer
- Posts: 18
- Joined: 04 Feb 2012 10:28
Re: Railway network graph exporter
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:
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?
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
Export my_savegame.sav to a basic graph.
Extract only passenger lines, and discard "subset railways" and "express railways" (see above)
Create a PDF file
Or, more simple:
Other OS
Should not be a problem, since all Code is written in C++.
Any thoughts/comments about this plan?
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
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
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.
Export my_savegame.sav to a basic graph.
Code: Select all
openttd -g my_savegame.sav -v graph > exported_graph.dot
Code: Select all
cat exported_graph.dot | openttd-graph-conv -cargo "passengers" -no-subset-railways -no-express-railways > my_savegame.dot
Code: Select all
dot -Tpdf my_savegame.dot > my_savegame.pdf
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
Should not be a problem, since all Code is written in C++.
Any thoughts/comments about this plan?
-
- Engineer
- Posts: 18
- Joined: 04 Feb 2012 10:28
Re: Railway network graph exporter
Hello,
two more questions:
two more questions:
- 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.
- 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?
- The exporter will use JSON instead of binary dumps. This is almost working now.
Re: Railway network graph exporter
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.
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.
-
- Engineer
- Posts: 18
- Joined: 04 Feb 2012 10:28
Re: Railway network graph exporter
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!
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!
Re: Railway network graph exporter
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?
Re: Railway network graph exporter
Could you upload a binary for those of those of us who want to test but arent comfortable compiling Openttd[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!
Who is online
Users browsing this forum: No registered users and 14 guests