fix handling of empty files
This commit is contained in:
@@ -376,14 +376,23 @@ MBTiles.prototype.getInfo = function(callback) {
|
||||
if (err) return callback(err);
|
||||
var range = parseInt(info.maxzoom, 10) - parseInt(info.minzoom, 10);
|
||||
info.minzoom = parseInt(info.minzoom, 10);
|
||||
if (isNaN(info.minzoom) || typeof info.minzoom !== 'number') delete info.minzoom;
|
||||
info.maxzoom = parseInt(info.maxzoom, 10);
|
||||
if (isNaN(info.maxzoom) || typeof info.maxzoom !== 'number') delete info.maxzoom;
|
||||
|
||||
info.bounds = _((info.bounds || '').split(',')).map(parseFloat);
|
||||
if (info.bounds.length !== 4 || info.bounds[0] === null) delete info.bounds;
|
||||
|
||||
if (info.center) info.center = _((info.center).split(',')).map(parseFloat);
|
||||
if (!info.center || info.center.length !== 3) info.center = [
|
||||
if ((!info.center || info.center.length !== 3) && info.bounds) info.center = [
|
||||
(info.bounds[2] - info.bounds[0]) / 2 + info.bounds[0],
|
||||
(info.bounds[3] - info.bounds[1]) / 2 + info.bounds[1],
|
||||
(range <= 1) ? info.maxzoom : Math.floor(range * 0.5) + info.minzoom
|
||||
];
|
||||
if (info.center && (info.center.length !== 3 || info.center[0] === null)) {
|
||||
delete info.center;
|
||||
}
|
||||
|
||||
return callback(null, info);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user