From a646fb5052ecefc950694f10dfb3fa344531f5b8 Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Mon, 5 Feb 2024 17:01:08 -0800 Subject: [PATCH 1/2] Allow tilekiln generation to specify metadata Tilekiln configs can include optional data for the creation of a TileJSON document. All of the metadata is optional except for id, which is used for storage and construction of URLs. In the themepark config generation we set a default id, but otherwise it takes it from the options passed. --- .gitignore | 1 + config/shortbread.lua | 8 ++++++-- config/shortbread_gen.lua | 8 ++++++-- lua/themepark/plugins/tilekiln.lua | 6 +++--- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index f276d42..15604ad 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ t-rex-config.toml +shortbread_config diff --git a/config/shortbread.lua b/config/shortbread.lua index 186703d..a32fd3b 100644 --- a/config/shortbread.lua +++ b/config/shortbread.lua @@ -64,9 +64,13 @@ if osm2pgsql.mode == 'create' then -- 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 'tk'.) +-- (You must also create the directory 'shortbread_config'.) -- --- themepark:plugin('tilekiln'):write_config('tk') +-- themepark:plugin('tilekiln'):write_config('shortbread_config', { +-- tileset = 'shortbread_v1', +-- name = 'OpenStreetMap Shortbread', +-- attribution = '© OpenStreetMap' +-- }) -- Enable if you want to create a taginfo project file. -- diff --git a/config/shortbread_gen.lua b/config/shortbread_gen.lua index ffc55e0..7128d6f 100644 --- a/config/shortbread_gen.lua +++ b/config/shortbread_gen.lua @@ -96,9 +96,13 @@ if osm2pgsql.mode == 'create' then -- }) -- Enable if you want to create a config file for the Tilekiln tile server. --- (You must also create the directory 'tk'.) +-- (You must also create the directory 'shortbread_config'.) -- --- themepark:plugin('tilekiln'):write_config('tk') +-- themepark:plugin('tilekiln'):write_config('shortbread_config', { +-- tileset = 'shortbread_v1', +-- name = 'OpenStreetMap Shortbread', +-- attribution = '© OpenStreetMap' +-- }) end -- --------------------------------------------------------------------------- diff --git a/lua/themepark/plugins/tilekiln.lua b/lua/themepark/plugins/tilekiln.lua index be3492b..7896b9a 100644 --- a/lua/themepark/plugins/tilekiln.lua +++ b/lua/themepark/plugins/tilekiln.lua @@ -106,10 +106,10 @@ function plugin:write_config(directory, options) local config = { metadata = { - id = 'v1', - name = options.tileset or 'osm', + id = options.tileset or 'mytiles', + name = options.name, attribution = options.attribution or plugin.themepark.options.attribution, - version = '0.0.1', + version = options.version, }, vector_layers = {} } From c055e11d041ac94be405ee1a4049f6703da28c19 Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Mon, 5 Feb 2024 17:16:44 -0800 Subject: [PATCH 2/2] tilekiln: Make min/max zoom configurable and rely on defaults Make the minzoom and maxzoom configurable for tilesets that don't run the 0-14 range, and make extent and buffer_size only appear in the config when set in the Lua. When not present tilekiln will rely on its defaults. --- lua/themepark/plugins/tilekiln.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lua/themepark/plugins/tilekiln.lua b/lua/themepark/plugins/tilekiln.lua index 7896b9a..93974b9 100644 --- a/lua/themepark/plugins/tilekiln.lua +++ b/lua/themepark/plugins/tilekiln.lua @@ -33,10 +33,10 @@ local lyaml = require 'lyaml' function plugin:build_sublayer_config(main_layer, sub_layer) local config = { - minzoom = sub_layer.tiles.minzoom or 0, - maxzoom = sub_layer.tiles.maxzoom or 14, - extent = sub_layer.tiles.extent or 4096, - buffer = sub_layer.tiles.buffer_size or 10, + minzoom = sub_layer.tiles.minzoom or self.minzoom, + maxzoom = sub_layer.tiles.maxzoom or self.maxzoom, + extent = sub_layer.tiles.extent, + buffer = sub_layer.tiles.buffer_size, } local mvt = 'ST_AsMVTGeom("' .. sub_layer.geom_column .. '", {{unbuffered_bbox}}, {{extent}}, {{buffer}}) AS way' @@ -99,6 +99,8 @@ end function plugin:write_config(directory, options) self.directory = directory + self.minzoom = options.minzoom or 0 + self.maxzoom = options.maxzoom or 14 if not options then options = {}