Closed zachsa closed 3 years ago
Actually I have just tested this, and the command is not set this way
I'd be open to PR that allows you to switch the base command from the default.
I've added some code that as far as I can tell will work. (I'm sure that it allows for switching the base command).
However, I'm not able to get the examples to run -, related to this thread: https://github.com/wavded/ogr2ogr/issues/26
If I replace this statement:
let s = cp.spawn('ogr2ogr', logCommand(args), commandOptions)
With this statment (i.e. provide a command that I know exists on the $PATH of the invoking user):
let s = cp.spawn('docker run -v /tmp/:/tmp --rm osgeo/gdal:alpine-small-latest ogr2ogr', logCommand(args), commandOptions)
Running the examples I get the ENOENT error (the docker
command appears not to be findable). If I replace cp.spawn
with cp.exec
then I get an error from the GDAL ogr2ogr client:
let s = cp.exec('docker run -v /tmp/:/tmp --rm osgeo/gdal:alpine-small-latest ogr2ogr', logCommand(args), commandOptions)
FAILURE: no target datasource provided
I think that the spawn command is not working as expected. I'm using Node.js 14.15 on WSL2 Ubuntu 20.04
I've adjusted the API like this:
// examples/docker.js
const ogr2ogr = require('../')
ogr2ogr('../test/samples/sample.shp.zip')
.command('docker run -v /tmp/:/tmp --rm osgeo/gdal:alpine-small-latest ogr2ogr') // <= This is the addition
.exec(function (er, data) {
if (er) {
console.log('er', er)
} else {
console.log('data', data)
}
})
Release in v2.1.0
Thanks very much!
Hi,
Thank you for your library! I'm just starting to look into GDAL (I'm an absolute beginner!) and this library will make that easier.
My preference for invoking GDAL would be via a Docker Image rather than installing the GDAL CLI. Looking at the source code: https://github.com/wavded/ogr2ogr/blob/master/index.js#L211:
I would need to alias the
ogr2ogr
command as part of my server configuration to allow for using the GDAL Docker image:Would it be useful to allow for configuring the command passed to
cp.spawn
? i.e. something like this?I think something like this would work:
Please let me know if you think this is a good idea and if you would accept a pull request for this.