Skip to content

Commit 7c96822

Browse files
committed
Use variables to enable/disable config generation
This avoids a luacheck warning, and is also easier to handle than commenting and uncommenting.
1 parent 0ce9ed7 commit 7c96822

File tree

2 files changed

+68
-58
lines changed

2 files changed

+68
-58
lines changed

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
-- ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)