mapbox / shp-write

create and write to shapefiles in pure javascript
BSD 3-Clause "New" or "Revised" License
300 stars 187 forks source link

Zip is empty, no errors during conversion #83

Closed Anexo closed 1 year ago

Anexo commented 3 years ago

Hi,

I am trying to convert a MultiLineString GeoJson into Shapefile and the final zip file is empty. It only contains a folder named 'layers', which is also empty.

Here is the code I am using:

            import * as shpwrite from 'shp-write';

            [...]

            shpwrite.download(
              {
                "type": "FeatureCollection",
                "features": [
                  {
                    "id": 258384,
                    "type": "Feature",
                    "geometry": {
                      "type": "MultiLineString",
                      "coordinates": [
                        [
                          [
                            2.94804345731098,
                            41.7861989359476
                          ],
                          [
                            2.94756940846232,
                            41.7861301538658
                          ],
                          [
                            2.94714948990444,
                            41.7859698961895
                          ],
                          [
                            2.94674545344417,
                            41.7857740738752
                          ],
                          [
                            2.94638895736845,
                            41.7855960575596
                          ]
                        ]
                      ]
                    },
                    "properties": {
                      "ID": 258
                    }
                  },
                  {
                    "id": 258385,
                    "type": "Feature",
                    "geometry": {
                      "type": "MultiLineString",
                      "coordinates": [
                        [
                          [
                            2.94805579072204,
                            41.7862446214451
                          ],
                          [
                            2.94804838481063,
                            41.7862205964173
                          ],
                          [
                            2.94804345731098,
                            41.7861989359476
                          ]
                        ]
                      ]
                    },
                    "properties": {
                      "ID": 258
                    }
                  }
                ]
              });

PD: I am using Angular 11 and with the polyfills.ts tweak, it worked.

elisa8rf commented 3 years ago

I'm having the same issue.

Anexo commented 3 years ago

Adding this lines to pollyfills.ts solved the problem for me (using Angular 11):

(window as any).process = { browser: true };

elisa8rf commented 3 years ago

I'm not using Angular :( I'm using only nodejs... Any ideas?

AlbertoMCS commented 2 years ago

Same issue here

sheindel commented 1 year ago

The issue here had to do with the jszip options, and as of tag v0.4.0 we've now made these available as part of the zip and download calls. Hopefully this version should be available on npm soon.

sheindel commented 1 year ago

Good news: v0.4.2 is now available.

Less good news: Mapbox changed their deployment organization so this package is now hosted under a different package

@mapbox/shp-write https://unpkg.com/@mapbox/shp-write@latest/shpwrite.js