[app] Fix Paste Features As New Vector Layer and "Save Vector Layer as..." dialog window when the pasted features or the source layer don't have the CRS information or if it is invalid #60852
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The current behaviour is that if the clipboard contains e.g. the following text:
and you use the Paste Features As -> New Vector Layer functionality, then you are presented with the "Save Vector Layer as..." dialog window in which you can choose, among other things, the CRS of the new vector layer. Even though you choose a specific CRS for the new vector layer (the one in which you know the coordinates of the features' geometries are referenced to), the new vector layer is created without a valid CRS.
I think such behaviour is incorrect and, looking at the code, it seems to me it was not intended: in fact the code doesn't take in consideration the case when the source CRS is invalid, since in such case an invalid Coordinate Transform is unawares created, while it takes in consideration the case when the destination CRS is invalid and in such case the Coordinate Transform is not created.
It is reasonable to me that, in such case (invalid source layer's CRS), the chosen CRS should be assigned to the new vector layer and the Coordinate Transform should be set only if both the source and destination layer's CRS are valid and not the same.
Fixes #60846.