Skip to content
Permalink
Browse files

Remove context-unaware QgsCoordinateTransform constructors from Pytho…

…n bindings

This forces Python code and plugins to become datum transform
aware, and given that upgrading python code is easy (just
add QgsProject.instance() as a new argument to the constructor)
it's relatively painless to force this on PyQGIS users.

Also fix upgrade the easy QgsCoordinateTransform c++ constructors
where the project is available, or where using QgsProject::instance()
is safe to do.

For others, just avoid the deprecated warnings until we can
get access to the correct project instance where the transform
is being constructed.
  • Loading branch information
nyalldawson committed Nov 5, 2017
1 parent 91e0afb commit 86d9492372ff17e90a95ee56e1f9dcb7b077e4fd
Showing with 208 additions and 88 deletions.
  1. +3 −2 doc/api_break.dox
  2. +0 −7 python/core/qgscoordinatetransform.sip
  3. +3 −3 python/plugins/MetaSearch/dialogs/maindialog.py
  4. +1 −1 python/plugins/processing/algs/qgis/ExportGeometryInfo.py
  5. +3 −1 python/plugins/processing/algs/qgis/FindProjection.py
  6. +1 −1 python/plugins/processing/algs/qgis/SpatialJoinSummary.py
  7. +2 −1 src/analysis/processing/qgsalgorithmtransform.cpp
  8. +1 −0 src/analysis/processing/qgsalgorithmtransform.h
  9. +3 −3 src/app/composer/qgscomposermapwidget.cpp
  10. +5 −5 src/app/gps/qgsgpsinformationwidget.cpp
  11. +2 −1 src/app/gps/qgsgpsmarker.cpp
  12. +2 −1 src/app/nodetool/qgsnodeeditor.cpp
  13. +3 −3 src/app/qgisapp.cpp
  14. +1 −1 src/app/qgsbookmarks.cpp
  15. +2 −1 src/app/qgsclipboard.cpp
  16. +1 −1 src/app/qgsdecorationlayoutextent.cpp
  17. +3 −3 src/app/qgsmapcanvasdockwidget.cpp
  18. +1 −1 src/app/qgsmaptoolannotation.cpp
  19. +2 −1 src/app/qgsmaptoolselectutils.cpp
  20. +1 −1 src/app/qgsmaptoolshowhidelabels.cpp
  21. +2 −1 src/app/qgsmeasuretool.cpp
  22. +1 −1 src/app/qgsprojectproperties.cpp
  23. +1 −1 src/core/composer/qgscomposerattributetablev2.cpp
  24. +1 −1 src/core/composer/qgscomposermap.cpp
  25. +1 −1 src/core/composer/qgscomposermapgrid.cpp
  26. +1 −1 src/core/composer/qgscomposermapoverview.cpp
  27. +2 −0 src/core/expression/qgsexpressionfunction.cpp
  28. +8 −8 src/core/processing/qgsprocessingparameters.cpp
  29. +2 −0 src/core/processing/qgsprocessingutils.cpp
  30. +2 −0 src/core/providers/memory/qgsmemoryfeatureiterator.cpp
  31. +2 −0 src/core/qgsbearingutils.cpp
  32. +4 −0 src/core/qgscachedfeatureiterator.cpp
  33. +7 −2 src/core/qgscoordinatetransform.h
  34. +2 −0 src/core/qgscoordinateutils.cpp
  35. +2 −0 src/core/qgscrscache.cpp
  36. +2 −0 src/core/qgspointlocator.cpp
  37. +2 −0 src/core/qgstracer.cpp
  38. +2 −0 src/core/qgsvectorfilewriter.cpp
  39. +4 −0 src/core/qgsvectorlayerdiagramprovider.cpp
  40. +4 −0 src/core/qgsvectorlayerexporter.cpp
  41. +2 −0 src/core/qgsvectorlayerfeatureiterator.cpp
  42. +4 −0 src/core/qgsvectorlayerlabelprovider.cpp
  43. +2 −0 src/core/raster/qgsrasterfilewriter.cpp
  44. +2 −2 src/gui/qgsextentgroupbox.cpp
  45. +1 −1 src/gui/qgsmapcanvas.cpp
  46. +2 −2 src/gui/qgsmapcanvasannotationitem.cpp
  47. +2 −1 src/gui/qgsrasterlayersaveasdialog.cpp
  48. +2 −1 src/gui/qgsrubberband.cpp
  49. +4 −4 src/plugins/grass/qgsgrassnewmapset.cpp
  50. +2 −0 src/providers/arcgisrest/qgsafsfeatureiterator.cpp
  51. +2 −0 src/providers/arcgisrest/qgsafsprovider.cpp
  52. +2 −0 src/providers/arcgisrest/qgsarcgisservicesourceselect.cpp
  53. +2 −0 src/providers/db2/qgsdb2featureiterator.cpp
  54. +2 −0 src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.cpp
  55. +2 −0 src/providers/gpx/qgsgpxfeatureiterator.cpp
  56. +2 −0 src/providers/mssql/qgsmssqlfeatureiterator.cpp
  57. +2 −0 src/providers/ogr/qgsogrfeatureiterator.cpp
  58. +2 −0 src/providers/postgres/qgspostgresfeatureiterator.cpp
  59. +2 −0 src/providers/spatialite/qgsspatialitefeatureiterator.cpp
  60. +2 −0 src/providers/virtual/qgsvirtuallayerfeatureiterator.cpp
  61. +2 −1 src/providers/wcs/qgswcsprovider.cpp
  62. +3 −0 src/providers/wfs/qgswfscapabilities.cpp
  63. +2 −0 src/providers/wfs/qgswfsfeatureiterator.cpp
  64. +2 −0 src/providers/wfs/qgswfsprovider.cpp
  65. +2 −0 src/providers/wms/qgswmscapabilities.cpp
  66. +12 −0 src/providers/wms/qgswmsprovider.cpp
  67. +4 −0 src/server/qgsconfigparserutils.cpp
  68. +2 −0 src/server/services/wcs/qgswcsgetcoverage.cpp
  69. +2 −0 src/server/services/wcs/qgswcsutils.cpp
  70. +2 −0 src/server/services/wfs/qgswfsgetcapabilities.cpp
  71. +6 −0 src/server/services/wfs/qgswfsgetfeature.cpp
  72. +6 −0 src/server/services/wms/qgswmsgetcapabilities.cpp
  73. +2 −0 src/server/services/wms/qgswmsgetcontext.cpp
  74. +1 −1 tests/src/app/testqgsmeasuretool.cpp
  75. +12 −11 tests/src/core/testqgscoordinatetransform.cpp
  76. +1 −1 tests/src/core/testqgsexpression.cpp
  77. +7 −6 tests/src/core/testqgsgeometry.cpp
  78. +2 −1 tests/src/core/testqgstracer.cpp
  79. +1 −1 tests/src/python/test_qgscoordinatetransform.py
  80. +2 −1 tests/src/python/test_qgsvectorfilewriter.py
