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

Add skipFailures option #109

Merged
merged 3 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ interface Options {
env?: Record<string, string>
timeout?: number
maxBuffer?: number
skipFailures?: boolean
}

// Known /vsistdout/ support.
Expand All @@ -47,6 +48,7 @@ class Ogr2ogr implements PromiseLike<Result> {
private customEnv?: Record<string, string>
private timeout: number
private maxBuffer: number
private skipFailures: boolean

constructor(input: Input, opts: Options = {}) {
this.inputPath = vsiStdIn
Expand All @@ -57,6 +59,7 @@ class Ogr2ogr implements PromiseLike<Result> {
this.customEnv = opts.env
this.timeout = opts.timeout ?? 0
this.maxBuffer = opts.maxBuffer ?? 1024 * 1024 * 50
this.skipFailures = opts.skipFailures ?? true

let {path, ext} = this.newOutputPath(this.outputFormat)
this.outputPath = path
Expand Down Expand Up @@ -146,13 +149,9 @@ class Ogr2ogr implements PromiseLike<Result> {

private async run() {
let command = this.customCommand ?? "ogr2ogr"
let args = [
"-f",
this.outputFormat,
"-skipfailures",
this.customDestination || this.outputPath,
this.inputPath,
]
let args = ["-f", this.outputFormat]
if (this.skipFailures) args.push("-skipfailures")
args.push(this.customDestination || this.outputPath, this.inputPath)
if (this.customOptions) args.push(...this.customOptions)
let env = this.customEnv ? {...process.env, ...this.customEnv} : undefined

Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ The following **`options`** are available (none required):
- `format` - Output format (default: `GeoJSON`)
- `timeout` - Timeout, in milliseconds, before command forcibly terminated (default: `0`)
- `maxBuffer` - Max output size in bytes for stdout/stderr (default: `1024 * 1024 * 50`)
- `skipFailures` - the `-skipfailures` switch is not included when false (default: true).
- `options` - Custom [ogr2ogr arguments][4] and [driver options][5] (e.g. `['--config', 'SHAPE_RESTORE_SHX', 'TRUE']`)
- `env` - Custom environmental variables (e.g. `{ATTRIBUTES_SKIP: 'YES'}`)
- `destination` - Select another output than the **output** object (e.g. useful for writing to databases).
Expand Down
Loading