Skip to content

Commit

Permalink
Reduce scope of try/catch blocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
yhahn committed Sep 9, 2014
1 parent 36a541d commit ad1d2e0
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions lib/datasourceProcessor.js
Expand Up @@ -307,23 +307,23 @@ function processRasterDatasource(file, filesize, name, info, filetype, callback)
var ds = new mapnik.Datasource(options);
var ref = gdal.SpatialReference.fromProj4(info.proj4);
var results = getCenterAndExtent(ds, info.proj4, filetype);
//calculate source's min/max zoom
getMinMaxZoomGDAL(info.raster.pixelSize, results.center, info.proj4, function(err, min, max) {
if (err) return callback(err);
//Values to input into xml for Mapnik
return callback(null, {
extent: results.extent,
center: results.center,
raster: info.raster,
proj: info.proj4,
minzoom: min,
maxzoom: max,
dstype: 'gdal'
});
});
} catch(err){
return callback(invalid(err));
}
//calculate source's min/max zoom
getMinMaxZoomGDAL(info.raster.pixelSize, results.center, info.proj4, function(err, min, max) {
if (err) return callback(err);
//Values to input into xml for Mapnik
return callback(null, {
extent: results.extent,
center: results.center,
raster: info.raster,
proj: info.proj4,
minzoom: min,
maxzoom: max,
dstype: 'gdal'
});
});
};
/**
* Calculates a GDAL source's min and max zoom level using native pixel size and converting to google mercator (meters)
Expand Down Expand Up @@ -419,10 +419,10 @@ function projectionFromRaster(file, callback) {

//get bands and bandStats
bands = getBands(ds, bandCount);
if(bands instanceof Error) return callback(bands);
} catch(err) {
return callback(invalid('Invalid gdal source. ' + err));
}
if (bands instanceof Error) return callback(bands);

//TODO: check if the current projection is something we can deal with
//...what are some projections we can't deal with?
Expand Down Expand Up @@ -615,10 +615,10 @@ function getDatasource(options, layers, callback) {
if (options.layer_by_index === 0) {
try {
var ds = new mapnik.Datasource(options);
return callback(null, ds);
} catch (err) {
return callback(invalid('Error creating Mapnik Datasource for .geojson file'));
}
return callback(null, ds);
//else obtain layers from KML or gpx file
} else {
var validDatasource;
Expand Down

0 comments on commit ad1d2e0

Please sign in to comment.