Merge remote-tracking branch 'upstream/master' into esm_update

This commit is contained in:
acalcutt 2022-09-21 13:17:10 -04:00
commit 5d1a2c7ff2
2 changed files with 27 additions and 23 deletions

View file

@ -44,7 +44,7 @@ master_doc = 'index'
# General information about the project. # General information about the project.
project = u'TileServer GL' 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 # The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the # |version| and |release|, also used in various other places throughout the
@ -197,7 +197,7 @@ latex_elements = {
# author, documentclass [howto, manual, or own class]). # author, documentclass [howto, manual, or own class]).
latex_documents = [ latex_documents = [
('index', 'TileServerGL.tex', u'TileServer GL Documentation', ('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 # 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). # (source start file, name, description, authors, manual section).
man_pages = [ man_pages = [
('index', 'tileservergl', u'TileServer GL Documentation', ('index', 'tileservergl', u'TileServer GL Documentation',
[u'Klokan Technologies GmbH'], 1) [u'MapTiler.com'], 1)
] ]
# If true, show URL addresses after external links. # If true, show URL addresses after external links.
@ -241,7 +241,7 @@ man_pages = [
# dir menu entry, description, category) # dir menu entry, description, category)
texinfo_documents = [ texinfo_documents = [
('index', 'TileServerGL', u'TileServer GL Documentation', ('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'), 'Miscellaneous'),
] ]

View file

@ -225,9 +225,7 @@ export const serve_rendered = {
const app = express().disable('x-powered-by'); const app = express().disable('x-powered-by');
const respondImage = (item, z, lon, lat, bearing, pitch, const respondImage = (item, z, lon, lat, bearing, pitch, width, height, scale, format, res, next, opt_overlay, opt_mode='tile') => {
width, height, scale, format, res, next,
opt_overlay) => {
if (Math.abs(lon) > 180 || Math.abs(lat) > 85.06 || if (Math.abs(lon) > 180 || Math.abs(lat) > 85.06 ||
lon !== lon || lat !== lat) { lon !== lon || lat !== lat) {
return res.status(400).send('Invalid center'); return res.status(400).send('Invalid center');
@ -244,7 +242,12 @@ export const serve_rendered = {
return res.status(400).send('Invalid format'); 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) => { pool.acquire((err, renderer) => {
const mlglZ = Math.max(0, z - 1); const mlglZ = Math.max(0, z - 1);
const params = { const params = {
@ -379,8 +382,7 @@ export const serve_rendered = {
((x + 0.5) / (1 << z)) * (256 << z), ((x + 0.5) / (1 << z)) * (256 << z),
((y + 0.5) / (1 << z)) * (256 << z) ((y + 0.5) / (1 << z)) * (256 << z)
], z); ], z);
return respondImage(item, z, tileCenter[0], tileCenter[1], 0, 0, return respondImage(item, z, tileCenter[0], tileCenter[1], 0, 0, tileSize, tileSize, scale, format, res, next);
tileSize, tileSize, scale, format, res, next);
}); });
if (options.serveStaticMaps !== false) { if (options.serveStaticMaps !== false) {
@ -422,11 +424,9 @@ export const serve_rendered = {
} }
const path = extractPathFromQuery(req.query, transformer); const path = extractPathFromQuery(req.query, transformer);
const overlay = renderOverlay(z, x, y, bearing, pitch, w, h, scale, const overlay = renderOverlay(z, x, y, bearing, pitch, w, h, scale, path, req.query);
path, req.query);
return respondImage(item, z, x, y, bearing, pitch, w, h, scale, format, return respondImage(item, z, x, y, bearing, pitch, w, h, scale, format, res, next, overlay, 'static');
res, next, overlay);
}); });
const serveBounds = (req, res, next) => { const serveBounds = (req, res, next) => {
@ -464,7 +464,8 @@ export const serve_rendered = {
const path = extractPathFromQuery(req.query, transformer); 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 boundsPattern = const boundsPattern =
@ -535,11 +536,9 @@ export const serve_rendered = {
const x = center[0]; const x = center[0];
const y = center[1]; const y = center[1];
const overlay = renderOverlay(z, x, y, bearing, pitch, w, h, scale, const overlay = renderOverlay(z, x, y, bearing, pitch, w, h, scale, path, req.query);
path, req.query);
return respondImage(item, z, x, y, bearing, pitch, w, h, scale, format, return respondImage(item, z, x, y, bearing, pitch, w, h, scale, format, res, next, overlay, 'static');
res, next, overlay);
}); });
} }
@ -559,14 +558,15 @@ export const serve_rendered = {
add: (options, repo, params, id, publicUrl, dataResolver) => { add: (options, repo, params, id, publicUrl, dataResolver) => {
const map = { const map = {
renderers: [], renderers: [],
renderers_static: [],
sources: {} sources: {}
}; };
let styleJSON; let styleJSON;
const createPool = (ratio, min, max) => { const createPool = (ratio, mode, min, max) => {
const createRenderer = (ratio, createCallback) => { const createRenderer = (ratio, createCallback) => {
const renderer = new mlgl.Map({ const renderer = new mbgl.Map({
mode: 'tile', mode: mode,
ratio: ratio, ratio: ratio,
request: (req, callback) => { request: (req, callback) => {
const protocol = req.url.split(':')[0]; const protocol = req.url.split(':')[0];
@ -810,7 +810,8 @@ export const serve_rendered = {
const j = Math.min(maxPoolSizes.length - 1, s - 1); const j = Math.min(maxPoolSizes.length - 1, s - 1);
const minPoolSize = minPoolSizes[i]; const minPoolSize = minPoolSizes[i];
const maxPoolSize = Math.max(minPoolSize, maxPoolSizes[j]); 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);
} }
}); });
@ -822,6 +823,9 @@ export const serve_rendered = {
item.map.renderers.forEach((pool) => { item.map.renderers.forEach((pool) => {
pool.close(); pool.close();
}); });
item.map.renderers_static.forEach(pool => {
pool.close();
});
} }
delete repo[id]; delete repo[id];
} }