Merge pull request #379 from stefslon/tile_margin
Add tileMargin option
This commit is contained in:
commit
f77ccd06af
2 changed files with 20 additions and 1 deletions
|
@ -27,7 +27,8 @@ Example::
|
||||||
"maxSize": 2048,
|
"maxSize": 2048,
|
||||||
"pbfAlias": "pbf",
|
"pbfAlias": "pbf",
|
||||||
"serveAllFonts": false,
|
"serveAllFonts": false,
|
||||||
"serveStaticMaps": true
|
"serveStaticMaps": true,
|
||||||
|
"tileMargin": 0
|
||||||
},
|
},
|
||||||
"styles": {
|
"styles": {
|
||||||
"basic": {
|
"basic": {
|
||||||
|
@ -95,6 +96,13 @@ Maximum image side length to be allowed to be rendered (including scale factor).
|
||||||
Be careful when changing this value since there are hardware limits that need to be considered.
|
Be careful when changing this value since there are hardware limits that need to be considered.
|
||||||
Default is ``2048``.
|
Default is ``2048``.
|
||||||
|
|
||||||
|
``tileMargin``
|
||||||
|
--------------
|
||||||
|
|
||||||
|
Additional image side length added during tile rendering that is cropped from the delivered tile. This is useful for resolving the issue with cropped labels,
|
||||||
|
but it does come with a performance degradation, because additional, adjacent vector tiles need to be loaded to genenrate a single tile.
|
||||||
|
Default is ``0`` to disable this processing.
|
||||||
|
|
||||||
``minRendererPoolSizes``
|
``minRendererPoolSizes``
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
|
|
|
@ -419,6 +419,13 @@ module.exports = function(options, repo, params, id, publicUrl, dataResolver) {
|
||||||
params.width *= 2;
|
params.width *= 2;
|
||||||
params.height *= 2;
|
params.height *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var tileMargin = Math.max(options.tileMargin || 0, 0);
|
||||||
|
if (z > 2 && tileMargin > 0) {
|
||||||
|
params.width += tileMargin * 2 * scale;
|
||||||
|
params.height += tileMargin * 2 * scale;
|
||||||
|
}
|
||||||
|
|
||||||
renderer.render(params, function(err, data) {
|
renderer.render(params, function(err, data) {
|
||||||
pool.release(renderer);
|
pool.release(renderer);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -433,6 +440,10 @@ module.exports = function(options, repo, params, id, publicUrl, dataResolver) {
|
||||||
channels: 4
|
channels: 4
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (z > 2 && tileMargin > 0) {
|
||||||
|
image.extract({ left: tileMargin * scale, top: tileMargin * scale, width: width * scale, height: height * scale });
|
||||||
|
}
|
||||||
|
|
||||||
if (z == 0) {
|
if (z == 0) {
|
||||||
// HACK: when serving zoom 0, resize the 0 tile from 512 to 256
|
// HACK: when serving zoom 0, resize the 0 tile from 512 to 256
|
||||||
|
|
Loading…
Reference in a new issue