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

Layers in a custom projection are not refreshed when the projection definition is changed #40704

Open
fuzzysolutions opened this issue Dec 21, 2020 · 6 comments
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Projections/Transformations Related to coordinate reference systems or coordinate transformation

Comments

@fuzzysolutions
Copy link
Contributor

Describe the bug
When I have a layer in a custom projection and I change the projection definition, e.g. edit the false easting parameter, there is no repaint triggered for the existing layer. I need to close and reload the project to get the layer displayed according to the new projection definition.

How to Reproduce

  1. Create a custom projection, e.g. by taking thedefinition of a UTM zone and adding a custom false_easting and false_northing
  2. Create a layer with this projection and add some features
  3. Edit the false_easting and false_northing parameter for this custom projection to some other value
  4. The features stay where they have been on the map before the redefinition until the project is closed and reloaded

QGIS and OS versions

QGIS-Version 3.16.1-Hannover QGIS-Codeversion b381a90
Kompiliert gegen Qt 5.11.2 Laufendes Qt 5.11.2
Kompiliert mit GDAL/OGR 3.1.4 Läuft mit GDAL/OGR 3.1.4
Kompiliert mit GEOS 3.8.1-CAPI-1.13.3 Läuft mit GEOS 3.8.1-CAPI-1.13.3
Kompiliert mit SQLite 3.29.0 Läuft mit SQLite 3.29.0
PostgreSQL-Client-Version 11.5 SpatiaLite-Version 4.3.0
QWT-Version 6.1.3 QScintilla2-Version 2.10.8
Kompiliert mit PROJ 6.3.2 Läuft mit PROJ Rel. 6.3.2, May 1st, 2020
BS-Version Windows 10 (10.0)
Aktive Python-Erweiterungen db_manager; MetaSearch; processing
@fuzzysolutions fuzzysolutions added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Dec 21, 2020
@gioman gioman added the Projections/Transformations Related to coordinate reference systems or coordinate transformation label Dec 21, 2020
@gioman
Copy link
Contributor

gioman commented Dec 21, 2020

@fuzzysolutions can you attach a sample layer, thanks.

@roya0045
Copy link
Contributor

I'm not sure this is a bug as people are not expected to change crs definition. This might be more of a feature request. I'd guess that one definition change you'd have to go through and the layer using this crs and replace it with the new definition. Otherwise the layers still use their internal 'outdated' definition.

@fuzzysolutions
Copy link
Contributor Author

fuzzysolutions commented Dec 22, 2020

@gioman
Here is a test layer with some railway points in a UTM 32 coordinate system with a local offset. That is my use case, such local coordinate systems are common for engineering projects in order to keep the number coordinate digits low (that is not for data size reasons, but in order to have more human-reading-friendly coordinates, so I easily see whether to points are 1m or 100m away from each other).

Load that Layer, create a user defined CRS according to the definition below and redefine the layer on that CRS (the layer first carries its definition in its own). Then change the FALSE EASTING / FALSE NORTHING parameters in the user-defined CRS and see that nothing happens.

test layer user-defined CRS.zip

PROJCRS["ETRS89 / UTM zone 32N",
    BASEGEOGCRS["ETRS89",
        DATUM["European Terrestrial Reference System 1989",
            ELLIPSOID["GRS 1980",6378137,298.257222101,
                LENGTHUNIT["metre",1]]],
        PRIMEM["Greenwich",0,
            ANGLEUNIT["degree",0.0174532925199433]],
        ID["EPSG",4258]],
    CONVERSION["UTM zone 32N",
        METHOD["Transverse Mercator",
            ID["EPSG",9807]],
        PARAMETER["Latitude of natural origin",0,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8801]],
        PARAMETER["Longitude of natural origin",9,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8802]],
        PARAMETER["Scale factor at natural origin",0.9996,
            SCALEUNIT["unity",1],
            ID["EPSG",8805]],
        PARAMETER["False easting",-5123501,
            LENGTHUNIT["metre",1],
            ID["EPSG",8806]],
        PARAMETER["False northing",-1630240,
            LENGTHUNIT["metre",1],
            ID["EPSG",8807]]],
    CS[Cartesian,2],
        AXIS["(E)",east,
            ORDER[1],
            LENGTHUNIT["metre",1]],
        AXIS["(N)",north,
            ORDER[2],
            LENGTHUNIT["metre",1]],
    USAGE[
        SCOPE["unknown"],
        AREA["Europe - 6?E to 12?E and ETRS89 by country"],
        BBOX[38.76,6,83.92,12]]]

