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

[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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

agiudiceandrea
Copy link
Member

@agiudiceandrea agiudiceandrea commented Mar 4, 2025

Description

The current behaviour is that if the clipboard contains e.g. the following text:

wkt_geom
Polygon ((602049.70009776263032109 4531463.99115845467895269, 621551.28105399641208351 4540522.10253156814724207, 619526.52674706501420587 4524643.76612458005547523, 604607.28448546538129449 4521127.08759148884564638, 602049.70009776263032109 4531463.99115845467895269))

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.

when the pasted features don't have the CRS information
@github-actions github-actions bot added this to the 3.44.0 milestone Mar 4, 2025
@agiudiceandrea
Copy link
Member Author

agiudiceandrea commented Mar 4, 2025

A different approach, suggested by @uclaros, would be to disable the CRS selector in the "Save Vector Layer as..." dialog window and leave the CRS of the new vector layer invalid.
If my approach isn't considered reasonable, I would invite @uclaros to propose a PR implementing such different fix, which would at least fix the misleading GUI.

@agiudiceandrea agiudiceandrea changed the title [app] Fix Paste Features As New Vector Layer when the pasted features don't have the CRS information [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 Mar 4, 2025
Copy link

github-actions bot commented Mar 4, 2025

🪟 Windows builds

Download Windows builds of this PR for testing.
Debug symbols for this build are available here.
(Built from commit 8a1460f)

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit 8a1460f)

@agiudiceandrea agiudiceandrea added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Mar 4, 2025
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!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Paste Features As -> New Vector Layer creates a vector layer with invalid CRS
1 participant