Skip to content

Commit 7d2027f

Browse files
committedJul 14, 2016
Fix most remaining methods which return a reference to
QgsCoordinateReferenceSystem or which take a pointer to a CRS
1 parent 726569c commit 7d2027f

19 files changed

+76
-34
lines changed
 

‎doc/api_break.dox

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ This page tries to maintain a list with incompatible changes that happened in pr
1818

1919
\section qgis_api_break_3_0 QGIS 3.0
2020

21+
\subsection qgis_api_break_3_0_QgsCoordinateTransform QgsCoordinateTransform
22+
23+
<ul>
24+
<li>sourceCrs() and destCrs() now return a copy instead of a reference to the CRS. This has no effect on PyQGIS code, but c++
25+
plugins calling these methods will need to be updated.</li>
26+
</ul>
27+
2128
\subsection qgis_api_break_3_0_DataProviders Data Providers
2229

2330
<ul>
@@ -47,6 +54,13 @@ only affects third party c++ providers, and does not affect PyQGIS scripts.</li>
4754
<li>crs() now returns a QgsCoordinateReferenceSystem object, not a reference. This change has no effect for PyQGIS code.</li>
4855
</ul>
4956

57+
\subsection qgis_api_break_3_0_QgsJSONExporter QgsJSONExporter
58+
59+
<ul>
60+
<li>sourceCrs() now returns a copy instead of a reference to the CRS. This has no effect on PyQGIS code, but c++
61+
plugins calling this method will need to be updated.</li>
62+
</ul>
63+
5064
\subsection qgis_api_break_3_0_QgsVectorLayerImport QgsVectorLayerImport
5165

5266
<ul>
@@ -56,6 +70,29 @@ pointers makes for more robust, safer code. Use an invalid (default constructed)
5670
in code which previously passed a null pointer to QgsVectorLayerImport.</li>
5771
</ul>
5872

73+
\subsection qgis_api_break_3_0_QgsPointLocator QgsPointLocator
74+
75+
<ul>
76+
<li>The constructor now takes a reference rather than a pointer to a CRS. This has no effect on PyQGIS code, but c++
77+
plugins calling this method will need to be updated.</li>
78+
<li>destCrs() now returns a copy instead of a reference to the CRS. This has no effect on PyQGIS code, but c++
79+
plugins calling this method will need to be updated.</li>
80+
</ul>
81+
82+
\subsection qgis_api_break_3_0_QgsMapSettings QgsMapSettings
83+
84+
<ul>
85+
<li>destinationCrs() now returns a copy instead of a reference to the CRS. This has no effect on PyQGIS code, but c++
86+
plugins calling this method will need to be updated.</li>
87+
</ul>
88+
89+
\subsection qgis_api_break_3_0_QgsGraphBuilderInterface QgsGraphBuilderInterface
90+
91+
<ul>
92+
<li>destinationCrs() now returns a copy instead of a reference to the CRS. This has no effect on PyQGIS code, but c++
93+
plugins calling this method will need to be updated.</li>
94+
</ul>
95+
5996
\subsection qgis_api_break_3_0_QgsVectorFileWriter QgsVectorFileWriter
6097

6198
<ul>

‎python/analysis/network/qgsgraphbuilderintr.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class QgsGraphBuilderInterface
3030
*/
3131
QgsGraphBuilderInterface( const QgsCoordinateReferenceSystem& crs, bool ctfEnabled = true, double topologyTolerance = 0.0, const QString& ellipsoidID = "WGS84" );
3232

33-
QgsCoordinateReferenceSystem& destinationCrs();
33+
QgsCoordinateReferenceSystem destinationCrs() const;
3434

3535
//! get coordinate transformation enabled
3636
bool coordinateTransformationEnabled();

‎python/core/qgscoordinatetransform.sip

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ class QgsCoordinateTransform : QObject
7979
* Get the QgsCoordinateReferenceSystem representation of the layer's coordinate system
8080
* @return QgsCoordinateReferenceSystem of the layer's coordinate system
8181
*/
82-
const QgsCoordinateReferenceSystem& sourceCrs() const;
82+
QgsCoordinateReferenceSystem sourceCrs() const;
8383

8484
/*!
8585
* Get the QgsCoordinateReferenceSystem representation of the map canvas coordinate system
8686
* @return QgsCoordinateReferenceSystem of the map canvas coordinate system
8787
*/
88-
const QgsCoordinateReferenceSystem& destCRS() const;
88+
QgsCoordinateReferenceSystem destCRS() const;
8989

