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

Open options (-oo) support #41

Closed
mthh opened this issue Oct 6, 2022 · 2 comments · Fixed by #42
Closed

Open options (-oo) support #41

mthh opened this issue Oct 6, 2022 · 2 comments · Fixed by #42

Comments

@mthh
Copy link
Contributor

mthh commented Oct 6, 2022

Hi,

Are the "open options" of ogr2ogr supported?

I tried to use them without success like this:

const input = await Gdal.open(citiesFile);
const options = [
  '-oo', 'AUTODETECT_TYPE=YES',
  '-oo', 'X_POSSIBLE_NAMES=lng',
  '-oo', 'Y_POSSIBLE_NAMES=lat',
  '-f', 'GeoJSON',
  '-s_srs', 'EPSG:4326',
  '-t_srs', 'EPSG:4326',
  '-lco', 'RFC7946=YES'
];
const output = await Gdal.ogr2ogr(input.datasets[0], options);
const bytes = await Gdal.getFileBytes(output);
await Gdal.close(input);
const result = JSON.parse(new TextDecoder().decode(bytes));

I don't get any error but the 3 "open options" that I use do not appear to have been used. The numeric fields are still parsed as strings (so the AUTODETECT_TYPE option does not seem to have been used) and no geometry is created in the resulting GeoJSON (so X_POSSIBLE_NAMES and Y_POSSIBLE_NAMES do not seem to have been used).

On the other hand, if I test with the desktop version of ogr2ogr with the command ogr2ogr -f GeoJSON cities-output.geojson cities.csv -t_srs EPSG:4326 -s_srs EPSG:4326 -lco RFC7946=YES -oo X_POSSIBLE_NAMES=lng -oo Y_POSSIBLE_NAMES=lat -oo AUTODETECT_TYPE=YES, I get the expected result (geometries are created and the type of the fields becomes numeric when detected this way).

See the attached archive (cities.zip) that contains the 3 following files if it helps:

  • cities.csv (the input file)
  • cities-output-gdal3js.geojson (the output from gdal3.js)
  • citites-output-desktop-ogr2ogr.geojson (the output from the desktop version of ogr2ogr)
@mthh
Copy link
Contributor Author

mthh commented Oct 6, 2022

In fact the open options should be passed as an argument to the OpenEx function (wrapped by the Gdal.open JS function) which doesn't seem to be supported yet.
I will try to submit a PR soon.

@bugra9
Copy link
Owner

bugra9 commented Oct 23, 2022

Hi @mthh, thanks for the pull request, it's merged. A new version will be released in a few days.

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 a pull request may close this issue.

2 participants