Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Check and run
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install lua
run: |
sudo apt-get update -qq &&
sudo apt-get install -qq --no-install-recommends lua5.3 lua-check
- name: Check lua files
run: bin/check-lua-scripts.sh

42 changes: 24 additions & 18 deletions config/shortbread.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
--
-- ---------------------------------------------------------------------------

-- Set these to true in order to create a config or taginfo file
-- If you are creating a tilekiln config you must also create
-- the 'shortbread_config' directory.
local TREX = false
local TILEKILN = false
local TAGINFO = false

local themepark = require('themepark')

themepark.debug = false
Expand Down Expand Up @@ -59,24 +66,23 @@ themepark:add_topic('shortbread_v1/addresses')
-- Create config files only in create mode, not when updating the database.
-- This protects the file in case it contains manual edits.
if osm2pgsql.mode == 'create' then
-- Enable if you want to create a config file for the T-Rex tile server.
--
-- themepark:plugin('t-rex'):write_config('t-rex-config.toml', {})

-- Enable if you want to create a config file for the Tilekiln tile server.
-- (You must also create the directory 'shortbread_config'.)
--
-- themepark:plugin('tilekiln'):write_config('shortbread_config', {
-- tileset = 'shortbread_v1',
-- name = 'OpenStreetMap Shortbread',
-- attribution = '<a href="https://www.openstreetmap.org/copyright">© OpenStreetMap</a>'
-- })

-- Enable if you want to create a taginfo project file.
--
-- themepark:plugin('taginfo'):write_config('taginfo-shortbread', {
-- project = { name = 'shortbread' }
-- })
if TREX then
themepark:plugin('t-rex'):write_config('t-rex-config.toml', {})
end

if TILEKILN then
themepark:plugin('tilekiln'):write_config('shortbread_config', {
tileset = 'shortbread_v1',
name = 'OpenStreetMap Shortbread',
attribution = '<a href="https://www.openstreetmap.org/copyright">© OpenStreetMap</a>'
})
end

if TAGINFO then
themepark:plugin('taginfo'):write_config('taginfo-shortbread', {
project = { name = 'shortbread' }
})
end
end

-- ---------------------------------------------------------------------------
84 changes: 44 additions & 40 deletions config/shortbread_gen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
--
-- ---------------------------------------------------------------------------

-- Set these to true in order to create a config file
-- If you are creating a tilekiln config you must also create
-- the 'shortbread_config' directory.
local TREX = false
local TILEKILN = false

local themepark = require('themepark')

themepark.debug = false
Expand Down Expand Up @@ -63,46 +69,44 @@ themepark:add_topic('shortbread_v1/addresses')
-- Create config files only in create mode, not when updating the database.
-- This protects the file in case it contains manual edits.
if osm2pgsql.mode == 'create' then
-- Enable if you want to create a config file for the T-Rex tile server
--
-- themepark:plugin('t-rex'):write_config('t-rex-config.toml', {
-- tileset = 'osm',
-- extra_layers = {
-- {
-- buffer_size = 10,
-- name = 'street_labels',
-- geometry_type = 'LINESTRING',
-- query = {
-- {
-- minzoom = 14,
-- sql = [[
-- SELECT "name","name_de","name_en","kind","layer","ref","ref_rows","ref_cols","z_order","geom"
-- FROM "streets"
-- WHERE "geom" && !bbox! AND !zoom! >= "minzoom"
-- ORDER BY "z_order" asc]]
-- },
-- {
-- minzoom = 11,
-- maxzoom = 13,
-- sql = [[
-- SELECT "name","name_de","name_en","kind","layer","ref","ref_rows","ref_cols","z_order","geom"
-- FROM "streets_med"
-- WHERE "geom" && !bbox! AND !zoom! >= "minzoom"
-- ORDER BY "z_order" asc]]
-- },
-- }
-- }
-- }
-- })

