mapbox / shp-write

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

Possible to use interal helpers to write mulitple files to one zip #8

Closed newmanw closed 10 years ago

newmanw commented 10 years ago

I need the ability to write multiple shapefiles and compress them all in one zip and send them back to the client.

I.E. I would like to do: [geojson.point(gj), geojson.line(gj), geojson.polygon(gj)] .forEach(function(l) { if (l.geometries.length) { write( // field definitions l.properties, // geometry type l.type, // geometries l.geometries, function(err, files) { layers.file(l.type + '.shp', files.shp.buffer, { binary: true }); layers.file(l.type + '.shx', files.shx.buffer, { binary: true }); layers.file(l.type + '.dbf', files.dbf.buffer, { binary: true }); layers.file(l.type + '.prj', prj); }); } });

Over a few different layers and them zip them all up. The code you have will work perfectly if I could get at it, but from what I can see the only thing you are exposing is 'download'.

How do I get at the write method? Am I missing something.

tmcw commented 10 years ago

Feel free to pull-request more methods exported from index.js!

newmanw commented 10 years ago

Cool thanks!