@acalcutt/tileserver-gl
Advanced tools
Comparing version 4.0.27 to 4.0.28
{ | ||
"name": "@acalcutt/tileserver-gl", | ||
"version": "4.0.27", | ||
"version": "4.0.28", | ||
"description": "Map tile server for JSON GL styles - vector and server side generated raster tiles", | ||
@@ -5,0 +5,0 @@ "main": "src/main.js", |
106
src/main.js
@@ -22,57 +22,57 @@ #!/usr/bin/env node | ||
import {Command} from 'commander'; | ||
const program = new Command(); | ||
import {program} from 'commander'; | ||
program | ||
.description('tileserver-gl startup options') | ||
.usage('tileserver-gl [mbtiles] [options]') | ||
.option( | ||
'--mbtiles <file>', | ||
'MBTiles file (uses demo configuration);\n' + | ||
'\t ignored if the configuration file is also specified', | ||
) | ||
.option( | ||
'-c, --config <file>', | ||
'Configuration file [config.json]', | ||
'config.json', | ||
) | ||
.option( | ||
'-b, --bind <address>', | ||
'Bind address', | ||
) | ||
.option( | ||
'-p, --port <port>', | ||
'Port [8080]', | ||
8080, | ||
parseInt, | ||
) | ||
.option( | ||
'-C|--no-cors', | ||
'Disable Cross-origin resource sharing headers', | ||
) | ||
.option( | ||
'-u|--public_url <url>', | ||
'Enable exposing the server on subpaths, not necessarily the root of the domain', | ||
) | ||
.option( | ||
'-V, --verbose', | ||
'More verbose output', | ||
) | ||
.option( | ||
'-s, --silent', | ||
'Less verbose output', | ||
) | ||
.option( | ||
'-l|--log_file <file>', | ||
'output log file (defaults to standard out)', | ||
) | ||
.option( | ||
'-f|--log_format <format>', | ||
'define the log format: https://github.com/expressjs/morgan#morganformat-options', | ||
) | ||
.version( | ||
packageJson.version, | ||
'-v, --version', | ||
); | ||
.description('tileserver-gl startup options') | ||
.usage('tileserver-gl [mbtiles] [options]') | ||
.option( | ||
'--mbtiles <file>', | ||
'MBTiles file (uses demo configuration);\n' + | ||
'\t ignored if the configuration file is also specified' | ||
) | ||
.option( | ||
'-c, --config <file>', | ||
'Configuration file [config.json]', | ||
'config.json' | ||
) | ||
.option( | ||
'-b, --bind <address>', | ||
'Bind address' | ||
) | ||
.option( | ||
'-p, --port <port>', | ||
'Port [8080]', | ||
8080, | ||
parseInt | ||
) | ||
.option( | ||
'-C|--no-cors', | ||
'Disable Cross-origin resource sharing headers' | ||
) | ||
.option( | ||
'-u|--public_url <url>', | ||
'Enable exposing the server on subpaths, not necessarily the root of the domain' | ||
) | ||
.option( | ||
'-V, --verbose', | ||
'More verbose output' | ||
) | ||
.option( | ||
'-s, --silent', | ||
'Less verbose output' | ||
) | ||
.option( | ||
'-l|--log_file <file>', | ||
'output log file (defaults to standard out)' | ||
) | ||
.option( | ||
'-f|--log_format <format>', | ||
'define the log format: https://github.com/expressjs/morgan#morganformat-options' | ||
) | ||
.version( | ||
packageJson.version, | ||
'-v, --version' | ||
) | ||
program.parse(process.argv); | ||
const options = program.opts(); | ||
const opts = program.opts(); | ||
console.log(`Starting ${packageJson.name} v${packageJson.version}`); | ||
@@ -79,0 +79,0 @@ |
@@ -287,5 +287,3 @@ 'use strict'; | ||
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 || | ||
@@ -307,3 +305,8 @@ lon !== lon || lat !== lat) { | ||
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) => { | ||
@@ -445,4 +448,3 @@ const mlglZ = Math.max(0, z - 1); | ||
], 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); | ||
}); | ||
@@ -496,7 +498,5 @@ | ||
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'); | ||
}); | ||
@@ -539,6 +539,5 @@ | ||
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, 'static'); | ||
}; | ||
@@ -614,7 +613,5 @@ | ||
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'); | ||
}); | ||
@@ -639,10 +636,11 @@ } | ||
renderers: [], | ||
sources: {}, | ||
renderers_static: [], | ||
sources: {} | ||
}; | ||
let styleJSON; | ||
const createPool = (ratio, min, max) => { | ||
const createPool = (ratio, mode, min, max) => { | ||
const createRenderer = (ratio, createCallback) => { | ||
const renderer = new mlgl.Map({ | ||
mode: 'tile', | ||
const renderer = new mbgl.Map({ | ||
mode: mode, | ||
ratio: ratio, | ||
@@ -892,3 +890,4 @@ request: (req, callback) => { | ||
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); | ||
} | ||
@@ -905,2 +904,5 @@ }); | ||
}); | ||
item.map.renderers_static.forEach(pool => { | ||
pool.close(); | ||
}); | ||
} | ||
@@ -907,0 +909,0 @@ delete repo[id]; |
Sorry, the diff of this file is not supported yet
3356949