gipong / shp2geojson.js

Convert shapefile to geoJSON via a web browser without Server-Side code. This conversion will unzip your file and reproject the data with correct encoding in JavaScript.
http://gipong.github.io/shp2geojson.js/
MIT License
260 stars 92 forks source link

Format bug on Properties #6

Closed salucci closed 5 years ago

salucci commented 7 years ago

Hello, I liked this project a lot, unfortunately it's ocurring a little bug, when I load my project (shp + dbf) and generate a Json the properties are not well "splited" or formatted, tryed a couple of different Charsets but the bug persists

I opened the DBF with a GIS and It is ok shp2geojson

It seems like every char accented(á,é,ô etc) the last character of next column is "escaped" and rotated to the next column, for e.g. on DBF file: City Code Population CityA 001 333 CityBá 002 444 CityCá 003 555

after conversion: City Code Population CityA 001 333 CityBá 00 2444 CityCá 0 03555

and when the last column get its max size, the last char ir rotated to the beginning

what it could be? []'s

vharmain commented 5 years ago

I managed to fix similar issue with ISO-8859-1 by modifying DBFParser.prototype.parse code to set custom offset value for the encoding (similarly as the author did for big5).

Original:

offset = (encoding.match(/big5/i))?2:3;

My version:

    switch(encoding.toLowerCase()) {
      case "big5": offset = 2; break;
      case "iso-8859-1": offset = 1; break;
      default: offset = 3;
    }

I found the working offset value by trial & error. I hope this helps In case someone else bumps into this.

gipong commented 5 years ago

@vharmain Thanks a lot! You can send pull requests to this repo.