Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run mapshaper-xl commands programmatically #367

Closed
davidvermeir opened this issue Oct 14, 2019 · 4 comments
Closed

Can't run mapshaper-xl commands programmatically #367

davidvermeir opened this issue Oct 14, 2019 · 4 comments

Comments

@davidvermeir
Copy link

Mapshaper has what I can consider to be a great feature where you can run the commands programmatically directly from Node:

var mapshaper = require('mapshaper'); mapshaper.runCommands('-i shapefiles/*.shp -o geojson/ format=geojson');

However, I've noticed that it isn't possible to run mapshaper-xl commands in the same way. For triggering parsing of large files this would be very useful.

Unless I'm overlooking something?

@mbloch
Copy link
Owner

mbloch commented Oct 15, 2019

This is a good suggestion... I'll think about how to support allocating more memory to the runCommands() function.

Regarding the API, an optional second argument torunCommands() might work:

mapshaper.runCommands(commands, {xl: true})
mapshaper.runCommands(commands, {xl: "16gb"})

@mbloch
Copy link
Owner

mbloch commented Oct 17, 2019

I just published a new release with this functionality.

Instead of adding an option to runCommands(), I added a new API function, runCommandsXL(), which takes an optional value for setting a custom value for the heap, e.g. {xl: "16gb"}. The default heap size of runCommandsXL() is the same as mapshaper-xl: 8gb.

I'll document this in the mapshaper wiki soon.

The reason for adding a new command instead of overloading runCommands() is that setting a custom heap size would change the behavior of runCommands() a bit. To change the default heap size, I have to run Node + mapshaper as a subprocess, which means it's no longer possible to pass in input datasets as an argument to the runCommands() function. runCommandsXL() is limited to file i/o.

@davidvermeir
Copy link
Author

Wow, that was fast! Thx, I'll try this on Monday!

@davidvermeir
Copy link
Author

Works great, thx!

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

No branches or pull requests

2 participants