-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Reintroduce GDAL extract projection and update extractprojection.py to QGIS 3 #8378
Conversation
Fixes qgis#20263 (when some other files are also fixed)
please add also relative test tns for your contribution |
self.addParameter(ParameterRaster(self.INPUT, self.tr('Input file'))) | ||
self.addParameter(ParameterBoolean(self.PRJ_FILE, | ||
self.addParameter(QgsProcessingParameterRasterLayer(self.INPUT, self.tr('Input file'))) | ||
self.addParameter(QgsProcessingParameterBoolean(self.PRJ_FILE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be nice to also add a file output here:
self.addOutput(QgsProcessingOutputFile(self.WORLD_FILE, self.tr('World file')))
and return the path to the newly created world file within the algorithm results. (Maybe also the optional prj file too?) This would make this algorithm more useful within a model context, as these filenames could be used with other later algorithms, such as copying to a different location, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried.
…gdal sources and fixed boolean parameter handling + some formatting
Not so easy to find examples of QgsProcessingOutputFile usage, but I have given it a try. |
@luipir, I understand that tests would be useful, but could that be done in a second pull request? My focus was to fix a "bug". Now I am being asked for more... If this is merged, I will definitely do my best to make a test for the algorithm. Now that output is being generated, perhaps we could use the approach outlined in http://www.opengis.ch/2016/02/04/increasing-the-stability-of-processing-algorithms/ |
@luipir, I am considering these additions to the gdal_algorithm_tests.yaml file:
Would that work if I added the dem.wld and dem.prj to the python/plugins/processing/tests/testdata/expected/gdal/ directory? |
Thanks @havatv! One thing I'm not sure about with this algorithm is what it does/is supposed to do with raster layers from multilayer sources, such as a geopackage. My interpretation of the code is that the algorithm will likely crash on these inputs. Can you confirm? If so, i can point you to the correct way to handle these. |
The code will only work for simple raster files (TIFF, JPEG, PNG, ...).
This does not cause QGIS to crash. The error message is shown in the same way as when an exception is thrown in the algorithm code (the solution for handling non-GDAL sources). As far as I know, it only makes sense to create world files for simple raster files, so getting an error when trying to do it for for instance a layer in a geopackage should be OK. The question is perhaps how helpful the error message should be. Since we have added outputs, there is now a possible use case for just wanting to generate files for use "outside" the input layer. A possible future enhancement could be to allow the user to specify the location of the generated files. But I don't think that needs to be done now. |
Is there any chance to "backport" this to 3.4, so that it will be available in the LTR? Should be low risk, and it is a quite useful function that may be missed by those that upgrade from QGIS 2. |
indentation again...
Sorry for my late answer I was out... yes I suppose should work just adding the yaml and expected result in the correct directory. btw if you add a test you can simply run int and check if it works doing: |
I have added the tests, as described above. |
as you can see you should fix your test, before to push the PR, please test it locally you had the following error https://travis-ci.org/qgis/QGIS/jobs/451277706#L1594 |
Sorry, I did not understand that I also had to build before testing Python code. I will try to do a build. |
no strictly necessary, you can always modify your PR and wait (a long) that travis fail to find the error... building locally allow you to speedup test development. |
I agree that it is better to run tests locally. But building QGIS can be a bit involved - it took me some time. |
Anything else I should do before this is ready to be merged? |
tnx @havatv
Sorry @nyalldawson I merged too early without your opinion... feel free to revert or propose a ask for a new PR if this PR does not satisfy your requests. BTW it does not crash as said by @havatv |
Backporting to the LTR (3.4) should be done, as this fixes a regression in version 3. I guess that backport should be trivial. |
Yes please @havatv -- just open a PR with the backported fix to the release-3_4 branch and I'll merge |
This was missed in qgis#8378.
This was missed in #8378.
Fixes #20263 (when some other files are also fixed)
Description
Reintroduce GDAL extract projection and update extractprojection.py to QGIS 3
Checklist
fixes #11111
in the commit message next to the description[FEATURE]
in the commit message[needs-docs]
in the commit message and contain sufficient information in the commit message to be documentedscripts/prepare-commit.sh
script before each commit