Closed dot1q closed 8 years ago
you should change
var wfunc = function(base,cb){
importScripts('../../dist/shapefile-js/dist/shp.min.js');
shp(base).then(cb);
}
to be
var wfunc = function(base,cb){
importScripts('../../dist/shapefile-js/dist/shp.min.js');
shp(base).then(function (res) {
cb({ok: true, data: res});
}, function (err) {
cb({ok: false, data: err});
});
}
then you can change
var worker_result = worker.data(cw.makeUrl(file));
to
var worker_result = worker.data(cw.makeUrl(file)).then(function (stuff){
if (stuff.ok) {
return stuff.data;
}
throw stuff.data;
});
Howdy,
Maybe this is the wrong place, so direct me if need be. Per this example, the worker adds features to the map upon parsing, and prints out the exception on fail
However, when parsing zips that do not contain valid shp files, an error is retrievable when not using a worker, and when using catiline, no error is thrown. It may be that I just don't know what I am doing, but I can't figure out if the shp file I am processing is failing.
var worker = cw({data:wfunc},2); worker.data(cw.makeUrl('../files/nj_muni.zip')).then(function(data){ geo.addData(data); },function(a){ console.log(a); }); worker.data(cw.makeUrl('../files/maSP.zip')).then(function(data){ geo.addData(data); },function(a){ console.log(a); });
My code is very similar.
` var file = "actions/shape-files/view-file.php?name="+filename;