ginkgoch / node-shapefile

This is a NodeJs library to help to read/write shapefiles from your disk.

Home Page:https://ginkgoch.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect header of shx file

Rulexec opened this issue · comments

Currently .shx file uses the same header as .shp. They should be the same, except file length field.

So, some tools cannot read it correctly:

$ ogrinfo test.shp
ERROR 4: Failed to read all values for 3 records in .shx file.
ERROR 4: Failed to read all values for 3 records in .shx file.
FAILURE:
Unable to open datasource `test.shp' with the following drivers.

please use this package cloudv-node-shapefile instead of ginkgoch/node-shapefile;
I download it, fix this bug, and publish a new One, the problem is in shp.ts the _push method, it only update the shpHeader correctly and make a copy as the shxHeader, however shxHeader's fileLength is not the same as shpHeader, so the problem occurs. cloudv-node-shapefile fixes that.

this Author's code is gorgeous, the way I fix the problem is somehow ugly, I can't find a elegent way and I don't want to break the principle of the Author, so I make a new package and publish that, it can fullfill the practice need, and just follow this readme to use is fine