Progress
This commit is contained in:
parent
69245c49c5
commit
56d03692df
11
main.lua
11
main.lua
@ -5,7 +5,7 @@
|
|||||||
local maxc = 5000
|
local maxc = 5000
|
||||||
|
|
||||||
-- embed an image called "world.png"
|
-- embed an image called "world.png"
|
||||||
local wimg = false
|
local wimg = true
|
||||||
-- image file resolution (not world resolution!)
|
-- image file resolution (not world resolution!)
|
||||||
local wimresx = 3000
|
local wimresx = 3000
|
||||||
local wimresy = 3000
|
local wimresy = 3000
|
||||||
@ -124,7 +124,7 @@ if wimg then
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function writec(text)
|
local function writec(text)
|
||||||
print(text)
|
--print("\n"..text)
|
||||||
svgfile:write("<!-- " .. text .. " -->\n")
|
svgfile:write("<!-- " .. text .. " -->\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -137,6 +137,7 @@ end
|
|||||||
-- Note that the node at "pos" is already deleted from the NDB at the time of recall, therefore "conn" is specified
|
-- Note that the node at "pos" is already deleted from the NDB at the time of recall, therefore "conn" is specified
|
||||||
local bfs_rsp = {}
|
local bfs_rsp = {}
|
||||||
|
|
||||||
|
local ndb_nodes_handled = 0
|
||||||
|
|
||||||
-- Points of the current polyline. Inserted as xyz vectors, maybe we'll use the y value one day
|
-- Points of the current polyline. Inserted as xyz vectors, maybe we'll use the y value one day
|
||||||
local current_polyline = {}
|
local current_polyline = {}
|
||||||
@ -173,12 +174,14 @@ local function gen_rsp_polyline(rsp)
|
|||||||
--writec("Saved pos: "..pts(adj_pos).." mainbranch cont "..conn_mainbranch.." nextconns "..atdump(next_conns))
|
--writec("Saved pos: "..pts(adj_pos).." mainbranch cont "..conn_mainbranch.." nextconns "..atdump(next_conns))
|
||||||
current_polyline[#current_polyline+1] = adj_pos
|
current_polyline[#current_polyline+1] = adj_pos
|
||||||
advtrains.ndb.clear(adj_pos)
|
advtrains.ndb.clear(adj_pos)
|
||||||
|
ndb_nodes_handled = ndb_nodes_handled + 1
|
||||||
|
|
||||||
pos, connid, conns = adj_pos, conn_mainbranch, next_conns
|
pos, connid, conns = adj_pos, conn_mainbranch, next_conns
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
plcnt = 0
|
||||||
|
|
||||||
local function polyline_write(pl)
|
local function polyline_write(pl)
|
||||||
local str = {'<polyline style="fill:none;stroke:black;stroke-width:1" points="'}
|
local str = {'<polyline style="fill:none;stroke:black;stroke-width:1" points="'}
|
||||||
@ -195,6 +198,7 @@ local function polyline_write(pl)
|
|||||||
table.insert(str, '" />\n')
|
table.insert(str, '" />\n')
|
||||||
|
|
||||||
svgfile:write(table.concat(str))
|
svgfile:write(table.concat(str))
|
||||||
|
plcnt = plcnt + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -222,6 +226,8 @@ while stpos do
|
|||||||
gen_rsp_polyline(current_rsp)
|
gen_rsp_polyline(current_rsp)
|
||||||
|
|
||||||
polyline_write(current_polyline)
|
polyline_write(current_polyline)
|
||||||
|
|
||||||
|
io.write("Progress ", ndb_nodes_handled, "+", ndb_nodes_notrack, "/", ndb_nodes_total, "=", math.floor(((ndb_nodes_handled+ndb_nodes_notrack)/ndb_nodes_total)*100), "%\r")
|
||||||
end
|
end
|
||||||
stpos, conns = advtrains.ndb.mapper_find_starting_point()
|
stpos, conns = advtrains.ndb.mapper_find_starting_point()
|
||||||
end
|
end
|
||||||
@ -229,3 +235,4 @@ end
|
|||||||
svgfile:write("</svg>")
|
svgfile:write("</svg>")
|
||||||
svgfile:close()
|
svgfile:close()
|
||||||
|
|
||||||
|
print("\nWrote",plcnt,"polylines. Processed", ndb_nodes_handled, "track,",ndb_nodes_notrack, "non-track nodes out of", ndb_nodes_total)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
--nodedb.lua
|
--nodedb.lua
|
||||||
--database of all nodes that have 'save_in_at_nodedb' field set to true in node definition
|
--database of all nodes that have 'save_in_at_nodedb' field set to true in node definition
|
||||||
|
|
||||||
|
ndb_nodes_notrack = 0
|
||||||
|
|
||||||
--serialization format:
|
--serialization format:
|
||||||
--(2byte z) (2byte y) (2byte x) (2byte contentid)
|
--(2byte z) (2byte y) (2byte x) (2byte contentid)
|
||||||
@ -75,6 +76,7 @@ function ndb.load_data(data)
|
|||||||
cid=file:read(2)
|
cid=file:read(2)
|
||||||
end
|
end
|
||||||
print("nodedb: read", cnt, "nodes.")
|
print("nodedb: read", cnt, "nodes.")
|
||||||
|
ndb_nodes_total = cnt
|
||||||
file:close()
|
file:close()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -153,6 +155,7 @@ function ndb.mapper_find_starting_point()
|
|||||||
else
|
else
|
||||||
-- this is a signal or something similar, ignore.
|
-- this is a signal or something similar, ignore.
|
||||||
tx[z]=nil
|
tx[z]=nil
|
||||||
|
ndb_nodes_notrack = ndb_nodes_notrack + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user