-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTupfile-compress.lua
37 lines (30 loc) · 998 Bytes
/
Tupfile-compress.lua
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
34
35
36
37
tup.include("Tupfile-consts.lua")
files = tup.glob("data/*_s?_wkb.gpkg")
output_dir = "data/"
minprecxy = 3
for i = 1, #files do
input = files[i]
fullbase = tup.base(input)
base = fullbase:sub(1, -8)
simplify = fullbase:sub(-6, -5)
sqltable = basetotablemap[base] or base
-- -- Compress to TWKB
inputs = {"$(tgpkg)", input}
output = output_dir .. base .. "_" .. simplify .. "_twkb_p" .. minprecxy .. ".gpkg"
cmd = '^s^ $(tgpkg) ' ..
' -table ' .. table_from_base(base) ..
' -minprecxy ' .. minprecxy ..
' -o ' .. output ..
' compress ' .. input
tup.rule(inputs, cmd, output)
twkb_output = output
-- Decompress TWKB as a roundtrip test
inputs = {"$(tgpkg)", twkb_output}
output = output_dir .. base .. "_roundtrip_" .. simplify .. "_twkb_p" .. minprecxy .. ".gpkg"
cmd = '^s^ $(tgpkg) ' ..
' -table ' .. table_from_base(base) ..
' -minprecxy ' .. minprecxy ..
' -o ' .. output ..
' decompress ' .. twkb_output
tup.rule(inputs, cmd, output)
end