Gracefully fail on bad shapefile loads - this should return an error eventually, but after inspection works.

This commit is contained in:
Tom MacWright 2011-01-13 18:11:31 -05:00
parent 2de9117134
commit 4db08c47ec
2 changed files with 16 additions and 6 deletions

View File

@ -175,11 +175,15 @@ var External = function External(env) {
unzip: function(filename, resource_url, callback, that) {
// regrettably complex because zip library isn't written for
// node yet.
console.log('unzipping download from ' + filename);
spawn('unzip', [filename, '-d', that.pos(resource_url)])
.on('exit', function(code) {
if (code > 0) {
console.log('Unzip returned a code of %d', code);
console.log('unzip failed');
callback('Unzip returned a code of ' + code, [
resource_url, false]);
} else {
console.log('unzip succeeded');
// TODO; eliminate locality of reference
callback(null, [
resource_url,

View File

@ -63,11 +63,17 @@ mess.Renderer = function Renderer(env) {
},
function(err, results) {
var result_map = to(results);
m.Layer.forEach(function(l) {
if (l.Datasource.file) {
console.log(result_map);
m.Layer = _.map(_.filter(m.Layer,
function(l) {
return l.Datasource.file &&
result_map[l.Datasource.file];
}),
function(l) {
l.Datasource.file = result_map[l.Datasource.file];
return l;
}
});
);
callback(err, m);
}
);