How to use the mapnik.blend function in mapnik

To help you get started, we’ve selected a few mapnik examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github clarkx86 / papyrusjs / src / render / renderChunk.js View on Github external
} else {
                                await loadTexture( chunk.get( ix, iy, iz ).name, chunk.get( ix, iy, iz ).value, ix, iy, iz, 0, cache );
                                textureBuffer = cache.get( chunk.get( ix, iy, iz ).name, chunk.get( ix, iy, iz ).value, 0 );
                            };

                            composeArray.push( {
                                buffer: textureBuffer,
                                x: size_texture*ix,
                                y: size_texture*iz
                            } );
                        };
                    };
                };
            };

            mapnik.blend( composeArray, { width: 256, height: 256 }, function( err, data ) {
                // Zoomlevel Directory
                if ( !fs.existsSync( path.normalize( path_output + '/map/' + zoomLevelMax ) ) ) {
                    fs.mkdirSync( path.normalize( path_output + '/map/' + zoomLevelMax ) );
                };
                // X-Coordinate Directory
                if ( !fs.existsSync( path.normalize( path_output + '/map/' + zoomLevelMax + '/' + ( chunkX + Math.abs( worldOffset[ 'x' ][ 0 ] ) ) ) ) ) {
                    fs.mkdirSync( path.normalize( path_output + '/map/' + zoomLevelMax + '/' + ( chunkX + Math.abs( worldOffset[ 'x' ][ 0 ] ) ) ) );
                };
                    
                fs.writeFile( path.normalize( path_output + '/map/' + zoomLevelMax + '/' + ( chunkX + Math.abs( worldOffset[ 'x' ][ 0 ] ) ) + '/' + ( chunkZ + Math.abs( worldOffset[ 'z' ][ 0 ] ) ) + fileExt ), data, ( err ) => {
                    if ( err ) { throw err };
                } );
                resolve();
            } );
        };
    } );
github clarkx86 / papyrusjs / render / renderChunk.js View on Github external
} else {
                                await loadTexture(chunk.get(ix, iy, iz).name, chunk.get(ix, iy, iz).value, ix, iy, iz, 0, cache);
                                textureBuffer = cache.get(chunk.get(ix, iy, iz).name, chunk.get(ix, iy, iz).value, 0);
                            };

                            composeArray.push({
                                buffer: textureBuffer,
                                x: size_texture * ix,
                                y: size_texture * iz
                            });
                        };
                    };
                };
            };

            mapnik.blend(composeArray, { width: 256, height: 256 }, function (err, data) {
                // Zoomlevel Directory
                if (!fs.existsSync(path.normalize(path_output + '/map/' + zoomLevelMax))) {
                    fs.mkdirSync(path.normalize(path_output + '/map/' + zoomLevelMax));
                };
                // X-Coordinate Directory
                if (!fs.existsSync(path.normalize(path_output + '/map/' + zoomLevelMax + '/' + (chunkX + Math.abs(worldOffset['x'][0]))))) {
                    fs.mkdirSync(path.normalize(path_output + '/map/' + zoomLevelMax + '/' + (chunkX + Math.abs(worldOffset['x'][0]))));
                };

                fs.writeFile(path.normalize(path_output + '/map/' + zoomLevelMax + '/' + (chunkX + Math.abs(worldOffset['x'][0])) + '/' + (chunkZ + Math.abs(worldOffset['z'][0])) + fileExt), data, (err) => {
                    if (err) { throw err };
                });
                resolve();
            });
        };
    });
github clarkx86 / papyrusjs / render / renderZoomLevel.js View on Github external
await new Promise((resolve, reject) => {
                            mapnik.blend(blendArray, {
                                width: Math.pow(chunkSize, 2) * 2,
                                height: Math.pow(chunkSize, 2) * 2
                            }, function (err, buffer) {
                                tileImg = mapnik.Image.fromBytesSync(buffer);
                                tileImg = tileImg.resizeSync(Math.pow(chunkSize, 2), Math.pow(chunkSize, 2) /*, { 'scaling_method': mapnik.imageScaling.near } */);
                                if (!fs.existsSync(path.normalize(path_output + '/map/' + (zoomLevelCurrent) + '/' + (ix) + '/'))) {
                                    fs.mkdirSync(path.normalize(path_output + '/map/' + (zoomLevelCurrent) + '/' + (ix) + '/'));
                                }
                                tileImg.saveSync(path.normalize(path_output + '/map/' + (zoomLevelCurrent) + '/' + (ix) + '/' + (iz) + '.png'));
                                resolve();
                            }
                            )
                        });
                    }
github mapbox / spritezero / lib / generate.js View on Github external
function generateImage(layout, callback) {
    assert(typeof layout === 'object' && typeof callback === 'function');
    if (!layout.items.length) return callback(null, emptyPNG);

    mapnik.blend(layout.items, {
        width: layout.width,
        height: layout.height
    }, callback);
}
github kosmtik / kosmtik / src / plugins / base-exporters / PNG.js View on Github external
commit = function () {
            mapnik.blend(data, {format: 'png', width: +self.options.width, height: +self.options.height}, callback);
        };
    map.fromStringSync(this.project.render(), {base: this.project.root});
github mapbox / abaculus / index.js View on Github external
function tileQueueFinish(err, data) {
        if (err) return callback(err);
        if (!data) return callback(new Error('No tiles to stitch.'));
        var headers = [];
        data.forEach(function(d, i){
            headers.push(d.headers);
        });

        blend(data, {
            format: format,
            quality: quality,
            width: w,
            height: h,
            reencode: true
        }, function(err, buffer) {
            if (err) return callback(err);
            callback(null, buffer, headerReduce(headers, format));
        });
    }
github clarkx86 / papyrusjs / src / render / renderZoomLevel.js View on Github external
await new Promise( ( resolve, reject ) => {
                            mapnik.blend( blendArray, {
                                width:  Math.pow( chunkSize, 2 )*2,
                                height: Math.pow( chunkSize, 2 )*2
                        }, function( err, buffer ) {
                            tileImg = mapnik.Image.fromBytesSync( buffer );
                            tileImg = tileImg.resizeSync( Math.pow( chunkSize, 2 ), Math.pow( chunkSize, 2 ) /*, { 'scaling_method': mapnik.imageScaling.near } */ );
                            if ( !fs.existsSync( path.normalize( path_output + '/map/' + ( zoomLevelCurrent ) + '/' + ( ix ) + '/' ) ) ) {
                                fs.mkdirSync( path.normalize( path_output + '/map/' + ( zoomLevelCurrent ) + '/' + ( ix ) + '/' ) );
                            };
                            tileImg.saveSync( path.normalize( path_output + '/map/' + ( zoomLevelCurrent ) + '/' + ( ix ) + '/' + ( iz ) + '.png' ) );
                            resolve();
                        }
                        ) } );
                    };