calvinmetcalf / shapefile-js

Convert a Shapefile to GeoJSON. Not many caveats.
http://calvinmetcalf.github.io/shapefile-js/
714 stars 228 forks source link

RangeError: Trying to access beyond buffer length #204

Closed manarfalah closed 1 month ago

manarfalah commented 4 months ago

GeoJSON: RangeError: Trying to access beyond buffer length at checkOffset (index.js:1098:36) at Uint8Array.readDoubleLE (index.js:1248:18) at ParseShp.parseCoord (parseShp.js:215:53) at push../node_modules/shpjs/lib/parseShp.js.ParseShp.parsePointArray (parseShp.js:40:19) at push../node_modules/shpjs/lib/parseShp.js.ParseShp.parsePolyline (parseShp.js:146:28) at push../node_modules/shpjs/lib/parseShp.js.ParseShp.parsePolygon (parseShp.js:196:30) at push../node_modules/shpjs/lib/parseShp.js.ParseShp.getRows (parseShp.js:278:21) at new ParseShp (parseShp.js:235:20) at push../node_modules/shpjs/lib/parseShp.js.module.exports (parseShp.js:304:10) at push../node_modules/shpjs/lib/index.js.shp.parseShp (index.js:178:10)

MarkySparky commented 2 months ago

I also have this error - the zipped file works in QGIS and other. File is 165k, contains dbf, prj, shp, shx.

STILLMOREzzz commented 2 months ago

I hava the same error. The shapfile data works in arcmap.

calvinmetcalf commented 2 months ago

anyone able to give me a copy of the zipped shapefile that is causing the problem? Also are we all on version 5.0.0 when we're seeing this issue ?

STILLMOREzzz commented 2 months ago

Here is my data. I use shp.combine([shp.parseShp(pointshp), shp.parseDbf(pointdbf)]) to parse the shapefile, but it doesn't work. shapefiles.zip

calvinmetcalf commented 2 months ago

@STILLMOREzzz you mind if i include that file in a test?

calvinmetcalf commented 2 months ago

btw the root issue is that the shapefile is claiming to be shorter than it actually is, in your example @STILLMOREzzz your file is 5784 bytes long but the header says it's only 5712

STILLMOREzzz commented 1 month ago

@STILLMOREzzz you mind if i include that file in a test? I dont't mind. You can use this data as example.

STILLMOREzzz commented 1 month ago

@calvinmetcalf can you tell me how to fix this problem?

calvinmetcalf commented 1 month ago

The problem is caused by a malformed shape file that says it's shorter then it really is, I have a fix ready but was waiting on hearing from you about whether I could include your file in the tests

On Mon, May 6, 2024, 4:25 AM STILLMOREzzz @.***> wrote:

@calvinmetcalf https://github.com/calvinmetcalf can you tell me how to fix this problem?

— Reply to this email directly, view it on GitHub https://github.com/calvinmetcalf/shapefile-js/issues/204#issuecomment-2095440781, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAITRH3S2JU5C3UO2MBXRUTZA446PAVCNFSM6AAAAABDPI55GSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJVGQ2DANZYGE . You are receiving this because you were mentioned.Message ID: @.***>

calvinmetcalf commented 1 month ago

So I should have something published later today

On Mon, May 6, 2024, 7:14 AM Calvin Metcalf @.***> wrote:

The problem is caused by a malformed shape file that says it's shorter then it really is, I have a fix ready but was waiting on hearing from you about whether I could include your file in the tests

On Mon, May 6, 2024, 4:25 AM STILLMOREzzz @.***> wrote:

@calvinmetcalf https://github.com/calvinmetcalf can you tell me how to fix this problem?

— Reply to this email directly, view it on GitHub https://github.com/calvinmetcalf/shapefile-js/issues/204#issuecomment-2095440781, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAITRH3S2JU5C3UO2MBXRUTZA446PAVCNFSM6AAAAABDPI55GSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJVGQ2DANZYGE . You are receiving this because you were mentioned.Message ID: @.***>

calvinmetcalf commented 1 month ago

fixed in v5.0.1