Skip to content

Commit 0cf4ecf

Browse files
committedMay 31, 2019
Deprecate a QgsCoordinateTransformContext members which don't
apply in proj >= 6.0 builds
1 parent 823d28b commit 0cf4ecf

9 files changed

+75
-27
lines changed
 

‎python/core/auto_generated/qgscoordinatetransformcontext.sip.in

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Copy constructor
6363
Clears all stored transform information from the context.
6464
%End
6565

66-
QMap< QPair< QString, QString>, QgsDatumTransform::TransformPair > sourceDestinationDatumTransforms() const;
66+
QMap< QPair< QString, QString>, QgsDatumTransform::TransformPair > sourceDestinationDatumTransforms() const /Deprecated/;
6767
%Docstring
6868
Returns the stored mapping for source to destination CRS pairs to associated datum transforms to use.
6969
The map keys will be :py:func:`QgsCoordinateReferenceSystems.authid()`s.
@@ -78,12 +78,12 @@ required for transformations for that source or destination.
7878
to determine this.
7979

8080
.. seealso:: :py:func:`addSourceDestinationDatumTransform`
81+
82+
83+
.. deprecated:: Has no effect on builds based on Proj 6.0 or later
8184
%End
8285

83-
bool addSourceDestinationDatumTransform( const QgsCoordinateReferenceSystem &sourceCrs,
84-
const QgsCoordinateReferenceSystem &destinationCrs,
85-
int sourceTransformId,
86-
int destinationTransformId );
86+
bool addSourceDestinationDatumTransform( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, int sourceTransformId, int destinationTransformId ) /Deprecated/;
8787
%Docstring
8888
Adds a new ``sourceTransform`` and ``destinationTransform`` to use when projecting coordinates
8989
from the specified ``sourceCrs`` to the specified ``destinationCrs``.
@@ -101,15 +101,27 @@ Returns ``True`` if the new transform pair was added successfully.
101101
.. seealso:: :py:func:`sourceDestinationDatumTransforms`
102102

103103
.. seealso:: :py:func:`removeSourceDestinationDatumTransform`
104+
105+
106+
.. deprecated:: Has no effect on builds based on Proj 6.0 or later
104107
%End
105108

106-
void removeSourceDestinationDatumTransform( const QgsCoordinateReferenceSystem &sourceCrs,
107-
const QgsCoordinateReferenceSystem &destinationCrs );
109+
void removeSourceDestinationDatumTransform( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs ) /Deprecated/;
108110
%Docstring
109111
Removes the source to destination datum transform pair for the specified ``sourceCrs`` and
110112
``destinationCrs``.
111113

112114
.. seealso:: :py:func:`addSourceDestinationDatumTransform`
115+
116+
.. deprecated:: Use removeCoordinateOperation() instead
117+
%End
118+
119+
void removeCoordinateOperation( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs );
120+
%Docstring
121+
Removes the source to destination datum coordinated operation for the specified ``sourceCrs`` and
122+
``destinationCrs``.
123+
124+
.. versionadded:: 3.8
113125
%End
114126