@fuzzysolutions
Copy link
Contributor Author

fuzzysolutions commented Dec 22, 2020

@roya0045: Yes, while creating the example layer, I better understood to use the "Test" widget below the custom CRS definition. So the importance is not high. Still, I think not updating the layer is a kind of unexpected behavior, so to me it is a bug.
But I'd leave that decision to the community. Priority can be set to low, anyway.

I think it's already valuable for others that the behavior is now in some way documented here.

@roya0045
Copy link
Contributor

@fuzzysolutions 100% agreed

@drf5n
Copy link

drf5n commented Jan 5, 2021

My workaround after a CRS edit is to set the layer's CRS to something else, then back to the edited CRS. You do not have to close and reload the whole project in that case.

It might be nice if you could just click on the greyed-out current CRS under Layer CRS and have it refresh/reapply without the doubly re-assigning it.

@nyalldawson nyalldawson self-assigned this Jan 26, 2021
nyalldawson added a commit to nyalldawson/QGIS that referenced this issue Jan 27, 2021
to QgsApplication

In the long term all methods for retrieving available CRS details
should be moved here (instead of being scattered all over the place,
as they are now). But for now the logic for saving and updating
user CRS definitions has been moved here only.

The initial motivation is to create a central place where objects
can connect to in order to listen for when a user makes changes
to their custom projections.

Refs qgis#40704
nyalldawson added a commit to nyalldawson/QGIS that referenced this issue Jan 27, 2021
…ferenceSystem

object

Updates the definition and parameters of the coordinate reference system to their
latest values.

This only has an effect if the CRS is a user defined custom CRS, and the definition
of that custom CRS has changed. In this case the parameters of the object (such as the
proj and WKT string definitions, and other related properties) will be updated to
reflect the current definition of the custom CRS.

Any objects which store CRS objects should connect to the QgsApplication::coordinateReferenceSystemRegistry()'s
QgsCoordinateReferenceSystemRegistry::userCrsChanged() signal and call this method
on their stored CRS objects whenever the signal is emitted in order to update these
CRSes to their new definitions.

Refs qgis#40704
nyalldawson added a commit that referenced this issue Jan 27, 2021
to QgsApplication

In the long term all methods for retrieving available CRS details
should be moved here (instead of being scattered all over the place,
as they are now). But for now the logic for saving and updating
user CRS definitions has been moved here only.

The initial motivation is to create a central place where objects
can connect to in order to listen for when a user makes changes
to their custom projections.

Refs #40704
nyalldawson added a commit that referenced this issue Jan 27, 2021
…ferenceSystem

object

Updates the definition and parameters of the coordinate reference system to their
latest values.

This only has an effect if the CRS is a user defined custom CRS, and the definition
of that custom CRS has changed. In this case the parameters of the object (such as the
proj and WKT string definitions, and other related properties) will be updated to
reflect the current definition of the custom CRS.

Any objects which store CRS objects should connect to the QgsApplication::coordinateReferenceSystemRegistry()'s
QgsCoordinateReferenceSystemRegistry::userCrsChanged() signal and call this method
on their stored CRS objects whenever the signal is emitted in order to update these
CRSes to their new definitions.

Refs #40704
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! Projections/Transformations Related to coordinate reference systems or coordinate transformation
Projects
None yet
Development

No branches or pull requests

5 participants