Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c28bf2b21 | ||
|
|
f9f26f0d65 | ||
|
|
de60a0a076 | ||
|
|
90b9af3d95 | ||
|
|
78aea26318 | ||
|
|
292b1b6b44 | ||
|
|
de7f5f0366 |
@@ -20,10 +20,12 @@ Example::
|
||||
"127.0.0.1:8080"
|
||||
],
|
||||
"formatQuality": {
|
||||
"png": 90,
|
||||
"jpeg": 80,
|
||||
"webp": 90
|
||||
}
|
||||
"webp": 90,
|
||||
"pngQuantization": false,
|
||||
"png": 90
|
||||
},
|
||||
"maxSize": 2048
|
||||
},
|
||||
"styles": {
|
||||
"basic": {
|
||||
@@ -69,6 +71,13 @@ You can use this to optionally specify on what domains the rendered tiles are ac
|
||||
|
||||
Quality of the compression of individual image formats. [0-100]
|
||||
|
||||
The value for ``png`` is only used when ``pngQuantization`` is ``true``.
|
||||
|
||||
``maxSize``
|
||||
-----------
|
||||
|
||||
Maximum image side length to be allowed to be rendered (including scale factor). Default is ``2048``.
|
||||
|
||||
``styles``
|
||||
==========
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ Rendered tiles
|
||||
==============
|
||||
* Rendered tiles are served at ``/styles/{id}/rendered/{z}/{x}/{y}[@2x].{format}``
|
||||
|
||||
* The optional ``@2x`` (or ``@3x``) part can be used to render HiDPI (retina) tiles
|
||||
* The optional ``@2x`` (or ``@3x``, ``@4x``) part can be used to render HiDPI (retina) tiles
|
||||
* Available formats: ``png``, ``jpg`` (``jpeg``), ``webp``
|
||||
* TileJSON at ``/styles/{id}/rendered.json``
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "tileserver-gl",
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.0",
|
||||
"description": "Map tile server for JSON GL styles - serverside generated raster tiles",
|
||||
"main": "src/main.js",
|
||||
"bin": "src/main.js",
|
||||
@@ -22,7 +22,7 @@
|
||||
"canvas": "1.4.0",
|
||||
"clone": "1.0.2",
|
||||
"color": "0.11.3",
|
||||
"cors": "2.7.1",
|
||||
"cors": "2.8.0",
|
||||
"express": "4.14.0",
|
||||
"glyph-pbf-composite": "0.0.2",
|
||||
"handlebars": "4.0.5",
|
||||
|
||||
@@ -36,6 +36,16 @@ a:hover{
|
||||
font-size: 32px;
|
||||
text-align:center;
|
||||
margin:90px 0 0 0;
|
||||
position:relative;
|
||||
}
|
||||
.title.light:after {
|
||||
content: "light";
|
||||
display: block;
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
bottom: -5px;
|
||||
color: #499DCE;
|
||||
font-size:.8em;
|
||||
}
|
||||
section{
|
||||
margin: 15px auto;
|
||||
@@ -169,6 +179,9 @@ body {
|
||||
.title{
|
||||
margin: 25px 0 0 0;
|
||||
}
|
||||
.title.light:after {
|
||||
font-size:.6em;
|
||||
}
|
||||
.title img{
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
</head>
|
||||
<body>
|
||||
<section>
|
||||
<h1 class="title"><img src="/images/logo.png" alt="TileServer GL" /></h1>
|
||||
<h2 class="subtitle">Vector and raster maps with GL styles</h2>
|
||||
<h1 class="title {{#if is_light}}light{{/if}}"><img src="/images/logo.png" alt="TileServer GL" /></h1>
|
||||
<h2 class="subtitle">Vector {{#if is_light}}<s>and raster</s>{{else}}and raster{{/if}} maps with GL styles</h2>
|
||||
<h2 class="box-header">Styles</h2>
|
||||
<div class="box">
|
||||
{{#each styles}}
|
||||
|
||||
@@ -24,7 +24,7 @@ var Canvas = require('canvas'),
|
||||
var utils = require('./utils');
|
||||
|
||||
var FLOAT_PATTERN = '[+-]?(?:\\d+|\\d+\.?\\d+)';
|
||||
var SCALE_PATTERN = '@[23]x';
|
||||
var SCALE_PATTERN = '@[234]x';
|
||||
|
||||
var getScale = function(scale) {
|
||||
return (scale || '@1x').slice(1, 2) | 0;
|
||||
@@ -239,6 +239,7 @@ module.exports = function(options, repo, params, id, dataResolver) {
|
||||
map.renderers[1] = createPool(1, 4, 16);
|
||||
map.renderers[2] = createPool(2, 2, 8);
|
||||
map.renderers[3] = createPool(3, 2, 4);
|
||||
map.renderers[4] = createPool(4, 2, 4);
|
||||
});
|
||||
|
||||
repo[id] = tileJSON;
|
||||
@@ -253,7 +254,7 @@ module.exports = function(options, repo, params, id, dataResolver) {
|
||||
return res.status(400).send('Invalid center');
|
||||
}
|
||||
if (Math.min(width, height) <= 0 ||
|
||||
Math.max(width, height) * scale > 2048) {
|
||||
Math.max(width, height) * scale > (options.maxSize || 2048)) {
|
||||
return res.status(400).send('Invalid size');
|
||||
}
|
||||
if (format == 'png' || format == 'webp') {
|
||||
@@ -316,9 +317,13 @@ module.exports = function(options, repo, params, id, dataResolver) {
|
||||
}
|
||||
|
||||
if (format == 'png') {
|
||||
buffer = pngquant.compress(buffer, {
|
||||
quality: [0, formatQuality || 90]
|
||||
});
|
||||
var usePngQuant =
|
||||
(options.formatQuality || {}).pngQuantization === true;
|
||||
if (usePngQuant) {
|
||||
buffer = pngquant.compress(buffer, {
|
||||
quality: [0, formatQuality || 90]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
res.set({
|
||||
@@ -426,14 +431,13 @@ module.exports = function(options, repo, params, id, dataResolver) {
|
||||
|
||||
var minCorner = mercator.px([bbox[0], bbox[3]], z),
|
||||
maxCorner = mercator.px([bbox[2], bbox[1]], z);
|
||||
while ((((maxCorner[0] - minCorner[0]) * (1 + 2 * padding) > w) ||
|
||||
((maxCorner[1] - minCorner[1]) * (1 + 2 * padding) > h)) && z > 0) {
|
||||
z--;
|
||||
minCorner[0] /= 2;
|
||||
minCorner[1] /= 2;
|
||||
maxCorner[0] /= 2;
|
||||
maxCorner[1] /= 2;
|
||||
}
|
||||
w /= (1 + 2 * padding);
|
||||
h /= (1 + 2 * padding);
|
||||
|
||||
z -= Math.max(
|
||||
Math.log((maxCorner[0] - minCorner[0]) / w),
|
||||
Math.log((maxCorner[1] - minCorner[1]) / h)
|
||||
) / Math.LN2;
|
||||
|
||||
return z;
|
||||
};
|
||||
@@ -443,11 +447,12 @@ module.exports = function(options, repo, params, id, dataResolver) {
|
||||
':scale(' + SCALE_PATTERN + ')?\.:format([\\w]+)';
|
||||
|
||||
var centerPattern =
|
||||
util.format(':lon(%s),:lat(%s),:z(\\d+)(@:bearing(%s)(,:pitch(%s))?)?',
|
||||
FLOAT_PATTERN, FLOAT_PATTERN, FLOAT_PATTERN, FLOAT_PATTERN);
|
||||
util.format(':lon(%s),:lat(%s),:z(%s)(@:bearing(%s)(,:pitch(%s))?)?',
|
||||
FLOAT_PATTERN, FLOAT_PATTERN, FLOAT_PATTERN,
|
||||
FLOAT_PATTERN, FLOAT_PATTERN);
|
||||
|
||||
app.get(util.format(staticPattern, centerPattern), function(req, res, next) {
|
||||
var z = req.params.z | 0,
|
||||
var z = +req.params.z,
|
||||
x = +req.params.lon,
|
||||
y = +req.params.lat,
|
||||
bearing = +(req.params.bearing || '0'),
|
||||
|
||||
@@ -22,7 +22,8 @@ var packageJson = require('../package'),
|
||||
serve_data = require('./serve_data'),
|
||||
utils = require('./utils');
|
||||
|
||||
if (packageJson.name.slice(-6) !== '-light') {
|
||||
var isLight = packageJson.name.slice(-6) == '-light';
|
||||
if (!isLight) {
|
||||
// do not require `serve_rendered` in the light package
|
||||
serve_rendered = require('./serve_rendered');
|
||||
}
|
||||
@@ -212,6 +213,7 @@ module.exports = function(opts, callback) {
|
||||
}
|
||||
}
|
||||
data['server_version'] = packageJson.name + ' v' + packageJson.version;
|
||||
data['is_light'] = isLight;
|
||||
data['key_query_part'] =
|
||||
req.query.key ? 'key=' + req.query.key + '&' : '';
|
||||
data['key_query'] = req.query.key ? '?key=' + req.query.key : '';
|
||||
|
||||
Reference in New Issue
Block a user