Example lines and import
Example lines
Section titled “Example lines”content::musterbahn() — 7 km: 3 km straight (160 km/h), 1 km curve R = 1200 m with cant
ramp (130 km/h), 3 km at 8 ‰ gradient. Block signal at km 2.0 with distant signal,
1000/500/2000 Hz magnets, and over the last 4 km an LZB loop cable with block markers of its
own, so the LZB area runs in full block mode. A portal at each end says where trains come
from and where they go.
mods/example/lines/beispielstrecke.ron is the hand-written one, and the one to shunt on:
4 km of running road with a Ks main signal and a semaphore, then a turnout at km 4.0 into a
stabling siding, with a portal at each end of the line.
Importing a line
Section titled “Importing a line”Export track data from Overpass Turbo as JSON:
[out:json];way["railway"="rail"](50.90,10.00,51.00,10.30);(._;>;);out body;Taken from OSM are the geometry of the railway=rail ways, maxspeed and name.
Switches, signals, platforms and level crossings are not carried over (yet) — the line is
created as a single strand and is then equipped in the RON file.
The point sequence does not become a smoothed curve but an alignment: straight sections
and curves are separated, the radius is averaged over the whole curve (point noise cancels
out with √n) and rounded to the nearest standard radius if it is close enough. Transition
curves and cant cannot be measured from OSM and therefore come from the rulebook:
c = 11.8 · v²/R minus the permitted cant deficiency, capped at 160 mm, ramp length 1:10·v.
The result is a chain of straight – clothoid – circular arc – clothoid – straight.
Limits worth knowing: OSM is accurate to ±2…5 m from aerial imagery, and the start and end of a curve can only be determined to about ten metres from a point sequence. Radius, turn angle and cant, on the other hand, are hit precisely — exactly the quantities you feel while driving. The import report lists radii, cant and the deviation from the OSM line.
Elevations come from the state DGM data. --dgm takes a file or an entire directory
of tile sheets (subdirectories included):
cargo run -p content --bin import-line -- line.json --dgm ./dgm1_niedersachsen --epsg 25832 --name "Musterbahn" --out line.ron| Option | Default | Effect |
|---|---|---|
--dgm <path>, --epsg <code> |
none, 25832 |
height data and its coordinate system; without --dgm the line is flat |
--name <name> |
empty | the line’s name |
--track-type <mod:name> |
example:b70 |
the track type every imported edge is built of |
--sample <m> |
20 | distance between the support points the alignment is fitted to |
--smoothing <n> |
2 | smoothing window of the curvature, in points per side |
--no-snap |
off | keep the fitted radii instead of rounding them to the standard series |
--max-cant <mm> |
160 | the highest permitted cant |
--start-way <id> |
the OSM way ID the chain of ways starts at | |
--out <file> |
the RON file to write |
The result is an ordinary line file: put it into mods/<id>/lines/, open it in the
route editor (File ▸ Open module…) and finish it there — see
Building a line.
Supported are XYZ (x y z, UTM), ESRI ASCII Grid (.asc) and GeoTIFF (.tif, the
single-band float tiles NRW delivers). Sheet boundaries are read from
the file name (dgm1_32_389_5711_1_ni.xyz), so nothing is loaded at startup; each tile only
enters memory once a query falls into it, and at most eight stay loaded at a time. This makes
even a DGM1 of an entire federal state (several thousand tiles) usable.
The tool reports length, edge count, elevation coverage and the largest deviation of the alignment from the OSM points. Heights can also be pulled in later from inside the route editor: the DGM tile tool shows the elevation tile grid and imports either the picked tiles or the whole corridor.