Open softsprocket opened 7 years ago
HorshoeBa_ElevationToolbox_WedJun14163538.zip One of the zip files that fails. I can unzip it with zip.js and am trying to hack my away around jszip at the moment.
All that said the solution was to modify unzip thusly:
` var JSZip = require('jszip'); module.exports = function(buffer) { var zip = new JSZip(buffer); var files = zip.file(/.+/);
var out = {};
files.forEach(function(a) {
if (a.name.slice(-3).toLowerCase() === 'shx') { return out; }
if (a.name.slice(-3).toLowerCase() === 'shp' || a.name.slice(-3).toLowerCase() === 'dbf') {
out[a.name] = a.asArrayBuffer();
}
else {
out[a.name] = a.asText();
}
});
return out;
};
`
I'm not sure I understand your fix
On some loads the *.shx file would result in an exception. They were being processed by a.asText() (they are binary). The fix just ignores them. A better fix might be:
if (a.name.slice(-3).toLowerCase() === 'shp' || a.name.slice(-3).toLowerCase() === 'dbf') { out[a.name] = a.asArrayBuffer(); } else if (a.name.slice(-3).toLowerCase() === 'prj' { out[a.name] = a.asText(); }
thereby ignoring all files not required.
yeah it think I switched it when we started handling cpg files, I should be able to fix it monday
On Fri, Jun 16, 2017 at 12:08 PM softsprocket notifications@github.com wrote:
On some loads the *.shx file would result in an exception. They were being processed by a.asText() (they are binary). The fix just ignores them. A better fix might be: if (a.name.slice(-3).toLowerCase() === 'shp' || a.name.slice(-3).toLowerCase() === 'dbf') { out[a.name] = a.asArrayBuffer(); } else if (a.name.slice(-3).toLowerCase() === 'prj' { out[a.name] = a.asText(); }
thereby ignoring all files not required.
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/calvinmetcalf/leaflet.shapefile/issues/46#issuecomment-309067234, or mute the thread https://github.com/notifications/unsubscribe-auth/ABE4n1G_qFApklp3gWbAOIXiIaEnGRF8ks5sEqiIgaJpZM4N7iJV .
I'm using zipped shapefiles loaded from dronedeploy and passing an arraybuffer to leaflet.shapefile. I'm working on three projects. One succeeds but two don't I traced into shape and found this being throw by unzip: RangeError: Maximum call stack size exceeded at utf8Slice (http://localhost:1841/js/leaflet1/shp.js?_dc=1497547765872:1029:30) at Uint8Array.slowToString (http://localhost:1841/js/leaflet1/shp.js?_dc=1497547765872:710:16) at Uint8Array.toString (http://localhost:1841/js/leaflet1/shp.js?_dc=1497547765872:739:23) at Object.utf8decode (http://localhost:1841/js/leaflet1/shp.js?_dc=1497547765872:3984:53) at Object.utf8decode (http://localhost:1841/js/leaflet1/shp.js?_dc=1497547765872:3590:21) at ZipObject.dataToString (http://localhost:1841/js/leaflet1/shp.js?_dc=1497547765872:2788:22) at ZipObject.asText (http://localhost:1841/js/leaflet1/shp.js?_dc=1497547765872:2835:29) at http://localhost:1841/js/leaflet1/shp.js?_dc=1497547765872:320:20 at Array.forEach (native) at module.exports (http://localhost:1841/js/leaflet1/shp.js?_dc=1497547765872:315:8)
The line numbers won't mean much since I put some debugging in. I can download the zip file and drag it onto your test project and it works. I wondered if it's a size issue but the failed files give: ArrayBuffer returned 12228250 ArrayBuffer returned 1882584
and the successful on: ArrayBuffer returned 6531249
Only the successful one fires 'data:loaded' of course.
My code:
`