9090
/** Transform the point from Source Coordinate System to Destination Coordinate System
9191
* If the direction is ForwardTransform then coordinates are transformed from layer CS --> map canvas CS,

‎python/core/qgsjsonutils.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class QgsJSONExporter
9090
* correctly automatically reprojected to WGS 84, to match GeoJSON specifications.
9191
* @see setSourceCrs()
9292
*/
93-
const QgsCoordinateReferenceSystem& sourceCrs() const;
93+
QgsCoordinateReferenceSystem sourceCrs() const;
9494

9595
/** Sets the list of attributes to include in the JSON exports.
9696
* @param attributes list of attribute indexes, or an empty list to include all

‎python/core/qgsmapsettings.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class QgsMapSettings
8888
//! sets destination coordinate reference system
8989
void setDestinationCrs( const QgsCoordinateReferenceSystem& crs );
9090
//! returns CRS of destination coordinate reference system
91-
const QgsCoordinateReferenceSystem& destinationCrs() const;
91+
QgsCoordinateReferenceSystem destinationCrs() const;
9292

9393
//! Get units of map's geographical coordinates - used for scale calculation
9494
QGis::UnitType mapUnits() const;

‎python/core/qgspointlocator.sip

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,23 @@ class QgsPointLocator : QObject
1919
%End
2020

2121
public:
22+
2223
/** Construct point locator for a layer.
23-
* @arg destCRS if not null, will do the searches on data reprojected to the given CRS
24+
* @arg destCRS if a valid QgsCoordinateReferenceSystem is passed then the locator will
25+
* do the searches on data reprojected to the given CRS
2426
* @arg extent if not null, will index only a subset of the layer
2527
*/
26-
explicit QgsPointLocator( QgsVectorLayer* layer, const QgsCoordinateReferenceSystem* destCRS = 0, const QgsRectangle* extent = 0 );
28+
explicit QgsPointLocator( QgsVectorLayer* layer, const QgsCoordinateReferenceSystem& destCRS = QgsCoordinateReferenceSystem(),
29+
const QgsRectangle* extent = nullptr );
2730

2831
~QgsPointLocator();
2932

3033
//! Get associated layer
3134
//! @note added in QGIS 2.14
3235
QgsVectorLayer* layer() const;
33-
//! Get destination CRS - may be null if not doing OTF reprojection
36+
//! Get destination CRS - may be an invalid QgsCoordinateReferenceSystem if not doing OTF reprojection
3437
//! @note added in QGIS 2.14
35-
const QgsCoordinateReferenceSystem* destCRS() const;
38+
QgsCoordinateReferenceSystem destCRS() const;
3639
//! Get extent of the area point locator covers - if null then it caches the whole layer
3740
//! @note added in QGIS 2.14
3841
const QgsRectangle* extent() const;

‎src/analysis/network/qgsgraphbuilderintr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class ANALYSIS_EXPORT QgsGraphBuilderInterface
5656
{ }
5757

5858
//! get destinaltion Crs
59-
QgsCoordinateReferenceSystem& destinationCrs()
59+
QgsCoordinateReferenceSystem destinationCrs() const
6060
{
6161
return mCrs;
6262
}

‎src/app/qgsdecorationgrid.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ bool QgsDecorationGrid::getIntervalFromCurrentLayer( double* values )
833833
return false;
834834
}
835835
QgsCoordinateReferenceSystem layerCRS = layer->crs();
836-
const QgsCoordinateReferenceSystem& mapCRS =
836+
QgsCoordinateReferenceSystem mapCRS =
837837
QgisApp::instance()->mapCanvas()->mapSettings().destinationCrs();
838838
// is this the best way to compare CRS? should we also make sure map has OTF enabled?
839839
// TODO calculate transformed values if necessary

‎src/app/qgsidentifyresultsdialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class APP_EXPORT QgsIdentifyResultsFeatureItem: public QTreeWidgetItem
6868
QgsIdentifyResultsFeatureItem( const QgsFields &fields, const QgsFeature &feature, const QgsCoordinateReferenceSystem &crs, const QStringList & strings = QStringList() );
6969
const QgsFields &fields() const { return mFields; }
7070
const QgsFeature &feature() const { return mFeature; }
71-
const QgsCoordinateReferenceSystem &crs() { return mCrs; }
71+
QgsCoordinateReferenceSystem crs() const { return mCrs; }
7272

7373
private:
7474
QgsFields mFields;

