Skip to content

[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

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

Closed

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
@nyalldawson
Copy link
Collaborator

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.

I think having the ability to set an output crs when saving a layer which is missing one is a nice feature -- let's not lose that

@uclaros
Copy link
Contributor

uclaros commented Mar 11, 2025

I agree it's nice but we're also making an assumption here that the user is not trying to reproject the data.
The docs say:

CRS: can be changed to reproject the data

and the crs selection window says:

Select the coordinate reference system for the vector file. The data points will be transformed from the layer coordinate reference system.

We should definitely adjust those two in that case!

Copy link

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@github-actions github-actions bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Mar 26, 2025
Copy link

github-actions bot commented Apr 2, 2025

While we hate to see this happen, this PR has been automatically closed because it has not had any activity in the last 21 days. If this pull request should be reconsidered, please follow the guidelines in the previous comment and reopen this pull request. Or, if you have any further questions, just ask! We love to help, and if there's anything the QGIS project can do to help push this PR forward please let us know how we can assist.

@github-actions github-actions bot closed this Apr 2, 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! stale Uh oh! Seems this work is abandoned, and the PR is about to close.
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
3 participants