Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.initPromise.then(function(self) {
var tileDao = self.geoPackage.getTileDaoSync(table);
var maxZoom = tileDao.getMaxZoomSync();
var minZoom = tileDao.getMinZoomSync();
try {
var bytes = java.callStaticMethodSync('mil.nga.geopackage.tiles.TileDraw', 'drawTileBytes', self.geoPackage, table, 'png', java.newLong(x), java.newLong(y), java.newLong(z));
var buffer = new Buffer(bytes);
callback(null, BufferStream(buffer));
} catch (e) {
console.log('e', e);
callback(e, null);
}
});
}
var yRange = yCalculator(totalTileExtent, zoom);
var matrixWidth = ((xRangeMinZoom.max - xRangeMinZoom.min) + 1) * Math.pow(2,(zoom - minZoom));
var matrixHeight = ((yRangeMinZoom.max - yRangeMinZoom.min) + 1) * Math.pow(2,(zoom - minZoom));
console.log('zoom: %d, matrixheight: %d, matrixwidth: %d', zoom, matrixHeight, matrixWidth);
var pixelXSize = ((epsg3857ur[0] - epsg3857ll[0]) / matrixWidth) / 256;
var pixelYSize = ((epsg3857ur[1] - epsg3857ll[1]) / matrixHeight) / 256;
var TileMatrix = java.import('mil.nga.geopackage.tiles.matrix.TileMatrix');
var tileMatrix = new TileMatrix();
tileMatrix.setContentsSync(contents);
tileMatrix.setZoomLevelSync(java.newLong(zoom));
tileMatrix.setMatrixWidthSync(java.newLong(matrixWidth));
tileMatrix.setMatrixHeightSync(java.newLong(matrixHeight));
tileMatrix.setTileWidthSync(java.newLong(256));
tileMatrix.setTileHeightSync(java.newLong(256));
tileMatrix.setPixelXSizeSync(java.newDouble(pixelXSize));
tileMatrix.setPixelYSizeSync(java.newDouble(pixelYSize));
tileMatrixDao.createSync(tileMatrix);
}
callback(null, self);
}).done();
}
var matrixWidth = ((xRangeMinZoom.max - xRangeMinZoom.min) + 1) * Math.pow(2,(zoom - minZoom));
var matrixHeight = ((yRangeMinZoom.max - yRangeMinZoom.min) + 1) * Math.pow(2,(zoom - minZoom));
console.log('zoom: %d, matrixheight: %d, matrixwidth: %d', zoom, matrixHeight, matrixWidth);
var pixelXSize = ((epsg3857ur[0] - epsg3857ll[0]) / matrixWidth) / 256;
var pixelYSize = ((epsg3857ur[1] - epsg3857ll[1]) / matrixHeight) / 256;
var TileMatrix = java.import('mil.nga.geopackage.tiles.matrix.TileMatrix');
var tileMatrix = new TileMatrix();
tileMatrix.setContentsSync(contents);
tileMatrix.setZoomLevelSync(java.newLong(zoom));
tileMatrix.setMatrixWidthSync(java.newLong(matrixWidth));
tileMatrix.setMatrixHeightSync(java.newLong(matrixHeight));
tileMatrix.setTileWidthSync(java.newLong(256));
tileMatrix.setTileHeightSync(java.newLong(256));
tileMatrix.setPixelXSizeSync(java.newDouble(pixelXSize));
tileMatrix.setPixelYSizeSync(java.newDouble(pixelYSize));
tileMatrixDao.createSync(tileMatrix);
}
callback(null, self);
}).done();
var xRange = xCalculator(totalTileExtent, zoom);
var yRange = yCalculator(totalTileExtent, zoom);
var matrixWidth = ((xRangeMinZoom.max - xRangeMinZoom.min) + 1) * Math.pow(2,(zoom - minZoom));
var matrixHeight = ((yRangeMinZoom.max - yRangeMinZoom.min) + 1) * Math.pow(2,(zoom - minZoom));
console.log('zoom: %d, matrixheight: %d, matrixwidth: %d', zoom, matrixHeight, matrixWidth);
var pixelXSize = ((epsg3857ur[0] - epsg3857ll[0]) / matrixWidth) / 256;
var pixelYSize = ((epsg3857ur[1] - epsg3857ll[1]) / matrixHeight) / 256;
var TileMatrix = java.import('mil.nga.geopackage.tiles.matrix.TileMatrix');
var tileMatrix = new TileMatrix();
tileMatrix.setContentsSync(contents);
tileMatrix.setZoomLevelSync(java.newLong(zoom));
tileMatrix.setMatrixWidthSync(java.newLong(matrixWidth));
tileMatrix.setMatrixHeightSync(java.newLong(matrixHeight));
tileMatrix.setTileWidthSync(java.newLong(256));
tileMatrix.setTileHeightSync(java.newLong(256));
tileMatrix.setPixelXSizeSync(java.newDouble(pixelXSize));
tileMatrix.setPixelYSizeSync(java.newDouble(pixelYSize));
tileMatrixDao.createSync(tileMatrix);
}
callback(null, self);
}).done();
for (var zoom = minZoom; zoom <= maxZoom; zoom++) {
var xRange = xCalculator(totalTileExtent, zoom);
var yRange = yCalculator(totalTileExtent, zoom);
var matrixWidth = ((xRangeMinZoom.max - xRangeMinZoom.min) + 1) * Math.pow(2,(zoom - minZoom));
var matrixHeight = ((yRangeMinZoom.max - yRangeMinZoom.min) + 1) * Math.pow(2,(zoom - minZoom));
console.log('zoom: %d, matrixheight: %d, matrixwidth: %d', zoom, matrixHeight, matrixWidth);
var pixelXSize = ((epsg3857ur[0] - epsg3857ll[0]) / matrixWidth) / 256;
var pixelYSize = ((epsg3857ur[1] - epsg3857ll[1]) / matrixHeight) / 256;
var TileMatrix = java.import('mil.nga.geopackage.tiles.matrix.TileMatrix');
var tileMatrix = new TileMatrix();
tileMatrix.setContentsSync(contents);
tileMatrix.setZoomLevelSync(java.newLong(zoom));
tileMatrix.setMatrixWidthSync(java.newLong(matrixWidth));
tileMatrix.setMatrixHeightSync(java.newLong(matrixHeight));
tileMatrix.setTileWidthSync(java.newLong(256));
tileMatrix.setTileHeightSync(java.newLong(256));
tileMatrix.setPixelXSizeSync(java.newDouble(pixelXSize));
tileMatrix.setPixelYSizeSync(java.newDouble(pixelYSize));
tileMatrixDao.createSync(tileMatrix);
}
callback(null, self);
}).done();
}
var matrixWidth = ((xRangeMinZoom.max - xRangeMinZoom.min) + 1) * Math.pow(2,(zoom - minZoom));
var matrixHeight = ((yRangeMinZoom.max - yRangeMinZoom.min) + 1) * Math.pow(2,(zoom - minZoom));
console.log('zoom: %d, matrixheight: %d, matrixwidth: %d', zoom, matrixHeight, matrixWidth);
var pixelXSize = ((epsg3857ur[0] - epsg3857ll[0]) / matrixWidth) / 256;
var pixelYSize = ((epsg3857ur[1] - epsg3857ll[1]) / matrixHeight) / 256;
var TileMatrix = java.import('mil.nga.geopackage.tiles.matrix.TileMatrix');
var tileMatrix = new TileMatrix();
tileMatrix.setContentsSync(contents);
tileMatrix.setZoomLevelSync(java.newLong(zoom));
tileMatrix.setMatrixWidthSync(java.newLong(matrixWidth));
tileMatrix.setMatrixHeightSync(java.newLong(matrixHeight));
tileMatrix.setTileWidthSync(java.newLong(256));
tileMatrix.setTileHeightSync(java.newLong(256));
tileMatrix.setPixelXSizeSync(java.newDouble(pixelXSize));
tileMatrix.setPixelYSizeSync(java.newDouble(pixelYSize));
tileMatrixDao.createSync(tileMatrix);
}
callback(null, self);
}).done();
}
this.initPromise.then(function(self) {
var tileDao = self.tileDaos[tableName];
var newRow = tileDao.newRowSync();
newRow.setZoomLevelSync(java.newLong(zoom));
newRow.setTileColumnSync(java.newLong(tileColumn));
newRow.setTileRowSync(java.newLong(tileRow));
toArray(tileStream, function (err, parts) {
var byteArray = [];
for (var k = 0; k < parts.length; k++) {
var part = parts[k];
for (var i = 0; i < part.length; i++) {
var bufferPiece = part[i];
var byte = java.newByte(bufferPiece);
byteArray.push(byte);
}
}
var bytes = java.newArray('byte', byteArray);
newRow.setTileDataSync(bytes);
tileDao.createSync(newRow);
this.initPromise.then(function(self) {
var tileDao = self.tileDaos[tableName];
var newRow = tileDao.newRowSync();
newRow.setZoomLevelSync(java.newLong(zoom));
newRow.setTileColumnSync(java.newLong(tileColumn));
newRow.setTileRowSync(java.newLong(tileRow));
toArray(tileStream, function (err, parts) {
var byteArray = [];
for (var k = 0; k < parts.length; k++) {
var part = parts[k];
for (var i = 0; i < part.length; i++) {
var bufferPiece = part[i];
var byte = java.newByte(bufferPiece);
byteArray.push(byte);
}
}
var bytes = java.newArray('byte', byteArray);
newRow.setTileDataSync(bytes);
tileDao.createSync(newRow);
callback(null, self);
});
function newLong(val) { return _java.newLong(val); }
Java.newLong = newLong;