115127
bool hasTransform( const QgsCoordinateReferenceSystem &source,
@@ -123,8 +135,7 @@ when transforming from the specified ``source`` CRS to ``destination`` CRS.
123135
source and destination are reversible.
124136
%End
125137

126-
QgsDatumTransform::TransformPair calculateDatumTransforms( const QgsCoordinateReferenceSystem &source,
127-
const QgsCoordinateReferenceSystem &destination ) const;
138+
QgsDatumTransform::TransformPair calculateDatumTransforms( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination ) const /Deprecated/;
128139
%Docstring
129140
Returns the pair of source and destination datum transforms to use
130141
for a transform from the specified ``source`` CRS to ``destination`` CRS.
@@ -135,6 +146,8 @@ destination.
135146
.. note::
136147

137148
source and destination are reversible.
149+
150+
.. deprecated:: Has no effect on builds based on Proj 6.0 or later
138151
%End
139152

140153
bool readXml( const QDomElement &element, const QgsReadWriteContext &context, QStringList &missingTransforms /Out/ );

‎src/app/qgsdatumtransformtablewidget.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void QgsDatumTransformTableModel::removeTransform( const QModelIndexList &indexe
4646
}
4747
if ( sourceCrs.isValid() && destinationCrs.isValid() )
4848
{
49-
mTransformContext.removeSourceDestinationDatumTransform( sourceCrs, destinationCrs );
49+
mTransformContext.removeCoordinateOperation( sourceCrs, destinationCrs );
5050
reset();
5151
break;
5252
}
@@ -57,7 +57,9 @@ void QgsDatumTransformTableModel::removeTransform( const QModelIndexList &indexe
5757
int QgsDatumTransformTableModel::rowCount( const QModelIndex &parent ) const
5858
{
5959
Q_UNUSED( parent )
60+
Q_NOWARN_DEPRECATED_PUSH
6061
return mTransformContext.sourceDestinationDatumTransforms().count();
62+
Q_NOWARN_DEPRECATED_POP
6163
}
6264

6365
int QgsDatumTransformTableModel::columnCount( const QModelIndex &parent ) const
@@ -73,10 +75,14 @@ QVariant QgsDatumTransformTableModel::data( const QModelIndex &index, int role )
7375
int sourceTransform = -1;
7476
int destinationTransform = -1;
7577

78+
Q_NOWARN_DEPRECATED_PUSH
7679
QPair< QString, QString> crses = mTransformContext.sourceDestinationDatumTransforms().keys().at( index.row() );
80+
Q_NOWARN_DEPRECATED_POP
7781
sourceCrs = crses.first;
7882
destinationCrs = crses.second;
83+
Q_NOWARN_DEPRECATED_PUSH
7984
const QgsDatumTransform::TransformPair transforms = mTransformContext.sourceDestinationDatumTransforms().value( crses );
85+
Q_NOWARN_DEPRECATED_POP
8086
sourceTransform = transforms.sourceTransformId;
8187
destinationTransform = transforms.destinationTransformId;
8288

@@ -194,7 +200,9 @@ void QgsDatumTransformTableWidget::addDatumTransform()
194200
{
195201
const QgsDatumTransformDialog::TransformInfo dt = dlg.selectedDatumTransform();
196202
QgsCoordinateTransformContext context = mModel->transformContext();
203+
Q_NOWARN_DEPRECATED_PUSH
197204
context.addSourceDestinationDatumTransform( dt.sourceCrs, dt.destinationCrs, dt.sourceTransformId, dt.destinationTransformId );
205+
Q_NOWARN_DEPRECATED_POP
198206
mModel->setTransformContext( context );
199207
selectionChanged();
200208
}
@@ -248,7 +256,9 @@ void QgsDatumTransformTableWidget::editDatumTransform()
248256
const QgsDatumTransformDialog::TransformInfo dt = dlg.selectedDatumTransform();
249257
QgsCoordinateTransformContext context = mModel->transformContext();
250258
// QMap::insert takes care of replacing existing value
259+
Q_NOWARN_DEPRECATED_PUSH
251260
context.addSourceDestinationDatumTransform( sourceCrs, destinationCrs, dt.sourceTransformId, dt.destinationTransformId );
261+
Q_NOWARN_DEPRECATED_POP
252262
mModel->setTransformContext( context );
253263
}
254264
}

‎src/core/qgscoordinatetransform_p.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,9 @@ bool QgsCoordinateTransformPrivate::initialize()
244244
void QgsCoordinateTransformPrivate::calculateTransforms( const QgsCoordinateTransformContext &context )
245245
{
246246
// recalculate datum transforms from context
247+
Q_NOWARN_DEPRECATED_PUSH
247248
QgsDatumTransform::TransformPair transforms = context.calculateDatumTransforms( mSourceCRS, mDestCRS );
249+
Q_NOWARN_DEPRECATED_POP
248250
mSourceDatumTransform = transforms.sourceTransformId;
249251
mDestinationDatumTransform = transforms.destinationTransformId;
250252
}

