Bug report #9772

QgsMapSettings::setDestinationCrs() does not achieve desired effect

Added by Etienne Tourigny almost 7 years ago. Updated almost 2 years ago.

Assignee:Martin Dobias
Category:Map Canvas
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:



#1 Updated by Jürgen Fischer almost 7 years ago

  • Status changed from Open to Closed
  • Resolution set to invalid

Use QgsMapCanvas::setDestinationCrs() instead of QgsMapSettings::setDestinationCrs()

#2 Updated by Larry Shaffer almost 7 years ago

Jürgen Fischer wrote:

Use QgsMapCanvas::setDestinationCrs() instead of QgsMapSettings::setDestinationCrs()

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 almost 7 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 [1]). 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.

[1] http://osgeo-org.1560.x6.nabble.com/QGIS-Multi-threaded-Rendering-td5093928.html

#4 Updated by Etienne Tourigny almost 7 years ago

  • Assignee set to Martin Dobias
  • Priority changed from Normal to Low

I now understand from an email by Martin [1] 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.

[1] http://comments.gmane.org/gmane.comp.gis.qgis.devel/30592

#5 Updated by Giovanni Manghi almost 4 years ago

  • Regression? set to No
  • Easy fix? set to No

#6 Updated by Giovanni Manghi almost 2 years ago

  • Resolution changed from invalid to end of life
  • Status changed from Reopened to Closed

Also available in: Atom PDF