‎src/core/qgscoordinatetransform.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ class CORE_EXPORT QgsCoordinateTransform : public QObject
113113
* Get the QgsCoordinateReferenceSystem representation of the layer's coordinate system
114114
* @return QgsCoordinateReferenceSystem of the layer's coordinate system
115115
*/
116-
const QgsCoordinateReferenceSystem& sourceCrs() const { return mSourceCRS; }
116+
QgsCoordinateReferenceSystem sourceCrs() const { return mSourceCRS; }
117117

118118
/*!
119119
* Get the QgsCoordinateReferenceSystem representation of the map canvas coordinate system
120120
* @return QgsCoordinateReferenceSystem of the map canvas coordinate system
121121
*/
122-
const QgsCoordinateReferenceSystem& destCRS() const { return mDestCRS; }
122+
QgsCoordinateReferenceSystem destCRS() const { return mDestCRS; }
123123

124124
/** Transform the point from Source Coordinate System to Destination Coordinate System
125125
* If the direction is ForwardTransform then coordinates are transformed from layer CS --> map canvas CS,

‎src/core/qgsjsonutils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void QgsJSONExporter::setSourceCrs( const QgsCoordinateReferenceSystem& crs )
5858
mTransform.setSourceCrs( mCrs );
5959
}
6060

61-
const QgsCoordinateReferenceSystem& QgsJSONExporter::sourceCrs() const
61+
QgsCoordinateReferenceSystem QgsJSONExporter::sourceCrs() const
6262
{
6363
return mCrs;
6464
}

‎src/core/qgsjsonutils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class CORE_EXPORT QgsJSONExporter
112112
* correctly automatically reprojected to WGS 84, to match GeoJSON specifications.
113113
* @see setSourceCrs()
114114
*/
115-
const QgsCoordinateReferenceSystem& sourceCrs() const;
115+
QgsCoordinateReferenceSystem sourceCrs() const;
116116

117117
/** Sets the list of attributes to include in the JSON exports.
118118
* @param attributes list of attribute indexes, or an empty list to include all

‎src/core/qgsmapsettings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ void QgsMapSettings::setDestinationCrs( const QgsCoordinateReferenceSystem& crs
291291
mDatumTransformStore.setDestinationCrs( crs );
292292
}
293293

294-
const QgsCoordinateReferenceSystem& QgsMapSettings::destinationCrs() const
294+
QgsCoordinateReferenceSystem QgsMapSettings::destinationCrs() const
295295
{
296296
return mDestCRS;
297297
}

‎src/core/qgsmapsettings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class CORE_EXPORT QgsMapSettings
136136
//! sets destination coordinate reference system
137137
void setDestinationCrs( const QgsCoordinateReferenceSystem& crs );
138138
//! returns CRS of destination coordinate reference system
139-
const QgsCoordinateReferenceSystem& destinationCrs() const;
139+
QgsCoordinateReferenceSystem destinationCrs() const;
140140

141141
//! Get units of map's geographical coordinates - used for scale calculation
142142
QGis::UnitType mapUnits() const;

‎src/core/qgspointlocator.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -608,17 +608,17 @@ class QgsPointLocator_DumpTree : public SpatialIndex::IQueryStrategy
608608
////////////////////////////////////////////////////////////////////////////
609609

610610

611-
QgsPointLocator::QgsPointLocator( QgsVectorLayer* layer, const QgsCoordinateReferenceSystem* destCRS, const QgsRectangle* extent )
611+
QgsPointLocator::QgsPointLocator( QgsVectorLayer* layer, const QgsCoordinateReferenceSystem& destCRS, const QgsRectangle* extent )
612612
: mStorage( nullptr )
613613
, mRTree( nullptr )
614614
, mIsEmptyLayer( false )
615615
, mTransform( nullptr )
616616
, mLayer( layer )
617617
, mExtent( nullptr )
618618
{
619-
if ( destCRS )
619+
if ( destCRS.isValid() )
620620
{
621-
mTransform = new QgsCoordinateTransform( layer->crs(), *destCRS );
621+
mTransform = new QgsCoordinateTransform( layer->crs(), destCRS );
622622
}
623623

624624
setExtent( extent );
@@ -639,9 +639,9 @@ QgsPointLocator::~QgsPointLocator()
639639
delete mExtent;
640640
}
641641

642-
const QgsCoordinateReferenceSystem* QgsPointLocator::destCRS() const
642+
QgsCoordinateReferenceSystem QgsPointLocator::destCRS() const
643643
{
644-
return mTransform ? &mTransform->destCRS() : nullptr;
644+
return mTransform ? mTransform->destCRS() : QgsCoordinateReferenceSystem();
645645
}
646646

647647
void QgsPointLocator::setExtent( const QgsRectangle* extent )

‎src/core/qgspointlocator.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ class QgsVectorLayer;
2222
#include "qgsfeature.h"
2323
#include "qgspoint.h"
2424
#include "qgsrectangle.h"
25+
#include "qgscoordinatereferencesystem.h"
2526

2627
class QgsCoordinateTransform;
27-
class QgsCoordinateReferenceSystem;
2828

2929
class QgsPointLocator_VisitorNearestVertex;
3030
class QgsPointLocator_VisitorNearestEdge;
@@ -52,19 +52,21 @@ class CORE_EXPORT QgsPointLocator : public QObject
5252
Q_OBJECT
5353
public:
5454
/** Construct point locator for a layer.
55-
* @arg destCRS if not null, will do the searches on data reprojected to the given CRS
55+
* @arg destCRS if a valid QgsCoordinateReferenceSystem is passed then the locator will
56+
* do the searches on data reprojected to the given CRS
5657
* @arg extent if not null, will index only a subset of the layer
5758
*/
58-
explicit QgsPointLocator( QgsVectorLayer* layer, const QgsCoordinateReferenceSystem* destCRS = nullptr, const QgsRectangle* extent = nullptr );
59+
explicit QgsPointLocator( QgsVectorLayer* layer, const QgsCoordinateReferenceSystem& destCRS = QgsCoordinateReferenceSystem(),
60+
const QgsRectangle* extent = nullptr );
5961

