From 61fbbc59093065ec6adf39cf056d219862aaff8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20P=C3=A9rez-Cerezo?= Date: Thu, 21 Feb 2019 12:29:00 +0100 Subject: 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. --- main.lua | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/main.lua b/main.lua index 6699cf7..6f2abfa 100644 --- a/main.lua +++ b/main.lua @@ -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("") + if v.line then + svgfile:write(" "..v.line.."") + end + trains = trains+1 +end + svgfile:write("") 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") -- cgit v1.2.3