-- Enable if you want to create a config file for the Tilekiln tile server.
-- (You must also create the directory 'shortbread_config'.)
--
-- themepark:plugin('tilekiln'):write_config('shortbread_config', {
-- tileset = 'shortbread_v1',
-- name = 'OpenStreetMap Shortbread',
-- attribution = '<a href="https://www.openstreetmap.org/copyright">© OpenStreetMap</a>'
-- })
if TREX then
themepark:plugin('t-rex'):write_config('t-rex-config.toml', {
tileset = 'osm',
extra_layers = {
{
buffer_size = 10,
name = 'street_labels',
geometry_type = 'LINESTRING',
query = {
{
minzoom = 14,
sql = [[
SELECT "name","name_de","name_en","kind","layer","ref","ref_rows","ref_cols","z_order","geom"
FROM "streets"
WHERE "geom" && !bbox! AND !zoom! >= "minzoom"
ORDER BY "z_order" asc]]
},
{
minzoom = 11,
maxzoom = 13,
sql = [[
SELECT "name","name_de","name_en","kind","layer","ref","ref_rows","ref_cols","z_order","geom"
FROM "streets_med"
WHERE "geom" && !bbox! AND !zoom! >= "minzoom"
ORDER BY "z_order" asc]]
},
}
}
}
})
end
if TILEKILN then
themepark:plugin('tilekiln'):write_config('shortbread_config', {
tileset = 'shortbread_v1',
name = 'OpenStreetMap Shortbread',
attribution = '<a href="https://www.openstreetmap.org/copyright">© OpenStreetMap</a>'
})
end
end

-- ---------------------------------------------------------------------------
6 changes: 4 additions & 2 deletions themes/shortbread_v1_gen/topics/boundaries.lua
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,17 @@ end)
local function gen_commands(sql, level)
local c = gen_config[level]

table.insert(sql, 'CREATE TABLE {schema}.boundaries_' .. level .. '_new (LIKE {schema}.boundaries_' .. level .. ' INCLUDING IDENTITY)')
table.insert(sql, 'CREATE TABLE {schema}.boundaries_' .. level ..
'_new (LIKE {schema}.boundaries_' .. level .. ' INCLUDING IDENTITY)')

table.insert(sql, [[
WITH simplified AS (
SELECT way_ids, relation_ids, admin_level, maritime, disputed, ST_SimplifyVW(geom, ]] .. c.simplify .. [[) AS geom
FROM {schema}.boundaries ]] .. c.condition .. [[
)
INSERT INTO {schema}.boundaries_]] .. level .. [[_new (way_ids, relation_ids, admin_level, maritime, disputed, geom)
SELECT way_ids, relation_ids, admin_level, maritime, disputed, geom FROM simplified WHERE ST_Length(geom) > ]] .. c.minlength)
SELECT way_ids, relation_ids, admin_level, maritime, disputed, geom
FROM simplified WHERE ST_Length(geom) > ]] .. c.minlength)

table.insert(sql, 'ANALYZE {schema}.boundaries_' .. level .. '_new')
table.insert(sql, 'CREATE INDEX ON {schema}.boundaries_' .. level .. '_new USING GIST (geom)')
Expand Down
8 changes: 6 additions & 2 deletions themes/shortbread_v1_gen/topics/streets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,9 @@ themepark:add_proc('gen', function(data)
description = 'Merge street lines for medium zoom levels',
transaction = true,
sql = {
themepark.expand_template('CREATE TABLE {schema}.streets_med_new (LIKE {schema}.streets_med INCLUDING IDENTITY)'),
themepark.expand_template([[
CREATE TABLE {schema}.streets_med_new
(LIKE {schema}.streets_med INCLUDING IDENTITY)]]),
themepark.expand_template([[
CREATE OR REPLACE FUNCTION osm2pgsql_shortbread_streets_med() RETURNS void AS $$
DECLARE
Expand Down Expand Up @@ -469,7 +471,9 @@ $$ LANGUAGE plpgsql]]),
description = 'Merge street lines for low zoom levels',
transaction = true,
sql = {
themepark.expand_template('CREATE TABLE {schema}.streets_low_new (LIKE {schema}.streets_low INCLUDING IDENTITY)'),
themepark.expand_template([[
CREATE TABLE {schema}.streets_low_new
(LIKE {schema}.streets_low INCLUDING IDENTITY)]]),
themepark.expand_template([[
WITH
merged AS
Expand Down
4 changes: 3 additions & 1 deletion themes/shortbread_v1_gen/topics/water.lua
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ themepark:add_proc('gen', function(data)
if_has_rows = themepark.expand_template('SELECT 1 FROM {schema}.expire_water_lines LIMIT 1'),
transaction = true,
sql = {
themepark.expand_template('CREATE TABLE {schema}.water_lines_gen_new (LIKE {schema}.water_lines_gen INCLUDING IDENTITY)'),
themepark.expand_template([[
CREATE TABLE {schema}.water_lines_gen_new
(LIKE {schema}.water_lines_gen INCLUDING IDENTITY)]]),
themepark.expand_template([[
WITH merged AS
(SELECT ]] .. name_list .. [[, kind, tunnel, bridge, ST_LineMerge(ST_Collect(geom)) AS geom
Expand Down