Skip to content

Commit 5ec44a5

Browse files
authored
Merge pull request #6 from pnorman/ci
Fix luacheck errors and enable CI
2 parents afaa1a5 + 817e40a commit 5ec44a5

File tree

6 files changed

+95
-63
lines changed

6 files changed

+95
-63
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Check and run
2+
on: [push, pull_request]
3+
jobs:
4+
build:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v4
8+
- name: Install lua
9+
run: |
10+
sudo apt-get update -qq &&
11+
sudo apt-get install -qq --no-install-recommends lua5.3 lua-check
12+
- name: Check lua files
13+
run: bin/check-lua-scripts.sh
14+

config/shortbread.lua

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
--
77
-- ---------------------------------------------------------------------------
88

9+
-- Set these to true in order to create a config or taginfo file
10+
-- If you are creating a tilekiln config you must also create
11+
-- the 'shortbread_config' directory.
12+
local TREX = false
13+
local TILEKILN = false
14+
local TAGINFO = false
15+
916
local themepark = require('themepark')
1017

1118
themepark.debug = false
@@ -59,24 +66,23 @@ themepark:add_topic('shortbread_v1/addresses')
5966
-- Create config files only in create mode, not when updating the database.
6067
-- This protects the file in case it contains manual edits.
6168
if osm2pgsql.mode == 'create' then
62-
-- Enable if you want to create a config file for the T-Rex tile server.
63-
--
64-
-- themepark:plugin('t-rex'):write_config('t-rex-config.toml', {})
65-
66-
-- Enable if you want to create a config file for the Tilekiln tile server.
67-
-- (You must also create the directory 'shortbread_config'.)
68-
--
69-
-- themepark:plugin('tilekiln'):write_config('shortbread_config', {
70-
-- tileset = 'shortbread_v1',
71-
-- name = 'OpenStreetMap Shortbread',
72-
-- attribution = '<a href="https://www.openstreetmap.org/copyright">© OpenStreetMap</a>'
73-
-- })
74-
75-
-- Enable if you want to create a taginfo project file.
76-
--
77-
-- themepark:plugin('taginfo'):write_config('taginfo-shortbread', {
78-
-- project = { name = 'shortbread' }
79-
-- })
69+
if TREX then
70+
themepark:plugin('t-rex'):write_config('t-rex-config.toml', {})
71+
end
72+
73+
if TILEKILN then
74+
themepark:plugin('tilekiln'):write_config('shortbread_config', {
75+
tileset = 'shortbread_v1',
76+
name = 'OpenStreetMap Shortbread',
77+
attribution = '<a href="https://www.openstreetmap.org/copyright">© OpenStreetMap</a>'
78+
})
79+
end
80+
81+
if TAGINFO then
82+
themepark:plugin('taginfo'):write_config('taginfo-shortbread', {
83+
project = { name = 'shortbread' }
84+
})
85+
end
8086
end
8187

8288
-- ---------------------------------------------------------------------------

config/shortbread_gen.lua

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
--
77
-- ---------------------------------------------------------------------------
88

9+
-- Set these to true in order to create a config file
10+
-- If you are creating a tilekiln config you must also create
11+
-- the 'shortbread_config' directory.
12+
local TREX = false
13+
local TILEKILN = false
14+
915
local themepark = require('themepark')
1016

1117
themepark.debug = false
@@ -63,46 +69,44 @@ themepark:add_topic('shortbread_v1/addresses')
6369
-- Create config files only in create mode, not when updating the database.
6470
-- This protects the file in case it contains manual edits.
6571
if osm2pgsql.mode == 'create' then
66-
-- Enable if you want to create a config file for the T-Rex tile server
67-
--
68-
-- themepark:plugin('t-rex'):write_config('t-rex-config.toml', {
69-
-- tileset = 'osm',
70-
-- extra_layers = {
71-
-- {
72-
-- buffer_size = 10,
73-
-- name = 'street_labels',
74-
-- geometry_type = 'LINESTRING',
75-
-- query = {
76-
-- {
77-
-- minzoom = 14,
78-
-- sql = [[
79-
-- SELECT "name","name_de","name_en","kind","layer","ref","ref_rows","ref_cols","z_order","geom"
80-
-- FROM "streets"
81-
-- WHERE "geom" && !bbox! AND !zoom! >= "minzoom"
82-
-- ORDER BY "z_order" asc]]
83-
-- },
84-
-- {
85-
-- minzoom = 11,
86-
-- maxzoom = 13,
87-
-- sql = [[
88-
-- SELECT "name","name_de","name_en","kind","layer","ref","ref_rows","ref_cols","z_order","geom"
89-
-- FROM "streets_med"
90-
-- WHERE "geom" && !bbox! AND !zoom! >= "minzoom"
91-
-- ORDER BY "z_order" asc]]
92-
-- },
93-
-- }
94-
-- }
95-
-- }
96-
-- })
97-
98-
-- Enable if you want to create a config file for the Tilekiln tile server.
99-
-- (You must also create the directory 'shortbread_config'.)
100-
--
101-
-- themepark:plugin('tilekiln'):write_config('shortbread_config', {
102-
-- tileset = 'shortbread_v1',
103-
-- name = 'OpenStreetMap Shortbread',
104-
-- attribution = '<a href="https://www.openstreetmap.org/copyright">© OpenStreetMap</a>'
105-
-- })
72+
if TREX then
73+
themepark:plugin('t-rex'):write_config('t-rex-config.toml', {
74+
tileset = 'osm',
75+
extra_layers = {
76+
{
77+
buffer_size = 10,
78+
name = 'street_labels',
79+
geometry_type = 'LINESTRING',
80+
query = {
81+
{
82+
minzoom = 14,
83+
sql = [[
84+
SELECT "name","name_de","name_en","kind","layer","ref","ref_rows","ref_cols","z_order","geom"
85+
FROM "streets"
86+
WHERE "geom" && !bbox! AND !zoom! >= "minzoom"
87+
ORDER BY "z_order" asc]]
88+
},
89+
{
90+
minzoom = 11,
91+
maxzoom = 13,
92+
sql = [[
93+
SELECT "name","name_de","name_en","kind","layer","ref","ref_rows","ref_cols","z_order","geom"
94+
FROM "streets_med"
95+
WHERE "geom" && !bbox! AND !zoom! >= "minzoom"
96+
ORDER BY "z_order" asc]]
97+
},
98+
}
99+
}
100+
}
101+
})
102+
end
103+
if TILEKILN then
104+
themepark:plugin('tilekiln'):write_config('shortbread_config', {
105+
tileset = 'shortbread_v1',
106+
name = 'OpenStreetMap Shortbread',
107+
attribution = '<a href="https://www.openstreetmap.org/copyright">© OpenStreetMap</a>'
108+
})
109+
end
106110
end
107111

