Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} 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();
} );
};
} );
} 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();
});
};
});
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();
}
)
});
}
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);
}
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});
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));
});
}
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();
}
) } );
};