‎src/core/qgscoordinatetransformcontext.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,20 @@ bool QgsCoordinateTransformContext::addSourceDestinationDatumTransform( const Qg
8080
}
8181

8282
void QgsCoordinateTransformContext::removeSourceDestinationDatumTransform( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs )
83+
{
84+
removeCoordinateOperation( sourceCrs, destinationCrs );
85+
}
86+
87+
void QgsCoordinateTransformContext::removeCoordinateOperation( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs )
8388
{
8489
d->mSourceDestDatumTransforms.remove( qMakePair( sourceCrs.authid(), destinationCrs.authid() ) );
8590
}
8691

8792
bool QgsCoordinateTransformContext::hasTransform( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination ) const
8893
{
94+
Q_NOWARN_DEPRECATED_PUSH
8995
QgsDatumTransform::TransformPair t = calculateDatumTransforms( source, destination );
96+
Q_NOWARN_DEPRECATED_POP
9097
// calculateDatumTransforms already takes care of switching source and destination
9198
return t.sourceTransformId != -1 || t.destinationTransformId != -1;
9299
}

‎src/core/qgscoordinatetransformcontext.h

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@ class CORE_EXPORT QgsCoordinateTransformContext
9494
* to determine this.
9595
*
9696
* \see addSourceDestinationDatumTransform()
97+
*
98+
* \deprecated Has no effect on builds based on Proj 6.0 or later
9799
*/
98-
QMap< QPair< QString, QString>, QgsDatumTransform::TransformPair > sourceDestinationDatumTransforms() const;
100+
Q_DECL_DEPRECATED QMap< QPair< QString, QString>, QgsDatumTransform::TransformPair > sourceDestinationDatumTransforms() const SIP_DEPRECATED;
99101

100102
/**
101103
* Adds a new \a sourceTransform and \a destinationTransform to use when projecting coordinates
@@ -111,19 +113,27 @@ class CORE_EXPORT QgsCoordinateTransformContext
111113
*
112114
* \see sourceDestinationDatumTransforms()
113115
* \see removeSourceDestinationDatumTransform()
116+
*
117+
* \deprecated Has no effect on builds based on Proj 6.0 or later
114118
*/
115-
bool addSourceDestinationDatumTransform( const QgsCoordinateReferenceSystem &sourceCrs,
116-
const QgsCoordinateReferenceSystem &destinationCrs,
117-
int sourceTransformId,
118-
int destinationTransformId );
119+
Q_DECL_DEPRECATED bool addSourceDestinationDatumTransform( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, int sourceTransformId, int destinationTransformId ) SIP_DEPRECATED;
119120

120121
/**
121122
* Removes the source to destination datum transform pair for the specified \a sourceCrs and
122123
* \a destinationCrs.
123124
* \see addSourceDestinationDatumTransform()
125+
*
126+
* \deprecated Use removeCoordinateOperation() instead
127+
*/
128+
Q_DECL_DEPRECATED void removeSourceDestinationDatumTransform( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs ) SIP_DEPRECATED ;
129+
130+
/**
131+
* Removes the source to destination datum coordinated operation for the specified \a sourceCrs and
132+
* \a destinationCrs.
133+
*
134+
* \since QGIS 3.8
124135
*/
125-
void removeSourceDestinationDatumTransform( const QgsCoordinateReferenceSystem &sourceCrs,
126-
const QgsCoordinateReferenceSystem &destinationCrs );
136+
void removeCoordinateOperation( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs );
127137

128138
/**
129139
* Returns TRUE if the context has a valid datum transform to use
@@ -141,9 +151,9 @@ class CORE_EXPORT QgsCoordinateTransformContext
141151
* destination.
142152
*
143153
* \note source and destination are reversible.
154+
* \deprecated Has no effect on builds based on Proj 6.0 or later
144155
*/
145-
QgsDatumTransform::TransformPair calculateDatumTransforms( const QgsCoordinateReferenceSystem &source,
146-
const QgsCoordinateReferenceSystem &destination ) const;
156+
Q_DECL_DEPRECATED QgsDatumTransform::TransformPair calculateDatumTransforms( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination ) const SIP_DEPRECATED;
147157

