diff --git a/doc/api_break.dox b/doc/api_break.dox index 8b9a3443e1fe..58e196df5db6 100644 --- a/doc/api_break.dox +++ b/doc/api_break.dox @@ -2133,6 +2133,12 @@ loadDefaultStyle argument. signals now accept a QgsRasterBlockFeedback argument for reporting progress updates. +QgsRasterLayerSaveAsDialog {#qgis_api_break_3_0_QgsRasterLayerSaveAsDialog} +-------------------------- + +- The currentExtent and currentCrs arguments have been dropped from the constructor. Use setMapCanvas() instead. + + QgsRasterProjector {#qgis_api_break_3_0_QgsRasterProjector} ------------------ @@ -2524,6 +2530,8 @@ QgsTracer {#qgis_api_break_3_0_QgsTracer} --------- - hasCrsTransformEnabled() and setCrsTransformEnabled() were removed. CRS transformation is now always enabled when required. +- setDestinationCrs() now requires a QgsCoordinateTransformContext argument. + QgsTransaction {#qgis_api_break_3_0_QgsTransaction} -------------- diff --git a/python/core/qgstracer.sip b/python/core/qgstracer.sip index f6621e2992b3..f0c539d302c8 100644 --- a/python/core/qgstracer.sip +++ b/python/core/qgstracer.sip @@ -43,11 +43,16 @@ Set layers used for tracing QgsCoordinateReferenceSystem destinationCrs() const; %Docstring -Get CRS used for tracing +Returns the CRS used for tracing. + +.. seealso:: :py:func:`setDestinationCrs()` %End - void setDestinationCrs( const QgsCoordinateReferenceSystem &crs ); + + void setDestinationCrs( const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context ); %Docstring -Set CRS used for tracing +Sets the ``crs`` and transform ``context`` used for tracing. + +.. seealso:: :py:func:`destinationCrs()` %End QgsRectangle extent() const; diff --git a/python/gui/qgsmapcanvas.sip b/python/gui/qgsmapcanvas.sip index 8c4b54945ed8..c1e1d1b5548c 100644 --- a/python/gui/qgsmapcanvas.sip +++ b/python/gui/qgsmapcanvas.sip @@ -898,6 +898,13 @@ Emitted when zoom next status changed Emitted when map CRS has changed .. versionadded:: 2.4 +%End + + void transformContextChanged(); +%Docstring +Emitted when the canvas transform context is changed. + +.. versionadded:: 3.0 %End void currentLayerChanged( QgsMapLayer *layer ); diff --git a/src/core/qgstracer.cpp b/src/core/qgstracer.cpp index 071b5e7a2dc3..d4aefb3678b9 100644 --- a/src/core/qgstracer.cpp +++ b/src/core/qgstracer.cpp @@ -473,16 +473,13 @@ bool QgsTracer::initGraph() t1.start(); int featuresCounted = 0; - Q_FOREACH ( QgsVectorLayer *vl, mLayers ) + for ( QgsVectorLayer *vl : qgis::as_const( mLayers ) ) { - Q_NOWARN_DEPRECATED_PUSH - QgsCoordinateTransform ct( vl->crs(), mCRS ); - Q_NOWARN_DEPRECATED_POP - QgsFeatureRequest request; request.setSubsetOfAttributes( QgsAttributeList() ); + request.setDestinationCrs( mCRS, mTransformContext ); if ( !mExtent.isEmpty() ) - request.setFilterRect( ct.transformBoundingBox( mExtent, QgsCoordinateTransform::ReverseTransform ) ); + request.setFilterRect( mExtent ); QgsFeatureIterator fi = vl->getFeatures( request ); while ( fi.nextFeature( f ) ) @@ -490,20 +487,6 @@ bool QgsTracer::initGraph() if ( !f.hasGeometry() ) continue; - if ( !ct.isShortCircuited() ) - { - try - { - QgsGeometry transformedGeom = f.geometry(); - transformedGeom.transform( ct ); - f.setGeometry( transformedGeom ); - } - catch ( QgsCsException & ) - { - continue; // ignore if the transform failed - } - } - extractLinework( f.geometry(), mpl ); ++featuresCounted; @@ -596,12 +579,10 @@ void QgsTracer::setLayers( const QList &layers ) invalidateGraph(); } -void QgsTracer::setDestinationCrs( const QgsCoordinateReferenceSystem &crs ) +void QgsTracer::setDestinationCrs( const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context ) { - if ( mCRS == crs ) - return; - mCRS = crs; + mTransformContext = context; invalidateGraph(); } diff --git a/src/core/qgstracer.h b/src/core/qgstracer.h index 6995588d9325..d8a0d4a744be 100644 --- a/src/core/qgstracer.h +++ b/src/core/qgstracer.h @@ -53,10 +53,17 @@ class CORE_EXPORT QgsTracer : public QObject //! Set layers used for tracing void setLayers( const QList &layers ); - //! Get CRS used for tracing + /** + * Returns the CRS used for tracing. + * \see setDestinationCrs() + */ QgsCoordinateReferenceSystem destinationCrs() const { return mCRS; } - //! Set CRS used for tracing - void setDestinationCrs( const QgsCoordinateReferenceSystem &crs ); + + /** + * Sets the \a crs and transform \a context used for tracing. + * \see destinationCrs() + */ + void setDestinationCrs( const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context ); //! Get extent to which graph's features will be limited (empty extent means no limit) QgsRectangle extent() const { return mExtent; } @@ -161,6 +168,8 @@ class CORE_EXPORT QgsTracer : public QObject QList mLayers; //! Destination CRS in which graph is built and tracing done QgsCoordinateReferenceSystem mCRS; + //! Coordinate transform context + QgsCoordinateTransformContext mTransformContext; //! Extent for graph building (empty extent means no limit) QgsRectangle mExtent; diff --git a/src/gui/qgsmapcanvas.cpp b/src/gui/qgsmapcanvas.cpp index efaf8443de84..43faedda1c63 100644 --- a/src/gui/qgsmapcanvas.cpp +++ b/src/gui/qgsmapcanvas.cpp @@ -144,6 +144,7 @@ QgsMapCanvas::QgsMapCanvas( QWidget *parent ) this, [ = ] { mSettings.setTransformContext( QgsProject::instance()->transformContext() ); + emit transformContextChanged(); refresh(); } ); diff --git a/src/gui/qgsmapcanvas.h b/src/gui/qgsmapcanvas.h index 4046a1dfd536..3bd3086f5eae 100644 --- a/src/gui/qgsmapcanvas.h +++ b/src/gui/qgsmapcanvas.h @@ -801,6 +801,12 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView */ void destinationCrsChanged(); + /** + * Emitted when the canvas transform context is changed. + * \since QGIS 3.0 + */ + void transformContextChanged(); + /** * Emitted when the current layer is changed * \since QGIS 2.8 diff --git a/src/gui/qgsmapcanvastracer.cpp b/src/gui/qgsmapcanvastracer.cpp index 0d6ce3c9519d..1493eee40377 100644 --- a/src/gui/qgsmapcanvastracer.cpp +++ b/src/gui/qgsmapcanvastracer.cpp @@ -39,6 +39,7 @@ QgsMapCanvasTracer::QgsMapCanvasTracer( QgsMapCanvas *canvas, QgsMessageBar *mes // when things change we just invalidate the graph - and set up new parameters again only when necessary connect( canvas, &QgsMapCanvas::destinationCrsChanged, this, &QgsMapCanvasTracer::invalidateGraph ); + connect( canvas, &QgsMapCanvas::transformContextChanged, this, &QgsMapCanvasTracer::invalidateGraph ); connect( canvas, &QgsMapCanvas::layersChanged, this, &QgsMapCanvasTracer::invalidateGraph ); connect( canvas, &QgsMapCanvas::extentsChanged, this, &QgsMapCanvasTracer::invalidateGraph ); connect( canvas, &QgsMapCanvas::currentLayerChanged, this, &QgsMapCanvasTracer::onCurrentLayerChanged ); @@ -96,7 +97,7 @@ void QgsMapCanvasTracer::reportError( QgsTracer::PathError err, bool addingVerte void QgsMapCanvasTracer::configure() { - setDestinationCrs( mCanvas->mapSettings().destinationCrs() ); + setDestinationCrs( mCanvas->mapSettings().destinationCrs(), mCanvas->mapSettings().transformContext() ); setExtent( mCanvas->extent() ); QList layers; diff --git a/tests/src/core/testqgstracer.cpp b/tests/src/core/testqgstracer.cpp index 122f3bd95338..fb457f592860 100644 --- a/tests/src/core/testqgstracer.cpp +++ b/tests/src/core/testqgstracer.cpp @@ -313,7 +313,8 @@ void TestQgsTracer::testReprojection() QgsTracer tracer; tracer.setLayers( QList() << vl ); - tracer.setDestinationCrs( dstCrs ); + QgsCoordinateTransformContext context; + tracer.setDestinationCrs( dstCrs, context ); tracer.init(); QgsPolylineXY points1 = tracer.findShortestPath( p1, p2 );