@@ -914,11 +914,12 @@ called if changes are made to the CRS database.
QgsCoordinateTransform {#qgis_api_break_3_0_QgsCoordinateTransform}
----------------------

- QgsCoordinateTransform is no longer a QObject. readXml, writeXml and initialize are all normal public members now,
- QgsCoordinateTransform is no longer a QObject. Initialize is a normal public members now,
not slots. The invalidTransformInput() signal has been removed.
- The extra QgsCoordinateTransform constructors (those not taking QgsCoordinateReferenceSystem arguments) have been
removed. Now, QgsCoordinateTransform must be created using an already existing source and destination
QgsCoordinateReferenceSystem object.
QgsCoordinateReferenceSystem object, and either a QgsCoordinateTransformContext object or a reference to the
current project instance.
- QgsCoordinateTransform::clone() has been removed. Just use direct copies instead.
- sourceCrs() and destCrs() now return a copy instead of a reference to the CRS. This has no effect on PyQGIS code, but c++
plugins calling these methods will need to be updated.
@@ -45,13 +45,6 @@ class QgsCoordinateTransform
Default constructor, creates an invalid QgsCoordinateTransform.
%End

explicit QgsCoordinateTransform( const QgsCoordinateReferenceSystem &source,
const QgsCoordinateReferenceSystem &destination );
%Docstring
Constructs a QgsCoordinateTransform using QgsCoordinateReferenceSystem objects.
\param source source CRS, typically of the layer's coordinate system
\param destination CRS, typically of the map canvas coordinate system
%End

explicit QgsCoordinateTransform( const QgsCoordinateReferenceSystem &source,
const QgsCoordinateReferenceSystem &destination,
@@ -39,7 +39,7 @@

from qgis.core import (QgsApplication, QgsCoordinateReferenceSystem,
QgsCoordinateTransform, QgsGeometry, QgsPointXY,
QgsProviderRegistry, QgsSettings)
QgsProviderRegistry, QgsSettings, QgsProject)
from qgis.gui import QgsRubberBand
from qgis.utils import OverrideCursor

@@ -400,7 +400,7 @@ def set_bbox_from_map(self):
if crsid != 4326: # reproject to EPSG:4326
src = QgsCoordinateReferenceSystem(crsid)
dest = QgsCoordinateReferenceSystem(4326)
xform = QgsCoordinateTransform(src, dest)
xform = QgsCoordinateTransform(src, dest, QgsProject.instance())
minxy = xform.transform(QgsPointXY(extent.xMinimum(),
extent.yMinimum()))
maxxy = xform.transform(QgsPointXY(extent.xMaximum(),
@@ -570,7 +570,7 @@ def record_clicked(self):
dst = self.map.mapSettings().destinationCrs()
geom = QgsGeometry.fromWkt(points)
if src.postgisSrid() != dst.postgisSrid():
ctr = QgsCoordinateTransform(src, dst)
ctr = QgsCoordinateTransform(src, dst, QgsProject.instance())
try:
geom.transform(ctr)
except Exception as err:
@@ -126,7 +126,7 @@ def processAlgorithm(self, parameters, context, feedback):
self.distance_area.setSourceCrs(source.sourceCrs())
self.distance_area.setEllipsoid(context.project().ellipsoid())
elif method == 1:
coordTransform = QgsCoordinateTransform(source.sourceCrs(), context.project().crs())
coordTransform = QgsCoordinateTransform(source.sourceCrs(), context.project().crs(), context.project())

features = source.getFeatures()
total = 100.0 / source.featureCount() if source.featureCount() else 0
@@ -34,6 +34,7 @@
QgsFields,
QgsCoordinateReferenceSystem,
QgsCoordinateTransform,
QgsCoordinateTransformContext,
QgsWkbTypes,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterExtent,
@@ -108,6 +109,7 @@ def processAlgorithm(self, parameters, context, feedback):

found_results = 0

transform_context = QgsCoordinateTransformContext()
for current, srs_id in enumerate(crses_to_check):
if feedback.isCanceled():
break
@@ -116,7 +118,7 @@ def processAlgorithm(self, parameters, context, feedback):
if not candidate_crs.isValid():
continue

transform_candidate = QgsCoordinateTransform(candidate_crs, target_crs)
transform_candidate = QgsCoordinateTransform(candidate_crs, target_crs, transform_context)
transformed_bounds = QgsGeometry(layer_bounds)
try:
if not transformed_bounds.transform(transform_candidate) == 0:
@@ -262,7 +262,7 @@ def addField(original, stat, type):
total = 100.0 / source.featureCount() if source.featureCount() else 0

# bounding box transform
bbox_transform = QgsCoordinateTransform(source.sourceCrs(), join_source.sourceCrs())
bbox_transform = QgsCoordinateTransform(source.sourceCrs(), join_source.sourceCrs(), context.project())

for current, f in enumerate(features):
if feedback.isCanceled():
@@ -75,6 +75,7 @@ QgsTransformAlgorithm *QgsTransformAlgorithm::createInstance() const
bool QgsTransformAlgorithm::prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback * )
{
mDestCrs = parameterAsCrs( parameters, QStringLiteral( "TARGET_CRS" ), context );
mTransformContext = context.project() ? context.project()->transformContext() : QgsCoordinateTransformContext();
return true;
}

@@ -84,7 +85,7 @@ QgsFeature QgsTransformAlgorithm::processFeature( const QgsFeature &f, QgsProces
if ( !mCreatedTransform )
{
mCreatedTransform = true;
mTransform = QgsCoordinateTransform( sourceCrs(), mDestCrs );
mTransform = QgsCoordinateTransform( sourceCrs(), mDestCrs, mTransformContext );
}

if ( feature.hasGeometry() )
@@ -56,6 +56,7 @@ class QgsTransformAlgorithm : public QgsProcessingFeatureBasedAlgorithm
bool mCreatedTransform = false;
QgsCoordinateReferenceSystem mDestCrs;
QgsCoordinateTransform mTransform;
QgsCoordinateTransformContext mTransformContext;

};

@@ -314,7 +314,7 @@ void QgsComposerMapWidget::mapCrsChanged( const QgsCoordinateReferenceSystem &cr
QgsRectangle newExtent;
try
{
QgsCoordinateTransform xForm( oldCrs, crs.isValid() ? crs : QgsProject::instance()->crs() );
QgsCoordinateTransform xForm( oldCrs, crs.isValid() ? crs : QgsProject::instance()->crs(), QgsProject::instance() );
QgsRectangle prevExtent = *mComposerMap->currentMapExtent();
newExtent = xForm.transformBoundingBox( prevExtent );
updateExtent = true;
@@ -513,7 +513,7 @@ void QgsComposerMapWidget::mSetToMapCanvasExtentButton_clicked()
try
{
QgsCoordinateTransform xForm( QgisApp::instance()->mapCanvas()->mapSettings().destinationCrs(),
mComposerMap->crs() );
mComposerMap->crs(), QgsProject::instance() );
newExtent = xForm.transformBoundingBox( newExtent );
}
catch ( QgsCsException & )
@@ -546,7 +546,7 @@ void QgsComposerMapWidget::mViewExtentInCanvasButton_clicked()
try
{
QgsCoordinateTransform xForm( mComposerMap->crs(),
QgisApp::instance()->mapCanvas()->mapSettings().destinationCrs() );
QgisApp::instance()->mapCanvas()->mapSettings().destinationCrs(), QgsProject::instance() );
currentMapExtent = xForm.transformBoundingBox( currentMapExtent );
}
catch ( QgsCsException & )
@@ -684,7 +684,7 @@ void QgsGPSInformationWidget::displayGPSInformation( const QgsGPSInformation &in
if ( radRecenterMap->isChecked() || radRecenterWhenNeeded->isChecked() )
{
QgsCoordinateReferenceSystem mypSRS = mpCanvas->mapSettings().destinationCrs();
QgsCoordinateTransform myTransform( mWgs84CRS, mypSRS ); // use existing WGS84 CRS
QgsCoordinateTransform myTransform( mWgs84CRS, mypSRS, QgsProject::instance() ); // use existing WGS84 CRS

QgsPointXY myPoint = myTransform.transform( myNewCenter );
//keep the extent the same just center the map canvas in the display so our feature is in the middle
@@ -758,7 +758,7 @@ void QgsGPSInformationWidget::addVertex()
QgsPointXY myPoint;
if ( mpCanvas )
{
QgsCoordinateTransform t( mWgs84CRS, mpCanvas->mapSettings().destinationCrs() );
QgsCoordinateTransform t( mWgs84CRS, mpCanvas->mapSettings().destinationCrs(), QgsProject::instance() );
myPoint = t.transform( mLastGpsPosition );
}
else
@@ -809,7 +809,7 @@ void QgsGPSInformationWidget::mBtnCloseFeature_clicked()
{
QgsFeature *f = new QgsFeature( 0 );

QgsCoordinateTransform t( mWgs84CRS, vlayer->crs() );
QgsCoordinateTransform t( mWgs84CRS, vlayer->crs(), QgsProject::instance() );
QgsPointXY myPoint = t.transform( mLastGpsPosition );
double x = myPoint.x();
double y = myPoint.y();
@@ -864,7 +864,7 @@ void QgsGPSInformationWidget::mBtnCloseFeature_clicked()
{
QgsPointXY savePoint = *it;
// transform the gps point into the layer crs
QgsCoordinateTransform t( mWgs84CRS, vlayer->crs() );
QgsCoordinateTransform t( mWgs84CRS, vlayer->crs(), QgsProject::instance() );
QgsPointXY myPoint = t.transform( savePoint );

wkbPtr << myPoint.x() << myPoint.y();
@@ -887,7 +887,7 @@ void QgsGPSInformationWidget::mBtnCloseFeature_clicked()
{
QgsPointXY savePoint = *it;
// transform the gps point into the layer crs
QgsCoordinateTransform t( mWgs84CRS, vlayer->crs() );
QgsCoordinateTransform t( mWgs84CRS, vlayer->crs(), QgsProject::instance() );
QgsPointXY myPoint = t.transform( savePoint );
wkbPtr << myPoint.x() << myPoint.y();
}
@@ -19,6 +19,7 @@
#include "qgscoordinatetransform.h"
#include "qgsmapcanvas.h"
#include "qgsexception.h"
#include "qgsproject.h"

QgsGpsMarker::QgsGpsMarker( QgsMapCanvas *mapCanvas )
: QgsMapCanvasItem( mapCanvas )
@@ -42,7 +43,7 @@ void QgsGpsMarker::setCenter( const QgsPointXY &point )
//transform to map crs
if ( mMapCanvas )
{
QgsCoordinateTransform t( mWgs84CRS, mMapCanvas->mapSettings().destinationCrs() );
QgsCoordinateTransform t( mWgs84CRS, mMapCanvas->mapSettings().destinationCrs(), QgsProject::instance() );
try
{
mCenter = t.transform( point );
@@ -22,6 +22,7 @@
#include "qgsvertexentry.h"
#include "qgsvectorlayer.h"
#include "qgsgeometryutils.h"
#include "qgsproject.h"

#include <QTableWidget>
#include <QHeaderView>
@@ -366,7 +367,7 @@ void QgsNodeEditor::zoomToNode( int idx )
double y = mSelectedFeature->vertexMap().at( idx )->point().y();
QgsPointXY newCenter( x, y );

QgsCoordinateTransform t( mLayer->crs(), mCanvas->mapSettings().destinationCrs() );
QgsCoordinateTransform t( mLayer->crs(), mCanvas->mapSettings().destinationCrs(), QgsProject::instance() );
QgsPointXY tCenter = t.transform( newCenter );

QPolygonF ext = mCanvas->mapSettings().visiblePolygon();
@@ -5759,7 +5759,7 @@ void QgisApp::dxfExport()
//extent
if ( d.exportMapExtent() )
{
QgsCoordinateTransform t( mapCanvas()->mapSettings().destinationCrs(), d.crs() );
QgsCoordinateTransform t( mapCanvas()->mapSettings().destinationCrs(), d.crs(), QgsProject::instance() );
dxfExport.setExtent( t.transformBoundingBox( mapCanvas()->extent() ) );
}
}
@@ -7019,7 +7019,7 @@ void QgisApp::saveAsVectorFileGeneral( QgsVectorLayer *vlayer, bool symbologyOpt

if ( destCRS.isValid() && destCRS != vlayer->crs() )
{
ct = QgsCoordinateTransform( vlayer->crs(), destCRS );
ct = QgsCoordinateTransform( vlayer->crs(), destCRS, QgsProject::instance() );

//ask user about datum transformation
QgsSettings settings;
@@ -9493,7 +9493,7 @@ void QgisApp::legendLayerZoomNative()
QSize s = mMapCanvas->mapSettings().outputSize();
QgsPointXY p1( e.center().x(), e.center().y() );
QgsPointXY p2( e.center().x() + e.width() / s.width(), e.center().y() + e.height() / s.height() );
QgsCoordinateTransform ct( mMapCanvas->mapSettings().destinationCrs(), layer->crs() );
QgsCoordinateTransform ct( mMapCanvas->mapSettings().destinationCrs(), layer->crs(), QgsProject::instance() );
p1 = ct.transform( p1 );
p2 = ct.transform( p2 );
double width = std::sqrt( p1.sqrDist( p2 ) ); // width (actually the diagonal) of reprojected pixel
@@ -253,7 +253,7 @@ void QgsBookmarks::zoomToBookmark()
authid != QgisApp::instance()->mapCanvas()->mapSettings().destinationCrs().authid() )
{
QgsCoordinateTransform ct( QgsCoordinateReferenceSystem::fromOgcWmsCrs( authid ),
QgisApp::instance()->mapCanvas()->mapSettings().destinationCrs() );
QgisApp::instance()->mapCanvas()->mapSettings().destinationCrs(), QgsProject::instance() );
rect = ct.transform( rect );
if ( rect.isEmpty() )
{
@@ -38,6 +38,7 @@
#include "qgssettings.h"
#include "qgisapp.h"
#include "qgsmapcanvas.h"
#include "qgsproject.h"

QgsClipboard::QgsClipboard()
{
@@ -277,7 +278,7 @@ QgsFeatureList QgsClipboard::transformedCopyOf( const QgsCoordinateReferenceSyst
}
else
{
ct = QgsCoordinateTransform( crs(), destCRS );
ct = QgsCoordinateTransform( crs(), destCRS, QgsProject::instance() );
}

QgsDebugMsg( "transforming clipboard." );
@@ -139,7 +139,7 @@ void QgsDecorationLayoutExtent::render( const QgsMapSettings &mapSettings, QgsRe
{
// reproject extent
QgsCoordinateTransform ct( map->crs(),
mapSettings.destinationCrs() );
mapSettings.destinationCrs(), QgsProject::instance() );
g = g.densifyByCount( 20 );
try
{
@@ -322,7 +322,7 @@ void QgsMapCanvasDockWidget::syncViewCenter( QgsMapCanvas *sourceCanvas )

// reproject extent
QgsCoordinateTransform ct( sourceCanvas->mapSettings().destinationCrs(),
destCanvas->mapSettings().destinationCrs() );
destCanvas->mapSettings().destinationCrs(), QgsProject::instance() );
try
{
destCanvas->setCenter( ct.transform( sourceCanvas->center() ) );
@@ -412,7 +412,7 @@ void QgsMapCanvasDockWidget::syncMarker( const QgsPointXY &p )

// reproject point
QgsCoordinateTransform ct( mMainCanvas->mapSettings().destinationCrs(),
mMapCanvas->mapSettings().destinationCrs() );
mMapCanvas->mapSettings().destinationCrs(), QgsProject::instance() );
QgsPointXY t = p;
try
{
@@ -450,7 +450,7 @@ void QgsMapCanvasDockWidget::updateExtentRect()
{
// reproject extent
QgsCoordinateTransform ct( mMainCanvas->mapSettings().destinationCrs(),
mMapCanvas->mapSettings().destinationCrs() );
mMapCanvas->mapSettings().destinationCrs(), QgsProject::instance() );
g = g.densifyByCount( 5 );
try
{
@@ -359,7 +359,7 @@ QgsPointXY QgsMapToolAnnotation::transformCanvasToAnnotation( QgsPointXY p, QgsA
{
if ( annotation->mapPositionCrs() != mCanvas->mapSettings().destinationCrs() )
{
QgsCoordinateTransform transform( mCanvas->mapSettings().destinationCrs(), annotation->mapPositionCrs() );
QgsCoordinateTransform transform( mCanvas->mapSettings().destinationCrs(), annotation->mapPositionCrs(), QgsProject::instance() );
try
{
p = transform.transform( p );
@@ -28,6 +28,7 @@ email : jpalmer at linz dot govt dot nz
#include "qgsexception.h"
#include "qgslogger.h"
#include "qgis.h"
#include "qgsproject.h"

#include <QMouseEvent>
#include <QApplication>
@@ -176,7 +177,7 @@ QgsFeatureIds QgsMapToolSelectUtils::getMatchingFeatures( QgsMapCanvas *canvas,

try
{
QgsCoordinateTransform ct( canvas->mapSettings().destinationCrs(), vlayer->crs() );
QgsCoordinateTransform ct( canvas->mapSettings().destinationCrs(), vlayer->crs(), QgsProject::instance() );

if ( !ct.isShortCircuited() && selectGeomTrans.type() == QgsWkbTypes::PolygonGeometry )
{
@@ -199,7 +199,7 @@ bool QgsMapToolShowHideLabels::selectedFeatures( QgsVectorLayer *vlayer,

try
{
QgsCoordinateTransform ct( mCanvas->mapSettings().destinationCrs(), vlayer->crs() );
QgsCoordinateTransform ct( mCanvas->mapSettings().destinationCrs(), vlayer->crs(), QgsProject::instance() );
selectGeomTrans.transform( ct );
}
catch ( QgsCsException &cse )
@@ -26,6 +26,7 @@
#include "qgsmeasuretool.h"
#include "qgsmessagelog.h"
#include "qgssettings.h"
#include "qgsproject.h"

#include <QMessageBox>
#include <QMouseEvent>
@@ -133,7 +134,7 @@ void QgsMeasureTool::updateSettings()

mDialog->restart();
mDone = lastDone;
QgsCoordinateTransform ct( mDestinationCrs, mCanvas->mapSettings().destinationCrs() );
QgsCoordinateTransform ct( mDestinationCrs, mCanvas->mapSettings().destinationCrs(), QgsProject::instance() );

Q_FOREACH ( const QgsPointXY &previousPoint, points )
{
@@ -163,7 +163,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
{
// reproject extent
QgsCoordinateTransform ct( QgsProject::instance()->crs(),
QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) );
QgsCoordinateReferenceSystem::fromEpsgId( 4326 ), QgsProject::instance() );

g = g.densifyByCount( 5 );
try
@@ -413,7 +413,7 @@ bool QgsComposerAttributeTableV2::getTableContents( QgsComposerTableContents &co
if ( layer )
{
//transform back to layer CRS
QgsCoordinateTransform coordTransform( layer->crs(), mComposerMap->crs() );
QgsCoordinateTransform coordTransform( layer->crs(), mComposerMap->crs(), mComposition->project() );
try
{
selectionRect = coordTransform.transformBoundingBox( selectionRect, QgsCoordinateTransform::ReverseTransform );
@@ -1890,7 +1890,7 @@ QPointF QgsComposerMap::composerMapPosForItem( const QgsAnnotation *annotation )
if ( annotationCrs != crs() )
{
//need to reproject
QgsCoordinateTransform t( annotationCrs, crs() );
QgsCoordinateTransform t( annotationCrs, crs(), mComposition->project() );
double z = 0.0;
t.transformInPlace( mapX, mapY, z );
}

0 comments on commit 86d9492

Please sign in to comment.
You can’t perform that action at this time.