Bug report #9772
QgsMapSettings::setDestinationCrs() does not achieve desired effect
|Affected QGIS version:||master||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||end of life|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||18314|
since QgsMapSettings::mapRenderer() is deprecated, QgsMapRenderer::setDestinationCrs() should be replaced by QgsMapSettings::setDestinationCrs() , but it seems the implementation is not complete.
Calls to QgsMapSettings::setDestinationCrs() have no effect on the map settings and are not propagated to the project, but calling QgsMapRenderer::setDestinationCrs() works properly.
The following commands in the python console illustrate this:
iface.mapCanvas().mapSettings().destinationCrs().authid() u'EPSG:4326' crs=QgsCoordinateReferenceSystem('EPSG:3857') crs.authid() u'EPSG:3857' iface.mapCanvas().mapSettings().setDestinationCrs(crs) iface.mapCanvas().mapSettings().destinationCrs().authid() u'EPSG:4326' iface.mapCanvas().mapRenderer().setDestinationCrs(crs) iface.mapCanvas().mapSettings().destinationCrs().authid() u'EPSG:3857'
#2 Updated by Larry Shaffer over 6 years ago
Jürgen Fischer wrote:
While that works, I don't think you should have to do that if you already have
QgsMapSettings, which should be all you need to do a render (if I understand its implementation).
I think there should probably be
QMapCanvas::setMapSettings( const QgsMapSettings& settings ) where one can just apply built-up or manipulated
QgsMapSettings. If not, what is the purpose of the
QMapCanvas::mapSettings() getter then?
I've outlined this in a recent mailing list post.
Etienne, the reason the following doesn't work, is because a copy of the canvas's
QgsMapSettings is being returned, i.e. no direct access:
#3 Updated by Etienne Tourigny over 6 years ago
- Status changed from Closed to Reopened
the situation is a bit confusing... the functions in deprecated class QgsMapRenderer have been replaced by equivalents in QgsMapSettings (as described by a post by Martin Dobias ). Why does not use the mapSettings everywhere?
and what is the use of QgsMapSettings::setDestinationCrs() if it has no effect? Might as well remove it...
there are also a few duplicate get/set functions between QgsMapCanvas and QgsMapSettings (e.g. setCrsTransformEnabled) which further add to the confusion.
I am going to insist on re-opening this bug because I think the API needs a bit of cleanup to remove duplicates and make it consistent.
#4 Updated by Etienne Tourigny over 6 years ago
- Assignee set to Martin Dobias
- Priority changed from Normal to Low
I now understand from an email by Martin  that QgsMapSettings should be used to query map settings, not set them.
It would be nice to have this documented in the QgsMapSettings or QgsCanvas documentation.
The documentation in QgsMapCanvas::mapSettings reads "Get access to properties used for map rendering" which could be a bit clearer, stating that it should be used for consulting only.
I overlooked that this member returns a const& - probably because pyqt lets you modify the returned object without complaining.
#6 Updated by Giovanni Manghi over 1 year ago
- Resolution changed from invalid to end of life
- Status changed from Reopened to Closed
End of life notice: QGIS 2.18 LTR