108112
-- ---------------------------------------------------------------------------

themes/shortbread_v1_gen/topics/boundaries.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,17 @@ end)
193193
local function gen_commands(sql, level)
194194
local c = gen_config[level]
195195

196-
table.insert(sql, 'CREATE TABLE {schema}.boundaries_' .. level .. '_new (LIKE {schema}.boundaries_' .. level .. ' INCLUDING IDENTITY)')
196+
table.insert(sql, 'CREATE TABLE {schema}.boundaries_' .. level ..
197+
'_new (LIKE {schema}.boundaries_' .. level .. ' INCLUDING IDENTITY)')
197198

198199
table.insert(sql, [[
199200
WITH simplified AS (
200201
SELECT way_ids, relation_ids, admin_level, maritime, disputed, ST_SimplifyVW(geom, ]] .. c.simplify .. [[) AS geom
201202
FROM {schema}.boundaries ]] .. c.condition .. [[
202203
)
203204
INSERT INTO {schema}.boundaries_]] .. level .. [[_new (way_ids, relation_ids, admin_level, maritime, disputed, geom)
204-
SELECT way_ids, relation_ids, admin_level, maritime, disputed, geom FROM simplified WHERE ST_Length(geom) > ]] .. c.minlength)
205+
SELECT way_ids, relation_ids, admin_level, maritime, disputed, geom
206+
FROM simplified WHERE ST_Length(geom) > ]] .. c.minlength)
205207

206208
table.insert(sql, 'ANALYZE {schema}.boundaries_' .. level .. '_new')
207209
table.insert(sql, 'CREATE INDEX ON {schema}.boundaries_' .. level .. '_new USING GIST (geom)')

themes/shortbread_v1_gen/topics/streets.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,9 @@ themepark:add_proc('gen', function(data)
424424
description = 'Merge street lines for medium zoom levels',
425425
transaction = true,
426426
sql = {
427-
themepark.expand_template('CREATE TABLE {schema}.streets_med_new (LIKE {schema}.streets_med INCLUDING IDENTITY)'),
427+
themepark.expand_template([[
428+
CREATE TABLE {schema}.streets_med_new
429+
(LIKE {schema}.streets_med INCLUDING IDENTITY)]]),
428430
themepark.expand_template([[
429431
CREATE OR REPLACE FUNCTION osm2pgsql_shortbread_streets_med() RETURNS void AS $$
430432
DECLARE
@@ -469,7 +471,9 @@ $$ LANGUAGE plpgsql]]),
469471
description = 'Merge street lines for low zoom levels',
470472
transaction = true,
471473
sql = {
472-
themepark.expand_template('CREATE TABLE {schema}.streets_low_new (LIKE {schema}.streets_low INCLUDING IDENTITY)'),
474+
themepark.expand_template([[
475+
CREATE TABLE {schema}.streets_low_new
476+
(LIKE {schema}.streets_low INCLUDING IDENTITY)]]),
473477
themepark.expand_template([[
474478
WITH
475479
merged AS

themes/shortbread_v1_gen/topics/water.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,9 @@ themepark:add_proc('gen', function(data)
268268
if_has_rows = themepark.expand_template('SELECT 1 FROM {schema}.expire_water_lines LIMIT 1'),
269269
transaction = true,
270270
sql = {
271-
themepark.expand_template('CREATE TABLE {schema}.water_lines_gen_new (LIKE {schema}.water_lines_gen INCLUDING IDENTITY)'),
271+
themepark.expand_template([[
272+
CREATE TABLE {schema}.water_lines_gen_new
273+
(LIKE {schema}.water_lines_gen INCLUDING IDENTITY)]]),
272274
themepark.expand_template([[
273275
WITH merged AS
274276
(SELECT ]] .. name_list .. [[, kind, tunnel, bridge, ST_LineMerge(ST_Collect(geom)) AS geom

0 commit comments

Comments
 (0)