6062
~QgsPointLocator();
6163

6264
//! Get associated layer
6365
//! @note added in QGIS 2.14
6466
QgsVectorLayer* layer() const { return mLayer; }
65-
//! Get destination CRS - may be null if not doing OTF reprojection
67+
//! Get destination CRS - may be an invalid QgsCoordinateReferenceSystem if not doing OTF reprojection
6668
//! @note added in QGIS 2.14
67-
const QgsCoordinateReferenceSystem* destCRS() const;
69+
QgsCoordinateReferenceSystem destCRS() const;
6870
//! Get extent of the area point locator covers - if null then it caches the whole layer
6971
//! @note added in QGIS 2.14
7072
const QgsRectangle* extent() const { return mExtent; }

‎src/core/qgssnappingutils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,9 +572,9 @@ QString QgsSnappingUtils::dump()
572572
return msg;
573573
}
574574

575-
const QgsCoordinateReferenceSystem* QgsSnappingUtils::destCRS()
575+
QgsCoordinateReferenceSystem QgsSnappingUtils::destCRS() const
576576
{
577-
return mMapSettings.hasCrsTransformEnabled() ? &mMapSettings.destinationCrs() : nullptr;
577+
return mMapSettings.hasCrsTransformEnabled() ? mMapSettings.destinationCrs() : QgsCoordinateReferenceSystem();
578578
}
579579

580580

‎src/core/qgssnappingutils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ class CORE_EXPORT QgsSnappingUtils : public QObject
185185
void onLayersWillBeRemoved( const QStringList& layerIds );
186186

187187
private:
188-
//! get from map settings pointer to destination CRS - or 0 if projections are disabled
189-
const QgsCoordinateReferenceSystem* destCRS();
188+
//! Get destination CRS from map settings, or an invalid CRS if projections are disabled
189+
QgsCoordinateReferenceSystem destCRS() const;
190190

191191
//! delete all existing locators (e.g. when destination CRS has changed and we need to reindex)
192192
void clearAllLocators();

‎src/server/qgsserverprojectparser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ void QgsServerProjectParser::combineExtentAndCrsOfGroupChildren( QDomElement& gr
747747

748748
QgsConfigParserUtils::appendCRSElementsToLayer( groupElem, doc, combinedCRSSet.toList(), supportedOutputCrsList() );
749749

750-
const QgsCoordinateReferenceSystem& groupCRS = projectCRS();
750+
QgsCoordinateReferenceSystem groupCRS = projectCRS();
751751
if ( considerMapExtent )
752752
{
753753
QgsRectangle mapRect = mapRectangle();
@@ -879,7 +879,7 @@ QgsRectangle QgsServerProjectParser::layerBoundingBoxInProjectCRS( const QDomEle
879879
}
880880

881881
//get project crs
882-
const QgsCoordinateReferenceSystem& projectCrs = projectCRS();
882+
QgsCoordinateReferenceSystem projectCrs = projectCRS();
883883
QgsCoordinateTransform t( layerCrs, projectCrs );
884884

885885
//transform

0 commit comments

Comments
 (0)
Please sign in to comment.