148158
/**
149159
* Reads the context's state from a DOM \a element.

‎src/gui/qgsdatumtransformdialog.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ bool QgsDatumTransformDialog::run( const QgsCoordinateReferenceSystem &sourceCrs
4545
{
4646
const TransformInfo dt = dlg.selectedDatumTransform();
4747
QgsCoordinateTransformContext context = QgsProject::instance()->transformContext();
48+
Q_NOWARN_DEPRECATED_PUSH
4849
context.addSourceDestinationDatumTransform( dt.sourceCrs, dt.destinationCrs, dt.sourceTransformId, dt.destinationTransformId );
50+
Q_NOWARN_DEPRECATED_POP
4951
QgsProject::instance()->setTransformContext( context );
5052
return true;
5153
}
@@ -364,7 +366,9 @@ void QgsDatumTransformDialog::applyDefaultTransform()
364366
{
365367
QgsCoordinateTransformContext context = QgsProject::instance()->transformContext();
366368
const TransformInfo dt = defaultDatumTransform();
369+
Q_NOWARN_DEPRECATED_PUSH
367370
context.addSourceDestinationDatumTransform( dt.sourceCrs, dt.destinationCrs, dt.sourceTransformId, dt.destinationTransformId );
371+
Q_NOWARN_DEPRECATED_POP
368372
QgsProject::instance()->setTransformContext( context );
369373
}
370374
}

‎tests/src/core/testqgscoordinatetransform.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ void TestQgsCoordinateTransform::contextShared()
189189
{
190190
//test implicit sharing of QgsCoordinateTransformContext
191191
QgsCoordinateTransformContext original;
192+
Q_NOWARN_DEPRECATED_PUSH
192193
original.addSourceDestinationDatumTransform( QgsCoordinateReferenceSystem( 3111 ), QgsCoordinateReferenceSystem( 3113 ), 1, 2 );
193194

194195
QgsCoordinateTransformContext copy( original );
@@ -215,6 +216,8 @@ void TestQgsCoordinateTransform::contextShared()
215216
QCOMPARE( original.sourceDestinationDatumTransforms(), expected );
216217
expected.insert( qMakePair( QStringLiteral( "EPSG:3111" ), QStringLiteral( "EPSG:3113" ) ), QgsDatumTransform::TransformPair( 3, 4 ) );
217218
QCOMPARE( copy2.sourceDestinationDatumTransforms(), expected );
219+
220+
Q_NOWARN_DEPRECATED_POP
218221
}
219222

220223
void TestQgsCoordinateTransform::scaleFactor()

‎tests/src/gui/testqgsdatumtransformdialog.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ void TestQgsDatumTransformDialog::applyDefaultTransform()
114114
{
115115
QgsSettings().setValue( QStringLiteral( "/projections/promptWhenMultipleTransformsExist" ), false, QgsSettings::App );
116116

117+
Q_NOWARN_DEPRECATED_PUSH
117118
QgsDatumTransformDialog dlg( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:26742" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:7406" ) ) );
118119
dlg.applyDefaultTransform();
119120
QVERIFY( QgsProject::instance()->transformContext().sourceDestinationDatumTransforms().isEmpty() );
@@ -122,7 +123,6 @@ void TestQgsDatumTransformDialog::applyDefaultTransform()
122123
dlg2.applyDefaultTransform();
123124

124125
QVERIFY( !QgsProject::instance()->transformContext().sourceDestinationDatumTransforms().isEmpty() );
125-
Q_NOWARN_DEPRECATED_PUSH
126126
QCOMPARE( QgsDatumTransform::datumTransformToProj( QgsProject::instance()->transformContext().calculateDatumTransforms( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:26742" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ).sourceTransformId ), QStringLiteral( "+towgs84=-10,158,187" ) );
127127
Q_NOWARN_DEPRECATED_POP
128128
QgsProject::instance()->clear();
@@ -131,14 +131,13 @@ void TestQgsDatumTransformDialog::applyDefaultTransform()
131131
void TestQgsDatumTransformDialog::runDialog()
132132
{
133133
QgsSettings().setValue( QStringLiteral( "/projections/promptWhenMultipleTransformsExist" ), false, QgsSettings::App );
134-
134+
Q_NOWARN_DEPRECATED_PUSH
135135
QVERIFY( QgsDatumTransformDialog::run( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:26742" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:7406" ) ) ) );
136136
QVERIFY( QgsProject::instance()->transformContext().sourceDestinationDatumTransforms().isEmpty() );
137137

138138
QVERIFY( QgsDatumTransformDialog::run( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:26742" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ) );
139139

140140
QVERIFY( !QgsProject::instance()->transformContext().sourceDestinationDatumTransforms().isEmpty() );
141-
Q_NOWARN_DEPRECATED_PUSH
142141
QCOMPARE( QgsDatumTransform::datumTransformToProj( QgsProject::instance()->transformContext().calculateDatumTransforms( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:26742" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ).sourceTransformId ), QStringLiteral( "+towgs84=-10,158,187" ) );
143142
Q_NOWARN_DEPRECATED_POP
144143
QgsProject::instance()->clear();

‎tests/src/python/test_qgscoordinatetransformcontext.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def testSourceDestinationDatumTransforms(self):
9999
('EPSG:3111', 'EPSG:28356'): QgsDatumTransform.TransformPair(17, -1),
100100
('EPSG:3113', 'EPSG:28356'): QgsDatumTransform.TransformPair(-1, 18)})
101101
# remove non-existing
102-
context.removeSourceDestinationDatumTransform(QgsCoordinateReferenceSystem(3113), QgsCoordinateReferenceSystem(3111))
102+
context.removeCoordinateOperation(QgsCoordinateReferenceSystem(3113), QgsCoordinateReferenceSystem(3111))
103103
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): QgsDatumTransform.TransformPair(1, 2),
104104
('EPSG:28356', 'EPSG:4283'): QgsDatumTransform.TransformPair(3, 4),
105105
('EPSG:28356', 'EPSG:28357'): QgsDatumTransform.TransformPair(9, 11),
@@ -108,15 +108,15 @@ def testSourceDestinationDatumTransforms(self):
108108
('EPSG:3113', 'EPSG:28356'): QgsDatumTransform.TransformPair(-1, 18)})
109109

110110
# remove existing
111-
context.removeSourceDestinationDatumTransform(QgsCoordinateReferenceSystem(3111),
112-
QgsCoordinateReferenceSystem(4283))
111+
context.removeCoordinateOperation(QgsCoordinateReferenceSystem(3111),
112+
QgsCoordinateReferenceSystem(4283))
113113
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:28356', 'EPSG:4283'): QgsDatumTransform.TransformPair(3, 4),
114114
('EPSG:28356', 'EPSG:28357'): QgsDatumTransform.TransformPair(9, 11),
115115
('EPSG:28357', 'EPSG:28356'): QgsDatumTransform.TransformPair(-1, -1),
116116
('EPSG:3111', 'EPSG:28356'): QgsDatumTransform.TransformPair(17, -1),
117117
('EPSG:3113', 'EPSG:28356'): QgsDatumTransform.TransformPair(-1, 18)})
118-
context.removeSourceDestinationDatumTransform(QgsCoordinateReferenceSystem(3111),
119-
QgsCoordinateReferenceSystem(28356))
118+
context.removeCoordinateOperation(QgsCoordinateReferenceSystem(3111),
119+
QgsCoordinateReferenceSystem(28356))
120120
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:28356', 'EPSG:4283'): QgsDatumTransform.TransformPair(3, 4),
121121
('EPSG:28356', 'EPSG:28357'): QgsDatumTransform.TransformPair(9, 11),
122122
('EPSG:28357', 'EPSG:28356'): QgsDatumTransform.TransformPair(-1, -1),

0 commit comments

Comments
 (0)
Please sign in to comment.