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

zip files that contain no GIS information still resolve 'correctly' #150

Closed yaegel closed 3 years ago

yaegel commented 3 years ago

When passing a file into the shp function this is my basic understanding:

shp(file).then( (geojson) => { // do geojson processing here}, (error) => { // handle errors with grace here } )

but when I pass a zip file containing random json (not geojson) files - it still falls into the (geojson) => block.

It seems to me that if the parsing of the zip into a geojson object fails to produce valid geojson object, the result should fall into the (error) => block.

Otherwise, I have to check for the existence of the features property in the success block and handle errors in two places.

calvinmetcalf commented 3 years ago

ok so the deal is that you can have one or more shp or json files in the csv and any json file will be parsed and put in the output, now it is a bit weird that having any json file in addition to a .shp causes you to get an array of files back instead of just the geojson. But yes in generally we don't actually check if the json are sent is actually valid geojson (i guess it could be esrijson).

ok yeah it's a bit weird but at this point it would be breaking change to fix it so sorry.

yaegel commented 3 years ago

I understand you closing this one, but I thought I'd make sure I was clear enough in my issue tracker - if the file is a zip that contains one json file, and that json file is an array of ip addresses - shp still falls into the geojson block. No geojson is available, but it didn't fail.

I've already band-aided my code, but it seems like a valid bug.

Cheers,

-Lucas

On Wed, Feb 24, 2021 at 9:01 AM Calvin Metcalf notifications@github.com wrote:

Closed #150 https://github.com/calvinmetcalf/shapefile-js/issues/150.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/calvinmetcalf/shapefile-js/issues/150#event-4371791022, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXXLJ2S3JBIJUP5MNE2OUTTAUPFJANCNFSM4YEWL4RA .