calvinmetcalf / shapefile-js

Convert a Shapefile to GeoJSON. Not many caveats.
http://calvinmetcalf.github.io/shapefile-js/
MIT License
735 stars 230 forks source link

file extension uppercase #64

Closed joaosr closed 7 years ago

joaosr commented 8 years ago

When use a file with name name.DBF or name.PRJ or name.SHP, parseShp doesn't work. why this happen?

calvinmetcalf commented 8 years ago

because javascript is case sensitive so .DBF is not the same as .dbf

joaosr commented 8 years ago

I did one change on shp.js file, I added in this code:

parsed = shp.combine([parseShp(zip[name + '.shp'], zip[name + '.prj']), zip[name + '.dbf']]); parsed.fileName = name;

more this:

var _shp = zip[name + '.shp'] || zip[name + '.SHP']; var _prj = zip[name + '.prj'] || zip[name + '.PRJ']; var _dbf = zip[name + '.dbf'] || zip[name + '.DBF'];

parsed = shp.combine([parseShp(_shp, _prj), _dbf]); parsed.fileName = name;

Now I can import file with uppercase extension.

calvinmetcalf commented 8 years ago

we probably would need a more general solution that can deal with mixed case files as well e.g. .dbF

joaosr commented 8 years ago

In my case the pattern .SHP is very common in Brazil. I am going work in a solution for that, i wish get some headway.

calvinmetcalf commented 8 years ago

i looked into fixing this and remembered this code which is supposed to deal with just your problem, are you purchance using an older version ?