From 80d369938355d02277ce183b0e5c178fdce9eaee Mon Sep 17 00:00:00 2001 From: acalcutt Date: Tue, 20 Sep 2022 23:12:01 -0400 Subject: [PATCH 1/4] try to make a separate static renderer pool --- src/serve_rendered.js | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/serve_rendered.js b/src/serve_rendered.js index 39b6df5..766e3ce 100644 --- a/src/serve_rendered.js +++ b/src/serve_rendered.js @@ -229,9 +229,7 @@ module.exports = { const app = express().disable('x-powered-by'); - const respondImage = (item, z, lon, lat, bearing, pitch, - width, height, scale, format, res, next, - opt_overlay) => { + const respondImage = (item, z, lon, lat, bearing, pitch, width, height, scale, format, res, next, opt_overlay, opt_mode="tile") => { if (Math.abs(lon) > 180 || Math.abs(lat) > 85.06 || lon !== lon || lat !== lat) { return res.status(400).send('Invalid center'); @@ -248,7 +246,12 @@ module.exports = { return res.status(400).send('Invalid format'); } - const pool = item.map.renderers[scale]; + let pool; + if (opt_mode == 'tile') { + pool = item.map.renderers[scale]; + } else { + pool = item.map.renderers_static[scale]; + } pool.acquire((err, renderer) => { const mbglZ = Math.max(0, z - 1); const params = { @@ -383,8 +386,7 @@ module.exports = { ((x + 0.5) / (1 << z)) * (256 << z), ((y + 0.5) / (1 << z)) * (256 << z) ], z); - return respondImage(item, z, tileCenter[0], tileCenter[1], 0, 0, - tileSize, tileSize, scale, format, res, next); + return respondImage(item, z, tileCenter[0], tileCenter[1], 0, 0, tileSize, tileSize, scale, format, res, next); }); if (options.serveStaticMaps !== false) { @@ -426,11 +428,9 @@ module.exports = { } const path = extractPathFromQuery(req.query, transformer); - const overlay = renderOverlay(z, x, y, bearing, pitch, w, h, scale, - path, req.query); + const overlay = renderOverlay(z, x, y, bearing, pitch, w, h, scale, path, req.query); - return respondImage(item, z, x, y, bearing, pitch, w, h, scale, format, - res, next, overlay); + return respondImage(item, z, x, y, bearing, pitch, w, h, scale, format, res, next, overlay, "static"); }); const serveBounds = (req, res, next) => { @@ -468,10 +468,8 @@ module.exports = { pitch = 0; const path = extractPathFromQuery(req.query, transformer); - const overlay = renderOverlay(z, x, y, bearing, pitch, w, h, scale, - path, req.query); - return respondImage(item, z, x, y, bearing, pitch, w, h, scale, format, - res, next, overlay); + const overlay = renderOverlay(z, x, y, bearing, pitch, w, h, scale, path, req.query); + return respondImage(item, z, x, y, bearing, pitch, w, h, scale, format, res, next, overlay); }; const boundsPattern = @@ -542,11 +540,9 @@ module.exports = { x = center[0], y = center[1]; - const overlay = renderOverlay(z, x, y, bearing, pitch, w, h, scale, - path, req.query); + const overlay = renderOverlay(z, x, y, bearing, pitch, w, h, scale, path, req.query); - return respondImage(item, z, x, y, bearing, pitch, w, h, scale, format, - res, next, overlay); + return respondImage(item, z, x, y, bearing, pitch, w, h, scale, format, res, next, overlay); }); } @@ -566,14 +562,15 @@ module.exports = { add: (options, repo, params, id, publicUrl, dataResolver) => { const map = { renderers: [], + renderers_static: [], sources: {} }; let styleJSON; - const createPool = (ratio, min, max) => { + const createPool = (ratio, mode, min, max) => { const createRenderer = (ratio, createCallback) => { const renderer = new mbgl.Map({ - mode: "tile", + mode: mode, ratio: ratio, request: (req, callback) => { const protocol = req.url.split(':')[0]; @@ -814,7 +811,8 @@ module.exports = { const j = Math.min(maxPoolSizes.length - 1, s - 1); const minPoolSize = minPoolSizes[i]; const maxPoolSize = Math.max(minPoolSize, maxPoolSizes[j]); - map.renderers[s] = createPool(s, minPoolSize, maxPoolSize); + map.renderers[s] = createPool(s, "tile", minPoolSize, maxPoolSize); + map.renderers_static[s] = createPool(s, "static", minPoolSize, maxPoolSize); } }); @@ -826,6 +824,9 @@ module.exports = { item.map.renderers.forEach(pool => { pool.close(); }); + item.map.renderers_static.forEach(pool => { + pool.close(); + }); } delete repo[id]; }, From c1e9dc76eafd142becbc4cc7788b96a773231f66 Mon Sep 17 00:00:00 2001 From: acalcutt Date: Tue, 20 Sep 2022 23:33:51 -0400 Subject: [PATCH 2/4] more static respondImage --- src/serve_rendered.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/serve_rendered.js b/src/serve_rendered.js index 766e3ce..59d9d5f 100644 --- a/src/serve_rendered.js +++ b/src/serve_rendered.js @@ -247,7 +247,7 @@ module.exports = { } let pool; - if (opt_mode == 'tile') { + if (opt_mode === 'tile') { pool = item.map.renderers[scale]; } else { pool = item.map.renderers_static[scale]; @@ -469,7 +469,7 @@ module.exports = { const path = extractPathFromQuery(req.query, transformer); const overlay = renderOverlay(z, x, y, bearing, pitch, w, h, scale, path, req.query); - return respondImage(item, z, x, y, bearing, pitch, w, h, scale, format, res, next, overlay); + return respondImage(item, z, x, y, bearing, pitch, w, h, scale, format, res, next, overlay, "static"); }; const boundsPattern = @@ -542,7 +542,7 @@ module.exports = { const overlay = renderOverlay(z, x, y, bearing, pitch, w, h, scale, path, req.query); - return respondImage(item, z, x, y, bearing, pitch, w, h, scale, format, res, next, overlay); + return respondImage(item, z, x, y, bearing, pitch, w, h, scale, format, res, next, overlay, "static"); }); } From 5a4268fcc188a401bbe691e8cd7da8951ffdaa1e Mon Sep 17 00:00:00 2001 From: Petr Pridal Date: Wed, 21 Sep 2022 16:20:31 +0200 Subject: [PATCH 3/4] Update conf.py --- docs/conf.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 688edca..2f315ea 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -44,7 +44,7 @@ master_doc = 'index' # General information about the project. project = u'TileServer GL' -copyright = u'2016, Klokan Technologies GmbH' +copyright = u'2022, MapTiler.com' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -197,7 +197,7 @@ latex_elements = { # author, documentclass [howto, manual, or own class]). latex_documents = [ ('index', 'TileServerGL.tex', u'TileServer GL Documentation', - u'Klokan Technologies GmbH', 'manual'), + u'MapTiler.com', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -227,7 +227,7 @@ latex_documents = [ # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'tileservergl', u'TileServer GL Documentation', - [u'Klokan Technologies GmbH'], 1) + [u'MapTiler.com'], 1) ] # If true, show URL addresses after external links. @@ -241,7 +241,7 @@ man_pages = [ # dir menu entry, description, category) texinfo_documents = [ ('index', 'TileServerGL', u'TileServer GL Documentation', - u'Klokan Technologies GmbH', 'TileServerGL', 'One line description of project.', + u'MapTiler.com', 'TileServerGL', 'One line description of project.', 'Miscellaneous'), ] From 8584a117fe9893a091e560f0369dc8a08404d6ce Mon Sep 17 00:00:00 2001 From: acalcutt Date: Wed, 21 Sep 2022 10:31:57 -0400 Subject: [PATCH 4/4] change to single quotes --- src/serve_rendered.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/serve_rendered.js b/src/serve_rendered.js index 59d9d5f..3a264fd 100644 --- a/src/serve_rendered.js +++ b/src/serve_rendered.js @@ -229,7 +229,7 @@ module.exports = { const app = express().disable('x-powered-by'); - const respondImage = (item, z, lon, lat, bearing, pitch, width, height, scale, format, res, next, opt_overlay, opt_mode="tile") => { + const respondImage = (item, z, lon, lat, bearing, pitch, width, height, scale, format, res, next, opt_overlay, opt_mode='tile') => { if (Math.abs(lon) > 180 || Math.abs(lat) > 85.06 || lon !== lon || lat !== lat) { return res.status(400).send('Invalid center'); @@ -430,7 +430,7 @@ module.exports = { const path = extractPathFromQuery(req.query, transformer); const overlay = renderOverlay(z, x, y, bearing, pitch, w, h, scale, path, req.query); - return respondImage(item, z, x, y, bearing, pitch, w, h, scale, format, res, next, overlay, "static"); + return respondImage(item, z, x, y, bearing, pitch, w, h, scale, format, res, next, overlay, 'static'); }); const serveBounds = (req, res, next) => { @@ -469,7 +469,7 @@ module.exports = { const path = extractPathFromQuery(req.query, transformer); const overlay = renderOverlay(z, x, y, bearing, pitch, w, h, scale, path, req.query); - return respondImage(item, z, x, y, bearing, pitch, w, h, scale, format, res, next, overlay, "static"); + return respondImage(item, z, x, y, bearing, pitch, w, h, scale, format, res, next, overlay, 'static'); }; const boundsPattern = @@ -542,7 +542,7 @@ module.exports = { const overlay = renderOverlay(z, x, y, bearing, pitch, w, h, scale, path, req.query); - return respondImage(item, z, x, y, bearing, pitch, w, h, scale, format, res, next, overlay, "static"); + return respondImage(item, z, x, y, bearing, pitch, w, h, scale, format, res, next, overlay, 'static'); }); } @@ -811,8 +811,8 @@ module.exports = { const j = Math.min(maxPoolSizes.length - 1, s - 1); const minPoolSize = minPoolSizes[i]; const maxPoolSize = Math.max(minPoolSize, maxPoolSizes[j]); - map.renderers[s] = createPool(s, "tile", minPoolSize, maxPoolSize); - map.renderers_static[s] = createPool(s, "static", minPoolSize, maxPoolSize); + map.renderers[s] = createPool(s, 'tile', minPoolSize, maxPoolSize); + map.renderers_static[s] = createPool(s, 'static', minPoolSize, maxPoolSize); } });