From 4db08c47ec0357fe338de27ab421c123a7180dc6 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Thu, 13 Jan 2011 18:11:31 -0500 Subject: [PATCH] Gracefully fail on bad shapefile loads - this should return an error eventually, but after inspection works. --- lib/mess/external.js | 6 +++++- lib/mess/renderer.js | 16 +++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/mess/external.js b/lib/mess/external.js index 0f5e0a2..e50c7fb 100644 --- a/lib/mess/external.js +++ b/lib/mess/external.js @@ -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, diff --git a/lib/mess/renderer.js b/lib/mess/renderer.js index 9f71817..478f319 100644 --- a/lib/mess/renderer.js +++ b/lib/mess/renderer.js @@ -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) { - l.Datasource.file = result_map[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); } );