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

raster export (save as...) not working if QGIS locale uses commas as decimal separator #41284

Closed
gioman opened this issue Jan 31, 2021 · 6 comments · Fixed by #41316
Closed
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Rasters Related to general raster layer handling (not specific data formats)

Comments

@gioman
Copy link
Contributor

gioman commented Jan 31, 2021

QGIS master Ubuntu 20.04

*) in QGIS properties > general set a locale to language that uses the comma as a decimal separator (pt_PT in my case)

*) add a raster layer

*) right click the raster layer > export > save as...

*) set the export properties and try to set a HxV resolution to a decimal value > QGIS allows to enter the only the comma as a separator

*) click "ok" >

Cannot write raster. Error code: data source creation
Cannot create new dataset  /tmp/test.tif:
Attempt to create 0x0 dataset is illegal,sizes must be larger than zero.

*) works ok if resolution is set to values with no decimals

I am pretty sure to have seen this (QGIS not letting use the point as a separator in case the QGIS locale uses the comma) in other parts of QGIS but I don't recall where right now.

@gioman gioman added Rasters Related to general raster layer handling (not specific data formats) Bug Either a bug report, or a bug fix. Let's hope for the latter! labels Jan 31, 2021
@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented Jan 31, 2021

It seems the same occurs in the Extent box with a Locale with the comma as a decimal separator:
image

and in the No data values box, where it is possible to enter a comma as decimal separator but the values will not be used (the value range set will not be nodata in the exported raster layer), while using the point as a decimal separator the values will be used.

@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented Jan 31, 2021

I think the issue is caused by the use of QDoubleValidator with QLineEdit widgets and then to use toDouble() and QString::number(), which are not Locale aware, instead of QLocate().toDouble() and QLocale().toString() or the new QgsDoubleValidator.
Similar issues in other part of the code have been fixed by @SebastienPeillet and @elpaso.
See e.g. #33859, #37136 and #8358

@gioman
Copy link
Contributor Author

gioman commented Jan 31, 2021

Please note that the same error message is returned if the "resolution" fields are left empty (if the layer being exported is a WMS this fields are empty by default), regardless of the QGIS locale. This was not the case in the past see #29891 (comment) I suggest to not enable the "ok" button unless the resolution fields are filled.

@SrNetoChan
Copy link
Member

What doyou think it should be the expected behaviour, should the user be allowed to input either points or commas in the text widgets?

@SrNetoChan
Copy link
Member

@gioman I have created a regression test case to verify the locale comma related problems in the raster dialog:

https://qgis.tenant.kiwitcms.org/case/42/

We should run those on all platforms when the fix is merged into master.

@gioman
Copy link
Contributor Author

gioman commented Feb 3, 2021

We should run those on all platforms when the fix is merged into master.

@SrNetoChan thanks, agree!

nyalldawson pushed a commit to nyalldawson/QGIS that referenced this issue Feb 19, 2021
nyalldawson pushed a commit that referenced this issue Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Rasters Related to general raster layer handling (not specific data formats)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants