Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging ZIP-ed shapefile parsing? #49

Open
paultobey opened this issue Sep 19, 2017 · 3 comments
Open

Debugging ZIP-ed shapefile parsing? #49

paultobey opened this issue Sep 19, 2017 · 3 comments

Comments

@paultobey
Copy link

I have a zipped shapefile that generally works with stand-along shapefile tools, but which fails with the demo upload application. The error generated are:

shit RangeError: Invalid DataView length -4
at new DataView ()
at ParseShp.getRow (shp.js:sourcemap:419)
at ParseShp.getRows (shp.js:sourcemap:407)
at new ParseShp (shp.js:sourcemap:371)
at module.exports (shp.js:sourcemap:429)
at shp.js:sourcemap:103
at Array.map ()
at Function.shp.parseZip (shp.js:sourcemap:92)
at shp.js:sourcemap:140
at tryToUnwrap (shp.js:sourcemap:3000)
blob:http://leaflet.calvinmetcalf.com/40feeb75-ebed-4a72-9e49-67f0c8707e95:15 shit

How can I dig into this error tracking down what I've done wrong in the shapefile? Or what alternate steps should I use when I have an issue like this to track it. I guess I could try parsing the shapefile component files...

Thanks!
Rotor.zip

@calvinmetcalf
Copy link
Owner

so that looks to be an issue with the shapefile, you could try forking this repo and substituting your file for the demo one, but instead of pointing to the zipped version put all the varius files and point to them minus the extention

@paultobey
Copy link
Author

Thanks Calvin, Yes, I believe it's unique to this shapefile, but it's a professionally-produced survey and it works with the desktop ThinkGeo library (I attached the shapefile ZIP to my message). There's no "debug" switch I can throw to dump detailed information from leaflet.shapefile? Just being a lazy developer...

@paultobey
Copy link
Author

paultobey commented Sep 20, 2017

Best guess is that there's an uneven number of rows in the shape file. Should we adjust the code to exit the loop when there are less than 28 bytes left? Increase error checking in getRow()?

ParseShp.prototype.getRows = function() {
var offset = 100;
var len = this.buffer.byteLength;
var out = [];
var current;
while (offset < len) {
/* The error is here in this.parseFunc(offset):
shp.js:293 In ParseShp.prototype.getRows, exception RangeError: Trying to access beyond buffer length
at checkOffset (shp.js:1551)
at Uint8Array.readDoubleLE (shp.js:1701)
at ParseShp.2.exports.ParseShp.trans.buffer [as parseCoord] (shp.js:234)
at ParseShp.2.ParseShp.parsePoint (shp.js:61)
at ParseShp.2.ParseShp.getRows (shp.js:288)
at new ParseShp (shp.js:245)
at 2.module.exports (shp.js:312)
at shp.js:22373
at Array.map ()
at Function.58.shp.parseZip (shp.js:22359)
*/

current = this.getRow(offset);
offset += 8;
offset += current.len;
if (current.type) {
try {
let x = this.parseFunc(current.data);
console.warn('In ParseShp.prototype.getRows, parsed point %o', x);
out.push(x);
}
catch (e) {
console.error('In ParseShp.prototype.getRows, exception %o', e)
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants