-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTupfile-simplify.lua
More file actions
33 lines (30 loc) · 827 Bytes
/
Tupfile-simplify.lua
File metadata and controls
33 lines (30 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
tup.include("Tupfile-consts.lua")
files = tup.glob("data/*_makevalid.gpkg")
output_dir = "data/"
min_level = 3
max_level = 8
function generate_levels(n, m)
local levels = {}
for i = n, m do
table.insert(levels, string.format('%.6f', 10^(3 - i)))
end
return table.concat(levels, ",")
end
for i = 1, #files do
input = files[i]
fullbase = tup.base(input)
base = fullbase:gsub("%_makevalid", "")
for j = min_level, max_level do
inputs = {"$(simplify)", input}
levels = generate_levels(j, 8)
output = output_dir .. base .. "_s" .. j .. "_wkb.gpkg"
cmd =
'^s^ $(simplify) ' ..
' -table ' .. table_from_base(base) ..
' -levels ' .. levels ..
' -minpoints $(simplify_minpoints) ' ..
' -o ' .. output ..
' ' .. input
tup.rule(inputs, cmd, output)
end
end