atlefren / sosi.js

LIbrary to read SOSI files in Javascript
MIT License
28 stars 12 forks source link

Parse error for 1539_N50_Arealdekke.sos #27

Open lroal opened 8 years ago

lroal commented 8 years ago

I have downloaded the N50 map for rauma kommune. When converting 1539_N50_Arealdekke.sos to geojson (in node), I get the error:

/home/lroal/node_modules/sosijs/src/types/Head.js:40 var ll = data['MIN-NØ'].split(/\s+/); ^ TypeError: Cannot read property 'MIN-NØ' of undefined at parseBbox (/home/lroal/node_modules/sosijs/src/types/Head.js:40:18) at Base.extend.setData (/home/lroal/node_modules/sosijs/src/types/Head.js:89:21) at Base.extend.initialize (/home/lroal/node_modules/sosijs/src/types/Head.js:69:14) at Base (/home/lroal/node_modules/sosijs/src/class/Base.js:11:21) at new child (/home/lroal/node_modules/sosijs/src/class/Base.js:25:45) at Base.extend.initialize (/home/lroal/node_modules/sosijs/src/parser.js:23:21) at Base (/home/lroal/node_modules/sosijs/src/class/Base.js:11:21) at new child (/home/lroal/node_modules/sosijs/src/class/Base.js:25:45) at Base.extend.parse (/home/lroal/node_modules/sosijs/src/parser.js:57:16) at Object. (/home/lroal/sos2geo.js:10:23)

atlefren commented 7 years ago

Sorrry for the extremely late reply.

The issue is charsets, I guess that you are reading the file as utf-8, which it's probably not.

I've released a new version that handles charsets, version 0.0.4 in npm.

Take a look at https://github.com/atlefren/sosi.js/blob/node/test/fileread-test.js#L39 to see how to deal with charsets (main point: read the .sos file as a Buffer, not a string, and use SOSI.js as normal