Skip to content

Conversation

@dulldrums
Copy link

This addresses issue #70

Problem

When zipping and downloading a shp file, jsZip creates a folder to put the files in. When the downloaded zip file is loaded into QGIS, it throws an error because it has a folder inside it. We want to have an option to zip the files without putting them in a folder.

Usage

Set folder:false in the options object that is passed into the zip function.

Example:
import { zip } from 'shp-write';

const geojson = {} // some valid geojson object

const options = {
  folder: false,
  types: {
    polylines: 'lines',
  }
}

const zipResults = zip(geojson, options);

src/zip.js Outdated
module.exports = function(gj, options) {

var zip = new JSZip(),
layers = zip.folder(options && options.folder ? options.folder : 'layers');
Copy link

@mordka mordka Jul 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will create empty folder named 'layers' this line should be placed in the else block of line 12 if statement

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call.
Looking at this again now, I don't see why anyone would want the default of zip to behave the way it does. Ideally the default would be compatible with QGIS/ArcGIS, and currently you have to unzip it and use the resulting folder.
It's almost like you should only zip to a named folder if the user specifies that behavior in the zip options.

@dulldrums
Copy link
Author

I just updated this so the default behavior is a shallow zip, which is compatible with QGIS and ArcGIS. If options.folder is specified and a string, then this will create a zip file that unzips to a folder with the specified name.

@baxter1707
Copy link

@dulldrums Do you think this will be merged into master and released in the near future? This would be very helpful to have.

@dulldrums
Copy link
Author

@baxter1707 I doubt it, PRs haven't been merged in nearly four years. There are several forks that are being actively maintained

This was referenced Aug 21, 2023
@sheindel
Copy link
Contributor

Should be resolved thanks to #96 and #100 , will publish soon, thanks!!

@sheindel sheindel closed this Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants