diff options
author | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2019-02-21 12:29:00 +0100 |
---|---|---|
committer | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2019-02-21 12:29:00 +0100 |
commit | 61fbbc59093065ec6adf39cf056d219862aaff8e (patch) | |
tree | c551bb66454b072717b26cd5b3e8c7863e1ddfdd | |
parent | b6c5604dcf53f43a64243feaa654a7b422d1bfa9 (diff) | |
download | advtrains_netmapper-61fbbc59093065ec6adf39cf056d219862aaff8e.tar.gz advtrains_netmapper-61fbbc59093065ec6adf39cf056d219862aaff8e.tar.bz2 advtrains_netmapper-61fbbc59093065ec6adf39cf056d219862aaff8e.zip |
Draw trains
Trains get drawn now as small circles, the line number gets drawn next
to the train. Moving trains are green, stopped trains are orange.
-rw-r--r-- | main.lua | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -100,7 +100,7 @@ if type(tbl) ~= "table" then error("not a table") end if tbl.version then - + advtrains.trains = tbl.trains advtrains.ndb.load_data(tbl.ndb) else @@ -302,7 +302,23 @@ while stpos do stpos, conns = advtrains.ndb.mapper_find_starting_point() end +-- draw trains +trains = 0 +for i,v in pairs(advtrains.trains) do + pos = v.last_pos + color = "green" + if v.velocity == 0 then + color = "orange" + end + svgfile:write("<circle cx=\""..pos.x.."\" cy=\""..-pos.z.."\" r=\"3\" stroke=\""..color.."\" stroke-width=\"1\" fill=\"none\" />") + if v.line then + svgfile:write(" <text x=\""..(pos.x+5).."\" y=\""..-pos.z.."\" class=\"trainline\">"..v.line.."</text>") + end + trains = trains+1 +end + svgfile:write("</svg>") svgfile:close() print("\nWrote",plcnt,"polylines. Processed", ndb_nodes_handled, "track,",ndb_nodes_notrack, "non-track nodes out of", ndb_nodes_total) +print("Drew "..trains.." trains") |